diff --git a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.cpp b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.cpp index 46ed3c7..1f841c6 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.cpp @@ -6,3 +6,42 @@ QuickListItemBase::QuickListItemBase(QObject* parent) } QuickListItemBase::~QuickListItemBase() { } + +bool QuickListItemBase::isChecked() const +{ + return m_isChecked; +} + +void QuickListItemBase::set_isChecked(bool newIsChecked) +{ + if (m_isChecked == newIsChecked) + return; + m_isChecked = newIsChecked; + emit isCheckedChanged(); +} + +bool QuickListItemBase::isSelected() const +{ + return m_isSelected; +} + +void QuickListItemBase::set_isSelected(bool newIsSelected) +{ + if (m_isSelected == newIsSelected) + return; + m_isSelected = newIsSelected; + emit isSelectedChanged(); +} + +bool QuickListItemBase::isAlternate() const +{ + return m_isAlternate; +} + +void QuickListItemBase::set_isAlternate(bool newIsAlternate) +{ + if (m_isAlternate == newIsAlternate) + return; + m_isAlternate = newIsAlternate; + emit isAlternateChanged(); +} diff --git a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.h b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.h index a333698..ef70211 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.h +++ b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.h @@ -6,13 +6,17 @@ class TAO_API QuickListItemBase : public QObject { Q_OBJECT - AUTO_PROPERTY_V2(bool, isChecked, false) - AUTO_PROPERTY_V2(bool, isSelected, false) - AUTO_PROPERTY_V2(bool, isAlternate, false) -signals: - void isCheckedChanged(bool); - void isSelectedChanged(bool); - void isAlternateChanged(bool); + Q_PROPERTY(bool isChecked READ isChecked WRITE set_isChecked NOTIFY isCheckedChanged) + Q_PROPERTY(bool isSelected READ isSelected WRITE set_isSelected NOTIFY isSelectedChanged) + Q_PROPERTY(bool isAlternate READ isAlternate WRITE set_isAlternate NOTIFY isAlternateChanged FINAL) + + // AUTO_PROPERTY_V2(bool, isChecked, false) + // AUTO_PROPERTY_V2(bool, isSelected, false) + // AUTO_PROPERTY_V2(bool, isAlternate, false) + // signals: + // void isCheckedChanged(bool); + // void isSelectedChanged(bool); + // void isAlternateChanged(bool); public: explicit QuickListItemBase(QObject* parent = nullptr); @@ -38,5 +42,24 @@ class TAO_API QuickListItemBase : public QObject return true; } + bool isChecked() const; + void set_isChecked(bool newIsChecked); + + bool isSelected() const; + void set_isSelected(bool newIsSelected); + + bool isAlternate() const; + void set_isAlternate(bool newIsAlternate); + +signals: + void isCheckedChanged(); + + void isSelectedChanged(); + + void isAlternateChanged(); + private: + bool m_isChecked = false; + bool m_isSelected = false; + bool m_isAlternate = false; }; diff --git a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.cpp b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.cpp index b63b6fb..a543c15 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.cpp +++ b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.cpp @@ -338,3 +338,94 @@ void QuickListModel::updateCalcInfo() updateAlternate(); emit signalUpdateCalcCount(); } + +int QuickListModel::visibledCount() const +{ + return m_visibledCount; +} + +void QuickListModel::set_visibledCount(int newVisibleCount) +{ + if (m_visibledCount == newVisibleCount) + return; + m_visibledCount = newVisibleCount; + emit visibledCountChanged(); +} + +int QuickListModel::selectedCount() const +{ + return m_selectedCount; +} + +void QuickListModel::set_selectedCount(int newSelectedCount) +{ + if (m_selectedCount == newSelectedCount) + return; + m_selectedCount = newSelectedCount; + emit selectedCountChanged(); +} + +int QuickListModel::checkedCount() const +{ + return m_checkedCount; +} + +void QuickListModel::set_checkedCount(int newCheckedCount) +{ + if (m_checkedCount == newCheckedCount) + return; + m_checkedCount = newCheckedCount; + emit checkedCountChanged(); +} + +QStringList QuickListModel::headerRoles() const +{ + return m_headerRoles; +} + +void QuickListModel::set_headerRoles(const QStringList& newHeaderRoles) +{ + if (m_headerRoles == newHeaderRoles) + return; + m_headerRoles = newHeaderRoles; + emit headerRolesChanged(); +} + +Qt::SortOrder QuickListModel::sortOrder() const +{ + return m_sortOrder; +} + +void QuickListModel::set_sortOrder(Qt::SortOrder newSortOrder) +{ + if (m_sortOrder == newSortOrder) + return; + m_sortOrder = newSortOrder; + emit sortOrderChanged(); +} + +QString QuickListModel::sortRole() const +{ + return m_sortRole; +} + +void QuickListModel::set_sortRole(const QString& newSortRole) +{ + if (m_sortRole == newSortRole) + return; + m_sortRole = newSortRole; + emit sortRoleChanged(); +} + +QStringList QuickListModel::noSortRoles() const +{ + return m_noSortRoles; +} + +void QuickListModel::set_noSortRoles(const QStringList& newNoSortRoles) +{ + if (m_noSortRoles == newNoSortRoles) + return; + m_noSortRoles = newNoSortRoles; + emit noSortRolesChanged(); +} diff --git a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.h b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.h index 9d52943..184e357 100644 --- a/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.h +++ b/3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.h @@ -12,23 +12,32 @@ class TAO_API QuickListModel : public QuickModelBase Q_OBJECT Q_PROPERTY(bool allChecked READ allChecked WRITE setAllChecked NOTIFY allCheckedChanged) - AUTO_PROPERTY_V2(int, visibledCount, 0) - AUTO_PROPERTY_V2(int, selectedCount, 0) - AUTO_PROPERTY_V2(int, checkedCount, 0) - - AUTO_PROPERTY_V2(QStringList, headerRoles, {}) - AUTO_PROPERTY_V2(Qt::SortOrder, sortOrder, Qt::AscendingOrder) - AUTO_PROPERTY_V2(QString, sortRole, {}) - AUTO_PROPERTY_V2(QStringList, noSortRoles, {}) -signals: - void visibledCountChanged(int); - void selectedCountChanged(int); - void checkedCountChanged(int); - void headerRolesChanged(const QStringList&); - void sortOrderChanged(Qt::SortOrder); - void sortRoleChanged(const QString&); - void noSortRolesChanged(const QStringList&); - + Q_PROPERTY(int visibledCount READ visibledCount WRITE set_visibledCount NOTIFY visibledCountChanged FINAL) + Q_PROPERTY(int selectedCount READ selectedCount WRITE set_selectedCount NOTIFY selectedCountChanged FINAL) + Q_PROPERTY(int checkedCount READ checkedCount WRITE set_checkedCount NOTIFY checkedCountChanged FINAL) + + Q_PROPERTY(QStringList headerRoles READ headerRoles WRITE set_headerRoles NOTIFY headerRolesChanged FINAL) + Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE set_sortOrder NOTIFY sortOrderChanged FINAL) + Q_PROPERTY(QString sortRole READ sortRole WRITE set_sortRole NOTIFY sortRoleChanged FINAL) + Q_PROPERTY(QStringList noSortRoles READ noSortRoles WRITE set_noSortRoles NOTIFY noSortRolesChanged FINAL) + + // AUTO_PROPERTY_V2(int, visibledCount, 0) + // AUTO_PROPERTY_V2(int, selectedCount, 0) + // AUTO_PROPERTY_V2(int, checkedCount, 0) + + // AUTO_PROPERTY_V2(QStringList, headerRoles, {}) + // AUTO_PROPERTY_V2(Qt::SortOrder, sortOrder, Qt::AscendingOrder) + // AUTO_PROPERTY_V2(QString, sortRole, {}) + // AUTO_PROPERTY_V2(QStringList, noSortRoles, {}) + // signals: + // void visibledCountChanged(int); + // void selectedCountChanged(int); + // void checkedCountChanged(int); + // void headerRolesChanged(const QStringList&); + // void sortOrderChanged(Qt::SortOrder); + // void sortRoleChanged(const QString&); + // void noSortRolesChanged(const QStringList&); + public: using Super = QuickModelBase; explicit QuickListModel(QObject* parent = nullptr); @@ -98,6 +107,27 @@ class TAO_API QuickListModel : public QuickModelBase { emit scrollTo(index); } + int visibledCount() const; + void set_visibledCount(int newVisibleCount); + + int selectedCount() const; + void set_selectedCount(int newSelectedCount); + + int checkedCount() const; + void set_checkedCount(int newCheckedCount); + + QStringList headerRoles() const; + void set_headerRoles(const QStringList& newHeaderRoles); + + Qt::SortOrder sortOrder() const; + void set_sortOrder(Qt::SortOrder newSortOrder); + + QString sortRole() const; + void set_sortRole(const QString& newSortRole); + + QStringList noSortRoles() const; + void set_noSortRoles(const QStringList& newNoSortRoles); + public slots: void setAllChecked(bool allChecked); @@ -111,6 +141,20 @@ public slots: void beginSearch(); void endSearch(); + void visibledCountChanged(); + + void selectedCountChanged(); + + void checkedCountChanged(); + + void headerRolesChanged(); + + void sortOrderChanged(); + + void sortRoleChanged(); + + void noSortRolesChanged(); + protected slots: void onSearch(); @@ -124,7 +168,19 @@ protected slots: protected: bool mAllChecked = false; bool mIsPressed = false; + int m_visibledCount = 0; + + int m_selectedCount = 0; + + int m_checkedCount = 0; + + QStringList m_headerRoles; + + Qt::SortOrder m_sortOrder = Qt::AscendingOrder; + + QString m_sortRole; + QStringList m_noSortRoles; int mLastPressedRow = -1; QMap mSortCallbacksAscend; diff --git a/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.cpp b/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.cpp index 3424eb4..f7f1bfe 100644 --- a/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.cpp +++ b/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.cpp @@ -27,3 +27,55 @@ bool DeviceAddItem::match(const QString& key) } return false; } + +bool DeviceAddItem::online() const +{ + return m_online; +} + +void DeviceAddItem::set_online(bool newOnline) +{ + if (m_online == newOnline) + return; + m_online = newOnline; + emit onlineChanged(); +} + +QString DeviceAddItem::modelString() const +{ + return m_modelString; +} + +void DeviceAddItem::set_modelString(const QString& newModelString) +{ + if (m_modelString == newModelString) + return; + m_modelString = newModelString; + emit modelStringChanged(); +} + +QString DeviceAddItem::address() const +{ + return m_address; +} + +void DeviceAddItem::set_address(const QString& newAddress) +{ + if (m_address == newAddress) + return; + m_address = newAddress; + emit addressChanged(); +} + +QString DeviceAddItem::name() const +{ + return m_name; +} + +void DeviceAddItem::set_name(const QString& newName) +{ + if (m_name == newName) + return; + m_name = newName; + emit nameChanged(); +} diff --git a/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.h b/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.h index 76fb001..e1c8f01 100644 --- a/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.h +++ b/examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.h @@ -7,15 +7,19 @@ class DeviceAddItem : public QuickListItemBase { Q_OBJECT - AUTO_PROPERTY_V2(QString, name, "") - AUTO_PROPERTY_V2(QString, address, "") - AUTO_PROPERTY_V2(QString, modelString, "") - AUTO_PROPERTY_V2(bool, online, false) -signals: - void nameChanged(const QString&); - void addressChanged(const QString&); - void modelStringChanged(const QString&); - void onlineChanged(bool); + Q_PROPERTY(QString name READ name WRITE set_name NOTIFY nameChanged FINAL) + Q_PROPERTY(QString address READ address WRITE set_address NOTIFY addressChanged FINAL) + Q_PROPERTY(QString modelString READ modelString WRITE set_modelString NOTIFY modelStringChanged FINAL) + Q_PROPERTY(bool online READ online WRITE set_online NOTIFY onlineChanged FINAL) + // AUTO_PROPERTY_V2(QString, name, "") + // AUTO_PROPERTY_V2(QString, address, "") + // AUTO_PROPERTY_V2(QString, modelString, "") + // AUTO_PROPERTY_V2(bool, online, false) + // signals: + // void nameChanged(const QString&); + // void addressChanged(const QString&); + // void modelStringChanged(const QString&); + // void onlineChanged(bool); public: explicit DeviceAddItem(QObject* parent = nullptr); @@ -27,6 +31,31 @@ class DeviceAddItem : public QuickListItemBase return m_ipv4Address; } + bool online() const; + void set_online(bool newOnline); + + QString modelString() const; + void set_modelString(const QString& newModelString); + + QString address() const; + void set_address(const QString& newAddress); + + QString name() const; + void set_name(const QString& newName); + +signals: + void onlineChanged(); + + void modelStringChanged(); + + void addressChanged(); + + void nameChanged(); + private: quint32 m_ipv4Address = 0; + bool m_online; + QString m_modelString; + QString m_address; + QString m_name; };