Merge remote-tracking branch 'origin/4.6'

Change-Id: I0813763b7618c682b5fbb197273a1c8911cd3d7d
This commit is contained in:
Eike Ziller
2018-01-11 14:38:40 +01:00
29 changed files with 197 additions and 134 deletions

View File

@@ -55,9 +55,10 @@ Module {
validate: { validate: {
if (!clangProbe.found) { if (!clangProbe.found) {
console.warn("Set LLVM_INSTALL_DIR to build the Clang Code Model." console.warn("No usable libclang version found."
+ " Set LLVM_INSTALL_DIR to build the Clang Code Model."
+ " For details, see doc/src/editors/creator-clang-codemodel.qdoc."); + " For details, see doc/src/editors/creator-clang-codemodel.qdoc.");
throw "No usable libclang found"; throw new Error();
} }
} }
} }

View File

@@ -414,7 +414,7 @@ int main(int argc, char **argv)
const QString &creatorTrPath = resourcePath() + "/translations"; const QString &creatorTrPath = resourcePath() + "/translations";
foreach (QString locale, uiLanguages) { foreach (QString locale, uiLanguages) {
locale = QLocale(locale).name(); locale = QLocale(locale).name();
if (translator.load(QString::fromLatin1(Core::Constants::IDE_ID) + "_" + locale, creatorTrPath)) { if (translator.load("qtcreator_" + locale, creatorTrPath)) {
const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
const QString &qtTrFile = QLatin1String("qt_") + locale; const QString &qtTrFile = QLatin1String("qt_") + locale;
// Binary installer puts Qt tr files into creatorTrPath // Binary installer puts Qt tr files into creatorTrPath

View File

@@ -37,6 +37,7 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <QScrollArea> #include <QScrollArea>
#include <QSlider> #include <QSlider>
#include <QStyle>
#include <QToolButton> #include <QToolButton>
#include <QDebug> #include <QDebug>

View File

@@ -127,8 +127,7 @@ namespace {
static QString sdkSettingsFileName() static QString sdkSettingsFileName()
{ {
return QFileInfo(Core::ICore::settings(QSettings::SystemScope)->fileName()).absolutePath() return Core::ICore::installerResourcePath() + "/android.xml";
+ QLatin1String("/qtcreator/android.xml");
} }
static bool is32BitUserSpace() static bool is32BitUserSpace()

View File

@@ -47,19 +47,13 @@ namespace Internal {
const char dataKeyC[] = "GdbServerProvider."; const char dataKeyC[] = "GdbServerProvider.";
const char countKeyC[] = "GdbServerProvider.Count"; const char countKeyC[] = "GdbServerProvider.Count";
const char fileVersionKeyC[] = "Version"; const char fileVersionKeyC[] = "Version";
const char fileNameKeyC[] = "/qtcreator/gdbserverproviders.xml"; const char fileNameKeyC[] = "/gdbserverproviders.xml";
static Utils::FileName settingsFileName(const QString &path)
{
const QFileInfo settingsLocation(Core::ICore::settings()->fileName());
return Utils::FileName::fromString(settingsLocation.absolutePath() + path);
}
static GdbServerProviderManager *m_instance = 0; static GdbServerProviderManager *m_instance = 0;
GdbServerProviderManager::GdbServerProviderManager(QObject *parent) GdbServerProviderManager::GdbServerProviderManager(QObject *parent)
: QObject(parent) : QObject(parent)
, m_configFile(settingsFileName(QLatin1String(fileNameKeyC))) , m_configFile(Utils::FileName::fromString(Core::ICore::userResourcePath() + fileNameKeyC))
, m_factories({new DefaultGdbServerProviderFactory, , m_factories({new DefaultGdbServerProviderFactory,
new OpenOcdGdbServerProviderFactory, new OpenOcdGdbServerProviderFactory,
new StLinkUtilGdbServerProviderFactory}) new StLinkUtilGdbServerProviderFactory})

View File

@@ -500,7 +500,7 @@ Bookmark *BookmarkManager::bookmarkForIndex(const QModelIndex &index) const
return m_bookmarksList.at(index.row()); return m_bookmarksList.at(index.row());
} }
bool BookmarkManager::gotoBookmark(Bookmark *bookmark) bool BookmarkManager::gotoBookmark(const Bookmark *bookmark) const
{ {
if (IEditor *editor = EditorManager::openEditorAt(bookmark->fileName(), bookmark->lineNumber())) if (IEditor *editor = EditorManager::openEditorAt(bookmark->fileName(), bookmark->lineNumber()))
return editor->currentLine() == bookmark->lineNumber(); return editor->currentLine() == bookmark->lineNumber();

View File

@@ -96,7 +96,7 @@ public:
void moveDown(); void moveDown();
void edit(); void edit();
void editByFileAndLine(const Utils::FileName &fileName, int lineNumber); void editByFileAndLine(const Utils::FileName &fileName, int lineNumber);
bool gotoBookmark(Bookmark *bookmark); bool gotoBookmark(const Bookmark *bookmark) const;
signals: signals:
void updateActions(bool enableToggle, int state); void updateActions(bool enableToggle, int state);

View File

@@ -46,7 +46,7 @@ const char CMAKETOOL_COUNT_KEY[] = "CMakeTools.Count";
const char CMAKETOOL_DEFAULT_KEY[] = "CMakeTools.Default"; const char CMAKETOOL_DEFAULT_KEY[] = "CMakeTools.Default";
const char CMAKETOOL_DATA_KEY[] = "CMakeTools."; const char CMAKETOOL_DATA_KEY[] = "CMakeTools.";
const char CMAKETOOL_FILE_VERSION_KEY[] = "Version"; const char CMAKETOOL_FILE_VERSION_KEY[] = "Version";
const char CMAKETOOL_FILENAME[] = "/qtcreator/cmaketools.xml"; const char CMAKETOOL_FILENAME[] = "/cmaketools.xml";
class CMakeToolManagerPrivate class CMakeToolManagerPrivate
{ {
@@ -71,8 +71,7 @@ static void addCMakeTool(CMakeTool *item)
static FileName userSettingsFileName() static FileName userSettingsFileName()
{ {
QFileInfo settingsLocation(ICore::settings()->fileName()); return FileName::fromString(ICore::userResourcePath() + CMAKETOOL_FILENAME);
return FileName::fromString(settingsLocation.absolutePath() + QLatin1String(CMAKETOOL_FILENAME));
} }
static QList<CMakeTool *> readCMakeTools(const FileName &fileName, Core::Id *defaultId, bool fromSDK) static QList<CMakeTool *> readCMakeTools(const FileName &fileName, Core::Id *defaultId, bool fromSDK)
@@ -325,9 +324,8 @@ void CMakeToolManager::restoreCMakeTools()
{ {
Core::Id defaultId; Core::Id defaultId;
QFileInfo systemSettingsFile(ICore::settings(QSettings::SystemScope)->fileName()); FileName sdkSettingsFile = FileName::fromString(ICore::installerResourcePath()
FileName sdkSettingsFile = FileName::fromString(systemSettingsFile.absolutePath() + CMAKETOOL_FILENAME);
+ QLatin1String(CMAKETOOL_FILENAME));
QList<CMakeTool *> toolsToRegister = readCMakeTools(sdkSettingsFile, &defaultId, true); QList<CMakeTool *> toolsToRegister = readCMakeTools(sdkSettingsFile, &defaultId, true);

View File

@@ -37,6 +37,7 @@
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/stringutils.h> #include <utils/stringutils.h>
#include <QButtonGroup>
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QMap> #include <QMap>

View File

@@ -45,6 +45,7 @@
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
#include <QAbstractItemView>
#include <QCheckBox> #include <QCheckBox>
#include <QClipboard> #include <QClipboard>
#include <QCompleter> #include <QCompleter>

View File

@@ -410,7 +410,7 @@ QString ICore::userResourcePath()
{ {
// Create qtcreator dir if it doesn't yet exist // Create qtcreator dir if it doesn't yet exist
const QString configDir = QFileInfo(settings(QSettings::UserScope)->fileName()).path(); const QString configDir = QFileInfo(settings(QSettings::UserScope)->fileName()).path();
const QString urp = configDir + QLatin1String("/qtcreator"); const QString urp = configDir + '/' + QLatin1String(Constants::IDE_ID);
if (!QFileInfo::exists(urp + QLatin1Char('/'))) { if (!QFileInfo::exists(urp + QLatin1Char('/'))) {
QDir dir; QDir dir;
@@ -421,6 +421,12 @@ QString ICore::userResourcePath()
return urp; return urp;
} }
QString ICore::installerResourcePath()
{
return QFileInfo(settings(QSettings::SystemScope)->fileName()).path() + '/'
+ Constants::IDE_ID;
}
QString ICore::documentationPath() QString ICore::documentationPath()
{ {
return QDir::cleanPath(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DOC_PATH); return QDir::cleanPath(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DOC_PATH);
@@ -486,7 +492,7 @@ QWidget *ICore::currentContextWidget()
} }
QWidget *ICore::mainWindow() QMainWindow *ICore::mainWindow()
{ {
return m_mainwindow; return m_mainwindow;
} }

View File

@@ -28,6 +28,7 @@
#include "core_global.h" #include "core_global.h"
#include "id.h" #include "id.h"
#include <QMainWindow>
#include <QObject> #include <QObject>
#include <QRect> #include <QRect>
#include <QSettings> #include <QSettings>
@@ -93,13 +94,14 @@ public:
static QString resourcePath(); static QString resourcePath();
static QString userResourcePath(); static QString userResourcePath();
static QString installerResourcePath();
static QString documentationPath(); static QString documentationPath();
static QString libexecPath(); static QString libexecPath();
static QString versionString(); static QString versionString();
static QString buildCompatibilityString(); static QString buildCompatibilityString();
static QWidget *mainWindow(); static QMainWindow *mainWindow();
static QWidget *dialogParent(); static QWidget *dialogParent();
static QStatusBar *statusBar(); static QStatusBar *statusBar();
/* Raises and activates the window for the widget. This contains workarounds for X11. */ /* Raises and activates the window for the widget. This contains workarounds for X11. */

View File

@@ -71,9 +71,9 @@ namespace Internal {
const char DEBUGGER_COUNT_KEY[] = "DebuggerItem.Count"; const char DEBUGGER_COUNT_KEY[] = "DebuggerItem.Count";
const char DEBUGGER_DATA_KEY[] = "DebuggerItem."; const char DEBUGGER_DATA_KEY[] = "DebuggerItem.";
const char DEBUGGER_LEGACY_FILENAME[] = "/qtcreator/profiles.xml"; const char DEBUGGER_LEGACY_FILENAME[] = "/profiles.xml";
const char DEBUGGER_FILE_VERSION_KEY[] = "Version"; const char DEBUGGER_FILE_VERSION_KEY[] = "Version";
const char DEBUGGER_FILENAME[] = "/qtcreator/debuggers.xml"; const char DEBUGGER_FILENAME[] = "/debuggers.xml";
const char debuggingToolsWikiLinkC[] = "http://wiki.qt.io/Qt_Creator_Windows_Debugging"; const char debuggingToolsWikiLinkC[] = "http://wiki.qt.io/Qt_Creator_Windows_Debugging";
class DebuggerItemModel; class DebuggerItemModel;
@@ -821,8 +821,7 @@ void DebuggerItemManagerPrivate::readLegacyDebuggers(const FileName &file)
static FileName userSettingsFileName() static FileName userSettingsFileName()
{ {
QFileInfo settingsLocation(ICore::settings()->fileName()); return FileName::fromString(ICore::userResourcePath() + DEBUGGER_FILENAME);
return FileName::fromString(settingsLocation.absolutePath() + QLatin1String(DEBUGGER_FILENAME));
} }
DebuggerItemManagerPrivate::DebuggerItemManagerPrivate() DebuggerItemManagerPrivate::DebuggerItemManagerPrivate()
@@ -918,8 +917,7 @@ void DebuggerItemManagerPrivate::readDebuggers(const FileName &fileName, bool is
void DebuggerItemManagerPrivate::restoreDebuggers() void DebuggerItemManagerPrivate::restoreDebuggers()
{ {
// Read debuggers from SDK // Read debuggers from SDK
QFileInfo systemSettingsFile(ICore::settings(QSettings::SystemScope)->fileName()); readDebuggers(FileName::fromString(ICore::installerResourcePath() + DEBUGGER_FILENAME), true);
readDebuggers(FileName::fromString(systemSettingsFile.absolutePath() + DEBUGGER_FILENAME), true);
// Read all debuggers from user file. // Read all debuggers from user file.
readDebuggers(userSettingsFileName(), false); readDebuggers(userSettingsFileName(), false);
@@ -929,10 +927,8 @@ void DebuggerItemManagerPrivate::restoreDebuggers()
autoDetectGdbOrLldbDebuggers(); autoDetectGdbOrLldbDebuggers();
// Add debuggers from pre-3.x profiles.xml // Add debuggers from pre-3.x profiles.xml
QFileInfo systemLocation(ICore::settings(QSettings::SystemScope)->fileName()); readLegacyDebuggers(FileName::fromString(ICore::installerResourcePath() + DEBUGGER_LEGACY_FILENAME));
readLegacyDebuggers(FileName::fromString(systemLocation.absolutePath() + QLatin1String(DEBUGGER_LEGACY_FILENAME))); readLegacyDebuggers(FileName::fromString(ICore::userResourcePath() + DEBUGGER_LEGACY_FILENAME));
QFileInfo userLocation(ICore::settings()->fileName());
readLegacyDebuggers(FileName::fromString(userLocation.absolutePath() + QLatin1String(DEBUGGER_LEGACY_FILENAME)));
} }
void DebuggerItemManagerPrivate::saveDebuggers() void DebuggerItemManagerPrivate::saveDebuggers()

View File

@@ -5,6 +5,7 @@ QtcPlugin {
Depends { name: "Qt"; submodules: ["help", "network", "sql"]; } Depends { name: "Qt"; submodules: ["help", "network", "sql"]; }
Depends { name: "Qt.printsupport" } Depends { name: "Qt.printsupport" }
Depends { name: "Qt.webenginewidgets"; required: false }
Depends { name: "Aggregation" } Depends { name: "Aggregation" }
Depends { name: "Utils" } Depends { name: "Utils" }
@@ -16,6 +17,8 @@ QtcPlugin {
cpp.defines: { cpp.defines: {
var defines = base.concat(["QT_CLUCENE_SUPPORT"]); var defines = base.concat(["QT_CLUCENE_SUPPORT"]);
if (Qt.webenginewidgets.present)
defines.push("QTC_WEBENGINE_HELPVIEWER");
return defines; return defines;
} }
@@ -50,6 +53,14 @@ QtcPlugin {
] ]
} }
Group {
name: "WebEngine Sources"
condition: Qt.webenginewidgets.present
files: [
"webenginehelpviewer.cpp", "webenginehelpviewer.h"
]
}
Group { Group {
id: sharedSources id: sharedSources
name: "Shared Sources" name: "Shared Sources"

View File

@@ -35,6 +35,7 @@
#include <coreplugin/actionmanager/command.h> #include <coreplugin/actionmanager/command.h>
#include <coreplugin/id.h> #include <coreplugin/id.h>
#include <QAction>
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QTreeWidget> #include <QTreeWidget>

View File

@@ -31,6 +31,8 @@
#include <utils/portlist.h> #include <utils/portlist.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QRegExpValidator>
using namespace ProjectExplorer::Constants; using namespace ProjectExplorer::Constants;
namespace ProjectExplorer { namespace ProjectExplorer {

View File

@@ -150,7 +150,7 @@ void DeviceManager::load()
// read devices file from global settings path // read devices file from global settings path
QHash<Core::Id, Core::Id> defaultDevices; QHash<Core::Id, Core::Id> defaultDevices;
QList<IDevice::Ptr> sdkDevices; QList<IDevice::Ptr> sdkDevices;
if (reader.load(systemSettingsFilePath(QLatin1String("/qtcreator/devices.xml")))) if (reader.load(systemSettingsFilePath(QLatin1String("/devices.xml"))))
sdkDevices = fromMap(reader.restoreValues().value(DeviceManagerKey).toMap(), &defaultDevices); sdkDevices = fromMap(reader.restoreValues().value(DeviceManagerKey).toMap(), &defaultDevices);
// read devices file from user settings path // read devices file from user settings path
QList<IDevice::Ptr> userDevices; QList<IDevice::Ptr> userDevices;
@@ -230,9 +230,8 @@ Utils::FileName DeviceManager::settingsFilePath(const QString &extension)
Utils::FileName DeviceManager::systemSettingsFilePath(const QString &deviceFileRelativePath) Utils::FileName DeviceManager::systemSettingsFilePath(const QString &deviceFileRelativePath)
{ {
return Utils::FileName::fromString( return Utils::FileName::fromString(Core::ICore::installerResourcePath()
QFileInfo(Core::ICore::settings(QSettings::SystemScope)->fileName()).absolutePath() + deviceFileRelativePath);
+ deviceFileRelativePath);
} }
void DeviceManager::addDevice(const IDevice::ConstPtr &_device) void DeviceManager::addDevice(const IDevice::ConstPtr &_device)

View File

@@ -53,12 +53,11 @@ const char KIT_DATA_KEY[] = "Profile.";
const char KIT_COUNT_KEY[] = "Profile.Count"; const char KIT_COUNT_KEY[] = "Profile.Count";
const char KIT_FILE_VERSION_KEY[] = "Version"; const char KIT_FILE_VERSION_KEY[] = "Version";
const char KIT_DEFAULT_KEY[] = "Profile.Default"; const char KIT_DEFAULT_KEY[] = "Profile.Default";
const char KIT_FILENAME[] = "/qtcreator/profiles.xml"; const char KIT_FILENAME[] = "/profiles.xml";
static FileName settingsFileName() static FileName settingsFileName()
{ {
QFileInfo settingsLocation(ICore::settings()->fileName()); return FileName::fromString(ICore::resourcePath() + KIT_FILENAME);
return FileName::fromString(settingsLocation.absolutePath() + QLatin1String(KIT_FILENAME));
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@@ -131,8 +130,7 @@ void KitManager::restoreKits()
QList<Kit *> sdkKits; QList<Kit *> sdkKits;
// read all kits from SDK // read all kits from SDK
QFileInfo systemSettingsFile(ICore::settings(QSettings::SystemScope)->fileName()); QFileInfo kitFile(ICore::installerResourcePath() + KIT_FILENAME);
QFileInfo kitFile(systemSettingsFile.absolutePath() + QLatin1String(KIT_FILENAME));
if (kitFile.exists()) { if (kitFile.exists()) {
KitList system = restoreKits(FileName(kitFile)); KitList system = restoreKits(FileName(kitFile));
// make sure we mark these as autodetected and run additional setup logic // make sure we mark these as autodetected and run additional setup logic

View File

@@ -44,14 +44,13 @@
static const char TOOLCHAIN_DATA_KEY[] = "ToolChain."; static const char TOOLCHAIN_DATA_KEY[] = "ToolChain.";
static const char TOOLCHAIN_COUNT_KEY[] = "ToolChain.Count"; static const char TOOLCHAIN_COUNT_KEY[] = "ToolChain.Count";
static const char TOOLCHAIN_FILE_VERSION_KEY[] = "Version"; static const char TOOLCHAIN_FILE_VERSION_KEY[] = "Version";
static const char TOOLCHAIN_FILENAME[] = "/qtcreator/toolchains.xml"; static const char TOOLCHAIN_FILENAME[] = "/toolchains.xml";
using namespace Utils; using namespace Utils;
static FileName settingsFileName(const QString &path) static FileName settingsFileName(const QString &path)
{ {
QFileInfo settingsLocation(Core::ICore::settings()->fileName()); return FileName::fromString(Core::ICore::resourcePath() + path);
return FileName::fromString(settingsLocation.absolutePath() + path);
} }
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -304,9 +303,8 @@ void ToolChainManager::restoreToolChains()
QList<ToolChain *> ToolChainManager::readSystemFileToolChains() QList<ToolChain *> ToolChainManager::readSystemFileToolChains()
{ {
QFileInfo systemSettingsFile(Core::ICore::settings(QSettings::SystemScope)->fileName()); QList<ToolChain *> systemTcs = restoreFromFile(
QList<ToolChain *> systemTcs FileName::fromString(Core::ICore::installerResourcePath() + TOOLCHAIN_FILENAME));
= restoreFromFile(FileName::fromString(systemSettingsFile.absolutePath() + QLatin1String(TOOLCHAIN_FILENAME)));
foreach (ToolChain *tc, systemTcs) foreach (ToolChain *tc, systemTcs)
tc->setDetection(ToolChain::AutoDetection); tc->setDetection(ToolChain::AutoDetection);

View File

@@ -1571,8 +1571,7 @@ static QString maddeRoot(const QString &qmakePath)
void UserFileVersion11Upgrader::parseQtversionFile() void UserFileVersion11Upgrader::parseQtversionFile()
{ {
PersistentSettingsReader reader; PersistentSettingsReader reader;
QFileInfo settingsLocation = QFileInfo(Core::ICore::settings()->fileName()); reader.load(FileName::fromString(Core::ICore::userResourcePath() + "/../qtversion.xml"));
reader.load(FileName::fromString(settingsLocation.absolutePath() + "/qtversion.xml"));
QVariantMap data = reader.restoreValues(); QVariantMap data = reader.restoreValues();
int count = data.value("QtVersion.Count", 0).toInt(); int count = data.value("QtVersion.Count", 0).toInt();
@@ -1610,8 +1609,7 @@ void UserFileVersion11Upgrader::parseQtversionFile()
void UserFileVersion11Upgrader::parseToolChainFile() void UserFileVersion11Upgrader::parseToolChainFile()
{ {
PersistentSettingsReader reader; PersistentSettingsReader reader;
QFileInfo settingsLocation(Core::ICore::settings()->fileName()); reader.load(FileName::fromString(Core::ICore::userResourcePath() + "/../toolChains.xml"));
reader.load(FileName::fromString(settingsLocation.absolutePath() + "/toolChains.xml"));
QVariantMap data = reader.restoreValues(); QVariantMap data = reader.restoreValues();
int count = data.value("ToolChain.Count", 0).toInt(); int count = data.value("ToolChain.Count", 0).toInt();
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {

View File

@@ -382,60 +382,11 @@ void DesignDocument::deleteSelected()
void DesignDocument::copySelected() void DesignDocument::copySelected()
{ {
QScopedPointer<Model> copyModel(Model::create("QtQuick.Rectangle", 1, 0, currentModel()));
copyModel->setFileUrl(currentModel()->fileUrl());
copyModel->changeImports(currentModel()->imports(), {});
Q_ASSERT(copyModel);
DesignDocumentView view; DesignDocumentView view;
currentModel()->attachView(&view); currentModel()->attachView(&view);
if (view.selectedModelNodes().isEmpty()) DesignDocumentView::copyModelNodes(view.selectedModelNodes());
return;
QList<ModelNode> selectedNodes(view.selectedModelNodes());
foreach (const ModelNode &node, selectedNodes) {
foreach (const ModelNode &node2, selectedNodes) {
if (node.isAncestorOf(node2))
selectedNodes.removeAll(node2);
}
}
if (selectedNodes.count() == 1) {
ModelNode selectedNode(selectedNodes.first());
if (!selectedNode.isValid())
return;
currentModel()->detachView(&view);
copyModel->attachView(&view);
view.replaceModel(selectedNode);
Q_ASSERT(view.rootModelNode().isValid());
Q_ASSERT(view.rootModelNode().type() != "empty");
view.toClipboard();
} else { //multi items selected
currentModel()->detachView(&view);
copyModel->attachView(&view);
foreach (ModelNode node, view.rootModelNode().directSubModelNodes()) {
node.destroy();
}
view.changeRootNodeType("QtQuick.Rectangle", 1, 0);
view.rootModelNode().setIdWithRefactoring(QLatin1String("designer__Selection"));
foreach (const ModelNode &selectedNode, selectedNodes) {
ModelNode newNode(view.insertModel(selectedNode));
view.rootModelNode().nodeListProperty("data").reparentHere(newNode);
}
view.toClipboard();
}
} }
void DesignDocument::cutSelected() void DesignDocument::cutSelected()
@@ -479,28 +430,21 @@ static void scatterItem(const ModelNode &pastedNode, const ModelNode &targetNode
void DesignDocument::paste() void DesignDocument::paste()
{ {
QScopedPointer<Model> pasteModel(Model::create("empty", 1, 0, currentModel())); QScopedPointer<Model> pasteModel(DesignDocumentView::pasteToModel());
pasteModel->setFileUrl(currentModel()->fileUrl());
pasteModel->changeImports(currentModel()->imports(), {});
Q_ASSERT(pasteModel);
if (!pasteModel) if (!pasteModel)
return; return;
DesignDocumentView view; DesignDocumentView view;
pasteModel->attachView(&view); pasteModel->attachView(&view);
view.fromClipboard();
ModelNode rootNode(view.rootModelNode()); ModelNode rootNode(view.rootModelNode());
QList<ModelNode> selectedNodes = rootNode.directSubModelNodes();
pasteModel->detachView(&view);
if (rootNode.type() == "empty") if (rootNode.type() == "empty")
return; return;
if (rootNode.id() == QLatin1String("designer__Selection")) { if (rootNode.id() == "designer__Selection") {
QList<ModelNode> selectedNodes = rootNode.directSubModelNodes();
pasteModel->detachView(&view);
currentModel()->attachView(&view); currentModel()->attachView(&view);
ModelNode targetNode; ModelNode targetNode;
@@ -546,7 +490,6 @@ void DesignDocument::paste()
try { try {
RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste2")); RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste2"));
pasteModel->detachView(&view);
currentModel()->attachView(&view); currentModel()->attachView(&view);
ModelNode pastedNode(view.insertModel(rootNode)); ModelNode pastedNode(view.insertModel(rootNode));
ModelNode targetNode; ModelNode targetNode;

View File

@@ -26,6 +26,11 @@
#include "designdocumentview.h" #include "designdocumentview.h"
#include <rewriterview.h> #include <rewriterview.h>
#include <basetexteditmodifier.h> #include <basetexteditmodifier.h>
#include <modelmerger.h>
#include "designdocument.h"
#include <qmldesignerplugin.h>
#include <nodelistproperty.h>
#include <QApplication> #include <QApplication>
#include <QPlainTextEdit> #include <QPlainTextEdit>
@@ -33,10 +38,12 @@
#include <QMimeData> #include <QMimeData>
#include <QDebug> #include <QDebug>
#include <utils/qtcassert.h>
namespace QmlDesigner { namespace QmlDesigner {
DesignDocumentView::DesignDocumentView(QObject *parent) DesignDocumentView::DesignDocumentView(QObject *parent)
: AbstractView(parent), m_modelMerger(this) : AbstractView(parent), m_modelMerger(new ModelMerger(this))
{ {
} }
@@ -44,6 +51,16 @@ DesignDocumentView::~DesignDocumentView()
{ {
} }
ModelNode DesignDocumentView::insertModel(const ModelNode &modelNode)
{
return m_modelMerger->insertModel(modelNode);
}
void DesignDocumentView::replaceModel(const ModelNode &modelNode)
{
m_modelMerger->replaceModel(modelNode);
}
static QStringList arrayToStringList(const QByteArray &byteArray) static QStringList arrayToStringList(const QByteArray &byteArray)
{ {
QString str(QString::fromUtf8(byteArray)); QString str(QString::fromUtf8(byteArray));
@@ -140,4 +157,95 @@ void DesignDocumentView::fromText(QString text)
} }
} }
static Model *currentModel()
{
DesignDocument *document = QmlDesignerPlugin::instance()->viewManager().currentDesignDocument();
if (document)
return document->currentModel();
return 0;
}
Model *DesignDocumentView::pasteToModel()
{
Model *parentModel = currentModel();
QTC_ASSERT(parentModel, return 0);
Model *pasteModel(Model::create("empty", 1, 0, parentModel));
pasteModel->setFileUrl(parentModel->fileUrl());
pasteModel->changeImports(parentModel->imports(), {});
Q_ASSERT(pasteModel);
if (!pasteModel)
return 0;
DesignDocumentView view;
pasteModel->attachView(&view);
view.fromClipboard();
return pasteModel;
}
void DesignDocumentView::copyModelNodes(const QList<ModelNode> &nodesToCopy)
{
Model *parentModel = currentModel();
QTC_ASSERT(parentModel, return);
QScopedPointer<Model> copyModel(Model::create("QtQuick.Rectangle", 1, 0, parentModel));
copyModel->setFileUrl(parentModel->fileUrl());
copyModel->changeImports(parentModel->imports(), {});
Q_ASSERT(copyModel);
QList<ModelNode> selectedNodes = nodesToCopy;
if (selectedNodes.isEmpty())
return;
foreach (const ModelNode &node, selectedNodes) {
foreach (const ModelNode &node2, selectedNodes) {
if (node.isAncestorOf(node2))
selectedNodes.removeAll(node2);
}
}
DesignDocumentView view;
copyModel->attachView(&view);
if (selectedNodes.count() == 1) {
ModelNode selectedNode(selectedNodes.first());
if (!selectedNode.isValid())
return;
view.replaceModel(selectedNode);
Q_ASSERT(view.rootModelNode().isValid());
Q_ASSERT(view.rootModelNode().type() != "empty");
view.toClipboard();
} else { //multi items selected
foreach (ModelNode node, view.rootModelNode().directSubModelNodes()) {
node.destroy();
}
view.changeRootNodeType("QtQuick.Rectangle", 2, 0);
view.rootModelNode().setIdWithRefactoring("designer__Selection");
foreach (const ModelNode &selectedNode, selectedNodes) {
ModelNode newNode(view.insertModel(selectedNode));
view.rootModelNode().nodeListProperty("data").reparentHere(newNode);
}
view.toClipboard();
}
}
}// namespace QmlDesigner }// namespace QmlDesigner

View File

@@ -26,21 +26,22 @@
#pragma once #pragma once
#include <abstractview.h> #include <abstractview.h>
#include <modelmerger.h>
#include <memory>
namespace QmlDesigner { namespace QmlDesigner {
class DesignDocumentView : public AbstractView class ModelMerger;
class QMLDESIGNERCORE_EXPORT DesignDocumentView : public AbstractView
{ {
Q_OBJECT Q_OBJECT
public: public:
DesignDocumentView(QObject *parent = 0); DesignDocumentView(QObject *parent = 0);
~DesignDocumentView(); ~DesignDocumentView();
ModelNode insertModel(const ModelNode &modelNode) ModelNode insertModel(const ModelNode &modelNode);
{ return m_modelMerger.insertModel(modelNode); } void replaceModel(const ModelNode &modelNode);
void replaceModel(const ModelNode &modelNode)
{ m_modelMerger.replaceModel(modelNode); }
void toClipboard() const; void toClipboard() const;
void fromClipboard(); void fromClipboard();
@@ -48,8 +49,11 @@ public:
QString toText() const; QString toText() const;
void fromText(QString text); void fromText(QString text);
static Model *pasteToModel();
static void copyModelNodes(const QList<ModelNode> &nodesToCopy);
private: private:
ModelMerger m_modelMerger; std::unique_ptr<ModelMerger> m_modelMerger;
}; };
}// namespace QmlDesigner }// namespace QmlDesigner

View File

@@ -66,6 +66,7 @@ public:
const QList<ModelNode> keyframePositions() const; const QList<ModelNode> keyframePositions() const;
static bool isValidKeyframe(const ModelNode &node); static bool isValidKeyframe(const ModelNode &node);
static bool checkKeyframesType(const ModelNode &node);
static QmlTimelineFrames keyframesForKeyframe(const ModelNode &node); static QmlTimelineFrames keyframesForKeyframe(const ModelNode &node);
void moveAllFrames(qreal offset); void moveAllFrames(qreal offset);

View File

@@ -96,6 +96,7 @@ public:
void toggleStatesViewExpanded(); void toggleStatesViewExpanded();
QString qmlJSEditorHelpId() const; QString qmlJSEditorHelpId() const;
DesignDocument *currentDesignDocument() const;
private: // functions private: // functions
Q_DISABLE_COPY(ViewManager) Q_DISABLE_COPY(ViewManager)
@@ -107,7 +108,6 @@ private: // functions
Model *currentModel() const; Model *currentModel() const;
Model *documentModel() const; Model *documentModel() const;
DesignDocument *currentDesignDocument() const;
QString pathToQt() const; QString pathToQt() const;
void switchStateEditorViewToBaseState(); void switchStateEditorViewToBaseState();

View File

@@ -55,8 +55,7 @@ bool QmlTimelineFrames::isValid() const
bool QmlTimelineFrames::isValidQmlTimelineFrames(const ModelNode &modelNode) bool QmlTimelineFrames::isValidQmlTimelineFrames(const ModelNode &modelNode)
{ {
return isValidQmlModelNodeFacade(modelNode) return modelNode.isValid() && modelNode.metaInfo().isValid()
&& modelNode.metaInfo().isValid()
&& modelNode.metaInfo().isSubclassOf("QtQuick.Timeline.Keyframes"); && modelNode.metaInfo().isSubclassOf("QtQuick.Timeline.Keyframes");
} }
@@ -219,6 +218,11 @@ bool QmlTimelineFrames::isValidKeyframe(const ModelNode &node)
&& node.metaInfo().isSubclassOf("QtQuick.Timeline.Keyframe"); && node.metaInfo().isSubclassOf("QtQuick.Timeline.Keyframe");
} }
bool QmlTimelineFrames::checkKeyframesType(const ModelNode &node)
{
return node.isValid() && node.type() == "QtQuick.Timeline.Keyframes";
}
QmlTimelineFrames QmlTimelineFrames::keyframesForKeyframe(const ModelNode &node) QmlTimelineFrames QmlTimelineFrames::keyframesForKeyframe(const ModelNode &node)
{ {
if (isValidKeyframe(node) && node.hasParentProperty()) { if (isValidKeyframe(node) && node.hasParentProperty()) {

View File

@@ -63,7 +63,7 @@ using namespace Internal;
const char QTVERSION_DATA_KEY[] = "QtVersion."; const char QTVERSION_DATA_KEY[] = "QtVersion.";
const char QTVERSION_TYPE_KEY[] = "QtVersion.Type"; const char QTVERSION_TYPE_KEY[] = "QtVersion.Type";
const char QTVERSION_FILE_VERSION_KEY[] = "Version"; const char QTVERSION_FILE_VERSION_KEY[] = "Version";
const char QTVERSION_FILENAME[] = "/qtcreator/qtversion.xml"; const char QTVERSION_FILENAME[] = "/qtversion.xml";
static QMap<int, BaseQtVersion *> m_versions; static QMap<int, BaseQtVersion *> m_versions;
static int m_idcount = 0; static int m_idcount = 0;
@@ -77,16 +77,12 @@ enum { debug = 0 };
static FileName globalSettingsFileName() static FileName globalSettingsFileName()
{ {
QSettings *globalSettings = ExtensionSystem::PluginManager::globalSettings(); return FileName::fromString(Core::ICore::installerResourcePath() + QTVERSION_FILENAME);
return FileName::fromString(QFileInfo(globalSettings->fileName()).absolutePath()
+ QLatin1String(QTVERSION_FILENAME));
} }
static FileName settingsFileName(const QString &path) static FileName settingsFileName(const QString &path)
{ {
QSettings *settings = ExtensionSystem::PluginManager::settings(); return FileName::fromString(Core::ICore::resourcePath() + path);
QFileInfo settingsLocation(settings->fileName());
return FileName::fromString(settingsLocation.absolutePath() + path);
} }

View File

@@ -34,6 +34,7 @@
#include <QClipboard> #include <QClipboard>
#include <QIcon> #include <QIcon>
#include <QSettings> #include <QSettings>
#include <QStyle>
static const char SettingsApplication[] = "QtCreator"; static const char SettingsApplication[] = "QtCreator";
static const char SettingsKeySkipWarningAbortingBacktrace[] static const char SettingsKeySkipWarningAbortingBacktrace[]

View File

@@ -51,7 +51,7 @@ Settings::Settings() :
sdkPath.appendPath(QLatin1String(DATA_PATH)); sdkPath.appendPath(QLatin1String(DATA_PATH));
sdkPath = Utils::FileName::fromString(QDir::cleanPath(sdkPath.toString())); sdkPath = Utils::FileName::fromString(QDir::cleanPath(sdkPath.toString()));
sdkPath.appendPath(QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR) sdkPath.appendPath(QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR)
+ QLatin1String("/qtcreator")); + '/' + Core::Constants::IDE_ID);
} }
Utils::FileName Settings::getPath(const QString &file) Utils::FileName Settings::getPath(const QString &file)