/
assetslistmodel.h
59 lines (46 loc) · 1.11 KB
/
assetslistmodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef ASSETSLISTMODEL_H
#define ASSETSLISTMODEL_H
#include <QAbstractListModel>
#include <vector>
struct CommonAccountInfo;
class AssetItemData : public QObject
{
Q_OBJECT
public:
QString asset_name;
QString account_name;
double balance;
double price;
int level;
bool collapse;
bool theLast;
std::vector<AssetItemData*> children;
};
class AssetsListModel : public QAbstractListModel
{
Q_OBJECT
public:
AssetsListModel(QObject *parent);
~AssetsListModel();
void setAccountInfo(QMap<QString, CommonAccountInfo>* accountInfos);
void refresh();
const std::vector<AssetItemData*>* getItemDataList();
int getListHeight();
public:
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
public slots:
void collapse(const QModelIndex& index);
signals:
void listHeightChanged(int);
private:
void refreshList();
void clearItemDataList();
private:
std::vector<AssetItemData*>* m_itemDataList;
std::vector<AssetItemData*>* m_displayItemDataList;
QMap<QString, bool> itemCollapseState;
int listHeight = 0;
double totalPrice = 0;
};
#endif // ASSETSLISTMODEL_H