mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Update TableView and TableModel in DigitalLibrary plugin.
This is not backwards compatible with Cura < 5.0 due to the removal of Qt.labs CURA-8640
This commit is contained in:
parent
184f4b808e
commit
e86f860a2c
2 changed files with 26 additions and 15 deletions
|
@ -1,7 +1,6 @@
|
||||||
//Copyright (C) 2022 Ultimaker B.V.
|
//Copyright (C) 2022 Ultimaker B.V.
|
||||||
//Cura is released under the terms of the LGPLv3 or higher.
|
//Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import Qt.labs.qmlmodels 1.0
|
|
||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
|
@ -19,6 +18,7 @@ Item
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
property var fileModel: manager.digitalFactoryFileModel
|
property var fileModel: manager.digitalFactoryFileModel
|
||||||
|
property var modelRows: manager.digitalFactoryFileModel.items
|
||||||
|
|
||||||
signal openFilePressed()
|
signal openFilePressed()
|
||||||
signal selectDifferentProjectPressed()
|
signal selectDifferentProjectPressed()
|
||||||
|
@ -57,9 +57,8 @@ Item
|
||||||
border.width: UM.Theme.getSize("default_lining").width
|
border.width: UM.Theme.getSize("default_lining").width
|
||||||
border.color: UM.Theme.getColor("lining")
|
border.color: UM.Theme.getColor("lining")
|
||||||
|
|
||||||
//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.
|
// This is not backwards compatible with Cura < 5.0 due to QT.labs being removed in PyQt6
|
||||||
//So we have to define our own. Once support for 4.13 and earlier is dropped, we can switch to Cura.TableView.
|
Cura.TableView
|
||||||
Table
|
|
||||||
{
|
{
|
||||||
id: filesTableView
|
id: filesTableView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -68,8 +67,9 @@ Item
|
||||||
columnHeaders: ["Name", "Uploaded by", "Uploaded at"]
|
columnHeaders: ["Name", "Uploaded by", "Uploaded at"]
|
||||||
model: UM.TableModel
|
model: UM.TableModel
|
||||||
{
|
{
|
||||||
|
id: tableModel
|
||||||
headers: ["fileName", "username", "uploadedAt"]
|
headers: ["fileName", "username", "uploadedAt"]
|
||||||
rows: manager.digitalFactoryFileModel.items
|
rows: modelRows
|
||||||
}
|
}
|
||||||
|
|
||||||
onCurrentRowChanged:
|
onCurrentRowChanged:
|
||||||
|
@ -177,4 +177,10 @@ Item
|
||||||
openFilesButton.clicked.connect(base.openFilePressed)
|
openFilesButton.clicked.connect(base.openFilePressed)
|
||||||
selectDifferentProjectButton.clicked.connect(base.selectDifferentProjectPressed)
|
selectDifferentProjectButton.clicked.connect(base.selectDifferentProjectPressed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onModelRowsChanged:
|
||||||
|
{
|
||||||
|
tableModel.clear()
|
||||||
|
tableModel.rows = modelRows
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,11 @@
|
||||||
//Copyright (C) 2022 Ultimaker B.V.
|
//Copyright (C) 2022 Ultimaker B.V.
|
||||||
//Cura is released under the terms of the LGPLv3 or higher.
|
//Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import Qt.labs.qmlmodels 1.0
|
import QtQuick 2.15
|
||||||
import QtQuick 2.10
|
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
|
|
||||||
import UM 1.5 as UM
|
import UM 1.6 as UM
|
||||||
import Cura 1.6 as Cura
|
import Cura 1.6 as Cura
|
||||||
|
|
||||||
import DigitalFactory 1.0 as DF
|
import DigitalFactory 1.0 as DF
|
||||||
|
@ -17,7 +16,9 @@ Item
|
||||||
id: base
|
id: base
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
property var fileModel: manager.digitalFactoryFileModel
|
property var fileModel: manager.digitalFactoryFileModel
|
||||||
|
property var modelRows: manager.digitalFactoryFileModel.items
|
||||||
|
|
||||||
signal savePressed()
|
signal savePressed()
|
||||||
signal selectDifferentProjectPressed()
|
signal selectDifferentProjectPressed()
|
||||||
|
@ -92,9 +93,8 @@ Item
|
||||||
border.width: UM.Theme.getSize("default_lining").width
|
border.width: UM.Theme.getSize("default_lining").width
|
||||||
border.color: UM.Theme.getColor("lining")
|
border.color: UM.Theme.getColor("lining")
|
||||||
|
|
||||||
//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.
|
// This is not backwards compatible with Cura < 5.0 due to QT.labs being removed in PyQt6
|
||||||
//So we have to define our own. Once support for 4.13 and earlier is dropped, we can switch to Cura.TableView.
|
Cura.TableView
|
||||||
Table
|
|
||||||
{
|
{
|
||||||
id: filesTableView
|
id: filesTableView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -102,11 +102,10 @@ Item
|
||||||
|
|
||||||
allowSelection: false
|
allowSelection: false
|
||||||
columnHeaders: ["Name", "Uploaded by", "Uploaded at"]
|
columnHeaders: ["Name", "Uploaded by", "Uploaded at"]
|
||||||
model: TableModel
|
model: UM.TableModel
|
||||||
{
|
{
|
||||||
TableModelColumn { display: "fileName" }
|
id: tableModel
|
||||||
TableModelColumn { display: "username" }
|
headers: ["fileName", "username", "uploadedAt"]
|
||||||
TableModelColumn { display: "uploadedAt" }
|
|
||||||
rows: manager.digitalFactoryFileModel.items
|
rows: manager.digitalFactoryFileModel.items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,4 +247,10 @@ Item
|
||||||
saveButton.clicked.connect(base.savePressed)
|
saveButton.clicked.connect(base.savePressed)
|
||||||
selectDifferentProjectButton.clicked.connect(base.selectDifferentProjectPressed)
|
selectDifferentProjectButton.clicked.connect(base.selectDifferentProjectPressed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onModelRowsChanged:
|
||||||
|
{
|
||||||
|
tableModel.clear()
|
||||||
|
tableModel.rows = modelRows
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue