[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kexi/plugins/reportspgz/backend
From:       Adam Pigg <adam () piggz ! co ! uk>
Date:       2008-04-21 22:03:44
Message-ID: 1208815424.904629.30394.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 799573 by piggz:

Start the chart renderer....kinda works but size is wrong

 M  +3 -4      common/krchartdata.h  
 M  +24 -26    common/krsectiondata.cpp  
 M  +15 -38    renderer/orprerender.cpp  


--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krchartdata.h #799572:799573
@@ -42,7 +42,9 @@
 		~KRChartData();
 		virtual KRChartData * toChart();
 		virtual int type() const;
-	
+		KDChart::Widget *widget(){return _chartWidget;}
+		void populateData();
+		void setConnection(KexiDB::Connection*);
 	protected:
 		
 		KRPos _pos;
@@ -71,9 +73,6 @@
 		void setColorScheme ( const QString & );
 		void setAxis();
 		
-		
-		void populateData();
-		void setConnection(KexiDB::Connection*);
 		QStringList fieldNames(const QString &);
 		QStringList fieldNamesHackUntilImprovedParser(const QString &);
 		
--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krsectiondata.cpp \
#799572:799573 @@ -33,28 +33,29 @@
 #include "krbarcodedata.h"
 #include "krimagedata.h"
 #include "krlabeldata.h"
+#include "krchartdata.h"
 
 KRSectionData::KRSectionData()
 {
 	createProperties();
 }
 
-KRSectionData::KRSectionData ( const QDomElement & elemSource)
+KRSectionData::KRSectionData ( const QDomElement & elemSource )
 {
 	createProperties();
 	_name = elemSource.tagName();
 	setObjectName ( _name );
-	
+
 	if ( _name != "rpthead" && _name != "rptfoot" &&
-		    _name != "pghead" && _name != "pgfoot" &&
-		    _name != "grouphead" && _name != "groupfoot" &&
-		    _name != "head" && _name != "foot" &&
-		    _name != "detail" )
+	        _name != "pghead" && _name != "pgfoot" &&
+	        _name != "grouphead" && _name != "groupfoot" &&
+	        _name != "head" && _name != "foot" &&
+	        _name != "detail" )
 	{
 		_valid = false;
 		return;
 	}
-	_height->setValue(1);
+	_height->setValue ( 1 );
 
 	QDomNodeList section = elemSource.childNodes();
 	for ( int nodeCounter = 0; nodeCounter < section.count(); nodeCounter++ )
@@ -65,11 +66,11 @@
 			bool valid;
 			qreal height = elemThis.text().toDouble ( &valid );
 			if ( valid )
-				_height->setValue( height );
+				_height->setValue ( height );
 		}
 		else if ( elemThis.tagName() == "bgcolor" )
 		{
-			_bgColor->setValue( QColor ( elemThis.text() ) );
+			_bgColor->setValue ( QColor ( elemThis.text() ) );
 		}
 		else if ( elemThis.tagName() == "firstpage" )
 		{
@@ -125,26 +126,23 @@
 		{
 			KRBarcodeData * bc = new KRBarcodeData ( elemThis );
 			_objects.append ( bc );
-			
+
 		}
 		else if ( elemThis.tagName() == "image" )
 		{
 			KRImageData * img = new KRImageData ( elemThis );
 			_objects.append ( img );
 		}
-		//TODO Graph
-		//else if(elemThis.tagName() == "graph")
-		//{
-		//  ORGraphData * graph = new ORGraphData();
-		//  if(parseReportGraphData(elemThis, *graph) == TRUE)
-		//   sectionTarget.objects.append(graph);
-		//  else
-		//    delete graph;
-		//}
+		else if ( elemThis.tagName() == "chart" )
+		{
+			KRChartData * chart = new KRChartData ( elemThis );
+			_objects.append ( chart );
+
+		}
 		else
 			kDebug() << "While parsing section encountered an unknown element: " << \
elemThis.tagName() << endl;  }
-	qSort (_objects.begin(),_objects.end(), zLessThan );
+	qSort ( _objects.begin(),_objects.end(), zLessThan );
 	_valid = true;
 }
 
@@ -153,7 +151,7 @@
 
 }
 
-bool KRSectionData::zLessThan(KRObjectData* s1, KRObjectData* s2)
+bool KRSectionData::zLessThan ( KRObjectData* s1, KRObjectData* s2 )
 {
 	return s1->Z < s2->Z;
 }
@@ -161,15 +159,15 @@
 void KRSectionData::createProperties()
 {
 	_set = new KoProperty::Set ( 0, "Section" );
-	
-	_height = new KoProperty::Property ( "Height", 1.0, "Height", "Height");
+
+	_height = new KoProperty::Property ( "Height", 1.0, "Height", "Height" );
 	_bgColor = new KoProperty::Property ( "BackgroundColor", Qt::white, "Background \
                Color", "Background Color" );
-	
+
 	_set->addProperty ( _height );
 	_set->addProperty ( _bgColor );
 }
 
 QString KRSectionData::name() const
 {
-	return (_extra.isEmpty() ? _name : _name + "_" + _extra);
-}
\ No newline at end of file
+	return ( _extra.isEmpty() ? _name : _name + "_" + _extra );
+}
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/orprerender.cpp \
#799572:799573 @@ -42,6 +42,8 @@
 #include <krimagedata.h>
 #include <krlabeldata.h>
 #include <krlinedata.h>
+#include <krchartdata.h>
+
 #include "scripting/krscripthandler.h"
 #include <krreportdata.h>
 #include <krdetailsectiondata.h>
@@ -836,47 +838,22 @@
 			id->setSize ( size );
 			_page->addPrimitive ( id );
 		}
-//TODO Graphs
-#if 0
-		else if ( elemThis->isGraph() )
+		else if ( elemThis->type() == KRObjectData::EntityChart )
 		{
-			ORGraphData * gData = elemThis->toGraph();
-
-			QPointF pos = gData->rect.topLeft();
-			QSizeF size = gData->rect.size();
-			pos /= 100.0;
+			KRChartData * ch = elemThis->toChart();
+			ch->setConnection(_conn);
+			ch->populateData();
+			OROImage * id = new OROImage();
+			id->setImage ( QPixmap::grabWidget ( ch->widget() ).toImage() );
+			QPointF pos = ch->_pos.toScene();
+			QSizeF size = ch->_size.toScene();
+			
 			pos += QPointF ( _leftMargin, _yOffset );
-			size /= 100.0;
-
-			QRect rect = QRect ( QPoint ( 0, 0 ), gData->rect.size() );
-
-// What we are doing here is we are creating an image assuming the original
-// 100dpi to render the graph to. All the original code is usable this way
-// as we just need to setup a painter for the image and pass that along to
-// the graph drawing code.
-			QImage gImage ( rect.size(), QImage::Format_RGB32 );
-			gImage.setDotsPerMeterX ( 3937 ); // should be 100dpi
-			gImage.setDotsPerMeterY ( 3937 ); // should be 100dpi
-			QPainter gPainter;
-			if ( gPainter.begin ( &gImage ) )
-			{
-				gPainter.fillRect ( rect, QColor ( Qt::white ) );
-				gPainter.setPen ( Qt::black );
-				//renderGraph(gPainter, rect, *gData, \
                getQuerySource(gData->data.query)->getQuery(), _colorMap);
-				gPainter.end();
-
-				OROImage * id = new OROImage();
-				id->setImage ( gImage );
-				id->setPosition ( pos );
-				id->setSize ( size );
-				id->setScaled ( true );
-				id->setAspectRatioMode ( Qt::KeepAspectRatio );
-				id->setTransformationMode ( Qt::SmoothTransformation );
-				_page->addPrimitive ( id );
-
-			}
+			
+			id->setPosition ( pos );
+			id->setSize ( size );
+			_page->addPrimitive ( id );
 		}
-#endif
 		else
 		{
 			//logMessage("Encountered and unknown element while rendering a section.");


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic