kexi

kexisimpleprintingengine.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
00003 
00004    This program is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this program; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #ifndef KEXISIMPLEPRINTINGENGINE_H
00021 #define KEXISIMPLEPRINTINGENGINE_H
00022 
00023 class KexiSimplePrintingSettings;
00024 
00025 #include <kexidb/connection.h>
00026 #include <kexidb/tableschema.h>
00027 #include <kexidb/cursor.h>
00028 #include <kexidb/utils.h>
00029 #include <kexidb/queryschema.h>
00030 #include <widget/tableview/kexitableviewdata.h>
00031 #include <KoPageLayoutDia.h>
00032 
00033 #include <qpaintdevicemetrics.h>
00034 #include <qfontmetrics.h>
00035 #include <qfont.h>
00036 
00038 class KexiSimplePrintingSettings
00039 {
00040     public:
00041         KexiSimplePrintingSettings();
00042         ~KexiSimplePrintingSettings();
00043 
00044         static KexiSimplePrintingSettings load();
00045         void save();
00046 
00047         KoPageLayout pageLayout;
00048         KoUnit::Unit unit;
00049         QFont pageTitleFont;
00050         bool addPageNumbers : 1;
00051         bool addDateAndTime : 1;
00052         bool addTableBorders : 1;
00053 };
00054 
00057 class KexiSimplePrintingEngine : public QObject
00058 {
00059     Q_OBJECT
00060 
00061     public:
00062         KexiSimplePrintingEngine( const KexiSimplePrintingSettings& settings, QObject* parent );
00063         ~KexiSimplePrintingEngine();
00064 
00065         bool init(KexiDB::Connection& conn, KexiDB::TableOrQuerySchema& tableOrQuery,
00066             const QString& titleText, QString& errorMessage);
00067 
00068         void setTitleText(const QString& titleText);
00069 
00072         void calculatePagesCount(QPainter& painter);
00073 
00074         bool done();
00075         void clear();
00076         const KexiSimplePrintingSettings* settings() const { return m_settings; }
00077 
00079         bool eof() const { return m_eof; }
00080 
00082         uint pagesCount() { return m_pagesCount; }
00083 
00086         uint paintedPages() const { return m_dataOffsets.count(); }
00087 
00088     public slots:
00092         void paintPage(int pageNumber, QPainter& painter, bool paint = true);
00093 
00094     protected:
00095         void paintRecord(QPainter& painter, KexiTableItem *item, 
00096             int cellMargin, uint &y, uint paintedRows, bool paint);
00097 
00098         const KexiSimplePrintingSettings* m_settings;
00099 
00100 //      QPainter* m_painter;
00101         QFont m_mainFont, m_headerFont;
00102         QPaintDeviceMetrics m_pdm;
00103         int m_dpiX, m_dpiY;
00104         uint m_pageWidth, m_pageHeight;
00105         //QFontMetrics m_headerFM, m_mainFM;
00106         KexiDB::Cursor *m_cursor;
00107         KexiTableViewData *m_data;
00108 //      KexiTableViewData::Iterator *m_dataIterator;
00109         QPtrList<uint> m_dataOffsets;
00110         QString m_headerText;
00111         QString m_dateTimeText;
00112         uint m_dateTimeWidth;
00113         QRect m_headerTextRect;
00114         int m_maxFieldNameWidth;
00115         int m_mainLineSpacing;
00116         int m_footerHeight;
00117         KexiDB::QueryColumnInfo::Vector m_fieldsExpanded;
00118         uint m_visibleFieldsCount;
00119         uint m_pagesCount;
00120         bool m_eof;
00121         bool m_paintInitialized; 
00122         double leftMargin;
00123         double rightMargin;
00124         double topMargin;
00125         double bottomMargin;
00126         double m_fx, m_fy;
00127 };
00128 
00129 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys