Skip to content

Commit 5fc8835

Browse files
committed
update property
1 parent eba679c commit 5fc8835

File tree

6 files changed

+323
-33
lines changed

6 files changed

+323
-33
lines changed

3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,42 @@ QuickListItemBase::QuickListItemBase(QObject* parent)
66
}
77

88
QuickListItemBase::~QuickListItemBase() { }
9+
10+
bool QuickListItemBase::isChecked() const
11+
{
12+
return m_isChecked;
13+
}
14+
15+
void QuickListItemBase::set_isChecked(bool newIsChecked)
16+
{
17+
if (m_isChecked == newIsChecked)
18+
return;
19+
m_isChecked = newIsChecked;
20+
emit isCheckedChanged();
21+
}
22+
23+
bool QuickListItemBase::isSelected() const
24+
{
25+
return m_isSelected;
26+
}
27+
28+
void QuickListItemBase::set_isSelected(bool newIsSelected)
29+
{
30+
if (m_isSelected == newIsSelected)
31+
return;
32+
m_isSelected = newIsSelected;
33+
emit isSelectedChanged();
34+
}
35+
36+
bool QuickListItemBase::isAlternate() const
37+
{
38+
return m_isAlternate;
39+
}
40+
41+
void QuickListItemBase::set_isAlternate(bool newIsAlternate)
42+
{
43+
if (m_isAlternate == newIsAlternate)
44+
return;
45+
m_isAlternate = newIsAlternate;
46+
emit isAlternateChanged();
47+
}

3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListItemBase.h

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
class TAO_API QuickListItemBase : public QObject
77
{
88
Q_OBJECT
9-
AUTO_PROPERTY_V2(bool, isChecked, false)
10-
AUTO_PROPERTY_V2(bool, isSelected, false)
11-
AUTO_PROPERTY_V2(bool, isAlternate, false)
12-
signals:
13-
void isCheckedChanged(bool);
14-
void isSelectedChanged(bool);
15-
void isAlternateChanged(bool);
9+
Q_PROPERTY(bool isChecked READ isChecked WRITE set_isChecked NOTIFY isCheckedChanged)
10+
Q_PROPERTY(bool isSelected READ isSelected WRITE set_isSelected NOTIFY isSelectedChanged)
11+
Q_PROPERTY(bool isAlternate READ isAlternate WRITE set_isAlternate NOTIFY isAlternateChanged FINAL)
12+
13+
// AUTO_PROPERTY_V2(bool, isChecked, false)
14+
// AUTO_PROPERTY_V2(bool, isSelected, false)
15+
// AUTO_PROPERTY_V2(bool, isAlternate, false)
16+
// signals:
17+
// void isCheckedChanged(bool);
18+
// void isSelectedChanged(bool);
19+
// void isAlternateChanged(bool);
1620

1721
public:
1822
explicit QuickListItemBase(QObject* parent = nullptr);
@@ -38,5 +42,24 @@ class TAO_API QuickListItemBase : public QObject
3842
return true;
3943
}
4044

45+
bool isChecked() const;
46+
void set_isChecked(bool newIsChecked);
47+
48+
bool isSelected() const;
49+
void set_isSelected(bool newIsSelected);
50+
51+
bool isAlternate() const;
52+
void set_isAlternate(bool newIsAlternate);
53+
54+
signals:
55+
void isCheckedChanged();
56+
57+
void isSelectedChanged();
58+
59+
void isAlternateChanged();
60+
4161
private:
62+
bool m_isChecked = false;
63+
bool m_isSelected = false;
64+
bool m_isAlternate = false;
4265
};

3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.cpp

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,94 @@ void QuickListModel::updateCalcInfo()
338338
updateAlternate();
339339
emit signalUpdateCalcCount();
340340
}
341+
342+
int QuickListModel::visibledCount() const
343+
{
344+
return m_visibledCount;
345+
}
346+
347+
void QuickListModel::set_visibledCount(int newVisibleCount)
348+
{
349+
if (m_visibledCount == newVisibleCount)
350+
return;
351+
m_visibledCount = newVisibleCount;
352+
emit visibledCountChanged();
353+
}
354+
355+
int QuickListModel::selectedCount() const
356+
{
357+
return m_selectedCount;
358+
}
359+
360+
void QuickListModel::set_selectedCount(int newSelectedCount)
361+
{
362+
if (m_selectedCount == newSelectedCount)
363+
return;
364+
m_selectedCount = newSelectedCount;
365+
emit selectedCountChanged();
366+
}
367+
368+
int QuickListModel::checkedCount() const
369+
{
370+
return m_checkedCount;
371+
}
372+
373+
void QuickListModel::set_checkedCount(int newCheckedCount)
374+
{
375+
if (m_checkedCount == newCheckedCount)
376+
return;
377+
m_checkedCount = newCheckedCount;
378+
emit checkedCountChanged();
379+
}
380+
381+
QStringList QuickListModel::headerRoles() const
382+
{
383+
return m_headerRoles;
384+
}
385+
386+
void QuickListModel::set_headerRoles(const QStringList& newHeaderRoles)
387+
{
388+
if (m_headerRoles == newHeaderRoles)
389+
return;
390+
m_headerRoles = newHeaderRoles;
391+
emit headerRolesChanged();
392+
}
393+
394+
Qt::SortOrder QuickListModel::sortOrder() const
395+
{
396+
return m_sortOrder;
397+
}
398+
399+
void QuickListModel::set_sortOrder(Qt::SortOrder newSortOrder)
400+
{
401+
if (m_sortOrder == newSortOrder)
402+
return;
403+
m_sortOrder = newSortOrder;
404+
emit sortOrderChanged();
405+
}
406+
407+
QString QuickListModel::sortRole() const
408+
{
409+
return m_sortRole;
410+
}
411+
412+
void QuickListModel::set_sortRole(const QString& newSortRole)
413+
{
414+
if (m_sortRole == newSortRole)
415+
return;
416+
m_sortRole = newSortRole;
417+
emit sortRoleChanged();
418+
}
419+
420+
QStringList QuickListModel::noSortRoles() const
421+
{
422+
return m_noSortRoles;
423+
}
424+
425+
void QuickListModel::set_noSortRoles(const QStringList& newNoSortRoles)
426+
{
427+
if (m_noSortRoles == newNoSortRoles)
428+
return;
429+
m_noSortRoles = newNoSortRoles;
430+
emit noSortRolesChanged();
431+
}

3rdparty/TaoCommon/src/TaoCommon/QuickModel/QuickListModel.h

Lines changed: 73 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,32 @@ class TAO_API QuickListModel : public QuickModelBase<QuickListItemBase*>
1212
Q_OBJECT
1313
Q_PROPERTY(bool allChecked READ allChecked WRITE setAllChecked NOTIFY allCheckedChanged)
1414

15-
AUTO_PROPERTY_V2(int, visibledCount, 0)
16-
AUTO_PROPERTY_V2(int, selectedCount, 0)
17-
AUTO_PROPERTY_V2(int, checkedCount, 0)
18-
19-
AUTO_PROPERTY_V2(QStringList, headerRoles, {})
20-
AUTO_PROPERTY_V2(Qt::SortOrder, sortOrder, Qt::AscendingOrder)
21-
AUTO_PROPERTY_V2(QString, sortRole, {})
22-
AUTO_PROPERTY_V2(QStringList, noSortRoles, {})
23-
signals:
24-
void visibledCountChanged(int);
25-
void selectedCountChanged(int);
26-
void checkedCountChanged(int);
27-
void headerRolesChanged(const QStringList&);
28-
void sortOrderChanged(Qt::SortOrder);
29-
void sortRoleChanged(const QString&);
30-
void noSortRolesChanged(const QStringList&);
31-
15+
Q_PROPERTY(int visibledCount READ visibledCount WRITE set_visibledCount NOTIFY visibledCountChanged FINAL)
16+
Q_PROPERTY(int selectedCount READ selectedCount WRITE set_selectedCount NOTIFY selectedCountChanged FINAL)
17+
Q_PROPERTY(int checkedCount READ checkedCount WRITE set_checkedCount NOTIFY checkedCountChanged FINAL)
18+
19+
Q_PROPERTY(QStringList headerRoles READ headerRoles WRITE set_headerRoles NOTIFY headerRolesChanged FINAL)
20+
Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE set_sortOrder NOTIFY sortOrderChanged FINAL)
21+
Q_PROPERTY(QString sortRole READ sortRole WRITE set_sortRole NOTIFY sortRoleChanged FINAL)
22+
Q_PROPERTY(QStringList noSortRoles READ noSortRoles WRITE set_noSortRoles NOTIFY noSortRolesChanged FINAL)
23+
24+
// AUTO_PROPERTY_V2(int, visibledCount, 0)
25+
// AUTO_PROPERTY_V2(int, selectedCount, 0)
26+
// AUTO_PROPERTY_V2(int, checkedCount, 0)
27+
28+
// AUTO_PROPERTY_V2(QStringList, headerRoles, {})
29+
// AUTO_PROPERTY_V2(Qt::SortOrder, sortOrder, Qt::AscendingOrder)
30+
// AUTO_PROPERTY_V2(QString, sortRole, {})
31+
// AUTO_PROPERTY_V2(QStringList, noSortRoles, {})
32+
// signals:
33+
// void visibledCountChanged(int);
34+
// void selectedCountChanged(int);
35+
// void checkedCountChanged(int);
36+
// void headerRolesChanged(const QStringList&);
37+
// void sortOrderChanged(Qt::SortOrder);
38+
// void sortRoleChanged(const QString&);
39+
// void noSortRolesChanged(const QStringList&);
40+
3241
public:
3342
using Super = QuickModelBase<QuickListItemBase*>;
3443
explicit QuickListModel(QObject* parent = nullptr);
@@ -98,6 +107,27 @@ class TAO_API QuickListModel : public QuickModelBase<QuickListItemBase*>
98107
{
99108
emit scrollTo(index);
100109
}
110+
int visibledCount() const;
111+
void set_visibledCount(int newVisibleCount);
112+
113+
int selectedCount() const;
114+
void set_selectedCount(int newSelectedCount);
115+
116+
int checkedCount() const;
117+
void set_checkedCount(int newCheckedCount);
118+
119+
QStringList headerRoles() const;
120+
void set_headerRoles(const QStringList& newHeaderRoles);
121+
122+
Qt::SortOrder sortOrder() const;
123+
void set_sortOrder(Qt::SortOrder newSortOrder);
124+
125+
QString sortRole() const;
126+
void set_sortRole(const QString& newSortRole);
127+
128+
QStringList noSortRoles() const;
129+
void set_noSortRoles(const QStringList& newNoSortRoles);
130+
101131
public slots:
102132
void setAllChecked(bool allChecked);
103133

@@ -111,6 +141,20 @@ public slots:
111141

112142
void beginSearch();
113143
void endSearch();
144+
void visibledCountChanged();
145+
146+
void selectedCountChanged();
147+
148+
void checkedCountChanged();
149+
150+
void headerRolesChanged();
151+
152+
void sortOrderChanged();
153+
154+
void sortRoleChanged();
155+
156+
void noSortRolesChanged();
157+
114158
protected slots:
115159
void onSearch();
116160

@@ -124,7 +168,19 @@ protected slots:
124168
protected:
125169
bool mAllChecked = false;
126170
bool mIsPressed = false;
171+
int m_visibledCount = 0;
172+
173+
int m_selectedCount = 0;
174+
175+
int m_checkedCount = 0;
176+
177+
QStringList m_headerRoles;
178+
179+
Qt::SortOrder m_sortOrder = Qt::AscendingOrder;
180+
181+
QString m_sortRole;
127182

183+
QStringList m_noSortRoles;
128184
int mLastPressedRow = -1;
129185

130186
QMap<QString, SortCallback> mSortCallbacksAscend;

examples/TaoQuickShow/Src/DeviceAddTable/DeviceAddItem.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,55 @@ bool DeviceAddItem::match(const QString& key)
2727
}
2828
return false;
2929
}
30+
31+
bool DeviceAddItem::online() const
32+
{
33+
return m_online;
34+
}
35+
36+
void DeviceAddItem::set_online(bool newOnline)
37+
{
38+
if (m_online == newOnline)
39+
return;
40+
m_online = newOnline;
41+
emit onlineChanged();
42+
}
43+
44+
QString DeviceAddItem::modelString() const
45+
{
46+
return m_modelString;
47+
}
48+
49+
void DeviceAddItem::set_modelString(const QString& newModelString)
50+
{
51+
if (m_modelString == newModelString)
52+
return;
53+
m_modelString = newModelString;
54+
emit modelStringChanged();
55+
}
56+
57+
QString DeviceAddItem::address() const
58+
{
59+
return m_address;
60+
}
61+
62+
void DeviceAddItem::set_address(const QString& newAddress)
63+
{
64+
if (m_address == newAddress)
65+
return;
66+
m_address = newAddress;
67+
emit addressChanged();
68+
}
69+
70+
QString DeviceAddItem::name() const
71+
{
72+
return m_name;
73+
}
74+
75+
void DeviceAddItem::set_name(const QString& newName)
76+
{
77+
if (m_name == newName)
78+
return;
79+
m_name = newName;
80+
emit nameChanged();
81+
}

0 commit comments

Comments
 (0)