summaryrefslogtreecommitdiffstats
path: root/tools/assistant/tools/assistant
diff options
context:
space:
mode:
Diffstat (limited to 'tools/assistant/tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/aboutdialog.cpp30
-rw-r--r--tools/assistant/tools/assistant/aboutdialog.h30
-rw-r--r--tools/assistant/tools/assistant/assistant.pro118
-rw-r--r--tools/assistant/tools/assistant/assistant.qchbin368640 -> 364544 bytes
-rw-r--r--tools/assistant/tools/assistant/assistant_images.qrc1
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.cpp80
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.h35
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp275
-rw-r--r--tools/assistant/tools/assistant/centralwidget.h45
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.cpp332
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.h56
-rw-r--r--tools/assistant/tools/assistant/contentwindow.cpp44
-rw-r--r--tools/assistant/tools/assistant/contentwindow.h35
-rw-r--r--tools/assistant/tools/assistant/doc/assistant.qdoc41
-rw-r--r--tools/assistant/tools/assistant/doc/assistant.qdocconf2
-rw-r--r--tools/assistant/tools/assistant/filternamedialog.cpp30
-rw-r--r--tools/assistant/tools/assistant/filternamedialog.h30
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.cpp591
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.h212
-rw-r--r--tools/assistant/tools/assistant/helpviewer.cpp153
-rw-r--r--tools/assistant/tools/assistant/helpviewer.h40
-rw-r--r--tools/assistant/tools/assistant/images/bookmark.pngbin0 -> 1266 bytes
-rw-r--r--tools/assistant/tools/assistant/indexwindow.cpp62
-rw-r--r--tools/assistant/tools/assistant/indexwindow.h34
-rw-r--r--tools/assistant/tools/assistant/installdialog.cpp42
-rw-r--r--tools/assistant/tools/assistant/installdialog.h30
-rw-r--r--tools/assistant/tools/assistant/main.cpp302
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp502
-rw-r--r--tools/assistant/tools/assistant/mainwindow.h64
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.cpp159
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.h43
-rw-r--r--tools/assistant/tools/assistant/qtdocinstaller.cpp111
-rw-r--r--tools/assistant/tools/assistant/qtdocinstaller.h51
-rw-r--r--tools/assistant/tools/assistant/remotecontrol.cpp299
-rw-r--r--tools/assistant/tools/assistant/remotecontrol.h48
-rw-r--r--tools/assistant/tools/assistant/remotecontrol_win.h30
-rw-r--r--tools/assistant/tools/assistant/searchwidget.cpp33
-rw-r--r--tools/assistant/tools/assistant/searchwidget.h30
-rw-r--r--tools/assistant/tools/assistant/topicchooser.cpp30
-rw-r--r--tools/assistant/tools/assistant/topicchooser.h30
-rw-r--r--tools/assistant/tools/assistant/tracer.h75
-rw-r--r--tools/assistant/tools/assistant/xbelsupport.cpp238
-rw-r--r--tools/assistant/tools/assistant/xbelsupport.h91
43 files changed, 2929 insertions, 1555 deletions
diff --git a/tools/assistant/tools/assistant/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp
index eff4bb632..d8fd37c5f 100644
--- a/tools/assistant/tools/assistant/aboutdialog.cpp
+++ b/tools/assistant/tools/assistant/aboutdialog.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tools/assistant/tools/assistant/aboutdialog.h b/tools/assistant/tools/assistant/aboutdialog.h
index 347ff0c31..85ebe3c73 100644
--- a/tools/assistant/tools/assistant/aboutdialog.h
+++ b/tools/assistant/tools/assistant/aboutdialog.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro
index 1cbd1d32d..ca2e52ee9 100644
--- a/tools/assistant/tools/assistant/assistant.pro
+++ b/tools/assistant/tools/assistant/assistant.pro
@@ -1,88 +1,78 @@
include($$QT_SOURCE_TREE/tools/shared/fontpanel/fontpanel.pri)
-
TEMPLATE = app
LANGUAGE = C++
TARGET = assistant
-
-DEFINES += QT_CLUCENE_SUPPORT
-
-contains(QT_CONFIG, webkit) {
- QT += webkit
-}
-
-CONFIG += qt warn_on help
-
+contains(QT_CONFIG, webkit):QT += webkit
+CONFIG += qt \
+ warn_on \
+ help
QT += network
-
PROJECTNAME = Assistant
DESTDIR = ../../../../bin
-
-target.path=$$[QT_INSTALL_BINS]
+target.path = $$[QT_INSTALL_BINS]
INSTALLS += target
-### Work around a qmake issue when statically linking to
-### not-yet-installed plugins
+# ## Work around a qmake issue when statically linking to
+# ## not-yet-installed plugins
LIBS += -L$$QT_BUILD_TREE/plugins/sqldrivers
-
HEADERS += helpviewer.h \
- mainwindow.h \
- indexwindow.h \
- topicchooser.h \
- contentwindow.h \
- searchwidget.h \
- preferencesdialog.h \
- filternamedialog.h \
- centralwidget.h \
- installdialog.h \
- bookmarkmanager.h \
- remotecontrol.h \
- cmdlineparser.h \
- aboutdialog.h \
- qtdocinstaller.h
-
-win32 {
- HEADERS += remotecontrol_win.h
-}
-
+ mainwindow.h \
+ indexwindow.h \
+ topicchooser.h \
+ contentwindow.h \
+ searchwidget.h \
+ preferencesdialog.h \
+ filternamedialog.h \
+ centralwidget.h \
+ installdialog.h \
+ bookmarkmanager.h \
+ remotecontrol.h \
+ cmdlineparser.h \
+ aboutdialog.h \
+ qtdocinstaller.h \
+ xbelsupport.h \
+ ../shared/collectionconfiguration.h \
+ helpenginewrapper.h \
+ tracer.h
+win32:HEADERS += remotecontrol_win.h
SOURCES += helpviewer.cpp \
- main.cpp \
- mainwindow.cpp \
- indexwindow.cpp \
- topicchooser.cpp \
- contentwindow.cpp \
- searchwidget.cpp \
- preferencesdialog.cpp \
- filternamedialog.cpp \
- centralwidget.cpp \
- installdialog.cpp \
- bookmarkmanager.cpp \
- remotecontrol.cpp \
- cmdlineparser.cpp \
- aboutdialog.cpp \
- qtdocinstaller.cpp
-
+ main.cpp \
+ mainwindow.cpp \
+ indexwindow.cpp \
+ topicchooser.cpp \
+ contentwindow.cpp \
+ searchwidget.cpp \
+ preferencesdialog.cpp \
+ filternamedialog.cpp \
+ centralwidget.cpp \
+ installdialog.cpp \
+ bookmarkmanager.cpp \
+ remotecontrol.cpp \
+ cmdlineparser.cpp \
+ aboutdialog.cpp \
+ qtdocinstaller.cpp \
+ xbelsupport.cpp \
+ ../shared/collectionconfiguration.cpp \
+ helpenginewrapper.cpp
FORMS += topicchooser.ui \
- preferencesdialog.ui \
- filternamedialog.ui \
- installdialog.ui \
- bookmarkdialog.ui
-
-RESOURCES += assistant.qrc assistant_images.qrc
-
-win32 {
+ preferencesdialog.ui \
+ filternamedialog.ui \
+ installdialog.ui \
+ bookmarkdialog.ui
+RESOURCES += assistant.qrc \
+ assistant_images.qrc
+win32 {
!wince*:LIBS += -lshell32
RC_FILE = assistant.rc
}
-
-mac {
+mac {
ICON = assistant.icns
TARGET = Assistant
QMAKE_INFO_PLIST = Info_mac.plist
}
-
-contains(CONFIG, static): {
+contains(CONFIG, static): {
SQLPLUGINS = $$unique(sql-plugins)
- contains(SQLPLUGINS, sqlite): {
+ contains(SQLPLUGINS, sqlite): {
QTPLUGIN += qsqlite
DEFINES += USE_STATIC_SQLITE_PLUGIN
}
diff --git a/tools/assistant/tools/assistant/assistant.qch b/tools/assistant/tools/assistant/assistant.qch
index 3e66bd924..e6d52997b 100644
--- a/tools/assistant/tools/assistant/assistant.qch
+++ b/tools/assistant/tools/assistant/assistant.qch
Binary files differ
diff --git a/tools/assistant/tools/assistant/assistant_images.qrc b/tools/assistant/tools/assistant/assistant_images.qrc
index 58e03b54d..34918c0bf 100644
--- a/tools/assistant/tools/assistant/assistant_images.qrc
+++ b/tools/assistant/tools/assistant/assistant_images.qrc
@@ -4,6 +4,7 @@
<file>images/assistant-128.png</file>
<file>images/assistant.png</file>
<file>images/wrap.png</file>
+ <file>images/bookmark.png</file>
#mac
<file>images/mac/addtab.png</file>
<file>images/mac/book.png</file>
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp
index 6b13b8290..f8cad4d97 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.cpp
+++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,27 +21,27 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "bookmarkmanager.h"
#include "centralwidget.h"
+#include "helpenginewrapper.h"
#include <QtGui/QMenu>
#include <QtGui/QIcon>
@@ -56,7 +57,6 @@
#include <QtGui/QToolButton>
#include <QtGui/QPushButton>
#include <QtGui/QApplication>
-#include <QtHelp/QHelpEngineCore>
#include <QtGui/QDialogButtonBox>
#include <QtGui/QSortFilterProxyModel>
@@ -150,8 +150,8 @@ void BookmarkDialog::addNewFolder()
const QString &name = index.data().toString();
ui.bookmarkFolders->setCurrentIndex(ui.bookmarkFolders->findText(name));
+ renameFolder(index, newFolder);
}
- ui.treeView->setFocus();
}
void BookmarkDialog::toolButtonClicked()
@@ -243,14 +243,19 @@ void BookmarkDialog::customContextMenuRequested(const QPoint &point)
if (index.isValid())
name = index.data().toString();
ui.bookmarkFolders->setCurrentIndex(ui.bookmarkFolders->findText(name));
+ } else if (picked == renameItem) {
+ renameFolder(index, proxyIndex);
}
- else if (picked == renameItem) {
- BookmarkModel *model = bookmarkManager->treeBookmarkModel();
- if (QStandardItem *item = model->itemFromIndex(proxyIndex)) {
- item->setEditable(true);
- ui.treeView->edit(index);
- item->setEditable(false);
- }
+}
+
+void BookmarkDialog::renameFolder(const QModelIndex &index,
+ const QModelIndex &proxyIndex)
+{
+ const BookmarkModel * const model = bookmarkManager->treeBookmarkModel();
+ if (QStandardItem *item = model->itemFromIndex(proxyIndex)) {
+ item->setEditable(true);
+ ui.treeView->edit(index);
+ item->setEditable(false);
}
}
@@ -301,7 +306,7 @@ bool BookmarkDialog::eventFilter(QObject *object, QEvent *e)
}
-// #pragma mark -- BookmarkWidget
+// BookmarkWidget
BookmarkWidget::BookmarkWidget(BookmarkManager *manager, QWidget *parent,
@@ -587,7 +592,7 @@ bool BookmarkWidget::eventFilter(QObject *object, QEvent *e)
}
-// #pragma mark -- BookmarkModel
+// BookmarkModel
BookmarkModel::BookmarkModel(int rows, int columns, QObject *parent)
@@ -615,21 +620,22 @@ Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const
}
-// #pragma mark -- BookmarkManager
+// BookmarkManager
-BookmarkManager::BookmarkManager(QHelpEngineCore *_helpEngine)
+BookmarkManager::BookmarkManager()
: treeModel(new BookmarkModel(0, 1, this))
, listModel(new BookmarkModel(0, 1, this))
- , helpEngine(_helpEngine)
+ , renameItem(0)
{
folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon);
+ bookmarkIcon = QIcon(QLatin1String(":/trolltech/assistant/images/bookmark.png"));
connect(treeModel, SIGNAL(itemChanged(QStandardItem*)), this,
SLOT(itemChanged(QStandardItem*)));
connect(treeModel, SIGNAL(itemChanged(QStandardItem*)), this,
SIGNAL(bookmarksChanged()));
- connect(treeModel, SIGNAL(rowsRemoved(QModelIndex, int, int)),
+ connect(treeModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SIGNAL(bookmarksChanged()));
}
@@ -655,7 +661,7 @@ void BookmarkManager::saveBookmarks()
QDataStream stream(&bookmarks, QIODevice::WriteOnly);
readBookmarksRecursive(treeModel->invisibleRootItem(), stream, 0);
- helpEngine->setCustomValue(QLatin1String("Bookmarks"), bookmarks);
+ HelpEngineWrapper::instance().setBookmarks(bookmarks);
}
QStringList BookmarkManager::bookmarkFolders() const
@@ -733,6 +739,7 @@ void BookmarkManager::addNewBookmark(const QModelIndex &index,
{
QStandardItem *item = new QStandardItem(name);
item->setEditable(false);
+ item->setIcon(bookmarkIcon);
item->setData(false, Qt::UserRole + 11);
item->setData(url, Qt::UserRole + 10);
@@ -806,8 +813,7 @@ void BookmarkManager::setupBookmarkModels()
QList<int> lastDepths;
QList<QStandardItem*> parents;
- QByteArray ba =
- helpEngine->customValue(QLatin1String("Bookmarks")).toByteArray();
+ QByteArray ba = HelpEngineWrapper::instance().bookmarks();
QDataStream stream(ba);
while (!stream.atEnd()) {
stream >> depth >> name >> type >> expanded;
@@ -832,10 +838,12 @@ void BookmarkManager::setupBookmarkModels()
}
}
- if (type == QLatin1String("Folder"))
- item->setIcon(folderIcon);
- else
+ if (type != QLatin1String("Folder")) {
+ item->setIcon(bookmarkIcon);
listModel->appendRow(item->clone());
+ } else {
+ item->setIcon(folderIcon);
+ }
}
}
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.h b/tools/assistant/tools/assistant/bookmarkmanager.h
index 75bce4d7f..13d4b5c75 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.h
+++ b/tools/assistant/tools/assistant/bookmarkmanager.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -90,6 +90,7 @@ private slots:
private:
bool eventFilter(QObject *object, QEvent *e);
+ void renameFolder(const QModelIndex &index, const QModelIndex &proxyIndex);
private:
QString m_url;
@@ -167,7 +168,7 @@ class BookmarkManager : public QObject
Q_OBJECT
public:
- BookmarkManager(QHelpEngineCore* helpEngine);
+ BookmarkManager();
~BookmarkManager();
BookmarkModel* treeBookmarkModel();
@@ -202,11 +203,11 @@ private:
private:
QString oldText;
QIcon folderIcon;
+ QIcon bookmarkIcon;
BookmarkModel *treeModel;
BookmarkModel *listModel;
QStandardItem *renameItem;
- QHelpEngineCore *helpEngine;
QMap<QAction*, QModelIndex> map;
};
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index 908c444e3..7117b7675 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,30 +21,31 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "centralwidget.h"
+#include "helpenginewrapper.h"
#include "helpviewer.h"
#include "searchwidget.h"
#include "mainwindow.h"
#include "preferencesdialog.h"
+#include "../shared/collectionconfiguration.h"
#include <QtCore/QDir>
#include <QtCore/QEvent>
@@ -67,7 +69,6 @@
#include <QtGui/QPrintPreviewDialog>
#include <QtGui/QPageSetupDialog>
-#include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpSearchEngine>
QT_BEGIN_NAMESPACE
@@ -205,14 +206,12 @@ QToolButton* FindWidget::setupToolButton(const QString &text, const QString &ico
// --
-CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent)
+CentralWidget::CentralWidget(MainWindow *parent)
: QWidget(parent)
, lastTabPage(0)
- , collectionFile(engine->collectionFile())
, findBar(0)
, tabWidget(0)
, findWidget(0)
- , helpEngine(engine)
, printer(0)
, usesDefaultCollection(parent->usesDefaultCollection())
, m_searchWidget(0)
@@ -222,14 +221,15 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent)
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
QString resourcePath = QLatin1String(":/trolltech/assistant/images/");
-#ifndef Q_OS_MAC
vboxLayout->setMargin(0);
+ tabWidget = new QTabWidget(this);
+#ifndef Q_OS_MAC
resourcePath.append(QLatin1String("win"));
#else
resourcePath.append(QLatin1String("mac"));
+ tabWidget->setDocumentMode(true);
#endif
- tabWidget = new QTabWidget(this);
connect(tabWidget, SIGNAL(currentChanged(int)), this,
SLOT(currentPageChanged(int)));
@@ -291,32 +291,24 @@ CentralWidget::~CentralWidget()
delete printer;
#endif
- QHelpEngineCore engine(collectionFile, 0);
- if (!engine.setupData())
- return;
-
- QString zoomCount;
- QString currentPages;
- QLatin1Char separator('|');
+ QStringList zoomFactors;
+ QStringList currentPages;
bool searchAttached = m_searchWidget->isAttached();
int i = searchAttached ? 1 : 0;
for (; i < tabWidget->count(); ++i) {
HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i));
if (viewer && viewer->source().isValid()) {
- currentPages += viewer->source().toString() + separator;
- zoomCount += QString::number(viewer->zoom()) + separator;
+ currentPages << viewer->source().toString();
+ zoomFactors << QString::number(viewer->zoom());
}
}
- engine.setCustomValue(QLatin1String("LastTabPage"), lastTabPage);
- engine.setCustomValue(QLatin1String("LastShownPages"), currentPages);
- engine.setCustomValue(QLatin1String("SearchWasAttached"), searchAttached);
-#if !defined(QT_NO_WEBKIT)
- engine.setCustomValue(QLatin1String("LastPagesZoomWebView"), zoomCount);
-#else
- engine.setCustomValue(QLatin1String("LastPagesZoomTextBrowser"), zoomCount);
-#endif
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ helpEngine.setLastTabPage(lastTabPage);
+ helpEngine.setLastShownPages(currentPages);
+ helpEngine.setSearchWasAttached(searchAttached);
+ helpEngine.setLastZoomFactors(zoomFactors);
}
CentralWidget *CentralWidget::instance()
@@ -408,7 +400,7 @@ void CentralWidget::setSource(const QUrl &url)
qobject_cast<HelpViewer*>(tabWidget->widget(lastTabPage));
if (!viewer && !lastViewer) {
- viewer = new HelpViewer(helpEngine, this);
+ viewer = new HelpViewer(this);
viewer->installEventFilter(this);
lastTabPage = tabWidget->addTab(viewer, QString());
tabWidget->setCurrentIndex(lastTabPage);
@@ -426,18 +418,13 @@ void CentralWidget::setSource(const QUrl &url)
void CentralWidget::setupWidget()
{
- int option = helpEngine->customValue(QLatin1String("StartOption"),
- ShowLastPages).toInt();
-
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ int option = helpEngine.startOption();
if (option != ShowLastPages) {
QString homePage;
- if (option == ShowHomePage) {
- homePage = helpEngine->customValue(QLatin1String("defaultHomepage"),
- QLatin1String("help")).toString();
- homePage = helpEngine->customValue(QLatin1String("homepage"),
- homePage).toString();
- }
- if (option == ShowBlankPage)
+ if (option == ShowHomePage)
+ homePage = helpEngine.homePage();
+ else if (option == ShowBlankPage)
homePage = QLatin1String("about:blank");
setSource(homePage);
} else {
@@ -447,11 +434,8 @@ void CentralWidget::setupWidget()
void CentralWidget::setLastShownPages()
{
- const QLatin1String key("LastShownPages");
- QString value = helpEngine->customValue(key, QString()).toString();
- const QStringList lastShownPageList = value.split(QLatin1Char('|'),
- QString::SkipEmptyParts);
-
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ const QStringList lastShownPageList = helpEngine.lastShownPages();
const int pageCount = lastShownPageList.count();
if (pageCount == 0) {
if (usesDefaultCollection)
@@ -461,37 +445,24 @@ void CentralWidget::setLastShownPages()
return;
}
-#if !defined(QT_NO_WEBKIT)
- const QLatin1String zoom("LastPagesZoomWebView");
-#else
- const QLatin1String zoom("LastPagesZoomTextBrowser");
-#endif
-
- value = helpEngine->customValue(zoom, QString()).toString();
- QVector<QString> zoomVector = value.split(QLatin1Char('|'),
- QString::SkipEmptyParts).toVector();
+ QStringList zoomFactors = helpEngine.lastZoomFactors();
+ while (zoomFactors.count() < pageCount)
+ zoomFactors.append(CollectionConfiguration::DefaultZoomFactor);
- const int zoomCount = zoomVector.count();
- zoomVector.insert(zoomCount, pageCount - zoomCount, QLatin1String("0.0"));
-
- QVector<QString>::const_iterator zIt = zoomVector.constBegin();
+ QStringList::const_iterator zIt = zoomFactors.constBegin();
QStringList::const_iterator it = lastShownPageList.constBegin();
for (; it != lastShownPageList.constEnd(); ++it, ++zIt)
setSourceInNewTab((*it), (*zIt).toFloat());
- const QLatin1String lastTab("LastTabPage");
- int tab = helpEngine->customValue(lastTab, 1).toInt();
+ int tab = helpEngine.lastTabPage();
- const QLatin1String searchKey("SearchWasAttached");
const bool searchIsAttached = m_searchWidget->isAttached();
- const bool searchWasAttached = helpEngine->customValue(searchKey).toBool();
-
+ const bool searchWasAttached = helpEngine.searchWasAttached();
if (searchWasAttached && !searchIsAttached)
- tabWidget->setCurrentIndex(--tab);
+ --tab;
else if (!searchWasAttached && searchIsAttached)
- tabWidget->setCurrentIndex(++tab);
- else
- tabWidget->setCurrentIndex(tab);
+ ++tab;
+ tabWidget->setCurrentIndex(tab);
}
bool CentralWidget::hasSelection() const
@@ -549,18 +520,17 @@ void CentralWidget::print()
initPrinter();
- QPrintDialog *dlg = new QPrintDialog(printer, this);
+ QPrintDialog dlg(printer, this);
#if defined(QT_NO_WEBKIT)
if (viewer->textCursor().hasSelection())
- dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
+ dlg.addEnabledOption(QAbstractPrintDialog::PrintSelection);
#endif
- dlg->addEnabledOption(QAbstractPrintDialog::PrintPageRange);
- dlg->addEnabledOption(QAbstractPrintDialog::PrintCollateCopies);
- dlg->setWindowTitle(tr("Print Document"));
- if (dlg->exec() == QDialog::Accepted) {
+ dlg.addEnabledOption(QAbstractPrintDialog::PrintPageRange);
+ dlg.addEnabledOption(QAbstractPrintDialog::PrintCollateCopies);
+ dlg.setWindowTitle(tr("Print Document"));
+ if (dlg.exec() == QDialog::Accepted) {
viewer->print(printer);
}
- delete dlg;
#endif
}
@@ -658,41 +628,23 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom)
return;
#endif
- viewer = new HelpViewer(helpEngine, this);
+ viewer = new HelpViewer(this);
viewer->installEventFilter(this);
viewer->setSource(url);
viewer->setFocus(Qt::OtherFocusReason);
tabWidget->setCurrentIndex(tabWidget->addTab(viewer,
quoteTabTitle(viewer->documentTitle())));
- QFont font = qApp->font();
- bool userFont = helpEngine->customValue(QLatin1String("useBrowserFont")).toBool();
- if (userFont) {
- font = qVariantValue<QFont>(helpEngine->customValue(
- QLatin1String("browserFont")));
- }
-
-#if !defined(QT_NO_WEBKIT)
- QWebSettings *settings = QWebSettings::globalSettings();
- if (!userFont) {
- int fontSize = settings->fontSize(QWebSettings::DefaultFontSize);
- QString fontFamily = settings->fontFamily(QWebSettings::StandardFont);
- font = QFont(fontFamily, fontSize);
- }
+ QFont font;
+ getBrowserFontFor(viewer, &font);
- QWebView *view = qobject_cast<QWebView*> (viewer);
- if (view) {
- settings = view->settings();
- settings->setFontFamily(QWebSettings::StandardFont, font.family());
- settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
- } else if (viewer) {
- viewer->setFont(font);
- }
- viewer->setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
-#else
+#if defined(QT_NO_WEBKIT)
font.setPointSize((int)(font.pointSize() + zoom));
- viewer->setFont(font);
+ setBrowserFontFor(viewer, font);
viewer->setZoom((int)zoom);
+#else
+ setBrowserFontFor(viewer, font);
+ viewer->setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
#endif
connectSignals();
@@ -700,7 +652,7 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom)
HelpViewer *CentralWidget::newEmptyTab()
{
- HelpViewer *viewer = new HelpViewer(helpEngine, this);
+ HelpViewer *viewer = new HelpViewer(this);
viewer->installEventFilter(this);
viewer->setFocus(Qt::OtherFocusReason);
#if defined(QT_NO_WEBKIT)
@@ -1010,41 +962,17 @@ bool CentralWidget::findInTextBrowser(QTextBrowser* browser, const QString &ttf,
void CentralWidget::updateBrowserFont()
{
- QFont font = qApp->font();
- bool userFont = helpEngine->customValue(QLatin1String("useBrowserFont")).toBool();
- if (userFont) {
- font = qVariantValue<QFont>(helpEngine->customValue(
- QLatin1String("browserFont")));
- }
-
-#if !defined(QT_NO_WEBKIT)
- QWebSettings *settings = QWebSettings::globalSettings();
- if (!userFont) {
- int fontSize = settings->fontSize(QWebSettings::DefaultFontSize);
- QString fontFamily = settings->fontFamily(QWebSettings::StandardFont);
- font = QFont(fontFamily, fontSize);
+ QFont font;
+ bool searchAttached = searchWidgetAttached();
+ if (searchAttached) {
+ getBrowserFontFor(m_searchWidget, &font);
+ setBrowserFontFor(m_searchWidget, font);
}
-#endif
- QWidget *widget = 0;
- for (int i = 0; i < tabWidget->count(); ++i) {
- widget = tabWidget->widget(i);
-#if !defined(QT_NO_WEBKIT)
- QWebView *view = qobject_cast<QWebView*> (widget);
- if (view) {
- settings = view->settings();
- settings->setFontFamily(QWebSettings::StandardFont, font.family());
- settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
- } else if (widget) {
- if (!userFont)
- font = qApp->font();
- widget->setFont(font);
- }
-#else
- if (widget && widget->font() != font)
- widget->setFont(font);
-#endif
- }
+ int i = searchAttached ? 1 : 0;
+ getBrowserFontFor(tabWidget->widget(i), &font);
+ for (; i < tabWidget->count(); ++i)
+ setBrowserFontFor(tabWidget->widget(i), font);
}
void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine)
@@ -1057,12 +985,16 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine)
SLOT(setSourceFromSearch(QUrl)));
connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this,
SLOT(setSourceFromSearchInNewTab(QUrl)));
+
+ QFont font;
+ getBrowserFontFor(m_searchWidget, &font);
+ setBrowserFontFor(m_searchWidget, font);
}
void CentralWidget::activateSearchWidget(bool updateLastTabPage)
{
if (!m_searchWidget)
- createSearchWidget(helpEngine->searchEngine());
+ createSearchWidget(HelpEngineWrapper::instance().searchEngine());
if (!m_searchWidget->isAttached()) {
tabWidget->insertTab(0, m_searchWidget, tr("Search"));
@@ -1078,7 +1010,7 @@ void CentralWidget::activateSearchWidget(bool updateLastTabPage)
void CentralWidget::removeSearchWidget()
{
- if (m_searchWidget && m_searchWidget->isAttached()) {
+ if (searchWidgetAttached()) {
tabWidget->removeTab(0);
m_searchWidget->setAttached(false);
}
@@ -1087,7 +1019,7 @@ void CentralWidget::removeSearchWidget()
int CentralWidget::availableHelpViewer() const
{
int count = tabWidget->count();
- if (m_searchWidget && m_searchWidget->isAttached())
+ if (searchWidgetAttached())
count--;
return count;
}
@@ -1095,7 +1027,7 @@ int CentralWidget::availableHelpViewer() const
bool CentralWidget::enableTabCloseAction() const
{
int minTabCount = 1;
- if (m_searchWidget && m_searchWidget->isAttached())
+ if (searchWidgetAttached())
minTabCount = 2;
return (tabWidget->count() > minTabCount);
@@ -1129,7 +1061,8 @@ CentralWidget::highlightSearchTerms()
if (!viewer)
return;
- QHelpSearchEngine *searchEngine = helpEngine->searchEngine();
+ QHelpSearchEngine *searchEngine =
+ HelpEngineWrapper::instance().searchEngine();
QList<QHelpSearchQuery> queryList = searchEngine->query();
QStringList terms;
@@ -1180,6 +1113,17 @@ CentralWidget::highlightSearchTerms()
#endif
}
+
+void CentralWidget::closeTabs(const QList<int> &indices)
+{
+ QList<int> sortedIndices = indices;
+ qSort(sortedIndices);
+ for (int i = sortedIndices.count(); --i >= 0;)
+ closeTabAt(sortedIndices.at(i));
+ if (availableHelpViewer() == 0)
+ setSource(QUrl(QLatin1String("about:blank")));
+}
+
void CentralWidget::closeTabAt(int index)
{
HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(index));
@@ -1198,4 +1142,39 @@ QMap<int, QString> CentralWidget::currentSourceFileList() const
return sourceList;
}
+void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font)
+{
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ if (!helpEngine.usesBrowserFont()) {
+ *font = qApp->font(); // case for QTextBrowser and SearchWidget
+#if !defined(QT_NO_WEBKIT)
+ QWebView *view = qobject_cast<QWebView*> (viewer);
+ if (view) {
+ QWebSettings *settings = QWebSettings::globalSettings();
+ *font = QFont(settings->fontFamily(QWebSettings::StandardFont),
+ settings->fontSize(QWebSettings::DefaultFontSize));
+ }
+#endif
+ } else {
+ *font = helpEngine.browserFont();
+ }
+}
+
+void CentralWidget::setBrowserFontFor(QWidget *widget, const QFont &font)
+{
+#if !defined(QT_NO_WEBKIT)
+ QWebView *view = qobject_cast<QWebView*> (widget);
+ if (view) {
+ QWebSettings *settings = view->settings();
+ settings->setFontFamily(QWebSettings::StandardFont, font.family());
+ settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
+ } else if (widget && widget->font() != font) {
+ widget->setFont(font);
+ }
+#else
+ if (widget && widget->font() != font)
+ widget->setFont(font);
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h
index 02627cdc0..d90968e67 100644
--- a/tools/assistant/tools/assistant/centralwidget.h
+++ b/tools/assistant/tools/assistant/centralwidget.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -42,12 +42,15 @@
#ifndef CENTRALWIDGET_H
#define CENTRALWIDGET_H
+#include <QtCore/QList>
#include <QtCore/QUrl>
#include <QtCore/QPoint>
#include <QtCore/QObject>
#include <QtGui/QWidget>
+#include "searchwidget.h"
+
QT_BEGIN_NAMESPACE
class QEvent;
@@ -65,7 +68,6 @@ class CentralWidget;
class PrintHelper;
class MainWindow;
-class SearchWidget;
class QHelpSearchEngine;
class FindWidget : public QWidget
@@ -108,7 +110,7 @@ class CentralWidget : public QWidget
Q_OBJECT
public:
- CentralWidget(QHelpEngine *engine, MainWindow *parent);
+ CentralWidget(MainWindow *parent);
~CentralWidget();
void setupWidget();
@@ -123,6 +125,9 @@ public:
HelpViewer *currentHelpViewer() const;
void activateTab(bool onlyHelpViewer = false);
+ bool searchWidgetAttached() const {
+ return m_searchWidget && m_searchWidget->isAttached();
+ }
void createSearchWidget(QHelpSearchEngine *searchEngine);
void activateSearchWidget(bool updateLastTabPage = false);
void removeSearchWidget();
@@ -130,6 +135,7 @@ public:
int availableHelpViewer() const;
bool enableTabCloseAction() const;
+ void closeTabs(const QList<int> &indices);
void closeTabAt(int index);
QMap<int, QString> currentSourceFileList() const;
@@ -190,15 +196,16 @@ private:
void highlightSearchTerms();
void setLastShownPages();
+ void getBrowserFontFor(QWidget* viewer, QFont *font);
+ void setBrowserFontFor(QWidget *widget, const QFont &font);
+
private:
int lastTabPage;
- QString collectionFile;
QList<QAction*> globalActionList;
QWidget *findBar;
QTabWidget *tabWidget;
FindWidget *findWidget;
- QHelpEngine *helpEngine;
QPrinter *printer;
bool usesDefaultCollection;
diff --git a/tools/assistant/tools/assistant/cmdlineparser.cpp b/tools/assistant/tools/assistant/cmdlineparser.cpp
index 8bb599809..b17909c4d 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.cpp
+++ b/tools/assistant/tools/assistant/cmdlineparser.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -46,21 +46,7 @@
QT_BEGIN_NAMESPACE
-#define CHECK_NEXT_ARG \
- ++i < arguments.count() && !arguments.at(i).startsWith(QLatin1String("-"))
-
-CmdLineParser::CmdLineParser()
- : m_enableRemoteControl(false),
- m_contents(Untouched),
- m_index(Untouched),
- m_bookmarks(Untouched),
- m_search(Untouched),
- m_register(None),
- m_removeSearchIndex(false),
- m_copy(false),
- m_quiet(false)
-{
- m_helpMessage = QLatin1String(
+const QString CmdLineParser::m_helpMessage = QLatin1String(
"Usage: assistant [Options]\n\n"
"-collectionFile file Uses the specified collection\n"
" file instead of the default one\n"
@@ -89,152 +75,62 @@ CmdLineParser::CmdLineParser()
" status message.\n"
"-help Displays this help.\n"
);
-}
-CmdLineParser::Result CmdLineParser::parse(const QStringList &arguments)
-{
- QString error;
- bool showHelp = false;
- for (int j=1; j<arguments.count(); ++j) {
- if (arguments.at(j).toLower() == QLatin1String("-quiet")) {
+CmdLineParser::CmdLineParser(const QStringList &arguments)
+ : m_pos(0),
+ m_enableRemoteControl(false),
+ m_contents(Untouched),
+ m_index(Untouched),
+ m_bookmarks(Untouched),
+ m_search(Untouched),
+ m_register(None),
+ m_removeSearchIndex(false),
+ m_quiet(false)
+{
+ for (int i = 1; i < arguments.count(); ++i) {
+ const QString &arg = arguments.at(i);
+ if (arg.toLower() == "-quiet")
m_quiet = true;
- break;
- }
+ else
+ m_arguments.append(arg);
}
+}
- for (int i=1; i<arguments.count(); ++i) {
- QString arg = arguments.at(i).toLower();
- if (arg == QLatin1String("-collectionfile")) {
- if (CHECK_NEXT_ARG) {
- m_collectionFile = getFileName(arguments.at(i));
- if (m_collectionFile.isEmpty()) {
- error = QObject::tr("The specified collection file does not exist!");
- break;
- }
- } else {
- error = QObject::tr("Missing collection file!");
- break;
- }
- } else if (arg == QLatin1String("-showurl")) {
- if (CHECK_NEXT_ARG) {
- QUrl url(arguments.at(i));
- if (url.isValid()) {
- m_url = url;
- } else {
- error = QObject::tr("Invalid URL!");
- break;
- }
- } else {
- error = QObject::tr("Missing URL!");
- break;
- }
- } else if (arg == QLatin1String("-enableremotecontrol")) {
+CmdLineParser::Result CmdLineParser::parse()
+{
+ bool showHelp = false;
+
+ while (m_error.isEmpty() && hasMoreArgs()) {
+ const QString &arg = nextArg().toLower();
+ if (arg == QLatin1String("-collectionfile"))
+ handleCollectionFileOption();
+ else if (arg == QLatin1String("-showurl"))
+ handleShowUrlOption();
+ else if (arg == QLatin1String("-enableremotecontrol"))
m_enableRemoteControl = true;
- } else if (arg == QLatin1String("-show")) {
- if (CHECK_NEXT_ARG) {
- arg = arguments.at(i).toLower();
- if (arg == QLatin1String("contents")) {
- m_contents = Show;
- } else if (arg == QLatin1String("index")) {
- m_index = Show;
- } else if (arg == QLatin1String("bookmarks")) {
- m_bookmarks = Show;
- } else if (arg == QLatin1String("search")) {
- m_search = Show;
- } else {
- error = QObject::tr("Unknown widget: %1").arg(arg);
- break;
- }
- } else {
- error = QObject::tr("Missing widget!");
- break;
- }
- } else if (arg == QLatin1String("-hide")) {
- if (CHECK_NEXT_ARG) {
- arg = arguments.at(i).toLower();
- if (arg == QLatin1String("contents")) {
- m_contents = Hide;
- } else if (arg == QLatin1String("index")) {
- m_index = Hide;
- } else if (arg == QLatin1String("bookmarks")) {
- m_bookmarks = Hide;
- } else if (arg == QLatin1String("search")) {
- m_search = Hide;
- } else {
- error = QObject::tr("Unknown widget: %1").arg(arg);
- break;
- }
- } else {
- error = QObject::tr("Missing widget!");
- break;
- }
- } else if (arg == QLatin1String("-activate")) {
- if (CHECK_NEXT_ARG) {
- arg = arguments.at(i).toLower();
- if (arg == QLatin1String("contents")) {
- m_contents = Activate;
- } else if (arg == QLatin1String("index")) {
- m_index = Activate;
- } else if (arg == QLatin1String("bookmarks")) {
- m_bookmarks = Activate;
- } else if (arg == QLatin1String("search")) {
- m_search = Activate;
- } else {
- error = QObject::tr("Unknown widget: %1").arg(arg);
- break;
- }
- } else {
- error = QObject::tr("Missing widget!");
- break;
- }
- } else if (arg == QLatin1String("-register")) {
- if (CHECK_NEXT_ARG) {
- m_helpFile = getFileName(arguments.at(i));
- if (m_helpFile.isEmpty()) {
- error = QObject::tr("The specified Qt help file does not exist!");
- break;
- }
- m_register = Register;
- } else {
- error = QObject::tr("Missing help file!");
- break;
- }
- } else if (arg == QLatin1String("-unregister")) {
- if (CHECK_NEXT_ARG) {
- m_helpFile = getFileName(arguments.at(i));
- if (m_helpFile.isEmpty()) {
- error = QObject::tr("The specified Qt help file does not exist!");
- break;
- }
- m_register = Unregister;
- } else {
- error = QObject::tr("Missing help file!");
- break;
- }
- } else if (arg == QLatin1String("-setcurrentfilter")) {
- if (CHECK_NEXT_ARG) {
- m_currentFilter = arguments.at(i);
- } else {
- error = QObject::tr("Missing filter argument!");
- break;
- }
- } else if (arg == QLatin1String("-remove-search-index")) {
+ else if (arg == QLatin1String("-show"))
+ handleShowOption();
+ else if (arg == QLatin1String("-hide"))
+ handleHideOption();
+ else if (arg == QLatin1String("-activate"))
+ handleActivateOption();
+ else if (arg == QLatin1String("-register"))
+ handleRegisterOption();
+ else if (arg == QLatin1String("-unregister"))
+ handleUnregisterOption();
+ else if (arg == QLatin1String("-setcurrentfilter"))
+ handleSetCurrentFilterOption();
+ else if (arg == QLatin1String("-remove-search-index"))
m_removeSearchIndex = true;
- } else if (arg == QLatin1String("-quiet")) {
- continue;
- } else if (arg == QLatin1String("-help")) {
+ else if (arg == QLatin1String("-help"))
showHelp = true;
- } else if (arg == QLatin1String("-copy")) {
- m_copy = true;
- } else {
- error = QObject::tr("Unknown option: %1").arg(arg);
- break;
- }
+ else
+ m_error = tr("Unknown option: %1").arg(arg);
}
- if (!error.isEmpty()) {
- showMessage(error + QLatin1String("\n\n\n") + m_helpMessage, true);
+ if (!m_error.isEmpty()) {
+ showMessage(m_error + QLatin1String("\n\n\n") + m_helpMessage, true);
return Error;
} else if (showHelp) {
showMessage(m_helpMessage, false);
@@ -243,6 +139,110 @@ CmdLineParser::Result CmdLineParser::parse(const QStringList &arguments)
return Ok;
}
+bool CmdLineParser::hasMoreArgs() const
+{
+ return m_pos < m_arguments.count();
+}
+
+const QString &CmdLineParser::nextArg()
+{
+ Q_ASSERT(hasMoreArgs());
+ return m_arguments.at(m_pos++);
+}
+
+void CmdLineParser::handleCollectionFileOption()
+{
+ if (hasMoreArgs()) {
+ const QString &fileName = nextArg();
+ m_collectionFile = getFileName(fileName);
+ if (m_collectionFile.isEmpty())
+ m_error = tr("The collection file '%1' does not exist!").
+ arg(fileName);
+ } else {
+ m_error = tr("Missing collection file!");
+ }
+}
+
+void CmdLineParser::handleShowUrlOption()
+{
+ if (hasMoreArgs()) {
+ const QString &urlString = nextArg();
+ QUrl url(urlString);
+ if (url.isValid()) {
+ m_url = url;
+ } else
+ m_error = tr("Invalid URL '%1'!").arg(urlString);
+ } else {
+ m_error = tr("Missing URL!");
+ }
+}
+
+void CmdLineParser::handleShowOption()
+{
+ handleShowOrHideOrActivateOption(Show);
+}
+
+void CmdLineParser::handleHideOption()
+{
+ handleShowOrHideOrActivateOption(Hide);
+}
+
+void CmdLineParser::handleActivateOption()
+{
+ handleShowOrHideOrActivateOption(Activate);
+}
+
+void CmdLineParser::handleShowOrHideOrActivateOption(ShowState state)
+{
+ if (hasMoreArgs()) {
+ const QString &widget = nextArg().toLower();
+ if (widget == QLatin1String("contents"))
+ m_contents = state;
+ else if (widget == QLatin1String("index"))
+ m_index = state;
+ else if (widget == QLatin1String("bookmarks"))
+ m_bookmarks = state;
+ else if (widget == QLatin1String("search"))
+ m_search = state;
+ else
+ m_error = tr("Unknown widget: %1").arg(widget);
+ } else {
+ m_error = tr("Missing widget!");
+ }
+}
+
+void CmdLineParser::handleRegisterOption()
+{
+ handleRegisterOrUnregisterOption(Register);
+}
+
+void CmdLineParser::handleUnregisterOption()
+{
+ handleRegisterOrUnregisterOption(Unregister);
+}
+
+void CmdLineParser::handleRegisterOrUnregisterOption(RegisterState state)
+{
+ if (hasMoreArgs()) {
+ const QString &fileName = nextArg();
+ m_helpFile = getFileName(fileName);
+ if (m_helpFile.isEmpty())
+ m_error = tr("The Qt help file '%1' does not exist!").arg(fileName);
+ else
+ m_register = state;
+ } else {
+ m_error = tr("Missing help file!");
+ }
+}
+
+void CmdLineParser::handleSetCurrentFilterOption()
+{
+ if (hasMoreArgs())
+ m_currentFilter = nextArg();
+ else
+ m_error = tr("Missing filter argument!");
+}
+
QString CmdLineParser::getFileName(const QString &fileName)
{
QFileInfo fi(fileName);
diff --git a/tools/assistant/tools/assistant/cmdlineparser.h b/tools/assistant/tools/assistant/cmdlineparser.h
index 043e239c8..c1621d6d2 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.h
+++ b/tools/assistant/tools/assistant/cmdlineparser.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -42,6 +42,7 @@
#ifndef CMDLINEPARSER_H
#define CMDLINEPARSER_H
+#include <QtCore/QCoreApplication>
#include <QtCore/QStringList>
#include <QtCore/QUrl>
@@ -49,13 +50,14 @@ QT_BEGIN_NAMESPACE
class CmdLineParser
{
+ Q_DECLARE_TR_FUNCTIONS(CmdLineParser)
public:
enum Result {Ok, Help, Error};
enum ShowState {Untouched, Show, Hide, Activate};
enum RegisterState {None, Register, Unregister};
- CmdLineParser();
- Result parse(const QStringList &arguments);
+ CmdLineParser(const QStringList &arguments);
+ Result parse();
void setCollectionFile(const QString &file);
QString collectionFile() const;
@@ -71,14 +73,26 @@ public:
RegisterState registerRequest() const;
QString helpFile() const;
- bool copy() const { return m_copy; }
-
void showMessage(const QString &msg, bool error);
private:
QString getFileName(const QString &fileName);
+ bool hasMoreArgs() const;
+ const QString &nextArg();
+ void handleCollectionFileOption();
+ void handleShowUrlOption();
+ void handleShowOption();
+ void handleHideOption();
+ void handleActivateOption();
+ void handleShowOrHideOrActivateOption(ShowState state);
+ void handleRegisterOption();
+ void handleUnregisterOption();
+ void handleRegisterOrUnregisterOption(RegisterState state);
+ void handleSetCurrentFilterOption();
- QString m_helpMessage;
+ QStringList m_arguments;
+ int m_pos;
+ static const QString m_helpMessage;
QString m_collectionFile;
QString m_cloneFile;
QString m_helpFile;
@@ -92,8 +106,8 @@ private:
RegisterState m_register;
QString m_currentFilter;
bool m_removeSearchIndex;
- bool m_copy;
bool m_quiet;
+ QString m_error;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp
index 54784124d..17b19bab1 100644
--- a/tools/assistant/tools/assistant/contentwindow.cpp
+++ b/tools/assistant/tools/assistant/contentwindow.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,43 +21,40 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "contentwindow.h"
#include "centralwidget.h"
+#include "helpenginewrapper.h"
#include <QtGui/QLayout>
#include <QtGui/QFocusEvent>
#include <QtGui/QMenu>
-#include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpContentWidget>
QT_BEGIN_NAMESPACE
-ContentWindow::ContentWindow(QHelpEngine *helpEngine)
- : m_helpEngine(helpEngine)
- , m_contentWidget(0)
+ContentWindow::ContentWindow()
+ : m_contentWidget(HelpEngineWrapper::instance().contentWidget())
, m_expandDepth(-2)
{
- m_contentWidget = m_helpEngine->contentWidget();
m_contentWidget->viewport()->installEventFilter(this);
m_contentWidget->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -89,6 +87,7 @@ bool ContentWindow::syncToContent(const QUrl& url)
void ContentWindow::expandTOC()
{
+ Q_ASSERT(m_expandDepth >= -2);
if (m_expandDepth > -2) {
expandToDepth(m_expandDepth);
m_expandDepth = -2;
@@ -97,11 +96,14 @@ void ContentWindow::expandTOC()
void ContentWindow::expandToDepth(int depth)
{
+ Q_ASSERT(depth >= -2);
m_expandDepth = depth;
if (depth == -1)
m_contentWidget->expandAll();
+ else if (depth == 0)
+ m_contentWidget->collapseAll();
else
- m_contentWidget->expandToDepth(depth);
+ m_contentWidget->expandToDepth(depth - 1);
}
void ContentWindow::focusInEvent(QFocusEvent *e)
diff --git a/tools/assistant/tools/assistant/contentwindow.h b/tools/assistant/tools/assistant/contentwindow.h
index cfeb7b66a..639593221 100644
--- a/tools/assistant/tools/assistant/contentwindow.h
+++ b/tools/assistant/tools/assistant/contentwindow.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -57,7 +57,7 @@ class ContentWindow : public QWidget
Q_OBJECT
public:
- ContentWindow(QHelpEngine *helpEngine);
+ ContentWindow();
~ContentWindow();
bool syncToContent(const QUrl &url);
@@ -78,8 +78,7 @@ private:
bool eventFilter(QObject *o, QEvent *e);
bool isPdfFile(QHelpContentItem *item) const;
- QHelpEngine *m_helpEngine;
- QHelpContentWidget *m_contentWidget;
+ QHelpContentWidget * const m_contentWidget;
int m_expandDepth;
};
diff --git a/tools/assistant/tools/assistant/doc/assistant.qdoc b/tools/assistant/tools/assistant/doc/assistant.qdoc
index 0d1349065..0aeb6442f 100644
--- a/tools/assistant/tools/assistant/doc/assistant.qdoc
+++ b/tools/assistant/tools/assistant/doc/assistant.qdoc
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
/*!
\page assistant.html
\title Qt Assistant
diff --git a/tools/assistant/tools/assistant/doc/assistant.qdocconf b/tools/assistant/tools/assistant/doc/assistant.qdocconf
index 9566e90b0..08f8e2865 100644
--- a/tools/assistant/tools/assistant/doc/assistant.qdocconf
+++ b/tools/assistant/tools/assistant/doc/assistant.qdocconf
@@ -12,5 +12,5 @@ HTML.footer = "<p /><address><hr /><div align=\"center\">\n" \
"<table width=\"100%\" cellspacing=\"0\" border=\"0\"><tr class=\"address\">\n" \
"<td width=\"30%\" align=\"left\">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \
"<td width=\"40%\" align=\"center\">Trademarks</td>\n" \
- "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt 4.5.3</div></td>\n" \
+ "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt 4.7.0</div></td>\n" \
"</tr></table></div></address>"
diff --git a/tools/assistant/tools/assistant/filternamedialog.cpp b/tools/assistant/tools/assistant/filternamedialog.cpp
index ccf3e5fc3..781171e1e 100644
--- a/tools/assistant/tools/assistant/filternamedialog.cpp
+++ b/tools/assistant/tools/assistant/filternamedialog.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tools/assistant/tools/assistant/filternamedialog.h b/tools/assistant/tools/assistant/filternamedialog.h
index 3b1f0daf8..6346f6f23 100644
--- a/tools/assistant/tools/assistant/filternamedialog.h
+++ b/tools/assistant/tools/assistant/filternamedialog.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp
new file mode 100644
index 000000000..d399d1ebb
--- /dev/null
+++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp
@@ -0,0 +1,591 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Assistant of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "helpenginewrapper.h"
+#include "../shared/collectionconfiguration.h"
+
+#include <QtCore/QFileInfo>
+#include <QtCore/QFileSystemWatcher>
+#include <QtHelp/QHelpContentModel>
+#include <QtHelp/QHelpEngine>
+#include <QtHelp/QHelpIndexModel>
+#include <QtHelp/QHelpSearchEngine>
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+ const QString AppFontKey(QLatin1String("appFont"));
+ const QString AppWritingSystemKey(QLatin1String("appWritingSystem"));
+ const QString BookmarksKey(QLatin1String("Bookmarks"));
+ const QString BrowserFontKey(QLatin1String("browserFont"));
+ const QString BrowserWritingSystemKey(QLatin1String("browserWritingSystem"));
+ const QString HomePageKey(QLatin1String("homepage"));
+ const QString MainWindowKey(QLatin1String("MainWindow"));
+ const QString MainWindowGeometryKey(QLatin1String("MainWindowGeometry"));
+ const QString SearchWasAttachedKey(QLatin1String("SearchWasAttached"));
+ const QString StartOptionKey(QLatin1String("StartOption"));
+ const QString UnfilteredInsertedKey(QLatin1String("UnfilteredFilterInserted"));
+ const QString UseAppFontKey(QLatin1String("useAppFont"));
+ const QString UseBrowserFontKey(QLatin1String("useBrowserFont"));
+ const QString VersionKey(QString(QLatin1String("qtVersion%1$$$%2")).
+ arg(QLatin1String(QT_VERSION_STR)));
+} // anonymous namespace
+
+HelpEngineWrapper *HelpEngineWrapper::helpEngineWrapper = 0;
+
+HelpEngineWrapper &HelpEngineWrapper::instance(const QString &collectionFile)
+{
+ /*
+ * Note that this Singleton cannot be static, because it has to be
+ * deleted before the QApplication.
+ */
+ if (helpEngineWrapper == 0)
+ helpEngineWrapper = new HelpEngineWrapper(collectionFile);
+ return *helpEngineWrapper;
+}
+
+void HelpEngineWrapper::removeInstance()
+{
+ delete helpEngineWrapper;
+ helpEngineWrapper = 0;
+}
+
+HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile)
+ : m_helpEngine(new QHelpEngine(collectionFile, this)),
+ m_qchWatcher(new QFileSystemWatcher(this))
+{
+ connect(m_helpEngine, SIGNAL(currentFilterChanged(QString)),
+ this, SIGNAL(currentFilterChanged(QString)));
+ connect(m_helpEngine, SIGNAL(setupFinished()),
+ this, SIGNAL(setupFinished()));
+}
+
+void HelpEngineWrapper::initFileSystemWatchers()
+{
+ foreach(const QString &ns, m_helpEngine->registeredDocumentations()) {
+ const QString &docFile = m_helpEngine->documentationFileName(ns);
+ m_qchWatcher->addPath(docFile);
+ connect(m_qchWatcher, SIGNAL(fileChanged(QString)),
+ this, SLOT(qchFileChanged(QString)));
+ }
+ assertDocFilesWatched();
+}
+
+QHelpSearchEngine *HelpEngineWrapper::searchEngine() const
+{
+ return m_helpEngine->searchEngine();
+}
+
+QHelpContentModel *HelpEngineWrapper::contentModel() const
+{
+ return m_helpEngine->contentModel();
+}
+
+QHelpIndexModel *HelpEngineWrapper::indexModel() const
+{
+ return m_helpEngine->indexModel();
+}
+
+QHelpContentWidget *HelpEngineWrapper::contentWidget()
+{
+ return m_helpEngine->contentWidget();
+}
+
+QHelpIndexWidget *HelpEngineWrapper::indexWidget()
+{
+ return m_helpEngine->indexWidget();
+}
+
+const QStringList HelpEngineWrapper::registeredDocumentations() const
+{
+ return m_helpEngine->registeredDocumentations();
+}
+
+const QString HelpEngineWrapper::collectionFile() const
+{
+ return m_helpEngine->collectionFile();
+}
+
+bool HelpEngineWrapper::registerDocumentation(const QString &docFile)
+{
+ if (!m_helpEngine->registerDocumentation(docFile))
+ return false;
+ m_qchWatcher->addPath(docFile);
+ assertDocFilesWatched();
+ return true;
+}
+
+bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName)
+{
+ const QString &internalFile =
+ m_helpEngine->documentationFileName(namespaceName);
+ if (!m_helpEngine->unregisterDocumentation(namespaceName))
+ return false;
+ m_qchWatcher->removePath(internalFile);
+ assertDocFilesWatched();
+ return true;
+}
+
+bool HelpEngineWrapper::setupData()
+{
+ return m_helpEngine->setupData();
+}
+
+bool HelpEngineWrapper::addCustomFilter(const QString &filterName,
+ const QStringList &attributes)
+{
+ return m_helpEngine->addCustomFilter(filterName, attributes);
+}
+
+bool HelpEngineWrapper::removeCustomFilter(const QString &filterName)
+{
+ return m_helpEngine->removeCustomFilter(filterName);
+}
+
+void HelpEngineWrapper::setCurrentFilter(const QString &currentFilter)
+{
+ m_helpEngine->setCurrentFilter(currentFilter);
+}
+
+const QString HelpEngineWrapper::currentFilter() const
+{
+ return m_helpEngine->currentFilter();
+}
+
+const QStringList HelpEngineWrapper::customFilters() const
+{
+ return m_helpEngine->customFilters();
+}
+
+QUrl HelpEngineWrapper::findFile(const QUrl &url) const
+{
+ return m_helpEngine->findFile(url);
+}
+
+QByteArray HelpEngineWrapper::fileData(const QUrl &url) const
+{
+ return m_helpEngine->fileData(url);
+}
+
+QMap<QString, QUrl> HelpEngineWrapper::linksForIdentifier(const QString &id) const
+{
+ return m_helpEngine->linksForIdentifier(id);
+}
+
+const QStringList HelpEngineWrapper::filterAttributes() const
+{
+ return m_helpEngine->filterAttributes();
+}
+
+const QStringList HelpEngineWrapper::filterAttributes(const QString &filterName) const
+{
+ return m_helpEngine->filterAttributes(filterName);
+}
+
+QString HelpEngineWrapper::error() const
+{
+ return m_helpEngine->error();
+}
+
+bool HelpEngineWrapper::unfilteredInserted() const
+{
+ return m_helpEngine->customValue(UnfilteredInsertedKey).toInt() == 1;
+}
+
+void HelpEngineWrapper::setUnfilteredInserted()
+{
+ m_helpEngine->setCustomValue(UnfilteredInsertedKey, 1);
+}
+
+const QStringList HelpEngineWrapper::qtDocInfo(const QString &component) const
+{
+ return m_helpEngine->customValue(VersionKey.arg(component)).toString().
+ split(CollectionConfiguration::ListSeparator);
+}
+
+void HelpEngineWrapper::setQtDocInfo(const QString &component,
+ const QStringList &doc)
+{
+ m_helpEngine->setCustomValue(VersionKey.arg(component),
+ doc.join(CollectionConfiguration::ListSeparator));
+}
+
+const QStringList HelpEngineWrapper::lastShownPages() const
+{
+ return CollectionConfiguration::lastShownPages(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setLastShownPages(const QStringList &lastShownPages)
+{
+ CollectionConfiguration::setLastShownPages(*m_helpEngine, lastShownPages);
+}
+
+const QStringList HelpEngineWrapper::lastZoomFactors() const
+{
+ return CollectionConfiguration::lastZoomFactors(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setLastZoomFactors(const QStringList &lastZoomFactors)
+{
+ CollectionConfiguration::setLastZoomFactors(*m_helpEngine, lastZoomFactors);
+}
+
+const QString HelpEngineWrapper::cacheDir() const
+{
+ return CollectionConfiguration::cacheDir(*m_helpEngine);
+}
+
+bool HelpEngineWrapper::cacheDirIsRelativeToCollection() const
+{
+ return CollectionConfiguration::cacheDirIsRelativeToCollection(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setCacheDir(const QString &cacheDir,
+ bool relativeToCollection)
+{
+ CollectionConfiguration::setCacheDir(*m_helpEngine, cacheDir,
+ relativeToCollection);
+}
+
+bool HelpEngineWrapper::filterFunctionalityEnabled() const
+{
+ return CollectionConfiguration::filterFunctionalityEnabled(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setFilterFunctionalityEnabled(bool enabled)
+{
+ CollectionConfiguration::setFilterFunctionalityEnabled(*m_helpEngine,
+ enabled);
+}
+
+bool HelpEngineWrapper::filterToolbarVisible() const
+{
+ return CollectionConfiguration::filterToolbarVisible(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setFilterToolbarVisible(bool visible)
+{
+ CollectionConfiguration::setFilterToolbarVisible(*m_helpEngine, visible);
+}
+
+bool HelpEngineWrapper::addressBarEnabled() const
+{
+ return CollectionConfiguration::addressBarEnabled(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setAddressBarEnabled(bool enabled)
+{
+ CollectionConfiguration::setAddressBarEnabled(*m_helpEngine, enabled);
+}
+
+bool HelpEngineWrapper::addressBarVisible() const
+{
+ return CollectionConfiguration::addressBarVisible(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setAddressBarVisible(bool visible)
+{
+ CollectionConfiguration::setAddressBarVisible(*m_helpEngine, visible);
+}
+
+bool HelpEngineWrapper::documentationManagerEnabled() const
+{
+ return CollectionConfiguration::documentationManagerEnabled(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setDocumentationManagerEnabled(bool enabled)
+{
+ CollectionConfiguration::setDocumentationManagerEnabled(*m_helpEngine,
+ enabled);
+}
+
+const QByteArray HelpEngineWrapper::aboutMenuTexts() const
+{
+ return CollectionConfiguration::aboutMenuTexts(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setAboutMenuTexts(const QByteArray &texts)
+{
+ CollectionConfiguration::setAboutMenuTexts(*m_helpEngine, texts);
+}
+
+const QByteArray HelpEngineWrapper::aboutIcon() const
+{
+ return CollectionConfiguration::aboutIcon(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setAboutIcon(const QByteArray &icon)
+{
+ CollectionConfiguration::setAboutIcon(*m_helpEngine, icon);
+}
+
+const QByteArray HelpEngineWrapper::aboutImages() const
+{
+ return CollectionConfiguration::aboutImages(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setAboutImages(const QByteArray &images)
+{
+ CollectionConfiguration::setAboutImages(*m_helpEngine, images);
+}
+
+const QByteArray HelpEngineWrapper::aboutTexts() const
+{
+ return CollectionConfiguration::aboutTexts(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setAboutTexts(const QByteArray &texts)
+{
+ CollectionConfiguration::setAboutTexts(*m_helpEngine, texts);
+}
+
+const QString HelpEngineWrapper::windowTitle() const
+{
+ return CollectionConfiguration::windowTitle(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setWindowTitle(const QString &windowTitle)
+{
+ CollectionConfiguration::setWindowTitle(*m_helpEngine, windowTitle);
+}
+
+const QByteArray HelpEngineWrapper::applicationIcon() const
+{
+ return CollectionConfiguration::applicationIcon(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setApplicationIcon(const QByteArray &icon)
+{
+ CollectionConfiguration::setApplicationIcon(*m_helpEngine, icon);
+}
+
+const QByteArray HelpEngineWrapper::mainWindow() const
+{
+ return m_helpEngine->customValue(MainWindowKey).toByteArray();
+}
+
+void HelpEngineWrapper::setMainWindow(const QByteArray &mainWindow)
+{
+ m_helpEngine->setCustomValue(MainWindowKey, mainWindow);
+}
+
+const QByteArray HelpEngineWrapper::mainWindowGeometry() const
+{
+ return m_helpEngine->customValue(MainWindowGeometryKey).toByteArray();
+}
+
+void HelpEngineWrapper::setMainWindowGeometry(const QByteArray &geometry)
+{
+ m_helpEngine->setCustomValue(MainWindowGeometryKey, geometry);
+}
+
+const QByteArray HelpEngineWrapper::bookmarks() const
+{
+ return m_helpEngine->customValue(BookmarksKey).toByteArray();
+}
+
+void HelpEngineWrapper::setBookmarks(const QByteArray &bookmarks)
+{
+ m_helpEngine->setCustomValue(BookmarksKey, bookmarks);
+}
+
+int HelpEngineWrapper::lastTabPage() const
+{
+ return CollectionConfiguration::lastTabPage(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setLastTabPage(int lastPage)
+{
+ CollectionConfiguration::setLastTabPage(*m_helpEngine, lastPage);
+}
+
+bool HelpEngineWrapper::searchWasAttached() const
+{
+ return m_helpEngine->customValue(SearchWasAttachedKey).toBool();
+}
+
+void HelpEngineWrapper::setSearchWasAttached(bool attached)
+{
+ m_helpEngine->setCustomValue(SearchWasAttachedKey, attached);
+}
+
+int HelpEngineWrapper::startOption() const
+{
+ return m_helpEngine->customValue(StartOptionKey, ShowLastPages).toInt();
+}
+
+void HelpEngineWrapper::setStartOption(int option)
+{
+ m_helpEngine->setCustomValue(StartOptionKey, option);
+}
+
+const QString HelpEngineWrapper::homePage() const
+{
+ const QString &homePage = m_helpEngine->customValue(HomePageKey).toString();
+ if (!homePage.isEmpty())
+ return homePage;
+ return defaultHomePage();
+}
+
+void HelpEngineWrapper::setHomePage(const QString &page)
+{
+ m_helpEngine->setCustomValue(HomePageKey, page);
+
+}
+
+const QString HelpEngineWrapper::defaultHomePage() const
+{
+ return CollectionConfiguration::defaultHomePage(*m_helpEngine);
+}
+
+void HelpEngineWrapper::setDefaultHomePage(const QString &page)
+{
+ CollectionConfiguration::setDefaultHomePage(*m_helpEngine, page);
+}
+
+bool HelpEngineWrapper::hasFontSettings() const
+{
+ return m_helpEngine->customValue(UseAppFontKey).isValid();
+}
+
+bool HelpEngineWrapper::usesAppFont() const
+{
+ return m_helpEngine->customValue(UseAppFontKey).toBool();
+}
+
+void HelpEngineWrapper::setUseAppFont(bool useAppFont)
+{
+ m_helpEngine->setCustomValue(UseAppFontKey, useAppFont);
+}
+
+bool HelpEngineWrapper::usesBrowserFont() const
+{
+ return m_helpEngine->customValue(UseBrowserFontKey, false).toBool();
+}
+
+void HelpEngineWrapper::setUseBrowserFont(bool useBrowserFont)
+{
+ m_helpEngine->setCustomValue(UseBrowserFontKey, useBrowserFont);
+}
+
+const QFont HelpEngineWrapper::appFont() const
+{
+ return qVariantValue<QFont>(m_helpEngine->customValue(AppFontKey));
+}
+
+void HelpEngineWrapper::setAppFont(const QFont &font)
+{
+ m_helpEngine->setCustomValue(AppFontKey, font);
+}
+
+QFontDatabase::WritingSystem HelpEngineWrapper::appWritingSystem() const
+{
+ return static_cast<QFontDatabase::WritingSystem>(
+ m_helpEngine->customValue(AppWritingSystemKey).toInt());
+}
+
+void HelpEngineWrapper::setAppWritingSystem(QFontDatabase::WritingSystem system)
+{
+ m_helpEngine->setCustomValue(AppWritingSystemKey, system);
+}
+
+const QFont HelpEngineWrapper::browserFont() const
+{
+ return qVariantValue<QFont>(m_helpEngine->customValue(BrowserFontKey));
+}
+
+void HelpEngineWrapper::setBrowserFont(const QFont &font)
+{
+ m_helpEngine->setCustomValue(BrowserFontKey, font);
+}
+
+QFontDatabase::WritingSystem HelpEngineWrapper::browserWritingSystem() const
+{
+ return static_cast<QFontDatabase::WritingSystem>(
+ m_helpEngine->customValue(BrowserWritingSystemKey).toInt());
+}
+
+void HelpEngineWrapper::setBrowserWritingSystem(QFontDatabase::WritingSystem system)
+{
+ m_helpEngine->setCustomValue(BrowserWritingSystemKey, system);
+}
+
+
+void HelpEngineWrapper::assertDocFilesWatched()
+{
+ Q_ASSERT(m_qchWatcher->files().count()
+ == m_helpEngine->registeredDocumentations().count());
+}
+
+void HelpEngineWrapper::qchFileChanged(const QString &fileName)
+{
+ /*
+ * We don't use QHelpEngineCore::namespaceName(fileName), because the file
+ * may not exist anymore or contain a different namespace.
+ */
+ QString ns;
+ foreach (const QString &curNs, m_helpEngine->registeredDocumentations()) {
+ if (m_helpEngine->documentationFileName(curNs) == fileName) {
+ ns = curNs;
+ break;
+ }
+ }
+
+ /*
+ * We can't do an assertion here, because QFileSystemWatcher may send the
+ * signal more than once.
+ */
+ if (ns.isEmpty())
+ return;
+
+ if (m_helpEngine->unregisterDocumentation(ns)) {
+ if (!QFileInfo(fileName).exists()
+ || !m_helpEngine->registerDocumentation(fileName)) {
+ m_qchWatcher->removePath(fileName);
+ emit documentationRemoved(ns);
+ } else {
+ emit documentationUpdated(ns);
+ }
+ m_helpEngine->setupData();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h
new file mode 100644
index 000000000..1fc9eb60e
--- /dev/null
+++ b/tools/assistant/tools/assistant/helpenginewrapper.h
@@ -0,0 +1,212 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Assistant of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HELPENGINEWRAPPER_H
+#define HELPENGINEWRAPPER_H
+
+#include <QtCore/QMap>
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QUrl>
+#include <QtGui/QFont>
+#include <QtGui/QFontDatabase>
+
+QT_BEGIN_NAMESPACE
+
+class QFileSystemWatcher;
+class QHelpContentModel;
+class QHelpContentWidget;
+class QHelpEngine;
+class QHelpEngineCore;
+class QHelpIndexModel;
+class QHelpIndexWidget;
+class QHelpSearchEngine;
+
+enum {
+ ShowHomePage = 0,
+ ShowBlankPage = 1,
+ ShowLastPages = 2
+};
+
+class HelpEngineWrapper : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(HelpEngineWrapper)
+public:
+ static HelpEngineWrapper &instance(const QString &collectionFile = QString());
+ static void removeInstance();
+
+ void initFileSystemWatchers();
+
+ // Forwarded help engine member functions, possibly enriched.
+ QHelpSearchEngine *searchEngine() const;
+ QHelpContentModel *contentModel() const;
+ QHelpIndexModel *indexModel() const;
+ QHelpContentWidget *contentWidget();
+ QHelpIndexWidget *indexWidget();
+ bool setupData();
+ const QStringList registeredDocumentations() const;
+ const QString collectionFile() const;
+ bool registerDocumentation(const QString &docFile);
+ bool unregisterDocumentation(const QString &namespaceName);
+ bool addCustomFilter(const QString &filterName,
+ const QStringList &attributes);
+ bool removeCustomFilter(const QString &filterName);
+ void setCurrentFilter(const QString &filterName);
+ const QString currentFilter() const;
+ const QStringList customFilters() const;
+ QUrl findFile(const QUrl &url) const;
+ QByteArray fileData(const QUrl &url) const;
+ QMap<QString, QUrl> linksForIdentifier(const QString &id) const;
+ const QStringList filterAttributes() const;
+ const QStringList filterAttributes(const QString &filterName) const;
+ QString error() const;
+
+ // Access to a collection's custom values.
+ bool unfilteredInserted() const;
+ void setUnfilteredInserted();
+
+ const QStringList qtDocInfo(const QString &component) const;
+ void setQtDocInfo(const QString &component, const QStringList &doc);
+
+ const QString homePage() const;
+ void setHomePage(const QString &page);
+ const QString defaultHomePage() const;
+ void setDefaultHomePage(const QString &page);
+
+ int lastTabPage() const;
+ void setLastTabPage(int lastPage);
+
+ // TODO: Don't allow last pages and zoom factors to be set in isolation
+ // Perhaps also fill up missing elements automatically or assert.
+ const QStringList lastShownPages() const;
+ void setLastShownPages(const QStringList &lastShownPages);
+ const QStringList lastZoomFactors() const;
+ void setLastZoomFactors(const QStringList &lastZoomFactors);
+
+ const QString cacheDir() const;
+ bool cacheDirIsRelativeToCollection() const;
+ void setCacheDir(const QString &cacheDir, bool relativeToCollection);
+
+ bool filterFunctionalityEnabled() const;
+ void setFilterFunctionalityEnabled(bool enabled);
+
+ bool filterToolbarVisible() const;
+ void setFilterToolbarVisible(bool visible);
+
+ bool addressBarEnabled() const;
+ void setAddressBarEnabled(bool enabled);
+
+ bool addressBarVisible() const;
+ void setAddressBarVisible(bool visible);
+
+ bool documentationManagerEnabled() const;
+ void setDocumentationManagerEnabled(bool enabled);
+
+ const QByteArray aboutMenuTexts() const;
+ void setAboutMenuTexts(const QByteArray &texts);
+ const QByteArray aboutTexts() const;
+ void setAboutTexts(const QByteArray &texts);
+ const QByteArray aboutIcon() const;
+ void setAboutIcon(const QByteArray &icon);
+ const QByteArray aboutImages() const;
+ void setAboutImages(const QByteArray &images);
+
+ const QString windowTitle() const;
+ void setWindowTitle(const QString &windowTitle);
+
+ const QByteArray applicationIcon() const;
+ void setApplicationIcon(const QByteArray &icon);
+
+ const QByteArray mainWindow() const;
+ void setMainWindow(const QByteArray &mainWindow);
+ const QByteArray mainWindowGeometry() const;
+ void setMainWindowGeometry(const QByteArray &geometry);
+
+ const QByteArray bookmarks() const;
+ void setBookmarks(const QByteArray &bookmarks);
+
+ int startOption() const;
+ void setStartOption(int option);
+
+ bool searchWasAttached() const;
+ void setSearchWasAttached(bool attached);
+
+ bool hasFontSettings() const;
+ bool usesAppFont() const;
+ void setUseAppFont(bool useAppFont);
+ bool usesBrowserFont() const;
+ void setUseBrowserFont(bool useBrowserFont);
+ const QFont appFont() const;
+ void setAppFont(const QFont &font);
+ QFontDatabase::WritingSystem appWritingSystem() const;
+ void setAppWritingSystem(QFontDatabase::WritingSystem system);
+ const QFont browserFont() const;
+ void setBrowserFont(const QFont &font);
+ QFontDatabase::WritingSystem browserWritingSystem() const;
+ void setBrowserWritingSystem(QFontDatabase::WritingSystem system);
+
+signals:
+
+ // For asynchronous doc updates triggered by external actions.
+ void documentationRemoved(const QString &namespaceName);
+ void documentationUpdated(const QString &namespaceName);
+
+ // Forwarded from QHelpEngineCore.
+ void currentFilterChanged(const QString &currentFilter);
+ void setupFinished();
+
+private slots:
+ void qchFileChanged(const QString &fileName);
+
+private:
+ HelpEngineWrapper(const QString &collectionFile);
+ void assertDocFilesWatched();
+
+ static HelpEngineWrapper *helpEngineWrapper;
+ QHelpEngine * const m_helpEngine;
+ QFileSystemWatcher * const m_qchWatcher;
+};
+
+QT_END_NAMESPACE
+
+#endif // HELPENGINEWRAPPER_H
diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp
index a89ef62ed..5f2c02bfc 100644
--- a/tools/assistant/tools/assistant/helpviewer.cpp
+++ b/tools/assistant/tools/assistant/helpviewer.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,27 +21,27 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "helpviewer.h"
#include "centralwidget.h"
+#include "helpenginewrapper.h"
#include <QtCore/QDir>
#include <QtCore/QEvent>
@@ -55,14 +56,18 @@
#include <QtGui/QMessageBox>
#include <QtGui/QDesktopServices>
-#include <QtHelp/QHelpEngine>
-
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
QT_BEGIN_NAMESPACE
+namespace {
+ const QString PageNotFoundMessage =
+ QObject::tr("<title>Error 404...</title><div align=\"center\"><br><br>"
+ "<h1>The page could not be found</h1><br><h3>'%1'</h3></div>");
+}
+
#if !defined(QT_NO_WEBKIT)
class HelpNetworkReply : public QNetworkReply
@@ -117,50 +122,47 @@ qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen)
class HelpNetworkAccessManager : public QNetworkAccessManager
{
public:
- HelpNetworkAccessManager(QHelpEngine *engine, QObject *parent);
+ HelpNetworkAccessManager(QObject *parent);
protected:
virtual QNetworkReply *createRequest(Operation op,
const QNetworkRequest &request, QIODevice *outgoingData = 0);
-
-private:
- QHelpEngine *helpEngine;
};
-HelpNetworkAccessManager::HelpNetworkAccessManager(QHelpEngine *engine,
- QObject *parent)
- : QNetworkAccessManager(parent), helpEngine(engine)
+HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent)
+ : QNetworkAccessManager(parent)
{
}
-QNetworkReply *HelpNetworkAccessManager::createRequest(Operation op,
- const QNetworkRequest &request, QIODevice *outgoingData)
+QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
+ const QNetworkRequest &request, QIODevice* /*outgoingData*/)
{
- const QString& scheme = request.url().scheme();
- if (scheme == QLatin1String("qthelp") || scheme == QLatin1String("about")) {
- const QUrl& url = request.url();
- QString mimeType = url.toString();
- if (mimeType.endsWith(QLatin1String(".svg"))
- || mimeType.endsWith(QLatin1String(".svgz"))) {
- mimeType = QLatin1String("image/svg+xml");
- }
- else if (mimeType.endsWith(QLatin1String(".css"))) {
- mimeType = QLatin1String("text/css");
- }
- else if (mimeType.endsWith(QLatin1String(".js"))) {
- mimeType = QLatin1String("text/javascript");
- } else {
- mimeType = QLatin1String("text/html");
- }
- return new HelpNetworkReply(request, helpEngine->fileData(url), mimeType);
+ const QUrl& url = request.url();
+ QString mimeType = url.toString();
+ if (mimeType.endsWith(QLatin1String(".svg"))
+ || mimeType.endsWith(QLatin1String(".svgz"))) {
+ mimeType = QLatin1String("image/svg+xml");
+ }
+ else if (mimeType.endsWith(QLatin1String(".css"))) {
+ mimeType = QLatin1String("text/css");
+ }
+ else if (mimeType.endsWith(QLatin1String(".js"))) {
+ mimeType = QLatin1String("text/javascript");
+ } else {
+ mimeType = QLatin1String("text/html");
}
- return QNetworkAccessManager::createRequest(op, request, outgoingData);
+
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ const QByteArray &data = helpEngine.findFile(url).isValid()
+ ? helpEngine.fileData(url)
+ : PageNotFoundMessage.arg(url.toString()).toUtf8();
+ return new HelpNetworkReply(request, data, mimeType);
}
class HelpPage : public QWebPage
{
public:
- HelpPage(CentralWidget *central, QHelpEngine *engine, QObject *parent);
+ HelpPage(CentralWidget *central, QObject *parent);
protected:
virtual QWebPage *createWindow(QWebPage::WebWindowType);
@@ -171,7 +173,6 @@ protected:
private:
CentralWidget *centralWidget;
- QHelpEngine *helpEngine;
bool closeNewTabIfNeeded;
friend class HelpViewer;
@@ -179,10 +180,9 @@ private:
Qt::KeyboardModifiers m_keyboardModifiers;
};
-HelpPage::HelpPage(CentralWidget *central, QHelpEngine *engine, QObject *parent)
+HelpPage::HelpPage(CentralWidget *central, QObject *parent)
: QWebPage(parent)
, centralWidget(central)
- , helpEngine(engine)
, closeNewTabIfNeeded(false)
, m_pressedButtons(Qt::NoButton)
, m_keyboardModifiers(Qt::NoModifier)
@@ -241,7 +241,7 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *,
QFile tmpFile(QDir::cleanPath(fileName));
if (tmpFile.open(QIODevice::ReadWrite)) {
- tmpFile.write(helpEngine->fileData(url));
+ tmpFile.write(HelpEngineWrapper::instance().fileData(url));
tmpFile.close();
}
QDesktopServices::openUrl(QUrl(tmpFile.fileName()));
@@ -268,17 +268,17 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *,
return false;
}
-HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent)
+HelpViewer::HelpViewer(CentralWidget *parent)
: QWebView(parent)
- , helpEngine(engine)
, parentWidget(parent)
, loadFinished(false)
+ , helpEngine(HelpEngineWrapper::instance())
{
setAcceptDrops(false);
- setPage(new HelpPage(parent, helpEngine, this));
+ setPage(new HelpPage(parent, this));
- page()->setNetworkAccessManager(new HelpNetworkAccessManager(engine, this));
+ page()->setNetworkAccessManager(new HelpNetworkAccessManager(this));
QAction* action = pageAction(QWebPage::OpenLinkInNewWindow);
action->setText(tr("Open Link in New Tab"));
@@ -295,7 +295,7 @@ HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent)
SLOT(actionChanged()));
connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this,
SLOT(actionChanged()));
- connect(page(), SIGNAL(linkHovered(QString, QString, QString)), this,
+ connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this,
SIGNAL(highlighted(QString)));
connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
@@ -327,19 +327,6 @@ void HelpViewer::zoomOut(qreal range)
setTextSizeMultiplier(qMax(0.0, textSizeMultiplier() - range / 10.0));
}
-void HelpViewer::home()
-{
- QString homepage = helpEngine->customValue(QLatin1String("homepage"),
- QLatin1String("")).toString();
-
- if (homepage.isEmpty()) {
- homepage = helpEngine->customValue(QLatin1String("defaultHomepage"),
- QLatin1String("help")).toString();
- }
-
- setSource(homepage);
-}
-
void HelpViewer::wheelEvent(QWheelEvent *e)
{
if (e->modifiers() & Qt::ControlModifier) {
@@ -398,13 +385,13 @@ void HelpViewer::setLoadFinished(bool ok)
#else // !defined(QT_NO_WEBKIT)
-HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent)
+HelpViewer::HelpViewer(CentralWidget *parent)
: QTextBrowser(parent)
, zoomCount(0)
, controlPressed(false)
, lastAnchor(QString())
- , helpEngine(engine)
, parentWidget(parent)
+ , helpEngine(HelpEngineWrapper::instance())
{
document()->setDocumentMargin(8);
}
@@ -416,7 +403,7 @@ void HelpViewer::setSource(const QUrl &url)
if (launchedWithExternalApp(url))
return;
- QUrl u = helpEngine->findFile(url);
+ QUrl u = helpEngine.findFile(url);
if (u.isValid()) {
QTextBrowser::setSource(u);
return;
@@ -428,9 +415,7 @@ void HelpViewer::setSource(const QUrl &url)
"assistantinternal-1.0.0/assistant/assistant.html")));
} else {
QTextBrowser::setSource(url);
- setHtml(tr("<title>Error 404...</title><div align=\"center\"><br><br>"
- "<h1>The page could not be found</h1><br><h3>'%1'</h3></div>")
- .arg(url.toString()));
+ setHtml(PageNotFoundMessage.arg(url.toString()));
emit sourceChanged(url);
}
}
@@ -480,7 +465,7 @@ bool HelpViewer::launchedWithExternalApp(const QUrl &url)
QFile tmpFile(QDir::cleanPath(fileName));
if (tmpFile.open(QIODevice::ReadWrite)) {
- tmpFile.write(helpEngine->fileData(url));
+ tmpFile.write(helpEngine.fileData(url));
tmpFile.close();
}
launched = QDesktopServices::openUrl(QUrl(tmpFile.fileName()));
@@ -501,7 +486,7 @@ QVariant HelpViewer::loadResource(int type, const QUrl &name)
{
QByteArray ba;
if (type < 4) {
- ba = helpEngine->fileData(name);
+ ba = helpEngine.fileData(name);
if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) {
QImage image;
image.loadFromData(ba, "svg");
@@ -599,19 +584,6 @@ void HelpViewer::keyPressEvent(QKeyEvent *e)
QTextBrowser::keyPressEvent(e);
}
-void HelpViewer::home()
-{
- QString homepage = helpEngine->customValue(QLatin1String("homepage"),
- QLatin1String("")).toString();
-
- if (homepage.isEmpty()) {
- homepage = helpEngine->customValue(QLatin1String("defaultHomepage"),
- QLatin1String("help")).toString();
- }
-
- setSource(homepage);
-}
-
void HelpViewer::wheelEvent(QWheelEvent *e)
{
if (e->modifiers() == Qt::CTRL) {
@@ -625,4 +597,9 @@ void HelpViewer::wheelEvent(QWheelEvent *e)
#endif // !defined(QT_NO_WEBKIT)
+void HelpViewer::home()
+{
+ setSource(helpEngine.homePage());
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h
index ce0ed91eb..64742b571 100644
--- a/tools/assistant/tools/assistant/helpviewer.h
+++ b/tools/assistant/tools/assistant/helpviewer.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -53,8 +53,8 @@
QT_BEGIN_NAMESPACE
-class QHelpEngine;
class CentralWidget;
+class HelpEngineWrapper;
class QPoint;
class QString;
@@ -69,7 +69,7 @@ class HelpViewer : public QWebView
Q_OBJECT
public:
- HelpViewer(QHelpEngine *helpEngine, CentralWidget *parent);
+ HelpViewer(CentralWidget *parent);
void setSource(const QUrl &url);
inline QUrl source() const
@@ -118,9 +118,9 @@ private Q_SLOTS:
void setLoadFinished(bool ok);
private:
- QHelpEngine *helpEngine;
CentralWidget* parentWidget;
bool loadFinished;
+ HelpEngineWrapper &helpEngine;
};
#else
@@ -130,7 +130,7 @@ class HelpViewer : public QTextBrowser
Q_OBJECT
public:
- HelpViewer(QHelpEngine *helpEngine, CentralWidget *parent);
+ HelpViewer(CentralWidget *parent);
void setSource(const QUrl &url);
void resetZoom();
@@ -165,8 +165,8 @@ private:
int zoomCount;
bool controlPressed;
QString lastAnchor;
- QHelpEngine *helpEngine;
CentralWidget* parentWidget;
+ HelpEngineWrapper &helpEngine;
};
#endif
diff --git a/tools/assistant/tools/assistant/images/bookmark.png b/tools/assistant/tools/assistant/images/bookmark.png
new file mode 100644
index 000000000..57e57e343
--- /dev/null
+++ b/tools/assistant/tools/assistant/images/bookmark.png
Binary files differ
diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp
index 31c1efbfe..78cc2381d 100644
--- a/tools/assistant/tools/assistant/indexwindow.cpp
+++ b/tools/assistant/tools/assistant/indexwindow.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,27 +21,27 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "indexwindow.h"
#include "centralwidget.h"
+#include "helpenginewrapper.h"
#include "topicchooser.h"
#include <QtGui/QLayout>
@@ -51,22 +52,19 @@
#include <QtGui/QContextMenuEvent>
#include <QtGui/QListWidgetItem>
-#include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpIndexWidget>
QT_BEGIN_NAMESPACE
-IndexWindow::IndexWindow(QHelpEngine *helpEngine, QWidget *parent)
+IndexWindow::IndexWindow(QWidget *parent)
: QWidget(parent)
- , m_searchLineEdit(0)
- , m_indexWidget(0)
- , m_helpEngine(helpEngine)
+ , m_searchLineEdit(new QLineEdit)
+ , m_indexWidget(HelpEngineWrapper::instance().indexWidget())
{
QVBoxLayout *layout = new QVBoxLayout(this);
QLabel *l = new QLabel(tr("&Look for:"));
layout->addWidget(l);
- m_searchLineEdit = new QLineEdit();
l->setBuddy(m_searchLineEdit);
connect(m_searchLineEdit, SIGNAL(textChanged(QString)), this,
SLOT(filterIndices(QString)));
@@ -74,16 +72,16 @@ IndexWindow::IndexWindow(QHelpEngine *helpEngine, QWidget *parent)
layout->setMargin(4);
layout->addWidget(m_searchLineEdit);
- m_indexWidget = m_helpEngine->indexWidget();
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
m_indexWidget->installEventFilter(this);
- connect(m_helpEngine->indexModel(), SIGNAL(indexCreationStarted()), this,
+ connect(helpEngine.indexModel(), SIGNAL(indexCreationStarted()), this,
SLOT(disableSearchLineEdit()));
- connect(m_helpEngine->indexModel(), SIGNAL(indexCreated()), this,
+ connect(helpEngine.indexModel(), SIGNAL(indexCreated()), this,
SLOT(enableSearchLineEdit()));
- connect(m_indexWidget, SIGNAL(linkActivated(QUrl, QString)), this,
+ connect(m_indexWidget, SIGNAL(linkActivated(QUrl,QString)), this,
SIGNAL(linkActivated(QUrl)));
- connect(m_indexWidget, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)),
- this, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)));
+ connect(m_indexWidget, SIGNAL(linksActivated(QMap<QString,QUrl>,QString)),
+ this, SIGNAL(linksActivated(QMap<QString,QUrl>,QString)));
connect(m_searchLineEdit, SIGNAL(returnPressed()), m_indexWidget,
SLOT(activateCurrentItem()));
layout->addWidget(m_indexWidget);
@@ -112,18 +110,22 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e)
case Qt::Key_Up:
idx = m_indexWidget->model()->index(idx.row()-1,
idx.column(), idx.parent());
- if (idx.isValid())
+ if (idx.isValid()) {
m_indexWidget->setCurrentIndex(idx);
+ return true;
+ }
break;
case Qt::Key_Down:
idx = m_indexWidget->model()->index(idx.row()+1,
idx.column(), idx.parent());
- if (idx.isValid())
+ if (idx.isValid()) {
m_indexWidget->setCurrentIndex(idx);
+ return true;
+ }
break;
case Qt::Key_Escape:
emit escapePressed();
- break;
+ return true;
default: ; // stop complaining
}
} else if (obj == m_indexWidget && e->type() == QEvent::ContextMenu) {
diff --git a/tools/assistant/tools/assistant/indexwindow.h b/tools/assistant/tools/assistant/indexwindow.h
index 00da14108..6fbb250b5 100644
--- a/tools/assistant/tools/assistant/indexwindow.h
+++ b/tools/assistant/tools/assistant/indexwindow.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +49,6 @@
QT_BEGIN_NAMESPACE
class QHelpIndexWidget;
-class QHelpEngine;
class QModelIndex;
class IndexWindow : public QWidget
@@ -57,7 +56,7 @@ class IndexWindow : public QWidget
Q_OBJECT
public:
- IndexWindow(QHelpEngine *helpEngine, QWidget *parent = 0);
+ IndexWindow(QWidget *parent = 0);
~IndexWindow();
void setSearchLineEditText(const QString &text);
@@ -84,7 +83,6 @@ private:
QLineEdit *m_searchLineEdit;
QHelpIndexWidget *m_indexWidget;
- QHelpEngine *m_helpEngine;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/installdialog.cpp b/tools/assistant/tools/assistant/installdialog.cpp
index ae190e007..ea0bd2998 100644
--- a/tools/assistant/tools/assistant/installdialog.cpp
+++ b/tools/assistant/tools/assistant/installdialog.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -76,12 +76,12 @@ InstallDialog::InstallDialog(QHelpEngineCore *helpEngine, QWidget *parent,
m_windowTitle = tr("Install Documentation");
m_http = new QHttp(this);
- connect(m_http, SIGNAL(requestFinished(int, bool)),
- this, SLOT(httpRequestFinished(int, bool)));
- connect(m_http, SIGNAL(dataReadProgress(int, int)),
- this, SLOT(updateDataReadProgress(int, int)));
- connect(m_http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
- this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
+ connect(m_http, SIGNAL(requestFinished(int,bool)),
+ this, SLOT(httpRequestFinished(int,bool)));
+ connect(m_http, SIGNAL(dataReadProgress(int,int)),
+ this, SLOT(updateDataReadProgress(int,int)));
+ connect(m_http, SIGNAL(responseHeaderReceived(QHttpResponseHeader)),
+ this, SLOT(readResponseHeader(QHttpResponseHeader)));
connect(m_ui.installButton, SIGNAL(clicked()), this, SLOT(install()));
connect(m_ui.cancelButton, SIGNAL(clicked()), this, SLOT(cancelDownload()));
connect(m_ui.browseButton, SIGNAL(clicked()), this, SLOT(browseDirectories()));
diff --git a/tools/assistant/tools/assistant/installdialog.h b/tools/assistant/tools/assistant/installdialog.h
index d9fb0415d..ac7f94c18 100644
--- a/tools/assistant/tools/assistant/installdialog.h
+++ b/tools/assistant/tools/assistant/installdialog.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp
index ea0fc9e24..536095c7d 100644
--- a/tools/assistant/tools/assistant/main.cpp
+++ b/tools/assistant/tools/assistant/main.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -56,9 +56,13 @@
#include <QtSql/QSqlDatabase>
+#include "../shared/collectionconfiguration.h"
+#include "helpenginewrapper.h"
#include "mainwindow.h"
#include "cmdlineparser.h"
+// #define TRACING_REQUESTED
+
QT_USE_NAMESPACE
#if defined(USE_STATIC_SQLITE_PLUGIN)
@@ -66,89 +70,38 @@ QT_USE_NAMESPACE
Q_IMPORT_PLUGIN(qsqlite)
#endif
+namespace {
+
void
updateLastPagesOnUnregister(QHelpEngineCore& helpEngine, const QString& nsName)
{
- int lastPage = helpEngine.customValue(QLatin1String("LastTabPage")).toInt();
-
- QLatin1String sep("|");
- QLatin1String pages("LastShownPages");
-#if !defined(QT_NO_WEBKIT)
- QLatin1String zoom("LastPagesZoomWebView");
-#else
- QLatin1String zoom("LastPagesZoomTextBrowser");
-#endif
-
- QStringList currentPages =
- helpEngine.customValue(pages).toString().
- split(QLatin1Char('|'), QString::SkipEmptyParts);
-
+ int lastPage = CollectionConfiguration::lastTabPage(helpEngine);
+ QStringList currentPages = CollectionConfiguration::lastShownPages(helpEngine);
if (!currentPages.isEmpty()) {
- QVector<QString>zoomList = helpEngine.customValue(zoom).toString().
- split(sep, QString::SkipEmptyParts).toVector();
- if (zoomList.isEmpty())
- zoomList.fill(QLatin1String("0.0"), currentPages.size());
- else if(zoomList.count() < currentPages.count()) {
- zoomList.insert(zoomList.count(),
- currentPages.count() - zoomList.count(), QLatin1String("0.0"));
- }
+ QStringList zoomList = CollectionConfiguration::lastZoomFactors(helpEngine);
+ while (zoomList.count() < currentPages.count())
+ zoomList.append(CollectionConfiguration::DefaultZoomFactor);
for (int i = currentPages.count(); --i >= 0;) {
if (QUrl(currentPages.at(i)).host() == nsName) {
- zoomList.remove(i);
+ zoomList.removeAt(i);
currentPages.removeAt(i);
lastPage = (lastPage == (i + 1)) ? 1 : lastPage;
}
}
- helpEngine.setCustomValue(pages, currentPages.join(sep));
- helpEngine.setCustomValue(QLatin1String("LastTabPage"), lastPage);
- helpEngine.setCustomValue(zoom, QStringList(zoomList.toList()).join(sep));
+ CollectionConfiguration::setLastShownPages(helpEngine, currentPages);
+ CollectionConfiguration::setLastTabPage(helpEngine, lastPage);
+ CollectionConfiguration::setLastZoomFactors(helpEngine, zoomList);
}
}
bool
updateUserCollection(QHelpEngineCore& user, const QHelpEngineCore& caller)
{
- const uint callerCollectionCreationTime = caller.
- customValue(QLatin1String("CreationTime"), 0).toUInt();
- const uint userCollectionCreationTime = user.
- customValue(QLatin1String("CreationTime"), 1).toUInt();
-
- if (callerCollectionCreationTime == userCollectionCreationTime)
+ if (!CollectionConfiguration::isNewer(caller, user))
return false;
-
- user.setCustomValue(QLatin1String("CreationTime"),
- callerCollectionCreationTime);
- user.setCustomValue(QLatin1String("WindowTitle"),
- caller.customValue(QLatin1String("WindowTitle")));
- user.setCustomValue(QLatin1String("LastShownPages"),
- caller.customValue(QLatin1String("LastShownPages")));
- user.setCustomValue(QLatin1String("CurrentFilter"),
- caller.customValue(QLatin1String("CurrentFilter")));
- user.setCustomValue(QLatin1String("CacheDirectory"),
- caller.customValue(QLatin1String("CacheDirectory")));
- user.setCustomValue(QLatin1String("EnableFilterFunctionality"),
- caller.customValue(QLatin1String("EnableFilterFunctionality")));
- user.setCustomValue(QLatin1String("HideFilterFunctionality"),
- caller.customValue(QLatin1String("HideFilterFunctionality")));
- user.setCustomValue(QLatin1String("EnableDocumentationManager"),
- caller.customValue(QLatin1String("EnableDocumentationManager")));
- user.setCustomValue(QLatin1String("EnableAddressBar"),
- caller.customValue(QLatin1String("EnableAddressBar")));
- user.setCustomValue(QLatin1String("HideAddressBar"),
- caller.customValue(QLatin1String("HideAddressBar")));
- user.setCustomValue(QLatin1String("ApplicationIcon"),
- caller.customValue(QLatin1String("ApplicationIcon")));
- user.setCustomValue(QLatin1String("AboutMenuTexts"),
- caller.customValue(QLatin1String("AboutMenuTexts")));
- user.setCustomValue(QLatin1String("AboutIcon"),
- caller.customValue(QLatin1String("AboutIcon")));
- user.setCustomValue(QLatin1String("AboutTexts"),
- caller.customValue(QLatin1String("AboutTexts")));
- user.setCustomValue(QLatin1String("AboutImages"),
- caller.customValue(QLatin1String("AboutImages")));
-
+ CollectionConfiguration::copyConfiguration(caller, user);
return true;
}
@@ -179,27 +132,116 @@ QString indexFilesFolder(const QString &collectionFile)
return indexFilesFolder;
}
-int main(int argc, char *argv[])
+/*
+ * Returns the expected absolute file path of the cached collection file
+ * correspondinging to the given collection's file.
+ * It may or may not exist yet.
+ */
+QString cachedCollectionFile(const QHelpEngineCore &collection)
+{
+ const QString &filePath = collection.collectionFile();
+ const QString &fileName = QFileInfo(filePath).fileName();
+ const QString &cacheDir = CollectionConfiguration::cacheDir(collection);
+ const QString &dir = !cacheDir.isEmpty()
+ && CollectionConfiguration::cacheDirIsRelativeToCollection(collection)
+ ? QFileInfo(filePath).dir().absolutePath()
+ + QDir::separator() + cacheDir
+ : MainWindow::collectionFileDirectory(false, cacheDir);
+ return dir + QDir::separator() + fileName;
+}
+
+bool synchronizeDocs(QHelpEngineCore &collection,
+ QHelpEngineCore &cachedCollection)
+{
+ const QStringList &docs = collection.registeredDocumentations();
+ const QStringList &cachedDocs = cachedCollection.registeredDocumentations();
+
+ /*
+ * Step 1: Ensure that the cached collection contains all docs that
+ * the collection contains.
+ */
+ foreach (const QString &doc, docs) {
+ if (!cachedDocs.contains(doc)) {
+ if (!cachedCollection.registerDocumentation(
+ collection.documentationFileName(doc)))
+ return false;
+ }
+ }
+
+ /*
+ * Step 2: Ensure that the cached collection contains no docs that
+ * the collection doesn't contain.
+ */
+ QLatin1String intern("com.trolltech.com.assistantinternal-");
+ foreach (const QString &doc, cachedDocs) {
+ if (!docs.contains(doc) && !doc.startsWith(intern)
+ && !cachedCollection.unregisterDocumentation(doc))
+ return false;
+ }
+
+ return true;
+}
+
+bool removeSearchIndex(const QString &collectionFile)
{
- // First do a quick search for arguments that imply command-line mode.
+ QString path = QFileInfo(collectionFile).path();
+ path += QLatin1Char('/') + indexFilesFolder(collectionFile);
+
+ QLocalSocket localSocket;
+ localSocket.connectToServer(QString(QLatin1String("QtAssistant%1"))
+ .arg(QLatin1String(QT_VERSION_STR)));
+
+ QDir dir(path); // check if there is no other instance ruinning
+ if (!dir.exists() || localSocket.waitForConnected())
+ return false;
+
+ QStringList lst = dir.entryList(QDir::Files | QDir::Hidden);
+ foreach (const QString &item, lst)
+ dir.remove(item);
+ return true;
+}
+
+bool checkForSqlite(CmdLineParser &cmd)
+{
+ QSqlDatabase db;
+ QStringList sqlDrivers(db.drivers());
+ if (!sqlDrivers.contains(QLatin1String("QSQLITE"))) {
+ cmd.showMessage(QObject::tr("Cannot load sqlite database driver!"),
+ true);
+ return false;
+ }
+ return true;
+}
+
+bool useGui(int argc, char *argv[])
+{
+ bool gui = true;
+#ifndef Q_OS_WIN
+ // Look for arguments that imply command-line mode.
const char * cmdModeArgs[] = {
"-help", "-register", "-unregister", "-remove-search-index"
};
- bool useGui = true;
for (int i = 1; i < argc; ++i) {
for (size_t j = 0; j < sizeof cmdModeArgs/sizeof *cmdModeArgs; ++j) {
if(strcmp(argv[i], cmdModeArgs[j]) == 0) {
- useGui = false;
+ gui = false;
break;
}
}
}
+#endif
+ return gui;
+}
+
+} // Anonymous namespace.
- QApplication a(argc, argv, useGui);
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv, useGui(argc, argv));
a.addLibraryPath(a.applicationDirPath() + QLatin1String("/plugins"));
- CmdLineParser cmd;
- CmdLineParser::Result res = cmd.parse(a.arguments());
+ CmdLineParser cmd(a.arguments());
+ CmdLineParser::Result res = cmd.parse();
if (res == CmdLineParser::Help)
return 0;
else if (res == CmdLineParser::Error)
@@ -235,42 +277,20 @@ int main(int argc, char *argv[])
return -1;
}
}
- help.setCustomValue(QLatin1String("DocUpdate"), true);
+ CollectionConfiguration::setDocUpdatePending(help, true);
return 0;
}
+ // TODO: Also remove search index of cached collection file?
if (cmd.removeSearchIndex()) {
QString file = cmdCollectionFile;
if (file.isEmpty())
file = MainWindow::defaultHelpCollectionFileName();
- QString path = QFileInfo(file).path();
- path += QLatin1Char('/') + indexFilesFolder(file);
-
- QLocalSocket localSocket;
- localSocket.connectToServer(QString(QLatin1String("QtAssistant%1"))
- .arg(QLatin1String(QT_VERSION_STR)));
-
- QDir dir(path); // check if there is no other instance ruinning
- if (!localSocket.waitForConnected() && dir.exists()) {
- QStringList lst = dir.entryList(QDir::Files | QDir::Hidden);
- foreach (const QString &item, lst)
- dir.remove(item);
- return 0;
- } else {
- return -1;
- }
+ return removeSearchIndex(file) ? 0 : EXIT_FAILURE;
}
- {
- QSqlDatabase db;
- QStringList sqlDrivers(db.drivers());
- if (sqlDrivers.isEmpty()
- || !sqlDrivers.contains(QLatin1String("QSQLITE"))) {
- cmd.showMessage(QObject::tr("Cannot load sqlite database driver!"),
- true);
- return -1;
- }
- }
+ if (!checkForSqlite(cmd))
+ return EXIT_FAILURE;
if (!cmdCollectionFile.isEmpty()) {
QHelpEngineCore caller(cmdCollectionFile);
@@ -280,27 +300,17 @@ int main(int argc, char *argv[])
return -1;
}
- QString fileName = QFileInfo(cmdCollectionFile).fileName();
- QString dir = MainWindow::collectionFileDirectory(false,
- caller.customValue(QLatin1String("CacheDirectory"),
- QString()).toString());
-
- bool collectionFileExists = true;
- QFileInfo fi(dir + QDir::separator() + fileName);
- if (!fi.exists()) {
- collectionFileExists = false;
- if (!caller.copyCollectionFile(fi.absoluteFilePath())) {
+ const QString &cachedCollectionFilePath = cachedCollectionFile(caller);
+ if (!QFileInfo(cachedCollectionFilePath).exists()) {
+ if (!caller.copyCollectionFile(cachedCollectionFilePath)) {
cmd.showMessage(caller.error(), true);
return -1;
}
- }
-
- if (collectionFileExists) {
- QHelpEngineCore user(fi.absoluteFilePath());
+ } else {
+ QHelpEngineCore user(cachedCollectionFilePath);
if (user.setupData()) {
// some docs might have been un/registered
- bool docUpdate = caller.
- customValue(QLatin1String("DocUpdate"), false).toBool();
+ bool docUpdate = CollectionConfiguration::docUpdatePending(caller);
// update in case the passed collection file changed
if (updateUserCollection(user, caller))
@@ -312,25 +322,12 @@ int main(int argc, char *argv[])
docUpdate = true;
if (docUpdate) {
- QStringList callerDocs = caller.registeredDocumentations();
- foreach (const QString &doc, callerDocs) {
- if (!userDocs.contains(doc)) {
- user.registerDocumentation(
- caller.documentationFileName(doc));
- }
- }
-
- QLatin1String intern("com.trolltech.com.assistantinternal-");
- foreach (const QString &doc, userDocs) {
- if (!callerDocs.contains(doc) && !doc.startsWith(intern))
- user.unregisterDocumentation(doc);
- }
-
- caller.setCustomValue(QLatin1String("DocUpdate"), false);
+ synchronizeDocs(caller, user);
+ CollectionConfiguration::setDocUpdatePending(caller, false);
}
}
}
- cmd.setCollectionFile(fi.absoluteFilePath());
+ cmd.setCollectionFile(cachedCollectionFilePath);
}
if (!cmd.currentFilter().isEmpty()) {
@@ -360,8 +357,17 @@ int main(int argc, char *argv[])
qtHelpTranslator.load(QLatin1String("qt_help_") + locale, resourceDir);
a.installTranslator(&qtHelpTranslator);
- MainWindow w(&cmd);
- w.show();
+ /*
+ * We need to be careful here: The main window has to be deleted before
+ * the help engine wrapper, which has to be deleted before the
+ * QApplication.
+ */
+ int retval;
+ MainWindow *w = new MainWindow(&cmd);
+ w->show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
- return a.exec();
+ retval = a.exec();
+ delete w;
+ delete &HelpEngineWrapper::instance();
+ return retval;
}
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index 323fe8207..226ad51c9 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -47,15 +47,22 @@
#include "contentwindow.h"
#include "preferencesdialog.h"
#include "bookmarkmanager.h"
+#include "helpenginewrapper.h"
#include "remotecontrol.h"
#include "cmdlineparser.h"
#include "aboutdialog.h"
#include "searchwidget.h"
#include "qtdocinstaller.h"
+#include "xbelsupport.h"
+
+// #define TRACING_REQUESTED
#include <QtCore/QDir>
#include <QtCore/QTimer>
+#include <QtCore/QDateTime>
#include <QtCore/QDebug>
+#include <QtCore/QFileSystemWatcher>
+#include <QtCore/QPair>
#include <QtCore/QResource>
#include <QtCore/QByteArray>
#include <QtCore/QTextStream>
@@ -76,8 +83,9 @@
#include <QtGui/QProgressBar>
#include <QtGui/QDesktopServices>
#include <QtGui/QToolButton>
+#include <QtGui/QFileDialog>
-#include <QtHelp/QHelpEngine>
+#include <QtHelp/QHelpEngineCore>
#include <QtHelp/QHelpSearchEngine>
#include <QtHelp/QHelpContentModel>
#include <QtHelp/QHelpIndexModel>
@@ -93,26 +101,29 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
, m_qtDocInstaller(0)
, m_connectedInitSignals(false)
{
+
setToolButtonStyle(Qt::ToolButtonFollowStyle);
+ QString collectionFile;
if (usesDefaultCollection()) {
MainWindow::collectionFileDirectory(true);
- m_helpEngine = new QHelpEngine(MainWindow::defaultHelpCollectionFileName(),
- this);
+ collectionFile = MainWindow::defaultHelpCollectionFileName();
} else {
- m_helpEngine = new QHelpEngine(cmdLine->collectionFile(), this);
+ collectionFile = cmdLine->collectionFile();
}
+ HelpEngineWrapper &helpEngineWrapper =
+ HelpEngineWrapper::instance(collectionFile);
- m_centralWidget = new CentralWidget(m_helpEngine, this);
+ m_centralWidget = new CentralWidget(this);
setCentralWidget(m_centralWidget);
- m_indexWindow = new IndexWindow(m_helpEngine);
+ m_indexWindow = new IndexWindow(this);
QDockWidget *indexDock = new QDockWidget(tr("Index"), this);
indexDock->setObjectName(QLatin1String("IndexWindow"));
indexDock->setWidget(m_indexWindow);
addDockWidget(Qt::LeftDockWidgetArea, indexDock);
- m_contentWindow = new ContentWindow(m_helpEngine);
+ m_contentWindow = new ContentWindow;
QDockWidget *contentDock = new QDockWidget(tr("Contents"), this);
contentDock->setObjectName(QLatin1String("ContentWindow"));
contentDock->setWidget(m_contentWindow);
@@ -123,7 +134,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
bookmarkDock->setWidget(setupBookmarkWidget());
addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock);
- QHelpSearchEngine *searchEngine = m_helpEngine->searchEngine();
+ QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine();
connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted()));
connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished()));
@@ -148,10 +159,9 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
connect(m_bookmarkManager, SIGNAL(bookmarksChanged()), this,
SLOT(updateBookmarkMenu()));
- setWindowTitle(m_helpEngine->customValue(QLatin1String("WindowTitle"),
- defWindowTitle).toString());
- QByteArray iconArray = m_helpEngine->customValue(QLatin1String("ApplicationIcon"),
- QByteArray()).toByteArray();
+ const QString windowTitle = helpEngineWrapper.windowTitle();
+ setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle);
+ QByteArray iconArray = helpEngineWrapper.applicationIcon();
if (iconArray.size() > 0) {
QPixmap pix;
pix.loadFromData(iconArray);
@@ -165,11 +175,11 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
// Show the widget here, otherwise the restore geometry and state won't work
// on x11.
show();
- QByteArray ba(m_helpEngine->customValue(QLatin1String("MainWindow")).toByteArray());
+ QByteArray ba(helpEngineWrapper.mainWindow());
if (!ba.isEmpty())
restoreState(ba);
- ba = m_helpEngine->customValue(QLatin1String("MainWindowGeometry")).toByteArray();
+ ba = helpEngineWrapper.mainWindowGeometry();
if (!ba.isEmpty()) {
restoreGeometry(ba);
} else {
@@ -179,15 +189,13 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
resize(QSize(800, 600));
}
- if (!m_helpEngine->customValue(QLatin1String("useAppFont")).isValid()) {
- m_helpEngine->setCustomValue(QLatin1String("useAppFont"), false);
- m_helpEngine->setCustomValue(QLatin1String("useBrowserFont"), false);
- m_helpEngine->setCustomValue(QLatin1String("appFont"), qApp->font());
- m_helpEngine->setCustomValue(QLatin1String("appWritingSystem"),
- QFontDatabase::Latin);
- m_helpEngine->setCustomValue(QLatin1String("browserFont"), qApp->font());
- m_helpEngine->setCustomValue(QLatin1String("browserWritingSystem"),
- QFontDatabase::Latin);
+ if (!helpEngineWrapper.hasFontSettings()) {
+ helpEngineWrapper.setUseAppFont(false);
+ helpEngineWrapper.setUseBrowserFont(false);
+ helpEngineWrapper.setAppFont(qApp->font());
+ helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin);
+ helpEngineWrapper.setBrowserFont(qApp->font());
+ helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin);
} else {
updateApplicationFont();
}
@@ -196,7 +204,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
QTimer::singleShot(0, this, SLOT(insertLastPages()));
if (m_cmdLine->enableRemoteControl())
- (void)new RemoteControl(this, m_helpEngine);
+ (void)new RemoteControl(this);
if (m_cmdLine->contents() == CmdLineParser::Show)
showContents();
@@ -227,22 +235,20 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
if (!m_cmdLine->currentFilter().isEmpty()) {
const QString &curFilter = m_cmdLine->currentFilter();
- m_helpEngine->setCurrentFilter(curFilter);
- if (m_filterCombo) {
- int idx = m_filterCombo->findText(curFilter);
- if (idx >= 0) {
- bool blocked = m_filterCombo->signalsBlocked();
- m_filterCombo->blockSignals(true);
- m_filterCombo->setCurrentIndex(idx);
- m_filterCombo->blockSignals(blocked);
- }
- }
+ if (helpEngineWrapper.customFilters().contains(curFilter))
+ helpEngineWrapper.setCurrentFilter(curFilter);
}
if (usesDefaultCollection())
QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation()));
else
checkInitState();
+
+ helpEngineWrapper.initFileSystemWatchers();
+ connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)),
+ this, SLOT(documentationRemoved(QString)));
+ connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)),
+ this, SLOT(documentationUpdated(QString)));
}
setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
}
@@ -261,21 +267,20 @@ bool MainWindow::usesDefaultCollection() const
void MainWindow::closeEvent(QCloseEvent *e)
{
m_bookmarkManager->saveBookmarks();
- m_helpEngine->setCustomValue(QLatin1String("MainWindow"), saveState());
- m_helpEngine->setCustomValue(QLatin1String("MainWindowGeometry"),
- saveGeometry());
-
+ HelpEngineWrapper::instance().setMainWindow(saveState());
+ HelpEngineWrapper::instance().setMainWindowGeometry(saveGeometry());
QMainWindow::closeEvent(e);
}
bool MainWindow::initHelpDB()
{
- if (!m_helpEngine->setupData())
+ HelpEngineWrapper &helpEngineWrapper = HelpEngineWrapper::instance();
+ if (!helpEngineWrapper.setupData())
return false;
bool assistantInternalDocRegistered = false;
QString intern(QLatin1String("com.trolltech.com.assistantinternal-"));
- foreach (const QString &ns, m_helpEngine->registeredDocumentations()) {
+ foreach (const QString &ns, helpEngineWrapper.registeredDocumentations()) {
if (ns.startsWith(intern)) {
intern = ns;
assistantInternalDocRegistered = true;
@@ -283,8 +288,7 @@ bool MainWindow::initHelpDB()
}
}
- const QString &collectionFile = m_helpEngine->collectionFile();
-
+ const QString &collectionFile = helpEngineWrapper.collectionFile();
QFileInfo fi(collectionFile);
QString helpFile;
QTextStream(&helpFile) << fi.absolutePath() << QDir::separator()
@@ -301,57 +305,52 @@ bool MainWindow::initHelpDB()
file.close();
}
- QHelpEngineCore hc(fi.absoluteFilePath());
- hc.setupData();
- hc.unregisterDocumentation(intern);
- hc.registerDocumentation(helpFile);
+ helpEngineWrapper.unregisterDocumentation(intern);
+ helpEngineWrapper.registerDocumentation(helpFile);
needsSetup = true;
}
- const QLatin1String unfiltered("UnfilteredFilterInserted");
- if (1 != m_helpEngine->customValue(unfiltered).toInt()) {
- {
- QHelpEngineCore hc(collectionFile);
- hc.setupData();
- hc.addCustomFilter(tr("Unfiltered"), QStringList());
- hc.setCustomValue(unfiltered, 1);
- }
-
- m_helpEngine->blockSignals(true);
- m_helpEngine->setCurrentFilter(tr("Unfiltered"));
- m_helpEngine->blockSignals(false);
+ if (!helpEngineWrapper.unfilteredInserted()) {
+ helpEngineWrapper.addCustomFilter(tr("Unfiltered"), QStringList());
+ helpEngineWrapper.setUnfilteredInserted();
+ helpEngineWrapper.setCurrentFilter(tr("Unfiltered"));
needsSetup = true;
}
if (needsSetup)
- m_helpEngine->setupData();
+ helpEngineWrapper.setupData();
return true;
}
void MainWindow::lookForNewQtDocumentation()
{
- m_qtDocInstaller = new QtDocInstaller(m_helpEngine->collectionFile());
- connect(m_qtDocInstaller, SIGNAL(errorMessage(QString)), this,
- SLOT(displayInstallationError(QString)));
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ QStringList docs;
+ docs << QLatin1String("assistant")
+ << QLatin1String("designer")
+ << QLatin1String("linguist")
+ << QLatin1String("qmake")
+ << QLatin1String("qt");
+ QList<QtDocInstaller::DocInfo> qtDocInfos;
+ foreach (const QString &doc, docs)
+ qtDocInfos.append(QtDocInstaller::DocInfo(doc, helpEngine.qtDocInfo(doc)));
+
+ m_qtDocInstaller = new QtDocInstaller(qtDocInfos);
connect(m_qtDocInstaller, SIGNAL(docsInstalled(bool)), this,
SLOT(qtDocumentationInstalled(bool)));
-
- QString versionKey = QString(QLatin1String("qtVersion%1$$$qt")).
- arg(QLatin1String(QT_VERSION_STR));
- if (m_helpEngine->customValue(versionKey, 0).toInt() != 1)
+ connect(m_qtDocInstaller, SIGNAL(qchFileNotFound(QString)), this,
+ SLOT(resetQtDocInfo(QString)));
+ connect(m_qtDocInstaller, SIGNAL(registerDocumentation(QString, QString)),
+ this, SLOT(registerDocumentation(QString, QString)));
+ if (helpEngine.qtDocInfo(QLatin1String("qt")).count() != 2)
statusBar()->showMessage(tr("Looking for Qt Documentation..."));
m_qtDocInstaller->installDocs();
}
-void MainWindow::displayInstallationError(const QString &errorMessage)
-{
- QMessageBox::warning(this, tr("Qt Assistant"), errorMessage);
-}
-
void MainWindow::qtDocumentationInstalled(bool newDocsInstalled)
{
if (newDocsInstalled)
- m_helpEngine->setupData();
+ HelpEngineWrapper::instance().setupData();
statusBar()->clearMessage();
checkInitState();
}
@@ -361,19 +360,20 @@ void MainWindow::checkInitState()
if (!m_cmdLine->enableRemoteControl())
return;
- if (m_helpEngine->contentModel()->isCreatingContents()
- || m_helpEngine->indexModel()->isCreatingIndex()) {
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ if (helpEngine.contentModel()->isCreatingContents()
+ || helpEngine.indexModel()->isCreatingIndex()) {
if (!m_connectedInitSignals) {
- connect(m_helpEngine->contentModel(), SIGNAL(contentsCreated()),
+ connect(helpEngine.contentModel(), SIGNAL(contentsCreated()),
this, SLOT(checkInitState()));
- connect(m_helpEngine->indexModel(), SIGNAL(indexCreated()), this,
+ connect(helpEngine.indexModel(), SIGNAL(indexCreated()), this,
SLOT(checkInitState()));
m_connectedInitSignals = true;
}
} else {
if (m_connectedInitSignals) {
- disconnect(m_helpEngine->contentModel(), 0, this, 0);
- disconnect(m_helpEngine->indexModel(), 0, this, 0);
+ disconnect(helpEngine.contentModel(), 0, this, 0);
+ disconnect(helpEngine.indexModel(), 0, this, 0);
}
emit initDone();
}
@@ -382,13 +382,17 @@ void MainWindow::checkInitState()
void MainWindow::updateBookmarkMenu()
{
if (m_bookmarkManager) {
+ m_bookmarkMenu->removeAction(m_importBookmarkAction);
+ m_bookmarkMenu->removeAction(m_exportBookmarkAction);
m_bookmarkMenu->removeAction(m_bookmarkMenuAction);
-
+
m_bookmarkMenu->clear();
-
+
+ m_bookmarkMenu->addAction(m_importBookmarkAction);
+ m_bookmarkMenu->addAction(m_exportBookmarkAction);
m_bookmarkMenu->addAction(m_bookmarkMenuAction);
m_bookmarkMenu->addSeparator();
-
+
m_bookmarkManager->fillBookmarkMenu(m_bookmarkMenu);
}
}
@@ -445,8 +449,12 @@ void MainWindow::setupActions()
m_closeTabAction->setShortcuts(QKeySequence::Close);
QAction *tmp = menu->addAction(tr("&Quit"), this, SLOT(close()));
- tmp->setShortcut(QKeySequence::Quit);
tmp->setMenuRole(QAction::QuitRole);
+#ifdef Q_OS_WIN
+ tmp->setShortcut(QKeySequence(tr("CTRL+Q")));
+#else
+ tmp->setShortcut(QKeySequence::Quit);
+#endif
menu = menuBar()->addMenu(tr("&Edit"));
m_copyAction = menu->addAction(tr("&Copy selected Text"), m_centralWidget,
@@ -459,7 +467,7 @@ void MainWindow::setupActions()
m_findAction = menu->addAction(tr("&Find in Text..."), m_centralWidget,
SLOT(showTextSearch()));
- m_findAction->setIconText("&Find");
+ m_findAction->setIconText(tr("&Find"));
m_findAction->setIcon(QIcon(resourcePath + QLatin1String("/find.png")));
m_findAction->setShortcuts(QKeySequence::Find);
@@ -523,7 +531,7 @@ void MainWindow::setupActions()
m_syncAction = menu->addAction(tr("Sync with Table of Contents"), this,
SLOT(syncContents()));
- m_syncAction->setIconText("Sync");
+ m_syncAction->setIconText(tr("Sync"));
m_syncAction->setIcon(QIcon(resourcePath + QLatin1String("/synctoc.png")));
menu->addSeparator();
@@ -537,6 +545,10 @@ void MainWindow::setupActions()
<< QKeySequence(Qt::CTRL + Qt::Key_PageUp));
m_bookmarkMenu = menuBar()->addMenu(tr("&Bookmarks"));
+ m_importBookmarkAction = m_bookmarkMenu->addAction(tr("Import..."),
+ this, SLOT(importBookmarks()));
+ m_exportBookmarkAction = m_bookmarkMenu->addAction(tr("Export..."),
+ this, SLOT(exportBookmarks()));
m_bookmarkMenuAction = m_bookmarkMenu->addAction(tr("Add Bookmark..."),
this, SLOT(addBookmark()));
m_bookmarkMenuAction->setShortcut(tr("CTRL+D"));
@@ -600,8 +612,8 @@ void MainWindow::setupActions()
SLOT(updateNavigationItems()));
connect(m_centralWidget, SIGNAL(highlighted(QString)), statusBar(),
SLOT(showMessage(QString)));
- connect(m_centralWidget, SIGNAL(addNewBookmark(QString, QString)), this,
- SLOT(addNewBookmark(QString, QString)));
+ connect(m_centralWidget, SIGNAL(addNewBookmark(QString,QString)), this,
+ SLOT(addNewBookmark(QString,QString)));
// bookmarks
connect(m_bookmarkWidget, SIGNAL(requestShowLink(QUrl)), m_centralWidget,
@@ -612,8 +624,8 @@ void MainWindow::setupActions()
// index window
connect(m_indexWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
- connect(m_indexWindow, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)),
- this, SLOT(showTopicChooser(QMap<QString, QUrl>, QString)));
+ connect(m_indexWindow, SIGNAL(linksActivated(QMap<QString,QUrl>,QString)),
+ this, SLOT(showTopicChooser(QMap<QString,QUrl>,QString)));
connect(m_indexWindow, SIGNAL(escapePressed()), this,
SLOT(activateCurrentCentralWidgetTab()));
@@ -641,8 +653,8 @@ QMenu *MainWindow::toolBarMenu()
void MainWindow::setupFilterToolbar()
{
- if (!m_helpEngine->
- customValue(QLatin1String("EnableFilterFunctionality"), true).toBool())
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ if (!helpEngine.filterFunctionalityEnabled())
return;
m_filterCombo = new QComboBox(this);
@@ -655,22 +667,24 @@ void MainWindow::setupFilterToolbar()
this));
filterToolBar->addWidget(m_filterCombo);
- const QLatin1String hideFilter("HideFilterFunctionality");
- if (m_helpEngine->customValue(hideFilter, true).toBool())
+ if (!helpEngine.filterToolbarVisible())
filterToolBar->hide();
toolBarMenu()->addAction(filterToolBar->toggleViewAction());
- connect(m_helpEngine, SIGNAL(setupFinished()), this,
- SLOT(setupFilterCombo()));
+ connect(&helpEngine, SIGNAL(setupFinished()), this,
+ SLOT(setupFilterCombo()), Qt::QueuedConnection);
connect(m_filterCombo, SIGNAL(activated(QString)), this,
SLOT(filterDocumentation(QString)));
+ connect(&helpEngine, SIGNAL(currentFilterChanged(QString)), this,
+ SLOT(currentFilterChanged(QString)));
setupFilterCombo();
}
void MainWindow::setupAddressToolbar()
{
- if (!m_helpEngine->customValue(QLatin1String("EnableAddressBar"), true).toBool())
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ if (!helpEngine.addressBarEnabled())
return;
m_addressLineEdit = new QLineEdit(this);
@@ -682,7 +696,7 @@ void MainWindow::setupAddressToolbar()
this));
addressToolBar->addWidget(m_addressLineEdit);
- if (m_helpEngine->customValue(QLatin1String("HideAddressBar"), true).toBool())
+ if (!helpEngine.addressBarVisible())
addressToolBar->hide();
toolBarMenu()->addAction(addressToolBar->toggleViewAction());
@@ -697,31 +711,28 @@ void MainWindow::setupAddressToolbar()
void MainWindow::updateAboutMenuText()
{
- if (m_helpEngine) {
- QByteArray ba = m_helpEngine->customValue(QLatin1String("AboutMenuTexts"),
- QByteArray()).toByteArray();
- if (ba.size() > 0) {
- QString lang;
- QString str;
- QString trStr;
- QString currentLang = QLocale::system().name();
- int i = currentLang.indexOf(QLatin1Char('_'));
- if (i > -1)
- currentLang = currentLang.left(i);
- QDataStream s(&ba, QIODevice::ReadOnly);
- while (!s.atEnd()) {
- s >> lang;
- s >> str;
- if (lang == QLatin1String("default") && trStr.isEmpty()) {
- trStr = str;
- } else if (lang == currentLang) {
- trStr = str;
- break;
- }
+ QByteArray ba = HelpEngineWrapper::instance().aboutMenuTexts();
+ if (ba.size() > 0) {
+ QString lang;
+ QString str;
+ QString trStr;
+ QString currentLang = QLocale::system().name();
+ int i = currentLang.indexOf(QLatin1Char('_'));
+ if (i > -1)
+ currentLang = currentLang.left(i);
+ QDataStream s(&ba, QIODevice::ReadOnly);
+ while (!s.atEnd()) {
+ s >> lang;
+ s >> str;
+ if (lang == QLatin1String("default") && trStr.isEmpty()) {
+ trStr = str;
+ } else if (lang == currentLang) {
+ trStr = str;
+ break;
}
- if (!trStr.isEmpty())
- m_aboutAction->setText(trStr);
}
+ if (!trStr.isEmpty())
+ m_aboutAction->setText(trStr);
}
}
@@ -775,7 +786,7 @@ void MainWindow::showTopicChooser(const QMap<QString, QUrl> &links,
void MainWindow::showPreferences()
{
- PreferencesDialog dia(m_helpEngine, this);
+ PreferencesDialog dia(this);
connect(&dia, SIGNAL(updateApplicationFont()), this,
SLOT(updateApplicationFont()));
@@ -811,27 +822,25 @@ void MainWindow::addNewBookmark(const QString &title, const QString &url)
void MainWindow::showAboutDialog()
{
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
QByteArray contents;
- if (m_helpEngine) {
- QByteArray ba = m_helpEngine->customValue(QLatin1String("AboutTexts"),
- QByteArray()).toByteArray();
- if (!ba.isEmpty()) {
- QString lang;
- QByteArray cba;
- QString currentLang = QLocale::system().name();
- int i = currentLang.indexOf(QLatin1Char('_'));
- if (i > -1)
- currentLang = currentLang.left(i);
- QDataStream s(&ba, QIODevice::ReadOnly);
- while (!s.atEnd()) {
- s >> lang;
- s >> cba;
- if (lang == QLatin1String("default") && contents.isEmpty()) {
- contents = cba;
- } else if (lang == currentLang) {
- contents = cba;
- break;
- }
+ QByteArray ba = helpEngine.aboutTexts();
+ if (!ba.isEmpty()) {
+ QString lang;
+ QByteArray cba;
+ QString currentLang = QLocale::system().name();
+ int i = currentLang.indexOf(QLatin1Char('_'));
+ if (i > -1)
+ currentLang = currentLang.left(i);
+ QDataStream s(&ba, QIODevice::ReadOnly);
+ while (!s.atEnd()) {
+ s >> lang;
+ s >> cba;
+ if (lang == QLatin1String("default") && contents.isEmpty()) {
+ contents = cba;
+ } else if (lang == currentLang) {
+ contents = cba;
+ break;
}
}
}
@@ -840,11 +849,8 @@ void MainWindow::showAboutDialog()
QByteArray iconArray;
if (!contents.isEmpty()) {
- iconArray = m_helpEngine->customValue(QLatin1String("AboutIcon"),
- QByteArray()).toByteArray();
- QByteArray resources =
- m_helpEngine->customValue(QLatin1String("AboutImages"),
- QByteArray()).toByteArray();
+ iconArray = helpEngine.aboutIcon();
+ QByteArray resources = helpEngine.aboutImages();
QPixmap pix;
pix.loadFromData(iconArray);
aboutDia.setText(QString::fromUtf8(contents), resources);
@@ -856,10 +862,7 @@ void MainWindow::showAboutDialog()
aboutDia.setText(QString::fromLatin1("<center>"
"<h3>%1</h3>"
"<p>Version %2</p></center>"
- "<p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)"
- ".</p><p>The program is provided AS IS with NO WARRANTY OF ANY KIND,"
- " INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A"
- " PARTICULAR PURPOSE.<p/>")
+ "<p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).</p>")
.arg(tr("Qt Assistant")).arg(QLatin1String(QT_VERSION_STR)),
resources);
QLatin1String path(":/trolltech/assistant/images/assistant-128.png");
@@ -870,41 +873,84 @@ void MainWindow::showAboutDialog()
aboutDia.exec();
}
+void MainWindow::setContentsVisible(bool visible)
+{
+ if (visible)
+ showContents();
+ else
+ hideContents();
+}
+
void MainWindow::showContents()
{
activateDockWidget(m_contentWindow);
}
+void MainWindow::hideContents()
+{
+ m_contentWindow->parentWidget()->hide();
+}
+
+void MainWindow::setIndexVisible(bool visible)
+{
+ if (visible)
+ showIndex();
+ else
+ hideIndex();
+}
+
void MainWindow::showIndex()
{
activateDockWidget(m_indexWindow);
}
+void MainWindow::hideIndex()
+{
+ m_indexWindow->parentWidget()->hide();
+}
+
+void MainWindow::setBookmarksVisible(bool visible)
+{
+ if (visible)
+ showBookmarks();
+ else
+ hideBookmarks();
+}
+
+
void MainWindow::showBookmarks()
{
activateDockWidget(m_bookmarkWidget);
}
-void MainWindow::activateDockWidget(QWidget *w)
+void MainWindow::hideBookmarks()
{
- w->parentWidget()->show();
- w->parentWidget()->raise();
- w->setFocus();
+ m_bookmarkWidget->parentWidget()->hide();
}
-void MainWindow::hideContents()
+void MainWindow::setSearchVisible(bool visible)
{
- m_contentWindow->parentWidget()->hide();
+ if (visible)
+ showSearch();
+ else
+ hideSearch();
}
-void MainWindow::hideIndex()
+void MainWindow::showSearch()
{
- m_indexWindow->parentWidget()->hide();
+ m_centralWidget->activateSearchWidget();
}
-void MainWindow::hideBookmarks()
+void MainWindow::hideSearch()
{
- m_bookmarkWidget->parentWidget()->hide();
+ m_centralWidget->removeSearchWidget();
+}
+
+void MainWindow::activateDockWidget(QWidget *w)
+{
+ w->parentWidget()->show();
+ w->parentWidget()->raise();
+ w->setFocus();
}
void MainWindow::setIndexString(const QString &str)
@@ -925,37 +971,29 @@ void MainWindow::activateCurrentCentralWidgetTab()
m_centralWidget->activateTab();
}
-void MainWindow::showSearch()
-{
- m_centralWidget->activateSearchWidget();
-}
-
void MainWindow::showSearchWidget()
{
m_centralWidget->activateSearchWidget(true);
}
-void MainWindow::hideSearch()
-{
- m_centralWidget->removeSearchWidget();
-}
-
void MainWindow::updateApplicationFont()
{
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
QFont font = qApp->font();
- if (m_helpEngine->customValue(QLatin1String("useAppFont")).toBool())
- font = qVariantValue<QFont>(m_helpEngine->customValue(QLatin1String("appFont")));
+ if (helpEngine.usesAppFont())
+ font = helpEngine.appFont();
qApp->setFont(font, "QWidget");
}
void MainWindow::setupFilterCombo()
{
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
QString curFilter = m_filterCombo->currentText();
if (curFilter.isEmpty())
- curFilter = m_helpEngine->currentFilter();
+ curFilter = helpEngine.currentFilter();
m_filterCombo->clear();
- m_filterCombo->addItems(m_helpEngine->customFilters());
+ m_filterCombo->addItems(helpEngine.customFilters());
int idx = m_filterCombo->findText(curFilter);
if (idx < 0)
idx = 0;
@@ -964,11 +1002,12 @@ void MainWindow::setupFilterCombo()
void MainWindow::filterDocumentation(const QString &customFilter)
{
- m_helpEngine->setCurrentFilter(customFilter);
+ HelpEngineWrapper::instance().setCurrentFilter(customFilter);
}
void MainWindow::expandTOC(int depth)
{
+ Q_ASSERT(depth >= -1);
m_contentWindow->expandToDepth(depth);
}
@@ -1006,7 +1045,7 @@ void MainWindow::indexingFinished()
QWidget* MainWindow::setupBookmarkWidget()
{
- m_bookmarkManager = new BookmarkManager(m_helpEngine);
+ m_bookmarkManager = new BookmarkManager;
m_bookmarkWidget = new BookmarkWidget(m_bookmarkManager, this);
connect(m_bookmarkWidget, SIGNAL(addBookmark()), this, SLOT(addBookmark()));
return m_bookmarkWidget;
@@ -1044,4 +1083,87 @@ QString MainWindow::defaultHelpCollectionFileName()
arg(QLatin1String(QT_VERSION_STR));
}
+void MainWindow::importBookmarks()
+{
+ const QString &fileName = QFileDialog::getOpenFileName(0, tr("Open File"),
+ 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());
+ reader.readFromFile(&file);
+ }
+}
+
+void MainWindow::exportBookmarks()
+{
+ 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);
+ } else {
+ QMessageBox::information(this, tr("Qt Assistant"),
+ tr("Unable to save bookmarks."), tr("OK"));
+ }
+}
+
+void MainWindow::currentFilterChanged(const QString &filter)
+{
+ const int index = m_filterCombo->findText(filter);
+ Q_ASSERT(index != -1);
+ m_filterCombo->setCurrentIndex(index);
+}
+
+void MainWindow::documentationRemoved(const QString &namespaceName)
+{
+ CentralWidget* widget = CentralWidget::instance();
+ widget->closeTabs(widget->currentSourceFileList().keys(namespaceName));
+}
+
+void MainWindow::documentationUpdated(const QString &namespaceName)
+{
+ // TODO: Check whether the documents still exists and if they do, reload.
+ CentralWidget* widget = CentralWidget::instance();
+ widget->closeTabs(widget->currentSourceFileList().keys(namespaceName));
+}
+
+void MainWindow::resetQtDocInfo(const QString &component)
+{
+ HelpEngineWrapper::instance().setQtDocInfo(component,
+ QStringList(QDateTime().toString(Qt::ISODate)));
+}
+
+void MainWindow::registerDocumentation(const QString &component,
+ const QString &absFileName)
+{
+ QString ns = QHelpEngineCore::namespaceName(absFileName);
+ if (ns.isEmpty())
+ return;
+
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ if (helpEngine.registeredDocumentations().contains(ns))
+ helpEngine.unregisterDocumentation(ns);
+ if (!helpEngine.registerDocumentation(absFileName)) {
+ QMessageBox::warning(this, tr("Qt Assistant"),
+ tr("Could not register file '%1': %2").
+ arg(absFileName).arg(helpEngine.error()));
+ } else {
+ QStringList docInfo;
+ docInfo << QFileInfo(absFileName).lastModified().toString(Qt::ISODate)
+ << absFileName;
+ helpEngine.setQtDocInfo(component, docInfo);
+ }
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h
index b7abf8cbf..65eadd7f9 100644
--- a/tools/assistant/tools/assistant/mainwindow.h
+++ b/tools/assistant/tools/assistant/mainwindow.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,6 +48,7 @@
QT_BEGIN_NAMESPACE
class QAction;
+class QFileSystemWatcher;
class QLineEdit;
class QComboBox;
class QMenu;
@@ -76,10 +77,6 @@ public:
static QString defaultHelpCollectionFileName();
public:
- void hideContents();
- void hideIndex();
- void hideBookmarks();
- void hideSearch();
void setIndexString(const QString &str);
void expandTOC(int depth);
bool usesDefaultCollection() const;
@@ -88,15 +85,20 @@ signals:
void initDone();
public slots:
- void showContents();
- void showIndex();
- void showBookmarks();
- void showSearch();
+ void setContentsVisible(bool visible);
+ void setIndexVisible(bool visible);
+ void setBookmarksVisible(bool visible);
+ void setSearchVisible(bool visible);
void showSearchWidget();
void syncContents();
void activateCurrentCentralWidgetTab();
+ void currentFilterChanged(const QString &filter);
private slots:
+ void showContents();
+ void showIndex();
+ void showBookmarks();
+ void showSearch();
void insertLastPages();
void addBookmark();
void gotoAddress();
@@ -115,13 +117,20 @@ private slots:
void lookForNewQtDocumentation();
void indexingStarted();
void indexingFinished();
- void displayInstallationError(const QString &errorMessage);
void qtDocumentationInstalled(bool newDocsInstalled);
+ void registerDocumentation(const QString &component,
+ const QString &absFileName);
+ void resetQtDocInfo(const QString &component);
void checkInitState();
+ void documentationRemoved(const QString &namespaceName);
+ void documentationUpdated(const QString &namespaceName);
void updateBookmarkMenu();
void showBookmark(QAction *action);
+ void importBookmarks();
+ void exportBookmarks();
+
private:
bool initHelpDB();
void setupActions();
@@ -132,8 +141,11 @@ private:
void setupAddressToolbar();
QMenu *toolBarMenu();
QWidget *setupBookmarkWidget();
+ void hideContents();
+ void hideIndex();
+ void hideBookmarks();
+ void hideSearch();
- QHelpEngine *m_helpEngine;
CentralWidget *m_centralWidget;
IndexWindow *m_indexWindow;
ContentWindow *m_contentWindow;
@@ -162,6 +174,8 @@ private:
QMenu *m_toolBarMenu;
QMenu *m_bookmarkMenu;
QAction *m_bookmarkMenuAction;
+ QAction *m_importBookmarkAction;
+ QAction *m_exportBookmarkAction;
CmdLineParser *m_cmdLine;
diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp
index 7076b0f41..2f282b135 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.cpp
+++ b/tools/assistant/tools/assistant/preferencesdialog.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -45,8 +45,10 @@
#include "fontpanel.h"
#include "centralwidget.h"
#include "aboutdialog.h"
+#include "helpenginewrapper.h"
-#include <QtAlgorithms>
+#include <QtCore/QtAlgorithms>
+#include <QtCore/QFileSystemWatcher>
#include <QtGui/QHeaderView>
#include <QtGui/QFileDialog>
@@ -60,11 +62,11 @@
QT_BEGIN_NAMESPACE
-PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, QWidget *parent)
+PreferencesDialog::PreferencesDialog(QWidget *parent)
: QDialog(parent)
- , m_helpEngine(helpEngine)
, m_appFontChanged(false)
, m_browserFontChanged(false)
+ , helpEngine(HelpEngineWrapper::instance())
{
m_ui.setupUi(this);
@@ -73,21 +75,18 @@ PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, QWidget *paren
connect(m_ui.buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()),
this, SLOT(reject()));
- QLatin1String key("EnableFilterFunctionality");
- m_hideFiltersTab = !m_helpEngine->customValue(key, true).toBool();
-
- key = QLatin1String("EnableDocumentationManager");
- m_hideDocsTab = !m_helpEngine->customValue(key, true).toBool();
+ m_hideFiltersTab = !helpEngine.filterFunctionalityEnabled();
+ m_hideDocsTab = !helpEngine.documentationManagerEnabled();
if (!m_hideFiltersTab) {
m_ui.attributeWidget->header()->hide();
m_ui.attributeWidget->setRootIsDecorated(false);
- connect(m_ui.attributeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
+ connect(m_ui.attributeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
this, SLOT(updateFilterMap()));
connect(m_ui.filterWidget,
- SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this,
+ SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this,
SLOT(updateAttributes(QListWidgetItem*)));
connect(m_ui.filterAddButton, SIGNAL(clicked()), this,
@@ -106,7 +105,7 @@ PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, QWidget *paren
connect(m_ui.docRemoveButton, SIGNAL(clicked()), this,
SLOT(removeDocumentation()));
- m_docsBackup = m_helpEngine->registeredDocumentations();
+ m_docsBackup = helpEngine.registeredDocumentations();
m_ui.registeredDocsListWidget->addItems(m_docsBackup);
} else {
m_ui.tabWidget->removeTab(m_ui.tabWidget->indexOf(m_ui.docsTab));
@@ -118,27 +117,16 @@ PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, QWidget *paren
PreferencesDialog::~PreferencesDialog()
{
- QLatin1String key("");
if (m_appFontChanged) {
- key = QLatin1String("appFont");
- m_helpEngine->setCustomValue(key, m_appFontPanel->selectedFont());
-
- key = QLatin1String("useAppFont");
- m_helpEngine->setCustomValue(key, m_appFontPanel->isChecked());
-
- key = QLatin1String("appWritingSystem");
- m_helpEngine->setCustomValue(key, m_appFontPanel->writingSystem());
+ helpEngine.setAppFont(m_appFontPanel->selectedFont());
+ helpEngine.setUseAppFont(m_appFontPanel->isChecked());
+ helpEngine.setAppWritingSystem(m_appFontPanel->writingSystem());
}
if (m_browserFontChanged) {
- key = QLatin1String("browserFont");
- m_helpEngine->setCustomValue(key, m_browserFontPanel->selectedFont());
-
- key = QLatin1String("useBrowserFont");
- m_helpEngine->setCustomValue(key, m_browserFontPanel->isChecked());
-
- key = QLatin1String("browserWritingSystem");
- m_helpEngine->setCustomValue(key, m_browserFontPanel->writingSystem());
+ helpEngine.setBrowserFont(m_browserFontPanel->selectedFont());
+ helpEngine.setUseBrowserFont(m_browserFontPanel->isChecked());
+ helpEngine.setBrowserWritingSystem(m_browserFontPanel->writingSystem());
}
if (m_appFontChanged || m_browserFontChanged) {
@@ -149,10 +137,10 @@ PreferencesDialog::~PreferencesDialog()
QString homePage = m_ui.homePageLineEdit->text();
if (homePage.isEmpty())
homePage = QLatin1String("help");
- m_helpEngine->setCustomValue(QLatin1String("homepage"), homePage);
+ helpEngine.setHomePage(homePage);
int option = m_ui.helpStartComboBox->currentIndex();
- m_helpEngine->setCustomValue(QLatin1String("StartOption"), option);
+ helpEngine.setStartOption(option);
}
void PreferencesDialog::showDialog()
@@ -163,18 +151,13 @@ void PreferencesDialog::showDialog()
void PreferencesDialog::updateFilterPage()
{
- if (!m_helpEngine)
- return;
-
m_ui.filterWidget->clear();
m_ui.attributeWidget->clear();
- QHelpEngineCore help(m_helpEngine->collectionFile(), 0);
- help.setupData();
m_filterMapBackup.clear();
- const QStringList filters = help.customFilters();
+ const QStringList filters = helpEngine.customFilters();
foreach (const QString &filter, filters) {
- QStringList atts = help.filterAttributes(filter);
+ QStringList atts = helpEngine.filterAttributes(filter);
m_filterMapBackup.insert(filter, atts);
if (!m_filterMap.contains(filter))
m_filterMap.insert(filter, atts);
@@ -182,10 +165,10 @@ void PreferencesDialog::updateFilterPage()
m_ui.filterWidget->addItems(m_filterMap.keys());
- foreach (const QString &a, help.filterAttributes())
+ foreach (const QString &a, helpEngine.filterAttributes())
new QTreeWidgetItem(m_ui.attributeWidget, QStringList() << a);
- if (m_filterMap.keys().count())
+ if (!m_filterMap.keys().isEmpty())
m_ui.filterWidget->setCurrentRow(0);
}
@@ -275,10 +258,11 @@ void PreferencesDialog::addDocumentationLocal()
continue;
}
- m_helpEngine->registerDocumentation(fileName);
- m_ui.registeredDocsListWidget->addItem(nameSpace);
- m_regDocs.append(nameSpace);
- m_unregDocs.removeAll(nameSpace);
+ if (helpEngine.registerDocumentation(fileName)) {
+ m_ui.registeredDocsListWidget->addItem(nameSpace);
+ m_regDocs.append(nameSpace);
+ m_unregDocs.removeAll(nameSpace);
+ }
}
if (!invalidFiles.isEmpty() || !alreadyRegistered.isEmpty()) {
@@ -370,28 +354,21 @@ void PreferencesDialog::applyChanges()
if (filtersWereChanged) {
foreach (const QString &filter, m_removedFilters)
- m_helpEngine->removeCustomFilter(filter);
+ helpEngine.removeCustomFilter(filter);
QMapIterator<QString, QStringList> it(m_filterMap);
while (it.hasNext()) {
it.next();
- m_helpEngine->addCustomFilter(it.key(), it.value());
+ helpEngine.addCustomFilter(it.key(), it.value());
}
}
- qSort(m_TabsToClose);
- CentralWidget* widget = CentralWidget::instance();
- for (int i = m_TabsToClose.count(); --i >= 0;)
- widget->closeTabAt(m_TabsToClose.at(i));
- if (widget->availableHelpViewer()== 0)
- widget->setSource(QUrl(QLatin1String("about:blank")));
-
- if (m_unregDocs.count()) {
- foreach (const QString &doc, m_unregDocs)
- m_helpEngine->unregisterDocumentation(doc);
- }
+ CentralWidget::instance()->closeTabs(m_TabsToClose);
- if (filtersWereChanged || m_regDocs.count() || m_unregDocs.count())
- m_helpEngine->setupData();
+ foreach (const QString &doc, m_unregDocs)
+ helpEngine.unregisterDocumentation(doc);
+
+ if (filtersWereChanged || !m_regDocs.isEmpty() || !m_unregDocs.isEmpty())
+ helpEngine.setupData();
accept();
}
@@ -411,31 +388,23 @@ void PreferencesDialog::updateFontSettingsPage()
const QString customSettings(tr("Use custom settings"));
m_appFontPanel->setTitle(customSettings);
- QLatin1String key = QLatin1String("appFont");
- QFont font = qVariantValue<QFont>(m_helpEngine->customValue(key));
+ QFont font = helpEngine.appFont();
m_appFontPanel->setSelectedFont(font);
- key = QLatin1String("appWritingSystem");
- QFontDatabase::WritingSystem system = static_cast<QFontDatabase::WritingSystem>
- (m_helpEngine->customValue(key).toInt());
+ QFontDatabase::WritingSystem system = helpEngine.appWritingSystem();
m_appFontPanel->setWritingSystem(system);
- key = QLatin1String("useAppFont");
- m_appFontPanel->setChecked(m_helpEngine->customValue(key).toBool());
+ m_appFontPanel->setChecked(helpEngine.usesAppFont());
m_browserFontPanel->setTitle(customSettings);
- key = QLatin1String("browserFont");
- font = qVariantValue<QFont>(m_helpEngine->customValue(key));
+ font = helpEngine.browserFont();
m_browserFontPanel->setSelectedFont(font);
- key = QLatin1String("browserWritingSystem");
- system = static_cast<QFontDatabase::WritingSystem>
- (m_helpEngine->customValue(key).toInt());
+ system = helpEngine.browserWritingSystem();
m_browserFontPanel->setWritingSystem(system);
- key = QLatin1String("useBrowserFont");
- m_browserFontPanel->setChecked(m_helpEngine->customValue(key).toBool());
+ m_browserFontPanel->setChecked(helpEngine.usesBrowserFont());
connect(m_appFontPanel, SIGNAL(toggled(bool)), this,
SLOT(appFontSettingToggled(bool)));
@@ -481,17 +450,9 @@ void PreferencesDialog::browserFontSettingChanged(int index)
void PreferencesDialog::updateOptionsPage()
{
- QString homepage = m_helpEngine->customValue(QLatin1String("homepage"),
- QLatin1String("")).toString();
+ m_ui.homePageLineEdit->setText(helpEngine.homePage());
- if (homepage.isEmpty()) {
- homepage = m_helpEngine->customValue(QLatin1String("defaultHomepage"),
- QLatin1String("help")).toString();
- }
- m_ui.homePageLineEdit->setText(homepage);
-
- int option = m_helpEngine->customValue(QLatin1String("StartOption"),
- ShowLastPages).toInt();
+ int option = helpEngine.startOption();
m_ui.helpStartComboBox->setCurrentIndex(option);
connect(m_ui.blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage()));
@@ -515,9 +476,7 @@ void PreferencesDialog::setCurrentPage()
void PreferencesDialog::setDefaultPage()
{
- QString homepage = m_helpEngine->customValue(QLatin1String("defaultHomepage"),
- QLatin1String("help")).toString();
- m_ui.homePageLineEdit->setText(homepage);
+ m_ui.homePageLineEdit->setText(helpEngine.defaultHomePage());
}
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/preferencesdialog.h b/tools/assistant/tools/assistant/preferencesdialog.h
index 3200ebea1..1554a9fac 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.h
+++ b/tools/assistant/tools/assistant/preferencesdialog.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -48,20 +48,15 @@
QT_BEGIN_NAMESPACE
class FontPanel;
-class QHelpEngineCore;
-
-enum {
- ShowHomePage = 0,
- ShowBlankPage = 1,
- ShowLastPages = 2
-};
+class HelpEngineWrapper;
+class QFileSystemWatcher;
class PreferencesDialog : public QDialog
{
Q_OBJECT
public:
- PreferencesDialog(QHelpEngineCore *helpEngine, QWidget *parent = 0);
+ PreferencesDialog(QWidget *parent = 0);
~PreferencesDialog();
void showDialog();
@@ -93,7 +88,6 @@ private:
void updateOptionsPage();
Ui::PreferencesDialogClass m_ui;
- QHelpEngineCore *m_helpEngine;
bool m_hideFiltersTab;
bool m_hideDocsTab;
QMap<QString, QStringList> m_filterMapBackup;
@@ -107,6 +101,7 @@ private:
FontPanel *m_browserFontPanel;
bool m_appFontChanged;
bool m_browserFontChanged;
+ HelpEngineWrapper &helpEngine;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/qtdocinstaller.cpp b/tools/assistant/tools/assistant/qtdocinstaller.cpp
index 89ee00462..3675aec2f 100644
--- a/tools/assistant/tools/assistant/qtdocinstaller.cpp
+++ b/tools/assistant/tools/assistant/qtdocinstaller.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -42,15 +42,16 @@
#include <QtCore/QDir>
#include <QtCore/QLibraryInfo>
#include <QtCore/QDateTime>
+#include <QtCore/QFileSystemWatcher>
#include <QtHelp/QHelpEngineCore>
+#include "helpenginewrapper.h"
#include "qtdocinstaller.h"
QT_BEGIN_NAMESPACE
-QtDocInstaller::QtDocInstaller(const QString &collectionFile)
+QtDocInstaller::QtDocInstaller(const QList<DocInfo> &docInfos)
+ : m_abort(false), m_docInfos(docInfos)
{
- m_abort = false;
- m_collectionFile = collectionFile;
}
QtDocInstaller::~QtDocInstaller()
@@ -70,81 +71,51 @@ void QtDocInstaller::installDocs()
void QtDocInstaller::run()
{
- QHelpEngineCore *helpEngine = new QHelpEngineCore(m_collectionFile);
- helpEngine->setupData();
- bool changes = false;
-
- QStringList docs;
- docs << QLatin1String("assistant")
- << QLatin1String("designer")
- << QLatin1String("linguist")
- << QLatin1String("qmake")
- << QLatin1String("qt");
+ m_qchDir = QLibraryInfo::location(QLibraryInfo::DocumentationPath)
+ + QDir::separator() + QLatin1String("qch");
+ m_qchFiles = m_qchDir.entryList(QStringList() << QLatin1String("*.qch"));
- foreach (const QString &doc, docs) {
- changes |= installDoc(doc, helpEngine);
+ bool changes = false;
+ foreach (const DocInfo &docInfo, m_docInfos) {
+ changes |= installDoc(docInfo);
m_mutex.lock();
if (m_abort) {
- delete helpEngine;
m_mutex.unlock();
return;
}
m_mutex.unlock();
}
- delete helpEngine;
emit docsInstalled(changes);
}
-bool QtDocInstaller::installDoc(const QString &name, QHelpEngineCore *helpEngine)
+bool QtDocInstaller::installDoc(const DocInfo &docInfo)
{
- QString versionKey = QString(QLatin1String("qtVersion%1$$$%2")).
- arg(QLatin1String(QT_VERSION_STR)).arg(name);
-
- QString info = helpEngine->customValue(versionKey, QString()).toString();
- QStringList lst = info.split(QLatin1String("|"));
-
+ const QString &component = docInfo.first;
+ const QStringList &info = docInfo.second;
QDateTime dt;
- if (lst.count() && !lst.first().isEmpty())
- dt = QDateTime::fromString(lst.first(), Qt::ISODate);
+ if (!info.isEmpty() && !info.first().isEmpty())
+ dt = QDateTime::fromString(info.first(), Qt::ISODate);
QString qchFile;
- if (lst.count() == 2)
- qchFile = lst.last();
+ if (info.count() == 2)
+ qchFile = info.last();
- QDir dir(QLibraryInfo::location(QLibraryInfo::DocumentationPath)
- + QDir::separator() + QLatin1String("qch"));
-
- const QStringList files = dir.entryList(QStringList() << QLatin1String("*.qch"));
- if (files.isEmpty()) {
- helpEngine->setCustomValue(versionKey, QDateTime().toString(Qt::ISODate)
- + QLatin1String("|"));
+ if (m_qchFiles.isEmpty()) {
+ emit qchFileNotFound(component);
return false;
}
- foreach (const QString &f, files) {
- if (f.startsWith(name)) {
- QFileInfo fi(dir.absolutePath() + QDir::separator() + f);
- if (dt.isValid() && fi.lastModified().toString(Qt::ISODate) == dt.toString(Qt::ISODate)
+ foreach (const QString &f, m_qchFiles) {
+ if (f.startsWith(component)) {
+ QFileInfo fi(m_qchDir.absolutePath() + QDir::separator() + f);
+ if (dt.isValid() && fi.lastModified().toTime_t() == dt.toTime_t()
&& qchFile == fi.absoluteFilePath())
return false;
-
- QString namespaceName = QHelpEngineCore::namespaceName(fi.absoluteFilePath());
- if (namespaceName.isEmpty())
- continue;
-
- if (helpEngine->registeredDocumentations().contains(namespaceName))
- helpEngine->unregisterDocumentation(namespaceName);
-
- if (!helpEngine->registerDocumentation(fi.absoluteFilePath())) {
- emit errorMessage(
- tr("The file %1 could not be registered successfully!\n\nReason: %2")
- .arg(fi.absoluteFilePath()).arg(helpEngine->error()));
- }
-
- helpEngine->setCustomValue(versionKey, fi.lastModified().toString(Qt::ISODate)
- + QLatin1String("|") + fi.absoluteFilePath());
+ emit registerDocumentation(component, fi.absoluteFilePath());
return true;
}
}
+
+ emit qchFileNotFound(component);
return false;
}
diff --git a/tools/assistant/tools/assistant/qtdocinstaller.h b/tools/assistant/tools/assistant/qtdocinstaller.h
index bb5cadb37..c64a5c302 100644
--- a/tools/assistant/tools/assistant/qtdocinstaller.h
+++ b/tools/assistant/tools/assistant/qtdocinstaller.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -42,34 +42,41 @@
#ifndef QTDOCINSTALLER
#define QTDOCINSTALLER
-#include <QtCore/QThread>
+#include <QtCore/QDir>
#include <QtCore/QMutex>
+#include <QtCore/QPair>
+#include <QtCore/QStringList>
+#include <QtCore/QThread>
QT_BEGIN_NAMESPACE
-class QHelpEngineCore;
+class HelpEngineWrapper;
class QtDocInstaller : public QThread
{
Q_OBJECT
public:
- QtDocInstaller(const QString &collectionFile);
+ typedef QPair<QString, QStringList> DocInfo;
+ QtDocInstaller(const QList<DocInfo> &docInfos);
~QtDocInstaller();
void installDocs();
signals:
- void errorMessage(const QString &msg);
+ void qchFileNotFound(const QString &component);
+ void registerDocumentation(const QString &component,
+ const QString &absFileName);
void docsInstalled(bool newDocsInstalled);
private:
void run();
- bool installDoc(const QString &name,
- QHelpEngineCore *helpEngine);
+ bool installDoc(const DocInfo &docInfo);
bool m_abort;
- QString m_collectionFile;
QMutex m_mutex;
+ QStringList m_qchFiles;
+ QDir m_qchDir;
+ QList<DocInfo> m_docInfos;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp
index 7867ba018..f4ae3b42a 100644
--- a/tools/assistant/tools/assistant/remotecontrol.cpp
+++ b/tools/assistant/tools/assistant/remotecontrol.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -42,8 +42,11 @@
#include "remotecontrol.h"
#include "mainwindow.h"
#include "centralwidget.h"
+#include "helpenginewrapper.h"
#include <QtCore/QFile>
+#include <QtCore/QFileInfo>
+#include <QtCore/QFileSystemWatcher>
#include <QtCore/QThread>
#include <QtCore/QTextStream>
#include <QtCore/QSocketNotifier>
@@ -97,28 +100,28 @@ void StdInListenerWin::run()
#endif
while (ok) {
- ok = ReadFile(hStdinDup, chBuf, 4096, &dwRead, NULL);
+ ok = ReadFile(hStdinDup, chBuf, sizeof(chBuf), &dwRead, NULL);
if (ok && dwRead != 0)
- emit receivedCommand(QString::fromLocal8Bit(chBuf));
+ emit receivedCommand(QString::fromLocal8Bit(chBuf, dwRead));
}
}
#endif
-RemoteControl::RemoteControl(MainWindow *mainWindow, QHelpEngine *helpEngine)
+RemoteControl::RemoteControl(MainWindow *mainWindow)
: QObject(mainWindow)
, m_mainWindow(mainWindow)
- , m_helpEngine(helpEngine)
, m_debug(false)
, m_caching(true)
, m_syncContents(false)
- , m_expandTOC(-3)
+ , m_expandTOC(-2)
+ , helpEngine(HelpEngineWrapper::instance())
{
connect(m_mainWindow, SIGNAL(initDone()), this, SLOT(applyCache()));
#ifdef Q_OS_WIN
StdInListenerWin *l = new StdInListenerWin(this);
- connect(l, SIGNAL(receivedCommand(const QString&)),
- this, SLOT(handleCommandString(const QString&)));
+ connect(l, SIGNAL(receivedCommand(QString)),
+ this, SLOT(handleCommandString(QString)));
l->start();
#else
QSocketNotifier *notifier = new QSocketNotifier(fileno(stdin),
@@ -147,131 +150,189 @@ void RemoteControl::handleCommandString(const QString &cmdString)
{
QStringList cmds = cmdString.split(QLatin1Char(';'));
QStringList::const_iterator it = cmds.constBegin();
- QString cmdLine, cmd, arg;
while (it != cmds.constEnd()) {
- cmdLine = (*it).trimmed();
- cmd = cmdLine;
- arg.clear();
- int i = cmdLine.indexOf(QLatin1Char(' '));
- if (i > 0) {
- cmd = cmdLine.left(i);
- arg = cmdLine.mid(i+1);
- }
- cmd = cmd.toLower();
+ QString cmd, arg;
+ splitInputString(*it, cmd, arg);
if (m_debug)
QMessageBox::information(0, tr("Debugging Remote Control"),
tr("Received Command: %1 %2").arg(cmd).arg(arg));
- if (cmd == QLatin1String("debug")) {
- if (arg == QLatin1String("on"))
- m_debug = true;
- else
- m_debug = false;
- } else if (cmd == QLatin1String("show")) {
- if (arg.toLower() == QLatin1String("contents")) {
- m_mainWindow->showContents();
- } else if (arg.toLower() == QLatin1String("index")) {
- m_mainWindow->showIndex();
- } else if (arg.toLower() == QLatin1String("bookmarks")) {
- m_mainWindow->showBookmarks();
- } else if (arg.toLower() == QLatin1String("search")) {
- m_mainWindow->showSearch();
- }
- } else if (cmd == QLatin1String("hide")) {
- if (arg.toLower() == QLatin1String("contents")) {
- m_mainWindow->hideContents();
- } else if (arg.toLower() == QLatin1String("index")) {
- m_mainWindow->hideIndex();
- } else if (arg.toLower() == QLatin1String("bookmarks")) {
- m_mainWindow->hideBookmarks();
- } else if (arg.toLower() == QLatin1String("search")) {
- m_mainWindow->hideSearch();
- }
- } else if (cmd == QLatin1String("setsource")) {
- QUrl url(arg);
- if (url.isValid()) {
- if (url.isRelative())
- url = CentralWidget::instance()->currentSource().resolved(url);
- if (m_caching) {
- clearCache();
- m_setSource = url;
- } else {
- CentralWidget::instance()->setSource(url);
- }
- }
- } else if (cmd == QLatin1String("synccontents")) {
- if (m_caching)
- m_syncContents = true;
- else
- m_mainWindow->syncContents();
- } else if (cmd == QLatin1String("activatekeyword")) {
- if (m_caching) {
- clearCache();
- m_activateKeyword = arg;
- } else {
- m_mainWindow->setIndexString(arg);
- if (!arg.isEmpty())
- m_helpEngine->indexWidget()->activateCurrentItem();
- }
- } else if (cmd == QLatin1String("activateidentifier")) {
- if (m_caching) {
- clearCache();
- m_activateIdentifier = arg;
- } else {
- QMap<QString, QUrl> links =
- m_helpEngine->linksForIdentifier(arg);
- if (links.count())
- CentralWidget::instance()->setSource(links.constBegin().value());
- }
- } else if (cmd == QLatin1String("expandtoc")) {
- bool ok = false;
- int depth = -1;
- if (!arg.isEmpty())
- depth = arg.toInt(&ok);
- if (!ok)
- depth = -1;
-
- if (m_caching)
- m_expandTOC = depth;
- else
- m_mainWindow->expandTOC(depth);
- } else if (cmd == QLatin1String("setcurrentfilter")) {
- if (m_caching) {
- clearCache();
- m_currentFilter = arg;
- } else {
- m_helpEngine->setCurrentFilter(arg);
- }
- } else {
+ if (cmd == QLatin1String("debug"))
+ handleDebugCommand(arg);
+ else if (cmd == QLatin1String("show"))
+ handleShowOrHideCommand(arg, true);
+ else if (cmd == QLatin1String("hide"))
+ handleShowOrHideCommand(arg, false);
+ else if (cmd == QLatin1String("setsource"))
+ handleSetSourceCommand(arg);
+ else if (cmd == QLatin1String("synccontents"))
+ handleSyncContentsCommand();
+ else if (cmd == QLatin1String("activatekeyword"))
+ handleActivateKeywordCommand(arg);
+ else if (cmd == QLatin1String("activateidentifier"))
+ handleActivateIdentifierCommand(arg);
+ else if (cmd == QLatin1String("expandtoc"))
+ handleExpandTocCommand(arg);
+ else if (cmd == QLatin1String("setcurrentfilter"))
+ handleSetCurrentFilterCommand(arg);
+ else if (cmd == QLatin1String("register"))
+ handleRegisterCommand(arg);
+ else if (cmd == QLatin1String("unregister"))
+ handleUnregisterCommand(arg);
+ else
return;
- }
+
++it;
}
m_mainWindow->raise();
m_mainWindow->activateWindow();
}
+void RemoteControl::splitInputString(const QString &input, QString &cmd,
+ QString &arg)
+{
+ QString cmdLine = input.trimmed();
+ int i = cmdLine.indexOf(QLatin1Char(' '));
+ cmd = cmdLine.left(i);
+ arg = cmdLine.mid(i+1);
+ cmd = cmd.toLower();
+}
+
+void RemoteControl::handleDebugCommand(const QString &arg)
+{
+ m_debug = arg == QLatin1String("on");
+}
+
+void RemoteControl::handleShowOrHideCommand(const QString &arg, bool show)
+{
+ if (arg.toLower() == QLatin1String("contents"))
+ m_mainWindow->setContentsVisible(show);
+ else if (arg.toLower() == QLatin1String("index"))
+ m_mainWindow->setIndexVisible(show);
+ else if (arg.toLower() == QLatin1String("bookmarks"))
+ m_mainWindow->setBookmarksVisible(show);
+ else if (arg.toLower() == QLatin1String("search"))
+ m_mainWindow->setSearchVisible(show);
+}
+
+void RemoteControl::handleSetSourceCommand(const QString &arg)
+{
+ QUrl url(arg);
+ if (url.isValid()) {
+ if (url.isRelative())
+ url = CentralWidget::instance()->currentSource().resolved(url);
+ if (m_caching) {
+ clearCache();
+ m_setSource = url;
+ } else {
+ CentralWidget::instance()->setSource(url);
+ }
+ }
+}
+
+void RemoteControl::handleSyncContentsCommand()
+{
+ if (m_caching)
+ m_syncContents = true;
+ else
+ m_mainWindow->syncContents();
+}
+
+void RemoteControl::handleActivateKeywordCommand(const QString &arg)
+{
+ if (m_caching) {
+ clearCache();
+ m_activateKeyword = arg;
+ } else {
+ m_mainWindow->setIndexString(arg);
+ if (!arg.isEmpty())
+ helpEngine.indexWidget()->activateCurrentItem();
+ }
+}
+
+void RemoteControl::handleActivateIdentifierCommand(const QString &arg)
+{
+ if (m_caching) {
+ clearCache();
+ m_activateIdentifier = arg;
+ } else {
+ const QMap<QString, QUrl> &links = helpEngine.linksForIdentifier(arg);
+ if (!links.isEmpty())
+ CentralWidget::instance()->setSource(links.constBegin().value());
+ }
+}
+
+void RemoteControl::handleExpandTocCommand(const QString &arg)
+{
+ bool ok = false;
+ int depth = -2;
+ if (!arg.isEmpty())
+ depth = arg.toInt(&ok);
+ if (!ok || depth < -2)
+ depth = -2;
+
+ if (m_caching)
+ m_expandTOC = depth;
+ else if (depth != -2)
+ m_mainWindow->expandTOC(depth);
+}
+
+void RemoteControl::handleSetCurrentFilterCommand(const QString &arg)
+{
+ if (helpEngine.customFilters().contains(arg)) {
+ if (m_caching) {
+ clearCache();
+ m_currentFilter = arg;
+ } else {
+ helpEngine.setCurrentFilter(arg);
+ }
+ }
+}
+
+void RemoteControl::handleRegisterCommand(const QString &arg)
+{
+ const QString &absFileName = QFileInfo(arg).absoluteFilePath();
+ if (helpEngine.registeredDocumentations().
+ contains(QHelpEngineCore::namespaceName(absFileName)))
+ return;
+ if (helpEngine.registerDocumentation(absFileName))
+ helpEngine.setupData();
+}
+
+void RemoteControl::handleUnregisterCommand(const QString &arg)
+{
+ const QString &absFileName = QFileInfo(arg).absoluteFilePath();
+ const QString &ns = QHelpEngineCore::namespaceName(absFileName);
+ if (helpEngine.registeredDocumentations().contains(ns)) {
+ CentralWidget* widget = CentralWidget::instance();
+ widget->closeTabs(widget->currentSourceFileList().keys(ns));
+ if (helpEngine.unregisterDocumentation(ns))
+ helpEngine.setupData();
+ }
+}
+
void RemoteControl::applyCache()
{
if (m_setSource.isValid()) {
CentralWidget::instance()->setSource(m_setSource);
} else if (!m_activateKeyword.isEmpty()) {
m_mainWindow->setIndexString(m_activateKeyword);
- m_helpEngine->indexWidget()->activateCurrentItem();
+ helpEngine.indexWidget()->activateCurrentItem();
} else if (!m_activateIdentifier.isEmpty()) {
QMap<QString, QUrl> links =
- m_helpEngine->linksForIdentifier(m_activateIdentifier);
- if (links.count())
+ helpEngine.linksForIdentifier(m_activateIdentifier);
+ if (!links.isEmpty())
CentralWidget::instance()->setSource(links.constBegin().value());
} else if (!m_currentFilter.isEmpty()) {
- m_helpEngine->setCurrentFilter(m_currentFilter);
+ helpEngine.setCurrentFilter(m_currentFilter);
}
if (m_syncContents)
m_mainWindow->syncContents();
- if (m_expandTOC != -3)
+ Q_ASSERT(m_expandTOC >= -2);
+ if (m_expandTOC != -2)
m_mainWindow->expandTOC(m_expandTOC);
m_caching = false;
diff --git a/tools/assistant/tools/assistant/remotecontrol.h b/tools/assistant/tools/assistant/remotecontrol.h
index df2a1e418..5d7499621 100644
--- a/tools/assistant/tools/assistant/remotecontrol.h
+++ b/tools/assistant/tools/assistant/remotecontrol.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -43,19 +43,20 @@
#define REMOTECONTROL_H
#include <QtCore/QObject>
+#include <QtCore/QString>
#include <QtCore/QUrl>
QT_BEGIN_NAMESPACE
+class HelpEngineWrapper;
class MainWindow;
-class QHelpEngine;
class RemoteControl : public QObject
{
Q_OBJECT
public:
- RemoteControl(MainWindow *mainWindow, QHelpEngine *helpEngine);
+ RemoteControl(MainWindow *mainWindow);
private slots:
void receivedData();
@@ -64,10 +65,20 @@ private slots:
private:
void clearCache();
+ void splitInputString(const QString &input, QString &cmd, QString &arg);
+ void handleDebugCommand(const QString &arg);
+ void handleShowOrHideCommand(const QString &arg, bool show);
+ void handleSetSourceCommand(const QString &arg);
+ void handleSyncContentsCommand();
+ void handleActivateKeywordCommand(const QString &arg);
+ void handleActivateIdentifierCommand(const QString &arg);
+ void handleExpandTocCommand(const QString &arg);
+ void handleSetCurrentFilterCommand(const QString &arg);
+ void handleRegisterCommand(const QString &arg);
+ void handleUnregisterCommand(const QString &arg);
private:
MainWindow *m_mainWindow;
- QHelpEngine *m_helpEngine;
bool m_debug;
bool m_caching;
@@ -77,6 +88,7 @@ private:
QString m_activateIdentifier;
int m_expandTOC;
QString m_currentFilter;
+ HelpEngineWrapper &helpEngine;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/remotecontrol_win.h b/tools/assistant/tools/assistant/remotecontrol_win.h
index ea56a162d..721a5d349 100644
--- a/tools/assistant/tools/assistant/remotecontrol_win.h
+++ b/tools/assistant/tools/assistant/remotecontrol_win.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tools/assistant/tools/assistant/searchwidget.cpp b/tools/assistant/tools/assistant/searchwidget.cpp
index 364ca578d..3b456a38a 100644
--- a/tools/assistant/tools/assistant/searchwidget.cpp
+++ b/tools/assistant/tools/assistant/searchwidget.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -85,7 +85,8 @@ SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent)
SLOT(searchingFinished(int)));
QTextBrowser* browser = qFindChild<QTextBrowser*>(resultWidget);
- browser->viewport()->installEventFilter(this);
+ if (browser) // Will be null if lib was configured not to use CLucene.
+ browser->viewport()->installEventFilter(this);
}
SearchWidget::~SearchWidget()
diff --git a/tools/assistant/tools/assistant/searchwidget.h b/tools/assistant/tools/assistant/searchwidget.h
index 66519fbbc..d3c692173 100644
--- a/tools/assistant/tools/assistant/searchwidget.h
+++ b/tools/assistant/tools/assistant/searchwidget.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tools/assistant/tools/assistant/topicchooser.cpp b/tools/assistant/tools/assistant/topicchooser.cpp
index 2896a8724..0382fe2e9 100644
--- a/tools/assistant/tools/assistant/topicchooser.cpp
+++ b/tools/assistant/tools/assistant/topicchooser.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tools/assistant/tools/assistant/topicchooser.h b/tools/assistant/tools/assistant/topicchooser.h
index f1402886f..949c7da80 100644
--- a/tools/assistant/tools/assistant/topicchooser.h
+++ b/tools/assistant/tools/assistant/topicchooser.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Assistant of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** 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.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/tools/assistant/tools/assistant/tracer.h b/tools/assistant/tools/assistant/tracer.h
new file mode 100644
index 000000000..3d8b647e9
--- /dev/null
+++ b/tools/assistant/tools/assistant/tracer.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Assistant of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TRACER_H
+#define TRACER_H
+
+#include <QtCore/QtGlobal>
+
+QT_BEGIN_NAMESPACE
+
+class Tracer
+{
+public:
+ Tracer(const char *func) : m_func(func)
+ {
+ qDebug("Entering function %s.", m_func);
+ }
+
+ ~Tracer()
+ {
+ qDebug("Leaving function %s.", m_func);
+ }
+
+private:
+ const char * const m_func;
+};
+
+QT_END_NAMESPACE
+
+// #define TRACING_REQUESTED
+#ifdef TRACING_REQUESTED
+#define TRACE_OBJ Tracer traceObj__(Q_FUNC_INFO);
+#else
+#define TRACE_OBJ
+#endif
+
+#endif // TRACER_H
diff --git a/tools/assistant/tools/assistant/xbelsupport.cpp b/tools/assistant/tools/assistant/xbelsupport.cpp
new file mode 100644
index 000000000..3c545aca8
--- /dev/null
+++ b/tools/assistant/tools/assistant/xbelsupport.cpp
@@ -0,0 +1,238 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Assistant of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "xbelsupport.h"
+#include "bookmarkmanager.h"
+
+#include <QtCore/QCoreApplication>
+
+QT_BEGIN_NAMESPACE
+
+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();
+ }
+}
+
+
+// XbelReader
+
+
+XbelReader::XbelReader(BookmarkModel *tree, BookmarkModel *list)
+ : QXmlStreamReader()
+ , treeModel(tree)
+ , listModel(list)
+{
+ folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon);
+ bookmarkIcon = QIcon(QLatin1String(":/trolltech/assistant/images/bookmark.png"));
+}
+
+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(QLatin1String("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(QCoreApplication::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;
+}
+
+QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/xbelsupport.h b/tools/assistant/tools/assistant/xbelsupport.h
new file mode 100644
index 000000000..f3bf10272
--- /dev/null
+++ b/tools/assistant/tools/assistant/xbelsupport.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Assistant of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef XBELSUPPORT_H
+#define XBELSUPPORT_H
+
+#include <QtGui/QIcon>
+#include <QtXml/QXmlStreamReader>
+
+QT_FORWARD_DECLARE_CLASS(QIODevice)
+QT_FORWARD_DECLARE_CLASS(QStandardItem)
+
+QT_BEGIN_NAMESPACE
+
+class BookmarkModel;
+
+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;
+};
+
+QT_END_NAMESPACE
+
+#endif // XBELSUPPORT_H