From bb09cc2a37dbee65b1cfac07dad7bee288f6e958 Mon Sep 17 00:00:00 2001 From: jared Date: Fri, 13 Nov 2020 12:03:23 +0800 Subject: [PATCH] updat tables; add PropertyHelper.h --- 3rdparty/TaoCommon/Common/PropertyHelper.h | 47 +++++++++++++++++++ 3rdparty/TaoCommon/TaoCommon.pri | 1 + .../TaoQuickShow/Contents/General/Tables.qml | 19 +++----- 3 files changed, 54 insertions(+), 13 deletions(-) create mode 100644 3rdparty/TaoCommon/Common/PropertyHelper.h diff --git a/3rdparty/TaoCommon/Common/PropertyHelper.h b/3rdparty/TaoCommon/Common/PropertyHelper.h new file mode 100644 index 0000000..a339ca4 --- /dev/null +++ b/3rdparty/TaoCommon/Common/PropertyHelper.h @@ -0,0 +1,47 @@ +#pragma once +#include + +#define READ_PROPERTY(TYPE, NAME) \ +private: \ + Q_PROPERTY(TYPE NAME READ NAME NOTIFY NAME##Changed) \ +public: \ + const TYPE &NAME() const \ + { \ + return m_##NAME; \ + } \ + Q_SIGNAL void NAME##Changed(const TYPE &value); \ + \ +private: \ + TYPE m_##NAME; + +#define READONLY_PROPERTY(TYPE, NAME) \ +private: \ + Q_PROPERTY(TYPE NAME READ NAME CONSTANT) \ +public: \ + const TYPE &NAME() const \ + { \ + return m_##NAME; \ + } \ + \ +private: \ + TYPE m_##NAME; + +#define AUTO_PROPERTY(TYPE, NAME) \ +private: \ + Q_PROPERTY(TYPE NAME READ NAME WRITE NAME NOTIFY NAME##Changed) \ +public: \ + const TYPE &NAME() const \ + { \ + return m_##NAME; \ + } \ + void NAME(const TYPE &value) \ + { \ + if (m_##NAME == value) \ + return; \ + m_##NAME = value; \ + emit NAME##Changed(value); \ + } \ + Q_SIGNAL void NAME##Changed(const TYPE &value); \ + \ +private: \ + TYPE m_##NAME; diff --git a/3rdparty/TaoCommon/TaoCommon.pri b/3rdparty/TaoCommon/TaoCommon.pri index c3d18ae..538258d 100644 --- a/3rdparty/TaoCommon/TaoCommon.pri +++ b/3rdparty/TaoCommon/TaoCommon.pri @@ -6,6 +6,7 @@ INCLUDEPATH += $$PWD HEADERS += \ $$PWD/Common/FileReadWrite.h \ + $$PWD/Common/PropertyHelper.h \ $$PWD/Common/ObjectMap.h \ $$PWD/QuickTool/QuickTool.h \ $$PWD/Common/Subject.h \ diff --git a/examples/TaoQuickShow/Contents/General/Tables.qml b/examples/TaoQuickShow/Contents/General/Tables.qml index 50d1137..1e0ed25 100644 --- a/examples/TaoQuickShow/Contents/General/Tables.qml +++ b/examples/TaoQuickShow/Contents/General/Tables.qml @@ -16,16 +16,13 @@ Item { Row { spacing: 10 CusLabel { - text: qsTr("selectCount: %1").arg( - deviceAddModel.selectedCount) + trans.transString + text: qsTr("selectCount: %1").arg(deviceAddModel.selectedCount) + trans.transString } CusLabel { - text: qsTr("checkedCount: %1").arg( - deviceAddModel.checkedCount) + trans.transString + text: qsTr("checkedCount: %1").arg(deviceAddModel.checkedCount) + trans.transString } CusLabel { - text: qsTr("visibledCount: %1").arg( - deviceAddModel.visibledCount) + trans.transString + text: qsTr("visibledCount: %1").arg(deviceAddModel.visibledCount) + trans.transString } } CusTextField_Search { @@ -98,9 +95,7 @@ Item { && mouseX <= cusHeader.xList[2]) { editInput.x = cusHeader.xList[1] - editInput.y = cusView.y + (parseInt( - mouseY / CusConfig.fixedHeight)) - * CusConfig.fixedHeight + editInput.y = cusView.y + (parseInt(mouseY / CusConfig.fixedHeight)) * CusConfig.fixedHeight editInput.width = cusHeader.widthList[1] editInput.height = CusConfig.fixedHeight editInput.index = index @@ -334,8 +329,7 @@ Item { text: qsTr(" * Check All rows by header of Column 0") + trans.transString } CusLabel { - text: qsTr(" * Edit Column 1 by double click, and update data to model after edit") - + trans.transString + text: qsTr(" * Edit Column 1 by double click, and update data to model after edit") + trans.transString } CusLabel { text: qsTr(" * Fuzzy search") + trans.transString @@ -344,8 +338,7 @@ Item { text: qsTr(" * Reset column width by drag header splite line") + trans.transString } CusLabel { - text: qsTr(" * Sort by click header, click again can switch ascending or descending") - + trans.transString + text: qsTr(" * Sort by click header, click again can switch ascending or descending") + trans.transString } } }