mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
Allow overlap layouts to insert widgets at specific positions.
This commit is contained in:
parent
dcd63e4a7f
commit
c4238838e7
5 changed files with 17 additions and 2 deletions
|
|
@ -54,6 +54,14 @@ OverlapLayout::~OverlapLayout()
|
|||
}
|
||||
}
|
||||
|
||||
void OverlapLayout::insertWidgetAtIndex(QWidget *toInsert, int index)
|
||||
{
|
||||
addChildWidget(toInsert);
|
||||
itemList.insert(qBound(0, index, std::max(0, static_cast<int>(itemList.size()))), new QWidgetItem(toInsert));
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Adds a new item to the layout.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ private:
|
|||
|
||||
void insertIntoLayout(QWidget *toInsert, int insertAt) override
|
||||
{
|
||||
Q_UNUSED(insertAt);
|
||||
overlapWidget->addWidget(toInsert);
|
||||
overlapWidget->insertWidgetAtIndex(toInsert, insertAt);
|
||||
}
|
||||
|
||||
void removeFromLayout(QWidget *toRemove) override
|
||||
|
|
|
|||
|
|
@ -59,6 +59,12 @@ void OverlapWidget::addWidget(QWidget *widgetToAdd) const
|
|||
overlapLayout->addWidget(widgetToAdd);
|
||||
}
|
||||
|
||||
void OverlapWidget::insertWidgetAtIndex(QWidget *toInsert, int index)
|
||||
{
|
||||
overlapLayout->insertWidgetAtIndex(toInsert, index);
|
||||
update();
|
||||
}
|
||||
|
||||
void OverlapWidget::removeWidget(QWidget *widgetToRemove) const
|
||||
{
|
||||
overlapLayout->removeWidget(widgetToRemove);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public:
|
|||
Qt::Orientation direction,
|
||||
bool adjustOnResize = false);
|
||||
void addWidget(QWidget *widgetToAdd) const;
|
||||
void insertWidgetAtIndex(QWidget *toInsert, int index);
|
||||
void removeWidget(QWidget *widgetToRemove) const;
|
||||
void clearLayout();
|
||||
void adjustMaxColumnsAndRows();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue