summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/reports
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kexi/plugins/reports
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/plugins/reports')
-rw-r--r--kexi/plugins/reports/Makefile.am51
-rw-r--r--kexi/plugins/reports/kexireportfactory.cpp227
-rw-r--r--kexi/plugins/reports/kexireportfactory.h62
-rw-r--r--kexi/plugins/reports/kexireportform.cpp188
-rw-r--r--kexi/plugins/reports/kexireportform.h60
-rw-r--r--kexi/plugins/reports/kexireporthandler.desktop108
-rw-r--r--kexi/plugins/reports/kexireportpart.cpp141
-rw-r--r--kexi/plugins/reports/kexireportpart.h88
-rw-r--r--kexi/plugins/reports/kexireportpartinstui.rc37
-rw-r--r--kexi/plugins/reports/kexireportpartui.rc6
-rw-r--r--kexi/plugins/reports/kexireports.cpp24
-rw-r--r--kexi/plugins/reports/kexireportview.cpp477
-rw-r--r--kexi/plugins/reports/kexireportview.h130
-rw-r--r--kexi/plugins/reports/kformdesigner_kexireportfactory.desktop53
-rw-r--r--kexi/plugins/reports/reportwidgets.cpp181
-rw-r--r--kexi/plugins/reports/reportwidgets.h117
16 files changed, 1950 insertions, 0 deletions
diff --git a/kexi/plugins/reports/Makefile.am b/kexi/plugins/reports/Makefile.am
new file mode 100644
index 00000000..4f8e54c4
--- /dev/null
+++ b/kexi/plugins/reports/Makefile.am
@@ -0,0 +1,51 @@
+include $(top_srcdir)/kexi/Makefile.global
+
+kde_module_LTLIBRARIES = kexihandler_report.la kexireportwidgets.la
+
+kexihandler_report_la_SOURCES = kexireports.cpp
+kexihandler_report_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) $(VER_INFO) -module -no-undefined
+kexihandler_report_la_LIBADD = ../../core/libkexicore.la \
+ $(top_builddir)/kexi/widget/utils/libkexiguiutils.la \
+ $(top_builddir)/kexi/widget/libkexiextendedwidgets.la \
+ $(top_builddir)/kexi/formeditor/libkformdesigner.la \
+ $(top_builddir)/kexi/plugins/forms/libkexiformutils.la \
+ ./libkexireportutils.la
+
+kexireportwidgets_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) $(VER_INFO) -module -no-undefined
+kexireportwidgets_la_SOURCES = reportwidgets.cpp kexireportfactory.cpp
+kexireportwidgets_la_LIBADD = $(top_builddir)/kexi/formeditor/libkformdesigner.la \
+ $(top_builddir)/kexi/plugins/forms/libkexiformutils.la \
+ $(top_builddir)/kexi/plugins/forms/widgets/libkexiformutilswidgets.la \
+ $(top_builddir)/kexi/widget/libkexiextendedwidgets.la \
+ ./libkexireportutils.la
+
+lib_LTLIBRARIES = libkexireportutils.la
+libkexireportutils_la_SOURCES = \
+ kexireportpart.cpp kexireportview.cpp kexireportform.cpp
+libkexireportutils_la_LDFLAGS = $(all_libraries) $(VER_INFO) -no-undefined
+libkexireportutils_la_LIBADD = $(top_builddir)/kexi/core/libkexicore.la \
+ $(top_builddir)/kexi/formeditor/libkformdesigner.la \
+ $(top_builddir)/kexi/plugins/forms/widgets/libkexiformutilswidgets.la \
+ $(top_builddir)/kexi/widget/libkexiextendedwidgets.la \
+ $(top_builddir)/kexi/plugins/forms/libkexiformutils.la
+
+kformdesignerservicesdir=$(kde_servicesdir)/kformdesigner
+kformdesignerservices_DATA = kformdesigner_kexireportfactory.desktop
+
+servicesdir=$(kde_servicesdir)/kexi
+services_DATA=kexireporthandler.desktop
+
+rcdir = $(kde_datadir)/kexi
+rc_DATA = kexireportpartui.rc kexireportpartinstui.rc
+
+SUBDIRS = .
+
+INCLUDES= -I$(top_srcdir)/kexi/core -I$(top_srcdir)/kexi \
+ -I$(top_srcdir)/lib -I$(top_srcdir)/lib/kofficecore \
+ -I$(top_srcdir)/kexi/widget/utils \
+ -I$(top_srcdir)/kexi/widget \
+ -I$(top_srcdir)/kexi/formeditor -I$(top_srcdir)/kexi/plugins/forms $(all_includes)
+
+METASOURCES = AUTO
+
+include ../Makefile.common
diff --git a/kexi/plugins/reports/kexireportfactory.cpp b/kexi/plugins/reports/kexireportfactory.cpp
new file mode 100644
index 00000000..0ac782c4
--- /dev/null
+++ b/kexi/plugins/reports/kexireportfactory.cpp
@@ -0,0 +1,227 @@
+/* This file is part of the KDE project
+ 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 <qpopupmenu.h>
+#include <qvaluevector.h>
+
+#include <kgenericfactory.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kdebug.h>
+#include <klineedit.h>
+
+#include <container.h>
+#include <form.h>
+#include <formmanager.h>
+#include <widgetlibrary.h>
+
+#include "reportwidgets.h"
+#include "kexireportfactory.h"
+
+KexiReportFactory::KexiReportFactory(QObject *parent, const char *name, const QStringList &)
+ : KFormDesigner::WidgetFactory(parent, name)
+{
+ KFormDesigner::WidgetInfo *wView = new KFormDesigner::WidgetInfo(this);
+ wView->setPixmap("report");
+ wView->setClassName("KexiReportForm");
+ wView->setName(i18n("Report"));
+ wView->setNamePrefix(
+ i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "report"));
+ wView->setDescription(i18n("A report"));
+ addClass(wView);
+
+ KFormDesigner::WidgetInfo *wLabel = new KFormDesigner::WidgetInfo(this);
+ wLabel->setPixmap("label");
+ wLabel->setClassName("Label");
+ wLabel->setName(i18n("Label"));
+ wLabel->setNamePrefix(
+ i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "label"));
+ wLabel->setDescription(i18n("A label to display text"));
+ addClass(wLabel);
+
+ KFormDesigner::WidgetInfo *wPicLabel = new KFormDesigner::WidgetInfo(this);
+ wPicLabel->setPixmap("pixmaplabel");
+ wPicLabel->setClassName("PicLabel");
+ wPicLabel->setName(i18n("Picture Label"));
+ wPicLabel->setNamePrefix(
+ i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "picture"));
+ wPicLabel->setDescription(i18n("A label to display images or icons"));
+ addClass(wPicLabel);
+
+ KFormDesigner::WidgetInfo *wLine = new KFormDesigner::WidgetInfo(this);
+ wLine->setPixmap("line");
+ wLine->setClassName("ReportLine");
+ wLine->setName(i18n("Line"));
+ wLine->setNamePrefix(
+ i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "line"));
+ wLine->setDescription(i18n("A simple line"));
+ addClass(wLine);
+
+ KFormDesigner::WidgetInfo *wSubReport = new KFormDesigner::WidgetInfo(this);
+ wSubReport->setPixmap("report");
+ wSubReport->setClassName("KexiSubReport");
+ wSubReport->setName(i18n("Sub Report"));
+ wSubReport->setNamePrefix(
+ i18n("Widget name. This string will be used to name widgets of this class. It must _not_ contain white spaces and non latin1 characters.", "subReport"));
+ wSubReport->setDescription(i18n("A report embedded in another report"));
+ addClass(wSubReport);
+}
+
+KexiReportFactory::~KexiReportFactory()
+{
+}
+
+QString
+KexiReportFactory::name()
+{
+ return "kexireportwidgets";
+}
+
+QWidget*
+KexiReportFactory::createWidget(const QCString &c, QWidget *p, const char *n,
+ KFormDesigner::Container *container, int options)
+{
+ Q_UNUSED(options);
+ kexipluginsdbg << "KexiReportFactory::create() " << this << endl;
+
+ QString text( container->form()->library()->textForWidgetName(n, c) );
+
+ if(c == "Label")
+ return new Label(text, p, n);
+ else if(c == "PicLabel")
+ return new PicLabel(DesktopIcon("image"), p, n);
+ else if(c == "ReportLine")
+ return new ReportLine(p, n);
+ else if(c == "KexiSubReport")
+ return new KexiSubReport(p, n);
+
+ return 0;
+}
+
+bool
+KexiReportFactory::createMenuActions(const QCString &classname, QWidget *w,
+ QPopupMenu *menu, KFormDesigner::Container *container)
+{
+ Q_UNUSED(w);
+ Q_UNUSED(container);
+ if(classname == "Label") {
+ /*! @todo use KAction */
+ menu->insertItem(SmallIconSet("edit"), i18n("Edit Rich Text"), this, SLOT(editText()));
+ return true;
+ }
+ return false;
+}
+
+bool
+KexiReportFactory::startEditing(const QCString &c, QWidget *w, KFormDesigner::Container *container)
+{
+ m_container = container;
+
+ if(c == "Label") {
+ QLabel *label = static_cast<QLabel*>(w);
+ if(label->textFormat() == RichText) {
+ m_widget = w;
+ editText();
+ }
+ else
+ createEditor(c, label->text(), label, container, label->geometry(), label->alignment());
+ return true;
+ }
+ return false;
+}
+
+bool
+KexiReportFactory::isPropertyVisibleInternal(const QCString &classname, QWidget *w, const QCString &property, bool isTopLevel)
+{
+ if(classname == "Label") {
+ if(property == "pixmap")
+ return false;
+ }
+ else if(classname == "PicLabel") {
+ if((property == "text") || (property == "indent") || (property == "textFormat") || (property == "font") || (property == "alignment"))
+ return false;
+ }
+
+ return WidgetFactory::isPropertyVisibleInternal(classname, w, property, isTopLevel);
+}
+
+QValueList<QCString>
+KexiReportFactory::autoSaveProperties(const QCString &classname)
+{
+ QValueList<QCString> l;
+
+ if(classname == "Label")
+ l << "text";
+ else if(classname == "PicLabel")
+ l << "pixmap";
+
+ return l;
+}
+
+/*
+void
+KexiReportFactory::changeText(const QString &text)
+{
+ QWidget *w = WidgetFactory::m_widget;
+ changeProperty("text", text, m_container);
+
+ int width = w->sizeHint().width();
+
+ if(w->width() < width)
+ w->resize(width, w->height() );
+}
+
+void
+KexiReportFactory::resizeEditor(QWidget *widget, const QCString &)
+{
+ QSize s = widget->size();
+ QPoint p = widget->pos();
+ QRect r;
+
+ m_editor->resize(s);
+ m_editor->move(p);
+}*/
+
+void
+KexiReportFactory::editText()
+{
+ QCString classname = m_widget->className();
+ QString text;
+
+ if(classname == "Label")
+ text = ((QLabel*)m_widget)->text();
+
+ if(editRichText(m_widget, text)) {
+ changeProperty("textFormat", "RichText", m_container->form());
+ changeProperty("text", text, m_container->form());
+ }
+
+ if(classname == "Label")
+ m_widget->resize(m_widget->sizeHint());
+}
+
+bool
+KexiReportFactory::previewWidget(const QCString &, QWidget *, KFormDesigner::Container *)
+{
+ return false;
+}
+
+KFORMDESIGNER_WIDGET_FACTORY(KexiReportFactory, kexireportwidgets)
+
+#include "kexireportfactory.moc"
+
diff --git a/kexi/plugins/reports/kexireportfactory.h b/kexi/plugins/reports/kexireportfactory.h
new file mode 100644
index 00000000..c6b91702
--- /dev/null
+++ b/kexi/plugins/reports/kexireportfactory.h
@@ -0,0 +1,62 @@
+/* This file is part of the KDE project
+ 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.
+*/
+
+#ifndef KEXIREPORTFACTORY_H
+#define KEXIREPORTFACTORY_H
+
+#include <widgetfactory.h>
+
+//! Kexi Factory (DB widgets + subform)
+class KexiReportFactory : public KFormDesigner::WidgetFactory
+{
+ Q_OBJECT
+
+ public:
+ KexiReportFactory(QObject *parent, const char *name, const QStringList &args);
+ virtual ~KexiReportFactory();
+
+ virtual QString name();
+ virtual QWidget *createWidget(const QCString &classname, QWidget *parent, const char *name, KFormDesigner::Container *container,
+ int options = DefaultOptions);
+
+ virtual bool createMenuActions(const QCString &classname, QWidget *w, QPopupMenu *menu,
+ KFormDesigner::Container *container);
+ virtual bool startEditing(const QCString &classname, QWidget *w, KFormDesigner::Container *container);
+ virtual bool previewWidget(const QCString &, QWidget *, KFormDesigner::Container *);
+
+ //virtual void saveSpecialProperty(const QString &classname, const QString &name, const QVariant &value, QWidget *w,
+ //QDomElement &parentNode, QDomDocument &parent) {}
+ //virtual void readSpecialProperty(const QCString &classname, QDomElement &node, QWidget *w, KFormDesigner::ObjectTreeItem *item) {}
+ virtual QValueList<QCString> autoSaveProperties(const QCString &classname);
+
+ public slots:
+ void editText();
+
+ protected:
+ virtual bool isPropertyVisibleInternal(const QCString &, QWidget *, const QCString &, bool isTopLevel);
+// virtual void changeText(const QString &newText);
+// virtual void resizeEditor(QWidget *widget, const QCString &classname);
+
+ private:
+ QWidget *m_widget;
+ KFormDesigner::Container *m_container;
+};
+
+#endif
+
diff --git a/kexi/plugins/reports/kexireportform.cpp b/kexi/plugins/reports/kexireportform.cpp
new file mode 100644
index 00000000..d5dd6f55
--- /dev/null
+++ b/kexi/plugins/reports/kexireportform.cpp
@@ -0,0 +1,188 @@
+/* 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 <qobjectlist.h>
+#include <qpainter.h>
+#include <qcursor.h>
+
+#include <kdebug.h>
+
+#include "kexireportform.h"
+
+KexiReportForm::KexiReportForm(QWidget *parent, const char *name/*, KexiDB::Connection *conn*/)
+ : QWidget(parent, name)
+{
+ //m_conn = conn;
+ kexipluginsdbg << "KexiReportForm::KexiReportForm(): " << endl;
+ setCursor(QCursor(Qt::ArrowCursor)); //to avoid keeping Size cursor when moving from form's boundaries
+ setBackgroundColor(white);
+}
+
+KexiReportForm::~KexiReportForm()
+{
+ kexipluginsdbg << "KexiReportForm::~KexiReportForm(): close" << endl;
+}
+
+//repaint all children widgets
+static void repaintAll(QWidget *w)
+{
+ QObjectList *list = w->queryList("QWidget");
+ QObjectListIt it(*list);
+ for (QObject *obj; (obj=it.current()); ++it ) {
+ static_cast<QWidget*>(obj)->repaint();
+ }
+ delete list;
+}
+
+void
+KexiReportForm::drawRect(const QRect& r, int type)
+{
+ QValueList<QRect> l;
+ l.append(r);
+ drawRects(l, type);
+}
+
+void
+KexiReportForm::drawRects(const QValueList<QRect> &list, int type)
+{
+ QPainter p;
+ p.begin(this, true);
+ bool unclipped = testWFlags( WPaintUnclipped );
+ setWFlags( WPaintUnclipped );
+
+ if (prev_rect.isValid()) {
+ //redraw prev. selection's rectangle
+ p.drawPixmap( QPoint(prev_rect.x()-2, prev_rect.y()-2), buffer, QRect(prev_rect.x()-2, prev_rect.y()-2, prev_rect.width()+4, prev_rect.height()+4));
+ }
+ p.setBrush(QBrush::NoBrush);
+ if(type == 1) // selection rect
+ p.setPen(QPen(white, 1, Qt::DotLine));
+ else if(type == 2) // insert rect
+ p.setPen(QPen(white, 2));
+ p.setRasterOp(XorROP);
+
+ prev_rect = QRect();
+ QValueList<QRect>::ConstIterator endIt = list.constEnd();
+ for(QValueList<QRect>::ConstIterator it = list.constBegin(); it != endIt; ++it) {
+ p.drawRect(*it);
+ prev_rect = prev_rect.unite(*it);
+ }
+
+ if (!unclipped)
+ clearWFlags( WPaintUnclipped );
+ p.end();
+}
+
+void
+KexiReportForm::initBuffer()
+{
+ repaintAll(this);
+ buffer.resize( width(), height() );
+ buffer = QPixmap::grabWindow( winId() );
+ prev_rect = QRect();
+}
+
+void
+KexiReportForm::clearForm()
+{
+ QPainter p;
+ p.begin(this, true);
+ bool unclipped = testWFlags( WPaintUnclipped );
+ setWFlags( WPaintUnclipped );
+
+ //redraw entire form surface
+ p.drawPixmap( QPoint(0,0), buffer, QRect(0,0,buffer.width(), buffer.height()) );
+
+ if (!unclipped)
+ clearWFlags( WPaintUnclipped );
+ p.end();
+
+ repaintAll(this);
+}
+
+void
+KexiReportForm::highlightWidgets(QWidget *from, QWidget *to)//, const QPoint &point)
+{
+ QPoint fromPoint, toPoint;
+ if(from && from->parentWidget() && (from != this))
+ fromPoint = from->parentWidget()->mapTo(this, from->pos());
+ if(to && to->parentWidget() && (to != this))
+ toPoint = to->parentWidget()->mapTo(this, to->pos());
+
+ QPainter p;
+ p.begin(this, true);
+ bool unclipped = testWFlags( WPaintUnclipped );
+ setWFlags( WPaintUnclipped );
+
+ if (prev_rect.isValid()) {
+ //redraw prev. selection's rectangle
+ p.drawPixmap( QPoint(prev_rect.x(), prev_rect.y()), buffer, QRect(prev_rect.x(), prev_rect.y(), prev_rect.width(), prev_rect.height()));
+ }
+
+ p.setPen( QPen(Qt::red, 2) );
+
+ if(to)
+ {
+ QPixmap pix1 = QPixmap::grabWidget(from);
+ QPixmap pix2 = QPixmap::grabWidget(to);
+
+ if((from != this) && (to != this))
+ p.drawLine( from->parentWidget()->mapTo(this, from->geometry().center()), to->parentWidget()->mapTo(this, to->geometry().center()) );
+
+ p.drawPixmap(fromPoint.x(), fromPoint.y(), pix1);
+ p.drawPixmap(toPoint.x(), toPoint.y(), pix2);
+
+ if(to == this)
+ p.drawRoundRect(2, 2, width()-4, height()-4, 4, 4);
+ else
+ p.drawRoundRect(toPoint.x(), toPoint.y(), to->width(), to->height(), 5, 5);
+ }
+
+ if(from == this)
+ p.drawRoundRect(2, 2, width()-4, height()-4, 4, 4);
+ else
+ p.drawRoundRect(fromPoint.x(), fromPoint.y(), from->width(), from->height(), 5, 5);
+
+ if((to == this) || (from == this))
+ prev_rect = QRect(0, 0, buffer.width(), buffer.height());
+ else if(to)
+ {
+ prev_rect.setX( (fromPoint.x() < toPoint.x()) ? (fromPoint.x() - 5) : (toPoint.x() - 5) );
+ prev_rect.setY( (fromPoint.y() < toPoint.y()) ? (fromPoint.y() - 5) : (toPoint.y() - 5) );
+ prev_rect.setRight( (fromPoint.x() < toPoint.x()) ? (toPoint.x() + to->width() + 10) : (fromPoint.x() + from->width() + 10) );
+ prev_rect.setBottom( (fromPoint.y() < toPoint.y()) ? (toPoint.y() + to->height() + 10) : (fromPoint.y() + from->height() + 10) ) ;
+ }
+ else
+ prev_rect = QRect(fromPoint.x()- 5, fromPoint.y() -5, from->width() + 10, from->height() + 10);
+
+ if (!unclipped)
+ clearWFlags( WPaintUnclipped );
+ p.end();
+}
+
+QSize
+KexiReportForm::sizeHint() const
+{
+ //todo: find better size (user configured?)
+ return QSize(400,300);
+}
+
+#include "kexireportform.moc"
+
diff --git a/kexi/plugins/reports/kexireportform.h b/kexi/plugins/reports/kexireportform.h
new file mode 100644
index 00000000..8b03c2ec
--- /dev/null
+++ b/kexi/plugins/reports/kexireportform.h
@@ -0,0 +1,60 @@
+/* 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.
+*/
+
+#ifndef KEXIREPORTFORM_H
+#define KEXIREPORTFORM_H
+
+#include <qwidget.h>
+#include <qpixmap.h>
+
+#include <formeditor/form.h>
+
+//! The report top widget
+class KEXIREPORTUTILS_EXPORT KexiReportForm : public QWidget, public KFormDesigner::FormWidget
+{
+ Q_OBJECT
+
+ public:
+ KexiReportForm(QWidget *parent, const char *name="kexi_dbform");
+ virtual ~KexiReportForm();
+
+ /*QString datasource() const { return m_ds; }
+ bool navigatorShown() const { return m_nav; }
+ void setDatasource(const QString &s) { m_ds = s; }
+ void showRecordNavigator(bool s) { m_nav = s; }*/
+
+ virtual void drawRect(const QRect& r, int type);
+ virtual void drawRects(const QValueList<QRect> &list, int type);
+ virtual void initBuffer();
+ virtual void clearForm();
+ virtual void highlightWidgets(QWidget *from, QWidget *to/*, const QPoint &p*/);
+
+ virtual QSize sizeHint() const;
+
+ private:
+ /*QString m_ds;
+ bool m_nav;
+ KexiDB::Connection *m_conn;*/
+
+ QPixmap buffer; //!< stores grabbed entire form's area for redraw
+ QRect prev_rect; //!< previously selected rectangle
+};
+
+#endif
diff --git a/kexi/plugins/reports/kexireporthandler.desktop b/kexi/plugins/reports/kexireporthandler.desktop
new file mode 100644
index 00000000..e9606dbf
--- /dev/null
+++ b/kexi/plugins/reports/kexireporthandler.desktop
@@ -0,0 +1,108 @@
+[Desktop Entry]
+Type=Service
+ServiceTypes=Kexi/Handler
+
+GenericName=Reports
+GenericName[bg]=Отчети
+GenericName[ca]=Informes
+GenericName[cs]=Sestavy
+GenericName[cy]=Adroddiadau
+GenericName[da]=Rapporter
+GenericName[de]=Berichte
+GenericName[el]=Αναφορές
+GenericName[eo]=Raportoj
+GenericName[es]=Informes
+GenericName[et]=Aruanded
+GenericName[eu]=Txostenak
+GenericName[fa]=گزارشها
+GenericName[fi]=Raportit
+GenericName[fr]=Rapports
+GenericName[fy]=Rapporten
+GenericName[ga]=Tuairiscí
+GenericName[gl]=Informes
+GenericName[he]=דו"חות
+GenericName[hr]=Izvještaji
+GenericName[hu]=Jelentések
+GenericName[is]=Skýrslur
+GenericName[it]=Rapporti
+GenericName[ja]=レポート
+GenericName[km]=របាយការណ៍
+GenericName[lt]=Ataskaitos
+GenericName[lv]=Atskaites
+GenericName[ms]=Laporan
+GenericName[nb]=Rapporter
+GenericName[nds]=Berichten
+GenericName[ne]=प्रतिवेदनहरू
+GenericName[nl]=Rapporten
+GenericName[nn]=Rapportar
+GenericName[pl]=Raporty
+GenericName[pt]=Relatórios
+GenericName[pt_BR]=Relatórios
+GenericName[ru]=Отчёты
+GenericName[se]=Raporttat
+GenericName[sk]=Správy
+GenericName[sl]=Poročila
+GenericName[sr]=Извештаји
+GenericName[sr@Latn]=Izveštaji
+GenericName[sv]=Rapporter
+GenericName[uk]=Звіти
+GenericName[uz]=Hisobotlar
+GenericName[uz@cyrillic]=Ҳисоботлар
+GenericName[zh_CN]=报表
+GenericName[zh_TW]=報告
+Name=Reports
+Name[bg]=Отчети
+Name[ca]=Informes
+Name[cs]=Sestavy
+Name[cy]=Adroddiadau
+Name[da]=Rapporter
+Name[de]=Berichte
+Name[el]=Αναφορές
+Name[eo]=Raportoj
+Name[es]=Informes
+Name[et]=Aruanded
+Name[eu]=Txostenak
+Name[fa]=گزارشها
+Name[fi]=Raportit
+Name[fr]=Rapports
+Name[fy]=Rapporten
+Name[ga]=Tuairiscí
+Name[gl]=Informes
+Name[he]=דו"חות
+Name[hr]=Izvještaji
+Name[hu]=Jelentések
+Name[is]=Skýrslur
+Name[it]=Rapporti
+Name[ja]=レポート
+Name[km]=របាយការណ៍
+Name[lt]=Ataskaitos
+Name[lv]=Atskaites
+Name[ms]=Laporan
+Name[nb]=Rapporter
+Name[nds]=Berichten
+Name[ne]=प्रतिवेदनहरू
+Name[nl]=Rapporten
+Name[nn]=Rapportar
+Name[pl]=Raporty
+Name[pt]=Relatórios
+Name[pt_BR]=Relatórios
+Name[ru]=Отчёты
+Name[se]=Raporttat
+Name[sk]=Správy
+Name[sl]=Poročila
+Name[sr]=Извештаји
+Name[sr@Latn]=Izveštaji
+Name[sv]=Rapporter
+Name[uk]=Звіти
+Name[uz]=Hisobotlar
+Name[uz@cyrillic]=Ҳисоботлар
+Name[zh_CN]=报表
+Name[zh_TW]=報告
+X-KDE-Library=kexihandler_report
+X-KDE-ParentApp=kexi
+X-Kexi-PartVersion=2
+X-Kexi-TypeName=report
+X-Kexi-TypeMime=kexi/report
+X-Kexi-ItemIcon=report
+X-Kexi-SupportsDataExport=false
+X-Kexi-SupportsPrinting=false
diff --git a/kexi/plugins/reports/kexireportpart.cpp b/kexi/plugins/reports/kexireportpart.cpp
new file mode 100644
index 00000000..ad83cbf4
--- /dev/null
+++ b/kexi/plugins/reports/kexireportpart.cpp
@@ -0,0 +1,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(QObject *parent, const char *name, const QStringList &l)
+ : KexiPart::Part(parent, 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 */
+ QStringList 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(QWidget *parent, KexiDialogBase* dialog,
+ KexiPart::Item &item, int, QMap<QString,QString>*)
+{
+ kexipluginsdbg << "KexiReportPart::createView()" << endl;
+ KexiMainWindow *win = dialog->mainWin();
+ if (!win || !win->project() || !win->project()->dbConnection())
+ return 0;
+
+ KexiReportView *view = new KexiReportView(win, parent, item.name().latin1(),
+ win->project()->dbConnection() );
+
+ return view;
+}
+
+QString
+KexiReportPart::i18nMessage(const QCString& 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(QObject* parent)
+ : KexiDialogTempData(parent)
+{
+}
+
+KexiReportPart::TempData::~TempData()
+{
+}
+
+#include "kexireportpart.moc"
+
diff --git a/kexi/plugins/reports/kexireportpart.h b/kexi/plugins/reports/kexireportpart.h
new file mode 100644
index 00000000..19731e57
--- /dev/null
+++ b/kexi/plugins/reports/kexireportpart.h
@@ -0,0 +1,88 @@
+/* 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.
+*/
+
+#ifndef KEXIREPORTPART_H
+#define KEXIREPORTPART_H
+
+#include <kexi.h>
+#include <kexipart.h>
+#include <kexidialogbase.h>
+
+namespace KFormDesigner
+{
+ class FormManager;
+ class WidgetLibrary;
+ class Form;
+}
+
+namespace KexiDB
+{
+ class FieldList;
+}
+
+/*! @short Kexi Report Plugin
+ It just creates a \ref KexiReportView. See there for most of code. */
+class KEXIREPORTUTILS_EXPORT KexiReportPart : public KexiPart::Part
+{
+ Q_OBJECT
+
+ public:
+ KexiReportPart(QObject *parent, const char *name, const QStringList &);
+ virtual ~KexiReportPart();
+
+ //! \return a pointer to Reports Widget Library.
+ static KFormDesigner::WidgetLibrary* library();
+
+// KFormDesigner::FormManager *manager() { return m_manager; }
+
+ void generateForm(KexiDB::FieldList *list, QDomDocument &domDoc);
+
+ class TempData : public KexiDialogTempData
+ {
+ public:
+ TempData(QObject* parent);
+ ~TempData();
+ QGuardedPtr<KFormDesigner::Form> form;
+ QGuardedPtr<KFormDesigner::Form> previewForm;
+ QString tempForm;
+ QPoint scrollViewContentsPos; //!< to preserve contents pos after switching to other view
+ int resizeMode; //!< form's window's resize mode -one of KexiFormView::ResizeMode items
+ };
+
+ virtual QString i18nMessage(const QCString& englishMessage,
+ KexiDialogBase* dlg) const;
+
+ protected:
+ virtual KexiDialogTempData* createTempData(KexiDialogBase* dialog);
+
+ virtual KexiViewBase* createView(QWidget *parent, KexiDialogBase* dialog,
+ KexiPart::Item &item, int viewMode = Kexi::DataViewMode, QMap<QString,QString>* staticObjectArgs = 0);
+
+ virtual void initPartActions();
+ virtual void initInstanceActions();
+
+ static KFormDesigner::WidgetLibrary* static_reportsLibrary;
+
+ private:
+// QGuardedPtr<KFormDesigner::FormManager> m_manager;
+};
+
+#endif
+
diff --git a/kexi/plugins/reports/kexireportpartinstui.rc b/kexi/plugins/reports/kexireportpartinstui.rc
new file mode 100644
index 00000000..9bfc8fe3
--- /dev/null
+++ b/kexi/plugins/reports/kexireportpartinstui.rc
@@ -0,0 +1,37 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="kexireportpartinst" version="1">
+
+<MenuBar>
+ <Menu name="edit">
+ <Action name="fompart_clear_contents"/>
+ </Menu>
+ <Menu name="format" noMerge="1">
+ <text>&amp;Format</text>
+ <Action name="snap_to_grid"/>
+ <Separator/>
+ <Action name="reportpart_align_menu"/>
+ <Action name="reportpart_adjust_size_menu"/>
+ <Separator/>
+ <Action name="reportpart_format_raise"/>
+ <Action name="reportpart_format_lower"/>
+ </Menu>
+</MenuBar>
+
+<ToolBar name="widgets" fullWidth="false">
+ <text>Widgets</text>
+ <Action name="pointer"/>
+ <Separator/>
+ <Action name="library_widget_KexiSubReport"/>
+ <Separator/>
+ <Action name="library_widget_Label"/>
+ <Action name="library_widget_PicLabel"/>
+ <Action name="library_widget_ReportLine"/>
+</ToolBar>
+<ToolBar name="format" fullWidth="false" noMerge="1">
+<text>Format Toolbar</text>
+ <Action name="reportpart_align_menu"/>
+ <Action name="reportpart_adjust_size_menu"/>
+</ToolBar>
+
+</kpartgui>
+
diff --git a/kexi/plugins/reports/kexireportpartui.rc b/kexi/plugins/reports/kexireportpartui.rc
new file mode 100644
index 00000000..a81b09b1
--- /dev/null
+++ b/kexi/plugins/reports/kexireportpartui.rc
@@ -0,0 +1,6 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="kexireportpart" version="1">
+
+
+</kpartgui>
+
diff --git a/kexi/plugins/reports/kexireports.cpp b/kexi/plugins/reports/kexireports.cpp
new file mode 100644
index 00000000..51b03054
--- /dev/null
+++ b/kexi/plugins/reports/kexireports.cpp
@@ -0,0 +1,24 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
+
+ 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 <kgenericfactory.h>
+
+#include "kexireportpart.h"
+
+K_EXPORT_COMPONENT_FACTORY( kexihandler_report, KGenericFactory<KexiReportPart>("kexihandler_report") )
diff --git a/kexi/plugins/reports/kexireportview.cpp b/kexi/plugins/reports/kexireportview.cpp
new file mode 100644
index 00000000..6b7f46b5
--- /dev/null
+++ b/kexi/plugins/reports/kexireportview.cpp
@@ -0,0 +1,477 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
+ Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
+
+ 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 "kexireportview.h"
+
+#include <kdebug.h>
+
+#include <form.h>
+#include <formIO.h>
+#include <formmanager.h>
+#include <objecttree.h>
+#include <widgetpropertyset.h>
+#include <container.h>
+
+#include <kexidialogbase.h>
+//#include <kexidatasourcewizard.h>
+#include <kexidb/fieldlist.h>
+#include <kexidb/connection.h>
+
+#include "kexireportform.h"
+#include <utils/kexirecordnavigator.h>
+
+#define NO_DSWIZARD
+
+KexiReportScrollView::KexiReportScrollView(QWidget *parent, bool preview)
+ : KexiScrollView(parent, preview)
+{
+ if(preview) {
+ setRecordNavigatorVisible(true);
+ recordNavigator()->setLabelText(i18n("Page:"));
+ recordNavigator()->setInsertingButtonVisible(false);
+ }
+ connect(this, SIGNAL(resizingStarted()), this, SLOT(slotResizingStarted()));
+}
+
+KexiReportScrollView::~KexiReportScrollView()
+{
+}
+
+void
+KexiReportScrollView::show()
+{
+ KexiScrollView::show();
+
+ //now get resize mode settings for entire form
+ if (m_preview) {
+ KexiReportView* fv = dynamic_cast<KexiReportView*>(parent());
+ int resizeMode = fv ? fv->resizeMode() : KexiReportView::ResizeAuto;
+ if (resizeMode == KexiReportView::ResizeAuto)
+ setResizePolicy(AutoOneFit);
+ }
+}
+
+void
+KexiReportScrollView::slotResizingStarted()
+{
+ if(m_form && KFormDesigner::FormManager::self())
+ setSnapToGrid(KFormDesigner::FormManager::self()->snapWidgetsToGrid(), m_form->gridSize());
+ else
+ setSnapToGrid(false);
+}
+
+//////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////
+
+KexiReportView::KexiReportView(KexiMainWindow *win, QWidget *parent, const char *name,
+ KexiDB::Connection *conn)
+ : KexiViewBase(win, parent, name), m_propertySet(0), m_conn(conn)
+ , m_resizeMode(KexiReportView::ResizeDefault)
+{
+ QHBoxLayout *l = new QHBoxLayout(this);
+ l->setAutoAdd(true);
+
+ m_scrollView = new KexiReportScrollView(this, viewMode()==Kexi::DataViewMode);
+ setViewWidget(m_scrollView);
+// m_scrollView->show();
+
+ m_reportform = new KexiReportForm(m_scrollView->viewport(), name/*, conn*/);
+// m_reportform->resize(QSize(400, 300));
+ m_scrollView->setWidget(m_reportform);
+ m_scrollView->setResizingEnabled(viewMode()!=Kexi::DataViewMode);
+
+// initForm();
+
+ if (viewMode()==Kexi::DataViewMode) {
+ m_scrollView->viewport()->setPaletteBackgroundColor(m_reportform->palette().active().background());
+#if 0
+ connect(reportPart()->manager(), SIGNAL(noFormSelected()), SLOT(slotNoFormSelected()));
+#endif
+ }
+ else {
+ connect(KFormDesigner::FormManager::self(), SIGNAL(propertySetSwitched(KoProperty::Set *, bool)),
+ this, SLOT(slotPropertySetSwitched(KoProperty::Set *, bool)));
+ connect(KFormDesigner::FormManager::self(), SIGNAL(dirty(KFormDesigner::Form *, bool)),
+ this, SLOT(slotDirty(KFormDesigner::Form *, bool)));
+
+ // action stuff
+ /*connect(reportPart()->manager(), SIGNAL(widgetSelected(KFormDesigner::Form*, bool)), SLOT(slotWidgetSelected(KFormDesigner::Form*, bool)));
+ connect(reportPart()->manager(), SIGNAL(formWidgetSelected(KFormDesigner::Form*)), SLOT(slotFormWidgetSelected(KFormDesigner::Form*)));
+ connect(reportPart()->manager(), SIGNAL(undoEnabled(bool, const QString&)), this, SLOT(setUndoEnabled(bool)));
+ connect(reportPart()->manager(), SIGNAL(redoEnabled(bool, const QString&)), this, SLOT(setRedoEnabled(bool)));*/
+
+ plugSharedAction("edit_copy", KFormDesigner::FormManager::self(), SLOT(copyWidget()));
+ plugSharedAction("edit_cut", KFormDesigner::FormManager::self(), SLOT(cutWidget()));
+ plugSharedAction("edit_paste", KFormDesigner::FormManager::self(), SLOT(pasteWidget()));
+ plugSharedAction("edit_delete", KFormDesigner::FormManager::self(), SLOT(deleteWidget()));
+ plugSharedAction("edit_select_all", KFormDesigner::FormManager::self(), SLOT(selectAll()));
+ plugSharedAction("reportpart_clear_contents", KFormDesigner::FormManager::self(), SLOT(clearWidgetContent()));
+ plugSharedAction("edit_undo", KFormDesigner::FormManager::self(), SLOT(undo()));
+ plugSharedAction("edit_redo", KFormDesigner::FormManager::self(), SLOT(redo()));
+
+ plugSharedAction("reportpart_format_raise", KFormDesigner::FormManager::self(), SLOT(bringWidgetToFront()) );
+ plugSharedAction("reportpart_format_lower", KFormDesigner::FormManager::self(), SLOT(sendWidgetToBack()) );
+
+ plugSharedAction("reportpart_align_menu", KFormDesigner::FormManager::self(), 0 );
+ plugSharedAction("reportpart_align_to_left", KFormDesigner::FormManager::self(),SLOT(alignWidgetsToLeft()) );
+ plugSharedAction("reportpart_align_to_right", KFormDesigner::FormManager::self(), SLOT(alignWidgetsToRight()) );
+ plugSharedAction("reportpart_align_to_top", KFormDesigner::FormManager::self(), SLOT(alignWidgetsToTop()) );
+ plugSharedAction("reportpart_align_to_bottom", KFormDesigner::FormManager::self(), SLOT(alignWidgetsToBottom()) );
+ plugSharedAction("reportpart_align_to_grid", KFormDesigner::FormManager::self(), SLOT(alignWidgetsToGrid()) );
+
+ plugSharedAction("reportpart_adjust_size_menu", KFormDesigner::FormManager::self(), 0 );
+ plugSharedAction("reportpart_adjust_to_fit", KFormDesigner::FormManager::self(), SLOT(adjustWidgetSize()) );
+ plugSharedAction("reportpart_adjust_size_grid", KFormDesigner::FormManager::self(), SLOT(adjustSizeToGrid()) );
+ plugSharedAction("reportpart_adjust_height_small", KFormDesigner::FormManager::self(), SLOT(adjustHeightToSmall()) );
+ plugSharedAction("reportpart_adjust_height_big", KFormDesigner::FormManager::self(), SLOT(adjustHeightToBig()) );
+ plugSharedAction("reportpart_adjust_width_small", KFormDesigner::FormManager::self(), SLOT(adjustWidthToSmall()) );
+ plugSharedAction("reportpart_adjust_width_big", KFormDesigner::FormManager::self(), SLOT(adjustWidthToBig()) );
+ }
+
+ initForm();
+
+ connect(this, SIGNAL(focus(bool)), this, SLOT(slotFocus(bool)));
+ /// @todo skip this if ther're no borders
+// m_reportform->resize( m_reportform->size()+QSize(m_scrollView->verticalScrollBar()->width(), m_scrollView->horizontalScrollBar()->height()) );
+}
+
+KexiReportView::~KexiReportView()
+{
+ // Important: form window is closed.
+ // Set property set to 0 because there is *only one* instance of a property set class
+ // in Kexi, so the main window wouldn't know the set in fact has been changed.
+ m_propertySet = 0;
+ propertySetSwitched();
+}
+
+KFormDesigner::Form*
+KexiReportView::form() const
+{
+ if(viewMode()==Kexi::DataViewMode)
+ return tempData()->previewForm;
+ else
+ return tempData()->form;
+}
+
+void
+KexiReportView::setForm(KFormDesigner::Form *f)
+{
+ if(viewMode()==Kexi::DataViewMode)
+ tempData()->previewForm = f;
+ else
+ tempData()->form = f;
+}
+
+void
+KexiReportView::initForm()
+{
+ setForm( new KFormDesigner::Form(KexiReportPart::library()) );
+ form()->createToplevel(m_reportform, m_reportform);
+
+ // Show the form wizard if this is a new Form
+// KexiDB::FieldList *fields = 0;
+ if(parentDialog()->id() < 0)
+ {
+#ifndef NO_DSWIZARD
+ KexiDataSourceWizard *w = new KexiDataSourceWizard(mainWin(), (QWidget*)mainWin(), "datasource_wizard");
+ if(!w->exec())
+ fields = 0;
+ else
+ fields = w->fields();
+ delete w;
+#endif
+ }
+
+/* if(fields)
+ {
+ @todo generate a report from a table or a query
+ QDomDocument dom;
+ reportPart()->generateForm(fields, dom);
+ KFormDesigner::FormIO::loadFormFromDom(form(), m_reportform, dom);
+ }
+ else*/
+ loadForm();
+
+ KFormDesigner::FormManager::self()->importForm(form(), viewMode()==Kexi::DataViewMode);
+ m_scrollView->setForm(form());
+ m_scrollView->refreshContentsSize();
+}
+
+void
+KexiReportView::loadForm()
+{
+
+//@todo also load m_resizeMode !
+
+ kexipluginsdbg << "KexiReportForm::loadForm() Loading the form with id : " << parentDialog()->id() << endl;
+ // If we are previewing the Form, use the tempData instead of the form stored in the db
+ if(viewMode()==Kexi::DataViewMode && !tempData()->tempForm.isNull() ) {
+ KFormDesigner::FormIO::loadFormFromString(form(), m_reportform, tempData()->tempForm);
+ return;
+ }
+
+ // normal load
+ QString data;
+ loadDataBlock(data);
+ KFormDesigner::FormIO::loadFormFromString(form(), m_reportform, data);
+}
+
+void
+KexiReportView::slotPropertySetSwitched(KoProperty::Set *set, bool forceReload)
+{
+ m_propertySet = set;
+ if (forceReload)
+ propertySetReloaded(true/*preservePrevSelection*/);
+ else
+ propertySetSwitched();
+}
+
+tristate
+KexiReportView::beforeSwitchTo(int mode, bool &dontStore)
+{
+ if (mode!=viewMode() && viewMode()!=Kexi::DataViewMode) {
+ //remember our pos
+ tempData()->scrollViewContentsPos
+ = QPoint(m_scrollView->contentsX(), m_scrollView->contentsY());
+ }
+
+ // we don't store on db, but in our TempData
+ dontStore = true;
+ if(dirty() && (mode == Kexi::DataViewMode) && form()->objectTree())
+ KFormDesigner::FormIO::saveFormToString(form(), tempData()->tempForm);
+
+ return true;
+}
+
+tristate
+KexiReportView::afterSwitchFrom(int mode)
+{
+ if (mode != 0 && mode != Kexi::DesignViewMode) {
+ //preserve contents pos after switching to other view
+ m_scrollView->setContentsPos(tempData()->scrollViewContentsPos.x(),
+ tempData()->scrollViewContentsPos.y());
+ }
+// if (mode == Kexi::DesignViewMode) {
+ //m_scrollView->move(0,0);
+ //m_scrollView->setContentsPos(0,0);
+ //m_scrollView->moveChild(m_reportform, 0, 0);
+// }
+
+ if((mode == Kexi::DesignViewMode) && viewMode()==Kexi::DataViewMode) {
+ // The form may have been modified, so we must recreate the preview
+ delete m_reportform; // also deletes form()
+ m_reportform = new KexiReportForm(m_scrollView->viewport());
+ m_scrollView->setWidget(m_reportform);
+
+ initForm();
+#if 0
+ slotNoFormSelected();
+#endif
+
+ //reset position
+ m_scrollView->setContentsPos(0,0);
+ m_reportform->move(0,0);
+ }
+ return true;
+}
+
+void
+KexiReportView::slotDirty(KFormDesigner::Form *dirtyForm, bool isDirty)
+{
+ if(dirtyForm == form())
+ KexiViewBase::setDirty(isDirty);
+}
+
+KexiDB::SchemaData*
+KexiReportView::storeNewData(const KexiDB::SchemaData& sdata, bool &cancel)
+{
+ KexiDB::SchemaData *s = KexiViewBase::storeNewData(sdata, cancel);
+ kexipluginsdbg << "KexiReportForm::storeNewData(): new id:" << s->id() << endl;
+
+ if (!s || cancel) {
+ delete s;
+ return 0;
+ }
+ if (!storeData()) {
+ //failure: remove object's schema data to avoid garbage
+ m_conn->removeObject( s->id() );
+ delete s;
+ return 0;
+ }
+ return s;
+}
+
+tristate
+KexiReportView::storeData(bool dontAsk)
+{
+ Q_UNUSED(dontAsk)
+ kexipluginsdbg << "KexiReportForm::storeData(): " << parentDialog()->partItem()->name() << " [" << parentDialog()->id() << "]" << endl;
+ QString data;
+ KFormDesigner::FormIO::saveFormToString(tempData()->form, data);
+ if (!storeDataBlock(data))
+ return false;
+ tempData()->tempForm = QString();
+
+ return true;
+}
+
+#if 0
+/// Action stuff /////////////////
+void
+KexiReportView::slotWidgetSelected(KFormDesigner::Form *f, bool multiple)
+{
+ if(f != form())
+ return;
+
+ enableFormActions();
+ // Enable edit actions
+ setAvailable("edit_copy", true);
+ setAvailable("edit_cut", true);
+ setAvailable("edit_clear", true);
+
+ // 'Align Widgets' menu
+ setAvailable("reportpart_align_menu", multiple);
+ setAvailable("reportpart_align_to_left", multiple);
+ setAvailable("reportpart_align_to_right", multiple);
+ setAvailable("reportpart_align_to_top", multiple);
+ setAvailable("reportpart_align_to_bottom", multiple);
+
+ setAvailable("reportpart_adjust_size_menu", true);
+ setAvailable("reportpart_adjust_width_small", multiple);
+ setAvailable("reportpart_adjust_width_big", multiple);
+ setAvailable("reportpart_adjust_height_small", multiple);
+ setAvailable("reportpart_adjust_height_big", multiple);
+
+ setAvailable("reportpart_format_raise", true);
+ setAvailable("reportpart_format_lower", true);
+}
+
+void
+KexiReportView::slotFormWidgetSelected(KFormDesigner::Form *f)
+{
+ if(f != form())
+ return;
+
+ disableWidgetActions();
+ enableFormActions();
+}
+
+void
+KexiReportView::slotNoFormSelected() // == form in preview mode
+{
+ disableWidgetActions();
+
+ // Disable paste action
+ setAvailable("edit_paste", false);
+ setAvailable("edit_undo", false);
+ setAvailable("edit_redo", false);
+}
+
+void
+KexiReportView::enableFormActions()
+{
+ setAvailable("edit_paste", KFormDesigner::FormManager::self()->isPasteEnabled());
+}
+
+void
+KexiReportView::disableWidgetActions()
+{
+ // Disable edit actions
+ setAvailable("edit_copy", false);
+ setAvailable("edit_cut", false);
+ setAvailable("edit_clear", false);
+
+ // Disable format functions
+ setAvailable("reportpart_align_menu", false);
+ setAvailable("reportpart_align_to_left", false);
+ setAvailable("reportpart_align_to_right", false);
+ setAvailable("reportpart_align_to_top", false);
+ setAvailable("reportpart_align_to_bottom", false);
+
+ setAvailable("reportpart_adjust_size_menu", false);
+ setAvailable("reportpart_adjust_width_small", false);
+ setAvailable("reportpart_adjust_width_big", false);
+ setAvailable("reportpart_adjust_height_small", false);
+ setAvailable("reportpart_adjust_height_big", false);
+
+ setAvailable("reportpart_format_raise", false);
+ setAvailable("reportpart_format_lower", false);
+}
+
+void
+KexiReportView::setUndoEnabled(bool enabled)
+{
+ setAvailable("edit_undo", enabled);
+}
+
+void
+KexiReportView::setRedoEnabled(bool enabled)
+{
+ setAvailable("edit_redo", enabled);
+}
+#endif
+
+QSize
+KexiReportView::preferredSizeHint(const QSize& otherSize)
+{
+ return (m_reportform->size()
+ +QSize(m_scrollView->verticalScrollBar()->isVisible() ? m_scrollView->verticalScrollBar()->width()*3/2 : 10,
+ m_scrollView->horizontalScrollBar()->isVisible() ? m_scrollView->horizontalScrollBar()->height()*3/2 : 10))
+ .expandedTo( KexiViewBase::preferredSizeHint(otherSize) );
+}
+
+void
+KexiReportView::resizeEvent( QResizeEvent *e )
+{
+ if (viewMode()==Kexi::DataViewMode) {
+ m_scrollView->refreshContentsSizeLater(
+ e->size().width()!=e->oldSize().width(),
+ e->size().height()!=e->oldSize().height()
+ );
+ }
+ KexiViewBase::resizeEvent(e);
+ m_scrollView->updateNavPanelGeometry();
+}
+
+void
+KexiReportView::show()
+{
+ KexiViewBase::show();
+
+//moved from KexiFormScrollView::show():
+
+ //now get resize mode settings for entire form
+ // if (resizeMode() == KexiFormView::ResizeAuto)
+ if (viewMode()==Kexi::DataViewMode) {
+ if (resizeMode() == ResizeAuto)
+ m_scrollView->setResizePolicy(QScrollView::AutoOneFit);
+ }
+}
+
+void
+KexiReportView::slotFocus(bool in)
+{
+ if(in && form() && KFormDesigner::FormManager::self() && KFormDesigner::FormManager::self()->activeForm() != form())
+ KFormDesigner::FormManager::self()->windowChanged(form()->widget());//m_dbform);
+}
+
+
+#include "kexireportview.moc"
+
diff --git a/kexi/plugins/reports/kexireportview.h b/kexi/plugins/reports/kexireportview.h
new file mode 100644
index 00000000..b600c06d
--- /dev/null
+++ b/kexi/plugins/reports/kexireportview.h
@@ -0,0 +1,130 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
+ Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
+
+ 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 <qscrollview.h>
+#include <qtimer.h>
+
+#include <kexiviewbase.h>
+
+#include "kexiscrollview.h"
+#include "kexireportpart.h"
+
+class KexiReportForm;
+
+class KEXIREPORTUTILS_EXPORT KexiReportScrollView : public KexiScrollView
+{
+ Q_OBJECT
+
+ public:
+ KexiReportScrollView(QWidget *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, QWidget *parent, const char *name, KexiDB::Connection *conn);
+ virtual ~KexiReportView();
+
+ KexiDB::Connection* connection() { return m_conn; }
+
+ virtual QSize preferredSizeHint(const QSize& 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 ( QResizeEvent * );
+
+ private:
+ KexiReportForm *m_reportform;
+ KexiReportScrollView *m_scrollView;
+ KoProperty::Set *m_propertySet;
+ KexiDB::Connection *m_conn;
+ int m_resizeMode;
+};
+
+#endif
diff --git a/kexi/plugins/reports/kformdesigner_kexireportfactory.desktop b/kexi/plugins/reports/kformdesigner_kexireportfactory.desktop
new file mode 100644
index 00000000..46ccbd61
--- /dev/null
+++ b/kexi/plugins/reports/kformdesigner_kexireportfactory.desktop
@@ -0,0 +1,53 @@
+[Desktop Entry]
+Type=Service
+ServiceTypes=KFormDesigner/WidgetFactory
+
+Name=Kexi Report Widgets
+Name[bg]=Графични елементи за отчети на Kexi
+Name[ca]=Estris d'informe de Kexi
+Name[cy]=Celfigion Adroddiad i Kexi
+Name[da]=Kexi Rapportkontroller
+Name[de]=Kexi Bericht-Elemente
+Name[el]=Γραφικά συστατικά αναφορών Kexi
+Name[eo]=Kexi-raportfenestraĵo
+Name[es]=Widgets para informes de Kexi
+Name[et]=Kexi aruandevidinad
+Name[eu]=Kexi-ren txosten-trepetak
+Name[fa]=عناصر گزارش Kexi
+Name[fi]=Kexi Raporttielementit
+Name[fr]=Éléments de rapport Kexi
+Name[fy]=Kexi Rapport-widgets
+Name[gl]=Elementos de Informe de Kexi
+Name[he]=פריטי דו"חות של Kexi
+Name[hr]=Kexi widgeti izvještaja
+Name[hu]=Kexi jelentéskezelő grafikus elemek
+Name[is]=Kexi skýrslu hlutar
+Name[it]=Oggetti dei rapporti per Kexi
+Name[ja]=Kexi レポートウィジェット
+Name[km]=ធាតុ​ក្រាហ្វិក​របាយការណ៍​​សម្រាប់ Kexi
+Name[lv]=Kexi atskaišu logdaļas
+Name[ms]=Widget Laporan Kexi
+Name[nb]=Skjermelement for Kexi-rapport
+Name[nds]=Bericht-Elementen för Kexi
+Name[ne]=केक्सी प्रतिवेदन विजेटहरू
+Name[nl]=Kexi Rapportwidgets
+Name[nn]=Skjermelement for Kexi-rapport
+Name[pl]=Kontrolki raportów dla Kexi
+Name[pt]=Elementos de Relatório do Kexi
+Name[pt_BR]=Widgets de Relatório do Kexi
+Name[ru]=Элементы управления для отчётов Kexi
+Name[se]=Kexi-raportaáđat
+Name[sk]=Moduly správ Kexi
+Name[sl]=Gradniki za poročila za Kexi
+Name[sr]=Kexi-јеве контроле за извештаје
+Name[sr@Latn]=Kexi-jeve kontrole za izveštaje
+Name[sv]=Kexi-rapportkomponenter
+Name[uk]=Віджети звітів Kexi
+Name[uz]=Kexi hisobot vidjetlari
+Name[uz@cyrillic]=Kexi ҳисобот виджетлари
+Name[zh_CN]=Kexi 报表部件
+Name[zh_TW]=Kexi 報告視窗元件
+
+X-KDE-Library=kformdesigner_kexireportwidgets
+X-KFormDesigner-FactoryGroup=kexi-report
+X-KFormDesigner-WidgetFactoryVersion=2
diff --git a/kexi/plugins/reports/reportwidgets.cpp b/kexi/plugins/reports/reportwidgets.cpp
new file mode 100644
index 00000000..5437325a
--- /dev/null
+++ b/kexi/plugins/reports/reportwidgets.cpp
@@ -0,0 +1,181 @@
+/* This file is part of the KDE project
+ 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 <qpainter.h>
+
+#include <form.h>
+#include <formIO.h>
+#include <formmanager.h>
+#include <kexidb/utils.h>
+#include <kexidb/connection.h>
+#include <kexipart.h>
+
+#include "kexireportview.h"
+#include "reportwidgets.h"
+
+Label::Label(const QString &text, QWidget *parent, const char *name)
+: QLabel(text, parent, name)
+{
+ setPaletteBackgroundColor(white);
+}
+
+////////////////////////////////////////////////////////////////////
+
+ReportLine::ReportLine(QWidget *parent, const char *name)
+: QWidget(parent, name)
+{
+ m_lineStyle = (ReportLineStyle)Qt::SolidLine;
+ m_lineWidth = 1;
+ m_capStyle = (CapStyle)Qt::FlatCap;
+ m_color = paletteForegroundColor();
+ setPaletteBackgroundColor(white);
+}
+
+ReportLine::ReportLineStyle
+ReportLine::lineStyle() const
+{
+ return m_lineStyle;
+}
+
+void
+ReportLine::setLineStyle(ReportLineStyle style)
+{
+ m_lineStyle = style;
+ update();
+}
+
+int
+ReportLine::lineWidth() const
+{
+ return m_lineWidth;
+}
+
+void
+ReportLine::setLineWidth(int width)
+{
+ m_lineWidth = width;
+ update();
+}
+
+QColor
+ReportLine::color() const
+{
+ return m_color;
+}
+
+void
+ReportLine::setColor(const QColor &color)
+{
+ m_color = color;
+ update();
+}
+
+ReportLine::CapStyle
+ReportLine::capStyle() const
+{
+ return m_capStyle;
+}
+
+void
+ReportLine::setCapStyle(CapStyle capStyle)
+{
+ m_capStyle = capStyle;
+ update();
+}
+
+void
+ReportLine::paintEvent (QPaintEvent *ev)
+{
+ QPainter p(this);
+ if(!ev->erased())
+ p.eraseRect(0, 0, width(), height());
+ QPen pen(m_color, m_lineWidth, (Qt::PenStyle)m_lineStyle);
+ pen.setCapStyle((Qt::PenCapStyle)m_capStyle);
+ p.setPen(pen);
+ p.drawLine(0, 0, width() -1, height() - 1);
+}
+
+////////////////////////////////////////////////////////////////////
+
+
+PicLabel::PicLabel(const QPixmap &pix, QWidget *parent, const char *name)
+ : QLabel(parent, name)
+{
+ setPixmap(pix);
+ setScaledContents(false);
+ setPaletteBackgroundColor(white);
+}
+
+bool
+PicLabel::setProperty(const char *name, const QVariant &value)
+{
+ if(QString(name) == "pixmap")
+ resize(value.toPixmap().height(), value.toPixmap().width());
+ return QLabel::setProperty(name, value);
+}
+
+////////////////////////////////////////////////////////////////////
+
+KexiSubReport::KexiSubReport(QWidget *parent, const char *name)
+: QScrollView(parent, name), m_form(0), m_widget(0)
+{
+ setFrameStyle(QFrame::Plain | QFrame::Box);
+ viewport()->setPaletteBackgroundColor(white);
+}
+
+void
+KexiSubReport::setReportName(const QString &name)
+{
+ if(name.isEmpty())
+ return;
+
+ // we need a KexiReportView*
+ QWidget *w = parentWidget();
+ while(w && !w->isA("KexiReportView"))
+ w = w->parentWidget();
+ KexiReportView *view = (KexiReportView*)w;
+ if(!view)
+ return;
+
+ // we check if there is a form with this name
+ int id = KexiDB::idForObjectName(*(view->connection()), name, KexiPart::ReportObjectType);
+ if((id == 0) || (id == view->parentDialog()->id())) // == our form
+ return; // because of recursion when loading
+
+ // we create the container widget
+ delete m_widget;
+ m_widget = new QWidget(viewport(), "kexisubreport_widget");
+ m_widget->show();
+ addChild(m_widget);
+ m_form = new Form(KexiReportPart::library(), this->name());
+ m_form->createToplevel(m_widget);
+
+ // and load the sub form
+ QString data;
+ tristate res = view->connection()->loadDataBlock(id, data , QString::null);
+ if(res != true)
+ return;
+
+ KFormDesigner::FormIO::loadFormFromString(m_form, m_widget, data);
+ m_form->setDesignMode(false);
+
+ m_reportName = name;
+}
+
+#include "reportwidgets.moc"
+
diff --git a/kexi/plugins/reports/reportwidgets.h b/kexi/plugins/reports/reportwidgets.h
new file mode 100644
index 00000000..f8140b0c
--- /dev/null
+++ b/kexi/plugins/reports/reportwidgets.h
@@ -0,0 +1,117 @@
+/* This file is part of the KDE project
+ 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.
+*/
+
+#ifndef KEXIREPORTWIDGETS_H
+#define KEXIREPORTWIDGETS_H
+
+#include <qlabel.h>
+#include <qscrollview.h>
+
+namespace KFormDesigner {
+ class Form;
+ class FormManager;
+}
+
+using KFormDesigner::Form;
+
+//! A form embedded as a widget inside other form
+class KexiSubReport : public QScrollView
+{
+ Q_OBJECT
+ Q_PROPERTY(QString reportName READ reportName WRITE setReportName DESIGNABLE true);
+
+ public:
+ KexiSubReport(QWidget *parent, const char *name);
+ ~KexiSubReport() {}
+
+ //! \return the name of the subreport inside the db
+ QString reportName() const { return m_reportName; }
+ void setReportName(const QString &name);
+
+ private:
+// KFormDesigner::FormManager *m_manager;
+ Form *m_form;
+ QWidget *m_widget;
+ QString m_reportName;
+};
+
+//! A simple label inside a report
+class Label : public QLabel
+{
+ Q_OBJECT
+
+ public:
+ Label(const QString &text, QWidget *parent, const char *name);
+ ~Label() {}
+};
+
+//! A simple picture label inside a report
+class PicLabel : public QLabel
+{
+ Q_OBJECT
+
+ public:
+ PicLabel(const QPixmap &pix, QWidget *parent, const char *name);
+ ~PicLabel() {}
+
+ virtual bool setProperty(const char *name, const QVariant &value);
+};
+
+//! A line
+class ReportLine : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(ReportLineStyle lineStyle READ lineStyle WRITE setLineStyle)
+ Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(CapStyle capStyle READ capStyle WRITE setCapStyle)
+
+ public:
+ enum ReportLineStyle { NoLine = Qt::NoPen, Solid = Qt::SolidLine, Dash = Qt::DashLine, Dot = Qt::DotLine,
+ DashDot = Qt::DashDotLine, DashDotDot = Qt::DashDotDotLine };
+ enum CapStyle { Flat = Qt::FlatCap, Square = Qt::SquareCap, Round = Qt::RoundCap };
+
+ ReportLine(QWidget *parent, const char *name);
+ ~ReportLine(){;}
+
+ ReportLineStyle lineStyle() const;
+ void setLineStyle(ReportLineStyle style);
+
+ int lineWidth() const;
+ void setLineWidth(int width);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ CapStyle capStyle() const;
+ void setCapStyle(CapStyle capStyle);
+
+ protected:
+ virtual void paintEvent (QPaintEvent *ev);
+
+ private:
+ ReportLineStyle m_lineStyle;
+ int m_lineWidth;
+ CapStyle m_capStyle;
+ QColor m_color;
+};
+
+
+#endif
+