OSDN Git Service

Added LaTex image insert & edit
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / gui / TableViewHeader.java
index 2ccf8cf..75067de 100644 (file)
@@ -1,5 +1,7 @@
 package cx.fbn.nevernote.gui;\r
 \r
+import java.util.List;\r
+\r
 import com.trolltech.qt.core.Qt.Orientation;\r
 import com.trolltech.qt.gui.QAction;\r
 import com.trolltech.qt.gui.QContextMenuEvent;\r
@@ -15,75 +17,120 @@ public class TableViewHeader extends QHeaderView {
        public QAction changedDateAction;\r
        public QAction subjectDateAction;\r
        public QAction tagsAction;\r
+       public QAction titleAction;\r
        public QAction notebookAction;\r
        public QAction synchronizedAction;\r
        public QAction authorAction;\r
        public QAction urlAction;\r
+       public QAction thumbnailAction;\r
+       public QAction guidAction;\r
        \r
 \r
        public TableViewHeader(Orientation orientation, QWidget parent) {\r
                super(orientation, parent);\r
                \r
-<<<<<<< HEAD
                setSortIndicatorShown(true);\r
                setClickable(true);\r
                \r
-=======
->>>>>>> 14a0afe3faba057afbddf62aa8ed25139750d68b
                contextMenu = new QMenu();\r
 \r
+               titleAction = new QAction(this);\r
+               titleAction.setText(tr("Title"));\r
+               titleAction.setCheckable(true);\r
+               contextMenu.addAction(titleAction);\r
+               \r
                createdDateAction = new QAction(this);\r
                createdDateAction.setText(tr("Date Created"));\r
                createdDateAction.setCheckable(true);\r
-               createdDateAction.setChecked(Global.isColumnVisible("dateCreated"));\r
                contextMenu.addAction(createdDateAction);\r
                \r
                changedDateAction = new QAction(this);\r
                changedDateAction.setText(tr("Date Changed"));\r
                changedDateAction.setCheckable(true);\r
-               changedDateAction.setChecked(Global.isColumnVisible("dateChanged"));\r
                contextMenu.addAction(changedDateAction);\r
                \r
                subjectDateAction = new QAction(this);\r
                subjectDateAction.setText(tr("Subject Date"));\r
                subjectDateAction.setCheckable(true);\r
-               subjectDateAction.setChecked(Global.isColumnVisible("dateSubject"));\r
                contextMenu.addAction(subjectDateAction);\r
                \r
                tagsAction = new QAction(this);\r
                tagsAction.setText(tr("Tags"));\r
                tagsAction.setCheckable(true);\r
-               tagsAction.setChecked(Global.isColumnVisible("tags"));\r
                contextMenu.addAction(tagsAction);\r
                \r
                notebookAction = new QAction(this);\r
                notebookAction.setText(tr("Notebook"));\r
                notebookAction.setCheckable(true);\r
-               notebookAction.setChecked(Global.isColumnVisible("notebook"));\r
                contextMenu.addAction(notebookAction);\r
                \r
                synchronizedAction = new QAction(this);\r
                synchronizedAction.setText(tr("Synchronized"));\r
                synchronizedAction.setCheckable(true);\r
-               synchronizedAction.setChecked(Global.isColumnVisible("synchronized"));\r
                contextMenu.addAction(synchronizedAction);\r
                \r
                authorAction = new QAction(this);\r
                authorAction.setText(tr("Author"));\r
                authorAction.setCheckable(true);\r
-               authorAction.setChecked(Global.isColumnVisible("author"));\r
                contextMenu.addAction(authorAction);\r
                \r
                urlAction = new QAction(this);\r
                urlAction.setText(tr("Source URL"));\r
                urlAction.setCheckable(true);\r
-               urlAction.setChecked(Global.isColumnVisible("sourceUrl"));\r
                contextMenu.addAction(urlAction);\r
                \r
+               thumbnailAction = new QAction(this);\r
+               thumbnailAction.setText(tr("Thumbnail"));\r
+               thumbnailAction.setCheckable(true);\r
+               contextMenu.addAction(thumbnailAction);\r
+               \r
+               guidAction = new QAction(this);\r
+               guidAction.setText(tr("Guid"));\r
+               guidAction.setCheckable(true);\r
+//             contextMenu.addAction(guidAction);\r
+               setMouseTracking(true);\r
+               sectionEntered.connect(this, "sectionClicked(Integer)");\r
+               \r
+               checkActions();\r
+       }\r
+\r
+       private void checkActions() {\r
+               titleAction.setChecked(Global.isColumnVisible("title"));\r
+               createdDateAction.setChecked(Global.isColumnVisible("dateCreated"));\r
+               changedDateAction.setChecked(Global.isColumnVisible("dateChanged"));\r
+               subjectDateAction.setChecked(Global.isColumnVisible("dateSubject"));\r
+               tagsAction.setChecked(Global.isColumnVisible("tags"));\r
+               notebookAction.setChecked(Global.isColumnVisible("notebook"));\r
+               synchronizedAction.setChecked(Global.isColumnVisible("synchronized"));\r
+               authorAction.setChecked(Global.isColumnVisible("author"));\r
+               urlAction.setChecked(Global.isColumnVisible("sourceUrl"));\r
+               thumbnailAction.setChecked(Global.isColumnVisible("thumbnail"));\r
+               guidAction.setChecked(Global.isColumnVisible("guid"));\r
+       }\r
+       \r
+       public void sectionClicked(Integer position) {\r
+               if (position == Global.noteTableThumbnailPosition)\r
+                       setClickable(false);\r
+               else\r
+                       setClickable(true);\r
        }\r
        \r
        @Override\r
        public void contextMenuEvent(QContextMenuEvent event) {\r
+               checkActions();\r
+               List<QAction> actions = contextMenu.actions();\r
+               int count = 0;\r
+               for (int i=0; i<actions.size(); i++) {\r
+                       actions.get(i).setEnabled(true);\r
+                       if (actions.get(i).isChecked()) \r
+                               count++;\r
+               }\r
+               if (count <= 1) {\r
+                       for (int i=0; i<actions.size(); i++) {\r
+                               if (actions.get(i).isChecked()) \r
+                                       actions.get(i).setEnabled(false);\r
+                       }\r
+               }\r
                contextMenu.exec(event.globalPos());\r
        }\r
 }\r