mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-08 17:13:57 -07:00
Fix infinite scroll triggering in detail view.
Took 25 minutes Took 3 seconds
This commit is contained in:
parent
866c9b8ba0
commit
d0c93f19d1
2 changed files with 12 additions and 2 deletions
|
|
@ -29,7 +29,8 @@
|
||||||
#include <libcockatrice/models/database/card/card_search_model.h>
|
#include <libcockatrice/models/database/card/card_search_model.h>
|
||||||
#include <version_string.h>
|
#include <version_string.h>
|
||||||
|
|
||||||
TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor), currentPage(1), isLoadingMore(false)
|
TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor)
|
||||||
|
: Tab(_tabSupervisor), currentPage(1), isLoadingMore(false), isListMode(true)
|
||||||
{
|
{
|
||||||
// Initialize network
|
// Initialize network
|
||||||
networkManager = new QNetworkAccessManager(this);
|
networkManager = new QNetworkAccessManager(this);
|
||||||
|
|
@ -185,13 +186,14 @@ bool TabArchidekt::eventFilter(QObject *obj, QEvent *event)
|
||||||
if (obj == scrollArea->viewport() && event->type() == QEvent::Wheel) {
|
if (obj == scrollArea->viewport() && event->type() == QEvent::Wheel) {
|
||||||
auto *wheelEvent = static_cast<QWheelEvent *>(event);
|
auto *wheelEvent = static_cast<QWheelEvent *>(event);
|
||||||
|
|
||||||
if (wheelEvent->angleDelta().y() < 0 && !isLoadingMore) {
|
if (wheelEvent->angleDelta().y() < 0 && !isLoadingMore && isListMode) {
|
||||||
loadNextPage();
|
loadNextPage();
|
||||||
wheelEvent->accept();
|
wheelEvent->accept();
|
||||||
return false; // allow scrolling
|
return false; // allow scrolling
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Always pass the event to the parent to handle normal scrolling
|
||||||
return QWidget::eventFilter(obj, event);
|
return QWidget::eventFilter(obj, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -510,7 +512,11 @@ QString TabArchidekt::buildSearchUrl()
|
||||||
|
|
||||||
void TabArchidekt::doSearch()
|
void TabArchidekt::doSearch()
|
||||||
{
|
{
|
||||||
|
// Reset to first page on new search
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
|
// We're searching, so we'll be in list mode
|
||||||
|
isListMode = true;
|
||||||
|
// Don't debounce - only called by explicit user actions now
|
||||||
doSearchImmediate();
|
doSearchImmediate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -617,6 +623,9 @@ void TabArchidekt::processDeckResponse(QJsonObject reply)
|
||||||
ArchidektApiResponseDeck deckData;
|
ArchidektApiResponseDeck deckData;
|
||||||
deckData.fromJson(reply);
|
deckData.fromJson(reply);
|
||||||
|
|
||||||
|
// We're in single deck mode - disable infinite scroll
|
||||||
|
isListMode = false;
|
||||||
|
|
||||||
// Clear existing results for single deck view
|
// Clear existing results for single deck view
|
||||||
QLayoutItem *item;
|
QLayoutItem *item;
|
||||||
while ((item = resultsLayout->takeAt(0)) != nullptr) {
|
while ((item = resultsLayout->takeAt(0)) != nullptr) {
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,7 @@ private:
|
||||||
QTimer *searchDebounceTimer; ///< Timer to debounce search requests
|
QTimer *searchDebounceTimer; ///< Timer to debounce search requests
|
||||||
int currentPage; ///< Current page number for infinite scroll
|
int currentPage; ///< Current page number for infinite scroll
|
||||||
bool isLoadingMore; ///< Flag to prevent multiple simultaneous page loads
|
bool isLoadingMore; ///< Flag to prevent multiple simultaneous page loads
|
||||||
|
bool isListMode;
|
||||||
ArchidektApiResponseDeckListingsDisplayWidget *listingsWidget = nullptr;
|
ArchidektApiResponseDeckListingsDisplayWidget *listingsWidget = nullptr;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue