diff options
author | ck <qt-info@nokia.com> | 2010-04-23 12:44:44 (GMT) |
---|---|---|
committer | ck <qt-info@nokia.com> | 2010-04-23 12:44:44 (GMT) |
commit | 9c25bcd50a5eabd8c3bfa63ef27949aeb12eaa7f (patch) | |
tree | 319dafa676dab5bfa108cb23baa2bf981b628936 /tools/assistant | |
parent | bd9adf630d8f95cfb2cb18731ee581de4efda167 (diff) | |
parent | 868b5aff25a31f3531d5f0be5b16ef2bfc78667f (diff) | |
download | Qt-9c25bcd50a5eabd8c3bfa63ef27949aeb12eaa7f.zip Qt-9c25bcd50a5eabd8c3bfa63ef27949aeb12eaa7f.tar.gz Qt-9c25bcd50a5eabd8c3bfa63ef27949aeb12eaa7f.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1
Conflicts:
tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir
tools/assistant/tools/assistant/assistant.pro
tools/assistant/tools/assistant/centralwidget.cpp
tools/assistant/tools/assistant/helpviewer_qtb.cpp
tools/assistant/tools/assistant/helpviewer_qwv.cpp
tools/assistant/tools/assistant/mainwindow.cpp
Diffstat (limited to 'tools/assistant')
26 files changed, 219 insertions, 107 deletions
diff --git a/tools/assistant/lib/fulltextsearch/qclucene-config_p.h b/tools/assistant/lib/fulltextsearch/qclucene-config_p.h index 0c70718..387d64d 100644 --- a/tools/assistant/lib/fulltextsearch/qclucene-config_p.h +++ b/tools/assistant/lib/fulltextsearch/qclucene-config_p.h @@ -314,14 +314,12 @@ configure. #define _CL_HAVE_SYS_TYPES_H 1 #endif -// Do not use the tchar.h that ships with mingw, this causes the qt build to -// fail (211547, 211401, etc...), reuse the replacement as with any other compiler -// #if defined(__MINGW32__) -// /* Define to 1 if you have the <tchar.h> header file. */ -// # ifndef _CL_HAVE_TCHAR_H -// # define _CL_HAVE_TCHAR_H 1 -// # endif -// #endif +#if defined(__MINGW32__) + /* Define to 1 if you have the <tchar.h> header file. */ + # ifndef _CL_HAVE_TCHAR_H + # define _CL_HAVE_TCHAR_H 1 + # endif +#endif #if defined(__MINGW32__) || defined(__SUNPRO_CC) || defined(__SUNPRO_C) /* Define to 1 if you have the `tell' function. */ diff --git a/tools/assistant/lib/fulltextsearch/qclucene_global_p.h b/tools/assistant/lib/fulltextsearch/qclucene_global_p.h index f4b744d..206725b 100644 --- a/tools/assistant/lib/fulltextsearch/qclucene_global_p.h +++ b/tools/assistant/lib/fulltextsearch/qclucene_global_p.h @@ -36,7 +36,7 @@ #include <QtCore/QChar> #include <QtCore/QString> -#if !defined(_MSC_VER) && defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T) +#if !defined(_MSC_VER) && !defined(__MINGW32__) && defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T) # if !defined(TCHAR) # define TCHAR wchar_t # endif diff --git a/tools/assistant/lib/qhelpcollectionhandler.cpp b/tools/assistant/lib/qhelpcollectionhandler.cpp index 235f737..bd8dc20 100644 --- a/tools/assistant/lib/qhelpcollectionhandler.cpp +++ b/tools/assistant/lib/qhelpcollectionhandler.cpp @@ -114,6 +114,9 @@ bool QHelpCollectionHandler::openCollectionFile() return false; } + m_query.exec(QLatin1String("PRAGMA synchronous=OFF")); + m_query.exec(QLatin1String("PRAGMA cache_size=3000")); + m_query.exec(QLatin1String("SELECT COUNT(*) FROM sqlite_master WHERE TYPE=\'table\'" "AND Name=\'NamespaceTable\'")); m_query.next(); @@ -163,6 +166,9 @@ bool QHelpCollectionHandler::copyCollectionFile(const QString &fileName) return false; } + copyQuery->exec(QLatin1String("PRAGMA synchronous=OFF")); + copyQuery->exec(QLatin1String("PRAGMA cache_size=3000")); + if (!createTables(copyQuery)) { emit error(tr("Cannot copy collection file: %1").arg(colFile)); return false; @@ -582,6 +588,8 @@ void QHelpCollectionHandler::optimizeDatabase(const QString &fileName) } QSqlQuery query(db); + db.exec(QLatin1String("PRAGMA synchronous=OFF")); + db.exec(QLatin1String("PRAGMA cache_size=3000")); db.exec(QLatin1String("CREATE INDEX IF NOT EXISTS NameIndex ON IndexTable(Name)")); db.exec(QLatin1String("CREATE INDEX IF NOT EXISTS FileNameIndex ON FileNameTable(Name)")); db.exec(QLatin1String("CREATE INDEX IF NOT EXISTS FileIdIndex ON FileNameTable(FileId)")); diff --git a/tools/assistant/lib/qhelpcontentwidget.cpp b/tools/assistant/lib/qhelpcontentwidget.cpp index a80dc39..6f3f942 100644 --- a/tools/assistant/lib/qhelpcontentwidget.cpp +++ b/tools/assistant/lib/qhelpcontentwidget.cpp @@ -370,7 +370,8 @@ void QHelpContentModel::invalidateContents(bool onShutDown) delete d->rootItem; d->rootItem = 0; } - reset(); + if (!onShutDown) + reset(); } /*! diff --git a/tools/assistant/lib/qhelpengine.cpp b/tools/assistant/lib/qhelpengine.cpp index 96cf0fd..e8ae31b 100644 --- a/tools/assistant/lib/qhelpengine.cpp +++ b/tools/assistant/lib/qhelpengine.cpp @@ -75,14 +75,15 @@ void QHelpEnginePrivate::init(const QString &collectionFile, { QHelpEngineCorePrivate::init(collectionFile, helpEngineCore); - contentModel = new QHelpContentModel(this); - indexModel = new QHelpIndexModel(this); - - connect(helpEngineCore, SIGNAL(setupFinished()), - this, SLOT(applyCurrentFilter())); - connect(helpEngineCore, SIGNAL(currentFilterChanged(QString)), - this, SLOT(applyCurrentFilter())); - + if (!contentModel) + contentModel = new QHelpContentModel(this); + if (!indexModel) + indexModel = new QHelpIndexModel(this); + + connect(helpEngineCore, SIGNAL(setupFinished()), this, + SLOT(applyCurrentFilter())); + connect(helpEngineCore, SIGNAL(currentFilterChanged(QString)), this, + SLOT(applyCurrentFilter())); } void QHelpEnginePrivate::applyCurrentFilter() diff --git a/tools/assistant/lib/qhelpgenerator.cpp b/tools/assistant/lib/qhelpgenerator.cpp index 783f016..85bdd75 100644 --- a/tools/assistant/lib/qhelpgenerator.cpp +++ b/tools/assistant/lib/qhelpgenerator.cpp @@ -191,6 +191,9 @@ bool QHelpGenerator::generate(QHelpDataInterface *helpData, return false; } + d->query->exec(QLatin1String("PRAGMA synchronous=OFF")); + d->query->exec(QLatin1String("PRAGMA cache_size=3000")); + addProgress(1.0); createTables(); insertFileNotFoundFile(); diff --git a/tools/assistant/lib/qhelpindexwidget.cpp b/tools/assistant/lib/qhelpindexwidget.cpp index 270bcdd..11b9966 100644 --- a/tools/assistant/lib/qhelpindexwidget.cpp +++ b/tools/assistant/lib/qhelpindexwidget.cpp @@ -244,7 +244,8 @@ void QHelpIndexModel::invalidateIndex(bool onShutDown) disconnect(this, SLOT(insertIndices())); d->indexProvider->stopCollecting(); d->indices.clear(); - filter(QString()); + if (!onShutDown) + filter(QString()); } /*! diff --git a/tools/assistant/lib/qhelpprojectdata.cpp b/tools/assistant/lib/qhelpprojectdata.cpp index 83491a0..b0faf0c 100644 --- a/tools/assistant/lib/qhelpprojectdata.cpp +++ b/tools/assistant/lib/qhelpprojectdata.cpp @@ -47,6 +47,7 @@ #include <QtCore/QStack> #include <QtCore/QMap> #include <QtCore/QRegExp> +#include <QtCore/QUrl> #include <QtCore/QVariant> #include <QtXml/QXmlStreamReader> @@ -77,6 +78,7 @@ private: void readFiles(); void raiseUnknownTokenError(); void addMatchingFiles(const QString &pattern); + bool hasValidSyntax(const QString &nameSpace, const QString &vFolder) const; QMap<QString, QStringList> dirEntriesCache; }; @@ -115,16 +117,14 @@ void QHelpProjectDataPrivate::readProject() if (isStartElement()) { if (name() == QLatin1String("virtualFolder")) { virtualFolder = readElementText(); - if (virtualFolder.contains(QLatin1String("/"))) + if (!hasValidSyntax(QLatin1String("test"), virtualFolder)) raiseError(QCoreApplication::translate("QHelpProject", - "A virtual folder must not contain " - "a \'/\' character!")); + "Virtual folder has invalid syntax.")); } else if (name() == QLatin1String("namespace")) { namespaceName = readElementText(); - if (namespaceName.contains(QLatin1String("/"))) + if (!hasValidSyntax(namespaceName, QLatin1String("test"))) raiseError(QCoreApplication::translate("QHelpProject", - "A namespace must not contain a " - "\'/\' character!")); + "Namespace has invalid syntax.")); } else if (name() == QLatin1String("customFilter")) { readCustomFilter(); } else if (name() == QLatin1String("filterSection")) { @@ -318,6 +318,22 @@ void QHelpProjectDataPrivate::addMatchingFiles(const QString &pattern) filterSectionList.last().addFile(pattern); } +bool QHelpProjectDataPrivate::hasValidSyntax(const QString &nameSpace, + const QString &vFolder) const +{ + const QLatin1Char slash('/'); + if (nameSpace.contains(slash) || vFolder.contains(slash)) + return false; + QUrl url; + const QLatin1String scheme("qthelp"); + url.setScheme(scheme); + url.setHost(nameSpace); + url.setPath(vFolder); + + const QString expectedUrl(scheme + QLatin1String("://") + nameSpace + slash + vFolder); + return url.isValid() && url.toString() == expectedUrl; +} + /*! \internal \class QHelpProjectData diff --git a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp index d9dcec5..4baa376 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp +++ b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp @@ -586,7 +586,7 @@ void QHelpSearchIndexWriter::updateIndex(const QString &collectionFile, this->m_indexFilesFolder = indexFilesFolder; mutex.unlock(); - start(QThread::NormalPriority); + start(QThread::LowestPriority); } void QHelpSearchIndexWriter::optimizeIndex() diff --git a/tools/assistant/lib/qhelpsearchindexwriter_default.cpp b/tools/assistant/lib/qhelpsearchindexwriter_default.cpp index cb3e49c..827d145 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_default.cpp +++ b/tools/assistant/lib/qhelpsearchindexwriter_default.cpp @@ -191,7 +191,7 @@ void QHelpSearchIndexWriter::updateIndex(const QString &collectionFile, this->m_collectionFile = collectionFile; this->m_indexFilesFolder = indexFilesFolder; - start(QThread::NormalPriority); + start(QThread::LowestPriority); } void QHelpSearchIndexWriter::run() diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index 78f48c1..50f5b7e 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -17,7 +17,7 @@ INCLUDEPATH += . # ## Work around a qmake issue when statically linking to # ## not-yet-installed plugins -LIBS += -L$$QT_BUILD_TREE/plugins/sqldrivers +QMAKE_LIBDIR += $$QT_BUILD_TREE/plugins/sqldrivers HEADERS += aboutdialog.h \ bookmarkdialog.h \ bookmarkfiltermodel.h \ @@ -32,8 +32,6 @@ HEADERS += aboutdialog.h \ filternamedialog.h \ helpenginewrapper.h \ helpviewer.h \ - helpviewer_qtb.h \ - helpviewer_qwv.h \ indexwindow.h \ installdialog.h \ mainwindow.h \ @@ -49,6 +47,12 @@ HEADERS += aboutdialog.h \ globalactions.h \ openpageswidget.h \ openpagesmanager.h + +contains(QT_CONFIG, webkit) { + HEADERS += helpviewer_qwv.h +} else { + HEADERS += helpviewer_qtb.h + } win32:HEADERS += remotecontrol_win.h SOURCES += aboutdialog.cpp \ @@ -65,8 +69,6 @@ SOURCES += aboutdialog.cpp \ filternamedialog.cpp \ helpenginewrapper.cpp \ helpviewer.cpp \ - helpviewer_qtb.cpp \ - helpviewer_qwv.cpp \ indexwindow.cpp \ installdialog.cpp \ main.cpp \ @@ -82,6 +84,11 @@ SOURCES += aboutdialog.cpp \ globalactions.cpp \ openpageswidget.cpp \ openpagesmanager.cpp + contains(QT_CONFIG, webkit) { + SOURCES += helpviewer_qwv.cpp +} else { + SOURCES += helpviewer_qtb.cpp +} FORMS += bookmarkdialog.ui \ bookmarkmanagerwidget.ui \ diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp index b9a1b0e..4bc7027 100644 --- a/tools/assistant/tools/assistant/bookmarkmanager.cpp +++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp @@ -363,8 +363,9 @@ void BookmarkManager::refeshBookmarkMenu() bookmarkMenu->addAction(tr("Manage Bookmarks..."), this, SLOT(manageBookmarks())); - bookmarkMenu->addAction(tr("Add Bookmark..."), this, SLOT(addBookmark()), - QKeySequence(tr("Ctrl+D"))); + bookmarkMenu->addAction(QIcon::fromTheme("bookmark-new"), + tr("Add Bookmark..."), this, SLOT(addBookmark()), + QKeySequence(tr("Ctrl+D"))); bookmarkMenu->addSeparator(); const QModelIndex &root = bookmarkModel->index(0, 0, QModelIndex()); diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index c5a46af..6d61570 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -43,11 +43,15 @@ #include "findwidget.h" #include "helpenginewrapper.h" -#include "helpviewer_qtb.h" -#include "helpviewer_qwv.h" #include "tracer.h" #include "../shared/collectionconfiguration.h" +#if defined(QT_NO_WEBKIT) +#include "helpviewer_qtb.h" +#else +#include "helpviewer_qwv.h" +#endif // QT_NO_WEBKIT + #include <QtCore/QTimer> #include <QtGui/QKeyEvent> diff --git a/tools/assistant/tools/assistant/doc/assistant.qdocconf b/tools/assistant/tools/assistant/doc/assistant.qdocconf index 3b4b5f8..491f159 100644 --- a/tools/assistant/tools/assistant/doc/assistant.qdocconf +++ b/tools/assistant/tools/assistant/doc/assistant.qdocconf @@ -12,5 +12,5 @@ HTML.footer = "<p /><address><hr /><div align=\"center\">\n" \ "<table width=\"100%\" cellspacing=\"0\" border=\"0\"><tr class=\"address\">\n" \ "<td width=\"30%\" align=\"left\">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \ "<td width=\"40%\" align=\"center\">Trademarks</td>\n" \ - "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt 4.7.0</div></td>\n" \ + "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt 4.8.0</div></td>\n" \ "</tr></table></div></address>" diff --git a/tools/assistant/tools/assistant/findwidget.cpp b/tools/assistant/tools/assistant/findwidget.cpp index 2e40ab0..60318d4 100644 --- a/tools/assistant/tools/assistant/findwidget.cpp +++ b/tools/assistant/tools/assistant/findwidget.cpp @@ -72,6 +72,7 @@ FindWidget::FindWidget(QWidget *parent) toolClose = setupToolButton(QLatin1String(""), resourcePath + QLatin1String("/closetab.png")); hboxLayout->addWidget(toolClose); + connect(toolClose, SIGNAL(clicked()), SLOT(hide())); editFind = new QLineEdit(this); hboxLayout->addWidget(editFind); diff --git a/tools/assistant/tools/assistant/globalactions.cpp b/tools/assistant/tools/assistant/globalactions.cpp index 75c57b6..de47da0 100644 --- a/tools/assistant/tools/assistant/globalactions.cpp +++ b/tools/assistant/tools/assistant/globalactions.cpp @@ -133,7 +133,7 @@ GlobalActions::GlobalActions(QObject *parent) : QObject(parent) connect(m_findAction, SIGNAL(triggered()), centralWidget, SLOT(showTextSearch())); m_actionList << m_findAction; - #ifdef Q_WS_X11 +#ifdef Q_WS_X11 m_backAction->setIcon(QIcon::fromTheme("go-previous" , m_backAction->icon())); m_nextAction->setIcon(QIcon::fromTheme("go-next" , m_nextAction->icon())); m_zoomInAction->setIcon(QIcon::fromTheme("zoom-in" , m_zoomInAction->icon())); diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index c7f4091..60b83f7 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -112,7 +112,6 @@ private: QFileSystemWatcher * const m_qchWatcher; typedef QPair<QDateTime, QSharedPointer<TimeoutForwarder> > RecentSignal; QMap<QString, RecentSignal> m_recentQchUpdates; - bool m_initialReindexingNeeded; }; const QString HelpEngineWrapper::TrUnfiltered = tr("Unfiltered"); @@ -167,6 +166,13 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) HelpEngineWrapper::~HelpEngineWrapper() { TRACE_OBJ + const QStringList &namespaces = d->m_helpEngine->registeredDocumentations(); + foreach (const QString &nameSpace, namespaces) { + const QString &docFile + = d->m_helpEngine->documentationFileName(nameSpace); + d->m_qchWatcher->removePath(docFile); + } + delete d; } @@ -175,8 +181,7 @@ void HelpEngineWrapper::initialDocSetupDone() TRACE_OBJ connect(d->m_helpEngine, SIGNAL(setupFinished()), searchEngine(), SLOT(indexDocumentation())); - if (d->m_initialReindexingNeeded) - setupData(); + setupData(); } QHelpSearchEngine *HelpEngineWrapper::searchEngine() const @@ -229,7 +234,6 @@ bool HelpEngineWrapper::registerDocumentation(const QString &docFile) return false; d->m_qchWatcher->addPath(docFile); d->checkDocFilesWatched(); - d->m_initialReindexingNeeded = true; return true; } @@ -242,7 +246,6 @@ bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName) return false; d->m_qchWatcher->removePath(file); d->checkDocFilesWatched(); - d->m_initialReindexingNeeded = true; return true; } @@ -710,8 +713,7 @@ void TimeoutForwarder::forward() HelpEngineWrapperPrivate::HelpEngineWrapperPrivate(const QString &collectionFile) : m_helpEngine(new QHelpEngine(collectionFile, this)), - m_qchWatcher(new QFileSystemWatcher(this)), - m_initialReindexingNeeded(false) + m_qchWatcher(new QFileSystemWatcher(this)) { TRACE_OBJ if (!m_helpEngine->customFilters().contains(Unfiltered)) @@ -810,7 +812,6 @@ void HelpEngineWrapperPrivate::qchFileChanged(const QString &fileName, } else { emit documentationUpdated(ns); } - m_initialReindexingNeeded = true; m_helpEngine->setupData(); } m_recentQchUpdates.erase(it); diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 9b06400..0c51a02 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -63,6 +63,45 @@ QString AbstractHelpViewer::PageNotFoundMessage = "align=\"center\"><br><br><h1>The page could not be found</h1><br><h3>'%1'" "</h3></div>"); +struct ExtensionMap { + const char *extension; + const char *mimeType; +} extensionMap[] = { + { ".bmp", "image/bmp" }, + { ".css", "text/css" }, + { ".gif", "image/gif" }, + { ".html", "text/html" }, + { ".htm", "text/html" }, + { ".ico", "image/x-icon" }, + { ".jpeg", "image/jpeg" }, + { ".jpg", "image/jpeg" }, + { ".js", "application/x-javascript" }, + { ".mng", "video/x-mng" }, + { ".pbm", "image/x-portable-bitmap" }, + { ".pgm", "image/x-portable-graymap" }, + { ".pdf", "application/pdf" }, + { ".png", "image/png" }, + { ".ppm", "image/x-portable-pixmap" }, + { ".rss", "application/rss+xml" }, + { ".svg", "image/svg+xml" }, + { ".svgz", "image/svg+xml" }, + { ".text", "text/plain" }, + { ".tif", "image/tiff" }, + { ".tiff", "image/tiff" }, + { ".txt", "text/plain" }, + { ".xbm", "image/x-xbitmap" }, + { ".xml", "text/xml" }, + { ".xpm", "image/x-xpm" }, + { ".xsl", "text/xsl" }, + { ".xhtml", "application/xhtml+xml" }, + { ".wml", "text/vnd.wap.wml" }, + { ".wmlc", "application/vnd.wap.wmlc" }, + { "about:blank", 0 }, + { 0, 0 } +}; + +// -- AbstractHelpViewer + AbstractHelpViewer::AbstractHelpViewer() { } @@ -86,9 +125,22 @@ bool AbstractHelpViewer::isLocalUrl(const QUrl &url) bool AbstractHelpViewer::canOpenPage(const QString &url) { TRACE_OBJ - return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive) - || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive) - || url == QLatin1String("about:blank"); + return !mimeFromUrl(url).isEmpty(); +} + +QString AbstractHelpViewer::mimeFromUrl(const QString &url) +{ + TRACE_OBJ + const int index = url.lastIndexOf(QLatin1Char('.')); + const QByteArray &ext = url.mid(index).toUtf8().toLower(); + + const ExtensionMap *e = extensionMap; + while (e->extension) { + if (ext == e->extension) + return QLatin1String(e->mimeType); + ++e; + } + return QLatin1String(""); } bool AbstractHelpViewer::launchWithExternalApp(const QUrl &url) diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index 9e8f5f4..6f1f48d 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE +class QMouseEvent; class QUrl; class AbstractHelpViewer @@ -64,12 +65,15 @@ public: virtual void resetScale() = 0; virtual qreal scale() const = 0; + virtual bool handleForwardBackwardMouseButtons(QMouseEvent *e) = 0; + static QString AboutBlank; static QString LocalHelpFile; static QString PageNotFoundMessage; static bool isLocalUrl(const QUrl &url); static bool canOpenPage(const QString &url); + static QString mimeFromUrl(const QString &url); static bool launchWithExternalApp(const QUrl &url); }; diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index f6df611..c6bb7a8 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -40,8 +40,6 @@ ****************************************************************************/ #include "helpviewer_qtb.h" -#if defined(QT_NO_WEBKIT) - #include "globalactions.h" #include "helpenginewrapper.h" #include "openpagesmanager.h" @@ -129,6 +127,20 @@ void HelpViewer::resetScale() zoomCount = 0; } +bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e) +{ + if (e->button() == Qt::XButton1) { + QTextBrowser::backward(); + return true; + } + + if (e->button() == Qt::XButton2) { + QTextBrowser::forward(); + return true; + } + return false; +} + void HelpViewer::setSource(const QUrl &url) { TRACE_OBJ @@ -232,15 +244,10 @@ void HelpViewer::contextMenuEvent(QContextMenuEvent *e) void HelpViewer::mouseReleaseEvent(QMouseEvent *e) { TRACE_OBJ - if (e->button() == Qt::XButton1) { - QTextBrowser::backward(); +#ifndef Q_OS_LINUX + if (handleForwardBackwardMouseButtons(e)) return; - } - - if (e->button() == Qt::XButton2) { - QTextBrowser::forward(); - return; - } +#endif controlPressed = e->modifiers() & Qt::ControlModifier; if ((controlPressed && hasAnchorAt(e->pos())) || @@ -252,6 +259,15 @@ void HelpViewer::mouseReleaseEvent(QMouseEvent *e) QTextBrowser::mouseReleaseEvent(e); } +void HelpViewer::mousePressEvent(QMouseEvent *e) +{ +#ifdef Q_OS_LINUX + if (handleForwardBackwardMouseButtons(e)) + return; +#endif + QTextBrowser::mousePressEvent(e); +} + void HelpViewer::keyPressEvent(QKeyEvent *e) { TRACE_OBJ @@ -290,5 +306,3 @@ bool HelpViewer::eventFilter(QObject *obj, QEvent *event) } QT_END_NAMESPACE - -#endif // QT_NO_WEBKIT diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.h b/tools/assistant/tools/assistant/helpviewer_qtb.h index b6ab903..065557e 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.h +++ b/tools/assistant/tools/assistant/helpviewer_qtb.h @@ -41,10 +41,6 @@ #ifndef HELPVIEWERQTB_H #define HELPVIEWERQTB_H -#include <QtCore/qglobal.h> - -#if defined(QT_NO_WEBKIT) - #include "helpviewer.h" #include <QtCore/QUrl> @@ -75,6 +71,8 @@ public: void resetScale(); qreal scale() const { return zoomCount; } + bool handleForwardBackwardMouseButtons(QMouseEvent *e); + void setSource(const QUrl &url); inline bool hasSelection() const @@ -97,6 +95,7 @@ private: void contextMenuEvent(QContextMenuEvent *e); void mouseReleaseEvent(QMouseEvent *e); void keyPressEvent(QKeyEvent *e); + void mousePressEvent(QMouseEvent *e); private slots: void openLinkInNewTab(); @@ -112,6 +111,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_WEBKIT - #endif // HELPVIEWERQTB_H diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index 934fb03..15e3a5f 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -41,8 +41,6 @@ #include "helpviewer_qwv.h" -#if !defined(QT_NO_WEBKIT) - #include "centralwidget.h" #include "helpenginewrapper.h" #include "openpagesmanager.h" @@ -132,26 +130,15 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, const QNetworkRequest &request, QIODevice* /*outgoingData*/) { TRACE_OBJ - const QUrl& url = request.url(); - QString mimeType = url.toString(); - if (mimeType.endsWith(QLatin1String(".svg")) - || mimeType.endsWith(QLatin1String(".svgz"))) { - mimeType = QLatin1String("image/svg+xml"); - } else if (mimeType.endsWith(QLatin1String(".css"))) { - mimeType = QLatin1String("text/css"); - } else if (mimeType.endsWith(QLatin1String(".js"))) { - mimeType = QLatin1String("text/javascript"); - } else if (mimeType.endsWith(QLatin1String(".txt"))) { - mimeType = QLatin1String("text/plain"); - } else { - mimeType = QLatin1String("text/html"); - } - + const QUrl &url = request.url(); + const QString &mimeType = AbstractHelpViewer::mimeFromUrl(url.toString()); + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); const QByteArray &data = helpEngine.findFile(url).isValid() ? helpEngine.fileData(url) : AbstractHelpViewer::PageNotFoundMessage.arg(url.toString()).toUtf8(); - return new HelpNetworkReply(request, data, mimeType); + return new HelpNetworkReply(request, data, mimeType.isEmpty() + ? QLatin1String("application/octet-stream") : mimeType); } class HelpPage : public QWebPage @@ -307,6 +294,22 @@ void HelpViewer::resetScale() setTextSizeMultiplier(1.0); } +bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e) +{ + TRACE_OBJ + if (e->button() == Qt::XButton1) { + triggerPageAction(QWebPage::Back); + return true; + } + + if (e->button() == Qt::XButton2) { + triggerPageAction(QWebPage::Forward); + return true; + } + + return false; +} + void HelpViewer::setSource(const QUrl &url) { TRACE_OBJ @@ -334,15 +337,10 @@ void HelpViewer::wheelEvent(QWheelEvent *e) void HelpViewer::mouseReleaseEvent(QMouseEvent *e) { TRACE_OBJ - if (e->button() == Qt::XButton1) { - triggerPageAction(QWebPage::Back); - return; - } - - if (e->button() == Qt::XButton2) { - triggerPageAction(QWebPage::Forward); +#ifndef Q_OS_LINUX + if (handleForwardBackwardMouseButtons(e)) return; - } +#endif QWebView::mouseReleaseEvent(e); } @@ -362,6 +360,11 @@ void HelpViewer::actionChanged() void HelpViewer::mousePressEvent(QMouseEvent *event) { TRACE_OBJ +#ifdef Q_OS_LINUX + if (handleForwardBackwardMouseButtons(event)) + return; +#endif + HelpPage *currentPage = static_cast<HelpPage*>(page()); if (currentPage) { currentPage->m_pressedButtons = event->buttons(); @@ -378,5 +381,3 @@ void HelpViewer::setLoadFinished(bool ok) } QT_END_NAMESPACE - -#endif // !QT_NO_WEBKIT diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h index ea5ec78..92d9e11 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.h +++ b/tools/assistant/tools/assistant/helpviewer_qwv.h @@ -42,10 +42,6 @@ #ifndef HELPVIEWERQWV_H #define HELPVIEWERQWV_H -#include <QtCore/qglobal.h> - -#if !defined(QT_NO_WEBKIT) - #include "helpviewer.h" #include <QtGui/QAction> @@ -72,6 +68,8 @@ public: void resetScale(); qreal scale() const { return textSizeMultiplier(); } + bool handleForwardBackwardMouseButtons(QMouseEvent *e); + void setSource(const QUrl &url); inline QUrl source() const { return url(); } @@ -119,6 +117,4 @@ private: QT_END_NAMESPACE -#endif // !QT_NO_WEBKIT - #endif // HELPVIEWERQWV_H diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index 77e5e7c..51ea9f9 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -292,7 +292,7 @@ void setupTranslation(const QString &fileName, const QString &dir) QTranslator *translator = new QTranslator(QCoreApplication::instance()); if (translator->load(fileName, dir)) { QCoreApplication::installTranslator(translator); - } else { + } else if (!fileName.endsWith(QLatin1String("en_US"))) { qWarning("Could not load translation file %s in directory %s.", qPrintable(fileName), qPrintable(dir)); } diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 4c8a2dc..a9bcd90 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -355,7 +355,7 @@ void MainWindow::lookForNewQtDocumentation() m_qtDocInstaller = new QtDocInstaller(qtDocInfos); connect(m_qtDocInstaller, SIGNAL(docsInstalled(bool)), this, - SLOT(qtDocumentationInstalled(bool))); + SLOT(qtDocumentationInstalled())); connect(m_qtDocInstaller, SIGNAL(qchFileNotFound(QString)), this, SLOT(resetQtDocInfo(QString))); connect(m_qtDocInstaller, SIGNAL(registerDocumentation(QString, QString)), @@ -365,7 +365,7 @@ void MainWindow::lookForNewQtDocumentation() m_qtDocInstaller->installDocs(); } -void MainWindow::qtDocumentationInstalled(bool newDocsInstalled) +void MainWindow::qtDocumentationInstalled() { TRACE_OBJ statusBar()->clearMessage(); @@ -375,6 +375,7 @@ void MainWindow::qtDocumentationInstalled(bool newDocsInstalled) void MainWindow::checkInitState() { TRACE_OBJ + HelpEngineWrapper::instance().initialDocSetupDone(); if (!m_cmdLine->enableRemoteControl()) return; @@ -395,7 +396,6 @@ void MainWindow::checkInitState() } emit initDone(); } - HelpEngineWrapper::instance().initialDocSetupDone(); } void MainWindow::insertLastPages() @@ -418,6 +418,11 @@ void MainWindow::setupActions() QMenu *menu = menuBar()->addMenu(tr("&File")); + m_newTabAction = menu->addAction(tr("New &Tab"), m_centralWidget, SLOT(newTab())); + m_newTabAction->setShortcut(QKeySequence::AddTab); + + menu->addSeparator(); + m_pageSetupAction = menu->addAction(tr("Page Set&up..."), m_centralWidget, SLOT(pageSetup())); m_printPreviewAction = menu->addAction(tr("Print Preview..."), m_centralWidget, @@ -435,7 +440,8 @@ void MainWindow::setupActions() openPages, SLOT(closeCurrentPage())); m_closeTabAction->setShortcuts(QKeySequence::Close); - QAction *tmp = menu->addAction(tr("&Quit"), this, SLOT(close())); + QAction *tmp = menu->addAction(QIcon::fromTheme("application-exit"), + tr("&Quit"), this, SLOT(close())); tmp->setMenuRole(QAction::QuitRole); #ifdef Q_OS_WIN tmp->setShortcut(QKeySequence(tr("CTRL+Q"))); diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 93cc1ac..7eb44e9 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -112,7 +112,7 @@ private slots: void lookForNewQtDocumentation(); void indexingStarted(); void indexingFinished(); - void qtDocumentationInstalled(bool newDocsInstalled); + void qtDocumentationInstalled(); void registerDocumentation(const QString &component, const QString &absFileName); void resetQtDocInfo(const QString &component); |