30 #include <glxmodelparm.h> |
30 #include <glxmodelparm.h> |
31 #include <glxmediamodel.h> |
31 #include <glxmediamodel.h> |
32 #include <XQServiceRequest.h> |
32 #include <XQServiceRequest.h> |
33 #include <XQAiwRequest.h> |
33 #include <XQAiwRequest.h> |
34 |
34 |
35 GlxCommandHandlerEditImage::GlxCommandHandlerEditImage() : mReq(NULL) |
35 GlxCommandHandlerEditImage::GlxCommandHandlerEditImage() : |
|
36 mReq(NULL), mMediaModel(NULL) |
36 { |
37 { |
37 //Nothing to do here |
38 //Nothing to do here |
38 } |
39 } |
39 |
40 |
40 GlxCommandHandlerEditImage::~GlxCommandHandlerEditImage() |
41 GlxCommandHandlerEditImage::~GlxCommandHandlerEditImage() |
41 { |
42 { |
42 delete mReq; |
43 delete mReq; |
43 mReq = NULL; |
44 mReq = NULL; |
|
45 clearMediaModel(); |
44 } |
46 } |
45 |
47 |
46 void GlxCommandHandlerEditImage::executeCommand(int commandId,int collectionId, QList<QModelIndex> /*indexList*/) |
48 void GlxCommandHandlerEditImage::executeCommand(int commandId, |
|
49 int collectionId, QList<QModelIndex> /*indexList*/) |
47 { |
50 { |
48 const QString service = QLatin1String("PhotoEditor"); |
51 const QString service = QLatin1String("PhotoEditor"); |
49 const QString interface = QLatin1String("com.nokia.symbian.imageeditor"); |
52 const QString interface = QLatin1String("com.nokia.symbian.imageeditor"); |
50 const QString operation = QLatin1String("view(QString,int)"); |
53 const QString operation = QLatin1String("view(QString,int)"); |
51 |
54 |
52 //Connect to service provider |
55 //Connect to service provider |
53 if(mReq == NULL) |
56 if(mReq == NULL) |
54 { |
57 { |
55 mReq = mAppmgr.create(service, interface, operation, true); |
58 mReq = mAppmgr.create(service, interface, operation, true); |
56 mReq->setEmbedded(true); |
59 mReq->setEmbedded(true); |
57 mReq->setSynchronous(true); |
60 mReq->setSynchronous(false); |
58 } |
61 } |
59 |
62 |
60 if(mReq == NULL) |
63 if(mReq == NULL) |
61 { |
64 { |
62 return; |
65 return; |
|
66 } |
|
67 |
|
68 connect(mReq, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
|
69 connect(mReq, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&))); |
|
70 |
|
71 GlxModelParm modelParm(collectionId, 0); |
|
72 clearMediaModel(); |
|
73 mMediaModel = new GlxMediaModel(modelParm); |
|
74 if (!mMediaModel) |
|
75 { |
|
76 return; |
63 } |
77 } |
64 |
78 |
65 GlxModelParm modelParm (collectionId, 0); |
79 connect( mMediaModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( storeItems( QModelIndex, int, int ) ) ); |
66 GlxMediaModel* mediaModel = new GlxMediaModel (modelParm); |
80 |
67 |
|
68 //Get the file path for the item selected |
81 //Get the file path for the item selected |
69 QString imagePath = (mediaModel->data(mediaModel->index(mediaModel->data(mediaModel->index(0,0),GlxFocusIndexRole).value<int>(),0),GlxUriRole)).value<QString>(); |
82 QString imagePath = (mMediaModel->data( |
70 delete mediaModel; |
83 mMediaModel->index(mMediaModel->data(mMediaModel->index(0, 0), |
71 |
84 GlxFocusIndexRole).value<int> (), 0), GlxUriRole)).value< |
|
85 QString> (); |
|
86 //delete mediaModel; |
|
87 |
72 QList<QVariant> args; |
88 QList<QVariant> args; |
73 args << imagePath; |
89 args << imagePath; |
74 #ifdef FF_IMAGE_EDITOR |
90 #ifdef FF_IMAGE_EDITOR |
75 if(EGlxCmdSetWallpaper == commandId) |
91 if(EGlxCmdSetWallpaper == commandId) |
76 { |
92 { |
77 args << EEditorHighwayWallpaperCrop; |
93 args << EEditorHighwayWallpaperCrop; |
78 } |
94 } |
79 else if(EGlxCmdRotateImgCrop == commandId) |
95 else if(EGlxCmdRotateImgCrop == commandId) |
80 { |
96 { |
81 args << EEditorHighwayFreeCrop; |
97 args << EEditorHighwayFreeCrop; |
82 } |
98 } |
83 else if(EGlxCmdRotateImgCW == commandId) |
99 else if(EGlxCmdRotateImgCW == commandId) |
84 { |
100 { |
85 args << EEditorHighwayRotateCW; |
101 args << EEditorHighwayRotateCW; |
86 } |
102 } |
87 else // if(EGlxCmdRotateImgCCW == aCommandId) |
103 else // if(EGlxCmdRotateImgCCW == aCommandId) |
|
104 |
88 { |
105 { |
89 args << EEditorHighwayRotateCCW; |
106 args << EEditorHighwayRotateCCW; |
90 } |
107 } |
91 mReq->setArguments(args); |
108 mReq->setArguments(args); |
92 #endif //FF_IMAGE_EDITOR |
109 #endif //FF_IMAGE_EDITOR |
93 |
|
94 // Send the request |
110 // Send the request |
95 bool res = mReq->send(); |
111 bool res = mReq->send(); |
96 if (!res) |
112 if (!res) |
97 { |
113 { |
98 // Request failed. |
114 // Request failed. |
99 qDebug("QtSamplePhotos::launchPhotoEditor request cannot be send"); |
|
100 } |
115 } |
101 } |
116 } |
102 |
117 |
103 void GlxCommandHandlerEditImage::doHandleUserAction(GlxMediaModel* /*model*/,QList<QModelIndex> /*indexList*/) const |
118 void GlxCommandHandlerEditImage::doHandleUserAction(GlxMediaModel* /*model*/, |
|
119 QList<QModelIndex> /*indexList*/) const |
104 { |
120 { |
105 //Dummy, to keepup with compiler errore |
121 //Dummy, to keepup with compiler error |
106 } |
122 } |
|
123 |
|
124 void GlxCommandHandlerEditImage::handleOk(const QVariant& result) |
|
125 { |
|
126 //Nothing to do for - Needs further implementation to refine setting |
|
127 //default image in fullscreen view |
|
128 } |
|
129 |
|
130 void GlxCommandHandlerEditImage::handleError(int errorCode, |
|
131 const QString& errorMessage) |
|
132 { |
|
133 clearMediaModel(); |
|
134 } |
|
135 |
|
136 void GlxCommandHandlerEditImage::storeItems(const QModelIndex &parent, |
|
137 int aStartRow, int aEndRow) |
|
138 { |
|
139 //This implementation assumes that we will be getting only one new |
|
140 //image creation notification. Needs refined implementation |
|
141 if (mMediaModel) |
|
142 { |
|
143 QModelIndex modelIndex = mMediaModel->index(aStartRow, 0); |
|
144 mMediaModel->setData(modelIndex, modelIndex.row(), GlxFocusIndexRole); |
|
145 } |
|
146 } |
|
147 |
|
148 void GlxCommandHandlerEditImage::clearMediaModel() |
|
149 { |
|
150 if (mMediaModel) |
|
151 { |
|
152 disconnect(mMediaModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(storeItems(QModelIndex,int,int))); |
|
153 delete mMediaModel; |
|
154 mMediaModel = NULL; |
|
155 } |
|
156 } |