idian: Fix RowList insert position and count

The rowLayout index is 0 which means the header was being inserted at
index -1. Qt interprets negative indexes as the end of the list, which
caused it to be inserted after the actual rows, rather than before.

This also makes the count of rows public.
This commit is contained in:
Warchamp7
2026-09-23 18:53:19 -04:00
committed by Ryan Foster
parent e042e8aa1d
commit da8745ac33
2 changed files with 9 additions and 2 deletions
@@ -35,6 +35,8 @@ public:
void addRow(QWidget *row);
void clear();
int count() const;
private:
QWidget *first = nullptr;
QWidget *last = nullptr;
+7 -2
View File
@@ -39,7 +39,7 @@ RowList::RowList(QWidget *parent) : QFrame(parent)
void idian::RowList::addHeader(QWidget *widget)
{
layout->insertWidget(layout->indexOf(rowLayout) - 1, widget);
layout->insertWidget(layout->indexOf(rowLayout), widget);
}
// Note: This function takes ownership of the added widget
@@ -48,7 +48,7 @@ void idian::RowList::addHeader(QWidget *widget)
void RowList::addRow(QWidget *widget)
{
// Add custom spacer when more than one row exists
if (rowLayout->count() > 0) {
if (count() > 0) {
rowLayout->addWidget(new RowListSpacer(this));
}
@@ -88,3 +88,8 @@ void RowList::clear()
adjustSize();
}
int idian::RowList::count() const
{
return rowLayout->count();
}