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

List:       kde-commits
Subject:    koffice/kexi/plugins/reportspgz
From:       Adam Pigg <adam () piggz ! co ! uk>
Date:       2010-01-13 22:44:05
Message-ID: 1263422645.908676.14341.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1074360 by piggz:

Fix:
Switch between design/view mode
Loading/initialisation of report data
Dont crash on null report data

 M  +9 -26     kexireportdesignview.cpp  
 M  +13 -1     kexireportpart.cpp  
 M  +0 -1      kexireportpart.h  
 M  +6 -8      kexireportview.cpp  
 M  +5 -4      kexisourceselector.cpp  
 M  +8 -6      koreport/renderer/orprerender.cpp  
 M  +2 -5      koreport/renderer/orprerender.h  
 M  +6 -2      koreport/wrtembed/reportdesigner.cpp  


--- trunk/koffice/kexi/plugins/reportspgz/kexireportdesignview.cpp #1074359:1074360
@@ -131,7 +131,12 @@
     kDebug() << mode;
     dontStore = true;
     if (m_reportDesigner && mode == Kexi::DataViewMode) {
+	kDebug() << "Saving temp data";
+	
         tempData()->reportDefinition = m_reportDesigner->document();
+	
+	kDebug() << m_reportDesigner->document().toDocument().toString();
+	
         tempData()->reportSchemaChangedInPreviousView = true;
     }
     return true;
@@ -141,8 +146,7 @@
 {
     Q_UNUSED(mode);
 
-    kDebug() << tempData()->document;
-    if (tempData()->document.isEmpty()) {
+    if (tempData()->reportDefinition.isNull()) {
         m_reportDesigner = new ReportDesigner(this);
     } else {
         if (m_reportDesigner) {
@@ -151,33 +155,12 @@
             m_reportDesigner = 0;
         }
 
-        QDomDocument doc;
-        doc.setContent(tempData()->document);
-        QDomElement root = doc.documentElement();
-        QDomElement korep = root.firstChildElement("report:content");
-        QDomElement conn = root.firstChildElement("connection");
-        if (!korep.isNull()) {
-            m_reportDesigner = new ReportDesigner(this, korep);
-            if (!conn.isNull()) {
-                m_sourceSelector->setConnectionData(conn);
-            }
-        } else {
-            kDebug() << "no koreport section";
+        m_reportDesigner = new ReportDesigner(this, tempData()->reportDefinition);
+        m_sourceSelector->setConnectionData(tempData()->connectionDefinition);
+    } 
 
-            //TODO remove...just create a blank document
-            //Temp - allow load old style report definitions (no data)
-            root.setTagName("koreport");
-            m_reportDesigner = new ReportDesigner(this, root);
-        }
-    }
-
     m_scrollArea->setWidget(m_reportDesigner);
 
-    //plugSharedAction ( "edit_copy", _rd, SLOT ( slotEditCopy() ) );
-    //plugSharedAction ( "edit_cut", _rd, SLOT ( slotEditCut() ) );
-    //plugSharedAction ( "edit_paste", _rd, SLOT ( slotEditPaste() ) );
-    //plugSharedAction ( "edit_delete", _rd, SLOT ( slotEditDelete() ) );
-
     connect(m_reportDesigner, SIGNAL(propertySetChanged()), this, \
SLOT(slotDesignerPropertySetChanged()));  connect(m_reportDesigner, SIGNAL(dirty()), \
this, SLOT(setDirty()));  
--- trunk/koffice/kexi/plugins/reportspgz/kexireportpart.cpp #1074359:1074360
@@ -127,7 +127,19 @@
     kDebug();
     const QString document(loadReport(window->partItem()->name()));
     KexiReportPart::TempData *td = new KexiReportPart::TempData(window);
-    td->document = document;
+    
+    QDomDocument doc;
+    doc.setContent(document);
+    
+    kDebug() << doc.toString();
+    
+    QDomElement root = doc.documentElement();
+    QDomElement korep = root.firstChildElement("report:content");
+    QDomElement conn = root.firstChildElement("connection");
+
+    td->reportDefinition = korep;
+    td->connectionDefinition = conn;
+
     td->name = window->partItem()->name();
     return td;
 }
--- trunk/koffice/kexi/plugins/reportspgz/kexireportpart.h #1074359:1074360
@@ -59,7 +59,6 @@
     {
     public:
         TempData(QObject* parent);
-        QString document;
         QDomElement reportDefinition;
         QDomElement connectionDefinition;
 
--- trunk/koffice/kexi/plugins/reportspgz/kexireportview.cpp #1074359:1074360
@@ -222,17 +222,15 @@
 
     kDebug();
     if (tempData()->reportSchemaChangedInPreviousView) {
+	kDebug() << "Schema changed";
         delete m_preRenderer;
 
-        QDomDocument doc;
-        doc.setContent(tempData()->document);
-        QDomElement root = doc.documentElement();
-        QDomElement conn = root.firstChildElement("connection");
-
-        m_preRenderer = new ORPreRender(tempData()->document);
+	kDebug() << tempData()->reportDefinition.tagName();
+	
+        m_preRenderer = new ORPreRender(tempData()->reportDefinition);
         if (m_preRenderer->isValid()) {
-            if (!conn.isNull())  {
-                m_preRenderer->setSourceData(sourceData(conn));
+            if (!tempData()->connectionDefinition.isNull())  {
+                m_preRenderer->setSourceData(sourceData(tempData()->connectionDefinition));
  }
             m_preRenderer->setName(tempData()->name);
             m_currentPage = 1;
--- trunk/koffice/kexi/plugins/reportspgz/kexisourceselector.cpp #1074359:1074360
@@ -90,18 +90,17 @@
 
 void KexiSourceSelector::setConnectionData(QDomElement c)
 {
-    m_sourceType->setEditText(c.attribute("type"));
-
     if (c.attribute("type") == "internal") {
-        m_internalSource->setCurrentIndex(m_sourceType->findText(c.attribute("source")));
 +	m_sourceType->setCurrentIndex(m_sourceType->findData("internal"));
+        m_internalSource->setCurrentIndex(m_internalSource->findText(c.attribute("source")));
  }
 
     if (c.attribute("type") == "external") {
+	m_sourceType->setCurrentIndex(m_sourceType->findText("external"));
         m_externalSource->setText(c.attribute("source"));
     }
 
     emit(setData(sourceData()));
-
 }
 
 QDomElement KexiSourceSelector::connectionData()
@@ -132,6 +131,8 @@
         m_kexiMigrateData = 0;
     }
 
+    kDebug() << m_sourceType->itemData(m_sourceType->currentIndex()).toString();
+    
     if (m_sourceType->itemData(m_sourceType->currentIndex()).toString() == \
                "internal") {
         m_kexiDBData = new KexiDBReportData(m_internalSource->currentText(), \
m_conn);  return m_kexiDBData;
--- trunk/koffice/kexi/plugins/reportspgz/koreport/renderer/orprerender.cpp \
#1074359:1074360 @@ -70,7 +70,6 @@
     virtual ~ORPreRenderPrivate();
 
     bool m_valid;
-    QDomDocument m_docReport;
 
     KexiDB::Connection *m_conn;
 
@@ -831,7 +830,7 @@
 // ORPreRender
 //
 
-ORPreRender::ORPreRender(const QString & pDocument)
+ORPreRender::ORPreRender(const QDomElement & pDocument)
 {
     d = new ORPreRenderPrivate();
     setDom(pDocument);
@@ -1043,16 +1042,19 @@
     }
 }
 
-bool ORPreRender::setDom(const QString & docReport)
+bool ORPreRender::setDom(const QDomElement &docReport)
 {
-    kDebug() << docReport;
     if (d) {
         if (d->m_reportData)
             delete d->m_reportData;
         d->m_valid = false;
 
-        d->m_docReport.setContent(docReport);
-        d->m_reportData = new \
KRReportData(d->m_docReport.documentElement().firstChildElement("report:content")); \
+	if (docReport.tagName() != "report:content") { +		kDebug() << "report schema is \
invalid"; +		return false;
+	}
+	
+        d->m_reportData = new KRReportData(docReport);
         d->m_valid = d->m_reportData->isValid();
     }
     return isValid();
--- trunk/koffice/kexi/plugins/reportspgz/koreport/renderer/orprerender.h \
#1074359:1074360 @@ -46,7 +46,7 @@
 {
 public:
 //    ORPreRender(KexiDB::Connection*c = 0);
-    ORPreRender(const QString &);
+    ORPreRender(const QDomElement&);
 
     virtual ~ORPreRender();
 
@@ -55,9 +55,6 @@
 
     ORODocument * generate();
 
-
-//    KexiDB::Connection* database() const;
-
     /**
     @brief Set the name of the report so that it can be used internally by the \
                script engine
     */
@@ -69,7 +66,7 @@
 
 private:
     ORPreRenderPrivate* d;
-    bool setDom(const QString &);
+    bool setDom(const QDomElement &);
     QMap<QString, QObject*> m_scriptObjects;
 };
 
--- trunk/koffice/kexi/plugins/reportspgz/koreport/wrtembed/reportdesigner.cpp \
#1074359:1074360 @@ -222,6 +222,8 @@
         kDebug() << "root element was not <report:content>";;
     }
 
+    kDebug() << data.text();
+    
     deleteDetail();
 
     QDomNodeList nlist = data.childNodes();
@@ -409,8 +411,10 @@
 void ReportDesigner::setReportData(KoReportData* kodata)
 {
     kDebug();
-    m_kordata = kodata; m_conn = \
                static_cast<KexiDB::Connection*>(kodata->connection());
-    setModified(true);
+    if (kodata) {
+	m_kordata = kodata; m_conn = \
static_cast<KexiDB::Connection*>(kodata->connection()); +	setModified(true);
+    }
 }
 
 ReportSection * ReportDesigner::section(KRSectionData::Section s) const


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

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