Merge remote-tracking branch 'origin/2.8'

Conflicts:
	qtcreator.pri
	qtcreator.qbs

Change-Id: I1aa7506519e0f461f33921ca20ce1b51adb5783f
This commit is contained in:
Eike Ziller
2013-06-27 14:24:57 +02:00
71 changed files with 767 additions and 404 deletions

View File

@@ -83,7 +83,7 @@ Module {
} }
prepare: { prepare: {
var xslFile = project.path + "/src/pluginjsonmetadata.xsl"; var xslFile = project.path + "/../pluginjsonmetadata.xsl"; // project is "Plugins"
var xmlPatternsPath = product.moduleProperty("Qt/core", "binPath") + "/xmlpatterns"; var xmlPatternsPath = product.moduleProperty("Qt/core", "binPath") + "/xmlpatterns";
var args = [ var args = [
"-no-format", "-no-format",

View File

@@ -2,6 +2,7 @@
QTCREATOR_PRI_INCLUDED = 1 QTCREATOR_PRI_INCLUDED = 1
QTCREATOR_VERSION = 2.8.81 QTCREATOR_VERSION = 2.8.81
BINARY_ARTIFACTS_BRANCH = 3.0
isEqual(QT_MAJOR_VERSION, 5) { isEqual(QT_MAJOR_VERSION, 5) {

View File

@@ -77,7 +77,7 @@ macx {
deployqt.depends = install deployqt.depends = install
win32 { win32 {
deployartifacts.depends = install deployartifacts.depends = install
deployartifacts.commands = git clone "git://gitorious.org/qt-creator/binary-artifacts.git"&& xcopy /s /q /y /i "binary-artifacts\\win32" \"$(INSTALL_ROOT)$$QTC_PREFIX\"&& rmdir /s /q binary-artifacts deployartifacts.commands = git clone "git://gitorious.org/qt-creator/binary-artifacts.git" -b $$BINARY_ARTIFACTS_BRANCH&& xcopy /s /q /y /i "binary-artifacts\\win32" \"$(INSTALL_ROOT)$$QTC_PREFIX\"&& rmdir /s /q binary-artifacts
QMAKE_EXTRA_TARGETS += deployartifacts QMAKE_EXTRA_TARGETS += deployartifacts
} }
} }

View File

@@ -1,17 +1,14 @@
import qbs.base 1.0 import qbs.base 1.0
import qbs.fileinfo as FileInfo
import "qbs/defaults.js" as Defaults
Project { Project {
property string ide_version_major: '2' property string ide_version_major: '2'
property string ide_version_minor: '8' property string ide_version_minor: '8'
property string ide_version_release: '81' property string ide_version_release: '81'
property string qtcreator_version: ide_version_major + '.' + ide_version_minor + '.' + ide_version_release property string qtcreator_version: ide_version_major + '.' + ide_version_minor + '.' + ide_version_release
property string ide_app_path: qbs.targetOS.contains("mac") ? "" : "bin" property string ide_app_path: qbs.targetOS.contains("osx") ? "" : "bin"
property string ide_app_target: qbs.targetOS.contains("mac") ? "Qt Creator" : "qtcreator" property string ide_app_target: qbs.targetOS.contains("osx") ? "Qt Creator" : "qtcreator"
property string ide_library_path: { property string ide_library_path: {
if (qbs.targetOS.contains("mac")) if (qbs.targetOS.contains("osx"))
return ide_app_target + ".app/Contents/PlugIns" return ide_app_target + ".app/Contents/PlugIns"
else if (qbs.targetOS.contains("windows")) else if (qbs.targetOS.contains("windows"))
return ide_app_path return ide_app_path
@@ -19,222 +16,31 @@ Project {
return "lib/qtcreator" return "lib/qtcreator"
} }
property string ide_plugin_path: { property string ide_plugin_path: {
if (qbs.targetOS.contains("mac")) if (qbs.targetOS.contains("osx"))
return ide_library_path return ide_library_path
else if (qbs.targetOS.contains("windows")) else if (qbs.targetOS.contains("windows"))
return "lib/qtcreator/plugins" return "lib/qtcreator/plugins"
else else
return ide_library_path + "/plugins" return ide_library_path + "/plugins"
} }
property string ide_data_path: qbs.targetOS.contains("mac") property string ide_data_path: qbs.targetOS.contains("osx")
? ide_app_target + ".app/Contents/Resources" ? ide_app_target + ".app/Contents/Resources"
: "share/qtcreator" : "share/qtcreator"
property string ide_libexec_path: qbs.targetOS.contains("mac") property string ide_libexec_path: qbs.targetOS.contains("osx")
? ide_data_path ? ide_data_path
: ide_app_path : ide_app_path
property string ide_doc_path: qbs.targetOS.contains("mac") property string ide_doc_path: qbs.targetOS.contains("osx")
? ide_data_path + "/doc" ? ide_data_path + "/doc"
: "share/doc/qtcreator" : "share/doc/qtcreator"
property string ide_bin_path: qbs.targetOS.contains("mac") property string ide_bin_path: qbs.targetOS.contains("osx")
? ide_app_target + ".app/Contents/MacOS" ? ide_app_target + ".app/Contents/MacOS"
: ide_app_path : ide_app_path
moduleSearchPaths: "qbs" moduleSearchPaths: "qbs"
references: [ references: [
"src/src.qbs",
"lib/qtcreator/qtcomponents/qtcomponents.qbs", "lib/qtcreator/qtcomponents/qtcomponents.qbs",
"share/share.qbs", "share/share.qbs",
"share/qtcreator/translations/translations.qbs", "share/qtcreator/translations/translations.qbs",
"src/libs/aggregation/aggregation.qbs",
"src/libs/cplusplus/cplusplus.qbs",
"src/libs/extensionsystem/extensionsystem.qbs",
"src/libs/glsl/glsl.qbs",
"src/libs/languageutils/languageutils.qbs",
"src/libs/qmleditorwidgets/qmleditorwidgets.qbs",
"src/libs/qmljs/qmljs.qbs",
"src/libs/qmldebug/qmldebug.qbs",
"src/libs/qtcomponents/styleitem/styleitem.qbs",
"src/libs/ssh/ssh.qbs",
"src/libs/utils/process_stub.qbs",
"src/libs/utils/process_ctrlc_stub.qbs",
"src/libs/utils/utils.qbs",
"src/libs/zeroconf/zeroconf.qbs",
"src/plugins/analyzerbase/analyzerbase.qbs",
"src/plugins/android/android.qbs",
"src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs",
"src/plugins/bazaar/bazaar.qbs",
"src/plugins/bineditor/bineditor.qbs",
"src/plugins/bookmarks/bookmarks.qbs",
"src/plugins/classview/classview.qbs",
"src/plugins/clearcase/clearcase.qbs",
"src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs",
"src/plugins/coreplugin/coreplugin.qbs",
"src/plugins/coreplugin/images/logo/logo.qbs",
"src/plugins/cpaster/cpaster.qbs",
"src/plugins/cppeditor/cppeditor.qbs",
"src/plugins/cpptools/cpptools.qbs",
"src/plugins/cvs/cvs.qbs",
"src/plugins/debugger/debugger.qbs",
"src/plugins/debugger/ptracepreload.qbs",
"src/plugins/designer/designer.qbs",
"src/plugins/diffeditor/diffeditor.qbs",
"src/plugins/fakevim/fakevim.qbs",
"src/plugins/find/find.qbs",
"src/plugins/genericprojectmanager/genericprojectmanager.qbs",
"src/plugins/git/git.qbs",
"src/plugins/glsleditor/glsleditor.qbs",
"src/plugins/helloworld/helloworld.qbs",
"src/plugins/help/help.qbs",
"src/plugins/imageviewer/imageviewer.qbs",
"src/plugins/locator/locator.qbs",
"src/plugins/macros/macros.qbs",
"src/plugins/madde/madde.qbs",
"src/plugins/mercurial/mercurial.qbs",
"src/plugins/perforce/perforce.qbs",
"src/plugins/projectexplorer/projectexplorer.qbs",
"src/plugins/qbsprojectmanager/qbsprojectmanager.qbs",
"src/plugins/pythoneditor/pythoneditor.qbs",
// "src/plugins/qmldesigner/qmldesigner.qbs",
"src/plugins/qmljseditor/qmljseditor.qbs",
"src/plugins/qmljstools/qmljstools.qbs",
"src/plugins/qmlprofiler/qmlprofiler.qbs",
"src/plugins/qmlprojectmanager/qmlprojectmanager.qbs",
"src/plugins/qnx/qnx.qbs",
"src/plugins/qt4projectmanager/qt4projectmanager.qbs",
"src/plugins/qtsupport/qtsupport.qbs",
"src/plugins/remotelinux/remotelinux.qbs",
"src/plugins/resourceeditor/resourceeditor.qbs",
"src/plugins/subversion/subversion.qbs",
"src/plugins/tasklist/tasklist.qbs",
"src/plugins/texteditor/texteditor.qbs",
"src/plugins/todo/todo.qbs",
"src/plugins/updateinfo/updateinfo.qbs",
"src/plugins/valgrind/valgrind.qbs",
"src/plugins/vcsbase/vcsbase.qbs",
"src/plugins/welcome/welcome.qbs",
"src/tools/qtcdebugger/qtcdebugger.qbs",
"src/tools/qtcreatorcrashhandler/qtcreatorcrashhandler.qbs",
"src/tools/qtpromaker/qtpromaker.qbs",
"src/plugins/cpaster/frontend/frontend.qbs",
"src/tools/sdktool/sdktool.qbs"
] ]
Product {
name: "app_version_header"
type: "hpp"
files: "src/app/app_version.h.in"
property string ide_version_major: project.ide_version_major
property string ide_version_minor: project.ide_version_minor
property string ide_version_release: project.ide_version_release
property string qtcreator_version: project.qtcreator_version
Transformer {
inputs: ["src/app/app_version.h.in"]
Artifact {
fileName: "app/app_version.h"
fileTags: "hpp"
}
prepare: {
var cmd = new JavaScriptCommand();
cmd.description = "generating app_version.h";
cmd.highlight = "codegen";
cmd.qtcreator_version = product.qtcreator_version;
cmd.ide_version_major = product.ide_version_major;
cmd.ide_version_minor = product.ide_version_minor;
cmd.ide_version_release = product.ide_version_release;
cmd.onWindows = (product.moduleProperty("qbs", "targetOS") === "windows");
cmd.sourceCode = function() {
var file = new TextFile(input.fileName);
var content = file.readAll();
// replace quoted quotes
content = content.replace(/\\\"/g, '"');
// replace Windows line endings
if (onWindows)
content = content.replace(/\r\n/g, "\n");
// replace the magic qmake incantations
content = content.replace(/(\n#define IDE_VERSION) .+\n/, "$1 " + qtcreator_version + "\n");
content = content.replace(/(\n#define IDE_VERSION_MAJOR) .+\n/, "$1 " + ide_version_major + "\n")
content = content.replace(/(\n#define IDE_VERSION_MINOR) .+\n/, "$1 " + ide_version_minor + "\n")
content = content.replace(/(\n#define IDE_VERSION_RELEASE) .+\n/, "$1 " + ide_version_release + "\n")
file = new TextFile(output.fileName, TextFile.WriteOnly);
file.truncate();
file.write(content);
file.close();
}
return cmd;
}
}
Export {
Depends { name: "cpp" }
cpp.includePaths: product.buildDirectory
}
}
Application {
name: project.ide_app_target
consoleApplication: qbs.debugInformation
cpp.rpaths: qbs.targetOS.contains("mac") ? ["@executable_path/.."]
: ["$ORIGIN/../lib/qtcreator"]
cpp.defines: Defaults.defines(qbs)
cpp.linkerFlags: {
if (qbs.buildVariant == "release" && (qbs.toolchain == "gcc" || qbs.toolchain == "mingw"))
return ["-Wl,-s"]
}
cpp.includePaths: [
"src",
"src/libs",
"src/shared/qtsingleapplication",
"src/shared/qtlockedfile",
buildDirectory
]
Depends { name: "app_version_header" }
Depends { name: "cpp" }
Depends { name: "Qt"; submodules: ["widgets", "network"] }
Depends { name: "Utils" }
Depends { name: "ExtensionSystem" }
files: [
"src/app/main.cpp",
"src/app/qtcreator.rc",
"src/shared/qtsingleapplication/qtsingleapplication.h",
"src/shared/qtsingleapplication/qtsingleapplication.cpp",
"src/shared/qtsingleapplication/qtlocalpeer.h",
"src/shared/qtsingleapplication/qtlocalpeer.cpp",
"src/shared/qtlockedfile/qtlockedfile.cpp",
"src/tools/qtcreatorcrashhandler/crashhandlersetup.cpp",
"src/tools/qtcreatorcrashhandler/crashhandlersetup.h"
]
Group {
name: "qtcreator.sh"
condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("mac")
files: "bin/qtcreator.sh"
qbs.install: true
qbs.installDir: "bin"
}
Group {
name: "QtLockedFile_unix"
condition: qbs.targetOS.contains("unix")
files: [
"src/shared/qtlockedfile/qtlockedfile_unix.cpp"
]
}
Group {
name: "QtLockedFile_win"
condition: qbs.targetOS.contains("windows")
files: [
"src/shared/qtlockedfile/qtlockedfile_win.cpp"
]
}
Group {
fileTagsFilter: product.type
qbs.install: true
qbs.installDir: project.ide_app_path
}
}
} }

View File

@@ -567,6 +567,7 @@ class Dumper:
self.charPtrType_ = None self.charPtrType_ = None
self.voidType_ = None self.voidType_ = None
self.isShuttingDown_ = False self.isShuttingDown_ = False
self.isInterrupting_ = False
self.dummyValue = None self.dummyValue = None
def extractTemplateArgument(self, typename, index): def extractTemplateArgument(self, typename, index):
@@ -1082,8 +1083,9 @@ class Dumper:
if self.dummyValue is None: if self.dummyValue is None:
self.dummyValue = value self.dummyValue = value
with SubItem(self, value): with SubItem(self, value):
self.put('iname="%s",' % self.currentIName) if value.IsValid():
self.putItem(value) self.put('iname="%s",' % self.currentIName)
self.putItem(value)
# 'watchers':[{'id':'watch.0','exp':'23'},...] # 'watchers':[{'id':'watch.0','exp':'23'},...]
if not self.dummyValue is None: if not self.dummyValue is None:
@@ -1144,13 +1146,9 @@ class Dumper:
if self.process is None: if self.process is None:
self.report('msg="No process"') self.report('msg="No process"')
return return
self.isInterrupting_ = True
error = self.process.Stop() error = self.process.Stop()
self.reportError(error) self.reportError(error)
self.consumeEvents()
if error.GetType() == 1:
state = self.process.GetState()
if state != lldb.eStateStopped:
self.report('state="inferiorstopfailed"')
def detachInferior(self, _ = None): def detachInferior(self, _ = None):
if self.process is None: if self.process is None:
@@ -1167,6 +1165,10 @@ class Dumper:
error = self.process.Continue() error = self.process.Continue()
self.reportError(error) self.reportError(error)
def quitDebugger(self, _ = None):
self.report('state="inferiorshutdownrequested"')
self.process.Kill()
def handleEvent(self, event): def handleEvent(self, event):
out = lldb.SBStream() out = lldb.SBStream()
event.GetDescription(out) event.GetDescription(out)
@@ -1178,7 +1180,6 @@ class Dumper:
self.report('event={type="%s",data="%s",msg="%s",flavor="%s",state="%s"}' self.report('event={type="%s",data="%s",msg="%s",flavor="%s",state="%s"}'
% (type, out.GetData(), msg, flavor, state)) % (type, out.GetData(), msg, flavor, state))
if state != self.eventState: if state != self.eventState:
self.report('state="%s"' % stateNames[state])
self.eventState = state self.eventState = state
if state == lldb.eStateExited: if state == lldb.eStateExited:
if self.isShuttingDown_: if self.isShuttingDown_:
@@ -1187,6 +1188,14 @@ class Dumper:
self.report('state="inferiorexited"') self.report('state="inferiorexited"')
self.report('exited={status="%s",desc="%s"}' self.report('exited={status="%s",desc="%s"}'
% (self.process.GetExitStatus(), self.process.GetExitDescription())) % (self.process.GetExitStatus(), self.process.GetExitDescription()))
elif state == lldb.eStateStopped:
if self.isInterrupting_:
self.isInterrupting_ = False
self.report('state="inferiorstopok"')
else:
self.report('state="stopped"')
else:
self.report('state="%s"' % stateNames[state])
if type == lldb.SBProcess.eBroadcastBitStateChanged: if type == lldb.SBProcess.eBroadcastBitStateChanged:
state = self.process.GetState() state = self.process.GetState()
if state == lldb.eStateStopped: if state == lldb.eStateStopped:

View File

@@ -4,5 +4,5 @@
id="QB.QML Application for Qt Quick 1.1"> id="QB.QML Application for Qt Quick 1.1">
<displayname>Qt Quick 1 UI</displayname> <displayname>Qt Quick 1 UI</displayname>
<displayname xml:lang="de">Qt Quick 1 UI</displayname> <displayname xml:lang="de">Qt Quick 1 UI</displayname>
<description>Creates a Qt Quick 1 UI project with a single QML file that contains the main view.&lt;br/&gt;You can review Qt Quick 1 UI projects in the QML Viewer and you need not build them. You do not need to have the development environment installed on your computer to create and run this type of projects.&lt;br/&gt;&lt;br/&gt;Requires &lt;b&gt;Qt 4.8&lt;/b&gt; or newer.</description> <description>Creates a Qt Quick 1 UI project with a single QML file that contains the main view. You can review Qt Quick 1 UI projects in the QML Viewer and you need not build them. You do not need to have the development environment installed on your computer to create and run this type of projects. Requires Qt 4.8 or newer.</description>
</template> </template>

View File

@@ -4,5 +4,5 @@
id="QB.QML Application for Qt Quick 2.0"> id="QB.QML Application for Qt Quick 2.0">
<displayname>Qt Quick 2 UI</displayname> <displayname>Qt Quick 2 UI</displayname>
<displayname xml:lang="de">Qt Quick 2 UI</displayname> <displayname xml:lang="de">Qt Quick 2 UI</displayname>
<description>Creates a Qt Quick 2 UI project with a single QML file that contains the main view.&lt;br/&gt;You can review Qt Quick 2 UI projects in the QML Scene and you need not build them. You do not need to have the development environment installed on your computer to create and run this type of projects.&lt;br/&gt;&lt;br/&gt;Requires &lt;b&gt;Qt 5.0&lt;/b&gt; or newer.</description> <description>Creates a Qt Quick 2 UI project with a single QML file that contains the main view. You can review Qt Quick 2 UI projects in the QML Scene and you need not build them. You do not need to have the development environment installed on your computer to create and run this type of projects. Requires Qt 5.0 or newer.</description>
</template> </template>

View File

@@ -3,5 +3,5 @@
featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2, QtSupport.Wizards.FeatureQtQuick.Controls" featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2, QtSupport.Wizards.FeatureQtQuick.Controls"
id="QB.QML Application for Qt Quick 2.0"> id="QB.QML Application for Qt Quick 2.0">
<displayname>Qt Quick 2 UI with Controls</displayname> <displayname>Qt Quick 2 UI with Controls</displayname>
<description>Creates a Qt Quick 2 UI project with a single QML file that contains the main view and uses Qt Quick Controls.&lt;br/&gt;You can review Qt Quick 2 UI projects in the QML Scene and you need not build them. This project requires that you have installed Qt Quick Controls for your Qt version.&lt;br/&gt;&lt;br/&gt;Requires &lt;b&gt;Qt 5.1&lt;/b&gt; or newer.</description> <description>Creates a Qt Quick 2 UI project with a single QML file that contains the main view and uses Qt Quick Controls. You can review Qt Quick 2 UI projects in the QML Scene and you need not build them. This project requires that you have installed Qt Quick Controls for your Qt version. Requires Qt 5.1 or newer.</description>
</template> </template>

View File

@@ -39,7 +39,7 @@ leave room for the Qt 4 target page.
id="QtQuick1ExtensionPlugin" category="G.Libraries" id="QtQuick1ExtensionPlugin" category="G.Libraries"
featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.1"> featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.1">
<icon>lib.png</icon> <icon>lib.png</icon>
<description>Creates a C++ plugin to load extensions dynamically into applications using the QDeclarativeEngine class.&lt;br&gt;&lt;br&gt;Requires &lt;b&gt;Qt 4.7.0&lt;/b&gt; or newer.</description> <description>Creates a C++ plugin to load extensions dynamically into applications using the QDeclarativeEngine class. Requires Qt 4.7.0 or newer.</description>
<displayname>Qt Quick 1 Extension Plugin</displayname> <displayname>Qt Quick 1 Extension Plugin</displayname>
<displaycategory>Libraries</displaycategory> <displaycategory>Libraries</displaycategory>
<files> <files>

View File

@@ -39,7 +39,7 @@ leave room for the Qt 4 target page.
id="QtQuick2ExtensionPlugin" category="G.Libraries" id="QtQuick2ExtensionPlugin" category="G.Libraries"
featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.2"> featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.2">
<icon>lib.png</icon> <icon>lib.png</icon>
<description>Creates a C++ plugin to load extensions dynamically into applications using the QQmlEngine class.&lt;br&gt;&lt;br&gt;Requires &lt;b&gt;Qt 5.0&lt;/b&gt; or newer.</description> <description>Creates a C++ plugin to load extensions dynamically into applications using the QQmlEngine class. Requires Qt 5.0 or newer.</description>
<displayname>Qt Quick 2 Extension Plugin</displayname> <displayname>Qt Quick 2 Extension Plugin</displayname>
<displaycategory>Libraries</displaycategory> <displaycategory>Libraries</displaycategory>
<files> <files>

View File

@@ -35464,7 +35464,8 @@ Kurznamen können verwendet werden, sofern sie eindeutig sind.</translation>
</message> </message>
<message> <message>
<source>Mixed</source> <source>Mixed</source>
<translation>Gemischt</translation> <translatorcomment>Using the English original because this is what will be passed to git (--mixed).</translatorcomment>
<translation>Mixed</translation>
</message> </message>
<message> <message>
<source>Hard</source> <source>Hard</source>

70
src/app/app.qbs Normal file
View File

@@ -0,0 +1,70 @@
import qbs
import "../../qbs/defaults.js" as Defaults
Application {
name: project.ide_app_target
consoleApplication: qbs.debugInformation
cpp.rpaths: qbs.targetOS.contains("osx") ? ["@executable_path/.."]
: ["$ORIGIN/../lib/qtcreator"]
cpp.defines: Defaults.defines(qbs)
cpp.linkerFlags: {
if (qbs.buildVariant == "release" && (qbs.toolchain == "gcc" || qbs.toolchain == "mingw"))
return ["-Wl,-s"]
}
cpp.includePaths: [
"..",
"../libs",
"../shared/qtsingleapplication",
"../shared/qtlockedfile",
buildDirectory
]
Depends { name: "app_version_header" }
Depends { name: "cpp" }
Depends { name: "Qt"; submodules: ["widgets", "network"] }
Depends { name: "Utils" }
Depends { name: "ExtensionSystem" }
files: [
"main.cpp",
"qtcreator.rc",
"../shared/qtsingleapplication/qtsingleapplication.h",
"../shared/qtsingleapplication/qtsingleapplication.cpp",
"../shared/qtsingleapplication/qtlocalpeer.h",
"../shared/qtsingleapplication/qtlocalpeer.cpp",
"../shared/qtlockedfile/qtlockedfile.cpp",
"../tools/qtcreatorcrashhandler/crashhandlersetup.cpp",
"../tools/qtcreatorcrashhandler/crashhandlersetup.h"
]
Group {
name: "qtcreator.sh"
condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("osx")
files: "../../bin/qtcreator.sh"
qbs.install: true
qbs.installDir: "bin"
}
Group {
name: "QtLockedFile_unix"
condition: qbs.targetOS.contains("unix")
files: [
"../shared/qtlockedfile/qtlockedfile_unix.cpp"
]
}
Group {
name: "QtLockedFile_win"
condition: qbs.targetOS.contains("windows")
files: [
"../shared/qtlockedfile/qtlockedfile_win.cpp"
]
}
Group {
fileTagsFilter: product.type
qbs.install: true
qbs.installDir: project.ide_app_path
}
}

View File

@@ -0,0 +1,53 @@
import qbs
Product {
name: "app_version_header"
type: "hpp"
files: "app_version.h.in"
property string ide_version_major: project.ide_version_major
property string ide_version_minor: project.ide_version_minor
property string ide_version_release: project.ide_version_release
property string qtcreator_version: project.qtcreator_version
Transformer {
inputs: ["app_version.h.in"]
Artifact {
fileName: "app/app_version.h"
fileTags: "hpp"
}
prepare: {
var cmd = new JavaScriptCommand();
cmd.description = "generating app_version.h";
cmd.highlight = "codegen";
cmd.qtcreator_version = product.qtcreator_version;
cmd.ide_version_major = product.ide_version_major;
cmd.ide_version_minor = product.ide_version_minor;
cmd.ide_version_release = product.ide_version_release;
cmd.onWindows = (product.moduleProperty("qbs", "targetOS") === "windows");
cmd.sourceCode = function() {
var file = new TextFile(input.fileName);
var content = file.readAll();
// replace quoted quotes
content = content.replace(/\\\"/g, '"');
// replace Windows line endings
if (onWindows)
content = content.replace(/\r\n/g, "\n");
// replace the magic qmake incantations
content = content.replace(/(\n#define IDE_VERSION) .+\n/, "$1 " + qtcreator_version + "\n");
content = content.replace(/(\n#define IDE_VERSION_MAJOR) .+\n/, "$1 " + ide_version_major + "\n")
content = content.replace(/(\n#define IDE_VERSION_MINOR) .+\n/, "$1 " + ide_version_minor + "\n")
content = content.replace(/(\n#define IDE_VERSION_RELEASE) .+\n/, "$1 " + ide_version_release + "\n")
file = new TextFile(output.fileName, TextFile.WriteOnly);
file.truncate();
file.write(content);
file.close();
}
return cmd;
}
}
Export {
Depends { name: "cpp" }
cpp.includePaths: product.buildDirectory
}
}

View File

@@ -14,7 +14,7 @@ DynamicLibrary {
return ["-Wl,-s"] return ["-Wl,-s"]
} }
cpp.installNamePrefix: "@rpath/PlugIns/" cpp.installNamePrefix: "@rpath/PlugIns/"
cpp.rpaths: qbs.targetOS.contains("mac") cpp.rpaths: qbs.targetOS.contains("osx")
? ["@loader_path/..", "@executable_path/.."] ? ["@loader_path/..", "@executable_path/.."]
: ["$ORIGIN", "$ORIGIN/.."] : ["$ORIGIN", "$ORIGIN/.."]
cpp.includePaths: [ ".", ".." ] cpp.includePaths: [ ".", ".." ]

View File

@@ -344,7 +344,6 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
} }
} }
} }
} }
} }
} }

View File

@@ -105,7 +105,9 @@ void NamePrettyPrinter::visit(const DestructorNameId *name)
void NamePrettyPrinter::visit(const OperatorNameId *name) void NamePrettyPrinter::visit(const OperatorNameId *name)
{ {
_name += QLatin1String("operator "); _name += QLatin1String("operator");
if (_overview->includeWhiteSpaceInOperatorName)
_name += QLatin1Char(' ');
switch (name->kind()) { // ### i should probably do this in OperatorNameId switch (name->kind()) { // ### i should probably do this in OperatorNameId
case OperatorNameId::InvalidOp: case OperatorNameId::InvalidOp:
_name += QLatin1String("<invalid>"); _name += QLatin1String("<invalid>");

View File

@@ -45,6 +45,7 @@ Overview::Overview()
showFunctionSignatures(true), showFunctionSignatures(true),
showDefaultArguments(true), showDefaultArguments(true),
showTemplateParameters(false), showTemplateParameters(false),
includeWhiteSpaceInOperatorName(true),
markedArgument(0), markedArgument(0),
markedArgumentBegin(0), markedArgumentBegin(0),
markedArgumentEnd(0) markedArgumentEnd(0)

View File

@@ -108,6 +108,7 @@ public:
bool showFunctionSignatures: 1; bool showFunctionSignatures: 1;
bool showDefaultArguments: 1; bool showDefaultArguments: 1;
bool showTemplateParameters: 1; bool showTemplateParameters: 1;
bool includeWhiteSpaceInOperatorName: 1; /// "operator =()" vs "operator=()"
/*! /*!
You can get the start and end position of a function argument You can get the start and end position of a function argument

21
src/libs/libs.qbs Normal file
View File

@@ -0,0 +1,21 @@
import qbs
Project {
name: "Libs"
references: [
"aggregation/aggregation.qbs",
"cplusplus/cplusplus.qbs",
"extensionsystem/extensionsystem.qbs",
"glsl/glsl.qbs",
"languageutils/languageutils.qbs",
"qmleditorwidgets/qmleditorwidgets.qbs",
"qmljs/qmljs.qbs",
"qmldebug/qmldebug.qbs",
"qtcomponents/styleitem/styleitem.qbs",
"ssh/ssh.qbs",
"utils/process_stub.qbs",
"utils/process_ctrlc_stub.qbs",
"utils/utils.qbs",
"zeroconf/zeroconf.qbs",
]
}

View File

@@ -277,7 +277,7 @@ extern "C" HRESULT CALLBACK pid(CIDebugClient *client, PCSTR args)
int token; int token;
commandTokens<StringList>(args, &token); commandTokens<StringList>(args, &token);
dprintf("Qt Creator CDB extension version 2.7 (Qt 5 support) %d bit built %s.\n", dprintf("Qt Creator CDB extension version 2.8 %d bit built %s.\n",
sizeof(void *) * 8, __DATE__); sizeof(void *) * 8, __DATE__);
if (const ULONG pid = currentProcessId(client)) if (const ULONG pid = currentProcessId(client))
ExtensionContext::instance().report('R', token, 0, "pid", "%u", pid); ExtensionContext::instance().report('R', token, 0, "pid", "%u", pid);

View File

@@ -58,7 +58,7 @@ QtcLibrary {
result.push("advapi32", "user32") result.push("advapi32", "user32")
else if (qbs.targetOS.contains("linux")) else if (qbs.targetOS.contains("linux"))
result.push("rt", "dl"); result.push("rt", "dl");
else if (qbs.targetOS.contains("mac")) else if (qbs.targetOS.contains("osx"))
result.push("dl"); result.push("dl");
else if (qbs.targetOS.contains("unix")) else if (qbs.targetOS.contains("unix"))
result.push("rt"); result.push("rt");
@@ -82,7 +82,7 @@ QtcLibrary {
"BOTAN_HAS_ALLOC_MMAP", "BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM", "BOTAN_HAS_ALLOC_MMAP", "BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM",
"BOTAN_HAS_ENTROPY_SRC_EGD", "BOTAN_HAS_ENTROPY_SRC_FTW", "BOTAN_HAS_ENTROPY_SRC_EGD", "BOTAN_HAS_ENTROPY_SRC_FTW",
"BOTAN_HAS_ENTROPY_SRC_UNIX", "BOTAN_HAS_MUTEX_PTHREAD", "BOTAN_HAS_PIPE_UNIXFD_IO") "BOTAN_HAS_ENTROPY_SRC_UNIX", "BOTAN_HAS_MUTEX_PTHREAD", "BOTAN_HAS_PIPE_UNIXFD_IO")
if (qbs.targetOS.contains("mac")) if (qbs.targetOS.contains("osx"))
result.push("BOTAN_TARGET_OS_IS_DARWIN", "BOTAN_TARGET_OS_HAS_GETTIMEOFDAY", result.push("BOTAN_TARGET_OS_IS_DARWIN", "BOTAN_TARGET_OS_HAS_GETTIMEOFDAY",
"BOTAN_HAS_ALLOC_MMAP", "BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM", "BOTAN_HAS_ALLOC_MMAP", "BOTAN_HAS_ENTROPY_SRC_DEV_RANDOM",
"BOTAN_HAS_ENTROPY_SRC_EGD", "BOTAN_HAS_ENTROPY_SRC_FTW", "BOTAN_HAS_ENTROPY_SRC_EGD", "BOTAN_HAS_ENTROPY_SRC_FTW",

View File

@@ -190,6 +190,20 @@ void CompletingTextEdit::focusInEvent(QFocusEvent *e)
QTextEdit::focusInEvent(e); QTextEdit::focusInEvent(e);
} }
bool CompletingTextEdit::event(QEvent *e)
{
// workaround for QTCREATORBUG-9453
if (e->type() == QEvent::ShortcutOverride && completer()
&& completer()->popup() && completer()->popup()->isVisible()) {
QKeyEvent *ke = static_cast<QKeyEvent *>(e);
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept();
return true;
}
}
return QTextEdit::event(e);
}
} // namespace Utils } // namespace Utils
#include "moc_completingtextedit.cpp" #include "moc_completingtextedit.cpp"

View File

@@ -36,6 +36,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QCompleter; class QCompleter;
class QEvent;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Utils { namespace Utils {
@@ -59,6 +60,7 @@ public:
protected: protected:
void keyPressEvent(QKeyEvent *e); void keyPressEvent(QKeyEvent *e);
void focusInEvent(QFocusEvent *e); void focusInEvent(QFocusEvent *e);
bool event(QEvent *e);
private: private:
class CompletingTextEditPrivate *d; class CompletingTextEditPrivate *d;

View File

@@ -31,13 +31,15 @@
#include "historycompleter.h" #include "historycompleter.h"
#include "qtcassert.h" #include "qtcassert.h"
#include <QDebug> #include <QAbstractItemView>
#include <QPropertyAnimation>
#include <QApplication> #include <QApplication>
#include <QDebug>
#include <QDesktopWidget>
#include <QKeyEvent>
#include <QMenu> #include <QMenu>
#include <QPainter> #include <QPainter>
#include <QPropertyAnimation>
#include <QStyle> #include <QStyle>
#include <QDesktopWidget>
/*! Opens a menu at the specified widget position. /*! Opens a menu at the specified widget position.
* This functions computes the position where to show the menu, and opens it with * This functions computes the position where to show the menu, and opens it with
@@ -251,6 +253,20 @@ void FancyLineEdit::resizeEvent(QResizeEvent *)
updateButtonPositions(); updateButtonPositions();
} }
bool FancyLineEdit::event(QEvent *e)
{
// workaround for QTCREATORBUG-9453
if (e->type() == QEvent::ShortcutOverride && completer()
&& completer()->popup() && completer()->popup()->isVisible()) {
QKeyEvent *ke = static_cast<QKeyEvent *>(e);
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept();
return true;
}
}
return QLineEdit::event(e);
}
void FancyLineEdit::setButtonPixmap(Side side, const QPixmap &buttonPixmap) void FancyLineEdit::setButtonPixmap(Side side, const QPixmap &buttonPixmap)
{ {
d->m_iconbutton[side]->setPixmap(buttonPixmap); d->m_iconbutton[side]->setPixmap(buttonPixmap);

View File

@@ -35,6 +35,10 @@
#include <QLineEdit> #include <QLineEdit>
#include <QAbstractButton> #include <QAbstractButton>
QT_BEGIN_NAMESPACE
class QEvent;
QT_END_NAMESPACE
namespace Utils { namespace Utils {
class FancyLineEditPrivate; class FancyLineEditPrivate;
@@ -109,7 +113,8 @@ private slots:
void iconClicked(); void iconClicked();
protected: protected:
virtual void resizeEvent(QResizeEvent *e); void resizeEvent(QResizeEvent *e);
bool event(QEvent *e);
private: private:
// Unimplemented, to force the user to make a decision on // Unimplemented, to force the user to make a decision on

View File

@@ -173,6 +173,7 @@ void runFileSearch(QFutureInterface<FileSearchResultList> &future,
results << FileSearchResult(s, lineNr, resultItemText, results << FileSearchResult(s, lineNr, resultItemText,
regionPtr - chunkPtr, termLength, regionPtr - chunkPtr, termLength,
QStringList()); QStringList());
regionPtr += termLength - 1; // another +1 done by for-loop
++numMatches; ++numMatches;
} }
} }

View File

@@ -480,7 +480,10 @@ FileName FileName::fromString(const QString &filename)
/// \a fileName is only passed through QDir::cleanPath /// \a fileName is only passed through QDir::cleanPath
FileName FileName::fromUserInput(const QString &filename) FileName FileName::fromUserInput(const QString &filename)
{ {
return FileName(QDir::cleanPath(filename)); QString clean = QDir::cleanPath(filename);
if (clean.startsWith(QLatin1String("~/")))
clean = QDir::homePath() + clean.mid(1);
return FileName(clean);
} }
FileName::FileName(const QString &string) FileName::FileName(const QString &string)

View File

@@ -198,8 +198,6 @@ int main(int argc, char *argv[])
isDebug = !strcmp(argv[ArgAction], "debug"); isDebug = !strcmp(argv[ArgAction], "debug");
isDetached = 0; isDetached = 0;
sendMsg("spid %ld\n", (long)getpid());
if (*argv[ArgDir] && chdir(argv[ArgDir])) { if (*argv[ArgDir] && chdir(argv[ArgDir])) {
/* Only expected error: no such file or direcotry */ /* Only expected error: no such file or direcotry */
sendMsg("err:chdir %d\n", errno); sendMsg("err:chdir %d\n", errno);
@@ -235,6 +233,8 @@ int main(int argc, char *argv[])
env[count] = 0; env[count] = 0;
} }
/* send our pid after we read the environment file (creator will get rid of it) */
sendMsg("spid %ld\n", (long)getpid());
/* /*
* set up the signal handlers * set up the signal handlers

View File

@@ -15,7 +15,7 @@ QtcLibrary {
] ]
} }
Properties { Properties {
condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("mac") condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("osx")
cpp.dynamicLibraries: ["X11"] cpp.dynamicLibraries: ["X11"]
} }

View File

@@ -19,6 +19,7 @@ Product {
} }
return name; return name;
} }
moduleSearchPaths: "../../../qbs" // TODO: Should get inherited from project, but doesn't.
Depends { name: "ExtensionSystem" } Depends { name: "ExtensionSystem" }
Depends { name: "pluginspec" } Depends { name: "pluginspec" }
@@ -30,7 +31,7 @@ Product {
cpp.defines: Defaults.defines(qbs).concat([name.toUpperCase() + "_LIBRARY"]) cpp.defines: Defaults.defines(qbs).concat([name.toUpperCase() + "_LIBRARY"])
cpp.installNamePrefix: "@rpath/PlugIns/" + provider + "/" cpp.installNamePrefix: "@rpath/PlugIns/" + provider + "/"
cpp.rpaths: qbs.targetOS.contains("mac") ? ["@loader_path/../..", "@executable_path/.."] cpp.rpaths: qbs.targetOS.contains("osx") ? ["@loader_path/../..", "@executable_path/.."]
: ["$ORIGIN", "$ORIGIN/..", "$ORIGIN/../.."] : ["$ORIGIN", "$ORIGIN/..", "$ORIGIN/../.."]
cpp.linkerFlags: { cpp.linkerFlags: {
if (qbs.buildVariant == "release" && (qbs.toolchain == "gcc" || qbs.toolchain == "mingw")) if (qbs.buildVariant == "release" && (qbs.toolchain == "gcc" || qbs.toolchain == "mingw"))

View File

@@ -116,6 +116,7 @@ void AndroidToolChain::addToEnvironment(Environment &env) const
QString javaHome = AndroidConfigurations::instance().openJDKPath().toString(); QString javaHome = AndroidConfigurations::instance().openJDKPath().toString();
if (!javaHome.isEmpty() && QFileInfo(javaHome).exists()) if (!javaHome.isEmpty() && QFileInfo(javaHome).exists())
env.set(QLatin1String("JAVA_HOME"), javaHome); env.set(QLatin1String("JAVA_HOME"), javaHome);
env.set(QLatin1String("ANDROID_HOME"), AndroidConfigurations::instance().config().sdkLocation.toString());
} }
bool AndroidToolChain::operator ==(const ToolChain &tc) const bool AndroidToolChain::operator ==(const ToolChain &tc) const

View File

@@ -6,7 +6,7 @@ QtcPlugin {
name: "ClearCase" name: "ClearCase"
// provider: "AudioCodes" // provider: "AudioCodes"
condition: !qbs.targetOS.contains("mac") condition: !qbs.targetOS.contains("osx")
Depends { name: "Qt.widgets" } Depends { name: "Qt.widgets" }
Depends { name: "Core" } Depends { name: "Core" }

View File

@@ -31,7 +31,7 @@ QtcPlugin {
] ]
} }
cpp.frameworks: qbs.targetOS.contains("mac") ? ["AppKit"] : undefined cpp.frameworks: qbs.targetOS.contains("osx") ? ["AppKit"] : undefined
files: [ files: [
"basefilewizard.cpp", "basefilewizard.cpp",
@@ -241,7 +241,7 @@ QtcPlugin {
Group { Group {
name: "ProgressManager_mac" name: "ProgressManager_mac"
condition: qbs.targetOS.contains("mac") condition: qbs.targetOS.contains("osx")
files: [ files: [
"macfullscreen.h", "macfullscreen.h",
"macfullscreen.mm", "macfullscreen.mm",
@@ -251,7 +251,7 @@ QtcPlugin {
Group { Group {
name: "ProgressManager_x11" name: "ProgressManager_x11"
condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("mac") condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("osx")
files: [ files: [
"progressmanager/progressmanager_x11.cpp", "progressmanager/progressmanager_x11.cpp",
] ]

View File

@@ -29,10 +29,14 @@
#include "editormanager.h" #include "editormanager.h"
#include "editorview.h" #include "editorview.h"
#include "findplaceholder.h"
#include "openeditorswindow.h" #include "openeditorswindow.h"
#include "openeditorsview.h" #include "openeditorsview.h"
#include "openeditorsmodel.h" #include "openeditorsmodel.h"
#include "openwithdialog.h" #include "openwithdialog.h"
#include "outputpane.h"
#include "outputpanemanager.h"
#include "rightpane.h"
#include "documentmanager.h" #include "documentmanager.h"
#include "icore.h" #include "icore.h"
#include "ieditor.h" #include "ieditor.h"
@@ -852,6 +856,99 @@ void EditorManager::addNativeDirActions(QMenu *contextMenu, const QModelIndex &e
contextMenu->addAction(d->m_openTerminalAction); contextMenu->addAction(d->m_openTerminalAction);
} }
static void setFocusToEditorViewAndUnmaximizePanes(EditorView *view)
{
QWidget *w = 0;
if (view->currentEditor()) {
w = view->currentEditor()->widget()->focusWidget();
if (!w)
w = view->currentEditor()->widget();
} else {
w = view->focusWidget();
if (!w)
w = view;
}
w->setFocus();
ICore::raiseWindow(w);
if (OutputPanePlaceHolder::getCurrent()
&& OutputPanePlaceHolder::getCurrent()->window() == view->window()) {
// unmaximize output pane if necessary
if (OutputPanePlaceHolder::getCurrent()
&& OutputPanePlaceHolder::getCurrent()->isVisible()
&& OutputPanePlaceHolder::getCurrent()->isMaximized())
OutputPanePlaceHolder::getCurrent()->unmaximize();
}
}
/*!
Implements the logic of the escape key shortcut (ReturnToEditor).
Should only be called by the shortcut handler.
\internal
*/
void EditorManager::doEscapeKeyFocusMoveMagic()
{
// use cases to cover:
// 1. if app focus is in mode or external window without editor view (e.g. Projects, ext. Help)
// activate & raise the current editor view (can be external)
// if that is in edit mode
// activate edit mode and unmaximize output pane
// 2. if app focus is in external window with editor view
// hide find if necessary
// 2. if app focus is in mode with editor view
// if current editor view is in external window
// raise and activate current editor view
// otherwise if the current editor view is not app focus
// move focus to editor view in mode and unmaximize output pane
// otherwise if the current view is app focus
// if mode is not edit mode
// if there are extra views (find, help, output)
// hide them
// otherwise
// activate edit mode and unmaximize output pane
// otherwise (i.e. mode is edit mode)
// hide extra views (find, help, output)
EditorView *editorView = currentEditorView();
bool editorViewActive = (qApp->focusWidget() == editorView->focusWidget());
bool editorViewVisible = editorView->isVisible();
if (!editorViewActive && editorViewVisible) {
setFocusToEditorViewAndUnmaximizePanes(editorView);
return;
}
if (!editorViewActive && !editorViewVisible) {
// assumption is that editorView is in main window then
ModeManager::activateMode(Id(Constants::MODE_EDIT));
QTC_CHECK(editorView->isVisible());
setFocusToEditorViewAndUnmaximizePanes(editorView);
return;
}
if (editorViewActive) {
QTC_CHECK(editorViewVisible);
bool stuffHidden = false;
QWidget *findPane = FindToolBarPlaceHolder::getCurrent();
if (findPane && findPane->isVisibleTo(editorView)) {
findPane->hide();
stuffHidden = true;
}
QWidget *outputPane = OutputPanePlaceHolder::getCurrent();
if (outputPane && outputPane->isVisibleTo(editorView)) {
OutputPaneManager::instance()->slotHide();
stuffHidden = true;
}
QWidget *rightPane = RightPanePlaceHolder::current();
if (rightPane && rightPane->isVisibleTo(editorView)) {
RightPaneWidget::instance()->setShown(false);
stuffHidden = true;
}
if (!stuffHidden && editorView->window() == ICore::mainWindow()) {
// we are in a editor view and there's nothing to hide, switch to edit
ModeManager::activateMode(Id(Constants::MODE_EDIT));
// next call works only because editor views in main window are shared between modes
setFocusToEditorViewAndUnmaximizePanes(editorView);
}
}
}
void EditorManager::saveDocumentFromContextMenu() void EditorManager::saveDocumentFromContextMenu()
{ {
IEditor *editor = d->m_contextMenuEditorIndex.data(Qt::UserRole).value<Core::IEditor*>(); IEditor *editor = d->m_contextMenuEditorIndex.data(Qt::UserRole).value<Core::IEditor*>();

View File

@@ -210,6 +210,7 @@ public slots:
void revertToSaved(Core::IEditor *editor); void revertToSaved(Core::IEditor *editor);
void closeEditor(); void closeEditor();
void closeOtherEditors(); void closeOtherEditors();
void doEscapeKeyFocusMoveMagic();
private slots: private slots:
void gotoNextDocHistory(); void gotoNextDocHistory();

View File

@@ -48,7 +48,6 @@
#include "mimedatabase.h" #include "mimedatabase.h"
#include "newdialog.h" #include "newdialog.h"
#include "outputpanemanager.h" #include "outputpanemanager.h"
#include "outputpane.h"
#include "plugindialog.h" #include "plugindialog.h"
#include "progressmanager_p.h" #include "progressmanager_p.h"
#include "progressview.h" #include "progressview.h"
@@ -73,7 +72,6 @@
#endif #endif
#include <app/app_version.h> #include <app/app_version.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/icorelistener.h> #include <coreplugin/icorelistener.h>
#include <coreplugin/inavigationwidgetfactory.h> #include <coreplugin/inavigationwidgetfactory.h>
#include <coreplugin/settingsdatabase.h> #include <coreplugin/settingsdatabase.h>
@@ -877,48 +875,7 @@ IDocument *MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesF
void MainWindow::setFocusToEditor() void MainWindow::setFocusToEditor()
{ {
bool focusWasMovedToEditor = false; m_editorManager->doEscapeKeyFocusMoveMagic();
// give focus to the editor if we have one
if (IEditor *editor = EditorManager::currentEditor()) {
if (qApp->focusWidget() != editor->widget()->focusWidget()) {
QWidget *w = editor->widget()->focusWidget();
if (!w)
w = editor->widget();
w->setFocus();
focusWasMovedToEditor = w->hasFocus();
}
}
// check for some maximized pane which we want to unmaximize
if (OutputPanePlaceHolder::getCurrent()
&& OutputPanePlaceHolder::getCurrent()->isVisible()
&& OutputPanePlaceHolder::getCurrent()->isMaximized()) {
OutputPanePlaceHolder::getCurrent()->unmaximize();
return;
}
if (focusWasMovedToEditor)
return;
// check for some visible bar which we want to hide
bool stuffVisible =
(FindToolBarPlaceHolder::getCurrent() &&
FindToolBarPlaceHolder::getCurrent()->isVisible())
|| (OutputPanePlaceHolder::getCurrent() &&
OutputPanePlaceHolder::getCurrent()->isVisible())
|| (RightPanePlaceHolder::current() &&
RightPanePlaceHolder::current()->isVisible());
if (stuffVisible) {
if (FindToolBarPlaceHolder::getCurrent())
FindToolBarPlaceHolder::getCurrent()->hide();
OutputPaneManager::instance()->slotHide();
RightPaneWidget::instance()->setShown(false);
return;
}
// switch to edit mode if necessary
ModeManager::activateMode(Id(Constants::MODE_EDIT));
} }
void MainWindow::showNewItemDialog(const QString &title, void MainWindow::showNewItemDialog(const QString &title,

View File

@@ -287,8 +287,8 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
} }
return versionControl; return versionControl;
} else { } else {
InfoBar *infoBar = curDocument->infoBar(); InfoBar *infoBar = curDocument ? curDocument->infoBar() : 0;
if (infoBar->canInfoBeAdded(vcsWarning)) { if (infoBar && infoBar->canInfoBeAdded(vcsWarning)) {
InfoBarEntry info(vcsWarning, InfoBarEntry info(vcsWarning,
tr("%1 repository was detected but %1 is not configured.") tr("%1 repository was detected but %1 is not configured.")
.arg(versionControl->displayName()), .arg(versionControl->displayName()),

View File

@@ -36,6 +36,7 @@
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QGridLayout> #include <QGridLayout>
#include <QKeyEvent>
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
@@ -97,3 +98,15 @@ VersionDialog::VersionDialog(QWidget *parent)
layout->addWidget(copyRightLabel, 0, 1, 4, 4); layout->addWidget(copyRightLabel, 0, 1, 4, 4);
layout->addWidget(buttonBox, 4, 0, 1, 5); layout->addWidget(buttonBox, 4, 0, 1, 5);
} }
bool VersionDialog::event(QEvent *event)
{
if (event->type() == QEvent::ShortcutOverride) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept();
return true;
}
}
return QDialog::event(event);
}

View File

@@ -32,6 +32,10 @@
#include <QDialog> #include <QDialog>
QT_BEGIN_NAMESPACE
class QEvent;
QT_END_NAMESPACE
namespace Core { namespace Core {
namespace Internal { namespace Internal {
@@ -40,6 +44,9 @@ class VersionDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit VersionDialog(QWidget *parent); explicit VersionDialog(QWidget *parent);
bool event(QEvent *event);
}; };
} // namespace Internal } // namespace Internal

View File

@@ -641,9 +641,9 @@ void CPPEditorWidget::createToolBar(CPPEditor *editor)
connect(m_outlineCombo, SIGNAL(activated(int)), this, SLOT(jumpToOutlineElement(int))); connect(m_outlineCombo, SIGNAL(activated(int)), this, SLOT(jumpToOutlineElement(int)));
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateOutlineIndex())); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateOutlineIndex()));
connect(m_outlineCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateOutlineToolTip())); connect(m_outlineCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateOutlineToolTip()));
connect(document(), SIGNAL(contentsChange(int,int,int)),
this, SLOT(onContentsChanged(int,int,int)));
// set up slots to document changes
updateContentsChangedSignal();
connect(editorDocument(), SIGNAL(changed()), this, SLOT(updateFileName())); connect(editorDocument(), SIGNAL(changed()), this, SLOT(updateFileName()));
// set up function declaration - definition link // set up function declaration - definition link
@@ -1870,6 +1870,8 @@ Core::IEditor *CPPEditor::duplicate(QWidget *parent)
{ {
CPPEditorWidget *newEditor = new CPPEditorWidget(parent); CPPEditorWidget *newEditor = new CPPEditorWidget(parent);
newEditor->duplicateFrom(editorWidget()); newEditor->duplicateFrom(editorWidget());
// A new QTextDocument was set, so update our signal/slot connection to the new document
newEditor->updateContentsChangedSignal();
CppEditorPlugin::instance()->initializeEditor(newEditor); CppEditorPlugin::instance()->initializeEditor(newEditor);
return newEditor->editor(); return newEditor->editor();
} }
@@ -2218,6 +2220,12 @@ void CPPEditorWidget::applyDeclDefLinkChanges(bool jumpToMatch)
updateFunctionDeclDefLink(); updateFunctionDeclDefLink();
} }
void CPPEditorWidget::updateContentsChangedSignal()
{
connect(document(), SIGNAL(contentsChange(int,int,int)),
this, SLOT(onContentsChanged(int,int,int)));
}
void CPPEditorWidget::abortDeclDefLink() void CPPEditorWidget::abortDeclDefLink()
{ {
if (!m_declDefLink) if (!m_declDefLink)

View File

@@ -128,6 +128,8 @@ public:
QSharedPointer<FunctionDeclDefLink> declDefLink() const; QSharedPointer<FunctionDeclDefLink> declDefLink() const;
void applyDeclDefLinkChanges(bool jumpToMatch); void applyDeclDefLinkChanges(bool jumpToMatch);
void updateContentsChangedSignal();
Q_SIGNALS: Q_SIGNALS:
void outlineModelIndexChanged(const QModelIndex &index); void outlineModelIndexChanged(const QModelIndex &index);

View File

@@ -163,6 +163,8 @@ private slots:
void test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitionExists(); void test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitionExists();
void test_quickfix_InsertDefFromDecl_notTriggeringStatement(); void test_quickfix_InsertDefFromDecl_notTriggeringStatement();
void test_quickfix_InsertDefFromDecl_findRightImplementationFile(); void test_quickfix_InsertDefFromDecl_findRightImplementationFile();
void test_quickfix_InsertDefFromDecl_respectWsInOperatorNames1();
void test_quickfix_InsertDefFromDecl_respectWsInOperatorNames2();
void test_quickfix_InsertDeclFromDef(); void test_quickfix_InsertDeclFromDef();
@@ -202,6 +204,8 @@ private slots:
void test_quickfix_MoveFuncDefOutside_CtorWithInitialization1(); void test_quickfix_MoveFuncDefOutside_CtorWithInitialization1();
void test_quickfix_MoveFuncDefOutside_CtorWithInitialization2(); void test_quickfix_MoveFuncDefOutside_CtorWithInitialization2();
void test_quickfix_MoveFuncDefOutside_afterClass(); void test_quickfix_MoveFuncDefOutside_afterClass();
void test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames1();
void test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames2();
void test_quickfix_MoveFuncDefToDecl_MemberFunc(); void test_quickfix_MoveFuncDefToDecl_MemberFunc();
void test_quickfix_MoveFuncDefToDecl_MemberFuncOutside(); void test_quickfix_MoveFuncDefToDecl_MemberFuncOutside();

View File

@@ -1178,6 +1178,58 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findRightImplementationFil
data.run(&factory); data.run(&factory);
} }
/// Check if whitespace is respected for operator functions
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames1()
{
QByteArray original =
"class Foo\n"
"{\n"
" Foo &opera@tor =();\n"
"};\n";
QByteArray expected =
"class Foo\n"
"{\n"
" Foo &operator =();\n"
"};\n"
"\n"
"\n"
"Foo &Foo::operator =()\n"
"{\n"
"\n"
"}\n"
"\n";
InsertDefFromDecl factory;
TestCase data(original, expected);
data.run(&factory);
}
/// Check if whitespace is respected for operator functions
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames2()
{
QByteArray original =
"class Foo\n"
"{\n"
" Foo &opera@tor=();\n"
"};\n";
QByteArray expected =
"class Foo\n"
"{\n"
" Foo &operator=();\n"
"};\n"
"\n"
"\n"
"Foo &Foo::operator=()\n"
"{\n"
"\n"
"}\n"
"\n";
InsertDefFromDecl factory;
TestCase data(original, expected);
data.run(&factory);
}
// Function for one of InsertDeclDef section cases // Function for one of InsertDeclDef section cases
void insertToSectionDeclFromDef(const QByteArray &section, int sectionIndex) void insertToSectionDeclFromDef(const QByteArray &section, int sectionIndex)
{ {
@@ -2458,6 +2510,52 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_afterClass()
data.run(&factory, 1); data.run(&factory, 1);
} }
/// Check if whitespace is respected for operator functions
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames1()
{
QByteArray original =
"class Foo\n"
"{\n"
" Foo &opera@tor =() {}\n"
"};\n";
QByteArray expected =
"class Foo\n"
"{\n"
" Foo &operator =();\n"
"};\n"
"\n"
"\n"
"Foo &Foo::operator =() {}\n"
"\n";
MoveFuncDefOutside factory;
TestCase data(original, expected);
data.run(&factory);
}
/// Check if whitespace is respected for operator functions
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames2()
{
QByteArray original =
"class Foo\n"
"{\n"
" Foo &opera@tor=() {}\n"
"};\n";
QByteArray expected =
"class Foo\n"
"{\n"
" Foo &operator=();\n"
"};\n"
"\n"
"\n"
"Foo &Foo::operator=() {}\n"
"\n";
MoveFuncDefOutside factory;
TestCase data(original, expected);
data.run(&factory);
}
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCpp() /// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFunc() void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFunc()
{ {

View File

@@ -258,6 +258,12 @@ void insertNewIncludeDirective(const QString &include, CppRefactoringFilePtr fil
file->apply(); file->apply();
} }
bool nameIncludesOperatorName(const Name *name)
{
return name->isOperatorNameId()
|| (name->isQualifiedNameId() && name->asQualifiedNameId()->name()->isOperatorNameId());
}
} // anonymous namespace } // anonymous namespace
namespace { namespace {
@@ -2482,10 +2488,12 @@ class InsertDefOperation: public CppQuickFixOperation
public: public:
// Make sure that either loc is valid or targetFileName is not empty. // Make sure that either loc is valid or targetFileName is not empty.
InsertDefOperation(const QSharedPointer<const CppQuickFixAssistInterface> &interface, InsertDefOperation(const QSharedPointer<const CppQuickFixAssistInterface> &interface,
Declaration *decl, const InsertionLocation &loc, const DefPos defpos, Declaration *decl, DeclaratorAST *declAST, const InsertionLocation &loc,
const QString &targetFileName = QString(), bool freeFunction = false) const DefPos defpos, const QString &targetFileName = QString(),
bool freeFunction = false)
: CppQuickFixOperation(interface, 0) : CppQuickFixOperation(interface, 0)
, m_decl(decl) , m_decl(decl)
, m_declAST(declAST)
, m_loc(loc) , m_loc(loc)
, m_defpos(defpos) , m_defpos(defpos)
, m_targetFileName(targetFileName) , m_targetFileName(targetFileName)
@@ -2558,6 +2566,11 @@ public:
const FullySpecifiedType tn = rewriteType(m_decl->type(), &env, control); const FullySpecifiedType tn = rewriteType(m_decl->type(), &env, control);
// rewrite the function name // rewrite the function name
if (nameIncludesOperatorName(m_decl->name())) {
CppRefactoringFilePtr file = refactoring.file(fileName());
const QString operatorNameText = file->textOf(m_declAST->core_declarator);
oo.includeWhiteSpaceInOperatorName = operatorNameText.contains(QLatin1Char(' '));
}
const QString name = oo.prettyName(LookupContext::minimalName(m_decl, targetCoN, const QString name = oo.prettyName(LookupContext::minimalName(m_decl, targetCoN,
control)); control));
@@ -2590,6 +2603,7 @@ public:
private: private:
Declaration *m_decl; Declaration *m_decl;
DeclaratorAST *m_declAST;
InsertionLocation m_loc; InsertionLocation m_loc;
const DefPos m_defpos; const DefPos m_defpos;
const QString m_targetFileName; const QString m_targetFileName;
@@ -2622,6 +2636,7 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
} }
// Insert Position: Implementation File // Insert Position: Implementation File
DeclaratorAST *declAST = simpleDecl->declarator_list->value;
InsertDefOperation *op = 0; InsertDefOperation *op = 0;
ProjectFile::Kind kind = ProjectFile::classify(interface->fileName()); ProjectFile::Kind kind = ProjectFile::classify(interface->fileName());
const bool isHeaderFile = ProjectFile::isHeader(kind); const bool isHeaderFile = ProjectFile::isHeader(kind);
@@ -2634,7 +2649,7 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
foreach (const InsertionLocation &location, foreach (const InsertionLocation &location,
locator.methodDefinition(decl, false, QString())) { locator.methodDefinition(decl, false, QString())) {
if (location.isValid()) { if (location.isValid()) {
op = new InsertDefOperation(interface, decl, op = new InsertDefOperation(interface, decl, declAST,
InsertionLocation(), InsertionLocation(),
DefPosImplementationFile, DefPosImplementationFile,
location.fileName()); location.fileName());
@@ -2649,8 +2664,8 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
// Insert Position: Outside Class // Insert Position: Outside Class
if (!isFreeFunction) { if (!isFreeFunction) {
op = new InsertDefOperation(interface, decl, InsertionLocation(), op = new InsertDefOperation(interface, decl, declAST,
DefPosOutsideClass, InsertionLocation(), DefPosOutsideClass,
interface->fileName()); interface->fileName());
result.append(CppQuickFixOperation::Ptr(op)); result.append(CppQuickFixOperation::Ptr(op));
} }
@@ -2663,8 +2678,9 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
const InsertionLocation loc const InsertionLocation loc
= InsertionLocation(interface->fileName(), QString(), QString(), = InsertionLocation(interface->fileName(), QString(), QString(),
line, column); line, column);
op = new InsertDefOperation(interface, decl, loc, DefPosInsideClass, op = new InsertDefOperation(interface, decl, declAST, loc,
QString() , isFreeFunction); DefPosInsideClass, QString(),
isFreeFunction);
result.append(CppQuickFixOperation::Ptr(op)); result.append(CppQuickFixOperation::Ptr(op));
return; return;
@@ -3719,14 +3735,19 @@ void ApplyDeclDefLinkChanges::match(const CppQuickFixInterface &interface,
namespace { namespace {
QString getDefinitionSignature(const CppQuickFixAssistInterface *assist, Function *func, QString definitionSignature(const CppQuickFixAssistInterface *assist,
CppRefactoringFilePtr &file, Scope *scope) FunctionDefinitionAST *functionDefinitionAST,
CppRefactoringFilePtr &baseFile,
CppRefactoringFilePtr &targetFile,
Scope *scope)
{ {
QTC_ASSERT(assist, return QString()); QTC_ASSERT(assist, return QString());
QTC_ASSERT(func, return QString()); QTC_ASSERT(functionDefinitionAST, return QString());
QTC_ASSERT(scope, return QString()); QTC_ASSERT(scope, return QString());
Function *func = functionDefinitionAST->symbol;
QTC_ASSERT(func, return QString());
LookupContext cppContext(file->cppDocument(), assist->snapshot()); LookupContext cppContext(targetFile->cppDocument(), assist->snapshot());
ClassOrNamespace *cppCoN = cppContext.lookupType(scope); ClassOrNamespace *cppCoN = cppContext.lookupType(scope);
if (!cppCoN) if (!cppCoN)
cppCoN = cppContext.globalNamespace(); cppCoN = cppContext.globalNamespace();
@@ -3740,10 +3761,16 @@ QString getDefinitionSignature(const CppQuickFixAssistInterface *assist, Functio
oo.showFunctionSignatures = true; oo.showFunctionSignatures = true;
oo.showReturnTypes = true; oo.showReturnTypes = true;
oo.showArgumentNames = true; oo.showArgumentNames = true;
const Name *name = func->name();
if (nameIncludesOperatorName(name)) {
CoreDeclaratorAST *coreDeclarator = functionDefinitionAST->declarator->core_declarator;
const QString operatorNameText = baseFile->textOf(coreDeclarator);
oo.includeWhiteSpaceInOperatorName = operatorNameText.contains(QLatin1Char(' '));
}
const QString nameText = oo.prettyName(LookupContext::minimalName(func, cppCoN, control));
const FullySpecifiedType tn = rewriteType(func->type(), &env, control); const FullySpecifiedType tn = rewriteType(func->type(), &env, control);
const QString name = oo.prettyName(LookupContext::minimalName(func, cppCoN, control));
return oo.prettyType(tn, name); return oo.prettyType(tn, nameText);
} }
class MoveFuncDefOutsideOp : public CppQuickFixOperation class MoveFuncDefOutsideOp : public CppQuickFixOperation
@@ -3791,8 +3818,9 @@ public:
Scope *scopeAtInsertPos = toFile->cppDocument()->scopeAt(l.line(), l.column()); Scope *scopeAtInsertPos = toFile->cppDocument()->scopeAt(l.line(), l.column());
// construct definition // construct definition
const QString funcDec = getDefinitionSignature(assistInterface(), m_func, toFile, const QString funcDec = definitionSignature(assistInterface(), m_funcDef,
scopeAtInsertPos); fromFile, toFile,
scopeAtInsertPos);
QString funcDef = prefix + funcDec; QString funcDef = prefix + funcDec;
const int startPosition = fromFile->endOf(m_funcDef->declarator); const int startPosition = fromFile->endOf(m_funcDef->declarator);
const int endPosition = fromFile->endOf(m_funcDef->function_body); const int endPosition = fromFile->endOf(m_funcDef->function_body);

View File

@@ -115,7 +115,7 @@ static unsigned firstTypeSpecifierWithoutFollowingAttribute(
PointerDeclarationFormatter::PointerDeclarationFormatter( PointerDeclarationFormatter::PointerDeclarationFormatter(
const CppRefactoringFilePtr refactoringFile, const CppRefactoringFilePtr refactoringFile,
const Overview &overview, Overview &overview,
CursorHandling cursorHandling) CursorHandling cursorHandling)
: ASTVisitor(refactoringFile->cppDocument()->translationUnit()) : ASTVisitor(refactoringFile->cppDocument()->translationUnit())
, m_cppRefactoringFile(refactoringFile) , m_cppRefactoringFile(refactoringFile)
@@ -413,21 +413,14 @@ void PointerDeclarationFormatter::checkAndRewrite(DeclaratorAST *declarator,
QString rewrittenDeclaration; QString rewrittenDeclaration;
const Name *name = symbol->name(); const Name *name = symbol->name();
if (name) { if (name) {
if (name->isOperatorNameId()) { if (name->isOperatorNameId()
// Take the operator name from the file instead from the AST, so the white || (name->isQualifiedNameId()
// spaces within the operator names can be respected, e.g. in "operator =". && name->asQualifiedNameId()->name()->isOperatorNameId())) {
const QByteArray operatorText const QString operatorText = m_cppRefactoringFile->textOf(declarator->core_declarator);
= m_cppRefactoringFile->textOf(declarator->core_declarator).toLatin1(); m_overview.includeWhiteSpaceInOperatorName = operatorText.contains(QLatin1Char(' '));
Identifier operatorName(operatorText.constData(), operatorText.size());
rewrittenDeclaration = rewriteDeclaration(type, &operatorName);
} else {
rewrittenDeclaration = rewriteDeclaration(type, name);
} }
} else {
// The declaration will be correctly rewritten for name == 0 (e.g. "int *").
rewrittenDeclaration = rewriteDeclaration(type, name);
} }
rewrittenDeclaration = m_overview.prettyType(type, name);
rewrittenDeclaration.remove(0, charactersToRemove); rewrittenDeclaration.remove(0, charactersToRemove);
CHECK_R(originalDeclaration != rewrittenDeclaration, "Rewritten is same as original"); CHECK_R(originalDeclaration != rewrittenDeclaration, "Rewritten is same as original");
@@ -460,21 +453,6 @@ void PointerDeclarationFormatter::checkAndRewrite(DeclaratorAST *declarator,
qDebug() << "Replacement operation failed"; qDebug() << "Replacement operation failed";
} }
/*! Rewrite/format the given type and name. */
QString PointerDeclarationFormatter::rewriteDeclaration(FullySpecifiedType type, const Name *name)
const
{
CHECK_RV(type.isValid(), "Invalid type", QString());
const char *identifier = 0;
if (const Name *declarationName = name) {
if (const Identifier *id = declarationName->identifier())
identifier = id->chars();
}
return m_overview.prettyType(type, QLatin1String(identifier));
}
void PointerDeclarationFormatter::printCandidate(AST *ast) void PointerDeclarationFormatter::printCandidate(AST *ast)
{ {
#if DEBUG_OUTPUT #if DEBUG_OUTPUT

View File

@@ -78,7 +78,7 @@ public:
enum CursorHandling { RespectCursor, IgnoreCursor }; enum CursorHandling { RespectCursor, IgnoreCursor };
explicit PointerDeclarationFormatter(const CppRefactoringFilePtr refactoringFile, explicit PointerDeclarationFormatter(const CppRefactoringFilePtr refactoringFile,
const Overview &overview, Overview &overview,
CursorHandling cursorHandling = IgnoreCursor); CursorHandling cursorHandling = IgnoreCursor);
/*! /*!
@@ -113,11 +113,10 @@ private:
void processIfWhileForStatement(ExpressionAST *expression, Symbol *symbol); void processIfWhileForStatement(ExpressionAST *expression, Symbol *symbol);
void checkAndRewrite(DeclaratorAST *declarator, Symbol *symbol, TokenRange range, void checkAndRewrite(DeclaratorAST *declarator, Symbol *symbol, TokenRange range,
unsigned charactersToRemove = 0); unsigned charactersToRemove = 0);
QString rewriteDeclaration(FullySpecifiedType type, const Name *name) const;
void printCandidate(AST *ast); void printCandidate(AST *ast);
const CppRefactoringFilePtr m_cppRefactoringFile; const CppRefactoringFilePtr m_cppRefactoringFile;
const Overview &m_overview; Overview &m_overview;
const CursorHandling m_cursorHandling; const CursorHandling m_cursorHandling;
ChangeSet m_changeSet; ChangeSet m_changeSet;

View File

@@ -349,9 +349,13 @@ void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations_data()
<< source << stripCursor(source); << source << stripCursor(source);
// Respect white space within operator names // Respect white space within operator names
QTest::newRow("operators") QTest::newRow("operators1")
<< "class C { C@&operator = (const C &); };" << "class C { C@&operator = (const C &); };"
<< "class C { C & operator = (const C &); };"; << "class C { C & operator = (const C &); };";
QTest::newRow("operators2")
<< "C &C::operator = (const C &) {}"
<< "C & C::operator = (const C &) {}";
} }
void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements() void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements()

View File

@@ -237,6 +237,35 @@ static int commonStringLength(const QString &s1, const QString &s2)
return length; return length;
} }
static QString correspondingHeaderOrSourceInProject(const QFileInfo &fileInfo,
const QStringList &candidateFileNames,
const ProjectExplorer::Project *project)
{
QString bestFileName;
int compareValue = 0;
const QString filePath = fileInfo.filePath();
foreach (const QString &candidateFileName, candidateFileNames) {
const QStringList projectFiles = findFilesInProject(candidateFileName, project);
// Find the file having the most common path with fileName
foreach (const QString &projectFile, projectFiles) {
int value = commonStringLength(filePath, projectFile);
if (value > compareValue) {
compareValue = value;
bestFileName = projectFile;
}
}
}
if (!bestFileName.isEmpty()) {
const QFileInfo candidateFi(bestFileName);
QTC_ASSERT(candidateFi.isFile(), return QString());
m_headerSourceMapping[fileInfo.absoluteFilePath()] = candidateFi.absoluteFilePath();
m_headerSourceMapping[candidateFi.absoluteFilePath()] = fileInfo.absoluteFilePath();
return candidateFi.absoluteFilePath();
}
return QString();
}
} // namespace Internal } // namespace Internal
QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader) QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader)
@@ -287,29 +316,26 @@ QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader)
} }
} }
// Find files in the project // Find files in the current project
ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::currentProject(); ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject();
if (project) { if (currentProject) {
QString bestFileName; const QString path = correspondingHeaderOrSourceInProject(fi, candidateFileNames,
int compareValue = 0; currentProject);
foreach (const QString &candidateFileName, candidateFileNames) { if (!path.isEmpty())
const QStringList projectFiles = findFilesInProject(candidateFileName, project); return path;
// Find the file having the most common path with fileName }
foreach (const QString &projectFile, projectFiles) {
int value = commonStringLength(fileName, projectFile); // Find files in other projects
if (value > compareValue) { CppModelManager *modelManager = CppModelManager::instance();
compareValue = value; QList<CppModelManagerInterface::ProjectInfo> projectInfos = modelManager->projectInfos();
bestFileName = projectFile; foreach (const CppModelManagerInterface::ProjectInfo &projectInfo, projectInfos) {
} const ProjectExplorer::Project *project = projectInfo.project().data();
} if (project == currentProject)
} continue; // We have already checked the current project.
if (!bestFileName.isEmpty()) {
const QFileInfo candidateFi(bestFileName); const QString path = correspondingHeaderOrSourceInProject(fi, candidateFileNames, project);
QTC_ASSERT(candidateFi.isFile(), return QString()); if (!path.isEmpty())
m_headerSourceMapping[fi.absoluteFilePath()] = candidateFi.absoluteFilePath(); return path;
m_headerSourceMapping[candidateFi.absoluteFilePath()] = fi.absoluteFilePath();
return candidateFi.absoluteFilePath();
}
} }
return QString(); return QString();

View File

@@ -287,7 +287,7 @@ QtcPlugin {
Group { Group {
name: "LLDBOptions" name: "LLDBOptions"
condition: qbs.targetOS.contains("mac") condition: qbs.targetOS.contains("osx")
files: [ files: [
"lldblib/lldboptionspage.cpp", "lldblib/lldboptionspage.cpp",
"lldblib/lldboptionspage.h", "lldblib/lldboptionspage.h",

View File

@@ -57,6 +57,7 @@
#include <QDockWidget> #include <QDockWidget>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QToolButton>
using namespace Core; using namespace Core;
using namespace ProjectExplorer; using namespace ProjectExplorer;
@@ -113,6 +114,7 @@ public:
DebuggerLanguages m_supportedLanguages; DebuggerLanguages m_supportedLanguages;
QWidget *m_debugToolBar; QWidget *m_debugToolBar;
QToolButton *m_viewButton;
QHBoxLayout *m_debugToolBarLayout; QHBoxLayout *m_debugToolBarLayout;
QHash<DebuggerLanguage, Context> m_contextsForLanguage; QHash<DebuggerLanguage, Context> m_contextsForLanguage;
@@ -500,6 +502,12 @@ QWidget *DebuggerMainWindow::createContents(IMode *mode)
documentAndRightPane->setStretchFactor(0, 1); documentAndRightPane->setStretchFactor(0, 1);
documentAndRightPane->setStretchFactor(1, 0); documentAndRightPane->setStretchFactor(1, 0);
d->m_viewButton = new QToolButton();
// FIXME: Use real thing after string freeze.
QString hackyName = QCoreApplication::translate("Core::Internal::MainWindow", "&Views");
hackyName.replace(QLatin1Char('&'), QString());
d->m_viewButton->setText(hackyName);
Utils::StyledBar *debugToolBar = new Utils::StyledBar; Utils::StyledBar *debugToolBar = new Utils::StyledBar;
debugToolBar->setProperty("topBorder", true); debugToolBar->setProperty("topBorder", true);
QHBoxLayout *debugToolBarLayout = new QHBoxLayout(debugToolBar); QHBoxLayout *debugToolBarLayout = new QHBoxLayout(debugToolBar);
@@ -507,6 +515,9 @@ QWidget *DebuggerMainWindow::createContents(IMode *mode)
debugToolBarLayout->setSpacing(0); debugToolBarLayout->setSpacing(0);
debugToolBarLayout->addWidget(d->m_debugToolBar); debugToolBarLayout->addWidget(d->m_debugToolBar);
debugToolBarLayout->addWidget(new Utils::StyledSeparator); debugToolBarLayout->addWidget(new Utils::StyledSeparator);
debugToolBarLayout->addWidget(d->m_viewButton);
connect(d->m_viewButton, SIGNAL(clicked()), this, SLOT(showViewsMenu()));
QDockWidget *dock = new QDockWidget(DebuggerMainWindowPrivate::tr("Debugger Toolbar")); QDockWidget *dock = new QDockWidget(DebuggerMainWindowPrivate::tr("Debugger Toolbar"));
dock->setObjectName(QLatin1String("Debugger Toolbar")); dock->setObjectName(QLatin1String("Debugger Toolbar"));
@@ -569,6 +580,13 @@ void DebuggerMainWindow::writeSettings() const
settings->endGroup(); settings->endGroup();
} }
void DebuggerMainWindow::showViewsMenu()
{
QMenu *menu = createPopupMenu();
menu->exec(d->m_viewButton->mapToGlobal(QPoint()));
delete menu;
}
void DebuggerMainWindow::readSettings() void DebuggerMainWindow::readSettings()
{ {
QSettings *settings = ICore::settings(); QSettings *settings = ICore::settings();

View File

@@ -95,6 +95,9 @@ public:
void readSettings(); void readSettings();
void writeSettings() const; void writeSettings() const;
private slots:
void showViewsMenu();
private: private:
friend class Internal::DebuggerMainWindowPrivate; friend class Internal::DebuggerMainWindowPrivate;
Internal::DebuggerMainWindowPrivate *d; Internal::DebuggerMainWindowPrivate *d;

View File

@@ -1253,6 +1253,7 @@ public:
QIcon m_locationMarkIcon; QIcon m_locationMarkIcon;
StatusLabel *m_statusLabel; StatusLabel *m_statusLabel;
QMenu *m_viewMenu;
QComboBox *m_threadBox; QComboBox *m_threadBox;
BaseWindow *m_breakWindow; BaseWindow *m_breakWindow;

61
src/plugins/plugins.qbs Normal file
View File

@@ -0,0 +1,61 @@
import qbs
Project {
name: "Plugins"
references: [
"analyzerbase/analyzerbase.qbs",
"android/android.qbs",
"autotoolsprojectmanager/autotoolsprojectmanager.qbs",
"bazaar/bazaar.qbs",
"bineditor/bineditor.qbs",
"bookmarks/bookmarks.qbs",
"classview/classview.qbs",
"clearcase/clearcase.qbs",
"cmakeprojectmanager/cmakeprojectmanager.qbs",
"coreplugin/coreplugin.qbs",
"coreplugin/images/logo/logo.qbs",
"cpaster/cpaster.qbs",
"cpaster/frontend/frontend.qbs",
"cppeditor/cppeditor.qbs",
"cpptools/cpptools.qbs",
"cvs/cvs.qbs",
"debugger/debugger.qbs",
"debugger/ptracepreload.qbs",
"designer/designer.qbs",
"diffeditor/diffeditor.qbs",
"fakevim/fakevim.qbs",
"find/find.qbs",
"genericprojectmanager/genericprojectmanager.qbs",
"git/git.qbs",
"glsleditor/glsleditor.qbs",
"helloworld/helloworld.qbs",
"help/help.qbs",
"imageviewer/imageviewer.qbs",
"locator/locator.qbs",
"macros/macros.qbs",
"madde/madde.qbs",
"mercurial/mercurial.qbs",
"perforce/perforce.qbs",
"projectexplorer/projectexplorer.qbs",
"qbsprojectmanager/qbsprojectmanager.qbs",
"pythoneditor/pythoneditor.qbs",
// "qmldesigner/qmldesigner.qbs",
"qmljseditor/qmljseditor.qbs",
"qmljstools/qmljstools.qbs",
"qmlprofiler/qmlprofiler.qbs",
"qmlprojectmanager/qmlprojectmanager.qbs",
"qnx/qnx.qbs",
"qt4projectmanager/qt4projectmanager.qbs",
"qtsupport/qtsupport.qbs",
"remotelinux/remotelinux.qbs",
"resourceeditor/resourceeditor.qbs",
"subversion/subversion.qbs",
"tasklist/tasklist.qbs",
"texteditor/texteditor.qbs",
"todo/todo.qbs",
"updateinfo/updateinfo.qbs",
"valgrind/valgrind.qbs",
"vcsbase/vcsbase.qbs",
"welcome/welcome.qbs"
]
}

View File

@@ -1059,6 +1059,16 @@ QList<FileName> ClangToolChain::suggestedMkspecList() const
return QList<FileName>(); // Note: Not supported by Qt yet, so default to the mkspec the Qt was build with return QList<FileName>(); // Note: Not supported by Qt yet, so default to the mkspec the Qt was build with
} }
void ClangToolChain::addToEnvironment(Environment &env) const
{
GccToolChain::addToEnvironment(env);
// Clang takes PWD as basis for debug info, if set.
// When running Qt Creator from a shell, PWD is initially set to an "arbitrary" value.
// Since the tools are not called through a shell, PWD is never changed to the actual cwd,
// so we better make sure PWD is empty to begin with
env.unset(QLatin1String("PWD"));
}
ToolChain::CompilerFlags ClangToolChain::defaultCompilerFlags() const ToolChain::CompilerFlags ClangToolChain::defaultCompilerFlags() const
{ {
return CompilerFlags(GnuExtensions | StandardC99 | StandardCxx11); return CompilerFlags(GnuExtensions | StandardC99 | StandardCxx11);

View File

@@ -158,6 +158,7 @@ public:
ToolChain *clone() const; ToolChain *clone() const;
QList<Utils::FileName> suggestedMkspecList() const; QList<Utils::FileName> suggestedMkspecList() const;
void addToEnvironment(Utils::Environment &env) const;
protected: protected:
virtual CompilerFlags defaultCompilerFlags() const; virtual CompilerFlags defaultCompilerFlags() const;

View File

@@ -252,13 +252,23 @@ void QbsManager::addProfileFromKit(const ProjectExplorer::Kit *k)
if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) { if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) {
data.insert(QLatin1String(QBS_TARGETOS), QLatin1String("windows")); data.insert(QLatin1String(QBS_TARGETOS), QLatin1String("windows"));
data.insert(QLatin1String(QBS_TOOLCHAIN), data.insert(QLatin1String(QBS_TOOLCHAIN),
targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor ? targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor
QLatin1String("mingw") : QLatin1String("msvc")); ? QStringList() << QLatin1String("mingw") << QLatin1String("gcc")
: QStringList() << QLatin1String("msvc"));
} else if (targetAbi.os() == ProjectExplorer::Abi::MacOS) { } else if (targetAbi.os() == ProjectExplorer::Abi::MacOS) {
data.insert(QLatin1String(QBS_TARGETOS), QLatin1String("mac")); data.insert(QLatin1String(QBS_TARGETOS), QStringList() << QLatin1String("osx")
data.insert(QLatin1String(QBS_TOOLCHAIN), QLatin1String("gcc")); << QLatin1String("darwin") << QLatin1String("unix"));
if (tc->type() != QLatin1String("clang")) {
data.insert(QLatin1String(QBS_TOOLCHAIN), QLatin1String("gcc"));
} else {
data.insert(QLatin1String(QBS_TOOLCHAIN),
QStringList() << QLatin1String("clang")
<< QLatin1String("llvm")
<< QLatin1String("gcc"));
}
} else if (targetAbi.os() == ProjectExplorer::Abi::LinuxOS) { } else if (targetAbi.os() == ProjectExplorer::Abi::LinuxOS) {
data.insert(QLatin1String(QBS_TARGETOS), QLatin1String("linux")); data.insert(QLatin1String(QBS_TARGETOS), QStringList() << QLatin1String("linux")
<< QLatin1String("unix"));
if (tc->type() != QLatin1String("clang")) { if (tc->type() != QLatin1String("clang")) {
data.insert(QLatin1String(QBS_TOOLCHAIN), QLatin1String("gcc")); data.insert(QLatin1String(QBS_TOOLCHAIN), QLatin1String("gcc"));
} else { } else {

View File

@@ -418,8 +418,11 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
} }
QRectF QmlAnchorBindingProxy::parentBoundingBox() QRectF QmlAnchorBindingProxy::parentBoundingBox()
{ {
if (m_fxItemNode.hasInstanceParent()) if (m_fxItemNode.hasInstanceParent()) {
if (m_fxItemNode.instanceParent().toQmlItemNode().instanceContentItemBoundingRect().isValid())
return m_fxItemNode.instanceParent().toQmlItemNode().instanceContentItemBoundingRect();
return m_fxItemNode.instanceParent().toQmlItemNode().instanceBoundingRect(); return m_fxItemNode.instanceParent().toQmlItemNode().instanceBoundingRect();
}
return QRect(); return QRect();
} }
@@ -434,7 +437,7 @@ QRectF QmlAnchorBindingProxy::boundingBox(QmlItemNode node)
QRectF QmlAnchorBindingProxy::transformedBoundingBox() QRectF QmlAnchorBindingProxy::transformedBoundingBox()
{ {
return m_fxItemNode.instanceTransform().mapRect(m_fxItemNode.instanceBoundingRect()); return m_fxItemNode.instanceTransformWithContentTransform().mapRect(m_fxItemNode.instanceBoundingRect());
} }
void QmlAnchorBindingProxy::calcTopMargin() void QmlAnchorBindingProxy::calcTopMargin()

View File

@@ -43,7 +43,6 @@
#include <QWeakPointer> #include <QWeakPointer>
#include <QRectF> #include <QRectF>
#include <QTime> #include <QTime>
#include <QTimer>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDeclarativeEngine; class QDeclarativeEngine;
@@ -197,11 +196,9 @@ private: // functions
void resetVerticalAnchors(const ModelNode &node); void resetVerticalAnchors(const ModelNode &node);
void restartProcess(); void restartProcess();
void restartProcessDelayed();
private slots: private slots:
void handleChrash(); void handleChrash();
void restartProcessDelayedTimeOut();
private: //variables private: //variables
NodeInstance m_rootNodeInstance; NodeInstance m_rootNodeInstance;
@@ -216,8 +213,6 @@ private: //variables
QTime m_lastCrashTime; QTime m_lastCrashTime;
NodeInstanceServerInterface::RunModus m_runModus; NodeInstanceServerInterface::RunModus m_runModus;
QString m_pathToQt; QString m_pathToQt;
bool m_puppetRestarted;
QTimer m_singleShotTimerRestartProcessDelayed;
}; };
} // namespace ProxyNodeInstanceView } // namespace ProxyNodeInstanceView

View File

@@ -103,13 +103,9 @@ d too.
NodeInstanceView::NodeInstanceView(QObject *parent, NodeInstanceServerInterface::RunModus runModus) NodeInstanceView::NodeInstanceView(QObject *parent, NodeInstanceServerInterface::RunModus runModus)
: AbstractView(parent), : AbstractView(parent),
m_baseStatePreviewImage(QSize(100, 100), QImage::Format_ARGB32), m_baseStatePreviewImage(QSize(100, 100), QImage::Format_ARGB32),
m_runModus(runModus), m_runModus(runModus)
m_puppetRestarted(false)
{ {
m_baseStatePreviewImage.fill(0xFFFFFF); m_baseStatePreviewImage.fill(0xFFFFFF);
m_singleShotTimerRestartProcessDelayed.setSingleShot(true);
m_singleShotTimerRestartProcessDelayed.setInterval(400);
connect(&m_singleShotTimerRestartProcessDelayed, SIGNAL(timeout()), this, SLOT(restartProcessDelayedTimeOut()));
} }
@@ -194,15 +190,10 @@ void NodeInstanceView::handleChrash()
emit qmlPuppetCrashed(); emit qmlPuppetCrashed();
} }
void NodeInstanceView::restartProcessDelayedTimeOut()
{
if (!m_puppetRestarted)
restartProcess();
}
void NodeInstanceView::restartProcess() void NodeInstanceView::restartProcess()
{ {
m_puppetRestarted = true;
if (model()) { if (model()) {
delete nodeInstanceServer(); delete nodeInstanceServer();
@@ -220,12 +211,6 @@ void NodeInstanceView::restartProcess()
} }
} }
void NodeInstanceView::restartProcessDelayed()
{
m_puppetRestarted = false;
m_singleShotTimerRestartProcessDelayed.start();
}
void NodeInstanceView::nodeCreated(const ModelNode &createdNode) void NodeInstanceView::nodeCreated(const ModelNode &createdNode)
{ {
NodeInstance instance = loadNode(createdNode); NodeInstance instance = loadNode(createdNode);
@@ -1136,16 +1121,7 @@ void NodeInstanceView::setPathToQt(const QString &pathToQt)
{ {
if (m_pathToQt != pathToQt) { if (m_pathToQt != pathToQt) {
m_pathToQt = pathToQt; m_pathToQt = pathToQt;
restartProcess();
/* The restart is done delayed, because when creating a new project we switch to that project
* before we open the new file. This means the user can get an error about a missing puppet,
* because the new project is based on another Qt version.
*
* See QTCREATORBUG-8756 for more details.
*
*/
restartProcessDelayed();
} }
} }

View File

@@ -56,5 +56,6 @@ Item {
anchors.baseline: lbl.baseline anchors.baseline: lbl.baseline
anchors.left: guideline.right anchors.left: guideline.right
onLinkActivated: detail.linkActivated(link) onLinkActivated: detail.linkActivated(link)
textFormat: Text.PlainText
} }
} }

View File

@@ -129,6 +129,7 @@ Item {
x: 5 x: 5
width: 140 width: 140
text: descriptions[index] text: descriptions[index]
textFormat: Text.PlainText
elide: Text.ElideRight elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }

View File

@@ -262,6 +262,10 @@ void QmlProfilerEngine::cancelProcess()
{ {
QTC_ASSERT(d->m_profilerState, return); QTC_ASSERT(d->m_profilerState, return);
// no process to be canceled? (there might be multiple engines, but only one runs a process)
if (!d->m_runner)
return;
switch (d->m_profilerState->currentState()) { switch (d->m_profilerState->currentState()) {
case QmlProfilerStateManager::AppReadyToStop : { case QmlProfilerStateManager::AppReadyToStop : {
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopped); d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStopped);

View File

@@ -386,7 +386,7 @@ QDomNode BarDescriptorDocumentSplashScreenNodeHandler::toNode(QDomDocument &doc)
if (splashScreens.isEmpty()) if (splashScreens.isEmpty())
return QDomElement(); return QDomElement();
QDomElement splashScreenElement = doc.createElement(QLatin1String("splashscreens")); QDomElement splashScreenElement = doc.createElement(QLatin1String("splashScreens"));
foreach (const QString &splashScreen, splashScreens) foreach (const QString &splashScreen, splashScreens)
splashScreenElement.appendChild(createSimpleTextElement(doc, QLatin1String("image"), splashScreen)); splashScreenElement.appendChild(createSimpleTextElement(doc, QLatin1String("image"), splashScreen));

12
src/src.qbs Normal file
View File

@@ -0,0 +1,12 @@
import qbs
Project {
name: "Sources"
references: [
"app/app.qbs",
"app/app_version_header.qbs",
"libs/libs.qbs",
"plugins/plugins.qbs",
"tools/tools.qbs"
]
}

View File

@@ -246,9 +246,9 @@ void CrashHandler::runCommand(QStringList commandLine, QStringList environment,
qFatal("%s: freopen() failed for stderr: %s.\n.", Q_FUNC_INFO, strerror(errno)); qFatal("%s: freopen() failed for stderr: %s.\n.", Q_FUNC_INFO, strerror(errno));
if (environment.isEmpty()) if (environment.isEmpty())
execv(argv[0], argv.data()); execvp(argv[0], argv.data());
else else
execve(argv[0], argv.data(), envp.data()); execvpe(argv[0], argv.data(), envp.data());
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} default: // parent } default: // parent
if (waitMode == WaitForExit) { if (waitMode == WaitForExit) {

View File

@@ -48,6 +48,13 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include <sys/prctl.h>
// Enable compilation with older header that doesn't contain this constant
// for running on newer libraries that do support it
#ifndef PR_SET_PTRACER
#define PR_SET_PTRACER 0x59616d61
#endif
#ifdef Q_WS_X11 #ifdef Q_WS_X11
#include <qx11info_x11.h> #include <qx11info_x11.h>
@@ -72,6 +79,7 @@ extern "C" void signalHandler(int signal)
execl(crashHandlerPathC, crashHandlerPathC, strsignal(signal), (char *) 0); execl(crashHandlerPathC, crashHandlerPathC, strsignal(signal), (char *) 0);
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
default: // parent default: // parent
prctl(PR_SET_PTRACER, pid, 0, 0, 0);
waitpid(pid, 0, 0); waitpid(pid, 0, 0);
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
break; break;

View File

@@ -9,7 +9,7 @@ QtcTool {
Depends { name: "app_version_header" } Depends { name: "app_version_header" }
cpp.includePaths: "../../libs" cpp.includePaths: "../../libs"
cpp.defines: base.concat([qbs.targetOS.contains("mac") cpp.defines: base.concat([qbs.targetOS.contains("osx")
? 'DATA_PATH="."' : 'DATA_PATH="../share/qtcreator"']) ? 'DATA_PATH="."' : 'DATA_PATH="../share/qtcreator"'])
files: [ files: [

11
src/tools/tools.qbs Normal file
View File

@@ -0,0 +1,11 @@
import qbs
Project {
name: "Tools"
references: [
"qtcdebugger/qtcdebugger.qbs",
"qtcreatorcrashhandler/qtcreatorcrashhandler.qbs",
"qtpromaker/qtpromaker.qbs",
"sdktool/sdktool.qbs"
]
}

View File

@@ -2,4 +2,5 @@ wholeWordAtStart bla foo blubb wholeWordAtEnd
search to find multiple find results search to find multiple find results
search CaseSensitively for casesensitive search CaseSensitively for casesensitive
here you find another result here you find another result
aaaaaaaa this line has 2 results for four a in a row
wholeWordAtVeryEnd wholeWordAtVeryEnd

View File

@@ -46,6 +46,11 @@ bool operator==(const Utils::FileSearchResult &r1, const Utils::FileSearchResult
class tst_FileSearch : public QObject class tst_FileSearch : public QObject
{ {
Q_OBJECT Q_OBJECT
public:
enum RegExpFlag {
NoRegExp,
RegExp
};
private slots: private slots:
void multipleResults(); void multipleResults();
@@ -59,12 +64,15 @@ namespace {
void test_helper(const Utils::FileSearchResultList &expectedResults, void test_helper(const Utils::FileSearchResultList &expectedResults,
const QString &term, const QString &term,
QTextDocument::FindFlags flags) QTextDocument::FindFlags flags, tst_FileSearch::RegExpFlag regexp = tst_FileSearch::NoRegExp)
{ {
Utils::FileIterator *it = new Utils::FileIterator(QStringList() << QLatin1String(FILENAME), QList<QTextCodec *>() << QTextCodec::codecForLocale()); Utils::FileIterator *it = new Utils::FileIterator(QStringList() << QLatin1String(FILENAME), QList<QTextCodec *>() << QTextCodec::codecForLocale());
QFutureWatcher<Utils::FileSearchResultList> watcher; QFutureWatcher<Utils::FileSearchResultList> watcher;
QSignalSpy ready(&watcher, SIGNAL(resultsReadyAt(int,int))); QSignalSpy ready(&watcher, SIGNAL(resultsReadyAt(int,int)));
watcher.setFuture(Utils::findInFiles(term, it, flags)); if (regexp == tst_FileSearch::NoRegExp)
watcher.setFuture(Utils::findInFiles(term, it, flags));
else
watcher.setFuture(Utils::findInFilesRegExp(term, it, flags));
watcher.future().waitForFinished(); watcher.future().waitForFinished();
QTest::qWait(100); // process events QTest::qWait(100); // process events
QCOMPARE(ready.count(), 1); QCOMPARE(ready.count(), 1);
@@ -83,6 +91,16 @@ void tst_FileSearch::multipleResults()
expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 2, QLatin1String("search to find multiple find results"), 24, 4, QStringList()); expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 2, QLatin1String("search to find multiple find results"), 24, 4, QStringList());
expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 4, QLatin1String("here you find another result"), 9, 4, QStringList()); expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 4, QLatin1String("here you find another result"), 9, 4, QStringList());
test_helper(expectedResults, QLatin1String("find"), QTextDocument::FindFlags(0)); test_helper(expectedResults, QLatin1String("find"), QTextDocument::FindFlags(0));
expectedResults.clear();
expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 0, 4, QStringList());
expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 4, 4, QStringList());
test_helper(expectedResults, QLatin1String("aaaa"), QTextDocument::FindFlags(0));
expectedResults.clear();
expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 0, 4, QStringList() << QLatin1String("aaaa"));
expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 4, 4, QStringList() << QLatin1String("aaaa"));
test_helper(expectedResults, QLatin1String("aaaa"), QTextDocument::FindFlags(0), RegExp);
} }
void tst_FileSearch::caseSensitive() void tst_FileSearch::caseSensitive()

View File

@@ -28,7 +28,7 @@
****************************************************************************/ ****************************************************************************/
/* /*
Folow includes Follow includes
*/ */
#include <QDebug> #include <QDebug>
#include <QString> #include <QString>