// A note's tags have been updated
@SuppressWarnings("unused")
private void updateNoteTags(String guid, List<String> tags) {
+ // Save any new tags. We'll need them later.
+ List<String> newTags = new ArrayList<String>();
+ for (int i=0; i<tags.size(); i++) {
+ if (conn.getTagTable().findTagByName(tags.get(i))==null)
+ newTags.add(tags.get(i));
+ }
+
listManager.saveNoteTags(guid, tags);
listManager.countTagResults(listManager.getNoteIndex());
StringBuffer names = new StringBuffer("");
}
browserWindow.setTag(names.toString());
noteDirty = true;
-// tagTree.updateCounts(listManager.getTagCounter());
+
+ // Now, we need to add any new tags to the tag tree
+ for (int i=0; i<newTags.size(); i++)
+ tagTree.insertTag(newTags.get(i), conn.getTagTable().findTagByName(newTags.get(i)));
}
// Get a string containing all tag names for a note
private String getTagNamesForNote(Note n) {
addAction = a;\r
}\r
\r
+ // Insert a new tag into the tree. This is used when we dynamically add a \r
+ // new tag after the full tag tree has been built. It only adds to the\r
+ // top level.\r
+ public void insertTag(String name, String guid) {\r
+ String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
+ QIcon icon = new QIcon(iconPath+"tag.png");\r
+ QTreeWidgetItem child;\r
+ Qt.Alignment ra = new Qt.Alignment(Qt.AlignmentFlag.AlignRight);\r
+ \r
+ // Build new tag & add it\r
+ child = new QTreeWidgetItem();\r
+ child.setText(0, name);\r
+ child.setIcon(0,icon);\r
+ child.setText(2, guid);\r
+ child.setTextAlignment(1, ra.value());\r
+ addTopLevelItem(child);\r
+ \r
+ // Resort the list\r
+ resizeColumnToContents(0);\r
+ resizeColumnToContents(1);\r
+ sortItems(0, SortOrder.AscendingOrder);\r
+ }\r
+ \r
public void load(List<Tag> tags) {\r
Tag tag;\r
List<QTreeWidgetItem> index = new ArrayList<QTreeWidgetItem>();\r