mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Make last database error message private
It's not supposed to be edited by anyone else.
This commit is contained in:
@@ -97,5 +97,5 @@ void CreateIndexDialog::accept()
|
||||
if(pdb.executeSQL(sql))
|
||||
QDialog::accept();
|
||||
else
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Creating the index failed:\n%1").arg(pdb.lastErrorMessage));
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Creating the index failed:\n%1").arg(pdb.lastError()));
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ bool DbStructureModel::dropMimeData(const QMimeData* data, Qt::DropAction action
|
||||
reloadData();
|
||||
return true;
|
||||
} else {
|
||||
QMessageBox::warning(0, QApplication::applicationName(), m_db.lastErrorMessage);
|
||||
QMessageBox::warning(0, QApplication::applicationName(), m_db.lastError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ void EditTableDialog::accept()
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
QApplication::applicationName(),
|
||||
tr("Error creating table. Message from database engine:\n%1").arg(pdb.lastErrorMessage));
|
||||
tr("Error creating table. Message from database engine:\n%1").arg(pdb.lastError()));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -169,7 +169,7 @@ void EditTableDialog::accept()
|
||||
{
|
||||
if(!pdb.renameTable(curTable, ui->editTableName->text()))
|
||||
{
|
||||
QMessageBox::warning(this, QApplication::applicationName(), pdb.lastErrorMessage);
|
||||
QMessageBox::warning(this, QApplication::applicationName(), pdb.lastError());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -487,7 +487,7 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
|
||||
if(callRenameColumn)
|
||||
{
|
||||
if(!pdb.renameColumn(curTable, m_table, oldFieldName, field))
|
||||
QMessageBox::warning(this, qApp->applicationName(), tr("Modifying this column failed. Error returned from database:\n%1").arg(pdb.lastErrorMessage));
|
||||
QMessageBox::warning(this, qApp->applicationName(), tr("Modifying this column failed. Error returned from database:\n%1").arg(pdb.lastError()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,7 +575,7 @@ void EditTableDialog::removeField()
|
||||
{
|
||||
if(!pdb.renameColumn(curTable, m_table, ui->treeWidget->currentItem()->text(0), sqlb::FieldPtr()))
|
||||
{
|
||||
QMessageBox::warning(0, QApplication::applicationName(), pdb.lastErrorMessage);
|
||||
QMessageBox::warning(0, QApplication::applicationName(), pdb.lastError());
|
||||
} else {
|
||||
//relayout
|
||||
QString sTablesql = pdb.getObjectByName(curTable).getsql();
|
||||
@@ -659,7 +659,7 @@ void EditTableDialog::moveCurrentField(bool down)
|
||||
(down ? 1 : -1)
|
||||
))
|
||||
{
|
||||
QMessageBox::warning(0, QApplication::applicationName(), pdb.lastErrorMessage);
|
||||
QMessageBox::warning(0, QApplication::applicationName(), pdb.lastError());
|
||||
} else {
|
||||
// Reload table SQL
|
||||
QString sTablesql = pdb.getObjectByName(curTable).getsql();
|
||||
@@ -712,7 +712,7 @@ void EditTableDialog::setWithoutRowid(bool without_rowid)
|
||||
if(!pdb.renameColumn(curTable, m_table, QString(), sqlb::FieldPtr(), 0))
|
||||
{
|
||||
QMessageBox::warning(this, QApplication::applicationName(),
|
||||
tr("Setting the rowid column for the table failed. Error message:\n%1").arg(pdb.lastErrorMessage));
|
||||
tr("Setting the rowid column for the table failed. Error message:\n%1").arg(pdb.lastError()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -731,7 +731,7 @@ void EditTableDialog::setTemporary(bool is_temp)
|
||||
if(!pdb.renameColumn(curTable, m_table, QString(), sqlb::FieldPtr(), 0))
|
||||
{
|
||||
QMessageBox::warning(this, QApplication::applicationName(),
|
||||
tr("Setting the temporary flag for the table failed. Error message:\n%1").arg(pdb.lastErrorMessage));
|
||||
tr("Setting the temporary flag for the table failed. Error message:\n%1").arg(pdb.lastError()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,13 +209,13 @@ void ImportCsvDialog::accept()
|
||||
// db needs to be saved or an error will occur
|
||||
QString restorepointName = QString("CSVIMPORT_%1").arg(QDateTime::currentMSecsSinceEpoch());
|
||||
if(!pdb->setSavepoint(restorepointName))
|
||||
return rollback(this, pdb, progress, restorepointName, 0, tr("Creating restore point failed: %1").arg(pdb->lastErrorMessage));
|
||||
return rollback(this, pdb, progress, restorepointName, 0, tr("Creating restore point failed: %1").arg(pdb->lastError()));
|
||||
|
||||
// Create table
|
||||
if(!importToExistingTable)
|
||||
{
|
||||
if(!pdb->createTable(ui->editName->text(), fieldList))
|
||||
return rollback(this, pdb, progress, restorepointName, 0, tr("Creating the table failed: %1").arg(pdb->lastErrorMessage));
|
||||
return rollback(this, pdb, progress, restorepointName, 0, tr("Creating the table failed: %1").arg(pdb->lastError()));
|
||||
}
|
||||
|
||||
// now lets import all data, one row at a time
|
||||
@@ -246,7 +246,7 @@ void ImportCsvDialog::accept()
|
||||
sql.append(");");
|
||||
|
||||
if(!pdb->executeSQL(sql, false, false))
|
||||
return rollback(this, pdb, progress, restorepointName, std::distance(itBegin, it) + 1, tr("Inserting row failed: %1").arg(pdb->lastErrorMessage));
|
||||
return rollback(this, pdb, progress, restorepointName, std::distance(itBegin, it) + 1, tr("Inserting row failed: %1").arg(pdb->lastError()));
|
||||
|
||||
// Update progress bar and check if cancel button was clicked
|
||||
unsigned int prog = std::distance(csv.csv().begin(), it);
|
||||
|
||||
@@ -303,7 +303,7 @@ bool MainWindow::fileOpen(const QString& fileName, bool dontAddToRecentFiles, bo
|
||||
loadPragmas();
|
||||
retval = true;
|
||||
} else {
|
||||
QMessageBox::warning(this, qApp->applicationName(), tr("Could not open database file.\nReason: %1").arg(db.lastErrorMessage));
|
||||
QMessageBox::warning(this, qApp->applicationName(), tr("Could not open database file.\nReason: %1").arg(db.lastError()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -567,7 +567,7 @@ void MainWindow::addRecord()
|
||||
{
|
||||
selectTableLine(row);
|
||||
} else {
|
||||
QMessageBox::warning( this, QApplication::applicationName(), tr("Error adding record:\n") + db.lastErrorMessage);
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error adding record:\n") + db.lastError());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ void MainWindow::deleteRecord()
|
||||
int selected_rows_count = last_selected_row - first_selected_row + 1;
|
||||
if(!m_browseTableModel->removeRows(first_selected_row, selected_rows_count))
|
||||
{
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error deleting record:\n%1").arg(db.lastErrorMessage));
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error deleting record:\n%1").arg(db.lastError()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -747,7 +747,7 @@ void MainWindow::deleteObject()
|
||||
QString statement = QString("DROP %1 %2;").arg(type.toUpper()).arg(sqlb::escapeIdentifier(table));
|
||||
if(!db.executeSQL( statement))
|
||||
{
|
||||
QString error = tr("Error: could not delete the %1. Message from database engine:\n%2").arg(type).arg(db.lastErrorMessage);
|
||||
QString error = tr("Error: could not delete the %1. Message from database engine:\n%2").arg(type).arg(db.lastError());
|
||||
QMessageBox::warning(this, QApplication::applicationName(), error);
|
||||
} else {
|
||||
populateTable();
|
||||
@@ -1116,7 +1116,7 @@ void MainWindow::fileSave()
|
||||
if(!db.releaseAllSavepoints())
|
||||
{
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error while saving the database file. This means that not all changes to the database were "
|
||||
"saved. You need to resolve the following error first.\n\n%1").arg(db.lastErrorMessage));
|
||||
"saved. You need to resolve the following error first.\n\n%1").arg(db.lastError()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1184,7 +1184,7 @@ void MainWindow::importDatabaseFromSQL()
|
||||
QFile f(fileName);
|
||||
f.open(QIODevice::ReadOnly);
|
||||
if(!db.executeMultiSQL(f.readAll(), newDbFile.size() == 0))
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error importing data: %1").arg(db.lastErrorMessage));
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error importing data: %1").arg(db.lastError()));
|
||||
else
|
||||
QMessageBox::information(this, QApplication::applicationName(), tr("Import completed."));
|
||||
f.close();
|
||||
@@ -1633,7 +1633,7 @@ void MainWindow::loadExtension()
|
||||
if(db.loadExtension(file))
|
||||
QMessageBox::information(this, QApplication::applicationName(), tr("Extension successfully loaded."));
|
||||
else
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error loading extension: %1").arg(db.lastErrorMessage));
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error loading extension: %1").arg(db.lastError()));
|
||||
}
|
||||
|
||||
void MainWindow::loadExtensionsFromSettings()
|
||||
@@ -1645,7 +1645,7 @@ void MainWindow::loadExtensionsFromSettings()
|
||||
foreach(QString ext, list)
|
||||
{
|
||||
if(db.loadExtension(ext) == false)
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error loading extension: %1").arg(db.lastErrorMessage));
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error loading extension: %1").arg(db.lastError()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ void SqlExecutionArea::saveAsView()
|
||||
if(db.executeSQL(QString("CREATE VIEW %1 AS %2;").arg(sqlb::escapeIdentifier(name)).arg(model->query())))
|
||||
QMessageBox::information(this, qApp->applicationName(), tr("View successfully created."));
|
||||
else
|
||||
QMessageBox::warning(this, qApp->applicationName(), tr("Error creating view: %1").arg(db.lastErrorMessage));
|
||||
QMessageBox::warning(this, qApp->applicationName(), tr("Error creating view: %1").arg(db.lastError()));
|
||||
}
|
||||
|
||||
void SqlExecutionArea::reloadSettings()
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
bool dump(const QString & filename, const QStringList &tablesToDump, bool insertColNames, bool insertNew, bool exportSchema, bool exportData);
|
||||
bool executeSQL(QString statement, bool dirtyDB = true, bool logsql = true);
|
||||
bool executeMultiSQL(const QString& statement, bool dirty = true, bool log = false);
|
||||
const QString& lastError() const { return lastErrorMessage; }
|
||||
|
||||
/**
|
||||
* @brief getRow Executes a sqlite statement to get the rowdata(columns)
|
||||
@@ -126,8 +127,6 @@ public:
|
||||
|
||||
objectMap objMap;
|
||||
|
||||
QString lastErrorMessage;
|
||||
|
||||
signals:
|
||||
void sqlExecuted(QString sql, int msgtype);
|
||||
void dbChanged(bool dirty);
|
||||
@@ -135,9 +134,8 @@ signals:
|
||||
|
||||
private:
|
||||
QString curDBFilename;
|
||||
|
||||
QString lastErrorMessage;
|
||||
QStringList savepointList;
|
||||
|
||||
bool isEncrypted;
|
||||
bool isReadOnly;
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ bool SqliteTableModel::setTypedData(const QModelIndex& index, bool isBlob, const
|
||||
emit(dataChanged(index, index));
|
||||
return true;
|
||||
} else {
|
||||
QMessageBox::warning(0, qApp->applicationName(), tr("Error changing data:\n%1").arg(m_db.lastErrorMessage));
|
||||
QMessageBox::warning(0, qApp->applicationName(), tr("Error changing data:\n%1").arg(m_db.lastError()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user