Improve auto save handling.

This commit is contained in:
Florian Geyer 2012-06-24 17:53:01 +02:00
parent b0ad864fe0
commit 204822b66f
11 changed files with 52 additions and 54 deletions

View file

@ -503,7 +503,6 @@ void DatabaseTabWidget::insertDatabase(Database* db, const DatabaseManagerStruct
updateTabName(db);
int index = databaseIndex(db);
setCurrentIndex(index);
connect(db, SIGNAL(nameTextChanged()), SLOT(updateTabNameFromSender()));
connect(dbStruct.dbWidget->entryView(), SIGNAL(entrySelectionChanged()),
SLOT(emitEntrySelectionChanged()));
@ -511,7 +510,7 @@ void DatabaseTabWidget::insertDatabase(Database* db, const DatabaseManagerStruct
connect(db, SIGNAL(modified()), SLOT(modified()));
connect(dbStruct.dbWidget, SIGNAL(currentModeChanged(DatabaseWidget::Mode)),
SIGNAL(currentWidgetModeChanged(DatabaseWidget::Mode)));
connect(dbStruct.dbWidget, SIGNAL(editFinished()), SLOT(autoSave()));
db->setEmitModified(true);
}
DatabaseWidget* DatabaseTabWidget::currentDatabaseWidget()
@ -532,25 +531,17 @@ void DatabaseTabWidget::modified()
Database* db = static_cast<Database*>(sender());
DatabaseManagerStruct& dbStruct = m_dbList[db];
if (config()->get("AutoSaveAfterEveryChange").toBool() && dbStruct.file) {
saveDatabase(db);
return;
}
if (!dbStruct.modified) {
dbStruct.modified = true;
updateTabName(db);
}
}
void DatabaseTabWidget::autoSave()
{
Q_ASSERT(qobject_cast<DatabaseWidget*>(sender()));
DatabaseWidget* dbWidget = static_cast<DatabaseWidget*>(sender());
Database* db = databaseFromDatabaseWidget(dbWidget);
DatabaseManagerStruct& dbStruct = m_dbList[db];
if (dbStruct.modified && config()->get("AutoSaveAfterEveryChange").toBool() && dbStruct.file) {
saveDatabase(db);
}
}
void DatabaseTabWidget::updateLastDatabases(const QString& filename)
{
if (!config()->get("RememberLastDatabases").toBool()) {