OSDN Git Service

Moved the show/hide of the note index column from the Edit/Preferences menu to a...
authorRandy Baumgarte <randy@fbn.cx>
Wed, 1 Sep 2010 11:34:50 +0000 (07:34 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Tue, 14 Sep 2010 10:23:10 +0000 (06:23 -0400)
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/dialog/ConfigDialog.java
src/cx/fbn/nevernote/dialog/ConfigShowColumnsPage.java [deleted file]
src/cx/fbn/nevernote/gui/TableView.java
src/cx/fbn/nevernote/gui/TableViewHeader.java [new file with mode: 0644]

index d6d5262..230cd27 100644 (file)
@@ -85,6 +85,7 @@ import com.trolltech.qt.gui.QCloseEvent;
 import com.trolltech.qt.gui.QColor;
 import com.trolltech.qt.gui.QComboBox;
 import com.trolltech.qt.gui.QComboBox.InsertPolicy;
+import com.trolltech.qt.gui.QCursor;
 import com.trolltech.qt.gui.QDesktopServices;
 import com.trolltech.qt.gui.QDialog;
 import com.trolltech.qt.gui.QFileDialog;
index f932532..587faba 100644 (file)
@@ -46,7 +46,6 @@ public class ConfigDialog extends QDialog {
        private final ConfigConnectionPage              connectionPage;\r
        private final ConfigDebugPage                   debugPage;\r
        private final ConfigAppearancePage              appearancePage;\r
-       private final ConfigShowColumnsPage             columnsPage;\r
        private final ConfigIndexPage                   indexPage;\r
        private final ConfigShowEditorButtonsPage               editorButtonsPage;\r
        \r
@@ -64,12 +63,10 @@ public class ConfigDialog extends QDialog {
                appearancePage = new ConfigAppearancePage(this);\r
                indexPage = new ConfigIndexPage(this);\r
                debugPage = new ConfigDebugPage(this);\r
-               columnsPage = new ConfigShowColumnsPage(this);\r
                editorButtonsPage = new ConfigShowEditorButtonsPage(this);\r
                pagesWidget.addWidget(appearancePage);\r
                pagesWidget.addWidget(indexPage);\r
                pagesWidget.addWidget(connectionPage);\r
-               pagesWidget.addWidget(columnsPage);\r
                pagesWidget.addWidget(editorButtonsPage);\r
                pagesWidget.addWidget(debugPage);\r
                \r
@@ -179,14 +176,6 @@ public class ConfigDialog extends QDialog {
                \r
                Global.setSyncInterval(connectionPage.getSyncInterval());\r
                \r
-               Global.saveColumnVisible("dateCreated", columnsPage.showDateCreated());\r
-               Global.saveColumnVisible("dateChanged", columnsPage.showDateChanged());\r
-               Global.saveColumnVisible("dateSubject", columnsPage.showDateSubject());\r
-               Global.saveColumnVisible("author", columnsPage.showAuthor());\r
-               Global.saveColumnVisible("sourceUrl", columnsPage.showSourceUrl());\r
-               Global.saveColumnVisible("synchronized", columnsPage.showSynchronized());\r
-               Global.saveColumnVisible("notebook", columnsPage.showNotebook());\r
-               Global.saveColumnVisible("tags", columnsPage.showTags());\r
                \r
                Global.saveEditorButtonsVisible("undo", editorButtonsPage.showUndo());\r
                Global.saveEditorButtonsVisible("redo", editorButtonsPage.showRedo());\r
@@ -246,12 +235,6 @@ public class ConfigDialog extends QDialog {
                configButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
                configButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
                configButton.setIcon(new QIcon(iconPath+"synchronize.png"));\r
-               \r
-               QListWidgetItem columnsButton = new QListWidgetItem(contentsWidget);\r
-               columnsButton.setText(tr("Hide Columns"));\r
-               columnsButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
-               columnsButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
-               columnsButton.setIcon(new QIcon(iconPath+"show-columns.png"));\r
 \r
                QListWidgetItem editorButton = new QListWidgetItem(contentsWidget);\r
                editorButton.setText(tr("Hide Edit Buttons"));\r
@@ -318,16 +301,7 @@ public class ConfigDialog extends QDialog {
                appearancePage.setTimeFormat(Global.getTimeFormat());\r
                appearancePage.setStyle(Global.getStyle());\r
                appearancePage.setStandardPalette(Global.useStandardPalette());\r
-               \r
-               columnsPage.setDateCreated(Global.isColumnVisible("dateCreated"));\r
-               columnsPage.setDateSubject(Global.isColumnVisible("dateSubject"));\r
-               columnsPage.setDateChanged(Global.isColumnVisible("dateChanged"));\r
-               columnsPage.setAuthor(Global.isColumnVisible("author"));\r
-               columnsPage.setSourceUrl(Global.isColumnVisible("sourceUrl"));\r
-               columnsPage.setTags(Global.isColumnVisible("tags"));\r
-               columnsPage.setSynchronized(Global.isColumnVisible("synchronized"));\r
-               columnsPage.setNotebook(Global.isColumnVisible("notebook"));\r
-               \r
+                               \r
                editorButtonsPage.setUndo(Global.isEditorButtonVisible("undo"));\r
                editorButtonsPage.setRedo(Global.isEditorButtonVisible("redo"));\r
                editorButtonsPage.setCut(Global.isEditorButtonVisible("cut"));\r
diff --git a/src/cx/fbn/nevernote/dialog/ConfigShowColumnsPage.java b/src/cx/fbn/nevernote/dialog/ConfigShowColumnsPage.java
deleted file mode 100644 (file)
index e338e93..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*\r
- * This file is part of NeverNote \r
- * Copyright 2009 Randy Baumgarte\r
- * \r
- * This file may be licensed under the terms of of the\r
- * GNU General Public License Version 2 (the ``GPL'').\r
- *\r
- * Software distributed under the License is distributed\r
- * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either\r
- * express or implied. See the GPL for the specific language\r
- * governing rights and limitations.\r
- *\r
- * You should have received a copy of the GPL along with this\r
- * program. If not, go to http://www.gnu.org/licenses/gpl.html\r
- * or write to the Free Software Foundation, Inc.,\r
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
- *\r
-*/\r
-\r
-package cx.fbn.nevernote.dialog;\r
-\r
-import com.trolltech.qt.gui.QComboBox;\r
-import com.trolltech.qt.gui.QGroupBox;\r
-import com.trolltech.qt.gui.QHBoxLayout;\r
-import com.trolltech.qt.gui.QRadioButton;\r
-import com.trolltech.qt.gui.QVBoxLayout;\r
-import com.trolltech.qt.gui.QWidget;\r
-\r
-public class ConfigShowColumnsPage extends QWidget {\r
-       private final QRadioButton showDateCreated;\r
-       private final QRadioButton hideDateCreated;\r
-       private final QRadioButton showDateSubject;\r
-       private final QRadioButton hideDateSubject;\r
-       private final QRadioButton showDateChanged;\r
-       private final QRadioButton hideDateChanged;\r
-       private final QRadioButton showAuthor;\r
-       private final QRadioButton hideAuthor;\r
-       private final QRadioButton sourceUrlShow;\r
-       private final QRadioButton sourceUrlHide;\r
-       private final QRadioButton showTags;\r
-       private final QRadioButton hideTags;\r
-       private final QRadioButton showNotebook;\r
-       private final QRadioButton hideNotebook;\r
-       private final QRadioButton showSynchronized;\r
-       private final QRadioButton hideSynchronized;\r
-\r
-       \r
-       QComboBox messageCombo;\r
-       public ConfigShowColumnsPage(QWidget parent) {\r
-               super(parent);\r
-\r
-               // Date Created Column\r
-               QGroupBox dateCreatedGroup =  new QGroupBox(tr("Date Created"));\r
-               QHBoxLayout dateCreatedLayout = new QHBoxLayout();\r
-               showDateCreated = new QRadioButton(tr("Show"));\r
-               hideDateCreated = new QRadioButton(tr("Hide"));\r
-               dateCreatedLayout.addWidget(showDateCreated);\r
-               dateCreatedLayout.addWidget(hideDateCreated);\r
-               dateCreatedLayout.setStretch(1, 100);\r
-               dateCreatedGroup.setLayout(dateCreatedLayout);\r
-\r
-\r
-               // Subject Date Column\r
-               QGroupBox dateSubjectGroup =  new QGroupBox(tr("Subject Date"));\r
-               QHBoxLayout dateSubjectLayout = new QHBoxLayout();\r
-               showDateSubject = new QRadioButton(tr("Show"));\r
-               hideDateSubject = new QRadioButton(tr("Hide"));\r
-               dateSubjectLayout.addWidget(showDateSubject);\r
-               dateSubjectLayout.addWidget(hideDateSubject);\r
-               dateSubjectLayout.setStretch(1, 100);\r
-               dateSubjectGroup.setLayout(dateSubjectLayout);\r
-\r
-\r
-               // Title Column\r
-               QGroupBox sourceUrlGroup =  new QGroupBox(tr("Source URL"));\r
-               QHBoxLayout sourceUrlLayout = new QHBoxLayout();\r
-               sourceUrlShow = new QRadioButton(tr("Show"));\r
-               sourceUrlHide = new QRadioButton(tr("Hide"));\r
-               sourceUrlLayout.addWidget(sourceUrlShow);\r
-               sourceUrlLayout.addWidget(sourceUrlHide);\r
-               sourceUrlLayout.setStretch(1, 100);\r
-               sourceUrlGroup.setLayout(sourceUrlLayout);\r
-\r
-               // Author Column\r
-               QGroupBox authorGroup =  new QGroupBox(tr("Author"));\r
-               QHBoxLayout authorLayout = new QHBoxLayout();\r
-               showAuthor = new QRadioButton(tr("Show"));\r
-               hideAuthor = new QRadioButton(tr("Hide"));\r
-               authorLayout.addWidget(showAuthor);\r
-               authorLayout.addWidget(hideAuthor);\r
-               authorLayout.setStretch(1, 100);\r
-               authorGroup.setLayout(authorLayout);\r
-\r
-               \r
-               // Date Changed Column\r
-               QGroupBox dateChangedGroup =  new QGroupBox(tr("Date Changed"));\r
-               QHBoxLayout dateChangedLayout = new QHBoxLayout();\r
-               showDateChanged = new QRadioButton(tr("Show"));\r
-               hideDateChanged = new QRadioButton(tr("Hide"));\r
-               dateChangedLayout.addWidget(showDateChanged);\r
-               dateChangedLayout.addWidget(hideDateChanged);\r
-               dateChangedLayout.setStretch(1, 100);\r
-               dateChangedGroup.setLayout(dateChangedLayout);\r
-\r
-               // Notebook Column\r
-               QGroupBox notebookGroup =  new QGroupBox(tr("Notebook"));\r
-               QHBoxLayout notebookLayout = new QHBoxLayout();\r
-               showNotebook = new QRadioButton(tr("Show"));\r
-               hideNotebook = new QRadioButton(tr("Hide"));\r
-               notebookLayout.addWidget(showNotebook);\r
-               notebookLayout.addWidget(hideNotebook);\r
-               notebookLayout.setStretch(1, 100);\r
-               notebookGroup.setLayout(notebookLayout);\r
-\r
-               // Tags Column\r
-               QGroupBox tagsGroup =  new QGroupBox(tr("Tags"));\r
-               QHBoxLayout tagsLayout = new QHBoxLayout();\r
-               showTags = new QRadioButton(tr("Show"));\r
-               hideTags = new QRadioButton(tr("Hide"));\r
-               tagsLayout.addWidget(showTags);\r
-               tagsLayout.addWidget(hideTags);\r
-               tagsLayout.setStretch(1, 100);\r
-               tagsGroup.setLayout(tagsLayout);\r
-\r
-               // Synchronized Column\r
-               QGroupBox synchronizedGroup =  new QGroupBox(tr("Synchronized Indicator"));\r
-               QHBoxLayout syncLayout = new QHBoxLayout();\r
-               showSynchronized = new QRadioButton(tr("Show"));\r
-               hideSynchronized = new QRadioButton(tr("Hide"));\r
-               syncLayout.addWidget(showSynchronized);\r
-               syncLayout.addWidget(hideSynchronized);\r
-               syncLayout.setStretch(1, 100);\r
-               synchronizedGroup.setLayout(syncLayout);\r
-               \r
-               QVBoxLayout mainLayout = new QVBoxLayout();\r
-               mainLayout.addWidget(dateCreatedGroup);\r
-               mainLayout.addWidget(dateChangedGroup);\r
-               mainLayout.addWidget(dateSubjectGroup);\r
-               mainLayout.addWidget(notebookGroup);\r
-               mainLayout.addWidget(tagsGroup);\r
-               mainLayout.addWidget(sourceUrlGroup);\r
-               mainLayout.addWidget(authorGroup);\r
-               mainLayout.addWidget(synchronizedGroup);\r
-               mainLayout.addStretch(1);\r
-               setLayout(mainLayout);\r
-       }\r
-       \r
-       public void setDateCreated(boolean value) {\r
-               if (value)\r
-                       showDateCreated.click();\r
-               else\r
-                       hideDateCreated.click();\r
-       }\r
-       \r
-       public void setDateSubject(boolean value) {\r
-               if (value)\r
-                       showDateSubject.click();\r
-               else\r
-                       hideDateSubject.click();\r
-       }\r
-\r
-       public void setDateChanged(boolean value) {\r
-               if (value)\r
-                       showDateChanged.click();\r
-               else\r
-                       hideDateChanged.click();\r
-       }\r
-\r
-       public void setAuthor(boolean value) {\r
-               if (value)\r
-                       showAuthor.click();\r
-               else\r
-                       hideAuthor.click();\r
-       }\r
-\r
-       public void setSourceUrl(boolean value) {\r
-               if (value)\r
-                       sourceUrlShow.click();\r
-               else\r
-                       sourceUrlHide.click();\r
-       }\r
-       public void setNotebook(boolean value) {\r
-               if (value)\r
-                       showNotebook.click();\r
-               else\r
-                       hideNotebook.click();\r
-       }\r
-       public void setTags(boolean value) {\r
-               if (value)\r
-                       showTags.click();\r
-               else\r
-                       hideTags.click();\r
-       }\r
-       public void setSynchronized(boolean value) {\r
-               if (value)\r
-                       showSynchronized.click();\r
-               else\r
-                       hideSynchronized.click();\r
-       }\r
-       \r
-       public boolean showDateCreated() {\r
-               return showDateCreated.isChecked();\r
-       }\r
-       public boolean showDateChanged() {\r
-               return showDateChanged.isChecked();\r
-       }\r
-       public boolean showDateSubject() {\r
-               return showDateSubject.isChecked();\r
-       }\r
-       public boolean showAuthor() {\r
-               return showAuthor.isChecked();\r
-       }\r
-       public boolean showSourceUrl() {\r
-               return sourceUrlShow.isChecked();\r
-       }\r
-       public boolean showTags() {\r
-               return showTags.isChecked();\r
-       }\r
-       public boolean showSynchronized() {\r
-               return showSynchronized.isChecked();\r
-       }\r
-       public boolean showNotebook() {\r
-               return showNotebook.isChecked();\r
-       }\r
-\r
-\r
-\r
-\r
-\r
-\r
-}
\ No newline at end of file
index 3f13966..5886be8 100644 (file)
@@ -25,6 +25,7 @@ import com.evernote.edam.type.Note;
 import com.trolltech.qt.core.QByteArray;\r
 import com.trolltech.qt.core.QModelIndex;\r
 import com.trolltech.qt.core.Qt;\r
+import com.trolltech.qt.core.Qt.Orientation;\r
 import com.trolltech.qt.core.Qt.SortOrder;\r
 import com.trolltech.qt.gui.QAbstractItemView;\r
 import com.trolltech.qt.gui.QAction;\r
@@ -34,7 +35,6 @@ import com.trolltech.qt.gui.QContextMenuEvent;
 import com.trolltech.qt.gui.QDragEnterEvent;\r
 import com.trolltech.qt.gui.QDropEvent;\r
 import com.trolltech.qt.gui.QFontMetrics;\r
-import com.trolltech.qt.gui.QHeaderView;\r
 import com.trolltech.qt.gui.QKeyEvent;\r
 import com.trolltech.qt.gui.QKeySequence.StandardKey;\r
 import com.trolltech.qt.gui.QMenu;\r
@@ -70,7 +70,7 @@ public class TableView extends QTableView {
 \r
 \r
     \r
-    public QHeaderView header;\r
+    public TableViewHeader header;\r
     int fontHeight;\r
     public Signal1<String> rowChanged;\r
     public Signal0     resetViewport;\r
@@ -78,8 +78,17 @@ public class TableView extends QTableView {
        \r
        public TableView(ApplicationLogger l, ListManager m) {\r
                logger = l;\r
-               header = horizontalHeader();\r
+               header = new TableViewHeader(Orientation.Horizontal,this);\r
+               setHorizontalHeader(header);\r
                header.setMovable(true);\r
+               header.subjectDateAction.toggled.connect(this, "toggleSubjectDate(Boolean)");\r
+               header.createdDateAction.toggled.connect(this, "toggleCreationDate(Boolean)");\r
+               header.changedDateAction.toggled.connect(this, "toggleChangedDate(Boolean)");\r
+               header.authorAction.toggled.connect(this, "toggleAuthor(Boolean)");\r
+               header.urlAction.toggled.connect(this, "toggleSourceUrl(Boolean)");\r
+               header.tagsAction.toggled.connect(this, "toggleTags(Boolean)");\r
+               header.notebookAction.toggled.connect(this, "toggleNotebook(Boolean)");\r
+               header.synchronizedAction.toggled.connect(this, "toggleSynchronized(Boolean)");\r
                \r
                noteSignal = new NoteSignal();\r
                setAcceptDrops(true);\r
@@ -442,4 +451,45 @@ public class TableView extends QTableView {
         return verticalScrollBar().value();\r
     }\r
 */\r
+       \r
+       public void toggleSubjectDate(Boolean toggle) {\r
+               Global.saveColumnVisible("dateSubject", toggle);\r
+               setColumnHidden(Global.noteTableSubjectDatePosition, !toggle);\r
+       }\r
+       \r
+       public void toggleChangedDate(Boolean toggle) {\r
+               Global.saveColumnVisible("dateChanged", toggle);\r
+               setColumnHidden(Global.noteTableChangedPosition, !toggle);\r
+       }\r
+       \r
+       \r
+       public void toggleCreationDate(Boolean toggle) {\r
+               Global.saveColumnVisible("dateCreated", toggle);\r
+               setColumnHidden(Global.noteTableCreationPosition, !toggle);\r
+       }\r
+       \r
+       public void toggleSourceUrl(Boolean toggle) {\r
+               Global.saveColumnVisible("sourceUrl", toggle);\r
+               setColumnHidden(Global.noteTableSourceUrlPosition, !toggle);\r
+       }\r
+       \r
+       public void toggleAuthor(Boolean toggle) {\r
+               Global.saveColumnVisible("author", toggle);\r
+               setColumnHidden(Global.noteTableAuthorPosition, !toggle);\r
+       }\r
+       \r
+       public void toggleNotebook(Boolean toggle) {\r
+               Global.saveColumnVisible("notebook", toggle);\r
+               setColumnHidden(Global.noteTableNotebookPosition, !toggle);\r
+       }\r
+       \r
+       public void toggleTags(Boolean toggle) {\r
+               Global.saveColumnVisible("tags", toggle);\r
+               setColumnHidden(Global.noteTableTagPosition, !toggle);\r
+       }\r
+       \r
+       public void toggleSynchronized(Boolean toggle) {\r
+               Global.saveColumnVisible("synchronized", toggle);\r
+               setColumnHidden(Global.noteTableSynchronizedPosition, !toggle);\r
+       }\r
 }\r
diff --git a/src/cx/fbn/nevernote/gui/TableViewHeader.java b/src/cx/fbn/nevernote/gui/TableViewHeader.java
new file mode 100644 (file)
index 0000000..464301c
--- /dev/null
@@ -0,0 +1,83 @@
+package cx.fbn.nevernote.gui;\r
+\r
+import com.trolltech.qt.core.Qt.Orientation;\r
+import com.trolltech.qt.gui.QAction;\r
+import com.trolltech.qt.gui.QContextMenuEvent;\r
+import com.trolltech.qt.gui.QHeaderView;\r
+import com.trolltech.qt.gui.QMenu;\r
+import com.trolltech.qt.gui.QWidget;\r
+\r
+import cx.fbn.nevernote.Global;\r
+\r
+public class TableViewHeader extends QHeaderView {\r
+       public QMenu contextMenu;\r
+       public QAction createdDateAction;\r
+       public QAction changedDateAction;\r
+       public QAction subjectDateAction;\r
+       public QAction tagsAction;\r
+       public QAction notebookAction;\r
+       public QAction synchronizedAction;\r
+       public QAction authorAction;\r
+       public QAction urlAction;\r
+       \r
+\r
+       public TableViewHeader(Orientation orientation, QWidget parent) {\r
+               super(orientation, parent);\r
+               \r
+               contextMenu = new QMenu();\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
+       }\r
+       \r
+       @Override\r
+       public void contextMenuEvent(QContextMenuEvent event) {\r
+               contextMenu.exec(event.globalPos());\r
+       }\r
+}\r