summaryrefslogtreecommitdiffstats
path: root/kugar/kudesigner_lib
diff options
context:
space:
mode:
Diffstat (limited to 'kugar/kudesigner_lib')
-rw-r--r--kugar/kudesigner_lib/Makefile.am17
-rw-r--r--kugar/kudesigner_lib/band.cpp127
-rw-r--r--kugar/kudesigner_lib/band.h62
-rw-r--r--kugar/kudesigner_lib/box.cpp43
-rw-r--r--kugar/kudesigner_lib/box.h80
-rw-r--r--kugar/kudesigner_lib/calcfield.cpp56
-rw-r--r--kugar/kudesigner_lib/calcfield.h46
-rw-r--r--kugar/kudesigner_lib/canvas.cpp386
-rw-r--r--kugar/kudesigner_lib/canvas.h96
-rw-r--r--kugar/kudesigner_lib/command.cpp301
-rw-r--r--kugar/kudesigner_lib/command.h183
-rw-r--r--kugar/kudesigner_lib/commdefs.cpp71
-rw-r--r--kugar/kudesigner_lib/commdefs.h79
-rw-r--r--kugar/kudesigner_lib/detail.cpp52
-rw-r--r--kugar/kudesigner_lib/detail.h43
-rw-r--r--kugar/kudesigner_lib/detailbase.cpp45
-rw-r--r--kugar/kudesigner_lib/detailbase.h44
-rw-r--r--kugar/kudesigner_lib/detailfooter.cpp49
-rw-r--r--kugar/kudesigner_lib/detailfooter.h43
-rw-r--r--kugar/kudesigner_lib/detailheader.cpp49
-rw-r--r--kugar/kudesigner_lib/detailheader.h43
-rw-r--r--kugar/kudesigner_lib/field.cpp104
-rw-r--r--kugar/kudesigner_lib/field.h47
-rw-r--r--kugar/kudesigner_lib/kugartemplate.cpp411
-rw-r--r--kugar/kudesigner_lib/kugartemplate.h88
-rw-r--r--kugar/kudesigner_lib/label.cpp256
-rw-r--r--kugar/kudesigner_lib/label.h57
-rw-r--r--kugar/kudesigner_lib/line.cpp129
-rw-r--r--kugar/kudesigner_lib/line.h48
-rw-r--r--kugar/kudesigner_lib/pagefooter.cpp54
-rw-r--r--kugar/kudesigner_lib/pagefooter.h43
-rw-r--r--kugar/kudesigner_lib/pageheader.cpp55
-rw-r--r--kugar/kudesigner_lib/pageheader.h44
-rw-r--r--kugar/kudesigner_lib/plugin.cpp28
-rw-r--r--kugar/kudesigner_lib/plugin.h74
-rw-r--r--kugar/kudesigner_lib/propertyserializer.cpp76
-rw-r--r--kugar/kudesigner_lib/propertyserializer.h46
-rw-r--r--kugar/kudesigner_lib/reportfooter.cpp56
-rw-r--r--kugar/kudesigner_lib/reportfooter.h43
-rw-r--r--kugar/kudesigner_lib/reportheader.cpp54
-rw-r--r--kugar/kudesigner_lib/reportheader.h44
-rw-r--r--kugar/kudesigner_lib/reportitem.cpp247
-rw-r--r--kugar/kudesigner_lib/reportitem.h82
-rw-r--r--kugar/kudesigner_lib/section.cpp37
-rw-r--r--kugar/kudesigner_lib/section.h48
-rw-r--r--kugar/kudesigner_lib/specialfield.cpp69
-rw-r--r--kugar/kudesigner_lib/specialfield.h49
-rw-r--r--kugar/kudesigner_lib/structurewidget.cpp239
-rw-r--r--kugar/kudesigner_lib/structurewidget.h62
-rw-r--r--kugar/kudesigner_lib/view.cpp841
-rw-r--r--kugar/kudesigner_lib/view.h149
51 files changed, 5495 insertions, 0 deletions
diff --git a/kugar/kudesigner_lib/Makefile.am b/kugar/kudesigner_lib/Makefile.am
new file mode 100644
index 00000000..95b8fe00
--- /dev/null
+++ b/kugar/kudesigner_lib/Makefile.am
@@ -0,0 +1,17 @@
+INCLUDES = $(KOPROPERTY_INCLUDES) $(KOFFICE_INCLUDES) $(all_includes)
+
+# Temporary hack, to work around the KColorCombo bug with --enable-final
+KDE_OPTIONS = nofinal
+
+noinst_LTLIBRARIES = libkudesignercommon.la
+libkudesignercommon_la_LDFLAGS = $(all_libraries)
+libkudesignercommon_la_METASOURCES = AUTO
+libkudesignercommon_la_SOURCES = band.cpp box.cpp calcfield.cpp canvas.cpp \
+ command.cpp commdefs.cpp detailbase.cpp detail.cpp detailfooter.cpp \
+ detailheader.cpp field.cpp kugartemplate.cpp label.cpp line.cpp pagefooter.cpp \
+ pageheader.cpp propertyserializer.cpp reportfooter.cpp reportheader.cpp reportitem.cpp \
+ section.cpp specialfield.cpp structurewidget.cpp view.cpp plugin.cpp
+libkudesignercommon_la_LIBADD = $(LIB_KOPROPERTY)
+
+KDE_CXXFLAGS = $(USE_EXCEPTIONS) -DKPROPERTY_EXPORT=
+
diff --git a/kugar/kudesigner_lib/band.cpp b/kugar/kudesigner_lib/band.cpp
new file mode 100644
index 00000000..0b3225f6
--- /dev/null
+++ b/kugar/kudesigner_lib/band.cpp
@@ -0,0 +1,127 @@
+/* This file is part of the KDE project
+Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+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 "band.h"
+
+#include <qcanvas.h>
+#include <qrect.h>
+#include <qpainter.h>
+
+#include <kglobalsettings.h>
+
+#include "propertyserializer.h"
+#include "kugartemplate.h"
+#include "canvas.h"
+#include "reportitem.h"
+
+namespace Kudesigner
+{
+
+Band::~Band()
+{
+ for ( QCanvasItemList::Iterator it = items.begin(); it != items.end(); ++it )
+ {
+ // (*it)->hide();
+ m_canvas->selected.remove( static_cast<Box*>( *it ) );
+ ( *it ) ->setSelected( false );
+ delete ( *it );
+ }
+ items.clear();
+}
+
+void Band::draw( QPainter &painter )
+{
+ setX( m_canvas->kugarTemplate() ->props[ "LeftMargin" ].value().toInt() );
+ setSize( m_canvas->kugarTemplate() ->width()
+ - m_canvas->kugarTemplate() ->props[ "RightMargin" ].value().toInt()
+ - m_canvas->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ props[ "Height" ].value().toInt() );
+ Section::draw( painter );
+}
+
+//arrange band and all sublings (items)
+void Band::arrange( int base, bool destructive )
+{
+ int diff = base - ( int ) y();
+ setY( base );
+ if ( !destructive )
+ return ;
+ for ( QCanvasItemList::Iterator it = items.begin(); it != items.end(); ++it )
+ {
+ ( *it ) ->moveBy( 0, diff );
+ // ( (CanvasReportItem *)(*it) )->updateGeomProps();
+ m_canvas->update();
+ ( *it ) ->hide();
+ ( *it ) ->show();
+ }
+}
+
+int Band::minHeight()
+{
+ int result = static_cast<int>( y() + 10 );
+ for ( QCanvasItemList::Iterator it = items.begin(); it != items.end(); ++it )
+ {
+ result = QMAX( result, static_cast<int>( static_cast<QCanvasRectangle*>( *it ) ->y() +
+ static_cast<QCanvasRectangle*>( *it ) ->height() ) );
+ }
+ return result - static_cast<int>( y() );
+}
+
+QString Band::getXml()
+{
+ QString result = "";
+
+ for ( Set::Iterator it( props ); it.current(); ++it )
+ {
+ result += " " + QString(it.currentKey()) + "=" + "\"" + PropertySerializer::toString( it.current() ) + "\"";
+ }
+
+ result += ">\n";
+ for ( QCanvasItemList::Iterator it = items.begin(); it != items.end(); ++it )
+ {
+ result += static_cast<ReportItem*>( *it ) ->getXml();
+ }
+ return result;
+}
+
+int Band::isInHolder( const QPoint p )
+{
+ if ( bottomMiddleResizableRect().contains( p ) )
+ return ( ResizeBottom );
+ return ResizeNothing;
+}
+
+void Band::drawHolders( QPainter &painter )
+{
+ painter.setPen( QColor( 0, 0, 0 ) );
+ painter.setBrush( KGlobalSettings::highlightColor() );
+ painter.drawRect( bottomMiddleResizableRect() );
+}
+
+QRect Band::bottomMiddleResizableRect()
+{
+ return QRect( ( int ) ( x() + width() / 2 - HolderSize / 2. ), ( int ) ( y() + height() - HolderSize ), HolderSize, HolderSize );
+}
+
+void Band::updateGeomProps()
+{
+ props[ "Height" ].setValue( height() );
+ m_canvas->kugarTemplate() ->arrangeSections();
+}
+
+}
diff --git a/kugar/kudesigner_lib/band.h b/kugar/kudesigner_lib/band.h
new file mode 100644
index 00000000..6e93bb50
--- /dev/null
+++ b/kugar/kudesigner_lib/band.h
@@ -0,0 +1,62 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 BAND_H
+#define BAND_H
+
+#include "commdefs.h"
+#include "section.h"
+
+class QCanvasItemList;
+class QPainter;
+class QRect;
+class QPoint;
+
+namespace Kudesigner
+{
+
+class Band: public Section
+{
+public:
+ Band( int x, int y, int width, int height, Canvas *canvas ) :
+ Section( x, y, width, height, canvas )
+ {
+ setZ( 10 );
+ }
+ ~Band();
+
+ virtual int rtti() const
+ {
+ return Rtti_Band;
+ }
+ virtual void draw( QPainter &painter );
+ virtual QString getXml();
+ virtual int isInHolder( const QPoint );
+ virtual void drawHolders( QPainter & );
+
+ int minHeight();
+ QRect bottomMiddleResizableRect();
+ void arrange( int base, bool destructive = TRUE );
+ virtual void updateGeomProps();
+
+ QCanvasItemList items;
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/box.cpp b/kugar/kudesigner_lib/box.cpp
new file mode 100644
index 00000000..f80f9a5f
--- /dev/null
+++ b/kugar/kudesigner_lib/box.cpp
@@ -0,0 +1,43 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 <qcanvas.h>
+
+#include "box.h"
+#include "canvas.h"
+
+namespace Kudesigner
+{
+
+Box::~Box()
+{}
+
+void Box::registerAs( int /* type*/ )
+{}
+
+void Box::scale( int scale )
+{
+ setSize( width() * scale, height() * scale );
+}
+
+void Box::draw( QPainter &painter )
+{
+ QCanvasRectangle::draw( painter );
+}
+
+}
diff --git a/kugar/kudesigner_lib/box.h b/kugar/kudesigner_lib/box.h
new file mode 100644
index 00000000..38df93dd
--- /dev/null
+++ b/kugar/kudesigner_lib/box.h
@@ -0,0 +1,80 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 BOX_H
+#define BOX_H
+
+#include <koproperty/set.h>
+#include <koproperty/property.h>
+
+#include "commdefs.h"
+
+using namespace KoProperty;
+
+namespace Kudesigner
+{
+
+class Canvas;
+
+class Box: public QCanvasRectangle
+{
+public:
+ enum ResizeType {ResizeNothing = 0, ResizeLeft = 1, ResizeTop = 2, ResizeRight = 4, ResizeBottom = 8};
+
+ Box( int x, int y, int width, int height, Canvas *canvas ) :
+ QCanvasRectangle( x, y, width, height, ( QCanvas* ) canvas ), m_canvas( canvas )
+ {
+ setSelected( false );
+ }
+ virtual ~Box();
+
+ virtual int rtti() const
+ {
+ return Rtti_Box;
+ }
+ virtual void draw( QPainter &painter );
+ virtual QString getXml()
+ {
+ return "";
+ }
+
+ void scale( int scale );
+
+ virtual int isInHolder( const QPoint )
+ {
+ return ResizeNothing;
+ }
+ virtual void drawHolders( QPainter & )
+ {}
+
+ virtual void updateGeomProps()
+ {
+ ;
+ }
+
+ Set props;
+
+protected:
+ void registerAs( int type );
+
+ Canvas *m_canvas;
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/calcfield.cpp b/kugar/kudesigner_lib/calcfield.cpp
new file mode 100644
index 00000000..bccf7d96
--- /dev/null
+++ b/kugar/kudesigner_lib/calcfield.cpp
@@ -0,0 +1,56 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "calcfield.h"
+
+#include <klocale.h>
+
+#include <qmap.h>
+
+#include <koproperty/property.h>
+
+namespace Kudesigner
+{
+
+CalculatedField::CalculatedField( int x, int y, int width, int height, Canvas *canvas ) :
+ Field( x, y, width, height, canvas, false )
+{
+ QMap<QString, QString> m;
+
+ props.setGroupDescription( "Calculation", i18n( "Calculation" ) );
+ m[ i18n( "Count" ) ] = "0";
+ m[ i18n( "Sum" ) ] = "1";
+ m[ i18n( "Average" ) ] = "2";
+ m[ i18n( "Variance" ) ] = "3";
+ m[ i18n( "StandardDeviation" ) ] = "4";
+ props.addProperty( new Property( "CalculationType", m.values(), m.keys(), "1", i18n( "Type" ), i18n( "Calculation Type" ) ), "Calculation" );
+
+ registerAs( Rtti_Calculated );
+}
+
+void CalculatedField::draw( QPainter &painter )
+{
+ Field::draw( painter );
+}
+
+QString CalculatedField::getXml()
+{
+ return "\t\t<CalculatedField" + ReportItem::getXml() + " />\n";
+}
+
+}
diff --git a/kugar/kudesigner_lib/calcfield.h b/kugar/kudesigner_lib/calcfield.h
new file mode 100644
index 00000000..326e9ba4
--- /dev/null
+++ b/kugar/kudesigner_lib/calcfield.h
@@ -0,0 +1,46 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 CALCFIELD_H
+#define CALCFIELD_H
+
+#include "field.h"
+
+namespace Kudesigner
+{
+
+class CalculatedField: public Field
+{
+public:
+ CalculatedField( int x, int y, int width, int height, Canvas *canvas );
+
+ virtual int rtti() const
+ {
+ return Rtti_Calculated;
+ }
+ virtual QString getXml();
+ virtual void draw( QPainter &painter );
+ virtual void updateGeomProps()
+ {
+ Field::updateGeomProps();
+ }
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/canvas.cpp b/kugar/kudesigner_lib/canvas.cpp
new file mode 100644
index 00000000..e4cfb30f
--- /dev/null
+++ b/kugar/kudesigner_lib/canvas.cpp
@@ -0,0 +1,386 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "canvas.h"
+
+#include <qdom.h>
+#include <qstringlist.h>
+
+#include <koproperty/property.h>
+
+#include "box.h"
+#include "kugartemplate.h"
+
+#include "reportheader.h"
+#include "reportfooter.h"
+#include "pageheader.h"
+#include "pagefooter.h"
+#include "detailheader.h"
+#include "detailfooter.h"
+#include "detail.h"
+
+#include "reportitem.h"
+#include "calcfield.h"
+#include "field.h"
+#include "label.h"
+#include "line.h"
+#include "specialfield.h"
+
+#include "propertyserializer.h"
+
+#include <kdebug.h>
+
+namespace Kudesigner
+{
+
+Canvas::Canvas( int w, int h /*, Canvas *doc*/ )
+ : QCanvas( w, h ), m_plugin( 0 ), m_kugarTemplate( 0 ) //, m_doc(doc)
+{
+}
+
+Canvas::~Canvas()
+{
+ delete m_kugarTemplate;
+}
+
+void Canvas::scaleCanvas( int scale )
+{
+ resize( width() * scale, height() * scale );
+
+ //scale all child items if they are textbox's
+ /* QCanvasItemList l=this->allItems();
+ for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it)
+ {
+ if ((*it)->rtti() == Rtti_TextBox)
+ {
+ CanvasTextBox* b = (CanvasTextBox*)(*it);
+ b->scale(scale);
+ }
+ }*/
+}
+
+void Canvas::drawForeground ( QPainter & painter, const QRect & /*clip*/ )
+{
+ //kdDebug()<<"Canvas::drawForeGround"<<endl;
+ // qWarning("drawForeground ");
+ for ( BoxList::iterator it = selected.begin(); it != selected.end(); ++it )
+ {
+ // qWarning("sel:");
+ ( *it ) ->drawHolders( painter );
+ }
+}
+
+KuDesignerPlugin * Canvas::plugin( )
+{
+ return m_plugin;
+}
+
+void Canvas::setPlugin( KuDesignerPlugin * plugin )
+{
+ m_plugin = plugin;
+}
+
+void Canvas::unselectAll()
+{
+ for ( BoxList::iterator it = selected.begin(); it != selected.end(); ++it )
+ {
+ Box *b = *it;
+ b->setSelected( false );
+ setChanged( b->rect() );
+ }
+
+ selected.clear();
+ update();
+}
+
+void Canvas::selectAll()
+{
+ for ( QCanvasItemList::Iterator it = allItems().begin(); it != allItems().end(); ++it )
+ {
+ if ( ( ( *it ) ->rtti() > 2001 ) && ( ( *it ) ->isVisible() ) )
+ selectItem( static_cast<Box*>( *it ) );
+ }
+}
+
+void Canvas::selectItem( Box *it, bool addToSelection )
+{
+ if ( !it->isVisible() )
+ return ;
+ if ( !addToSelection )
+ unselectAll();
+ selected.append( it );
+ it->setSelected( true );
+
+ emit itemSelected();
+ /* if (!selectionStarted)
+ finishSelection();*/
+}
+
+void Canvas::unselectItem( Box *it )
+{
+ selected.remove( it );
+ it->setSelected( false );
+}
+
+KugarTemplate *Canvas::kugarTemplate()
+{
+ return m_kugarTemplate;
+}
+
+void Canvas::setKugarTemplate( KugarTemplate *kugarTemplate )
+{
+ m_kugarTemplate = kugarTemplate;
+}
+
+bool Canvas::loadXML( const QDomNode &report )
+{
+ QDomNamedNodeMap attributes = report.attributes();
+
+ //creating KugarTemplate object
+ KugarTemplate *templ = new KugarTemplate( 0, 0, width(), height(), this );
+ templ->show();
+ templ->props[ "PageSize" ].setValue( attributes.namedItem( "PageSize" ).nodeValue() );
+ templ->props[ "PageOrientation" ].setValue( attributes.namedItem( "PageOrientation" ).nodeValue() );
+ templ->props[ "TopMargin" ].setValue( attributes.namedItem( "TopMargin" ).nodeValue().toInt() );
+ templ->props[ "BottomMargin" ].setValue( attributes.namedItem( "BottomMargin" ).nodeValue().toInt() );
+ templ->props[ "LeftMargin" ].setValue( attributes.namedItem( "LeftMargin" ).nodeValue().toInt() );
+ templ->props[ "RightMargin" ].setValue( attributes.namedItem( "RightMargin" ).nodeValue().toInt() );
+
+ // Get all the child report elements
+ QDomNodeList children = report.childNodes();
+ int childCount = children.length();
+ for ( int j = 0; j < childCount; j++ )
+ {
+ QDomNode child = children.item( j );
+
+ if ( child.nodeType() == QDomNode::ElementNode )
+ {
+ if ( child.nodeName() == "ReportHeader" )
+ setReportHeaderAttributes( &child );
+ else if ( child.nodeName() == "PageHeader" )
+ setPageHeaderAttributes( &child );
+ else if ( child.nodeName() == "DetailHeader" )
+ setDetailHeaderAttributes( &child );
+ else if ( child.nodeName() == "Detail" )
+ {
+ templ->detailsCount++;
+ setDetailAttributes( &child );
+ }
+ else if ( child.nodeName() == "DetailFooter" )
+ setDetailFooterAttributes( &child );
+ else if ( child.nodeName() == "PageFooter" )
+ setPageFooterAttributes( &child );
+ else if ( child.nodeName() == "ReportFooter" )
+ setReportFooterAttributes( &child );
+ }
+ }
+ templ->arrangeSections( FALSE );
+ QCanvasItemList l = allItems();
+ for ( QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it )
+ {
+ ( *it ) ->show();
+ }
+ update();
+
+ return true;
+}
+
+void Canvas::setReportHeaderAttributes( QDomNode *node )
+{
+ QDomNamedNodeMap attributes = node->attributes();
+
+ ReportHeader *rh = new ReportHeader( kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, kugarTemplate() ->width() - kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ attributes.namedItem( "Height" ).nodeValue().toInt(), this );
+ rh->props[ "Height" ].setValue( attributes.namedItem( "Height" ).nodeValue().toInt() );
+ kugarTemplate() ->reportHeader = rh;
+ addReportItems( node, rh );
+}
+
+void Canvas::setReportFooterAttributes( QDomNode *node )
+{
+ QDomNamedNodeMap attributes = node->attributes();
+
+ ReportFooter *rf = new ReportFooter( kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, kugarTemplate() ->width() - kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ attributes.namedItem( "Height" ).nodeValue().toInt(), this );
+ rf->props[ "Height" ].setValue( attributes.namedItem( "Height" ).nodeValue().toInt() );
+ kugarTemplate() ->reportFooter = rf;
+ addReportItems( node, rf );
+}
+
+void Canvas::setPageHeaderAttributes( QDomNode *node )
+{
+ QDomNamedNodeMap attributes = node->attributes();
+
+ PageHeader *ph = new PageHeader( kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, kugarTemplate() ->width() - kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ attributes.namedItem( "Height" ).nodeValue().toInt(), this );
+ ph->props[ "Height" ].setValue( attributes.namedItem( "Height" ).nodeValue().toInt() );
+ kugarTemplate() ->pageHeader = ph;
+ addReportItems( node, ph );
+}
+
+void Canvas::setPageFooterAttributes( QDomNode *node )
+{
+ QDomNamedNodeMap attributes = node->attributes();
+
+ PageFooter *pf = new PageFooter( kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, kugarTemplate() ->width() - kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ attributes.namedItem( "Height" ).nodeValue().toInt(), this );
+ pf->props[ "Height" ].setValue( attributes.namedItem( "Height" ).nodeValue().toInt() );
+ kugarTemplate() ->pageFooter = pf;
+ addReportItems( node, pf );
+}
+
+void Canvas::setDetailHeaderAttributes( QDomNode *node )
+{
+ QDomNamedNodeMap attributes = node->attributes();
+
+ DetailHeader *dh = new DetailHeader( kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, kugarTemplate() ->width() - kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ attributes.namedItem( "Height" ).nodeValue().toInt(),
+ attributes.namedItem( "Level" ).nodeValue().toInt(), this );
+ dh->props[ "Level" ].setValue( attributes.namedItem( "Level" ).nodeValue().toInt() );
+ dh->props[ "Height" ].setValue( attributes.namedItem( "Height" ).nodeValue().toInt() );
+ kugarTemplate() ->details[ attributes.namedItem( "Level" ).nodeValue().toInt() ].first.first = dh;
+ addReportItems( node, dh );
+}
+
+void Canvas::setDetailAttributes( QDomNode *node )
+{
+ QDomNamedNodeMap attributes = node->attributes();
+
+ Detail *d = new Detail( kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, kugarTemplate() ->width() - kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ attributes.namedItem( "Height" ).nodeValue().toInt(),
+ attributes.namedItem( "Level" ).nodeValue().toInt(), this );
+ d->props[ "Level" ].setValue( attributes.namedItem( "Level" ).nodeValue().toInt() );
+ d->props[ "Height" ].setValue( attributes.namedItem( "Height" ).nodeValue().toInt() );
+ d->props[ "Repeat" ].setValue( QVariant( attributes.namedItem( "Repeat" ).nodeValue() == "true", 3 ) );
+ kugarTemplate() ->details[ attributes.namedItem( "Level" ).nodeValue().toInt() ].second = d;
+ addReportItems( node, d );
+}
+
+void Canvas::setDetailFooterAttributes( QDomNode *node )
+{
+ QDomNamedNodeMap attributes = node->attributes();
+
+ DetailFooter *df = new DetailFooter( kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, kugarTemplate() ->width() - kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ attributes.namedItem( "Height" ).nodeValue().toInt(),
+ attributes.namedItem( "Level" ).nodeValue().toInt(), this );
+ df->props[ "Level" ].setValue( attributes.namedItem( "Level" ).nodeValue().toInt() );
+ df->props[ "Height" ].setValue( attributes.namedItem( "Height" ).nodeValue().toInt() );
+ kugarTemplate() ->details[ attributes.namedItem( "Level" ).nodeValue().toInt() ].first.second = df;
+ addReportItems( node, df );
+}
+
+
+void Canvas::addReportItems( QDomNode *node, Band *section )
+{
+ QDomNodeList children = node->childNodes();
+ int childCount = children.length();
+
+ for ( int j = 0; j < childCount; j++ )
+ {
+ QDomNode child = children.item( j );
+ if ( child.nodeType() == QDomNode::ElementNode )
+ {
+ if ( child.nodeName() == "Line" )
+ {
+ Line * line = new Line( 0, 0, 50, 20, this );
+ section->items.append( line );
+
+ setReportItemAttributes( &child, line );
+ line->setSectionUndestructive( section );
+ //line->show();
+ }
+ else if ( child.nodeName() == "Label" )
+ {
+ Label * label = new Label( 0, 0, 50, 20, this );
+ section->items.append( label );
+ setReportItemAttributes( &child, label );
+ label->setSectionUndestructive( section );
+ //label->show();
+ }
+ else if ( child.nodeName() == "Special" )
+ {
+ SpecialField * special = new SpecialField( 0, 0, 50, 20, this );
+ section->items.append( special );
+ setReportItemAttributes( &child, special );
+ special->setSectionUndestructive( section );
+ //special->show();
+ }
+ else if ( child.nodeName() == "Field" )
+ {
+ Field * field = new Field( 0, 0, 50, 20, this );
+ section->items.append( field );
+ setReportItemAttributes( &child, field );
+ field->setSectionUndestructive( section );
+ //field->show();
+ }
+ else if ( child.nodeName() == "CalculatedField" )
+ {
+ CalculatedField * calcField = new CalculatedField( 0, 0, 50, 20, this );
+ section->items.append( calcField );
+ setReportItemAttributes( &child, calcField );
+ calcField->setSectionUndestructive( section );
+ //calcField->show();
+ }
+ }
+ }
+}
+
+void Canvas::setReportItemAttributes( QDomNode *node, ReportItem *item )
+{
+ QDomNamedNodeMap attributes = node->attributes();
+
+ for ( unsigned int i = 0; i < attributes.count(); i++ )
+ {
+ QString propertyName = attributes.item( i ).nodeName();
+ QString propertyValue = attributes.item( i ).nodeValue();
+
+ item->props[ propertyName.utf8() ].setValue(
+ PropertySerializer::fromString( &item->props[ propertyName.utf8() ], propertyValue ) );
+ }
+}
+
+void Canvas::changed()
+{
+ for ( Kudesigner::BoxList::iterator it = selected.begin();
+ it != selected.end(); ++it )
+ {
+ Kudesigner::Box *b = *it;
+ b->hide();
+ b->show();
+ if ( ( b->rtti() >= 1800 ) && ( b->rtti() < 2000 ) )
+ kugarTemplate() ->arrangeSections();
+ }
+}
+
+}
+
+#include "canvas.moc"
diff --git a/kugar/kudesigner_lib/canvas.h b/kugar/kudesigner_lib/canvas.h
new file mode 100644
index 00000000..fda6aa7d
--- /dev/null
+++ b/kugar/kudesigner_lib/canvas.h
@@ -0,0 +1,96 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 MYCANVAS_H
+#define MYCANVAS_H
+
+#include <qcanvas.h>
+#include <qvaluelist.h>
+
+#include "box.h"
+
+class QDomNode;
+class QIODevice;
+class KuDesignerPlugin;
+
+namespace Kudesigner
+{
+
+class KugarTemplate;
+class Band;
+class ReportItem;
+
+typedef QValueList<Box*> BoxList;
+
+class Canvas: public QCanvas
+{
+ Q_OBJECT
+public:
+ Canvas( int w, int h );
+ ~Canvas();
+
+ KugarTemplate *kugarTemplate();
+ void setKugarTemplate( KugarTemplate *kugarTemplate );
+
+ // KudesignerDoc *document(){return m_doc;}
+
+ BoxList selected;
+
+ KuDesignerPlugin *plugin();
+ void setPlugin( KuDesignerPlugin *plugin );
+
+ void unselectAll();
+ void selectAll();
+ void selectItem( Box *it, bool addToSelection = true );
+ void unselectItem( Box *it );
+ void setStructureModified() { emit structureModified(); }
+ // void deleteSelected();
+
+ virtual bool loadXML( const QDomNode &report );
+
+public slots:
+ void changed();
+
+signals:
+ void itemSelected();
+ void structureModified();
+
+protected:
+ virtual void drawForeground( QPainter &painter, const QRect &clip );
+
+ void setReportItemAttributes( QDomNode *node, ReportItem *item );
+ void addReportItems( QDomNode *node, Band *section );
+ void setReportHeaderAttributes( QDomNode *node );
+ void setReportFooterAttributes( QDomNode *node );
+ void setPageHeaderAttributes( QDomNode *node );
+ void setPageFooterAttributes( QDomNode *node );
+ void setDetailHeaderAttributes( QDomNode *node );
+ void setDetailAttributes( QDomNode *node );
+ void setDetailFooterAttributes( QDomNode *node );
+
+private:
+ // KudesignerDoc *m_doc;
+ void scaleCanvas( int scale );
+ KuDesignerPlugin *m_plugin;
+ KugarTemplate *m_kugarTemplate;
+
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/command.cpp b/kugar/kudesigner_lib/command.cpp
new file mode 100644
index 00000000..1644868a
--- /dev/null
+++ b/kugar/kudesigner_lib/command.cpp
@@ -0,0 +1,301 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "command.h"
+
+#include <klocale.h>
+#include <kdebug.h>
+
+//#include "kudesigner_doc.h"
+
+#include <koproperty/editor.h>
+#include <koproperty/property.h>
+
+#include "view.h"
+#include "canvas.h"
+
+#include "field.h"
+#include "calcfield.h"
+#include "label.h"
+#include "line.h"
+#include "specialfield.h"
+
+#include "kugartemplate.h"
+#include "reportheader.h"
+#include "reportfooter.h"
+#include "pageheader.h"
+#include "pagefooter.h"
+#include "detailheader.h"
+#include "detailfooter.h"
+#include "detail.h"
+
+
+namespace Kudesigner
+{
+
+//AddDetailFooterCommand
+
+AddDetailFooterCommand::AddDetailFooterCommand( int level, Canvas *doc )
+ : KNamedCommand( QObject::tr( "Insert Detail Footer Section" ) ), m_level( level ), m_doc( doc )
+{}
+
+void AddDetailFooterCommand::execute()
+{
+ m_section = new DetailFooter( m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, m_doc->kugarTemplate() ->width() - m_doc->kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 50, m_level, m_doc );
+ m_section->props[ "Level" ].setValue( m_level );
+ m_doc->kugarTemplate() ->details[ m_level ].first.second = m_section;
+ m_doc->kugarTemplate() ->arrangeSections();
+ m_doc->setStructureModified();
+}
+
+void AddDetailFooterCommand::unexecute()
+{
+ m_doc->kugarTemplate() ->removeReportItem( m_section );
+ m_doc->setStructureModified();
+}
+
+//AddDetailCommand
+
+AddDetailCommand::AddDetailCommand( int level, Canvas *doc )
+ : KNamedCommand( QObject::tr( "Insert Detail Section" ) ), m_level( level ), m_doc( doc )
+{}
+
+void AddDetailCommand::execute()
+{
+ m_section = new Detail( m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, m_doc->kugarTemplate() ->width() - m_doc->kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 50, m_level, m_doc );
+ m_section->props[ "Level" ].setValue( m_level );
+ m_doc->kugarTemplate() ->details[ m_level ].second = m_section;
+ m_doc->kugarTemplate() ->arrangeSections();
+ m_doc->kugarTemplate() ->detailsCount++;
+ m_doc->setStructureModified();
+}
+
+void AddDetailCommand::unexecute()
+{
+ m_doc->kugarTemplate() ->removeReportItem( m_section );
+ m_doc->setStructureModified();
+}
+
+//AddDetailHeaderCommand
+AddDetailHeaderCommand::AddDetailHeaderCommand( int level, Canvas *doc )
+ : KNamedCommand( QObject::tr( "Insert Detail Header Section" ) ), m_level( level ), m_doc( doc )
+{}
+
+void AddDetailHeaderCommand::execute()
+{
+ m_section = new DetailHeader( m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, m_doc->kugarTemplate() ->width() - m_doc->kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 50, m_level, m_doc );
+ m_section->props[ "Level" ].setValue( m_level );
+ m_doc->kugarTemplate() ->details[ m_level ].first.first = m_section;
+ m_doc->kugarTemplate() ->arrangeSections();
+ m_doc->setStructureModified();
+}
+
+void AddDetailHeaderCommand::unexecute()
+{
+ m_doc->kugarTemplate() ->removeReportItem( m_section );
+ m_doc->setStructureModified();
+}
+
+//AddPageFooterCommand
+
+AddPageFooterCommand::AddPageFooterCommand( Canvas *doc )
+ : KNamedCommand( QObject::tr( "Insert Page Footer Section" ) ), m_doc( doc )
+{}
+
+void AddPageFooterCommand::execute()
+{
+ m_section = new PageFooter( m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, m_doc->kugarTemplate() ->width() - m_doc->kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 50, m_doc );
+ m_doc->kugarTemplate() ->pageFooter = m_section;
+ m_doc->kugarTemplate() ->arrangeSections();
+ m_doc->setStructureModified();
+}
+
+void AddPageFooterCommand::unexecute()
+{
+ m_doc->kugarTemplate() ->removeReportItem( m_section );
+ m_doc->setStructureModified();
+}
+
+//AddPageHeaderCommand
+
+AddPageHeaderCommand::AddPageHeaderCommand( Canvas *doc )
+ : KNamedCommand( QObject::tr( "Insert Page Header Section" ) ), m_doc( doc )
+{}
+
+void AddPageHeaderCommand::execute()
+{
+ m_section = new PageHeader( m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, m_doc->kugarTemplate() ->width() - m_doc->kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 50, m_doc );
+ m_doc->kugarTemplate() ->pageHeader = m_section;
+ m_doc->kugarTemplate() ->arrangeSections();
+ m_doc->setStructureModified();
+}
+
+void AddPageHeaderCommand::unexecute()
+{
+ m_doc->kugarTemplate() ->removeReportItem( m_section );
+ m_doc->setStructureModified();
+}
+
+//AddReportFooterCommand
+
+AddReportFooterCommand::AddReportFooterCommand( Canvas *doc )
+ : KNamedCommand( QObject::tr( "Insert Report Footer Section" ) ), m_doc( doc )
+{}
+
+void AddReportFooterCommand::execute()
+{
+ m_section = new ReportFooter( m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, m_doc->kugarTemplate() ->width() - m_doc->kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 50, m_doc );
+ m_doc->kugarTemplate() ->reportFooter = m_section;
+ m_doc->kugarTemplate() ->arrangeSections();
+ m_doc->setStructureModified();
+}
+
+void AddReportFooterCommand::unexecute()
+{
+ m_doc->kugarTemplate() ->removeReportItem( m_section );
+ m_doc->setStructureModified();
+}
+
+//AddReportHeaderCommand
+
+AddReportHeaderCommand::AddReportHeaderCommand( Canvas *doc )
+ : KNamedCommand( QObject::tr( "Insert Report Header Section" ) ), m_doc( doc )
+{}
+
+void AddReportHeaderCommand::execute()
+{
+ m_section = new ReportHeader( m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 0, m_doc->kugarTemplate() ->width() - m_doc->kugarTemplate() ->props[ "RightMargin" ].value().toInt() -
+ m_doc->kugarTemplate() ->props[ "LeftMargin" ].value().toInt(),
+ 50, m_doc );
+ m_doc->kugarTemplate() ->reportHeader = m_section;
+ m_doc->kugarTemplate() ->arrangeSections();
+ m_doc->setStructureModified();
+}
+
+void AddReportHeaderCommand::unexecute()
+{
+ m_doc->kugarTemplate() ->removeReportItem( m_section );
+ m_doc->setStructureModified();
+}
+
+//AddReportItemCommand
+
+AddReportItemCommand::AddReportItemCommand( Canvas *doc, View *rc, int x, int y, RttiValues section, int sectionLevel ) :
+ KNamedCommand( QObject::tr( "Insert Report Item" ) ), m_doc( doc ), m_rc( rc ), m_x( x ), m_y( y ), m_section( section ), m_sectionLevel( sectionLevel )
+{
+ m_rtti = m_rc->itemToInsert;
+ setName( "Insert " + Kudesigner::rttiName( m_rc->itemToInsert ) );
+}
+
+void AddReportItemCommand::execute()
+{
+ // kdDebug() << "Execute: rtti = " << m_rtti << endl;
+ switch ( m_rtti )
+ {
+ case Rtti_Label:
+ m_item = new Label( 0, 0, DefaultItemWidth, DefaultItemHeight, m_doc );
+ break;
+ case Rtti_Field:
+ m_item = new Field( 0, 0, DefaultItemWidth, DefaultItemHeight, m_doc );
+ break;
+ case Rtti_Special:
+ m_item = new SpecialField( 0, 0, DefaultItemWidth, DefaultItemHeight, m_doc );
+ break;
+ case Rtti_Calculated:
+ m_item = new CalculatedField( 0, 0, DefaultItemWidth, DefaultItemHeight, m_doc );
+ break;
+ case Rtti_Line:
+ m_item = new Line( 0, 0, DefaultItemWidth, DefaultItemHeight, m_doc );
+ break;
+ default:
+ m_item = 0;
+ return ;
+ }
+
+ m_item->setX( m_x );
+ m_item->setY( m_y );
+ // kdDebug() << "Execute: item created" << endl;
+ m_item->setSection( m_doc->kugarTemplate() ->band( m_section, m_sectionLevel ) );
+ m_item->updateGeomProps();
+
+ m_doc->selectItem( m_item, false );
+
+ m_item->show();
+ m_doc->kugarTemplate() ->band( m_section, m_sectionLevel ) ->items.append( m_item );
+ m_doc->setStructureModified();
+}
+
+void AddReportItemCommand::unexecute()
+{
+ if ( m_item )
+ {
+ m_doc->unselectItem( m_item );
+ m_doc->kugarTemplate() ->removeReportItem( m_item );
+ m_doc->setStructureModified();
+ }
+}
+
+DeleteReportItemsCommand::DeleteReportItemsCommand( Canvas * doc, QValueList< Box* > & items )
+ : KNamedCommand( QObject::tr( "Delete Report Item(s)" ) ), m_doc( doc ), m_items( items )
+{}
+
+void DeleteReportItemsCommand::execute( )
+{
+ m_doc->unselectAll();
+
+ for ( QValueList< Box* >::iterator it = m_items.begin(); it != m_items.end(); ++it )
+ {
+ Box *b = *it;
+ m_doc->kugarTemplate() ->removeReportItem( b );
+ }
+
+ m_doc->setStructureModified();
+}
+
+void DeleteReportItemsCommand::unexecute( )
+{
+ /* Box *b;
+ for (b = m_items.first(); b; b = m_items.next())
+ {
+ b->show();*/
+ // m_doc->kugarTemplate()->removeReportItem( b );
+ // }
+
+ m_doc->setStructureModified();
+}
+
+}
diff --git a/kugar/kudesigner_lib/command.h b/kugar/kudesigner_lib/command.h
new file mode 100644
index 00000000..6c040a85
--- /dev/null
+++ b/kugar/kudesigner_lib/command.h
@@ -0,0 +1,183 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 COMMAND_H
+#define COMMAND_H
+
+#include <kcommand.h>
+#include "commdefs.h"
+
+/* void slotAddDetailFooter();
+ void slotAddDetail();
+ void slotAddDetailHeader();
+ void slotAddPageFooter();
+ void slotAddPageHeader();
+ void slotAddReportFooter();
+ void slotAddReportHeader();
+ void slotAddItemLine();
+ void slotAddItemCalculated();
+ void slotAddItemSpecial();
+ void slotAddItemField();
+ void slotAddItemLabel();*/
+
+//class KudesignerDoc;
+
+namespace Kudesigner
+{
+
+class DetailFooter;
+class Detail;
+class DetailHeader;
+class PageFooter;
+class PageHeader;
+class ReportFooter;
+class ReportHeader;
+class Band;
+class ReportItem;
+class View;
+class Canvas;
+class Box;
+
+class AddDetailFooterCommand: public KNamedCommand
+{
+public:
+ AddDetailFooterCommand( int level, Canvas *doc );
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ int m_level;
+ Canvas *m_doc;
+ DetailFooter *m_section;
+};
+
+class AddDetailCommand: public KNamedCommand
+{
+public:
+ AddDetailCommand( int level, Canvas *doc );
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ int m_level;
+ Canvas *m_doc;
+ Detail *m_section;
+};
+
+class AddDetailHeaderCommand: public KNamedCommand
+{
+public:
+ AddDetailHeaderCommand( int level, Canvas *doc );
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ int m_level;
+ Canvas *m_doc;
+ DetailHeader *m_section;
+};
+
+class AddPageFooterCommand: public KNamedCommand
+{
+public:
+ AddPageFooterCommand( Canvas *doc );
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Canvas *m_doc;
+ PageFooter *m_section;
+};
+
+class AddPageHeaderCommand: public KNamedCommand
+{
+public:
+ AddPageHeaderCommand( Canvas *doc );
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Canvas *m_doc;
+ PageHeader *m_section;
+};
+
+class AddReportFooterCommand: public KNamedCommand
+{
+public:
+ AddReportFooterCommand( Canvas *doc );
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Canvas *m_doc;
+ ReportFooter *m_section;
+};
+
+class AddReportHeaderCommand: public KNamedCommand
+{
+public:
+ AddReportHeaderCommand( Canvas *doc );
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Canvas *m_doc;
+ ReportHeader *m_section;
+};
+
+class AddReportItemCommand: public KNamedCommand
+{
+public:
+ AddReportItemCommand( Canvas *doc, View *rc, int x, int y, RttiValues section, int sectionLevel = -1 );
+
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ int m_rtti;
+ Canvas *m_doc;
+ View *m_rc;
+ int m_x;
+ int m_y;
+ ReportItem *m_item;
+ RttiValues m_section;
+ int m_sectionLevel;
+};
+
+class DeleteReportItemsCommand: public KNamedCommand
+{
+public:
+ DeleteReportItemsCommand( Canvas *doc, QValueList<Box*>& items );
+ virtual void execute();
+ virtual void unexecute();
+
+private:
+ Canvas *m_doc;
+ QValueList<Box*> m_items;
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/commdefs.cpp b/kugar/kudesigner_lib/commdefs.cpp
new file mode 100644
index 00000000..44a40bf9
--- /dev/null
+++ b/kugar/kudesigner_lib/commdefs.cpp
@@ -0,0 +1,71 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Alexander Dymo <adymo@mksat.net>
+
+ 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 <klocale.h>
+
+#include <qsettings.h>
+
+#include "commdefs.h"
+
+namespace Kudesigner
+{
+
+QString rttiName( int rtti )
+{
+ switch ( rtti )
+ {
+ case Rtti_Label:
+ return i18n( "Label" );
+ case Rtti_Field:
+ return i18n( "Field" );
+ case Rtti_Special:
+ return i18n( "Special" );
+ case Rtti_Calculated:
+ return i18n( "Calculated Field" );
+ case Rtti_Line:
+ return i18n( "Line" );
+ case Rtti_ReportItem:
+ default:
+ return i18n( "Report Item" );
+ }
+}
+
+int Config::m_holderSize = 6;
+int Config::m_gridSize = 10;
+
+void Config::setGridSize( int gridSize )
+{
+ QSettings settings;
+ settings.writeEntry( "/kudesigner/gridSize", gridSize );
+ m_gridSize = gridSize;
+}
+
+int Config::gridSize()
+{
+ static bool confRead = false;
+ if ( !confRead )
+ {
+ QSettings settings;
+ m_gridSize = settings.readNumEntry( "/kudesigner/gridSize", 10 );
+ confRead = true;
+ }
+ return m_gridSize;
+}
+
+}
diff --git a/kugar/kudesigner_lib/commdefs.h b/kugar/kudesigner_lib/commdefs.h
new file mode 100644
index 00000000..1143043d
--- /dev/null
+++ b/kugar/kudesigner_lib/commdefs.h
@@ -0,0 +1,79 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Alexander Dymo <adymo@mksat.net>
+
+ 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 COMMDEFS_H
+#define COMMDEFS_H
+
+#include <qapplication.h>
+#include <qcanvas.h>
+#include <qstringlist.h>
+
+namespace Kudesigner
+{
+
+enum RttiValues {
+ Rtti_Box = 1700,
+ Rtti_Section = 1701,
+ Rtti_Band = 1702,
+ Rtti_KugarTemplate = 1800,
+ Rtti_ReportHeader = 1801,
+ Rtti_PageHeader = 1802,
+ Rtti_DetailHeader = 1803,
+ Rtti_Detail = 1804,
+ Rtti_DetailFooter = 1805,
+ Rtti_PageFooter = 1806,
+ Rtti_ReportFooter = 1807,
+ Rtti_TextBox = 2000,
+ Rtti_ReportItem = 2001,
+ Rtti_Label = 2002,
+ Rtti_Field = 2003,
+ Rtti_Special = 2004,
+ Rtti_Calculated = 2005,
+ Rtti_Line = 2006
+};
+
+QString rttiName( int rtti );
+
+class Config
+{
+public:
+ static int holderSize()
+ {
+ return m_holderSize;
+ }
+ static void setHolderSize( int holderSize )
+ {
+ m_holderSize = holderSize;
+ }
+ static int gridSize();
+ static void setGridSize( int gridSize );
+
+private:
+ static int m_holderSize;
+ static int m_gridSize;
+};
+
+}
+
+//Holder size for report items. TODO: configurable
+const int HolderSize = 6;
+
+const int DefaultItemWidth = 50;
+const int DefaultItemHeight = 20;
+
+#endif
diff --git a/kugar/kudesigner_lib/detail.cpp b/kugar/kudesigner_lib/detail.cpp
new file mode 100644
index 00000000..9dbf4b62
--- /dev/null
+++ b/kugar/kudesigner_lib/detail.cpp
@@ -0,0 +1,52 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "detail.h"
+
+#include <klocale.h>
+
+#include <qpainter.h>
+
+#include <koproperty/property.h>
+
+namespace Kudesigner
+{
+
+Detail::Detail( int x, int y, int width, int height, int level, Canvas *canvas )
+ : DetailBase( x, y, width, height, level, canvas )
+{
+ props.addProperty( new Property( "Height", 50, i18n( "Height" ), i18n( "Height" ), KoProperty::Integer ), "Detail" );
+ props.addProperty( new Property( "Level", 0, i18n( "Level" ), i18n( "Detail Level" ), KoProperty::Integer ), "Detail" );
+ props.addProperty( new Property( "Repeat", QVariant( false, 3 ), i18n( "Repeat" ), i18n( "Repeat After Page Break" ), KoProperty::Boolean ), "Detail" );
+
+ registerAs( Rtti_Detail );
+}
+
+void Detail::draw( QPainter &painter )
+{
+ QString str = QString( "%1 %2" ).arg( i18n( "Detail" ) ).arg( props[ "Level" ].value().toInt() );
+ painter.drawText( rect(), AlignVCenter | AlignLeft, str );
+ Band::draw( painter );
+}
+
+QString Detail::getXml()
+{
+ return "\t<Detail" + Band::getXml() + "\t</Detail>\n\n";
+}
+
+}
diff --git a/kugar/kudesigner_lib/detail.h b/kugar/kudesigner_lib/detail.h
new file mode 100644
index 00000000..6837578c
--- /dev/null
+++ b/kugar/kudesigner_lib/detail.h
@@ -0,0 +1,43 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 DETAIL_H
+#define DETAIL_H
+
+#include "commdefs.h"
+#include "detailbase.h"
+
+namespace Kudesigner
+{
+
+class Detail: public DetailBase
+{
+public:
+ Detail( int x, int y, int width, int height, int level, Canvas *canvas );
+
+ virtual int rtti() const
+ {
+ return Rtti_Detail;
+ }
+ virtual void draw( QPainter &painter );
+ virtual QString getXml();
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/detailbase.cpp b/kugar/kudesigner_lib/detailbase.cpp
new file mode 100644
index 00000000..e338baa1
--- /dev/null
+++ b/kugar/kudesigner_lib/detailbase.cpp
@@ -0,0 +1,45 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "detailbase.h"
+
+#include "klocale.h"
+
+namespace Kudesigner
+{
+
+DetailBase::DetailBase( int x, int y, int width, int height, int level, Canvas *canvas )
+ : Band( x, y, width, height, canvas ), m_level( level )
+{
+ props.setGroupDescription( "Detail", i18n( "Detail" ) );
+}
+
+DetailBase::~DetailBase()
+{}
+
+int DetailBase::level() const
+{
+ return m_level;
+}
+
+void DetailBase::setLevel( const int level )
+{
+ m_level = level;
+}
+
+}
diff --git a/kugar/kudesigner_lib/detailbase.h b/kugar/kudesigner_lib/detailbase.h
new file mode 100644
index 00000000..6cd208da
--- /dev/null
+++ b/kugar/kudesigner_lib/detailbase.h
@@ -0,0 +1,44 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 DETAILBASE_H
+#define DETAILBASE_H
+
+#include "band.h"
+
+namespace Kudesigner
+{
+
+class DetailBase: public Band
+{
+public:
+ virtual ~DetailBase();
+
+ virtual int level() const;
+ virtual void setLevel( const int level );
+
+protected:
+ DetailBase( int x, int y, int width, int height, int level, Canvas* canvas );
+
+private:
+ int m_level;
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/detailfooter.cpp b/kugar/kudesigner_lib/detailfooter.cpp
new file mode 100644
index 00000000..0b9b041c
--- /dev/null
+++ b/kugar/kudesigner_lib/detailfooter.cpp
@@ -0,0 +1,49 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "detailfooter.h"
+
+#include <klocale.h>
+
+#include <qpainter.h>
+
+#include <koproperty/property.h>
+
+namespace Kudesigner
+{
+
+DetailFooter::DetailFooter( int x, int y, int width, int height, int level, Canvas *canvas ) :
+ DetailBase( x, y, width, height, level, canvas )
+{
+ props.addProperty( new Property( "Height", 50, i18n( "Height" ), i18n( "Height" ), KoProperty::Integer ), "Detail" );
+ props.addProperty( new Property( "Level", 0, i18n( "Level" ), i18n( "Detail Level" ), KoProperty::Integer ), "Detail" );
+}
+
+void DetailFooter::draw( QPainter &painter )
+{
+ QString str = QString( "%1 %2" ).arg( i18n( "Detail Footer" ) ).arg( props[ "Level" ].value().toInt() );
+ painter.drawText( rect(), AlignVCenter | AlignLeft, str );
+ Band::draw( painter );
+}
+
+QString DetailFooter::getXml()
+{
+ return "\t<DetailFooter" + Band::getXml() + "\t</DetailFooter>\n\n";
+}
+
+}
diff --git a/kugar/kudesigner_lib/detailfooter.h b/kugar/kudesigner_lib/detailfooter.h
new file mode 100644
index 00000000..b7815105
--- /dev/null
+++ b/kugar/kudesigner_lib/detailfooter.h
@@ -0,0 +1,43 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 DETAILFOOTER_H
+#define DETAILFOOTER_H
+
+#include "commdefs.h"
+#include "detailbase.h"
+
+namespace Kudesigner
+{
+
+class DetailFooter: public DetailBase
+{
+public:
+ DetailFooter( int x, int y, int width, int height, int level, Canvas *canvas );
+
+ virtual int rtti() const
+ {
+ return Rtti_DetailFooter;
+ }
+ virtual void draw( QPainter &painter );
+ virtual QString getXml();
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/detailheader.cpp b/kugar/kudesigner_lib/detailheader.cpp
new file mode 100644
index 00000000..89fdb42e
--- /dev/null
+++ b/kugar/kudesigner_lib/detailheader.cpp
@@ -0,0 +1,49 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "detailheader.h"
+
+#include <klocale.h>
+
+#include <qpainter.h>
+
+#include <koproperty/property.h>
+
+namespace Kudesigner
+{
+
+DetailHeader::DetailHeader( int x, int y, int width, int height, int level, Canvas *canvas )
+ : DetailBase( x, y, width, height, level, canvas )
+{
+ props.addProperty( new Property( "Height", 50, i18n( "Height" ), i18n( "Height" ), KoProperty::Integer ), "Detail" );
+ props.addProperty( new Property( "Level", 0, i18n( "Level" ), i18n( "Detail Level" ), KoProperty::Integer ), "Detail" );
+}
+
+void DetailHeader::draw( QPainter &painter )
+{
+ QString str = QString( "%1 %2" ).arg( i18n( "Detail Header" ) ).arg( props[ "Level" ].value().toInt() );
+ painter.drawText( rect(), AlignVCenter | AlignLeft, str );
+ Band::draw( painter );
+}
+
+QString DetailHeader::getXml()
+{
+ return "\t<DetailHeader" + Band::getXml() + "\t</DetailHeader>\n\n";
+}
+
+}
diff --git a/kugar/kudesigner_lib/detailheader.h b/kugar/kudesigner_lib/detailheader.h
new file mode 100644
index 00000000..f08152d5
--- /dev/null
+++ b/kugar/kudesigner_lib/detailheader.h
@@ -0,0 +1,43 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 DETAILHEADER_H
+#define DETAILHEADER_H
+
+#include "commdefs.h"
+#include "detailbase.h"
+
+namespace Kudesigner
+{
+
+class DetailHeader: public DetailBase
+{
+public:
+ DetailHeader( int x, int y, int width, int height, int level, Canvas *canvas );
+
+ virtual int rtti() const
+ {
+ return Rtti_DetailHeader;
+ }
+ virtual void draw( QPainter &painter );
+ virtual QString getXml();
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/field.cpp b/kugar/kudesigner_lib/field.cpp
new file mode 100644
index 00000000..c029f8e4
--- /dev/null
+++ b/kugar/kudesigner_lib/field.cpp
@@ -0,0 +1,104 @@
+/* This file is part of the KDE project
+Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+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 "field.h"
+
+#include <klocale.h>
+#include <klineeditdlg.h>
+
+#include <kdebug.h>
+
+#include <koproperty/property.h>
+
+namespace Kudesigner
+{
+
+Field::Field( int x, int y, int width, int height, Canvas *canvas, bool reg )
+ : Label( x, y, width, height, canvas )
+{
+ QMap<QString, QString> m;
+
+ props.setGroupDescription( "Field", i18n( "Field" ) );
+
+ props.addProperty( new Property( "Field", "", i18n( "Name" ), i18n( "Field Name" ), KoProperty::String ), "Field" );
+
+ m[ i18n( "String" ) ] = "0";
+ m[ i18n( "Integer" ) ] = "1";
+ m[ i18n( "Float" ) ] = "2";
+ m[ i18n( "Date" ) ] = "3";
+ m[ i18n( "Currency" ) ] = "4";
+ props.addProperty( new Property( "DataType", m.values(), m.keys(), "0", i18n( "Type" ), i18n( "Data Type" ), KoProperty::String ), "Field" );
+ m.clear();
+
+ m[ i18n( "m/d/y" ) ] = "0";
+ m[ i18n( "m-d-y" ) ] = "1";
+ m[ i18n( "mm/dd/y" ) ] = "2";
+ m[ i18n( "mm-dd-y" ) ] = "3";
+ m[ i18n( "m/d/yyyy" ) ] = "4";
+ m[ i18n( "m-d-yyyy" ) ] = "5";
+ m[ i18n( "mm/dd/yyyy" ) ] = "6";
+ m[ i18n( "mm-dd-yyyy" ) ] = "7";
+ m[ i18n( "yyyy/m/d" ) ] = "8";
+ m[ i18n( "yyyy-m-d" ) ] = "9";
+ m[ i18n( "dd.mm.yy" ) ] = "10";
+ m[ i18n( "dd.mm.yyyy" ) ] = "11";
+
+ //TODO: make date format not hard-coded, use locale settings
+ props.addProperty( new Property( "DateFormat", m.values(), m.keys(), "11", i18n( "Date Format" ), i18n( "Date Format" ), KoProperty::String ), "Field" );
+ m.clear();
+
+ props.addProperty( new Property( "Precision", 2, i18n( "Precision" ), i18n( "Number of Digits After Comma" ), KoProperty::Integer ), "Field" );
+
+ //TODO: make currency locale-aware
+ props.addProperty( new Property( "Currency", 32, i18n( "Currency" ), i18n( "Currency Symbol" ), KoProperty::Symbol ), "Field" );
+
+ props.addProperty( new Property( "NegValueColor", QColor( 0, 0, 0 ), i18n( "Negative Value Color" ), i18n( "Negative Value Color" ), KoProperty::Color ), "Field" );
+
+ props.addProperty( new Property( "CommaSeparator", 44, i18n( "Comma Separator" ), i18n( "Comma Separator" ), KoProperty::Symbol ), "Field" );
+
+ props.addProperty( new Property( "InputMask", "", i18n( "InputMask" ), i18n( "InputMask" ), KoProperty::String ), "Field" );
+
+ if ( reg )
+ registerAs( Rtti_Field );
+}
+
+void Field::draw( QPainter &painter )
+{
+ props[ "Text" ].setValue( "[" + props[ "Field" ].value().toString() + "]" );
+ Label::draw( painter );
+ props[ "Text" ].setValue( "" );
+}
+
+QString Field::getXml()
+{
+ return "\t\t<Field" + ReportItem::getXml() + " />\n";
+}
+
+void Field::fastProperty()
+{
+ bool accepted;
+ QString sValue = props[ "Field" ].value().toString();
+ QString sText = KLineEditDlg::getText( i18n( "Change Field" ),
+ "Enter field name:", sValue , &accepted );
+
+ if ( accepted )
+ props[ "Field" ].setValue( sText );
+
+}
+
+}
diff --git a/kugar/kudesigner_lib/field.h b/kugar/kudesigner_lib/field.h
new file mode 100644
index 00000000..43f0d73f
--- /dev/null
+++ b/kugar/kudesigner_lib/field.h
@@ -0,0 +1,47 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 FIELD_H
+#define FIELD_H
+
+#include "label.h"
+
+namespace Kudesigner
+{
+
+class Field: public Label
+{
+public:
+ Field( int x, int y, int width, int height, Canvas *canvas, bool reg = true );
+
+ virtual int rtti() const
+ {
+ return Rtti_Field;
+ }
+ virtual QString getXml();
+ virtual void draw( QPainter &painter );
+ virtual void updateGeomProps()
+ {
+ Label::updateGeomProps();
+ }
+ virtual void fastProperty();
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/kugartemplate.cpp b/kugar/kudesigner_lib/kugartemplate.cpp
new file mode 100644
index 00000000..500bc419
--- /dev/null
+++ b/kugar/kudesigner_lib/kugartemplate.cpp
@@ -0,0 +1,411 @@
+/* This file is part of the KDE project
+Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+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 "kugartemplate.h"
+
+#include <klocale.h>
+
+#include <qcanvas.h>
+#include <qpainter.h>
+#include <qprinter.h>
+#include <qpaintdevicemetrics.h>
+
+#include <koproperty/property.h>
+
+#include "propertyserializer.h"
+
+#include "canvas.h"
+#include "reportitem.h"
+
+#include "reportheader.h"
+#include "reportfooter.h"
+#include "pageheader.h"
+#include "pagefooter.h"
+#include "detailheader.h"
+#include "detailfooter.h"
+#include "detail.h"
+
+#include <kdebug.h>
+
+namespace Kudesigner
+{
+
+KugarTemplate::KugarTemplate( int x, int y, int width, int height, Canvas *canvas )
+ : Section( x, y, width, height, canvas )
+{
+ detailsCount = 0;
+
+ setZ( 1 );
+ m_canvas->setKugarTemplate( this );
+
+ reportHeader = 0;
+ reportFooter = 0;
+ pageHeader = 0;
+ pageFooter = 0;
+
+ props.setGroupDescription( "DocumentSettings", i18n( "Document Settings" ) );
+
+ QMap<QString, QString> m;
+ m[ "A4" ] = "0";
+ m[ "B5" ] = "1";
+ m[ "Letter" ] = "2";
+ m[ "Legal" ] = "3";
+ m[ "Executive" ] = "4";
+ m[ "A0" ] = "5";
+ m[ "A1" ] = "6";
+ m[ "A2" ] = "7";
+ m[ "A3" ] = "8";
+ m[ "A5" ] = "9";
+ m[ "A6" ] = "10";
+ m[ "A7" ] = "11";
+ m[ "A8" ] = "12";
+ m[ "A9" ] = "13";
+ m[ "B0" ] = "14";
+ m[ "B1" ] = "15";
+ m[ "B10" ] = "16";
+ m[ "B2" ] = "17";
+ m[ "B3" ] = "18";
+ m[ "B4" ] = "19";
+ m[ "B6" ] = "20";
+ m[ "B7" ] = "21";
+ m[ "B8" ] = "22";
+ m[ "B9" ] = "23";
+ m[ "C5E" ] = "24";
+ m[ "Comm10E" ] = "25";
+ m[ "DLE" ] = "26";
+ m[ "Folio" ] = "27";
+ m[ "Ledger" ] = "28";
+ m[ "Tabloid" ] = "29";
+ m[ "NPageSize" ] = "30";
+ props.addProperty( new Property( "PageSize", m.values(), m.keys(), "0", i18n( "Page Size" ), i18n( "Page Size" ) ), "DocumentSettings" );
+ m.clear();
+
+ m[ i18n( "Portrait" ) ] = "0";
+ m[ i18n( "Landscape" ) ] = "1";
+ props.addProperty( new Property( "PageOrientation", m.values(), m.keys(), "0", i18n( "Page Orientation" ), i18n( "Page Orientation" ) ), "DocumentSettings" );
+ m.clear();
+
+ props.addProperty( new Property( "TopMargin", 0, i18n( "Top Margin" ), i18n( "Top Margin" ), KoProperty::Integer ), "DocumentSettings" );
+ props.addProperty( new Property( "BottomMargin", 0, i18n( "Bottom Margin" ), i18n( "Bottom Margin" ), KoProperty::Integer ), "DocumentSettings" );
+ props.addProperty( new Property( "LeftMargin", 0, i18n( "Left Margin" ), i18n( "Left Margin" ), KoProperty::Integer ), "DocumentSettings" );
+ props.addProperty( new Property( "RightMargin", 0, i18n( "Right Margin" ), i18n( "Right Margin" ), KoProperty::Integer ), "DocumentSettings" );
+}
+
+KugarTemplate::~KugarTemplate()
+{
+ if ( reportHeader )
+ delete reportHeader;
+ if ( pageHeader )
+ delete pageHeader;
+
+ std::map<int, DetailBand>::const_iterator it;
+ for ( it = details.begin(); it != details.end(); ++it )
+ {
+ if ( it->second.first.first )
+ delete it->second.first.first;
+ if ( it->second.second )
+ delete it->second.second;
+ if ( it->second.first.second )
+ delete it->second.first.second;
+ }
+ if ( pageFooter )
+ delete pageFooter;
+ if ( reportFooter )
+ delete reportFooter;
+}
+
+void KugarTemplate::draw( QPainter &painter )
+{
+ updatePaperProps();
+ painter.setPen( QPen( QColor( 160, 160, 160 ), 0, Qt::SolidLine ) );
+ QPoint p1( ( int ) ( x() + props[ "LeftMargin" ].value().toInt() ),
+ ( int ) ( y() + props[ "TopMargin" ].value().toInt() ) );
+ QPoint p2( ( int ) ( x() + props[ "LeftMargin" ].value().toInt() ),
+ ( int ) y() + height() - props[ "BottomMargin" ].value().toInt() );
+ QPoint p3( ( int ) x() + width() - props[ "RightMargin" ].value().toInt(),
+ ( int ) y() + height() - props[ "BottomMargin" ].value().toInt() );
+ QPoint p4( ( int ) x() + width() - props[ "RightMargin" ].value().toInt(),
+ ( int ) ( y() + props[ "TopMargin" ].value().toInt() ) );
+ painter.moveTo( p1 );
+ painter.lineTo( p2 );
+ painter.lineTo( p3 );
+ painter.lineTo( p4 );
+ painter.lineTo( p1 );
+ /* painter.drawRect((int)(x()+props["LeftMargin"].first.toInt()),
+ (int)(y()+props["TopMargin"].first.toInt()),
+ width() - props["LeftMargin"].first.toInt() - props["RightMargin"].first.toInt(),
+ height() - props["TopMargin"].first.toInt() - props["BottomMargin"].first.toInt());*/
+
+ if ( Config::gridSize() > 1 )
+ {
+ int x = Config::gridSize();
+ while ( x < width() )
+ {
+ int y = Config::gridSize();
+ while ( y < height() )
+ {
+ painter.drawPoint( x, y );
+ y += Config::gridSize();
+ }
+ x += Config::gridSize();
+ }
+ }
+
+ Section::draw( painter );
+}
+
+void KugarTemplate::updatePaperProps()
+{
+ QPrinter * printer;
+
+ // Set the page size
+ printer = new QPrinter();
+ printer->setFullPage( true );
+ printer->setPageSize( ( QPrinter::PageSize ) props[ "PageSize" ].value().toInt() );
+ printer->setOrientation( ( QPrinter::Orientation ) props[ "PageOrientation" ].value().toInt() );
+
+ // Get the page metrics and set appropriate wigth and height
+ QPaintDeviceMetrics pdm( printer );
+ canvas() ->resize( pdm.width(), pdm.height() );
+ setSize( pdm.width(), pdm.height() );
+
+ //this is not needed anymore
+ delete printer;
+}
+
+/*arrange sections on page automatically*/
+void KugarTemplate::arrangeSections( bool destructive )
+{
+ int base = props[ "TopMargin" ].value().toInt();
+ if ( reportHeader )
+ {
+ reportHeader->arrange( base, destructive );
+ base += reportHeader->props[ "Height" ].value().toInt();
+ reportHeader->show();
+ }
+ if ( pageHeader )
+ {
+ pageHeader->arrange( base, destructive );
+ base += pageHeader->props[ "Height" ].value().toInt();
+ pageHeader->show();
+ }
+
+ std::map<int, DetailBand>::const_iterator it;
+ for ( it = details.begin(); it != details.end(); ++it )
+ {
+ //arranging detail header
+ if ( it->second.first.first )
+ {
+ it->second.first.first->arrange( base, destructive );
+ base += it->second.first.first->props[ "Height" ].value().toInt();
+ it->second.first.first->show();
+ }
+ //arranging detail
+ if ( it->second.second )
+ {
+ it->second.second->arrange( base, destructive );
+ base += it->second.second->props[ "Height" ].value().toInt();
+ it->second.second->show();
+ }
+ }
+ std::map<int, DetailBand>::reverse_iterator itr;
+ for ( itr = details.rbegin(); itr != details.rend(); ++itr )
+ {
+ //arranging detail footer
+ if ( itr->second.first.second )
+ {
+ itr->second.first.second->arrange( base, destructive );
+ base += itr->second.first.second->props[ "Height" ].value().toInt();
+ itr->second.first.second->show();
+ }
+ }
+
+ if ( pageFooter )
+ {
+ pageFooter->arrange( base, destructive );
+ base += pageFooter->props[ "Height" ].value().toInt();
+ pageFooter->show();
+ }
+ if ( reportFooter )
+ {
+ reportFooter->arrange( base, destructive );
+ base += reportFooter->props[ "Height" ].value().toInt();
+ reportFooter->show();
+ }
+}
+
+QString KugarTemplate::getXml()
+{
+ QString result = "";
+ result += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n";
+ result += "<!DOCTYPE KugarTemplate SYSTEM \"kugartemplate.dtd\">\n\n";
+ result += "<KugarTemplate";
+
+ for ( Set::Iterator it( props ); it.current(); ++it )
+ {
+ QString attribute = it.currentKey();
+ QString value = PropertySerializer::toString( it.current() );
+ if ( !attribute.isEmpty() && !value.isEmpty() )
+ result += " " + attribute + "=" + "\"" + value + "\"";
+ }
+
+ result += " PageWidth=\"" + QString::number( width() )
+ + "\" PageHeight=\"" + QString::number( height() ) + "\"";
+
+ result += ">\n";
+
+ if ( reportHeader )
+ result += reportHeader->getXml();
+ if ( pageHeader )
+ result += pageHeader->getXml();
+
+ std::map<int, DetailBand>::const_iterator it;
+ for ( it = details.begin(); it != details.end(); ++it )
+ {
+ //getting xml from detail header
+ if ( it->second.first.first )
+ result += it->second.first.first->getXml();
+ //getting xml from detail
+ if ( it->second.second )
+ result += it->second.second->getXml();
+ //getting xml from detail footer
+ if ( it->second.first.second )
+ result += it->second.first.second->getXml();
+ }
+ if ( pageFooter )
+ result += pageFooter->getXml();
+ if ( reportFooter )
+ result += reportFooter->getXml();
+
+ result += "</KugarTemplate>\n";
+
+ return result;
+}
+
+bool KugarTemplate::removeReportItem( QCanvasItem *item )
+{
+ if ( item->rtti() > 2000 )
+ {
+
+ item->hide();
+ ReportItem *ritem = dynamic_cast<ReportItem*>( item );
+ if ( ritem != 0 )
+ {
+ ritem->section() ->items.remove( ritem );
+ qWarning( "good" );
+ }
+ //delete item;
+ // section = 0;
+ canvas() ->update();
+
+ return true;
+ }
+ if ( item->rtti() > 1800 )
+ {
+ /* if ((*it)->rtti() == Detail)
+ {
+ CanvasDetail *det = (CanvasDetail*)(*it);
+ if ( det->props["Level"].first.toInt() <
+ ((MyCanvas*)(canvas()))->templ->detailsCount - 1)
+ return;
+ }*/
+
+ Band * section = dynamic_cast<Band *>( item );
+
+ DetailHeader *header = 0;
+ DetailFooter *footer = 0;
+ removeSection( section, &header, &footer );
+ section->hide();
+ delete section;
+
+ if ( header )
+ {
+ header->hide();
+ delete header;
+ }
+ if ( footer )
+ {
+ footer->hide();
+ delete footer;
+ }
+ arrangeSections();
+ canvas() ->update();
+
+ return true;
+ }
+
+ return false;
+}
+
+void KugarTemplate::removeSection( Band *section,
+ DetailHeader **header, DetailFooter **footer )
+{
+ *header = 0;
+ *footer = 0;
+ if ( section == reportHeader )
+ reportHeader = 0;
+ if ( section == reportFooter )
+ reportFooter = 0;
+ if ( section == pageHeader )
+ pageHeader = 0;
+ if ( section == pageFooter )
+ pageFooter = 0;
+ for ( std::map<int, DetailBand>::iterator i = details.begin(); i != details.end(); ++i )
+ {
+ if ( i->second.second == section )
+ {
+ //delete not only detail but it's header and footer
+ i->second.second = 0;
+ *header = i->second.first.first;
+ i->second.first.first = 0;
+ *footer = i->second.first.second;
+ i->second.first.second = 0;
+ detailsCount--;
+ }
+ if ( i->second.first.first == section )
+ i->second.first.first = 0;
+ if ( i->second.first.second == section )
+ i->second.first.second = 0;
+ }
+}
+
+Band *KugarTemplate::band( Kudesigner::RttiValues type, int level )
+{
+ switch ( type )
+ {
+ case Rtti_ReportHeader:
+ return reportHeader;
+ case Rtti_PageHeader:
+ return pageHeader;
+ case Rtti_DetailHeader:
+ return details[ level ].first.first;
+ case Rtti_Detail:
+ return details[ level ].second;
+ case Rtti_DetailFooter:
+ return details[ level ].first.second;
+ case Rtti_PageFooter:
+ return pageFooter;
+ case Rtti_ReportFooter:
+ return reportFooter;
+ default:
+ return 0;
+ }
+ return 0;
+}
+
+}
diff --git a/kugar/kudesigner_lib/kugartemplate.h b/kugar/kudesigner_lib/kugartemplate.h
new file mode 100644
index 00000000..baaf5206
--- /dev/null
+++ b/kugar/kudesigner_lib/kugartemplate.h
@@ -0,0 +1,88 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 KUGARTEMPLATE_H
+#define KUGARTEMPLATE_H
+
+#include <map>
+
+#include "commdefs.h"
+#include "section.h"
+
+class QPainter;
+
+namespace Kudesigner
+{
+
+class DetailHeader;
+class DetailFooter;
+class Detail;
+class Band;
+class ReportHeader;
+class ReportFooter;
+class PageHeader;
+class PageFooter;
+class Canvas;
+
+typedef QPair< QPair<DetailHeader*, DetailFooter*>, Detail*> DetailBand;
+
+class KugarTemplate: public Section
+{
+public:
+ KugarTemplate( int x, int y, int width, int height, Canvas *canvas );
+ ~KugarTemplate();
+
+ virtual int rtti() const
+ {
+ return Rtti_KugarTemplate;
+ }
+ virtual void draw( QPainter &painter );
+
+ void arrangeSections( bool destructive = true );
+ void updatePaperProps();
+
+ QString fileName() const
+ {
+ return m_reportFileName;
+ }
+ void setFileName( const QString &fName )
+ {
+ m_reportFileName = fName;
+ }
+
+ virtual QString getXml();
+
+ void removeSection( Band *section, DetailHeader **header, DetailFooter **footer );
+ bool removeReportItem( QCanvasItem *item );
+
+ Band *band( Kudesigner::RttiValues type, int level = -1 );
+
+ ReportHeader *reportHeader;
+ ReportFooter *reportFooter;
+ PageHeader *pageHeader;
+ PageFooter *pageFooter;
+ std::map<int, DetailBand> details;
+ unsigned int detailsCount;
+
+private:
+ QString m_reportFileName;
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/label.cpp b/kugar/kudesigner_lib/label.cpp
new file mode 100644
index 00000000..d77e484e
--- /dev/null
+++ b/kugar/kudesigner_lib/label.cpp
@@ -0,0 +1,256 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "label.h"
+
+#include <klocale.h>
+#include <klineeditdlg.h>
+
+#include <qmap.h>
+#include <qpainter.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+
+#include <koproperty/property.h>
+
+#include "band.h"
+
+namespace Kudesigner
+{
+
+Label::Label( int x, int y, int width, int height, Canvas *canvas )
+ : ReportItem( x, y, width, height, canvas )
+{
+ QMap<QString, QString> m;
+
+ props.addProperty( new Property( "Text", i18n( "Text" ), i18n( "Text to Display" ), i18n( "Text" ), KoProperty::String ) );
+
+ props.setGroupDescription( "Geometry", i18n( "Geometry" ) );
+ props.addProperty( new Property( "X", x, i18n( "X" ), i18n( "X value" ), KoProperty::Integer ), "Geometry" );
+
+ props.addProperty( new Property( "Y", y, i18n( "Y" ), i18n( "Y value" ), KoProperty::Integer ), "Geometry" );
+
+ props.addProperty( new Property( "Width", width, i18n( "Width" ), i18n( "Width" ), KoProperty::Integer ), "Geometry" );
+
+ props.addProperty( new Property( "Height", height, i18n( "Height" ), i18n( "Height" ), KoProperty::Integer ), "Geometry" );
+
+ props.addProperty( new Property( "BackgroundColor", QColor( 255, 255, 255 ), i18n( "Background Color" ), i18n( "Background Color" ), KoProperty::Color ) );
+
+ props.addProperty( new Property( "ForegroundColor", QColor( 0, 0, 0 ), i18n( "Foreground Color" ), i18n( "Foreground Color" ), KoProperty::Color ) );
+
+ props.setGroupDescription( "BorderStyle", i18n( "Border Style" ) );
+ props.addProperty( new Property( "BorderColor", QColor( 0, 0, 0 ), i18n( "Color" ), i18n( "Border Color" ), KoProperty::Color ), "BorderStyle" );
+
+ props.addProperty( new Property( "BorderWidth", 1, i18n( "Width" ), i18n( "Border Width" ), KoProperty::Integer ), "BorderStyle" );
+
+ props.addProperty( new Property( "BorderStyle", 1, i18n( "Line" ), i18n( "Border Style" ), KoProperty::LineStyle ), "BorderStyle" );
+
+ props.setGroupDescription( "DrawBorder", i18n( "Border" ) );
+ props.addProperty( new Property( "DrawTop", QVariant( false, 3 ), i18n( "Top" ), i18n( "Draw Top Border" ), KoProperty::Boolean ), "DrawBorder" );
+ props.addProperty( new Property( "DrawBottom", QVariant( false, 3 ), i18n( "Bottom" ), i18n( "Draw Bottom Border" ), KoProperty::Boolean ), "DrawBorder" );
+ props.addProperty( new Property( "DrawLeft", QVariant( false, 3 ), i18n( "Left" ), i18n( "Draw Left Border" ), KoProperty::Boolean ), "DrawBorder" );
+ props.addProperty( new Property( "DrawRight", QVariant( false, 3 ), i18n( "Right" ), i18n( "Draw Right Border" ), KoProperty::Boolean ), "DrawBorder" );
+
+
+ props.setGroupDescription( "Font", i18n( "Font" ) );
+ props.addProperty( new Property( "FontFamily", QApplication::font(), i18n( "Family" ), i18n( "Font Family" ), KoProperty::Font ), "Font" );
+
+ props.addProperty( new Property( "FontSize", QApplication::font().pointSize(), i18n( "Size" ), i18n( "Font Size" ), KoProperty::Integer ), "Font" );
+
+ m[ i18n( "Light" ) ] = "25";
+ m[ i18n( "Normal" ) ] = "50";
+ m[ i18n( "DemiBold" ) ] = "63";
+ m[ i18n( "Bold" ) ] = "75";
+ m[ i18n( "Black" ) ] = "87";
+ props.addProperty( new Property( "FontWeight", m.values(), m.keys(), "50", i18n( "Weight" ), i18n( "Weight" ) ), "Font" );
+ m.clear();
+
+ m[ i18n( "Regular" ) ] = "0";
+ m[ i18n( "Italic" ) ] = "1";
+ props.addProperty( new Property( "FontItalic", m.values(), m.keys(), "0", i18n( "Italic" ), i18n( "Italic" ) ), "Font" );
+ m.clear();
+
+ m[ i18n( "Left" ) ] = "0";
+ m[ i18n( "Center" ) ] = "1";
+ m[ i18n( "Right" ) ] = "2";
+ props.addProperty( new Property( "HAlignment", m.values(), m.keys(),
+ QString( "" ).isRightToLeft() ? "2" : "0", i18n( "HAlignment" ), i18n( "HAlignment" ) ) );
+ m.clear();
+
+ m[ i18n( "Top" ) ] = "0";
+ m[ i18n( "Middle" ) ] = "1";
+ m[ i18n( "Bottom" ) ] = "2";
+ props.addProperty( new Property( "VAlignment", m.values(), m.keys(), "1", i18n( "VAlignment" ), i18n( "VAlignment" ) ) );
+ m.clear();
+
+ m[ i18n( "False" ) ] = "0";
+ m[ i18n( "True" ) ] = "1";
+ props.addProperty( new Property( "WordWrap", m.values(), m.keys(), "0", i18n( "Word wrap" ), i18n( "Word wrap" ) ) );
+}
+
+int Label::getTextAlignment()
+{
+ int result = 0;
+ switch ( props[ "HAlignment" ].value().toInt() )
+ {
+ case 0:
+ result = AlignLeft;
+ break;
+ case 1:
+ result = AlignHCenter;
+ break;
+ case 2:
+ result = AlignRight;
+ break;
+ default:
+ result = AlignHCenter;
+ }
+ switch ( props[ "VAlignment" ].value().toInt() )
+ {
+ case 0:
+ result = result | AlignTop;
+ break;
+ case 1:
+ result = result | AlignVCenter;
+ break;
+ case 2:
+ result = result | AlignBottom;
+ break;
+ default:
+ result = result | AlignVCenter;
+ }
+ return result;
+}
+
+int Label::getTextWrap()
+{
+ switch ( props[ "WordWrap" ].value().toInt() )
+ {
+ case 0:
+ return SingleLine;
+ break;
+ case 1:
+ return WordBreak;
+ break;
+ default:
+ return SingleLine;
+ }
+}
+
+QFont Label::getFont()
+{
+ return QFont( props[ "FontFamily" ].value().toString(),
+ props[ "FontSize" ].value().toInt(),
+ props[ "FontWeight" ].value().toInt(),
+ props[ "FontItalic" ].value().toInt() );
+}
+
+QPen Label::getPenForText()
+{
+ return QPen( QColor( props[ "ForegroundColor" ].value().toColor() ) );
+}
+
+QPen Label::getPenForShape()
+{
+ PenStyle style = SolidLine;
+ switch ( props[ "BorderStyle" ].value().toInt() )
+ {
+ case 0:
+ style = NoPen;
+ break;
+ case 1:
+ style = SolidLine;
+ break;
+ case 2:
+ style = DashLine;
+ break;
+ case 3:
+ style = DotLine;
+ break;
+ case 4:
+ style = DashDotLine;
+ break;
+ case 5:
+ style = DashDotDotLine;
+ break;
+ }
+ return QPen( QColor( props[ "BorderColor" ].value().toColor() ),
+ props[ "BorderWidth" ].value().toInt(), style );
+}
+
+QBrush Label::getBrush()
+{
+ return QBrush( QColor( props[ "BackgroundColor" ].value().toColor() ) );
+}
+
+void Label::draw( QPainter &painter )
+{
+ //update dimensions
+ if ( !section() )
+ return ;
+
+ setX( props[ "X" ].value().toInt() + section() ->x() );
+ setY( props[ "Y" ].value().toInt() + section() ->y() );
+ setSize( props[ "Width" ].value().toInt(), props[ "Height" ].value().toInt() );
+
+ //draw border and background
+ painter.setBrush( getBrush() );
+ painter.setPen( NoPen );
+ painter.drawRect( rect() );
+ painter.setPen( getPenForShape() );
+ if ( props[ "DrawLeft" ].value().toBool() )
+ painter.drawLine( rect().topLeft(), rect().bottomLeft() );
+ if ( props[ "DrawRight" ].value().toBool() )
+ painter.drawLine( rect().topRight(), rect().bottomRight() );
+ if ( props[ "DrawTop" ].value().toBool() )
+ painter.drawLine( rect().topLeft(), rect().topRight() );
+ if ( props[ "DrawBottom" ].value().toBool() )
+ painter.drawLine( rect().bottomLeft(), rect().bottomRight() );
+
+ //draw text inside
+ painter.setFont( getFont() );
+ painter.setPen( getPenForText() );
+ painter.drawText( ( int ) x(), ( int ) y(), width(), height(),
+ getTextAlignment() | getTextWrap(),
+ props[ "Text" ].value().toString() );
+
+ //draw resizable region
+ // if (isSelected())
+ // drawHolders(painter);
+ // CanvasReportItem::draw(painter);
+}
+
+QString Label::getXml()
+{
+ return "\t\t<Label" + ReportItem::getXml() + " />\n";
+}
+
+void Label::fastProperty()
+{
+ bool accepted;
+
+ QString sText = KLineEditDlg::getText( i18n( "Change Label" ),
+ "Enter label name:", props[ "Text" ].value().toString(),
+ &accepted );
+
+ if ( accepted )
+ props[ "Text" ].setValue( sText );
+}
+
+}
diff --git a/kugar/kudesigner_lib/label.h b/kugar/kudesigner_lib/label.h
new file mode 100644
index 00000000..b777353a
--- /dev/null
+++ b/kugar/kudesigner_lib/label.h
@@ -0,0 +1,57 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 LABEL_H
+#define LABEL_H
+
+#include "reportitem.h"
+
+namespace Kudesigner
+{
+
+class Label: public ReportItem
+{
+public:
+ Label( int x, int y, int width, int height, Canvas *canvas );
+
+ virtual int rtti() const
+ {
+ return Rtti_Label;
+ }
+ virtual QString getXml();
+
+ int getTextAlignment();
+ int getTextWrap();
+
+ QFont getFont();
+ QPen getPenForText();
+ QPen getPenForShape();
+ QBrush getBrush();
+
+ virtual void draw( QPainter &painter );
+ virtual void updateGeomProps()
+ {
+ ReportItem::updateGeomProps();
+ }
+
+ virtual void fastProperty();
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/line.cpp b/kugar/kudesigner_lib/line.cpp
new file mode 100644
index 00000000..75631b1b
--- /dev/null
+++ b/kugar/kudesigner_lib/line.cpp
@@ -0,0 +1,129 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "line.h"
+
+#include <klocale.h>
+
+#include <qpainter.h>
+
+#include <koproperty/property.h>
+
+#include "band.h"
+
+namespace Kudesigner
+{
+
+Line::Line( int x, int y, int width, int height, Canvas *canvas ) :
+ ReportItem( x, y, width, height, canvas )
+{
+ props.setGroupDescription( "Line", i18n( "Line" ) );
+ props.addProperty( new Property( "X1", x, i18n( "X1" ), i18n( "X1" ), KoProperty::Integer ), "Line" );
+
+ props.addProperty( new Property( "Y1", y, i18n( "Y1" ), i18n( "Y1" ), KoProperty::Integer ), "Line" );
+
+ props.addProperty( new Property( "X2", x + width, i18n( "X2" ), i18n( "X2" ), KoProperty::Integer ), "Line" );
+
+ props.addProperty( new Property( "Y2", y + height, i18n( "Y2" ), i18n( "Y2" ), KoProperty::Integer ), "Line" );
+
+ props.addProperty( new Property( "Color", QColor( 0, 0, 0 ), i18n( "Color" ), i18n( "Color" ), KoProperty::Color ), "Line" );
+
+ props.addProperty( new Property( "Width", 1, i18n( "Width" ), i18n( "Width" ), KoProperty::Integer ), "Line" );
+
+ props.addProperty( new Property( "Style", 1, i18n( "Line Style" ), i18n( "Line Style" ), KoProperty::LineStyle ), "Line" );
+}
+
+QString Line::getXml()
+{
+ return "\t\t<Line" + ReportItem::getXml() + " />\n";
+}
+
+QPen Line::getPenForShape()
+{
+ PenStyle style = SolidLine;
+ switch ( props[ "Style" ].value().toInt() )
+ {
+ case 0:
+ style = NoPen;
+ break;
+ case 1:
+ style = SolidLine;
+ break;
+ case 2:
+ style = DashLine;
+ break;
+ case 3:
+ style = DotLine;
+ break;
+ case 4:
+ style = DashDotLine;
+ break;
+ case 5:
+ style = DashDotDotLine;
+ break;
+ }
+ return QPen( QColor( props[ "Color" ].value().toColor() ),
+ props[ "Width" ].value().toInt(), style );
+}
+
+void Line::draw( QPainter &painter )
+{
+ //update dimensions
+ if ( !section() )
+ return ;
+ setX( props[ "X1" ].value().toInt() + section() ->x() );
+ setY( props[ "Y1" ].value().toInt() + section() ->y() );
+ setSize( props[ "X2" ].value().toInt() - props[ "X1" ].value().toInt(),
+ props[ "Y2" ].value().toInt() - props[ "Y1" ].value().toInt() );
+
+ //draw border and background
+ painter.setPen( getPenForShape() );
+ painter.setBrush( QColor( 0, 0, 0 ) );
+ painter.drawLine( props[ "X1" ].value().toInt() + ( int ) section() ->x(),
+ props[ "Y1" ].value().toInt() + ( int ) section() ->y(),
+ props[ "X2" ].value().toInt() + ( int ) section() ->x(),
+ props[ "Y2" ].value().toInt() + ( int ) section() ->y() );
+
+ painter.setPen( QColor( 0, 0, 0 ) );
+ painter.setBrush( QColor( 0, 0, 0 ) );
+ // painter.drawRect(topLeftResizableRect());
+ // painter.drawRect(topRightResizableRect());
+ // painter.drawRect(bottomLeftResizableRect());
+ painter.drawRect( bottomRightResizableRect() );
+
+ // drawHolders(painter);
+}
+
+void Line::setSection( Band *section )
+{
+ props[ "X1" ].setValue( ( int ) ( x() - section->x() ) );
+ props[ "Y1" ].setValue( ( int ) ( y() - section->y() ) );
+ parentSection = section;
+}
+
+void Line::updateGeomProps()
+{
+ props[ "X1" ].setValue( ( int ) ( x() - section() ->x() ) );
+ props[ "Y1" ].setValue( ( int ) ( y() - section() ->y() ) );
+ props[ "X2" ].setValue( ( int ) ( x() - section() ->x() + width() ) );
+ props[ "Y2" ].setValue( ( int ) ( y() - section() ->y() + height() ) );
+
+ // if (width() )
+}
+
+}
diff --git a/kugar/kudesigner_lib/line.h b/kugar/kudesigner_lib/line.h
new file mode 100644
index 00000000..0da1eec5
--- /dev/null
+++ b/kugar/kudesigner_lib/line.h
@@ -0,0 +1,48 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 LINE_H
+#define LINE_H
+
+#include "reportitem.h"
+
+namespace Kudesigner
+{
+
+class Line: public ReportItem
+{
+public:
+ Line( int x, int y, int width, int height, Canvas *canvas );
+
+ virtual int rtti() const
+ {
+ return Rtti_Line;
+ }
+ virtual QString getXml();
+ virtual void draw( QPainter &painter );
+
+ virtual void updateGeomProps();
+ virtual void setSection( Band *section );
+
+private:
+ QPen getPenForShape();
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/pagefooter.cpp b/kugar/kudesigner_lib/pagefooter.cpp
new file mode 100644
index 00000000..9091f31b
--- /dev/null
+++ b/kugar/kudesigner_lib/pagefooter.cpp
@@ -0,0 +1,54 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "pagefooter.h"
+
+#include <klocale.h>
+
+#include <qpainter.h>
+
+#include <koproperty/property.h>
+
+namespace Kudesigner
+{
+
+PageFooter::PageFooter( int x, int y, int width, int height, Canvas *canvas ) :
+ Band( x, y, width, height, canvas )
+{
+ props.addProperty( new Property( "Height", 50, i18n( "Height" ), i18n( "Height" ), KoProperty::Integer ), "Section" );
+ QMap<QString, QString> m;
+
+ m[ i18n( "First Page" ) ] = "0";
+ m[ i18n( "Every Page" ) ] = "1";
+ m[ i18n( "Last Page" ) ] = "2";
+
+ props.addProperty( new Property( "PrintFrequency", m.values(), m.keys(), "1", i18n( "Print Frequency" ), i18n( "Print Frequency" ) ), "Section" );
+}
+
+void PageFooter::draw( QPainter &painter )
+{
+ painter.drawText( rect(), AlignVCenter | AlignLeft, i18n( "Page Footer" ) );
+ Band::draw( painter );
+}
+
+QString PageFooter::getXml()
+{
+ return "\t<PageFooter" + Band::getXml() + "\t</PageFooter>\n\n";
+}
+
+}
diff --git a/kugar/kudesigner_lib/pagefooter.h b/kugar/kudesigner_lib/pagefooter.h
new file mode 100644
index 00000000..b24d6a77
--- /dev/null
+++ b/kugar/kudesigner_lib/pagefooter.h
@@ -0,0 +1,43 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 PAGEFOOTER_H
+#define PAGEFOOTER_H
+
+#include "commdefs.h"
+#include "band.h"
+
+namespace Kudesigner
+{
+
+class PageFooter: public Band
+{
+public:
+ PageFooter( int x, int y, int width, int height, Canvas *canvas );
+
+ virtual int rtti() const
+ {
+ return Rtti_PageFooter;
+ }
+ virtual void draw( QPainter &painter );
+ virtual QString getXml();
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/pageheader.cpp b/kugar/kudesigner_lib/pageheader.cpp
new file mode 100644
index 00000000..710dd210
--- /dev/null
+++ b/kugar/kudesigner_lib/pageheader.cpp
@@ -0,0 +1,55 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "pageheader.h"
+
+#include <klocale.h>
+
+#include <qpainter.h>
+
+#include <koproperty/property.h>
+
+namespace Kudesigner
+{
+
+PageHeader::PageHeader( int x, int y, int width, int height, Canvas *canvas ) :
+ Band( x, y, width, height, canvas )
+{
+ props.addProperty( new Property( "Height", 50, i18n( "Height" ), i18n( "Height" ), KoProperty::Integer ), "Section" );
+ QMap<QString, QString> m;
+
+ m[ i18n( "First Page" ) ] = "0";
+ m[ i18n( "Every Page" ) ] = "1";
+ m[ i18n( "Last Page" ) ] = "2";
+
+ props.addProperty( new Property( "PrintFrequency", m.values(), m.keys(), "1", i18n( "Print Frequency" ), i18n( "Print Frequency" ) ), "Section" );
+}
+
+void PageHeader::draw( QPainter &painter )
+{
+ painter.drawText( rect(), AlignVCenter | AlignLeft,
+ i18n( "Page Header" ) );
+ Band::draw( painter );
+}
+
+QString PageHeader::getXml()
+{
+ return "\t<PageHeader" + Band::getXml() + "\t</PageHeader>\n\n";
+}
+
+}
diff --git a/kugar/kudesigner_lib/pageheader.h b/kugar/kudesigner_lib/pageheader.h
new file mode 100644
index 00000000..577957b0
--- /dev/null
+++ b/kugar/kudesigner_lib/pageheader.h
@@ -0,0 +1,44 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Alexander Dymo <adymo@mksat.net>
+
+ 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 PAGEHEADER_H
+#define PAGEHEADER_H
+
+#include "commdefs.h"
+#include "band.h"
+
+class QPainter;
+
+namespace Kudesigner
+{
+
+class PageHeader: public Band
+{
+public:
+ PageHeader( int x, int y, int width, int height, Canvas *canvas );
+ virtual void draw( QPainter &painter );
+ virtual int rtti() const
+ {
+ return Rtti_PageHeader;
+ }
+ virtual QString getXml();
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/plugin.cpp b/kugar/kudesigner_lib/plugin.cpp
new file mode 100644
index 00000000..711c485f
--- /dev/null
+++ b/kugar/kudesigner_lib/plugin.cpp
@@ -0,0 +1,28 @@
+/***************************************************************************
+ plugin.h - description
+ -------------------
+ begin : 19.01.2003
+ copyright : (C) 2003 Joseph Wenninger
+ email : jowenn@kde.org
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program 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. *
+ * *
+ ***************************************************************************/
+
+#include "plugin.h"
+
+KuDesignerPlugin::KuDesignerPlugin( QObject *parent, const char *name, const QStringList& ) : QObject( parent, name )
+{}
+KuDesignerPlugin::~KuDesignerPlugin()
+{}
+void KuDesignerPlugin::createPluggedInEditor( QWidget *&/*retVal*/, Editor */*editor*/,
+ Property */*property*/, Box */*cb*/ )
+{}
+
+#include "plugin.moc"
diff --git a/kugar/kudesigner_lib/plugin.h b/kugar/kudesigner_lib/plugin.h
new file mode 100644
index 00000000..d4363cfc
--- /dev/null
+++ b/kugar/kudesigner_lib/plugin.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ plugin.h - description
+ -------------------
+ begin : 19.01.2003
+ copyright : (C) 2003 Joseph Wenninger
+ email : jowenn@kde.org
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _KUGAR_DESIGNER_PLUGIN_H_
+#define _KUGAR_DESIGNER_PLUGIN_H_
+
+#include <qobject.h>
+#include <koproperty/property.h>
+#include <koproperty/editor.h>
+#include <box.h>
+
+class QString;
+class QWidget;
+class CanvasReportItem;
+class KoStore;
+
+using namespace KoProperty;
+using namespace Kudesigner;
+
+class KuDesignerPlugin: public QObject
+{
+ Q_OBJECT
+public:
+ KuDesignerPlugin( QObject *parent, const char* name, const QStringList& args );
+ virtual ~KuDesignerPlugin();
+ virtual bool acceptsDrops()
+ {
+ return false;
+ }
+ virtual bool dragMove( QDragMoveEvent *, Box */*cb*/ )
+ {
+ return false;
+ }
+ virtual void newCanvasBox( int /*type*/, Box */*cb*/ )
+ {
+ ;
+ }
+ virtual void modifyItemPropertyOnSave( CanvasReportItem */*item*/, const Property & /*p*/ , QString &/*propertyName*/, QString &/*propertyValue*/ )
+ {
+ ;
+ }
+ virtual void modifyItemPropertyOnLoad( CanvasReportItem */*item*/, const Property & /*p*/, QString &/*propertyName*/, QString &/*propertyValue*/ )
+ {
+ ;
+ }
+ virtual bool store ( KoStore* )
+ {
+ return true;
+ }
+ virtual bool load ( KoStore* )
+ {
+ return true;
+ }
+
+public slots:
+ virtual void createPluggedInEditor( QWidget *& retVal, Editor *editor,
+ Property *property, Box * );
+};
+
+#endif
diff --git a/kugar/kudesigner_lib/propertyserializer.cpp b/kugar/kudesigner_lib/propertyserializer.cpp
new file mode 100644
index 00000000..dc3e91e6
--- /dev/null
+++ b/kugar/kudesigner_lib/propertyserializer.cpp
@@ -0,0 +1,76 @@
+/***************************************************************************
+* Copyright (C) 2004 by Alexander Dymo *
+* cloudtemple@mskat.net *
+* *
+* This program 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 program 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 General Public License for more details. *
+* *
+* You should have received a copy of the GNU Library General Public *
+* License along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA. *
+***************************************************************************/
+#include "propertyserializer.h"
+
+#include <qcolor.h>
+#include <qfont.h>
+
+#include <kdebug.h>
+
+namespace Kudesigner
+{
+
+PropertySerializer::PropertySerializer()
+{}
+
+PropertySerializer::~PropertySerializer()
+{}
+
+QString PropertySerializer::toString( Property *prop )
+{
+ QVariant val = prop->value();
+ switch ( prop->type() )
+ {
+ case KoProperty::Color:
+ return QString( "%1,%2,%3" ).arg( val.toColor().red() ).arg( val.toColor().green() ).arg( val.toColor().blue() );
+ case KoProperty::Boolean:
+ return val.toBool() ? "true" : "false";
+ case KoProperty::Font:
+ return val.toFont().family();
+ default:
+ return val.toString();
+ }
+}
+
+QVariant PropertySerializer::fromString( Property *prop, const QString &str )
+{
+ switch ( prop->type() )
+ {
+ case KoProperty::Color:
+ return QVariant( QColor( str.section( ',', 0, 0 ).toInt(),
+ str.section( ',', 1, 1 ).toInt(),
+ str.section( ',', 2, 2 ).toInt() ) );
+ case KoProperty::Integer:
+ return QVariant( str.toInt() );
+ case KoProperty::Boolean:
+ return QVariant( str == "true", 3 );
+ case KoProperty::Font:
+ return QVariant( QFont( str ) );
+ case KoProperty::LineStyle:
+ return QVariant( str.toInt() );
+ case KoProperty::Symbol:
+ return QVariant( str.at( 0 ).latin1() );
+ default:
+ return QVariant( str );
+ }
+}
+
+}
diff --git a/kugar/kudesigner_lib/propertyserializer.h b/kugar/kudesigner_lib/propertyserializer.h
new file mode 100644
index 00000000..4851946f
--- /dev/null
+++ b/kugar/kudesigner_lib/propertyserializer.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+* Copyright (C) 2004 by Alexander Dymo *
+* cloudtemple@mskat.net *
+* *
+* This program 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 program 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 General Public License for more details. *
+* *
+* You should have received a copy of the GNU Library General Public *
+* License along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA. *
+***************************************************************************/
+#ifndef KUDESIGNERPROPERTYSERIALIZER_H
+#define KUDESIGNERPROPERTYSERIALIZER_H
+
+#include <koproperty/property.h>
+
+using namespace KoProperty;
+
+namespace Kudesigner
+{
+
+/**
+@short Contains functions to convert Property values to strings
+*/
+class PropertySerializer
+{
+public:
+ PropertySerializer();
+ ~PropertySerializer();
+
+ static QString toString( Property *prop );
+ static QVariant fromString( Property *prop, const QString &str );
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/reportfooter.cpp b/kugar/kudesigner_lib/reportfooter.cpp
new file mode 100644
index 00000000..222757ad
--- /dev/null
+++ b/kugar/kudesigner_lib/reportfooter.cpp
@@ -0,0 +1,56 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "reportfooter.h"
+
+#include <klocale.h>
+
+#include <qpainter.h>
+
+#include <koproperty/property.h>
+
+namespace Kudesigner
+{
+
+ReportFooter::ReportFooter( int x, int y, int width, int height, Canvas *canvas ) :
+ Band( x, y, width, height, canvas )
+{
+ props.addProperty( new Property( "Height", 50, i18n( "Height" ), i18n( "Height" ), KoProperty::Integer ), "Section" );
+
+ QMap<QString, QString> m;
+
+ m[ i18n( "First Page" ) ] = "0";
+ m[ i18n( "Every Page" ) ] = "1";
+ m[ i18n( "Last Page" ) ] = "2";
+
+ props.addProperty( new Property( "PrintFrequency", m.values(), m.keys(), "2", i18n( "Print Frequency" ), i18n( "Print Frequency" ) ), "Section" );
+}
+
+void ReportFooter::draw( QPainter &painter )
+{
+ painter.drawText( rect(), AlignVCenter | AlignLeft,
+ i18n( "Report Footer" ) );
+ Band::draw( painter );
+}
+
+QString ReportFooter::getXml()
+{
+ return "\t<ReportFooter" + Band::getXml() + "\t</ReportFooter>\n\n";
+}
+
+}
diff --git a/kugar/kudesigner_lib/reportfooter.h b/kugar/kudesigner_lib/reportfooter.h
new file mode 100644
index 00000000..d6011a65
--- /dev/null
+++ b/kugar/kudesigner_lib/reportfooter.h
@@ -0,0 +1,43 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 REPORTFOOTER_H
+#define REPORTFOOTER_H
+
+#include "commdefs.h"
+#include "band.h"
+
+namespace Kudesigner
+{
+
+class ReportFooter: public Band
+{
+public:
+ ReportFooter( int x, int y, int width, int height, Canvas *canvas );
+
+ virtual int rtti() const
+ {
+ return Rtti_ReportFooter;
+ }
+ virtual void draw( QPainter &painter );
+ virtual QString getXml();
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/reportheader.cpp b/kugar/kudesigner_lib/reportheader.cpp
new file mode 100644
index 00000000..a3311be9
--- /dev/null
+++ b/kugar/kudesigner_lib/reportheader.cpp
@@ -0,0 +1,54 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "reportheader.h"
+
+#include <klocale.h>
+
+#include <qpainter.h>
+
+#include <koproperty/property.h>
+
+namespace Kudesigner
+{
+
+ReportHeader::ReportHeader( int x, int y, int width, int height, Canvas *canvas ) :
+ Band( x, y, width, height, canvas )
+{
+ props.addProperty( new Property( "Height", 50, i18n( "Height" ), i18n( "Height" ), KoProperty::Integer ), "Section" );
+ QMap<QString, QString> m;
+
+ m[ i18n( "First Page" ) ] = "0";
+ m[ i18n( "Every Page" ) ] = "1";
+ m[ i18n( "Last Page" ) ] = "2";
+
+ props.addProperty( new Property( "PrintFrequency", m.values(), m.keys(), "0", i18n( "Print Frequency" ), i18n( "Print Frequency" ) ), "Section" );
+}
+
+void ReportHeader::draw( QPainter &painter )
+{
+ painter.drawText( rect(), AlignVCenter | AlignLeft, i18n( "Report Header" ) );
+ Band::draw( painter );
+}
+
+QString ReportHeader::getXml()
+{
+ return "\t<ReportHeader" + Band::getXml() + "\t</ReportHeader>\n\n";
+}
+
+}
diff --git a/kugar/kudesigner_lib/reportheader.h b/kugar/kudesigner_lib/reportheader.h
new file mode 100644
index 00000000..e8c4a38b
--- /dev/null
+++ b/kugar/kudesigner_lib/reportheader.h
@@ -0,0 +1,44 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 REPORTHEADER_H
+#define REPORTHEADER_H
+
+#include "commdefs.h"
+#include "band.h"
+
+class QPainter;
+
+namespace Kudesigner
+{
+
+class ReportHeader: public Band
+{
+public:
+ ReportHeader( int x, int y, int width, int height, Canvas *canvas );
+ virtual int rtti() const
+ {
+ return Rtti_ReportHeader;
+ }
+ virtual void draw( QPainter &painter );
+ virtual QString getXml();
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/reportitem.cpp b/kugar/kudesigner_lib/reportitem.cpp
new file mode 100644
index 00000000..077bc1fe
--- /dev/null
+++ b/kugar/kudesigner_lib/reportitem.cpp
@@ -0,0 +1,247 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "reportitem.h"
+
+#include <klocale.h>
+#include <kglobalsettings.h>
+
+#include <qrect.h>
+#include <qpainter.h>
+#include <qregexp.h>
+
+#include <koproperty/property.h>
+
+#include "canvas.h"
+#include "band.h"
+#include "propertyserializer.h"
+
+#include <kdebug.h>
+
+namespace Kudesigner
+{
+
+QRect ReportItem::topLeftResizableRect()
+{
+ return QRect( ( int ) x(), ( int ) y(), HolderSize, HolderSize );
+}
+
+QRect ReportItem::bottomLeftResizableRect()
+{
+ return QRect( ( int ) x(), ( int ) ( y() + height() - HolderSize ), HolderSize, HolderSize );
+}
+
+QRect ReportItem::topRightResizableRect()
+{
+ return QRect( ( int ) ( x() + width() - HolderSize ), ( int ) y(), HolderSize, HolderSize );
+}
+
+QRect ReportItem::bottomRightResizableRect()
+{
+ return QRect( ( int ) ( x() + width() - HolderSize ), ( int ) ( y() + height() - HolderSize ), HolderSize, HolderSize );
+}
+
+QRect ReportItem::topMiddleResizableRect()
+{
+ return QRect( ( int ) ( x() + width() / 2 - HolderSize / 2. ), ( int ) y(), HolderSize, HolderSize );
+}
+
+QRect ReportItem::bottomMiddleResizableRect()
+{
+ return QRect( ( int ) ( x() + width() / 2 - HolderSize / 2. ), ( int ) ( y() + height() - HolderSize ), HolderSize, HolderSize );
+}
+
+QRect ReportItem::leftMiddleResizableRect()
+{
+ return QRect( ( int ) x(), ( int ) ( y() + height() / 2 - HolderSize / 2. ), HolderSize, HolderSize );
+}
+
+QRect ReportItem::rightMiddleResizableRect()
+{
+ return QRect( ( int ) ( x() + width() - HolderSize ), ( int ) ( y() + height() / 2 - HolderSize / 2. ), HolderSize, HolderSize );
+}
+
+void ReportItem::updateGeomProps()
+{
+ if ( !section() )
+ return ;
+ props[ "X" ].setValue( ( int ) ( x() - section() ->x() ) );
+ props[ "Y" ].setValue( ( int ) ( y() - section() ->y() ) );
+ props[ "Width" ].setValue( width() );
+ props[ "Height" ].setValue( height() );
+}
+
+Band *ReportItem::section()
+{
+ return parentSection;
+}
+
+void ReportItem::setSection( Band *section )
+{
+ props[ "X" ].setValue( ( int ) ( x() - section->x() ) );
+ props[ "Y" ].setValue( ( int ) ( y() - section->y() ) );
+ parentSection = section;
+}
+
+void ReportItem::setSectionUndestructive( Band *section )
+{
+ parentSection = section;
+}
+
+QString ReportItem::getXml()
+{
+ QString result = "";
+
+ int i = 1;
+ for ( Set::Iterator it( props ); it.current(); ++it )
+ {
+ if ( !( i % 3 ) )
+ result += "\n\t\t ";
+ result += " " + QString(it.currentKey()) + "=" + "\"" + escape( PropertySerializer::toString( it.current() ) ) + "\"";
+ i++;
+ }
+
+ return result;
+}
+
+int ReportItem::isInHolder( const QPoint p )
+{
+ if ( topLeftResizableRect().contains( p ) )
+ return ( ResizeTop | ResizeLeft );
+ if ( bottomLeftResizableRect().contains( p ) )
+ return ( ResizeBottom | ResizeLeft );
+ if ( leftMiddleResizableRect().contains( p ) )
+ return ( ResizeLeft );
+ if ( bottomMiddleResizableRect().contains( p ) )
+ return ( ResizeBottom );
+ if ( topMiddleResizableRect().contains( p ) )
+ return ( ResizeTop );
+ if ( topRightResizableRect().contains( p ) )
+ return ( ResizeTop | ResizeRight );
+ if ( bottomRightResizableRect().contains( p ) )
+ return ( ResizeBottom | ResizeRight );
+ if ( rightMiddleResizableRect().contains( p ) )
+ return ( ResizeRight );
+
+ return ResizeNothing;
+}
+
+void ReportItem::drawHolders( QPainter &painter )
+{
+ painter.setPen( QColor( 0, 0, 0 ) );
+
+ painter.setBrush( KGlobalSettings::highlightColor() );
+
+ QCanvasItemList list = collisions( false );
+ QCanvasItemList::iterator it = list.begin();
+ for ( ; it != list.end(); ++it )
+ {
+ switch ( ( *it )->rtti() )
+ {
+ case Rtti_Label:
+ case Rtti_Field:
+ case Rtti_Special:
+ case Rtti_Calculated:
+ case Rtti_Line:
+ {
+ ReportItem *item = static_cast<ReportItem*>( *it );
+ if ( section() != item->section() )
+ continue;
+ if ( intersects( item ) )
+ painter.setBrush( Qt::red );
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ if ( props["Height"].value().toInt() > section()->props["Height"].value().toInt() )
+ painter.setBrush( Qt::red );
+
+ painter.drawRect( topLeftResizableRect() );
+ painter.drawRect( topRightResizableRect() );
+ painter.drawRect( bottomLeftResizableRect() );
+ painter.drawRect( bottomRightResizableRect() );
+ painter.drawRect( topMiddleResizableRect() );
+ painter.drawRect( bottomMiddleResizableRect() );
+ painter.drawRect( leftMiddleResizableRect() );
+ painter.drawRect( rightMiddleResizableRect() );
+}
+
+bool ReportItem::intersects( ReportItem *item )
+{
+ QRect r1;
+ QRect r2;
+
+ if ( rtti() == Rtti_Line /*line*/ )
+ {
+ int x1 = props["X1"].value().toInt();
+ int x2 = props["X2"].value().toInt();
+ int y1 = props["Y1"].value().toInt();
+ int y2 = props["Y2"].value().toInt();
+ int width = props["Width"].value().toInt();
+ //TODO I'm not sure of a good fix for this, but for now I'm assuming lines
+ // in reports are either horizontal or vertical.
+ if ( x1 == x2 )
+ r1 = QRect( x1, y1, x2 + width, y2 );
+ else if ( y1 == y2 )
+ r1 = QRect( x1, y1, x2, y2 + width );
+ }
+ else
+ r1 = QRect( props["X"].value().toInt(), props["Y"].value().toInt(),
+ props["Width"].value().toInt(), props["Height"].value().toInt() );
+
+ if ( item->rtti() == Rtti_Line /*line*/ )
+ {
+ int x1 = item->props["X1"].value().toInt();
+ int x2 = item->props["X2"].value().toInt();
+ int y1 = item->props["Y1"].value().toInt();
+ int y2 = item->props["Y2"].value().toInt();
+ int width = item->props["Width"].value().toInt();
+ //TODO I'm not sure of a good fix for this, but for now I'm assuming lines
+ // in reports are either horizontal or vertical.
+ if ( x1 == x2 )
+ r2 = QRect( x1, y1, x2 + width, y2 );
+ else if ( y1 == y2 )
+ r2 = QRect( x1, y1, x2, y2 + width );
+ }
+ else
+ r2 = QRect( item->props["X"].value().toInt(), item->props["Y"].value().toInt(),
+ item->props["Width"].value().toInt(), item->props["Height"].value().toInt() );
+
+ bool intersects = r1.intersects( r2 );
+
+ if ( intersects )
+ kdDebug(30001) << rttiName( rtti() ) << " " << r1 << "\n"
+ << "...is intersected by..." << "\n"
+ << rttiName( item->rtti() ) << " " << r2
+ << endl;
+
+ return intersects;
+}
+
+QString ReportItem::escape( QString string )
+{
+ string.replace( QRegExp( "&" ), "&amp;" );
+ string.replace( QRegExp( "<" ), "&lt;" );
+ string.replace( QRegExp( ">" ), "&gt;" );
+ return string;
+}
+
+}
diff --git a/kugar/kudesigner_lib/reportitem.h b/kugar/kudesigner_lib/reportitem.h
new file mode 100644
index 00000000..bfee4bd7
--- /dev/null
+++ b/kugar/kudesigner_lib/reportitem.h
@@ -0,0 +1,82 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 REPORTITEM_H
+#define REPORTITEM_H
+
+#include "commdefs.h"
+#include "box.h"
+
+class QString;
+class QStringList;
+
+namespace Kudesigner
+{
+
+class Band;
+
+class ReportItem: public Box
+{
+public:
+ ReportItem( int x, int y, int width, int height, Canvas *canvas )
+ : Box( x, y, width, height, canvas )
+ {
+ setZ( 20 );
+ parentSection = 0;
+ }
+ virtual int rtti() const
+ {
+ return Rtti_ReportItem;
+ }
+
+ virtual void updateGeomProps();
+ virtual void draw( QPainter &painter )
+ {
+ Box::draw( painter );
+ }
+ virtual QString getXml();
+
+ QRect topLeftResizableRect();
+ QRect bottomLeftResizableRect();
+ QRect topRightResizableRect();
+ QRect bottomRightResizableRect();
+ QRect topMiddleResizableRect();
+ QRect bottomMiddleResizableRect();
+ QRect leftMiddleResizableRect();
+ QRect rightMiddleResizableRect();
+
+ virtual Band *section();
+ virtual void setSection( Band *section );
+ virtual void setSectionUndestructive( Band *section );
+
+ virtual int isInHolder( const QPoint p );
+ virtual void drawHolders( QPainter &painter );
+ virtual void fastProperty()
+ { }
+ ;
+ bool intersects( ReportItem *item );
+ QString escape( QString string );
+
+protected:
+ friend class View;
+ Band *parentSection;
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/section.cpp b/kugar/kudesigner_lib/section.cpp
new file mode 100644
index 00000000..1ec5bc59
--- /dev/null
+++ b/kugar/kudesigner_lib/section.cpp
@@ -0,0 +1,37 @@
+/* This file is part of the KDE project
+Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+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 "section.h"
+
+#include "klocale.h"
+
+namespace Kudesigner
+{
+
+Section::Section( int x, int y, int width, int height, Canvas *canvas )
+ : Box( x, y, width, height, canvas )
+{
+ props.setGroupDescription( "Section", i18n( "Section" ) );
+}
+
+void Section::draw( QPainter &painter )
+{
+ Box::draw( painter );
+}
+
+}
diff --git a/kugar/kudesigner_lib/section.h b/kugar/kudesigner_lib/section.h
new file mode 100644
index 00000000..e321f78f
--- /dev/null
+++ b/kugar/kudesigner_lib/section.h
@@ -0,0 +1,48 @@
+/* This file is part of the KDE project
+Copyright (C) 2003-2004 Alexander Dymo <adymo@mksat.net>
+
+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 SECTION_H
+#define SECTION_H
+
+#include "commdefs.h"
+#include "box.h"
+
+class QPainter;
+
+namespace Kudesigner
+{
+
+class Section: public Box
+{
+public:
+ Section( int x, int y, int width, int height, Canvas *canvas );
+
+ virtual QString getXml()
+ {
+ return "";
+ }
+ virtual void draw( QPainter &painter );
+ virtual int rtti() const
+ {
+ return Rtti_Section;
+ }
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/specialfield.cpp b/kugar/kudesigner_lib/specialfield.cpp
new file mode 100644
index 00000000..5e404066
--- /dev/null
+++ b/kugar/kudesigner_lib/specialfield.cpp
@@ -0,0 +1,69 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "specialfield.h"
+
+#include <klocale.h>
+
+#include <koproperty/property.h>
+
+namespace Kudesigner
+{
+
+SpecialField::SpecialField( int x, int y, int width, int height, Canvas *canvas )
+ : Label( x, y, width, height, canvas )
+{
+ QMap<QString, QString> m;
+
+ props.setGroupDescription( "SpecialField", i18n( "Special Field" ) );
+
+ m[ i18n( "Date" ) ] = "0";
+ m[ i18n( "PageNumber" ) ] = "1";
+ props.addProperty( new Property( "Type", m.values(), m.keys(), "0", i18n( "Type" ), i18n( "Special Field Type" ) ), "SpecialField" );
+ m.clear();
+
+ m[ i18n( "m/d/y" ) ] = "0";
+ m[ i18n( "m-d-y" ) ] = "1";
+ m[ i18n( "mm/dd/y" ) ] = "2";
+ m[ i18n( "mm-dd-y" ) ] = "3";
+ m[ i18n( "m/d/yyyy" ) ] = "4";
+ m[ i18n( "m-d-yyyy" ) ] = "5";
+ m[ i18n( "mm/dd/yyyy" ) ] = "6";
+ m[ i18n( "mm-dd-yyyy" ) ] = "7";
+ m[ i18n( "yyyy/m/d" ) ] = "8";
+ m[ i18n( "yyyy-m-d" ) ] = "9";
+ m[ i18n( "dd.mm.yy" ) ] = "10";
+ m[ i18n( "dd.mm.yyyy" ) ] = "11";
+ //TODO: make date format not hard-coded, use locale settings
+ props.addProperty( new Property( "DateFormat", m.values(), m.keys(), "11", i18n( "Date Format" ), i18n( "Date Format" ) ), "SpecialField" );
+}
+
+void SpecialField::draw( QPainter &painter )
+{
+ props[ "Text" ].setValue( "[" +
+ QString( props[ "Type" ].value().toInt() ? i18n( "PageNo" ) : i18n( "Date" ) )
+ + "]" );
+ Label::draw( painter );
+}
+
+QString SpecialField::getXml()
+{
+ return "\t\t<Special" + ReportItem::getXml() + " />\n";
+}
+
+}
diff --git a/kugar/kudesigner_lib/specialfield.h b/kugar/kudesigner_lib/specialfield.h
new file mode 100644
index 00000000..d1dd2be6
--- /dev/null
+++ b/kugar/kudesigner_lib/specialfield.h
@@ -0,0 +1,49 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 SPECIALFIELD_H
+#define SPECIALFIELD_H
+
+#include "label.h"
+
+namespace Kudesigner
+{
+
+class SpecialField: public Label
+{
+public:
+ SpecialField( int x, int y, int width, int height, Canvas *canvas );
+
+ virtual int rtti() const
+ {
+ return Rtti_Special;
+ }
+ virtual QString getXml();
+ virtual void draw( QPainter &painter );
+ virtual void updateGeomProps()
+ {
+ Label::updateGeomProps();
+ }
+ virtual void fastProperty()
+ {}
+ ;
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/structurewidget.cpp b/kugar/kudesigner_lib/structurewidget.cpp
new file mode 100644
index 00000000..7f986ffb
--- /dev/null
+++ b/kugar/kudesigner_lib/structurewidget.cpp
@@ -0,0 +1,239 @@
+/***************************************************************************
+* Copyright (C) 2005 by Alexander Dymo *
+* adymo@kdevelop.org *
+* *
+* This program 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 program 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 General Public License for more details. *
+* *
+* You should have received a copy of the GNU Library General Public *
+* License along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA. *
+***************************************************************************/
+#include "structurewidget.h"
+
+#include <qpainter.h>
+#include <qcanvas.h>
+
+#include <koproperty/property.h>
+
+#include "canvas.h"
+#include "kugartemplate.h"
+#include "reportheader.h"
+#include "reportfooter.h"
+#include "pageheader.h"
+#include "pagefooter.h"
+#include "detail.h"
+#include "detailfooter.h"
+#include "detailheader.h"
+
+#include <kdebug.h>
+
+namespace Kudesigner
+{
+
+using namespace KoProperty;
+
+class StructureItem: public KListViewItem
+{
+public:
+ StructureItem( KListView *parent, const QString &name )
+ : KListViewItem( parent, name ), m_bold( false )
+ {}
+ StructureItem( KListViewItem *parent, const QString &name )
+ : KListViewItem( parent, name ), m_bold( false )
+ {}
+ void setBold( bool b )
+ {
+ m_bold = b;
+ }
+ bool isBold() const
+ {
+ return m_bold;
+ }
+
+ virtual void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
+ {
+ if ( m_bold )
+ {
+ QFont f = p->font();
+ f.setWeight( 75 );
+ p->setFont( f );
+ }
+ KListViewItem::paintCell( p, cg, column, width, align );
+ }
+
+private:
+ bool m_bold;
+};
+
+StructureWidget::StructureWidget( QWidget* parent, const char* name )
+ : KListView( parent, name )
+{
+ setFullWidth( true );
+ addColumn( tr( "Report Structure" ) );
+ setSorting( -1 );
+ connect( this, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) );
+}
+
+void StructureWidget::refresh()
+{
+ if ( !m_doc )
+ return ;
+ clear();
+ m_selected.clear();
+
+ StructureItem *root = new StructureItem( this, tr( "Report Template" ) );
+ m_items[ m_doc->kugarTemplate() ] = root;
+ root->setOpen( true );
+
+ refreshSection( m_doc->kugarTemplate() ->reportFooter, root );
+ refreshSection( m_doc->kugarTemplate() ->pageFooter, root );
+
+ for ( std::map<int, DetailBand>::iterator it =
+ m_doc->kugarTemplate() ->details.begin();
+ it != m_doc->kugarTemplate() ->details.end(); ++it )
+ {
+ int level = ( *it ).first;
+ refreshSection( ( *it ).second.first.second, root, level );
+ refreshSection( ( *it ).second.second, root, level );
+ refreshSection( ( *it ).second.first.first, root, level );
+ }
+
+ refreshSection( m_doc->kugarTemplate() ->pageHeader, root );
+ refreshSection( m_doc->kugarTemplate() ->reportHeader, root );
+}
+
+void StructureWidget::refreshSection( Kudesigner::Band *section, StructureItem *root, int level )
+{
+ if ( !section )
+ return ;
+ QString name;
+ switch ( section->rtti() )
+ {
+ case Kudesigner::Rtti_ReportHeader:
+ name = tr( "Report Header" );
+ break;
+ case Kudesigner::Rtti_ReportFooter:
+ name = tr( "Report Footer" );
+ break;
+ case Kudesigner::Rtti_PageFooter:
+ name = tr( "Page Footer" );
+ break;
+ case Kudesigner::Rtti_PageHeader:
+ name = tr( "Page Header" );
+ break;
+ case Kudesigner::Rtti_Detail:
+ name = tr( "Detail" );
+ break;
+ case Kudesigner::Rtti_DetailHeader:
+ name = tr( "Detail Header" );
+ break;
+ case Kudesigner::Rtti_DetailFooter:
+ name = tr( "Detail Footer" );
+ break;
+ }
+ if ( level > 0 )
+ name += tr( " (level %1)" ).arg( level );
+ StructureItem *item = new StructureItem( root, name );
+ m_items[ section ] = item;
+
+ refreshSectionContents( section, item );
+}
+
+void StructureWidget::refreshSectionContents( Kudesigner::Band *section, StructureItem *root )
+{
+ if ( !section )
+ return ;
+
+ for ( QCanvasItemList::iterator it = section->items.begin(); it != section->items.end(); ++it )
+ {
+ Kudesigner::Box *box = static_cast<Kudesigner::Box*>( *it );
+ if ( !box )
+ continue;
+
+ QString name = tr( "<unknown>" );
+ int idx;
+ switch ( box->rtti() )
+ {
+ case Kudesigner::Rtti_Label:
+ name = tr( "Label: %1" ).arg( box->props[ "Text" ].value().toString() );
+ break;
+ case Kudesigner::Rtti_Field:
+ name = tr( "Field: %1" ).arg( box->props[ "Field" ].value().toString() );
+ break;
+ case Kudesigner::Rtti_Calculated:
+ name = tr( "Calculated Field: %1" ).arg( box->props[ "Field" ].value().toString() );
+ break;
+ case Kudesigner::Rtti_Special:
+ idx = box->props[ "Type" ].listData()->keys.findIndex(
+ box->props[ "Type" ].value().toInt() );
+ name = tr( "Special Field: %1" ).arg( box->props[ "Type" ].listData()->keys[ idx ].toString() );
+ break;
+ case Kudesigner::Rtti_Line:
+ name = tr( "Line" );
+ break;
+ }
+
+ StructureItem *item = new StructureItem( root, name );
+ m_items[ box ] = item;
+ }
+}
+
+void StructureWidget::selectionMade()
+{
+ m_selected.clear();
+ BoxList sel = m_doc->selected;
+ for ( BoxList::iterator it = sel.begin(); it != sel.end(); ++it )
+ {
+ if ( m_items.contains( *it ) )
+ {
+ StructureItem * item = static_cast<StructureItem*>( m_items[ *it ] );
+ item->setBold( true );
+ item->repaint();
+ m_selected.append( item );
+ }
+ }
+}
+
+void StructureWidget::selectionClear()
+{
+ for ( QValueList<StructureItem*>::iterator it = m_selected.begin(); it != m_selected.end(); ++it )
+ {
+ if ( ( *it ) == 0 )
+ continue;
+ ( *it ) ->setBold( false );
+ ( *it ) ->repaint();
+ }
+ m_selected.clear();
+}
+
+void StructureWidget::selectItem( QListViewItem *item )
+{
+ if ( !item )
+ return ;
+ int idx = m_items.values().findIndex( static_cast<StructureItem*>( item ) );
+ if ( idx == -1 )
+ return ;
+ Kudesigner::Box *box = m_items.keys() [ idx ];
+ if ( box )
+ m_doc->selectItem( box, false );
+}
+
+void StructureWidget::setDocument( Kudesigner::Canvas *doc )
+{
+ m_doc = doc;
+ m_items.clear();
+}
+
+}
+
+#include "structurewidget.moc"
diff --git a/kugar/kudesigner_lib/structurewidget.h b/kugar/kudesigner_lib/structurewidget.h
new file mode 100644
index 00000000..2601ac1f
--- /dev/null
+++ b/kugar/kudesigner_lib/structurewidget.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+* Copyright (C) 2005 by Alexander Dymo *
+* adymo@kdevelop.org *
+* *
+* This program 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 program 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 General Public License for more details. *
+* *
+* You should have received a copy of the GNU Library General Public *
+* License along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA. *
+***************************************************************************/
+#ifndef KUDESIGNERSTRUCTUREWIDGET_H
+#define KUDESIGNERSTRUCTUREWIDGET_H
+
+#include <klistview.h>
+#include <qmap.h>
+
+class KudesignerDoc;
+
+namespace Kudesigner
+{
+
+class Box;
+class Band;
+class Canvas;
+class StructureItem;
+
+class StructureWidget: public KListView
+{
+ Q_OBJECT
+public:
+ StructureWidget( QWidget* parent = 0, const char* name = 0 );
+
+public slots:
+ void refresh();
+ void selectionMade();
+ void selectionClear();
+
+ void selectItem( QListViewItem *item );
+ void setDocument( Kudesigner::Canvas *doc );
+
+private:
+ void refreshSection( Kudesigner::Band *section, StructureItem *root, int level = -1 );
+ void refreshSectionContents( Kudesigner::Band *section, StructureItem *root );
+
+ Kudesigner::Canvas *m_doc;
+ QMap<Kudesigner::Box*, StructureItem*> m_items;
+ QValueList<StructureItem*> m_selected;
+};
+
+}
+
+#endif
diff --git a/kugar/kudesigner_lib/view.cpp b/kugar/kudesigner_lib/view.cpp
new file mode 100644
index 00000000..b2684ee1
--- /dev/null
+++ b/kugar/kudesigner_lib/view.cpp
@@ -0,0 +1,841 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 "view.h"
+
+#include <math.h>
+
+#include <qwmatrix.h>
+#include <qevent.h>
+#include <qpoint.h>
+#include <qcanvas.h>
+#include <qaction.h>
+#include <qcursor.h>
+#include <qpainter.h>
+#include <qbitmap.h>
+#include <qimage.h>
+
+#include <qprinter.h>
+#include <kdebug.h>
+
+#include <koproperty/property.h>
+
+#include "canvas.h"
+#include "box.h"
+#include "commdefs.h"
+#include "reportitem.h"
+#include "label.h"
+#include "field.h"
+#include "specialfield.h"
+#include "calcfield.h"
+#include "line.h"
+#include "kugartemplate.h"
+#include "detailbase.h"
+#include "band.h"
+#include "command.h"
+
+#include "plugin.h"
+
+namespace Kudesigner
+{
+
+void SelectionRect::draw( QPainter & painter )
+{
+ // painter.setPen(Qt::NoPen);
+
+ /* QPrinter pr;
+ if ( pr.setup() ) {
+ QPainter p(&pr);
+ m_canvas->drawArea( m_canvas->rect(), &p );
+ } */
+
+ /* kdDebug(31000) << "creating pixmap" << endl;
+ QPixmap mp(rect().size());
+ kdDebug(31000) << "creating painter" << endl;
+ QPainter p(&mp);
+ kdDebug(31000) << "filling pixmap" << endl;
+ m_canvas->drawArea(m_canvas->rect(), &p);
+ kdDebug(31000) << "converting to image" << endl;
+ QImage im = mp.convertToImage();
+ if (!im.isNull())
+ {
+ kdDebug(31000) << "do dither" << endl;
+ mp.convertFromImage(im, Qt::OrderedAlphaDither);
+
+ kdDebug(31000) << "creating brush" << endl;
+ QBrush br(KGlobalSettings::highlightColor(),Qt::CustomPattern);
+ br.setPixmap(mp);
+ painter.setBrush(br);
+ }
+ kdDebug(31000) << "drawing" << endl;*/
+ // painter.drawRect(rect());
+ QPen pen( QColor( 0, 0, 0 ), 0, Qt::DotLine );
+ painter.setPen( pen );
+ painter.setBrush( QBrush( NoBrush ) );
+ painter.drawRect( rect() );
+ // QCanvasRectangle::draw(painter);
+}
+
+
+
+View::View( Canvas *canvas, QWidget *parent, const char *name, WFlags f ) :
+ QCanvasView( canvas, parent, name, f ), selectionBuf( 0 ), m_plugin( 0 ), m_canvas( canvas )
+{
+ itemToInsert = 0;
+ moving = 0;
+ resizing = 0;
+ selectionStarted = 0;
+ request = RequestNone;
+
+ selectionRect = new SelectionRect( 0, 0, 0, 0, canvas );
+
+ connect( m_canvas, SIGNAL( itemSelected() ), this, SLOT( selectItem() ) );
+}
+
+void View::deleteItem( QCanvasItemList &l )
+{
+ for ( QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it )
+ {
+ m_canvas->unselectItem( static_cast<Kudesigner::Box*>( *it ) );
+ if ( m_canvas->kugarTemplate() ->removeReportItem( *it ) )
+ break;
+ }
+}
+
+void View::editItem( QCanvasItemList & /* l */ )
+{
+ //display editor for report items or sections
+ /* for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it)
+ {
+ if ((*it)->rtti() >= 1800) //for my own report items
+ {
+ CanvasKudesigner::Box *l = (CanvasKudesigner::Box*)(*it);
+ dlgItemOptions *dlgOpts = new dlgItemOptions(&(l->props), this);
+ dlgOpts->exec();
+ delete dlgOpts;
+ if ((*it)->rtti() == KugarTemplate)
+ ((CanvasKugarTemplate*)(*it))->updatePaperProps();
+ (*it)->hide();
+ (*it)->show();
+ if ((*it)->rtti() < 2000)
+ ((MyCanvas *)(m_canvas))->templ->arrangeSections();
+ m_canvas->update();
+ emit modificationPerformed();
+ break;
+ }
+ }*/
+}
+
+void View::selectItemFromList( QCanvasItemList &l )
+{
+ //display editor for report items or sections
+ for ( QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it )
+ {
+ if ( ( *it ) ->rtti() >= 1800 ) //include bands and the template itself
+ {
+ Kudesigner::Box * b = static_cast<Kudesigner::Box*>( *it );
+ if ( !m_canvas->selected.contains( b ) )
+ {
+ m_canvas->unselectAll();
+ m_canvas->selectItem( b, false );
+ m_canvas->update();
+ // qWarning("selected item set");
+ // selected->drawHolders();
+ return ;
+ }
+ if ( m_canvas->selected.contains( b ) )
+ {
+ if ( m_canvas->selected.count() > 1 )
+ {
+ m_canvas->unselectAll();
+ m_canvas->selectItem( b, false );
+ m_canvas->update();
+ }
+ return ;
+ }
+ }
+ }
+ m_canvas->unselectAll();
+ // qWarning("unselect");
+}
+
+
+void View::placeItem( QCanvasItemList &l, QMouseEvent *e )
+{
+ for ( QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it )
+ {
+ if ( ( ( *it ) ->rtti() > 1800 ) && ( ( ( *it ) ->rtti() < 2000 ) ) )
+ {
+ int band = ( *it ) ->rtti();
+ int bandLevel = -1;
+ if ( ( band == Rtti_DetailHeader ) ||
+ ( band == Rtti_Detail ) ||
+ ( band == Rtti_DetailFooter ) )
+ bandLevel = static_cast<DetailBase*>( *it ) ->level();
+ emit itemPlaced( e->x(), e->y(), band, bandLevel );
+
+ // emit modificationPerformed();
+ }
+ }
+ itemToInsert = 0;
+ emit selectedActionProcessed();
+}
+
+
+bool View::startResizing( QMouseEvent * /*e*/, QPoint &p )
+{
+ if ( m_canvas->selected.count() == 0 )
+ return false;
+ for ( BoxList::iterator it = m_canvas->selected.begin();
+ it != m_canvas->selected.end(); ++it )
+ {
+ Kudesigner::Box *cbx = *it;
+ resizing_type = cbx->isInHolder( p );
+ /* qWarning("POINT: %d %d", p.x(), p.y());
+ qWarning("RESIZE: %d", resizing_type);*/
+ if ( resizing_type )
+ {
+ m_canvas->selectItem( cbx, false );
+ //kdDebug()<<"A Widget should be resized"<<endl;
+ moving = 0;
+ resizing = cbx;
+ moving_start = p;
+ moving_offsetX = 0;
+ moving_offsetY = 0;
+
+ if ( cbx->rtti() > 2001 )
+ {
+ ReportItem * item = static_cast<ReportItem*>( cbx );
+ resizing_constraint.setX( ( int ) item->section() ->x() );
+ resizing_constraint.setY( ( int ) item->section() ->y() );
+ resizing_constraint.setWidth( item->section() ->width() );
+ resizing_constraint.setHeight(
+ item->section() ->height() );
+ if ( cbx->rtti() != Rtti_Line )
+ {
+ resizing_minSize.setWidth( 10 );
+ resizing_minSize.setHeight( 10 );
+ }
+ else
+ {
+ resizing_minSize.setWidth( 0 );
+ resizing_minSize.setHeight( 0 );
+ }
+ }
+ else
+ if ( cbx->rtti() >= Rtti_ReportHeader )
+ {
+ resizing_constraint = QRect( 0, 0, 1000, 1000 );
+ resizing_minSize.setWidth( 0 );
+ resizing_minSize.setHeight( static_cast<Band*>( cbx ) ->minHeight() );
+ }
+ else
+ {
+ resizing_constraint = QRect( 0, 0, 1000, 1000 );
+ resizing_minSize.setWidth( 0 );
+ resizing_minSize.setHeight( 10 );
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+void View::startMoveOrResizeOrSelectItem( QCanvasItemList &l,
+ QMouseEvent * /*e*/, QPoint &p )
+{
+ //allow user to move any item except for page rectangle
+ for ( QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it )
+ {
+ Kudesigner::Box *cb = static_cast<Kudesigner::Box*>( *it );
+ if ( cb->rtti() >= 1700 ) //> 2001)
+ {
+ moving_start = p;
+ moving_offsetX = 0;
+ moving_offsetY = 0;
+ resizing_type = cb->isInHolder( p );
+ if ( ( *it ) ->rtti() > 2001 )
+ {
+ ReportItem * item = static_cast<ReportItem*>( *it );
+ moving = item;
+ resizing = 0;
+ return ;
+ }
+ }
+ }
+ moving = 0;
+ resizing = 0;
+ // qWarning("1");
+ selectionStarted = 1;
+ selectionRect->setX( p.x() );
+ selectionRect->setY( p.y() );
+ selectionRect->setZ( 50 );
+ // qWarning("2");
+ selectionRect->show();
+ // qWarning("3");
+}
+
+void View::contentsMousePressEvent( QMouseEvent* e )
+{
+ QPoint p = inverseWorldMatrix().QWMatrix::map( e->pos() );
+ QCanvasItemList l = m_canvas->collisions( p );
+
+ //if there is a request for properties or for delete operation
+ //perform that and do not take care about mouse buttons
+
+ // qWarning("mouse press");
+
+ switch ( request )
+ {
+ case RequestProps:
+ clearRequest();
+ editItem( l );
+ return ;
+ case RequestDelete:
+ deleteItem( l );
+ clearRequest();
+ return ;
+ case RequestNone:
+ break;
+ }
+
+ moving = 0;
+ resizing = 0;
+ selectionStarted = 0;
+
+
+
+ /* Kudesigner::Box *b;
+ qWarning("Selected items:");
+ for (b = selected.first(); b; b = selected.next())
+ qWarning("%s", b->props["Text"].first.latin1());
+
+ */
+ switch ( e->button() )
+ {
+ case LeftButton:
+ if ( itemToInsert )
+ {
+ // qWarning("placing item");
+ m_canvas->unselectAll();
+ placeItem( l, e );
+ }
+ else
+ {
+ // qWarning("starting move or resize");
+ if ( !startResizing( e, p ) )
+ {
+ selectItemFromList( l );
+ startMoveOrResizeOrSelectItem( l, e, p );
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void View::contentsMouseReleaseEvent( QMouseEvent* e )
+{
+ selectionRect->setSize( 0, 0 );
+ selectionRect->setX( 0 );
+ selectionRect->setY( 0 );
+ selectionRect->hide();
+
+ QPoint p = inverseWorldMatrix().QWMatrix::map( e->pos() );
+ QCanvasItemList l = m_canvas->collisions( p );
+
+ switch ( e->button() )
+ {
+ case LeftButton:
+ if ( selectionStarted )
+ finishSelection();
+ break;
+ /* case MidButton:
+ deleteItem(l);
+ break;
+ case RightButton:
+ editItem(l);
+ break;*/
+ default:
+ break;
+ }
+}
+
+
+void View::fixMinValues( double &pos, double minv, double &offset )
+{
+ if ( pos < minv )
+ {
+ offset = offset + pos - minv;
+ pos = minv;
+ }
+ else
+ {
+ if ( offset < 0 )
+ {
+ offset = offset + pos - minv;
+ if ( offset < 0 )
+ pos = minv;
+ else
+ {
+ pos = offset + minv;
+ offset = 0;
+ }
+ }
+ }
+}
+
+void View::fixMaxValues( double &pos, double size, double maxv, double &offset )
+{
+ double tmpMax = pos + size;
+ if ( tmpMax > maxv )
+ {
+ offset = offset + tmpMax - maxv;
+ pos = maxv - size;
+ }
+ else
+ {
+ if ( offset > 0 )
+ {
+ offset = offset + tmpMax - maxv;
+ if ( offset > 0 )
+ pos = maxv - size;
+ else
+ {
+ pos = offset + maxv - size;
+ offset = 0;
+ }
+ }
+ }
+}
+
+#ifdef Q_WS_WIN
+double rint( double x )
+{
+ if ( fabs( x - floor( x ) ) < fabs( x - ceil( x ) ) )
+ return floor( x );
+ else
+ return ceil( x );
+}
+#endif
+
+void View::stickToGrid( double &x, double &y )
+{
+ int cx = int( rint( x / Config::gridSize() ) );
+ int cy = int( rint( y / Config::gridSize() ) );
+ x = cx * Config::gridSize();
+ y = cy * Config::gridSize();
+}
+
+void View::stickDimToGrid( double x, double y, double &w, double &h )
+{
+ int rightX = int( x + w );
+ int bottomY = int( y + h );
+ int nx = int( rint( rightX /Config::gridSize() ) * Config::gridSize() );
+ int ny = int( rint( bottomY / Config::gridSize() ) * Config::gridSize() );
+ w = nx - x;
+ h = ny - y;
+}
+
+void View::contentsMouseMoveEvent( QMouseEvent* e )
+{
+ QPoint p = inverseWorldMatrix().map( e->pos() );
+
+ /* QCanvasItemList l=m_canvas->collisions(p);
+ setCursor(QCursor(Qt::ArrowCursor));
+ unsetCursor();
+ for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it)
+ {
+ if ((*it)->rtti() > 2000)
+ {
+ CanvasReportItem *item = (CanvasReportItem*)(*it);
+ if (item->bottomRightResizableRect().contains(e->pos()))
+ setCursor(QCursor(Qt::SizeFDiagCursor));
+ }
+ }*/
+
+ if ( moving )
+ {
+ double newXPos = moving->x() + p.x() - moving_start.x();
+ double newYPos = moving->y() + p.y() - moving_start.y();
+ fixMinValues( newYPos, moving->parentSection->y(), moving_offsetY );
+ fixMinValues( newXPos, moving->parentSection->x(), moving_offsetX );
+ fixMaxValues( newYPos, moving->height(), moving->parentSection->y() + moving->parentSection->height(), moving_offsetY );
+ fixMaxValues( newXPos, moving->width(), moving->parentSection->x() + moving->parentSection->width(), moving_offsetX );
+
+ double sx = newXPos;
+ double sy = newYPos;
+ if ( Config::gridSize() > 1 )
+ stickToGrid( newXPos, newYPos );
+
+ moving->move( newXPos, newYPos );
+
+ /* attempt to prevent item collisions
+ QCanvasItemList l=m_canvas->collisions(moving->rect());
+ if (l.count() > 2)
+ {
+ moving->moveBy(-(p.x() - moving_start.x()),
+ -(p.y() - moving_start.y()));
+ m_canvas->update();
+ return;
+ }*/
+ // moving_start = p;
+ moving_start = QPoint( p.x() + ( int ) ( newXPos - sx ), p.y() + ( int ) ( newYPos - sy ) );
+ moving->updateGeomProps();
+ m_canvas->update();
+ emit modificationPerformed();
+ }
+ if ( resizing )
+ {
+ QCanvasRectangle * r = ( QCanvasRectangle * ) resizing;
+ double newXPos = r->x();
+ double newYPos = r->y();
+ double h = r->height();
+ double w = r->width();
+ // kdDebug()<<"resizing"<<endl;
+
+ //vertical resizing
+ if ( resizing_type & Kudesigner::Box::ResizeBottom )
+ {
+ // kdDebug()<<"Resize bottom"<<endl;
+ h = h + p.y() - moving_start.y();
+ fixMaxValues( h, r->y(), resizing_constraint.bottom(), moving_offsetY );
+ if ( resizing->rtti() != Rtti_Line )
+ fixMinValues( h, resizing_minSize.height(), moving_offsetY );
+ }
+ else
+ if ( resizing_type & Kudesigner::Box::ResizeTop )
+ {
+ // kdDebug()<<"Resize top"<<endl;
+ newYPos = r->y() + p.y() - moving_start.y();
+ fixMinValues( newYPos, resizing_constraint.top(), moving_offsetY );
+ if ( resizing->rtti() != Rtti_Line )
+ fixMaxValues( newYPos, resizing_minSize.height(), r->y() + r->height(), moving_offsetY );
+ h = h + ( r->y() - newYPos );
+ }
+
+
+ //horizontal resizing
+ if ( resizing_type & Kudesigner::Box::ResizeRight )
+ {
+ //kdDebug()<<"Resize right"<<endl;
+ w = w + p.x() - moving_start.x();
+ fixMaxValues( w, r->x(), resizing_constraint.right(), moving_offsetX );
+ if ( resizing->rtti() != Rtti_Line )
+ fixMinValues( w, resizing_minSize.width(), moving_offsetX );
+ }
+ else
+ if ( resizing_type & Kudesigner::Box::ResizeLeft )
+ {
+ // kdDebug()<<"Resize left"<<endl;
+ newXPos = r->x() + p.x() - moving_start.x();
+ fixMinValues( newXPos, resizing_constraint.left(), moving_offsetX );
+ if ( resizing->rtti() != Rtti_Line )
+ fixMaxValues( newXPos, resizing_minSize.width(), r->x() + r->width(), moving_offsetX );
+ w = w + ( r->x() - newXPos );
+ }
+
+ //sticky stuff
+ double sx = newXPos;
+ double sy = newYPos;
+ if ( Config::gridSize() > 1 )
+ stickToGrid( newXPos, newYPos );
+
+ r->move( newXPos, newYPos );
+
+ int dx = ( int ) ( newXPos - sx );
+ int dy = ( int ) ( newYPos - sy );
+ // moving_start = QPoint(p.x() + dx, p.y() + dy);
+ w -= dx;
+ h -= dy;
+ // moving_start = p;
+
+ double sw = w;
+ double sh = h;
+ stickDimToGrid( newXPos, newYPos, w, h );
+ int dw = ( int ) ( w - sw );
+ int dh = ( int ) ( h - sh );
+
+ moving_start = QPoint( p.x() + dx + dw, p.y() + dy + dh );
+
+ r->setSize( ( int ) w, ( int ) h );
+ resizing->updateGeomProps();
+ m_canvas->update();
+ emit modificationPerformed();
+ }
+ if ( selectionStarted )
+ {
+ selectionRect->setSize( ( int ) ( e->pos().x() - selectionRect->x() ),
+ ( int ) ( e->pos().y() - selectionRect->y() ) );
+ m_canvas->unselectAll();
+ QCanvasItemList l = m_canvas->collisions( selectionRect->rect() );
+ for ( QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it )
+ {
+ QRect r;
+ int left = selectionRect->rect().left();
+ int right = selectionRect->rect().right();
+ int top = selectionRect->rect().top();
+ int bottom = selectionRect->rect().bottom();
+ r.setLeft( left < right ? left : right );
+ r.setRight( left < right ? right : left );
+ r.setTop( top < bottom ? top : bottom );
+ r.setBottom( top < bottom ? bottom : top );
+
+ if ( ( ( *it ) ->rtti() > 2001 ) &&
+ ( r.contains( static_cast<Kudesigner::Box*>( *it ) ->rect() ) ) )
+ {
+ m_canvas->selectItem( static_cast<Kudesigner::Box*>( *it ) );
+ m_canvas->update();
+ }
+ }
+
+
+ /* selectionRect->setSize(e->pos().x() - selectionRect->x(),
+ e->pos().y() - selectionRect->y());
+ unselectAll();
+ QCanvasItemList l = m_canvas->collisions(selectionRect->rect());
+ for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it)
+ {
+ if ( ((*it)->rtti() > 2001) &&
+ (selectionRect->rect().contains(((CanvasKudesigner::Box*)(*it))->rect())) )
+ {
+ selectItem((CanvasKudesigner::Box*)(*it));
+ m_canvas->update();
+ }
+ }*/
+ }
+}
+
+
+void View::contentsMouseDoubleClickEvent( QMouseEvent *e )
+{
+ ReportItem * item = 0L;
+ if ( e->button() == Qt::LeftButton && m_canvas->selected.count() == 1 )
+ item = dynamic_cast<ReportItem*>( m_canvas->selected.first() );
+ if ( item )
+ {
+ item->fastProperty();
+ emit changed();
+ item->hide();
+ item->show();
+ }
+}
+
+void View::setRequest( RequestType r )
+{
+ switch ( r )
+ {
+ case RequestProps:
+ QApplication::restoreOverrideCursor();
+ QApplication::setOverrideCursor( Qt::PointingHandCursor );
+ break;
+ case RequestDelete:
+ QApplication::restoreOverrideCursor();
+ QApplication::setOverrideCursor( Qt::ForbiddenCursor );
+ break;
+ case RequestNone:
+ QApplication::restoreOverrideCursor();
+ break;
+ }
+ request = r;
+}
+
+void View::clearRequest()
+{
+ QApplication::restoreOverrideCursor();
+ request = RequestNone;
+ emit selectedEditActionProcessed();
+}
+
+bool View::requested()
+{
+ if ( request == RequestNone )
+ return false;
+ else
+ return true;
+}
+
+void View::updateProperty()
+{
+ for ( Kudesigner::BoxList::iterator it = m_canvas->selected.begin();
+ it != m_canvas->selected.end(); ++it )
+ {
+ Kudesigner::Box *b = *it;
+ // b->props[name]->setValue(value);
+ b->hide();
+ b->show();
+ if ( ( b->rtti() >= 1800 ) && ( b->rtti() < 2000 ) )
+ m_canvas->kugarTemplate() ->arrangeSections();
+ }
+}
+
+
+void View::finishSelection()
+{
+ selectionStarted = false;
+
+ if ( !m_canvas->selected.isEmpty() )
+ {
+ Kudesigner::BoxList::const_iterator it = m_canvas->selected.begin();
+ Kudesigner::Box *b = *it;
+ Buffer *buf = new Buffer( &( b->props ) );
+ ++it;
+ // qWarning("== %d", m_canvas->selected.count());
+ // Kudesigner::BoxList::const_iterator it2 = m_canvas->selected.end();
+ // qWarning("41: %d", it != it2);
+ for ( ; it != m_canvas->selected.end(); ++it )
+ {
+ b = *it;
+ buf->intersect( &( b->props ) );
+ }
+ emit selectionClear();
+ // delete selectionBuf;
+ selectionBuf = buf;
+ emit selectionMade( selectionBuf );
+ }
+}
+
+void View::setPlugin( KuDesignerPlugin *plugin )
+{
+ m_plugin = plugin;
+}
+
+void View::contentsDragMoveEvent( QDragMoveEvent * event )
+{
+ //perhaps this could be optimized a little bit
+ if ( !m_plugin )
+ return ;
+ QCanvasItemList l = m_canvas->collisions( event->pos() );
+ /* kdDebug()<<l.count()<<endl;*/
+ if ( l.count() < 2 )
+ {
+ event->ignore();
+ return ;
+ }
+ Kudesigner::Box *b = static_cast<Kudesigner::Box*>( *( l.begin() ) );
+ event->accept();
+ if ( m_plugin->dragMove( event, b ) )
+ event->accept();
+ else
+ event->ignore();
+}
+
+void View::contentsDragEnterEvent ( QDragEnterEvent * /*event*/ )
+{
+ // event->accept();
+}
+
+void View::keyPressEvent( QKeyEvent *e )
+{
+ kdDebug(31000) << k_funcinfo << endl;
+
+ if ( m_canvas->selected.count() == 1 )
+ {
+ ReportItem * item = static_cast<ReportItem *>( m_canvas->selected.first() );
+
+ switch ( e->key() )
+ {
+ case Qt::Key_Delete:
+ kdDebug(31000) << "Deleting selection" << endl;
+ /* unselectItem(item);
+ ( (MyCanvas*) m_canvas )->templ->removeReportItem( item );
+ clearRequest();*/
+ // deleteSelected();
+ //FIXME: this disregards undo/redo
+ if ( m_canvas->selected.count() > 0 )
+ {
+ emit selectionClear();
+ DeleteReportItemsCommand *cmd = new DeleteReportItemsCommand( m_canvas,
+ m_canvas->selected );
+ cmd->execute();
+ delete cmd;
+ }
+ return ;
+
+ /* Adjust height with - and + */
+ case Qt::Key_Minus:
+ case Qt::Key_Plus:
+ {
+ int size = item->props[ "FontSize" ].value().toInt();
+
+ if ( e->key() == Qt::Key_Minus )
+ size--;
+ else
+ size++;
+
+ if ( size < 5 )
+ size = 5;
+
+ if ( size > 50 )
+ size = 50;
+
+ item->props[ "FontSize" ].setValue( size );
+ item->hide();
+ item->show();
+ return ;
+ }
+
+ default:
+ e->ignore();
+ }
+
+ }
+}
+
+void View::selectItem( )
+{
+ if ( !selectionStarted )
+ finishSelection();
+}
+
+/*void View::deleteSelected( )
+{
+ CanvasKudesigner::Box *b;
+
+ QPtrList<CanvasKudesigner::Box> list = m_canvas->selected;
+ unselectAll();
+
+ for (b = list.first(); b; b = list.next())
+ {
+ ( (MyCanvas*) m_canvas )->templ->removeReportItem( b );
+ }
+}
+*/
+
+void View::setCanvas( Canvas *canvas )
+{
+ if ( selectionRect )
+ delete selectionRect;
+ QCanvasView::setCanvas( ( QCanvas* ) canvas );
+ m_canvas = canvas;
+ selectionRect = new SelectionRect( 0, 0, 0, 0, m_canvas );
+ connect( m_canvas, SIGNAL( itemSelected() ), this, SLOT( selectItem() ) );
+ clearRequest();
+}
+
+void View::setGridSize( int size )
+{
+ Config::setGridSize( size );
+ m_canvas->setChanged( m_canvas->rect() );
+ m_canvas->update();
+}
+
+}
+
+#include "view.moc"
diff --git a/kugar/kudesigner_lib/view.h b/kugar/kudesigner_lib/view.h
new file mode 100644
index 00000000..8ca5a9d4
--- /dev/null
+++ b/kugar/kudesigner_lib/view.h
@@ -0,0 +1,149 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002-2004 Alexander Dymo <adymo@mksat.net>
+
+ 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 VIEW_H
+#define VIEW_H
+
+#include <qcanvas.h>
+#include <qpainter.h>
+#include <qptrlist.h>
+
+#include <koproperty/property.h>
+
+class KuDesignerPlugin;
+
+class QMouseEvent;
+class QCanvasItemList;
+
+namespace KoProperty
+{
+class Buffer;
+}
+
+using namespace KoProperty;
+
+namespace Kudesigner
+{
+
+class ReportItem;
+class Box;
+class Canvas;
+class Band;
+
+class SelectionRect: public QCanvasRectangle
+{
+public:
+ SelectionRect( int x, int y, int width, int height, Canvas *canvas ) :
+ QCanvasRectangle( x, y, width, height, ( QCanvas* ) canvas )
+ {}
+
+ virtual void draw( QPainter & painter );
+};
+
+class View: public QCanvasView
+{
+ Q_OBJECT
+public:
+ View( Canvas *canvas, QWidget *parent, const char *name = 0, WFlags f = 0 );
+
+ int itemToInsert;
+
+ enum RequestType {RequestNone = 0, RequestProps, RequestDelete};
+
+ void setRequest( RequestType r );
+ void clearRequest();
+ bool requested();
+
+ void finishSelection();
+
+ void setPlugin( KuDesignerPlugin *plugin );
+
+ void setCanvas( Canvas *canvas );
+
+protected:
+ void contentsMousePressEvent( QMouseEvent* );
+ void contentsMouseReleaseEvent( QMouseEvent* );
+ void contentsMouseMoveEvent( QMouseEvent* );
+ void contentsMouseDoubleClickEvent( QMouseEvent * );
+
+ void contentsDragEnterEvent ( QDragEnterEvent * );
+ void contentsDragMoveEvent ( QDragMoveEvent * );
+ // void contentsDragLeaveEvent ( QDragLeaveEvent * );
+ // void contentsDropEvent ( QDropEvent * );
+ void keyPressEvent( QKeyEvent * );
+
+ void startMoveOrResizeOrSelectItem( QCanvasItemList &l, QMouseEvent *e, QPoint &p );
+ bool startResizing( QMouseEvent *e, QPoint &p );
+ void placeItem( QCanvasItemList &l, QMouseEvent *e );
+ void editItem( QCanvasItemList &l );
+ void deleteItem( QCanvasItemList &l );
+ void selectItemFromList( QCanvasItemList &l );
+
+ void stickToGrid( double &x, double &y );
+ void stickDimToGrid( double x, double y, double &X, double &Y );
+
+private:
+ Buffer *selectionBuf;
+
+ ReportItem *moving;
+ QPoint moving_start;
+ double moving_offsetY;
+ double moving_offsetX;
+ QRect resizing_constraint;
+ QSize resizing_minSize;
+ int resizing_type;
+ class Box *resizing;
+ bool selectionStarted;
+
+ KuDesignerPlugin *m_plugin;
+
+ SelectionRect *selectionRect;
+
+ RequestType request;
+
+ Canvas *m_canvas;
+
+ void fixMinValues( double &pos, double minv, double &offset );
+ void fixMaxValues( double &pos, double size, double maxv, double &offset );
+
+signals: // Signals
+ /** Emitted when user clicks on the canvas, so a button
+ or a menu item assosiated with the selected item should
+ be unchecked. */
+ void selectedActionProcessed();
+ void selectedEditActionProcessed();
+ void modificationPerformed();
+
+ /** Emitted when selection is made, so that property editor can display properties
+ for the selected items. */
+ void selectionMade( Buffer *buf );
+ void selectionClear();
+ void changed();
+
+ void itemPlaced( int x, int y, int band, int bandLevel );
+
+public slots:
+ void updateProperty();
+
+ void selectItem();
+ void setGridSize( int size );
+};
+
+}
+
+#endif