X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=src%2Fcx%2Ffbn%2Fnevernote%2FNeverNote.java;h=5e6f845d7d7d1969f193ab89ac738b851954d26f;hb=e0ca12f9a3252642d3e4632f580b368965830e94;hp=6c49b34b35114a587acf6a8c95638bd2f5dde809;hpb=eac4a6b584374547a416d7e6362eae1c293d59fd;p=neighbornote%2FNeighborNote.git diff --git a/src/cx/fbn/nevernote/NeverNote.java b/src/cx/fbn/nevernote/NeverNote.java index 6c49b34..5e6f845 100644 --- a/src/cx/fbn/nevernote/NeverNote.java +++ b/src/cx/fbn/nevernote/NeverNote.java @@ -139,6 +139,8 @@ import cx.fbn.nevernote.dialog.NotebookArchive; import cx.fbn.nevernote.dialog.NotebookEdit; import cx.fbn.nevernote.dialog.OnlineNoteHistory; import cx.fbn.nevernote.dialog.SavedSearchEdit; +import cx.fbn.nevernote.dialog.SetIcon; +import cx.fbn.nevernote.dialog.StackNotebook; import cx.fbn.nevernote.dialog.TagEdit; import cx.fbn.nevernote.dialog.ThumbnailViewer; import cx.fbn.nevernote.dialog.WatchFolder; @@ -310,11 +312,11 @@ public class NeverNote extends QMainWindow{ public NeverNote(DatabaseConnection dbConn) { conn = dbConn; if (conn.getConnection() == null) { - String msg = "Unable to connect to the database.\n\nThe most probable reason is that some other process\n" + + String msg = new String(tr("Unable to connect to the database.\n\nThe most probable reason is that some other process\n" + "is accessing the database or NeverNote is already running.\n\n" + - "Please end any other process or shutdown the other NeverNote before starting.\n\nExiting program."; + "Please end any other process or shutdown the other NeverNote before starting.\n\nExiting program.")); - QMessageBox.critical(null, "Database Connection Error",msg); + QMessageBox.critical(null, tr("Database Connection Error") ,msg); System.exit(16); } @@ -439,7 +441,7 @@ public class NeverNote extends QMainWindow{ importFilesKeep = new ArrayList(); externalFileSaveTimer.start(); - notebookTree = new NotebookTreeWidget(); + notebookTree = new NotebookTreeWidget(conn); attributeTree = new AttributeTreeWidget(); tagTree = new TagTreeWidget(conn); savedSearchTree = new SavedSearchTreeWidget(); @@ -504,6 +506,7 @@ public class NeverNote extends QMainWindow{ tagTree.setDeleteAction(menuBar.tagDeleteAction); tagTree.setEditAction(menuBar.tagEditAction); tagTree.setAddAction(menuBar.tagAddAction); + tagTree.setIconAction(menuBar.tagIconAction); tagTree.setVisible(Global.isWindowVisible("tagTree")); tagTree.noteSignal.tagsAdded.connect(this, "tagsAdded(String, String)"); menuBar.hideTags.setChecked(Global.isWindowVisible("tagTree")); @@ -512,6 +515,8 @@ public class NeverNote extends QMainWindow{ notebookTree.setDeleteAction(menuBar.notebookDeleteAction); notebookTree.setEditAction(menuBar.notebookEditAction); notebookTree.setAddAction(menuBar.notebookAddAction); + notebookTree.setIconAction(menuBar.notebookIconAction); + notebookTree.setStackAction(menuBar.notebookStackAction); notebookTree.setVisible(Global.isWindowVisible("notebookTree")); notebookTree.noteSignal.notebookChanged.connect(this, "updateNoteNotebook(String, String)"); menuBar.hideNotebooks.setChecked(Global.isWindowVisible("notebookTree")); @@ -519,6 +524,7 @@ public class NeverNote extends QMainWindow{ savedSearchTree.setAddAction(menuBar.savedSearchAddAction); savedSearchTree.setEditAction(menuBar.savedSearchEditAction); savedSearchTree.setDeleteAction(menuBar.savedSearchDeleteAction); + savedSearchTree.setIconAction(menuBar.savedSearchIconAction); savedSearchTree.itemSelectionChanged.connect(this, "updateSavedSearchSelection()"); savedSearchTree.setVisible(Global.isWindowVisible("savedSearchTree")); menuBar.hideSavedSearches.setChecked(Global.isWindowVisible("savedSearchTree")); @@ -1138,10 +1144,8 @@ public class NeverNote extends QMainWindow{ // Setup the tree containing the user's notebooks. private void initializeNotebookTree() { logger.log(logger.HIGH, "Entering NeverNote.initializeNotebookTree"); - // notebookTree.itemSelectionChanged.connect(this, "notebookTreeSelection()"); notebookTree.itemClicked.connect(this, "notebookTreeSelection()"); listManager.notebookSignal.refreshNotebookTreeCounts.connect(notebookTree, "updateCounts(List, List)"); - // notebookTree.resize(Global.getSize("notebookTree")); logger.log(logger.HIGH, "Leaving NeverNote.initializeNotebookTree"); } // Listener when a notebook is selected @@ -1158,13 +1162,24 @@ public class NeverNote extends QMainWindow{ menuBar.noteRestoreAction.setVisible(false); menuBar.notebookEditAction.setEnabled(true); menuBar.notebookDeleteAction.setEnabled(true); + menuBar.notebookIconAction.setEnabled(true); + menuBar.notebookStackAction.setEnabled(true); List selections = notebookTree.selectedItems(); QTreeWidgetItem currentSelection; selectedNotebookGUIDs.clear(); if (!Global.mimicEvernoteInterface) { for (int i=0; i 0) + String stackName = ""; + if (selections.size() > 0) { guid = (selections.get(0).text(2)); - if (!guid.equals("")) + stackName = selections.get(0).text(0); + } + if (!guid.equals("") && !guid.equals("STACK")) { selectedNotebookGUIDs.add(guid); + menuBar.notebookIconAction.setEnabled(true); + } + else { + menuBar.notebookIconAction.setEnabled(false); + for (int j=0; j icons = conn.getNotebookTable().getAllIcons(); + notebookTree.setIcons(icons); + + if (selectedNotebookGUIDs == null) selectedNotebookGUIDs = new ArrayList(); List books = conn.getNotebookTable().getAll(); for (int i=books.size()-1; i>=0; i--) { @@ -1285,29 +1320,89 @@ public class NeverNote extends QMainWindow{ } // Edit an existing notebook @SuppressWarnings("unused") + private void stackNotebook() { + logger.log(logger.HIGH, "Entering NeverNote.stackNotebook"); + StackNotebook edit = new StackNotebook(); + + List selections = notebookTree.selectedItems(); + QTreeWidgetItem currentSelection; + for (int i=0; i selections = notebookTree.selectedItems(); QTreeWidgetItem currentSelection; currentSelection = selections.get(0); edit.setNotebook(currentSelection.text(0)); - edit.setNotebooks(listManager.getNotebookIndex()); - + String guid = currentSelection.text(2); - for (int i=0; i selections = notebookTree.selectedItems(); @@ -1351,13 +1448,18 @@ public class NeverNote extends QMainWindow{ QTreeWidgetItem currentSelection; currentSelection = selections.get(i); String guid = currentSelection.text(2); - for (int j=0; j=0; i--) { - // if (dbRunner.getLocalNotebooks().get(i).equals(arg0)) - // } + notebookTreeSelection(); notebookTree.load(listManager.getNotebookIndex(), listManager.getLocalNotebooks()); listManager.countNotebookResults(listManager.getNoteIndex()); -// notebookTree.updateCounts(listManager.getNotebookIndex(), listManager.getNotebookCounter()); logger.log(logger.HIGH, "Entering NeverNote.deleteNotebook"); } // A note's notebook has been updated @@ -1483,9 +1598,47 @@ public class NeverNote extends QMainWindow{ waitCursor(false); browserWindow.setNotebookList(nbooks); } + // Change the notebook's icon + private void setNotebookIcon() { + QTreeWidgetItem currentSelection; + List selections = notebookTree.selectedItems(); + if (selections.size() == 0) + return; + + currentSelection = selections.get(0); + String guid = currentSelection.text(2); + if (guid.equalsIgnoreCase("")) + return; + QIcon currentIcon = currentSelection.icon(0); + QIcon icon = conn.getNotebookTable().getIcon(guid); + SetIcon dialog; + if (icon == null) { + dialog = new SetIcon(currentIcon); + dialog.setUseDefaultIcon(true); + } else { + dialog = new SetIcon(icon); + dialog.setUseDefaultIcon(false); + } + dialog.exec(); + if (dialog.okPressed()) { + QIcon newIcon = dialog.getIcon(); + conn.getNotebookTable().setIcon(guid, newIcon, dialog.getFileType()); + if (newIcon == null) { + boolean isPublished = false;; + boolean found = false; + for (int i=0; i 0) { menuBar.tagEditAction.setEnabled(true); menuBar.tagDeleteAction.setEnabled(true); + menuBar.tagIconAction.setEnabled(true); } else { menuBar.tagEditAction.setEnabled(false); menuBar.tagDeleteAction.setEnabled(false); + menuBar.tagIconAction.setEnabled(true); } if (selectedTagGUIDs.size() == 1 && selectedTagGUIDs.get(0).equals(previousSelectedTag)) { previousSelectedTag = selectedTagGUIDs.get(0); @@ -1670,8 +1825,10 @@ public class NeverNote extends QMainWindow{ // selectedTagGUIDs.clear(); // clear out old entries tagTree.blockSignals(true); - if (reload) + if (reload) { + tagTree.setIcons(conn.getTagTable().getAllIcons()); tagTree.load(listManager.getTagIndex()); + } for (int i=selectedTagGUIDs.size()-1; i>=0; i--) { boolean found = tagTree.selectGuid(selectedTagGUIDs.get(i)); if (!found) @@ -1792,11 +1949,42 @@ public class NeverNote extends QMainWindow{ menuBar.noteRestoreAction.setVisible(false); menuBar.tagEditAction.setEnabled(false); menuBar.tagDeleteAction.setEnabled(false); + menuBar.tagIconAction.setEnabled(false); selectedTagGUIDs.clear(); listManager.setSelectedTags(selectedTagGUIDs); tagTree.blockSignals(false); } + // Change the icon for a tag + private void setTagIcon() { + QTreeWidgetItem currentSelection; + List selections = tagTree.selectedItems(); + if (selections.size() == 0) + return; + + currentSelection = selections.get(0); + String guid = currentSelection.text(2); + + QIcon currentIcon = currentSelection.icon(0); + QIcon icon = conn.getTagTable().getIcon(guid); + SetIcon dialog; + if (icon == null) { + dialog = new SetIcon(currentIcon); + dialog.setUseDefaultIcon(true); + } else { + dialog = new SetIcon(icon); + dialog.setUseDefaultIcon(false); + } + dialog.exec(); + if (dialog.okPressed()) { + QIcon newIcon = dialog.getIcon(); + conn.getTagTable().setIcon(guid, newIcon, dialog.getFileType()); + if (newIcon == null) + newIcon = new QIcon(iconPath+"tag.png"); + currentSelection.setIcon(0, newIcon); + } + } + //*************************************************************** //*************************************************************** @@ -1912,6 +2100,7 @@ public class NeverNote extends QMainWindow{ String currentGuid = selectedSavedSearchGUID; menuBar.savedSearchEditAction.setEnabled(true); menuBar.savedSearchDeleteAction.setEnabled(true); + menuBar.savedSearchIconAction.setEnabled(true); List selections = savedSearchTree.selectedItems(); QTreeWidgetItem currentSelection; selectedSavedSearchGUID = ""; @@ -1938,6 +2127,7 @@ public class NeverNote extends QMainWindow{ private void clearSavedSearchFilter() { menuBar.savedSearchEditAction.setEnabled(false); menuBar.savedSearchDeleteAction.setEnabled(false); + menuBar.savedSearchIconAction.setEnabled(false); savedSearchTree.blockSignals(true); savedSearchTree.clearSelection(); savedSearchTree.blockSignals(false); @@ -1951,6 +2141,7 @@ public class NeverNote extends QMainWindow{ if (selectedSavedSearchGUID == null) selectedSavedSearchGUID = new String(); savedSearchTree.blockSignals(true); + savedSearchTree.setIcons(conn.getSavedSearchTable().getAllIcons()); savedSearchTree.load(listManager.getSavedSearchIndex()); savedSearchTree.selectGuid(selectedSavedSearchGUID); savedSearchTree.blockSignals(false); @@ -1962,17 +2153,20 @@ public class NeverNote extends QMainWindow{ menuBar.savedSearchEditAction.setEnabled(true); menuBar.savedSearchDeleteAction.setEnabled(true); + menuBar.savedSearchIconAction.setEnabled(true); List selections = savedSearchTree.selectedItems(); if (selections.size() > 0) { menuBar.savedSearchEditAction.setEnabled(true); menuBar.savedSearchDeleteAction.setEnabled(true); + menuBar.savedSearchIconAction.setEnabled(true); selectedSavedSearchGUID = selections.get(0).text(1); SavedSearch s = conn.getSavedSearchTable().getSavedSearch(selectedSavedSearchGUID); searchField.setEditText(s.getQuery()); } else { menuBar.savedSearchEditAction.setEnabled(false); menuBar.savedSearchDeleteAction.setEnabled(false); + menuBar.savedSearchIconAction.setEnabled(false); selectedSavedSearchGUID = ""; searchField.setEditText(""); } @@ -1994,6 +2188,36 @@ public class NeverNote extends QMainWindow{ Global.saveWindowVisible("savedSearchTree", savedSearchTree.isVisible()); logger.log(logger.HIGH, "Leaving NeverNote.toggleSavedSearchWindow"); } + // Change the icon for a saved search + private void setSavedSearchIcon() { + QTreeWidgetItem currentSelection; + List selections = savedSearchTree.selectedItems(); + if (selections.size() == 0) + return; + + currentSelection = selections.get(0); + String guid = currentSelection.text(1); + + QIcon currentIcon = currentSelection.icon(0); + QIcon icon = conn.getSavedSearchTable().getIcon(guid); + SetIcon dialog; + if (icon == null) { + dialog = new SetIcon(currentIcon); + dialog.setUseDefaultIcon(true); + } else { + dialog = new SetIcon(icon); + dialog.setUseDefaultIcon(false); + } + dialog.exec(); + if (dialog.okPressed()) { + QIcon newIcon = dialog.getIcon(); + conn.getSavedSearchTable().setIcon(guid, newIcon, dialog.getFileType()); + if (newIcon == null) + newIcon = new QIcon(iconPath+"search.png"); + currentSelection.setIcon(0, newIcon); + } + + } @@ -3386,7 +3610,6 @@ public class NeverNote extends QMainWindow{ externalWindows.get(currentNoteGuid).raise(); return; } - // We have a new external editor to create QIcon appIcon = new QIcon(iconPath+"nevernote.png"); ExternalBrowse newBrowser = new ExternalBrowse(conn); @@ -3887,7 +4110,11 @@ public class NeverNote extends QMainWindow{ listManager.countNotebookResults(listManager.getNoteIndex()); browserWindow.titleLabel.setFocus(); browserWindow.titleLabel.selectAll(); -// notebookTree.updateCounts(listManager.getNotebookIndex(), listManager.getNotebookCounter()); +// notebookTree.updateCounts(listManager.getNotebookIndex(), listManager.getNotebookCounter()); + + // If the window is hidden, then we want to popup this in an external window & + if (!isVisible()) + listDoubleClick(); logger.log(logger.HIGH, "Leaving NeverNote.addNote"); } // Restore a note from the trash;