mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Print: provide means to print profile tables
This patch adds a couple of classes and some other modifications in PrintLayout that handle the printing of tables under a profile. models.h : ProfilePrintModel The class uses a 'struct *dive' to output all required data for a certain dive at specific rows and columns. It also handles font formatting and text alignment. modeldelagatates.h : ProfilePrintDelegate The class is used only for drawing a custom grid for profile tables. PrintLayout::createProfileTable() The function is used to create and setup the profile table object PrintLayout::printProfileDives() The function now has correct padding of dive profiles on a page and also the printing of actual tables below them. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
374f3d0de6
commit
e727b899a6
6 changed files with 402 additions and 32 deletions
|
@ -300,3 +300,30 @@ void AirTypesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,
|
|||
AirTypesDelegate::AirTypesDelegate(QObject* parent) : ComboBoxDelegate(airTypes(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
ProfilePrintDelegate::ProfilePrintDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/* this method overrides the default table drawing method and places grid lines only at certain rows and columns */
|
||||
void ProfilePrintDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
const QRect rect(option.rect);
|
||||
const int row = index.row();
|
||||
const int col = index.column();
|
||||
|
||||
// grid color
|
||||
painter->setPen(QPen(QColor(0xff999999)));
|
||||
// top line
|
||||
if (row == 2 || row == 3 || row == 10 || col == 3 || col == 4)
|
||||
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||
if (row > 1 && row < 10) {
|
||||
// left line - draw always for these rows
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
// "fix" for missing (?) right line after col 5
|
||||
if (col > 5 || (col > 4 && row == 2))
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
}
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue