aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktreeview/testmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquicktreeview/testmodel.cpp')
-rw-r--r--tests/auto/quick/qquicktreeview/testmodel.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/auto/quick/qquicktreeview/testmodel.cpp b/tests/auto/quick/qquicktreeview/testmodel.cpp
index 9962234a06..66fbf9b656 100644
--- a/tests/auto/quick/qquicktreeview/testmodel.cpp
+++ b/tests/auto/quick/qquicktreeview/testmodel.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "testmodel.h"
@@ -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;
+}