OSDN Git Service

Cleanup compiler warning messages and alter backup & restore to handle new database...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / gui / AttributeTreeWidget.java
1 /*\r
2  * This file is part of NeverNote \r
3  * Copyright 2009,2010 Randy Baumgarte\r
4  * Copyright 2010 Hiroshi Miura\r
5  * \r
6  * This file may be licensed under the terms of of the\r
7  * GNU General Public License Version 2 (the ``GPL'').\r
8  *\r
9  * Software distributed under the License is distributed\r
10  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either\r
11  * express or implied. See the GPL for the specific language\r
12  * governing rights and limitations.\r
13  *\r
14  * You should have received a copy of the GPL along with this\r
15  * program. If not, go to http://www.gnu.org/licenses/gpl.html\r
16  * or write to the Free Software Foundation, Inc.,\r
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
18  *\r
19 */\r
20 \r
21 package cx.fbn.nevernote.gui;\r
22 \r
23 import com.trolltech.qt.core.Qt;\r
24 import com.trolltech.qt.gui.QAbstractItemView;\r
25 import com.trolltech.qt.gui.QIcon;\r
26 import com.trolltech.qt.gui.QTreeWidget;\r
27 import com.trolltech.qt.gui.QTreeWidgetItem;\r
28 \r
29 import cx.fbn.nevernote.Global;\r
30 \r
31 public class AttributeTreeWidget extends QTreeWidget {\r
32         public enum Attributes {Created, Since, Before, LastModified};\r
33         \r
34         public AttributeTreeWidget() {\r
35         setHeaderLabel(tr("Attributes"));\r
36         setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection);\r
37  \r
38         setHeaderLabel(tr("Attributes"));\r
39         setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection);\r
40         \r
41         // Setup the first attribute tree\r
42         QTreeWidgetItem created = new QTreeWidgetItem();\r
43         created.setText(0,tr("Created"));\r
44             created.setData(0, Qt.ItemDataRole.UserRole, Attributes.Created);\r
45         addTopLevelItem(created);\r
46         // Created Since List\r
47         QTreeWidgetItem parent = created;\r
48         QTreeWidgetItem child;\r
49         child = new QTreeWidgetItem();\r
50         child.setText(0,tr("Since"));\r
51             child.setData(0,Qt.ItemDataRole.UserRole, Attributes.Since);\r
52         parent.addChild(child);         \r
53         parent = child;\r
54                 \r
55                 // -Since=true/Before=false, Created=true/Updated=false)\r
56         Global.createdBeforeFilter = new DateAttributeFilterTable(false, true);\r
57         Global.createdSinceFilter = new DateAttributeFilterTable(true, true);\r
58         Global.changedBeforeFilter = new DateAttributeFilterTable(false, false);\r
59         Global.changedSinceFilter = new DateAttributeFilterTable(true, false);\r
60         Global.containsFilter = new ContainsAttributeFilterTable();\r
61         \r
62                 String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
63                 QIcon icon = new QIcon(iconPath+"attribute.png");\r
64         for (int i=0; i<Global.createdSinceFilter.size(); i++) {\r
65                 child = new QTreeWidgetItem();\r
66                 child.setIcon(0, icon);\r
67                 child.setText(0, Global.createdSinceFilter.getLabel(i));\r
68                 parent.addChild(child);\r
69         }\r
70         \r
71         \r
72         // Created Before List\r
73         parent = created;\r
74         child = new QTreeWidgetItem();\r
75         child.setText(0,tr("Before"));\r
76             child.setData(0,Qt.ItemDataRole.UserRole, Attributes.Before);\r
77         created.addChild(child);\r
78         parent = child;\r
79         for (int i=0; i<Global.createdBeforeFilter.size(); i++) {\r
80                 child = new QTreeWidgetItem();\r
81                 child.setIcon(0, icon);\r
82                 child.setText(0, Global.createdBeforeFilter.getLabel(i));\r
83                 parent.addChild(child);\r
84         }\r
85         \r
86         \r
87         QTreeWidgetItem lastModified = new QTreeWidgetItem();\r
88         lastModified.setText(0,tr("Last Modified"));\r
89             lastModified.setData(0,Qt.ItemDataRole.UserRole, Attributes.LastModified);\r
90         addTopLevelItem(lastModified);\r
91  \r
92         // Changed Since List\r
93         parent = lastModified;\r
94         child = new QTreeWidgetItem();\r
95         child.setText(0,tr("Since"));\r
96         child.setData(0,Qt.ItemDataRole.UserRole, Attributes.Since);\r
97         lastModified.addChild(child);\r
98         parent = child;\r
99         for (int i=0; i<Global.changedSinceFilter.size(); i++) {\r
100                 child = new QTreeWidgetItem();\r
101                 child.setIcon(0, icon);\r
102                 child.setText(0, Global.changedSinceFilter.getLabel(i));\r
103                 parent.addChild(child);\r
104         }\r
105         \r
106         \r
107         parent = created;\r
108         child = new QTreeWidgetItem();\r
109         child.setText(0,tr("Before"));\r
110                 child.setData(0,Qt.ItemDataRole.UserRole, Attributes.Before);\r
111         lastModified.addChild(child);\r
112         parent = child;\r
113         for (int i=0; i<Global.changedBeforeFilter.size(); i++) {\r
114                 child = new QTreeWidgetItem();\r
115                 child.setIcon(0, icon);\r
116                 child.setText(0, Global.changedBeforeFilter.getLabel(i));\r
117                 parent.addChild(child);\r
118         }\r
119         \r
120         // Now we are into the other attributes\r
121         QTreeWidgetItem contains = new QTreeWidgetItem();\r
122         contains.setText(0,tr("Contains"));\r
123             contains.setData(0,Qt.ItemDataRole.UserRole,"Contains");\r
124         addTopLevelItem(contains);\r
125 \r
126         for (int i=0; i<Global.containsFilter.size(); i++) {\r
127                 child = new QTreeWidgetItem();\r
128                 child.setText(0,Global.containsFilter.getLabel(i));\r
129                 child.setIcon(0, icon);\r
130                 contains.addChild(child);\r
131             }\r
132         \r
133         }\r
134         \r
135 }\r