MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / dropEvent

Method dropEvent

ImagePlay/src/IPProcessGridScene.cpp:176–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176void IPProcessGridScene::dropEvent(QGraphicsSceneDragDropEvent *event)
177{
178 const QMimeData* mimeData = event->mimeData();
179 QString processID = event->mimeData()->data("application/x-imageplay");
180
181 // check for our needed mime type, here a file or a list of files
182 if (mimeData->hasUrls())
183 {
184 QList<QUrl> urlList = mimeData->urls();
185 QMimeDatabase db;
186
187 // extract the local paths of the files
188 QPointF offset;
189 for (int i = 0; i < urlList.size() && i < 32; i++)
190 {
191 QString filePath = urlList.at(i).toLocalFile();
192
193 QMimeType type = db.mimeTypeForFile(filePath);
194
195 // automatically load IPJ files
196 if(type.name() == "text/plain" && filePath.endsWith(".ipj"))
197 {
198 MainWindow* mainWindow = ((IPProcessGrid*) parent())->mainWindow();
199 if(mainWindow)
200 {
201 mainWindow->readProcessFile(filePath);
202 }
203
204 return;
205 }
206
207 // automatically add IPLLoadImage for image types
208 if(type.name().startsWith("image/"))
209 {
210 IPProcessStep* newStep = createProcessStep("IPLLoadImage", event->scenePos() + offset);
211 IPLLoadImage* stepLoadImage = dynamic_cast<IPLLoadImage*>(newStep->process());
212
213 if(stepLoadImage)
214 {
215 stepLoadImage->setPath(filePath.toStdString());
216 }
217 }
218
219 // automatically add IPLLoadImageSequence for folders
220 if(type.name() == "inode/directory")
221 {
222 IPProcessStep* newStep = createProcessStep("IPLLoadImageSequence", event->scenePos() + offset);
223 IPLLoadImageSequence* stepLoadImageSequence = dynamic_cast<IPLLoadImageSequence*>(newStep->process());
224
225 if(stepLoadImageSequence)
226 {
227 stepLoadImageSequence->setFolder(filePath.toStdString());
228 }
229 }
230
231 offset += QPointF(0, 50);
232 }
233

Callers

nothing calls this directly

Calls 8

mainWindowMethod · 0.80
readProcessFileMethod · 0.80
setPathMethod · 0.80
setFolderMethod · 0.80
sizeMethod · 0.45
atMethod · 0.45
nameMethod · 0.45
processMethod · 0.45

Tested by

no test coverage detected