mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 22:42:14 -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.
|
* @brief Adds a new item to the layout.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ public:
|
||||||
Qt::Orientation overlapDirection = Qt::Vertical,
|
Qt::Orientation overlapDirection = Qt::Vertical,
|
||||||
Qt::Orientation flowDirection = Qt::Horizontal);
|
Qt::Orientation flowDirection = Qt::Horizontal);
|
||||||
~OverlapLayout();
|
~OverlapLayout();
|
||||||
|
void insertWidgetAtIndex(QWidget *toInsert, int index);
|
||||||
|
|
||||||
void addItem(QLayoutItem *item) override;
|
void addItem(QLayoutItem *item) override;
|
||||||
int count() const override;
|
int count() const override;
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,7 @@ private:
|
||||||
|
|
||||||
void insertIntoLayout(QWidget *toInsert, int insertAt) override
|
void insertIntoLayout(QWidget *toInsert, int insertAt) override
|
||||||
{
|
{
|
||||||
Q_UNUSED(insertAt);
|
overlapWidget->insertWidgetAtIndex(toInsert, insertAt);
|
||||||
overlapWidget->addWidget(toInsert);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeFromLayout(QWidget *toRemove) override
|
void removeFromLayout(QWidget *toRemove) override
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,12 @@ void OverlapWidget::addWidget(QWidget *widgetToAdd) const
|
||||||
overlapLayout->addWidget(widgetToAdd);
|
overlapLayout->addWidget(widgetToAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OverlapWidget::insertWidgetAtIndex(QWidget *toInsert, int index)
|
||||||
|
{
|
||||||
|
overlapLayout->insertWidgetAtIndex(toInsert, index);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void OverlapWidget::removeWidget(QWidget *widgetToRemove) const
|
void OverlapWidget::removeWidget(QWidget *widgetToRemove) const
|
||||||
{
|
{
|
||||||
overlapLayout->removeWidget(widgetToRemove);
|
overlapLayout->removeWidget(widgetToRemove);
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ public:
|
||||||
Qt::Orientation direction,
|
Qt::Orientation direction,
|
||||||
bool adjustOnResize = false);
|
bool adjustOnResize = false);
|
||||||
void addWidget(QWidget *widgetToAdd) const;
|
void addWidget(QWidget *widgetToAdd) const;
|
||||||
|
void insertWidgetAtIndex(QWidget *toInsert, int index);
|
||||||
void removeWidget(QWidget *widgetToRemove) const;
|
void removeWidget(QWidget *widgetToRemove) const;
|
||||||
void clearLayout();
|
void clearLayout();
|
||||||
void adjustMaxColumnsAndRows();
|
void adjustMaxColumnsAndRows();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue