Merge remote branch 'origin/2.0'

Conflicts:
	doc/qtcreator.qdoc
	src/plugins/projectexplorer/taskwindow.h
	src/plugins/qmldesigner/designercore/model/modelmerger.cpp
	src/plugins/qmljseditor/qmljshoverhandler.h
	src/plugins/qt4projectmanager/Qt4ProjectManager.pluginspec
	src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.cpp
	src/plugins/subversion/subversionplugin.cpp
This commit is contained in:
con
2010-06-11 16:30:39 +02:00
110 changed files with 1328 additions and 730 deletions

12
dist/changes-2.0.0 vendored
View File

@@ -36,6 +36,11 @@ Editing
the syntax highlighting. the syntax highlighting.
* Block selection defines a find & replace scope * Block selection defines a find & replace scope
* Added customizable default file encoding (in addition to the project setting) * Added customizable default file encoding (in addition to the project setting)
* Added syntax highlighting for CMake project files
* Fixed .pro files being reformatted if files have been added or removed.
In addition, whitespace is preserved
* Fixed the file system sidebar to update automatically
* Fixed updating code completion for generated UI header files
CodePaster CodePaster
* Implemented new protocol of pastebin.com including list functionality * Implemented new protocol of pastebin.com including list functionality
@@ -55,6 +60,9 @@ Project support
* Allow changing the build environment for Generic Projects * Allow changing the build environment for Generic Projects
* Added context menu options to open file manager or terminal in a files * Added context menu options to open file manager or terminal in a files
directory directory
* Fixed the DEFINES and INCLUDES set in .pro files to be dealt with
on a file-specific level and enabled the handling of DEFINES.
Also, the .qmake.cache is now parsed
Debugging Debugging
* Add on-device debugging for the Symbian platform using gdb * Add on-device debugging for the Symbian platform using gdb
@@ -72,6 +80,10 @@ Debugging
names names
* pdb: Added some basic debugging for Python scripts based on pdb * pdb: Added some basic debugging for Python scripts based on pdb
* Improvements in the dialogs, status messages, and general appearance * Improvements in the dialogs, status messages, and general appearance
* Fixed debugging helpers to work while debugging applications on devices
* On Linux and Windows, enabled installing Qt with one user account and
then using it with another without workarounds
* Fixed all data types to work in the Watch Window of CDB
Help Help

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

@@ -1787,7 +1787,7 @@
\image qtcreator-qt4-qtversions-win-msvc.png \image qtcreator-qt4-qtversions-win-msvc.png
\endlist \endlist
If you are using \bold{Qt for Symbian} and your S60 SDK is registered If you are using \bold{Qt for Symbian} and your Symbian SDK is registered
with devices.exe, Qt Creator automatically detects the Qt version. To add a with devices.exe, Qt Creator automatically detects the Qt version. To add a
Qt for Symbian version: Qt for Symbian version:
\list 1 \list 1
@@ -1804,7 +1804,7 @@
the \c{PATH} environment variable. the \c{PATH} environment variable.
\o To build an application for the emulator (WINSCW toolchain), enter \o To build an application for the emulator (WINSCW toolchain), enter
the path to your Carbide C++ installation directory in the path to your Carbide C++ installation directory in
\gui{Carbide Directory}. \gui{Carbide directory}.
\note You need to have Carbide C++ version 2.0 or later installed. \note You need to have Carbide C++ version 2.0 or later installed.
\endlist \endlist
@@ -2142,7 +2142,7 @@
\list \list
\o You selected the Symbian Device target for building the application. \o You selected the Symbian Device target for building the application.
\o The settings for the Qt version you use to build your project are \o The settings for the Qt version you use to build your project are
correct. The path to the S60 SDK must point to the S60 SDK correct. The path to the Symbian SDK must point to the Symbian SDK
installation directory. Select \gui Tools > \gui Options... installation directory. Select \gui Tools > \gui Options...
> \gui Debugger > \gui{Symbian TRK} and check if it points to the > \gui Debugger > \gui{Symbian TRK} and check if it points to the
debugger toolchain. debugger toolchain.
@@ -2697,12 +2697,12 @@
\o Click \o Click
\inlineimage{qtcreator-run.png} \inlineimage{qtcreator-run.png}
to build the application for Qt Simulator. to build the application and run it in Qt Simulator.
\o To see the compilation progress, press \key{Alt+4} to open the \o To see the compilation progress, press \key{Alt+4} to open the
\gui Compile Output pane. \gui Compile Output pane.
The gui Build progress bar on the toolbar turns green when the project The \gui Build progress bar on the toolbar turns green when the project
is successfully built. The application opens in Qt Simulator. is successfully built. The application opens in Qt Simulator.
\image {qt-simulator.png} "Qt Simulator" \image {qt-simulator.png} "Qt Simulator"
@@ -5025,7 +5025,7 @@
specified in the \c CMake project file. specified in the \c CMake project file.
Known issues for the current version can be found Known issues for the current version can be found
\l{Known Issues of version 2.0.80}{here}. \l{Known Issues}{here}.
\section1 Adding External Libraries to a CMake Project \section1 Adding External Libraries to a CMake Project
@@ -5782,6 +5782,32 @@
\image qtcreator-mad-developer-screenshot.png \image qtcreator-mad-developer-screenshot.png
\endlist \endlist
\section1 Installing Qt Mobility APIs
To develop applications that use the Qt Mobility APIs, you must install the
APIs on the devices. The APIs are not available in the Nokia N900 package
manager, and therefore, you must install them from the command line as the
root user. To become the root user you must first install \c rootsh from the
application manager.
\list 1
\o On the device, install \c rootsh from the \gui {Application Manager}.
\o In \gui Programs, select \c {X Terminal} to open a terminal window.
\o To switch to the root user, enter the following command:
\c{sudo gainroot}
\o To install Qt Mobility libraries, enter the following command:
\c{apt-get install libqtm-*}
\o To confirm the installation, enter: \c Y
\o Close the terminal.
\endlist
\section1 Setting Up Network Connectivity on Development PC \section1 Setting Up Network Connectivity on Development PC
Use the network configuration tools on your platform to specify the Use the network configuration tools on your platform to specify the
@@ -5879,6 +5905,13 @@
necessary software is installed and configured automatically and you necessary software is installed and configured automatically and you
only need to configure a connection to the device. only need to configure a connection to the device.
By default, you create the connection as the \e developer user. This
protects real user data on the device from getting corrupted during
testing. If you write applications that use Mobility APIs, you might want
to test them with real user data. To create a connection as a user, specify
the \gui Username and \gui Password in Qt Creator. For more information, see
\l{Testing with User Data}.
You can protect the connections between Qt Creator and the Maemo emulator You can protect the connections between Qt Creator and the Maemo emulator
or a device by using either a password or an SSH key. You must always or a device by using either a password or an SSH key. You must always
use a password for the initial connection, but can then deploy an SSH use a password for the initial connection, but can then deploy an SSH
@@ -6000,6 +6033,30 @@
\endlist \endlist
\section2 Testing with User Data
To run your application as the default user, you must first assign a password
for the user account and then create the connection to the device as the
user:
\list 1
\o On the device, in \gui Programs, select \c {X Terminal} to open a
terminal window.
\o To switch to the root user, enter the following command:
\c{sudo gainroot}
\o To specify the password, enter the following command:
\c {passwd user}
\o In Qt Creator, Select \gui Tools > \gui Options... > \gui Projects >
\gui{Maemo Device Configurations}.
\o Specify the username \c user and the password in the device configuration.
\endlist
\section2 Generating SSH Keys \section2 Generating SSH Keys
If you do not have an SSH public and private key pair, you can generate it If you do not have an SSH public and private key pair, you can generate it
@@ -6186,7 +6243,9 @@
\o The \l{http://tools.ext.nokia.com/trk/}{App TRK} application for \o The \l{http://tools.ext.nokia.com/trk/}{App TRK} application for
your device your device
\o The \e{qt_installer.sis} package installed on the device, that is \o The \e{qt_installer.sis} package installed on the device, that is
delivered with the Qt SDK. delivered with the Qt SDK
\o \e {Qt Mobility APIs} installed on the device, if you use them in
applications
\endlist \endlist
To run your applications in the Symbian emulator, you also need To run your applications in the Symbian emulator, you also need
@@ -6221,6 +6280,10 @@
\endlist \endlist
\note If errors occur during the installation, copy the .sis files from
\c {<NokiaQtSDK_install_path>\Symbian\sis} to the device using USB storage
mode. Then install them from the file manager on the device.
\section1 Adding Symbian Platform SDKs \section1 Adding Symbian Platform SDKs
Nokia Qt SDK contains all the tools you need for developing Qt applications for Nokia Qt SDK contains all the tools you need for developing Qt applications for
@@ -6230,33 +6293,33 @@
\list \list
\o \l{http://www.forum.nokia.com/main/resources/tools_and_sdks/S60SDK/} \o \l{http://www.forum.nokia.com/main/resources/tools_and_sdks/S60SDK/}
{S60 Platform SDK 3rd Edition FP1 or higher}. {S60 Platform SDK 3rd Edition FP1 or higher}.
\o Either the GCCE ARM Toolchain that is included in the S60 Platform \o Either the GCCE ARM Toolchain that is included in the Symbian
SDKs, or RVCT 2.2 [build 686] or later (which is not available free SDKs, or RVCT 2.2 [build 686] or later (which is not available free
of charge)(Your environment needs to find the compiler in the PATH). of charge)(Your environment needs to find the compiler in the PATH).
\o Qt for Symbian 4.6.2 or later, installed into the S60 SDKs you want \o Qt for Symbian 4.6.2 or later, installed into the Symbian SDKs you want
to use. to use.
\endlist \endlist
\section2 Setting Up Qt Creator \section2 Setting Up Qt Creator
When you run Qt Creator after installing the S60 Platform SDK and Qt for When you run Qt Creator after installing the Symbian SDK and Qt for
Symbian, the installed SDKs and their corresponding Qt versions are Symbian, the installed SDKs and their corresponding Qt versions are
automatically detected. For each detected S60 SDK with Qt, a special entry automatically detected. For each detected Symbian SDK with Qt, a special entry
is made in the Qt version management settings in \gui{Tools} > is made in the Qt version management settings in \gui{Tools} >
\gui{Options...} > \gui{Qt4} > \gui{Qt Versions}. \gui{Options...} > \gui{Qt4} > \gui{Qt Versions}.
\note If you manually add a Qt version for Symbian, you must \note If you manually add a Qt version for Symbian, you must
also manually specify the S60 SDK to use for this version. also manually specify the Symbian SDK to use for this version.
\image qtcreator-qt4-qtversions-win-symbian.png \image qtcreator-qt4-qtversions-win-symbian.png
If you want to run your applications in the Symbian emulator, you need to If you want to run your applications in the Symbian emulator, you need to
point Qt Creator to the Metrowerks Compiler that you want to use, by point Qt Creator to the Metrowerks Compiler that you want to use, by
setting the \gui{Carbide Directory} of the Qt version to the corresponding setting the \gui{Carbide directory} of the Qt version to the corresponding
Carbide.c++ installation directory. Carbide.c++ installation directory.
You can check what S60 SDKs and corresponding Qt versions are found in the You can check which Symbian SDKs and corresponding Qt versions are found in the
\gui{Tools} > \gui{Options...} > \gui{Qt4} > \gui{S60 SDKs} preference \gui{Tools} > \gui{Options...} > \gui{Qt4} > \gui{S60 SDKs} preference
page. page.
@@ -7100,41 +7163,16 @@
\title Known Issues \title Known Issues
There are some known issues with Qt Creator. This section lists known issues in Qt Creator version 2.0.0.
The development team is aware of them, there is no need to report them as bugs. The development team is aware of them, and therefore, you do not need to
report them as bugs.
\section1 Known Issues of Version 2.0.80 For a list of fixed issues and added features, see the changelog file in
the qtcreator\dist folder or the \l{http://bugreports.qt.nokia.com}{Qt Bug Tracker}.
\section1 General
\list \list
\o On Windows, debugging a MinGW-built console application (with \gui{Run in terminal}
checked) using gdb does not work due to a bug in gdb related to attaching to
stopped processes (see \l{http://bugreports.qt.nokia.com/browse/QTCREATORBUG-1020}).
\o Debugging Helper does not work while performing On-Device Debugging.
\o QML Preview (Run Project) only works if built against Qt with
Declarative UI.
\o Setting breakpoints in code that is compiled into the binary more
than once does not work.
\o On Linux and Windows, installing Qt with one user account and
then using it with another requires other users to manually set
the Qt version. On Windows, setting the MinGW location is
required as well. The same applies to the location of GDB for Symbian.
A workaround is to copy %APPDATA%/Nokia/qtcreator.ini (Windows) or
$HOME/.config/Nokia/QtCreator.ini (Linux) from the directory
of the user who installed Qt Creator to the other user.
This issue does not exist on Mac OS X.
\endlist
\section1 Known Issues of Version 1.2.0 and 1.2.1
\list
\o Gdb on Windows may not work if the 'Embassy \reg Security Center' software
by 'Wave \reg Systems' is installed and active (causing crashes in \c{vxvault.dll)}).
\o Only simple data types (POD) work in the Watch Window of CDB.
\o Qt Creator uses SQLite for storing some of its settings. SQLite is \o Qt Creator uses SQLite for storing some of its settings. SQLite is
known to have problems with certain NFS servers (most notably the known to have problems with certain NFS servers (most notably the
@@ -7143,9 +7181,18 @@
NFS share and you encounter this issue, one option would be to NFS share and you encounter this issue, one option would be to
switch to the nfs-kernel-server, or create a symlink so that the switch to the nfs-kernel-server, or create a symlink so that the
settings are stored locally. settings are stored locally.
\endlist \endlist
\section1 Known Issues of Version 1.1.0 \section1 Editing
\list
\o Code completion does not support typedefs for nested classes.
\endlist
\section1 Projects
\list \list
\o Paths or file names containing spaces or special characters, e.g., \o Paths or file names containing spaces or special characters, e.g.,
@@ -7156,59 +7203,39 @@
items with names consisting of plain characters, numbers, items with names consisting of plain characters, numbers,
underscores, and hyphens. underscores, and hyphens.
\o \c{.pro} files are reformatted if files have been added or removed.
Whitespace is not preserved.
\o There is no IDE support for adding files to include (\c .pri) files.
\o There is no IDE support for adding/removing sub-projects. Project \o There is no IDE support for adding/removing sub-projects. Project
hierarchies (SUBDIRS template) have to be created manually. hierarchies (SUBDIRS template) have to be created manually.
\o The file system sidebar does not update automatically. As a \o Creating new \c CMake projects with Qt Creator is not supported.
workaround, switch to another directory and then back.
\o Loading KDE4 designer plugins breaks the style in KDE < 4.2.1 \endlist
due to a bug in KDE.
\o The DEFINES and INCLUDES set in \c{.pro} files are not dealt with \section1 Debugging
on a file-specific level. Because of this, handling of DEFINES has
been disabled completely. Also the \c{.qmake.cache} is not being
parsed. In general, the \c{.pro} file parser is incomplete and
problems are still to be expected.
\o Code completion for generated UI header files is updated only \list
after a build.
\o Code completion does not support typedefs for nested classes. \o When debugging executables created by the GNU Compiler version 4.5.0
(all platforms), some data types will not be displayed in the
\gui{Locals and Watchers} view due to missing debug information.
\o There is a kernel bug essentially making debugging unreliable on \o On Windows, debugging a MinGW-built console application (with \gui{Run in terminal}
2.6.24 kernels for i386 (which is, unfortunately, the default on checked) using gdb does not work due to a bug in gdb related to attaching to
Ubuntu 8.04). See stopped processes (see \l{http://bugreports.qt.nokia.com/browse/QTCREATORBUG-1020}).
\l{https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/230315/} for
details. The only solution to this problem is to boot another \o Gdb on Windows may not work if the 'Embassy \reg Security Center' software
kernel. by 'Wave \reg Systems' is installed and active (causing crashes in \c{vxvault.dll)}).
\o Gdb may take long to load debugging symbols, especially from large \o Gdb may take long to load debugging symbols, especially from large
libraries like \c libQtWebKit. Starting the debugging module can libraries like \c libQtWebKit. Starting the debugging module can
take up to several minutes without visible progress. take up to several minutes without visible progress.
\o Setting breakpoints in code that is compiled into the binary more
than once does not work.
\o Setting breakpoints in files that do not have unique absolute \o Setting breakpoints in files that do not have unique absolute
paths may fail. For example, remounting parts of a file system paths may fail. For example, remounting parts of a file system
using the --bind mount option. using the --bind mount option.
\o There is no syntax highlighting for \c CMake project files.
\o Project files included from \c{CMakeLists.txt} are not shown in the
navigation tree.
\o Using the Visual Studio Compiler with \c CMake is not supported.
\o Creating new \c CMake projects with Qt Creator is not supported.
\o Having more than one build directory for \c CMake is not supported.
\o Changing the build directory for \c CMake after the initial import
is disabled.
\endlist \endlist
*/ */

View File

@@ -62,7 +62,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeTarget *parent, CMakeBuild
m_msvcVersion(source->m_msvcVersion) m_msvcVersion(source->m_msvcVersion)
{ {
cloneSteps(source); cloneSteps(source);
m_buildDirectory = cmakeTarget()->defaultBuildDirectory();
} }
QVariantMap CMakeBuildConfiguration::toMap() const QVariantMap CMakeBuildConfiguration::toMap() const

View File

@@ -144,6 +144,11 @@ MimeDatabase *CoreImpl::mimeDatabase() const
return m_mainwindow->mimeDatabase(); return m_mainwindow->mimeDatabase();
} }
HelpManager *CoreImpl::helpManager() const
{
return m_mainwindow->helpManager();
}
QSettings *CoreImpl::settings(QSettings::Scope scope) const QSettings *CoreImpl::settings(QSettings::Scope scope) const
{ {
return m_mainwindow->settings(scope); return m_mainwindow->settings(scope);

View File

@@ -67,6 +67,7 @@ public:
VCSManager *vcsManager() const; VCSManager *vcsManager() const;
ModeManager *modeManager() const; ModeManager *modeManager() const;
MimeDatabase *mimeDatabase() const; MimeDatabase *mimeDatabase() const;
HelpManager *helpManager() const;
QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const; QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const;
SettingsDatabase *settingsDatabase() const; SettingsDatabase *settingsDatabase() const;

View File

@@ -6,6 +6,7 @@ QT += xml \
script \ script \
svg \ svg \
sql sql
CONFIG += help
include(../../qtcreatorplugin.pri) include(../../qtcreatorplugin.pri)
include(../../libs/utils/utils.pri) include(../../libs/utils/utils.pri)
include(../../shared/scriptwrapper/scriptwrapper.pri) include(../../shared/scriptwrapper/scriptwrapper.pri)
@@ -86,7 +87,8 @@ SOURCES += mainwindow.cpp \
editortoolbar.cpp \ editortoolbar.cpp \
ssh/ne7sshobject.cpp \ ssh/ne7sshobject.cpp \
ssh/sshconnection.cpp \ ssh/sshconnection.cpp \
ssh/sshkeygenerator.cpp ssh/sshkeygenerator.cpp \
helpmanager.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
editmode.h \ editmode.h \
@@ -171,7 +173,8 @@ HEADERS += mainwindow.h \
editortoolbar.h \ editortoolbar.h \
ssh/ne7sshobject.h \ ssh/ne7sshobject.h \
ssh/sshconnection.h \ ssh/sshconnection.h \
ssh/sshkeygenerator.h ssh/sshkeygenerator.h \
helpmanager.h
FORMS += dialogs/newdialog.ui \ FORMS += dialogs/newdialog.ui \
actionmanager/commandmappings.ui \ actionmanager/commandmappings.ui \

View File

@@ -0,0 +1,321 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "helpmanager.h"
#include "icore.h"
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QStringList>
#include <QtHelp/QHelpEngineCore>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlDriver>
#include <QtSql/QSqlError>
#include <QtSql/QSqlQuery>
namespace Core {
HelpManager *HelpManager::m_instance = 0;
static const char linksForKeyQuery[] = "SELECT d.Title, f.Name, e.Name, "
"d.Name, a.Anchor FROM IndexTable a, FileNameTable d, FolderTable e, "
"NamespaceTable f WHERE a.FileId=d.FileId AND d.FolderId=e.Id AND "
"a.NamespaceId=f.Id AND a.Name='%1'";
// -- DbCleaner
struct DbCleaner {
DbCleaner(const QString &dbName)
: name(dbName) {}
~DbCleaner() {
QSqlDatabase::removeDatabase(name);
}
QString name;
};
// -- HelpManager
HelpManager::HelpManager(QObject *parent)
: QObject(parent)
, m_needsSetup(true)
, m_helpEngine(0)
{
Q_ASSERT(!m_instance);
m_instance = this;
connect(Core::ICore::instance(), SIGNAL(coreOpened()), this,
SLOT(setupHelpManager()));
}
HelpManager::~HelpManager()
{
delete m_helpEngine;
m_helpEngine = 0;
m_instance = 0;
}
HelpManager* HelpManager::instance()
{
Q_ASSERT(m_instance);
return m_instance;
}
QString HelpManager::collectionFilePath()
{
const QFileInfo fi(Core::ICore::instance()->settings()->fileName());
const QDir directory(fi.absolutePath() + QLatin1String("/qtcreator"));
if (!directory.exists())
directory.mkpath(directory.absolutePath());
return QDir::cleanPath(directory.absolutePath() + QLatin1String("/helpcollection.qhc"));
}
void HelpManager::registerDocumentation(const QStringList &files)
{
if (m_needsSetup) {
m_filesToRegister.append(files);
return;
}
bool docsChanged = false;
foreach (const QString &file, files) {
const QString &nameSpace = m_helpEngine->namespaceName(file);
if (nameSpace.isEmpty())
continue;
if (!m_helpEngine->registeredDocumentations().contains(nameSpace)) {
if (m_helpEngine->registerDocumentation(file)) {
docsChanged = true;
} else {
qWarning() << "Error registering namespace '" << nameSpace
<< "' from file '" << file << "':" << m_helpEngine->error();
}
}
}
if (docsChanged)
emit documentationChanged();
}
void HelpManager::unregisterDocumentation(const QStringList &nameSpaces)
{
if (m_needsSetup) {
m_nameSpacesToUnregister.append(nameSpaces);
return;
}
bool docsChanged = false;
foreach (const QString &nameSpace, nameSpaces) {
if (m_helpEngine->unregisterDocumentation(nameSpace)) {
docsChanged = true;
} else {
qWarning() << "Error unregistering namespace '" << nameSpace
<< "' from file '" << m_helpEngine->documentationFileName(nameSpace)
<< "': " << m_helpEngine->error();
}
}
if (docsChanged)
emit documentationChanged();
}
QUrl buildQUrl(const QString &nameSpace, const QString &folder,
const QString &relFileName, const QString &anchor)
{
QUrl url;
url.setScheme(QLatin1String("qthelp"));
url.setAuthority(nameSpace);
url.setPath(folder + QLatin1Char('/') + relFileName);
url.setFragment(anchor);
return url;
}
// This should go into Qt 4.8 once we start using it for Qt Creator
QMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key) const
{
QMap<QString, QUrl> links;
if (m_needsSetup)
return links;
const QLatin1String sqlite("QSQLITE");
const QLatin1String name("HelpManager::linksForKeyword");
DbCleaner cleaner(name);
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
const QStringList &registeredDocs = m_helpEngine->registeredDocumentations();
foreach (const QString &nameSpace, registeredDocs) {
db.setDatabaseName(m_helpEngine->documentationFileName(nameSpace));
if (db.open()) {
QSqlQuery query = QSqlQuery(db);
query.setForwardOnly(true);
query.exec(QString::fromLatin1(linksForKeyQuery).arg(key));
while (query.next()) {
QString title = query.value(0).toString();
if (title.isEmpty()) // generate a title + corresponding path
title = key + QLatin1String(" : ") + query.value(3).toString();
links.insertMulti(title, buildQUrl(query.value(1).toString(),
query.value(2).toString(), query.value(3).toString(),
query.value(4).toString()));
}
}
}
}
return links;
}
QMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id) const
{
if (m_needsSetup)
return QMap<QString, QUrl>();
return m_helpEngine->linksForIdentifier(id);
}
// This should go into Qt 4.8 once we start using it for Qt Creator
QStringList HelpManager::findKeywords(const QString &key, int maxHits) const
{
QStringList keywords;
if (m_needsSetup)
return keywords;
const QLatin1String sqlite("QSQLITE");
const QLatin1String name("HelpManager::findKeywords");
DbCleaner cleaner(name);
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
const QStringList &registeredDocs = m_helpEngine->registeredDocumentations();
foreach (const QString &nameSpace, registeredDocs) {
db.setDatabaseName(m_helpEngine->documentationFileName(nameSpace));
if (db.open()) {
QSqlQuery query = QSqlQuery(db);
query.setForwardOnly(true);
query.exec(QString::fromLatin1("SELECT DISTINCT Name FROM "
"IndexTable WHERE Name LIKE '%%1%'").arg(key));
while (query.next()) {
const QString &key = query.value(0).toString();
if (!key.isEmpty()) {
keywords.append(key);
if (keywords.count() == maxHits)
return keywords;
}
}
}
}
}
return keywords;
}
QUrl HelpManager::findFile(const QUrl &url) const
{
if (m_needsSetup)
return QUrl();
return m_helpEngine->findFile(url);
}
void HelpManager::handleHelpRequest(const QString &url)
{
emit helpRequested(QUrl(url));
}
QStringList HelpManager::registeredNamespaces() const
{
if (m_needsSetup)
return QStringList();
return m_helpEngine->registeredDocumentations();
}
QString HelpManager::namespaceFromFile(const QString &file) const
{
if (m_needsSetup)
return QString();
return m_helpEngine->namespaceName(file);
}
QString HelpManager::fileFromNamespace(const QString &nameSpace) const
{
if (m_needsSetup)
return QString();
return m_helpEngine->documentationFileName(nameSpace);
}
// -- private slots
void HelpManager::setupHelpManager()
{
if (!m_needsSetup)
return;
m_needsSetup = false;
m_helpEngine = new QHelpEngineCore(collectionFilePath(), this);
m_helpEngine->setAutoSaveFilter(false);
m_helpEngine->setCurrentFilter(tr("Unfiltered"));
m_helpEngine->setupData();
verifyDocumenation();
if (!m_nameSpacesToUnregister.isEmpty()) {
unregisterDocumentation(m_nameSpacesToUnregister);
m_nameSpacesToUnregister.clear();
}
// this might come from the installer
const QLatin1String key("AddedDocs");
const QString &addedDocs = m_helpEngine->customValue(key).toString();
if (!addedDocs.isEmpty()) {
m_helpEngine->removeCustomValue(key);
m_filesToRegister += addedDocs.split(QLatin1Char(';'));
}
if (!m_filesToRegister.isEmpty()) {
registerDocumentation(m_filesToRegister);
m_filesToRegister.clear();
}
emit setupFinished();
}
// -- private
void HelpManager::verifyDocumenation()
{
QStringList nameSpacesToUnregister;
const QStringList &registeredDocs = m_helpEngine->registeredDocumentations();
foreach (const QString &nameSpace, registeredDocs) {
const QString &file = m_helpEngine->documentationFileName(nameSpace);
if (!QFileInfo(file).exists())
nameSpacesToUnregister.append(nameSpace);
}
if (!nameSpacesToUnregister.isEmpty())
unregisterDocumentation(nameSpacesToUnregister);
}
} // Core

View File

@@ -0,0 +1,96 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef HELPMANAGER_H
#define HELPMANAGER_H
#include "core_global.h"
#include <QtCore/QMap>
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QUrl>
#include <QtCore/QVariant>
QT_FORWARD_DECLARE_CLASS(QHelpEngineCore)
QT_FORWARD_DECLARE_CLASS(QSqlQuery)
namespace Core {
class CORE_EXPORT HelpManager : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(HelpManager)
public:
explicit HelpManager(QObject *parent = 0);
virtual ~HelpManager();
static HelpManager* instance();
static QString collectionFilePath();
void registerDocumentation(const QStringList &fileNames);
void unregisterDocumentation(const QStringList &nameSpaces);
QMap<QString, QUrl> linksForKeyword(const QString &key) const;
QMap<QString, QUrl> linksForIdentifier(const QString &id) const;
QStringList findKeywords(const QString &key, int maxHits = INT_MAX) const;
QUrl findFile(const QUrl &url) const;
void handleHelpRequest(const QString &url);
QStringList registeredNamespaces() const;
QString namespaceFromFile(const QString &file) const;
QString fileFromNamespace(const QString &nameSpace) const;
signals:
void setupFinished();
void documentationChanged();
void helpRequested(const QUrl &url);
private slots:
void setupHelpManager();
private:
void verifyDocumenation();
private:
bool m_needsSetup;
QHelpEngineCore *m_helpEngine;
QStringList m_filesToRegister;
QStringList m_nameSpacesToUnregister;
static HelpManager *m_instance;
};
} // Core
#endif // HELPMANAGER_H

View File

@@ -50,6 +50,7 @@ namespace Core {
class ActionManager; class ActionManager;
class EditorManager; class EditorManager;
class FileManager; class FileManager;
class HelpManager;
class IContext; class IContext;
class MessageManager; class MessageManager;
class MimeDatabase; class MimeDatabase;
@@ -96,6 +97,7 @@ public:
virtual VCSManager *vcsManager() const = 0; virtual VCSManager *vcsManager() const = 0;
virtual ModeManager *modeManager() const = 0; virtual ModeManager *modeManager() const = 0;
virtual MimeDatabase *mimeDatabase() const = 0; virtual MimeDatabase *mimeDatabase() const = 0;
virtual HelpManager *helpManager() const = 0;
virtual QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const = 0; virtual QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const = 0;
virtual SettingsDatabase *settingsDatabase() const = 0; virtual SettingsDatabase *settingsDatabase() const = 0;

View File

@@ -37,6 +37,7 @@
#include "fancytabwidget.h" #include "fancytabwidget.h"
#include "filemanager.h" #include "filemanager.h"
#include "generalsettings.h" #include "generalsettings.h"
#include "helpmanager.h"
#include "ifilefactory.h" #include "ifilefactory.h"
#include "messagemanager.h" #include "messagemanager.h"
#include "modemanager.h" #include "modemanager.h"
@@ -132,6 +133,7 @@ MainWindow::MainWindow() :
m_statusBarManager(0), m_statusBarManager(0),
m_modeManager(0), m_modeManager(0),
m_mimeDatabase(new MimeDatabase), m_mimeDatabase(new MimeDatabase),
m_helpManager(new HelpManager),
m_navigationWidget(0), m_navigationWidget(0),
m_rightPaneWidget(0), m_rightPaneWidget(0),
m_versionDialog(0), m_versionDialog(0),
@@ -288,6 +290,9 @@ MainWindow::~MainWindow()
m_modeManager = 0; m_modeManager = 0;
delete m_mimeDatabase; delete m_mimeDatabase;
m_mimeDatabase = 0; m_mimeDatabase = 0;
delete m_helpManager;
m_helpManager = 0;
} }
bool MainWindow::init(QString *errorMessage) bool MainWindow::init(QString *errorMessage)
@@ -1021,6 +1026,11 @@ MimeDatabase *MainWindow::mimeDatabase() const
return m_mimeDatabase; return m_mimeDatabase;
} }
HelpManager *MainWindow::helpManager() const
{
return m_helpManager;
}
IContext *MainWindow::contextObject(QWidget *widget) IContext *MainWindow::contextObject(QWidget *widget)
{ {
return m_contextWidgets.value(widget); return m_contextWidgets.value(widget);
@@ -1078,8 +1088,8 @@ void MainWindow::updateFocusWidget(QWidget *old, QWidget *now)
{ {
Q_UNUSED(old) Q_UNUSED(old)
// Prevent changing the context object just because the menu is activated // Prevent changing the context object just because the menu or a menu item is activated
if (qobject_cast<QMenuBar*>(now)) if (qobject_cast<QMenuBar*>(now) || qobject_cast<QMenu*>(now))
return; return;
IContext *newContext = 0; IContext *newContext = 0;

View File

@@ -52,6 +52,7 @@ class ActionManager;
class StatusBarWidget; class StatusBarWidget;
class EditorManager; class EditorManager;
class FileManager; class FileManager;
class HelpManager;
class IContext; class IContext;
class IWizard; class IWizard;
class MessageManager; class MessageManager;
@@ -107,6 +108,7 @@ public:
Core::VariableManager *variableManager() const; Core::VariableManager *variableManager() const;
Core::ModeManager *modeManager() const; Core::ModeManager *modeManager() const;
Core::MimeDatabase *mimeDatabase() const; Core::MimeDatabase *mimeDatabase() const;
Core::HelpManager *helpManager() const;
VCSManager *vcsManager() const; VCSManager *vcsManager() const;
QSettings *settings(QSettings::Scope scope) const; QSettings *settings(QSettings::Scope scope) const;
@@ -193,6 +195,7 @@ private:
StatusBarManager *m_statusBarManager; StatusBarManager *m_statusBarManager;
ModeManager *m_modeManager; ModeManager *m_modeManager;
MimeDatabase *m_mimeDatabase; MimeDatabase *m_mimeDatabase;
HelpManager *m_helpManager;
FancyTabWidget *m_modeStack; FancyTabWidget *m_modeStack;
NavigationWidget *m_navigationWidget; NavigationWidget *m_navigationWidget;
RightPaneWidget *m_rightPaneWidget; RightPaneWidget *m_rightPaneWidget;

View File

@@ -1,7 +1,6 @@
TEMPLATE = lib TEMPLATE = lib
TARGET = CppEditor TARGET = CppEditor
DEFINES += CPPEDITOR_LIBRARY DEFINES += CPPEDITOR_LIBRARY
CONFIG += help
include(../../qtcreatorplugin.pri) include(../../qtcreatorplugin.pri)
include(../../libs/utils/utils.pri) include(../../libs/utils/utils.pri)
include(../../shared/indenter/indenter.pri) include(../../shared/indenter/indenter.pri)

View File

@@ -32,6 +32,7 @@
#include "cppplugin.h" #include "cppplugin.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <coreplugin/uniqueidmanager.h> #include <coreplugin/uniqueidmanager.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <cpptools/cppmodelmanagerinterface.h> #include <cpptools/cppmodelmanagerinterface.h>
@@ -60,7 +61,6 @@
#include <QtGui/QToolTip> #include <QtGui/QToolTip>
#include <QtGui/QTextCursor> #include <QtGui/QTextCursor>
#include <QtGui/QTextBlock> #include <QtGui/QTextBlock>
#include <QtHelp/QHelpEngineCore>
using namespace CppEditor::Internal; using namespace CppEditor::Internal;
using namespace CPlusPlus; using namespace CPlusPlus;
@@ -68,27 +68,11 @@ using namespace Core;
CppHoverHandler::CppHoverHandler(QObject *parent) CppHoverHandler::CppHoverHandler(QObject *parent)
: QObject(parent) : QObject(parent)
, m_helpEngineNeedsSetup(false)
{ {
m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>(); m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
ICore *core = ICore::instance();
QFileInfo fi(core->settings()->fileName());
// FIXME shouldn't the help engine create the directory if it doesn't exist?
QDir directory(fi.absolutePath()+"/qtcreator");
if (!directory.exists())
directory.mkpath(directory.absolutePath());
m_helpEngine = new QHelpEngineCore(directory.absolutePath()
+ QLatin1String("/helpcollection.qhc"), this);
if (!m_helpEngine->setupData())
qWarning() << "Could not initialize help engine:" << m_helpEngine->error();
m_helpEngine->setAutoSaveFilter(false);
m_helpEngine->setCurrentFilter(tr("Unfiltered"));
m_helpEngineNeedsSetup = m_helpEngine->registeredDocumentations().count() == 0;
// Listen for editor opened events in order to connect to tooltip/helpid requests // Listen for editor opened events in order to connect to tooltip/helpid requests
connect(core->editorManager(), SIGNAL(editorOpened(Core::IEditor *)), connect(ICore::instance()->editorManager(), SIGNAL(editorOpened(Core::IEditor *)),
this, SLOT(editorOpened(Core::IEditor *))); this, SLOT(editorOpened(Core::IEditor *)));
} }
@@ -221,19 +205,13 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
} }
} }
if (m_helpEngineNeedsSetup
&& m_helpEngine->registeredDocumentations().count() > 0) {
m_helpEngine->setupData();
m_helpEngineNeedsSetup = false;
}
QMap<QString, QUrl> helpLinks; QMap<QString, QUrl> helpLinks;
if (m_toolTip.isEmpty()) { if (m_toolTip.isEmpty()) {
foreach (const Document::Include &incl, doc->includes()) { foreach (const Document::Include &incl, doc->includes()) {
if (incl.line() == lineNumber) { if (incl.line() == lineNumber) {
m_toolTip = QDir::toNativeSeparators(incl.fileName()); m_toolTip = QDir::toNativeSeparators(incl.fileName());
m_helpId = QFileInfo(incl.fileName()).fileName(); m_helpId = QFileInfo(incl.fileName()).fileName();
helpLinks = m_helpEngine->linksForIdentifier(m_helpId); helpLinks = Core::HelpManager::instance()->linksForIdentifier(m_helpId);
break; break;
} }
} }
@@ -309,7 +287,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
// To show their help anyway, try stripping scopes until we find something. // To show their help anyway, try stripping scopes until we find something.
const QString startHelpId = m_helpId; const QString startHelpId = m_helpId;
while (!m_helpId.isEmpty()) { while (!m_helpId.isEmpty()) {
helpLinks = m_helpEngine->linksForIdentifier(m_helpId); helpLinks = Core::HelpManager::instance()->linksForIdentifier(m_helpId);
if (!helpLinks.isEmpty()) if (!helpLinks.isEmpty())
break; break;

View File

@@ -33,7 +33,6 @@
#include <QtCore/QObject> #include <QtCore/QObject>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QHelpEngineCore;
class QPoint; class QPoint;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -70,10 +69,8 @@ private:
void updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos); void updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos);
CppTools::CppModelManagerInterface *m_modelManager; CppTools::CppModelManagerInterface *m_modelManager;
QHelpEngineCore *m_helpEngine;
QString m_helpId; QString m_helpId;
QString m_toolTip; QString m_toolTip;
bool m_helpEngineNeedsSetup;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -227,6 +227,7 @@ DebuggerSettings *DebuggerSettings::instance()
"operation mode. In this mode, stepping operates on single " "operation mode. In this mode, stepping operates on single "
"instructions and the source location view also shows the " "instructions and the source location view also shows the "
"disassembled instructions.")); "disassembled instructions."));
item->setIconVisibleInMenu(false);
instance->insertItem(OperateByInstruction, item); instance->insertItem(OperateByInstruction, item);
item = new SavedAction(instance); item = new SavedAction(instance);

View File

@@ -566,6 +566,7 @@ void DebuggerManager::init()
d->m_actions.reverseDirectionAction->setChecked(false); d->m_actions.reverseDirectionAction->setChecked(false);
d->m_actions.reverseDirectionAction->setIcon( d->m_actions.reverseDirectionAction->setIcon(
QIcon(":/debugger/images/debugger_reversemode_16.png")); QIcon(":/debugger/images/debugger_reversemode_16.png"));
d->m_actions.reverseDirectionAction->setIconVisibleInMenu(false);
d->m_actions.frameDownAction = d->m_actions.frameDownAction =
new QAction(tr("Move to Called Frame"), this); new QAction(tr("Move to Called Frame"), this);

View File

@@ -852,7 +852,7 @@ void GdbEngine::handleVarListChildrenHelperClassic(const GdbMi &item,
data.type = tr("<anonymous union>"); data.type = tr("<anonymous union>");
} else { } else {
// A structure. Hope there's nothing else... // A structure. Hope there's nothing else...
data.exp = parent.exp + '.' + data.name.toLatin1(); data.exp = '(' + parent.exp + ")." + data.name.toLatin1();
} }
if (hasDebuggingHelperForType(data.type)) { if (hasDebuggingHelperForType(data.type)) {

View File

@@ -45,6 +45,7 @@
#include <coreplugin/designmode.h> #include <coreplugin/designmode.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <coreplugin/uniqueidmanager.h> #include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actioncontainer.h>
@@ -282,14 +283,8 @@ void FormEditorW::fullInit()
m_integration = new QtCreatorIntegration(m_formeditor, this); m_integration = new QtCreatorIntegration(m_formeditor, this);
m_formeditor->setIntegration(m_integration); m_formeditor->setIntegration(m_integration);
// Connect Qt Designer help request to HelpManager. // Connect Qt Designer help request to HelpManager.
// TODO: Use Core::HelpManager once it has been introduced. connect(m_integration, SIGNAL(creatorHelpRequested(QUrl)),
foreach(QObject *object, ExtensionSystem::PluginManager::instance()->allObjects()) { Core::HelpManager::instance(), SIGNAL(helpRequested(QUrl)));
if (!qstrcmp(object->metaObject()->className(), "Help::HelpManager")) {
connect(m_integration, SIGNAL(creatorHelpRequested(QString)),
object, SLOT(handleHelpRequest(QString)));
break;
}
}
/** /**
* This will initialize our TabOrder, Signals and slots and Buddy editors. * This will initialize our TabOrder, Signals and slots and Buddy editors.

View File

@@ -61,6 +61,7 @@
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QUrl>
enum { indentation = 4 }; enum { indentation = 4 };
@@ -101,7 +102,8 @@ QtCreatorIntegration::QtCreatorIntegration(QDesignerFormEditorInterface *core, F
void QtCreatorIntegration::slotDesignerHelpRequested(const QString &manual, const QString &document) void QtCreatorIntegration::slotDesignerHelpRequested(const QString &manual, const QString &document)
{ {
// Pass on as URL. // Pass on as URL.
emit creatorHelpRequested(QString::fromLatin1("qthelp://com.trolltech.%1/qdoc/%2").arg(manual, document)); emit creatorHelpRequested(QUrl(QString::fromLatin1("qthelp://com.trolltech.%1/qdoc/%2")
.arg(manual, document)));
} }
void QtCreatorIntegration::updateSelection() void QtCreatorIntegration::updateSelection()

View File

@@ -34,6 +34,8 @@
#include "qt_private/qdesigner_integration_p.h" #include "qt_private/qdesigner_integration_p.h"
QT_FORWARD_DECLARE_CLASS(QUrl)
namespace Designer { namespace Designer {
namespace Internal { namespace Internal {
@@ -49,7 +51,7 @@ public:
bool supportsToSlotNavigation() { return true; } bool supportsToSlotNavigation() { return true; }
signals: signals:
void creatorHelpRequested(const QString &url); void creatorHelpRequested(const QUrl &url);
public slots: public slots:
void updateSelection(); void updateSelection();

View File

@@ -45,7 +45,6 @@
#include <QtGui/QStackedWidget> #include <QtGui/QStackedWidget>
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpEngineCore>
#include <QtHelp/QHelpSearchEngine> #include <QtHelp/QHelpSearchEngine>
using namespace Help::Internal; using namespace Help::Internal;
@@ -85,7 +84,7 @@ CentralWidget::~CentralWidget()
} }
} }
QHelpEngineCore *engine = &HelpManager::helpEngineCore(); QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
engine->setCustomValue(QLatin1String("LastShownPages"), currentPages); engine->setCustomValue(QLatin1String("LastShownPages"), currentPages);
engine->setCustomValue(QLatin1String("LastShownPagesZoom"), zoomFactors); engine->setCustomValue(QLatin1String("LastShownPagesZoom"), zoomFactors);
engine->setCustomValue(QLatin1String("LastTabPage"), currentIndex()); engine->setCustomValue(QLatin1String("LastTabPage"), currentIndex());
@@ -313,7 +312,7 @@ void CentralWidget::highlightSearchTerms()
{ {
if (HelpViewer *viewer = currentHelpViewer()) { if (HelpViewer *viewer = currentHelpViewer()) {
QHelpSearchEngine *searchEngine = QHelpSearchEngine *searchEngine =
HelpManager::instance().helpEngine().searchEngine(); LocalHelpManager::helpEngine().searchEngine();
QList<QHelpSearchQuery> queryList = searchEngine->query(); QList<QHelpSearchQuery> queryList = searchEngine->query();
QStringList terms; QStringList terms;

View File

@@ -29,7 +29,8 @@
#include "docsettingspage.h" #include "docsettingspage.h"
#include "helpconstants.h" #include "helpconstants.h"
#include "helpmanager.h"
#include <coreplugin/helpmanager.h>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
@@ -37,8 +38,6 @@
#include <QtGui/QKeyEvent> #include <QtGui/QKeyEvent>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtHelp/QHelpEngineCore>
using namespace Help::Internal; using namespace Help::Internal;
DocSettingsPage::DocSettingsPage() DocSettingsPage::DocSettingsPage()
@@ -80,10 +79,10 @@ QWidget *DocSettingsPage::createPage(QWidget *parent)
m_ui.docsListWidget->installEventFilter(this); m_ui.docsListWidget->installEventFilter(this);
QHelpEngineCore *engine = &HelpManager::helpEngineCore(); Core::HelpManager *manager = Core::HelpManager::instance();
const QStringList &nameSpaces = engine->registeredDocumentations(); const QStringList &nameSpaces = manager->registeredNamespaces();
foreach (const QString &nameSpace, nameSpaces) foreach (const QString &nameSpace, nameSpaces)
addItem(nameSpace, engine->documentationFileName(nameSpace)); addItem(nameSpace, manager->fileFromNamespace(nameSpace));
m_filesToRegister.clear(); m_filesToRegister.clear();
m_filesToUnregister.clear(); m_filesToUnregister.clear();
@@ -103,11 +102,11 @@ void DocSettingsPage::addDocumentation()
return; return;
m_recentDialogPath = QFileInfo(files.first()).canonicalPath(); m_recentDialogPath = QFileInfo(files.first()).canonicalPath();
const QHelpEngineCore &engine = HelpManager::helpEngineCore(); Core::HelpManager *manager = Core::HelpManager::instance();
const QStringList &nameSpaces = engine.registeredDocumentations(); const QStringList &nameSpaces = manager->registeredNamespaces();
foreach (const QString &file, files) { foreach (const QString &file, files) {
const QString &nameSpace = engine.namespaceName(file); const QString &nameSpace = manager->namespaceFromFile(file);
if (nameSpace.isEmpty()) if (nameSpace.isEmpty())
continue; continue;
@@ -130,14 +129,10 @@ void DocSettingsPage::removeDocumentation()
void DocSettingsPage::apply() void DocSettingsPage::apply()
{ {
HelpManager* manager = &HelpManager::instance(); Core::HelpManager *manager = Core::HelpManager::instance();
manager->unregisterDocumentation(m_filesToUnregister.keys()); manager->unregisterDocumentation(m_filesToUnregister.keys());
manager->registerDocumentation(m_filesToRegister.values()); manager->registerDocumentation(m_filesToRegister.values());
if (manager->guiEngineNeedsUpdate()) {
// emit this signal to the help plugin, since we don't want
// to force gui help engine setup if we are not in help mode
emit documentationChanged();
}
m_filesToRegister.clear(); m_filesToRegister.clear();
m_filesToUnregister.clear(); m_filesToUnregister.clear();
@@ -172,10 +167,10 @@ void DocSettingsPage::removeDocumentation(const QList<QListWidgetItem*> items)
return; return;
int row = 0; int row = 0;
QHelpEngineCore *engine = &HelpManager::helpEngineCore(); Core::HelpManager *manager = Core::HelpManager::instance();
foreach (QListWidgetItem* item, items) { foreach (QListWidgetItem* item, items) {
const QString &nameSpace = item->text(); const QString &nameSpace = item->text();
const QString &docPath = engine->documentationFileName(nameSpace); const QString &docPath = manager->fileFromNamespace(nameSpace);
if (m_filesToRegister.value(nameSpace) != docPath) { if (m_filesToRegister.value(nameSpace) != docPath) {
if (!m_filesToUnregister.contains(nameSpace)) if (!m_filesToUnregister.contains(nameSpace))

View File

@@ -55,9 +55,6 @@ public:
void finish() {} void finish() {}
virtual bool matches(const QString &s) const; virtual bool matches(const QString &s) const;
signals:
void documentationChanged();
private slots: private slots:
void addDocumentation(); void addDocumentation();
void removeDocumentation(); void removeDocumentation();

View File

@@ -33,16 +33,19 @@
#include "helpconstants.h" #include "helpconstants.h"
#include "helpmanager.h" #include "helpmanager.h"
#include <coreplugin/helpmanager.h>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtHelp/QHelpEngineCore> #include <QtHelp/QHelpEngine>
using namespace Help::Internal; using namespace Help::Internal;
FilterSettingsPage::FilterSettingsPage() FilterSettingsPage::FilterSettingsPage()
: m_helpManager(0)
{ {
} }
@@ -76,6 +79,7 @@ QWidget *FilterSettingsPage::createPage(QWidget *parent)
QWidget *widget = new QWidget(parent); QWidget *widget = new QWidget(parent);
m_ui.setupUi(widget); m_ui.setupUi(widget);
m_helpManager->setupGuiHelpEngine();
updateFilterPage(); // does call setupData on the engine updateFilterPage(); // does call setupData on the engine
connect(m_ui.attributeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), connect(m_ui.attributeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
@@ -86,6 +90,8 @@ QWidget *FilterSettingsPage::createPage(QWidget *parent)
connect(m_ui.filterAddButton, SIGNAL(clicked()), this, SLOT(addFilter())); connect(m_ui.filterAddButton, SIGNAL(clicked()), this, SLOT(addFilter()));
connect(m_ui.filterRemoveButton, SIGNAL(clicked()), this, connect(m_ui.filterRemoveButton, SIGNAL(clicked()), this,
SLOT(removeFilter())); SLOT(removeFilter()));
connect(Core::HelpManager::instance(), SIGNAL(documentationChanged()),
this, SLOT(updateFilterPage()));
if (m_searchKeywords.isEmpty()) { if (m_searchKeywords.isEmpty()) {
m_searchKeywords = m_ui.filterGroupBox->title() + QLatin1Char(' ') m_searchKeywords = m_ui.filterGroupBox->title() + QLatin1Char(' ')
@@ -100,7 +106,7 @@ void FilterSettingsPage::updateFilterPage()
m_ui.attributeWidget->clear(); m_ui.attributeWidget->clear();
m_filterMapBackup.clear(); m_filterMapBackup.clear();
const QHelpEngineCore &engine = HelpManager::helpEngineCore(); const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
const QStringList &filters = engine.customFilters(); const QStringList &filters = engine.customFilters();
foreach (const QString &filter, filters) { foreach (const QString &filter, filters) {
const QStringList &attributes = engine.filterAttributes(filter); const QStringList &attributes = engine.filterAttributes(filter);
@@ -114,8 +120,10 @@ void FilterSettingsPage::updateFilterPage()
foreach (const QString &attribute, attributes) foreach (const QString &attribute, attributes)
new QTreeWidgetItem(m_ui.attributeWidget, QStringList(attribute)); new QTreeWidgetItem(m_ui.attributeWidget, QStringList(attribute));
if (m_filterMap.keys().count()) if (m_filterMap.keys().isEmpty()) {
m_ui.filterWidget->setCurrentRow(0); m_ui.filterWidget->setCurrentRow(0);
updateAttributes(m_ui.filterWidget->currentItem());
}
} }
void FilterSettingsPage::updateAttributes(QListWidgetItem *item) void FilterSettingsPage::updateAttributes(QListWidgetItem *item)
@@ -208,7 +216,7 @@ void FilterSettingsPage::apply()
} }
if (changed) { if (changed) {
QHelpEngineCore *engine = &HelpManager::helpEngineCore(); QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
foreach (const QString &filter, m_removedFilters) foreach (const QString &filter, m_removedFilters)
engine->removeCustomFilter(filter); engine->removeCustomFilter(filter);
@@ -226,3 +234,8 @@ bool FilterSettingsPage::matches(const QString &s) const
{ {
return m_searchKeywords.contains(s, Qt::CaseInsensitive); return m_searchKeywords.contains(s, Qt::CaseInsensitive);
} }
void FilterSettingsPage::setHelpManager(LocalHelpManager *manager)
{
m_helpManager = manager;
}

View File

@@ -36,6 +36,8 @@
namespace Help { namespace Help {
namespace Internal { namespace Internal {
class LocalHelpManager;
class FilterSettingsPage : public Core::IOptionsPage class FilterSettingsPage : public Core::IOptionsPage
{ {
Q_OBJECT Q_OBJECT
@@ -55,6 +57,8 @@ public:
void finish() {} void finish() {}
virtual bool matches(const QString &s) const; virtual bool matches(const QString &s) const;
void setHelpManager(LocalHelpManager *manager);
signals: signals:
void filtersChanged(); void filtersChanged();
@@ -73,6 +77,8 @@ private:
QString m_searchKeywords; QString m_searchKeywords;
QStringList m_removedFilters; QStringList m_removedFilters;
LocalHelpManager *m_helpManager;
}; };
} // namespace Help } // namespace Help

View File

@@ -44,7 +44,7 @@
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtHelp/QHelpEngineCore> #include <QtHelp/QHelpEngine>
#if !defined(QT_NO_WEBKIT) #if !defined(QT_NO_WEBKIT)
#include <QtWebKit/QWebSettings> #include <QtWebKit/QWebSettings>
@@ -94,7 +94,7 @@ QWidget *GeneralSettingsPage::createPage(QWidget *parent)
m_ui.sizeComboBox->setEditable(false); m_ui.sizeComboBox->setEditable(false);
m_ui.styleComboBox->setEditable(false); m_ui.styleComboBox->setEditable(false);
const QHelpEngineCore &engine = HelpManager::helpEngineCore(); const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
m_font = qVariantValue<QFont>(engine.customValue(QLatin1String("font"), m_font)); m_font = qVariantValue<QFont>(engine.customValue(QLatin1String("font"), m_font));
updateFontSize(); updateFontSize();
@@ -163,7 +163,7 @@ void GeneralSettingsPage::apply()
if (weight >= 0) // Weight < 0 asserts... if (weight >= 0) // Weight < 0 asserts...
newFont.setWeight(weight); newFont.setWeight(weight);
QHelpEngineCore *engine = &HelpManager::helpEngineCore(); QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
engine->setCustomValue(QLatin1String("font"), newFont); engine->setCustomValue(QLatin1String("font"), newFont);
if (newFont != m_font) if (newFont != m_font)
@@ -197,7 +197,7 @@ void GeneralSettingsPage::setBlankPage()
void GeneralSettingsPage::setDefaultPage() void GeneralSettingsPage::setDefaultPage()
{ {
const QString &defaultHomePage = HelpManager::helpEngineCore() const QString &defaultHomePage = LocalHelpManager::helpEngine()
.customValue(QLatin1String("DefaultHomePage"), QString()).toString(); .customValue(QLatin1String("DefaultHomePage"), QString()).toString();
m_ui.homePageLineEdit->setText(defaultHomePage); m_ui.homePageLineEdit->setText(defaultHomePage);
} }
@@ -214,7 +214,7 @@ void GeneralSettingsPage::importBookmarks()
QFile file(fileName); QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) { if (file.open(QIODevice::ReadOnly)) {
const BookmarkManager &manager = HelpManager::bookmarkManager(); const BookmarkManager &manager = LocalHelpManager::bookmarkManager();
XbelReader reader(manager.treeBookmarkModel(), manager.listBookmarkModel()); XbelReader reader(manager.treeBookmarkModel(), manager.listBookmarkModel());
if (reader.readFromFile(&file)) if (reader.readFromFile(&file))
return; return;
@@ -237,7 +237,7 @@ void GeneralSettingsPage::exportBookmarks()
QFile file(fileName); QFile file(fileName);
if (file.open(QIODevice::WriteOnly)) { if (file.open(QIODevice::WriteOnly)) {
XbelWriter writer(HelpManager::bookmarkManager().treeBookmarkModel()); XbelWriter writer(LocalHelpManager::bookmarkManager().treeBookmarkModel());
writer.writeToFile(&file); writer.writeToFile(&file);
} }
} }

View File

@@ -28,197 +28,28 @@
**************************************************************************/ **************************************************************************/
#include "helpindexfilter.h" #include "helpindexfilter.h"
#include "helpmanager.h"
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <QtGui/QIcon> #include <QtGui/QIcon>
#include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpIndexModel>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlDriver>
#include <QtSql/QSqlError>
#include <QtSql/QSqlQuery>
using namespace Locator; using namespace Locator;
using namespace Help; using namespace Help;
using namespace Help::Internal; using namespace Help::Internal;
Q_DECLARE_METATYPE(ILocatorFilter*); Q_DECLARE_METATYPE(ILocatorFilter*);
static const char linksForKeyQuery[] = "SELECT d.Title, f.Name, e.Name, "
"d.Name, a.Anchor FROM IndexTable a, FileNameTable d, FolderTable e, "
"NamespaceTable f WHERE a.FileId=d.FileId AND d.FolderId=e.Id AND "
"a.NamespaceId=f.Id AND a.Name='%1'";
// -- HelpIndexFilter::HelpFileReader
class HelpIndexFilter::HelpFileReader
{
struct dbCleaner {
dbCleaner(const QString &dbName)
: name(dbName) {}
~dbCleaner() {
QSqlDatabase::removeDatabase(name);
}
QString name;
};
public:
HelpFileReader();
~HelpFileReader();
public:
void updateHelpFiles();
QMap<QString, QUrl> linksForKey(const QString &key);
QList<FilterEntry> matchesFor(const QString &entry, ILocatorFilter *locator,
int maxHits = INT_MAX);
private:
QIcon m_icon;
bool m_initialized;
QStringList m_helpFiles;
};
HelpIndexFilter::HelpFileReader::HelpFileReader()
: m_initialized(false)
{
m_icon = QIcon(QLatin1String(":/help/images/bookmark.png"));
}
HelpIndexFilter::HelpFileReader::~HelpFileReader()
{
}
void HelpIndexFilter::HelpFileReader::updateHelpFiles()
{
m_helpFiles.clear();
const QLatin1String id("HelpIndexFilter::HelpFileReader::helpFiles");
{
QSqlDatabase db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), id);
if (db.driver()
&& db.driver()->lastError().type() == QSqlError::NoError) {
db.setDatabaseName(HelpManager::collectionFilePath());
if (db.open()) {
QSqlQuery query = QSqlQuery(db);
query.exec(QLatin1String("SELECT a.FilePath FROM NamespaceTable a"));
while (query.next())
m_helpFiles.append(query.value(0).toString());
}
}
}
QSqlDatabase::removeDatabase(id);
}
QUrl buildQUrl(const QString &nameSpace, const QString &folder,
const QString &relFileName, const QString &anchor)
{
QUrl url;
url.setScheme(QLatin1String("qthelp"));
url.setAuthority(nameSpace);
url.setPath(folder + QLatin1Char('/') + relFileName);
url.setFragment(anchor);
return url;
}
QMap<QString, QUrl>HelpIndexFilter::HelpFileReader::linksForKey(const QString &key)
{
if (!m_initialized) {
updateHelpFiles();
m_initialized = true;
}
QMap<QString, QUrl> links;
const QLatin1String sqlite("QSQLITE");
const QLatin1String name("HelpIndexFilter::HelpFileReader::linksForKey");
dbCleaner cleaner(name);
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
foreach(const QString &file, m_helpFiles) {
if (!QFile::exists(file))
continue;
db.setDatabaseName(file);
if (db.open()) {
QSqlQuery query = QSqlQuery(db);
query.setForwardOnly(true);
query.exec(QString::fromLatin1(linksForKeyQuery).arg(key));
while (query.next()) {
QString title = query.value(0).toString();
if (title.isEmpty()) // generate a title + corresponding path
title = key + QLatin1String(" : ") + query.value(3).toString();
links.insertMulti(title, buildQUrl(query.value(1).toString(),
query.value(2).toString(), query.value(3).toString(),
query.value(4).toString()));
}
}
}
}
return links;
}
QList<FilterEntry> HelpIndexFilter::HelpFileReader::matchesFor(const QString &id,
ILocatorFilter *locator, int maxHits)
{
if (!m_initialized) {
updateHelpFiles();
m_initialized = true;
}
QList<FilterEntry> entries;
const QLatin1String sqlite("QSQLITE");
const QLatin1String name("HelpIndexFilter::HelpFileReader::matchesFor");
dbCleaner cleaner(name);
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
foreach(const QString &file, m_helpFiles) {
if (!QFile::exists(file))
continue;
db.setDatabaseName(file);
if (db.open()) {
QSqlQuery query = QSqlQuery(db);
query.setForwardOnly(true);
query.exec(QString::fromLatin1("SELECT DISTINCT Name FROM "
"IndexTable WHERE Name LIKE '%%1%'").arg(id));
while (query.next()) {
const QString &key = query.value(0).toString();
if (!key.isEmpty()) {
entries.append(FilterEntry(locator, key, QVariant(),
m_icon));
if (entries.count() == maxHits)
return entries;
}
}
}
}
}
return entries;
}
// -- HelpIndexFilter
HelpIndexFilter::HelpIndexFilter() HelpIndexFilter::HelpIndexFilter()
: m_fileReader(new HelpFileReader)
{ {
setIncludedByDefault(false); setIncludedByDefault(false);
setShortcutString(QString(QLatin1Char('?'))); setShortcutString(QString(QLatin1Char('?')));
m_icon = QIcon(QLatin1String(":/help/images/bookmark.png"));
connect(&HelpManager::helpEngineCore(), SIGNAL(setupFinished()), this,
SLOT(updateHelpFiles()));
} }
HelpIndexFilter::~HelpIndexFilter() HelpIndexFilter::~HelpIndexFilter()
{ {
delete m_fileReader;
}
void HelpIndexFilter::updateHelpFiles()
{
m_fileReader->updateHelpFiles();
} }
QString HelpIndexFilter::displayName() const QString HelpIndexFilter::displayName() const
@@ -238,15 +69,23 @@ ILocatorFilter::Priority HelpIndexFilter::priority() const
QList<FilterEntry> HelpIndexFilter::matchesFor(const QString &entry) QList<FilterEntry> HelpIndexFilter::matchesFor(const QString &entry)
{ {
QStringList keywords;
if (entry.length() < 2) if (entry.length() < 2)
return m_fileReader->matchesFor(entry, this, 300); keywords = Core::HelpManager::instance()->findKeywords(entry, 300);
return m_fileReader->matchesFor(entry, this); else
keywords = Core::HelpManager::instance()->findKeywords(entry);
QList<FilterEntry> entries;
foreach (const QString &keyword, keywords)
entries.append(FilterEntry(this, keyword, QVariant(), m_icon));
return entries;
} }
void HelpIndexFilter::accept(FilterEntry selection) const void HelpIndexFilter::accept(FilterEntry selection) const
{ {
const QString &key = selection.displayName; const QString &key = selection.displayName;
const QMap<QString, QUrl> &links = m_fileReader->linksForKey(key); const QMap<QString, QUrl> &links = Core::HelpManager::instance()->linksForKeyword(key);
if (links.size() == 1) { if (links.size() == 1) {
emit linkActivated(links.begin().value()); emit linkActivated(links.begin().value());
} else if (!links.isEmpty()) { } else if (!links.isEmpty()) {

View File

@@ -32,6 +32,8 @@
#include <locator/ilocatorfilter.h> #include <locator/ilocatorfilter.h>
#include <QtGui/QIcon>
namespace Help { namespace Help {
namespace Internal { namespace Internal {
@@ -40,7 +42,6 @@ class HelpPlugin;
class HelpIndexFilter : public Locator::ILocatorFilter class HelpIndexFilter : public Locator::ILocatorFilter
{ {
Q_OBJECT Q_OBJECT
class HelpFileReader;
public: public:
HelpIndexFilter(); HelpIndexFilter();
@@ -58,11 +59,8 @@ signals:
void linkActivated(const QUrl &link) const; void linkActivated(const QUrl &link) const;
void linksActivated(const QMap<QString, QUrl> &urls, const QString &keyword) const; void linksActivated(const QMap<QString, QUrl> &urls, const QString &keyword) const;
private slots:
void updateHelpFiles();
private: private:
HelpFileReader *m_fileReader; QIcon m_icon;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -30,38 +30,29 @@
#include "helpmanager.h" #include "helpmanager.h"
#include "bookmarkmanager.h" #include "bookmarkmanager.h"
#include <coreplugin/icore.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/helpmanager.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QMutexLocker> #include <QtCore/QMutexLocker>
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpEngineCore>
using namespace Help; using namespace Help::Internal;
bool HelpManager::m_guiNeedsSetup = true; QMutex LocalHelpManager::m_guiMutex;
bool HelpManager::m_needsCollectionFile = true; QHelpEngine* LocalHelpManager::m_guiEngine = 0;
QMutex HelpManager::m_guiMutex; QMutex LocalHelpManager::m_bkmarkMutex;
QHelpEngine* HelpManager::m_guiEngine = 0; BookmarkManager* LocalHelpManager::m_bookmarkManager = 0;
QMutex HelpManager::m_coreMutex; LocalHelpManager::LocalHelpManager(QObject *parent)
QHelpEngineCore* HelpManager::m_coreEngine = 0;
HelpManager* HelpManager::m_helpManager = 0;
BookmarkManager* HelpManager::m_bookmarkManager = 0;
HelpManager::HelpManager(QObject *parent)
: QObject(parent) : QObject(parent)
, m_guiNeedsSetup(true)
, m_needsCollectionFile(true)
{ {
Q_ASSERT(!m_helpManager);
m_helpManager = this;
} }
HelpManager::~HelpManager() LocalHelpManager::~LocalHelpManager()
{ {
if (m_bookmarkManager) { if (m_bookmarkManager) {
m_bookmarkManager->saveBookmarks(); m_bookmarkManager->saveBookmarks();
@@ -71,88 +62,27 @@ HelpManager::~HelpManager()
delete m_guiEngine; delete m_guiEngine;
m_guiEngine = 0; m_guiEngine = 0;
delete m_coreEngine;
m_coreEngine = 0;
} }
HelpManager& HelpManager::instance() void LocalHelpManager::setupGuiHelpEngine()
{
Q_ASSERT(m_helpManager);
return *m_helpManager;
}
void HelpManager::setupGuiHelpEngine()
{ {
if (m_needsCollectionFile) { if (m_needsCollectionFile) {
m_needsCollectionFile = false; m_needsCollectionFile = false;
(&helpEngine())->setCollectionFile(collectionFilePath()); helpEngine().setCollectionFile(Core::HelpManager::collectionFilePath());
} }
if (m_guiNeedsSetup) { if (m_guiNeedsSetup) {
m_guiNeedsSetup = false; m_guiNeedsSetup = false;
(&helpEngine())->setupData(); helpEngine().setupData();
} }
} }
bool HelpManager::guiEngineNeedsUpdate() const void LocalHelpManager::setEngineNeedsUpdate()
{ {
return m_guiNeedsSetup;
}
void HelpManager::handleHelpRequest(const QString &url)
{
emit helpRequested(QUrl(url));
}
void HelpManager::verifyDocumenation()
{
QStringList nameSpacesToUnregister;
QHelpEngineCore *engine = &helpEngineCore();
const QStringList &registeredDocs = engine->registeredDocumentations();
foreach (const QString &nameSpace, registeredDocs) {
const QString &file = engine->documentationFileName(nameSpace);
if (!QFileInfo(file).exists())
nameSpacesToUnregister.append(nameSpace);
}
if (!nameSpacesToUnregister.isEmpty())
unregisterDocumentation(nameSpacesToUnregister);
}
void HelpManager::registerDocumentation(const QStringList &files)
{
QHelpEngineCore *engine = &helpEngineCore();
foreach (const QString &file, files) {
const QString &nameSpace = engine->namespaceName(file);
if (nameSpace.isEmpty())
continue;
if (!engine->registeredDocumentations().contains(nameSpace)) {
if (engine->registerDocumentation(file)) {
m_guiNeedsSetup = true; m_guiNeedsSetup = true;
} else {
qWarning() << "Error registering namespace '" << nameSpace
<< "' from file '" << file << "':" << engine->error();
}
}
}
} }
void HelpManager::unregisterDocumentation(const QStringList &nameSpaces) QHelpEngine &LocalHelpManager::helpEngine()
{
QHelpEngineCore *engine = &helpEngineCore();
foreach (const QString &nameSpace, nameSpaces) {
const QString &file = engine->documentationFileName(nameSpace);
if (engine->unregisterDocumentation(nameSpace)) {
m_guiNeedsSetup = true;
} else {
qWarning() << "Error unregistering namespace '" << nameSpace
<< "' from file '" << file << "': " << engine->error();
}
}
}
QHelpEngine &HelpManager::helpEngine()
{ {
if (!m_guiEngine) { if (!m_guiEngine) {
QMutexLocker _(&m_guiMutex); QMutexLocker _(&m_guiMutex);
@@ -164,34 +94,18 @@ QHelpEngine &HelpManager::helpEngine()
return *m_guiEngine; return *m_guiEngine;
} }
QString HelpManager::collectionFilePath() BookmarkManager& LocalHelpManager::bookmarkManager()
{
const QFileInfo fi(Core::ICore::instance()->settings()->fileName());
const QDir directory(fi.absolutePath() + QLatin1String("/qtcreator"));
if (!directory.exists())
directory.mkpath(directory.absolutePath());
return QDir::cleanPath(directory.absolutePath() + QLatin1String("/helpcollection.qhc"));
}
QHelpEngineCore& HelpManager::helpEngineCore()
{
if (!m_coreEngine) {
QMutexLocker _(&m_coreMutex);
if (!m_coreEngine) {
m_coreEngine = new QHelpEngineCore(collectionFilePath());
m_coreEngine->setAutoSaveFilter(false);
m_coreEngine->setCurrentFilter(tr("Unfiltered"));
m_coreEngine->setupData();
}
}
return *m_coreEngine;
}
BookmarkManager& HelpManager::bookmarkManager()
{ {
if (!m_bookmarkManager) {
QMutexLocker _(&m_bkmarkMutex);
if (!m_bookmarkManager) { if (!m_bookmarkManager) {
m_bookmarkManager = new BookmarkManager; m_bookmarkManager = new BookmarkManager;
m_bookmarkManager->setupBookmarkModels(); m_bookmarkManager->setupBookmarkModels();
const QString &url = QString::fromLatin1("qthelp://com.nokia.qtcreator."
"%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
.arg(IDE_VERSION_RELEASE);
helpEngine().setCustomValue(QLatin1String("DefaultHomePage"), url);
}
} }
return *m_bookmarkManager; return *m_bookmarkManager;
} }

View File

@@ -27,66 +27,44 @@
** **
**************************************************************************/ **************************************************************************/
#ifndef HELPMANAGER_H #ifndef LOCALHELPMANAGER_H
#define HELPMANAGER_H #define LOCALHELPMANAGER_H
#include "help_global.h"
#include <QtCore/QMutex> #include <QtCore/QMutex>
#include <QtCore/QObject> #include <QtCore/QObject>
QT_FORWARD_DECLARE_CLASS(QHelpEngine) QT_FORWARD_DECLARE_CLASS(QHelpEngine)
QT_FORWARD_DECLARE_CLASS(QHelpEngineCore)
QT_FORWARD_DECLARE_CLASS(QString)
QT_FORWARD_DECLARE_CLASS(QStringList)
QT_FORWARD_DECLARE_CLASS(QUrl)
class BookmarkManager; class BookmarkManager;
namespace Help { namespace Help {
namespace Internal {
class HELP_EXPORT HelpManager : public QObject class LocalHelpManager : public QObject
{ {
Q_OBJECT Q_OBJECT
public:
HelpManager(QObject *parent = 0);
~HelpManager();
static HelpManager& instance(); public:
LocalHelpManager(QObject *parent = 0);
~LocalHelpManager();
void setupGuiHelpEngine(); void setupGuiHelpEngine();
bool guiEngineNeedsUpdate() const; void setEngineNeedsUpdate();
void verifyDocumenation();
void registerDocumentation(const QStringList &fileNames);
void unregisterDocumentation(const QStringList &nameSpaces);
static QHelpEngine& helpEngine(); static QHelpEngine& helpEngine();
static QString collectionFilePath();
static QHelpEngineCore& helpEngineCore();
static BookmarkManager& bookmarkManager(); static BookmarkManager& bookmarkManager();
public slots:
void handleHelpRequest(const QString &url);
signals:
void helpRequested(const QUrl &url);
private: private:
static bool m_guiNeedsSetup; bool m_guiNeedsSetup;
static bool m_needsCollectionFile; bool m_needsCollectionFile;
static QMutex m_guiMutex; static QMutex m_guiMutex;
static QHelpEngine *m_guiEngine; static QHelpEngine *m_guiEngine;
static QMutex m_coreMutex; static QMutex m_bkmarkMutex;
static QHelpEngineCore *m_coreEngine;
static HelpManager *m_helpManager;
static BookmarkManager *m_bookmarkManager; static BookmarkManager *m_bookmarkManager;
}; };
} // Internal
} // Help } // Help
#endif // HELPMANAGER_H #endif // LOCALHELPMANAGER_H

View File

@@ -54,6 +54,7 @@
#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/findplaceholder.h> #include <coreplugin/findplaceholder.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <coreplugin/minisplitter.h> #include <coreplugin/minisplitter.h>
#include <coreplugin/modemanager.h> #include <coreplugin/modemanager.h>
#include <coreplugin/rightpane.h> #include <coreplugin/rightpane.h>
@@ -78,10 +79,8 @@
#include <QtGui/QToolBar> #include <QtGui/QToolBar>
#include <QtHelp/QHelpEngine> #include <QtHelp/QHelpEngine>
#include <QtHelp/QHelpEngineCore>
using namespace Core::Constants; using namespace Core::Constants;
using namespace Help;
using namespace Help::Internal; using namespace Help::Internal;
const char * const SB_INDEX = QT_TRANSLATE_NOOP("Help::Internal::HelpPlugin", "Index"); const char * const SB_INDEX = QT_TRANSLATE_NOOP("Help::Internal::HelpPlugin", "Index");
@@ -141,22 +140,20 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
qApp->installTranslator(qhelptr); qApp->installTranslator(qhelptr);
} }
addAutoReleasedObject(m_helpManager = new HelpManager(this)); addAutoReleasedObject(m_helpManager = new LocalHelpManager(this));
addAutoReleasedObject(m_openPagesManager = new OpenPagesManager(this)); addAutoReleasedObject(m_openPagesManager = new OpenPagesManager(this));
addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage()); addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage());
addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage()); addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage());
addAutoReleasedObject(m_generalSettingsPage = new GeneralSettingsPage()); addAutoReleasedObject(m_generalSettingsPage = new GeneralSettingsPage());
connect(m_docSettingsPage, SIGNAL(documentationChanged()), m_filterSettingsPage,
SLOT(updateFilterPage()));
connect(m_generalSettingsPage, SIGNAL(fontChanged()), this, connect(m_generalSettingsPage, SIGNAL(fontChanged()), this,
SLOT(fontChanged())); SLOT(fontChanged()));
connect(m_helpManager, SIGNAL(helpRequested(QUrl)), this, connect(Core::HelpManager::instance(), SIGNAL(helpRequested(QUrl)), this,
SLOT(handleHelpRequest(QUrl))); SLOT(handleHelpRequest(QUrl)));
m_filterSettingsPage->setHelpManager(m_helpManager);
connect(m_filterSettingsPage, SIGNAL(filtersChanged()), this, connect(m_filterSettingsPage, SIGNAL(filtersChanged()), this,
SLOT(setupHelpEngineIfNeeded())); SLOT(setupHelpEngineIfNeeded()));
connect(m_docSettingsPage, SIGNAL(documentationChanged()), this, connect(Core::HelpManager::instance(), SIGNAL(documentationChanged()), this,
SLOT(setupHelpEngineIfNeeded())); SLOT(setupHelpEngineIfNeeded()));
m_splitter = new Core::MiniSplitter; m_splitter = new Core::MiniSplitter;
@@ -314,30 +311,20 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
void HelpPlugin::extensionsInitialized() void HelpPlugin::extensionsInitialized()
{ {
const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3") const QString &nsInternal = QString::fromLatin1("com.nokia.qtcreator.%1%2%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
const QRegExp filterRegExp(QLatin1String("Qt Creator \\d*\\.\\d*\\.\\d*"));
QHelpEngineCore *engine = &m_helpManager->helpEngineCore();
const QStringList &filters = engine->customFilters();
foreach (const QString &filter, filters) {
if (filterRegExp.exactMatch(filter) && filter != filterInternal)
engine->removeCustomFilter(filter);
}
const QString &docInternal = QString::fromLatin1("com.nokia.qtcreator.%1%2%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE); .arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
foreach (const QString &ns, engine->registeredDocumentations()) { Core::HelpManager *helpManager = Core::HelpManager::instance();
foreach (const QString &ns, helpManager->registeredNamespaces()) {
if (ns.startsWith(QLatin1String("com.nokia.qtcreator.")) if (ns.startsWith(QLatin1String("com.nokia.qtcreator."))
&& ns != docInternal) && ns != nsInternal)
m_helpManager->unregisterDocumentation(QStringList() << ns); helpManager->unregisterDocumentation(QStringList() << ns);
} }
QStringList filesToRegister; QStringList filesToRegister;
// Explicitly register qml.qch if located in creator directory. This is only // Explicitly register qml.qch if located in creator directory. This is only
// needed for the creator-qml package, were we want to ship the documentation // needed for the creator-qml package, were we want to ship the documentation
// without a qt development version. // without a qt development version. TODO: is this still really needed, remove
const QString &appPath = QCoreApplication::applicationDirPath(); const QString &appPath = QCoreApplication::applicationDirPath();
filesToRegister.append(QDir::cleanPath(QDir::cleanPath(appPath filesToRegister.append(QDir::cleanPath(QDir::cleanPath(appPath
+ QLatin1String(DOCPATH "qml.qch")))); + QLatin1String(DOCPATH "qml.qch"))));
@@ -345,24 +332,6 @@ void HelpPlugin::extensionsInitialized()
// we might need to register creators inbuild help // we might need to register creators inbuild help
filesToRegister.append(QDir::cleanPath(appPath filesToRegister.append(QDir::cleanPath(appPath
+ QLatin1String(DOCPATH "qtcreator.qch"))); + QLatin1String(DOCPATH "qtcreator.qch")));
// this comes from the installer
const QLatin1String key("AddedDocs");
const QString &addedDocs = engine->customValue(key).toString();
if (!addedDocs.isEmpty()) {
engine->removeCustomValue(key);
filesToRegister += addedDocs.split(QLatin1Char(';'));
}
updateFilterComboBox();
m_helpManager->verifyDocumenation();
m_helpManager->registerDocumentation(filesToRegister);
const QString &url = QString::fromLatin1("qthelp://com.nokia.qtcreator."
"%1%2%3/doc/index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR)
.arg(IDE_VERSION_RELEASE);
engine->setCustomValue(QLatin1String("DefaultHomePage"), url);
connect(engine, SIGNAL(setupFinished()), this, SLOT(updateFilterComboBox()));
} }
void HelpPlugin::aboutToShutdown() void HelpPlugin::aboutToShutdown()
@@ -425,7 +394,7 @@ void HelpPlugin::setupUi()
// connect(shortcut, SIGNAL(activated()), this, SLOT(activateSearch())); // connect(shortcut, SIGNAL(activated()), this, SLOT(activateSearch()));
// shortcutMap.insert(QLatin1String(SB_SEARCH), cmd); // shortcutMap.insert(QLatin1String(SB_SEARCH), cmd);
BookmarkManager *manager = &HelpManager::bookmarkManager(); BookmarkManager *manager = &LocalHelpManager::bookmarkManager();
BookmarkWidget *bookmarkWidget = new BookmarkWidget(manager, 0, false); BookmarkWidget *bookmarkWidget = new BookmarkWidget(manager, 0, false);
bookmarkWidget->setWindowTitle(tr(SB_BOOKMARKS)); bookmarkWidget->setWindowTitle(tr(SB_BOOKMARKS));
m_bookmarkItem = new Core::SideBarItem(bookmarkWidget, QLatin1String(SB_BOOKMARKS)); m_bookmarkItem = new Core::SideBarItem(bookmarkWidget, QLatin1String(SB_BOOKMARKS));
@@ -470,24 +439,36 @@ void HelpPlugin::setupUi()
void HelpPlugin::resetFilter() void HelpPlugin::resetFilter()
{ {
const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
const QRegExp filterRegExp(QLatin1String("Qt Creator \\d*\\.\\d*\\.\\d*"));
QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
const QStringList &filters = engine->customFilters();
foreach (const QString &filter, filters) {
if (filterRegExp.exactMatch(filter) && filter != filterInternal)
engine->removeCustomFilter(filter);
}
const QLatin1String weAddedFilterKey("UnfilteredFilterInserted"); const QLatin1String weAddedFilterKey("UnfilteredFilterInserted");
const QLatin1String previousFilterNameKey("UnfilteredFilterName"); const QLatin1String previousFilterNameKey("UnfilteredFilterName");
if (engine->customValue(weAddedFilterKey).toInt() == 1) {
QHelpEngineCore *core = &m_helpManager->helpEngineCore();
if (core->customValue(weAddedFilterKey).toInt() == 1) {
// we added a filter at some point, remove previously added filter // we added a filter at some point, remove previously added filter
const QString &filter = core->customValue(previousFilterNameKey).toString(); const QString &filter = engine->customValue(previousFilterNameKey).toString();
if (!filter.isEmpty()) if (!filter.isEmpty())
core->removeCustomFilter(filter); engine->removeCustomFilter(filter);
} }
// potentially remove a filter with new name // potentially remove a filter with new name
const QString filterName = tr("Unfiltered"); const QString filterName = tr("Unfiltered");
core->removeCustomFilter(filterName); engine->removeCustomFilter(filterName);
core->addCustomFilter(filterName, QStringList()); engine->addCustomFilter(filterName, QStringList());
core->setCustomValue(weAddedFilterKey, 1); engine->setCustomValue(weAddedFilterKey, 1);
core->setCustomValue(previousFilterNameKey, filterName); engine->setCustomValue(previousFilterNameKey, filterName);
(&m_helpManager->helpEngine())->setCurrentFilter(filterName); engine->setCurrentFilter(filterName);
updateFilterComboBox();
connect(engine, SIGNAL(setupFinished()), this, SLOT(updateFilterComboBox()));
} }
void HelpPlugin::createRightPaneContextViewer() void HelpPlugin::createRightPaneContextViewer()
@@ -595,9 +576,9 @@ void HelpPlugin::modeChanged(Core::IMode *mode)
qApp->processEvents(); qApp->processEvents();
qApp->setOverrideCursor(Qt::WaitCursor); qApp->setOverrideCursor(Qt::WaitCursor);
m_helpManager->setupGuiHelpEngine();
setupUi(); setupUi();
resetFilter(); resetFilter();
m_helpManager->setupGuiHelpEngine();
OpenPagesManager::instance().setupInitialPages(); OpenPagesManager::instance().setupInitialPages();
qApp->restoreOverrideCursor(); qApp->restoreOverrideCursor();
@@ -633,7 +614,7 @@ void HelpPlugin::fontChanged()
if (!m_helpViewerForSideBar) if (!m_helpViewerForSideBar)
createRightPaneContextViewer(); createRightPaneContextViewer();
const QHelpEngineCore &engine = m_helpManager->helpEngineCore(); const QHelpEngine &engine = LocalHelpManager::helpEngine();
QFont font = qVariantValue<QFont>(engine.customValue(QLatin1String("font"), QFont font = qVariantValue<QFont>(engine.customValue(QLatin1String("font"),
m_helpViewerForSideBar->viewerFont())); m_helpViewerForSideBar->viewerFont()));
@@ -647,7 +628,8 @@ void HelpPlugin::fontChanged()
void HelpPlugin::setupHelpEngineIfNeeded() void HelpPlugin::setupHelpEngineIfNeeded()
{ {
if (Core::ICore::instance()->modeManager()->currentMode() == m_mode) m_helpManager->setEngineNeedsUpdate();
if (Core::ModeManager::instance()->currentMode() == m_mode)
m_helpManager->setupGuiHelpEngine(); m_helpManager->setupGuiHelpEngine();
} }
@@ -656,7 +638,7 @@ HelpViewer* HelpPlugin::viewerForContextMode()
using namespace Core; using namespace Core;
bool showSideBySide = false; bool showSideBySide = false;
const QHelpEngineCore &engine = m_helpManager->helpEngineCore(); const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current(); RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
switch (engine.customValue(QLatin1String("ContextHelpOption"), 0).toInt()) { switch (engine.customValue(QLatin1String("ContextHelpOption"), 0).toInt()) {
case 0: { case 0: {
@@ -713,7 +695,7 @@ void HelpPlugin::activateContext()
// Find out what to show // Find out what to show
if (IContext *context = m_core->currentContextObject()) { if (IContext *context = m_core->currentContextObject()) {
id = context->contextHelpId(); id = context->contextHelpId();
links = m_helpManager->helpEngineCore().linksForIdentifier(id); links = Core::HelpManager::instance()->linksForIdentifier(id);
} }
if (HelpViewer* viewer = viewerForContextMode()) { if (HelpViewer* viewer = viewerForContextMode()) {
@@ -803,7 +785,7 @@ QToolBar *HelpPlugin::createToolBar()
void HelpPlugin::updateFilterComboBox() void HelpPlugin::updateFilterComboBox()
{ {
const QHelpEngine &engine = m_helpManager->helpEngine(); const QHelpEngine &engine = LocalHelpManager::helpEngine();
QString curFilter = m_filterComboBox->currentText(); QString curFilter = m_filterComboBox->currentText();
if (curFilter.isEmpty()) if (curFilter.isEmpty())
curFilter = engine.currentFilter(); curFilter = engine.currentFilter();
@@ -817,7 +799,7 @@ void HelpPlugin::updateFilterComboBox()
void HelpPlugin::filterDocumentation(const QString &customFilter) void HelpPlugin::filterDocumentation(const QString &customFilter)
{ {
(&m_helpManager->helpEngine())->setCurrentFilter(customFilter); LocalHelpManager::helpEngine().setCurrentFilter(customFilter);
} }
void HelpPlugin::addBookmark() void HelpPlugin::addBookmark()
@@ -828,7 +810,7 @@ void HelpPlugin::addBookmark()
if (url.isEmpty() || url == Help::Constants::AboutBlank) if (url.isEmpty() || url == Help::Constants::AboutBlank)
return; return;
BookmarkManager *manager = &HelpManager::bookmarkManager(); BookmarkManager *manager = &LocalHelpManager::bookmarkManager();
manager->showBookmarkDialog(m_centralWidget, viewer->title(), url); manager->showBookmarkDialog(m_centralWidget, viewer->title(), url);
} }
@@ -837,7 +819,7 @@ void HelpPlugin::handleHelpRequest(const QUrl &url)
if (HelpViewer::launchWithExternalApp(url)) if (HelpViewer::launchWithExternalApp(url))
return; return;
if (m_helpManager->helpEngineCore().findFile(url).isValid()) { if (Core::HelpManager::instance()->findFile(url).isValid()) {
if (url.queryItemValue(QLatin1String("view")) == QLatin1String("split")) { if (url.queryItemValue(QLatin1String("view")) == QLatin1String("split")) {
if (HelpViewer* viewer = viewerForContextMode()) if (HelpViewer* viewer = viewerForContextMode())
viewer->setSource(url); viewer->setSource(url);

View File

@@ -49,8 +49,6 @@ class SideBarItem;
} // Core } // Core
namespace Help { namespace Help {
class HelpManager;
namespace Internal { namespace Internal {
class CentralWidget; class CentralWidget;
class DocSettingsPage; class DocSettingsPage;
@@ -58,6 +56,7 @@ class FilterSettingsPage;
class GeneralSettingsPage; class GeneralSettingsPage;
class HelpMode; class HelpMode;
class HelpViewer; class HelpViewer;
class LocalHelpManager;
class OpenPagesManager; class OpenPagesManager;
class SearchWidget; class SearchWidget;
@@ -129,7 +128,7 @@ private:
Core::SideBar *m_sideBar; Core::SideBar *m_sideBar;
bool m_firstModeChange; bool m_firstModeChange;
HelpManager *m_helpManager; LocalHelpManager *m_helpManager;
OpenPagesManager *m_openPagesManager; OpenPagesManager *m_openPagesManager;
Core::MiniSplitter *m_splitter; Core::MiniSplitter *m_splitter;

View File

@@ -40,7 +40,7 @@
#include <QtGui/QDesktopServices> #include <QtGui/QDesktopServices>
#include <QtGui/QMouseEvent> #include <QtGui/QMouseEvent>
#include <QtHelp/QHelpEngineCore> #include <QtHelp/QHelpEngine>
using namespace Help::Internal; using namespace Help::Internal;
@@ -126,7 +126,7 @@ QString HelpViewer::mimeFromUrl(const QUrl &url)
bool HelpViewer::launchWithExternalApp(const QUrl &url) bool HelpViewer::launchWithExternalApp(const QUrl &url)
{ {
if (isLocalUrl(url)) { if (isLocalUrl(url)) {
const QHelpEngineCore &helpEngine = Help::HelpManager::helpEngineCore(); const QHelpEngineCore &helpEngine = LocalHelpManager::helpEngine();
const QUrl &resolvedUrl = helpEngine.findFile(url); const QUrl &resolvedUrl = helpEngine.findFile(url);
if (!resolvedUrl.isValid()) if (!resolvedUrl.isValid())
return false; return false;
@@ -155,7 +155,7 @@ bool HelpViewer::launchWithExternalApp(const QUrl &url)
void HelpViewer::home() void HelpViewer::home()
{ {
const QHelpEngineCore &engine = Help::HelpManager::helpEngineCore(); const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
QString homepage = engine.customValue(QLatin1String("HomePage"), QString homepage = engine.customValue(QLatin1String("HomePage"),
QLatin1String("")).toString(); QLatin1String("")).toString();

View File

@@ -44,7 +44,7 @@
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtGui/QWheelEvent> #include <QtGui/QWheelEvent>
#include <QtHelp/QHelpEngineCore> #include <QtHelp/QHelpEngine>
#include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply> #include <QtNetwork/QNetworkReply>
@@ -125,7 +125,7 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
const QNetworkRequest &request, QIODevice* /*outgoingData*/) const QNetworkRequest &request, QIODevice* /*outgoingData*/)
{ {
QString url = request.url().toString(); QString url = request.url().toString();
const QHelpEngineCore &engine = HelpManager::helpEngineCore(); const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
// TODO: For some reason the url to load is already wrong (passed from webkit) // TODO: For some reason the url to load is already wrong (passed from webkit)
// though the css file and the references inside should work that way. One // though the css file and the references inside should work that way. One
// possible problem might be that the css is loaded at the same level as the // possible problem might be that the css is loaded at the same level as the
@@ -266,7 +266,7 @@ QFont HelpViewer::viewerFont() const
QWebSettings* webSettings = QWebSettings::globalSettings(); QWebSettings* webSettings = QWebSettings::globalSettings();
QFont font(QApplication::font().family(), QFont font(QApplication::font().family(),
webSettings->fontSize(QWebSettings::DefaultFontSize)); webSettings->fontSize(QWebSettings::DefaultFontSize));
const QHelpEngineCore &engine = HelpManager::helpEngineCore(); const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
return qVariantValue<QFont>(engine.customValue(QLatin1String("font"), return qVariantValue<QFont>(engine.customValue(QLatin1String("font"),
font)); font));
} }

View File

@@ -41,7 +41,7 @@
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
#include <QtGui/QTreeView> #include <QtGui/QTreeView>
#include <QtHelp/QHelpEngineCore> #include <QtHelp/QHelpEngine>
using namespace Help::Internal; using namespace Help::Internal;
@@ -118,7 +118,7 @@ QStringList splitString(const QVariant &value)
void OpenPagesManager::setupInitialPages() void OpenPagesManager::setupInitialPages()
{ {
const QHelpEngineCore &engine = HelpManager::helpEngineCore(); const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
const int option = engine.customValue(QLatin1String("StartOption"), const int option = engine.customValue(QLatin1String("StartOption"),
Help::Constants::ShowLastPages).toInt(); Help::Constants::ShowLastPages).toInt();
QString homePage = engine.customValue(QLatin1String("DefaultHomePage"), QString homePage = engine.customValue(QLatin1String("DefaultHomePage"),

View File

@@ -100,7 +100,7 @@ void SearchWidget::showEvent(QShowEvent *event)
QVBoxLayout *vLayout = new QVBoxLayout(this); QVBoxLayout *vLayout = new QVBoxLayout(this);
vLayout->setMargin(4); vLayout->setMargin(4);
searchEngine = (&HelpManager::helpEngine())->searchEngine(); searchEngine = (&LocalHelpManager::helpEngine())->searchEngine();
resultWidget = searchEngine->resultWidget(); resultWidget = searchEngine->resultWidget();
QHelpSearchQueryWidget *queryWidget = searchEngine->queryWidget(); QHelpSearchQueryWidget *queryWidget = searchEngine->queryWidget();
@@ -126,7 +126,7 @@ void SearchWidget::showEvent(QShowEvent *event)
connect(searchEngine, SIGNAL(indexingFinished()), this, connect(searchEngine, SIGNAL(indexingFinished()), this,
SLOT(indexingFinished())); SLOT(indexingFinished()));
QMetaObject::invokeMethod(&HelpManager::helpEngine(), "setupFinished", QMetaObject::invokeMethod(&LocalHelpManager::helpEngine(), "setupFinished",
Qt::QueuedConnection); Qt::QueuedConnection);
} }
} }

View File

@@ -114,7 +114,6 @@ plugin_qt4projectmanager.depends = plugin_texteditor
plugin_qt4projectmanager.depends += plugin_projectexplorer plugin_qt4projectmanager.depends += plugin_projectexplorer
plugin_qt4projectmanager.depends += plugin_cpptools plugin_qt4projectmanager.depends += plugin_cpptools
plugin_qt4projectmanager.depends += plugin_cppeditor plugin_qt4projectmanager.depends += plugin_cppeditor
plugin_qt4projectmanager.depends += plugin_help
plugin_qt4projectmanager.depends += plugin_designer plugin_qt4projectmanager.depends += plugin_designer
plugin_qt4projectmanager.depends += plugin_debugger plugin_qt4projectmanager.depends += plugin_debugger

View File

@@ -248,7 +248,7 @@ void AbstractProcessStep::stdOutput(const QString &line)
if (m_outputParserChain) if (m_outputParserChain)
m_outputParserChain->stdOutput(line); m_outputParserChain->stdOutput(line);
QTextCharFormat textCharFormat; QTextCharFormat textCharFormat;
emit addOutput(Qt::escape(line), textCharFormat); emit addOutput(line, textCharFormat);
} }
void AbstractProcessStep::processReadyReadStdError() void AbstractProcessStep::processReadyReadStdError()

View File

@@ -151,8 +151,8 @@ void BuildManager::cancel()
disconnect(m_currentBuildStep, SIGNAL(addTask(ProjectExplorer::Task)), disconnect(m_currentBuildStep, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task))); this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
disconnect(m_currentBuildStep, SIGNAL(addOutput(QString)), disconnect(m_currentBuildStep, SIGNAL(addOutput(QString, QTextCharFormat)),
this, SLOT(addToOutputWindow(QString))); this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
decrementActiveBuildSteps(m_currentBuildStep->buildConfiguration()->target()->project()); decrementActiveBuildSteps(m_currentBuildStep->buildConfiguration()->target()->project());
m_progressFutureInterface->setProgressValueAndText(m_progress*100, "Build canceled"); //TODO NBS fix in qtconcurrent m_progressFutureInterface->setProgressValueAndText(m_progress*100, "Build canceled"); //TODO NBS fix in qtconcurrent
@@ -191,8 +191,8 @@ void BuildManager::clearBuildQueue()
decrementActiveBuildSteps(bs->buildConfiguration()->target()->project()); decrementActiveBuildSteps(bs->buildConfiguration()->target()->project());
disconnect(bs, SIGNAL(addTask(ProjectExplorer::Task)), disconnect(bs, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task))); this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
disconnect(bs, SIGNAL(addOutput(QString)), disconnect(bs, SIGNAL(addOutput(QString, QTextCharFormat)),
this, SLOT(addToOutputWindow(QString))); this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
} }
m_buildQueue.clear(); m_buildQueue.clear();
@@ -344,7 +344,7 @@ void BuildManager::nextStep()
const QString projectName = m_currentBuildStep->buildConfiguration()->target()->project()->displayName(); const QString projectName = m_currentBuildStep->buildConfiguration()->target()->project()->displayName();
QTextCharFormat textCharFormat; QTextCharFormat textCharFormat;
textCharFormat.setFontWeight(QFont::Bold); textCharFormat.setFontWeight(QFont::Bold);
addToOutputWindow(tr("Running build steps for project %2...") addToOutputWindow(tr("Running build steps for project %1...")
.arg(projectName), textCharFormat); .arg(projectName), textCharFormat);
m_previousBuildStepProject = m_currentBuildStep->buildConfiguration()->target()->project(); m_previousBuildStepProject = m_currentBuildStep->buildConfiguration()->target()->project();
} }

View File

@@ -69,12 +69,14 @@ struct PROJECTEXPLORER_EXPORT Task {
QString file; QString file;
int line; int line;
QString category; QString category;
// Having a QList<QTextLayout> in Task isn't that great. It would be // Having a QList<QTextLayout::FormatRange> in Task isn't that great
// cleaner to split up the text into the logical hunks and then assemble // It would be cleaner to split up the text into
// them again (That is diffrent consumers of tasks could show them in // the logical hunks and then assemble them again
// different ways!). But then again, the wording of the text most likely // (That is different consumers of tasks could show them in
// doesn't work if you split it up, nor are our parsers anywhere near being // different ways!)
// that good. // But then again, the wording of the text most likely
// doesn't work if you split it up, nor are our parsers
// anywhere near being that good
QList<QTextLayout::FormatRange> formats; QList<QTextLayout::FormatRange> formats;
}; };

View File

@@ -235,7 +235,7 @@ FormEditorWidget *FormEditorView::widget() const
void FormEditorView::nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId) void FormEditorView::nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId)
{ {
nodeInstanceView()->nodeIdChanged(node, newId, oldId); QmlModelView::nodeIdChanged(node, newId, oldId);
} }
void FormEditorView::selectedNodesChanged(const QList<ModelNode> &selectedNodeList, void FormEditorView::selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
@@ -258,6 +258,12 @@ void FormEditorView::selectedNodesChanged(const QList<ModelNode> &selectedNodeLi
m_scene->update(); m_scene->update();
} }
void FormEditorView::scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList)
{
QmlModelView::scriptFunctionsChanged(node, scriptFunctionList);
}
AbstractFormEditorTool* FormEditorView::currentTool() const AbstractFormEditorTool* FormEditorView::currentTool() const
{ {
return m_currentTool; return m_currentTool;

View File

@@ -77,6 +77,7 @@ public:
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
const QList<ModelNode> &lastSelectedNodeList); const QList<ModelNode> &lastSelectedNodeList);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
// FormEditorView // FormEditorView
FormEditorWidget *widget() const; FormEditorWidget *widget() const;

View File

@@ -123,7 +123,7 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
m_selectOnlyContentItemsAction->setShortcut(Qt::Key_S); m_selectOnlyContentItemsAction->setShortcut(Qt::Key_S);
m_selectOnlyContentItemsAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); m_selectOnlyContentItemsAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
m_selectOnlyContentItemsAction->setCheckable(true); m_selectOnlyContentItemsAction->setCheckable(true);
m_selectOnlyContentItemsAction->setChecked(true); m_selectOnlyContentItemsAction->setChecked(false);
m_selectOnlyContentItemsAction->setIcon(QPixmap(":/icon/selection/selectonlycontentitems.png")); m_selectOnlyContentItemsAction->setIcon(QPixmap(":/icon/selection/selectonlycontentitems.png"));
addAction(m_selectOnlyContentItemsAction.data()); addAction(m_selectOnlyContentItemsAction.data());

View File

@@ -145,29 +145,34 @@ void MoveManipulator::begin(const QPointF &beginPoint)
QPointF MoveManipulator::findSnappingOffset(const QList<QRectF> &boundingRectList) QPointF MoveManipulator::findSnappingOffset(const QHash<FormEditorItem*, QRectF> &boundingRectHash)
{ {
QPointF offset; QPointF offset;
QMap<double, double> verticalOffsetMap; QMap<double, double> verticalOffsetMap;
foreach (const QRectF &boundingRect, boundingRectList) { QMap<double, double> horizontalOffsetMap;
QHashIterator<FormEditorItem*, QRectF> hashIterator(boundingRectHash);
while(hashIterator.hasNext()) {
hashIterator.next();
FormEditorItem *formEditorItem = hashIterator.key();
QRectF boundingRect = hashIterator.value();
if (!formEditorItem->qmlItemNode().hasBindingProperty("x")) {
double verticalOffset = m_snapper.snappedVerticalOffset(boundingRect); double verticalOffset = m_snapper.snappedVerticalOffset(boundingRect);
if (verticalOffset < std::numeric_limits<double>::max()) if (verticalOffset < std::numeric_limits<double>::max())
verticalOffsetMap.insert(qAbs(verticalOffset), verticalOffset); verticalOffsetMap.insert(qAbs(verticalOffset), verticalOffset);
} }
if (!formEditorItem->qmlItemNode().hasBindingProperty("y")) {
if (!verticalOffsetMap.isEmpty())
offset.rx() = verticalOffsetMap.begin().value();
QMap<double, double> horizontalOffsetMap;
foreach (const QRectF &boundingRect, boundingRectList) {
double horizontalOffset = m_snapper.snappedHorizontalOffset(boundingRect); double horizontalOffset = m_snapper.snappedHorizontalOffset(boundingRect);
if (horizontalOffset < std::numeric_limits<double>::max()) if (horizontalOffset < std::numeric_limits<double>::max())
horizontalOffsetMap.insert(qAbs(horizontalOffset), horizontalOffset); horizontalOffsetMap.insert(qAbs(horizontalOffset), horizontalOffset);
} }
}
if (!verticalOffsetMap.isEmpty())
offset.rx() = verticalOffsetMap.begin().value();
if (!horizontalOffsetMap.isEmpty()) if (!horizontalOffsetMap.isEmpty())
@@ -177,22 +182,33 @@ QPointF MoveManipulator::findSnappingOffset(const QList<QRectF> &boundingRectLis
} }
void MoveManipulator::generateSnappingLines(const QList<QRectF> &boundingRectList) void MoveManipulator::generateSnappingLines(const QHash<FormEditorItem*, QRectF> &boundingRectHash)
{ {
m_graphicsLineList = m_snapper.generateSnappingLines(boundingRectList, m_graphicsLineList = m_snapper.generateSnappingLines(boundingRectHash.values(),
m_layerItem.data(), m_layerItem.data(),
m_snapper.transformtionSpaceFormEditorItem()->sceneTransform()); m_snapper.transformtionSpaceFormEditorItem()->sceneTransform());
} }
QList<QRectF> MoveManipulator::tanslatedBoundingRects(const QList<QRectF> &boundingRectList, const QPointF& offsetVector) QHash<FormEditorItem*, QRectF> MoveManipulator::tanslatedBoundingRects(const QHash<FormEditorItem*, QRectF> &boundingRectHash, const QPointF& offsetVector)
{ {
QList<QRectF> translatedBoundingRectList; QHash<FormEditorItem*, QRectF> translatedBoundingRectHash;
foreach (const QRectF &boundingRect, boundingRectList)
translatedBoundingRectList.append(boundingRect.translated(offsetVector));
return translatedBoundingRectList; QHashIterator<FormEditorItem*, QRectF> hashIterator(boundingRectHash);
while(hashIterator.hasNext()) {
QPointF alignedOffset(offsetVector);
hashIterator.next();
FormEditorItem *formEditorItem = hashIterator.key();
QRectF boundingRect = hashIterator.value();
if (formEditorItem->qmlItemNode().hasBindingProperty("x"))
alignedOffset.setX(0);
if (formEditorItem->qmlItemNode().hasBindingProperty("y"))
alignedOffset.setY(0);
translatedBoundingRectHash.insert(formEditorItem, boundingRect.translated(offsetVector));
}
return translatedBoundingRectHash;
} }
@@ -220,8 +236,8 @@ void MoveManipulator::update(const QPointF& updatePoint, Snapping useSnapping, S
} }
if (useSnapping == UseSnapping || useSnapping == UseSnappingAndAnchoring) { if (useSnapping == UseSnapping || useSnapping == UseSnappingAndAnchoring) {
offsetVector -= findSnappingOffset(tanslatedBoundingRects(m_beginItemRectHash.values(), offsetVector)); offsetVector -= findSnappingOffset(tanslatedBoundingRects(m_beginItemRectHash, offsetVector));
generateSnappingLines(tanslatedBoundingRects(m_beginItemRectHash.values(), offsetVector)); generateSnappingLines(tanslatedBoundingRects(m_beginItemRectHash, offsetVector));
} }
foreach (FormEditorItem* item, m_itemList) { foreach (FormEditorItem* item, m_itemList) {
@@ -255,7 +271,7 @@ void MoveManipulator::update(const QPointF& updatePoint, Snapping useSnapping, S
anchors.setMargin(AnchorLine::VerticalCenter, m_beginVerticalCenterHash.value(item) + offsetVector.y()); anchors.setMargin(AnchorLine::VerticalCenter, m_beginVerticalCenterHash.value(item) + offsetVector.y());
} }
item->qmlItemNode().setPosition(positionInContainerSpace); setPosition(item->qmlItemNode(), positionInContainerSpace);
} else { } else {
item->qmlItemNode().modelNode().variantProperty("x").setValue(qRound(positionInContainerSpace.x())); item->qmlItemNode().modelNode().variantProperty("x").setValue(qRound(positionInContainerSpace.x()));
item->qmlItemNode().modelNode().variantProperty("y").setValue(qRound(positionInContainerSpace.y())); item->qmlItemNode().modelNode().variantProperty("y").setValue(qRound(positionInContainerSpace.y()));
@@ -345,7 +361,7 @@ void MoveManipulator::moveBy(double deltaX, double deltaY)
anchors.setMargin(AnchorLine::VerticalCenter, anchors.instanceMargin(AnchorLine::VerticalCenter) + deltaY); anchors.setMargin(AnchorLine::VerticalCenter, anchors.instanceMargin(AnchorLine::VerticalCenter) + deltaY);
} }
item->qmlItemNode().setPosition(QPointF(item->qmlItemNode().instanceValue("x").toDouble() + deltaX, setPosition(item->qmlItemNode(), QPointF(item->qmlItemNode().instanceValue("x").toDouble() + deltaX,
item->qmlItemNode().instanceValue("y").toDouble() + deltaY)); item->qmlItemNode().instanceValue("y").toDouble() + deltaY));
} }
} }
@@ -381,4 +397,13 @@ bool MoveManipulator::isActive() const
return m_isActive; return m_isActive;
} }
void MoveManipulator::setPosition(QmlItemNode itemNode, const QPointF &position)
{
if (!itemNode.hasBindingProperty("x"))
itemNode.setVariantProperty("x", qRound(position.x()));
if (!itemNode.hasBindingProperty("y"))
itemNode.setVariantProperty("y", qRound(position.y()));
}
} }

View File

@@ -86,19 +86,21 @@ public:
protected: protected:
void setOpacityForAllElements(qreal opacity); void setOpacityForAllElements(qreal opacity);
QPointF findSnappingOffset(const QList<QRectF> &boundingRectList); QPointF findSnappingOffset(const QHash<FormEditorItem*, QRectF> &boundingRectHash);
void deleteSnapLines(); void deleteSnapLines();
QList<QRectF> tanslatedBoundingRects(const QList<QRectF> &boundingRectList, const QPointF& offset); QHash<FormEditorItem*, QRectF> tanslatedBoundingRects(const QHash<FormEditorItem*, QRectF> &boundingRectHash, const QPointF& offset);
QPointF calculateBoundingRectMovementOffset(const QPointF& updatePoint); QPointF calculateBoundingRectMovementOffset(const QPointF& updatePoint);
QRectF boundingRect(FormEditorItem* item, const QPointF& updatePoint); QRectF boundingRect(FormEditorItem* item, const QPointF& updatePoint);
void generateSnappingLines(const QList<QRectF> &boundingRectList); void generateSnappingLines(const QHash<FormEditorItem*, QRectF> &boundingRectHash);
void updateHashes(); void updateHashes();
bool itemsCanReparented() const; bool itemsCanReparented() const;
void setPosition(QmlItemNode itemNode, const QPointF &position);
private: private:
Snapper m_snapper; Snapper m_snapper;
QWeakPointer<LayerItem> m_layerItem; QWeakPointer<LayerItem> m_layerItem;

View File

@@ -146,7 +146,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapping useSnapping)
if (boundingRect.height() < minimumHeight) if (boundingRect.height() < minimumHeight)
boundingRect.setHeight(minimumHeight); boundingRect.setHeight(minimumHeight);
formEditorItem->qmlItemNode().setSize(boundingRect.size()); setSize(formEditorItem->qmlItemNode(), boundingRect.size());
if (anchors.instanceHasAnchor(AnchorLine::Bottom)) { if (anchors.instanceHasAnchor(AnchorLine::Bottom)) {
@@ -186,8 +186,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapping useSnapping)
if (boundingRect.height() < minimumHeight) if (boundingRect.height() < minimumHeight)
boundingRect.setTop(boundingRect.top() - minimumHeight + boundingRect.height()); boundingRect.setTop(boundingRect.top() - minimumHeight + boundingRect.height());
formEditorItem->qmlItemNode().setSize(boundingRect.size()); setSize(formEditorItem->qmlItemNode(), boundingRect.size());
formEditorItem->qmlItemNode().setPositionWithBorder(m_beginToParentTransform.map(boundingRect.topLeft())); setPosition(formEditorItem->qmlItemNode(), m_beginToParentTransform.map(boundingRect.topLeft()));
if (anchors.instanceHasAnchor(AnchorLine::Top)) { if (anchors.instanceHasAnchor(AnchorLine::Top)) {
@@ -227,8 +227,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapping useSnapping)
if (boundingRect.width() < minimumWidth) if (boundingRect.width() < minimumWidth)
boundingRect.setWidth(minimumWidth); boundingRect.setWidth(minimumWidth);
formEditorItem->qmlItemNode().setSize(boundingRect.size()); setSize(formEditorItem->qmlItemNode(), boundingRect.size());
formEditorItem->qmlItemNode().setPositionWithBorder(m_beginToParentTransform.map(boundingRect.topLeft())); setPosition(formEditorItem->qmlItemNode(), m_beginToParentTransform.map(boundingRect.topLeft()));
if (anchors.instanceHasAnchor(AnchorLine::Top)) { if (anchors.instanceHasAnchor(AnchorLine::Top)) {
anchors.setMargin(AnchorLine::Top, anchors.setMargin(AnchorLine::Top,
@@ -267,8 +267,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapping useSnapping)
if (boundingRect.width() < minimumWidth) if (boundingRect.width() < minimumWidth)
boundingRect.setLeft(boundingRect.left() - minimumWidth + boundingRect.width()); boundingRect.setLeft(boundingRect.left() - minimumWidth + boundingRect.width());
formEditorItem->qmlItemNode().setSize(boundingRect.size()); setSize(formEditorItem->qmlItemNode(), boundingRect.size());
formEditorItem->qmlItemNode().setPositionWithBorder(m_beginToParentTransform.map(boundingRect.topLeft())); setPosition(formEditorItem->qmlItemNode(), m_beginToParentTransform.map(boundingRect.topLeft()));
if (anchors.instanceHasAnchor(AnchorLine::Left)) { if (anchors.instanceHasAnchor(AnchorLine::Left)) {
anchors.setMargin(AnchorLine::Left, anchors.setMargin(AnchorLine::Left,
@@ -297,7 +297,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapping useSnapping)
if (boundingRect.height() < minimumHeight) if (boundingRect.height() < minimumHeight)
boundingRect.setHeight(minimumHeight); boundingRect.setHeight(minimumHeight);
formEditorItem->qmlItemNode().setSize(boundingRect.size()); setSize(formEditorItem->qmlItemNode(), boundingRect.size());
if (anchors.instanceHasAnchor(AnchorLine::Bottom)) { if (anchors.instanceHasAnchor(AnchorLine::Bottom)) {
anchors.setMargin(AnchorLine::Bottom, anchors.setMargin(AnchorLine::Bottom,
@@ -321,8 +321,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapping useSnapping)
if (boundingRect.height() < minimumHeight) if (boundingRect.height() < minimumHeight)
boundingRect.setTop(boundingRect.top() - minimumHeight + boundingRect.height()); boundingRect.setTop(boundingRect.top() - minimumHeight + boundingRect.height());
formEditorItem->qmlItemNode().setSize(boundingRect.size()); setSize(formEditorItem->qmlItemNode(), boundingRect.size());
formEditorItem->qmlItemNode().setPositionWithBorder(m_beginToParentTransform.map(boundingRect.topLeft())); setPosition(formEditorItem->qmlItemNode(), m_beginToParentTransform.map(boundingRect.topLeft()));
if (anchors.instanceHasAnchor(AnchorLine::Top)) { if (anchors.instanceHasAnchor(AnchorLine::Top)) {
anchors.setMargin(AnchorLine::Top, anchors.setMargin(AnchorLine::Top,
@@ -346,7 +346,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapping useSnapping)
if (boundingRect.width() < minimumWidth) if (boundingRect.width() < minimumWidth)
boundingRect.setWidth(minimumWidth); boundingRect.setWidth(minimumWidth);
formEditorItem->qmlItemNode().setSize(boundingRect.size()); setSize(formEditorItem->qmlItemNode(), boundingRect.size());
if (anchors.instanceHasAnchor(AnchorLine::Right)) { if (anchors.instanceHasAnchor(AnchorLine::Right)) {
@@ -371,8 +371,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapping useSnapping)
if (boundingRect.width() < minimumWidth) if (boundingRect.width() < minimumWidth)
boundingRect.setLeft(boundingRect.left() - minimumWidth + boundingRect.width()); boundingRect.setLeft(boundingRect.left() - minimumWidth + boundingRect.width());
formEditorItem->qmlItemNode().setSize(boundingRect.size()); setSize(formEditorItem->qmlItemNode(), boundingRect.size());
formEditorItem->qmlItemNode().setPositionWithBorder(m_beginToParentTransform.map(boundingRect.topLeft())); setPosition(formEditorItem->qmlItemNode(), m_beginToParentTransform.map(boundingRect.topLeft()));
if (anchors.instanceHasAnchor(AnchorLine::Left)) { if (anchors.instanceHasAnchor(AnchorLine::Left)) {
anchors.setMargin(AnchorLine::Left, anchors.setMargin(AnchorLine::Left,
@@ -503,4 +503,23 @@ void ResizeManipulator::clear()
removeHandle(); removeHandle();
} }
void ResizeManipulator::setSize(QmlItemNode itemNode, const QSizeF &size)
{
int penWidth = (itemNode.instancePenWidth() / 2) * 2;
if (!itemNode.hasBindingProperty("width"))
itemNode.setVariantProperty("width", qRound(size.width()) - penWidth);
if (!itemNode.hasBindingProperty("height"))
itemNode.setVariantProperty("height", qRound(size.height()) - penWidth);
}
void ResizeManipulator::setPosition(QmlItemNode itemNode, const QPointF &position)
{
if (!itemNode.hasBindingProperty("x"))
itemNode.setVariantProperty("x", qRound(position.x()) + (itemNode.instancePenWidth() / 2));
if (!itemNode.hasBindingProperty("y"))
itemNode.setVariantProperty("y", qRound(position.y()) + (itemNode.instancePenWidth() / 2));
}
} }

View File

@@ -68,6 +68,8 @@ protected:
bool isInvalidSize(const QSizeF & size); bool isInvalidSize(const QSizeF & size);
void deleteSnapLines(); void deleteSnapLines();
ResizeHandleItem *resizeHandle(); ResizeHandleItem *resizeHandle();
void setSize(QmlItemNode itemNode, const QSizeF &size);
void setPosition(QmlItemNode itemNode, const QPointF &position);
private: private:
Snapper m_snapper; Snapper m_snapper;

View File

@@ -50,7 +50,7 @@ SelectionTool::SelectionTool(FormEditorView *editorView)
m_singleSelectionManipulator(editorView), m_singleSelectionManipulator(editorView),
m_selectionIndicator(editorView->scene()->manipulatorLayerItem()), m_selectionIndicator(editorView->scene()->manipulatorLayerItem()),
m_resizeIndicator(editorView->scene()->manipulatorLayerItem()), m_resizeIndicator(editorView->scene()->manipulatorLayerItem()),
m_selectOnlyContentItems(true) m_selectOnlyContentItems(false)
{ {
// view()->setCursor(Qt::CrossCursor); // view()->setCursor(Qt::CrossCursor);
} }

View File

@@ -159,6 +159,7 @@ void ComponentView::propertiesRemoved(const QList<AbstractProperty>& /*propertyL
void ComponentView::variantPropertiesChanged(const QList<VariantProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) {} void ComponentView::variantPropertiesChanged(const QList<VariantProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) {}
void ComponentView::bindingPropertiesChanged(const QList<BindingProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) {} void ComponentView::bindingPropertiesChanged(const QList<BindingProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) {}
void ComponentView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) {} void ComponentView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) {}
void ComponentView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStringList &/*scriptFunctionList*/) {}

View File

@@ -66,7 +66,7 @@ public:
void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange); void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange);
void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange); void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,

View File

@@ -459,7 +459,7 @@ void DesignDocumentController::deleteSelected()
void DesignDocumentController::copySelected() void DesignDocumentController::copySelected()
{ {
QScopedPointer<Model> model(Model::create("import Qt 4.7; Qt/Rectangle")); QScopedPointer<Model> model(Model::create("Qt/Rectangle"));
model->setMetaInfo(m_d->model->metaInfo()); model->setMetaInfo(m_d->model->metaInfo());
model->setFileUrl(m_d->model->fileUrl()); model->setFileUrl(m_d->model->fileUrl());

View File

@@ -56,6 +56,11 @@ void DesignDocumentControllerView::selectedNodesChanged(const QList<ModelNode> &
void DesignDocumentControllerView::nodeOrderChanged(const NodeListProperty & /*listProperty*/, const ModelNode & /*movedNode*/, int /*oldIndex*/) {}; void DesignDocumentControllerView::nodeOrderChanged(const NodeListProperty & /*listProperty*/, const ModelNode & /*movedNode*/, int /*oldIndex*/) {};
void DesignDocumentControllerView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStringList &/*scriptFunctionList*/)
{
}
static QStringList arrayToStringList(const QByteArray &byteArray) static QStringList arrayToStringList(const QByteArray &byteArray)
{ {
QString str(QString::fromLatin1(byteArray)); QString str(QString::fromLatin1(byteArray));

View File

@@ -57,6 +57,7 @@ public:
const QList<ModelNode> &lastSelectedNodeList); const QList<ModelNode> &lastSelectedNodeList);
virtual void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); virtual void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
virtual void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
ModelNode insertModel(const ModelNode &modelNode) ModelNode insertModel(const ModelNode &modelNode)
{ return m_modelMerger.insertModel(modelNode); } { return m_modelMerger.insertModel(modelNode); }

View File

@@ -186,6 +186,11 @@ void NavigatorView::auxiliaryDataChanged(const ModelNode &node, const QString &
} }
} }
void NavigatorView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStringList &/*scriptFunctionList*/)
{
}
void NavigatorView::nodeOrderChanged(const NodeListProperty &/*listProperty*/, const ModelNode &node, int /*oldIndex*/) void NavigatorView::nodeOrderChanged(const NodeListProperty &/*listProperty*/, const ModelNode &node, int /*oldIndex*/)
{ {
if (m_treeModel->isInTree(node)) if (m_treeModel->isInTree(node))

View File

@@ -80,6 +80,7 @@ public:
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
const QList<ModelNode> &lastSelectedNodeList); const QList<ModelNode> &lastSelectedNodeList);
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data); void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
private slots: private slots:

View File

@@ -798,6 +798,11 @@ void PropertyEditor::nodeIdChanged(const ModelNode& node, const QString& newId,
} }
} }
void PropertyEditor::scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList)
{
QmlModelView::scriptFunctionsChanged(node, scriptFunctionList);
}
void PropertyEditor::select(const ModelNode &node) void PropertyEditor::select(const ModelNode &node)
{ {
if (QmlItemNode(node).isValid()) if (QmlItemNode(node).isValid())

View File

@@ -101,6 +101,7 @@ public:
void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange); void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId); void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
protected: protected:
void timerEvent(QTimerEvent *event); void timerEvent(QTimerEvent *event);

View File

@@ -399,6 +399,15 @@ void StatesEditorView::customNotification(const AbstractView * view, const QStri
QmlModelView::customNotification(view, identifier, nodeList, data); QmlModelView::customNotification(view, identifier, nodeList, data);
} }
void StatesEditorView::scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList)
{
if (debug)
qDebug() << __FUNCTION__;
QmlModelView::scriptFunctionsChanged(node, scriptFunctionList);
}
QPixmap StatesEditorView::renderState(int i) QPixmap StatesEditorView::renderState(int i)
{ {
if (debug) if (debug)

View File

@@ -57,7 +57,6 @@ public:
void nodeInstancePropertyChanged(const ModelNode &node, const QString &propertyName); void nodeInstancePropertyChanged(const ModelNode &node, const QString &propertyName);
protected:
// AbstractView // AbstractView
void modelAttached(Model *model); void modelAttached(Model *model);
void modelAboutToBeDetached(Model *model); void modelAboutToBeDetached(Model *model);
@@ -76,6 +75,7 @@ protected:
void otherPropertyChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName); void otherPropertyChanged(const QmlObjectNode &qmlObjectNode, const QString &propertyName);
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data); void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
protected: protected:

View File

@@ -62,7 +62,7 @@ bool ChangeImportsVisitor::add(QmlJS::AST::UiProgram *ast, const Import &import)
if (!c.isSpace() && c != QLatin1Char(';')) if (!c.isSpace() && c != QLatin1Char(';'))
break; break;
} }
replace(insertionPoint, 0, QLatin1String("\n") + import.toString(false)); replace(insertionPoint+1, 0, QLatin1String("\n") + import.toString(false));
} else { } else {
replace(0, 0, import.toString(false) + QLatin1String("\n\n")); replace(0, 0, import.toString(false) + QLatin1String("\n\n"));
} }

View File

@@ -129,6 +129,8 @@ public:
virtual void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data); virtual void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
virtual void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList) = 0;
QmlModelView *toQmlModelView(); QmlModelView *toQmlModelView();
void changeRootNodeType(const QString &type, int majorVersion, int minorVersion); void changeRootNodeType(const QString &type, int majorVersion, int minorVersion);

View File

@@ -76,6 +76,7 @@ public:
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data); void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
protected: protected:
void appendView(ViewType *view); void appendView(ViewType *view);
@@ -245,6 +246,13 @@ void ForwardView<ViewType>::auxiliaryDataChanged(const ModelNode &node, const QS
view->auxiliaryDataChanged(ModelNode(node, view.data()), name, data); view->auxiliaryDataChanged(ModelNode(node, view.data()), name, data);
} }
template <class ViewType>
void ForwardView<ViewType>::scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList)
{
foreach (const ViewTypePointer &view, m_targetViewList)
view->scriptFunctionsChanged(node, scriptFunctionList);
}
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::appendView(ViewType *view) void ForwardView<ViewType>::appendView(ViewType *view)
{ {

View File

@@ -96,7 +96,7 @@ public:
// Editing sub-components: // Editing sub-components:
// Imports: // Imports:
QSet<Import> imports() const; QList<Import> imports() const;
void addImport(const Import &import); void addImport(const Import &import);
void removeImport(const Import &import); void removeImport(const Import &import);

View File

@@ -135,6 +135,10 @@ public:
bool hasNodeProperty(const QString &name) const; bool hasNodeProperty(const QString &name) const;
bool hasNodeListProperty(const QString &name) const; bool hasNodeListProperty(const QString &name) const;
void setScriptFunctions(const QStringList &scriptFunctionList);
QStringList scriptFunctions() const;
//### //###
void destroy(); void destroy();

View File

@@ -84,6 +84,8 @@ public:
void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId); void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList); void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
QList<NodeInstance> instances() const; QList<NodeInstance> instances() const;
NodeInstance instanceForNode(const ModelNode &node); NodeInstance instanceForNode(const ModelNode &node);

View File

@@ -71,13 +71,11 @@ public:
QTransform instanceSceneTransform() const; QTransform instanceSceneTransform() const;
QPointF instancePosition() const; QPointF instancePosition() const;
QSizeF instanceSize() const; QSizeF instanceSize() const;
int instancePenWidth() const;
void paintInstance(QPainter *painter) const; void paintInstance(QPainter *painter) const;
void setSize(const QSizeF &size);
void setPosition(const QPointF &position);
void setPositionWithBorder(const QPointF &position);
void selectNode(); void selectNode();
void deselectNode(); void deselectNode();
bool isSelected() const; bool isSelected() const;

View File

@@ -124,6 +124,7 @@ public:
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data); void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void importAdded(const Import &import); void importAdded(const Import &import);
void importRemoved(const Import &import); void importRemoved(const Import &import);

View File

@@ -26,10 +26,16 @@ void NodeInstanceSignalSpy::setObjectNodeInstance(const ObjectNodeInstance::Poin
void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &prefix) void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &prefix)
{ {
if (registeredObjectList.contains(spiedObject)) // prevent cycles
return;
registeredObjectList.append(spiedObject);
for (int index = QObject::staticMetaObject.propertyOffset(); for (int index = QObject::staticMetaObject.propertyOffset();
index < spiedObject->metaObject()->propertyCount(); index < spiedObject->metaObject()->propertyCount();
index++) { index++) {
QMetaProperty metaProperty = spiedObject->metaObject()->property(index); QMetaProperty metaProperty = spiedObject->metaObject()->property(index);
// handle dot properties and connect the signals to the object
if (metaProperty.isReadable() if (metaProperty.isReadable()
&& !metaProperty.isWritable() && !metaProperty.isWritable()
&& QDeclarativeMetaType::isQObject(metaProperty.userType())) { && QDeclarativeMetaType::isQObject(metaProperty.userType())) {
@@ -43,6 +49,28 @@ void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &
m_indexPropertyHash.insert(methodeOffset, prefix + metaProperty.name()); m_indexPropertyHash.insert(methodeOffset, prefix + metaProperty.name());
methodeOffset++; methodeOffset++;
} }
// search recursive in objects
if (metaProperty.isReadable()
&& metaProperty.isWritable()
&& QDeclarativeMetaType::isQObject(metaProperty.userType())) {
QObject *propertyObject = QDeclarativeMetaType::toQObject(metaProperty.read(spiedObject));
if (propertyObject)
registerObject(propertyObject, prefix + metaProperty.name() + "/");
}
// search recursive in objects list
if (metaProperty.isReadable()
&& QDeclarativeMetaType::isList(metaProperty.userType())) {
QDeclarativeListReference list(spiedObject, metaProperty.name());
if (list.canCount() && list.canAt()) {
for (int i = 0; i < list.count(); i++) {
QObject *propertyObject = list.at(i);
if (propertyObject)
registerObject(propertyObject, prefix + metaProperty.name() + "/");
}
}
}
} }
} }

View File

@@ -27,6 +27,7 @@ protected:
private: private:
int methodeOffset; int methodeOffset;
QHash<int, QString> m_indexPropertyHash; QHash<int, QString> m_indexPropertyHash;
QObjectList registeredObjectList;
ObjectNodeInstanceWeakPointer m_objectNodeInstance; ObjectNodeInstanceWeakPointer m_objectNodeInstance;
}; };

View File

@@ -374,6 +374,10 @@ void NodeInstanceView::selectedNodesChanged(const QList<ModelNode> &/*selectedNo
{ {
} }
void NodeInstanceView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStringList &/*scriptFunctionList*/)
{
}
//\} //\}

View File

@@ -196,6 +196,9 @@ QRectF QmlGraphicsItemNodeInstance::boundingRect() const
void QmlGraphicsItemNodeInstance::setPropertyVariant(const QString &name, const QVariant &value) void QmlGraphicsItemNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
{ {
if (name == "state")
return; // states are only set by us
if (name == "height") { if (name == "height") {
if (value.isValid()) if (value.isValid())
m_hasHeight = true; m_hasHeight = true;
@@ -215,6 +218,9 @@ void QmlGraphicsItemNodeInstance::setPropertyVariant(const QString &name, const
void QmlGraphicsItemNodeInstance::setPropertyBinding(const QString &name, const QString &expression) void QmlGraphicsItemNodeInstance::setPropertyBinding(const QString &name, const QString &expression)
{ {
if (name == "state")
return; // states are only set by us
GraphicsObjectNodeInstance::setPropertyBinding(name, expression); GraphicsObjectNodeInstance::setPropertyBinding(name, expression);
} }

View File

@@ -313,5 +313,15 @@ bool operator <(const InternalNode::Pointer &firstNode, const InternalNode::Poin
return firstNode.data() < secondNode.data(); return firstNode.data() < secondNode.data();
} }
void InternalNode::setScriptFunctions(const QStringList &scriptFunctionList)
{
m_scriptFunctionList = scriptFunctionList;
}
QStringList InternalNode::scriptFunctions() const
{
return m_scriptFunctionList;
}
} }
} }

View File

@@ -34,6 +34,7 @@
#include <QHash> #include <QHash>
#include <QSharedPointer> #include <QSharedPointer>
#include <QWeakPointer> #include <QWeakPointer>
#include <QStringList>
#include "internalproperty.h" #include "internalproperty.h"
#include "internalvariantproperty.h" #include "internalvariantproperty.h"
#include "internalbindingproperty.h" #include "internalbindingproperty.h"
@@ -112,6 +113,9 @@ public:
QList<InternalNode::Pointer> allSubNodes() const; QList<InternalNode::Pointer> allSubNodes() const;
QList<InternalNode::Pointer> allDirectSubNodes() const; QList<InternalNode::Pointer> allDirectSubNodes() const;
void setScriptFunctions(const QStringList &scriptFunctionList);
QStringList scriptFunctions() const;
protected: protected:
Pointer internalPointer() const; Pointer internalPointer() const;
void setInternalWeakPointer(const Pointer &pointer); void setInternalWeakPointer(const Pointer &pointer);
@@ -133,6 +137,7 @@ private:
bool m_valid; bool m_valid;
QHash<QString, InternalPropertyPointer> m_namePropertyHash; QHash<QString, InternalPropertyPointer> m_namePropertyHash;
QStringList m_scriptFunctionList;
}; };
uint qHash(const InternalNodePointer& node); uint qHash(const InternalNodePointer& node);

View File

@@ -122,13 +122,13 @@ void ModelPrivate::addImport(const Import &import)
if (m_imports.contains(import)) if (m_imports.contains(import))
return; return;
m_imports.insert(import); m_imports.append(import);
notifyImportAdded(import); notifyImportAdded(import);
} }
void ModelPrivate::removeImport(const Import &import) void ModelPrivate::removeImport(const Import &import)
{ {
if (!m_imports.remove(import)) if (!m_imports.removeOne(import))
return; return;
notifyImportRemoved(import); notifyImportRemoved(import);
@@ -531,6 +531,29 @@ void ModelPrivate::notifyBindingPropertiesChanged(const QList<InternalBindingPro
} }
} }
void ModelPrivate::notifyScriptFunctionsChanged(const InternalNodePointer &internalNodePointer, const QStringList &scriptFunctionList)
{
bool resetModel = false;
QString description;
foreach (const QWeakPointer<AbstractView> &view, m_viewList) {
Q_ASSERT(view != 0);
ModelNode node(internalNodePointer, model(), view.data());
try {
view->scriptFunctionsChanged(node, scriptFunctionList);
} catch (RewritingException &e) {
description = e.description();
resetModel = true;
}
}
if (resetModel) {
resetModelByRewriter(description);
}
}
void ModelPrivate::notifyVariantPropertiesChanged(const InternalNodePointer &internalNodePointer, const QStringList& propertyNameList, AbstractView::PropertyChangeFlags propertyChange) void ModelPrivate::notifyVariantPropertiesChanged(const InternalNodePointer &internalNodePointer, const QStringList& propertyNameList, AbstractView::PropertyChangeFlags propertyChange)
{ {
bool resetModel = false; bool resetModel = false;
@@ -840,6 +863,13 @@ void ModelPrivate::changeRootNodeType(const QString &type, int majorVersion, int
notifyRootNodeTypeChanged(type, majorVersion, minorVersion); notifyRootNodeTypeChanged(type, majorVersion, minorVersion);
} }
void ModelPrivate::setScriptFunctions(const InternalNode::Pointer &internalNode, const QStringList &scriptFunctionList)
{
internalNode->setScriptFunctions(scriptFunctionList);
notifyScriptFunctionsChanged(internalNode, scriptFunctionList);
}
void ModelPrivate::changeNodeOrder(const InternalNode::Pointer &internalParentNode, const QString &listPropertyName, int from, int to) void ModelPrivate::changeNodeOrder(const InternalNode::Pointer &internalParentNode, const QString &listPropertyName, int from, int to)
{ {
InternalNodeListProperty::Pointer nodeList(internalParentNode->nodeListProperty(listPropertyName)); InternalNodeListProperty::Pointer nodeList(internalParentNode->nodeListProperty(listPropertyName));
@@ -1004,7 +1034,7 @@ Model *Model::create(QString type, int major, int minor)
// return subModel; // return subModel;
//} //}
QSet<Import> Model::imports() const QList<Import> Model::imports() const
{ {
return m_d->imports(); return m_d->imports();
} }

View File

@@ -132,6 +132,7 @@ public:
void notifyPropertiesAboutToBeRemoved(const QList<InternalPropertyPointer> &propertyList); void notifyPropertiesAboutToBeRemoved(const QList<InternalPropertyPointer> &propertyList);
void notifyBindingPropertiesChanged(const QList<InternalBindingPropertyPointer> &propertyList, AbstractView::PropertyChangeFlags propertyChange); void notifyBindingPropertiesChanged(const QList<InternalBindingPropertyPointer> &propertyList, AbstractView::PropertyChangeFlags propertyChange);
void notifyVariantPropertiesChanged(const InternalNodePointer &internalNodePointer, const QStringList& propertyNameList, AbstractView::PropertyChangeFlags propertyChange); void notifyVariantPropertiesChanged(const InternalNodePointer &internalNodePointer, const QStringList& propertyNameList, AbstractView::PropertyChangeFlags propertyChange);
void notifyScriptFunctionsChanged(const InternalNodePointer &internalNodePointer, const QStringList &scriptFunctionList);
void notifyNodeOrderChanged(const InternalNodeListPropertyPointer &internalListPropertyPointer, const InternalNodePointer &internalNodePointer, int oldIndex); void notifyNodeOrderChanged(const InternalNodeListPropertyPointer &internalListPropertyPointer, const InternalNodePointer &internalNodePointer, int oldIndex);
void notifyAuxiliaryDataChanged(const InternalNodePointer &internalNode, const QString &name, const QVariant &data); void notifyAuxiliaryDataChanged(const InternalNodePointer &internalNode, const QString &name, const QVariant &data);
@@ -140,6 +141,8 @@ public:
void notifyCustomNotification(const AbstractView *senderView, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data); void notifyCustomNotification(const AbstractView *senderView, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
void setSelectedNodes(const QList<InternalNodePointer> &selectedNodeList); void setSelectedNodes(const QList<InternalNodePointer> &selectedNodeList);
void clearSelectedNodes(); void clearSelectedNodes();
QList<InternalNodePointer> selectedNodes() const; QList<InternalNodePointer> selectedNodes() const;
@@ -154,7 +157,7 @@ public:
// Imports: // Imports:
QSet<Import> imports() const { return m_imports; } QList<Import> imports() const { return m_imports; }
void addImport(const Import &import); void addImport(const Import &import);
void removeImport(const Import &import); void removeImport(const Import &import);
void notifyImportAdded(const Import &import) const; void notifyImportAdded(const Import &import) const;
@@ -176,6 +179,7 @@ public:
void checkPropertyName(const QString &propertyName); void checkPropertyName(const QString &propertyName);
void clearParent(const InternalNodePointer &internalNode); void clearParent(const InternalNodePointer &internalNode);
void changeRootNodeType(const QString &type, int majorVersion, int minorVersion); void changeRootNodeType(const QString &type, int majorVersion, int minorVersion);
void setScriptFunctions(const InternalNodePointer &internalNode, const QStringList &scriptFunctionList);
InternalNodePointer nodeForId(const QString &id) const; InternalNodePointer nodeForId(const QString &id) const;
bool hasId(const QString &id) const; bool hasId(const QString &id) const;
@@ -197,7 +201,7 @@ private:
Model *m_q; Model *m_q;
MetaInfo m_metaInfo; MetaInfo m_metaInfo;
QSet<Import> m_imports; QList<Import> m_imports;
QList<QWeakPointer<AbstractView> > m_viewList; QList<QWeakPointer<AbstractView> > m_viewList;
QList<InternalNodePointer> m_selectedNodeList; QList<InternalNodePointer> m_selectedNodeList;
QHash<QString,InternalNodePointer> m_idNodeHash; QHash<QString,InternalNodePointer> m_idNodeHash;

View File

@@ -170,9 +170,8 @@ void ModelMerger::replaceModel(const ModelNode &modelNode)
{ {
RewriterTransaction transaction(view()->beginRewriterTransaction()); RewriterTransaction transaction(view()->beginRewriterTransaction());
// foreach (const Import &import, modelNode.model()->imports()) { foreach (const Import &import, modelNode.model()->imports())
//view()->model()->addImport(import); //### view()->model()->addImport(import);
// }
view()->model()->setFileUrl(modelNode.model()->fileUrl()); view()->model()->setFileUrl(modelNode.model()->fileUrl());
ModelNode rootNode(view()->rootModelNode()); ModelNode rootNode(view()->rootModelNode());

View File

@@ -908,4 +908,14 @@ bool ModelNode::hasAuxiliaryData(const QString &name) const
return internalNode()->hasAuxiliaryData(name); return internalNode()->hasAuxiliaryData(name);
} }
void ModelNode::setScriptFunctions(const QStringList &scriptFunctionList)
{
model()->m_d->setScriptFunctions(internalNode(), scriptFunctionList);
}
QStringList ModelNode::scriptFunctions() const
{
return internalNode()->scriptFunctions();
}
} }

View File

@@ -191,34 +191,17 @@ QSizeF QmlItemNode::instanceSize() const
return nodeInstance().size(); return nodeInstance().size();
} }
int QmlItemNode::instancePenWidth() const
{
return nodeInstance().penWidth();
}
void QmlItemNode::paintInstance(QPainter *painter) const void QmlItemNode::paintInstance(QPainter *painter) const
{ {
if (nodeInstance().isValid()) if (nodeInstance().isValid())
nodeInstance().paint(painter); nodeInstance().paint(painter);
} }
void QmlItemNode::setSize(const QSizeF &size)
{
int penWidth = (nodeInstance().penWidth() / 2) * 2;
RewriterTransaction transaction = qmlModelView()->beginRewriterTransaction();
setVariantProperty("width", qRound(size.width()) - penWidth);
setVariantProperty("height", qRound(size.height()) - penWidth);
}
void QmlItemNode::setPosition(const QPointF &position)
{
RewriterTransaction transaction = qmlModelView()->beginRewriterTransaction();
setVariantProperty("x", qRound(position.x()));
setVariantProperty("y", qRound(position.y()));
}
void QmlItemNode::setPositionWithBorder(const QPointF &position)
{
RewriterTransaction transaction = qmlModelView()->beginRewriterTransaction();
setVariantProperty("x", qRound(position.x()) + (nodeInstance().penWidth() / 2));
setVariantProperty("y", qRound(position.y()) + (nodeInstance().penWidth() / 2));
}
void QmlItemNode::selectNode() void QmlItemNode::selectNode()
{ {
modelNode().selectNode(); modelNode().selectNode();

View File

@@ -98,6 +98,24 @@ QmlItemNode QmlModelView::createQmlItemNodeFromImage(const QString &imageName, c
QmlItemNode newNode; QmlItemNode newNode;
RewriterTransaction transaction = beginRewriterTransaction(); RewriterTransaction transaction = beginRewriterTransaction();
{ {
const QString newImportUrl = QLatin1String("Qt");
const QString newImportVersion = QLatin1String("4.7");
Import newImport = Import::createLibraryImport(newImportUrl, newImportVersion);
foreach (const Import &import, model()->imports()) {
if (import.isLibraryImport()
&& import.url() == newImport.url()
&& import.version() == newImport.version()) {
// reuse this import
newImport = import;
break;
}
}
if (!model()->imports().contains(newImport)) {
model()->addImport(newImport);
}
QList<QPair<QString, QVariant> > propertyPairList; QList<QPair<QString, QVariant> > propertyPairList;
propertyPairList.append(qMakePair(QString("x"), QVariant( round(position.x(), 4)))); propertyPairList.append(qMakePair(QString("x"), QVariant( round(position.x(), 4))));
propertyPairList.append(qMakePair(QString("y"), QVariant( round(position.y(), 4)))); propertyPairList.append(qMakePair(QString("y"), QVariant( round(position.y(), 4))));
@@ -146,10 +164,29 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
Q_ASSERT(parentNode.isValid()); Q_ASSERT(parentNode.isValid());
QmlItemNode newNode; QmlItemNode newNode;
RewriterTransaction transaction = beginRewriterTransaction(); RewriterTransaction transaction = beginRewriterTransaction();
{ {
if (itemLibraryEntry.typeName().contains('.')) {
const QString newImportUrl = itemLibraryEntry.typeName().split('/').first();
const QString newImportVersion = QString("%1.%2").arg(QString::number(itemLibraryEntry.majorVersion()), QString::number(itemLibraryEntry.minorVersion()));
Import newImport = Import::createLibraryImport(newImportUrl, newImportVersion);
foreach (const Import &import, model()->imports()) {
if (import.isLibraryImport()
&& import.url() == newImport.url()
&& import.version() == newImport.version()) {
// reuse this import
newImport = import;
break;
}
}
if (!model()->imports().contains(newImport)) {
model()->addImport(newImport);
}
}
QList<QPair<QString, QVariant> > propertyPairList; QList<QPair<QString, QVariant> > propertyPairList;
propertyPairList.append(qMakePair(QString("x"), QVariant(round(position.x(), 4)))); propertyPairList.append(qMakePair(QString("x"), QVariant(round(position.x(), 4))));
propertyPairList.append(qMakePair(QString("y"), QVariant(round(position.y(), 4)))); propertyPairList.append(qMakePair(QString("y"), QVariant(round(position.y(), 4))));

View File

@@ -35,6 +35,7 @@
#include "nodelistproperty.h" #include "nodelistproperty.h"
#include "qmltextgenerator.h" #include "qmltextgenerator.h"
#include "variantproperty.h" #include "variantproperty.h"
#include "model.h"
using namespace QmlDesigner; using namespace QmlDesigner;
using namespace QmlDesigner::Internal; using namespace QmlDesigner::Internal;
@@ -122,11 +123,31 @@ QString QmlTextGenerator::toQml(const AbstractProperty &property, int indentDept
QString QmlTextGenerator::toQml(const ModelNode &node, int indentDepth) const QString QmlTextGenerator::toQml(const ModelNode &node, int indentDepth) const
{ {
QString type = node.type(); QString type = node.type();
int lastSlashIndex = type.lastIndexOf('/'); QString url;
if (lastSlashIndex != -1) if (type.contains('/')) {
type = type.mid(lastSlashIndex + 1); QStringList nameComponents = type.split("/");
url = nameComponents.first();
type = nameComponents.last();
}
QString result = type; QString alias;
if (!url.isEmpty()) {
const QString &versionUrl = QString("%1.%2").arg(QString::number(node.majorVersion()), QString::number(node.minorVersion()));
foreach (const Import &import, node.model()->imports()) {
if (import.url() == url
&& import.version() == versionUrl) {
alias = import.alias();
break;
}
}
}
QString result;
if (!alias.isEmpty())
result = alias + ".";
result += type;
result += QLatin1String(" {\n"); result += QLatin1String(" {\n");
const int propertyIndentDepth = indentDepth + 4; const int propertyIndentDepth = indentDepth + 4;

View File

@@ -369,7 +369,7 @@ QString AddImportRewriteAction::info() const
bool RemoveImportRewriteAction::execute(QmlDesigner::QmlRefactoring &refactoring, bool RemoveImportRewriteAction::execute(QmlDesigner::QmlRefactoring &refactoring,
ModelNodePositionStorage &/*positionStore*/) ModelNodePositionStorage &/*positionStore*/)
{ {
const bool result = refactoring.addImport(m_import); const bool result = refactoring.removeImport(m_import);
if (!result) if (!result)
qDebug() << "*** RemoveImportRewriteAction::execute failed in changeImports (" qDebug() << "*** RemoveImportRewriteAction::execute failed in changeImports ("

View File

@@ -352,6 +352,10 @@ void RewriterView::customNotification(const AbstractView * /*view*/, const QStri
} }
} }
void RewriterView::scriptFunctionsChanged(const ModelNode &/*node*/, const QStringList &/*scriptFunctionList*/)
{
}
void RewriterView::selectedNodesChanged(const QList<ModelNode> & /* selectedNodeList, */, const QList<ModelNode> & /*lastSelectedNodeList */) void RewriterView::selectedNodesChanged(const QList<ModelNode> & /* selectedNodeList, */, const QList<ModelNode> & /*lastSelectedNodeList */)
{ {
} }

View File

@@ -491,7 +491,7 @@ bool TextToModelMerger::isActive() const
void TextToModelMerger::setupImports(const Document::Ptr &doc, void TextToModelMerger::setupImports(const Document::Ptr &doc,
DifferenceHandler &differenceHandler) DifferenceHandler &differenceHandler)
{ {
QSet<Import> existingImports = m_rewriterView->model()->imports(); QList<Import> existingImports = m_rewriterView->model()->imports();
for (UiImportList *iter = doc->qmlProgram()->imports; iter; iter = iter->next) { for (UiImportList *iter = doc->qmlProgram()->imports; iter; iter = iter->next) {
UiImport *import = iter->import; UiImport *import = iter->import;
@@ -510,13 +510,13 @@ void TextToModelMerger::setupImports(const Document::Ptr &doc,
const Import newImport = Import::createFileImport(strippedFileName, const Import newImport = Import::createFileImport(strippedFileName,
version, as); version, as);
if (!existingImports.remove(newImport)) if (!existingImports.removeOne(newImport))
differenceHandler.modelMissesImport(newImport); differenceHandler.modelMissesImport(newImport);
} else { } else {
const Import newImport = const Import newImport =
Import::createLibraryImport(flatten(import->importUri), as, version); Import::createLibraryImport(flatten(import->importUri), version, as);
if (!existingImports.remove(newImport)) if (!existingImports.removeOne(newImport))
differenceHandler.modelMissesImport(newImport); differenceHandler.modelMissesImport(newImport);
} }
} }

View File

@@ -192,6 +192,12 @@ void ViewLogger::customNotification(const AbstractView *view, const QString &ide
m_output << time() << indent("data: ") << variant.toString() << endl; m_output << time() << indent("data: ") << variant.toString() << endl;
} }
void ViewLogger::scriptFunctionsChanged(const ModelNode &node, const QStringList &/*scriptFunctionList*/)
{
m_output << time() << indent("function scripts changed:") << node << endl;
}
} // namespace Internal } // namespace Internal
} // namespace QmlDesigner } // namespace QmlDesigner

View File

@@ -70,6 +70,7 @@ public:
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data); void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data); void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
protected: protected:
QString time() const; QString time() const;

View File

@@ -3,7 +3,6 @@ TARGET = QmlJSEditor
include(../../qtcreatorplugin.pri) include(../../qtcreatorplugin.pri)
include(qmljseditor_dependencies.pri) include(qmljseditor_dependencies.pri)
CONFIG += help
DEFINES += \ DEFINES += \
QMLJSEDITOR_LIBRARY \ QMLJSEDITOR_LIBRARY \
QT_CREATOR QT_CREATOR

View File

@@ -32,6 +32,7 @@
#include "qmljshoverhandler.h" #include "qmljshoverhandler.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <coreplugin/uniqueidmanager.h> #include <coreplugin/uniqueidmanager.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <debugger/debuggerconstants.h> #include <debugger/debuggerconstants.h>
@@ -52,7 +53,6 @@
#include <QtGui/QToolTip> #include <QtGui/QToolTip>
#include <QtGui/QTextCursor> #include <QtGui/QTextCursor>
#include <QtGui/QTextBlock> #include <QtGui/QTextBlock>
#include <QtHelp/QHelpEngineCore>
using namespace Core; using namespace Core;
using namespace QmlJS; using namespace QmlJS;
@@ -61,27 +61,11 @@ using namespace QmlJSEditor::Internal;
HoverHandler::HoverHandler(QObject *parent) HoverHandler::HoverHandler(QObject *parent)
: QObject(parent) : QObject(parent)
, m_helpEngineNeedsSetup(false)
{ {
m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>(); m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>();
ICore *core = ICore::instance();
QFileInfo fi(core->settings()->fileName());
// FIXME shouldn't the help engine create the directory if it doesn't exist?
QDir directory(fi.absolutePath()+"/qtcreator");
if (!directory.exists())
directory.mkpath(directory.absolutePath());
m_helpEngine = new QHelpEngineCore(directory.absolutePath()
+ QLatin1String("/helpcollection.qhc"), this);
if (!m_helpEngine->setupData())
qWarning() << "Could not initialize help engine:" << m_helpEngine->error();
m_helpEngine->setAutoSaveFilter(false);
m_helpEngine->setCurrentFilter(tr("Unfiltered"));
m_helpEngineNeedsSetup = m_helpEngine->registeredDocumentations().count() == 0;
// Listen for editor opened events in order to connect to tooltip/helpid requests // Listen for editor opened events in order to connect to tooltip/helpid requests
connect(core->editorManager(), SIGNAL(editorOpened(Core::IEditor *)), connect(ICore::instance()->editorManager(), SIGNAL(editorOpened(Core::IEditor *)),
this, SLOT(editorOpened(Core::IEditor *))); this, SLOT(editorOpened(Core::IEditor *)));
} }
@@ -151,11 +135,6 @@ void HoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int p
const Snapshot snapshot = semanticInfo.snapshot; const Snapshot snapshot = semanticInfo.snapshot;
const Document::Ptr qmlDocument = semanticInfo.document; const Document::Ptr qmlDocument = semanticInfo.document;
if (m_helpEngineNeedsSetup && m_helpEngine->registeredDocumentations().count() > 0) {
m_helpEngine->setupData();
m_helpEngineNeedsSetup = false;
}
// We only want to show F1 if the tooltip matches the help id // We only want to show F1 if the tooltip matches the help id
bool showF1 = true; bool showF1 = true;
@@ -188,7 +167,7 @@ void HoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int p
QString helpId = QLatin1String("QML."); QString helpId = QLatin1String("QML.");
helpId += baseClass; helpId += baseClass;
if (! m_helpEngine->linksForIdentifier(helpId).isEmpty()) { if (!Core::HelpManager::instance()->linksForIdentifier(helpId).isEmpty()) {
m_helpId = helpId; m_helpId = helpId;
break; break;
} }

View File

@@ -34,7 +34,6 @@
#include <QtCore/QObject> #include <QtCore/QObject>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QHelpEngineCore;
class QPoint; class QPoint;
class QStringList; class QStringList;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -79,10 +78,8 @@ private:
private: private:
QmlJS::ModelManagerInterface *m_modelManager; QmlJS::ModelManagerInterface *m_modelManager;
QHelpEngineCore *m_helpEngine;
QString m_helpId; QString m_helpId;
QString m_toolTip; QString m_toolTip;
bool m_helpEngineNeedsSetup;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -18,7 +18,6 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General
<dependency name="ProjectExplorer" version="2.0.80"/> <dependency name="ProjectExplorer" version="2.0.80"/>
<dependency name="CppTools" version="2.0.80"/> <dependency name="CppTools" version="2.0.80"/>
<dependency name="CppEditor" version="2.0.80"/> <dependency name="CppEditor" version="2.0.80"/>
<dependency name="Help" version="2.0.80"/>
<dependency name="Designer" version="2.0.80"/> <dependency name="Designer" version="2.0.80"/>
<dependency name="Debugger" version="2.0.80"/> <dependency name="Debugger" version="2.0.80"/>
</dependencyList> </dependencyList>

View File

@@ -31,6 +31,7 @@
#include "ui_gettingstartedwelcomepagewidget.h" #include "ui_gettingstartedwelcomepagewidget.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/mainwindow.h> #include <coreplugin/mainwindow.h>
@@ -38,8 +39,6 @@
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <help/helpmanager.h>
#include <QtCore/QDateTime> #include <QtCore/QDateTime>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
@@ -338,15 +337,13 @@ void GettingStartedWelcomePageWidget::slotOpenExample()
void GettingStartedWelcomePageWidget::slotOpenHelpPage(const QString& url) void GettingStartedWelcomePageWidget::slotOpenHelpPage(const QString& url)
{ {
Help::HelpManager *helpManager Core::HelpManager *helpManager = Core::HelpManager::instance();
= ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>();
Q_ASSERT(helpManager); Q_ASSERT(helpManager);
helpManager->handleHelpRequest(url); helpManager->handleHelpRequest(url);
} }
void GettingStartedWelcomePageWidget::slotOpenContextHelpPage(const QString& url) void GettingStartedWelcomePageWidget::slotOpenContextHelpPage(const QString& url)
{ {
Help::HelpManager *helpManager Core::HelpManager *helpManager = Core::HelpManager::instance();
= ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>();
Q_ASSERT(helpManager); Q_ASSERT(helpManager);
helpManager->handleHelpRequest(url % QLatin1String("?view=split")); helpManager->handleHelpRequest(url % QLatin1String("?view=split"));
} }

View File

@@ -176,23 +176,26 @@ bool QMakeStep::init()
setEnvironment(qt4bc->environment()); setEnvironment(qt4bc->environment());
setOutputParser(new QMakeParser); setOutputParser(new QMakeParser);
Qt4Project *pro = qt4BuildConfiguration()->qt4Target()->qt4Project();
QString proFile = pro->file()->fileName();
m_tasks = qt4BuildConfiguration()->qtVersion()->reportIssues(proFile);
m_scriptTemplate = pro->rootProjectNode()->projectType() == ScriptTemplate;
return AbstractProcessStep::init(); return AbstractProcessStep::init();
} }
void QMakeStep::run(QFutureInterface<bool> &fi) void QMakeStep::run(QFutureInterface<bool> &fi)
{ {
Qt4Project *pro = qt4BuildConfiguration()->qt4Target()->qt4Project(); if (m_scriptTemplate) {
if (pro->rootProjectNode()->projectType() == ScriptTemplate) {
fi.reportResult(true); fi.reportResult(true);
return; return;
} }
// Warn on common error conditions: // Warn on common error conditions:
QList<ProjectExplorer::Task> issues =
qt4BuildConfiguration()->qtVersion()->reportIssues(qt4BuildConfiguration()->qt4Target()->
qt4Project()->file()->fileName());
bool canContinue = true; bool canContinue = true;
foreach (const ProjectExplorer::Task &t, issues) { foreach (const ProjectExplorer::Task &t, m_tasks) {
addTask(t); addTask(t);
if (t.type == Task::Error) if (t.type == Task::Error)
canContinue = false; canContinue = false;

View File

@@ -110,6 +110,8 @@ private:
bool m_forced; bool m_forced;
bool m_needToRunQMake; // set in init(), read in run() bool m_needToRunQMake; // set in init(), read in run()
QStringList m_userArgs; QStringList m_userArgs;
bool m_scriptTemplate;
QList<ProjectExplorer::Task> m_tasks;
}; };

View File

@@ -59,6 +59,8 @@
#include <QtCore/QStringBuilder> #include <QtCore/QStringBuilder>
#include <QtGui/QWidget> #include <QtGui/QWidget>
namespace { const QLatin1String PackagingEnabledKey("Packaging Enabled"); }
using namespace ProjectExplorer::Constants; using namespace ProjectExplorer::Constants;
using ProjectExplorer::BuildConfiguration; using ProjectExplorer::BuildConfiguration;
using ProjectExplorer::BuildStepConfigWidget; using ProjectExplorer::BuildStepConfigWidget;
@@ -69,14 +71,16 @@ namespace Internal {
MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig) MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig)
: ProjectExplorer::BuildStep(buildConfig, CreatePackageId), : ProjectExplorer::BuildStep(buildConfig, CreatePackageId),
m_packageContents(new MaemoPackageContents(this)) m_packageContents(new MaemoPackageContents(this)),
m_packagingEnabled(true)
{ {
} }
MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig, MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig,
MaemoPackageCreationStep *other) MaemoPackageCreationStep *other)
: BuildStep(buildConfig, other), : BuildStep(buildConfig, other),
m_packageContents(new MaemoPackageContents(this)) m_packageContents(new MaemoPackageContents(this)),
m_packagingEnabled(other->m_packagingEnabled)
{ {
@@ -90,18 +94,20 @@ bool MaemoPackageCreationStep::init()
QVariantMap MaemoPackageCreationStep::toMap() const QVariantMap MaemoPackageCreationStep::toMap() const
{ {
QVariantMap map(ProjectExplorer::BuildStep::toMap()); QVariantMap map(ProjectExplorer::BuildStep::toMap());
map.insert(PackagingEnabledKey, m_packagingEnabled);
return map.unite(m_packageContents->toMap()); return map.unite(m_packageContents->toMap());
} }
bool MaemoPackageCreationStep::fromMap(const QVariantMap &map) bool MaemoPackageCreationStep::fromMap(const QVariantMap &map)
{ {
m_packageContents->fromMap(map); m_packageContents->fromMap(map);
m_packagingEnabled = map.value(PackagingEnabledKey, true).toBool();
return ProjectExplorer::BuildStep::fromMap(map); return ProjectExplorer::BuildStep::fromMap(map);
} }
void MaemoPackageCreationStep::run(QFutureInterface<bool> &fi) void MaemoPackageCreationStep::run(QFutureInterface<bool> &fi)
{ {
fi.reportResult(createPackage()); fi.reportResult(m_packagingEnabled ? createPackage() : true);
} }
BuildStepConfigWidget *MaemoPackageCreationStep::createConfigWidget() BuildStepConfigWidget *MaemoPackageCreationStep::createConfigWidget()

View File

@@ -69,6 +69,9 @@ public:
MaemoPackageContents *packageContents() const { return m_packageContents; } MaemoPackageContents *packageContents() const { return m_packageContents; }
const Qt4BuildConfiguration *qt4BuildConfiguration() const; const Qt4BuildConfiguration *qt4BuildConfiguration() const;
bool isPackagingEnabled() const { return m_packagingEnabled; }
void setPackagingEnabled(bool enabled) { m_packagingEnabled = enabled; }
private: private:
MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig, MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig,
MaemoPackageCreationStep *other); MaemoPackageCreationStep *other);
@@ -94,6 +97,7 @@ private:
static const QLatin1String CreatePackageId; static const QLatin1String CreatePackageId;
MaemoPackageContents *const m_packageContents; MaemoPackageContents *const m_packageContents;
bool m_packagingEnabled;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -65,6 +65,8 @@ MaemoPackageCreationWidget::MaemoPackageCreationWidget(MaemoPackageCreationStep
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->packageContentsView->setWordWrap(false); m_ui->packageContentsView->setWordWrap(false);
m_ui->skipCheckBox->setChecked(!m_step->isPackagingEnabled());
m_ui->packageContentsView->setEnabled(m_step->isPackagingEnabled());
m_ui->packageContentsView->setModel(step->packageContents()); m_ui->packageContentsView->setModel(step->packageContents());
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
connect(step->packageContents(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), connect(step->packageContents(), SIGNAL(dataChanged(QModelIndex,QModelIndex)),
@@ -138,5 +140,11 @@ void MaemoPackageCreationWidget::enableOrDisableRemoveButton()
&& selectedRows.first().row() != 0); && selectedRows.first().row() != 0);
} }
void MaemoPackageCreationWidget::handleSkipButtonToggled(bool checked)
{
m_step->setPackagingEnabled(!checked);
m_ui->packageContentsView->setEnabled(m_step->isPackagingEnabled());
}
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager

View File

@@ -67,6 +67,7 @@ private slots:
void addFile(); void addFile();
void removeFile(); void removeFile();
void enableOrDisableRemoveButton(); void enableOrDisableRemoveButton();
void handleSkipButtonToggled(bool checked);
private: private:
MaemoPackageCreationStep * const m_step; MaemoPackageCreationStep * const m_step;

View File

@@ -17,6 +17,20 @@
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="skipCheckBox">
<property name="toolTip">
<string>Check this if you build the package externally. It still needs to be at the location listed above
and the remote executable is assumed to be in the directory mentioned below.</string>
</property>
<property name="text">
<string>Skip Packaging Step</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="contentsLabel"> <widget class="QLabel" name="contentsLabel">
<property name="font"> <property name="font">
@@ -126,8 +140,8 @@
<slot>addFile()</slot> <slot>addFile()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>712</x> <x>729</x>
<y>44</y> <y>88</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>732</x> <x>732</x>
@@ -142,8 +156,8 @@
<slot>removeFile()</slot> <slot>removeFile()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>723</x> <x>729</x>
<y>77</y> <y>124</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>735</x> <x>735</x>
@@ -151,9 +165,26 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>skipCheckBox</sender>
<signal>clicked(bool)</signal>
<receiver>MaemoPackageCreationWidget</receiver>
<slot>handleSkipButtonToggled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>129</x>
<y>18</y>
</hint>
<hint type="destinationlabel">
<x>240</x>
<y>31</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>addFile()</slot> <slot>addFile()</slot>
<slot>removeFile()</slot> <slot>removeFile()</slot>
<slot>handleSkipButtonToggled(bool)</slot>
</slots> </slots>
</ui> </ui>

Some files were not shown because too many files have changed in this diff Show More