Make current filename a private class member

This commit is contained in:
Martin Kleusberg
2016-01-27 23:08:48 +01:00
parent 910c15ae25
commit 1a7aad0ff0
4 changed files with 9 additions and 7 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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

View File

@@ -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;