summaryrefslogtreecommitdiffstats
path: root/kexi/main/printing/kexisimpleprintingpagesetup.h
blob: e4e99bd51be0cce128c81e8045b2c6323b4533bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* This file is part of the KDE project
   Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this program; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef KEXISIMPLEPRINTINGPAGESETUP_H
#define KEXISIMPLEPRINTINGPAGESETUP_H

#include "kexisimpleprintingengine.h"
#include <kexiviewbase.h>

class KexiSimplePrintingPageSetupBase;
class KoPageLayoutSize;
class KexiSimplePrintPreviewWindow;

/*! @short A command for simple printing and print preview. 
 This class is instantiated in KexiMainWindowImpl so there's:
 - a single print preview window per part item regardless of a way how user invoked
    the 'print preview' command (using 'File->Print Preview' command or 'Print Preview' button 
    of the 'Page Setup' dialog)
 - a single printing engine per part item regardless of a way how user started
   (using 'File->Print' command or 'Print' button of the 'Page Setup' dialog)
*/
class KexiSimplePrintingCommand : public QObject
{
	Q_OBJECT

	public:
		KexiSimplePrintingCommand(KexiMainWindow* mainWin, int objectId, 
			QObject* parent = 0);
		~KexiSimplePrintingCommand();

	public slots:
		bool print(const KexiSimplePrintingSettings& settings, 
			const QString& aTitleText = QString::null);
		bool print(const QString& aTitleText = QString::null);
		bool showPrintPreview(const KexiSimplePrintingSettings& settings, 
			const QString& aTitleText = QString::null, bool reload = false);
//		void setPrintPreviewNeedsReloading();

	signals:
		//! connected to Kexi Main Window
		void showPageSetupRequested(KexiPart::Item* item);

	protected slots:
		void slotShowPageSetupRequested();

	protected:
		KexiSimplePrintingEngine* m_previewEngine;
		KexiMainWindow* m_mainWin;
		int m_objectId;
		KexiSimplePrintingSettings m_settings;
		KexiSimplePrintPreviewWindow *m_previewWindow;
		bool m_printPreviewNeedsReloading : 1;
};

//! @short A window for displaying settings for simple printing.
class KexiSimplePrintingPageSetup : public KexiViewBase
{
	Q_OBJECT

	public:
		KexiSimplePrintingPageSetup( KexiMainWindow *mainWin, QWidget *parent, QMap<QString,QString>* args );
		~KexiSimplePrintingPageSetup();

	public slots:
		void print();
		void printPreview();

	signals:
		void printItemRequested(KexiPart::Item* item, 
			const KexiSimplePrintingSettings& settings, const QString& titleText);
		void printPreviewForItemRequested(KexiPart::Item* item, 
			const KexiSimplePrintingSettings& settings, const QString& titleText, bool reload);

	protected slots:
		void slotOpenData();
		void slotSaveSetup();
		void slotChangeTitleFont();
		void slotChangePageSizeAndMargins();
		void slotAddPageNumbersCheckboxToggled(bool set);
		void slotAddDateTimeCheckboxToggled(bool set);
		void slotAddTableBordersCheckboxToggled(bool set);
		void slotTitleTextChanged(const QString&);

	protected:
		void setupPrintingCommand();
		void updatePageLayoutAndUnitInfo();
		void setDirty(bool set);

		KexiSimplePrintingSettings m_settings;
//		KexiSimplePrintingEngine *m_engine;
		KoUnit::Unit m_unit;
		KexiSimplePrintingPageSetupBase *m_contents;
		KoPageLayoutSize *m_pageLayoutWidget;
		KexiPart::Item *m_item;
//		KexiSimplePrintingCommand *m_command;
		QString m_origCaptionLabelText;
		bool m_printPreviewNeedsReloading : 1;

};

#endif