Changeset 561 for trunk/examples/xml/streambookmarks
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/examples/xml/streambookmarks/frank.xbel
r2 r561 72 72 <folder folded="no"> 73 73 <title>Qt</title> 74 <bookmark href="http:// doc.trolltech.com/2.3/">74 <bookmark href="http:///2.3/"> 75 75 <title>Qt 2.3 Reference</title> 76 76 </bookmark> 77 <bookmark href="http:// doc.trolltech.com/3.3/">77 <bookmark href="http:///3.3/"> 78 78 <title>Qt 3.3 Reference</title> 79 79 </bookmark> 80 <bookmark href="http:// doc.trolltech.com/4.0/">80 <bookmark href="http:///4.0/"> 81 81 <title>Qt 4.0 Reference</title> 82 82 </bookmark> 83 <bookmark href="http://qt software.com/">84 <title> TrolltechHome Page</title>83 <bookmark href="http://qt.com/"> 84 <title> Home Page</title> 85 85 </bookmark> 86 86 </folder> -
trunk/examples/xml/streambookmarks/jennifer.xbel
r2 r561 5 5 <title>Qt Resources</title> 6 6 <folder folded="yes"> 7 <title> TrolltechPartners</title>7 <title> Partners</title> 8 8 <bookmark href="http://partners.trolltech.com/partners/training.html"> 9 9 <title>Training Partners</title> … … 46 46 </bookmark> 47 47 </folder> 48 <bookmark href="http:// doc.trolltech.com/qq/">48 <bookmark href="http:///qq/"> 49 49 <title>Qt Quarterly</title> 50 50 </bookmark> 51 <bookmark href="http://qt software.com/">52 <title> Trolltech'shome page</title>51 <bookmark href="http://qt.com/"> 52 <title> home page</title> 53 53 </bookmark> 54 <bookmark href="http:// doc.trolltech.com/4.0/">54 <bookmark href="http:///4.0/"> 55 55 <title>Qt 4.0 documentation</title> 56 56 </bookmark> 57 <bookmark href="http://qt software.com/developer/faqs/">57 <bookmark href="http://qt.com/developer/faqs/"> 58 58 <title>Frequently Asked Questions</title> 59 59 </bookmark> -
trunk/examples/xml/streambookmarks/main.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/examples/xml/streambookmarks/mainwindow.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 92 92 if (!reader.read(&file)) { 93 93 QMessageBox::warning(this, tr("QXmlStream Bookmarks"), 94 tr("Parse error in file %1 at line %2, column %3:\n%4")94 tr("Parse error in file %1") 95 95 .arg(fileName) 96 .arg(reader.lineNumber())97 .arg(reader.columnNumber())98 96 .arg(reader.errorString())); 99 97 } else { … … 142 140 { 143 141 openAct = new QAction(tr("&Open..."), this); 144 openAct->setShortcut (tr("Ctrl+O"));142 openAct->setShortcut); 145 143 connect(openAct, SIGNAL(triggered()), this, SLOT(open())); 146 144 147 145 saveAsAct = new QAction(tr("&Save As..."), this); 148 saveAsAct->setShortcut (tr("Ctrl+S"));146 saveAsAct->setShortcut); 149 147 connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); 150 148 151 149 exitAct = new QAction(tr("E&xit"), this); 152 exitAct->setShortcut (tr("Ctrl+Q"));150 exitAct->setShortcut); 153 151 connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); 154 152 -
trunk/examples/xml/streambookmarks/mainwindow.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** -
trunk/examples/xml/streambookmarks/streambookmarks.pro
r2 r561 13 13 sources.path = $$[QT_INSTALL_EXAMPLES]/xml/streambookmarks 14 14 INSTALLS += target sources 15 16 -
trunk/examples/xml/streambookmarks/xbelreader.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 61 61 bool XbelReader::read(QIODevice *device) 62 62 { 63 setDevice(device);63 setDevice(device); 64 64 65 while (!atEnd()) { 66 readNext(); 67 68 if (isStartElement()) { 69 if (name() == "xbel" && attributes().value("version") == "1.0") 70 readXBEL(); 71 else 72 raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); 73 } 65 if (xml.readNextStartElement()) { 66 if (xml.name() == "xbel" && xml.attributes().value("version") == "1.0") 67 readXBEL(); 68 else 69 xml.raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); 74 70 } 75 71 76 return ! error();72 return !error(); 77 73 } 78 74 //! [1] 79 75 80 76 //! [2] 81 void XbelReader::readUnknownElement() 77 QString XbelReader::errorString() const 82 78 { 83 Q_ASSERT(isStartElement()); 84 85 while (!atEnd()) { 86 readNext(); 87 88 if (isEndElement()) 89 break; 90 91 if (isStartElement()) 92 readUnknownElement(); 93 } 79 return QObject::tr("%1\nLine %2, column %3") 80 .arg(xml.errorString()) 81 .arg(xml.lineNumber()) 82 .arg(xml.columnNumber()); 94 83 } 95 84 //! [2] … … 98 87 void XbelReader::readXBEL() 99 88 { 100 Q_ASSERT( isStartElement() &&name() == "xbel");89 Q_ASSERT(name() == "xbel"); 101 90 102 while (!atEnd()) { 103 readNext(); 104 105 if (isEndElement()) 106 break; 107 108 if (isStartElement()) { 109 if (name() == "folder") 110 readFolder(0); 111 else if (name() == "bookmark") 112 readBookmark(0); 113 else if (name() == "separator") 114 readSeparator(0); 115 else 116 readUnknownElement(); 117 } 91 while (xml.readNextStartElement()) { 92 if (xml.name() == "folder") 93 readFolder(0); 94 else if (xml.name() == "bookmark") 95 readBookmark(0); 96 else if (xml.name() == "separator") 97 readSeparator(0); 98 else 99 xml.skipCurrentElement(); 118 100 } 119 101 } … … 123 105 void XbelReader::readTitle(QTreeWidgetItem *item) 124 106 { 125 Q_ASSERT( isStartElement() &&name() == "title");107 Q_ASSERT(name() == "title"); 126 108 127 QString title = readElementText();109 QString title = readElementText(); 128 110 item->setText(0, title); 129 111 } … … 133 115 void XbelReader::readSeparator(QTreeWidgetItem *item) 134 116 { 117 118 135 119 QTreeWidgetItem *separator = createChildItem(item); 136 120 separator->setFlags(item->flags() & ~Qt::ItemIsSelectable); 137 121 separator->setText(0, QString(30, 0xB7)); 138 readElementText();122 t(); 139 123 } 140 124 //! [5] … … 142 126 void XbelReader::readFolder(QTreeWidgetItem *item) 143 127 { 144 Q_ASSERT( isStartElement() &&name() == "folder");128 Q_ASSERT(name() == "folder"); 145 129 146 130 QTreeWidgetItem *folder = createChildItem(item); 147 bool folded = ( attributes().value("folded") != "no");131 bool folded = (attributes().value("folded") != "no"); 148 132 treeWidget->setItemExpanded(folder, !folded); 149 133 150 while (!atEnd()) { 151 readNext(); 152 153 if (isEndElement()) 154 break; 155 156 if (isStartElement()) { 157 if (name() == "title") 158 readTitle(folder); 159 else if (name() == "folder") 160 readFolder(folder); 161 else if (name() == "bookmark") 162 readBookmark(folder); 163 else if (name() == "separator") 164 readSeparator(folder); 165 else 166 readUnknownElement(); 167 } 134 while (xml.readNextStartElement()) { 135 if (xml.name() == "title") 136 readTitle(folder); 137 else if (xml.name() == "folder") 138 readFolder(folder); 139 else if (xml.name() == "bookmark") 140 readBookmark(folder); 141 else if (xml.name() == "separator") 142 readSeparator(folder); 143 else 144 xml.skipCurrentElement(); 168 145 } 169 146 } … … 171 148 void XbelReader::readBookmark(QTreeWidgetItem *item) 172 149 { 173 Q_ASSERT( isStartElement() &&name() == "bookmark");150 Q_ASSERT(name() == "bookmark"); 174 151 175 152 QTreeWidgetItem *bookmark = createChildItem(item); … … 177 154 bookmark->setIcon(0, bookmarkIcon); 178 155 bookmark->setText(0, QObject::tr("Unknown title")); 179 bookmark->setText(1, attributes().value("href").toString()); 180 while (!atEnd()) { 181 readNext(); 156 bookmark->setText(1, xml.attributes().value("href").toString()); 182 157 183 if (isEndElement()) 184 break; 185 186 if (isStartElement()) { 187 if (name() == "title") 188 readTitle(bookmark); 189 else 190 readUnknownElement(); 191 } 158 while (xml.readNextStartElement()) { 159 if (xml.name() == "title") 160 readTitle(bookmark); 161 else 162 xml.skipCurrentElement(); 192 163 } 193 164 } … … 201 172 childItem = new QTreeWidgetItem(treeWidget); 202 173 } 203 childItem->setData(0, Qt::UserRole, name().toString());174 childItem->setData(0, Qt::UserRole, name().toString()); 204 175 return childItem; 205 176 } -
trunk/examples/xml/streambookmarks/xbelreader.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 52 52 53 53 //! [0] 54 class XbelReader : public QXmlStreamReader54 class XbelReader 55 55 { 56 56 public: … … 61 61 bool read(QIODevice *device); 62 62 63 64 63 65 private: 64 66 //! [2] 65 void readUnknownElement();66 67 void readXBEL(); 67 68 void readTitle(QTreeWidgetItem *item); … … 72 73 QTreeWidgetItem *createChildItem(QTreeWidgetItem *item); 73 74 75 74 76 QTreeWidget *treeWidget; 75 77 //! [2] -
trunk/examples/xml/streambookmarks/xbelwriter.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 48 48 : treeWidget(treeWidget) 49 49 { 50 setAutoFormatting(true);50 setAutoFormatting(true); 51 51 } 52 52 //! [0] … … 55 55 bool XbelWriter::writeFile(QIODevice *device) 56 56 { 57 setDevice(device);57 setDevice(device); 58 58 59 writeStartDocument();60 writeDTD("<!DOCTYPE xbel>");61 writeStartElement("xbel");62 writeAttribute("version", "1.0");59 writeStartDocument(); 60 writeDTD("<!DOCTYPE xbel>"); 61 writeStartElement("xbel"); 62 writeAttribute("version", "1.0"); 63 63 for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) 64 64 writeItem(treeWidget->topLevelItem(i)); 65 65 66 writeEndDocument();66 writeEndDocument(); 67 67 return true; 68 68 } … … 75 75 if (tagName == "folder") { 76 76 bool folded = !treeWidget->isItemExpanded(item); 77 writeStartElement(tagName);78 writeAttribute("folded", folded ? "yes" : "no");79 writeTextElement("title", item->text(0));77 writeStartElement(tagName); 78 writeAttribute("folded", folded ? "yes" : "no"); 79 writeTextElement("title", item->text(0)); 80 80 for (int i = 0; i < item->childCount(); ++i) 81 81 writeItem(item->child(i)); 82 writeEndElement();82 writeEndElement(); 83 83 } else if (tagName == "bookmark") { 84 writeStartElement(tagName);84 writeStartElement(tagName); 85 85 if (!item->text(1).isEmpty()) 86 writeAttribute("href", item->text(1));87 writeTextElement("title", item->text(0));88 writeEndElement();86 writeAttribute("href", item->text(1)); 87 writeTextElement("title", item->text(0)); 88 writeEndElement(); 89 89 } else if (tagName == "separator") { 90 writeEmptyElement(tagName);90 writeEmptyElement(tagName); 91 91 } 92 92 } -
trunk/examples/xml/streambookmarks/xbelwriter.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the examples of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 51 51 52 52 //! [0] 53 class XbelWriter : public QXmlStreamWriter53 class XbelWriter 54 54 { 55 55 public: … … 59 59 private: 60 60 void writeItem(QTreeWidgetItem *item); 61 61 62 QTreeWidget *treeWidget; 62 63 };
Note:
See TracChangeset
for help on using the changeset viewer.