More granular decklist signals (#5981)

* Performance stuffs.

* Actually make widgets track their indices.

* Functional stuff.

* More display stuff.

* Determine where we will insert the card before actually inserting it in the model.

* Allow overlap layouts to insert widgets at specific positions.

* Modified signals.

* Raise trailing widgets on overlap layout widget insertion.

* Nix the logging config changes.

* Lint.

* Address comments.

* Address comments.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-06-13 19:21:34 +02:00 committed by GitHub
parent 18d9c1d609
commit d5dc70ccee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 546 additions and 322 deletions

View file

@ -548,6 +548,17 @@ void FlowLayout::addItem(QLayoutItem *item)
}
}
void FlowLayout::insertWidgetAtIndex(QWidget *toInsert, int index)
{
addChildWidget(toInsert);
// We don't want to fail on an index that violates the bounds, so we just clamp it.
int boundedIndex = qBound(0, index, qMax(0, static_cast<int>(items.size())));
items.insert(boundedIndex, new QWidgetItem(toInsert));
invalidate();
}
/**
* @brief Retrieves the count of items in the layout.
* @return The number of layout items.

View file

@ -15,6 +15,7 @@ public:
explicit FlowLayout(QWidget *parent = nullptr);
FlowLayout(QWidget *parent, Qt::Orientation _flowDirection, int margin = 0, int hSpacing = 0, int vSpacing = 0);
~FlowLayout() override;
void insertWidgetAtIndex(QWidget *toInsert, int index);
QSize calculateMinimumSizeHorizontal() const;
QSize calculateSizeHintVertical() const;

View file

@ -54,6 +54,19 @@ OverlapLayout::~OverlapLayout()
}
}
void OverlapLayout::insertWidgetAtIndex(QWidget *toInsert, int index)
{
addChildWidget(toInsert);
int clampedIndex = qBound(0, index, qMax(0, static_cast<int>(itemList.size())));
itemList.insert(clampedIndex, new QWidgetItem(toInsert));
for (int i = clampedIndex; i < itemList.size(); ++i) {
dynamic_cast<QWidgetItem *>(itemList.at(i))->widget()->raise();
}
invalidate();
}
/**
* @brief Adds a new item to the layout.
*

View file

@ -18,6 +18,7 @@ public:
Qt::Orientation overlapDirection = Qt::Vertical,
Qt::Orientation flowDirection = Qt::Horizontal);
~OverlapLayout();
void insertWidgetAtIndex(QWidget *toInsert, int index);
void addItem(QLayoutItem *item) override;
int count() const override;