Block non-user updates in DatabaseWidgetStateSync.

This commit is contained in:
Felix Geyer 2014-05-17 18:05:02 +02:00
parent c806f9ebf4
commit 9391de74c7
4 changed files with 35 additions and 0 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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();
}

View File

@ -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<int> m_splitterSizes;
QList<int> m_columnSizesList;
QList<int> m_columnSizesSearch;