27 //SYSTEM |
27 //SYSTEM |
28 #include <QObject> |
28 #include <QObject> |
29 #include <dialpad.h> |
29 #include <dialpad.h> |
30 #include <dialpadkeyhandler.h> |
30 #include <dialpadkeyhandler.h> |
31 #include <hbtoolbar.h> |
31 #include <hbtoolbar.h> |
|
32 #include <hbmainwindow.h> |
|
33 #include <QTimer> |
|
34 |
|
35 const int logsRepositoryLazyInitTimerMsec = 3000; |
32 |
36 |
33 // ----------------------------------------------------------------------------- |
37 // ----------------------------------------------------------------------------- |
34 // |
38 // |
35 // ----------------------------------------------------------------------------- |
39 // ----------------------------------------------------------------------------- |
36 // |
40 // |
37 LogsComponentRepository::LogsComponentRepository(LogsAbstractViewManager& viewManager) |
41 LogsComponentRepository::LogsComponentRepository(LogsAbstractViewManager& viewManager) |
38 : HbDocumentLoader(), |
42 : QObject(), |
|
43 HbDocumentLoader(), |
39 mViewManager(viewManager), |
44 mViewManager(viewManager), |
40 mRecentCallsView(0), |
45 mRecentCallsView(0), |
41 mDetailsView(0), |
46 mDetailsView(0), |
42 mMatchesView(0), |
47 mMatchesView(0), |
43 mDialpad(0), |
48 mDialpad(0), |
44 mDialpadKeyHandler(0) |
49 mDialpadKeyHandler(0), |
45 { |
50 mCurrentObjectTree(0) |
46 mModel = new LogsModel(LogsModel::LogsRecentModel); |
51 { |
|
52 mModel = new LogsModel(LogsModel::LogsRecentModel, ETrue); |
|
53 QTimer::singleShot(logsRepositoryLazyInitTimerMsec, this, SLOT(lazyInit())); |
47 } |
54 } |
48 |
55 |
49 // ----------------------------------------------------------------------------- |
56 // ----------------------------------------------------------------------------- |
50 // |
57 // |
51 // ----------------------------------------------------------------------------- |
58 // ----------------------------------------------------------------------------- |
83 |
90 |
84 // ----------------------------------------------------------------------------- |
91 // ----------------------------------------------------------------------------- |
85 // |
92 // |
86 // ----------------------------------------------------------------------------- |
93 // ----------------------------------------------------------------------------- |
87 // |
94 // |
88 LogsRecentCallsView* LogsComponentRepository::recentCallsView() |
95 LogsRecentCallsView* LogsComponentRepository::recentCallsView(bool onlyInit) |
89 { |
96 { |
90 LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::recentCallsView()" ); |
97 LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::recentCallsView()" ); |
91 setObjectTreeToView( LogsRecentViewId ); |
|
92 |
98 |
93 if ( !mRecentCallsView ) { |
99 if ( !mRecentCallsView ) { |
94 bool ok = false; |
100 mRecentCallsView = qobject_cast<LogsRecentCallsView*>(doLoadView( |
95 mRecentViewComponents = load( logsRecentCallsViewFile, &ok ); |
101 logsRecentCallsViewFile, logsRecentCallsViewId, |
96 if ( ok ) { |
102 mRecentViewComponents, LogsRecentViewId, onlyInit)); |
97 mRecentCallsView = qobject_cast<LogsRecentCallsView*> |
103 } else if ( !onlyInit ){ |
98 ( findWidget(logsRecentCallsViewId) ); |
104 setObjectTreeToView( LogsRecentViewId ); |
99 |
|
100 addToolbarToObjectList(mRecentViewComponents); |
|
101 } else { |
|
102 LOGS_QCRITICAL( "logs [UI] XML loading failed..." ); |
|
103 } |
|
104 } |
105 } |
105 |
106 |
106 LOGS_QDEBUG( "logs [UI] <- LogsComponentRepository::recentCallsView()" ); |
107 LOGS_QDEBUG( "logs [UI] <- LogsComponentRepository::recentCallsView()" ); |
107 return mRecentCallsView; |
108 return mRecentCallsView; |
108 } |
109 } |
109 |
110 |
110 // ----------------------------------------------------------------------------- |
111 // ----------------------------------------------------------------------------- |
111 // |
112 // |
112 // ----------------------------------------------------------------------------- |
113 // ----------------------------------------------------------------------------- |
113 // |
114 // |
114 LogsDetailsView* LogsComponentRepository::detailsView() |
115 LogsDetailsView* LogsComponentRepository::detailsView(bool onlyInit) |
115 { |
116 { |
116 LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::detailsView()" ); |
117 LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::detailsView()" ); |
117 setObjectTreeToView( LogsDetailsViewId ); |
118 |
118 |
|
119 if ( !mDetailsView ) { |
119 if ( !mDetailsView ) { |
120 bool ok = false; |
120 mDetailsView = qobject_cast<LogsDetailsView*>(doLoadView( |
121 mDetailsViewComponents = load( logsDetailsViewFile, &ok ); |
121 logsDetailsViewFile, logsDetailsViewId, |
122 if ( ok ) { |
122 mDetailsViewComponents, LogsDetailsViewId, onlyInit)); |
123 mDetailsView = qobject_cast<LogsDetailsView*> |
123 } else if ( !onlyInit ){ |
124 ( findWidget(logsDetailsViewId) ); |
124 setObjectTreeToView( LogsDetailsViewId ); |
125 |
125 } |
126 addToolbarToObjectList(mDetailsViewComponents); |
126 |
127 } else { |
|
128 LOGS_QCRITICAL( "logs [UI] XML loading failed..." ); |
|
129 } |
|
130 } |
|
131 LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::detailsView()" ); |
127 LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::detailsView()" ); |
132 return mDetailsView; |
128 return mDetailsView; |
133 } |
129 } |
134 |
130 |
135 // ----------------------------------------------------------------------------- |
131 // ----------------------------------------------------------------------------- |
136 // |
132 // |
137 // ----------------------------------------------------------------------------- |
133 // ----------------------------------------------------------------------------- |
138 // |
134 // |
139 LogsMatchesView* LogsComponentRepository::matchesView() |
135 LogsMatchesView* LogsComponentRepository::matchesView(bool onlyInit) |
140 { |
136 { |
141 LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::matchedCallsView()" ); |
137 LOGS_QDEBUG( "logs [UI] -> LogsComponentRepository::matchedCallsView()" ); |
142 setObjectTreeToView( LogsMatchesViewId ); |
|
143 |
138 |
144 if ( !mMatchesView ) { |
139 if ( !mMatchesView ) { |
145 bool ok = false; |
140 mMatchesView = qobject_cast<LogsMatchesView*>(doLoadView( |
146 mMatchesViewComponents = load( logsMatchedCallsViewFile, &ok ); |
141 logsMatchedCallsViewFile, logsMatchesViewId, |
147 if ( ok ) { |
142 mMatchesViewComponents, LogsMatchesViewId, onlyInit)); |
148 mMatchesView = qobject_cast<LogsMatchesView*> |
143 } else if ( !onlyInit ){ |
149 ( findWidget(logsMatchesViewId) ); |
144 setObjectTreeToView( LogsMatchesViewId ); |
150 |
|
151 addToolbarToObjectList(mMatchesViewComponents); |
|
152 } else { |
|
153 LOGS_QCRITICAL( "logs [UI] XML loading failed..." ); |
|
154 } |
|
155 } |
145 } |
156 |
146 |
157 LOGS_QDEBUG( "logs [UI] <- LogsComponentRepository::matchedCallsView()" ); |
147 LOGS_QDEBUG( "logs [UI] <- LogsComponentRepository::matchedCallsView()" ); |
158 return mMatchesView; |
148 return mMatchesView; |
159 } |
149 } |
186 // ----------------------------------------------------------------------------- |
176 // ----------------------------------------------------------------------------- |
187 // |
177 // |
188 void LogsComponentRepository::setObjectTreeToView( LogsAppViewId viewId ) |
178 void LogsComponentRepository::setObjectTreeToView( LogsAppViewId viewId ) |
189 { |
179 { |
190 reset(); |
180 reset(); |
|
181 QObjectList* objTree = 0; |
191 if ( viewId == LogsRecentViewId ) { |
182 if ( viewId == LogsRecentViewId ) { |
192 setObjectTree( mRecentViewComponents ); |
183 objTree = &mRecentViewComponents; |
193 } else if ( viewId == LogsDetailsViewId ) { |
184 } else if ( viewId == LogsDetailsViewId ) { |
194 setObjectTree( mDetailsViewComponents ); |
185 objTree = &mDetailsViewComponents; |
195 } else if ( viewId == LogsMatchesViewId ) { |
186 } else if ( viewId == LogsMatchesViewId ) { |
196 setObjectTree( mMatchesViewComponents ); |
187 objTree = &mMatchesViewComponents; |
|
188 } |
|
189 if ( objTree ){ |
|
190 setObjectTree( *objTree ); |
|
191 mCurrentObjectTree = objTree; |
197 } |
192 } |
198 } |
193 } |
199 |
194 |
200 // ----------------------------------------------------------------------------- |
195 // ----------------------------------------------------------------------------- |
201 // |
196 // |
257 |
252 |
258 LOGS_QDEBUG_2( "logs [UI] -> LogsComponentRepository::loadSection(): ", ok ) |
253 LOGS_QDEBUG_2( "logs [UI] -> LogsComponentRepository::loadSection(): ", ok ) |
259 return ok; |
254 return ok; |
260 } |
255 } |
261 |
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void LogsComponentRepository::lazyInit() |
|
262 { |
|
263 mModel->refreshData(); |
|
264 recentCallsView(true); |
|
265 detailsView(true); |
|
266 matchesView(true); |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 QGraphicsWidget* LogsComponentRepository::doLoadView( |
|
274 const QString &fileName, const QString &viewName, |
|
275 QObjectList& viewComponents, LogsAppViewId viewId, bool onlyInit) |
|
276 { |
|
277 QObjectList* prevObjectTree = mCurrentObjectTree; |
|
278 setObjectTreeToView( viewId ); |
|
279 |
|
280 QGraphicsWidget* view = 0; |
|
281 bool ok = false; |
|
282 viewComponents = load( fileName, &ok ); |
|
283 if ( ok ) { |
|
284 view = findWidget(viewName); |
|
285 addToolbarToObjectList(viewComponents); |
|
286 } else { |
|
287 LOGS_QCRITICAL( "logs [UI] XML loading failed..." ); |
|
288 } |
|
289 |
|
290 if ( onlyInit && prevObjectTree ){ |
|
291 LOGS_QDEBUG( "logs [UI] set back previous object tree" ) |
|
292 mCurrentObjectTree = prevObjectTree; |
|
293 setObjectTree( *mCurrentObjectTree ); |
|
294 } |
|
295 return view; |
|
296 } |