Truncate history of all items when history limits are changed.

This commit is contained in:
Florian Geyer 2012-05-13 19:43:01 +02:00
parent 8cd5b1f582
commit 459cf051bf
2 changed files with 19 additions and 2 deletions

View File

@ -288,8 +288,12 @@ void DatabaseWidget::updateSettings(bool accepted)
m_db->metadata()->setDefaultUserName(m_databaseSettingsWidget->defaultUsername()); m_db->metadata()->setDefaultUserName(m_databaseSettingsWidget->defaultUsername());
m_db->metadata()->setRecycleBinEnabled(m_databaseSettingsWidget->recylceBinEnabled()); m_db->metadata()->setRecycleBinEnabled(m_databaseSettingsWidget->recylceBinEnabled());
m_db->metadata()->setName(m_databaseSettingsWidget->dbName()); m_db->metadata()->setName(m_databaseSettingsWidget->dbName());
if (m_db->metadata()->historyMaxItems() != m_databaseSettingsWidget->historyMaxItems() ||
m_db->metadata()->historyMaxSize() != m_databaseSettingsWidget->historyMaxSize()) {
m_db->metadata()->setHistoryMaxItems(m_databaseSettingsWidget->historyMaxItems()); m_db->metadata()->setHistoryMaxItems(m_databaseSettingsWidget->historyMaxItems());
m_db->metadata()->setHistoryMaxSize(m_databaseSettingsWidget->historyMaxSize()); m_db->metadata()->setHistoryMaxSize(m_databaseSettingsWidget->historyMaxSize());
truncateHistories();
}
} }
setCurrentIndex(0); setCurrentIndex(0);
@ -343,3 +347,13 @@ bool DatabaseWidget::canDeleteCurrentGoup()
bool isRecycleBin = m_db->metadata()->recycleBin() == m_groupView->currentGroup(); bool isRecycleBin = m_db->metadata()->recycleBin() == m_groupView->currentGroup();
return !isRootGroup && !isRecycleBin; return !isRootGroup && !isRecycleBin;
} }
void DatabaseWidget::truncateHistories()
{
QList<Entry*> allEntries = m_db->rootGroup()->entriesRecursive(false);
QListIterator<Entry*> i(allEntries);
while (i.hasNext()) {
Entry* entry = i.next();
entry->truncateHistory();
}
}

View File

@ -55,6 +55,7 @@ public:
void setCurrentIndex(int index); void setCurrentIndex(int index);
DatabaseWidget::Mode currentMode(); DatabaseWidget::Mode currentMode();
Q_SIGNALS: Q_SIGNALS:
void closeRequest(); void closeRequest();
void currentModeChanged(DatabaseWidget::Mode mode); void currentModeChanged(DatabaseWidget::Mode mode);
@ -90,6 +91,8 @@ private:
Entry* m_newEntry; Entry* m_newEntry;
Group* m_newParent; Group* m_newParent;
QLineEdit* m_searchEdit; QLineEdit* m_searchEdit;
void truncateHistories();
}; };
#endif // KEEPASSX_DATABASEWIDGET_H #endif // KEEPASSX_DATABASEWIDGET_H