Skip to content

Commit

Permalink
update property
Browse files Browse the repository at this point in the history
  • Loading branch information
jared2020 committed Dec 8, 2024
1 parent eba679c commit 5fc8835
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 33 deletions.
39 changes: 39 additions & 0 deletions 3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
37 changes: 30 additions & 7 deletions 3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
};
91 changes: 91 additions & 0 deletions 3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
90 changes: 73 additions & 17 deletions 3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,32 @@ class TAO_API QuickListModel : public QuickModelBase<QuickListItemBase*>
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<QuickListItemBase*>;
explicit QuickListModel(QObject* parent = nullptr);
Expand Down Expand Up @@ -98,6 +107,27 @@ class TAO_API QuickListModel : public QuickModelBase<QuickListItemBase*>
{
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);

Expand All @@ -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();

Expand All @@ -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<QString, SortCallback> mSortCallbacksAscend;
Expand Down
52 changes: 52 additions & 0 deletions examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Loading

0 comments on commit 5fc8835

Please sign in to comment.