From 83953b03b433c7f6771364b15d116eeff0df2ae3 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 25 Jan 2022 18:48:45 +0100 Subject: [PATCH] Use new table element for saving files as well Re-using that component. Contributes to issue CURA-8686. --- .../resources/qml/OpenProjectFilesPage.qml | 1 - .../resources/qml/SaveProjectFilesPage.qml | 43 +++++++------------ 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/plugins/DigitalLibrary/resources/qml/OpenProjectFilesPage.qml b/plugins/DigitalLibrary/resources/qml/OpenProjectFilesPage.qml index 6c74675227..5f594cb79e 100644 --- a/plugins/DigitalLibrary/resources/qml/OpenProjectFilesPage.qml +++ b/plugins/DigitalLibrary/resources/qml/OpenProjectFilesPage.qml @@ -4,7 +4,6 @@ import Qt.labs.qmlmodels 1.0 import QtQuick 2.15 import QtQuick.Window 2.2 -import QtQuick.Controls 1.4 as OldControls // TableView doesn't exist in the QtQuick Controls 2.x in 5.10, so use the old one import QtQuick.Controls 2.3 import UM 1.2 as UM diff --git a/plugins/DigitalLibrary/resources/qml/SaveProjectFilesPage.qml b/plugins/DigitalLibrary/resources/qml/SaveProjectFilesPage.qml index 139333c150..8d72ed9ff4 100644 --- a/plugins/DigitalLibrary/resources/qml/SaveProjectFilesPage.qml +++ b/plugins/DigitalLibrary/resources/qml/SaveProjectFilesPage.qml @@ -1,8 +1,9 @@ -// Copyright (C) 2021 Ultimaker B.V. +//Copyright (C) 2022 Ultimaker B.V. +//Cura is released under the terms of the LGPLv3 or higher. +import Qt.labs.qmlmodels 1.0 import QtQuick 2.10 import QtQuick.Window 2.2 -import QtQuick.Controls 1.4 as OldControls // TableView doesn't exist in the QtQuick Controls 2.x in 5.10, so use the old one import QtQuick.Controls 2.3 import UM 1.2 as UM @@ -85,35 +86,22 @@ Item border.width: UM.Theme.getSize("default_lining").width border.color: UM.Theme.getColor("lining") - - Cura.TableView + //We can't use Cura's TableView here, since in Cura >= 5.0 this uses QtQuick.TableView, while in Cura < 5.0 this uses QtControls1.TableView. + //So we have to define our own. Once support for 4.13 and earlier is dropped, we can switch to Cura.TableView. + Table { id: filesTableView anchors.fill: parent - model: manager.digitalFactoryFileModel - visible: model.count != 0 && manager.retrievingFileStatus != DF.RetrievalStatus.InProgress - selectionMode: OldControls.SelectionMode.NoSelection + anchors.margins: parent.border.width - OldControls.TableViewColumn + allowSelection: false + columnHeaders: ["Name", "Uploaded by", "Uploaded at"] + model: TableModel { - id: fileNameColumn - role: "fileName" - title: "@tableViewColumn:title", "Name" - width: Math.round(filesTableView.width / 3) - } - - OldControls.TableViewColumn - { - id: usernameColumn - role: "username" - title: "Uploaded by" - width: Math.round(filesTableView.width / 3) - } - - OldControls.TableViewColumn - { - role: "uploadedAt" - title: "Uploaded at" + TableModelColumn { display: "fileName" } + TableModelColumn { display: "username" } + TableModelColumn { display: "uploadedAt" } + rows: manager.digitalFactoryFileModel.items } } @@ -172,8 +160,7 @@ Item function onItemsChanged() { // Make sure no files are selected when the file model changes - filesTableView.currentRow = -1 - filesTableView.selection.clear() + filesTableView.currentRow = -1; } } }