diff options
| author | 2016-06-13 18:42:42 -0400 | |
|---|---|---|
| committer | 2016-06-13 18:42:42 -0400 | |
| commit | 5d9314f134ddd3dc4c853e398ac90ba247fb2e4f (patch) | |
| tree | 5c457fc188036988d7abd29a3eb09931e406510f /SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp | |
| parent | 8e640722c62692818ab840d50b3758f89a41a54e (diff) | |
Imported Upstream version 3.1.0upstream/3.1.0
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
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 <QMimeData> #include <QDebug> #include <QFile> @@ -1040,7 +1041,10 @@ bool DbTreeModel::dropDbTreeItem(const QList<DbTreeItem*>& 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<QUrl>& urls) { + QString filePath; + bool autoTest = false; for (const QUrl& url : urls) { if (!url.isLocalFile()) @@ -1143,13 +1149,41 @@ bool DbTreeModel::dropUrls(const QList<QUrl>& 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<QString,QVariant> opts; + opts[DB_PLUGIN] = plugin->getName(); + return DBLIST->addDb(name, filePath, opts, !CFG_UI.General.NewDbNotPermanentByDefault.get()); +} + void DbTreeModel::moveOrCopyDbObjects(const QList<DbTreeItem*>& srcItems, DbTreeItem* dstItem, bool move, bool includeData, bool includeIndexes, bool includeTriggers) { if (srcItems.size() == 0) |
