|
1 #ifndef CONTENTWIDGET_H |
|
2 #define CONTENTWIDGET_H |
|
3 |
|
4 #include <hbview.h> |
|
5 #include <hbradiobuttonlist.h> |
|
6 |
|
7 #include <QPersistentModelIndex> |
|
8 |
|
9 QT_BEGIN_NAMESPACE |
|
10 |
|
11 class QFileSystemWatcher; |
|
12 class QGraphicsTextItem; |
|
13 class QGraphicsLinearLayout; |
|
14 class QItemSelection; |
|
15 class QStandardItem; |
|
16 |
|
17 QT_END_NAMESPACE |
|
18 |
|
19 class HbMenuItem; |
|
20 class HbMainWindow; |
|
21 class HbListView; |
|
22 class HbMenu; |
|
23 class HbAction; |
|
24 class HbIcon; |
|
25 class HbAbstractViewItem; |
|
26 class HbLabel; |
|
27 class HbListViewItem; |
|
28 class HbTreeView; |
|
29 class TreeDataForm; |
|
30 |
|
31 class ContentWidget : public HbView |
|
32 { |
|
33 Q_OBJECT |
|
34 |
|
35 public: |
|
36 ContentWidget(QString& imagesDir, HbMainWindow *mainWindow); |
|
37 virtual ~ContentWidget(); |
|
38 |
|
39 public slots: |
|
40 void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); |
|
41 void onLongPressed(HbAbstractViewItem *index, const QPointF &coords); |
|
42 void aboutToClose(); |
|
43 void launchInPopup(); |
|
44 void setRootItemActionTriggered(); |
|
45 void setTargetItemActionTriggered(); |
|
46 |
|
47 void addOneToModel(); |
|
48 void addOneToModelExt(); |
|
49 void removeFromModel(); |
|
50 |
|
51 protected: |
|
52 void keyPressEvent(QKeyEvent *event); |
|
53 |
|
54 private slots: |
|
55 // refreshes model |
|
56 void refresh(); |
|
57 void populateDirModel(); |
|
58 void populateFileSystemModel(); |
|
59 void populateGreenOddBrownEvenModel(); |
|
60 void showSettings(); |
|
61 void removeModel(); |
|
62 void changeModel(HbAction* action); |
|
63 void editItem(HbAction* action); |
|
64 |
|
65 void insertItemAboveTarget(); |
|
66 void insertItemBelowTarget(); |
|
67 |
|
68 void setMainMenu(); |
|
69 void resetItemManagementMenu(); |
|
70 void doCommand(int index); |
|
71 void itemActivated(const QModelIndex& index); |
|
72 void backButtonClicked(); |
|
73 void confirmDelete(); |
|
74 |
|
75 void addItem(); |
|
76 void changeItem(); |
|
77 |
|
78 void removeItems(); |
|
79 void removeAllItems(); |
|
80 |
|
81 void expandAll(); |
|
82 void collapseAll(); |
|
83 |
|
84 void changeMirroring(); |
|
85 void scrollToTarget(); |
|
86 void changeOrientation(); |
|
87 |
|
88 void populateTreeModelDefault(); |
|
89 void populateTreeModelSimple(); |
|
90 void populateTreeModelDeep(); |
|
91 void populateTreeModelFlat(); |
|
92 //void populateTreeModelMail(); |
|
93 void populateTreeModelMixed(); |
|
94 |
|
95 void autoInsertOne(); |
|
96 void autoRemoveOne(); |
|
97 void simulateMultipleFastInserts(); |
|
98 void simulateMultipleFastRemovals(); |
|
99 void timerReadyForInsert(); |
|
100 void timerReadyForRemoval(); |
|
101 |
|
102 void insertItemAboveTargetClosed(int action); |
|
103 void insertItemBelowTargetClosed(int action); |
|
104 void expandTargetItem(); |
|
105 void collapseTargetItem(); |
|
106 |
|
107 private: |
|
108 void doAddItem(); |
|
109 void doAddItem(int pos, QStandardItem *item); |
|
110 void doSettings(); |
|
111 void doRemoveItems(); |
|
112 |
|
113 void createAndInitTreeView(int newModelType); |
|
114 void initTreeView(); |
|
115 void resetTreeView(); |
|
116 |
|
117 void updateTextLabel(int count); |
|
118 |
|
119 // Calculates the item's depth in the tree. Topmost items are on depth 1. |
|
120 // This information is needed only for debug purposes. |
|
121 int calculateDepth(QModelIndex m) const; |
|
122 void expand(const QAbstractItemModel *model, |
|
123 const QModelIndex &parent, |
|
124 int level ); |
|
125 void expandUpwards( const QAbstractItemModel *model, |
|
126 const QModelIndex &parent ); |
|
127 void collapse( const QAbstractItemModel *model, |
|
128 const QModelIndex &parent, |
|
129 int depth ); |
|
130 void postEvents(); |
|
131 |
|
132 private: |
|
133 // submenu items for selecting model |
|
134 enum modelType { |
|
135 noModel = 0, |
|
136 treeModelDefault, |
|
137 treeModelSimple, |
|
138 treeModelDeep, |
|
139 treeModelFlat, |
|
140 //treeModelMail, |
|
141 treeModelMixed, |
|
142 dirModel, |
|
143 fileSystemModel, |
|
144 greenOddBrownEvenModel, |
|
145 }; |
|
146 |
|
147 // submenu items for list item operation |
|
148 enum itemOperation { |
|
149 addItemOperation, |
|
150 changeItemOperation, |
|
151 removeItemOperation, |
|
152 removeAllItemsOperation, |
|
153 expandAllOperation, |
|
154 collapseAllOperation, |
|
155 autoInsertOneOperation, |
|
156 autoRemoveOneOperation, |
|
157 simulateVisible, |
|
158 resetDuringSimulation, |
|
159 simulateMultipleFastInsertsOperation, |
|
160 simulateMultipleFastRemovalsOperation, |
|
161 selectAll, |
|
162 unselect |
|
163 }; |
|
164 |
|
165 // submenu items for list item operation |
|
166 enum orientationOperation { |
|
167 toggleOrientationOperation, |
|
168 customOrientationOperation |
|
169 }; |
|
170 |
|
171 // submenu items for list item operation |
|
172 enum optionsOperation { |
|
173 optionsOperationLast // not in use |
|
174 }; |
|
175 |
|
176 QString& mImagesDir; |
|
177 HbMainWindow *mWindow; |
|
178 HbTreeView *mTreeView; |
|
179 |
|
180 HbAction *mRemoveModelAction; |
|
181 HbAction *mOrientationSwitch; |
|
182 HbAction *mMirroring; |
|
183 |
|
184 HbAction *mScrollToAction; |
|
185 HbAction *mInsertAboveTargetAction; |
|
186 HbAction *mInsertBelowTargetAction; |
|
187 |
|
188 HbMenu *mItemSubMenu; |
|
189 HbMenu *mTargetActionsSubMenu; |
|
190 |
|
191 QFileSystemWatcher *mFileWatcher; |
|
192 int mModelType; |
|
193 |
|
194 HbMenu *mMainMenu; |
|
195 int mCountAdded; |
|
196 bool mMute; |
|
197 HbAction *mSoftKeyQuitAction; |
|
198 HbAction *mSoftKeyConfirmAction; |
|
199 HbAction *mSoftKeyBackAction; |
|
200 HbAction *mSoftKeyDoneAction; |
|
201 HbLabel *mInfoLabel; |
|
202 QGraphicsLinearLayout *mMainlayout; |
|
203 TreeDataForm *mForm; |
|
204 HbView *mDetailView; |
|
205 QPersistentModelIndex mTarget; |
|
206 |
|
207 QString mTextOfNewItem; |
|
208 HbAbstractItemView::ScrollHint mScrollHint; |
|
209 int mDepth; |
|
210 QAbstractItemModel *mPopupModel; |
|
211 |
|
212 QModelIndexList mItemsToRemove; |
|
213 QTimer *mTimer; |
|
214 int mItemsToAdd; |
|
215 QTimer *mTimerExt; |
|
216 int mItemsToAddExt; |
|
217 |
|
218 QMap<int, HbAction*> mCheckableItemActions; |
|
219 }; |
|
220 |
|
221 #endif // CONTENTWIDGET_H |