DAWorkbench 0.0.1
DAWorkbench API
载入中...
搜索中...
未找到
DAAbstractCacheWindowTableModel.h
1#ifndef DAABSTRACTCACHEWINDOWTABLEMODEL_H
2#define DAABSTRACTCACHEWINDOWTABLEMODEL_H
3#include "DAGuiAPI.h"
4#include <QAbstractTableModel>
5
6namespace DA
7{
8
15class DAGUI_API DAAbstractCacheWindowTableModel : public QAbstractTableModel
16{
17 Q_OBJECT
18public:
19 DAAbstractCacheWindowTableModel(QObject* parent = nullptr);
21 // 滑动窗模式
22 // 设置滑动窗模式的起始行
23 virtual void setCacheWindowStartRow(int startRow);
24 int getCacheWindowStartRow() const;
25 // windows size决定了显示的行数
26 void setCacheWindowSize(int s);
27 int getCacheWindowSize() const;
28 virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
29 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
30 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
31 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
32 virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
33
34 // 滑动窗模式需要基础的接口
35
36 virtual Qt::ItemFlags actualFlags(int actualRow, int actualColumn) const;
37 // 获取真实的行数,相当于普通模型的rowCount
38 virtual int actualRowCount() const = 0;
39 // 获取真实的HeaderData,相当于普通模型的headerData
40 virtual QVariant actualHeaderData(int actualSection, Qt::Orientation orientation, int role = Qt::DisplayRole) const = 0;
41 // 获取真实的HeaderData,相当于普通模型的headerData
42 virtual QVariant actualData(int actualRow, int actualColumn, int role = Qt::DisplayRole) const = 0;
43 // 设置数据
44 virtual bool setActualData(int actualRow, int actualColumn, const QVariant& value, int role = Qt::EditRole);
45 void notifyRowChanged(int row);
46 void notifyColumnChanged(int col);
47 void notifyDataChanged(int row, int col);
48 void notifyDataChanged(int rowStart, int colStart, int rowEnd, int colEnd);
49 // 行将移除
50 void notifyRowsRemoved(const QList< int >& r);
51 // 行将插入
52 void notifyRowsInserted(const QList< int >& r);
53 // 行将移除
54 void notifyColumnsRemoved(const QList< int >& c);
55 // 行将插入
56 void notifyColumnsInserted(const QList< int >& c);
57
58protected:
59 virtual void cacheShape();
60
61protected:
62 int mCacheWindowSize { 20000 }; // 默认窗口大小,Qt的MVC性能足够,这里主要是避免大表会触发全行遍历表头求表头宽度导致的性能问题
63 int mWindowStartRow { 0 }; // 当前窗口起始行
64};
65}
66
67#endif // DAABSTRACTCACHEWINDOWTABLEMODEL_H
这是一个有缓存窗的模型,模型的显示行数固定在缓存窗的大小,这个模型适合超多行数据的显示
Definition DAAbstractCacheWindowTableModel.h:16
序列化类都是带异常的,使用中需要处理异常
Definition AppMainWindow.cpp:44