Skip to content

Commit 1a7aad0

Browse files
committed
Make current filename a private class member
1 parent 910c15a commit 1a7aad0

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/DbStructureModel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ QMimeData* DbStructureModel::mimeData(const QModelIndexList& indices) const
231231

232232
// Create the MIME data object
233233
QMimeData* mime = new QMimeData();
234-
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
234+
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
235235
mime->setData("text/plain", d);
236236
return mime;
237237
}
@@ -244,7 +244,7 @@ bool DbStructureModel::dropMimeData(const QMimeData* data, Qt::DropAction action
244244
if(!data->hasFormat("text/plain"))
245245
return false;
246246

247-
if(data->property("db_file") == m_db->curDBFilename)
247+
if(data->property("db_file") == m_db->currentFile())
248248
return false;
249249

250250
// Get data

src/ExportSqlDialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void ExportSqlDialog::accept()
6969
if(selectedItems.count() == 1) // One table -> Suggest table name
7070
defaultFileName = selectedItems.at(0)->text() + ".sql";
7171
else if(selectedItems.count() == ui->listTables->count()) // All tables -> Suggest database name
72-
defaultFileName = pdb->curDBFilename + ".sql";;
72+
defaultFileName = pdb->currentFile() + ".sql";;
7373

7474
QString fileName = FileDialog::getSaveFileName(
7575
this,

src/MainWindow.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ void MainWindow::fileSave()
10301030
void MainWindow::fileRevert()
10311031
{
10321032
if (db.isOpen()){
1033-
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);
1033+
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());
10341034
if(QMessageBox::question(this, QApplication::applicationName(), msg, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape) == QMessageBox::Yes)
10351035
{
10361036
db.revertAll();
@@ -2116,7 +2116,7 @@ void MainWindow::saveProject()
21162116
QString filename = FileDialog::getSaveFileName(this,
21172117
tr("Choose a filename to save under"),
21182118
tr("DB Browser for SQLite project file (*.sqbpro)"),
2119-
db.curDBFilename);
2119+
db.currentFile());
21202120
if(!filename.isEmpty())
21212121
{
21222122
// Make sure the file has got a .sqbpro ending
@@ -2131,7 +2131,7 @@ void MainWindow::saveProject()
21312131

21322132
// Database file name
21332133
xml.writeStartElement("db");
2134-
xml.writeAttribute("path", db.curDBFilename);
2134+
xml.writeAttribute("path", db.currentFile());
21352135
xml.writeEndElement();
21362136

21372137
// Window settings

src/sqlitedb.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class DBBrowserDB : public QObject
108108
bool encrypted() const { return isEncrypted; }
109109
bool readOnly() const { return isReadOnly; }
110110
bool getDirty() const;
111+
QString currentFile() const { return curDBFilename; }
111112
void logSQL(QString statement, int msgtype);
112113

113114
QString getPragma(const QString& pragma);
@@ -122,13 +123,14 @@ class DBBrowserDB : public QObject
122123
objectMap objMap;
123124

124125
QString lastErrorMessage;
125-
QString curDBFilename;
126126

127127
signals:
128128
void sqlExecuted(QString sql, int msgtype);
129129
void dbChanged(bool dirty);
130130

131131
private:
132+
QString curDBFilename;
133+
132134
QStringList savepointList;
133135

134136
bool isEncrypted;

0 commit comments

Comments
 (0)