17 |
17 |
18 #include <hbapplication.h> |
18 #include <hbapplication.h> |
19 #include <hbview.h> |
19 #include <hbview.h> |
20 #include <hbmenu.h> |
20 #include <hbmenu.h> |
21 #include <hbaction.h> |
21 #include <hbaction.h> |
22 #include <hbtoolbar.h> |
|
23 #include <hbstyleloader.h> |
|
24 #include <hbnotificationdialog.h> |
22 #include <hbnotificationdialog.h> |
25 |
23 |
26 #include <QtDebug> |
24 #include <QtDebug> |
27 #include <Qt> |
25 #include <Qt> |
28 #include <QDir> |
26 #include <QDir> |
29 #include <QStringList> |
27 #include <QStringList> |
30 |
28 |
31 #include <glxmediamodel.h> |
29 #include <xqserviceutil.h> |
32 #include <glxviewsfactory.h> |
30 #include <xqaiwdeclplat.h> |
33 #include <glxviewids.h> |
31 #include <xqappmgr.h> |
34 #include <glxview.h> |
32 |
35 #include <glxgridview.h> |
33 #include <glxmodelroles.h> |
36 #include <glxmodelparm.h> |
|
37 #include <glxaiwservicehandler.h> |
34 #include <glxaiwservicehandler.h> |
38 #include <glxcollectionpluginall.hrh> |
|
39 #include <glxcollectionpluginimageviewer.hrh> |
|
40 #include <xqserviceutil.h> |
|
41 #include <glxstatemanager.h> |
35 #include <glxstatemanager.h> |
42 #include <glximageviewermanager.h> |
36 #include <glximageviewermanager.h> |
43 #include <glxexternalutility.h> |
37 #include <glxexternalutility.h> |
44 #include "glxlocalisationstrings.h" |
38 #include "glxlocalisationstrings.h" |
45 #include <xqaiwdeclplat.h> |
|
46 #include <xqappmgr.h> |
|
47 |
39 |
48 #define IMAGE_FETCHER_SERVICE_NAME QLatin1String("photos.com.nokia.symbian.IImageFetch") |
40 #define IMAGE_FETCHER_SERVICE_NAME QLatin1String("photos.com.nokia.symbian.IImageFetch") |
49 #define IMAGE_FETCHER_SERVICE_DEPINTERFACE_NAME QLatin1String("photos.Image") |
41 #define IMAGE_FETCHER_SERVICE_DEPINTERFACE_NAME QLatin1String("photos.Image") |
50 #define IMAGE_FETCHER_DEPSERVICE_DEPINTERFACE_NAME QLatin1String("com.nokia.services.media.Image") |
42 #define IMAGE_FETCHER_DEPSERVICE_DEPINTERFACE_NAME QLatin1String("com.nokia.services.media.Image") |
51 #define FILE_VIEWER_SERVICE_NAME QLatin1String("photos.com.nokia.symbian.IFileView") |
43 #define FILE_VIEWER_SERVICE_NAME QLatin1String("photos.com.nokia.symbian.IFileView") |
124 |
104 |
125 // ---------------------------------------------------------------------------- |
105 // ---------------------------------------------------------------------------- |
126 // itemSelected() |
106 // itemSelected() |
127 // ---------------------------------------------------------------------------- |
107 // ---------------------------------------------------------------------------- |
128 // |
108 // |
129 void GlxAiwServiceHandler::itemSelected(const QModelIndex & index) |
109 void GlxAiwServiceHandler::itemSelected(const QModelIndex & index,QAbstractItemModel & model) |
130 { |
110 { |
131 qDebug() << "GlxFetcher::itemSelected"; |
111 qDebug() << "GlxFetcher::itemSelected"; |
132 |
|
133 if (mFetcherService && mFetcherService->isActive()) |
112 if (mFetcherService && mFetcherService->isActive()) |
134 { |
113 { |
135 qDebug() << "GlxFetcher::itemSelected mFetcherService->isActive()"; |
114 qDebug() << "GlxFetcher::itemSelected mFetcherService->isActive()"; |
136 QVariant variant = mModel->data(index, GlxUriRole); |
115 QVariant variant = model.data(index, GlxUriRole); |
137 if (variant.isValid()) |
116 if (variant.isValid()) |
138 { |
117 { |
139 QString itemPath = variant.value<QString> (); |
118 QString itemPath = variant.value<QString> (); |
|
119 qDebug() << "GlxFetcher::itemSelected mFetcherService->isActive()::PATH = " << itemPath; |
140 QStringList list = (QStringList() << itemPath); |
120 QStringList list = (QStringList() << itemPath); |
141 mFetcherService->complete(list); |
121 mFetcherService->complete(list); |
142 } |
122 } |
143 } |
123 } |
144 |
124 |
145 else if (mNSDIService && mNSDIService->isActive()) |
125 else if (mNSDIService && mNSDIService->isActive()) |
146 { |
126 { |
147 qDebug() << "GlxFetcher::itemSelected mNSDIService->isActive()"; |
127 qDebug() << "GlxFetcher::itemSelected mNSDIService->isActive()"; |
148 QVariant variant = mModel->data(index, GlxUriRole); |
128 QVariant variant = model.data(index, GlxUriRole); |
149 if (variant.isValid()) |
129 if (variant.isValid()) |
150 { |
130 { |
151 QString itemPath = variant.value<QString> (); |
131 QString itemPath = variant.value<QString> (); |
152 QStringList list = (QStringList() << itemPath); |
132 QStringList list = (QStringList() << itemPath); |
153 mNSDIService->complete(list); |
133 mNSDIService->complete(list); |
155 } |
135 } |
156 |
136 |
157 else if (mDSDIService && mDSDIService->isActive()) |
137 else if (mDSDIService && mDSDIService->isActive()) |
158 { |
138 { |
159 qDebug() << "GlxFetcher::itemSelected mDSDIService->isActive()"; |
139 qDebug() << "GlxFetcher::itemSelected mDSDIService->isActive()"; |
160 QVariant variant = mModel->data(index, GlxUriRole); |
140 QVariant variant = model.data(index, GlxUriRole); |
161 if (variant.isValid()) |
141 if (variant.isValid()) |
162 { |
142 { |
163 QString itemPath = variant.value<QString> (); |
143 QString itemPath = variant.value<QString> (); |
164 QStringList list = (QStringList() << itemPath); |
144 QStringList list = (QStringList() << itemPath); |
165 mDSDIService->complete(list); |
145 mDSDIService->complete(list); |
166 } |
146 } |
167 } |
147 } |
168 } |
148 } |
169 |
149 |
170 |
150 |
171 |
|
172 void GlxAiwServiceHandler::launchFetcher(QString viewTitle) |
151 void GlxAiwServiceHandler::launchFetcher(QString viewTitle) |
173 { |
152 { |
174 qDebug() << "GlxAiwServiceHandler::launchFetcher START"; |
153 qDebug() << "GlxAiwServiceHandler::launchFetcher START"; |
175 qApp->setApplicationName(viewTitle); |
154 qApp->setApplicationName(viewTitle); |
176 HbStyleLoader::registerFilePath(":/data/photos.css"); |
155 |
177 GlxModelParm modelParm(KGlxCollectionPluginAllImplementationUid, 0); |
156 mUtil = GlxExternalUtility::instance(); |
178 mModel = new GlxMediaModel(modelParm); |
157 mUtil->setMainWindow(this); |
179 |
158 |
180 if ( this->orientation() == Qt::Horizontal ) { |
159 mStateMgr = new GlxStateManager(); |
181 mModel->setData(QModelIndex(), (int)GlxContextLsGrid, GlxContextRole ); |
160 int err = connect(mStateMgr, SIGNAL(gridItemSelected(const QModelIndex &,QAbstractItemModel &)), this, |
182 } |
161 SLOT( itemSelected(const QModelIndex &,QAbstractItemModel &))); |
183 else { |
162 qDebug() << "GlxAiwServiceHandler::launchFetcher err = "<< err; |
184 mModel->setData(QModelIndex(), (int)GlxContextPtGrid, GlxContextRole ); |
|
185 } |
|
186 |
|
187 mView = GlxViewsFactory::createView(GLX_GRIDVIEW_ID, this); |
|
188 mView->activate(); |
|
189 mView->setModel(mModel); |
|
190 addView(mView); |
|
191 connect(mView, SIGNAL(gridItemSelected(const QModelIndex &)), this, |
|
192 SLOT( itemSelected(const QModelIndex &))); |
|
193 |
|
194 connect ( mView, SIGNAL(itemSpecificMenuTriggered(qint32,QPointF ) ), |
|
195 this, SLOT( itemSpecificMenuTriggered(qint32,QPointF ) ), |
|
196 Qt::QueuedConnection ); |
|
197 qDebug() << "GlxAiwServiceHandler::launchFetcher END"; |
|
198 } |
|
199 |
|
200 void GlxAiwServiceHandler::itemSpecificMenuTriggered(qint32 viewId,QPointF pos) |
|
201 { |
|
202 mFetcherContextMenu = new HbMenu(); |
|
203 HbAction *action = mFetcherContextMenu->addAction(GLX_MENU_OPEN); |
|
204 action->setObjectName( "Menu Open" ); |
|
205 connect(action, SIGNAL(triggered()), this, SLOT(openFSView())); |
|
206 connect(this, SIGNAL(aboutToChangeOrientation ()), mFetcherContextMenu, SLOT(close())); |
|
207 connect( mFetcherContextMenu, SIGNAL( aboutToClose () ), this, SLOT( closeContextMenu() ) ); |
|
208 mFetcherContextMenu->setPreferredPos( pos ); |
|
209 mFetcherContextMenu->show(); |
|
210 } |
|
211 |
|
212 void GlxAiwServiceHandler::closeContextMenu() |
|
213 { |
|
214 disconnect( this, SIGNAL( aboutToChangeOrientation () ), mFetcherContextMenu, SLOT( close() ) ); |
|
215 disconnect( mFetcherContextMenu, SIGNAL( aboutToClose () ), this, SLOT( closeContextMenu() ) ); |
|
216 mFetcherContextMenu->deleteLater(); |
|
217 mFetcherContextMenu = NULL; |
|
218 } |
|
219 |
163 |
220 void GlxAiwServiceHandler::openFSView() |
164 mStateMgr->launchFetcher(); |
221 { |
165 return; |
222 if ( this->orientation() == Qt::Horizontal ) { |
166 } |
223 mModel->setData(QModelIndex(), (int)GlxContextLsFs, GlxContextRole ); |
167 |
224 } |
168 void GlxAiwServiceHandler::launchImageViewer(QString viewTitle) |
225 else { |
169 { |
226 mModel->setData(QModelIndex(), (int)GlxContextPtFs, GlxContextRole ); |
170 qApp->setApplicationName(viewTitle); |
227 } |
171 mUtil = GlxExternalUtility::instance(); |
228 HbAction* selectAction = new HbAction(GLX_BUTTON_SELECT); |
172 mUtil->setMainWindow(this); |
229 selectAction->setObjectName( "FS Select" ); |
173 |
230 |
|
231 connect(selectAction, SIGNAL(triggered()), this, SLOT(handleFSSelect())); |
|
232 HbToolBar* toolBar = new HbToolBar(); |
|
233 toolBar->setOrientation( Qt::Horizontal ); |
|
234 toolBar->setVisible(true); |
|
235 toolBar->addAction(selectAction); |
|
236 |
|
237 mModel->setData( QModelIndex(), FETCHER_S, GlxSubStateRole ); |
|
238 mFSView = GlxViewsFactory::createView(GLX_FULLSCREENVIEW_ID, this); |
|
239 //ownership transfered to view |
|
240 mFSView->setToolBar(toolBar); |
|
241 mView->deActivate(); |
|
242 mFSView->activate(); |
|
243 mFSView->setModel(mModel); |
|
244 addView(mFSView); |
|
245 setCurrentView(mFSView,false); |
|
246 } |
|
247 |
|
248 |
|
249 void GlxAiwServiceHandler::handleFSSelect() |
|
250 { |
|
251 QModelIndex selectedIndex = mModel->index(mModel->data(mModel->index(0,0),GlxFocusIndexRole).value<int>(),0); |
|
252 itemSelected(selectedIndex); |
|
253 } |
|
254 |
|
255 void GlxAiwServiceHandler::launchImageViewer() |
|
256 { |
|
257 qApp->setApplicationName("Image Viewer"); |
|
258 GlxExternalUtility* util = GlxExternalUtility::instance(); |
|
259 util->setMainWindow(this); |
|
260 delete mStateMgr; |
|
261 mStateMgr = NULL; |
|
262 mStateMgr = new GlxStateManager(); |
174 mStateMgr = new GlxStateManager(); |
263 mStateMgr->launchFromExternal(); |
175 mStateMgr->launchFromExternal(); |
264 if (mImageViewerService && mImageViewerService->asyncRequest()) |
176 if (mImageViewerService && mImageViewerService->asyncRequest()) |
265 { |
177 { |
266 connect(mImageViewerService, SIGNAL(returnValueDelivered()), this, |
178 connect(mImageViewerService, SIGNAL(returnValueDelivered()), this, |