From 5d9314f134ddd3dc4c853e398ac90ba247fb2e4f Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Mon, 13 Jun 2016 18:42:42 -0400 Subject: Imported Upstream version 3.1.0 --- .../guiSQLiteStudio/dbtree/dbtreemodel.cpp | 36 +++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp') diff --git a/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp index c0f527f..c11221d 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp @@ -13,6 +13,7 @@ #include "dialogs/errorsconfirmdialog.h" #include "dialogs/versionconvertsummarydialog.h" #include "db/invaliddb.h" +#include "services/notifymanager.h" #include #include #include @@ -1040,7 +1041,10 @@ bool DbTreeModel::dropDbTreeItem(const QList& srcItems, DbTreeItem* return false; if (srcItem->getDb() == dstItem->getDb()) + { + invokeStdDropAction = true; return true; + } return dropDbObjectItem(srcItems, dstItem, defaultAction); } @@ -1135,6 +1139,8 @@ QCheckBox* DbTreeModel::createCopyOrMoveMenuCheckBox(QMenu* menu, const QString& bool DbTreeModel::dropUrls(const QList& urls) { + QString filePath; + bool autoTest = false; for (const QUrl& url : urls) { if (!url.isLocalFile()) @@ -1143,13 +1149,41 @@ bool DbTreeModel::dropUrls(const QList& urls) continue; } + autoTest = false; + filePath = url.toLocalFile(); + if (CFG_UI.General.BypassDbDialogWhenDropped.get()) + { + if (quickAddDroppedDb(filePath)) + { + continue; + } + else + { + notifyWarn(tr("Could not add dropped database file '%1' automatically. Manual setup is necessary.").arg(filePath)); + autoTest = true; + } + } + DbDialog dialog(DbDialog::ADD, MAINWINDOW); - dialog.setPath(url.toLocalFile()); + dialog.setPath(filePath); + dialog.setDoAutoTest(autoTest); dialog.exec(); } return false; } +bool DbTreeModel::quickAddDroppedDb(const QString& filePath) +{ + DbPlugin* plugin = DBLIST->getPluginForDbFile(filePath); + if (!plugin) + return false; + + QString name = DBLIST->generateUniqueDbName(plugin, filePath); + QHash opts; + opts[DB_PLUGIN] = plugin->getName(); + return DBLIST->addDb(name, filePath, opts, !CFG_UI.General.NewDbNotPermanentByDefault.get()); +} + void DbTreeModel::moveOrCopyDbObjects(const QList& srcItems, DbTreeItem* dstItem, bool move, bool includeData, bool includeIndexes, bool includeTriggers) { if (srcItems.size() == 0) -- cgit v1.2.3