summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/reports/kexireportpart.cpp
blob: 6b9c6bc3273855b3eced3283b0cc6b1743d385a5 (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
133
134
135
136
137
138
139
140
141
/* This file is part of the KDE project
   Copyright (C) 2004 Lucijan Busch <lucijan@kde.org>
   Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>

   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.
*/

#include <kdebug.h>
#include <kgenericfactory.h>

#include "kexiviewbase.h"
#include "keximainwindow.h"
#include "kexiproject.h"
#include <kexipartitem.h>
#include <kexidialogbase.h>

#include <kexidb/connection.h>
#include <kexidb/fieldlist.h>
#include <kexidb/field.h>

#include <form.h>
#include <formIO.h>
#include <widgetlibrary.h>

#include <kexiformmanager.h>
#include <kexiformpart.h>

#include "kexireportview.h"
#include "kexireportpart.h"

KFormDesigner::WidgetLibrary* KexiReportPart::static_reportsLibrary = 0L;

KexiReportPart::KexiReportPart(TQObject *tqparent, const char *name, const TQStringList &l)
 : KexiPart::Part(tqparent, name, l)
{
	// REGISTERED ID:
	m_registeredPartID = (int)KexiPart::ReportObjectType;

	kexipluginsdbg << "KexiReportPart::KexiReportPart()" << endl;
	m_names["instanceName"] 
		= i18n("Translate this word using only lowercase alphanumeric characters (a..z, 0..9). "
		"Use '_' character instead of spaces. First character should be a..z character. "
		"If you cannot use latin characters in your language, use english word.", 
		"report");
	m_names["instanceCaption"] = i18n("Report");
	m_supportedViewModes = Kexi::DataViewMode | Kexi::DesignViewMode;

	// Only create form manager if it's not yet created.
	// KexiFormPart could have created is already.
	KFormDesigner::FormManager *formManager = KFormDesigner::FormManager::self();
	if (!formManager) 
		formManager = new KexiFormManager(this, "kexi_form_and_report_manager");

	// Create and store a handle to report' library. Forms will have their own library too.
/* @todo add configuration for supported factory groups */
	TQStringList supportedFactoryGroups;
	supportedFactoryGroups += "kexi-report";
	static_reportsLibrary = KFormDesigner::FormManager::createWidgetLibrary(
		formManager, supportedFactoryGroups);
	static_reportsLibrary->setAdvancedPropertiesVisible(false);
}

KexiReportPart::~KexiReportPart()
{
}

KFormDesigner::WidgetLibrary* KexiReportPart::library()
{
	return static_reportsLibrary;
}

void
KexiReportPart::initPartActions()
{
}

void
KexiReportPart::initInstanceActions()
{
	KFormDesigner::FormManager::self()->createActions(
		library(), actionCollectionForMode(Kexi::DesignViewMode), guiClient());
}

KexiDialogTempData*
KexiReportPart::createTempData(KexiDialogBase* dialog)
{
	return new KexiReportPart::TempData(dialog);
}

KexiViewBase*
KexiReportPart::createView(TQWidget *tqparent, KexiDialogBase* dialog,
	KexiPart::Item &item, int, TQMap<TQString,TQString>*)
{
	kexipluginsdbg << "KexiReportPart::createView()" << endl;
	KexiMainWindow *win = dialog->mainWin();
	if (!win || !win->project() || !win->project()->dbConnection())
		return 0;

	KexiReportView *view = new KexiReportView(win, tqparent, item.name().latin1(),
		win->project()->dbConnection() );

	return view;
}

TQString
KexiReportPart::i18nMessage(const TQCString& englishMessage, KexiDialogBase* dlg) const
{
	Q_UNUSED(dlg);
	if (englishMessage=="Design of object \"%1\" has been modified.")
		return i18n("Design of report \"%1\" has been modified.");
	if (englishMessage=="Object \"%1\" already exists.")
		return i18n("Report \"%1\" already exists.");
	return englishMessage;
}

//---------------

KexiReportPart::TempData::TempData(TQObject* tqparent)
 : KexiDialogTempData(tqparent)
{
}

KexiReportPart::TempData::~TempData()
{
}

#include "kexireportpart.moc"