diff options
author | Tarja Sundqvist <[email protected]> | 2025-06-03 13:43:35 +0300 |
---|---|---|
committer | Tarja Sundqvist <[email protected]> | 2025-06-03 13:43:35 +0300 |
commit | 0f0972d542d9869c2dcfaf9c963d42ff32766460 (patch) | |
tree | f283360ffbf0453e04a321e01f0c3df1c07df3e3 /tests/auto/quick/qquicktreeview/testmodel.cpp | |
parent | 07e23b0f4983631524716f034c0268fd11d037f9 (diff) | |
parent | ff0a47c8f267e905113b82c53af2742027f0eca6 (diff) |
Merge tag 'v6.5.6-lts-lgpl' into 6.56.5
Qt 6.5.6-lts-lgpl release
Diffstat (limited to 'tests/auto/quick/qquicktreeview/testmodel.cpp')
-rw-r--r-- | tests/auto/quick/qquicktreeview/testmodel.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktreeview/testmodel.cpp b/tests/auto/quick/qquicktreeview/testmodel.cpp index 9962234a06..a6a756ba68 100644 --- a/tests/auto/quick/qquicktreeview/testmodel.cpp +++ b/tests/auto/quick/qquicktreeview/testmodel.cpp @@ -128,3 +128,33 @@ bool TestModel::insertRows(int position, int rows, const QModelIndex &parent) endInsertRows(); return true; } + + +void insertColumnsRecursive(TreeItem *item, int row, int pos, int cols) +{ + for (int col = 0; col < cols; col++) + item->m_entries.insert(pos + col, QVariant(QString("%1, %2 (inserted)").arg(row).arg(pos + col))); + for (auto child : item->m_childItems) { + insertColumnsRecursive(child, row, pos, cols); + row++; + } +} + +bool TestModel::insertColumns(int position, int cols, const QModelIndex &parent) +{ + if (!parent.isValid()) { + qWarning() << "Cannot insert columns on an invalid parent!"; + return false; + } + + beginInsertColumns(parent, position, position + cols - 1); + TreeItem *parentItem = treeItem(parent); + + TreeItem *item = m_rootItem.data(); + + insertColumnsRecursive(item, 0, position, cols); + m_columnCount += cols; + + endInsertColumns(); + return true; +} |