From a308f430f694423064ebc86fd0506c8c6fdb3d93 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sun, 19 Apr 2015 22:30:21 -0400 Subject: Imported Upstream version 3.0.5 --- SQLiteStudio3/guiSQLiteStudio/common/ipvalidator.h | 3 +- .../guiSQLiteStudio/common/widgetcover.cpp | 36 +++++++++ SQLiteStudio3/guiSQLiteStudio/common/widgetcover.h | 8 +- .../guiSQLiteStudio/datagrid/sqlquerymodel.cpp | 20 ++++- .../guiSQLiteStudio/datagrid/sqlquerymodel.h | 6 ++ SQLiteStudio3/guiSQLiteStudio/dataview.cpp | 39 ++++++++++ SQLiteStudio3/guiSQLiteStudio/dataview.h | 6 ++ SQLiteStudio3/guiSQLiteStudio/dbtree/dbtree.cpp | 38 ++++++++- SQLiteStudio3/guiSQLiteStudio/dbtree/dbtree.h | 3 + .../guiSQLiteStudio/dbtree/dbtreemodel.cpp | 29 +++++-- SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp | 22 +++--- .../guiSQLiteStudio/dialogs/populatedialog.cpp | 13 ++++ .../guiSQLiteStudio/dialogs/populatedialog.h | 2 + SQLiteStudio3/guiSQLiteStudio/iconmanager.h | 2 + SQLiteStudio3/guiSQLiteStudio/icons.qrc | 2 + SQLiteStudio3/guiSQLiteStudio/img/delete.png | Bin 0 -> 729 bytes .../guiSQLiteStudio/img/erase_table_data.png | Bin 0 -> 885 bytes .../translations/guiSQLiteStudio_sk.ts | 86 ++++++++++----------- SQLiteStudio3/guiSQLiteStudio/uiconfig.h | 6 +- SQLiteStudio3/guiSQLiteStudio/uidebug.cpp | 8 ++ SQLiteStudio3/guiSQLiteStudio/uidebug.h | 2 + .../guiSQLiteStudio/windows/tablewindow.cpp | 8 +- .../guiSQLiteStudio/windows/viewwindow.cpp | 10 +-- 23 files changed, 269 insertions(+), 80 deletions(-) create mode 100644 SQLiteStudio3/guiSQLiteStudio/img/delete.png create mode 100644 SQLiteStudio3/guiSQLiteStudio/img/erase_table_data.png (limited to 'SQLiteStudio3/guiSQLiteStudio') diff --git a/SQLiteStudio3/guiSQLiteStudio/common/ipvalidator.h b/SQLiteStudio3/guiSQLiteStudio/common/ipvalidator.h index 1c9ca4d..2cda2d7 100644 --- a/SQLiteStudio3/guiSQLiteStudio/common/ipvalidator.h +++ b/SQLiteStudio3/guiSQLiteStudio/common/ipvalidator.h @@ -1,9 +1,10 @@ #ifndef IPVALIDATOR_H #define IPVALIDATOR_H +#include "guiSQLiteStudio_global.h" #include -class IpValidator : public QValidator +class GUI_API_EXPORT IpValidator : public QValidator { public: IpValidator(QObject* parent = 0); diff --git a/SQLiteStudio3/guiSQLiteStudio/common/widgetcover.cpp b/SQLiteStudio3/guiSQLiteStudio/common/widgetcover.cpp index 7cc6a4e..168c7f9 100644 --- a/SQLiteStudio3/guiSQLiteStudio/common/widgetcover.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/common/widgetcover.cpp @@ -140,6 +140,11 @@ void WidgetCover::hide() animation->start(); } +void WidgetCover::setProgress(int value) +{ + busyBar->setValue(value); +} + QEasingCurve WidgetCover::getEasingCurve() const { return easingCurve; @@ -192,6 +197,37 @@ bool WidgetCover::eventFilter(QObject* obj, QEvent* e) return false; } +void WidgetCover::displayProgress(int maxValue, const QString& format) +{ + if (!busyBar) + return; + + busyBar->setRange(0, maxValue); + if (!format.isNull()) + busyBar->setFormat(format); + + busyBar->setTextVisible(true); +} + +void WidgetCover::noDisplayProgress() +{ + if (!busyBar) + return; + + busyBar->setRange(0, 0); + busyBar->setTextVisible(true); +} + +void WidgetCover::initWithProgressBarOnly(const QString& format) +{ + busyBar = new QProgressBar(); + busyBar->setRange(0, 100); + busyBar->setFormat(format); + busyBar->setTextVisible(true); + + containerLayout->addWidget(busyBar, 0, 0); +} + void WidgetCover::initWithInterruptContainer(const QString& interruptButtonText) { cancelButton = new QPushButton(); diff --git a/SQLiteStudio3/guiSQLiteStudio/common/widgetcover.h b/SQLiteStudio3/guiSQLiteStudio/common/widgetcover.h index d0ccef7..0b7a2f5 100644 --- a/SQLiteStudio3/guiSQLiteStudio/common/widgetcover.h +++ b/SQLiteStudio3/guiSQLiteStudio/common/widgetcover.h @@ -22,16 +22,15 @@ class GUI_API_EXPORT WidgetCover : public QWidget QEasingCurve getEasingCurve() const; void setEasingCurve(const QEasingCurve& value); - int getDuration() const; void setDuration(int value); - int getTransparency() const; void setTransparency(int value); - QGridLayout* getContainerLayout(); bool eventFilter(QObject* obj, QEvent* e); - + void displayProgress(int maxValue, const QString& format = QString()); + void noDisplayProgress(); + void initWithProgressBarOnly(const QString& format); void initWithInterruptContainer(const QString& interruptButtonText = QString()); private: @@ -67,6 +66,7 @@ class GUI_API_EXPORT WidgetCover : public QWidget public slots: void show(); void hide(); + void setProgress(int value); }; #endif // WIDGETCOVER_H diff --git a/SQLiteStudio3/guiSQLiteStudio/datagrid/sqlquerymodel.cpp b/SQLiteStudio3/guiSQLiteStudio/datagrid/sqlquerymodel.cpp index 8024abf..ac97283 100644 --- a/SQLiteStudio3/guiSQLiteStudio/datagrid/sqlquerymodel.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/datagrid/sqlquerymodel.cpp @@ -385,14 +385,19 @@ void SqlQueryModel::commitInternal(const QList& items) // Grouping by row and commiting QList> groupedItems = groupItemsByRows(items); + emit aboutToCommit(groupedItems.size()); + + int step = 1; + rowsDeletedSuccessfullyInTheCommit.clear(); bool ok = true; - foreach (const QList& itemsInRow, groupedItems) + for (const QList& itemsInRow : groupedItems) { if (!commitRow(itemsInRow)) { ok = false; break; } + emit commitingStepFinished(step++); } // Getting current uncommited list (after rows deletion it may be different) @@ -417,15 +422,21 @@ void SqlQueryModel::commitInternal(const QList& items) else { // Commited successfully - foreach (SqlQueryItem* item, itemsLeft) + for (SqlQueryItem* item : itemsLeft) { item->setUncommited(false); item->setNewRow(false); } + qSort(rowsDeletedSuccessfullyInTheCommit); + int removeOffset = 0; + for (int row : rowsDeletedSuccessfullyInTheCommit) + removeRow(row - removeOffset++); // deleting row decrements all rows below + emit commitStatusChanged(getUncommitedItems().size() > 0); } } + rowsDeletedSuccessfullyInTheCommit.clear(); if (!ok) { @@ -447,6 +458,8 @@ void SqlQueryModel::commitInternal(const QList& items) int itemsAddedDeletedDelta = numberOfItemsAdded - numberOfItemsDeleted; recalculateRowsAndPages(itemsAddedDeletedDelta); + + emit commitFinished(); } void SqlQueryModel::rollbackInternal(const QList& items) @@ -604,7 +617,8 @@ bool SqlQueryModel::commitDeletedRow(const QList& itemsInRow) } int row = itemsInRow[0]->index().row(); - return removeRow(row); + rowsDeletedSuccessfullyInTheCommit << row; + return true; } void SqlQueryModel::rollbackAddedRow(const QList& itemsInRow) diff --git a/SQLiteStudio3/guiSQLiteStudio/datagrid/sqlquerymodel.h b/SQLiteStudio3/guiSQLiteStudio/datagrid/sqlquerymodel.h index 3e92bb2..062af95 100644 --- a/SQLiteStudio3/guiSQLiteStudio/datagrid/sqlquerymodel.h +++ b/SQLiteStudio3/guiSQLiteStudio/datagrid/sqlquerymodel.h @@ -351,6 +351,8 @@ class GUI_API_EXPORT SqlQueryModel : public QStandardItemModel */ QList columnEditionStatus; + QList rowsDeletedSuccessfullyInTheCommit; + private slots: void handleExecFinished(SqlQueryPtr results); void handleExecFailed(int code, QString errorMessage); @@ -446,6 +448,10 @@ class GUI_API_EXPORT SqlQueryModel : public QStandardItemModel * Emitted after columns header sorting has been changed. */ void sortingUpdated(const QueryExecutor::SortList& sortOrder); + + void aboutToCommit(int totalSteps); + void commitingStepFinished(int step); + void commitFinished(); }; Q_DECLARE_OPERATORS_FOR_FLAGS(SqlQueryModel::Features) diff --git a/SQLiteStudio3/guiSQLiteStudio/dataview.cpp b/SQLiteStudio3/guiSQLiteStudio/dataview.cpp index e99b9b8..32efae4 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dataview.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dataview.cpp @@ -11,6 +11,7 @@ #include "iconmanager.h" #include "uiconfig.h" #include "datagrid/sqlqueryitem.h" +#include "common/widgetcover.h" #include #include #include @@ -42,6 +43,7 @@ void DataView::init(SqlQueryModel* model) formViewRowCountLabel = new QLabel(); formViewCurrentRowLabel = new QLabel(); + initWidgetCover(); initFormView(); initPageEdit(); initFilter(); @@ -139,6 +141,15 @@ void DataView::initPageEdit() connect(pageEdit, SIGNAL(editingFinished()), this, SLOT(pageEntered())); } +void DataView::initWidgetCover() +{ + widgetCover = new WidgetCover(this); + widgetCover->initWithProgressBarOnly("%v / %m"); + connect(model, SIGNAL(aboutToCommit(int)), this, SLOT(coverForGridCommit(int))); + connect(model, SIGNAL(commitingStepFinished(int)), this, SLOT(updateGridCommitCover(int))); + connect(model, SIGNAL(commitFinished()), this, SLOT(hideGridCommitCover())); +} + void DataView::createActions() { bool rowInserting = model->features().testFlag(SqlQueryModel::INSERT_ROW); @@ -438,6 +449,34 @@ void DataView::filterModeSelected() actionMap[FILTER]->setIcon(modeAction->icon()); } +void DataView::coverForGridCommit(int total) +{ + if (total <= 3) + return; + + widgetCover->displayProgress(total); + widgetCover->show(); + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); +} + +void DataView::updateGridCommitCover(int value) +{ + if (!widgetCover->isVisible()) + return; + + widgetCover->setProgress(value); + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); +} + +void DataView::hideGridCommitCover() +{ + if (!widgetCover->isVisible()) + return; + + widgetCover->hide(); + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); +} + void DataView::updateCommitRollbackActions(bool enabled) { gridView->getAction(SqlQueryView::COMMIT)->setEnabled(enabled); diff --git a/SQLiteStudio3/guiSQLiteStudio/dataview.h b/SQLiteStudio3/guiSQLiteStudio/dataview.h index 5207fdb..64bbb07 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dataview.h +++ b/SQLiteStudio3/guiSQLiteStudio/dataview.h @@ -13,6 +13,7 @@ class FormView; class ExtLineEdit; class QLabel; class IntValidator; +class WidgetCover; CFG_KEY_LIST(DataView, QObject::tr("Data view (both grid and form)"), CFG_KEY_ENTRY(REFRESH_DATA, Qt::Key_F5, QObject::tr("Refresh data")) @@ -115,6 +116,7 @@ class GUI_API_EXPORT DataView : public QTabWidget, public ExtActionContainer void initUpdates(); void initSlots(); void initPageEdit(); + void initWidgetCover(); void createContents(); void goToFormRow(IndexModifier idxMod); void setNavigationState(bool enabled); @@ -153,6 +155,7 @@ class GUI_API_EXPORT DataView : public QTabWidget, public ExtActionContainer QMutex manualPageChangeMutex; bool uncommittedGrid = false; bool uncommittedForm = false; + WidgetCover* widgetCover = nullptr; signals: @@ -193,6 +196,9 @@ class GUI_API_EXPORT DataView : public QTabWidget, public ExtActionContainer void showFormView(); void updateTabsMode(); void filterModeSelected(); + void coverForGridCommit(int total); + void updateGridCommitCover(int value); + void hideGridCommitCover(); }; int qHash(DataView::ActionGroup action); diff --git a/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtree.cpp b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtree.cpp index 509594d..1aeff0f 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtree.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtree.cpp @@ -136,6 +136,7 @@ void DbTree::createActions() createAction(CLEAR_FILTER, tr("Clear filter"), ui->nameFilter, SLOT(clear()), this); createAction(REFRESH_SCHEMAS, ICONS.DATABASE_RELOAD, tr("Refresh all database schemas"), this, SLOT(refreshSchemas()), this); createAction(REFRESH_SCHEMA, ICONS.DATABASE_RELOAD, tr("Refresh selected database schema"), this, SLOT(refreshSchema()), this); + createAction(ERASE_TABLE_DATA, ICONS.ERASE_TABLE_DATA, tr("Erase table data"), this, SLOT(eraseTableData()), this); } void DbTree::updateActionStates(const QStandardItem *item) @@ -189,7 +190,7 @@ void DbTree::updateActionStates(const QStandardItem *item) break; case DbTreeItem::Type::TABLE: enabled << EDIT_TABLE << DEL_TABLE << EXPORT_TABLE << IMPORT_TABLE << POPULATE_TABLE << ADD_COLUMN << CREATE_SIMILAR_TABLE; - enabled << RESET_AUTOINCREMENT << ADD_INDEX << ADD_TRIGGER; + enabled << RESET_AUTOINCREMENT << ADD_INDEX << ADD_TRIGGER << ERASE_TABLE_DATA; break; case DbTreeItem::Type::VIRTUAL_TABLE: // TODO change below when virtual tables can be edited @@ -393,6 +394,7 @@ void DbTree::setupActionsForMenu(DbTreeItem* currItem, QMenu* contextMenu) actions += ActionEntry(POPULATE_TABLE); actions += ActionEntry(CREATE_SIMILAR_TABLE); actions += ActionEntry(RESET_AUTOINCREMENT); + actions += ActionEntry(ERASE_TABLE_DATA); actions += ActionEntry(_separator); actions += dbEntryExt; break; @@ -1399,6 +1401,35 @@ void DbTree::resetAutoincrement() notifyInfo(tr("Autoincrement value for table '%1' has been reset successfly.").arg(table)); } +void DbTree::eraseTableData() +{ + Db* db = getSelectedDb(); + if (!db || !db->isValid()) + return; + + DbTreeItem* item = ui->treeView->currentItem(); + QString table = item->getTable(); + if (table.isNull()) + { + qWarning() << "Tried to erase table data, while table wasn't selected in DbTree."; + return; + } + + QMessageBox::StandardButton btn = QMessageBox::question(this, tr("Erase table data"), tr("Are you sure you want to delete all data from table '%1'?") + .arg(table)); + if (btn != QMessageBox::Yes) + return; + + SqlQueryPtr res = db->exec(QString("DELETE FROM %1;").arg(wrapObjIfNeeded(table, db->getDialect()))); + if (res->isError()) + { + notifyError(tr("An error occurred while trying to delete data from table '%1': %2").arg(table, res->getErrorText())); + return; + } + + notifyInfo(tr("All data has been deleted for table '%1'.").arg(table)); +} + void DbTree::addColumn(DbTreeItem* item) { Db* db = getSelectedOpenDb(); @@ -1591,6 +1622,11 @@ void DbTree::setupDefShortcuts() BIND_SHORTCUTS(DbTree, Action); } +void DbTree::closeEvent(QCloseEvent *e) +{ + e->ignore(); +} + int qHash(DbTree::Action action) { return static_cast(action); diff --git a/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtree.h b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtree.h index 60b8dd5..2f5583e 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtree.h +++ b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtree.h @@ -84,6 +84,7 @@ class GUI_API_EXPORT DbTree : public QDockWidget, public ExtActionContainer REFRESH_SCHEMA, CREATE_SIMILAR_TABLE, RESET_AUTOINCREMENT, + ERASE_TABLE_DATA, _separator // Never use it directly, it's just for menu setup }; @@ -116,6 +117,7 @@ class GUI_API_EXPORT DbTree : public QDockWidget, public ExtActionContainer protected: void createActions(); void setupDefShortcuts(); + void closeEvent(QCloseEvent* e); private: void setActionEnabled(int action, bool enabled); @@ -187,6 +189,7 @@ class GUI_API_EXPORT DbTree : public QDockWidget, public ExtActionContainer void integrityCheck(); void createSimilarTable(); void resetAutoincrement(); + void eraseTableData(); void addColumn(DbTreeItem* item); void editColumn(DbTreeItem* item); void delColumn(DbTreeItem* item); diff --git a/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp index a4e736f..78f0db8 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dbtree/dbtreemodel.cpp @@ -250,8 +250,19 @@ void DbTreeModel::restoreGroup(const Config::DbGroupPtr& group, QList* dbLi { if (db) { - if (db->open()) + // If the db was stored in cfg as open, it was already open by DbManager. + // Now the DbTreeModel didn't catch that (as it didn't exist yet), so we need to + // call handler for 'connected' event, instead of forcing another open call. + // Otherwise the database that could not be open would be requested to open twice: + // 1. when restoring DbManager + // 2. here + // Instead of that, we just check if the database is already open (by DbManager) + // and call proper handler to refresh database's schema and create tree nodes. + if (db->isOpen()) + { + dbConnected(db); treeView->expand(item->index()); + } } else { @@ -401,8 +412,12 @@ QString DbTreeModel::getDbToolTip(DbTreeItem* item) const QStringList rows; Db* db = item->getDb(); - QFile dbFile(db->getPath()); QString iconPath = db->isValid() ? ICONS.DATABASE.toImgSrc() : ICONS.DATABASE_INVALID.toImgSrc(); + int fileSize = -1; + + QUrl url(db->getPath()); + if (url.scheme().isEmpty() || url.scheme() == "file") + fileSize = QFile(db->getPath()).size(); rows << toolTipHdrRowTmp.arg(iconPath).arg(tr("Database: %1", "dbtree tooltip").arg(db->getName())); rows << toolTipRowTmp.arg("URI:").arg(db->getPath()); @@ -410,13 +425,17 @@ QString DbTreeModel::getDbToolTip(DbTreeItem* item) const if (db->isValid()) { rows << toolTipRowTmp.arg(tr("Version:", "dbtree tooltip")).arg(QString("SQLite %1").arg(db->getVersion())); - rows << toolTipRowTmp.arg(tr("File size:", "dbtree tooltip")).arg(formatFileSize(dbFile.size())); - rows << toolTipRowTmp.arg(tr("Encoding:", "dbtree tooltip")).arg(db->getEncoding()); + + if (fileSize > -1) + rows << toolTipRowTmp.arg(tr("File size:", "dbtree tooltip")).arg(formatFileSize(fileSize)); + + if (db->isOpen()) + rows << toolTipRowTmp.arg(tr("Encoding:", "dbtree tooltip")).arg(db->getEncoding()); } else { InvalidDb* idb = dynamic_cast(db); - rows << toolTipRowTmp.arg(tr("Error details:", "dbtree tooltip")).arg(idb->getError()); + rows << toolTipRowTmp.arg(tr("Error:", "dbtree tooltip")).arg(idb->getError()); } return toolTipTableTmp.arg(rows.join("")); diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp b/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp index 05d50af..ac7cd8a 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp @@ -455,10 +455,6 @@ bool DbDialog::testDatabase() if (url.scheme().isEmpty()) url.setScheme("file"); - bool existed = false; - if (url.isLocalFile() && QFile::exists(path)) - existed = QFile::exists(path); - QHash options = collectOptions(); DbPlugin* plugin = dbPlugins[ui->typeCombo->currentText()]; Db* testDb = plugin->getInstance("", path, options); @@ -466,15 +462,14 @@ bool DbDialog::testDatabase() bool res = false; if (testDb) { - res = true; + if (testDb->openForProbing()) + { + res = !testDb->getEncoding().isEmpty(); + testDb->closeQuiet(); + } delete testDb; } - if (!existed) - { - QFile file(path); - file.remove(); - } return res; } @@ -605,7 +600,12 @@ void DbDialog::browseClicked() { if (customBrowseHandler) { - customBrowseHandler(ui->fileEdit->text()); + QString newUrl = customBrowseHandler(ui->fileEdit->text()); + if (!newUrl.isNull()) + { + ui->fileEdit->setText(newUrl); + updateState(); + } return; } diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/populatedialog.cpp b/SQLiteStudio3/guiSQLiteStudio/dialogs/populatedialog.cpp index ca3fd31..7861ff0 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/populatedialog.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/populatedialog.cpp @@ -51,7 +51,9 @@ void PopulateDialog::init() pluginTitles << plugin->getTitle(); widgetCover = new WidgetCover(this); + widgetCover->initWithInterruptContainer(tr("Abort")); widgetCover->setVisible(false); + connect(widgetCover, SIGNAL(cancelClicked()), POPULATE_MANAGER, SLOT(interrupt())); ui->scrollArea->setAutoFillBackground(false); ui->scrollArea->viewport()->setAutoFillBackground(false); @@ -71,6 +73,7 @@ void PopulateDialog::init() connect(ui->databaseCombo, SIGNAL(currentTextChanged(QString)), this, SLOT(refreshTables())); connect(ui->tableCombo, SIGNAL(currentTextChanged(QString)), this, SLOT(refreshColumns())); connect(POPULATE_MANAGER, SIGNAL(populatingFinished()), widgetCover, SLOT(hide())); + connect(POPULATE_MANAGER, SIGNAL(finishedStep(int)), widgetCover, SLOT(setProgress(int))); connect(POPULATE_MANAGER, SIGNAL(populatingSuccessful()), this, SLOT(finished())); } @@ -317,10 +320,20 @@ void PopulateDialog::accept() QString table = ui->tableCombo->currentText(); qint64 rows = ui->rowsSpin->value(); + started = true; + widgetCover->displayProgress(rows, "%v / %m"); widgetCover->show(); POPULATE_MANAGER->populate(db, table, engines, rows); } +void PopulateDialog::reject() +{ + if (started) + POPULATE_MANAGER->interrupt(); + + QDialog::reject(); +} + PopulateDialog::ColumnEntry::ColumnEntry(QCheckBox* check, QComboBox* combo, QToolButton* button) : check(check), combo(combo), button(button) { diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/populatedialog.h b/SQLiteStudio3/guiSQLiteStudio/dialogs/populatedialog.h index 0ecc318..948d6ce 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/populatedialog.h +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/populatedialog.h @@ -58,6 +58,7 @@ class GUI_API_EXPORT PopulateDialog : public QDialog QSignalMapper* buttonMapper = nullptr; QHash columnsValid; WidgetCover* widgetCover = nullptr; + bool started = false; private slots: void refreshTables(); @@ -71,6 +72,7 @@ class GUI_API_EXPORT PopulateDialog : public QDialog public: void accept(); + void reject(); }; #endif // POPULATEDIALOG_H diff --git a/SQLiteStudio3/guiSQLiteStudio/iconmanager.h b/SQLiteStudio3/guiSQLiteStudio/iconmanager.h index cf4f2ec..940c869 100644 --- a/SQLiteStudio3/guiSQLiteStudio/iconmanager.h +++ b/SQLiteStudio3/guiSQLiteStudio/iconmanager.h @@ -90,6 +90,7 @@ class GUI_API_EXPORT IconManager : public QObject DEF_ICON(DATABASE_ONLINE, "database_online") DEF_ICON(DATABASE_RELOAD, "database_reload") DEF_ICON(DDL_HISTORY, "ddl_history") + DEF_ICON(DELETE, "delete") DEF_ICON(DELETE_ROW, "delete_row") DEF_ICO3(DELETE_COLLATION, DELETE_ROW) DEF_ICO3(DELETE_DATATYPE, DELETE_ROW) @@ -104,6 +105,7 @@ class GUI_API_EXPORT IconManager : public QObject DEF_ICON(DIRECTORY_OPEN_WITH_DB, "directory_open_with_db") DEF_ICON(DIRECTORY_WITH_DB, "directory_with_db") DEF_ICON(ERASE, "erase") + DEF_ICON(ERASE_TABLE_DATA, "erase_table_data") DEF_ICON(EXEC_QUERY, "exec_query") DEF_ICON(EXPLAIN_QUERY, "explain_query") DEF_ICON(EXPORT, "export") diff --git a/SQLiteStudio3/guiSQLiteStudio/icons.qrc b/SQLiteStudio3/guiSQLiteStudio/icons.qrc index 6612814..9cf981d 100644 --- a/SQLiteStudio3/guiSQLiteStudio/icons.qrc +++ b/SQLiteStudio3/guiSQLiteStudio/icons.qrc @@ -191,5 +191,7 @@ img/go_back.png img/reset_autoincrement.png img/plus.png + img/erase_table_data.png + img/delete.png diff --git a/SQLiteStudio3/guiSQLiteStudio/img/delete.png b/SQLiteStudio3/guiSQLiteStudio/img/delete.png new file mode 100644 index 0000000..20d6f5e Binary files /dev/null and b/SQLiteStudio3/guiSQLiteStudio/img/delete.png differ diff --git a/SQLiteStudio3/guiSQLiteStudio/img/erase_table_data.png b/SQLiteStudio3/guiSQLiteStudio/img/erase_table_data.png new file mode 100644 index 0000000..a07585a Binary files /dev/null and b/SQLiteStudio3/guiSQLiteStudio/img/erase_table_data.png differ diff --git a/SQLiteStudio3/guiSQLiteStudio/translations/guiSQLiteStudio_sk.ts b/SQLiteStudio3/guiSQLiteStudio/translations/guiSQLiteStudio_sk.ts index 26e0fb1..42a735f 100644 --- a/SQLiteStudio3/guiSQLiteStudio/translations/guiSQLiteStudio_sk.ts +++ b/SQLiteStudio3/guiSQLiteStudio/translations/guiSQLiteStudio_sk.ts @@ -1028,7 +1028,7 @@ but it's okay to use it. Execute only the query under the cursor - + Vykonať len dotaz, na ktorom stojí kurzor @@ -1089,12 +1089,12 @@ but it's okay to use it. Sort table columns alphabetically - + Zoradiť stĺpce tabuľky abecedne Expand tables node when connected to a database - + Rozbaliť zoznam tabuliek po pripojení k databáze @@ -1104,7 +1104,7 @@ but it's okay to use it. Display additional labels on the list - + Zobraziť doplnkové popisky v zozname @@ -1114,7 +1114,7 @@ but it's okay to use it. Display labels for regular tables - + Zobraziť popisky pre regulárne tabuľky @@ -1124,12 +1124,12 @@ but it's okay to use it. Display labels for virtual tables - + Zobraziť popisky pre virtuálne tabuľky Expand views node when connected to a database - + Rozbaliť zoznam pohľadov po pripojení k databáze @@ -1139,42 +1139,42 @@ but it's okay to use it. Sort objects (tables, indexes, triggers and views) alphabetically - + Zoradiť objekty (tabuľky, indexy, spúšťače a pohľady) abecedne Display system tables and indexes on the list - + Zobraziť systémové tabuľky a indexy v zozname Table windows - + Okná tabuľky When enabled, Table Windows will show up with the data tab, instead of the structure tab. - + Ak je táto možnosť zaškrtnutá, tak sa v okne zobrazia dáta a nie štruktúra tabuľky. Open Table Windows with the data tab for start - + Zobraziť dáta po otvorení tabuľky View windows - + Okná pohľadov When enabled, View Windows will show up with the data tab, instead of the structure tab. - + Ak je táto možnosť zaškrtnutá, tak sa v okne zobrazia dáta a nie SQL dotaz. Open View Windows with the data tab for start - + Zobraziť dáta po otvorení pohľadu @@ -1184,22 +1184,22 @@ but it's okay to use it. Current style: - + Aktuálny štýl: Preview - + Náhľad Enabled - + Zapnutý Disabled - + Vypnutý @@ -1209,17 +1209,17 @@ but it's okay to use it. SQL editor font - + Písmo SQL editora Database list font - + Font zoznamu databáz Database list additional label font - + Font doplnkového popisku @@ -1835,7 +1835,7 @@ Prezeranie ďalších strán bude možné až po dokončení spočítavania. Database type - + Typ databázy @@ -1845,22 +1845,22 @@ Prezeranie ďalších strán bude možné až po dokončení spočítavania. Generate automatically - + Generovať automaticky Options - Voľby + Voľby Permanent (keep it in configuration) - + Zapamätať si databázu Test connection - + Test spojenia Name @@ -1877,7 +1877,7 @@ Prezeranie ďalších strán bude možné až po dokončení spočítavania. Create new database file - + Vytvoriť nový databázový súbor @@ -1888,7 +1888,7 @@ Prezeranie ďalších strán bude možné až po dokončení spočítavania. Name (on the list) - + Názov (v zozname) @@ -1912,7 +1912,7 @@ Prezeranie ďalších strán bude možné až po dokončení spočítavania. Browse for existing database file on local computer - + Hľadať databázový súbor na lokálnom počítači @@ -1947,7 +1947,7 @@ Prezeranie ďalších strán bude možné až po dokončení spočítavania. Auto-generated - + Automaticky vygenerovaný The name will be auto-generated @@ -3325,7 +3325,7 @@ Please enter new, unique name, or press '%1' to abort the operation: Cannot create unique index, because values in selected columns are not unique. Would you like to execute SELECT query to see problematic values? - + Nemôžem vytvoriť jedinečný index, pretože hodnoty vo vybraných stĺpcoch nie sú jedinečné. Chcete spustiť dotaz SELECT na zobrazenie problematických hodnôt? @@ -4265,7 +4265,7 @@ Please enter new, unique name, or press '%1' to abort the operation: Cell text value editor - + Úprava hodnôt v bunkách @@ -4401,7 +4401,7 @@ Please enter new, unique name, or press '%1' to abort the operation: SQL editor window - + Okno SQL editora @@ -4411,42 +4411,42 @@ Please enter new, unique name, or press '%1' to abort the operation: Execute "%1" query - + Vykonať "%1" dotaz Switch current working database to previous on the list - + Prepnúť sa na predchádzajúcu databázu v zozname Switch current working database to next on the list - + Prepnúť sa na nasledujúcu databázu v zozname Go to next editor tab - + Prechod na nasledujúcu záložku editora Go to previous editor tab - + Prechod na predchádzajúcu záložku editora Move keyboard input focus to the results view below - + Prepnúť kurzor na výsledky Move keyboard input focus to the SQL editor above - + Prepnúť kurzor do editora Table window - + Okno tabuľky @@ -4491,7 +4491,7 @@ Please enter new, unique name, or press '%1' to abort the operation: Delete selected table constraint - Vymazaťˇvybrané obmedzenie + Vymazať vybrané obmedzenie diff --git a/SQLiteStudio3/guiSQLiteStudio/uiconfig.h b/SQLiteStudio3/guiSQLiteStudio/uiconfig.h index 3372979..b434dc8 100644 --- a/SQLiteStudio3/guiSQLiteStudio/uiconfig.h +++ b/SQLiteStudio3/guiSQLiteStudio/uiconfig.h @@ -85,9 +85,9 @@ CFG_CATEGORIES(Ui, ) ) -QString getFileDialogInitPath(); -void setFileDialogInitPath(const QString& path); -void setFileDialogInitPathByFile(const QString& filePath); +GUI_API_EXPORT QString getFileDialogInitPath(); +GUI_API_EXPORT void setFileDialogInitPath(const QString& path); +GUI_API_EXPORT void setFileDialogInitPathByFile(const QString& filePath); #define CFG_UI CFG_INSTANCE(Ui) diff --git a/SQLiteStudio3/guiSQLiteStudio/uidebug.cpp b/SQLiteStudio3/guiSQLiteStudio/uidebug.cpp index 00aaac4..a2ce9f8 100644 --- a/SQLiteStudio3/guiSQLiteStudio/uidebug.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/uidebug.cpp @@ -12,6 +12,8 @@ bool UI_DEBUG_ENABLED = false; bool UI_DEBUG_CONSOLE = true; QString UI_DEBUG_FILE; +QStringList MsgHandlerThreadProxy::ignoredWarnings; + void uiMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { if (!UI_DEBUG_ENABLED) @@ -100,6 +102,9 @@ MsgHandlerThreadProxy::~MsgHandlerThreadProxy() void MsgHandlerThreadProxy::init() { + ignoredWarnings << QStringLiteral("libpng warning: Unknown iTXt compression type or method"); + ignoredWarnings << QStringLiteral("QPainter::font: Painter not active"); + if (sqliteStudioUiDebugConsole) { connect(this, SIGNAL(debugRequested(QString)), sqliteStudioUiDebugConsole, SLOT(debug(QString))); @@ -139,6 +144,9 @@ void MsgHandlerThreadProxy::debug(const QString &msg) void MsgHandlerThreadProxy::warn(const QString &msg) { + if (ignoredWarnings.contains(msg.mid(25))) + return; + emit warnRequested(msg); } diff --git a/SQLiteStudio3/guiSQLiteStudio/uidebug.h b/SQLiteStudio3/guiSQLiteStudio/uidebug.h index d2a2a51..449eb29 100644 --- a/SQLiteStudio3/guiSQLiteStudio/uidebug.h +++ b/SQLiteStudio3/guiSQLiteStudio/uidebug.h @@ -20,6 +20,8 @@ class GUI_API_EXPORT MsgHandlerThreadProxy : public QObject void init(); void initFile(const QString& fileName); + static QStringList ignoredWarnings; + QFile* outFile = nullptr; QTextStream outFileStream; diff --git a/SQLiteStudio3/guiSQLiteStudio/windows/tablewindow.cpp b/SQLiteStudio3/guiSQLiteStudio/windows/tablewindow.cpp index 77a4adc..3a315db 100644 --- a/SQLiteStudio3/guiSQLiteStudio/windows/tablewindow.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/windows/tablewindow.cpp @@ -621,20 +621,20 @@ bool TableWindow::restoreSession(const QVariant& sessionValue) QHash value = sessionValue.toHash(); if (value.size() == 0) { - notifyWarn("Could not restore window, because no database or table was stored in session for this window."); + notifyWarn(tr("Could not restore window %1, because no database or table was stored in session for this window.").arg(value["title"].toString())); return false; } if (!value.contains("db") || !value.contains("table")) { - notifyWarn("Could not restore window, because no database or table was stored in session for this window."); + notifyWarn(tr("Could not restore window '%1', because no database or table was stored in session for this window.").arg(value["title"].toString())); return false; } db = DBLIST->getByName(value["db"].toString()); if (!db || !db->isValid() || (!db->isOpen() && !db->open())) { - notifyWarn(tr("Could not restore window, because database %1 could not be resolved.").arg(value["db"].toString())); + notifyWarn(tr("Could not restore window '%1', because database %2 could not be resolved.").arg(value["title"].toString(), value["db"].toString())); return false; } @@ -643,7 +643,7 @@ bool TableWindow::restoreSession(const QVariant& sessionValue) SchemaResolver resolver(db); if (!resolver.getTables(database).contains(table, Qt::CaseInsensitive)) { - notifyWarn(tr("Could not restore window, because the table %1 doesn't exist in the database %2.").arg(table).arg(db->getName())); + notifyWarn(tr("Could not restore window '%1'', because the table %2 doesn't exist in the database %3.").arg(value["title"].toString(), table, db->getName())); return false; } diff --git a/SQLiteStudio3/guiSQLiteStudio/windows/viewwindow.cpp b/SQLiteStudio3/guiSQLiteStudio/windows/viewwindow.cpp index a699801..9a30e1c 100644 --- a/SQLiteStudio3/guiSQLiteStudio/windows/viewwindow.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/windows/viewwindow.cpp @@ -99,26 +99,26 @@ bool ViewWindow::restoreSession(const QVariant& sessionValue) QHash value = sessionValue.toHash(); if (value.size() == 0) { - notifyWarn("Could not restore window, because no database or view was stored in session for this window."); + notifyWarn(tr("Could not restore window '%1', because no database or view was stored in session for this window.").arg(value["title"].toString())); return false; } if (!value.contains("db") || !value.contains("view")) { - notifyWarn("Could not restore window, because no database or view was stored in session for this window."); + notifyWarn(tr("Could not restore window '%1', because no database or view was stored in session for this window.").arg(value["title"].toString())); return false; } db = DBLIST->getByName(value["db"].toString()); if (!db) { - notifyWarn(tr("Could not restore window, because database %1 could not be resolved.").arg(value["db"].toString())); + notifyWarn(tr("Could not restore window '%1', because database %2 could not be resolved.").arg(value["title"].toString(), value["db"].toString())); return false; } if (!db->isOpen() && !db->open()) { - notifyWarn(tr("Could not restore window, because database %1 could not be open.").arg(value["db"].toString())); + notifyWarn(tr("Could not restore window '%1', because database %2 could not be open.").arg(value["title"].toString(), value["db"].toString())); return false; } @@ -127,7 +127,7 @@ bool ViewWindow::restoreSession(const QVariant& sessionValue) SchemaResolver resolver(db); if (!resolver.getViews(database).contains(view, Qt::CaseInsensitive)) { - notifyWarn(tr("Could not restore window, because the view %1 doesn't exist in the database %2.").arg(view).arg(db->getName())); + notifyWarn(tr("Could not restore window '%1', because the view %2 doesn't exist in the database %3.").arg(value["title"].toString(), view, db->getName())); return false; } -- cgit v1.2.3