summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/reports/kexireportview.h
blob: 794fa49cf1338ac86226179c4455d21853628d69 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* This file is part of the KDE project
   Copyright (C) 2004 Cedric Pasteur <[email protected]>
   Copyright (C) 2004 Jaroslaw Staniek <[email protected]>

   This library 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 library 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 library; 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 KEXIREPORTVIEW_H
#define KEXIREPORTVIEW_H

#include <tqscrollview.h>
#include <tqtimer.h>

#include <kexiviewbase.h>

#include "kexiscrollview.h"
#include "kexireportpart.h"

class KexiReportForm;

class KEXIREPORTUTILS_EXPORT KexiReportScrollView : public KexiScrollView
{
	Q_OBJECT
  

	public:
		KexiReportScrollView(TQWidget *parent, bool preview);
		virtual ~KexiReportScrollView();

		void setForm(KFormDesigner::Form *form) { m_form = form; }

	public slots:
		/*! Reimplemented to update resize policy. */
		virtual void show();

	protected slots:
		void slotResizingStarted();

	private:
		KFormDesigner::Form *m_form;
};


//! The FormPart's view
/*! This class presents a single view used inside KexiDialogBase.
 It takes care of saving/loading report, of enabling actions when needed.
 One KexiReportView object is instantiated for data view mode (preview == true in constructor),
 and second KexiReportView object is instantiated for design view mode
 (preview == false in constructor). */
class KEXIREPORTUTILS_EXPORT KexiReportView : public KexiViewBase
{
	Q_OBJECT
  

	public:
		enum ResizeMode {
			ResizeAuto = 0,
			ResizeDefault = ResizeAuto,
			ResizeFixed = 1,
			NoResize = 2 /*! @todo */
		};

		KexiReportView(KexiMainWindow *win, TQWidget *parent, const char *name, KexiDB::Connection *conn);
		virtual ~KexiReportView();

		KexiDB::Connection* connection() { return m_conn; }

		virtual TQSize preferredSizeHint(const TQSize& otherSize);

		int resizeMode() const { return m_resizeMode; }

	public slots:
		/*! Reimplemented to update resize policy. */
		virtual void show();

	protected slots:
		void slotPropertySetSwitched(KoProperty::Set *set, bool forceReload = false);
		void slotDirty(KFormDesigner::Form *f, bool isDirty);
		void slotFocus(bool in);

		/*void slotWidgetSelected(KFormDesigner::Form *form, bool multiple);
		void slotFormWidgetSelected(KFormDesigner::Form *form);
		void slotNoFormSelected();

		void setUndoEnabled(bool enabled);
		void setRedoEnabled(bool enabled); */

	protected:
		virtual tristate beforeSwitchTo(int mode, bool &dontStore);
		virtual tristate afterSwitchFrom(int mode);
		virtual KoProperty::Set* propertySet() { return m_propertySet; }

		virtual KexiDB::SchemaData* storeNewData(const KexiDB::SchemaData& sdata, bool &cancel);
		virtual tristate storeData(bool dontAsk = false);

		KexiReportPart::TempData* tempData() const {
			return static_cast<KexiReportPart::TempData*>(parentDialog()->tempData()); }
		KexiReportPart* reportPart() const { return static_cast<KexiReportPart*>(part()); }

		void disableWidgetActions();
		void enableFormActions();

		KFormDesigner::Form* form() const;
		void setForm(KFormDesigner::Form *f);

		void initForm();
		void loadForm();

		virtual void resizeEvent ( TQResizeEvent * );

	private:
		KexiReportForm *m_reportform;
		KexiReportScrollView *m_scrollView;
		KoProperty::Set *m_propertySet;
		KexiDB::Connection *m_conn;
		int m_resizeMode;
};

#endif