diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-08-19 03:19:32 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-08-19 03:19:32 (GMT) |
commit | 9f7f71160053b64a23abc472d9d9ddd5d9bb8b3d (patch) | |
tree | 22f60abbc45a5ef8e1beab0af8d9980134d914ad /demos | |
parent | f792bae5b13ad68f846a2be1f002d8376f2daef8 (diff) | |
parent | af98f27a847688e53ab1d34b4a9c04bdc63fe3e1 (diff) | |
download | Qt-9f7f71160053b64a23abc472d9d9ddd5d9bb8b3d.zip Qt-9f7f71160053b64a23abc472d9d9ddd5d9bb8b3d.tar.gz Qt-9f7f71160053b64a23abc472d9d9ddd5d9bb8b3d.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Conflicts:
doc/src/index.qdoc
doc/src/topics.qdoc
src/gui/graphicsview/qgraphicsitem.cpp
src/gui/graphicsview/qgraphicsitem.h
src/gui/graphicsview/qgraphicsitem_p.h
tests/auto/auto.pro
Diffstat (limited to 'demos')
-rw-r--r-- | demos/browser/data/defaultbookmarks.xbel | 3 | ||||
-rw-r--r-- | demos/browser/xbel.cpp | 109 | ||||
-rw-r--r-- | demos/browser/xbel.h | 1 | ||||
-rw-r--r-- | demos/macmainwindow/macmainwindow.pro | 2 |
4 files changed, 40 insertions, 75 deletions
diff --git a/demos/browser/data/defaultbookmarks.xbel b/demos/browser/data/defaultbookmarks.xbel index 1d20ac0..dce5297 100644 --- a/demos/browser/data/defaultbookmarks.xbel +++ b/demos/browser/data/defaultbookmarks.xbel @@ -30,6 +30,9 @@ <bookmark href="http://xkcd.com/"> <title>xkcd</title> </bookmark> + <bookmark href="http://twitter.com/qtbynokia"> + <title>Twitter</title> + </bookmark> </folder> <folder folded="yes"> <title>Bookmarks Menu</title> diff --git a/demos/browser/xbel.cpp b/demos/browser/xbel.cpp index ed62868..66b49a4 100644 --- a/demos/browser/xbel.cpp +++ b/demos/browser/xbel.cpp @@ -133,16 +133,13 @@ BookmarkNode *XbelReader::read(QIODevice *device) { BookmarkNode *root = new BookmarkNode(BookmarkNode::Root); setDevice(device); - while (!atEnd()) { - readNext(); - if (isStartElement()) { - QString version = attributes().value(QLatin1String("version")).toString(); - if (name() == QLatin1String("xbel") - && (version.isEmpty() || version == QLatin1String("1.0"))) { - readXBEL(root); - } else { - raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); - } + if (readNextStartElement()) { + QString version = attributes().value(QLatin1String("version")).toString(); + if (name() == QLatin1String("xbel") + && (version.isEmpty() || version == QLatin1String("1.0"))) { + readXBEL(root); + } else { + raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); } } return root; @@ -152,21 +149,15 @@ void XbelReader::readXBEL(BookmarkNode *parent) { Q_ASSERT(isStartElement() && name() == QLatin1String("xbel")); - while (!atEnd()) { - readNext(); - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == QLatin1String("folder")) - readFolder(parent); - else if (name() == QLatin1String("bookmark")) - readBookmarkNode(parent); - else if (name() == QLatin1String("separator")) - readSeparator(parent); - else - skipUnknownElement(); - } + while (readNextStartElement()) { + if (name() == QLatin1String("folder")) + readFolder(parent); + else if (name() == QLatin1String("bookmark")) + readBookmarkNode(parent); + else if (name() == QLatin1String("separator")) + readSeparator(parent); + else + skipCurrentElement(); } } @@ -177,26 +168,19 @@ void XbelReader::readFolder(BookmarkNode *parent) BookmarkNode *folder = new BookmarkNode(BookmarkNode::Folder, parent); folder->expanded = (attributes().value(QLatin1String("folded")) == QLatin1String("no")); - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == QLatin1String("title")) - readTitle(folder); - else if (name() == QLatin1String("desc")) - readDescription(folder); - else if (name() == QLatin1String("folder")) - readFolder(folder); - else if (name() == QLatin1String("bookmark")) - readBookmarkNode(folder); - else if (name() == QLatin1String("separator")) - readSeparator(folder); - else - skipUnknownElement(); - } + while (readNextStartElement()) { + if (name() == QLatin1String("title")) + readTitle(folder); + else if (name() == QLatin1String("desc")) + readDescription(folder); + else if (name() == QLatin1String("folder")) + readFolder(folder); + else if (name() == QLatin1String("bookmark")) + readBookmarkNode(folder); + else if (name() == QLatin1String("separator")) + readSeparator(folder); + else + skipCurrentElement(); } } @@ -224,39 +208,18 @@ void XbelReader::readBookmarkNode(BookmarkNode *parent) Q_ASSERT(isStartElement() && name() == QLatin1String("bookmark")); BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark, parent); bookmark->url = attributes().value(QLatin1String("href")).toString(); - while (!atEnd()) { - readNext(); - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == QLatin1String("title")) - readTitle(bookmark); - else if (name() == QLatin1String("desc")) - readDescription(bookmark); - else - skipUnknownElement(); - } + while (readNextStartElement()) { + if (name() == QLatin1String("title")) + readTitle(bookmark); + else if (name() == QLatin1String("desc")) + readDescription(bookmark); + else + skipCurrentElement(); } if (bookmark->title.isEmpty()) bookmark->title = QObject::tr("Unknown title"); } -void XbelReader::skipUnknownElement() -{ - Q_ASSERT(isStartElement()); - - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) - skipUnknownElement(); - } -} - XbelWriter::XbelWriter() { diff --git a/demos/browser/xbel.h b/demos/browser/xbel.h index 2bdffe1..ec9008e 100644 --- a/demos/browser/xbel.h +++ b/demos/browser/xbel.h @@ -87,7 +87,6 @@ public: BookmarkNode *read(QIODevice *device); private: - void skipUnknownElement(); void readXBEL(BookmarkNode *parent); void readTitle(BookmarkNode *parent); void readDescription(BookmarkNode *parent); diff --git a/demos/macmainwindow/macmainwindow.pro b/demos/macmainwindow/macmainwindow.pro index f5165a7..ba6ffbb 100644 --- a/demos/macmainwindow/macmainwindow.pro +++ b/demos/macmainwindow/macmainwindow.pro @@ -12,7 +12,7 @@ build_all:!build_pass { CONFIG += release } -LIBS += -framework Cocoa +LIBS += -framework Cocoa -framework Carbon # install mac { |