[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the Qt Assistant of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at qt-info@nokia.com.
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #include "qhelpengine.h"
|
---|
| 43 | #include "qhelpengine_p.h"
|
---|
| 44 | #include "qhelpdbreader_p.h"
|
---|
| 45 | #include "qhelpcontentwidget.h"
|
---|
| 46 | #include "qhelpindexwidget.h"
|
---|
| 47 | #include "qhelpsearchengine.h"
|
---|
| 48 | #include "qhelpcollectionhandler_p.h"
|
---|
| 49 |
|
---|
| 50 | #include <QtCore/QDir>
|
---|
| 51 | #include <QtCore/QFile>
|
---|
| 52 | #include <QtCore/QLibrary>
|
---|
| 53 | #include <QtCore/QPluginLoader>
|
---|
| 54 | #include <QtGui/QApplication>
|
---|
| 55 | #include <QtSql/QSqlQuery>
|
---|
| 56 |
|
---|
| 57 | QT_BEGIN_NAMESPACE
|
---|
| 58 |
|
---|
| 59 | QHelpEnginePrivate::QHelpEnginePrivate()
|
---|
| 60 | : QHelpEngineCorePrivate()
|
---|
| 61 | , contentModel(0)
|
---|
| 62 | , contentWidget(0)
|
---|
| 63 | , indexModel(0)
|
---|
| 64 | , indexWidget(0)
|
---|
| 65 | , searchEngine(0)
|
---|
| 66 | {
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | QHelpEnginePrivate::~QHelpEnginePrivate()
|
---|
| 70 | {
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | void QHelpEnginePrivate::init(const QString &collectionFile,
|
---|
| 74 | QHelpEngineCore *helpEngineCore)
|
---|
| 75 | {
|
---|
| 76 | QHelpEngineCorePrivate::init(collectionFile, helpEngineCore);
|
---|
| 77 |
|
---|
[846] | 78 | if (!contentModel)
|
---|
| 79 | contentModel = new QHelpContentModel(this);
|
---|
| 80 | if (!indexModel)
|
---|
| 81 | indexModel = new QHelpIndexModel(this);
|
---|
[2] | 82 |
|
---|
[846] | 83 | connect(helpEngineCore, SIGNAL(setupFinished()), this,
|
---|
| 84 | SLOT(applyCurrentFilter()));
|
---|
| 85 | connect(helpEngineCore, SIGNAL(currentFilterChanged(QString)), this,
|
---|
| 86 | SLOT(applyCurrentFilter()));
|
---|
[2] | 87 | }
|
---|
| 88 |
|
---|
| 89 | void QHelpEnginePrivate::applyCurrentFilter()
|
---|
| 90 | {
|
---|
| 91 | if (!error.isEmpty())
|
---|
| 92 | return;
|
---|
| 93 | contentModel->createContents(currentFilter);
|
---|
| 94 | indexModel->createIndex(currentFilter);
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | void QHelpEnginePrivate::setContentsWidgetBusy()
|
---|
| 98 | {
|
---|
| 99 | contentWidget->setCursor(Qt::WaitCursor);
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | void QHelpEnginePrivate::unsetContentsWidgetBusy()
|
---|
| 103 | {
|
---|
| 104 | contentWidget->unsetCursor();
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | void QHelpEnginePrivate::setIndexWidgetBusy()
|
---|
| 108 | {
|
---|
| 109 | indexWidget->setCursor(Qt::WaitCursor);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | void QHelpEnginePrivate::unsetIndexWidgetBusy()
|
---|
| 113 | {
|
---|
| 114 | indexWidget->unsetCursor();
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | void QHelpEnginePrivate::stopDataCollection()
|
---|
| 118 | {
|
---|
| 119 | contentModel->invalidateContents(true);
|
---|
| 120 | indexModel->invalidateIndex(true);
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | /*!
|
---|
| 126 | \class QHelpEngine
|
---|
| 127 | \since 4.4
|
---|
| 128 | \inmodule QtHelp
|
---|
| 129 | \brief The QHelpEngine class provides access to contents and
|
---|
| 130 | indices of the help engine.
|
---|
| 131 |
|
---|
| 132 |
|
---|
| 133 | */
|
---|
| 134 |
|
---|
| 135 | /*!
|
---|
| 136 | Constructs a new help engine with the given \a parent. The help
|
---|
| 137 | engine uses the information stored in the \a collectionFile for
|
---|
| 138 | providing help. If the collection file does not already exist,
|
---|
| 139 | it will be created.
|
---|
| 140 | */
|
---|
| 141 | QHelpEngine::QHelpEngine(const QString &collectionFile, QObject *parent)
|
---|
| 142 | : QHelpEngineCore(d = new QHelpEnginePrivate(), parent)
|
---|
| 143 | {
|
---|
| 144 | d->init(collectionFile, this);
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | /*!
|
---|
| 148 | Destroys the help engine object.
|
---|
| 149 | */
|
---|
| 150 | QHelpEngine::~QHelpEngine()
|
---|
| 151 | {
|
---|
| 152 | d->stopDataCollection();
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | /*!
|
---|
| 156 | Returns the content model.
|
---|
| 157 | */
|
---|
| 158 | QHelpContentModel *QHelpEngine::contentModel() const
|
---|
| 159 | {
|
---|
| 160 | return d->contentModel;
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | /*!
|
---|
| 164 | Returns the index model.
|
---|
| 165 | */
|
---|
| 166 | QHelpIndexModel *QHelpEngine::indexModel() const
|
---|
| 167 | {
|
---|
| 168 | return d->indexModel;
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | /*!
|
---|
| 172 | Returns the content widget.
|
---|
| 173 | */
|
---|
| 174 | QHelpContentWidget *QHelpEngine::contentWidget()
|
---|
| 175 | {
|
---|
| 176 | if (!d->contentWidget) {
|
---|
| 177 | d->contentWidget = new QHelpContentWidget();
|
---|
| 178 | d->contentWidget->setModel(d->contentModel);
|
---|
| 179 | connect(d->contentModel, SIGNAL(contentsCreationStarted()),
|
---|
| 180 | d, SLOT(setContentsWidgetBusy()));
|
---|
| 181 | connect(d->contentModel, SIGNAL(contentsCreated()),
|
---|
| 182 | d, SLOT(unsetContentsWidgetBusy()));
|
---|
| 183 | }
|
---|
| 184 | return d->contentWidget;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | /*!
|
---|
| 188 | Returns the index widget.
|
---|
| 189 | */
|
---|
| 190 | QHelpIndexWidget *QHelpEngine::indexWidget()
|
---|
| 191 | {
|
---|
| 192 | if (!d->indexWidget) {
|
---|
| 193 | d->indexWidget = new QHelpIndexWidget();
|
---|
| 194 | d->indexWidget->setModel(d->indexModel);
|
---|
| 195 | connect(d->indexModel, SIGNAL(indexCreationStarted()),
|
---|
| 196 | d, SLOT(setIndexWidgetBusy()));
|
---|
| 197 | connect(d->indexModel, SIGNAL(indexCreated()),
|
---|
| 198 | d, SLOT(unsetIndexWidgetBusy()));
|
---|
| 199 | }
|
---|
| 200 | return d->indexWidget;
|
---|
| 201 | }
|
---|
| 202 |
|
---|
| 203 | /*!
|
---|
| 204 | Returns the default search engine.
|
---|
| 205 | */
|
---|
| 206 | QHelpSearchEngine* QHelpEngine::searchEngine()
|
---|
| 207 | {
|
---|
| 208 | if (!d->searchEngine)
|
---|
| 209 | d->searchEngine = new QHelpSearchEngine(this, this);
|
---|
| 210 | return d->searchEngine;
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | QT_END_NAMESPACE
|
---|