From e4b0bd28cb6e303a9ded09537fde8a3ee5c34332 Mon Sep 17 00:00:00 2001
From: kh <qtc-committer@nokia.com>
Date: Wed, 8 Jul 2009 15:03:40 +0200
Subject: [PATCH] Implement import - export of help bookmarks.

Task-number: 254695
---
 src/plugins/help/generalsettingspage.cpp |  51 +++++-
 src/plugins/help/generalsettingspage.h   |   8 +-
 src/plugins/help/generalsettingspage.ui  |  86 ++++++++-
 src/plugins/help/help.pro                |   6 +-
 src/plugins/help/helpplugin.cpp          |   4 +-
 src/plugins/help/images/bookmark.png     | Bin 913 -> 1266 bytes
 src/plugins/help/xbelsupport.cpp         | 222 +++++++++++++++++++++++
 src/plugins/help/xbelsupport.h           |  81 +++++++++
 8 files changed, 451 insertions(+), 7 deletions(-)
 create mode 100644 src/plugins/help/xbelsupport.cpp
 create mode 100644 src/plugins/help/xbelsupport.h

diff --git a/src/plugins/help/generalsettingspage.cpp b/src/plugins/help/generalsettingspage.cpp
index 5dbd91d9dbf..61a93ba8518 100644
--- a/src/plugins/help/generalsettingspage.cpp
+++ b/src/plugins/help/generalsettingspage.cpp
@@ -29,8 +29,10 @@
 
 #include "generalsettingspage.h"
 
+#include "bookmarkmanager.h"
 #include "centralwidget.h"
 #include "helpviewer.h"
+#include "xbelsupport.h"
 
 #if defined(QT_NO_WEBKIT)
 #include <QtGui/QApplication>
@@ -38,6 +40,8 @@
 #include <QtWebKit/QWebSettings>
 #endif
 
+#include <QtCore/QDebug>
+#include <QtGui/QFileDialog>
 #include <QtHelp/QHelpEngine>
 
 #include <coreplugin/coreconstants.h>
@@ -45,10 +49,11 @@
 using namespace Help::Internal;
 
 GeneralSettingsPage::GeneralSettingsPage(QHelpEngine *helpEngine,
-        CentralWidget *centralWidget)
+        CentralWidget *centralWidget, BookmarkManager *bookmarkManager)
     : m_currentPage(0)
     , m_helpEngine(helpEngine)
     , m_centralWidget(centralWidget)
+    , m_bookmarkManager(bookmarkManager)
 {
 #if !defined(QT_NO_WEBKIT)
     QWebSettings* webSettings = QWebSettings::globalSettings();
@@ -114,6 +119,10 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent)
     if (viewer == 0)
         m_ui.currentPageButton->setEnabled(false);
 
+    m_ui.errorLabel->setVisible(false);
+    connect(m_ui.importButton, SIGNAL(clicked()), this, SLOT(importBookmarks()));
+    connect(m_ui.exportButton, SIGNAL(clicked()), this, SLOT(exportBookmarks()));
+
     return m_currentPage;
 }
 
@@ -183,6 +192,46 @@ void GeneralSettingsPage::setDefaultPage()
     m_ui.homePageLineEdit->setText(homePage);
 }
 
+void GeneralSettingsPage::importBookmarks()
+{
+    m_ui.errorLabel->setVisible(false);
+
+    QString fileName = QFileDialog::getOpenFileName(0, tr("Open Image"),
+        QDir::currentPath(), tr("Files (*.xbel)"));
+
+    if (fileName.isEmpty())
+        return;
+
+    QFile file(fileName);
+    if (file.open(QIODevice::ReadOnly)) {
+        XbelReader reader(m_bookmarkManager->treeBookmarkModel(),
+            m_bookmarkManager->listBookmarkModel());
+        if (reader.readFromFile(&file))
+            return;
+    }
+
+    m_ui.errorLabel->setVisible(true);
+    m_ui.errorLabel->setText(tr("There was an error while importing bookmarks!"));
+}
+
+void GeneralSettingsPage::exportBookmarks()
+{
+    m_ui.errorLabel->setVisible(false);
+
+    QString fileName = QFileDialog::getSaveFileName(0, tr("Save File"),
+        "untitled.xbel", tr("Files (*.xbel)"));
+
+    QLatin1String suffix(".xbel");
+    if (!fileName.endsWith(suffix))
+        fileName.append(suffix);
+
+    QFile file(fileName);
+    if (file.open(QIODevice::WriteOnly)) {
+        XbelWriter writer(m_bookmarkManager->treeBookmarkModel());
+        writer.writeToFile(&file);
+    }
+}
+
 void GeneralSettingsPage::updateFontSize()
 {
     const QString &family = font.family();
diff --git a/src/plugins/help/generalsettingspage.h b/src/plugins/help/generalsettingspage.h
index aa4995257d0..c39a9e0944e 100644
--- a/src/plugins/help/generalsettingspage.h
+++ b/src/plugins/help/generalsettingspage.h
@@ -37,6 +37,8 @@
 
 #include "ui_generalsettingspage.h"
 
+class BookmarkManager;
+
 QT_FORWARD_DECLARE_CLASS(QFont)
 QT_FORWARD_DECLARE_CLASS(QHelpEngine)
 
@@ -50,7 +52,8 @@ class GeneralSettingsPage : public Core::IOptionsPage
     Q_OBJECT
 
 public:
-    GeneralSettingsPage(QHelpEngine *helpEngine, CentralWidget *centralWidget);
+    GeneralSettingsPage(QHelpEngine *helpEngine, CentralWidget *centralWidget,
+        BookmarkManager *bookmarkManager);
 
     QString id() const;
     virtual QString trName() const;
@@ -68,6 +71,8 @@ private slots:
     void setCurrentPage();
     void setBlankPage();
     void setDefaultPage();
+    void importBookmarks();
+    void exportBookmarks();
 
 private:
     void updateFontSize();
@@ -79,6 +84,7 @@ private:
     QWidget *m_currentPage;
     QHelpEngine *m_helpEngine;
     CentralWidget *m_centralWidget;
+    BookmarkManager *m_bookmarkManager;
 
     QFont font;
     QFontDatabase fontDatabase;
diff --git a/src/plugins/help/generalsettingspage.ui b/src/plugins/help/generalsettingspage.ui
index abf3a2336e3..5d4b58a8c69 100644
--- a/src/plugins/help/generalsettingspage.ui
+++ b/src/plugins/help/generalsettingspage.ui
@@ -13,7 +13,7 @@
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
+  <layout class="QVBoxLayout" name="verticalLayout_3">
    <item>
     <widget class="QGroupBox" name="groupBox">
      <property name="title">
@@ -249,6 +249,90 @@
      </layout>
     </widget>
    </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox_3">
+     <property name="title">
+      <string>Help Bookmarks</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_2">
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <item>
+         <spacer name="horizontalSpacer_4">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>244</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+        <item>
+         <widget class="QPushButton" name="importButton">
+          <property name="text">
+           <string>Import...</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="exportButton">
+          <property name="text">
+           <string>Export...</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <widget class="QLabel" name="errorLabel">
+        <property name="palette">
+         <palette>
+          <active>
+           <colorrole role="Text">
+            <brush brushstyle="SolidPattern">
+             <color alpha="255">
+              <red>255</red>
+              <green>0</green>
+              <blue>0</blue>
+             </color>
+            </brush>
+           </colorrole>
+          </active>
+          <inactive>
+           <colorrole role="Text">
+            <brush brushstyle="SolidPattern">
+             <color alpha="255">
+              <red>255</red>
+              <green>0</green>
+              <blue>0</blue>
+             </color>
+            </brush>
+           </colorrole>
+          </inactive>
+          <disabled>
+           <colorrole role="Text">
+            <brush brushstyle="SolidPattern">
+             <color alpha="255">
+              <red>120</red>
+              <green>120</green>
+              <blue>120</blue>
+             </color>
+            </brush>
+           </colorrole>
+          </disabled>
+         </palette>
+        </property>
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
    <item>
     <spacer name="verticalSpacer">
      <property name="orientation">
diff --git a/src/plugins/help/help.pro b/src/plugins/help/help.pro
index 31f97c6cc96..b733a1fa70d 100644
--- a/src/plugins/help/help.pro
+++ b/src/plugins/help/help.pro
@@ -17,7 +17,8 @@ HEADERS += helpplugin.h \
     helpfindsupport.h \
     help_global.h \
     helpindexfilter.h \
-    generalsettingspage.h
+    generalsettingspage.h \
+    xbelsupport.h
 
 SOURCES += helpplugin.cpp \
     docsettingspage.cpp \
@@ -27,7 +28,8 @@ SOURCES += helpplugin.cpp \
     searchwidget.cpp \
     helpfindsupport.cpp \
     helpindexfilter.cpp \
-    generalsettingspage.cpp
+    generalsettingspage.cpp \
+    xbelsupport.cpp
 
 FORMS += docsettingspage.ui \
     filtersettingspage.ui \
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index 482edff4cea..b88fca51815 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -417,8 +417,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
         advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
     }
 
-    GeneralSettingsPage *generalSettings =
-        new GeneralSettingsPage(m_helpEngine, m_centralWidget);
+    GeneralSettingsPage *generalSettings = new GeneralSettingsPage(m_helpEngine,
+        m_centralWidget, m_bookmarkManager);
     addAutoReleasedObject(generalSettings);
     connect(generalSettings, SIGNAL(fontChanged()), this, SLOT(fontChanged()));
 
diff --git a/src/plugins/help/images/bookmark.png b/src/plugins/help/images/bookmark.png
index 7b2e5fd0cefcf2a980989d6cbb044739f9652d06..57e57e343ba5e5d710fe01b1720d06aacf97863d 100644
GIT binary patch
literal 1266
zcmV<O1P%L%P)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F8000EJNkl<ZcwV)Z
zeP~r>9LGP;bIv_?=gzz9Hg=ornwyDknlIqOG7U@{NwlUSE{H~u{$pfNP+;XBL4Opa
zMSp1Z&nk^dH<J*YSu#;4hA;HSrf#!Mmu^dUue<KPobz<)oXgO8<@mBMeEGq1AMWqN
z_xU|MM<}JZS%*(w>;sB$B=92T7F%78$72U-7F9OjK{~fq-u%k2VfeHgdniaGA(?<g
z%BjgDB(gQ*wCpdjZR`2wmgB>~`V}>gs5=G_0;CjVJeJH4!rdbjjz%j==~g5>+3f5+
z_mX8>1sRZr41`4vN$yZmf?<Hqm$3oHO;t$j{D8r<$jm%V`c{Hy&OjKR0lb{MrZL*o
z=T_IchH3aA6!cU6z)Vw<{$(h!F9Q+q0N`Cd-D!Ap8bTob2AC!UC-{gIS7ji~1t`&)
zfe76<0J!y02nkYxX*$l&*9nIzO-%%6D<#@85G5XNfmb;IN`bP$R-j42;gg*VT#2C+
zj9M8=*_8-!q_MHFs-dAFeO~~i%tAPhgbSH7qY!{=*Py)vEX#q24i9mn{a{I{$tK{P
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=AGT$YjUE!RfyCmTx5|${v3R3`~7~(W0ptL7X0OM)h%p1KwyR
z{#tJdVVE$9C7}yi2rj}_!nR_LHMpt7LZHn(|Ek_R>mtFpL_i@#2+4)dLiW`Zt-_HZ
n;EDs#M>nVQ^slVP9{~mcUD#3nIC{Fo00000NkvXXu0mjff#9CB

diff --git a/src/plugins/help/xbelsupport.cpp b/src/plugins/help/xbelsupport.cpp
new file mode 100644
index 00000000000..4b75daaaef1
--- /dev/null
+++ b/src/plugins/help/xbelsupport.cpp
@@ -0,0 +1,222 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#include "xbelsupport.h"
+#include "bookmarkmanager.h"
+
+using namespace Help::Internal;
+
+struct Bookmark {
+    QString title;
+    QString url;
+    bool folded;
+};
+
+XbelWriter::XbelWriter(BookmarkModel *model)
+    : QXmlStreamWriter()
+    , treeModel(model)
+{
+    setAutoFormatting(true);
+}
+
+void XbelWriter::writeToFile(QIODevice *device)
+{
+    setDevice(device);
+
+    writeStartDocument();
+    writeDTD(QLatin1String("<!DOCTYPE xbel>"));
+    writeStartElement(QLatin1String("xbel"));
+    writeAttribute(QLatin1String("version"), QLatin1String("1.0"));
+
+    QStandardItem *root = treeModel->invisibleRootItem();
+    for (int i = 0; i < root->rowCount(); ++i)
+        writeData(root->child(i));
+
+    writeEndDocument();
+}
+
+void XbelWriter::writeData(QStandardItem *child)
+{
+    Bookmark entry;
+    entry.title = child->data(Qt::DisplayRole).toString();
+    entry.url = child->data(Qt::UserRole + 10).toString();
+
+    if (entry.url == QLatin1String("Folder")) {
+        writeStartElement(QLatin1String("folder"));
+
+        entry.folded = !child->data(Qt::UserRole + 11).toBool();
+        writeAttribute(QLatin1String("folded"),
+            entry.folded ? QLatin1String("yes") : QLatin1String("no"));
+
+        writeTextElement(QLatin1String("title"), entry.title);
+
+        for (int i = 0; i < child->rowCount(); ++i)
+            writeData(child->child(i));
+
+        writeEndElement();
+    } else {
+        writeStartElement(QLatin1String("bookmark"));
+        writeAttribute(QLatin1String("href"), entry.url);
+        writeTextElement(QLatin1String("title"), entry.title);
+        writeEndElement();
+    }
+}
+
+
+// #pragma mark -- XbelReader
+
+
+XbelReader::XbelReader(BookmarkModel *tree, BookmarkModel *list)
+    : QXmlStreamReader()
+    , treeModel(tree)
+    , listModel(list)
+{
+    bookmarkIcon = QIcon(QLatin1String(":/help/images/bookmark.png"));
+    folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon);
+}
+
+bool XbelReader::readFromFile(QIODevice *device)
+{
+    setDevice(device);
+
+    while (!atEnd()) {
+        readNext();
+
+        if (isStartElement()) {
+            if (name() == QLatin1String("xbel")
+                && attributes().value(QLatin1String("version"))
+                    == QLatin1String("1.0")) {
+                readXBEL();
+            } else {
+                raiseError(QObject::tr("The file is not an XBEL version 1.0 file."));
+            }
+        }
+    }
+
+    return !error();
+}
+
+void XbelReader::readXBEL()
+{
+    while (!atEnd()) {
+        readNext();
+
+        if (isEndElement())
+            break;
+
+        if (isStartElement()) {
+            if (name() == QLatin1String("folder"))
+                readFolder(0);
+            else if (name() == QLatin1String("bookmark"))
+                readBookmark(0);
+            else
+                readUnknownElement();
+        }
+    }
+}
+
+void XbelReader::readUnknownElement()
+{
+    while (!atEnd()) {
+        readNext();
+
+        if (isEndElement())
+            break;
+
+        if (isStartElement())
+            readUnknownElement();
+    }
+}
+
+void XbelReader::readFolder(QStandardItem *item)
+{
+    QStandardItem *folder = createChildItem(item);
+    folder->setIcon(folderIcon);
+    folder->setData(QLatin1String("Folder"), Qt::UserRole + 10);
+
+    bool expanded =
+        (attributes().value(QLatin1String("folded")) != QLatin1String("no"));
+    folder->setData(expanded, Qt::UserRole + 11);
+
+    while (!atEnd()) {
+        readNext();
+
+        if (isEndElement())
+            break;
+
+        if (isStartElement()) {
+            if (name() == QLatin1String("title"))
+                folder->setText(readElementText());
+            else if (name() == QLatin1String("folder"))
+                readFolder(folder);
+            else if (name() == QLatin1String("bookmark"))
+                readBookmark(folder);
+            else
+                readUnknownElement();
+        }
+    }
+}
+
+void XbelReader::readBookmark(QStandardItem *item)
+{
+    QStandardItem *bookmark = createChildItem(item);
+    bookmark->setIcon(bookmarkIcon);
+    bookmark->setText(QObject::tr("Unknown title"));
+    bookmark->setData(attributes().value(QLatin1String("href")).toString(),
+        Qt::UserRole + 10);
+
+    while (!atEnd()) {
+        readNext();
+
+        if (isEndElement())
+            break;
+
+        if (isStartElement()) {
+            if (name() == QLatin1String("title"))
+                bookmark->setText(readElementText());
+            else
+                readUnknownElement();
+        }
+    }
+
+    listModel->appendRow(bookmark->clone());
+}
+
+QStandardItem *XbelReader::createChildItem(QStandardItem *item)
+{
+    QStandardItem *childItem = new QStandardItem();
+    childItem->setEditable(false);
+
+    if (item)
+        item->appendRow(childItem);
+    else
+        treeModel->appendRow(childItem);
+
+    return childItem;
+}
diff --git a/src/plugins/help/xbelsupport.h b/src/plugins/help/xbelsupport.h
new file mode 100644
index 00000000000..cc91000b05e
--- /dev/null
+++ b/src/plugins/help/xbelsupport.h
@@ -0,0 +1,81 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#ifndef XBELSUPPORT_H
+#define XBELSUPPORT_H
+
+#include <QtGui/QIcon>
+#include <QtXml/QXmlStreamReader>
+
+QT_FORWARD_DECLARE_CLASS(QIODevice)
+QT_FORWARD_DECLARE_CLASS(QStandardItem)
+
+class BookmarkModel;
+
+namespace Help {
+namespace Internal {
+
+class XbelWriter : public QXmlStreamWriter
+{
+public:
+    XbelWriter(BookmarkModel *model);
+    void writeToFile(QIODevice *device);
+
+private:
+    void writeData(QStandardItem *item);
+
+private:
+    BookmarkModel *treeModel;
+};
+
+class XbelReader : public QXmlStreamReader
+{
+public:
+    XbelReader(BookmarkModel *tree, BookmarkModel *list);
+    bool readFromFile(QIODevice *device);
+
+private:
+    void readXBEL();
+    void readUnknownElement();
+    void readFolder(QStandardItem *item);
+    void readBookmark(QStandardItem *item);
+    QStandardItem* createChildItem(QStandardItem *item);
+
+private:
+    QIcon folderIcon;
+    QIcon bookmarkIcon;
+
+    BookmarkModel *treeModel;
+    BookmarkModel *listModel;
+};
+
+    }   // Internal
+}   // Help
+
+#endif  // XBELSUPPORT_H
-- 
GitLab