summaryrefslogtreecommitdiffstats
path: root/tools/assistant
diff options
context:
space:
mode:
authorck <qt-info@nokia.com>2010-04-27 09:13:17 (GMT)
committerck <qt-info@nokia.com>2010-04-27 09:13:17 (GMT)
commitd513ab6e72cc6e180f788e67e48d04fc16a2817e (patch)
tree5042df44d35eb340b7fe4aa33d93c318d4e4b166 /tools/assistant
parent12c3858494167b701208a9f56faf79ec2a0f61cd (diff)
downloadQt-d513ab6e72cc6e180f788e67e48d04fc16a2817e.zip
Qt-d513ab6e72cc6e180f788e67e48d04fc16a2817e.tar.gz
Qt-d513ab6e72cc6e180f788e67e48d04fc16a2817e.tar.bz2
Assistant: Fix line endings.
Diffstat (limited to 'tools/assistant')
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.cpp620
-rw-r--r--tools/assistant/tools/assistant/openpagesmanager.h208
-rw-r--r--tools/assistant/tools/assistant/openpageswidget.cpp392
-rw-r--r--tools/assistant/tools/assistant/openpageswidget.h176
4 files changed, 698 insertions, 698 deletions
diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp
index 472a846..7a2228f 100644
--- a/tools/assistant/tools/assistant/openpagesmanager.cpp
+++ b/tools/assistant/tools/assistant/openpagesmanager.cpp
@@ -1,310 +1,310 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Assistant module 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 "openpagesmanager.h"
-
-#include "centralwidget.h"
-#include "helpenginewrapper.h"
-#if defined(QT_NO_WEBKIT)
-#include "helpviewer_qtb.h"
-#else
-#include "helpviewer_qwv.h"
-#endif // QT_NO_WEBKIT
-#include "openpagesmodel.h"
-#include "openpageswidget.h"
-#include "tracer.h"
-#include "../shared/collectionconfiguration.h"
-
-#include <QtGui/QTreeView>
-
-QT_BEGIN_NAMESPACE
-
-OpenPagesManager *OpenPagesManager::createInstance(QObject *parent,
- bool defaultCollection, const QUrl &cmdLineUrl)
-{
- TRACE_OBJ
- Q_ASSERT(!m_instance);
- m_instance = new OpenPagesManager(parent, defaultCollection, cmdLineUrl);
- return m_instance;
-}
-
-OpenPagesManager *OpenPagesManager::instance()
-{
- TRACE_OBJ
- Q_ASSERT(m_instance);
- return m_instance;
-}
-
-OpenPagesManager::OpenPagesManager(QObject *parent, bool defaultCollection,
- const QUrl &cmdLineUrl)
- : QObject(parent), m_model(new OpenPagesModel(this)),
- m_openPagesWidget(new OpenPagesWidget(m_model))
-{
- TRACE_OBJ
- connect(m_openPagesWidget, SIGNAL(setCurrentPage(QModelIndex)), this,
- SLOT(setCurrentPage(QModelIndex)));
- connect(m_openPagesWidget, SIGNAL(closePage(QModelIndex)), this,
- SLOT(closePage(QModelIndex)));
- connect(m_openPagesWidget, SIGNAL(closePagesExcept(QModelIndex)), this,
- SLOT(closePagesExcept(QModelIndex)));
- setupInitialPages(defaultCollection, cmdLineUrl);
-}
-
-int OpenPagesManager::pageCount() const
-{
- TRACE_OBJ
- return m_model->rowCount();
-}
-
-void OpenPagesManager::setupInitialPages(bool defaultCollection,
- const QUrl &cmdLineUrl)
-{
- TRACE_OBJ
- if (cmdLineUrl.isValid()) {
- createPage(cmdLineUrl);
- return;
- }
-
- HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
- int initialPage = 0;
- switch (helpEngine.startOption()) {
- case ShowHomePage:
- m_model->addPage(helpEngine.homePage());
- break;
- case ShowBlankPage:
- m_model->addPage(QUrl(QLatin1String("about:blank")));
- break;
- case ShowLastPages: {
- const QStringList &lastShownPageList = helpEngine.lastShownPages();
- const int pageCount = lastShownPageList.count();
- if (pageCount == 0) {
- if (defaultCollection)
- m_model->addPage(QUrl(QLatin1String("help")));
- else
- m_model->addPage(QUrl(QLatin1String("about:blank")));
- } else {
- QStringList zoomFactors = helpEngine.lastZoomFactors();
- while (zoomFactors.count() < pageCount)
- zoomFactors.append(CollectionConfiguration::DefaultZoomFactor);
- initialPage = helpEngine.lastTabPage();
- if (initialPage >= pageCount) {
- qWarning("Initial page set to %d, maximum possible value is %d",
- initialPage, pageCount - 1);
- initialPage = 0;
- }
- for (int curPage = 0; curPage < pageCount; ++curPage) {
- const QString &curFile = lastShownPageList.at(curPage);
- if (helpEngine.findFile(curFile).isValid()
- || curFile == QLatin1String("about:blank")) {
- m_model->addPage(curFile, zoomFactors.at(curPage).toFloat());
- } else if (curPage <= initialPage && initialPage > 0)
- --initialPage;
- }
- }
- break;
- }
- default:
- Q_ASSERT(!"Unhandled option");
- }
-
- if (m_model->rowCount() == 0)
- m_model->addPage(helpEngine.homePage());
- for (int i = 0; i < m_model->rowCount(); ++i)
- CentralWidget::instance()->addPage(m_model->pageAt(i));
- setCurrentPage(initialPage);
-}
-
-HelpViewer *OpenPagesManager::createPage()
-{
- TRACE_OBJ
- return createPage(QUrl(QLatin1String("about:blank")));
-}
-
-void OpenPagesManager::closeCurrentPage()
-{
- TRACE_OBJ
- Q_ASSERT(m_model->rowCount() > 1);
- const QModelIndexList selectedIndexes
- = m_openPagesWidget->selectionModel()->selectedRows();
- if (selectedIndexes.isEmpty())
- return;
- Q_ASSERT(selectedIndexes.count() == 1);
- removePage(selectedIndexes.first().row());
-}
-
-HelpViewer *OpenPagesManager::createPage(const QUrl &url, bool fromSearch)
-{
- TRACE_OBJ
- if (AbstractHelpViewer::launchWithExternalApp(url))
- return 0;
-
- m_model->addPage(url);
- const int index = m_model->rowCount() - 1;
- HelpViewer * const page = m_model->pageAt(index);
- CentralWidget::instance()->addPage(page, fromSearch);
- setCurrentPage(index);
- return page;
-}
-
-HelpViewer *OpenPagesManager::createNewPageFromSearch(const QUrl &url)
-{
- return createPage(url, true);
-}
-
-void OpenPagesManager::closePage(const QModelIndex &index)
-{
- if (index.isValid())
- removePage(index.row());
-}
-
-void OpenPagesManager::closePages(const QString &nameSpace)
-{
- TRACE_OBJ
- closeOrReloadPages(nameSpace, false);
-}
-
-void OpenPagesManager::reloadPages(const QString &nameSpace)
-{
- TRACE_OBJ
- closeOrReloadPages(nameSpace, true);
- selectCurrentPage();
-}
-
-void OpenPagesManager::closeOrReloadPages(const QString &nameSpace, bool tryReload)
-{
- TRACE_OBJ
-
- for (int i = m_model->rowCount() - 1; i >= 0; --i) {
- HelpViewer *page = m_model->pageAt(i);
- if (page->source().host() != nameSpace)
- continue;
- if (tryReload && HelpEngineWrapper::instance().findFile(page->source()).isValid())
- page->reload();
- else if (m_model->rowCount() == 1)
- page->setSource(QUrl(QLatin1String("about:blank")));
- else
- removePage(i);
- }
-}
-
-bool OpenPagesManager::pagesOpenForNamespace(const QString &nameSpace) const
-{
- TRACE_OBJ
- for (int i = 0; i < m_model->rowCount(); ++i)
- if (m_model->pageAt(i)->source().host() == nameSpace)
- return true;
- return false;
-}
-
-void OpenPagesManager::setCurrentPage(const QModelIndex &index)
-{
- TRACE_OBJ
- if (!index.isValid())
- return;
- HelpViewer * const page = m_model->pageAt(index.row());
- CentralWidget::instance()->setCurrentPage(page);
-}
-
-void OpenPagesManager::setCurrentPage(int index)
-{
- TRACE_OBJ
- CentralWidget::instance()->setCurrentPage(m_model->pageAt(index));
- selectCurrentPage();
-}
-
-void OpenPagesManager::selectCurrentPage()
-{
- TRACE_OBJ
- QItemSelectionModel * const selModel = m_openPagesWidget->selectionModel();
- selModel->clearSelection();
- selModel->select(m_model->index(CentralWidget::instance()->currentIndex(), 0),
- QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
- m_openPagesWidget->scrollTo(m_openPagesWidget->currentIndex());
-}
-
-void OpenPagesManager::removePage(int index)
-{
- TRACE_OBJ
- CentralWidget::instance()->removePage(index);
- m_model->removePage(index);
- selectCurrentPage();
-}
-
-
-void OpenPagesManager::closePagesExcept(const QModelIndex &index)
-{
- TRACE_OBJ
- if (!index.isValid())
- return;
-
- int i = 0;
- HelpViewer *viewer = m_model->pageAt(index.row());
- while (m_model->rowCount() > 1) {
- if (m_model->pageAt(i) != viewer)
- removePage(i);
- else
- ++i;
- }
-}
-
-QWidget *OpenPagesManager::openPagesWidget() const
-{
- return m_openPagesWidget;
-}
-
-void OpenPagesManager::nextPage()
-{
- nextOrPreviousPage(1);
-}
-
-void OpenPagesManager::previousPage()
-{
- nextOrPreviousPage(-1);
-}
-
-void OpenPagesManager::nextOrPreviousPage(int offset)
-{
- setCurrentPage((CentralWidget::instance()->currentIndex() + offset
- + m_model->rowCount()) % m_model->rowCount());
-}
-
-OpenPagesManager *OpenPagesManager::m_instance = 0;
-
-QT_END_NAMESPACE
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Assistant module 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 "openpagesmanager.h"
+
+#include "centralwidget.h"
+#include "helpenginewrapper.h"
+#if defined(QT_NO_WEBKIT)
+#include "helpviewer_qtb.h"
+#else
+#include "helpviewer_qwv.h"
+#endif // QT_NO_WEBKIT
+#include "openpagesmodel.h"
+#include "openpageswidget.h"
+#include "tracer.h"
+#include "../shared/collectionconfiguration.h"
+
+#include <QtGui/QTreeView>
+
+QT_BEGIN_NAMESPACE
+
+OpenPagesManager *OpenPagesManager::createInstance(QObject *parent,
+ bool defaultCollection, const QUrl &cmdLineUrl)
+{
+ TRACE_OBJ
+ Q_ASSERT(!m_instance);
+ m_instance = new OpenPagesManager(parent, defaultCollection, cmdLineUrl);
+ return m_instance;
+}
+
+OpenPagesManager *OpenPagesManager::instance()
+{
+ TRACE_OBJ
+ Q_ASSERT(m_instance);
+ return m_instance;
+}
+
+OpenPagesManager::OpenPagesManager(QObject *parent, bool defaultCollection,
+ const QUrl &cmdLineUrl)
+ : QObject(parent), m_model(new OpenPagesModel(this)),
+ m_openPagesWidget(new OpenPagesWidget(m_model))
+{
+ TRACE_OBJ
+ connect(m_openPagesWidget, SIGNAL(setCurrentPage(QModelIndex)), this,
+ SLOT(setCurrentPage(QModelIndex)));
+ connect(m_openPagesWidget, SIGNAL(closePage(QModelIndex)), this,
+ SLOT(closePage(QModelIndex)));
+ connect(m_openPagesWidget, SIGNAL(closePagesExcept(QModelIndex)), this,
+ SLOT(closePagesExcept(QModelIndex)));
+ setupInitialPages(defaultCollection, cmdLineUrl);
+}
+
+int OpenPagesManager::pageCount() const
+{
+ TRACE_OBJ
+ return m_model->rowCount();
+}
+
+void OpenPagesManager::setupInitialPages(bool defaultCollection,
+ const QUrl &cmdLineUrl)
+{
+ TRACE_OBJ
+ if (cmdLineUrl.isValid()) {
+ createPage(cmdLineUrl);
+ return;
+ }
+
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ int initialPage = 0;
+ switch (helpEngine.startOption()) {
+ case ShowHomePage:
+ m_model->addPage(helpEngine.homePage());
+ break;
+ case ShowBlankPage:
+ m_model->addPage(QUrl(QLatin1String("about:blank")));
+ break;
+ case ShowLastPages: {
+ const QStringList &lastShownPageList = helpEngine.lastShownPages();
+ const int pageCount = lastShownPageList.count();
+ if (pageCount == 0) {
+ if (defaultCollection)
+ m_model->addPage(QUrl(QLatin1String("help")));
+ else
+ m_model->addPage(QUrl(QLatin1String("about:blank")));
+ } else {
+ QStringList zoomFactors = helpEngine.lastZoomFactors();
+ while (zoomFactors.count() < pageCount)
+ zoomFactors.append(CollectionConfiguration::DefaultZoomFactor);
+ initialPage = helpEngine.lastTabPage();
+ if (initialPage >= pageCount) {
+ qWarning("Initial page set to %d, maximum possible value is %d",
+ initialPage, pageCount - 1);
+ initialPage = 0;
+ }
+ for (int curPage = 0; curPage < pageCount; ++curPage) {
+ const QString &curFile = lastShownPageList.at(curPage);
+ if (helpEngine.findFile(curFile).isValid()
+ || curFile == QLatin1String("about:blank")) {
+ m_model->addPage(curFile, zoomFactors.at(curPage).toFloat());
+ } else if (curPage <= initialPage && initialPage > 0)
+ --initialPage;
+ }
+ }
+ break;
+ }
+ default:
+ Q_ASSERT(!"Unhandled option");
+ }
+
+ if (m_model->rowCount() == 0)
+ m_model->addPage(helpEngine.homePage());
+ for (int i = 0; i < m_model->rowCount(); ++i)
+ CentralWidget::instance()->addPage(m_model->pageAt(i));
+ setCurrentPage(initialPage);
+}
+
+HelpViewer *OpenPagesManager::createPage()
+{
+ TRACE_OBJ
+ return createPage(QUrl(QLatin1String("about:blank")));
+}
+
+void OpenPagesManager::closeCurrentPage()
+{
+ TRACE_OBJ
+ Q_ASSERT(m_model->rowCount() > 1);
+ const QModelIndexList selectedIndexes
+ = m_openPagesWidget->selectionModel()->selectedRows();
+ if (selectedIndexes.isEmpty())
+ return;
+ Q_ASSERT(selectedIndexes.count() == 1);
+ removePage(selectedIndexes.first().row());
+}
+
+HelpViewer *OpenPagesManager::createPage(const QUrl &url, bool fromSearch)
+{
+ TRACE_OBJ
+ if (AbstractHelpViewer::launchWithExternalApp(url))
+ return 0;
+
+ m_model->addPage(url);
+ const int index = m_model->rowCount() - 1;
+ HelpViewer * const page = m_model->pageAt(index);
+ CentralWidget::instance()->addPage(page, fromSearch);
+ setCurrentPage(index);
+ return page;
+}
+
+HelpViewer *OpenPagesManager::createNewPageFromSearch(const QUrl &url)
+{
+ return createPage(url, true);
+}
+
+void OpenPagesManager::closePage(const QModelIndex &index)
+{
+ if (index.isValid())
+ removePage(index.row());
+}
+
+void OpenPagesManager::closePages(const QString &nameSpace)
+{
+ TRACE_OBJ
+ closeOrReloadPages(nameSpace, false);
+}
+
+void OpenPagesManager::reloadPages(const QString &nameSpace)
+{
+ TRACE_OBJ
+ closeOrReloadPages(nameSpace, true);
+ selectCurrentPage();
+}
+
+void OpenPagesManager::closeOrReloadPages(const QString &nameSpace, bool tryReload)
+{
+ TRACE_OBJ
+
+ for (int i = m_model->rowCount() - 1; i >= 0; --i) {
+ HelpViewer *page = m_model->pageAt(i);
+ if (page->source().host() != nameSpace)
+ continue;
+ if (tryReload && HelpEngineWrapper::instance().findFile(page->source()).isValid())
+ page->reload();
+ else if (m_model->rowCount() == 1)
+ page->setSource(QUrl(QLatin1String("about:blank")));
+ else
+ removePage(i);
+ }
+}
+
+bool OpenPagesManager::pagesOpenForNamespace(const QString &nameSpace) const
+{
+ TRACE_OBJ
+ for (int i = 0; i < m_model->rowCount(); ++i)
+ if (m_model->pageAt(i)->source().host() == nameSpace)
+ return true;
+ return false;
+}
+
+void OpenPagesManager::setCurrentPage(const QModelIndex &index)
+{
+ TRACE_OBJ
+ if (!index.isValid())
+ return;
+ HelpViewer * const page = m_model->pageAt(index.row());
+ CentralWidget::instance()->setCurrentPage(page);
+}
+
+void OpenPagesManager::setCurrentPage(int index)
+{
+ TRACE_OBJ
+ CentralWidget::instance()->setCurrentPage(m_model->pageAt(index));
+ selectCurrentPage();
+}
+
+void OpenPagesManager::selectCurrentPage()
+{
+ TRACE_OBJ
+ QItemSelectionModel * const selModel = m_openPagesWidget->selectionModel();
+ selModel->clearSelection();
+ selModel->select(m_model->index(CentralWidget::instance()->currentIndex(), 0),
+ QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+ m_openPagesWidget->scrollTo(m_openPagesWidget->currentIndex());
+}
+
+void OpenPagesManager::removePage(int index)
+{
+ TRACE_OBJ
+ CentralWidget::instance()->removePage(index);
+ m_model->removePage(index);
+ selectCurrentPage();
+}
+
+
+void OpenPagesManager::closePagesExcept(const QModelIndex &index)
+{
+ TRACE_OBJ
+ if (!index.isValid())
+ return;
+
+ int i = 0;
+ HelpViewer *viewer = m_model->pageAt(index.row());
+ while (m_model->rowCount() > 1) {
+ if (m_model->pageAt(i) != viewer)
+ removePage(i);
+ else
+ ++i;
+ }
+}
+
+QWidget *OpenPagesManager::openPagesWidget() const
+{
+ return m_openPagesWidget;
+}
+
+void OpenPagesManager::nextPage()
+{
+ nextOrPreviousPage(1);
+}
+
+void OpenPagesManager::previousPage()
+{
+ nextOrPreviousPage(-1);
+}
+
+void OpenPagesManager::nextOrPreviousPage(int offset)
+{
+ setCurrentPage((CentralWidget::instance()->currentIndex() + offset
+ + m_model->rowCount()) % m_model->rowCount());
+}
+
+OpenPagesManager *OpenPagesManager::m_instance = 0;
+
+QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/openpagesmanager.h b/tools/assistant/tools/assistant/openpagesmanager.h
index 95bf247..407ee79 100644
--- a/tools/assistant/tools/assistant/openpagesmanager.h
+++ b/tools/assistant/tools/assistant/openpagesmanager.h
@@ -1,104 +1,104 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Assistant module 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 OPENPAGESMANAGER_H
-#define OPENPAGESMANAGER_H
-
-#include <QtCore/QObject>
-
-QT_BEGIN_NAMESPACE
-
-class QModelIndex;
-class QUrl;
-class QWidget;
-
-class HelpViewer;
-class OpenPagesModel;
-class OpenPagesWidget;
-
-class OpenPagesManager : public QObject
- {
- Q_OBJECT
- public:
- static OpenPagesManager *createInstance(QObject *parent,
- bool defaultCollection, const QUrl &cmdLineUrl);
- static OpenPagesManager *instance();
-
- bool pagesOpenForNamespace(const QString &nameSpace) const;
- void closePages(const QString &nameSpace);
- void reloadPages(const QString &nameSpace);
-
- QWidget* openPagesWidget() const;
-
- int pageCount() const;
-
- public slots:
- HelpViewer *createPage(const QUrl &url, bool fromSearch = false);
- HelpViewer *createNewPageFromSearch(const QUrl &url);
- HelpViewer *createPage();
- void closeCurrentPage();
- void nextPage();
- void previousPage();
-
-private slots:
- void setCurrentPage(const QModelIndex &index);
- void closePage(const QModelIndex &index);
- void closePagesExcept(const QModelIndex &index);
-
-private:
- OpenPagesManager(QObject *parent, bool defaultCollection,
- const QUrl &cmdLineUrl);
- void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl);
- void closeOrReloadPages(const QString &nameSpace, bool tryReload);
- void setCurrentPage(int index);
- void selectCurrentPage();
- void removePage(int index);
- void nextOrPreviousPage(int offset);
-
- OpenPagesModel *m_model;
- OpenPagesWidget *m_openPagesWidget;
-
- static OpenPagesManager *m_instance;
- };
-
-QT_END_NAMESPACE
-
-#endif // OPENPAGESMANAGER_H
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Assistant module 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 OPENPAGESMANAGER_H
+#define OPENPAGESMANAGER_H
+
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+
+class QModelIndex;
+class QUrl;
+class QWidget;
+
+class HelpViewer;
+class OpenPagesModel;
+class OpenPagesWidget;
+
+class OpenPagesManager : public QObject
+ {
+ Q_OBJECT
+ public:
+ static OpenPagesManager *createInstance(QObject *parent,
+ bool defaultCollection, const QUrl &cmdLineUrl);
+ static OpenPagesManager *instance();
+
+ bool pagesOpenForNamespace(const QString &nameSpace) const;
+ void closePages(const QString &nameSpace);
+ void reloadPages(const QString &nameSpace);
+
+ QWidget* openPagesWidget() const;
+
+ int pageCount() const;
+
+ public slots:
+ HelpViewer *createPage(const QUrl &url, bool fromSearch = false);
+ HelpViewer *createNewPageFromSearch(const QUrl &url);
+ HelpViewer *createPage();
+ void closeCurrentPage();
+ void nextPage();
+ void previousPage();
+
+private slots:
+ void setCurrentPage(const QModelIndex &index);
+ void closePage(const QModelIndex &index);
+ void closePagesExcept(const QModelIndex &index);
+
+private:
+ OpenPagesManager(QObject *parent, bool defaultCollection,
+ const QUrl &cmdLineUrl);
+ void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl);
+ void closeOrReloadPages(const QString &nameSpace, bool tryReload);
+ void setCurrentPage(int index);
+ void selectCurrentPage();
+ void removePage(int index);
+ void nextOrPreviousPage(int offset);
+
+ OpenPagesModel *m_model;
+ OpenPagesWidget *m_openPagesWidget;
+
+ static OpenPagesManager *m_instance;
+ };
+
+QT_END_NAMESPACE
+
+#endif // OPENPAGESMANAGER_H
diff --git a/tools/assistant/tools/assistant/openpageswidget.cpp b/tools/assistant/tools/assistant/openpageswidget.cpp
index 96af7b5..d702c28 100644
--- a/tools/assistant/tools/assistant/openpageswidget.cpp
+++ b/tools/assistant/tools/assistant/openpageswidget.cpp
@@ -1,196 +1,196 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Assistant module 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 "openpageswidget.h"
-
-#include "openpagesmodel.h"
-
-#include <QtGui/QApplication>
-#include <QtGui/QHeaderView>
-#include <QtGui/QKeyEvent>
-#include <QtGui/QMouseEvent>
-#include <QtGui/QMenu>
-#include <QtGui/QPainter>
-
-#ifdef Q_WS_MAC
-#include <qmacstyle_mac.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-OpenPagesDelegate::OpenPagesDelegate(QObject *parent)
- : QStyledItemDelegate(parent)
-{
-}
-
-void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index) const
-{
- if (option.state & QStyle::State_MouseOver) {
- if ((QApplication::mouseButtons() & Qt::LeftButton) == 0)
- pressedIndex = QModelIndex();
- QBrush brush = option.palette.alternateBase();
- if (index == pressedIndex)
- brush = option.palette.dark();
- painter->fillRect(option.rect, brush);
- }
-
- QStyledItemDelegate::paint(painter, option, index);
-
- if (index.column() == 1 && index.model()->rowCount() > 1
- && option.state & QStyle::State_MouseOver) {
- QIcon icon((option.state & QStyle::State_Selected)
- ? ":/trolltech/assistant/images/closebutton.png"
- : ":/trolltech/assistant/images/darkclosebutton.png");
-
- const QRect iconRect(option.rect.right() - option.rect.height(),
- option.rect.top(), option.rect.height(), option.rect.height());
- icon.paint(painter, iconRect, Qt::AlignRight | Qt::AlignVCenter);
- }
-}
-
-
-OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model)
-{
- setModel(model);
- setIndentation(0);
- setItemDelegate((m_delegate = new OpenPagesDelegate(this)));
-
- setFrameStyle(QFrame::NoFrame);
- setTextElideMode(Qt::ElideMiddle);
- setAttribute(Qt::WA_MacShowFocusRect, false);
-
- viewport()->setAttribute(Qt::WA_Hover);
- setSelectionBehavior(QAbstractItemView::SelectRows);
- setSelectionMode(QAbstractItemView::SingleSelection);
-
- header()->hide();
- header()->setStretchLastSection(false);
- header()->setResizeMode(0, QHeaderView::Stretch);
- header()->setResizeMode(1, QHeaderView::Fixed);
- header()->resizeSection(1, 18);
-
- installEventFilter(this);
- setUniformRowHeights(true);
- setContextMenuPolicy(Qt::CustomContextMenu);
-
- connect(this, SIGNAL(clicked(QModelIndex)), this,
- SLOT(handleClicked(QModelIndex)));
- connect(this, SIGNAL(pressed(QModelIndex)), this,
- SLOT(handlePressed(QModelIndex)));
- connect(this, SIGNAL(customContextMenuRequested(QPoint)), this,
- SLOT(contextMenuRequested(QPoint)));
-}
-
-OpenPagesWidget::~OpenPagesWidget()
-{
-}
-
-void OpenPagesWidget::contextMenuRequested(QPoint pos)
-{
- QModelIndex index = indexAt(pos);
- if (!index.isValid())
- return;
-
- if (index.column() == 1)
- index = index.sibling(index.row(), 0);
- QMenu contextMenu;
- QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(index.data()
- .toString()));
- QAction *closeOtherEditors = contextMenu.addAction(tr("Close All Except %1")
- .arg(index.data().toString()));
-
- if (model()->rowCount() == 1) {
- closeEditor->setEnabled(false);
- closeOtherEditors->setEnabled(false);
- }
-
- QAction *action = contextMenu.exec(mapToGlobal(pos));
- if (action == closeEditor)
- emit closePage(index);
- else if (action == closeOtherEditors)
- emit closePagesExcept(index);
-}
-
-void OpenPagesWidget::handlePressed(const QModelIndex &index)
-{
- if (index.column() == 0)
- emit setCurrentPage(index);
-
- if (index.column() == 1)
- m_delegate->pressedIndex = index;
-}
-
-void OpenPagesWidget::handleClicked(const QModelIndex &index)
-{
- // implemented here to handle the funky close button and to work around a
- // bug in item views where the delegate wouldn't get the QStyle::State_MouseOver
- if (index.column() == 1) {
- if (model()->rowCount() > 1)
- emit closePage(index);
-
- QWidget *vp = viewport();
- const QPoint &cursorPos = QCursor::pos();
- QMouseEvent e(QEvent::MouseMove, vp->mapFromGlobal(cursorPos), cursorPos,
- Qt::NoButton, 0, 0);
- QCoreApplication::sendEvent(vp, &e);
- }
-}
-
-bool OpenPagesWidget::eventFilter(QObject *obj, QEvent *event)
-{
- if (obj == this && event->type() == QEvent::KeyPress) {
- if (currentIndex().isValid()) {
- QKeyEvent *ke = static_cast<QKeyEvent*>(event);
- const int key = ke->key();
- if ((key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space)
- && ke->modifiers() == 0) {
- emit setCurrentPage(currentIndex());
- } else if ((key == Qt::Key_Delete || key == Qt::Key_Backspace)
- && ke->modifiers() == 0 && model()->rowCount() > 1) {
- emit closePage(currentIndex());
- }
- }
- }
- return QWidget::eventFilter(obj, event);
-}
-
-QT_END_NAMESPACE
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Assistant module 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 "openpageswidget.h"
+
+#include "openpagesmodel.h"
+
+#include <QtGui/QApplication>
+#include <QtGui/QHeaderView>
+#include <QtGui/QKeyEvent>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QMenu>
+#include <QtGui/QPainter>
+
+#ifdef Q_WS_MAC
+#include <qmacstyle_mac.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+OpenPagesDelegate::OpenPagesDelegate(QObject *parent)
+ : QStyledItemDelegate(parent)
+{
+}
+
+void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ if (option.state & QStyle::State_MouseOver) {
+ if ((QApplication::mouseButtons() & Qt::LeftButton) == 0)
+ pressedIndex = QModelIndex();
+ QBrush brush = option.palette.alternateBase();
+ if (index == pressedIndex)
+ brush = option.palette.dark();
+ painter->fillRect(option.rect, brush);
+ }
+
+ QStyledItemDelegate::paint(painter, option, index);
+
+ if (index.column() == 1 && index.model()->rowCount() > 1
+ && option.state & QStyle::State_MouseOver) {
+ QIcon icon((option.state & QStyle::State_Selected)
+ ? ":/trolltech/assistant/images/closebutton.png"
+ : ":/trolltech/assistant/images/darkclosebutton.png");
+
+ const QRect iconRect(option.rect.right() - option.rect.height(),
+ option.rect.top(), option.rect.height(), option.rect.height());
+ icon.paint(painter, iconRect, Qt::AlignRight | Qt::AlignVCenter);
+ }
+}
+
+
+OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model)
+{
+ setModel(model);
+ setIndentation(0);
+ setItemDelegate((m_delegate = new OpenPagesDelegate(this)));
+
+ setFrameStyle(QFrame::NoFrame);
+ setTextElideMode(Qt::ElideMiddle);
+ setAttribute(Qt::WA_MacShowFocusRect, false);
+
+ viewport()->setAttribute(Qt::WA_Hover);
+ setSelectionBehavior(QAbstractItemView::SelectRows);
+ setSelectionMode(QAbstractItemView::SingleSelection);
+
+ header()->hide();
+ header()->setStretchLastSection(false);
+ header()->setResizeMode(0, QHeaderView::Stretch);
+ header()->setResizeMode(1, QHeaderView::Fixed);
+ header()->resizeSection(1, 18);
+
+ installEventFilter(this);
+ setUniformRowHeights(true);
+ setContextMenuPolicy(Qt::CustomContextMenu);
+
+ connect(this, SIGNAL(clicked(QModelIndex)), this,
+ SLOT(handleClicked(QModelIndex)));
+ connect(this, SIGNAL(pressed(QModelIndex)), this,
+ SLOT(handlePressed(QModelIndex)));
+ connect(this, SIGNAL(customContextMenuRequested(QPoint)), this,
+ SLOT(contextMenuRequested(QPoint)));
+}
+
+OpenPagesWidget::~OpenPagesWidget()
+{
+}
+
+void OpenPagesWidget::contextMenuRequested(QPoint pos)
+{
+ QModelIndex index = indexAt(pos);
+ if (!index.isValid())
+ return;
+
+ if (index.column() == 1)
+ index = index.sibling(index.row(), 0);
+ QMenu contextMenu;
+ QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(index.data()
+ .toString()));
+ QAction *closeOtherEditors = contextMenu.addAction(tr("Close All Except %1")
+ .arg(index.data().toString()));
+
+ if (model()->rowCount() == 1) {
+ closeEditor->setEnabled(false);
+ closeOtherEditors->setEnabled(false);
+ }
+
+ QAction *action = contextMenu.exec(mapToGlobal(pos));
+ if (action == closeEditor)
+ emit closePage(index);
+ else if (action == closeOtherEditors)
+ emit closePagesExcept(index);
+}
+
+void OpenPagesWidget::handlePressed(const QModelIndex &index)
+{
+ if (index.column() == 0)
+ emit setCurrentPage(index);
+
+ if (index.column() == 1)
+ m_delegate->pressedIndex = index;
+}
+
+void OpenPagesWidget::handleClicked(const QModelIndex &index)
+{
+ // implemented here to handle the funky close button and to work around a
+ // bug in item views where the delegate wouldn't get the QStyle::State_MouseOver
+ if (index.column() == 1) {
+ if (model()->rowCount() > 1)
+ emit closePage(index);
+
+ QWidget *vp = viewport();
+ const QPoint &cursorPos = QCursor::pos();
+ QMouseEvent e(QEvent::MouseMove, vp->mapFromGlobal(cursorPos), cursorPos,
+ Qt::NoButton, 0, 0);
+ QCoreApplication::sendEvent(vp, &e);
+ }
+}
+
+bool OpenPagesWidget::eventFilter(QObject *obj, QEvent *event)
+{
+ if (obj == this && event->type() == QEvent::KeyPress) {
+ if (currentIndex().isValid()) {
+ QKeyEvent *ke = static_cast<QKeyEvent*>(event);
+ const int key = ke->key();
+ if ((key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space)
+ && ke->modifiers() == 0) {
+ emit setCurrentPage(currentIndex());
+ } else if ((key == Qt::Key_Delete || key == Qt::Key_Backspace)
+ && ke->modifiers() == 0 && model()->rowCount() > 1) {
+ emit closePage(currentIndex());
+ }
+ }
+ }
+ return QWidget::eventFilter(obj, event);
+}
+
+QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/openpageswidget.h b/tools/assistant/tools/assistant/openpageswidget.h
index 511735e..46c0022 100644
--- a/tools/assistant/tools/assistant/openpageswidget.h
+++ b/tools/assistant/tools/assistant/openpageswidget.h
@@ -1,88 +1,88 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Assistant module 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 OPENPAGESWIDGET_H
-#define OPENPAGESWIDGET_H
-
-#include <QtGui/QStyledItemDelegate>
-#include <QtGui/QTreeView>
-
-QT_BEGIN_NAMESPACE
-
-class OpenPagesModel;
-
-class OpenPagesDelegate : public QStyledItemDelegate
-{
- Q_OBJECT
-public:
- explicit OpenPagesDelegate(QObject *parent = 0);
- void paint(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
-
- mutable QModelIndex pressedIndex;
-};
-
-class OpenPagesWidget : public QTreeView
-{
- Q_OBJECT
-public:
- OpenPagesWidget(OpenPagesModel *model);
- ~OpenPagesWidget();
-
-signals:
- void setCurrentPage(const QModelIndex &index);
- void closePage(const QModelIndex &index);
- void closePagesExcept(const QModelIndex &index);
-
-private slots:
- void contextMenuRequested(QPoint pos);
- void handlePressed(const QModelIndex &index);
- void handleClicked(const QModelIndex &index);
-
-private:
- bool eventFilter(QObject *obj, QEvent *event);
-
- OpenPagesDelegate *m_delegate;
-};
-
-QT_END_NAMESPACE
-
-#endif // OPENPAGESWIDGET_H
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Assistant module 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 OPENPAGESWIDGET_H
+#define OPENPAGESWIDGET_H
+
+#include <QtGui/QStyledItemDelegate>
+#include <QtGui/QTreeView>
+
+QT_BEGIN_NAMESPACE
+
+class OpenPagesModel;
+
+class OpenPagesDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+public:
+ explicit OpenPagesDelegate(QObject *parent = 0);
+ void paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+
+ mutable QModelIndex pressedIndex;
+};
+
+class OpenPagesWidget : public QTreeView
+{
+ Q_OBJECT
+public:
+ OpenPagesWidget(OpenPagesModel *model);
+ ~OpenPagesWidget();
+
+signals:
+ void setCurrentPage(const QModelIndex &index);
+ void closePage(const QModelIndex &index);
+ void closePagesExcept(const QModelIndex &index);
+
+private slots:
+ void contextMenuRequested(QPoint pos);
+ void handlePressed(const QModelIndex &index);
+ void handleClicked(const QModelIndex &index);
+
+private:
+ bool eventFilter(QObject *obj, QEvent *event);
+
+ OpenPagesDelegate *m_delegate;
+};
+
+QT_END_NAMESPACE
+
+#endif // OPENPAGESWIDGET_H