From 067deb9bd708360d8de9b8349ce7233032e64c3b Mon Sep 17 00:00:00 2001 From: qycyfjy Date: Sat, 21 Oct 2023 05:50:55 +0800 Subject: [PATCH] Fix removing entry from history and improve logic of history tab showing --- src/gui/entry/EditEntryWidget.cpp | 1 + src/gui/entry/EntryHistoryModel.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 6d8ba5061..b84fa2488 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -1151,6 +1151,7 @@ bool EditEntryWidget::commitEntry() } m_historyModel->setEntries(m_entry->historyItems(), m_entry); + setPageHidden(m_historyWidget, m_history || m_entry->historyItems().count() < 1); m_advancedUi->attachmentsWidget->linkAttachments(m_entry->attachments()); showMessage(tr("Entry updated successfully."), MessageWidget::Positive); diff --git a/src/gui/entry/EntryHistoryModel.cpp b/src/gui/entry/EntryHistoryModel.cpp index acde63cb5..618f4328f 100644 --- a/src/gui/entry/EntryHistoryModel.cpp +++ b/src/gui/entry/EntryHistoryModel.cpp @@ -158,9 +158,10 @@ void EntryHistoryModel::deleteIndex(QModelIndex index) { auto entry = entryFromIndex(index); if (entry) { - beginRemoveRows(QModelIndex(), m_historyEntries.indexOf(entry), m_historyEntries.indexOf(entry)); + beginRemoveRows(QModelIndex(), index.row(), index.row()); m_historyEntries.removeAll(entry); m_deletedHistoryEntries << entry; + m_historyModifications.erase(m_historyModifications.begin() + index.row()); endRemoveRows(); } }