kexi

kexisimpleprintingengine.h
1/* This file is part of the KDE project
2 Copyright (C) 2005-2007 Jaroslaw Staniek <js@iidea.pl>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef KEXISIMPLEPRINTINGENGINE_H
21#define KEXISIMPLEPRINTINGENGINE_H
22
24
25#include <kexidb/connection.h>
26#include <kexidb/tableschema.h>
27#include <kexidb/cursor.h>
28#include <kexidb/utils.h>
29#include <kexidb/queryschema.h>
30#include <widget/tableview/kexitableviewdata.h>
31#include <KoPageLayoutDia.h>
32
33#include <tqpaintdevicemetrics.h>
34#include <tqfontmetrics.h>
35#include <tqfont.h>
36
38class KexiSimplePrintingSettings
39{
40 public:
41 KexiSimplePrintingSettings();
42 ~KexiSimplePrintingSettings();
43
44 static KexiSimplePrintingSettings load();
45 void save();
46
47 KoPageLayout pageLayout;
48 KoUnit::Unit unit;
49 TQFont pageTitleFont;
50 bool addPageNumbers : 1;
51 bool addDateAndTime : 1;
52 bool addTableBorders : 1;
53};
54
57class KexiSimplePrintingEngine : public TQObject
58{
59 TQ_OBJECT
60
61
62 public:
63 KexiSimplePrintingEngine( const KexiSimplePrintingSettings& settings, TQObject* parent );
64 ~KexiSimplePrintingEngine();
65
66 bool init(KexiDB::Connection& conn, KexiDB::TableOrQuerySchema& tableOrQuery,
67 const TQString& titleText, TQString& errorMessage);
68
69 void setTitleText(const TQString& titleText);
70
73 void calculatePagesCount(TQPainter& painter);
74
75 bool done();
76 void clear();
77 const KexiSimplePrintingSettings* settings() const { return m_settings; }
78
80 bool eof() const { return m_eof; }
81
83 uint pagesCount() const { return m_pagesCount; }
84
87 uint paintedPages() const { return m_dataOffsets.count(); }
88
89 public slots:
93 void paintPage(int pageNumber, TQPainter& painter, bool paint = true);
94
95 protected:
96 void paintRecord(TQPainter& painter, KexiTableItem *item,
97 int cellMargin, double &y, uint paintedRows, bool paint, bool printing);
98
99 const KexiSimplePrintingSettings* m_settings;
100
101// TQPainter* m_painter;
102 TQFont m_mainFont, m_headerFont;
103 TQPaintDeviceMetrics m_pdm;
104 double m_dpiX, m_dpiY;
105 uint m_pageWidth, m_pageHeight;
106 uint m_SCALE;
107 //TQFontMetrics m_headerFM, m_mainFM;
108 KexiDB::Cursor *m_cursor;
109 KexiTableViewData *m_data;
110// KexiTableViewData::Iterator *m_dataIterator;
111 TQPtrList<uint> m_dataOffsets;
112 TQString m_headerText;
113 TQString m_dateTimeText;
114 uint m_dateTimeWidth;
115 TQRect m_headerTextRect;
116 int m_maxFieldNameWidth;
117 int m_mainLineSpacing;
118 int m_footerHeight;
119 KexiDB::QueryColumnInfo::Vector m_fieldsExpanded;
120 uint m_visibleFieldsCount;
121 uint m_pagesCount;
122 bool m_eof;
124 double m_leftMargin;
125 double m_rightMargin;
126 double m_topMargin;
127 double m_bottomMargin;
128 double m_fx, m_fy;
129};
130
131#endif
Provides database connection, allowing queries and data modification.
Definition connection.h:62
Provides database cursor functionality.
Definition cursor.h:67
void paintPage(int pageNumber, TQPainter &painter, bool paint=true)
void paintRecord(TQPainter &painter, KexiTableItem *item, int cellMargin, double &y, uint paintedRows, bool paint, bool printing)
bool m_paintInitialized
used by paintPage()
bool init(KexiDB::Connection &conn, KexiDB::TableOrQuerySchema &tableOrQuery, const TQString &titleText, TQString &errorMessage)
void calculatePagesCount(TQPainter &painter)
Settings data for simple printing engine.
static KexiSimplePrintingSettings load()