[games/chessament] src: Extract TableView from TablePage

Manuel Alcaraz Zambrano <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit d6a5ffa5024e96ce6903b5fa98f1fb3c3821e908 by Manuel Alcaraz Zambrano.
Committed on 04/08/2026 at 10:19.
Pushed by manuelal into branch 'master'.

Extract TableView from TablePage

For better qmllint support.

M  +5    -2    src/CMakeLists.txt
R  +1    -1    src/qml/table/TableDelegate.qml [from: src/qml/TableDelegate.qml - 097% similarity]
R  +3    -22   src/qml/table/TablePage.qml [from: src/qml/TablePage.qml - 079% similarity]
A  +28   -0    src/qml/table/TablePageTableView.qml     [License: GPL(v3.0+)]

https://invent.kde.org/games/chessament/-/commit/d6a5ffa5024e96ce6903b5fa98f1fb3c3821e908

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8169c11..3ebac99 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -21,8 +21,6 @@ ecm_add_qml_module(chessament_static
         qml/components/TimeControlDelegate.qml
 
         qml/Main.qml
-        qml/TablePage.qml
-        qml/TableDelegate.qml
         qml/AddPlayerDialog.qml
         qml/AddTiebreakDialog.qml
         qml/DeletePairingsDialog.qml
@@ -39,6 +37,11 @@ ecm_add_qml_module(chessament_static
         qml/UpdateRatingsDialog.qml
         qml/WelcomePage.qml
 
+        # Table
+        qml/table/TableDelegate.qml
+        qml/table/TablePage.qml
+        qml/table/TablePageTableView.qml
+
         # Player details
         qml/player/PlayerDetails.qml
         qml/player/PlayerPairingsPage.qml
diff --git a/src/qml/TableDelegate.qml b/src/qml/table/TableDelegate.qml
similarity index 97%
rename from src/qml/TableDelegate.qml
rename to src/qml/table/TableDelegate.qml
index aa8a01b..bf821a7 100644
--- a/src/qml/TableDelegate.qml
+++ b/src/qml/table/TableDelegate.qml
@@ -18,7 +18,7 @@ T.ItemDelegate {
     required property bool selected
     required property bool current
     property Components.ConvergentContextMenu contextMenu: null
-    readonly property bool rowHovered: root.tableView.hoveredRow === row || hovered
+    readonly property bool rowHovered: (root.tableView as TablePageTableView).hoveredRow === row || hovered
     required property TableView tableView
     required property var model
 
diff --git a/src/qml/TablePage.qml b/src/qml/table/TablePage.qml
similarity index 79%
rename from src/qml/TablePage.qml
rename to src/qml/table/TablePage.qml
index 5f3117f..fee1c56 100644
--- a/src/qml/TablePage.qml
+++ b/src/qml/table/TablePage.qml
@@ -5,7 +5,6 @@
 pragma ComponentBehavior: Bound
 
 import QtQuick
-import QtQml.Models
 import QtQuick.Controls as Controls
 
 import org.kde.kirigami as Kirigami
@@ -77,33 +76,15 @@ Kirigami.Page {
             anchors.fill: parent
             anchors.topMargin: heading.height
 
-            TableView {
+            TablePageTableView {
                 id: tableView
 
-                property int hoveredRow: -1
-
                 model: root.model
-                delegateModelAccess: DelegateModel.ReadWrite
-
-                clip: true
-                pixelAligned: true
-                boundsBehavior: Flickable.StopAtBounds
-
-                selectionBehavior: root.selectionBehavior
-                selectionMode: TableView.SingleSelection
-
-                selectionModel: ItemSelectionModel {
-                    id: selectionModel
-
-                    onCurrentChanged: function (current, previous): void {
-                        tableView.itemAtIndex(current)?.forceActiveFocus();
-                    }
-                }
-
                 delegate: root.delegate
+                selectionBehavior: root.selectionBehavior
 
                 columnWidthProvider: function (column) {
-                    const w = root.tableView.explicitColumnWidth(column);
+                    const w = tableView.explicitColumnWidth(column);
                     if (w >= 0) {
                         return w;
                     }
diff --git a/src/qml/table/TablePageTableView.qml b/src/qml/table/TablePageTableView.qml
new file mode 100644
index 0000000..aded90c
--- /dev/null
+++ b/src/qml/table/TablePageTableView.qml
@@ -0,0 +1,28 @@
+// SPDX-FileCopyrightText: 2025 Carl Schwan <[email protected]>
+// SPDX-FileCopyrightText: 2025 Manuel Alcaraz Zambrano <[email protected]>
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+pragma ComponentBehavior: Bound
+
+import QtQuick
+import QtQml.Models as Models
+
+TableView {
+    id: tableView
+
+    property int hoveredRow: -1
+
+    delegateModelAccess: DelegateModel.ReadWrite
+
+    clip: true
+    pixelAligned: true
+    boundsBehavior: Flickable.StopAtBounds
+
+    selectionMode: TableView.SingleSelection
+
+    selectionModel: Models.ItemSelectionModel {
+        onCurrentChanged: function (current, previous): void {
+            tableView.itemAtIndex(current)?.forceActiveFocus();
+        }
+    }
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.