| 2187 | } |
| 2188 | |
| 2189 | void MainWindow::dropEvent(QDropEvent *event) |
| 2190 | { |
| 2191 | qInfo(Q_FUNC_INFO); |
| 2192 | |
| 2193 | if (event->mimeData()->hasUrls()) { |
| 2194 | // Get the urls into a stringlist |
| 2195 | QStringList fileNames; |
| 2196 | for (const QUrl &url : event->mimeData()->urls()) { |
| 2197 | if (url.isLocalFile()) { |
| 2198 | QFileInfo info(url.toLocalFile()); |
| 2199 | |
| 2200 | if (info.exists()) { |
| 2201 | if (info.isDir()) { |
| 2202 | QDirIterator it(url.toLocalFile(), QDir::Files, QDirIterator::FollowSymlinks| QDirIterator::Subdirectories); |
| 2203 | while (it.hasNext()) { |
| 2204 | fileNames << it.next(); |
| 2205 | } |
| 2206 | } |
| 2207 | else { |
| 2208 | fileNames.append(url.toLocalFile()); |
| 2209 | } |
| 2210 | } |
| 2211 | } |
| 2212 | } |
| 2213 | |
| 2214 | openFileList(fileNames); |
| 2215 | bringWindowToForeground(); |
| 2216 | event->acceptProposedAction(); |
| 2217 | } |
| 2218 | else if (event->mimeData()->hasText()) { |
| 2219 | if (event->source()) { |
| 2220 | // if it is from an editor, remove the text |
| 2221 | ScintillaNext *sn = qobject_cast<ScintillaNext *>(event->source()); |
| 2222 | if (sn) { |
| 2223 | sn->replaceSel(""); |
| 2224 | } |
| 2225 | } |
| 2226 | |
| 2227 | newFile(); |
| 2228 | currentEditor()->setText(event->mimeData()->text().toLocal8Bit().constData()); |
| 2229 | bringWindowToForeground(); |
| 2230 | event->acceptProposedAction(); |
| 2231 | } |
| 2232 | else { |
| 2233 | event->ignore(); |
| 2234 | } |
| 2235 | } |
| 2236 | |
| 2237 | QMenu *MainWindow::buildMenu(QStringList actionNames) |
| 2238 | { |