|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Definition file for class NotesDocLoader. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <qdebug.h> |
|
20 #include <qglobal.h> |
|
21 #include <QtGui> |
|
22 #include <HbMainWindow> |
|
23 #include <HbView> |
|
24 #include <HbInstance> |
|
25 #include <HbListView> |
|
26 |
|
27 // User includes |
|
28 #include "notesviewmanager.h" |
|
29 #include "notesmainview.h" |
|
30 #include "notescollectionview.h" |
|
31 #include "notestodoview.h" |
|
32 #include "notesfavoriteview.h" |
|
33 #include "notesnoteview.h" |
|
34 #include "notesdocloader.h" |
|
35 #include "notescommon.h" |
|
36 #include "notesmodel.h" |
|
37 #include "notessortfilterproxymodel.h" |
|
38 #include "agendautil.h" |
|
39 |
|
40 /*! |
|
41 \class NotesViewManager |
|
42 |
|
43 This is the heart of the notes application. This is responsible for |
|
44 managing the notes views and owning the agenda interface object. |
|
45 This also is the source for the notes list model. |
|
46 */ |
|
47 /*! |
|
48 Constructor. |
|
49 |
|
50 \param controller A reference to the object of NotesAppController. |
|
51 */ |
|
52 NotesViewManager::NotesViewManager( |
|
53 NotesAppControllerIf &controllerIf, QObject *parent) |
|
54 :QObject(parent), |
|
55 mAppControllerIf(controllerIf) |
|
56 { |
|
57 qDebug() << "notes: NotesViewManager::NotesViewManager -->"; |
|
58 |
|
59 // The document loader and views. |
|
60 loadViews(); |
|
61 |
|
62 qDebug() << "notes: NotesViewManager::NotesViewManager <--"; |
|
63 } |
|
64 |
|
65 /*! |
|
66 Destructor. |
|
67 */ |
|
68 NotesViewManager::~NotesViewManager() |
|
69 { |
|
70 // No implementation yet |
|
71 } |
|
72 |
|
73 /*! |
|
74 Switches to view specified by viewId. |
|
75 |
|
76 \param viewId View Id. |
|
77 */ |
|
78 void NotesViewManager::switchToView(NotesNamespace::NotesViewIds viewId) |
|
79 { |
|
80 HbMainWindow *window = hbInstance->allMainWindows().first(); |
|
81 |
|
82 switch (viewId) { |
|
83 case NotesNamespace::NotesMainViewId: |
|
84 window->removeView(window->currentView()); |
|
85 window->addView(mMainView); |
|
86 window->setCurrentView(mMainView); |
|
87 break; |
|
88 |
|
89 case NotesNamespace::NotesCollectionViewId: |
|
90 window->removeView(window->currentView()); |
|
91 window->addView(mCollectionView); |
|
92 window->setCurrentView(mCollectionView); |
|
93 break; |
|
94 |
|
95 case NotesNamespace::NotesTodoViewId: |
|
96 window->removeView(window->currentView()); |
|
97 window->addView(mTodoView); |
|
98 window->setCurrentView(mTodoView); |
|
99 break; |
|
100 |
|
101 case NotesNamespace::NotesFavoritesViewId: |
|
102 window->removeView(window->currentView()); |
|
103 window->addView(mFavoriteView); |
|
104 window->setCurrentView(mFavoriteView); |
|
105 break; |
|
106 |
|
107 case NotesNamespace::NotesNoteViewId: |
|
108 window->removeView(window->currentView()); |
|
109 window->addView(mNoteView); |
|
110 window->setCurrentView(mNoteView); |
|
111 break; |
|
112 |
|
113 default: |
|
114 break; |
|
115 } |
|
116 } |
|
117 |
|
118 /*! |
|
119 Loads the views from the docml file. |
|
120 */ |
|
121 void NotesViewManager::loadViews() |
|
122 { |
|
123 qDebug() << "notes: NotesViewManager::loadViews -->"; |
|
124 |
|
125 // Load the main view. |
|
126 loadNotesMainView(); |
|
127 // Load the collection view. |
|
128 loadNotesCollectionView(); |
|
129 // Load the to-do view. |
|
130 loadTodoView(); |
|
131 // Load the favorites view. |
|
132 loadFavoritesView(); |
|
133 // Load the recent notes view. |
|
134 loadNoteView(); |
|
135 |
|
136 // Set the main view to the window |
|
137 hbInstance->allMainWindows().first()->addView(mMainView); |
|
138 |
|
139 qDebug() << "notes: NotesViewManager::loadViews <--"; |
|
140 } |
|
141 |
|
142 /*! |
|
143 Loads the notes main view. |
|
144 */ |
|
145 void NotesViewManager::loadNotesMainView() |
|
146 { |
|
147 qDebug() << "notes: NotesViewManager::loadNotesMainView -->"; |
|
148 |
|
149 bool loadSuccess; |
|
150 |
|
151 // Construct the document loader instance |
|
152 NotesDocLoader *docLoader = new NotesDocLoader(); |
|
153 |
|
154 // Load the application xml. |
|
155 docLoader->load(NOTES_MAIN_VIEW_XML, &loadSuccess); |
|
156 Q_ASSERT_X( |
|
157 loadSuccess, |
|
158 "notesviewmanager.cpp", |
|
159 "Unable to load the main view app xml"); |
|
160 |
|
161 // Find the main view. |
|
162 mMainView = static_cast<NotesMainView *> ( |
|
163 docLoader->findWidget(NOTES_MAIN_VIEW)); |
|
164 Q_ASSERT_X( |
|
165 mMainView, "notesviewmanager.cpp", "Unable to find the main view."); |
|
166 // Setup the view. |
|
167 mMainView->setupView(mAppControllerIf, docLoader); |
|
168 |
|
169 qDebug() << "notes: NotesViewManager::loadNotesMainView <--"; |
|
170 } |
|
171 |
|
172 /*! |
|
173 Loads the notes collection view. |
|
174 */ |
|
175 void NotesViewManager::loadNotesCollectionView() |
|
176 { |
|
177 qDebug("notes: NotesViewManager::loadNotesCollectionView -- Entry"); |
|
178 |
|
179 bool loadSuccess; |
|
180 |
|
181 // Construct the document loader instance |
|
182 NotesDocLoader *docLoader = new NotesDocLoader(); |
|
183 |
|
184 // Load the application xml. |
|
185 docLoader->load(NOTES_COLLECTION_VIEW_XML, &loadSuccess); |
|
186 |
|
187 // Find the collection view. |
|
188 mCollectionView = static_cast<NotesCollectionView *> ( |
|
189 docLoader->findWidget(NOTES_COLLECTION_VIEW)); |
|
190 // Setup the view. |
|
191 mCollectionView->setupView(mAppControllerIf, docLoader); |
|
192 |
|
193 qDebug() << "notes: NotesViewManager::loadNotesCollectionView <--"; |
|
194 } |
|
195 |
|
196 /*! |
|
197 Loads the to-do view. |
|
198 */ |
|
199 void NotesViewManager::loadTodoView() |
|
200 { |
|
201 qDebug("notes: NotesViewManager::loadTodoView -->"); |
|
202 |
|
203 bool loadSuccess; |
|
204 |
|
205 // Construct the document loader instance |
|
206 NotesDocLoader *docLoader = new NotesDocLoader(); |
|
207 |
|
208 // Load the application xml. |
|
209 docLoader->load(NOTES_TODO_VIEW_XML, &loadSuccess); |
|
210 |
|
211 // Find the to-do view. |
|
212 mTodoView = static_cast<NotesTodoView *> ( |
|
213 docLoader->findWidget(NOTES_TODO_VIEW)); |
|
214 // Setup the view. |
|
215 mTodoView->setupView(mAppControllerIf, docLoader); |
|
216 |
|
217 qDebug() << "notes: NotesViewManager::loadTodoView <--"; |
|
218 } |
|
219 |
|
220 /*! |
|
221 Loads the favorites view. |
|
222 */ |
|
223 void NotesViewManager::loadFavoritesView() |
|
224 { |
|
225 qDebug("notes: NotesViewManager::loadFavoritesView -->"); |
|
226 |
|
227 bool loadSuccess; |
|
228 |
|
229 // Construct the document loader instance |
|
230 NotesDocLoader *docLoader = new NotesDocLoader(); |
|
231 |
|
232 // Load the application xml. |
|
233 docLoader->load(NOTES_FAVORITES_VIEW_XML, &loadSuccess); |
|
234 |
|
235 // Find the favorites view. |
|
236 mFavoriteView = static_cast<NotesFavoriteView *> ( |
|
237 docLoader->findWidget(NOTES_FAVORITES_VIEW)); |
|
238 // Setup the view. |
|
239 mFavoriteView->setupView(mAppControllerIf, docLoader); |
|
240 |
|
241 qDebug() << "notes: NotesViewManager::loadFavoritesView <--"; |
|
242 } |
|
243 |
|
244 /*! |
|
245 Loads the recent notes view. |
|
246 */ |
|
247 void NotesViewManager::loadNoteView() |
|
248 { |
|
249 qDebug("notes: NotesViewManager::loadNoteView -->"); |
|
250 |
|
251 bool loadSuccess; |
|
252 |
|
253 // Construct the document loader instance |
|
254 NotesDocLoader *docLoader = new NotesDocLoader(); |
|
255 |
|
256 // Load the application xml. |
|
257 docLoader->load(NOTES_NOTE_VIEW_XML, &loadSuccess); |
|
258 |
|
259 // Find the note view. |
|
260 mNoteView = static_cast<NotesNoteView *> ( |
|
261 docLoader->findWidget(NOTES_NOTE_VIEW)); |
|
262 // Setup the view. |
|
263 mNoteView->setupView(mAppControllerIf, docLoader); |
|
264 |
|
265 qDebug() << "notes: NotesViewManager::loadNoteView <--"; |
|
266 } |
|
267 |
|
268 // End of file --Don't remove this. |