From 8f87b5cfd4e9d8de2214f08974e0627abb79d476 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sun, 31 Jul 2016 23:53:26 +0200 Subject: [PATCH] Split EditWidgetIcons::save() into state() and reset(). --- src/gui/EditWidgetIcons.cpp | 11 ++++++----- src/gui/EditWidgetIcons.h | 3 ++- src/gui/entry/EditEntryWidget.cpp | 3 ++- src/gui/group/EditGroupWidget.cpp | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp index 0aab991a3..832defd04 100644 --- a/src/gui/EditWidgetIcons.cpp +++ b/src/gui/EditWidgetIcons.cpp @@ -61,11 +61,8 @@ EditWidgetIcons::~EditWidgetIcons() { } -IconStruct EditWidgetIcons::save() +IconStruct EditWidgetIcons::state() const { - Q_ASSERT(m_database); - Q_ASSERT(!m_currentUuid.isNull()); - IconStruct iconStruct; if (m_ui->defaultIconsRadio->isChecked()) { QModelIndex index = m_ui->defaultIconsView->currentIndex(); @@ -86,9 +83,13 @@ IconStruct EditWidgetIcons::save() } } + return iconStruct; +} + +void EditWidgetIcons::reset() +{ m_database = nullptr; m_currentUuid = Uuid(); - return iconStruct; } void EditWidgetIcons::load(Uuid currentUuid, Database* database, IconStruct iconStruct) diff --git a/src/gui/EditWidgetIcons.h b/src/gui/EditWidgetIcons.h index f3f3f11c5..db58801fa 100644 --- a/src/gui/EditWidgetIcons.h +++ b/src/gui/EditWidgetIcons.h @@ -46,7 +46,8 @@ public: explicit EditWidgetIcons(QWidget* parent = nullptr); ~EditWidgetIcons(); - IconStruct save(); + IconStruct state() const; + void reset(); void load(Uuid currentUuid, Database* database, IconStruct iconStruct); private Q_SLOTS: diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 5ad612cfc..6d5cfdc93 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -430,7 +430,7 @@ void EditEntryWidget::saveEntry() m_entry->attributes()->copyCustomKeysFrom(m_entryAttributes); m_entry->attachments()->copyDataFrom(m_entryAttachments); - IconStruct iconStruct = m_iconsWidget->save(); + IconStruct iconStruct = m_iconsWidget->state(); if (iconStruct.number < 0) { m_entry->setIcon(Entry::DefaultIconNumber); @@ -489,6 +489,7 @@ void EditEntryWidget::clear() m_entryAttachments->clear(); m_autoTypeAssoc->clear(); m_historyModel->clear(); + m_iconsWidget->reset(); } void EditEntryWidget::togglePasswordGeneratorButton(bool checked) diff --git a/src/gui/group/EditGroupWidget.cpp b/src/gui/group/EditGroupWidget.cpp index 7fdec89a2..a5b426b92 100644 --- a/src/gui/group/EditGroupWidget.cpp +++ b/src/gui/group/EditGroupWidget.cpp @@ -113,7 +113,7 @@ void EditGroupWidget::save() m_group->setDefaultAutoTypeSequence(m_mainUi->autoTypeSequenceCustomEdit->text()); } - IconStruct iconStruct = m_editGroupWidgetIcons->save(); + IconStruct iconStruct = m_editGroupWidgetIcons->state(); if (iconStruct.number < 0) { m_group->setIcon(Group::DefaultIconNumber); @@ -144,6 +144,7 @@ void EditGroupWidget::clear() { m_group = nullptr; m_database = nullptr; + m_editGroupWidgetIcons->reset(); } void EditGroupWidget::addTriStateItems(QComboBox* comboBox, bool inheritDefault)