Changeset View
Changeset View
Standalone View
Standalone View
shell/mainwindow.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
54 | #include "sourceformattercontroller.h" | 54 | #include "sourceformattercontroller.h" | ||
55 | #include "areadisplay.h" | 55 | #include "areadisplay.h" | ||
56 | #include "project.h" | 56 | #include "project.h" | ||
57 | #include "debug.h" | 57 | #include "debug.h" | ||
58 | #include "uiconfig.h" | 58 | #include "uiconfig.h" | ||
59 | 59 | | |||
60 | #include <interfaces/isession.h> | 60 | #include <interfaces/isession.h> | ||
61 | #include <interfaces/iprojectcontroller.h> | 61 | #include <interfaces/iprojectcontroller.h> | ||
62 | #include <vcs/interfaces/ibasicversioncontrol.h> | ||||
62 | #include <sublime/view.h> | 63 | #include <sublime/view.h> | ||
63 | #include <sublime/document.h> | 64 | #include <sublime/document.h> | ||
64 | #include <sublime/urldocument.h> | 65 | #include <sublime/urldocument.h> | ||
65 | #include <sublime/container.h> | 66 | #include <sublime/container.h> | ||
66 | #include <util/path.h> | 67 | #include <util/path.h> | ||
67 | #include <util/widgetcolorizer.h> | 68 | #include <util/widgetcolorizer.h> | ||
68 | 69 | | |||
69 | using namespace KDevelop; | 70 | using namespace KDevelop; | ||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | 191 | if (element.tagName().toLower() == QLatin1String("separator") | |||
197 | } | 198 | } | ||
198 | } | 199 | } | ||
199 | 200 | | |||
200 | return KXMLGUIBuilder::createCustomElement(parent, index, element); | 201 | return KXMLGUIBuilder::createCustomElement(parent, index, element); | ||
201 | } | 202 | } | ||
202 | 203 | | |||
203 | void MainWindow::dragEnterEvent( QDragEnterEvent* ev ) | 204 | void MainWindow::dragEnterEvent( QDragEnterEvent* ev ) | ||
204 | { | 205 | { | ||
205 | if( ev->mimeData()->hasFormat( QStringLiteral("text/uri-list") ) && ev->mimeData()->hasUrls() ) | 206 | const QMimeData* mimeData = ev->mimeData(); | ||
206 | { | 207 | if (mimeData->hasUrls()) { | ||
208 | ev->acceptProposedAction(); | ||||
209 | } else if (mimeData->hasText()) { | ||||
210 | // also take text which contains a URL | ||||
211 | const QUrl url = QUrl::fromUserInput(mimeData->text()); | ||||
212 | if (url.isValid()) { | ||||
207 | ev->acceptProposedAction(); | 213 | ev->acceptProposedAction(); | ||
208 | } | 214 | } | ||
209 | } | 215 | } | ||
216 | } | ||||
210 | 217 | | |||
211 | void MainWindow::dropEvent( QDropEvent* ev ) | 218 | void MainWindow::dropEvent( QDropEvent* ev ) | ||
212 | { | 219 | { | ||
213 | Sublime::View* dropToView = viewForPosition(mapToGlobal(ev->pos())); | 220 | Sublime::View* dropToView = viewForPosition(mapToGlobal(ev->pos())); | ||
214 | if(dropToView) | 221 | if(dropToView) | ||
215 | activateView(dropToView); | 222 | activateView(dropToView); | ||
216 | 223 | | |||
217 | foreach( const QUrl& u, ev->mimeData()->urls() ) | 224 | QList<QUrl> urls; | ||
218 | { | 225 | | ||
219 | Core::self()->documentController()->openDocument( u ); | 226 | const QMimeData* mimeData = ev->mimeData(); | ||
227 | if (mimeData->hasUrls()) { | ||||
228 | urls = mimeData->urls(); | ||||
229 | } else if (mimeData->hasText()) { | ||||
230 | const QUrl url = QUrl::fromUserInput(mimeData->text()); | ||||
231 | if (url.isValid()) { | ||||
232 | urls << url; | ||||
233 | } | ||||
234 | } | ||||
235 | | ||||
236 | bool eventUsed = false; | ||||
237 | if (urls.size() == 1) { | ||||
238 | const QUrl& url = urls.at(0); | ||||
239 | // TODO: query also projectprovider plugins, and that before plain vcs plugins | ||||
mwolff: ? please extend this comment, no clue what you mean | |||||
240 | // e.g. KDE provider plugin could catch URLs from mirror or pickup kde:repo things | ||||
241 | | ||||
mwolff: auto* | |||||
242 | auto* pluginController = Core::self()->pluginController(); | ||||
mwolff: const auto& | |||||
243 | const auto& plugins = pluginController->allPluginsForExtension(QStringLiteral("org.kdevelop.IBasicVersionControl")); | ||||
244 | | ||||
mwolff: don't use foreach in new code, use `for (auto* plugin : plugins) {` | |||||
245 | for (auto* plugin : plugins) { | ||||
mwolff: auto | |||||
246 | auto* iface = plugin->extension<IBasicVersionControl>(); | ||||
247 | if (iface->isValidRemoteRepositoryUrl(url)) { | ||||
248 | Core::self()->projectControllerInternal()->fetchProjectFromUrl(url, plugin); | ||||
249 | eventUsed = true; | ||||
250 | break; | ||||
251 | } | ||||
252 | } | ||||
220 | } | 253 | } | ||
254 | | ||||
255 | if (!eventUsed) { | ||||
mwolff: dito | |||||
256 | for(const auto& url : urls) { | ||||
257 | Core::self()->documentController()->openDocument(url); | ||||
258 | } | ||||
259 | } | ||||
260 | | ||||
221 | ev->acceptProposedAction(); | 261 | ev->acceptProposedAction(); | ||
222 | } | 262 | } | ||
223 | 263 | | |||
224 | void MainWindow::loadSettings() | 264 | void MainWindow::loadSettings() | ||
225 | { | 265 | { | ||
226 | qCDebug(SHELL) << "Loading Settings"; | 266 | qCDebug(SHELL) << "Loading Settings"; | ||
227 | initializeCorners(); | 267 | initializeCorners(); | ||
228 | 268 | | |||
▲ Show 20 Lines • Show All 245 Lines • Show Last 20 Lines |
? please extend this comment, no clue what you mean