Ask before closing database when in edit mode.

Fixes #12
This commit is contained in:
Florian Geyer 2012-04-21 20:36:26 +02:00 committed by Felix Geyer
parent 8467e7756d
commit e7d0dfbd26

View File

@ -150,11 +150,22 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
const DatabaseManagerStruct& dbStruct = m_dbList.value(db); const DatabaseManagerStruct& dbStruct = m_dbList.value(db);
int index = databaseIndex(db); int index = databaseIndex(db);
Q_ASSERT(index != -1); Q_ASSERT(index != -1);
if (dbStruct.modified) {
QString dbName = tabText(index); QString dbName = tabText(index);
if (dbName.right(1) == "*") { if (dbName.right(1) == "*") {
dbName.chop(1); dbName.chop(1);
} }
if (dbStruct.dbWidget->currentIndex() != 0) {
QMessageBox::StandardButton result =
QMessageBox::question(
this, tr("Close?"),
tr("\"%1\" is in edit mode.\nClose anyway?").arg(dbName),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (result == QMessageBox::No) {
return false;
}
}
if (dbStruct.modified) {
QMessageBox::StandardButton result = QMessageBox::StandardButton result =
QMessageBox::question( QMessageBox::question(
this, tr("Save changes?"), this, tr("Save changes?"),