summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2010-02-18 14:31:01 (GMT)
committeraxis <qt-info@nokia.com>2010-02-18 14:31:01 (GMT)
commitd24f440ed547f8e9a3737670e41bb645a9159501 (patch)
tree14e9ac83c6d688e5480403a152e3ad2e60566ea8 /tools
parentb477d02479d9effbdb97e189a60dbf44dda5cbc9 (diff)
parent505dc33a4060b6fb2a80f3a3ab2a6702ec0b5f3b (diff)
downloadQt-d24f440ed547f8e9a3737670e41bb645a9159501.zip
Qt-d24f440ed547f8e9a3737670e41bb645a9159501.tar.gz
Qt-d24f440ed547f8e9a3737670e41bb645a9159501.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-s60-public into merge-with-qt-master
Conflicts: mkspecs/common/symbian/symbian.conf qmake/Makefile.unix qmake/generators/makefile.cpp
Diffstat (limited to 'tools')
-rw-r--r--tools/assistant/tools/assistant/aboutdialog.cpp31
-rw-r--r--tools/assistant/tools/assistant/assistant.pro4
-rw-r--r--tools/assistant/tools/assistant/bookmarkdialog.cpp8
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp104
-rw-r--r--tools/assistant/tools/assistant/centralwidget.h5
-rw-r--r--tools/assistant/tools/assistant/contentwindow.cpp4
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.cpp28
-rw-r--r--tools/assistant/tools/assistant/helpenginewrapper.h6
-rw-r--r--tools/assistant/tools/assistant/helpviewer.cpp601
-rw-r--r--tools/assistant/tools/assistant/helpviewer.h137
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qtb.cpp331
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qtb.h116
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qwv.cpp413
-rw-r--r--tools/assistant/tools/assistant/helpviewer_qwv.h122
-rw-r--r--tools/assistant/tools/assistant/indexwindow.cpp2
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp10
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.cpp26
-rw-r--r--tools/designer/src/components/formeditor/formeditor.pri2
-rw-r--r--tools/designer/src/components/formeditor/formwindow.cpp219
-rw-r--r--tools/designer/src/components/formeditor/formwindow.h15
-rw-r--r--tools/designer/src/components/formeditor/qdesignerundostack.cpp112
-rw-r--r--tools/designer/src/components/formeditor/qdesignerundostack.h90
-rw-r--r--tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp6
-rw-r--r--tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h4
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertycommand.cpp54
-rw-r--r--tools/designer/src/lib/shared/qdesigner_propertycommand_p.h28
26 files changed, 1528 insertions, 950 deletions
diff --git a/tools/assistant/tools/assistant/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp
index 26d488d..a9bc352 100644
--- a/tools/assistant/tools/assistant/aboutdialog.cpp
+++ b/tools/assistant/tools/assistant/aboutdialog.cpp
@@ -70,7 +70,7 @@ void AboutLabel::setText(const QString &text, const QByteArray &resources)
TRACE_OBJ
QDataStream in(resources);
in >> m_resourceMap;
-
+
QTextBrowser::setText(text);
}
@@ -96,34 +96,34 @@ QVariant AboutLabel::loadResource(int type, const QUrl &name)
void AboutLabel::setSource(const QUrl &url)
{
TRACE_OBJ
- if (url.isValid() && (!HelpViewer::isLocalUrl(url)
- || !HelpViewer::canOpenPage(url.path()))) {
+ if (url.isValid() && (!AbstractHelpViewer::isLocalUrl(url)
+ || !AbstractHelpViewer::canOpenPage(url.path()))) {
if (!QDesktopServices::openUrl(url)) {
QMessageBox::warning(this, tr("Warning"),
- tr("Unable to launch external application.\n"),
- tr("OK"));
+ tr("Unable to launch external application.\n"), tr("OK"));
}
}
}
AboutDialog::AboutDialog(QWidget *parent)
- : QDialog(parent, Qt::MSWindowsFixedSizeDialogHint|Qt::WindowTitleHint|Qt::WindowSystemMenuHint)
+ : QDialog(parent, Qt::MSWindowsFixedSizeDialogHint |
+ Qt::WindowTitleHint|Qt::WindowSystemMenuHint)
{
TRACE_OBJ
m_pixmapLabel = 0;
m_aboutLabel = new AboutLabel();
-
+
m_closeButton = new QPushButton();
m_closeButton->setText(tr("&Close"));
- connect(m_closeButton, SIGNAL(clicked()),
- this, SLOT(close()));
+ connect(m_closeButton, SIGNAL(clicked()), this, SLOT(close()));
m_layout = new QGridLayout(this);
m_layout->addWidget(m_aboutLabel, 1, 0, 1, -1);
- m_layout->addItem(new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Fixed), 2, 1, 1, 1);
+ m_layout->addItem(new QSpacerItem(20, 10, QSizePolicy::Minimum,
+ QSizePolicy::Fixed), 2, 1, 1, 1);
m_layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding), 3, 0, 1, 1);
m_layout->addWidget(m_closeButton, 3, 1, 1, 1);
- m_layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding), 3, 2, 1, 1);
+ m_layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding), 3, 2, 1, 1);
}
void AboutDialog::setText(const QString &text, const QByteArray &resources)
@@ -153,7 +153,8 @@ QString AboutDialog::documentTitle() const
void AboutDialog::updateSize()
{
TRACE_OBJ
- QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
+ QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos())
+ .size();
int limit = qMin(screenSize.width()/2, 500);
#ifdef Q_WS_MAC
@@ -165,7 +166,7 @@ void AboutDialog::updateSize()
if (width > limit)
width = limit;
-
+
QFontMetrics fm(qApp->font("QWorkspaceTitleBar"));
int windowTitleWidth = qMin(fm.width(windowTitle()) + 50, limit);
if (windowTitleWidth > width)
@@ -173,8 +174,8 @@ void AboutDialog::updateSize()
layout()->activate();
int height = (layout()->hasHeightForWidth())
- ? layout()->totalHeightForWidth(width)
- : layout()->totalMinimumSize().height();
+ ? layout()->totalHeightForWidth(width)
+ : layout()->totalMinimumSize().height();
setFixedSize(width, height);
QCoreApplication::removePostedEvents(this, QEvent::LayoutRequest);
}
diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro
index d57aa99..4677458 100644
--- a/tools/assistant/tools/assistant/assistant.pro
+++ b/tools/assistant/tools/assistant/assistant.pro
@@ -29,6 +29,8 @@ HEADERS += aboutdialog.h \
filternamedialog.h \
helpenginewrapper.h \
helpviewer.h \
+ helpviewer_qtb.h \
+ helpviewer_qwv.h \
indexwindow.h \
installdialog.h \
mainwindow.h \
@@ -55,6 +57,8 @@ SOURCES += aboutdialog.cpp \
filternamedialog.cpp \
helpenginewrapper.cpp \
helpviewer.cpp \
+ helpviewer_qtb.cpp \
+ helpviewer_qwv.cpp \
indexwindow.cpp \
installdialog.cpp \
main.cpp \
diff --git a/tools/assistant/tools/assistant/bookmarkdialog.cpp b/tools/assistant/tools/assistant/bookmarkdialog.cpp
index f081c15..c053b62 100644
--- a/tools/assistant/tools/assistant/bookmarkdialog.cpp
+++ b/tools/assistant/tools/assistant/bookmarkdialog.cpp
@@ -38,12 +38,12 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "tracer.h"
-
#include "bookmarkdialog.h"
#include "bookmarkfiltermodel.h"
#include "bookmarkitem.h"
#include "bookmarkmodel.h"
+#include "helpenginewrapper.h"
+#include "tracer.h"
#include <QtGui/QKeyEvent>
#include <QtGui/QMenu>
@@ -94,6 +94,10 @@ BookmarkDialog::BookmarkDialog(BookmarkModel *sourceModel, const QString &title,
ui.bookmarkFolders->setCurrentIndex(0);
ui.treeView->setCurrentIndex(ui.treeView->indexAt(QPoint(2, 2)));
+
+ const HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ if (helpEngine.usesAppFont())
+ setFont(helpEngine.appFont());
}
BookmarkDialog::~BookmarkDialog()
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index 03af06c..dd91326 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -43,7 +43,8 @@
#include "centralwidget.h"
#include "findwidget.h"
#include "helpenginewrapper.h"
-#include "helpviewer.h"
+#include "helpviewer_qtb.h"
+#include "helpviewer_qwv.h"
#include "searchwidget.h"
#include "mainwindow.h"
#include "../shared/collectionconfiguration.h"
@@ -57,6 +58,7 @@
#include <QtGui/QPrinter>
#include <QtGui/QTabBar>
#include <QtGui/QTabWidget>
+#include <QtGui/QTextBrowser>
#include <QtGui/QToolButton>
#include <QtGui/QPageSetupDialog>
#include <QtGui/QPrintDialog>
@@ -70,6 +72,7 @@ namespace {
HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget,
const QPoint &point)
{
+ TRACE_OBJ
QTabBar *tabBar = qFindChild<QTabBar*>(widget);
for (int i = 0; i < tabBar->count(); ++i) {
if (tabBar->tabRect(i).contains(point))
@@ -80,10 +83,8 @@ namespace {
CentralWidget *staticCentralWidget = 0;
}
-
// -- CentralWidget
-
CentralWidget::CentralWidget(MainWindow *parent)
: QWidget(parent)
, lastTabPage(0)
@@ -174,7 +175,7 @@ CentralWidget::~CentralWidget()
HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(i));
if (viewer && viewer->source().isValid()) {
currentPages << viewer->source().toString();
- zoomFactors << QString::number(viewer->zoom());
+ zoomFactors << QString::number(viewer->scale());
}
}
@@ -208,7 +209,7 @@ void CentralWidget::zoomIn()
TRACE_OBJ
HelpViewer *viewer = currentHelpViewer();
if (viewer)
- viewer->zoomIn();
+ viewer->scaleUp();
if (tabWidget->currentWidget() == m_searchWidget)
m_searchWidget->zoomIn();
@@ -219,7 +220,7 @@ void CentralWidget::zoomOut()
TRACE_OBJ
HelpViewer *viewer = currentHelpViewer();
if (viewer)
- viewer->zoomOut();
+ viewer->scaleDown();
if (tabWidget->currentWidget() == m_searchWidget)
m_searchWidget->zoomOut();
@@ -237,9 +238,8 @@ void CentralWidget::nextPage()
void CentralWidget::resetZoom()
{
TRACE_OBJ
- HelpViewer *viewer = currentHelpViewer();
- if (viewer)
- viewer->resetZoom();
+ if (HelpViewer *viewer = currentHelpViewer())
+ viewer->resetScale();
if (tabWidget->currentWidget() == m_searchWidget)
m_searchWidget->resetZoom();
@@ -522,25 +522,12 @@ void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom)
return;
#endif
- viewer = new HelpViewer(this);
+ viewer = new HelpViewer(this, zoom);
viewer->installEventFilter(this);
viewer->setSource(url);
viewer->setFocus(Qt::OtherFocusReason);
tabWidget->setCurrentIndex(tabWidget->addTab(viewer,
quoteTabTitle(viewer->documentTitle())));
-
- QFont font;
- getBrowserFontFor(viewer, &font);
-
-#if defined(QT_NO_WEBKIT)
- font.setPointSize((int)(font.pointSize() + zoom));
- setBrowserFontFor(viewer, font);
- viewer->setZoom((int)zoom);
-#else
- setBrowserFontFor(viewer, font);
- viewer->setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
-#endif
-
connectSignals();
}
@@ -579,7 +566,13 @@ void CentralWidget::connectSignals()
}
}
-HelpViewer *CentralWidget::currentHelpViewer() const
+HelpViewer* CentralWidget::viewerAt(int index) const
+{
+ TRACE_OBJ
+ return qobject_cast<HelpViewer*>(tabWidget->widget(index));
+}
+
+HelpViewer* CentralWidget::currentHelpViewer() const
{
TRACE_OBJ
return qobject_cast<HelpViewer*>(tabWidget->currentWidget());
@@ -755,6 +748,7 @@ void CentralWidget::keyPressEvent(QKeyEvent *e)
void CentralWidget::findNext()
{
+ TRACE_OBJ
find(findWidget->text(), true);
}
@@ -876,21 +870,24 @@ bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward)
void CentralWidget::updateBrowserFont()
{
TRACE_OBJ
- QFont font;
- bool searchAttached = searchWidgetAttached();
+ const bool searchAttached = searchWidgetAttached();
if (searchAttached) {
- getBrowserFontFor(m_searchWidget, &font);
- setBrowserFontFor(m_searchWidget, font);
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ m_searchWidget->setFont(helpEngine.usesBrowserFont()
+ ? helpEngine.browserFont() : qApp->font());
}
- int i = searchAttached ? 1 : 0;
- getBrowserFontFor(tabWidget->widget(i), &font);
- for ( ; i < tabWidget->count(); ++i)
- setBrowserFontFor(tabWidget->widget(i), font);
+ const int count = tabWidget->count();
+ if (HelpViewer* viewer = viewerAt(count - 1)) {
+ const QFont &font = viewer->viewerFont();
+ for (int i = searchAttached ? 1 : 0; i < count; ++i)
+ viewerAt(i)->setViewerFont(font);
+ }
}
bool CentralWidget::searchWidgetAttached() const
{
+ TRACE_OBJ
return m_searchWidget && m_searchWidget->isAttached();
}
@@ -906,9 +903,9 @@ void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine)
connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this,
SLOT(setSourceFromSearchInNewTab(QUrl)));
- QFont font;
- getBrowserFontFor(m_searchWidget, &font);
- setBrowserFontFor(m_searchWidget, font);
+ HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
+ m_searchWidget->setFont(!helpEngine.usesBrowserFont() ? qApp->font()
+ : helpEngine.browserFont());
}
void CentralWidget::activateSearchWidget(bool updateLastTabPage)
@@ -1103,41 +1100,4 @@ QMap<int, QString> CentralWidget::currentSourceFileList() const
return sourceList;
}
-void CentralWidget::getBrowserFontFor(QWidget *viewer, QFont *font)
-{
- TRACE_OBJ
- HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
- if (!helpEngine.usesBrowserFont()) {
- *font = qApp->font(); // case for QTextBrowser and SearchWidget
-#if !defined(QT_NO_WEBKIT)
- QWebView *view = qobject_cast<QWebView*> (viewer);
- if (view) {
- QWebSettings *settings = QWebSettings::globalSettings();
- *font = QFont(settings->fontFamily(QWebSettings::StandardFont),
- settings->fontSize(QWebSettings::DefaultFontSize));
- }
-#endif
- } else {
- *font = helpEngine.browserFont();
- }
-}
-
-void CentralWidget::setBrowserFontFor(QWidget *widget, const QFont &font)
-{
- TRACE_OBJ
-#if !defined(QT_NO_WEBKIT)
- QWebView *view = qobject_cast<QWebView*> (widget);
- if (view) {
- QWebSettings *settings = view->settings();
- settings->setFontFamily(QWebSettings::StandardFont, font.family());
- settings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
- } else if (widget && widget->font() != font) {
- widget->setFont(font);
- }
-#else
- if (widget && widget->font() != font)
- widget->setFont(font);
-#endif
-}
-
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h
index 6c3e93c..f286ff7 100644
--- a/tools/assistant/tools/assistant/centralwidget.h
+++ b/tools/assistant/tools/assistant/centralwidget.h
@@ -70,6 +70,8 @@ public:
bool isBackwardAvailable() const;
QList<QAction*> globalActions() const;
void setGlobalActions(const QList<QAction*> &actions);
+
+ HelpViewer *viewerAt(int index) const;
HelpViewer *currentHelpViewer() const;
bool searchWidgetAttached() const;
@@ -143,9 +145,6 @@ private:
QString quoteTabTitle(const QString &title) const;
void setLastShownPages();
- void getBrowserFontFor(QWidget* viewer, QFont *font);
- void setBrowserFontFor(QWidget *widget, const QFont &font);
-
private:
int lastTabPage;
QList<QAction*> globalActionList;
diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp
index 976ed7a..e0347c8 100644
--- a/tools/assistant/tools/assistant/contentwindow.cpp
+++ b/tools/assistant/tools/assistant/contentwindow.cpp
@@ -144,7 +144,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e)
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
if (contentModel) {
QHelpContentItem *itm = contentModel->contentItemAt(index);
- if (itm && HelpViewer::canOpenPage(itm->url().path()))
+ if (itm && AbstractHelpViewer::canOpenPage(itm->url().path()))
CentralWidget::instance()->setSourceInNewTab(itm->url());
}
} else if (button == Qt::LeftButton) {
@@ -170,7 +170,7 @@ void ContentWindow::showContextMenu(const QPoint &pos)
QMenu menu;
QAction *curTab = menu.addAction(tr("Open Link"));
QAction *newTab = menu.addAction(tr("Open Link in New Tab"));
- if (!HelpViewer::canOpenPage(itm->url().path()))
+ if (!AbstractHelpViewer::canOpenPage(itm->url().path()))
newTab->setEnabled(false);
menu.move(m_contentWidget->mapToGlobal(pos));
diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp
index 76211c5..a181c71 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.cpp
+++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp
@@ -112,6 +112,7 @@ 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");
@@ -141,6 +142,18 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile)
: d(new HelpEngineWrapperPrivate(collectionFile))
{
TRACE_OBJ
+
+ /*
+ * Otherwise we will waste time if several new docs are found,
+ * 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
+ * called after the new docs have been installed.
+ */
+ disconnect(d->m_helpEngine, SIGNAL(setupFinished()),
+ searchEngine(), SLOT(indexDocumentation()));
+
connect(d, SIGNAL(documentationRemoved(QString)),
this, SIGNAL(documentationRemoved(QString)));
connect(d, SIGNAL(documentationUpdated(QString)),
@@ -157,6 +170,15 @@ HelpEngineWrapper::~HelpEngineWrapper()
delete d;
}
+void HelpEngineWrapper::initialDocSetupDone()
+{
+ TRACE_OBJ
+ connect(d->m_helpEngine, SIGNAL(setupFinished()),
+ searchEngine(), SLOT(indexDocumentation()));
+ if (d->m_initialReindexingNeeded)
+ setupData();
+}
+
QHelpSearchEngine *HelpEngineWrapper::searchEngine() const
{
TRACE_OBJ
@@ -207,6 +229,7 @@ bool HelpEngineWrapper::registerDocumentation(const QString &docFile)
return false;
d->m_qchWatcher->addPath(docFile);
d->checkDocFilesWatched();
+ d->m_initialReindexingNeeded = true;
return true;
}
@@ -219,6 +242,7 @@ bool HelpEngineWrapper::unregisterDocumentation(const QString &namespaceName)
return false;
d->m_qchWatcher->removePath(file);
d->checkDocFilesWatched();
+ d->m_initialReindexingNeeded = true;
return true;
}
@@ -698,7 +722,8 @@ void TimeoutForwarder::forward()
HelpEngineWrapperPrivate::HelpEngineWrapperPrivate(const QString &collectionFile)
: m_helpEngine(new QHelpEngine(collectionFile, this)),
- m_qchWatcher(new QFileSystemWatcher(this))
+ m_qchWatcher(new QFileSystemWatcher(this)),
+ m_initialReindexingNeeded(false)
{
TRACE_OBJ
if (!m_helpEngine->customFilters().contains(Unfiltered))
@@ -797,6 +822,7 @@ 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/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h
index a30fab8..8d95273 100644
--- a/tools/assistant/tools/assistant/helpenginewrapper.h
+++ b/tools/assistant/tools/assistant/helpenginewrapper.h
@@ -101,6 +101,12 @@ public:
const QStringList filterAttributes(const QString &filterName) const;
QString error() const;
+ /*
+ * To be called after assistant has finished looking for new documentation.
+ * This will mainly cause the search index to be updated, if necessary.
+ */
+ void initialDocSetupDone();
+
const QStringList qtDocInfo(const QString &component) const;
void setQtDocInfo(const QString &component, const QStringList &doc);
diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp
index 8e4d3ed..8597f6b 100644
--- a/tools/assistant/tools/assistant/helpviewer.cpp
+++ b/tools/assistant/tools/assistant/helpviewer.cpp
@@ -38,603 +38,31 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "tracer.h"
-
#include "helpviewer.h"
-#include "centralwidget.h"
-#include "helpenginewrapper.h"
-
-#include <QtCore/QDir>
-#include <QtCore/QEvent>
-#include <QtCore/QVariant>
-#include <QtCore/QByteArray>
-#include <QtCore/QStringBuilder>
-#include <QtCore/QTemporaryFile>
-#include <QtCore/QTimer>
-
-#include <QtGui/QMenu>
-#include <QtGui/QKeyEvent>
-#include <QtGui/QClipboard>
-#include <QtGui/QApplication>
-#include <QtGui/QMessageBox>
-#include <QtGui/QDesktopServices>
+#include "tracer.h"
-#include <QNetworkAccessManager>
-#include <QNetworkReply>
-#include <QNetworkRequest>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QUrl>
QT_BEGIN_NAMESPACE
-namespace {
- const QString PageNotFoundMessage =
- QCoreApplication::translate("HelpViewer",
- "<title>Error 404...</title><div align=\"center\"><br><br>"
- "<h1>The page could not be found</h1><br><h3>'%1'</h3></div>");
-}
-
-#if !defined(QT_NO_WEBKIT)
-
-class HelpNetworkReply : public QNetworkReply
-{
-public:
- HelpNetworkReply(const QNetworkRequest &request, const QByteArray &fileData,
- const QString &mimeType);
-
- virtual void abort();
-
- virtual qint64 bytesAvailable() const
- { return data.length() + QNetworkReply::bytesAvailable(); }
-
-protected:
- virtual qint64 readData(char *data, qint64 maxlen);
-
-private:
- QByteArray data;
- qint64 origLen;
-};
-
-HelpNetworkReply::HelpNetworkReply(const QNetworkRequest &request,
- const QByteArray &fileData, const QString& mimeType)
- : data(fileData), origLen(fileData.length())
-{
- TRACE_OBJ
- setRequest(request);
- setOpenMode(QIODevice::ReadOnly);
-
- setHeader(QNetworkRequest::ContentTypeHeader, mimeType);
- setHeader(QNetworkRequest::ContentLengthHeader, QByteArray::number(origLen));
- QTimer::singleShot(0, this, SIGNAL(metaDataChanged()));
- QTimer::singleShot(0, this, SIGNAL(readyRead()));
-}
-
-void HelpNetworkReply::abort()
-{
- TRACE_OBJ
- // nothing to do
-}
-
-qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen)
-{
- TRACE_OBJ
- qint64 len = qMin(qint64(data.length()), maxlen);
- if (len) {
- qMemCopy(buffer, data.constData(), len);
- data.remove(0, len);
- }
- if (!data.length())
- QTimer::singleShot(0, this, SIGNAL(finished()));
- return len;
-}
-
-class HelpNetworkAccessManager : public QNetworkAccessManager
-{
-public:
- HelpNetworkAccessManager(QObject *parent);
-
-protected:
- virtual QNetworkReply *createRequest(Operation op,
- const QNetworkRequest &request, QIODevice *outgoingData = 0);
-};
-
-HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent)
- : QNetworkAccessManager(parent)
-{
- TRACE_OBJ
-}
-
-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");
- }
-
- HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance();
- const QByteArray &data = helpEngine.findFile(url).isValid()
- ? helpEngine.fileData(url)
- : PageNotFoundMessage.arg(url.toString()).toUtf8();
- return new HelpNetworkReply(request, data, mimeType);
-}
-
-class HelpPage : public QWebPage
-{
-public:
- HelpPage(CentralWidget *central, QObject *parent);
-
-protected:
- virtual QWebPage *createWindow(QWebPage::WebWindowType);
- virtual void triggerAction(WebAction action, bool checked = false);
-
- virtual bool acceptNavigationRequest(QWebFrame *frame,
- const QNetworkRequest &request, NavigationType type);
-
-private:
- CentralWidget *centralWidget;
- bool closeNewTabIfNeeded;
-
- friend class HelpViewer;
- Qt::MouseButtons m_pressedButtons;
- Qt::KeyboardModifiers m_keyboardModifiers;
-};
-
-HelpPage::HelpPage(CentralWidget *central, QObject *parent)
- : QWebPage(parent)
- , centralWidget(central)
- , closeNewTabIfNeeded(false)
- , m_pressedButtons(Qt::NoButton)
- , m_keyboardModifiers(Qt::NoModifier)
-{
- TRACE_OBJ
-}
-
-QWebPage *HelpPage::createWindow(QWebPage::WebWindowType)
-{
- TRACE_OBJ
- HelpPage* newPage = static_cast<HelpPage*>(centralWidget->newEmptyTab()->page());
- if (newPage)
- newPage->closeNewTabIfNeeded = closeNewTabIfNeeded;
- closeNewTabIfNeeded = false;
- return newPage;
-}
+QString AbstractHelpViewer::PageNotFoundMessage =
+ QCoreApplication::translate("HelpViewer", "<title>Error 404...</title><div "
+ "align=\"center\"><br><br><h1>The page could not be found</h1><br><h3>'%1'"
+ "</h3></div>");
-void HelpPage::triggerAction(WebAction action, bool checked)
+AbstractHelpViewer::AbstractHelpViewer()
{
- TRACE_OBJ
- switch (action) {
- case OpenLinkInNewWindow:
- closeNewTabIfNeeded = true;
- default: // fall through
- QWebPage::triggerAction(action, checked);
- break;
- }
}
-bool HelpPage::acceptNavigationRequest(QWebFrame *,
- const QNetworkRequest &request, QWebPage::NavigationType type)
+AbstractHelpViewer::~AbstractHelpViewer()
{
- TRACE_OBJ
- const QUrl &url = request.url();
- const bool closeNewTab = closeNewTabIfNeeded;
- closeNewTabIfNeeded = false;
-
- if (HelpViewer::isLocalUrl(url)) {
- const QString& path = url.path();
- if (!HelpViewer::canOpenPage(path)) {
- QTemporaryFile tmpTmpFile;
- if (!tmpTmpFile.open())
- return false;
- const QString extension = QFileInfo(path).completeSuffix();
- QFile actualTmpFile(tmpTmpFile.fileName() % QLatin1String(".")
- % extension);
- if (actualTmpFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
- actualTmpFile.write(HelpEngineWrapper::instance().fileData(url));
- actualTmpFile.close();
- QDesktopServices::openUrl(QUrl(actualTmpFile.fileName()));
- }
-
- if (closeNewTab)
- QMetaObject::invokeMethod(CentralWidget::instance(), "closeTab");
- return false;
- }
-
- if (type == QWebPage::NavigationTypeLinkClicked
- && (m_keyboardModifiers & Qt::ControlModifier
- || m_pressedButtons == Qt::MidButton)) {
- HelpViewer* viewer = centralWidget->newEmptyTab();
- if (viewer)
- CentralWidget::instance()->setSource(url);
- m_pressedButtons = Qt::NoButton;
- m_keyboardModifiers = Qt::NoModifier;
- return false;
- }
- return true;
- }
-
- QDesktopServices::openUrl(url);
- return false;
}
-HelpViewer::HelpViewer(CentralWidget *parent)
- : QWebView(parent)
- , parentWidget(parent)
- , loadFinished(false)
- , helpEngine(HelpEngineWrapper::instance())
+bool AbstractHelpViewer::isLocalUrl(const QUrl &url)
{
TRACE_OBJ
- setAcceptDrops(false);
-
- setPage(new HelpPage(parent, this));
-
- page()->setNetworkAccessManager(new HelpNetworkAccessManager(this));
-
- QAction* action = pageAction(QWebPage::OpenLinkInNewWindow);
- action->setText(tr("Open Link in New Tab"));
- if (!parent)
- action->setVisible(false);
-
- pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false);
- pageAction(QWebPage::DownloadImageToDisk)->setVisible(false);
- pageAction(QWebPage::OpenImageInNewWindow)->setVisible(false);
-
- connect(pageAction(QWebPage::Copy), SIGNAL(changed()), this,
- SLOT(actionChanged()));
- connect(pageAction(QWebPage::Back), SIGNAL(changed()), this,
- SLOT(actionChanged()));
- connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this,
- SLOT(actionChanged()));
- connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this,
- SIGNAL(highlighted(QString)));
- connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl)));
- connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
-}
-
-void HelpViewer::setSource(const QUrl &url)
-{
- TRACE_OBJ
- loadFinished = false;
- if (url.toString() == QLatin1String("help")) {
- load(QUrl(QLatin1String("qthelp://com.trolltech.com."
- "assistantinternal-1.0.0/assistant/assistant.html")));
- } else {
- load(url);
- }
-}
-
-void HelpViewer::resetZoom()
-{
- TRACE_OBJ
- setTextSizeMultiplier(1.0);
-}
-
-void HelpViewer::zoomIn(qreal range)
-{
- TRACE_OBJ
- setTextSizeMultiplier(textSizeMultiplier() + range / 10.0);
-}
-
-void HelpViewer::zoomOut(qreal range)
-{
- TRACE_OBJ
- setTextSizeMultiplier(qMax(0.0, textSizeMultiplier() - range / 10.0));
-}
-
-void HelpViewer::wheelEvent(QWheelEvent *e)
-{
- TRACE_OBJ
- if (e->modifiers() & Qt::ControlModifier) {
- const int delta = e->delta();
- if (delta > 0)
- zoomIn(delta / 120);
- else if (delta < 0)
- zoomOut(-delta / 120);
- e->accept();
- return;
- }
- QWebView::wheelEvent(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);
- return;
- }
-
- QWebView::mouseReleaseEvent(e);
-}
-
-void HelpViewer::actionChanged()
-{
- TRACE_OBJ
- QAction *a = qobject_cast<QAction *>(sender());
- if (a == pageAction(QWebPage::Copy))
- emit copyAvailable(a->isEnabled());
- else if (a == pageAction(QWebPage::Back))
- emit backwardAvailable(a->isEnabled());
- else if (a == pageAction(QWebPage::Forward))
- emit forwardAvailable(a->isEnabled());
-}
-
-void HelpViewer::mousePressEvent(QMouseEvent *event)
-{
- TRACE_OBJ
- HelpPage *currentPage = static_cast<HelpPage*>(page());
- if (currentPage) {
- currentPage->m_pressedButtons = event->buttons();
- currentPage->m_keyboardModifiers = event->modifiers();
- }
- QWebView::mousePressEvent(event);
-}
-
-void HelpViewer::setLoadFinished(bool ok)
-{
- TRACE_OBJ
- loadFinished = ok;
- emit sourceChanged(url());
-}
-
-#else // !defined(QT_NO_WEBKIT)
-
-HelpViewer::HelpViewer(CentralWidget *parent)
- : QTextBrowser(parent)
- , zoomCount(0)
- , controlPressed(false)
- , lastAnchor(QString())
- , parentWidget(parent)
- , helpEngine(HelpEngineWrapper::instance())
-{
- TRACE_OBJ
- document()->setDocumentMargin(8);
-}
-
-void HelpViewer::setSource(const QUrl &url)
-{
- TRACE_OBJ
- bool help = url.toString() == QLatin1String("help");
- if (url.isValid() && !help) {
- if (launchedWithExternalApp(url))
- return;
-
- QUrl u = helpEngine.findFile(url);
- if (u.isValid()) {
- QTextBrowser::setSource(u);
- return;
- }
- }
-
- if (help) {
- QTextBrowser::setSource(QUrl(QLatin1String("qthelp://com.trolltech.com."
- "assistantinternal-1.0.0/assistant/assistant.html")));
- } else {
- QTextBrowser::setSource(url);
- setHtml(PageNotFoundMessage.arg(url.toString()));
- emit sourceChanged(url);
- }
-}
-
-void HelpViewer::resetZoom()
-{
- TRACE_OBJ
- if (zoomCount == 0)
- return;
-
- QTextBrowser::zoomOut(zoomCount);
- zoomCount = 0;
-}
-
-void HelpViewer::zoomIn(int range)
-{
- TRACE_OBJ
- if (zoomCount == 10)
- return;
-
- QTextBrowser::zoomIn(range);
- zoomCount++;
-}
-
-void HelpViewer::zoomOut(int range)
-{
- TRACE_OBJ
- if (zoomCount == -5)
- return;
-
- QTextBrowser::zoomOut(range);
- zoomCount--;
-}
-
-bool HelpViewer::launchedWithExternalApp(const QUrl &url)
-{
- TRACE_OBJ
- const bool canOpen = canOpenPage(url.path());
- if (!isLocalUrl(url) || !canOpen) {
- bool launched = false;
- if (!canOpen && url.scheme() == QLatin1String("qthelp")) {
- const QString& path = url.path();
- const int lastDash = path.lastIndexOf(QChar('/'));
- QString fileName = QDir::tempPath() + QDir::separator();
- if (lastDash < 0)
- fileName += path;
- else
- fileName += path.mid(lastDash + 1, path.length());
-
- QFile tmpFile(QDir::cleanPath(fileName));
- if (tmpFile.open(QIODevice::ReadWrite)) {
- tmpFile.write(helpEngine.fileData(url));
- tmpFile.close();
- }
- launched = QDesktopServices::openUrl(QUrl(tmpFile.fileName()));
- } else {
- launched = QDesktopServices::openUrl(url);
- }
-
- if (!launched) {
- QMessageBox::information(this, tr("Help"),
- tr("Unable to launch external application.\n"), tr("OK"));
- }
- return true;
- }
- return false;
-}
-
-QVariant HelpViewer::loadResource(int type, const QUrl &name)
-{
- TRACE_OBJ
- QByteArray ba;
- if (type < 4) {
- ba = helpEngine.fileData(name);
- if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) {
- QImage image;
- image.loadFromData(ba, "svg");
- if (!image.isNull())
- return image;
- }
- }
- return ba;
-}
-
-void HelpViewer::openLinkInNewTab()
-{
- TRACE_OBJ
- if(lastAnchor.isEmpty())
- return;
-
- parentWidget->setSourceInNewTab(QUrl(lastAnchor));
- lastAnchor.clear();
-}
-
-void HelpViewer::openLinkInNewTab(const QString &link)
-{
- TRACE_OBJ
- lastAnchor = link;
- openLinkInNewTab();
-}
-
-bool HelpViewer::hasAnchorAt(const QPoint& pos)
-{
- TRACE_OBJ
- lastAnchor = anchorAt(pos);
- if (lastAnchor.isEmpty())
- return false;
-
- lastAnchor = source().resolved(lastAnchor).toString();
- if (lastAnchor.at(0) == QLatin1Char('#')) {
- QString src = source().toString();
- int hsh = src.indexOf(QLatin1Char('#'));
- lastAnchor = (hsh>=0 ? src.left(hsh) : src) + lastAnchor;
- }
-
- return true;
-}
-
-void HelpViewer::contextMenuEvent(QContextMenuEvent *e)
-{
- TRACE_OBJ
- QMenu menu(QLatin1String(""), 0);
-
- QUrl link;
- QAction *copyAnchorAction = 0;
- if (hasAnchorAt(e->pos())) {
- link = anchorAt(e->pos());
- if (link.isRelative())
- link = source().resolved(link);
- copyAnchorAction = menu.addAction(tr("Copy &Link Location"));
- copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid());
-
- menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), this,
- SLOT(openLinkInNewTab()));
- menu.addSeparator();
- }
- menu.addActions(parentWidget->globalActions());
- QAction *action = menu.exec(e->globalPos());
- if (action == copyAnchorAction)
- QApplication::clipboard()->setText(link.toString());
-}
-
-void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
-{
- TRACE_OBJ
- if (e->button() == Qt::XButton1) {
- QTextBrowser::backward();
- return;
- }
-
- if (e->button() == Qt::XButton2) {
- QTextBrowser::forward();
- return;
- }
-
- controlPressed = e->modifiers() & Qt::ControlModifier;
- if ((controlPressed && hasAnchorAt(e->pos())) ||
- (e->button() == Qt::MidButton && hasAnchorAt(e->pos()))) {
- openLinkInNewTab();
- return;
- }
-
- QTextBrowser::mouseReleaseEvent(e);
-}
-
-void HelpViewer::keyPressEvent(QKeyEvent *e)
-{
- TRACE_OBJ
- if ((e->key() == Qt::Key_Home && e->modifiers() != Qt::NoModifier)
- || (e->key() == Qt::Key_End && e->modifiers() != Qt::NoModifier)) {
- QKeyEvent* event = new QKeyEvent(e->type(), e->key(), Qt::NoModifier,
- e->text(), e->isAutoRepeat(), e->count());
- e = event;
- }
- QTextBrowser::keyPressEvent(e);
-}
-
-void HelpViewer::wheelEvent(QWheelEvent *e)
-{
- TRACE_OBJ
- if (e->modifiers() == Qt::CTRL) {
- e->accept();
- (e->delta() > 0) ? zoomIn() : zoomOut();
- } else {
- e->ignore();
- QTextBrowser::wheelEvent(e);
- }
-}
-
-#endif // !defined(QT_NO_WEBKIT)
-
-void HelpViewer::home()
-{
- TRACE_OBJ
- setSource(helpEngine.homePage());
-}
-
-bool HelpViewer::canOpenPage(const QString &url)
-{
- TRACE_OBJ
- return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive)
- || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive)
- || url == QLatin1String("blank");
-}
-
-bool HelpViewer::isLocalUrl(const QUrl &url)
-{
- TRACE_OBJ
- const QString scheme = url.scheme();
+ const QString &scheme = url.scheme();
return scheme.isEmpty()
|| scheme == QLatin1String("file")
|| scheme == QLatin1String("qrc")
@@ -643,5 +71,12 @@ bool HelpViewer::isLocalUrl(const QUrl &url)
|| scheme == QLatin1String("about");
}
+bool AbstractHelpViewer::canOpenPage(const QString &url)
+{
+ TRACE_OBJ
+ return url.endsWith(QLatin1String(".html"), Qt::CaseInsensitive)
+ || url.endsWith(QLatin1String(".htm"), Qt::CaseInsensitive)
+ || url == QLatin1String("blank");
+}
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h
index 4dd8064..fe860fd 100644
--- a/tools/assistant/tools/assistant/helpviewer.h
+++ b/tools/assistant/tools/assistant/helpviewer.h
@@ -38,144 +38,37 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
#ifndef HELPVIEWER_H
#define HELPVIEWER_H
-#include <QtCore/QUrl>
-#include <QtCore/QVariant>
-#include <QtGui/QTextBrowser>
-#include <QtGui/QAction>
+#include <QtCore/QString>
-#if !defined(QT_NO_WEBKIT)
-#include <QWebView>
-#endif
+#include <QtGui/QFont>
QT_BEGIN_NAMESPACE
-class CentralWidget;
-class HelpEngineWrapper;
-
-class QPoint;
-class QString;
-class QKeyEvent;
-class QMouseEvent;
-class QContextMenuEvent;
+class QUrl;
-#if !defined(QT_NO_WEBKIT)
-
-class HelpViewer : public QWebView
+class AbstractHelpViewer
{
- Q_OBJECT
-
public:
- HelpViewer(CentralWidget *parent);
- void setSource(const QUrl &url);
-
- inline QUrl source() const
- { return url(); }
-
- inline QString documentTitle() const
- { return title(); }
-
- inline bool hasSelection() const
- { return !selectedText().isEmpty(); } // ### this is suboptimal
-
- void resetZoom();
- void zoomIn(qreal range = 1);
- void zoomOut(qreal range = 1);
+ AbstractHelpViewer();
+ ~AbstractHelpViewer();
- inline void copy()
- { return triggerPageAction(QWebPage::Copy); }
+ virtual QFont viewerFont() const = 0;
+ virtual void setViewerFont(const QFont &font) = 0;
- inline bool isForwardAvailable() const
- { return pageAction(QWebPage::Forward)->isEnabled(); }
- inline bool isBackwardAvailable() const
- { return pageAction(QWebPage::Back)->isEnabled(); }
- inline bool hasLoadFinished() const
- { return loadFinished; }
- inline qreal zoom() const
- { return textSizeMultiplier(); }
+ virtual void scaleUp() = 0;
+ virtual void scaleDown() = 0;
+
+ virtual void resetScale() = 0;
+ virtual qreal scale() const = 0;
- static bool canOpenPage(const QString &url);
+ static QString PageNotFoundMessage;
static bool isLocalUrl(const QUrl &url);
-
-public Q_SLOTS:
- void home();
- void backward() { back(); }
-
-Q_SIGNALS:
- void copyAvailable(bool enabled);
- void forwardAvailable(bool enabled);
- void backwardAvailable(bool enabled);
- void highlighted(const QString &);
- void sourceChanged(const QUrl &);
-
-protected:
- virtual void wheelEvent(QWheelEvent *);
- void mouseReleaseEvent(QMouseEvent *e);
- void mousePressEvent(QMouseEvent *event);
-
-private Q_SLOTS:
- void actionChanged();
- void setLoadFinished(bool ok);
-
-private:
- CentralWidget* parentWidget;
- bool loadFinished;
- HelpEngineWrapper &helpEngine;
-};
-
-#else
-
-class HelpViewer : public QTextBrowser
-{
- Q_OBJECT
-
-public:
- HelpViewer(CentralWidget *parent);
- void setSource(const QUrl &url);
-
- void resetZoom();
- void zoomIn(int range = 1);
- void zoomOut(int range = 1);
- int zoom() const { return zoomCount; }
- void setZoom(int zoom) { zoomCount = zoom; }
-
- inline bool hasSelection() const
- { return textCursor().hasSelection(); }
-
- bool launchedWithExternalApp(const QUrl &url);
static bool canOpenPage(const QString &url);
- static bool isLocalUrl(const QUrl &url);
-
-public Q_SLOTS:
- void home();
-
-protected:
- void wheelEvent(QWheelEvent *e);
-
-private:
- QVariant loadResource(int type, const QUrl &name);
- void openLinkInNewTab(const QString &link);
- bool hasAnchorAt(const QPoint& pos);
- void contextMenuEvent(QContextMenuEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
- void keyPressEvent(QKeyEvent *e);
-
-private slots:
- void openLinkInNewTab();
-
-private:
- int zoomCount;
- bool controlPressed;
- QString lastAnchor;
- CentralWidget* parentWidget;
- HelpEngineWrapper &helpEngine;
};
-#endif
-
QT_END_NAMESPACE
-#endif
+#endif // HELPVIEWER_H
diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp
new file mode 100644
index 0000000..3aafe67
--- /dev/null
+++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp
@@ -0,0 +1,331 @@
+/****************************************************************************
+**
+** 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 Qt Assistant of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#if defined(QT_NO_WEBKIT)
+
+#include "helpviewer_qtb.h"
+#include "helpviewer_qwv.h"
+
+#include "centralwidget.h"
+#include "helpenginewrapper.h"
+#include "tracer.h"
+
+#include <QtCore/QDir>
+#include <QtCore/QStringBuilder>
+
+#include <QtGui/QContextMenuEvent>
+#include <QtGui/QMenu>
+#include <QtGui/QClipboard>
+#include <QtGui/QApplication>
+#include <QtGui/QMessageBox>
+#include <QtGui/QDesktopServices>
+
+QT_BEGIN_NAMESPACE
+
+HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom)
+ : QTextBrowser(parent)
+ , zoomCount(zoom)
+ , controlPressed(false)
+ , lastAnchor(QString())
+ , parentWidget(parent)
+ , helpEngine(HelpEngineWrapper::instance())
+ , forceFont(false)
+{
+ TRACE_OBJ
+ installEventFilter(this);
+ document()->setDocumentMargin(8);
+
+ QFont font = viewerFont();
+ font.setPointSize(int(font.pointSize() + zoom));
+ setViewerFont(font);
+}
+
+HelpViewer::~HelpViewer()
+{
+ TRACE_OBJ
+}
+
+QFont HelpViewer::viewerFont() const
+{
+ TRACE_OBJ
+ if (HelpEngineWrapper::instance().usesBrowserFont())
+ return helpEngine.browserFont();
+ return qApp->font();
+}
+
+void HelpViewer::setViewerFont(const QFont &newFont)
+{
+ TRACE_OBJ
+ if (font() != newFont) {
+ forceFont = true;
+ setFont(newFont);
+ forceFont = false;
+ }
+}
+
+void HelpViewer::scaleUp()
+{
+ TRACE_OBJ
+ if (zoomCount < 10) {
+ ++zoomCount;
+ forceFont = true;
+ zoomIn();
+ forceFont = false;
+ }
+}
+
+void HelpViewer::scaleDown()
+{
+ TRACE_OBJ
+ if (zoomCount > -5) {
+ --zoomCount;
+ forceFont = true;
+ zoomOut();
+ forceFont = false;
+ }
+}
+
+void HelpViewer::resetScale()
+{
+ TRACE_OBJ
+ if (zoomCount != 0) {
+ forceFont = true;
+ zoomOut(zoomCount);
+ forceFont = false;
+ }
+ zoomCount = 0;
+}
+
+void HelpViewer::setSource(const QUrl &url)
+{
+ TRACE_OBJ
+ bool help = url.toString() == QLatin1String("help");
+ if (url.isValid() && !help) {
+ if (launchedWithExternalApp(url))
+ return;
+
+ QUrl u = helpEngine.findFile(url);
+ if (u.isValid()) {
+ QTextBrowser::setSource(u);
+ return;
+ }
+ }
+
+ if (help) {
+ QTextBrowser::setSource(QUrl(QLatin1String("qthelp://com.trolltech.com."
+ "assistantinternal-1.0.0/assistant/assistant.html")));
+ } else {
+ QTextBrowser::setSource(url);
+ setHtml(PageNotFoundMessage.arg(url.toString()));
+ emit sourceChanged(url);
+ }
+}
+
+bool HelpViewer::launchedWithExternalApp(const QUrl &url)
+{
+ TRACE_OBJ
+ const bool canOpen = canOpenPage(url.path());
+ if (!isLocalUrl(url) || !canOpen) {
+ bool launched = false;
+ if (!canOpen && url.scheme() == QLatin1String("qthelp")) {
+ const QString& path = url.path();
+ const int lastDash = path.lastIndexOf(QChar('/'));
+ QString fileName = QDir::tempPath() + QDir::separator();
+ if (lastDash < 0)
+ fileName += path;
+ else
+ fileName += path.mid(lastDash + 1, path.length());
+
+ QFile tmpFile(QDir::cleanPath(fileName));
+ if (tmpFile.open(QIODevice::ReadWrite)) {
+ tmpFile.write(helpEngine.fileData(url));
+ tmpFile.close();
+ }
+ launched = QDesktopServices::openUrl(QUrl(tmpFile.fileName()));
+ } else {
+ launched = QDesktopServices::openUrl(url);
+ }
+
+ if (!launched) {
+ QMessageBox::information(this, tr("Help"),
+ tr("Unable to launch external application.\n"), tr("OK"));
+ }
+ return true;
+ }
+ return false;
+}
+
+QVariant HelpViewer::loadResource(int type, const QUrl &name)
+{
+ TRACE_OBJ
+ QByteArray ba;
+ if (type < 4) {
+ ba = helpEngine.fileData(name);
+ if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) {
+ QImage image;
+ image.loadFromData(ba, "svg");
+ if (!image.isNull())
+ return image;
+ }
+ }
+ return ba;
+}
+
+void HelpViewer::openLinkInNewTab()
+{
+ TRACE_OBJ
+ if(lastAnchor.isEmpty())
+ return;
+
+ parentWidget->setSourceInNewTab(QUrl(lastAnchor));
+ lastAnchor.clear();
+}
+
+void HelpViewer::openLinkInNewTab(const QString &link)
+{
+ TRACE_OBJ
+ lastAnchor = link;
+ openLinkInNewTab();
+}
+
+bool HelpViewer::hasAnchorAt(const QPoint& pos)
+{
+ TRACE_OBJ
+ lastAnchor = anchorAt(pos);
+ if (lastAnchor.isEmpty())
+ return false;
+
+ lastAnchor = source().resolved(lastAnchor).toString();
+ if (lastAnchor.at(0) == QLatin1Char('#')) {
+ QString src = source().toString();
+ int hsh = src.indexOf(QLatin1Char('#'));
+ lastAnchor = (hsh>=0 ? src.left(hsh) : src) + lastAnchor;
+ }
+
+ return true;
+}
+
+void HelpViewer::contextMenuEvent(QContextMenuEvent *e)
+{
+ TRACE_OBJ
+ QMenu menu(QLatin1String(""), 0);
+
+ QUrl link;
+ QAction *copyAnchorAction = 0;
+ if (hasAnchorAt(e->pos())) {
+ link = anchorAt(e->pos());
+ if (link.isRelative())
+ link = source().resolved(link);
+ copyAnchorAction = menu.addAction(tr("Copy &Link Location"));
+ copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid());
+
+ menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), this,
+ SLOT(openLinkInNewTab()));
+ menu.addSeparator();
+ }
+ menu.addActions(parentWidget->globalActions());
+ QAction *action = menu.exec(e->globalPos());
+ if (action == copyAnchorAction)
+ QApplication::clipboard()->setText(link.toString());
+}
+
+void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
+{
+ TRACE_OBJ
+ if (e->button() == Qt::XButton1) {
+ QTextBrowser::backward();
+ return;
+ }
+
+ if (e->button() == Qt::XButton2) {
+ QTextBrowser::forward();
+ return;
+ }
+
+ controlPressed = e->modifiers() & Qt::ControlModifier;
+ if ((controlPressed && hasAnchorAt(e->pos())) ||
+ (e->button() == Qt::MidButton && hasAnchorAt(e->pos()))) {
+ openLinkInNewTab();
+ return;
+ }
+
+ QTextBrowser::mouseReleaseEvent(e);
+}
+
+void HelpViewer::keyPressEvent(QKeyEvent *e)
+{
+ TRACE_OBJ
+ if ((e->key() == Qt::Key_Home && e->modifiers() != Qt::NoModifier)
+ || (e->key() == Qt::Key_End && e->modifiers() != Qt::NoModifier)) {
+ QKeyEvent* event = new QKeyEvent(e->type(), e->key(), Qt::NoModifier,
+ e->text(), e->isAutoRepeat(), e->count());
+ e = event;
+ }
+ QTextBrowser::keyPressEvent(e);
+}
+
+void HelpViewer::home()
+{
+ TRACE_OBJ
+ setSource(helpEngine.homePage());
+}
+
+void HelpViewer::wheelEvent(QWheelEvent *e)
+{
+ TRACE_OBJ
+ if (e->modifiers() == Qt::ControlModifier) {
+ e->accept();
+ e->delta() > 0 ? scaleUp() : scaleDown();
+ } else {
+ QTextBrowser::wheelEvent(e);
+ }
+}
+
+bool HelpViewer::eventFilter(QObject *obj, QEvent *event)
+{
+ TRACE_OBJ
+ if (event->type() == QEvent::FontChange && !forceFont)
+ return true;
+ return QTextBrowser::eventFilter(obj, 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
new file mode 100644
index 0000000..e927b34
--- /dev/null
+++ b/tools/assistant/tools/assistant/helpviewer_qtb.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** 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 Qt Assistant of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#if defined(QT_NO_WEBKIT)
+
+#ifndef HELPVIEWERQTB_H
+#define HELPVIEWERQTB_H
+
+#include "helpviewer.h"
+
+#include <QtCore/QUrl>
+#include <QtCore/QVariant>
+
+#include <QtGui/QTextBrowser>
+
+QT_BEGIN_NAMESPACE
+
+class CentralWidget;
+class HelpEngineWrapper;
+class QContextMenuEvent;
+class QKeyEvent;
+class QMouseEvent;
+
+class HelpViewer : public QTextBrowser, public AbstractHelpViewer
+{
+ Q_OBJECT
+
+public:
+ HelpViewer(CentralWidget *parent, qreal zoom = 0.0);
+ ~HelpViewer();
+
+ QFont viewerFont() const;
+ void setViewerFont(const QFont &font);
+
+ void scaleUp();
+ void scaleDown();
+ void resetScale();
+ qreal scale() const { return zoomCount; }
+
+ void setSource(const QUrl &url);
+
+ inline bool hasSelection() const
+ { return textCursor().hasSelection(); }
+
+ bool launchedWithExternalApp(const QUrl &url);
+
+public Q_SLOTS:
+ void home();
+
+protected:
+ void wheelEvent(QWheelEvent *e);
+ bool eventFilter(QObject *obj, QEvent *event);
+
+private:
+ QVariant loadResource(int type, const QUrl &name);
+ void openLinkInNewTab(const QString &link);
+ bool hasAnchorAt(const QPoint& pos);
+ void contextMenuEvent(QContextMenuEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+ void keyPressEvent(QKeyEvent *e);
+
+private slots:
+ void openLinkInNewTab();
+
+private:
+ int zoomCount;
+ bool controlPressed;
+ QString lastAnchor;
+ CentralWidget* parentWidget;
+ HelpEngineWrapper &helpEngine;
+
+ bool forceFont;
+};
+
+QT_END_NAMESPACE
+
+#endif // HELPVIEWERQTB_H
+
+#endif // QT_NO_WEBKIT
diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp
new file mode 100644
index 0000000..4857e00
--- /dev/null
+++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp
@@ -0,0 +1,413 @@
+/****************************************************************************
+**
+** 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 Qt Assistant of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#if !defined(QT_NO_WEBKIT)
+
+#include "helpviewer_qwv.h"
+
+#include "centralwidget.h"
+#include "helpenginewrapper.h"
+#include "tracer.h"
+
+#include <QtCore/QFileInfo>
+#include <QtCore/QString>
+#include <QtCore/QStringBuilder>
+#include <QtCore/QTemporaryFile>
+#include <QtCore/QTimer>
+
+#include <QtGui/QDesktopServices>
+#include <QtGui/QWheelEvent>
+
+#include <QtNetwork/QNetworkAccessManager>
+#include <QtNetwork/QNetworkReply>
+#include <QtNetwork/QNetworkRequest>
+
+QT_BEGIN_NAMESPACE
+
+class HelpNetworkReply : public QNetworkReply
+{
+public:
+ HelpNetworkReply(const QNetworkRequest &request, const QByteArray &fileData,
+ const QString &mimeType);
+
+ virtual void abort();
+
+ virtual qint64 bytesAvailable() const
+ { return data.length() + QNetworkReply::bytesAvailable(); }
+
+protected:
+ virtual qint64 readData(char *data, qint64 maxlen);
+
+private:
+ QByteArray data;
+ qint64 origLen;
+};
+
+HelpNetworkReply::HelpNetworkReply(const QNetworkRequest &request,
+ const QByteArray &fileData, const QString& mimeType)
+ : data(fileData), origLen(fileData.length())
+{
+ TRACE_OBJ
+ setRequest(request);
+ setOpenMode(QIODevice::ReadOnly);
+
+ setHeader(QNetworkRequest::ContentTypeHeader, mimeType);
+ setHeader(QNetworkRequest::ContentLengthHeader, QByteArray::number(origLen));
+ QTimer::singleShot(0, this, SIGNAL(metaDataChanged()));
+ QTimer::singleShot(0, this, SIGNAL(readyRead()));
+}
+
+void HelpNetworkReply::abort()
+{
+ TRACE_OBJ
+}
+
+qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen)
+{
+ TRACE_OBJ
+ qint64 len = qMin(qint64(data.length()), maxlen);
+ if (len) {
+ qMemCopy(buffer, data.constData(), len);
+ data.remove(0, len);
+ }
+ if (!data.length())
+ QTimer::singleShot(0, this, SIGNAL(finished()));
+ return len;
+}
+
+class HelpNetworkAccessManager : public QNetworkAccessManager
+{
+public:
+ HelpNetworkAccessManager(QObject *parent);
+
+protected:
+ virtual QNetworkReply *createRequest(Operation op,
+ const QNetworkRequest &request, QIODevice *outgoingData = 0);
+};
+
+HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent)
+ : QNetworkAccessManager(parent)
+{
+ TRACE_OBJ
+}
+
+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");
+ }
+
+ 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);
+}
+
+class HelpPage : public QWebPage
+{
+public:
+ HelpPage(CentralWidget *central, QObject *parent);
+
+protected:
+ virtual QWebPage *createWindow(QWebPage::WebWindowType);
+ virtual void triggerAction(WebAction action, bool checked = false);
+
+ virtual bool acceptNavigationRequest(QWebFrame *frame,
+ const QNetworkRequest &request, NavigationType type);
+
+private:
+ CentralWidget *centralWidget;
+ bool closeNewTabIfNeeded;
+
+ friend class HelpViewer;
+ Qt::MouseButtons m_pressedButtons;
+ Qt::KeyboardModifiers m_keyboardModifiers;
+};
+
+HelpPage::HelpPage(CentralWidget *central, QObject *parent)
+ : QWebPage(parent)
+ , centralWidget(central)
+ , closeNewTabIfNeeded(false)
+ , m_pressedButtons(Qt::NoButton)
+ , m_keyboardModifiers(Qt::NoModifier)
+{
+ TRACE_OBJ
+}
+
+QWebPage *HelpPage::createWindow(QWebPage::WebWindowType)
+{
+ TRACE_OBJ
+ HelpPage* newPage = static_cast<HelpPage*>(centralWidget->newEmptyTab()->page());
+ if (newPage)
+ newPage->closeNewTabIfNeeded = closeNewTabIfNeeded;
+ closeNewTabIfNeeded = false;
+ return newPage;
+}
+
+void HelpPage::triggerAction(WebAction action, bool checked)
+{
+ TRACE_OBJ
+ switch (action) {
+ case OpenLinkInNewWindow:
+ closeNewTabIfNeeded = true;
+ default: // fall through
+ QWebPage::triggerAction(action, checked);
+ break;
+ }
+}
+
+bool HelpPage::acceptNavigationRequest(QWebFrame *,
+ const QNetworkRequest &request, QWebPage::NavigationType type)
+{
+ TRACE_OBJ
+ const QUrl &url = request.url();
+ const bool closeNewTab = closeNewTabIfNeeded;
+ closeNewTabIfNeeded = false;
+
+ if (AbstractHelpViewer::isLocalUrl(url)) {
+ const QString& path = url.path();
+ if (!AbstractHelpViewer::canOpenPage(path)) {
+ QTemporaryFile tmpTmpFile;
+ if (!tmpTmpFile.open())
+ return false;
+ const QString &extension = QFileInfo(path).completeSuffix();
+ QFile actualTmpFile(tmpTmpFile.fileName() % QLatin1String(".")
+ % extension);
+ if (actualTmpFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
+ actualTmpFile.write(HelpEngineWrapper::instance().fileData(url));
+ actualTmpFile.close();
+ QDesktopServices::openUrl(QUrl(actualTmpFile.fileName()));
+ }
+
+ if (closeNewTab)
+ QMetaObject::invokeMethod(CentralWidget::instance(), "closeTab");
+ return false;
+ }
+
+ if (type == QWebPage::NavigationTypeLinkClicked
+ && (m_keyboardModifiers & Qt::ControlModifier
+ || m_pressedButtons == Qt::MidButton)) {
+ HelpViewer* viewer = centralWidget->newEmptyTab();
+ if (viewer)
+ CentralWidget::instance()->setSource(url);
+ m_pressedButtons = Qt::NoButton;
+ m_keyboardModifiers = Qt::NoModifier;
+ return false;
+ }
+ return true;
+ }
+
+ QDesktopServices::openUrl(url);
+ return false;
+}
+
+// -- HelpViewer
+
+HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom)
+ : QWebView(parent)
+ , parentWidget(parent)
+ , loadFinished(false)
+ , helpEngine(HelpEngineWrapper::instance())
+{
+ TRACE_OBJ
+ setAcceptDrops(false);
+
+ setPage(new HelpPage(parent, this));
+
+ page()->setNetworkAccessManager(new HelpNetworkAccessManager(this));
+
+ QAction* action = pageAction(QWebPage::OpenLinkInNewWindow);
+ action->setText(tr("Open Link in New Tab"));
+ if (!parent)
+ action->setVisible(false);
+
+ pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false);
+ pageAction(QWebPage::DownloadImageToDisk)->setVisible(false);
+ pageAction(QWebPage::OpenImageInNewWindow)->setVisible(false);
+
+ connect(pageAction(QWebPage::Copy), SIGNAL(changed()), this,
+ SLOT(actionChanged()));
+ connect(pageAction(QWebPage::Back), SIGNAL(changed()), this,
+ SLOT(actionChanged()));
+ connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this,
+ SLOT(actionChanged()));
+ connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this,
+ SIGNAL(highlighted(QString)));
+ connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl)));
+ connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
+
+ setFont(viewerFont());
+ setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
+}
+
+HelpViewer::~HelpViewer()
+{
+ TRACE_OBJ
+}
+
+QFont HelpViewer::viewerFont() const
+{
+ TRACE_OBJ
+ if (helpEngine.usesBrowserFont())
+ return helpEngine.browserFont();
+
+ QWebSettings *webSettings = QWebSettings::globalSettings();
+ return QFont(webSettings->fontFamily(QWebSettings::StandardFont),
+ webSettings->fontSize(QWebSettings::DefaultFontSize));
+}
+
+void HelpViewer::setViewerFont(const QFont &font)
+{
+ TRACE_OBJ
+ QWebSettings *webSettings = settings();
+ webSettings->setFontFamily(QWebSettings::StandardFont, font.family());
+ webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
+}
+
+void HelpViewer::scaleUp()
+{
+ TRACE_OBJ
+ setTextSizeMultiplier(textSizeMultiplier() + 0.1);
+}
+
+void HelpViewer::scaleDown()
+{
+ TRACE_OBJ
+ setTextSizeMultiplier(qMax(0.0, textSizeMultiplier() - 0.1));
+}
+
+void HelpViewer::resetScale()
+{
+ TRACE_OBJ
+ setTextSizeMultiplier(1.0);
+}
+
+void HelpViewer::setSource(const QUrl &url)
+{
+ TRACE_OBJ
+ loadFinished = false;
+ if (url.toString() == QLatin1String("help")) {
+ load(QUrl(QLatin1String("qthelp://com.trolltech.com."
+ "assistantinternal-1.0.0/assistant/assistant.html")));
+ } else {
+ load(url);
+ }
+}
+
+void HelpViewer::home()
+{
+ TRACE_OBJ
+ setSource(helpEngine.homePage());
+}
+
+void HelpViewer::wheelEvent(QWheelEvent *e)
+{
+ TRACE_OBJ
+ if (e->modifiers()& Qt::ControlModifier) {
+ e->accept();
+ e->delta() > 0 ? scaleUp() : scaleDown();
+ } else {
+ QWebView::wheelEvent(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);
+ return;
+ }
+
+ QWebView::mouseReleaseEvent(e);
+}
+
+void HelpViewer::actionChanged()
+{
+ TRACE_OBJ
+ QAction *a = qobject_cast<QAction *>(sender());
+ if (a == pageAction(QWebPage::Copy))
+ emit copyAvailable(a->isEnabled());
+ else if (a == pageAction(QWebPage::Back))
+ emit backwardAvailable(a->isEnabled());
+ else if (a == pageAction(QWebPage::Forward))
+ emit forwardAvailable(a->isEnabled());
+}
+
+void HelpViewer::mousePressEvent(QMouseEvent *event)
+{
+ TRACE_OBJ
+ HelpPage *currentPage = static_cast<HelpPage*>(page());
+ if (currentPage) {
+ currentPage->m_pressedButtons = event->buttons();
+ currentPage->m_keyboardModifiers = event->modifiers();
+ }
+ QWebView::mousePressEvent(event);
+}
+
+void HelpViewer::setLoadFinished(bool ok)
+{
+ TRACE_OBJ
+ loadFinished = ok;
+ emit sourceChanged(url());
+}
+
+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
new file mode 100644
index 0000000..3f2e537
--- /dev/null
+++ b/tools/assistant/tools/assistant/helpviewer_qwv.h
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** 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 Qt Assistant of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#if !defined(QT_NO_WEBKIT)
+
+#ifndef HELPVIEWERQWV_H
+#define HELPVIEWERQWV_H
+
+#include "helpviewer.h"
+
+#include <QtGui/QAction>
+#include <QtWebKit/QWebView>
+
+QT_BEGIN_NAMESPACE
+
+class CentralWidget;
+class HelpEngineWrapper;
+class QMouseEvent;
+
+class HelpViewer : public QWebView, public AbstractHelpViewer
+{
+ Q_OBJECT
+
+public:
+ HelpViewer(CentralWidget *parent, qreal zoom = 0.0);
+ ~HelpViewer();
+
+ QFont viewerFont() const;
+ void setViewerFont(const QFont &font);
+
+ void scaleUp();
+ void scaleDown();
+ void resetScale();
+ qreal scale() const { return textSizeMultiplier(); }
+
+ void setSource(const QUrl &url);
+ inline QUrl source() const { return url(); }
+
+ inline QString documentTitle() const
+ { return title(); }
+
+ inline bool hasSelection() const
+ { return !selectedText().isEmpty(); } // ### this is suboptimal
+
+ inline void copy()
+ { return triggerPageAction(QWebPage::Copy); }
+
+ inline bool isForwardAvailable() const
+ { return pageAction(QWebPage::Forward)->isEnabled(); }
+ inline bool isBackwardAvailable() const
+ { return pageAction(QWebPage::Back)->isEnabled(); }
+ inline bool hasLoadFinished() const
+ { return loadFinished; }
+
+public Q_SLOTS:
+ void home();
+ void backward() { back(); }
+
+Q_SIGNALS:
+ void copyAvailable(bool enabled);
+ void forwardAvailable(bool enabled);
+ void backwardAvailable(bool enabled);
+ void highlighted(const QString &);
+ void sourceChanged(const QUrl &);
+
+protected:
+ virtual void wheelEvent(QWheelEvent *);
+ void mouseReleaseEvent(QMouseEvent *e);
+ void mousePressEvent(QMouseEvent *event);
+
+private Q_SLOTS:
+ void actionChanged();
+ void setLoadFinished(bool ok);
+
+private:
+ CentralWidget* parentWidget;
+ bool loadFinished;
+ HelpEngineWrapper &helpEngine;
+};
+
+QT_END_NAMESPACE
+
+#endif // HELPVIEWERQWV_H
+
+#endif // !QT_NO_WEBKIT
diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp
index 82242e5..63ddbe4 100644
--- a/tools/assistant/tools/assistant/indexwindow.cpp
+++ b/tools/assistant/tools/assistant/indexwindow.cpp
@@ -219,7 +219,7 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index)
return;
}
- if (!HelpViewer::canOpenPage(url.path()))
+ if (!AbstractHelpViewer::canOpenPage(url.path()))
CentralWidget::instance()->setSource(url);
else
CentralWidget::instance()->setSourceInNewTab(url);
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index 2ff6b5e..8096218 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -44,7 +44,6 @@
#include "bookmarkmanager.h"
#include "centralwidget.h"
-#include "helpviewer.h"
#include "indexwindow.h"
#include "topicchooser.h"
#include "contentwindow.h"
@@ -355,8 +354,6 @@ void MainWindow::lookForNewQtDocumentation()
void MainWindow::qtDocumentationInstalled(bool newDocsInstalled)
{
TRACE_OBJ
- if (newDocsInstalled)
- HelpEngineWrapper::instance().setupData();
statusBar()->clearMessage();
checkInitState();
}
@@ -384,6 +381,7 @@ void MainWindow::checkInitState()
}
emit initDone();
}
+ HelpEngineWrapper::instance().initialDocSetupDone();
}
void MainWindow::insertLastPages()
@@ -760,12 +758,10 @@ void MainWindow::showPreferences()
{
TRACE_OBJ
PreferencesDialog dia(this);
-
connect(&dia, SIGNAL(updateApplicationFont()), this,
SLOT(updateApplicationFont()));
connect(&dia, SIGNAL(updateBrowserFont()), m_centralWidget,
SLOT(updateBrowserFont()));
-
dia.showDialog();
}
@@ -970,7 +966,9 @@ void MainWindow::updateApplicationFont()
if (helpEngine.usesAppFont())
font = helpEngine.appFont();
- qApp->setFont(font, "QWidget");
+ const QWidgetList &widgets = qApp->allWidgets();
+ foreach (QWidget* widget, widgets)
+ widget->setFont(font);
}
void MainWindow::setupFilterCombo()
diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp
index f0ef054..0e1d719 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.cpp
+++ b/tools/assistant/tools/assistant/preferencesdialog.cpp
@@ -38,26 +38,24 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "tracer.h"
-
#include "preferencesdialog.h"
+
+#include "centralwidget.h"
#include "filternamedialog.h"
-#include "installdialog.h"
#include "fontpanel.h"
-#include "centralwidget.h"
-#include "aboutdialog.h"
#include "helpenginewrapper.h"
+#include "installdialog.h"
+#include "tracer.h"
#include <QtCore/QtAlgorithms>
#include <QtCore/QFileSystemWatcher>
-#include <QtGui/QHeaderView>
+#include <QtGui/QDesktopWidget>
#include <QtGui/QFileDialog>
-#include <QtGui/QMessageBox>
-#include <QtGui/QMenu>
#include <QtGui/QFontDatabase>
-#include <QtGui/QApplication>
-#include <QtGui/QDesktopWidget>
+#include <QtGui/QHeaderView>
+#include <QtGui/QMenu>
+#include <QtGui/QMessageBox>
#include <QtHelp/QHelpEngineCore>
@@ -115,6 +113,9 @@ PreferencesDialog::PreferencesDialog(QWidget *parent)
updateFontSettingsPage();
updateOptionsPage();
+
+ if (helpEngine.usesAppFont())
+ setFont(helpEngine.appFont());
}
PreferencesDialog::~PreferencesDialog()
@@ -124,16 +125,13 @@ PreferencesDialog::~PreferencesDialog()
helpEngine.setAppFont(m_appFontPanel->selectedFont());
helpEngine.setUseAppFont(m_appFontPanel->isChecked());
helpEngine.setAppWritingSystem(m_appFontPanel->writingSystem());
+ emit updateApplicationFont();
}
if (m_browserFontChanged) {
helpEngine.setBrowserFont(m_browserFontPanel->selectedFont());
helpEngine.setUseBrowserFont(m_browserFontPanel->isChecked());
helpEngine.setBrowserWritingSystem(m_browserFontPanel->writingSystem());
- }
-
- if (m_appFontChanged || m_browserFontChanged) {
- emit updateApplicationFont();
emit updateBrowserFont();
}
diff --git a/tools/designer/src/components/formeditor/formeditor.pri b/tools/designer/src/components/formeditor/formeditor.pri
index bbe96d5..b1a9318 100644
--- a/tools/designer/src/components/formeditor/formeditor.pri
+++ b/tools/designer/src/components/formeditor/formeditor.pri
@@ -8,6 +8,7 @@ FORMS += $$PWD/deviceprofiledialog.ui \
$$PWD/templateoptionspage.ui
HEADERS += $$PWD/qdesigner_resource.h \
+ $$PWD/qdesignerundostack.h \
$$PWD/formwindow.h \
$$PWD/formwindow_widgetstack.h \
$$PWD/formwindow_dnditem.h \
@@ -41,6 +42,7 @@ HEADERS += $$PWD/qdesigner_resource.h \
$$PWD/templateoptionspage.h
SOURCES += $$PWD/qdesigner_resource.cpp \
+ $$PWD/qdesignerundostack.cpp \
$$PWD/formwindow.cpp \
$$PWD/formwindow_widgetstack.cpp \
$$PWD/formwindow_dnditem.cpp \
diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp
index 3a7cd83..631ca7c 100644
--- a/tools/designer/src/components/formeditor/formwindow.cpp
+++ b/tools/designer/src/components/formeditor/formwindow.cpp
@@ -399,8 +399,7 @@ void FormWindow::setCursorToAll(const QCursor &c, QWidget *start)
void FormWindow::init()
{
if (FormWindowManager *manager = qobject_cast<FormWindowManager*> (core()->formWindowManager())) {
- m_commandHistory = new QUndoStack(this);
- manager->undoGroup()->addStack(m_commandHistory);
+ manager->undoGroup()->addStack(m_undoStack.qundoStack());
}
m_blockSelectionChanged = false;
@@ -429,9 +428,8 @@ void FormWindow::init()
m_mainContainer = 0;
m_currentWidget = 0;
- connect(m_commandHistory, SIGNAL(indexChanged(int)), this, SLOT(updateDirty()));
- connect(m_commandHistory, SIGNAL(indexChanged(int)), this, SIGNAL(changed()));
- connect(m_commandHistory, SIGNAL(indexChanged(int)), this, SLOT(checkSelection()));
+ connect(&m_undoStack, SIGNAL(changed()), this, SIGNAL(changed()));
+ connect(&m_undoStack, SIGNAL(changed()), this, SLOT(checkSelection()));
core()->metaDataBase()->add(this);
@@ -1227,14 +1225,14 @@ void FormWindow::insertWidget(QWidget *w, const QRect &rect, QWidget *container,
if (w->parentWidget() != container) {
ReparentWidgetCommand *cmd = new ReparentWidgetCommand(this);
cmd->init(w, container);
- m_commandHistory->push(cmd);
+ m_undoStack.push(cmd);
}
- m_commandHistory->push(geom_cmd);
+ m_undoStack.push(geom_cmd);
InsertWidgetCommand *cmd = new InsertWidgetCommand(this);
cmd->init(w, already_in_form);
- m_commandHistory->push(cmd);
+ m_undoStack.push(cmd);
endCommand();
@@ -1277,12 +1275,10 @@ void FormWindow::resizeWidget(QWidget *widget, const QRect &geometry)
Q_ASSERT(isDescendant(this, widget));
QRect r = geometry;
- if (m_lastIndex > m_commandHistory->index())
- m_lastIndex = -1;
SetPropertyCommand *cmd = new SetPropertyCommand(this);
cmd->init(widget, QLatin1String("geometry"), r);
cmd->setText(tr("Resize"));
- m_commandHistory->push(cmd);
+ m_undoStack.push(cmd);
}
void FormWindow::raiseChildSelections(QWidget *w)
@@ -1428,26 +1424,117 @@ int FormWindow::calcValue(int val, bool forward, bool snap, int snapOffset) cons
return (forward ? val + 1 : val - 1);
}
-QRect FormWindow::applyValue(const QRect &rect, int val, int key, bool size) const
+// ArrowKeyOperation: Stores a keyboard move or resize (Shift pressed)
+// operation.
+struct ArrowKeyOperation {
+ ArrowKeyOperation() : resize(false), distance(0), arrowKey(Qt::Key_Left) {}
+
+ QRect apply(const QRect &in) const;
+
+ bool resize; // Resize: Shift-Key->drag bottom/right corner, else just move
+ int distance;
+ int arrowKey;
+};
+
+QRect ArrowKeyOperation::apply(const QRect &rect) const
{
QRect r = rect;
- if (size) {
- if (key == Qt::Key_Left || key == Qt::Key_Right)
- r.setWidth(val);
+ if (resize) {
+ if (arrowKey == Qt::Key_Left || arrowKey == Qt::Key_Right)
+ r.setWidth(r.width() + distance);
else
- r.setHeight(val);
+ r.setHeight(r.height() + distance);
} else {
- if (key == Qt::Key_Left || key == Qt::Key_Right)
- r.moveLeft(val);
+ if (arrowKey == Qt::Key_Left || arrowKey == Qt::Key_Right)
+ r.moveLeft(r.x() + distance);
else
- r.moveTop(val);
+ r.moveTop(r.y() + distance);
}
return r;
}
+QDebug operator<<(QDebug in, const ArrowKeyOperation &op)
+{
+ in.nospace() << "Resize=" << op.resize << " dist=" << op.distance << " Key=" << op.arrowKey << ' ';
+ return in;
+}
+
+// ArrowKeyPropertyHelper: Applies a struct ArrowKeyOperation
+// (stored as new value) to a list of widgets using to calculate the
+// changed geometry of the widget in setValue(). Thus, the 'newValue'
+// of the property command is the relative move distance, which is the same
+// for all widgets (although resulting in different geometries for the widgets).
+// The command merging can then work as it would when applying the same text
+// to all QLabels.
+
+class ArrowKeyPropertyHelper : public PropertyHelper {
+public:
+ ArrowKeyPropertyHelper(QObject* o, SpecialProperty sp,
+ QDesignerPropertySheetExtension *s, int i) :
+ PropertyHelper(o, sp, s, i) {}
+
+ virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask);
+};
+
+PropertyHelper::Value ArrowKeyPropertyHelper::setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask)
+{
+ // Apply operation to obtain the new geometry value.
+ QWidget *w = qobject_cast<QWidget*>(object());
+ const ArrowKeyOperation operation = qvariant_cast<ArrowKeyOperation>(value);
+ const QRect newGeom = operation.apply(w->geometry());
+ return PropertyHelper::setValue(fw, QVariant(newGeom), changed, subPropertyMask);
+}
+
+// ArrowKeyPropertyCommand: Helper factory overwritten to create
+// ArrowKeyPropertyHelper and a merge operation that merges values of
+// the same direction.
+class ArrowKeyPropertyCommand: public SetPropertyCommand {
+public:
+ explicit ArrowKeyPropertyCommand(QDesignerFormWindowInterface *fw,
+ QUndoCommand *p = 0);
+
+ void init(QWidgetList &l, const ArrowKeyOperation &op);
+
+protected:
+ virtual PropertyHelper *createPropertyHelper(QObject *o, SpecialProperty sp,
+ QDesignerPropertySheetExtension *s, int i) const
+ { return new ArrowKeyPropertyHelper(o, sp, s, i); }
+ virtual QVariant mergeValue(const QVariant &newValue);
+};
+
+ArrowKeyPropertyCommand::ArrowKeyPropertyCommand(QDesignerFormWindowInterface *fw,
+ QUndoCommand *p) :
+ SetPropertyCommand(fw, p)
+{
+ static const int mid = qRegisterMetaType<qdesigner_internal::ArrowKeyOperation>();
+ Q_UNUSED(mid)
+}
+
+void ArrowKeyPropertyCommand::init(QWidgetList &l, const ArrowKeyOperation &op)
+{
+ QObjectList ol;
+ foreach(QWidget *w, l)
+ ol.push_back(w);
+ SetPropertyCommand::init(ol, QLatin1String("geometry"), qVariantFromValue(op));
+
+ setText(op.resize ? FormWindow::tr("Key Resize") : FormWindow::tr("Key Move"));
+}
+
+QVariant ArrowKeyPropertyCommand::mergeValue(const QVariant &newMergeValue)
+{
+ // Merge move operations of the same arrow key
+ if (!qVariantCanConvert<ArrowKeyOperation>(newMergeValue))
+ return QVariant();
+ ArrowKeyOperation mergedOperation = qvariant_cast<ArrowKeyOperation>(newValue());
+ const ArrowKeyOperation newMergeOperation = qvariant_cast<ArrowKeyOperation>(newMergeValue);
+ if (mergedOperation.resize != newMergeOperation.resize || mergedOperation.arrowKey != newMergeOperation.arrowKey)
+ return QVariant();
+ mergedOperation.distance += newMergeOperation.distance;
+ return qVariantFromValue(mergedOperation);
+}
+
void FormWindow::handleArrowKeyEvent(int key, Qt::KeyboardModifiers modifiers)
{
- bool startMacro = false;
const QDesignerFormWindowCursorInterface *c = cursor();
if (!c->hasSelection())
return;
@@ -1480,57 +1567,14 @@ void FormWindow::handleArrowKeyEvent(int key, Qt::KeyboardModifiers modifiers)
const int newValue = calcValue(oldValue, forward, snap, snapPoint);
- const int offset = newValue - oldValue;
-
- const int selCount = selection.count();
- // check if selection is the same as last time
- if (selCount != m_moveSelection.count() ||
- m_lastUndoIndex != m_commandHistory->index()) {
- m_moveSelection.clear();
- startMacro = true;
- } else {
- for (int index = 0; index < selCount; ++index) {
- if (m_moveSelection[index]->object() != selection.at(index)) {
- m_moveSelection.clear();
- startMacro = true;
- break;
- }
- }
- }
-
- if (startMacro)
- beginCommand(tr("Key Move"));
-
- for (int index = 0; index < selCount; ++index) {
- QWidget *w = selection.at(index);
- const QRect oldGeom = w->geometry();
- const QRect geom = applyValue(oldGeom, getValue(oldGeom, key, size) + offset, key, size);
-
- SetPropertyCommand *cmd = 0;
-
- if (m_moveSelection.count() > index)
- cmd = m_moveSelection[index];
-
- if (!cmd) {
- cmd = new SetPropertyCommand(this);
- cmd->init(w, QLatin1String("geometry"), geom);
- cmd->setText(tr("Key Move"));
- m_commandHistory->push(cmd);
+ ArrowKeyOperation operation;
+ operation.resize = modifiers & Qt::ShiftModifier;
+ operation.distance = newValue - oldValue;
+ operation.arrowKey = key;
- if (m_moveSelection.count() > index)
- m_moveSelection.replace(index, cmd);
- else
- m_moveSelection.append(cmd);
- } else {
- cmd->setNewValue(geom);
- cmd->redo();
- }
- }
-
- if (startMacro) {
- endCommand();
- m_lastUndoIndex = m_commandHistory->index();
- }
+ ArrowKeyPropertyCommand *cmd = new ArrowKeyPropertyCommand(this);
+ cmd->init(selection, operation);
+ m_undoStack.push(cmd);
}
bool FormWindow::handleKeyReleaseEvent(QWidget *, QWidget *, QKeyEvent *e)
@@ -1809,7 +1853,7 @@ void FormWindow::paste(PasteMode pasteMode)
foreach (QWidget *w, clipboard.m_widgets) {
InsertWidgetCommand *cmd = new InsertWidgetCommand(this);
cmd->init(w);
- m_commandHistory->push(cmd);
+ m_undoStack.push(cmd);
selectWidget(w);
}
}
@@ -1819,7 +1863,7 @@ void FormWindow::paste(PasteMode pasteMode)
ensureUniqueObjectName(a);
AddActionCommand *cmd = new AddActionCommand(this);
cmd->init(a);
- m_commandHistory->push(cmd);
+ m_undoStack.push(cmd);
}
endCommand();
} while (false);
@@ -1955,14 +1999,12 @@ void FormWindow::breakLayout(QWidget *w)
void FormWindow::beginCommand(const QString &description)
{
- if (m_lastIndex > m_commandHistory->index())
- m_lastIndex = -1;
- m_commandHistory->beginMacro(description);
+ m_undoStack.beginMacro(description);
}
void FormWindow::endCommand()
{
- m_commandHistory->endMacro();
+ m_undoStack.endMacro();
}
void FormWindow::raiseWidgets()
@@ -1977,7 +2019,7 @@ void FormWindow::raiseWidgets()
foreach (QWidget *widget, widgets) {
RaiseWidgetCommand *cmd = new RaiseWidgetCommand(this);
cmd->init(widget);
- m_commandHistory->push(cmd);
+ m_undoStack.push(cmd);
}
endCommand();
}
@@ -1994,7 +2036,7 @@ void FormWindow::lowerWidgets()
foreach (QWidget *widget, widgets) {
LowerWidgetCommand *cmd = new LowerWidgetCommand(this);
cmd->init(widget);
- m_commandHistory->push(cmd);
+ m_undoStack.push(cmd);
}
endCommand();
}
@@ -2375,20 +2417,12 @@ FormWindow *FormWindow::findFormWindow(QWidget *w)
bool FormWindow::isDirty() const
{
- return m_dirty;
+ return m_undoStack.isDirty();
}
void FormWindow::setDirty(bool dirty)
{
- m_dirty = dirty;
-
- if (!m_dirty)
- m_lastIndex = m_commandHistory->index();
-}
-
-void FormWindow::updateDirty()
-{
- m_dirty = m_commandHistory->index() != m_lastIndex;
+ m_undoStack.setDirty(dirty);
}
QWidget *FormWindow::containerAt(const QPoint &pos)
@@ -2757,7 +2791,7 @@ bool FormWindow::dropDockWidget(QDesignerDnDItemInterface *item, const QPoint &g
qVariantSetValue(v, e);
SetPropertyCommand *cmd = new SetPropertyCommand(this);
cmd->init(widget, dockWidgetAreaName, v);
- m_commandHistory->push(cmd);
+ m_undoStack.push(cmd);
}
endCommand();
@@ -2921,6 +2955,13 @@ QWidget *FormWindow::formContainer() const
return m_widgetStack->formContainer();
}
+QUndoStack *FormWindow::commandHistory() const
+{
+ return const_cast<QDesignerUndoStack &>(m_undoStack).qundoStack();
+}
+
} // namespace
QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(qdesigner_internal::ArrowKeyOperation)
diff --git a/tools/designer/src/components/formeditor/formwindow.h b/tools/designer/src/components/formeditor/formwindow.h
index 3eee476..dc0026f 100644
--- a/tools/designer/src/components/formeditor/formwindow.h
+++ b/tools/designer/src/components/formeditor/formwindow.h
@@ -43,6 +43,7 @@
#define FORMWINDOW_H
#include "formeditor_global.h"
+#include "qdesignerundostack.h"
#include <formwindowbase_p.h>
// Qt
@@ -64,7 +65,6 @@ class QLabel;
class QTimer;
class QAction;
class QMenu;
-class QUndoStack;
class QRubberBand;
namespace qdesigner_internal {
@@ -165,9 +165,7 @@ public:
void manageWidget(QWidget *w);
void unmanageWidget(QWidget *w);
- inline QUndoStack *commandHistory() const
- { return m_commandHistory; }
-
+ virtual QUndoStack *commandHistory() const;
void beginCommand(const QString &description);
void endCommand();
@@ -238,7 +236,6 @@ protected:
private slots:
void selectionChangedTimerDone();
- void updateDirty();
void checkSelection();
void checkSelectionNow();
void slotSelectWidget(QAction *);
@@ -263,7 +260,6 @@ private:
int getValue(const QRect &rect, int key, bool size) const;
int calcValue(int val, bool forward, bool snap, int snapOffset) const;
- QRect applyValue(const QRect &rect, int val, int key, bool size) const;
void handleClickSelection(QWidget *managedWidget, unsigned mouseFlags);
bool frameNeeded(QWidget *w) const;
@@ -338,7 +334,7 @@ private:
QPoint m_startPos;
- QUndoStack *m_commandHistory;
+ QDesignerUndoStack m_undoStack;
QString m_fileName;
@@ -352,9 +348,6 @@ private:
QTimer *m_checkSelectionTimer;
QTimer *m_geometryChangedTimer;
- int m_dirty;
- int m_lastIndex;
-
FormWindowWidgetStack *m_widgetStack;
WidgetEditorTool *m_widgetEditor;
@@ -368,8 +361,6 @@ private:
QString m_exportMacro;
QStringList m_includeHints;
- QList<SetPropertyCommand*> m_moveSelection;
- int m_lastUndoIndex;
QPoint m_contextMenuPosition;
private:
diff --git a/tools/designer/src/components/formeditor/qdesignerundostack.cpp b/tools/designer/src/components/formeditor/qdesignerundostack.cpp
new file mode 100644
index 0000000..007031d
--- /dev/null
+++ b/tools/designer/src/components/formeditor/qdesignerundostack.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** 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 Qt Designer 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 "qdesignerundostack.h"
+
+#include <QtGui/QUndoStack>
+#include <QtGui/QUndoCommand>
+
+QT_BEGIN_NAMESPACE
+
+namespace qdesigner_internal {
+
+QDesignerUndoStack::QDesignerUndoStack(QObject *parent) :
+ QObject(parent),
+ m_undoStack(new QUndoStack),
+ m_fakeDirty(false)
+{
+ connect(m_undoStack, SIGNAL(indexChanged(int)), this, SIGNAL(changed()));
+}
+
+QDesignerUndoStack::~QDesignerUndoStack()
+{ // QUndoStack is managed by the QUndoGroup
+}
+
+void QDesignerUndoStack::push(QUndoCommand * cmd)
+{
+ m_undoStack->push(cmd);
+}
+
+void QDesignerUndoStack::beginMacro(const QString &text)
+{
+ m_undoStack->beginMacro(text);
+}
+
+void QDesignerUndoStack::endMacro()
+{
+ m_undoStack->endMacro();
+}
+
+int QDesignerUndoStack::index() const
+{
+ return m_undoStack->index();
+}
+
+const QUndoStack *QDesignerUndoStack::qundoStack() const
+{
+ return m_undoStack;
+}
+QUndoStack *QDesignerUndoStack::qundoStack()
+{
+ return m_undoStack;
+}
+
+bool QDesignerUndoStack::isDirty() const
+{
+ return m_fakeDirty || !m_undoStack->isClean();
+}
+
+void QDesignerUndoStack::setDirty(bool v)
+{
+ if (isDirty() == v)
+ return;
+ if (v) {
+ m_fakeDirty = true;
+ emit changed();
+ } else {
+ m_fakeDirty = false;
+ m_undoStack->setClean();
+ }
+}
+
+} // namespace qdesigner_internal
+
+QT_END_NAMESPACE
diff --git a/tools/designer/src/components/formeditor/qdesignerundostack.h b/tools/designer/src/components/formeditor/qdesignerundostack.h
new file mode 100644
index 0000000..5451ad8
--- /dev/null
+++ b/tools/designer/src/components/formeditor/qdesignerundostack.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** 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 Qt Designer 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 QDESIGNERUNDOSTACK_H
+#define QDESIGNERUNDOSTACK_H
+
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+class QUndoStack;
+class QUndoCommand;
+
+namespace qdesigner_internal {
+
+/* QDesignerUndoStack: A QUndoStack extended by a way of setting it to
+ * "dirty" indepently of commands (by modifications without commands
+ * such as resizing). Accomplished via bool m_fakeDirty flag. The
+ * lifecycle of the QUndoStack is managed by the QUndoGroup. */
+class QDesignerUndoStack : public QObject
+{
+ Q_DISABLE_COPY(QDesignerUndoStack)
+ Q_OBJECT
+public:
+ explicit QDesignerUndoStack(QObject *parent = 0);
+ virtual ~QDesignerUndoStack();
+
+ void push(QUndoCommand * cmd);
+ void beginMacro(const QString &text);
+ void endMacro();
+ int index() const;
+
+ const QUndoStack *qundoStack() const;
+ QUndoStack *qundoStack();
+
+ bool isDirty() const;
+
+signals:
+ void changed();
+
+public slots:
+ void setDirty(bool);
+
+private:
+ QUndoStack *m_undoStack;
+ bool m_fakeDirty;
+};
+
+} // namespace qdesigner_internal
+
+QT_END_NAMESPACE
+
+#endif // QDESIGNERUNDOSTACK_H
diff --git a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp
index 8c55d26..490373e 100644
--- a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp
@@ -62,8 +62,10 @@ QT_BEGIN_NAMESPACE
namespace qdesigner_internal {
// ---- QDesignerFormWindowCommand ----
-QDesignerFormWindowCommand::QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow)
- : QUndoCommand(description),
+QDesignerFormWindowCommand::QDesignerFormWindowCommand(const QString &description,
+ QDesignerFormWindowInterface *formWindow,
+ QUndoCommand *parent)
+ : QUndoCommand(description, parent),
m_formWindow(formWindow)
{
}
diff --git a/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h b/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h
index d8cd018..d73d70c 100644
--- a/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_formwindowcommand_p.h
@@ -70,7 +70,9 @@ class QDESIGNER_SHARED_EXPORT QDesignerFormWindowCommand: public QUndoCommand
{
public:
- QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow);
+ QDesignerFormWindowCommand(const QString &description,
+ QDesignerFormWindowInterface *formWindow,
+ QUndoCommand *parent = 0);
virtual void undo();
virtual void redo();
diff --git a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp
index 822c14b..6cc054c 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp
@@ -926,8 +926,9 @@ bool PropertyListCommand::PropertyDescription::equals(const PropertyDescription
// ---- PropertyListCommand
-PropertyListCommand::PropertyListCommand(QDesignerFormWindowInterface *formWindow) :
- QDesignerFormWindowCommand(QString(), formWindow)
+PropertyListCommand::PropertyListCommand(QDesignerFormWindowInterface *formWindow,
+ QUndoCommand *parent) :
+ QDesignerFormWindowCommand(QString(), formWindow, parent)
{
}
@@ -966,10 +967,17 @@ bool PropertyListCommand::add(QObject *object, const QString &propertyName)
if (!match || m_propertyDescription.m_specialProperty == SP_ObjectName)
return false;
}
- m_propertyHelperList.push_back(PropertyHelper(object, m_propertyDescription.m_specialProperty, sheet, index));
+
+ const PropertyHelperPtr ph(createPropertyHelper(object, m_propertyDescription.m_specialProperty, sheet, index));
+ m_propertyHelperList.push_back(ph);
return true;
}
+PropertyHelper *PropertyListCommand::createPropertyHelper(QObject *object, SpecialProperty sp,
+ QDesignerPropertySheetExtension *sheet, int sheetIndex) const
+{
+ return new PropertyHelper(object, sp, sheet, sheetIndex);
+}
// Init from a list and make sure referenceObject is added first to obtain the right property group
bool PropertyListCommand::initList(const ObjectList &list, const QString &apropertyName, QObject *referenceObject)
@@ -993,19 +1001,19 @@ bool PropertyListCommand::initList(const ObjectList &list, const QString &aprope
QObject* PropertyListCommand::object(int index) const
{
Q_ASSERT(index < m_propertyHelperList.size());
- return m_propertyHelperList[index].object();
+ return m_propertyHelperList.at(index)->object();
}
QVariant PropertyListCommand::oldValue(int index) const
{
Q_ASSERT(index < m_propertyHelperList.size());
- return m_propertyHelperList[index].oldValue();
+ return m_propertyHelperList.at(index)->oldValue();
}
void PropertyListCommand::setOldValue(const QVariant &oldValue, int index)
{
Q_ASSERT(index < m_propertyHelperList.size());
- m_propertyHelperList[index].setOldValue(oldValue);
+ m_propertyHelperList.at(index)->setOldValue(oldValue);
}
// ----- SetValueFunction: Set a new value when applied to a PropertyHelper.
class SetValueFunction {
@@ -1065,9 +1073,10 @@ template <class PropertyListIterator, class Function>
bool updatedPropertyEditor = false;
for (PropertyListIterator it = begin; it != end; ++it) {
- if (QObject* object = it->object()) { // Might have been deleted in the meantime
- const PropertyHelper::Value newValue = function(*it);
- updateMask |= it->updateMask();
+ PropertyHelper *ph = it->data();
+ if (QObject* object = ph->object()) { // Might have been deleted in the meantime
+ const PropertyHelper::Value newValue = function( *ph );
+ updateMask |= ph->updateMask();
// Update property editor if it is the current object
if (!updatedPropertyEditor && propertyEditor && object == propertyEditor->object()) {
propertyEditor->setPropertyValue(propertyName, newValue.first, newValue.second);
@@ -1084,9 +1093,11 @@ template <class PropertyListIterator, class Function>
unsigned PropertyListCommand::setValue(QVariant value, bool changed, unsigned subPropertyMask)
{
if(debugPropertyCommands)
- qDebug() << "PropertyListCommand::setValue(" << value << changed << subPropertyMask << ')';
+ qDebug() << "PropertyListCommand::setValue(" << value
+ << changed << subPropertyMask << ')';
return changePropertyList(formWindow()->core(),
- m_propertyDescription.m_propertyName, m_propertyHelperList.begin(), m_propertyHelperList.end(),
+ m_propertyDescription.m_propertyName,
+ m_propertyHelperList.begin(), m_propertyHelperList.end(),
SetValueFunction(formWindow(), PropertyHelper::Value(value, changed), subPropertyMask));
}
@@ -1146,15 +1157,16 @@ bool PropertyListCommand::canMergeLists(const PropertyHelperList& other) const
if (m_propertyHelperList.size() != other.size())
return false;
for (int i = 0; i < m_propertyHelperList.size(); i++) {
- if (!m_propertyHelperList[i].canMerge(other[i]))
+ if (!m_propertyHelperList.at(i)->canMerge(*other.at(i)))
return false;
}
return true;
}
// ---- SetPropertyCommand ----
-SetPropertyCommand::SetPropertyCommand(QDesignerFormWindowInterface *formWindow)
- : PropertyListCommand(formWindow),
+SetPropertyCommand::SetPropertyCommand(QDesignerFormWindowInterface *formWindow,
+ QUndoCommand *parent)
+ : PropertyListCommand(formWindow, parent),
m_subPropertyMask(SubPropertyAll)
{
}
@@ -1210,7 +1222,7 @@ unsigned SetPropertyCommand::subPropertyMask(const QVariant &newValue, QObject *
void SetPropertyCommand::setDescription()
{
if (propertyHelperList().size() == 1) {
- setText(QApplication::translate("Command", "Changed '%1' of '%2'").arg(propertyName()).arg(propertyHelperList()[0].object()->objectName()));
+ setText(QApplication::translate("Command", "Changed '%1' of '%2'").arg(propertyName()).arg(propertyHelperList().at(0)->object()->objectName()));
} else {
int count = propertyHelperList().size();
setText(QApplication::translate("Command", "Changed '%1' of %n objects", "", QCoreApplication::UnicodeUTF8, count).arg(propertyName()));
@@ -1231,6 +1243,11 @@ int SetPropertyCommand::id() const
return 1976;
}
+QVariant SetPropertyCommand::mergeValue(const QVariant &newValue)
+{
+ return newValue;
+}
+
bool SetPropertyCommand::mergeWith(const QUndoCommand *other)
{
if (id() != other->id() || !formWindow()->isDirty())
@@ -1248,7 +1265,10 @@ bool SetPropertyCommand::mergeWith(const QUndoCommand *other)
!canMergeLists(cmd->propertyHelperList()))
return false;
- m_newValue = cmd->newValue();
+ const QVariant newValue = mergeValue(cmd->newValue());
+ if (!newValue.isValid())
+ return false;
+ m_newValue = newValue;
m_subPropertyMask |= cmd->m_subPropertyMask;
if(debugPropertyCommands)
qDebug() << "SetPropertyCommand::mergeWith() succeeded " << propertyName();
@@ -1289,7 +1309,7 @@ bool ResetPropertyCommand::init(const ObjectList &list, const QString &aproperty
void ResetPropertyCommand::setDescription()
{
if (propertyHelperList().size() == 1) {
- setText(QApplication::translate("Command", "Reset '%1' of '%2'").arg(propertyName()).arg(propertyHelperList()[0].object()->objectName()));
+ setText(QApplication::translate("Command", "Reset '%1' of '%2'").arg(propertyName()).arg(propertyHelperList().at(0)->object()->objectName()));
} else {
int count = propertyHelperList().size();
setText(QApplication::translate("Command", "Reset '%1' of %n objects", "", QCoreApplication::UnicodeUTF8, count).arg(propertyName()));
diff --git a/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h b/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h
index f6b7262..75b23ca 100644
--- a/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_propertycommand_p.h
@@ -58,6 +58,7 @@
#include <QtCore/QVariant>
#include <QtCore/QList>
#include <QtCore/QPair>
+#include <QtCore/QSharedPointer>
QT_BEGIN_NAMESPACE
@@ -77,11 +78,12 @@ enum SpecialProperty {
//Determine special property
enum SpecialProperty getSpecialProperty(const QString& propertyName);
-
// A helper class for applying properties to objects.
// Can be used for Set commands (setValue(), restoreOldValue()) or
// Reset Commands restoreDefaultValue(), restoreOldValue()).
-class PropertyHelper {
+//
+class QDESIGNER_SHARED_EXPORT PropertyHelper {
+ Q_DISABLE_COPY(PropertyHelper)
public:
// A pair of Value and changed flag
typedef QPair<QVariant, bool> Value;
@@ -92,11 +94,13 @@ public:
SpecialProperty specialProperty,
QDesignerPropertySheetExtension *sheet,
int index);
+ virtual ~PropertyHelper() {}
QObject *object() const { return m_object; }
SpecialProperty specialProperty() const { return m_specialProperty; }
- // set a new value
- Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask);
+ // set a new value. Can be overwritten to perform a transformation (see
+ // handling of Arrow key move in FormWindow class).
+ virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, unsigned subPropertyMask);
// restore old value
Value restoreOldValue(QDesignerFormWindowInterface *fw);
@@ -147,7 +151,7 @@ class QDESIGNER_SHARED_EXPORT PropertyListCommand : public QDesignerFormWindowCo
public:
typedef QList<QObject *> ObjectList;
- explicit PropertyListCommand(QDesignerFormWindowInterface *formWindow);
+ explicit PropertyListCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent = 0);
QObject* object(int index = 0) const;
@@ -159,8 +163,8 @@ public:
virtual void undo();
protected:
- typedef QList<PropertyHelper> PropertyHelperList;
-
+ typedef QSharedPointer<PropertyHelper> PropertyHelperPtr;
+ typedef QList<PropertyHelperPtr> PropertyHelperList;
// add an object
bool add(QObject *object, const QString &propertyName);
@@ -204,6 +208,10 @@ protected:
};
const PropertyDescription &propertyDescription() const { return m_propertyDescription; }
+protected:
+ virtual PropertyHelper *createPropertyHelper(QObject *o, SpecialProperty sp,
+ QDesignerPropertySheetExtension *sheet, int sheetIndex) const;
+
private:
PropertyDescription m_propertyDescription;
PropertyHelperList m_propertyHelperList;
@@ -215,7 +223,7 @@ class QDESIGNER_SHARED_EXPORT SetPropertyCommand: public PropertyListCommand
public:
typedef QList<QObject *> ObjectList;
- explicit SetPropertyCommand(QDesignerFormWindowInterface *formWindow);
+ explicit SetPropertyCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent = 0);
bool init(QObject *object, const QString &propertyName, const QVariant &newValue);
bool init(const ObjectList &list, const QString &propertyName, const QVariant &newValue,
@@ -232,6 +240,10 @@ public:
bool mergeWith(const QUndoCommand *other);
virtual void redo();
+
+protected:
+ virtual QVariant mergeValue(const QVariant &newValue);
+
private:
unsigned subPropertyMask(const QVariant &newValue, QObject *referenceObject);
void setDescription();