diff options
| author | 2015-04-04 14:41:04 -0400 | |
|---|---|---|
| committer | 2015-04-04 14:41:04 -0400 | |
| commit | a5b034d4a9c44f9bc1e83b01de82530f8fc63013 (patch) | |
| tree | 7a358206c4aff9c33df1752c92eafec97cee2244 /SQLiteStudio3/guiSQLiteStudio/dialogs | |
| parent | 306d6d3ca9c9ad774d19135681a7f9805f77035f (diff) | |
Imported Upstream version 3.0.4upstream/3.0.4
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/dialogs')
11 files changed, 310 insertions, 230 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/columndialog.ui b/SQLiteStudio3/guiSQLiteStudio/dialogs/columndialog.ui index 2133aca..1ac6cbb 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/columndialog.ui +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/columndialog.ui @@ -31,6 +31,9 @@ <height>0</height> </size> </property> + <property name="toolTip"> + <string>Scale</string> + </property> </widget> </item> <item row="1" column="3"> @@ -48,6 +51,9 @@ <height>0</height> </size> </property> + <property name="toolTip"> + <string>Precision</string> + </property> </widget> </item> <item row="0" column="1"> diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/configdialog.cpp b/SQLiteStudio3/guiSQLiteStudio/dialogs/configdialog.cpp index b22ee6e..1ff053f 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/configdialog.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/configdialog.cpp @@ -1238,7 +1238,7 @@ void ConfigDialog::initPluginsPage() builtIn = PLUGINS->isBuiltIn(pluginName);
title = PLUGINS->getTitle(pluginName);
if (builtIn)
- title += tr("%1 (built-in)", "plugins manager in configuration dialog").arg(title);
+ title = tr("%1 (built-in)", "plugins manager in configuration dialog").arg(title);
item = new QTreeWidgetItem({title});
item->setCheckState(0, PLUGINS->isLoaded(pluginName) ? Qt::Checked : Qt::Unchecked);
diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp b/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp index a2a9c36..05d50af 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp @@ -15,6 +15,7 @@ #include <QPushButton> #include <QFileDialog> #include <QComboBox> +#include <QTimer> DbDialog::DbDialog(Mode mode, QWidget *parent) : QDialog(parent), @@ -54,26 +55,6 @@ QString DbDialog::getName() return ui->nameEdit->text(); } -Db* DbDialog::getDb() -{ - if (ui->typeCombo->currentIndex() < 0) - return nullptr; - - Db* testDb = nullptr; - QHash<QString, QVariant> options = collectOptions(); - QString path = ui->fileEdit->text(); - foreach (DbPlugin* plugin, dbPlugins) - { - if (options.contains(DB_PLUGIN) && options[DB_PLUGIN].toString() != plugin->getName()) - continue; - - testDb = plugin->getInstance("", path, options); - if (testDb) - return testDb; - } - return testDb; -} - bool DbDialog::isPermanent() { return ui->permamentCheckBox->isChecked(); @@ -95,17 +76,18 @@ void DbDialog::showEvent(QShowEvent *e) { if (db) { + disableTypeAutodetection = true; int idx = ui->typeCombo->findText(db->getTypeLabel()); ui->typeCombo->setCurrentIndex(idx); - ui->typeCombo->setEnabled(false); // converting to other type is in separate dialog, it's different feature ui->generateCheckBox->setChecked(false); ui->fileEdit->setText(db->getPath()); ui->nameEdit->setText(db->getName()); + disableTypeAutodetection = false; } else if (ui->typeCombo->count() > 0) { - int idx = ui->typeCombo->findText("SQLite3"); // we should have SQLite3 plugin + int idx = ui->typeCombo->findText("SQLite 3", Qt::MatchFixedString); // we should have SQLite 3 plugin if (idx > -1) ui->typeCombo->setCurrentIndex(idx); else @@ -126,24 +108,30 @@ void DbDialog::init() { ui->setupUi(this); - ui->browseButton->setIcon(ICONS.DATABASE_FILE); - dbPlugins = PLUGINS->getLoadedPlugins<DbPlugin>(); - foreach (DbPlugin* dbPlugin, dbPlugins) - { - ui->typeCombo->addItem(dbPlugin->getLabel()); - } + ui->browseCreateButton->setIcon(ICONS.PLUS); - ui->browseButton->setVisible(true); + for (DbPlugin* dbPlugin : PLUGINS->getLoadedPlugins<DbPlugin>()) + dbPlugins[dbPlugin->getLabel()] = dbPlugin; + + QStringList typeLabels; + typeLabels += dbPlugins.keys(); + typeLabels.sort(Qt::CaseInsensitive); + ui->typeCombo->addItems(typeLabels); + + ui->browseCreateButton->setVisible(true); ui->testConnIcon->setVisible(false); connect(ui->fileEdit, SIGNAL(textChanged(QString)), this, SLOT(fileChanged(QString))); connect(ui->nameEdit, SIGNAL(textChanged(QString)), this, SLOT(nameModified(QString))); connect(ui->generateCheckBox, SIGNAL(toggled(bool)), this, SLOT(generateNameSwitched(bool))); - connect(ui->browseButton, SIGNAL(clicked()), this, SLOT(browseClicked())); + connect(ui->browseCreateButton, SIGNAL(clicked()), this, SLOT(browseClicked())); + connect(ui->browseOpenButton, SIGNAL(clicked()), this, SLOT(browseClicked())); connect(ui->testConnButton, SIGNAL(clicked()), this, SLOT(testConnectionClicked())); connect(ui->typeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(dbTypeChanged(int))); generateNameSwitched(true); + + layout()->setSizeConstraint(QLayout::SetFixedSize); } void DbDialog::updateOptions() @@ -153,10 +141,14 @@ void DbDialog::updateOptions() // Remove olds foreach (QWidget* w, optionWidgets) { - ui->gridLayout->removeWidget(w); + ui->optionsGrid->removeWidget(w); delete w; } - adjustSize(); + + customBrowseHandler = nullptr; + ui->pathGroup->setTitle(tr("File")); + ui->browseOpenButton->setToolTip(tr("Browse for existing database file on local computer")); + ui->browseCreateButton->setVisible(true); optionWidgets.clear(); optionKeyToWidget.clear(); @@ -166,31 +158,43 @@ void DbDialog::updateOptions() lastWidgetInTabOrder = ui->permamentCheckBox; // Retrieve new list - DbPlugin* plugin = nullptr; - if (dbPlugins.count() > 0) + if (ui->typeCombo->currentIndex() > -1) { - int idx = ui->typeCombo->currentIndex(); - if (idx > -1 ) + DbPlugin* plugin = dbPlugins[ui->typeCombo->currentText()]; + QList<DbPluginOption> optList = plugin->getOptionsList(); + if (optList.size() > 0) { - plugin = dbPlugins[idx]; - QList<DbPluginOption> optList = plugin->getOptionsList(); - if (optList.size() > 0) + // Add new options + int row = ADDITIONAL_ROWS_BEGIN_INDEX; + for (const DbPluginOption& opt : optList) { - // Add new options - int row = ADDITIONAL_ROWS_BEGIN_INDEX; - foreach (DbPluginOption opt, optList) - addOption(opt, row++); + addOption(opt, row); + row++; } } } - adjustSize(); + setUpdatesEnabled(true); } -void DbDialog::addOption(const DbPluginOption& option, int row) +void DbDialog::addOption(const DbPluginOption& option, int& row) { + if (option.type == DbPluginOption::CUSTOM_PATH_BROWSE) + { + // This option does not add any editor, but has it's own label for path edit. + row--; + ui->pathGroup->setTitle(option.label); + ui->browseCreateButton->setVisible(false); + if (!option.toolTip.isEmpty()) + ui->browseOpenButton->setToolTip(option.toolTip); + + customBrowseHandler = option.customBrowseHandler; + return; + } + QLabel* label = new QLabel(option.label, this); + label->setAlignment(Qt::AlignVCenter|Qt::AlignRight); QWidget* editor = nullptr; QWidget* editorHelper = nullptr; // TODO, based on plugins for Url handlers @@ -204,15 +208,15 @@ void DbDialog::addOption(const DbPluginOption& option, int row) optionKeyToWidget[option.key] = editor; optionKeyToType[option.key] = option.type; - ui->gridLayout->addWidget(label, row, 0); - ui->gridLayout->addWidget(editor, row, 1); + ui->optionsGrid->addWidget(label, row, 0); + ui->optionsGrid->addWidget(editor, row, 1); setTabOrder(lastWidgetInTabOrder, editor); lastWidgetInTabOrder = editor; if (editorHelper) { - ui->gridLayout->addWidget(editorHelper, row, 2); + ui->optionsGrid->addWidget(editorHelper, row, 2); optionWidgets << editorHelper; helperToKey[editorHelper] = option.key; @@ -307,6 +311,8 @@ QWidget *DbDialog::getEditor(const DbPluginOption& opt, QWidget*& editorHelper) connect(sb, SIGNAL(valueChanged(double)), this, SLOT(propertyChanged())); break; } + case DbPluginOption::CUSTOM_PATH_BROWSE: + return nullptr; // should not happen ever, asserted one stack level before default: // TODO plugin based handling of custom editors qWarning() << "Unhandled DbDialog option for creating editor."; @@ -344,6 +350,8 @@ QVariant DbDialog::getValueFrom(DbPluginOption::Type type, QWidget *editor) case DbPluginOption::CHOICE: value = dynamic_cast<QComboBox*>(editor)->currentText(); break; + case DbPluginOption::CUSTOM_PATH_BROWSE: + break; // should not happen ever default: // TODO plugin based handling of custom editors qWarning() << "Unhandled DbDialog option for value."; @@ -373,6 +381,8 @@ void DbDialog::setValueFor(DbPluginOption::Type type, QWidget *editor, const QVa case DbPluginOption::CHOICE: dynamic_cast<QComboBox*>(editor)->setCurrentText(value.toString()); break; + case DbPluginOption::CUSTOM_PATH_BROWSE: + break; // should not happen ever default: qWarning() << "Unhandled DbDialog option to set value."; // TODO plugin based handling of custom editors @@ -382,18 +392,19 @@ void DbDialog::setValueFor(DbPluginOption::Type type, QWidget *editor, const QVa void DbDialog::updateType() { + if (disableTypeAutodetection) + return; + QFileInfo file(ui->fileEdit->text()); if (!file.exists() || file.isDir()) - { - ui->typeCombo->setEnabled(true); return; - } - DbPlugin* validPlugin = nullptr; + QString currentPluginLabel = ui->typeCombo->currentText(); + QList<DbPlugin*> validPlugins; QHash<QString,QVariant> options; QString path = ui->fileEdit->text(); Db* probeDb = nullptr; - foreach (DbPlugin* plugin, dbPlugins) + for (DbPlugin* plugin : dbPlugins) { probeDb = plugin->getInstance("", path, options); if (probeDb) @@ -401,15 +412,15 @@ void DbDialog::updateType() delete probeDb; probeDb = nullptr; - validPlugin = plugin; - break; + if (plugin->getLabel() == currentPluginLabel) + return; // current plugin is among valid plugins, no need to change anything + + validPlugins << plugin; } } - if (validPlugin) - ui->typeCombo->setCurrentText(validPlugin->getLabel()); - - ui->typeCombo->setEnabled(!validPlugin); + if (validPlugins.size() > 0) + ui->typeCombo->setCurrentText(validPlugins.first()->getLabel()); } QHash<QString, QVariant> DbDialog::collectOptions() @@ -424,7 +435,7 @@ QHash<QString, QVariant> DbDialog::collectOptions() DbPlugin* plugin = nullptr; if (dbPlugins.count() > 0) { - plugin = dbPlugins[ui->typeCombo->currentIndex()]; + plugin = dbPlugins[ui->typeCombo->currentText()]; options[DB_PLUGIN] = plugin->getName(); } @@ -433,9 +444,32 @@ QHash<QString, QVariant> DbDialog::collectOptions() bool DbDialog::testDatabase() { + if (ui->typeCombo->currentIndex() < 0) + return false; + QString path = ui->fileEdit->text(); - bool existed = QFile::exists(path); - bool res = getDb() != nullptr; + if (path.isEmpty()) + return false; + + QUrl url(path); + if (url.scheme().isEmpty()) + url.setScheme("file"); + + bool existed = false; + if (url.isLocalFile() && QFile::exists(path)) + existed = QFile::exists(path); + + QHash<QString, QVariant> options = collectOptions(); + DbPlugin* plugin = dbPlugins[ui->typeCombo->currentText()]; + Db* testDb = plugin->getInstance("", path, options); + + bool res = false; + if (testDb) + { + res = true; + delete testDb; + } + if (!existed) { QFile file(path); @@ -522,10 +556,9 @@ void DbDialog::valueForNameGenerationChanged() if (!ui->generateCheckBox->isChecked()) return; - DbPlugin* plugin = nullptr; if (dbPlugins.count() > 0) { - plugin = dbPlugins[ui->typeCombo->currentIndex()]; + DbPlugin* plugin = dbPlugins[ui->typeCombo->currentText()]; QString generatedName = plugin->generateDbName(ui->fileEdit->text()); generatedName = generateUniqueName(generatedName, existingDatabaseNames); ui->nameEdit->setText(generatedName); @@ -549,7 +582,7 @@ void DbDialog::generateNameSwitched(bool checked) { if (checked) { - ui->nameEdit->setPlaceholderText(tr("The name will be auto-generated")); + ui->nameEdit->setPlaceholderText(tr("Auto-generated")); valueForNameGenerationChanged(); } else @@ -570,6 +603,14 @@ void DbDialog::fileChanged(const QString &arg1) void DbDialog::browseClicked() { + if (customBrowseHandler) + { + customBrowseHandler(ui->fileEdit->text()); + return; + } + + bool createMode = (sender() == ui->browseCreateButton); + QFileInfo fileInfo(ui->fileEdit->text()); QString dir; if (ui->fileEdit->text().isEmpty()) @@ -581,7 +622,7 @@ void DbDialog::browseClicked() else dir = getFileDialogInitPath(); - QString path = getDbPath(dir); + QString path = getDbPath(createMode, dir); if (path.isNull()) return; diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.h b/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.h index b2c0d68..ce73b11 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.h +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.h @@ -47,12 +47,11 @@ class GUI_API_EXPORT DbDialog : public QDialog private: void init(); void updateOptions(); - void addOption(const DbPluginOption& option, int row); + void addOption(const DbPluginOption& option, int& row); QWidget* getEditor(const DbPluginOption& opt, QWidget *&editorHelper); QVariant getValueFrom(DbPluginOption::Type type, QWidget* editor); void setValueFor(DbPluginOption::Type type, QWidget* editor, const QVariant& value); void updateType(); - Db* getDb(); bool testDatabase(); bool validate(); void updateState(); @@ -61,14 +60,16 @@ class GUI_API_EXPORT DbDialog : public QDialog Mode mode; QStringList existingDatabaseNames; Db* db = nullptr; - QList<DbPlugin*> dbPlugins; + QHash<QString,DbPlugin*> dbPlugins; QList<QWidget*> optionWidgets; QHash<QString,QWidget*> optionKeyToWidget; QHash<QString,DbPluginOption::Type> optionKeyToType; QHash<QWidget*,QString> helperToKey; QWidget* lastWidgetInTabOrder = nullptr; + DbPluginOption::CustomBrowseHandler customBrowseHandler = nullptr; + bool disableTypeAutodetection = false; - static const constexpr int ADDITIONAL_ROWS_BEGIN_INDEX = 4; + static const constexpr int ADDITIONAL_ROWS_BEGIN_INDEX = 1; private slots: void typeChanged(int index); diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.ui b/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.ui index fb53428..6f35079 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.ui +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>455</width> - <height>200</height> + <height>365</height> </rect> </property> <property name="minimumSize"> @@ -21,127 +21,124 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QComboBox" name="typeCombo"> - <property name="toolTip"> - <string>Database driver</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="nameEdit"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="nameLabel"> - <property name="text"> - <string>Name</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="typeLabel"> - <property name="text"> - <string>Type</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="fileEdit"/> - </item> - <item row="0" column="2"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QToolButton" name="browseButton"> - <property name="toolTip"> - <string>Browse for database file on local computer</string> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="fileLabel"> - <property name="text"> - <string>File</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QCheckBox" name="generateCheckBox"> - <property name="toolTip"> - <string>Generate name basing on file path</string> - </property> - <property name="text"> - <string/> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Permanent</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QCheckBox" name="permamentCheckBox"> - <property name="toolTip"> - <string extracomment="aasfd"><p>Enable this if you want the database to be stored in configuration file and restored every time SQLiteStudio is started.</p></string> - </property> - <property name="text"> - <string/> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </item> - </layout> + <widget class="QGroupBox" name="typeGroup"> + <property name="title"> + <string>Database type</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QComboBox" name="typeCombo"> + <property name="toolTip"> + <string>Database driver</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="pathGroup"> + <property name="title"> + <string>File</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QLineEdit" name="fileEdit"/> + </item> + <item> + <widget class="QToolButton" name="browseCreateButton"> + <property name="toolTip"> + <string>Create new database file</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="../icons.qrc"> + <normaloff>:/icons/img/plus.png</normaloff>:/icons/img/plus.png</iconset> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="browseOpenButton"> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="../icons.qrc"> + <normaloff>:/icons/img/open_sql_file.png</normaloff>:/icons/img/open_sql_file.png</iconset> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="nameGroup"> + <property name="title"> + <string>Name (on the list)</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item> + <widget class="QLineEdit" name="nameEdit"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="generateCheckBox"> + <property name="toolTip"> + <string>Generate name basing on file path</string> + </property> + <property name="text"> + <string>Generate automatically</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="optionsGroup"> + <property name="title"> + <string>Options</string> + </property> + <layout class="QGridLayout" name="optionsGrid"> + <item row="0" column="0" colspan="2"> + <widget class="QCheckBox" name="permamentCheckBox"> + <property name="toolTip"> + <string extracomment="aasfd"><p>Enable this if you want the database to be stored in configuration file and restored every time SQLiteStudio is started.</p></string> + </property> + <property name="text"> + <string>Permanent (keep it in configuration)</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>360</width> + <height>1</height> + </size> + </property> + </spacer> </item> <item> <widget class="QWidget" name="bottomWidget" native="true"> @@ -161,7 +158,7 @@ <item> <widget class="QPushButton" name="testConnButton"> <property name="text"> - <string>Test database connection</string> + <string>Test connection</string> </property> </widget> </item> @@ -190,15 +187,9 @@ </item> </layout> </widget> - <tabstops> - <tabstop>fileEdit</tabstop> - <tabstop>browseButton</tabstop> - <tabstop>nameEdit</tabstop> - <tabstop>generateCheckBox</tabstop> - <tabstop>typeCombo</tabstop> - <tabstop>permamentCheckBox</tabstop> - </tabstops> - <resources/> + <resources> + <include location="../icons.qrc"/> + </resources> <connections> <connection> <sender>buttonBox</sender> diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/exportdialog.cpp b/SQLiteStudio3/guiSQLiteStudio/dialogs/exportdialog.cpp index e495dd9..91b4087 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/exportdialog.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/exportdialog.cpp @@ -124,6 +124,14 @@ void ExportDialog::setDatabaseMode(Db* db) this->db = db; } +void ExportDialog::setPreselectedDb(Db *db) +{ + if (!db->isOpen()) + return; + + this->db = db; +} + void ExportDialog::initModePage() { connect(ui->subjectDatabaseRadio, SIGNAL(clicked()), this, SLOT(updateExportMode())); @@ -146,10 +154,11 @@ void ExportDialog::initTablePage() dbListModel = new DbListModel(this); dbListModel->setCombo(ui->exportTableDbNameCombo); - dbListModel->setSortMode(DbListModel::SortMode::Alphabetical); + dbListModel->setSortMode(DbListModel::SortMode::AlphabeticalCaseInsensitive); tablesModel = new DbObjListModel(this); tablesModel->setType(DbObjListModel::ObjectType::TABLE); + tablesModel->setSortMode(DbObjListModel::SortMode::AlphabeticalCaseInsensitive); connect(this, SIGNAL(tablePageCompleteChanged()), ui->tablePage, SIGNAL(completeChanged())); } @@ -295,6 +304,9 @@ void ExportDialog::tablePageDisplayed() if (table.isNull()) // table mode selected by user, not forced by setTableMode(). { ui->exportTableDbNameCombo->setModel(dbListModel); + if (db) + ui->exportTableDbNameCombo->setCurrentText(db->getName()); + connect(ui->exportTableDbNameCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDbTables())); ui->exportTableNameCombo->setModel(tablesModel); @@ -313,6 +325,9 @@ void ExportDialog::queryPageDisplayed() if (query.isNull()) // query mode selected by user, not forced by setQueryMode(). { ui->queryDatabaseCombo->setModel(dbListModel); + if (db) + ui->queryDatabaseCombo->setCurrentText(db->getName()); + connect(ui->queryDatabaseCombo, SIGNAL(currentIndexChanged(int)), ui->queryPage, SIGNAL(completeChanged())); } diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/exportdialog.h b/SQLiteStudio3/guiSQLiteStudio/dialogs/exportdialog.h index 296aa4d..0471172 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/exportdialog.h +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/exportdialog.h @@ -26,6 +26,7 @@ class GUI_API_EXPORT ExportDialog : public QWizard void setTableMode(Db* db, const QString& table); void setQueryMode(Db* db, const QString& query); void setDatabaseMode(Db* db); + void setPreselectedDb(Db* db); int nextId() const; bool isPluginConfigValid() const; diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/importdialog.cpp b/SQLiteStudio3/guiSQLiteStudio/dialogs/importdialog.cpp index 32ec30f..c16b90e 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/importdialog.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/importdialog.cpp @@ -83,12 +83,13 @@ void ImportDialog::initTablePage() { dbListModel = new DbListModel(this); dbListModel->setCombo(ui->dbNameCombo); - dbListModel->setSortMode(DbListModel::SortMode::Alphabetical); + dbListModel->setSortMode(DbListModel::SortMode::AlphabeticalCaseInsensitive); ui->dbNameCombo->setModel(dbListModel); tablesModel = new DbObjListModel(this); tablesModel->setIncludeSystemObjects(false); tablesModel->setType(DbObjListModel::ObjectType::TABLE); + tablesModel->setSortMode(DbObjListModel::SortMode::AlphabeticalCaseInsensitive); ui->tableNameCombo->setModel(tablesModel); refreshTables(); @@ -166,14 +167,6 @@ void ImportDialog::updateStandardOptions() bool showFileName = currentPlugin->standardOptionsToEnable().testFlag(ImportManager::FILE_NAME); bool showCodec = currentPlugin->standardOptionsToEnable().testFlag(ImportManager::CODEC); - if (!showFileName && !showCodec) - { - ui->dsOptionsGroup->setVisible(false); - return; - } - - ui->dsOptionsGroup->setVisible(true); - int row = 0; QGridLayout* grid = dynamic_cast<QGridLayout*>(ui->dsOptionsGroup->layout()); if (showFileName) @@ -355,6 +348,8 @@ void ImportDialog::accept() if (currentPlugin->standardOptionsToEnable().testFlag(ImportManager::CODEC)) stdConfig.codec = ui->codecCombo->currentText(); + stdConfig.ignoreErrors = ui->ignoreErrorsCheck->isChecked(); + Db* db = DBLIST->getByName(ui->dbNameCombo->currentText());; if (!db) { diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/importdialog.ui b/SQLiteStudio3/guiSQLiteStudio/dialogs/importdialog.ui index c8756f7..dfa8ace 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/importdialog.ui +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/importdialog.ui @@ -103,8 +103,8 @@ <rect> <x>0</x> <y>0</y> - <width>479</width> - <height>310</height> + <width>269</width> + <height>280</height> </rect> </property> <property name="styleSheet"> @@ -141,13 +141,6 @@ <string>Options</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="inputFileLabel"> - <property name="text"> - <string>Input file:</string> - </property> - </widget> - </item> <item row="0" column="1"> <widget class="QWidget" name="inputFileWidget" native="true"> <layout class="QHBoxLayout" name="horizontalLayout"> @@ -183,9 +176,26 @@ </property> </widget> </item> + <item row="0" column="0"> + <widget class="QLabel" name="inputFileLabel"> + <property name="text"> + <string>Input file:</string> + </property> + </widget> + </item> <item row="1" column="1"> <widget class="QComboBox" name="codecCombo"/> </item> + <item row="2" column="0" colspan="2"> + <widget class="QCheckBox" name="ignoreErrorsCheck"> + <property name="toolTip"> + <string><p>If enabled, any constraint violation, or invalid data format (wrong column count), or any other problem encountered during import will be ignored and the importing will be continued.</p></string> + </property> + <property name="text"> + <string>Ignore errors</string> + </property> + </widget> + </item> </layout> </widget> </item> diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/triggerdialog.cpp b/SQLiteStudio3/guiSQLiteStudio/dialogs/triggerdialog.cpp index 0707bd3..12baafd 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/triggerdialog.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/triggerdialog.cpp @@ -19,6 +19,9 @@ #include <QMessageBox> #include <QPushButton> +QStringList TriggerDialog::tableEventNames; +QStringList TriggerDialog::viewEventNames; + TriggerDialog::TriggerDialog(Db* db, QWidget *parent) : QDialog(parent), db(db), @@ -54,6 +57,18 @@ void TriggerDialog::setTrigger(const QString& name) initTrigger(); } +void TriggerDialog::staticInit() +{ + tableEventNames = QStringList({ + SqliteCreateTrigger::time(SqliteCreateTrigger::Time::null), + SqliteCreateTrigger::time(SqliteCreateTrigger::Time::AFTER), + SqliteCreateTrigger::time(SqliteCreateTrigger::Time::BEFORE) + }); + viewEventNames = QStringList({ + SqliteCreateTrigger::time(SqliteCreateTrigger::Time::INSTEAD_OF) + }); +} + void TriggerDialog::changeEvent(QEvent *e) { QDialog::changeEvent(e); @@ -99,6 +114,9 @@ void TriggerDialog::init() }); } + // Event combo - default values + ui->whenCombo->addItems(tableEventNames + viewEventNames); + // Precondition connect(ui->preconditionCheck, SIGNAL(clicked()), this, SLOT(updateState())); connect(ui->preconditionEdit, SIGNAL(errorsChecked(bool)), this, SLOT(updateValidation())); @@ -128,22 +146,19 @@ void TriggerDialog::initTrigger() } // Event combo + QString eventValue = ui->whenCombo->currentText(); + ui->whenCombo->clear(); if (forTable) { - ui->whenCombo->addItems({ - SqliteCreateTrigger::time(SqliteCreateTrigger::Time::null), - SqliteCreateTrigger::time(SqliteCreateTrigger::Time::BEFORE), - SqliteCreateTrigger::time(SqliteCreateTrigger::Time::AFTER) - }); + ui->whenCombo->addItems(tableEventNames); } else { - ui->whenCombo->addItems({ - SqliteCreateTrigger::time(SqliteCreateTrigger::Time::INSTEAD_OF) - }); + ui->whenCombo->addItems(viewEventNames); ui->whenCombo->setEnabled(false); ui->onLabel->setText(tr("On view:")); } + ui->whenCombo->setCurrentText(eventValue); if (!view.isNull() || !table.isNull()) { diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/triggerdialog.h b/SQLiteStudio3/guiSQLiteStudio/dialogs/triggerdialog.h index d8e7ed4..712ea5e 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/triggerdialog.h +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/triggerdialog.h @@ -22,6 +22,8 @@ class GUI_API_EXPORT TriggerDialog : public QDialog void setParentView(const QString& name); void setTrigger(const QString& name); + static void staticInit(); + protected: void changeEvent(QEvent *e); @@ -35,6 +37,9 @@ class GUI_API_EXPORT TriggerDialog : public QDialog QString getTargetObjectName() const; void rebuildTrigger(); + static QStringList tableEventNames; + static QStringList viewEventNames; + QString originalTriggerName; QString trigger; QString table; |
