diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2013-07-25 12:52:20 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-08-05 06:59:19 +0200 |
commit | e5b18db8026f1488f73b5fed7fa62ba4990cea46 (patch) | |
tree | a96a8a9226272afc1ea8bcaec2e496fc8df554ec /qt-ui/models.h | |
parent | 1f976371bff0a3c23119165aa601e27da458c22d (diff) | |
download | subsurface-e5b18db8026f1488f73b5fed7fa62ba4990cea46.tar.gz |
Print: improve table printing by using QTableView
The current QTextDocument implementation is slow due to
HTML parsing. By using QTableView with QAbstractTableModel
we boost the performance of the table print drastically.
This patch completely replaces the old solution.
There is a hidden QTableView widget which is populated
with all data and rendered using a QPainter attached to
the printer device.
A couple of new classes are added in models.h/cpp
that handle the table print model and these are then used
in printlayout.h/cpp.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/models.h')
-rw-r--r-- | qt-ui/models.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/qt-ui/models.h b/qt-ui/models.h index e8a7daaf3..22cfe4b7e 100644 --- a/qt-ui/models.h +++ b/qt-ui/models.h @@ -230,4 +230,45 @@ public: YearlyStatisticsModel(QObject* parent = 0); void update_yearly_stats(); }; + +/* TablePrintModel: + * for now we use a blank table model with row items TablePrintItem. + * these are pretty much the same as DiveItem, but have color + * properties, as well. perhaps later one a more unified model has to be + * considered, but the current TablePrintModel idea has to be extended + * to support variadic column lists and column list orders that can + * be controlled by the user. + */ +struct TablePrintItem { + QString number; + QString date; + QString depth; + QString duration; + QString divemaster; + QString buddy; + QString location; + unsigned int colorBackground; +}; + +class TablePrintModel : public QAbstractTableModel +{ + Q_OBJECT + +private: + QList<struct TablePrintItem *> list; + +public: + ~TablePrintModel(); + TablePrintModel(); + + int rows, columns; + void insertRow(int index = -1); + void callReset(); + + QVariant data(const QModelIndex &index, int role) const; + bool setData(const QModelIndex &index, const QVariant &value, int role); + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; +}; + #endif |