From 1a7aad0ff026d73f4df076b77b7dc7438b1a4134 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Wed, 27 Jan 2016 23:08:48 +0100 Subject: [PATCH] Make current filename a private class member --- src/DbStructureModel.cpp | 4 ++-- src/ExportSqlDialog.cpp | 2 +- src/MainWindow.cpp | 6 +++--- src/sqlitedb.h | 4 +++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/DbStructureModel.cpp b/src/DbStructureModel.cpp index f07945f0..46015a4a 100644 --- a/src/DbStructureModel.cpp +++ b/src/DbStructureModel.cpp @@ -231,7 +231,7 @@ QMimeData* DbStructureModel::mimeData(const QModelIndexList& indices) const // Create the MIME data object QMimeData* mime = new QMimeData(); - mime->setProperty("db_file", m_db->curDBFilename); // Also save the file name to avoid dropping an object on the same database as it comes from + mime->setProperty("db_file", m_db->currentFile()); // Also save the file name to avoid dropping an object on the same database as it comes from mime->setData("text/plain", d); return mime; } @@ -244,7 +244,7 @@ bool DbStructureModel::dropMimeData(const QMimeData* data, Qt::DropAction action if(!data->hasFormat("text/plain")) return false; - if(data->property("db_file") == m_db->curDBFilename) + if(data->property("db_file") == m_db->currentFile()) return false; // Get data diff --git a/src/ExportSqlDialog.cpp b/src/ExportSqlDialog.cpp index 6e821f1b..173ba12a 100644 --- a/src/ExportSqlDialog.cpp +++ b/src/ExportSqlDialog.cpp @@ -69,7 +69,7 @@ void ExportSqlDialog::accept() if(selectedItems.count() == 1) // One table -> Suggest table name defaultFileName = selectedItems.at(0)->text() + ".sql"; else if(selectedItems.count() == ui->listTables->count()) // All tables -> Suggest database name - defaultFileName = pdb->curDBFilename + ".sql";; + defaultFileName = pdb->currentFile() + ".sql";; QString fileName = FileDialog::getSaveFileName( this, diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index f27d5f42..93ecbc3b 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1030,7 +1030,7 @@ void MainWindow::fileSave() void MainWindow::fileRevert() { if (db.isOpen()){ - QString msg = tr("Are you sure you want to undo all changes made to the database file '%1' since the last save?").arg(db.curDBFilename); + QString msg = tr("Are you sure you want to undo all changes made to the database file '%1' since the last save?").arg(db.currentFile()); if(QMessageBox::question(this, QApplication::applicationName(), msg, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape) == QMessageBox::Yes) { db.revertAll(); @@ -2116,7 +2116,7 @@ void MainWindow::saveProject() QString filename = FileDialog::getSaveFileName(this, tr("Choose a filename to save under"), tr("DB Browser for SQLite project file (*.sqbpro)"), - db.curDBFilename); + db.currentFile()); if(!filename.isEmpty()) { // Make sure the file has got a .sqbpro ending @@ -2131,7 +2131,7 @@ void MainWindow::saveProject() // Database file name xml.writeStartElement("db"); - xml.writeAttribute("path", db.curDBFilename); + xml.writeAttribute("path", db.currentFile()); xml.writeEndElement(); // Window settings diff --git a/src/sqlitedb.h b/src/sqlitedb.h index 829a9014..f8d09970 100644 --- a/src/sqlitedb.h +++ b/src/sqlitedb.h @@ -108,6 +108,7 @@ public: bool encrypted() const { return isEncrypted; } bool readOnly() const { return isReadOnly; } bool getDirty() const; + QString currentFile() const { return curDBFilename; } void logSQL(QString statement, int msgtype); QString getPragma(const QString& pragma); @@ -122,13 +123,14 @@ public: objectMap objMap; QString lastErrorMessage; - QString curDBFilename; signals: void sqlExecuted(QString sql, int msgtype); void dbChanged(bool dirty); private: + QString curDBFilename; + QStringList savepointList; bool isEncrypted;