subsurface/qt-ui/modeldelegates.h
Lubomir I. Ivanov e727b899a6 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>
2013-10-03 09:38:37 -07:00

75 lines
2.8 KiB
C++

#ifndef MODELDELEGATES_H
#define MODELDELEGATES_H
#include <QStyledItemDelegate>
class QComboBox;
class QPainter;
class StarWidgetsDelegate : public QStyledItemDelegate {
Q_OBJECT
public:
explicit StarWidgetsDelegate(QWidget* parent = 0);
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
private:
QWidget *parentWidget;
};
class ComboBoxDelegate : public QStyledItemDelegate{
Q_OBJECT
public:
explicit ComboBoxDelegate(QAbstractItemModel *model, QObject* parent = 0);
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
virtual bool eventFilter(QObject* object, QEvent* event);
public slots:
void testActivation(const QString& currString = QString());
//HACK: try to get rid of this in the future.
void fakeActivation();
virtual void revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint) = 0;
protected:
QAbstractItemModel *model;
};
class TankInfoDelegate : public ComboBoxDelegate{
Q_OBJECT
public:
explicit TankInfoDelegate(QObject* parent = 0);
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
public slots:
void revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint);
};
class WSInfoDelegate : public ComboBoxDelegate{
Q_OBJECT
public:
explicit WSInfoDelegate(QObject* parent = 0);
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
public slots:
void revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint);
};
class AirTypesDelegate : public ComboBoxDelegate{
Q_OBJECT
public:
explicit AirTypesDelegate(QObject* parent = 0);
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
public slots:
void revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint);
};
/* ProfilePrintDelagate:
* this delegate is used to modify the look of the table that is printed
* bellow profiles.
*/
class ProfilePrintDelegate : public QStyledItemDelegate
{
public:
explicit ProfilePrintDelegate(QObject *parent = 0);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
#endif