From 9391de74c7117ad40d8bd1d530e2620cedc101c1 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sat, 17 May 2014 18:05:02 +0200 Subject: [PATCH] Block non-user updates in DatabaseWidgetStateSync. --- src/gui/DatabaseWidget.cpp | 5 +++++ src/gui/DatabaseWidget.h | 2 ++ src/gui/DatabaseWidgetStateSync.cpp | 26 ++++++++++++++++++++++++++ src/gui/DatabaseWidgetStateSync.h | 2 ++ 4 files changed, 35 insertions(+) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 5379e1a1f..0779297ef 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -724,6 +724,9 @@ void DatabaseWidget::toggleSearch() void DatabaseWidget::closeSearch() { Q_ASSERT(m_lastGroup); + + Q_EMIT listModeAboutToActivate(); + m_groupView->setCurrentGroup(m_lastGroup); m_searchTimer->stop(); @@ -732,6 +735,8 @@ void DatabaseWidget::closeSearch() void DatabaseWidget::showSearch() { + Q_EMIT searchModeAboutToActivate(); + m_searchUi->searchEdit->blockSignals(true); m_searchUi->searchEdit->clear(); m_searchUi->searchEdit->blockSignals(false); diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index 981784d48..cbab175e4 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -88,7 +88,9 @@ Q_SIGNALS: void groupContextMenuRequested(const QPoint& globalPos); void entryContextMenuRequested(const QPoint& globalPos); void unlockedDatabase(); + void listModeAboutToActivate(); void listModeActivated(); + void searchModeAboutToActivate(); void searchModeActivated(); void splitterSizesChanged(); void entryColumnSizesChanged(); diff --git a/src/gui/DatabaseWidgetStateSync.cpp b/src/gui/DatabaseWidgetStateSync.cpp index c9e60bb93..66b8492e2 100644 --- a/src/gui/DatabaseWidgetStateSync.cpp +++ b/src/gui/DatabaseWidgetStateSync.cpp @@ -23,6 +23,7 @@ DatabaseWidgetStateSync::DatabaseWidgetStateSync(QObject* parent) : QObject(parent) , m_activeDbWidget(Q_NULLPTR) + , m_blockUpdates(false) { m_splitterSizes = variantToIntList(config()->get("GUI/SplitterState")); m_columnSizesList = variantToIntList(config()->get("GUI/EntryListColumnSizes")); @@ -45,6 +46,8 @@ void DatabaseWidgetStateSync::setActive(DatabaseWidget* dbWidget) m_activeDbWidget = dbWidget; if (m_activeDbWidget) { + m_blockUpdates = true; + if (!m_splitterSizes.isEmpty()) { m_activeDbWidget->setSplitterSizes(m_splitterSizes); } @@ -56,6 +59,8 @@ void DatabaseWidgetStateSync::setActive(DatabaseWidget* dbWidget) restoreSearchView(); } + m_blockUpdates = false; + connect(m_activeDbWidget, SIGNAL(splitterSizesChanged()), SLOT(updateSplitterSizes())); connect(m_activeDbWidget, SIGNAL(entryColumnSizesChanged()), @@ -64,6 +69,10 @@ void DatabaseWidgetStateSync::setActive(DatabaseWidget* dbWidget) SLOT(restoreListView())); connect(m_activeDbWidget, SIGNAL(searchModeActivated()), SLOT(restoreSearchView())); + connect(m_activeDbWidget, SIGNAL(listModeAboutToActivate()), + SLOT(blockUpdates())); + connect(m_activeDbWidget, SIGNAL(searchModeAboutToActivate()), + SLOT(blockUpdates())); } } @@ -72,6 +81,8 @@ void DatabaseWidgetStateSync::restoreListView() if (!m_columnSizesList.isEmpty()) { m_activeDbWidget->setEntryViewHeaderSizes(m_columnSizesList); } + + m_blockUpdates = false; } void DatabaseWidgetStateSync::restoreSearchView() @@ -79,15 +90,30 @@ void DatabaseWidgetStateSync::restoreSearchView() if (!m_columnSizesSearch.isEmpty()) { m_activeDbWidget->setEntryViewHeaderSizes(m_columnSizesSearch); } + + m_blockUpdates = false; +} + +void DatabaseWidgetStateSync::blockUpdates() +{ + m_blockUpdates = true; } void DatabaseWidgetStateSync::updateSplitterSizes() { + if (m_blockUpdates) { + return; + } + m_splitterSizes = m_activeDbWidget->splitterSizes(); } void DatabaseWidgetStateSync::updateColumnSizes() { + if (m_blockUpdates) { + return; + } + if (m_activeDbWidget->isGroupSelected()) { m_columnSizesList = m_activeDbWidget->entryHeaderViewSizes(); } diff --git a/src/gui/DatabaseWidgetStateSync.h b/src/gui/DatabaseWidgetStateSync.h index 26911837c..f6a87cd9a 100644 --- a/src/gui/DatabaseWidgetStateSync.h +++ b/src/gui/DatabaseWidgetStateSync.h @@ -35,6 +35,7 @@ public Q_SLOTS: void restoreSearchView(); private Q_SLOTS: + void blockUpdates(); void updateSplitterSizes(); void updateColumnSizes(); @@ -44,6 +45,7 @@ private: DatabaseWidget* m_activeDbWidget; + bool m_blockUpdates; QList m_splitterSizes; QList m_columnSizesList; QList m_columnSizesSearch;