mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 19:13:25 -08:00
[VisualDatabase] Debounce filter refreshes with QtUtils::Debouncer (#7624)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
28c8474f03
commit
77a3875c25
12 changed files with 22 additions and 18 deletions
|
|
@ -11,7 +11,6 @@
|
||||||
#include <QPersistentModelIndex>
|
#include <QPersistentModelIndex>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTimer>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <libcockatrice/filters/filter_tree.h>
|
#include <libcockatrice/filters/filter_tree.h>
|
||||||
|
|
@ -49,7 +48,7 @@ VisualDatabaseDisplayColorFilterWidget::VisualDatabaseDisplayColorFilterWidget(Q
|
||||||
&VisualDatabaseDisplayColorFilterWidget::updateFilterMode);
|
&VisualDatabaseDisplayColorFilterWidget::updateFilterMode);
|
||||||
|
|
||||||
connect(filterModel, &FilterTreeModel::layoutChanged, this,
|
connect(filterModel, &FilterTreeModel::layoutChanged, this,
|
||||||
[this]() { QTimer::singleShot(100, this, &VisualDatabaseDisplayColorFilterWidget::syncWithFilterModel); });
|
[this]() { syncDebouncer.call([this] { syncWithFilterModel(); }); });
|
||||||
|
|
||||||
// Call retranslateUi to set the initial text
|
// Call retranslateUi to set the initial text
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <libcockatrice/utility/debouncer.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
class FilterTreeModel;
|
class FilterTreeModel;
|
||||||
|
|
@ -71,6 +72,7 @@ private:
|
||||||
QHBoxLayout *layout;
|
QHBoxLayout *layout;
|
||||||
QComboBox *modeComboBox;
|
QComboBox *modeComboBox;
|
||||||
FilterMode currentMode = FilterMode::Includes; // Default mode
|
FilterMode currentMode = FilterMode::Includes; // Default mode
|
||||||
|
QtUtils::Debouncer syncDebouncer{100};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISUAL_DATABASE_DISPLAY_COLOR_FILTER_WIDGET_H
|
#endif // VISUAL_DATABASE_DISPLAY_COLOR_FILTER_WIDGET_H
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QTimer>
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
@ -72,9 +71,8 @@ VisualDatabaseDisplayFormatLegalityFilterWidget::VisualDatabaseDisplayFormatLega
|
||||||
layout->addWidget(toggleButton);
|
layout->addWidget(toggleButton);
|
||||||
connect(toggleButton, &QPushButton::clicked, this,
|
connect(toggleButton, &QPushButton::clicked, this,
|
||||||
&VisualDatabaseDisplayFormatLegalityFilterWidget::updateFilterMode);
|
&VisualDatabaseDisplayFormatLegalityFilterWidget::updateFilterMode);
|
||||||
connect(filterModel, &FilterTreeModel::layoutChanged, this, [this]() {
|
connect(filterModel, &FilterTreeModel::layoutChanged, this,
|
||||||
QTimer::singleShot(100, this, &VisualDatabaseDisplayFormatLegalityFilterWidget::syncWithFilterModel);
|
[this]() { syncDebouncer.call([this] { syncWithFilterModel(); }); });
|
||||||
});
|
|
||||||
|
|
||||||
createFormatButtons(); // Populate buttons initially
|
createFormatButtons(); // Populate buttons initially
|
||||||
updateFilterMode(); // Initialize toggle button text
|
updateFilterMode(); // Initialize toggle button text
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <libcockatrice/utility/debouncer.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
class FilterTreeModel;
|
class FilterTreeModel;
|
||||||
|
|
@ -42,6 +43,7 @@ private:
|
||||||
QMap<QString, QPushButton *> formatButtons; // Store toggle buttons
|
QMap<QString, QPushButton *> formatButtons; // Store toggle buttons
|
||||||
|
|
||||||
bool exactMatchMode = true; // Toggle between "Exact Match" and "Includes"
|
bool exactMatchMode = true; // Toggle between "Exact Match" and "Includes"
|
||||||
|
QtUtils::Debouncer syncDebouncer{100};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_VISUAL_DATABASE_DISPLAY_FORMAT_LEGALITY_FILTER_WIDGET_H
|
#endif // COCKATRICE_VISUAL_DATABASE_DISPLAY_FORMAT_LEGALITY_FILTER_WIDGET_H
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QTimer>
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <libcockatrice/card/database/card_database_manager.h>
|
#include <libcockatrice/card/database/card_database_manager.h>
|
||||||
|
|
@ -65,9 +64,8 @@ VisualDatabaseDisplayMainTypeFilterWidget::VisualDatabaseDisplayMainTypeFilterWi
|
||||||
toggleButton = new QPushButton(this);
|
toggleButton = new QPushButton(this);
|
||||||
layout->addWidget(toggleButton);
|
layout->addWidget(toggleButton);
|
||||||
connect(toggleButton, &QPushButton::clicked, this, &VisualDatabaseDisplayMainTypeFilterWidget::updateFilterMode);
|
connect(toggleButton, &QPushButton::clicked, this, &VisualDatabaseDisplayMainTypeFilterWidget::updateFilterMode);
|
||||||
connect(filterModel, &FilterTreeModel::layoutChanged, this, [this]() {
|
connect(filterModel, &FilterTreeModel::layoutChanged, this,
|
||||||
QTimer::singleShot(100, this, &VisualDatabaseDisplayMainTypeFilterWidget::syncWithFilterModel);
|
[this]() { syncDebouncer.call([this] { syncWithFilterModel(); }); });
|
||||||
});
|
|
||||||
|
|
||||||
createMainTypeButtons(); // Populate buttons initially
|
createMainTypeButtons(); // Populate buttons initially
|
||||||
updateFilterMode(); // Initialize toggle button text
|
updateFilterMode(); // Initialize toggle button text
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <libcockatrice/utility/debouncer.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
class FilterTreeModel;
|
class FilterTreeModel;
|
||||||
|
|
@ -48,6 +49,7 @@ private:
|
||||||
QMap<QString, QPushButton *> typeButtons; // Store toggle buttons
|
QMap<QString, QPushButton *> typeButtons; // Store toggle buttons
|
||||||
|
|
||||||
bool exactMatchMode = true; // Toggle between "Exact Match" and "Includes"
|
bool exactMatchMode = true; // Toggle between "Exact Match" and "Includes"
|
||||||
|
QtUtils::Debouncer syncDebouncer{100};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISUAL_DATABASE_DISPLAY_MAIN_TYPE_FILTER_WIDGET_H
|
#endif // VISUAL_DATABASE_DISPLAY_MAIN_TYPE_FILTER_WIDGET_H
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ VisualDatabaseDisplayNameFilterWidget::VisualDatabaseDisplayNameFilterWidget(QWi
|
||||||
&VisualDatabaseDisplayNameFilterWidget::actLoadFromClipboard);
|
&VisualDatabaseDisplayNameFilterWidget::actLoadFromClipboard);
|
||||||
|
|
||||||
connect(filterModel, &FilterTreeModel::layoutChanged, this,
|
connect(filterModel, &FilterTreeModel::layoutChanged, this,
|
||||||
[this]() { QTimer::singleShot(100, this, &VisualDatabaseDisplayNameFilterWidget::syncWithFilterModel); });
|
[this]() { syncDebouncer.call([this] { syncWithFilterModel(); }); });
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <libcockatrice/utility/debouncer.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
class DeckListModel;
|
class DeckListModel;
|
||||||
|
|
@ -46,6 +47,7 @@ private:
|
||||||
QPushButton *loadFromClipboardButton;
|
QPushButton *loadFromClipboardButton;
|
||||||
|
|
||||||
QMap<QString, QPushButton *> activeFilters; // Store active name filter buttons
|
QMap<QString, QPushButton *> activeFilters; // Store active name filter buttons
|
||||||
|
QtUtils::Debouncer syncDebouncer{100};
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void actLoadFromDeck();
|
void actLoadFromDeck();
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QTimer>
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
@ -101,7 +100,7 @@ VisualDatabaseDisplaySetFilterWidget::VisualDatabaseDisplaySetFilterWidget(QWidg
|
||||||
layout->addWidget(toggleButton);
|
layout->addWidget(toggleButton);
|
||||||
connect(toggleButton, &QPushButton::clicked, this, &VisualDatabaseDisplaySetFilterWidget::updateFilterMode);
|
connect(toggleButton, &QPushButton::clicked, this, &VisualDatabaseDisplaySetFilterWidget::updateFilterMode);
|
||||||
connect(filterModel, &FilterTreeModel::layoutChanged, this,
|
connect(filterModel, &FilterTreeModel::layoutChanged, this,
|
||||||
[this]() { QTimer::singleShot(100, this, &VisualDatabaseDisplaySetFilterWidget::syncWithFilterModel); });
|
[this]() { syncDebouncer.call([this] { syncWithFilterModel(); }); });
|
||||||
|
|
||||||
createSetButtons(); // Populate buttons initially
|
createSetButtons(); // Populate buttons initially
|
||||||
updateFilterMode();
|
updateFilterMode();
|
||||||
|
|
@ -304,5 +303,5 @@ void VisualDatabaseDisplaySetFilterWidget::updateFilterMode()
|
||||||
|
|
||||||
// Reconnect the layoutChanged -> sync lambda
|
// Reconnect the layoutChanged -> sync lambda
|
||||||
connect(filterModel, &FilterTreeModel::layoutChanged, this,
|
connect(filterModel, &FilterTreeModel::layoutChanged, this,
|
||||||
[this]() { QTimer::singleShot(100, this, &VisualDatabaseDisplaySetFilterWidget::syncWithFilterModel); });
|
[this]() { syncDebouncer.call([this] { syncWithFilterModel(); }); });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <libcockatrice/utility/debouncer.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
class FilterTreeModel;
|
class FilterTreeModel;
|
||||||
|
|
@ -64,6 +65,7 @@ private:
|
||||||
QMap<QString, bool> activeSets; // Track active set filters
|
QMap<QString, bool> activeSets; // Track active set filters
|
||||||
|
|
||||||
bool exactMatchMode = true; // Toggle between "Exact Match" and "Includes"
|
bool exactMatchMode = true; // Toggle between "Exact Match" and "Includes"
|
||||||
|
QtUtils::Debouncer syncDebouncer{100};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISUAL_DATABASE_DISPLAY_SET_FILTER_WIDGET_H
|
#endif // VISUAL_DATABASE_DISPLAY_SET_FILTER_WIDGET_H
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QTimer>
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <libcockatrice/card/database/card_database_manager.h>
|
#include <libcockatrice/card/database/card_database_manager.h>
|
||||||
|
|
@ -70,9 +69,8 @@ VisualDatabaseDisplaySubTypeFilterWidget::VisualDatabaseDisplaySubTypeFilterWidg
|
||||||
toggleButton = new QPushButton(this);
|
toggleButton = new QPushButton(this);
|
||||||
layout->addWidget(toggleButton);
|
layout->addWidget(toggleButton);
|
||||||
connect(toggleButton, &QPushButton::clicked, this, &VisualDatabaseDisplaySubTypeFilterWidget::updateFilterMode);
|
connect(toggleButton, &QPushButton::clicked, this, &VisualDatabaseDisplaySubTypeFilterWidget::updateFilterMode);
|
||||||
connect(filterModel, &FilterTreeModel::layoutChanged, this, [this]() {
|
connect(filterModel, &FilterTreeModel::layoutChanged, this,
|
||||||
QTimer::singleShot(100, this, &VisualDatabaseDisplaySubTypeFilterWidget::syncWithFilterModel);
|
[this]() { syncDebouncer.call([this] { syncWithFilterModel(); }); });
|
||||||
});
|
|
||||||
|
|
||||||
createSubTypeButtons(); // Populate buttons initially
|
createSubTypeButtons(); // Populate buttons initially
|
||||||
updateFilterMode(); // Initialize the toggle button text
|
updateFilterMode(); // Initialize the toggle button text
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <libcockatrice/utility/debouncer.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
class FilterTreeModel;
|
class FilterTreeModel;
|
||||||
|
|
@ -50,6 +51,7 @@ private:
|
||||||
QMap<QString, QPushButton *> typeButtons; // Store toggle buttons
|
QMap<QString, QPushButton *> typeButtons; // Store toggle buttons
|
||||||
|
|
||||||
bool exactMatchMode = true; // Toggle between "Exact Match" and "Includes"
|
bool exactMatchMode = true; // Toggle between "Exact Match" and "Includes"
|
||||||
|
QtUtils::Debouncer syncDebouncer{100};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISUAL_DATABASE_DISPLAY_SUB_TYPE_FILTER_WIDGET_H
|
#endif // VISUAL_DATABASE_DISPLAY_SUB_TYPE_FILTER_WIDGET_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue