forked from qt-creator/qt-creator
Introduce dragging for all explorer nodes.
Extend drop support with variant values. A drop may be a file drop or a value drop or both. Rename Utils::FileDropSupport to Utils::DropSupport and add methods to add not only files but any QVariant value to the mime data. Project explorer adds dragged nodes (which will be needed for future ModelEditor plugin). Change-Id: I799542c60fdecb3e64af0d3ba47b6caa9adbcfd7 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -207,10 +207,10 @@ MainWindow::MainWindow() :
|
||||
|
||||
statusBar()->setProperty("p_styled", true);
|
||||
|
||||
auto dropSupport = new FileDropSupport(this, [](QDropEvent *event) {
|
||||
auto dropSupport = new DropSupport(this, [](QDropEvent *event, DropSupport *) {
|
||||
return event->source() == 0; // only accept drops from the "outside" (e.g. file manager)
|
||||
});
|
||||
connect(dropSupport, &FileDropSupport::filesDropped,
|
||||
connect(dropSupport, &DropSupport::filesDropped,
|
||||
this, &MainWindow::openDroppedFiles);
|
||||
}
|
||||
|
||||
@@ -371,11 +371,11 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void MainWindow::openDroppedFiles(const QList<FileDropSupport::FileSpec> &files)
|
||||
void MainWindow::openDroppedFiles(const QList<DropSupport::FileSpec> &files)
|
||||
{
|
||||
raiseWindow();
|
||||
QStringList filePaths = Utils::transform(files,
|
||||
[](const FileDropSupport::FileSpec &spec) -> QString {
|
||||
[](const DropSupport::FileSpec &spec) -> QString {
|
||||
return spec.filePath;
|
||||
});
|
||||
openFiles(filePaths, ICore::SwitchMode);
|
||||
|
||||
Reference in New Issue
Block a user