diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp
index 89c3fc56a..de61ca1d7 100644
--- a/src/gui/entry/EditEntryWidget.cpp
+++ b/src/gui/entry/EditEntryWidget.cpp
@@ -103,6 +103,7 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
SLOT(updateHistoryButtons(QModelIndex, QModelIndex)));
connect(m_historyUi->showButton, SIGNAL(clicked()), SLOT(showHistoryEntry()));
connect(m_historyUi->deleteButton, SIGNAL(clicked()), SLOT(deleteHistoryEntry()));
+ connect(m_historyUi->deleteAllButton, SIGNAL(clicked()), SLOT(deleteAllHistoryEntries()));
connect(this, SIGNAL(accepted()), SLOT(saveEntry()));
connect(this, SIGNAL(rejected()), SLOT(cancel()));
@@ -200,7 +201,7 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, bool history, const Q
m_historyUi->showButton->setEnabled(false);
m_historyUi->restoreButton->setEnabled(false);
m_historyUi->deleteButton->setEnabled(false);
-
+ m_historyUi->deleteAllButton->setEnabled(false);
setForms(entry);
@@ -240,6 +241,10 @@ void EditEntryWidget::setForms(const Entry* entry)
m_iconsWidget->load(entry->uuid(), m_database, iconStruct);
if (!m_history) {
m_historyModel->setEntries(entry->historyItems());
+ if (m_historyModel->rowCount() > 0) {
+ m_historyUi->deleteAllButton->setEnabled(true);
+ }
+
}
}
@@ -532,5 +537,22 @@ void EditEntryWidget::deleteHistoryEntry()
QModelIndex index = m_historyUi->historyView->currentIndex();
if (index.isValid()) {
m_historyModel->deleteIndex(index);
+ if (m_historyModel->rowCount() > 0) {
+ m_historyUi->deleteAllButton->setEnabled(true);
+ }
+ else {
+ m_historyUi->deleteAllButton->setEnabled(false);
+ }
+ }
+}
+
+void EditEntryWidget::deleteAllHistoryEntries()
+{
+ m_historyModel->deleteAll();
+ if (m_historyModel->rowCount() > 0) {
+ m_historyUi->deleteAllButton->setEnabled(true);
+ }
+ else {
+ m_historyUi->deleteAllButton->setEnabled(false);
}
}
diff --git a/src/gui/entry/EditEntryWidget.h b/src/gui/entry/EditEntryWidget.h
index 111cfffe4..b66b826a0 100644
--- a/src/gui/entry/EditEntryWidget.h
+++ b/src/gui/entry/EditEntryWidget.h
@@ -73,6 +73,7 @@ private Q_SLOTS:
void removeCurrentAttachment();
void showHistoryEntry();
void deleteHistoryEntry();
+ void deleteAllHistoryEntries();
void emitHistoryEntryActivated(const QModelIndex &index);
void updateHistoryButtons(const QModelIndex& current, const QModelIndex& previous);
diff --git a/src/gui/entry/EditEntryWidgetHistory.ui b/src/gui/entry/EditEntryWidgetHistory.ui
index 2edd14462..f8c0e55b4 100644
--- a/src/gui/entry/EditEntryWidgetHistory.ui
+++ b/src/gui/entry/EditEntryWidgetHistory.ui
@@ -49,6 +49,16 @@
+ -
+
+
+ false
+
+
+ Delete all
+
+
+
diff --git a/src/gui/entry/EntryHistoryModel.cpp b/src/gui/entry/EntryHistoryModel.cpp
index bd22865ac..2d410090d 100644
--- a/src/gui/entry/EntryHistoryModel.cpp
+++ b/src/gui/entry/EntryHistoryModel.cpp
@@ -125,3 +125,16 @@ void EntryHistoryModel::deleteIndex(QModelIndex index)
endRemoveRows();
}
}
+
+void EntryHistoryModel::deleteAll()
+{
+ Q_ASSERT(m_historyEntries.count() > 0);
+
+ beginRemoveRows(QModelIndex(), 0, m_historyEntries.size() - 1);
+
+ Q_FOREACH (Entry* entry, m_historyEntries) {
+ m_deletedHistoryEntries << entry;
+ }
+ m_historyEntries.clear();
+ endRemoveRows();
+}
diff --git a/src/gui/entry/EntryHistoryModel.h b/src/gui/entry/EntryHistoryModel.h
index 404c10352..db7d08c37 100644
--- a/src/gui/entry/EntryHistoryModel.h
+++ b/src/gui/entry/EntryHistoryModel.h
@@ -39,6 +39,7 @@ public:
void clear();
QList deletedEntries();
void deleteIndex(QModelIndex index);
+ void deleteAll();
private:
QList m_historyEntries;