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