From 83aef35cdd0ae5c046dcdd72d1d3e55b4e90b915 Mon Sep 17 00:00:00 2001 From: "David A. Cuadrado" Date: Sat, 22 Dec 2007 18:45:36 -0500 Subject: [PATCH] Fixed XDBMS --- src/dashserver/xdbms/table.cpp | 98 +++++++++++++++++++++++++++--------------- src/shell/documentviewer.cpp | 5 +++ src/shell/documentviewer.h | 1 + 3 files changed, 69 insertions(+), 35 deletions(-) diff --git a/src/dashserver/xdbms/table.cpp b/src/dashserver/xdbms/table.cpp index dc8a56a..a40df44 100644 --- a/src/dashserver/xdbms/table.cpp +++ b/src/dashserver/xdbms/table.cpp @@ -76,49 +76,48 @@ QString Table::Private::objectXml(const QString &id, const QString &klass) const if( !f.open(QIODevice::ReadOnly) ) return xml; - XmlReader reader(&f); - QXmlStreamWriter writer(&xml); - bool read = false; - int level = 0; - - while(!reader.atEnd() ) { - reader.readNext(); + XmlReader reader(&f); + QXmlStreamWriter writer(&xml); + bool read = false; + int level = 0; - if( reader.tokenType() == QXmlStreamReader::StartElement ) + while(!reader.atEnd() ) { - QString tagName = reader.name().toString(); + reader.readNext(); - if( tagName == "object" ) + if( reader.tokenType() == QXmlStreamReader::StartElement ) { - if( reader.attributes().value("id").toString() == id && reader.attributes().value("class").toString() == klass ) + QString tagName = reader.name().toString(); + + if( tagName == "object" ) { - read = true; + dfDebug << reader.attributes().value("class").toString(); + + if( reader.attributes().value("id").toString() == id && reader.attributes().value("class").toString() == klass ) + { + read = true; + } + + level++; } - - level++; } - - if( read && level >= 1 ) + else if( reader.tokenType() == QXmlStreamReader::EndElement ) { - writer.writeCurrentToken(reader); + QString tagName = reader.name().toString(); + + if( tagName == "object" ) + { + level--; + } } - } - else if( reader.tokenType() == QXmlStreamReader::EndElement ) - { - QString tagName = reader.name().toString(); - if( read && level >= 1) + if( read ) { writer.writeCurrentToken(reader); } - if( tagName == "object" ) - { - level--; - } - - if( level == 0) + if( read && level == 0) { read = false; break; @@ -191,6 +190,7 @@ bool Table::Private::removeObject(const QString &id) const bool read = true; bool modified = false; + int level = 0; while( !reader.atEnd() ) { @@ -201,10 +201,12 @@ bool Table::Private::removeObject(const QString &id) const if( !read ) break; QString localName = reader.name().toString(); - if( localName == "object" ) + if( localName == "object" && level == 0 ) { if( reader.attributes().value("id").toString() == id ) { + level++; + read = false; modified = true; break; @@ -240,7 +242,12 @@ bool Table::Private::removeObject(const QString &id) const } else { - if( reader.name().toString() == "object" ) + if( reader.name().toString() == "object" && !read ) + { + level--; + } + + if( level == 0 && !read) { read = true; } @@ -322,6 +329,9 @@ bool Table::addObject(const Object *object) bool Table::load(Object *object) const { QString id = object->id(); + + dfDebug << object->klass(); + if( id.isEmpty() ) return false; if( d->objects.contains(id) ) @@ -380,16 +390,34 @@ void Table::reload() QXmlStreamReader reader(&f); + int level = 0; + while(!reader.atEnd() ) { - if( reader.readNext() == QXmlStreamReader::StartElement ) + reader.readNext(); + + if( reader.tokenType() == QXmlStreamReader::StartElement ) { - if( reader.qualifiedName() == "object" ) + if( reader.name() == "object" ) { - QStringRef str = reader.attributes().value("id"); + if( level == 0 ) + { + QStringRef str = reader.attributes().value("id"); + + if( !str.isEmpty() ) + { + d->objects << str.toString(); + } + } - if( !str.isEmpty() ) - d->objects << str.toString(); + level++; + } + } + else if( reader.tokenType() == QXmlStreamReader::EndElement ) + { + if( reader.name() == "object" ) + { + level--; } } } diff --git a/src/shell/documentviewer.cpp b/src/shell/documentviewer.cpp index 279dd9c..ac271bc 100644 --- a/src/shell/documentviewer.cpp +++ b/src/shell/documentviewer.cpp @@ -79,6 +79,11 @@ YAMF::Drawing::View *DocumentViewer::view() return m_view; } +void DocumentViewer::update(const Dash::DataSource *, bool) +{ + m_view->paintArea()->photogram()->drawCurrentPhotogram(); +} + void DocumentViewer::reset() { m_view->setCurrentFrame(-1, -1, -1); diff --git a/src/shell/documentviewer.h b/src/shell/documentviewer.h index 070b67e..5ec18cc 100644 --- a/src/shell/documentviewer.h +++ b/src/shell/documentviewer.h @@ -49,6 +49,7 @@ class DocumentViewer : public QMainWindow, public Dash::Module YAMF::Drawing::View *view(); + virtual void update(const Dash::DataSource *datasource, bool undo = false); virtual void reset(); private: -- 2.11.4.GIT