kexi

kexireportpart.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2004 Lucijan Busch <lucijan@kde.org>
3 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include <kdebug.h>
22#include <kgenericfactory.h>
23
24#include "kexiviewbase.h"
25#include "keximainwindow.h"
26#include "kexiproject.h"
27#include <kexipartitem.h>
28#include <kexidialogbase.h>
29
30#include <kexidb/connection.h>
31#include <kexidb/fieldlist.h>
32#include <kexidb/field.h>
33
34#include <form.h>
35#include <formIO.h>
36#include <widgetlibrary.h>
37
38#include <kexiformmanager.h>
39#include <kexiformpart.h>
40
41#include "kexireportview.h"
42#include "kexireportpart.h"
43
44KFormDesigner::WidgetLibrary* KexiReportPart::static_reportsLibrary = 0L;
45
46KexiReportPart::KexiReportPart(TQObject *parent, const char *name, const TQStringList &l)
47 : KexiPart::Part(parent, name, l)
48{
49 // REGISTERED ID:
50 m_registeredPartID = (int)KexiPart::ReportObjectType;
51
52 kexipluginsdbg << "KexiReportPart::KexiReportPart()" << endl;
53 m_names["instanceName"]
54 = i18n("Translate this word using only lowercase alphanumeric characters (a..z, 0..9). "
55 "Use '_' character instead of spaces. First character should be a..z character. "
56 "If you cannot use latin characters in your language, use english word.",
57 "report");
58 m_names["instanceCaption"] = i18n("Report");
59 m_supportedViewModes = Kexi::DataViewMode | Kexi::DesignViewMode;
60
61 // Only create form manager if it's not yet created.
62 // KexiFormPart could have created is already.
64 if (!formManager)
65 formManager = new KexiFormManager(this, "kexi_form_and_report_manager");
66
67 // Create and store a handle to report' library. Forms will have their own library too.
68/* @todo add configuration for supported factory groups */
69 TQStringList supportedFactoryGroups;
70 supportedFactoryGroups += "kexi-report";
72 formManager, supportedFactoryGroups);
73 static_reportsLibrary->setAdvancedPropertiesVisible(false);
74}
75
76KexiReportPart::~KexiReportPart()
77{
78}
79
81{
82 return static_reportsLibrary;
83}
84
85void
86KexiReportPart::initPartActions()
87{
88}
89
90void
91KexiReportPart::initInstanceActions()
92{
94 library(), actionCollectionForMode(Kexi::DesignViewMode), guiClient());
95}
96
99{
100 return new KexiReportPart::TempData(dialog);
101}
102
105 KexiPart::Item &item, int, TQMap<TQString,TQString>*)
106{
107 kexipluginsdbg << "KexiReportPart::createView()" << endl;
108 KexiMainWindow *win = dialog->mainWin();
109 if (!win || !win->project() || !win->project()->dbConnection())
110 return 0;
111
112 KexiReportView *view = new KexiReportView(win, parent, item.name().latin1(),
113 win->project()->dbConnection() );
114
115 return view;
116}
117
118TQString
119KexiReportPart::i18nMessage(const TQCString& englishMessage, KexiDialogBase* dlg) const
120{
121 Q_UNUSED(dlg);
122 if (englishMessage=="Design of object \"%1\" has been modified.")
123 return i18n("Design of report \"%1\" has been modified.");
124 if (englishMessage=="Object \"%1\" already exists.")
125 return i18n("Report \"%1\" already exists.");
126 return englishMessage;
127}
128
129//---------------
130
131KexiReportPart::TempData::TempData(TQObject* parent)
132 : KexiDialogTempData(parent)
133{
134}
135
136KexiReportPart::TempData::~TempData()
137{
138}
139
140#include "kexireportpart.moc"
141
A class to manage (create/load/save) Forms.
Definition formmanager.h:73
static FormManager * self()
Access to FormManager singleton.
static WidgetLibrary * createWidgetLibrary(FormManager *m, const TQStringList &supportedFactoryGroups)
ActionList createActions(WidgetLibrary *lib, TDEActionCollection *collection, KXMLGUIClient *client)
This class searches for factories and provides TDEActions for widget creation.
Base class for child window of Kexi's main application window.
Privides temporary data shared between KexiDialogBase's views (KexiView's).
virtual KexiProject * project()=0
Project data of currently opened project or NULL if no project here yet.
Information about a single object that can be instantiated using Kexi Part.
TDEActionCollection * actionCollectionForMode(int viewMode) const
Definition kexipart.cpp:164
GUIClient * guiClient() const
Definition kexipart.h:171
KexiDB::Connection * dbConnection() const
static KFormDesigner::WidgetLibrary * library()
virtual KexiDialogTempData * createTempData(KexiDialogBase *dialog)
virtual TQString i18nMessage(const TQCString &englishMessage, KexiDialogBase *dlg) const
virtual KexiViewBase * createView(TQWidget *parent, KexiDialogBase *dialog, KexiPart::Item &item, int viewMode=Kexi::DataViewMode, TQMap< TQString, TQString > *staticObjectArgs=0)
The FormPart's view.
Base class for single view embeddable of in KexiDialogBase.