Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/demos/browser/xbel.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the demonstration applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    134134    BookmarkNode *root = new BookmarkNode(BookmarkNode::Root);
    135135    setDevice(device);
    136     while (!atEnd()) {
    137         readNext();
    138         if (isStartElement()) {
    139             QString version = attributes().value(QLatin1String("version")).toString();
    140             if (name() == QLatin1String("xbel")
    141                 && (version.isEmpty() || version == QLatin1String("1.0"))) {
    142                 readXBEL(root);
    143             } else {
    144                 raiseError(QObject::tr("The file is not an XBEL version 1.0 file."));
    145             }
     136    if (readNextStartElement()) {
     137        QString version = attributes().value(QLatin1String("version")).toString();
     138        if (name() == QLatin1String("xbel")
     139            && (version.isEmpty() || version == QLatin1String("1.0"))) {
     140            readXBEL(root);
     141        } else {
     142            raiseError(QObject::tr("The file is not an XBEL version 1.0 file."));
    146143        }
    147144    }
     
    153150    Q_ASSERT(isStartElement() && name() == QLatin1String("xbel"));
    154151
    155     while (!atEnd()) {
    156         readNext();
    157         if (isEndElement())
    158             break;
    159 
    160         if (isStartElement()) {
    161             if (name() == QLatin1String("folder"))
    162                 readFolder(parent);
    163             else if (name() == QLatin1String("bookmark"))
    164                 readBookmarkNode(parent);
    165             else if (name() == QLatin1String("separator"))
    166                 readSeparator(parent);
    167             else
    168                 skipUnknownElement();
    169         }
     152    while (readNextStartElement()) {
     153        if (name() == QLatin1String("folder"))
     154            readFolder(parent);
     155        else if (name() == QLatin1String("bookmark"))
     156            readBookmarkNode(parent);
     157        else if (name() == QLatin1String("separator"))
     158            readSeparator(parent);
     159        else
     160            skipCurrentElement();
    170161    }
    171162}
     
    178169    folder->expanded = (attributes().value(QLatin1String("folded")) == QLatin1String("no"));
    179170
    180     while (!atEnd()) {
    181         readNext();
    182 
    183         if (isEndElement())
    184             break;
    185 
    186         if (isStartElement()) {
    187             if (name() == QLatin1String("title"))
    188                 readTitle(folder);
    189             else if (name() == QLatin1String("desc"))
    190                 readDescription(folder);
    191             else if (name() == QLatin1String("folder"))
    192                 readFolder(folder);
    193             else if (name() == QLatin1String("bookmark"))
    194                 readBookmarkNode(folder);
    195             else if (name() == QLatin1String("separator"))
    196                 readSeparator(folder);
    197             else
    198                 skipUnknownElement();
    199         }
     171    while (readNextStartElement()) {
     172        if (name() == QLatin1String("title"))
     173            readTitle(folder);
     174        else if (name() == QLatin1String("desc"))
     175            readDescription(folder);
     176        else if (name() == QLatin1String("folder"))
     177            readFolder(folder);
     178        else if (name() == QLatin1String("bookmark"))
     179            readBookmarkNode(folder);
     180        else if (name() == QLatin1String("separator"))
     181            readSeparator(folder);
     182        else
     183            skipCurrentElement();
    200184    }
    201185}
     
    225209    BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark, parent);
    226210    bookmark->url = attributes().value(QLatin1String("href")).toString();
    227     while (!atEnd()) {
    228         readNext();
    229         if (isEndElement())
    230             break;
    231 
    232         if (isStartElement()) {
    233             if (name() == QLatin1String("title"))
    234                 readTitle(bookmark);
    235             else if (name() == QLatin1String("desc"))
    236                 readDescription(bookmark);
    237             else
    238                 skipUnknownElement();
    239         }
     211    while (readNextStartElement()) {
     212        if (name() == QLatin1String("title"))
     213            readTitle(bookmark);
     214        else if (name() == QLatin1String("desc"))
     215            readDescription(bookmark);
     216        else
     217            skipCurrentElement();
    240218    }
    241219    if (bookmark->title.isEmpty())
    242220        bookmark->title = QObject::tr("Unknown title");
    243 }
    244 
    245 void XbelReader::skipUnknownElement()
    246 {
    247     Q_ASSERT(isStartElement());
    248 
    249     while (!atEnd()) {
    250         readNext();
    251 
    252         if (isEndElement())
    253             break;
    254 
    255         if (isStartElement())
    256             skipUnknownElement();
    257     }
    258221}
    259222
Note: See TracChangeset for help on using the changeset viewer.