| 174 | } |
| 175 | |
| 176 | void 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 |
nothing calls this directly
no test coverage detected