/*\r
* This file is part of NeverNote \r
- * Copyright 2009 Randy Baumgarte\r
+ * Copyright 2009,2010 Randy Baumgarte\r
+ * Copyright 2010 Hiroshi Miura\r
* \r
* This file may be licensed under the terms of of the\r
* GNU General Public License Version 2 (the ``GPL'').\r
package cx.fbn.nevernote.gui;\r
\r
import java.util.ArrayList;\r
+import java.util.HashMap;\r
import java.util.List;\r
\r
import com.evernote.edam.type.Tag;\r
private QAction editAction;\r
private QAction deleteAction;\r
private QAction addAction;\r
+ private QAction iconAction;\r
public TagSignal tagSignal;\r
public NoteSignal noteSignal;\r
private boolean showAllTags;\r
private final DatabaseConnection db;\r
+ private HashMap<String, QIcon> icons;\r
\r
\r
public TagTreeWidget(DatabaseConnection d) {\r
noteSignal = new NoteSignal();\r
setDragDropMode(QAbstractItemView.DragDropMode.DragDrop);\r
setHeaderLabels(headers);\r
- setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection);\r
+// setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection);\r
+ setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection);\r
\r
int width = Global.getColumnWidth("tagTreeName");\r
if (width>0)\r
public void setAddAction(QAction a) {\r
addAction = a;\r
}\r
+ public void setIconAction(QAction i) {\r
+ iconAction = i;\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
if (tag.getParentGuid()==null || tag.getParentGuid().equals("")) {\r
child = new QTreeWidgetItem();\r
child.setText(0, tag.getName());\r
- child.setIcon(0,icon);\r
+ if (icons != null && !icons.containsKey(tag.getGuid())) {\r
+ child.setIcon(0, icon);\r
+ } else {\r
+ child.setIcon(0, icons.get(tag.getGuid()));\r
+ }\r
+\r
child.setText(2, tag.getGuid());\r
child.setTextAlignment(1, ra.value());\r
index.add(child);\r
return;\r
}\r
if (event.source() == this) {\r
+ if (Global.tagBehavior().equals("HideInactiveCount")) {\r
+ event.ignore();\r
+ return;\r
+ }\r
event.mimeData().setData("application/x-nevernote-tag", new QByteArray(currentItem().text(2)));\r
event.accept();\r
return;\r
return false;\r
QTreeWidgetItem newChild;\r
if (parent == null) {\r
- tagSignal.changeParent.emit(current, "");\r
+// tagSignal.changeParent.emit(current, "");\r
db.getTagTable().updateTagParent(current, "");\r
newChild = new QTreeWidgetItem(this);\r
} else {\r
- tagSignal.changeParent.emit(current, parent.text(2));\r
+// tagSignal.changeParent.emit(current, parent.text(2));\r
db.getTagTable().updateTagParent(current, parent.text(2));\r
newChild = new QTreeWidgetItem(parent);\r
}\r
menu.addAction(addAction);\r
menu.addAction(editAction);\r
menu.addAction(deleteAction);\r
+ menu.addSeparator();\r
+ menu.addAction(iconAction);\r
menu.exec(event.globalPos());\r
}\r
\r
+ public void setIcons(HashMap<String, QIcon> i) {\r
+ icons = i;\r
+ }\r
+ \r
// Copy an individual item within the tree. I need to do this because\r
// Qt doesn't call the dropMimeData on a move, just a copy.\r
private void copyTreeItem(QTreeWidgetItem source, QTreeWidgetItem target) {\r