[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/sharedkraft/src
From: Klaas Freitag <freitag () suse ! de>
Date: 2011-01-27 10:24:52
Message-ID: 20110127102452.8C8B6AC8BC () svn ! kde ! org
[Download RAW message or body]
SVN commit 1217449 by freitag:
- increased version
- xml document loading and saving
- new class documentindexer
- various stuff...
M +3 -1 CMakeLists.txt
U docdigestview.cpp
M +54 -8 docposition.cpp
M +6 -0 docposition.h
A documentindexer.cpp [License: UNKNOWN]
A documentindexer.h [License: UNKNOWN]
M +51 -14 documentsaverfile.cpp
M +8 -5 kraftdoc.cpp
M +5 -0 portal.cpp
M +5 -3 version.h
--- branches/work/sharedkraft/src/CMakeLists.txt #1217448:1217449
@@ -1,7 +1,7 @@
include_directories(${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} \
${CMAKE_CURRENT_BINARY_DIR} ${KDEPIMLIBS_INCLUDE_DIRS})
-add_subdirectory(pics)
+add_subdirectory(pics kode)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}" )
@@ -145,6 +145,8 @@
impviewwidgets.cpp
addressselection.cpp
setupassistant.cpp
+ kode/document.cpp
+ documentindexer.cpp
)
kde4_add_kcfg_files(kraft_SRCS databasesettings.kcfgc kraftsettings.kcfgc)
--- branches/work/sharedkraft/src/docposition.cpp #1217448:1217449
@@ -35,6 +35,7 @@
/**
@author Klaas Freitag
*/
+const QStringList DocPositionBase::TaxTypes = QStringList() << "Ambigous" << "NoTax" \
<< "ReducedTax" << "FullTax";
DocPositionBase::DocPositionBase() : QObject(),
m_dbId( -1 ),
@@ -45,6 +46,7 @@
{
+
}
DocPositionBase::DocPositionBase( const PositionType& t )
@@ -203,6 +205,23 @@
return 0; // Invalid
}
+QString DocPositionBase::taxTypeString()
+{
+ return TaxTypes.at( taxTypeNumeric( ));
+}
+
+void DocPositionBase::setTaxTypeFromString( const QString& type )
+{
+ int pos = TaxTypes.indexOf( type );
+ mTaxType = TaxInvalid;
+ if( pos > 0 && pos < 4 ) {
+ if( pos == 1 ) mTaxType = TaxNone;
+ if( pos == 2 ) mTaxType = TaxReduced;
+ if( pos == 3 ) mTaxType = TaxFull;
+ }
+}
+
+
// ##############################################################
const QString DocPosition::Kind( QString::fromLatin1( "kind" ) );
@@ -400,17 +419,51 @@
posElem.appendChild( xmlTextElement( doc, "amount", h ));
Einheit e = dp->unit();
- posElem.appendChild( xmlTextElement( doc, "unit", e.einheit( am ) ) );
+ posElem.appendChild( xmlTextElement( doc, "unit", e.einheitSingular() ) );
+ posElem.appendChild( xmlTextElement( doc, "taxType", dp->taxTypeString() ) );
Geld g = dp->unitPrice();
posElem.appendChild( xmlTextElement( doc, "unitprice", \
QString::number(g.toDouble())) ); g = Geld( g*am );
posElem.appendChild( xmlTextElement( doc, "sumprice", QString::number( \
g.toDouble()))); +
+ // attribute list
+ if( ! dp->attributes().isEmpty() ) {
+ QDomElement attribTopElem = doc.createElement( "item_attributes" );
+ posElem.appendChild( attribTopElem );
+ foreach( Attribute attrib, dp->attributes() ) {
+ QDomElement attribElem = doc.createElement( "item_attribute");
+ attribElem.setAttribute( "name", attrib.name() );
+ attribTopElem.appendChild( attribElem );
+ QDomText t = doc.createTextNode( attrib.value().toString() );
+ attribElem.appendChild( t );
}
}
+#if 0
+ // tags are written as attributes, see code above.
+ QStringList tags = dp->tags();
+ if( ! tags.isEmpty() ) {
+ QDomElement tagTopElem = doc.createElement( "tags" );
+ posElem.appendChild( tagTopElem );
+ foreach( QString tag, tags ) {
+ tagTopElem.appendChild( xmlTextElement( doc, "tag", tag ) );
+ }
+ }
+#endif
+ }
+ }
return topElem;
}
+
+QDomElement DocPositionList::xmlTextElement( QDomDocument& doc, const QString& name, \
const QString& value ) +{
+ QDomElement elem = doc.createElement( name );
+ QDomText t = doc.createTextNode( value );
+ elem.appendChild( t );
+ return elem;
+}
+
int DocPositionList::compareItems ( DocPosition *dp1, DocPosition *dp2 )
{
//DocPositionBase *dpb1 = static_cast<DocPositionBase*>( item1 );
@@ -428,13 +481,6 @@
}
-QDomElement DocPositionList::xmlTextElement( QDomDocument& doc, const QString& name, \
const QString& value )
-{
- QDomElement elem = doc.createElement( name );
- QDomText t = doc.createTextNode( value );
- elem.appendChild( t );
- return elem;
-}
DocPositionBase *DocPositionList::positionFromId( int id )
{
--- branches/work/sharedkraft/src/docposition.h #1217448:1217449
@@ -74,6 +74,10 @@
QStringList tags();
int taxTypeNumeric();
+
+ QString taxTypeString();
+ void setTaxTypeFromString( const QString& );
+
void setTaxType( DocPositionBase::TaxType );
/**
@@ -95,6 +99,8 @@
TaxType mTaxType;
PositionType mType;
AttributeMap mAttribs;
+
+ static const QStringList TaxTypes;
};
--- branches/work/sharedkraft/src/documentsaverfile.cpp #1217448:1217449
@@ -16,11 +16,14 @@
***************************************************************************/
#include "documentsaverfile.h"
#include "kraftdoc.h"
+#include "kode/document.h"
+#include "unitmanager.h"
#include <KDebug>
#include <QTextStream>
#include <QFile>
+using namespace Kode;
DocumentSaverFile::DocumentSaverFile()
{
@@ -29,25 +32,59 @@
void DocumentSaverFile::load( const QString& id, KraftDoc* doc )
{
if( ! doc ) return ;
-#if 0
- QString errorStr;
- int errorLine;
- int errorColumn;
- if (!domDocument.setContent(device, true, &errorStr, &errorLine,
- &errorColumn)) {
- QMessageBox::information(window(), tr("DOM Bookmarks"),
- tr("Parse error at line %1, column %2:\n%3")
- .arg(errorLine)
- .arg(errorColumn)
- .arg(errorStr));
- return false;
+ bool ok;
+ // use the kxml_compiler generated parsing code to parse the xml file.
+ // after thats finished, set the values in the doc from the parsing result \
classes. +
+ Kraftdocument xmldoc = Kraftdocument::parseFile( mFileName, &ok );
+ if( ! ok ) {
+ kDebug() << "ERR: Document loading failed for id " << id;
+ return;
}
- QDomElement root = domDocument.documentElement();
-#endif
+ doc->setAddress( xmldoc.client().address() );
+ doc->setAddressUid( xmldoc.client().clientId() );
+ doc->setCountryLanguage( xmldoc.docframe().country(), xmldoc.docframe().language() \
); + doc->setDate( QDate::fromString( xmldoc.docframe().date(), Qt::ISODate ) );
+ doc->setDocID( -1 );
+ doc->setDocType( xmldoc.docframe().docType() );
+ doc->setGoodbye( xmldoc.docframe().goodbye() );
+ doc->setIdent( xmldoc.docframe().ident() );
+ qint64 t = xmldoc.meta().lastModified().toLongLong( &ok );
+ QDateTime lm;
+ if( ok) lm.setMSecsSinceEpoch(t);
+ doc->setLastModified( lm );
+ doc->setModified( false );
+ doc->setPostText( xmldoc.docframe().postText() );
+ doc->setPreText( xmldoc.docframe().preText() );
+ doc->setProjectLabel( xmldoc.docframe().projectLabel() );
+ doc->setSalut( xmldoc.docframe().salut() );
+ doc->setWhiteboard( xmldoc.docframe().docDesc() );
+
+ Position::List posList = xmldoc.positions().positionList();
+
+ foreach( Position xmlPos, posList ) {
+ DocPosition *pos = new DocPosition();
+ bool ok;
+ double a = xmlPos.amount().toDouble( &ok );
+ if( ok ) pos->setAmount( a );
+ pos->setText( xmlPos.text() );
+ pos->setPositionNumber( xmlPos.number() );
+ Einheit e = UnitManager::self()->getUnitIDSingular( xmlPos.unit() );
+ pos->setUnit(e);
+ QString tt = "foobar"; // xmlPos.taxType();
+ pos->setTaxTypeFromString( tt );
+
+ ItemAttribute::List xmlAttrList = xmlPos.itemAttributes().itemAttributeList();
+ foreach( ItemAttribute xmlAttr, xmlAttrList ) {
+ Attribute attr( xmlAttr.name() );
+ attr.setValue( xmlAttr.value() );
+ pos->setAttribute( attr);
}
+ }
+}
void DocumentSaverFile::setFilename( const QString& name )
{
--- branches/work/sharedkraft/src/kraftdoc.cpp #1217448:1217449
@@ -40,6 +40,7 @@
#include "defaultprovider.h"
#include "documentman.h"
#include "kraftsettings.h"
+#include "version.h"
// FIXME: Make KraftDoc inheriting DocDigest!
@@ -330,8 +331,7 @@
DocumentSaverBase* KraftDoc::getSaver( const QString& )
{
- if( ! mSaver )
- {
+ if( ! mSaver ) {
kDebug() << "Create new Document DB-Saver" << endl;
DocumentSaverFile *saver = new DocumentSaverFile();
@@ -422,7 +422,7 @@
{
QDomDocument xmldoc( "kraftdocument" );
QDomElement root = xmldoc.createElement( "kraftdocument" );
- root.setAttribute( "xmlSchemaVersion", 1.0 );
+ root.setAttribute( "xmlSchemaVersion", KRAFT_DOC_XML_SCHEMA_VERSION );
// Fixme:
xmldoc.appendChild( root );
QDomElement cust = xmldoc.createElement( "client" );
@@ -440,13 +440,16 @@
docElem.appendChild( xmlTextElement( xmldoc, "currency", \
locale()->currencyCode() ) ); docElem.appendChild( xmlTextElement( xmldoc, \
"docType", docType() ) ); docElem.appendChild( xmlTextElement( xmldoc, \
"docDesc", whiteboard() ) );
- docElem.appendChild( xmlTextElement( xmldoc, "ident", ident() ) );
+ QString id = ident();
+ if( id.isEmpty() ) id = "unspec";
+ docElem.appendChild( xmlTextElement( xmldoc, "ident", id ) );
docElem.appendChild( xmlTextElement( xmldoc, "preText", preText() ) );
docElem.appendChild( xmlTextElement( xmldoc, "postText", postText() ) );
docElem.appendChild( xmlTextElement( xmldoc, "projectLabel", projectLabel() ) );
docElem.appendChild( xmlTextElement( xmldoc, "salut", salut() ) );
docElem.appendChild( xmlTextElement( xmldoc, "goodbye", goodbye() ) );
-
+ docElem.appendChild( xmlTextElement( xmldoc, "country", country() ) );
+ docElem.appendChild( xmlTextElement( xmldoc, "language", language() ) );
docElem.appendChild( xmlTextElement( xmldoc, "date", date().toString( Qt::ISODate \
) ) ); root.appendChild( positions().domElement( xmldoc ) );
--- branches/work/sharedkraft/src/portal.cpp #1217448:1217449
@@ -73,6 +73,7 @@
#include "kraftview_ro.h"
#include "databasesettings.h"
#include "setupassistant.h"
+#include "documentindexer.h"
#define ID_STATUS_MSG 1
@@ -364,6 +365,10 @@
doc->setAddressUid( wiz.addressUid() );
doc->setDocType( wiz.docType() );
doc->setWhiteboard( wiz.whiteboard() );
+
+ DocumentIndexer indexer;
+ indexer.indexNewDoc( doc );
+
createView( doc );
}
slotStatusMsg(i18n("Ready."));
--- branches/work/sharedkraft/src/version.h #1217448:1217449
@@ -1,7 +1,9 @@
#define KPLANT_VERSION "0.4"
-#define KRAFT_VERSION "0.41"
+#define KRAFT_VERSION "0.42"
-#define KRAFT_CODENAME "Tiddler"
+#define KRAFT_DOC_XML_SCHEMA_VERSION "1.0"
-#define KRAFT_REQUIRED_SCHEMA_VERSION 18
+#define KRAFT_CODENAME "Share your Kraft"
+#define KRAFT_REQUIRED_SCHEMA_VERSION 19
+
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic