1
0
mirror of https://github.com/jaredtao/TaoQuick.git synced 2025-01-17 20:12:54 +08:00

update table

This commit is contained in:
jared 2020-10-27 23:04:57 +08:00
parent 791080fddb
commit 5e6df1a993
17 changed files with 198 additions and 33 deletions

View File

@ -48,5 +48,6 @@
<file>Contents/ShaderEffect/Planet1.png</file>
<file>Contents/ShaderEffect/Snail.qml</file>
<file>Contents/ShaderEffect/SuperMario.qml</file>
<file>Contents/General/Tables.qml</file>
</qresource>
</RCC>

View File

@ -0,0 +1,127 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import TaoQuick 1.0
Item {
anchors.fill: parent
Rectangle {
id: mainItem
width: 800
height: 600
border.color: "steelblue"
anchors.centerIn: parent
Row {
spacing: 10
CusLabel {
text: qsTr("selectCount: %1").arg(deviceAddModel.selectedCount) + trans.transString
}
CusLabel {
text: qsTr("checkedCount: %1").arg(deviceAddModel.checkedCount) + trans.transString
}
CusLabel {
text: qsTr("visibledCount: %1").arg(deviceAddModel.visibledCount) + trans.transString
}
}
CusTextField_Search {
anchors {
right: parent.right
rightMargin: 10
top: parent.top
}
onTextChanged: {
deviceAddModel.search(text)
}
placeholderText: qsTr("Search") + trans.transString
}
CusTableHeader {
id: cusHeader
y: 50
width: parent.width
height: 30
averageCount: 4
averageSize: 1.0
dataObj: deviceAddModel
headerNames: deviceAddModel.headerRoles
headerRoles: deviceAddModel.headerRoles
widthList: cusView.widthList
xList: cusView.xList
}
CusTableView {
id: cusView
y: cusHeader.y + cusHeader.height
width: parent.width
height: parent.height - y - 40
model: deviceAddModel
onPressed: {
doPress(mouseX, mouseY)
}
onReleased: {
doRelease()
}
onPositionChanged: {
doPositionChanged(mouseX, mouseY)
}
onDoubleClicked: {
var index = indexAt(mouseX, mouseY + contentY)
if (index < 0 || index >= count) {
return
}
if (cusHeader.xList[1] <= mouseX && mouseX <= cusHeader.xList[2]) {
editInput.x = cusHeader.xList[1]
editInput.y = cusView.y + (parseInt(mouseY / CusConfig.fixedHeight)) * CusConfig.fixedHeight
editInput.width = cusHeader.widthList[1]
editInput.height = CusConfig.fixedHeight
editInput.index = index
var dataObj = deviceAddModel.data(index)
editInput.text = dataObj[deviceAddModel.headerRoles[0]]
editInput.visible = true
editInput.focus = true
}
}
delegate: CusTableRow {
width: cusView.width
roles: cusView.model.headerRoles
dataObj: model.display
widthList: cusHeader.widthList
xList: cusHeader.xList
onCheckedChanged: {
deviceAddModel.check(index, checked)
}
}
}
CusTextField {
id: editInput
visible: false
onEditingFinished: {
deviceAddModel.doUpdateName(index, text)
visible = false
}
property int index: -1
onFocusChanged: {
if (!focus) {
deviceAddModel.doUpdateName(index, text)
visible = false
}
}
}
Column {
x: cusHeader.x + cusHeader.mouseX
y: cusView.y
visible: cusHeader.isSpliting && !cusHeader.isOut
height: cusView.height
width: 1
spacing: 2
Repeater {
model: (cusHeader.isSpliting
&& !cusHeader.isOut) ? parent.height / 6 : 0
Rectangle {
width: 1
height: 4
color: CusConfig.splitLineColor
}
}
}
}
}

View File

@ -23,7 +23,6 @@ ListModel {
group: "General"
groupOpen: true
}
ListElement {
name: "Data Entry"
source: "General/DataEntrys.qml"
@ -31,6 +30,13 @@ ListModel {
group: "General"
groupOpen: true
}
ListElement {
name: "Table"
source: "General/Tables.qml"
visible: true
group: "General"
groupOpen: true
}
ListElement {
name: "Drag Rect"
source: "General/Drags.qml"

View File

@ -32,3 +32,17 @@ DeviceAddModel::DeviceAddModel(QObject *parent)
};
setSortCallbacks(callBacks);
}
void DeviceAddModel::doUpdateName(int row, const QString &name)
{
if (row < 0 || row >= rowCount({}))
{
return;
}
const auto &n = name.simplified();
if (n.isEmpty())
{
return;
}
static_cast<DeviceAddItem *>(mObjs.at(row))->setName(name);
}

View File

@ -8,6 +8,8 @@ class DeviceAddModel : public QuickListModel
public:
explicit DeviceAddModel(QObject *parent = nullptr);
public slots:
void doUpdateName(int row, const QString &name);
signals:
};

View File

@ -416,7 +416,26 @@
{
"key": "Go to",
"value": "转到"
},
{
"key": "Table",
"value": "表格"
},
{
"key": "Tree",
"value": "树"
},
{
"key": "selectCount: %1",
"value": "选中数量: %1"
},
{
"key": "checkedCount: %1",
"value": "打勾数量: %1"
},
{
"key": "visibledCount: %1",
"value": "可见数量: %1"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

View File

@ -111,7 +111,7 @@ QtObject {
splitLineColor:"#f38d8d"
invalidColor: "#e29696"
alterColor: "#6a6a6b"
alterColor: "#8a8a9b"
tipBackgroundColor: "#ffffff"
tipBorderColor: "#767676"
@ -155,7 +155,7 @@ QtObject {
splitLineColor:"#c62f2f"
invalidColor: "#e29696"
alterColor: "#6a6a6b"
alterColor: "#8a8a9b"
tipBackgroundColor: "#ffffff"
tipBorderColor: "#767676"
@ -177,7 +177,7 @@ QtObject {
splitLineColor:"#c62f2f"
invalidColor: "#e29696"
alterColor: "#6a6a6b"
alterColor: "#8a8a9b"
tipBackgroundColor: "#ffffff"
tipBorderColor: "#767676"
@ -199,7 +199,7 @@ QtObject {
splitLineColor:"#c62f2f"
invalidColor: "#e29696"
alterColor: "#6a6a6b"
alterColor: "#8a8a9b"
tipBackgroundColor: "#ffffff"
tipBorderColor: "#767676"
@ -221,7 +221,7 @@ QtObject {
splitLineColor:"#c62f2f"
invalidColor: "#e29696"
alterColor: "#6a6a6b"
alterColor: "#8a8a9b"
tipBackgroundColor: "#ffffff"
tipBorderColor: "#767676"

View File

@ -3,7 +3,7 @@ pragma Singleton
import QtQuick 2.9
QtObject {
readonly property int column0Width: 40
readonly property int column0Width: 50
readonly property int minWidth: 30
readonly property int maxWidth: 400
function bound(minValue, midValue, maxValue) {

View File

@ -70,8 +70,9 @@ Item {
height: CusConfig.fixedHeight
CusCheckBox {
id: checkAllBox
anchors.centerIn: parent
height: CusConfig.fixedHeight
anchors.verticalCenter: parent.verticalCenter
x: 6
height: 24
width: height
property bool notify: true
onCheckedChanged: {
@ -104,7 +105,7 @@ Item {
color: CusConfig.textColor_pressed
}
Rectangle {
width: 1
width: 2
anchors {
left: parent.left
top: parent.top
@ -121,9 +122,11 @@ Item {
top: parent.top
}
readonly property string ascUrl: CusConfig.imagePathPrefix + "Table_Asc.png"
readonly property string ascUrl_Hovered: CusConfig.imagePathPrefix + "Table_Asc_Hover.png"
readonly property string ascUrl_Hovered: CusConfig.imagePathPrefix
+ "Table_Asc_Hovered.png"
readonly property string descUrl: CusConfig.imagePathPrefix + "Table_Desc.png"
readonly property string descUrl_Hovered: CusConfig.imagePathPrefix + "Table_DescHover.png"
readonly property string descUrl_Hovered: CusConfig.imagePathPrefix
+ "Table_Desc_Hovered.png"
property string ascImageUrl: (headerArea.containsMouse) ? ascUrl_Hovered : ascUrl
property string descImageUrl: (headerArea.containsMouse) ? descUrl_Hovered : descUrl
@ -136,8 +139,11 @@ Item {
id: headerArea
hoverEnabled: true
anchors {
fill: parent
left: parent.left
leftMargin: 4
right: parent.right
top: parent.top
bottom: parent.bottom
}
onClicked: {
if (dataObj.sortRole !== headerRoles[index]) {
@ -157,6 +163,7 @@ Item {
width: 4
height: parent.height
enabled: index > 0
hoverEnabled: true
anchors {
left: parent.left
}

View File

@ -22,10 +22,9 @@ Rectangle {
property var xList
property var roles
property color textColor: CusConfig.textColor
property bool showOnlineState: true
signal checkedChanged(bool checked)
color: isSelected ? CusConfig.controlColor_pressed : ( isAlternate ? CusConfig.controlColor : CusConfig.alterColor )
color: isSelected ? CusConfig.controlColor_pressed : ( isAlternate ? CusConfig.controlColor : Qt.darker(CusConfig.controlColor, 1.1) )
Item {
id: checkBoxItem
width: widthList[0]
@ -33,9 +32,10 @@ Rectangle {
CusCheckBox {
id: checkBox
height: CusConfig.fixedHeight
anchors.verticalCenter: parent.verticalCenter
x: 6
height: 24
width: height
anchors.centerIn: parent
property bool notify: true
onCheckedChanged: {
if(notify) {
@ -43,21 +43,6 @@ Rectangle {
}
}
}
CusImage {
visible: showOnlineState
readonly property string cameraOnlineImg: CusConfig.imagePathPrefix
+ "Icon_Camera_Online.png"
readonly property string cameraOfflineImg: CusConfig.imagePathPrefix
+ "Icon_Camera_Offline.png"
source: dataObj["online"] ? cameraOnlineImg : cameraOfflineImg
width: 16
height: 16
anchors {
verticalCenter: parent.verticalCenter
left: checkBox.right
leftMargin: -10
}
}
}
Repeater {
model: roles

View File

@ -82,6 +82,8 @@
<file>Images/ComboBox_Down.png</file>
<file>Images/ellipsis.png</file>
<file>Images/Expanded.png</file>
<file>Images/Icon_Camera_Offline.png</file>
<file>Images/Icon_Camera_Online.png</file>
<file>Images/last.png</file>
<file>Images/left.png</file>
<file>Images/next.png</file>
@ -91,6 +93,8 @@
<file>Images/Search_Clear.png</file>
<file>Images/spinner.png</file>
<file>Images/Table_Asc.png</file>
<file>Images/Table_Asc_Hovered.png</file>
<file>Images/Table_Desc.png</file>
<file>Images/Table_Desc_Hovered.png</file>
</qresource>
</RCC>