1 package cx.fbn.nevernote.gui;
\r
3 import java.util.List;
\r
5 import com.trolltech.qt.core.Qt.Orientation;
\r
6 import com.trolltech.qt.gui.QAction;
\r
7 import com.trolltech.qt.gui.QContextMenuEvent;
\r
8 import com.trolltech.qt.gui.QHeaderView;
\r
9 import com.trolltech.qt.gui.QMenu;
\r
10 import com.trolltech.qt.gui.QWidget;
\r
12 import cx.fbn.nevernote.Global;
\r
14 public class TableViewHeader extends QHeaderView {
\r
15 public QMenu contextMenu;
\r
16 public QAction createdDateAction;
\r
17 public QAction changedDateAction;
\r
18 public QAction subjectDateAction;
\r
19 public QAction tagsAction;
\r
20 public QAction titleAction;
\r
21 public QAction notebookAction;
\r
22 public QAction synchronizedAction;
\r
23 public QAction authorAction;
\r
24 public QAction urlAction;
\r
25 public QAction thumbnailAction;
\r
26 public QAction guidAction;
\r
29 public TableViewHeader(Orientation orientation, QWidget parent) {
\r
30 super(orientation, parent);
\r
32 setSortIndicatorShown(true);
\r
35 contextMenu = new QMenu();
\r
37 titleAction = new QAction(this);
\r
38 titleAction.setText(tr("Title"));
\r
39 titleAction.setCheckable(true);
\r
40 contextMenu.addAction(titleAction);
\r
42 createdDateAction = new QAction(this);
\r
43 createdDateAction.setText(tr("Date Created"));
\r
44 createdDateAction.setCheckable(true);
\r
45 contextMenu.addAction(createdDateAction);
\r
47 changedDateAction = new QAction(this);
\r
48 changedDateAction.setText(tr("Date Changed"));
\r
49 changedDateAction.setCheckable(true);
\r
50 contextMenu.addAction(changedDateAction);
\r
52 subjectDateAction = new QAction(this);
\r
53 subjectDateAction.setText(tr("Subject Date"));
\r
54 subjectDateAction.setCheckable(true);
\r
55 contextMenu.addAction(subjectDateAction);
\r
57 tagsAction = new QAction(this);
\r
58 tagsAction.setText(tr("Tags"));
\r
59 tagsAction.setCheckable(true);
\r
60 contextMenu.addAction(tagsAction);
\r
62 notebookAction = new QAction(this);
\r
63 notebookAction.setText(tr("Notebook"));
\r
64 notebookAction.setCheckable(true);
\r
65 contextMenu.addAction(notebookAction);
\r
67 synchronizedAction = new QAction(this);
\r
68 synchronizedAction.setText(tr("Synchronized"));
\r
69 synchronizedAction.setCheckable(true);
\r
70 contextMenu.addAction(synchronizedAction);
\r
72 authorAction = new QAction(this);
\r
73 authorAction.setText(tr("Author"));
\r
74 authorAction.setCheckable(true);
\r
75 contextMenu.addAction(authorAction);
\r
77 urlAction = new QAction(this);
\r
78 urlAction.setText(tr("Source URL"));
\r
79 urlAction.setCheckable(true);
\r
80 contextMenu.addAction(urlAction);
\r
82 thumbnailAction = new QAction(this);
\r
83 thumbnailAction.setText(tr("Thumbnail"));
\r
84 thumbnailAction.setCheckable(true);
\r
85 contextMenu.addAction(thumbnailAction);
\r
87 guidAction = new QAction(this);
\r
88 guidAction.setText(tr("Guid"));
\r
89 guidAction.setCheckable(true);
\r
90 // contextMenu.addAction(guidAction);
\r
91 setMouseTracking(true);
\r
92 sectionEntered.connect(this, "sectionClicked(Integer)");
\r
97 private void checkActions() {
\r
98 titleAction.setChecked(Global.isColumnVisible("title"));
\r
99 createdDateAction.setChecked(Global.isColumnVisible("dateCreated"));
\r
100 changedDateAction.setChecked(Global.isColumnVisible("dateChanged"));
\r
101 subjectDateAction.setChecked(Global.isColumnVisible("dateSubject"));
\r
102 tagsAction.setChecked(Global.isColumnVisible("tags"));
\r
103 notebookAction.setChecked(Global.isColumnVisible("notebook"));
\r
104 synchronizedAction.setChecked(Global.isColumnVisible("synchronized"));
\r
105 authorAction.setChecked(Global.isColumnVisible("author"));
\r
106 urlAction.setChecked(Global.isColumnVisible("sourceUrl"));
\r
107 thumbnailAction.setChecked(Global.isColumnVisible("thumbnail"));
\r
108 guidAction.setChecked(Global.isColumnVisible("guid"));
\r
111 public void sectionClicked(Integer position) {
\r
112 if (position == Global.noteTableThumbnailPosition)
\r
113 setClickable(false);
\r
115 setClickable(true);
\r
119 public void contextMenuEvent(QContextMenuEvent event) {
\r
121 List<QAction> actions = contextMenu.actions();
\r
123 for (int i=0; i<actions.size(); i++) {
\r
124 actions.get(i).setEnabled(true);
\r
125 if (actions.get(i).isChecked())
\r
129 for (int i=0; i<actions.size(); i++) {
\r
130 if (actions.get(i).isChecked())
\r
131 actions.get(i).setEnabled(false);
\r
134 contextMenu.exec(event.globalPos());
\r