-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathstockstablemodel.h
65 lines (42 loc) · 1.46 KB
/
stockstablemodel.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
60
61
62
63
64
65
#ifndef STOCKSTABLEMODEL_H
#define STOCKSTABLEMODEL_H
#include <QObject>
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include "stock.h"
class StocksTableModel : public QAbstractTableModel
{
Q_OBJECT
public:
StocksTableModel(QObject *parent = 0);
~StocksTableModel();
int rowCount ( const QModelIndex & parent = QModelIndex() ) const ;
int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const ;
QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
Stock * getStock(const QModelIndex & index);
public slots:
void setStocks(const QList<Stock *> &stocks);
void setRowCount(int count);
void setStartIndex(int index);
private:
QList<Stock*> m_allStocks; //Code,Stock
int m_rowCount;
int m_startIndex;
};
/////////////////////////////////////////////////////////////////////////////
class SortFilterProxyModel : public QSortFilterProxyModel{
Q_OBJECT
public:
SortFilterProxyModel(QObject *parent);
void cleanFilters();
void setFilters(const QRegExp &code, const QRegExp &name);
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
// bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
private:
QRegExp m_code;
QRegExp m_name;
QRegExp serviceType;
};
#endif // STOCKSTABLEMODEL_H