summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/lib/fulltextsearch/qsort_p.h8
-rw-r--r--tools/assistant/lib/qhelpcollectionhandler_p.h3
-rw-r--r--tools/assistant/lib/qhelpengine.h2
-rw-r--r--tools/assistant/lib/qhelpenginecore.cpp2
-rw-r--r--tools/assistant/lib/qhelpenginecore.h2
-rw-r--r--tools/assistant/lib/qhelpsearchengine.h3
-rw-r--r--tools/assistant/lib/qhelpsearchindexreader_clucene.cpp4
-rw-r--r--tools/assistant/lib/qhelpsearchquerywidget.cpp84
-rw-r--r--tools/assistant/lib/qhelpsearchquerywidget.h4
-rw-r--r--tools/assistant/tools/assistant/bookmarkfiltermodel.cpp116
-rw-r--r--tools/assistant/tools/assistant/bookmarkitem.cpp5
-rw-r--r--tools/assistant/tools/assistant/bookmarkitem.h2
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.cpp101
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanager.h9
-rw-r--r--tools/assistant/tools/assistant/bookmarkmanagerwidget.h5
-rw-r--r--tools/assistant/tools/assistant/bookmarkmodel.cpp35
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp148
-rw-r--r--tools/assistant/tools/assistant/centralwidget.h30
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.cpp6
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.h1
-rw-r--r--tools/assistant/tools/assistant/globalactions.cpp83
-rw-r--r--tools/assistant/tools/assistant/globalactions.h14
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.cpp27
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.h5
-rw-r--r--tools/assistant/tools/assistant/helpviewer.h1
-rw-r--r--tools/assistant/tools/assistant/installdialog.h2
-rw-r--r--tools/assistant/tools/assistant/main.cpp5
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp36
-rw-r--r--tools/assistant/tools/assistant/mainwindow.h2
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.cpp19
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.h3
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.cpp7
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.h2
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.ui20
-rw-r--r--tools/assistant/tools/assistant/remotecontrol.cpp22
-rw-r--r--tools/assistant/tools/assistant/searchwidget.cpp13
-rw-r--r--tools/assistant/tools/assistant/searchwidget.h6
-rw-r--r--tools/assistant/tools/qcollectiongenerator/main.cpp86
-rw-r--r--tools/assistant/tools/qhelpconverter/filespage.cpp4
-rw-r--r--tools/assistant/tools/qhelpconverter/filterpage.cpp4
-rw-r--r--tools/assistant/tools/qhelpconverter/finishpage.cpp3
-rw-r--r--tools/assistant/tools/qhelpconverter/helpwindow.cpp2
-rw-r--r--tools/assistant/tools/qhelpconverter/inputpage.h2
-rw-r--r--tools/assistant/tools/qhelpconverter/main.cpp15
-rw-r--r--tools/assistant/tools/qhelpgenerator/main.cpp42
-rw-r--r--tools/assistant/tools/shared/collectionconfiguration.cpp14
-rw-r--r--tools/assistant/tools/shared/collectionconfiguration.h4
-rw-r--r--tools/assistant/tools/shared/helpgenerator.cpp4
48 files changed, 788 insertions, 229 deletions
diff --git a/tools/assistant/lib/fulltextsearch/qsort_p.h b/tools/assistant/lib/fulltextsearch/qsort_p.h
index e6f024b..5c75c58 100644
--- a/tools/assistant/lib/fulltextsearch/qsort_p.h
+++ b/tools/assistant/lib/fulltextsearch/qsort_p.h
@@ -64,15 +64,15 @@ private:
class QHELP_EXPORT QCLuceneSort
{
public:
- QCLuceneSort();
- QCLuceneSort(const QStringList &fieldNames);
- QCLuceneSort(const QString &field, bool reverse = false);
+ QCLuceneSort();
+ explicit QCLuceneSort(const QStringList &fieldNames);
+ explicit QCLuceneSort(const QString &field, bool reverse = false);
virtual ~QCLuceneSort();
QString toString() const;
void setSort(const QStringList &fieldNames);
- void setSort(const QString &field, bool reverse = false);
+ void setSort(const QString &field, bool reverse = false);
protected:
friend class QCLuceneHits;
diff --git a/tools/assistant/lib/qhelpcollectionhandler_p.h b/tools/assistant/lib/qhelpcollectionhandler_p.h
index 8efe507..8901b06 100644
--- a/tools/assistant/lib/qhelpcollectionhandler_p.h
+++ b/tools/assistant/lib/qhelpcollectionhandler_p.h
@@ -76,7 +76,8 @@ public:
};
typedef QList<DocInfo> DocInfoList;
- QHelpCollectionHandler(const QString &collectionFile, QObject *parent = 0);
+ explicit QHelpCollectionHandler(const QString &collectionFile,
+ QObject *parent = 0);
~QHelpCollectionHandler();
QString collectionFile() const;
diff --git a/tools/assistant/lib/qhelpengine.h b/tools/assistant/lib/qhelpengine.h
index 2bdb983..3577f4b 100644
--- a/tools/assistant/lib/qhelpengine.h
+++ b/tools/assistant/lib/qhelpengine.h
@@ -62,7 +62,7 @@ class QHELP_EXPORT QHelpEngine : public QHelpEngineCore
Q_OBJECT
public:
- QHelpEngine(const QString &collectionFile, QObject *parent = 0);
+ explicit QHelpEngine(const QString &collectionFile, QObject *parent = 0);
~QHelpEngine();
QHelpContentModel *contentModel() const;
diff --git a/tools/assistant/lib/qhelpenginecore.cpp b/tools/assistant/lib/qhelpenginecore.cpp
index 71306af..d72dfe4 100644
--- a/tools/assistant/lib/qhelpenginecore.cpp
+++ b/tools/assistant/lib/qhelpenginecore.cpp
@@ -706,7 +706,7 @@ QVariant QHelpEngineCore::metaData(const QString &documentationFileName,
}
/*!
- Returns a description of the last error that occured.
+ Returns a description of the last error that occurred.
*/
QString QHelpEngineCore::error() const
{
diff --git a/tools/assistant/lib/qhelpenginecore.h b/tools/assistant/lib/qhelpenginecore.h
index 118c310..db25c0b 100644
--- a/tools/assistant/lib/qhelpenginecore.h
+++ b/tools/assistant/lib/qhelpenginecore.h
@@ -65,7 +65,7 @@ class QHELP_EXPORT QHelpEngineCore : public QObject
Q_PROPERTY(QString currentFilter READ currentFilter WRITE setCurrentFilter)
public:
- QHelpEngineCore(const QString &collectionFile, QObject *parent = 0);
+ explicit QHelpEngineCore(const QString &collectionFile, QObject *parent = 0);
virtual ~QHelpEngineCore();
bool setupData();
diff --git a/tools/assistant/lib/qhelpsearchengine.h b/tools/assistant/lib/qhelpsearchengine.h
index 545360c..0b07920 100644
--- a/tools/assistant/lib/qhelpsearchengine.h
+++ b/tools/assistant/lib/qhelpsearchengine.h
@@ -80,7 +80,8 @@ class QHELP_EXPORT QHelpSearchEngine : public QObject
Q_OBJECT
public:
- QHelpSearchEngine(QHelpEngineCore *helpEngine, QObject *parent = 0);
+ explicit QHelpSearchEngine(QHelpEngineCore *helpEngine,
+ QObject *parent = 0);
~QHelpSearchEngine();
QHelpSearchQueryWidget* queryWidget();
diff --git a/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp b/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp
index c2274c4..75cc2b9 100644
--- a/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp
+++ b/tools/assistant/lib/qhelpsearchindexreader_clucene.cpp
@@ -173,7 +173,7 @@ void QHelpSearchIndexReaderClucene::run()
QCLuceneDocument document;
const QStringList namespaceList = engine.registeredDocumentations();
- foreach (QSharedPointer<QCLuceneHits> hits, cluceneHitsList) {
+ foreach (const QSharedPointer<QCLuceneHits> &hits, cluceneHitsList) {
for (qint32 i = 0; i < hits->length(); i++) {
document = hits->document(i);
const QString path = document.get(PathField);
@@ -415,7 +415,7 @@ bool QHelpSearchIndexReaderClucene::addAttributesQuery(
void QHelpSearchIndexReaderClucene::boostSearchHits(const QHelpEngineCore &engine,
QList<QHelpSearchEngine::SearchHit> &hitList, const QList<QHelpSearchQuery> &queryList)
{
- foreach (const QHelpSearchQuery query, queryList) {
+ foreach (const QHelpSearchQuery &query, queryList) {
if (query.fieldName != QHelpSearchQuery::DEFAULT)
continue;
diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp
index 1634a0d..8e8b278 100644
--- a/tools/assistant/lib/qhelpsearchquerywidget.cpp
+++ b/tools/assistant/lib/qhelpsearchquerywidget.cpp
@@ -215,37 +215,36 @@ private:
queryHist->curQuery += addend;
const QList<QHelpSearchQuery> &query =
- queryHist->queries.at(queryHist->curQuery);
+ queryHist->queries.at(queryHist->curQuery);
foreach (const QHelpSearchQuery &queryPart, query) {
- QLineEdit *lineEdit = 0;
- switch (queryPart.fieldName) {
+ if (QLineEdit *lineEdit = lineEditFor(queryPart.fieldName))
+ lineEdit->setText(queryPart.wordList.join(" "));
+ }
+
+ if (queryHist->curQuery == maxOrMinIndex)
+ thisButton->setEnabled(false);
+ otherButton->setEnabled(true);
+ }
+
+ QLineEdit* lineEditFor(const QHelpSearchQuery::FieldName &fieldName) const
+ {
+ switch (fieldName) {
case QHelpSearchQuery::DEFAULT:
- lineEdit = defaultQuery;
- break;
+ return defaultQuery;
case QHelpSearchQuery::ALL:
- lineEdit = allQuery;
- break;
+ return allQuery;
case QHelpSearchQuery::ATLEAST:
- lineEdit = atLeastQuery;
- break;
+ return atLeastQuery;
case QHelpSearchQuery::FUZZY:
- lineEdit = similarQuery;
- break;
+ return similarQuery;
case QHelpSearchQuery::WITHOUT:
- lineEdit = withoutQuery;
- break;
+ return withoutQuery;
case QHelpSearchQuery::PHRASE:
- lineEdit = exactQuery;
- break;
+ return exactQuery;
default:
Q_ASSERT(0);
- }
- lineEdit->setText(queryPart.wordList.join(" "));
}
-
- if (queryHist->curQuery == maxOrMinIndex)
- thisButton->setEnabled(false);
- otherButton->setEnabled(true);
+ return 0;
}
void enableOrDisableToolButtons()
@@ -512,8 +511,27 @@ QHelpSearchQueryWidget::~QHelpSearchQueryWidget()
}
/*!
+ Expands the search query widget so that the extended search fields are shown.
+*/
+void QHelpSearchQueryWidget::expandExtendedSearch()
+{
+ if (d->simpleSearch)
+ d->showHideAdvancedSearch();
+}
+
+/*!
+ Collapses the search query widget so that only the default search field is
+ shown.
+*/
+void QHelpSearchQueryWidget::collapseExtendedSearch()
+{
+ if (!d->simpleSearch)
+ d->showHideAdvancedSearch();
+}
+
+/*!
Returns a list of queries to use in combination with the search engines
- search(QList<QHelpSearchQuery> &query) function.
+ search(QList<QHelpSearchQuery> &queryList) function.
*/
QList<QHelpSearchQuery> QHelpSearchQueryWidget::query() const
{
@@ -524,6 +542,28 @@ QList<QHelpSearchQuery> QHelpSearchQueryWidget::query() const
}
/*!
+ Sets the QHelpSearchQueryWidget input fields to the values specified by
+ \a queryList search field name. Please note that one has to call the search
+ engine's search(QList<QHelpSearchQuery> &queryList) function to perform the
+ actual search.
+*/
+void QHelpSearchQueryWidget::setQuery(const QList<QHelpSearchQuery> &queryList)
+{
+ QList<QLineEdit *> lineEdits;
+ lineEdits << d->defaultQuery << d->allQuery << d->atLeastQuery
+ << d->similarQuery << d->withoutQuery << d->exactQuery;
+ foreach (QLineEdit *lineEdit, lineEdits)
+ lineEdit->clear();
+
+ const QLatin1String space(" ");
+ foreach (const QHelpSearchQuery &q, queryList) {
+ if (QLineEdit *lineEdit = d->lineEditFor(q.fieldName))
+ lineEdit->setText(lineEdit->text() + q.wordList.join(space) + space);
+ }
+ d->searchRequested();
+}
+
+/*!
\reimp
*/
void QHelpSearchQueryWidget::focusInEvent(QFocusEvent *focusEvent)
diff --git a/tools/assistant/lib/qhelpsearchquerywidget.h b/tools/assistant/lib/qhelpsearchquerywidget.h
index 2afc4b4..f3c290f 100644
--- a/tools/assistant/lib/qhelpsearchquerywidget.h
+++ b/tools/assistant/lib/qhelpsearchquerywidget.h
@@ -68,7 +68,11 @@ public:
QHelpSearchQueryWidget(QWidget *parent = 0);
~QHelpSearchQueryWidget();
+ void expandExtendedSearch();
+ void collapseExtendedSearch();
+
QList<QHelpSearchQuery> query() const;
+ void setQuery(const QList<QHelpSearchQuery> &queryList);
Q_SIGNALS:
void search();
diff --git a/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp b/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp
index 5874493..fe510a5 100644
--- a/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp
+++ b/tools/assistant/tools/assistant/bookmarkfiltermodel.cpp
@@ -50,11 +50,30 @@ BookmarkFilterModel::BookmarkFilterModel(QObject *parent)
{
}
-void
-BookmarkFilterModel::setSourceModel(QAbstractItemModel *_sourceModel)
+void BookmarkFilterModel::setSourceModel(QAbstractItemModel *_sourceModel)
{
beginResetModel();
+ disconnect(sourceModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
+ SLOT(changed(QModelIndex, QModelIndex)));
+
+ disconnect(sourceModel, SIGNAL(rowsInserted(QModelIndex, int, int)),
+ this, SLOT(rowsInserted(QModelIndex, int, int)));
+
+ disconnect(sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)),
+ this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int)));
+ disconnect(sourceModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
+ SLOT(rowsRemoved(QModelIndex, int, int)));
+
+ disconnect(sourceModel, SIGNAL(layoutAboutToBeChanged()), this,
+ SLOT(layoutAboutToBeChanged()));
+ disconnect(sourceModel, SIGNAL(layoutChanged()), this,
+ SLOT(layoutChanged()));
+
+ disconnect(sourceModel, SIGNAL(modelAboutToBeReset()), this,
+ SLOT(modelAboutToBeReset()));
+ disconnect(sourceModel, SIGNAL(modelReset()), this, SLOT(modelReset()));
+
QAbstractProxyModel::setSourceModel(sourceModel);
sourceModel = qobject_cast<BookmarkModel*> (_sourceModel);
@@ -79,20 +98,18 @@ BookmarkFilterModel::setSourceModel(QAbstractItemModel *_sourceModel)
connect(sourceModel, SIGNAL(modelReset()), this, SLOT(modelReset()));
if (sourceModel)
- setupCache(sourceModel->index(0, 0, QModelIndex()));
+ setupCache(sourceModel->index(0, 0, QModelIndex()).parent());
endResetModel();
}
-int
-BookmarkFilterModel::rowCount(const QModelIndex &index) const
+int BookmarkFilterModel::rowCount(const QModelIndex &index) const
{
Q_UNUSED(index)
return cache.count();
}
-int
-BookmarkFilterModel::columnCount(const QModelIndex &index) const
+int BookmarkFilterModel::columnCount(const QModelIndex &index) const
{
Q_UNUSED(index)
if (sourceModel)
@@ -100,8 +117,7 @@ BookmarkFilterModel::columnCount(const QModelIndex &index) const
return 0;
}
-QModelIndex
-BookmarkFilterModel::mapToSource(const QModelIndex &proxyIndex) const
+QModelIndex BookmarkFilterModel::mapToSource(const QModelIndex &proxyIndex) const
{
const int row = proxyIndex.row();
if (proxyIndex.isValid() && row >= 0 && row < cache.count())
@@ -109,21 +125,19 @@ BookmarkFilterModel::mapToSource(const QModelIndex &proxyIndex) const
return QModelIndex();
}
-QModelIndex
-BookmarkFilterModel::mapFromSource(const QModelIndex &sourceIndex) const
+QModelIndex BookmarkFilterModel::mapFromSource(const QModelIndex &sourceIndex) const
{
return index(cache.indexOf(sourceIndex), 0, QModelIndex());
}
-QModelIndex
-BookmarkFilterModel::parent(const QModelIndex &child) const
+QModelIndex BookmarkFilterModel::parent(const QModelIndex &child) const
{
Q_UNUSED(child)
return QModelIndex();
}
-QModelIndex
-BookmarkFilterModel::index(int row, int column, const QModelIndex &index) const
+QModelIndex BookmarkFilterModel::index(int row, int column,
+ const QModelIndex &index) const
{
Q_UNUSED(index)
if (row < 0 || column < 0 || cache.count() <= row
@@ -133,32 +147,28 @@ BookmarkFilterModel::index(int row, int column, const QModelIndex &index) const
return createIndex(row, 0);
}
-Qt::DropActions
-BookmarkFilterModel::supportedDropActions () const
+Qt::DropActions BookmarkFilterModel::supportedDropActions () const
{
if (sourceModel)
return sourceModel->supportedDropActions();
return Qt::IgnoreAction;
}
-Qt::ItemFlags
-BookmarkFilterModel::flags(const QModelIndex &index) const
+Qt::ItemFlags BookmarkFilterModel::flags(const QModelIndex &index) const
{
if (sourceModel)
return sourceModel->flags(index);
return Qt::NoItemFlags;
}
-QVariant
-BookmarkFilterModel::data(const QModelIndex &index, int role) const
+QVariant BookmarkFilterModel::data(const QModelIndex &index, int role) const
{
if (sourceModel)
return sourceModel->data(mapToSource(index), role);
return QVariant();
}
-bool
-BookmarkFilterModel::setData(const QModelIndex &index, const QVariant &value,
+bool BookmarkFilterModel::setData(const QModelIndex &index, const QVariant &value,
int role)
{
if (sourceModel)
@@ -166,37 +176,34 @@ BookmarkFilterModel::setData(const QModelIndex &index, const QVariant &value,
return false;
}
-void
-BookmarkFilterModel::filterBookmarks()
+void BookmarkFilterModel::filterBookmarks()
{
if (sourceModel) {
beginResetModel();
hideBookmarks = true;
- setupCache(sourceModel->index(0, 0, QModelIndex()));
+ setupCache(sourceModel->index(0, 0, QModelIndex()).parent());
endResetModel();
}
}
-void
-BookmarkFilterModel::filterBookmarkFolders()
+void BookmarkFilterModel::filterBookmarkFolders()
{
if (sourceModel) {
beginResetModel();
hideBookmarks = false;
- setupCache(sourceModel->index(0, 0, QModelIndex()));
+ setupCache(sourceModel->index(0, 0, QModelIndex()).parent());
endResetModel();
}
}
-void
-BookmarkFilterModel::changed(const QModelIndex &topLeft,
+void BookmarkFilterModel::changed(const QModelIndex &topLeft,
const QModelIndex &bottomRight)
{
emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight));
}
-void
-BookmarkFilterModel::rowsInserted(const QModelIndex &parent, int start, int end)
+void BookmarkFilterModel::rowsInserted(const QModelIndex &parent, int start,
+ int end)
{
if (!sourceModel)
return;
@@ -218,15 +225,16 @@ BookmarkFilterModel::rowsInserted(const QModelIndex &parent, int start, int end)
const bool isFolder = newIndex.data(UserRoleFolder).toBool();
if ((isFolder && hideBookmarks) || (!isFolder && !hideBookmarks)) {
beginInsertRows(mapFromSource(parent), start, end);
- cache.insert(cache.indexOf(cachePrevious) + 1, newIndex);
+ const int index = cache.indexOf(cachePrevious) + 1;
+ if (cache.value(index, QPersistentModelIndex()) != newIndex)
+ cache.insert(index, newIndex);
endInsertRows();
}
}
}
-void
-BookmarkFilterModel::rowsAboutToBeRemoved(const QModelIndex &parent, int start,
- int end)
+void BookmarkFilterModel::rowsAboutToBeRemoved(const QModelIndex &parent,
+ int start, int end)
{
if (!sourceModel)
return;
@@ -240,8 +248,7 @@ BookmarkFilterModel::rowsAboutToBeRemoved(const QModelIndex &parent, int start,
}
}
-void
-BookmarkFilterModel::rowsRemoved(const QModelIndex &/*parent*/, int, int)
+void BookmarkFilterModel::rowsRemoved(const QModelIndex &/*parent*/, int, int)
{
if (cache.contains(indexToRemove)) {
cache.removeAll(indexToRemove);
@@ -249,41 +256,36 @@ BookmarkFilterModel::rowsRemoved(const QModelIndex &/*parent*/, int, int)
}
}
-void
-BookmarkFilterModel::layoutAboutToBeChanged()
+void BookmarkFilterModel::layoutAboutToBeChanged()
{
// TODO: ???
}
-void
-BookmarkFilterModel::layoutChanged()
+void BookmarkFilterModel::layoutChanged()
{
// TODO: ???
}
-void
-BookmarkFilterModel::modelAboutToBeReset()
+void BookmarkFilterModel::modelAboutToBeReset()
{
beginResetModel();
}
-void
-BookmarkFilterModel::modelReset()
+void BookmarkFilterModel::modelReset()
{
if (sourceModel)
- setupCache(sourceModel->index(0, 0, QModelIndex()));
+ setupCache(sourceModel->index(0, 0, QModelIndex()).parent());
endResetModel();
}
-void
-BookmarkFilterModel::setupCache(const QModelIndex &parent)
+void BookmarkFilterModel::setupCache(const QModelIndex &parent)
{
cache.clear();
- collectItems(parent);
+ for (int i = 0; i < sourceModel->rowCount(parent); ++i)
+ collectItems(sourceModel->index(i, 0, parent));
}
-void
-BookmarkFilterModel::collectItems(const QModelIndex &parent)
+void BookmarkFilterModel::collectItems(const QModelIndex &parent)
{
if (parent.isValid()) {
bool isFolder = sourceModel->data(parent, UserRoleFolder).toBool();
@@ -304,14 +306,12 @@ BookmarkTreeModel::BookmarkTreeModel(QObject *parent)
{
}
-int
-BookmarkTreeModel::columnCount(const QModelIndex &parent) const
+int BookmarkTreeModel::columnCount(const QModelIndex &parent) const
{
return qMin(1, QSortFilterProxyModel::columnCount(parent));
}
-bool
-BookmarkTreeModel::filterAcceptsRow(int row, const QModelIndex &parent) const
+bool BookmarkTreeModel::filterAcceptsRow(int row, const QModelIndex &parent) const
{
Q_UNUSED(row)
BookmarkModel *model = qobject_cast<BookmarkModel*> (sourceModel());
@@ -319,4 +319,4 @@ BookmarkTreeModel::filterAcceptsRow(int row, const QModelIndex &parent) const
&& model->data(model->index(row, 0, parent), UserRoleFolder).toBool())
return true;
return false;
-} \ No newline at end of file
+}
diff --git a/tools/assistant/tools/assistant/bookmarkitem.cpp b/tools/assistant/tools/assistant/bookmarkitem.cpp
index 2e81e38..2c92113 100644
--- a/tools/assistant/tools/assistant/bookmarkitem.cpp
+++ b/tools/assistant/tools/assistant/bookmarkitem.cpp
@@ -41,6 +41,7 @@
#include "bookmarkitem.h"
+#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
QT_BEGIN_NAMESPACE
@@ -147,7 +148,9 @@ BookmarkItem::insertChildren(bool isFolder, int position, int count)
for (int row = 0; row < count; ++row) {
m_children.insert(position, new BookmarkItem(DataVector()
- << QObject::tr(isFolder ? "New Folder" : "Untitled")
+ << (isFolder
+ ? QCoreApplication::translate("BookmarkItem", "New Folder")
+ : QCoreApplication::translate("BookmarkItem", "Untitled"))
<< (isFolder ? "Folder" : "about:blank") << false, this));
}
diff --git a/tools/assistant/tools/assistant/bookmarkitem.h b/tools/assistant/tools/assistant/bookmarkitem.h
index 924a762..7c5b8d0 100644
--- a/tools/assistant/tools/assistant/bookmarkitem.h
+++ b/tools/assistant/tools/assistant/bookmarkitem.h
@@ -58,7 +58,7 @@ typedef QVector<QVariant> DataVector;
class BookmarkItem
{
public:
- BookmarkItem(const DataVector &data, BookmarkItem *parent = 0);
+ explicit BookmarkItem(const DataVector &data, BookmarkItem *parent = 0);
~BookmarkItem();
BookmarkItem *parent() const;
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp
index 65888fe..7a11ffe 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.cpp
+++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp
@@ -53,6 +53,7 @@
#include <QtGui/QKeyEvent>
#include <QtGui/QMessageBox>
#include <QtGui/QSortFilterProxyModel>
+#include <QtGui/QToolBar>
QT_BEGIN_NAMESPACE
@@ -136,11 +137,18 @@ QWidget* BookmarkManager::bookmarkDockWidget() const
return 0;
}
-void BookmarkManager::takeBookmarksMenu(QMenu* menu)
+void BookmarkManager::setBookmarksMenu(QMenu* menu)
{
TRACE_OBJ
bookmarkMenu = menu;
- refeshBookmarkMenu();
+ refreshBookmarkMenu();
+}
+
+void BookmarkManager::setBookmarksToolbar(QToolBar *toolBar)
+{
+ TRACE_OBJ
+ m_toolBar = toolBar;
+ refreshBookmarkToolBar();
}
// -- public slots
@@ -157,7 +165,10 @@ void BookmarkManager::addBookmark(const QString &title, const QString &url)
BookmarkManager::BookmarkManager()
: typeAndSearch(false)
, bookmarkMenu(0)
+ , m_toolBar(0)
, bookmarkModel(new BookmarkModel)
+ , bookmarkFilterModel(0)
+ , typeAndSearchModel(0)
, bookmarkWidget(new BookmarkWidget)
, bookmarkTreeView(new BookmarkTreeView)
, bookmarkManagerWidget(0)
@@ -186,11 +197,18 @@ BookmarkManager::BookmarkManager()
connect(&HelpEngineWrapper::instance(), SIGNAL(setupFinished()), this,
SLOT(setupFinished()));
connect(bookmarkModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
- SLOT(refeshBookmarkMenu()));
+ SLOT(refreshBookmarkMenu()));
+ connect(bookmarkModel, SIGNAL(rowsInserted(QModelIndex, int, int)), this,
+ SLOT(refreshBookmarkMenu()));
+ connect(bookmarkModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
+ SLOT(refreshBookmarkMenu()));
+
+ connect(bookmarkModel, SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
+ SLOT(refreshBookmarkToolBar()));
connect(bookmarkModel, SIGNAL(rowsInserted(QModelIndex, int, int)), this,
- SLOT(refeshBookmarkMenu()));
+ SLOT(refreshBookmarkToolBar()));
connect(bookmarkModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
- SLOT(refeshBookmarkMenu()));
+ SLOT(refreshBookmarkToolBar()));
}
BookmarkManager::~BookmarkManager()
@@ -310,17 +328,20 @@ void BookmarkManager::setupFinished()
bookmarkModel->setBookmarks(HelpEngineWrapper::instance().bookmarks());
bookmarkModel->expandFoldersIfNeeeded(bookmarkTreeView);
- refeshBookmarkMenu();
+ refreshBookmarkMenu();
+ refreshBookmarkToolBar();
bookmarkTreeView->hideColumn(1);
bookmarkTreeView->header()->setVisible(false);
bookmarkTreeView->header()->setStretchLastSection(true);
- bookmarkFilterModel = new BookmarkFilterModel(this);
+ if (!bookmarkFilterModel)
+ bookmarkFilterModel = new BookmarkFilterModel(this);
bookmarkFilterModel->setSourceModel(bookmarkModel);
bookmarkFilterModel->filterBookmarkFolders();
- typeAndSearchModel = new QSortFilterProxyModel(this);
+ if (!typeAndSearchModel)
+ typeAndSearchModel = new QSortFilterProxyModel(this);
typeAndSearchModel->setDynamicSortFilter(true);
typeAndSearchModel->setSourceModel(bookmarkFilterModel);
}
@@ -354,7 +375,7 @@ void BookmarkManager::manageBookmarks()
bookmarkManagerWidget->raise();
}
-void BookmarkManager::refeshBookmarkMenu()
+void BookmarkManager::refreshBookmarkMenu()
{
TRACE_OBJ
if (!bookmarkMenu)
@@ -365,11 +386,16 @@ void BookmarkManager::refeshBookmarkMenu()
bookmarkMenu->addAction(tr("Manage Bookmarks..."), this,
SLOT(manageBookmarks()));
bookmarkMenu->addAction(QIcon::fromTheme("bookmark-new"),
- tr("Add Bookmark..."), this, SLOT(addBookmark()),
- QKeySequence(tr("Ctrl+D")));
+ tr("Add Bookmark..."), this, SLOT(addBookmark()), QKeySequence(tr("Ctrl+D")));
+
bookmarkMenu->addSeparator();
- const QModelIndex &root = bookmarkModel->index(0, 0, QModelIndex());
+ QModelIndex root = bookmarkModel->index(0, 0, QModelIndex()).parent();
+ buildBookmarksMenu(bookmarkModel->index(0, 0, root), bookmarkMenu);
+
+ bookmarkMenu->addSeparator();
+
+ root = bookmarkModel->index(1, 0, QModelIndex());
for (int i = 0; i < bookmarkModel->rowCount(root); ++i)
buildBookmarksMenu(bookmarkModel->index(i, 0, root), bookmarkMenu);
@@ -377,6 +403,41 @@ void BookmarkManager::refeshBookmarkMenu()
SLOT(setSourceFromAction(QAction*)));
}
+void BookmarkManager::refreshBookmarkToolBar()
+{
+ TRACE_OBJ
+ if (!m_toolBar)
+ return;
+
+ m_toolBar->clear();
+ m_toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+
+ const QModelIndex &root = bookmarkModel->index(0, 0, QModelIndex());
+ for (int i = 0; i < bookmarkModel->rowCount(root); ++i) {
+ const QModelIndex &index = bookmarkModel->index(i, 0, root);
+ if (index.data(UserRoleFolder).toBool()) {
+ QToolButton *button = new QToolButton(m_toolBar);
+ button->setPopupMode(QToolButton::InstantPopup);
+ button->setText(index.data().toString());
+ QMenu *menu = new QMenu(button);
+ for (int j = 0; j < bookmarkModel->rowCount(index); ++j)
+ buildBookmarksMenu(bookmarkModel->index(j, 0, index), menu);
+ connect(menu, SIGNAL(triggered(QAction*)), this,
+ SLOT(setSourceFromAction(QAction*)));
+ button->setMenu(menu);
+ button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ button->setIcon(qvariant_cast<QIcon>(index.data(Qt::DecorationRole)));
+ QAction *a = m_toolBar->addWidget(button);
+ a->setText(index.data().toString());
+ } else {
+ QAction *action = m_toolBar->addAction(
+ qvariant_cast<QIcon>(index.data(Qt::DecorationRole)),
+ index.data().toString(), this, SLOT(setSourceFromAction()));
+ action->setData(index.data(UserRoleUrl).toString());
+ }
+ }
+}
+
void BookmarkManager::renameBookmark(const QModelIndex &index)
{
// check if we should rename the "Bookmarks Menu", bail
@@ -388,13 +449,21 @@ void BookmarkManager::renameBookmark(const QModelIndex &index)
bookmarkModel->setItemsEditable(false);
}
-void BookmarkManager::setSourceFromAction(QAction *action)
+
+void BookmarkManager::setSourceFromAction()
{
TRACE_OBJ
- const QVariant &data = action->data();
+ setSourceFromAction(qobject_cast<QAction*> (sender()));
+}
- if (data.canConvert<QUrl>())
- emit setSource(data.toUrl());
+void BookmarkManager::setSourceFromAction(QAction *action)
+{
+ TRACE_OBJ
+ if (action) {
+ const QVariant &data = action->data();
+ if (data.canConvert<QUrl>())
+ emit setSource(data.toUrl());
+ }
}
void BookmarkManager::setSourceFromIndex(const QModelIndex &index, bool newTab)
diff --git a/tools/assistant/tools/assistant/bookmarkmanager.h b/tools/assistant/tools/assistant/bookmarkmanager.h
index c26dad8..ae27b59 100644
--- a/tools/assistant/tools/assistant/bookmarkmanager.h
+++ b/tools/assistant/tools/assistant/bookmarkmanager.h
@@ -53,6 +53,7 @@ class BookmarkModel;
class BookmarkFilterModel;
class QKeyEvent;
class QSortFilterProxyModel;
+class QToolBar;
class BookmarkManager : public QObject
{
@@ -67,7 +68,8 @@ public:
static void destroy();
QWidget* bookmarkDockWidget() const;
- void takeBookmarksMenu(QMenu* menu);
+ void setBookmarksMenu(QMenu* menu);
+ void setBookmarksToolbar(QToolBar *toolBar);
public slots:
void addBookmark(const QString &title, const QString &url);
@@ -92,9 +94,11 @@ private slots:
void addBookmark();
void removeBookmark();
void manageBookmarks();
- void refeshBookmarkMenu();
+ void refreshBookmarkMenu();
+ void refreshBookmarkToolBar();
void renameBookmark(const QModelIndex &index);
+ void setSourceFromAction();
void setSourceFromAction(QAction *action);
void setSourceFromIndex(const QModelIndex &index, bool newTab = false);
@@ -110,6 +114,7 @@ private:
static BookmarkManager *bookmarkManager;
QMenu *bookmarkMenu;
+ QToolBar *m_toolBar;
BookmarkModel *bookmarkModel;
BookmarkFilterModel *bookmarkFilterModel;
diff --git a/tools/assistant/tools/assistant/bookmarkmanagerwidget.h b/tools/assistant/tools/assistant/bookmarkmanagerwidget.h
index 94384a6..56433cb 100644
--- a/tools/assistant/tools/assistant/bookmarkmanagerwidget.h
+++ b/tools/assistant/tools/assistant/bookmarkmanagerwidget.h
@@ -57,7 +57,8 @@ class BookmarkManagerWidget : public QWidget
{
Q_OBJECT
public:
- BookmarkManagerWidget(BookmarkModel *bookmarkModel, QWidget *parent = 0);
+ explicit BookmarkManagerWidget(BookmarkModel *bookmarkModel,
+ QWidget *parent = 0);
~BookmarkManagerWidget();
protected:
@@ -99,4 +100,4 @@ private:
QT_END_NAMESPACE
-#endif // BOOKMARKMANAGERWIDGET_H \ No newline at end of file
+#endif // BOOKMARKMANAGERWIDGET_H
diff --git a/tools/assistant/tools/assistant/bookmarkmodel.cpp b/tools/assistant/tools/assistant/bookmarkmodel.cpp
index 4c30b42..320b233 100644
--- a/tools/assistant/tools/assistant/bookmarkmodel.cpp
+++ b/tools/assistant/tools/assistant/bookmarkmodel.cpp
@@ -48,6 +48,7 @@
#include <QtGui/QStyle>
#include <QtGui/QTreeView>
+const quint32 VERSION = 0xe53798;
const QLatin1String MIMETYPE("application/bookmarks.assistant");
BookmarkModel::BookmarkModel()
@@ -68,8 +69,9 @@ BookmarkModel::bookmarks() const
{
QByteArray ba;
QDataStream stream(&ba, QIODevice::WriteOnly);
+ stream << qint32(VERSION);
- const QModelIndex &root = index(0,0, QModelIndex());
+ const QModelIndex &root = index(0,0, QModelIndex()).parent();
for (int i = 0; i < rowCount(root); ++i)
collectItems(index(i, 0, root), 0, &stream);
@@ -87,24 +89,35 @@ BookmarkModel::setBookmarks(const QByteArray &bookmarks)
rootItem = new BookmarkItem(DataVector() << tr("Name") << tr("Address")
<< true);
- BookmarkItem* item = new BookmarkItem(DataVector() << tr("Bookmarks Menu")
- << QLatin1String("Folder") << true);
- rootItem->addChild(item);
QStack<BookmarkItem*> parents;
- parents.push(item);
+ QDataStream stream(bookmarks);
+
+ qint32 version;
+ stream >> version;
+ if (version < VERSION) {
+ stream.device()->seek(0);
+ BookmarkItem* toolbar = new BookmarkItem(DataVector() << tr("Toolbar Menu")
+ << QLatin1String("Folder") << true);
+ rootItem->addChild(toolbar);
+
+ BookmarkItem* menu = new BookmarkItem(DataVector() << tr("Bookmarks Menu")
+ << QLatin1String("Folder") << true);
+ rootItem->addChild(menu);
+ parents.push(menu);
+ } else {
+ parents.push(rootItem);
+ }
qint32 depth;
bool expanded;
QString name, url;
- QDataStream stream(bookmarks);
while (!stream.atEnd()) {
stream >> depth >> name >> url >> expanded;
-
while ((parents.count() - 1) != depth)
parents.pop();
- item = new BookmarkItem(DataVector() << name << url << expanded);
+ BookmarkItem *item = new BookmarkItem(DataVector() << name << url << expanded);
if (url == QLatin1String("Folder")) {
parents.top()->addChild(item);
parents.push(item);
@@ -114,11 +127,7 @@ BookmarkModel::setBookmarks(const QByteArray &bookmarks)
}
cache.clear();
- const QModelIndex &root = index(0,0, QModelIndex());
-
- setupCache(root);
- cache.insert(static_cast<BookmarkItem*> (root.internalPointer()), root);
-
+ setupCache(index(0,0, QModelIndex().parent()));
endResetModel();
}
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index b6fa159..a232383 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -44,12 +44,14 @@
#include "findwidget.h"
#include "helpenginewrapper.h"
#include "helpviewer.h"
+#include "openpagesmanager.h"
#include "tracer.h"
#include "../shared/collectionconfiguration.h"
#include <QtCore/QTimer>
#include <QtGui/QKeyEvent>
+#include <QtGui/QMenu>
#include <QtGui/QPageSetupDialog>
#include <QtGui/QPrintDialog>
#include <QtGui/QPrintPreviewDialog>
@@ -66,6 +68,124 @@ namespace {
CentralWidget *staticCentralWidget = 0;
}
+// -- TabBar
+
+TabBar::TabBar(QWidget *parent)
+ : QTabBar(parent)
+{
+ TRACE_OBJ
+#ifdef Q_OS_MAC
+ setDocumentMode(true);
+#endif
+ setMovable(true);
+ setShape(QTabBar::RoundedNorth);
+ setContextMenuPolicy(Qt::CustomContextMenu);
+ setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred,
+ QSizePolicy::TabWidget));
+ connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int)));
+ connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(slotTabCloseRequested(int)));
+ connect(this, SIGNAL(customContextMenuRequested(QPoint)), this,
+ SLOT(slotCustomContextMenuRequested(QPoint)));
+}
+
+TabBar::~TabBar()
+{
+ TRACE_OBJ
+}
+
+int TabBar::addNewTab(const QString &title)
+{
+ TRACE_OBJ
+ const int index = addTab(title);
+ setTabsClosable(count() > 1);
+ return index;
+}
+
+void TabBar::setCurrent(HelpViewer *viewer)
+{
+ TRACE_OBJ
+ for (int i = 0; i < count(); ++i) {
+ HelpViewer *data = tabData(i).value<HelpViewer*>();
+ if (data == viewer) {
+ setCurrentIndex(i);
+ break;
+ }
+ }
+}
+
+void TabBar::removeTabAt(HelpViewer *viewer)
+{
+ TRACE_OBJ
+ for (int i = 0; i < count(); ++i) {
+ HelpViewer *data = tabData(i).value<HelpViewer*>();
+ if (data == viewer) {
+ removeTab(i);
+ break;
+ }
+ }
+ setTabsClosable(count() > 1);
+}
+
+void TabBar::titleChanged()
+{
+ TRACE_OBJ
+ for (int i = 0; i < count(); ++i) {
+ HelpViewer *data = tabData(i).value<HelpViewer*>();
+ QString title = data->title();
+ title.replace(QLatin1Char('&'), QLatin1String("&&"));
+ setTabText(i, title.isEmpty() ? tr("(Untitled)") : title);
+ }
+}
+
+void TabBar::slotCurrentChanged(int index)
+{
+ TRACE_OBJ
+ emit currentTabChanged(tabData(index).value<HelpViewer*>());
+}
+
+void TabBar::slotTabCloseRequested(int index)
+{
+ TRACE_OBJ
+ OpenPagesManager::instance()->closePage(tabData(index).value<HelpViewer*>());
+}
+
+void TabBar::slotCustomContextMenuRequested(const QPoint &pos)
+{
+ TRACE_OBJ
+ const int tab = tabAt(pos);
+ if (tab < 0)
+ return;
+
+ QMenu menu(QLatin1String(""), this);
+ menu.addAction(tr("New &Tab"), OpenPagesManager::instance(), SLOT(createPage()));
+
+ const bool enableAction = count() > 1;
+ QAction *closePage = menu.addAction(tr("&Close Tab"));
+ closePage->setEnabled(enableAction);
+
+ QAction *closePages = menu.addAction(tr("Close Other Tabs"));
+ closePages->setEnabled(enableAction);
+
+ menu.addSeparator();
+
+ HelpViewer *viewer = tabData(tab).value<HelpViewer*>();
+ QAction *newBookmark = menu.addAction(tr("Add Bookmark for this Page..."));
+ const QString &url = viewer->source().toString();
+ if (url.isEmpty() || url == QLatin1String("about:blank"))
+ newBookmark->setEnabled(false);
+
+ QAction *pickedAction = menu.exec(mapToGlobal(pos));
+ if (pickedAction == closePage)
+ slotTabCloseRequested(tab);
+ else if (pickedAction == closePages) {
+ for (int i = count() - 1; i >= 0; --i) {
+ if (i != tab)
+ slotTabCloseRequested(i);
+ }
+ } else if (pickedAction == newBookmark)
+ emit addBookmark(viewer->title(), url);
+}
+
// -- CentralWidget
CentralWidget::CentralWidget(QWidget *parent)
@@ -75,12 +195,16 @@ CentralWidget::CentralWidget(QWidget *parent)
#endif
, m_findWidget(new FindWidget(this))
, m_stackedWidget(new QStackedWidget(this))
+ , m_tabBar(new TabBar(this))
{
TRACE_OBJ
staticCentralWidget = this;
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
vboxLayout->setMargin(0);
+ vboxLayout->setSpacing(0);
+ vboxLayout->addWidget(m_tabBar);
+ m_tabBar->setVisible(HelpEngineWrapper::instance().showTabs());
vboxLayout->addWidget(m_stackedWidget);
vboxLayout->addWidget(m_findWidget);
m_findWidget->hide();
@@ -90,6 +214,8 @@ CentralWidget::CentralWidget(QWidget *parent)
connect(m_findWidget, SIGNAL(find(QString, bool, bool)), this,
SLOT(find(QString, bool, bool)));
connect(m_findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab()));
+ connect(m_tabBar, SIGNAL(addBookmark(QString, QString)), this,
+ SIGNAL(addBookmark(QString, QString)));
}
CentralWidget::~CentralWidget()
@@ -170,7 +296,11 @@ void CentralWidget::addPage(HelpViewer *page, bool fromSearch)
page->installEventFilter(this);
page->setFocus(Qt::OtherFocusReason);
connectSignals(page);
- m_stackedWidget->addWidget(page);
+ const int index = m_stackedWidget->addWidget(page);
+ m_tabBar->setTabData(m_tabBar->addNewTab(page->title()),
+ QVariant::fromValue(viewerAt(index)));
+ connect (page, SIGNAL(titleChanged()), m_tabBar, SLOT(titleChanged()));
+
if (fromSearch) {
connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this,
SLOT(highlightSearchTerms()));
@@ -181,6 +311,7 @@ void CentralWidget::removePage(int index)
{
TRACE_OBJ
const bool currentChanged = index == currentIndex();
+ m_tabBar->removeTabAt(viewerAt(index));
m_stackedWidget->removeWidget(m_stackedWidget->widget(index));
if (currentChanged)
emit currentViewerChanged();
@@ -195,10 +326,18 @@ int CentralWidget::currentIndex() const
void CentralWidget::setCurrentPage(HelpViewer *page)
{
TRACE_OBJ
+ m_tabBar->setCurrent(page);
m_stackedWidget->setCurrentWidget(page);
emit currentViewerChanged();
}
+void CentralWidget::connectTabBar()
+{
+ TRACE_OBJ
+ connect(m_tabBar, SIGNAL(currentTabChanged(HelpViewer*)),
+ OpenPagesManager::instance(), SLOT(setCurrentPage(HelpViewer*)));
+}
+
// -- public slots
void CentralWidget::copy()
@@ -367,6 +506,11 @@ void CentralWidget::updateBrowserFont()
viewerAt(i)->setViewerFont(font);
}
+void CentralWidget::updateUserInterface()
+{
+ m_tabBar->setVisible(HelpEngineWrapper::instance().showTabs());
+}
+
// -- protected
void CentralWidget::keyPressEvent(QKeyEvent *e)
@@ -415,7 +559,7 @@ void CentralWidget::highlightSearchTerms()
case QHelpSearchQuery::DEFAULT:
case QHelpSearchQuery::ATLEAST:
foreach (QString term, query.wordList)
- terms.append(term.remove(QLatin1String("\"")));
+ terms.append(term.remove(QLatin1Char('"')));
}
}
}
diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h
index 69e334a..bcadcf4 100644
--- a/tools/assistant/tools/assistant/centralwidget.h
+++ b/tools/assistant/tools/assistant/centralwidget.h
@@ -43,6 +43,8 @@
#define CENTRALWIDGET_H
#include <QtCore/QUrl>
+
+#include <QtGui/QTabBar>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
@@ -51,6 +53,30 @@ class FindWidget;
class HelpViewer;
class QStackedWidget;
+class TabBar : public QTabBar
+{
+ Q_OBJECT
+public:
+ TabBar(QWidget *parent = 0);
+ ~TabBar();
+
+ int addNewTab(const QString &title);
+ void setCurrent(HelpViewer *viewer);
+ void removeTabAt(HelpViewer *viewer);
+
+public slots:
+ void titleChanged();
+
+signals:
+ void currentTabChanged(HelpViewer *viewer);
+ void addBookmark(const QString &title, const QString &url);
+
+private slots:
+ void slotCurrentChanged(int index);
+ void slotTabCloseRequested(int index);
+ void slotCustomContextMenuRequested(const QPoint &pos);
+};
+
class CentralWidget : public QWidget
{
Q_OBJECT
@@ -77,6 +103,8 @@ public:
int currentIndex() const;
void setCurrentPage(HelpViewer *page);
+ void connectTabBar();
+
public slots:
void copy();
void home();
@@ -105,6 +133,7 @@ public slots:
void activateTab();
void showTextSearch();
void updateBrowserFont();
+ void updateUserInterface();
signals:
void currentViewerChanged();
@@ -135,6 +164,7 @@ private:
#endif
FindWidget *m_findWidget;
QStackedWidget *m_stackedWidget;
+ TabBar *m_tabBar;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/cmdlineparser.cpp b/tools/assistant/tools/assistant/cmdlineparser.cpp
index b6c0beb..1cf2915 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.cpp
+++ b/tools/assistant/tools/assistant/cmdlineparser.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
-const QString CmdLineParser::m_helpMessage = QLatin1String(
+static const char helpMessage[] = QT_TRANSLATE_NOOP("CmdLineParser",
"Usage: assistant [Options]\n\n"
"-collectionFile file Uses the specified collection\n"
" file instead of the default one\n"
@@ -138,10 +138,10 @@ CmdLineParser::Result CmdLineParser::parse()
}
if (!m_error.isEmpty()) {
- showMessage(m_error + QLatin1String("\n\n\n") + m_helpMessage, true);
+ showMessage(m_error + QLatin1String("\n\n\n") + tr(helpMessage), true);
return Error;
} else if (showHelp) {
- showMessage(m_helpMessage, false);
+ showMessage(tr(helpMessage), false);
return Help;
}
return Ok;
diff --git a/tools/assistant/tools/assistant/cmdlineparser.h b/tools/assistant/tools/assistant/cmdlineparser.h
index 5573081..db66494 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.h
+++ b/tools/assistant/tools/assistant/cmdlineparser.h
@@ -93,7 +93,6 @@ private:
QStringList m_arguments;
int m_pos;
- static const QString m_helpMessage;
QString m_collectionFile;
QString m_cloneFile;
QString m_helpFile;
diff --git a/tools/assistant/tools/assistant/globalactions.cpp b/tools/assistant/tools/assistant/globalactions.cpp
index a9cc392..0eeab21 100644
--- a/tools/assistant/tools/assistant/globalactions.cpp
+++ b/tools/assistant/tools/assistant/globalactions.cpp
@@ -42,9 +42,15 @@
#include "globalactions.h"
#include "centralwidget.h"
+#include "helpviewer.h"
#include "tracer.h"
#include <QtGui/QAction>
+#include <QtGui/QMenu>
+
+#if !defined(QT_NO_WEBKIT)
+#include <QtWebKit/QWebHistory>
+#endif
GlobalActions *GlobalActions::instance(QObject *parent)
{
@@ -82,6 +88,8 @@ GlobalActions::GlobalActions(QObject *parent) : QObject(parent)
connect(m_nextAction, SIGNAL(triggered()), centralWidget, SLOT(forward()));
m_actionList << m_nextAction;
+ setupNavigationMenus(m_backAction, m_nextAction, centralWidget);
+
m_homeAction = new QAction(tr("&Home"), parent);
m_homeAction->setShortcut(tr("ALT+Home"));
m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png")));
@@ -160,4 +168,79 @@ void GlobalActions::setCopyAvailable(bool available)
m_copyAction->setEnabled(available);
}
+#if !defined(QT_NO_WEBKIT)
+
+void GlobalActions::slotAboutToShowBackMenu()
+{
+ TRACE_OBJ
+ m_backMenu->clear();
+ if (QWebHistory *history = CentralWidget::instance()->currentHelpViewer()->history()) {
+ const int currentItemIndex = history->currentItemIndex();
+ QList<QWebHistoryItem> items = history->backItems(history->count());
+ for (int i = items.count() - 1; i >= 0; --i) {
+ QAction *action = new QAction(this);
+ action->setText(items.at(i).title());
+ action->setData(-1 * (currentItemIndex - i));
+ m_backMenu->addAction(action);
+ }
+ }
+}
+
+void GlobalActions::slotAboutToShowNextMenu()
+{
+ TRACE_OBJ
+ m_nextMenu->clear();
+ if (QWebHistory *history = CentralWidget::instance()->currentHelpViewer()->history()) {
+ const int count = history->count();
+ QList<QWebHistoryItem> items = history->forwardItems(count);
+ for (int i = 0; i < items.count(); ++i) {
+ QAction *action = new QAction(this);
+ action->setData(count - i);
+ action->setText(items.at(i).title());
+ m_nextMenu->addAction(action);
+ }
+ }
+}
+
+void GlobalActions::slotOpenActionUrl(QAction *action)
+{
+ TRACE_OBJ
+ if (HelpViewer* viewer = CentralWidget::instance()->currentHelpViewer()) {
+ const int offset = action->data().toInt();
+ QWebHistory *history = viewer->history();
+ if (offset > 0) {
+ history->goToItem(history->forwardItems(history->count()
+ - offset + 1).back()); // forward
+ } else if (offset < 0) {
+ history->goToItem(history->backItems(-1 * offset).first()); // back
+ }
+ }
+}
+
+#endif
+
+void GlobalActions::setupNavigationMenus(QAction *back, QAction *next,
+ QWidget *parent)
+{
+#if !defined(QT_NO_WEBKIT)
+ m_backMenu = new QMenu(parent);
+ connect(m_backMenu, SIGNAL(aboutToShow()), this,
+ SLOT(slotAboutToShowBackMenu()));
+ connect(m_backMenu, SIGNAL(triggered(QAction*)), this,
+ SLOT(slotOpenActionUrl(QAction*)));
+ back->setMenu(m_backMenu);
+
+ m_nextMenu = new QMenu(parent);
+ connect(m_nextMenu, SIGNAL(aboutToShow()), this,
+ SLOT(slotAboutToShowNextMenu()));
+ connect(m_nextMenu, SIGNAL(triggered(QAction*)), this,
+ SLOT(slotOpenActionUrl(QAction*)));
+ next->setMenu(m_nextMenu);
+#else
+ Q_UNUSED(back)
+ Q_UNUSED(next)
+ Q_UNUSED(parent)
+#endif
+}
+
GlobalActions *GlobalActions::m_instance = 0;
diff --git a/tools/assistant/tools/assistant/globalactions.h b/tools/assistant/tools/assistant/globalactions.h
index e53e08f..ca8d7eb 100644
--- a/tools/assistant/tools/assistant/globalactions.h
+++ b/tools/assistant/tools/assistant/globalactions.h
@@ -48,6 +48,7 @@
QT_BEGIN_NAMESPACE
class QAction;
+class QMenu;
class GlobalActions : public QObject
{
@@ -69,6 +70,16 @@ public:
Q_SLOT void updateActions();
Q_SLOT void setCopyAvailable(bool available);
+#if !defined(QT_NO_WEBKIT)
+private slots:
+ void slotAboutToShowBackMenu();
+ void slotAboutToShowNextMenu();
+ void slotOpenActionUrl(QAction *action);
+#endif
+
+private:
+ void setupNavigationMenus(QAction *back, QAction *next, QWidget *parent);
+
private:
GlobalActions(QObject *parent);
@@ -84,6 +95,9 @@ private:
QAction *m_findAction;
QList<QAction *> m_actionList;
+
+ QMenu *m_backMenu;
+ QMenu *m_nextMenu;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp
index 0a5445a..ba54dd6 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.cpp
+++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp
@@ -72,6 +72,7 @@ namespace {
const QString UseBrowserFontKey(QLatin1String("useBrowserFont"));
const QString VersionKey(QString(QLatin1String("qtVersion%1$$$%2")).
arg(QLatin1String(QT_VERSION_STR)));
+ const QString ShowTabsKey(QLatin1String("showTabs"));
} // anonymous namespace
class TimeoutForwarder : public QObject
@@ -114,7 +115,7 @@ private:
QMap<QString, RecentSignal> m_recentQchUpdates;
};
-const QString HelpEngineWrapper::TrUnfiltered = tr("Unfiltered");
+const QString HelpEngineWrapper::TrUnfiltered = HelpEngineWrapper::tr("Unfiltered");
HelpEngineWrapper *HelpEngineWrapper::helpEngineWrapper = 0;
@@ -147,7 +148,7 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile)
* because we will start to index them, only to be interupted
* by the next request. Also, there is a nasty SQLITE bug that will
* cause the application to hang for minutes in that case.
- * This call is reverted by initalDocSetupDone(), which must be
+ * This call is reverted by initialDocSetupDone(), which must be
* called after the new docs have been installed.
*/
disconnect(d->m_helpEngine, SIGNAL(setupFinished()),
@@ -692,11 +693,31 @@ void HelpEngineWrapper::setBrowserWritingSystem(QFontDatabase::WritingSystem sys
void HelpEngineWrapper::handleCurrentFilterChanged(const QString &filter)
{
+ TRACE_OBJ
const QString &filterToReport
= filter == Unfiltered ? TrUnfiltered : filter;
emit currentFilterChanged(filterToReport);
}
+bool HelpEngineWrapper::showTabs() const
+{
+ TRACE_OBJ
+ return d->m_helpEngine->customValue(ShowTabsKey, false).toBool();
+}
+
+void HelpEngineWrapper::setShowTabs(bool show)
+{
+ TRACE_OBJ
+ d->m_helpEngine->setCustomValue(ShowTabsKey, show);
+}
+
+bool HelpEngineWrapper::fullTextSearchFallbackEnabled() const
+{
+ TRACE_OBJ
+ return CollectionConfiguration::fullTextSearchFallbackEnabled(*d->m_helpEngine);
+}
+
+// -- TimeoutForwarder
TimeoutForwarder::TimeoutForwarder(const QString &fileName)
: m_fileName(fileName)
@@ -710,6 +731,7 @@ void TimeoutForwarder::forward()
HelpEngineWrapper::instance().d->qchFileChanged(m_fileName, true);
}
+// -- HelpEngineWrapperPrivate
HelpEngineWrapperPrivate::HelpEngineWrapperPrivate(const QString &collectionFile)
: m_helpEngine(new QHelpEngine(collectionFile, this)),
@@ -817,7 +839,6 @@ void HelpEngineWrapperPrivate::qchFileChanged(const QString &fileName,
m_recentQchUpdates.erase(it);
}
-
QT_END_NAMESPACE
#include "helpenginewrapper.moc"
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h
index f1a381a..38bde9b 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.h
+++ b/tools/assistant/tools/assistant/helpenginewrapper.h
@@ -184,8 +184,13 @@ public:
QFontDatabase::WritingSystem browserWritingSystem() const;
void setBrowserWritingSystem(QFontDatabase::WritingSystem system);
+ bool showTabs() const;
+ void setShowTabs(bool show);
+
static const QString TrUnfiltered;
+ bool fullTextSearchFallbackEnabled() const;
+
signals:
// For asynchronous doc updates triggered by external actions.
diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h
index 939096d..e2aefca 100644
--- a/tools/assistant/tools/assistant/helpviewer.h
+++ b/tools/assistant/tools/assistant/helpviewer.h
@@ -153,5 +153,6 @@ private:
};
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(HelpViewer*)
#endif // HELPVIEWER_H
diff --git a/tools/assistant/tools/assistant/installdialog.h b/tools/assistant/tools/assistant/installdialog.h
index 2f19519..afafc63 100644
--- a/tools/assistant/tools/assistant/installdialog.h
+++ b/tools/assistant/tools/assistant/installdialog.h
@@ -61,7 +61,7 @@ class InstallDialog : public QDialog
Q_OBJECT
public:
- InstallDialog(QHelpEngineCore *helpEngine, QWidget *parent = 0,
+ explicit InstallDialog(QHelpEngineCore *helpEngine, QWidget *parent = 0,
const QString &host = QString(), int port = -1);
~InstallDialog();
diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp
index 51ea9f9..bb86bfe 100644
--- a/tools/assistant/tools/assistant/main.cpp
+++ b/tools/assistant/tools/assistant/main.cpp
@@ -316,6 +316,7 @@ int main(int argc, char *argv[])
TRACE_OBJ
QApplication a(argc, argv, useGui(argc, argv));
a.addLibraryPath(a.applicationDirPath() + QLatin1String("/plugins"));
+ setupTranslations();
// Parse arguments.
CmdLineParser cmd(a.arguments());
@@ -355,7 +356,7 @@ int main(int argc, char *argv[])
QHelpEngineCore cachedCollection(cachedCollectionFile);
if (!cachedCollection.setupData()) {
cmd.showMessage(QCoreApplication::translate("Assistant",
- "Error reading collection file '%1': %2").
+ "Error reading collection file '%1': %2.").
arg(cachedCollectionFile).
arg(cachedCollection.error()), true);
return EXIT_FAILURE;
@@ -419,8 +420,6 @@ int main(int argc, char *argv[])
cachedCollection.setCurrentFilter(cmd.currentFilter());
}
- setupTranslations();
-
/*
* 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
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index e436201..537f867 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -117,6 +117,14 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
}
HelpEngineWrapper &helpEngineWrapper =
HelpEngineWrapper::instance(collectionFile);
+ BookmarkManager *bookMarkManager = BookmarkManager::instance();
+
+ if (!initHelpDB()) {
+ qDebug("Fatal error: Help engine initialization failed. "
+ "Error message was: %s\nAssistant will now exit.",
+ qPrintable(HelpEngineWrapper::instance().error()));
+ std::exit(1);
+ }
m_centralWidget = new CentralWidget(this);
setCentralWidget(m_centralWidget);
@@ -141,7 +149,6 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
searchDock->setWidget(m_searchWindow);
addDockWidget(Qt::LeftDockWidgetArea, searchDock);
- BookmarkManager *bookMarkManager = BookmarkManager::instance();
QDockWidget *bookmarkDock = new QDockWidget(tr("Bookmarks"), this);
bookmarkDock->setObjectName(QLatin1String("BookmarkWindow"));
bookmarkDock->setWidget(m_bookmarkWidget
@@ -155,33 +162,25 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
openPagesDock->setWidget(openPagesManager->openPagesWidget());
addDockWidget(Qt::LeftDockWidgetArea, openPagesDock);
-#if 0
+ connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)),
+ bookMarkManager, SLOT(addBookmark(QString, QString)));
connect(bookMarkManager, SIGNAL(escapePressed()), this,
SLOT(activateCurrentCentralWidgetTab()));
connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)),
openPagesManager, SLOT(createPage(QUrl)));
- connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)),
- bookMarkManager, SLOT(addBookmark(QString, QString)));
QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine();
connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted()));
connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished()));
-#endif
QString defWindowTitle = tr("Qt Assistant");
setWindowTitle(defWindowTitle);
setupActions();
statusBar()->show();
-
- if (!initHelpDB()) {
- qDebug("Fatal error: Help engine initialization failed. "
- "Error message was: %s\nAssistant will now exit.",
- qPrintable(HelpEngineWrapper::instance().error()));
- std::exit(1);
- }
+ m_centralWidget->connectTabBar();
setupFilterToolbar();
setupAddressToolbar();
@@ -199,9 +198,16 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
qApp->setWindowIcon(appIcon);
}
+ QToolBar *toolBar = addToolBar(tr("Bookmark Toolbar"));
+ bookMarkManager->setBookmarksToolbar(toolBar);
+
// Show the widget here, otherwise the restore geometry and state won't work
// on x11.
show();
+
+ toolBar->hide();
+ toolBarMenu()->addAction(toolBar->toggleViewAction());
+
QByteArray ba(helpEngineWrapper.mainWindow());
if (!ba.isEmpty())
restoreState(ba);
@@ -529,7 +535,7 @@ void MainWindow::setupActions()
connect(sct, SIGNAL(activated()), openPages, SLOT(previousPageWithSwitcher()));
#endif
- BookmarkManager::instance()->takeBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks")));
+ BookmarkManager::instance()->setBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks")));
menu = menuBar()->addMenu(tr("&Help"));
m_aboutAction = menu->addAction(tr("About..."), this, SLOT(showAboutDialog()));
@@ -736,6 +742,8 @@ void MainWindow::showPreferences()
SLOT(updateApplicationFont()));
connect(&dia, SIGNAL(updateBrowserFont()), m_centralWidget,
SLOT(updateBrowserFont()));
+ connect(&dia, SIGNAL(updateUserInterface()), m_centralWidget,
+ SLOT(updateUserInterface()));
dia.showDialog();
}
@@ -791,7 +799,7 @@ void MainWindow::showAboutDialog()
aboutDia.setWindowTitle(aboutDia.documentTitle());
} else {
QByteArray resources;
- aboutDia.setText(QString::fromLatin1("<center>"
+ aboutDia.setText(tr("<center>"
"<h3>%1</h3>"
"<p>Version %2</p></center>"
"<p>Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).</p>")
diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h
index 7eb44e9..ea4ebd6 100644
--- a/tools/assistant/tools/assistant/mainwindow.h
+++ b/tools/assistant/tools/assistant/mainwindow.h
@@ -69,7 +69,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
- MainWindow(CmdLineParser *cmdLine, QWidget *parent = 0);
+ explicit MainWindow(CmdLineParser *cmdLine, QWidget *parent = 0);
~MainWindow();
static void activateCurrentBrowser();
diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp
index 6b08c46..3b69b50 100644
--- a/tools/assistant/tools/assistant/openpagesmanager.cpp
+++ b/tools/assistant/tools/assistant/openpagesmanager.cpp
@@ -209,6 +209,17 @@ HelpViewer *OpenPagesManager::createNewPageFromSearch(const QUrl &url)
return createPage(url, true);
}
+void OpenPagesManager::closePage(HelpViewer *viewer)
+{
+ TRACE_OBJ
+ for (int i = 0; i < m_model->rowCount(); ++i) {
+ if (m_model->pageAt(i) == viewer) {
+ removePage(i);
+ break;
+ }
+ }
+}
+
void OpenPagesManager::closePage(const QModelIndex &index)
{
TRACE_OBJ
@@ -264,7 +275,13 @@ void OpenPagesManager::setCurrentPage(const QModelIndex &index)
void OpenPagesManager::setCurrentPage(int index)
{
TRACE_OBJ
- CentralWidget::instance()->setCurrentPage(m_model->pageAt(index));
+ setCurrentPage(m_model->pageAt(index));
+}
+
+void OpenPagesManager::setCurrentPage(HelpViewer *page)
+{
+ TRACE_OBJ
+ CentralWidget::instance()->setCurrentPage(page);
m_openPagesWidget->selectCurrentPage();
}
diff --git a/tools/assistant/tools/assistant/openpagesmanager.h b/tools/assistant/tools/assistant/openpagesmanager.h
index 56a1ce7..5837392 100644
--- a/tools/assistant/tools/assistant/openpagesmanager.h
+++ b/tools/assistant/tools/assistant/openpagesmanager.h
@@ -83,6 +83,9 @@ public slots:
void previousPage();
void previousPageWithSwitcher();
+ void closePage(HelpViewer *page);
+ void setCurrentPage(HelpViewer *page);
+
private slots:
void setCurrentPage(const QModelIndex &index);
void closePage(const QModelIndex &index);
diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp
index 40a449e..495dad9 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.cpp
+++ b/tools/assistant/tools/assistant/preferencesdialog.cpp
@@ -379,6 +379,10 @@ void PreferencesDialog::applyChanges()
if (filtersWereChanged || !m_regDocs.isEmpty() || !m_unregDocs.isEmpty())
helpEngine.setupData();
+ helpEngine.setShowTabs(m_ui.showTabs->isChecked());
+ if (m_showTabs != m_ui.showTabs->isChecked())
+ emit updateUserInterface();
+
accept();
}
@@ -470,6 +474,9 @@ void PreferencesDialog::updateOptionsPage()
int option = helpEngine.startOption();
m_ui.helpStartComboBox->setCurrentIndex(option);
+ m_showTabs = helpEngine.showTabs();
+ m_ui.showTabs->setChecked(m_showTabs);
+
connect(m_ui.blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage()));
connect(m_ui.currentPageButton, SIGNAL(clicked()), this, SLOT(setCurrentPage()));
connect(m_ui.defaultPageButton, SIGNAL(clicked()), this, SLOT(setDefaultPage()));
diff --git a/tools/assistant/tools/assistant/preferencesdialog.h b/tools/assistant/tools/assistant/preferencesdialog.h
index 7a17275..22cf8c9 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.h
+++ b/tools/assistant/tools/assistant/preferencesdialog.h
@@ -81,6 +81,7 @@ private slots:
signals:
void updateBrowserFont();
void updateApplicationFont();
+ void updateUserInterface();
private:
void updateFilterPage();
@@ -101,6 +102,7 @@ private:
bool m_appFontChanged;
bool m_browserFontChanged;
HelpEngineWrapper &helpEngine;
+ bool m_showTabs;
};
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/preferencesdialog.ui b/tools/assistant/tools/assistant/preferencesdialog.ui
index 279084d..1c6833a 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.ui
+++ b/tools/assistant/tools/assistant/preferencesdialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>375</width>
- <height>266</height>
+ <height>275</height>
</rect>
</property>
<property name="windowTitle">
@@ -187,7 +187,7 @@
<attribute name="title">
<string>Options</string>
</attribute>
- <layout class="QVBoxLayout" name="verticalLayout_2">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
@@ -310,6 +310,22 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Appearance</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="showTabs">
+ <property name="text">
+ <string>Show tabs for each individual page</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp
index 06e5602..51bc733 100644
--- a/tools/assistant/tools/assistant/remotecontrol.cpp
+++ b/tools/assistant/tools/assistant/remotecontrol.cpp
@@ -58,6 +58,7 @@
#include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpIndexWidget>
+#include <QtHelp/QHelpSearchQueryWidget>
#ifdef Q_OS_WIN
# include "remotecontrol_win.h"
@@ -260,8 +261,25 @@ void RemoteControl::handleActivateKeywordCommand(const QString &arg)
m_activateKeyword = arg;
} else {
m_mainWindow->setIndexString(arg);
- if (!arg.isEmpty())
- helpEngine.indexWidget()->activateCurrentItem();
+ if (!arg.isEmpty()) {
+ if (!helpEngine.indexWidget()->currentIndex().isValid()
+ && helpEngine.fullTextSearchFallbackEnabled()) {
+ if (QHelpSearchEngine *se = helpEngine.searchEngine()) {
+ m_mainWindow->setSearchVisible(true);
+ if (QHelpSearchQueryWidget *w = se->queryWidget()) {
+ w->collapseExtendedSearch();
+ QList<QHelpSearchQuery> queryList;
+ queryList << QHelpSearchQuery(QHelpSearchQuery::DEFAULT,
+ QStringList(arg));
+ w->setQuery(queryList);
+ se->search(queryList);
+ }
+ }
+ } else {
+ m_mainWindow->setIndexVisible(true);
+ helpEngine.indexWidget()->activateCurrentItem();
+ }
+ }
}
}
diff --git a/tools/assistant/tools/assistant/searchwidget.cpp b/tools/assistant/tools/assistant/searchwidget.cpp
index 9eb2106..bb5bdeb 100644
--- a/tools/assistant/tools/assistant/searchwidget.cpp
+++ b/tools/assistant/tools/assistant/searchwidget.cpp
@@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE
SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent)
: QWidget(parent)
, zoomCount(0)
- , attached(false)
, searchEngine(engine)
{
TRACE_OBJ
@@ -130,18 +129,6 @@ void SearchWidget::resetZoom()
}
}
-bool SearchWidget::isAttached() const
-{
- TRACE_OBJ
- return attached;
-}
-
-void SearchWidget::setAttached(bool state)
-{
- TRACE_OBJ
- attached = state;
-}
-
void SearchWidget::search() const
{
TRACE_OBJ
diff --git a/tools/assistant/tools/assistant/searchwidget.h b/tools/assistant/tools/assistant/searchwidget.h
index 465e8f6..04d3e28 100644
--- a/tools/assistant/tools/assistant/searchwidget.h
+++ b/tools/assistant/tools/assistant/searchwidget.h
@@ -58,16 +58,13 @@ class SearchWidget : public QWidget
Q_OBJECT
public:
- SearchWidget(QHelpSearchEngine *engine, QWidget *parent = 0);
+ explicit SearchWidget(QHelpSearchEngine *engine, QWidget *parent = 0);
~SearchWidget();
void zoomIn();
void zoomOut();
void resetZoom();
- bool isAttached() const;
- void setAttached(bool state);
-
signals:
void requestShowLink(const QUrl &url);
void requestShowLinkInNewTab(const QUrl &url);
@@ -84,7 +81,6 @@ private:
private:
int zoomCount;
- bool attached;
QHelpSearchEngine *searchEngine;
QHelpSearchResultWidget *resultWidget;
};
diff --git a/tools/assistant/tools/qcollectiongenerator/main.cpp b/tools/assistant/tools/qcollectiongenerator/main.cpp
index b3f6bd9..1046e56 100644
--- a/tools/assistant/tools/qcollectiongenerator/main.cpp
+++ b/tools/assistant/tools/qcollectiongenerator/main.cpp
@@ -49,15 +49,21 @@
#include <QtCore/QDir>
#include <QtCore/QMap>
#include <QtCore/QFileInfo>
-#include <QtCore/QCoreApplication>
#include <QtCore/QDateTime>
#include <QtCore/QBuffer>
+#include <QtCore/QTranslator>
+#include <QtCore/QLocale>
+#include <QtCore/QLibraryInfo>
#include <QtHelp/QHelpEngineCore>
#include <QtXml/QXmlStreamReader>
QT_USE_NAMESPACE
+class QCG {
+ Q_DECLARE_TR_FUNCTIONS(QCollectionGenerator)
+};
+
class CollectionConfigReader : public QXmlStreamReader
{
public:
@@ -91,6 +97,10 @@ public:
QString cacheDirectory() const { return m_cacheDirectory; }
bool cacheDirRelativeToCollection() const { return m_cacheDirRelativeToCollection; }
+ bool fullTextSearchFallbackEnabled() const {
+ return m_enableFullTextSearchFallback;
+ }
+
private:
void raiseErrorWithLine();
void readConfig();
@@ -119,13 +129,12 @@ private:
QStringList m_filesToRegister;
QString m_cacheDirectory;
bool m_cacheDirRelativeToCollection;
+ bool m_enableFullTextSearchFallback;
};
void CollectionConfigReader::raiseErrorWithLine()
{
- raiseError(QCoreApplication::translate("QCollectionGenerator",
- "Unknown token at line %1.")
- .arg(lineNumber()));
+ raiseError(QCG::tr("Unknown token at line %1.").arg(lineNumber()));
}
void CollectionConfigReader::readData(const QByteArray &contents)
@@ -135,6 +144,7 @@ void CollectionConfigReader::readData(const QByteArray &contents)
m_enableAddressBar = true;
m_hideAddressBar = true;
m_enableDocumentationManager = true;
+ m_enableFullTextSearchFallback = false;
addData(contents);
while (!atEnd()) {
@@ -144,9 +154,8 @@ void CollectionConfigReader::readData(const QByteArray &contents)
&& attributes().value(QLatin1String("version")) == QLatin1String("1.0"))
readConfig();
else
- raiseError(QCoreApplication::translate("QCollectionGenerator",
- "Unknown token at line %1. "
- "Expected \"QtHelpCollectionProject\"!")
+ raiseError(QCG::tr("Unknown token at line %1. "
+ "Expected \"QtHelpCollectionProject\".")
.arg(lineNumber()));
}
}
@@ -169,7 +178,7 @@ void CollectionConfigReader::readConfig()
}
}
if (!ok && !hasError())
- raiseError(QLatin1String("Missing end tags."));
+ raiseError(QCG::tr("Missing end tags."));
}
void CollectionConfigReader::readAssistantSettings()
@@ -209,6 +218,9 @@ void CollectionConfigReader::readAssistantSettings()
attributes().value(QLatin1String("base"))
== QLatin1String("collection");
m_cacheDirectory = readElementText();
+ } else if (name() == QLatin1String("enableFullTextSearchFallback")) {
+ if (readElementText() == QLatin1String("true"))
+ m_enableFullTextSearchFallback = true;
} else {
raiseErrorWithLine();
}
@@ -311,7 +323,7 @@ void CollectionConfigReader::readFiles()
}
}
if (input.isEmpty() || output.isEmpty()) {
- raiseError(QLatin1String("Missing input or output file for help file generation!"));
+ raiseError(QCG::tr("Missing input or output file for help file generation."));
return;
}
m_filesToGenerate.insert(input, output);
@@ -350,6 +362,20 @@ int main(int argc, char *argv[])
bool showHelp = false;
bool showVersion = false;
+ QCoreApplication app(argc, argv);
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QTranslator qt_helpTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)
+ && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ app.installTranslator(&qt_helpTranslator);
+ }
+
for (int i=1; i<argc; ++i) {
arg = QString::fromLocal8Bit(argv[i]);
if (arg == QLatin1String("-o")) {
@@ -357,8 +383,7 @@ int main(int argc, char *argv[])
QFileInfo fi(QString::fromLocal8Bit(argv[i]));
collectionFile = fi.absoluteFilePath();
} else {
- error = QCoreApplication::translate("QCollectionGenerator",
- "Missing output file name!");
+ error = QCG::tr("Missing output file name.");
}
} else if (arg == QLatin1String("-h")) {
showHelp = true;
@@ -372,16 +397,15 @@ int main(int argc, char *argv[])
}
if (showVersion) {
- fprintf(stdout, "Qt Collection Generator version 1.0 (Qt %s)\n",
- QT_VERSION_STR);
+ fputs(qPrintable(QCG::tr("Qt Collection Generator version 1.0 (Qt %1)\n")
+ .arg(QT_VERSION_STR)), stdout);
return 0;
}
if (configFile.isEmpty() && !showHelp)
- error = QCoreApplication::translate("QCollectionGenerator",
- "Missing collection config file!");
+ error = QCG::tr("Missing collection config file.");
- QString help = QCoreApplication::translate("QCollectionGenerator", "\nUsage:\n\n"
+ QString help = QCG::tr("\nUsage:\n\n"
"qcollectiongenerator <collection-config-file> [options]\n\n"
" -o <collection-file> Generates a collection file\n"
" called <collection-file>. If\n"
@@ -391,7 +415,7 @@ int main(int argc, char *argv[])
" qcollectiongenerator.\n\n");
if (showHelp) {
- fprintf(stdout, "%s", qPrintable(help));
+ fputs(qPrintable(help), stdout);
return 0;
}else if (!error.isEmpty()) {
fprintf(stderr, "%s\n\n%s", qPrintable(error), qPrintable(help));
@@ -400,7 +424,7 @@ int main(int argc, char *argv[])
QFile file(configFile);
if (!file.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Could not open %s!\n", qPrintable(configFile));
+ fputs(qPrintable(QCG::tr("Could not open %1.\n").arg(configFile)), stderr);
return -1;
}
@@ -410,19 +434,18 @@ int main(int argc, char *argv[])
+ fi.baseName() + QLatin1String(".qhc");
}
- QCoreApplication app(argc, argv);
-
- fprintf(stdout, "Reading collection config file...\n");
+ fputs(qPrintable(QCG::tr("Reading collection config file...\n")), stdout);
CollectionConfigReader config;
config.readData(file.readAll());
if (config.hasError()) {
- fprintf(stderr, "Collection config file error: %s\n", qPrintable(config.errorString()));
+ fputs(qPrintable(QCG::tr("Collection config file error: %1\n")
+ .arg(config.errorString())), stderr);
return -1;
}
QMap<QString, QString>::const_iterator it = config.filesToGenerate().constBegin();
while (it != config.filesToGenerate().constEnd()) {
- fprintf(stdout, "Generating help for %s...\n", qPrintable(it.key()));
+ fputs(qPrintable(QCG::tr("Generating help for %1...\n").arg(it.key())), stdout);
QHelpProjectData helpData;
if (!helpData.readData(absoluteFileName(basePath, it.key()))) {
fprintf(stderr, "%s\n", qPrintable(helpData.errorMessage()));
@@ -437,12 +460,13 @@ int main(int argc, char *argv[])
++it;
}
- fprintf(stdout, "Creating collection file...\n");
+ fputs(qPrintable(QCG::tr("Creating collection file...\n")), stdout);
QFileInfo colFi(collectionFile);
if (colFi.exists()) {
if (!colFi.dir().remove(colFi.fileName())) {
- fprintf(stderr, "The file %s cannot be overwritten!\n", qPrintable(collectionFile));
+ fputs(qPrintable(QCG::tr("The file %1 cannot be overwritten.\n")
+ .arg(collectionFile)), stderr);
return -1;
}
}
@@ -496,11 +520,13 @@ int main(int argc, char *argv[])
!config.hideAddressBar());
CollectionConfiguration::setCreationTime(helpEngine,
QDateTime::currentDateTime().toTime_t());
+ CollectionConfiguration::setFullTextSearchFallbackEnabled(helpEngine,
+ config.fullTextSearchFallbackEnabled());
if (!config.applicationIcon().isEmpty()) {
QFile icon(absoluteFileName(basePath, config.applicationIcon()));
if (!icon.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Cannot open %s!\n", qPrintable(icon.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(icon.fileName())), stderr);
return -1;
}
CollectionConfiguration::setApplicationIcon(helpEngine, icon.readAll());
@@ -521,7 +547,7 @@ int main(int argc, char *argv[])
if (!config.aboutIcon().isEmpty()) {
QFile icon(absoluteFileName(basePath, config.aboutIcon()));
if (!icon.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Cannot open %s!\n", qPrintable(icon.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(icon.fileName())), stderr);
return -1;
}
CollectionConfiguration::setAboutIcon(helpEngine, icon.readAll());
@@ -543,7 +569,7 @@ int main(int argc, char *argv[])
QFileInfo fi(absoluteFileName(basePath, it.value()));
QFile f(fi.absoluteFilePath());
if (!f.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Cannot open %s!\n", qPrintable(f.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open %1.\n").arg(f.fileName())), stderr);
return -1;
}
QByteArray data = f.readAll();
@@ -565,8 +591,8 @@ int main(int argc, char *argv[])
if (!imgData.contains(src))
imgData.insert(src, img.readAll());
} else {
- fprintf(stderr, "Cannot open referenced image file %s!\n",
- qPrintable(img.fileName()));
+ fputs(qPrintable(QCG::tr("Cannot open referenced image file %1.\n")
+ .arg(img.fileName())), stderr);
}
}
}
diff --git a/tools/assistant/tools/qhelpconverter/filespage.cpp b/tools/assistant/tools/qhelpconverter/filespage.cpp
index 4ebf391..fd4a40e 100644
--- a/tools/assistant/tools/qhelpconverter/filespage.cpp
+++ b/tools/assistant/tools/qhelpconverter/filespage.cpp
@@ -59,8 +59,8 @@ FilesPage::FilesPage(QWidget *parent)
connect(m_ui.removeAllButton, SIGNAL(clicked()),
this, SLOT(removeAllFiles()));
- m_ui.fileLabel->setText(tr("<p><b>Warning:</b> Be aware "
- "when removing images or stylesheets since those files "
+ m_ui.fileLabel->setText(tr("<p><b>Warning:</b> "
+ "When removing images or stylesheets, be aware that those files "
"are not directly referenced by the .adp or .dcf "
"file.</p>"));
}
diff --git a/tools/assistant/tools/qhelpconverter/filterpage.cpp b/tools/assistant/tools/qhelpconverter/filterpage.cpp
index 7f86980..c15a580 100644
--- a/tools/assistant/tools/qhelpconverter/filterpage.cpp
+++ b/tools/assistant/tools/qhelpconverter/filterpage.cpp
@@ -50,7 +50,7 @@ FilterPage::FilterPage(QWidget *parent)
setTitle(tr("Filter Settings"));
setSubTitle(tr("Specify the filter attributes for the "
"documentation. If filter attributes are used, "
- "also define a custom filter for it. Both, the "
+ "also define a custom filter for it. Both the "
"filter attributes and the custom filters are "
"optional."));
@@ -127,7 +127,7 @@ void FilterPage::addFilter()
{
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.customFilterWidget);
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsSelectable);
- item->setText(0, QLatin1String("unfiltered"));
+ item->setText(0, tr("unfiltered", "list of available documentation"));
item->setText(1, QLatin1String(""));
m_ui.customFilterWidget->editItem(item, 0);
m_ui.removeButton->setDisabled(false);
diff --git a/tools/assistant/tools/qhelpconverter/finishpage.cpp b/tools/assistant/tools/qhelpconverter/finishpage.cpp
index 0be3a1b..f0228e3 100644
--- a/tools/assistant/tools/qhelpconverter/finishpage.cpp
+++ b/tools/assistant/tools/qhelpconverter/finishpage.cpp
@@ -52,8 +52,7 @@ FinishPage::FinishPage(QWidget *parent)
: QWizardPage(parent)
{
setTitle(tr("Converting File"));
- setSubTitle(QLatin1String("Creating the new Qt help files from the "
- "old .adp file."));
+ setSubTitle(tr("Creating the new Qt help files from the old ADP file."));
setFinalPage(true);
QVBoxLayout *layout = new QVBoxLayout(this);
diff --git a/tools/assistant/tools/qhelpconverter/helpwindow.cpp b/tools/assistant/tools/qhelpconverter/helpwindow.cpp
index 9cc1a85..2c7e030 100644
--- a/tools/assistant/tools/qhelpconverter/helpwindow.cpp
+++ b/tools/assistant/tools/qhelpconverter/helpwindow.cpp
@@ -64,7 +64,7 @@ HelpWindow::HelpWindow(QWidget *parent)
layout = new QVBoxLayout(frame);
layout->setMargin(2);
- QLabel *l = new QLabel(QLatin1String("<center><b>Wizard Assistant</b></center>"));
+ QLabel *l = new QLabel(tr("<center><b>Wizard Assistant</b></center>"));
layout->addWidget(l);
m_textEdit = new QTextEdit();
m_textEdit->setFrameStyle(QFrame::NoFrame);
diff --git a/tools/assistant/tools/qhelpconverter/inputpage.h b/tools/assistant/tools/qhelpconverter/inputpage.h
index e9276c6..28a7075 100644
--- a/tools/assistant/tools/qhelpconverter/inputpage.h
+++ b/tools/assistant/tools/qhelpconverter/inputpage.h
@@ -54,7 +54,7 @@ class InputPage : public QWizardPage
Q_OBJECT
public:
- InputPage(AdpReader *reader, QWidget *parent = 0);
+ explicit InputPage(AdpReader *reader, QWidget *parent = 0);
private slots:
void getFileName();
diff --git a/tools/assistant/tools/qhelpconverter/main.cpp b/tools/assistant/tools/qhelpconverter/main.cpp
index 4b1d815..5ee624d 100644
--- a/tools/assistant/tools/qhelpconverter/main.cpp
+++ b/tools/assistant/tools/qhelpconverter/main.cpp
@@ -40,6 +40,9 @@
****************************************************************************/
#include <QtCore/QFileInfo>
+#include <QtCore/QTranslator>
+#include <QtCore/QLocale>
+#include <QtCore/QLibraryInfo>
#include <QtGui/QApplication>
#include "conversionwizard.h"
@@ -49,6 +52,18 @@ QT_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QTranslator qt_helpTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)
+ && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ app.installTranslator(&qt_helpTranslator);
+ }
ConversionWizard w;
if (argc == 2) {
diff --git a/tools/assistant/tools/qhelpgenerator/main.cpp b/tools/assistant/tools/qhelpgenerator/main.cpp
index a309f42..637786c 100644
--- a/tools/assistant/tools/qhelpgenerator/main.cpp
+++ b/tools/assistant/tools/qhelpgenerator/main.cpp
@@ -44,11 +44,18 @@
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QCoreApplication>
+#include <QtCore/QTranslator>
+#include <QtCore/QLocale>
+#include <QtCore/QLibraryInfo>
#include <private/qhelpprojectdata_p.h>
QT_USE_NAMESPACE
+class QHG {
+ Q_DECLARE_TR_FUNCTIONS(QHelpGenerator)
+};
+
int main(int argc, char *argv[])
{
QString error;
@@ -60,6 +67,20 @@ int main(int argc, char *argv[])
bool showVersion = false;
bool checkLinks = false;
+ QCoreApplication app(argc, argv);
+ QTranslator translator;
+ QTranslator qtTranslator;
+ QTranslator qt_helpTranslator;
+ QString sysLocale = QLocale::system().name();
+ QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+ if (translator.load(QLatin1String("assistant_") + sysLocale, resourceDir)
+ && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)
+ && qt_helpTranslator.load(QLatin1String("qt_help_") + sysLocale, resourceDir)) {
+ app.installTranslator(&translator);
+ app.installTranslator(&qtTranslator);
+ app.installTranslator(&qt_helpTranslator);
+ }
+
for (int i = 1; i < argc; ++i) {
arg = QString::fromLocal8Bit(argv[i]);
if (arg == QLatin1String("-o")) {
@@ -67,8 +88,7 @@ int main(int argc, char *argv[])
QFileInfo fi(QString::fromLocal8Bit(argv[i]));
compressedFile = fi.absoluteFilePath();
} else {
- error = QCoreApplication::translate("QHelpGenerator",
- "Missing output file name!");
+ error = QHG::tr("Missing output file name.");
}
} else if (arg == QLatin1String("-v")) {
showVersion = true;
@@ -84,16 +104,15 @@ int main(int argc, char *argv[])
}
if (showVersion) {
- fprintf(stdout, "Qt Help Generator version 1.0 (Qt %s)\n",
- QT_VERSION_STR);
+ fputs(qPrintable(QHG::tr("Qt Help Generator version 1.0 (Qt %1)\n")
+ .arg(QT_VERSION_STR)), stdout);
return 0;
}
if (projectFile.isEmpty() && !showHelp)
- error = QCoreApplication::translate("QHelpGenerator",
- "Missing Qt help project file!");
+ error = QHG::tr("Missing Qt help project file.");
- QString help = QCoreApplication::translate("QHelpGenerator", "\nUsage:\n\n"
+ QString help = QHG::tr("\nUsage:\n\n"
"qhelpgenerator <help-project-file> [options]\n\n"
" -o <compressed-file> Generates a Qt compressed help\n"
" file called <compressed-file>.\n"
@@ -105,7 +124,7 @@ int main(int argc, char *argv[])
" qhelpgenerator.\n\n");
if (showHelp) {
- fprintf(stdout, "%s", qPrintable(help));
+ fputs(qPrintable(help), stdout);
return 0;
}else if (!error.isEmpty()) {
fprintf(stderr, "%s\n\n%s", qPrintable(error), qPrintable(help));
@@ -114,7 +133,7 @@ int main(int argc, char *argv[])
QFile file(projectFile);
if (!file.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Could not open %s!\n", qPrintable(projectFile));
+ fputs(qPrintable(QHG::tr("Could not open %1.\n").arg(projectFile)), stderr);
return -1;
}
@@ -130,8 +149,8 @@ int main(int argc, char *argv[])
QDir parentDir = fi.dir();
if (!parentDir.exists()) {
if (!parentDir.mkpath(QLatin1String("."))) {
- fprintf(stderr, "Could not create output directory: %s\n",
- qPrintable(parentDir.path()));
+ fputs(qPrintable(QHG::tr("Could not create output directory: %1\n")
+ .arg(parentDir.path())), stderr);
}
}
}
@@ -142,7 +161,6 @@ int main(int argc, char *argv[])
return -1;
}
- QCoreApplication app(argc, argv);
HelpGenerator generator;
bool success = true;
if (checkLinks)
diff --git a/tools/assistant/tools/shared/collectionconfiguration.cpp b/tools/assistant/tools/shared/collectionconfiguration.cpp
index e3944b6..2272c64 100644
--- a/tools/assistant/tools/shared/collectionconfiguration.cpp
+++ b/tools/assistant/tools/shared/collectionconfiguration.cpp
@@ -71,6 +71,7 @@ namespace {
#endif
));
const QString WindowTitleKey(QLatin1String("WindowTitle"));
+ const QString FullTextSearchFallbackKey(QLatin1String("FullTextSearchFallback"));
} // anonymous namespace
const QString CollectionConfiguration::DefaultZoomFactor(QLatin1String("0.0"));
@@ -308,6 +309,19 @@ void CollectionConfiguration::copyConfiguration(const QHelpEngineCore &source,
setAboutTexts(target, aboutTexts(source));
setAboutImages(target, aboutImages(source));
setDefaultHomePage(target, defaultHomePage(source));
+ setFullTextSearchFallbackEnabled(target, fullTextSearchFallbackEnabled(source));
+}
+
+bool CollectionConfiguration:: fullTextSearchFallbackEnabled(
+ const QHelpEngineCore &helpEngine)
+{
+ return helpEngine.customValue(FullTextSearchFallbackKey, false).toBool();
+}
+
+void CollectionConfiguration::setFullTextSearchFallbackEnabled(
+ QHelpEngineCore &helpEngine, bool on)
+{
+ helpEngine.setCustomValue(FullTextSearchFallbackKey, on);
}
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/shared/collectionconfiguration.h b/tools/assistant/tools/shared/collectionconfiguration.h
index b7bf247..aeb636f 100644
--- a/tools/assistant/tools/shared/collectionconfiguration.h
+++ b/tools/assistant/tools/shared/collectionconfiguration.h
@@ -136,6 +136,10 @@ public:
static const QDateTime lastRegisterTime(const QHelpEngineCore &helpEngine);
static void updateLastRegisterTime(QHelpEngineCore &helpEngine);
+ static bool fullTextSearchFallbackEnabled(const QHelpEngineCore &helpEngine);
+ static void setFullTextSearchFallbackEnabled(QHelpEngineCore &helpEngine,
+ bool on);
+
static const QString DefaultZoomFactor;
static const QString ListSeparator;
};
diff --git a/tools/assistant/tools/shared/helpgenerator.cpp b/tools/assistant/tools/shared/helpgenerator.cpp
index 12008e6..4812bc5 100644
--- a/tools/assistant/tools/shared/helpgenerator.cpp
+++ b/tools/assistant/tools/shared/helpgenerator.cpp
@@ -73,12 +73,12 @@ QString HelpGenerator::error() const
void HelpGenerator::printStatus(const QString &msg)
{
- fprintf(stdout, "%s\n", qPrintable(msg));
+ puts(qPrintable(msg));
}
void HelpGenerator::printWarning(const QString &msg)
{
- fprintf(stdout, "Warning: %s\n", qPrintable(msg));
+ puts(qPrintable(tr("Warning: %1").arg(msg)));
}
QT_END_NAMESPACE