From da8745ac33b3b091854b58759503f8823405d8d9 Mon Sep 17 00:00:00 2001 From: Warchamp7 Date: Mon, 21 Sep 2026 14:54:25 -0400 Subject: [PATCH] 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. --- shared/qt/idian/include/Idian/RowList.hpp | 2 ++ shared/qt/idian/widgets/RowList.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/shared/qt/idian/include/Idian/RowList.hpp b/shared/qt/idian/include/Idian/RowList.hpp index 518e2cef3..44399e9b2 100644 --- a/shared/qt/idian/include/Idian/RowList.hpp +++ b/shared/qt/idian/include/Idian/RowList.hpp @@ -35,6 +35,8 @@ public: void addRow(QWidget *row); void clear(); + int count() const; + private: QWidget *first = nullptr; QWidget *last = nullptr; diff --git a/shared/qt/idian/widgets/RowList.cpp b/shared/qt/idian/widgets/RowList.cpp index fae414e53..887310fe1 100644 --- a/shared/qt/idian/widgets/RowList.cpp +++ b/shared/qt/idian/widgets/RowList.cpp @@ -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(); +}