--- a/ui/commandhandlers/commoncommandhandlers/src/glxcommandhandlereditimage.cpp Fri Jul 23 20:41:04 2010 +0530
+++ b/ui/commandhandlers/commoncommandhandlers/src/glxcommandhandlereditimage.cpp Fri Aug 06 20:44:25 2010 +0530
@@ -32,7 +32,8 @@
#include <XQServiceRequest.h>
#include <XQAiwRequest.h>
-GlxCommandHandlerEditImage::GlxCommandHandlerEditImage() : mReq(NULL)
+GlxCommandHandlerEditImage::GlxCommandHandlerEditImage() :
+ mReq(NULL), mMediaModel(NULL)
{
//Nothing to do here
}
@@ -41,9 +42,11 @@
{
delete mReq;
mReq = NULL;
+ clearMediaModel();
}
-void GlxCommandHandlerEditImage::executeCommand(int commandId,int collectionId, QList<QModelIndex> /*indexList*/)
+void GlxCommandHandlerEditImage::executeCommand(int commandId,
+ int collectionId, QList<QModelIndex> /*indexList*/)
{
const QString service = QLatin1String("PhotoEditor");
const QString interface = QLatin1String("com.nokia.symbian.imageeditor");
@@ -54,29 +57,42 @@
{
mReq = mAppmgr.create(service, interface, operation, true);
mReq->setEmbedded(true);
- mReq->setSynchronous(true);
+ mReq->setSynchronous(false);
}
if(mReq == NULL)
{
return;
+ }
+
+ connect(mReq, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&)));
+ connect(mReq, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&)));
+
+ GlxModelParm modelParm(collectionId, 0);
+ clearMediaModel();
+ mMediaModel = new GlxMediaModel(modelParm);
+ if (!mMediaModel)
+ {
+ return;
}
- GlxModelParm modelParm (collectionId, 0);
- GlxMediaModel* mediaModel = new GlxMediaModel (modelParm);
-
+ connect( mMediaModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( storeItems( QModelIndex, int, int ) ) );
+
//Get the file path for the item selected
- QString imagePath = (mediaModel->data(mediaModel->index(mediaModel->data(mediaModel->index(0,0),GlxFocusIndexRole).value<int>(),0),GlxUriRole)).value<QString>();
- delete mediaModel;
-
+ QString imagePath = (mMediaModel->data(
+ mMediaModel->index(mMediaModel->data(mMediaModel->index(0, 0),
+ GlxFocusIndexRole).value<int> (), 0), GlxUriRole)).value<
+ QString> ();
+ //delete mediaModel;
+
QList<QVariant> args;
args << imagePath;
#ifdef FF_IMAGE_EDITOR
- if(EGlxCmdSetWallpaper == commandId)
- {
- args << EEditorHighwayWallpaperCrop;
- }
- else if(EGlxCmdRotateImgCrop == commandId)
+ if(EGlxCmdSetWallpaper == commandId)
+ {
+ args << EEditorHighwayWallpaperCrop;
+ }
+ else if(EGlxCmdRotateImgCrop == commandId)
{
args << EEditorHighwayFreeCrop;
}
@@ -85,22 +101,56 @@
args << EEditorHighwayRotateCW;
}
else // if(EGlxCmdRotateImgCCW == aCommandId)
+
{
args << EEditorHighwayRotateCCW;
}
mReq->setArguments(args);
#endif //FF_IMAGE_EDITOR
-
// Send the request
bool res = mReq->send();
- if (!res)
+ if (!res)
{
- // Request failed.
- qDebug("QtSamplePhotos::launchPhotoEditor request cannot be send");
+ // Request failed.
}
}
-void GlxCommandHandlerEditImage::doHandleUserAction(GlxMediaModel* /*model*/,QList<QModelIndex> /*indexList*/) const
+void GlxCommandHandlerEditImage::doHandleUserAction(GlxMediaModel* /*model*/,
+ QList<QModelIndex> /*indexList*/) const
+ {
+ //Dummy, to keepup with compiler error
+ }
+
+void GlxCommandHandlerEditImage::handleOk(const QVariant& result)
+ {
+ //Nothing to do for - Needs further implementation to refine setting
+ //default image in fullscreen view
+ }
+
+void GlxCommandHandlerEditImage::handleError(int errorCode,
+ const QString& errorMessage)
{
- //Dummy, to keepup with compiler errore
+ clearMediaModel();
}
+
+void GlxCommandHandlerEditImage::storeItems(const QModelIndex &parent,
+ int aStartRow, int aEndRow)
+ {
+ //This implementation assumes that we will be getting only one new
+ //image creation notification. Needs refined implementation
+ if (mMediaModel)
+ {
+ QModelIndex modelIndex = mMediaModel->index(aStartRow, 0);
+ mMediaModel->setData(modelIndex, modelIndex.row(), GlxFocusIndexRole);
+ }
+ }
+
+void GlxCommandHandlerEditImage::clearMediaModel()
+ {
+ if (mMediaModel)
+ {
+ disconnect(mMediaModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(storeItems(QModelIndex,int,int)));
+ delete mMediaModel;
+ mMediaModel = NULL;
+ }
+ }