kexi

kexireportpart.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Lucijan Busch <lucijan@kde.org>
00003    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include <kdebug.h>
00022 #include <kgenericfactory.h>
00023 
00024 #include "kexiviewbase.h"
00025 #include "keximainwindow.h"
00026 #include "kexiproject.h"
00027 #include <kexipartitem.h>
00028 #include <kexidialogbase.h>
00029 
00030 #include <kexidb/connection.h>
00031 #include <kexidb/fieldlist.h>
00032 #include <kexidb/field.h>
00033 
00034 #include <form.h>
00035 #include <formIO.h>
00036 #include <widgetlibrary.h>
00037 
00038 #include <kexiformmanager.h>
00039 #include <kexiformpart.h>
00040 
00041 #include "kexireportview.h"
00042 #include "kexireportpart.h"
00043 
00044 KFormDesigner::WidgetLibrary* KexiReportPart::static_reportsLibrary = 0L;
00045 
00046 KexiReportPart::KexiReportPart(QObject *parent, const char *name, const QStringList &l)
00047  : KexiPart::Part(parent, name, l)
00048 {
00049     // REGISTERED ID:
00050     m_registeredPartID = (int)KexiPart::ReportObjectType;
00051 
00052     kexipluginsdbg << "KexiReportPart::KexiReportPart()" << endl;
00053     m_names["instanceName"] 
00054         = i18n("Translate this word using only lowercase alphanumeric characters (a..z, 0..9). "
00055         "Use '_' character instead of spaces. First character should be a..z character. "
00056         "If you cannot use latin characters in your language, use english word.", 
00057         "report");
00058     m_names["instanceCaption"] = i18n("Report");
00059     m_supportedViewModes = Kexi::DataViewMode | Kexi::DesignViewMode;
00060 
00061     // Only create form manager if it's not yet created.
00062     // KexiFormPart could have created is already.
00063     KFormDesigner::FormManager *formManager = KFormDesigner::FormManager::self();
00064     if (!formManager) 
00065         formManager = new KexiFormManager(this, "kexi_form_and_report_manager");
00066 
00067     // Create and store a handle to report' library. Forms will have their own library too.
00068 /* @todo add configuration for supported factory groups */
00069     QStringList supportedFactoryGroups;
00070     supportedFactoryGroups += "kexi-report";
00071     static_reportsLibrary = KFormDesigner::FormManager::createWidgetLibrary(
00072         formManager, supportedFactoryGroups);
00073     static_reportsLibrary->setAdvancedPropertiesVisible(false);
00074 }
00075 
00076 KexiReportPart::~KexiReportPart()
00077 {
00078 }
00079 
00080 KFormDesigner::WidgetLibrary* KexiReportPart::library()
00081 {
00082     return static_reportsLibrary;
00083 }
00084 
00085 void
00086 KexiReportPart::initPartActions()
00087 {
00088 }
00089 
00090 void
00091 KexiReportPart::initInstanceActions()
00092 {
00093     KFormDesigner::FormManager::self()->createActions(
00094         library(), actionCollectionForMode(Kexi::DesignViewMode));
00095 }
00096 
00097 KexiDialogTempData*
00098 KexiReportPart::createTempData(KexiDialogBase* dialog)
00099 {
00100     return new KexiReportPart::TempData(dialog);
00101 }
00102 
00103 KexiViewBase*
00104 KexiReportPart::createView(QWidget *parent, KexiDialogBase* dialog,
00105     KexiPart::Item &item, int, QMap<QString,QString>*)
00106 {
00107     kexipluginsdbg << "KexiReportPart::createView()" << endl;
00108     KexiMainWindow *win = dialog->mainWin();
00109     if (!win || !win->project() || !win->project()->dbConnection())
00110         return 0;
00111 
00112     KexiReportView *view = new KexiReportView(win, parent, item.name().latin1(),
00113         win->project()->dbConnection() );
00114 
00115     return view;
00116 }
00117 
00118 QString
00119 KexiReportPart::i18nMessage(const QCString& englishMessage, KexiDialogBase* dlg) const
00120 {
00121     Q_UNUSED(dlg);
00122     if (englishMessage=="Design of object \"%1\" has been modified.")
00123         return i18n("Design of report \"%1\" has been modified.");
00124     if (englishMessage=="Object \"%1\" already exists.")
00125         return i18n("Report \"%1\" already exists.");
00126     return englishMessage;
00127 }
00128 
00129 //---------------
00130 
00131 KexiReportPart::TempData::TempData(QObject* parent)
00132  : KexiDialogTempData(parent)
00133 {
00134 }
00135 
00136 KexiReportPart::TempData::~TempData()
00137 {
00138 }
00139 
00140 #include "kexireportpart.moc"
00141 
KDE Home | KDE Accessibility Home | Description of Access Keys