diff --git a/dist/changes-3.3.1 b/dist/changes-3.3.1 new file mode 100644 index 00000000000..4a1c4af81a9 --- /dev/null +++ b/dist/changes-3.3.1 @@ -0,0 +1,50 @@ +Qt Creator version 3.3.1 contains bug fixes. + +The most important changes are listed in this document. For a complete +list of changes, see the Git log for the Qt Creator sources that +you can check out from the public Git repository. For example: + +git clone git://gitorious.org/qt-creator/qt-creator.git +git log --cherry-pick --pretty=oneline v3.3.0..v3.3.1 + +Editing + * Fixed crash with some highlighting files (QTCREATORBUG-13883) + +CMake Projects + * Fixed include completion (QTCREATORBUG-13567) + * Fixed highlighting for CMake files (QTCREATORBUG-13588) + +C++ Support + * Fixed comment continuation (QTCREATORBUG-13415) + * Fixed Convert to Pointer refactoring action for auto variables + (QTCREATORBUG-13605) + * Fixed that triggering refactoring actions from the context menu + worked only if the text cursor was set first (QTCREATORBUG-13388) + * Fixed crash if no kits are available (QTCREATORBUG-13730) + * Fixed infinite loop when parsing some files (QTCREATORBUG-13703) + * Fixed crash when #if nesting is deeper than 512 levels + +Version Control Systems + * Git + * Fixed reverting chunks in diff viewer when diff.mnemonicprefix is set + (QTCREATORBUG-13782) + * ClearCase + * Fixed that check out was requested even though the file was already + checked out (QTCREATORBUG-13782) + +Code Pasting + * Fixed pasting to pastebin.ca (QTCREATORBUG-13802) + +Platform Specific + +OS X + * Fixed dropping files from Finder onto Qt Creator (QTBUG-40449) + +Android + * Fixed crash when removing auto-detected kits (QTCREATORBUG-13736) + * Fixed debugging applications that link many modules (QTCREATORBUG-13691) + +WinRT + * Fixed installing custom files into package root (QTCREATORBUG-13835) + * Fixed occasional crashes when debugging + diff --git a/dist/known-issues b/dist/known-issues index 33275b31979..fd4935d0628 100644 --- a/dist/known-issues +++ b/dist/known-issues @@ -1,6 +1,6 @@ The Qt Creator Manual lists known issues in Qt Creator: -http://qt-project.org/doc/qtcreator/creator-known-issues.html +http://doc.qt.io/qtcreator/creator-known-issues.html For a complete list of reported issues, see the Qt Bug Tracker: diff --git a/doc/api/coding-style.qdoc b/doc/api/coding-style.qdoc index 96f1aab7d6c..8c51f1d34df 100644 --- a/doc/api/coding-style.qdoc +++ b/doc/api/coding-style.qdoc @@ -891,7 +891,7 @@ for signals and slots inside connect statements to safely make signal and slot lookup a few cycles faster. You can use $QTDIR/util/normalize to normalize existing code. For more - information, see \l{http://qt-project.org/doc/qt-4.8/qmetaobject.html#normalizedSignature}{QMetaObject::normalizedSignature}. + information, see QMetaObject::normalizedSignature. \endlist \section2 File Headers diff --git a/doc/api/first-plugin.qdoc b/doc/api/first-plugin.qdoc index 2da093f03fb..2684271b48d 100644 --- a/doc/api/first-plugin.qdoc +++ b/doc/api/first-plugin.qdoc @@ -227,7 +227,7 @@ for use in \QC, by using the information you gave above. For more information about qmake, and writing .pro files in general, - see the \l{http://qt-project.org/doc/qt-4.8/qmake-manual.html}{qmake Manual}. + see the \l{qmake Manual}. \section1 Plugin Meta Data Template diff --git a/doc/api/qtcreator-dev-wizards.qdoc b/doc/api/qtcreator-dev-wizards.qdoc index 5974cf43f22..b9b9aabdae3 100644 --- a/doc/api/qtcreator-dev-wizards.qdoc +++ b/doc/api/qtcreator-dev-wizards.qdoc @@ -23,7 +23,7 @@ \section1 Introduction If the functionality provided by template-based - \l{http://doc.qt.digia.com/qtcreator-snapshot/creator-project-wizards.html}{custom wizards} + \l{http://doc.qt.io/qtcreator/creator-project-wizards.html}{custom wizards} is not sufficient for your case, you can write wizards in code. A wizard in Qt Creator is an instance of a class implementing diff --git a/doc/api/qtcreator-dev.qdoc b/doc/api/qtcreator-dev.qdoc index 8352da37ac0..094cc3915ad 100644 --- a/doc/api/qtcreator-dev.qdoc +++ b/doc/api/qtcreator-dev.qdoc @@ -53,7 +53,7 @@ to which you can add your own snippets. \list - \li \l{http://doc.qt.digia.com/qtcreator/creator-completing-code.html#editing-code-snippets} + \li \l{http://doc.qt.io/qtcreator/creator-completing-code.html#editing-code-snippets} {Snippets User Interface} \li \l{Snippets} {Adding Snippets Groups} \endlist @@ -64,7 +64,7 @@ own file and project templates by writing XML definition files for them. \list - \li \l{http://doc.qt.digia.com/qtcreator/creator-project-wizards.html} + \li \l{http://doc.qt.io/qtcreator/creator-project-wizards.html} {Adding New Custom Wizards} \li \l{User Interface Text Guidelines} \endlist @@ -96,7 +96,7 @@ the MIME type definitions in Qt Creator to your specific setup, by adding or removing file extensions and specifying magic headers. \list - \li \l{http://doc.qt.digia.com/qtcreator/creator-mime-types.html} + \li \l{http://doc.qt.io/qtcreator/creator-mime-types.html} {Editing MIME Types} \li \l{http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html} {MIME Type Specification Files} @@ -110,7 +110,7 @@ provided by the Kate Editor. You can download highlight definition files for use with Qt Creator and create your own definition files. \list - \li \l{http://doc.qt.digia.com/qtcreator/creator-editor-options.html#generic-highlighting} + \li \l{http://doc.qt.io/qtcreator/creator-editor-options.html#generic-highlighting} {Generic Highlighting} \li \l{http://kate-editor.org/2005/03/24/writing-a-syntax-highlighting-file/} {Writing a Syntax Highlighting File} @@ -162,7 +162,7 @@ to fill a feature suggestion. The tool descriptions are saved as XML files that you can share. \list - \li \l{http://doc.qt.digia.com/qtcreator/creator-editor-external.html} + \li \l{http://doc.qt.io/qtcreator/creator-editor-external.html} {Using External Tools} \li \l{External Tool Specification Files} \endlist @@ -189,7 +189,7 @@ If you need a way to configure the tool in Qt Creator, you can add an \uicontrol Options page for it. \list - \li \l{http://doc.qt.digia.com/qtcreator/creator-editor-external.html} + \li \l{http://doc.qt.io/qtcreator/creator-editor-external.html} {Using External Tools} \li \l{External Tool Specification Files} \li \l{Creating Plugins} @@ -214,7 +214,7 @@ the \uicontrol {Issues} output pane. \list - \li \l{http://doc.qt.digia.com/qtcreator/creator-task-lists.html} + \li \l{http://doc.qt.io/qtcreator/creator-task-lists.html} {Showing Task List Files in the Issues Pane} \li \l{Creating Plugins} \li \l{Qt Creator Coding Rules} diff --git a/doc/api/qtcreator-documentation.qdoc b/doc/api/qtcreator-documentation.qdoc index 32cb491f589..8c7bbd52bde 100644 --- a/doc/api/qtcreator-documentation.qdoc +++ b/doc/api/qtcreator-documentation.qdoc @@ -61,7 +61,7 @@ \section1 Configuring the Documentation Project \QC documentation is written by using QDoc. For more information about using - QDoc, see the \l{http://qt-project.org/doc/qt-5.1/qdoc/qdoc-index.html} + QDoc, see the \l{http://doc.qt.io/qt-5/qdoc-index.html} {QDoc Manual}. QDoc finds the new topics automatically, when you place them as .qdoc files @@ -299,7 +299,7 @@ on OS X. You can view the HTML files in a browser and the help files in the \QC \uicontrol Help mode. For more information about adding the help files to \QC, see - \l{http://qt-project.org/doc/qtcreator/creator-help.html#adding-external-documentation} + \l{http://doc.qt.io/qtcreator/creator-help.html#adding-external-documentation} {Adding External Documentation}. Besides \c docs, you have the following options: diff --git a/doc/config/qtcreator-project.qdocconf b/doc/config/qtcreator-project.qdocconf index 7764b14868d..0cbfa5740f9 100644 --- a/doc/config/qtcreator-project.qdocconf +++ b/doc/config/qtcreator-project.qdocconf @@ -1,6 +1,6 @@ project = "QtCreator" description = "Qt Creator Manual" -url = http://qt-project.org/doc/qtcreator +url = http://doc.qt.io/qtcreator headerdirs = sourcedirs = $SRCDIR/src diff --git a/doc/src/projects/creator-projects-qbs.qdoc b/doc/src/projects/creator-projects-qbs.qdoc index 84096da901c..aee18ca444a 100644 --- a/doc/src/projects/creator-projects-qbs.qdoc +++ b/doc/src/projects/creator-projects-qbs.qdoc @@ -27,7 +27,7 @@ To use Qbs to build a project, you must create a .qbs file for the project. You can use \QC to create a C or C++ project that is built with Qbs. For more information about Qbs, see - the \l{http://qt-project.org/doc/qbs/index.html}{Qbs Manual}. + the \l{http://doc.qt.io/qbs/index.html}{Qbs Manual}. \section1 Building Qbs @@ -89,7 +89,7 @@ \li In the \uicontrol Properties field, specify the properties to pass to the project. Use colons (:) to separate keys from values. For more information, see - \l{http://qt-project.org/doc/qbs/language-introduction.html} + \l{http://doc.qt.io/qbs/language-introduction.html} {Modules} in the Qbs Manual. \li In the \uicontrol Flags field: diff --git a/doc/src/projects/creator-projects-settings-build.qdoc b/doc/src/projects/creator-projects-settings-build.qdoc index 51066862cf8..4c84c2c7f9b 100644 --- a/doc/src/projects/creator-projects-settings-build.qdoc +++ b/doc/src/projects/creator-projects-settings-build.qdoc @@ -114,7 +114,7 @@ the build step and add a custom build step that specifies another shell command. - \QC is integrated to \l{http://doc.qt.digia.com/QtQuickCompiler/} + \QC is integrated to \l{http://doc.qt.io/QtQuickCompiler/} {Qt Quick Compiler} (commercial only) that enables you to compile QML source code into the final binary. This improves the startup time of the application and eliminates the need to diff --git a/scripts/deployqtHelper_mac.sh b/scripts/deployqtHelper_mac.sh index 85f7a080c53..974e008043d 100755 --- a/scripts/deployqtHelper_mac.sh +++ b/scripts/deployqtHelper_mac.sh @@ -65,7 +65,8 @@ if [ $LLVM_INSTALL_DIR ]; then _CLANG_CODEMODEL_LIB="$1/Contents/PlugIns/libClangCodeModel.dylib" fi # this will just fail when run a second time on libClangCodeModel - xcrun install_name_tool -rpath "$LLVM_INSTALL_DIR/lib" "@loader_path/" "$_CLANG_CODEMODEL_LIB" || true + xcrun install_name_tool -delete_rpath "$LLVM_INSTALL_DIR/lib" "$_CLANG_CODEMODEL_LIB" || true + xcrun install_name_tool -add_rpath "@loader_path/" "$_CLANG_CODEMODEL_LIB" || true fi #### macdeployqt diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py index 7ffe1e74ac0..e9635d057a3 100644 --- a/share/qtcreator/debugger/gdbbridge.py +++ b/share/qtcreator/debugger/gdbbridge.py @@ -1566,6 +1566,9 @@ class Dumper(DumperBase): return typeobj def stackListFrames(self, args): + def fromNativePath(str): + return str.replace(os.path.sep, '/') + limit = int(args['limit']) if limit <= 0: limit = 10000 @@ -1594,9 +1597,9 @@ class Dumper(DumperBase): line = sal.line symtab = sal.symtab if not symtab is None: - objfile = symtab.objfile.filename - fileName = symtab.filename - fullName = symtab.fullname() + objfile = fromNativePath(symtab.objfile.filename) + fileName = fromNativePath(symtab.filename) + fullName = fromNativePath(symtab.fullname()) if self.nativeMixed: if self.isReportableQmlFrame(functionName): diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py index b7c24b6a0d3..71b5ddec0a6 100644 --- a/share/qtcreator/debugger/lldbbridge.py +++ b/share/qtcreator/debugger/lldbbridge.py @@ -69,7 +69,7 @@ Value = lldb.SBValue def impl_SBValue__add__(self, offset): if self.GetType().IsPointerType(): - if isinstance(offset, int): + if isinstance(offset, int) or isinstance(offset, long): pass else: offset = offset.GetValueAsSigned() @@ -647,8 +647,19 @@ class Dumper(DumperBase): self.platform_ = args.get('platform', '') self.ignoreStops = 0 - if self.useTerminal_ and platform.system() == "Linux": - self.ignoreStops = 2 + self.silentStops = 0 + if platform.system() == "Linux": + if self.startMode_ == AttachCore: + pass + else: + if self.useTerminal_: + self.ignoreStops = 2 + else: + self.silentStops = 1 + + else: + if self.useTerminal_: + self.ignoreStops = 1 if self.platform_: self.debugger.SetCurrentPlatform(self.platform_) @@ -656,6 +667,7 @@ class Dumper(DumperBase): if self.sysRoot_: self.debugger.SetCurrentPlatformSDKRoot(self.sysRoot_) + if os.path.isfile(self.executable_): self.target = self.debugger.CreateTarget(self.executable_, None, None, True, error) else: @@ -668,12 +680,12 @@ class Dumper(DumperBase): state = "inferiorsetupok" if self.target.IsValid() else "inferiorsetupfailed" self.report('state="%s",msg="%s",exe="%s"' % (state, error, self.executable_)) - def runEngine(self, _): - self.prepare() + def runEngine(self, args): + self.prepare(args) s = threading.Thread(target=self.loop, args=[]) s.start() - def prepare(self): + def prepare(self, args): error = lldb.SBError() listener = self.debugger.GetListener() @@ -700,6 +712,11 @@ class Dumper(DumperBase): # and later detects that it did stop after all, so it is be # better to mirror that and wait for the spontaneous stop. self.reportState("enginerunandinferiorrunok") + elif self.startMode_ == AttachCore: + coreFile = args.get('coreFile', ''); + self.process = self.target.LoadCore(coreFile) + self.reportState("enginerunokandinferiorunrunnable") + #self.reportContinuation(args) else: launchInfo = lldb.SBLaunchInfo(self.processArgs_) launchInfo.SetWorkingDirectory(os.getcwd()) @@ -744,13 +761,12 @@ class Dumper(DumperBase): thread = self.currentThread() return None if thread is None else thread.GetSelectedFrame() - def reportLocation(self): - thread = self.currentThread() - frame = thread.GetSelectedFrame() - file = fileName(frame.line_entry.file) - line = frame.line_entry.line - self.report('location={file="%s",line="%s",addr="%s"}' - % (file, line, frame.pc)) + def reportLocation(self, frame): + if int(frame.pc) != 0xffffffffffffffff: + file = fileName(frame.line_entry.file) + line = frame.line_entry.line + self.report('location={file="%s",line="%s",addr="%s"}' + % (file, line, frame.pc)) def firstStoppedThread(self): for i in xrange(0, self.process.GetNumThreads()): @@ -1218,7 +1234,11 @@ class Dumper(DumperBase): for group in frame.GetRegisters(): for reg in group: result += '{name="%s"' % reg.GetName() - result += ',value="%s"' % reg.GetValue() + value = reg.GetValue() + if value is None: + result += ',value=""' + else: + result += ',value="%s"' % value result += ',size="%s"' % reg.GetByteSize() result += ',type="%s"},' % reg.GetType() result += ']' @@ -1304,6 +1324,8 @@ class Dumper(DumperBase): elif self.ignoreStops > 0: self.ignoreStops -= 1 self.process.Continue() + elif self.silentStops > 0: + self.silentStops -= 1 #elif bp and bp in self.qmlBreakpointResolvers: # self.report("RESOLVER HIT") # self.qmlBreakpointResolvers[bp]() @@ -1320,7 +1342,8 @@ class Dumper(DumperBase): self.process.SetSelectedThread(stoppedThread) self.reportStackTop() self.reportThreads() - self.reportLocation() + if stoppedThread: + self.reportLocation(stoppedThread.GetSelectedFrame()) elif eventType == lldb.SBProcess.eBroadcastBitInterrupt: # 2 pass elif eventType == lldb.SBProcess.eBroadcastBitSTDOUT: @@ -1545,16 +1568,14 @@ class Dumper(DumperBase): self.reportState("running") self.reportState("stopped") self.reportError(error) - self.reportLocation() + self.reportLocation(self.currentFrame()) else: self.reportData() def executeJumpToLocation(self, args): frame = self.currentFrame() - self.reportState("stopped") if not frame: self.reportStatus("No frame available.") - self.reportLocation() return addr = args.get('address', 0) if addr: @@ -1565,12 +1586,15 @@ class Dumper(DumperBase): if bp.GetNumLocations() == 0: self.target.BreakpointDelete(bp.GetID()) self.reportStatus("No target location found.") - self.reportLocation() + self.reportLocation(frame) return loc = bp.GetLocationAtIndex(0) self.target.BreakpointDelete(bp.GetID()) - frame.SetPC(loc.GetLoadAddress()) - self.reportData() + if frame.SetPC(loc.GetLoadAddress()): + self.report("Jumped.") + else: + self.report("Cannot jump.") + self.reportLocation(frame) def breakList(self): result = lldb.SBCommandReturnObject() @@ -1587,7 +1611,6 @@ class Dumper(DumperBase): def selectThread(self, args): self.process.SetSelectedThreadByID(args['id']) - self.reportData() def requestModuleSymbols(self, frame): self.handleCommand("target module list " + frame) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CustomComboBoxStyle.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CustomComboBoxStyle.qml index 5eb59eb163b..a662773a080 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CustomComboBoxStyle.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CustomComboBoxStyle.qml @@ -68,7 +68,6 @@ ComboBoxStyle { anchors.fill: parent anchors.margins: -1 color: "transparent" - radius: 4 opacity: 0.3 visible: control.activeFocus } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CustomSpinBoxStyle.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CustomSpinBoxStyle.qml index 02503f3fe46..4fa9ff3d401 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CustomSpinBoxStyle.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CustomSpinBoxStyle.qml @@ -70,7 +70,6 @@ SpinBoxStyle { implicitWidth: Math.max(64, styleData.contentWidth) implicitHeight: 23 border.color: borderColor - radius: 3 gradient: Gradient { GradientStop {color: "#2c2c2c" ; position: 0} GradientStop {color: "#343434" ; position: 0.15} @@ -81,7 +80,6 @@ SpinBoxStyle { anchors.fill: parent anchors.margins: -1 color: "transparent" - radius: 4 opacity: 0.3 visible: control.activeFocus } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml index 43a9b5619bd..5e6827b4a04 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml @@ -123,7 +123,6 @@ Controls.TextField { implicitWidth: 100 implicitHeight: 23 border.color: borderColor - radius: 3 gradient: Gradient { GradientStop {color: "#2c2c2c" ; position: 0} GradientStop {color: "#343434" ; position: 0.15} diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/RoundedPanel.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/RoundedPanel.qml index 8a4aecbd12c..512fb8edc68 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/RoundedPanel.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/RoundedPanel.qml @@ -48,7 +48,7 @@ Rectangle { property bool roundRight: false - radius: roundLeft || roundRight ? 4 : 0 + radius: roundLeft || roundRight ? 1 : 0 gradient: Gradient { GradientStop {color: '#555' ; position: 0} GradientStop {color: '#444' ; position: 1} diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/Section.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/Section.qml index fde373a423d..0b5d444d5bc 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/Section.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/Section.qml @@ -68,12 +68,10 @@ Item { Behavior on rotation {NumberAnimation{duration: 80}} } - gradient: Gradient { - GradientStop {color: '#555' ; position: 0} - GradientStop {color: '#444' ; position: 1} - } + color: "#444" Rectangle { + visible: false color:"#333" width: parent.width height: 1 diff --git a/share/qtcreator/qmldesigner/statesEditorQmlSources/DesignerTextFieldStyle.qml b/share/qtcreator/qmldesigner/statesEditorQmlSources/DesignerTextFieldStyle.qml index 4f1f5a91fba..285fa08b06c 100644 --- a/share/qtcreator/qmldesigner/statesEditorQmlSources/DesignerTextFieldStyle.qml +++ b/share/qtcreator/qmldesigner/statesEditorQmlSources/DesignerTextFieldStyle.qml @@ -45,7 +45,6 @@ TextFieldStyle { implicitWidth: 100 implicitHeight: font.pixelSize + padding.top + padding.bottom border.color: "#222222" - radius: 3 gradient: Gradient { GradientStop {color: "#2c2c2c" ; position: 0} GradientStop {color: "#343434" ; position: 0.15} diff --git a/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml b/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml index 076960a0e48..e649a8944bb 100644 --- a/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml +++ b/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml @@ -36,17 +36,12 @@ Rectangle { border.width: 1 property bool isBaseState property bool isCurrentState - property color gradiantBaseColor + property color baseColor property string delegateStateName property string delegateStateImageSource property int delegateStateImageSize - gradient: Gradient { - GradientStop { position: 0.0; color: Qt.lighter(gradiantBaseColor, 1.5) } - GradientStop { position: 0.1; color: Qt.lighter(gradiantBaseColor, 1) } - GradientStop { position: 0.8; color: gradiantBaseColor } - GradientStop { position: 1.0; color: Qt.darker(gradiantBaseColor) } - } + color: baseColor MouseArea { anchors.fill: parent @@ -63,7 +58,7 @@ Rectangle { style: ButtonStyle { background: Rectangle { - color: control.hovered ? Qt.lighter(gradiantBaseColor, 1.4) : "transparent" + color: control.hovered ? Qt.lighter(baseColor, 1.2) : "transparent" radius: 2 } } diff --git a/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesList.qml b/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesList.qml index ba4570563e4..38d141e667d 100644 --- a/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesList.qml +++ b/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesList.qml @@ -102,14 +102,24 @@ FocusScope { id: addStateButton visible: canAddNewStates + tooltip: qsTr("Add a new state.") + anchors.right: parent.right - anchors.rightMargin: padding + anchors.rightMargin: 8 anchors.verticalCenter: parent.verticalCenter - width: Math.max(parent.height / 2, 24) + width: Math.max(parent.height / 2 - 8, 18) height: width iconSource: "images/plus.png" onClicked: root.createNewState() + + style: ButtonStyle { + background: Rectangle { + property color buttonBaseColor: "#6f6f6f" + color: control.hovered ? Qt.lighter(buttonBaseColor, 1.2) : buttonBaseColor + border.width: 1 + } + } } } @@ -136,7 +146,7 @@ FocusScope { height: delegateHeight isBaseState: 0 == internalNodeId isCurrentState: root.currentStateInternalId == internalNodeId - gradiantBaseColor: isCurrentState ? Qt.darker(highlightColor, 1.2) : background.color + baseColor: isCurrentState ? Qt.darker(highlightColor, 1.2) : background.color delegateStateName: stateName delegateStateImageSource: stateImageSource delegateStateImageSize: stateImageSize diff --git a/share/qtcreator/qmldesigner/statesEditorQmlSources/images/plus.png b/share/qtcreator/qmldesigner/statesEditorQmlSources/images/plus.png index 20928fb402a..d16329ca450 100644 Binary files a/share/qtcreator/qmldesigner/statesEditorQmlSources/images/plus.png and b/share/qtcreator/qmldesigner/statesEditorQmlSources/images/plus.png differ diff --git a/share/qtcreator/welcomescreen/widgets/dummydata/context/ExampleDelegate.qml b/share/qtcreator/welcomescreen/widgets/dummydata/context/ExampleDelegate.qml index 8784151f1ec..f17c790838f 100644 --- a/share/qtcreator/welcomescreen/widgets/dummydata/context/ExampleDelegate.qml +++ b/share/qtcreator/welcomescreen/widgets/dummydata/context/ExampleDelegate.qml @@ -35,6 +35,6 @@ DummyContextObject { property variant model: QtObject { property string name: "Calculator" property string description: "his demo shows how to write a simple calculator application in QML and JavaScript." - property string imageSource: "http://qt-project.org/doc/qt-4.8/images/qml-calculator-example-small.png" + property string imageSource: "http://doc.qt.io/qt-4.8/images/qml-calculator-example-small.png" } } diff --git a/share/qtcreator/welcomescreen/widgets/dummydata/examplesModel.qml b/share/qtcreator/welcomescreen/widgets/dummydata/examplesModel.qml index ff1596dd490..f730111a071 100644 --- a/share/qtcreator/welcomescreen/widgets/dummydata/examplesModel.qml +++ b/share/qtcreator/welcomescreen/widgets/dummydata/examplesModel.qml @@ -34,27 +34,27 @@ ListModel { ListElement { name: "Calculator with more info on something bla bla on Qt if you know" description: "his demo shows how to write a simple calculator application in QML and JavaScript." - imageSource: "http://qt-project.org/doc/qt-4.8/images/qml-calculator-example-small.png" + imageSource: "http://doc.qt.io/qt-4.8/images/qml-calculator-example-small.png" } ListElement { name: "RSS News Reader" description: "This demo shows how to write a RSS news reader in QML." - imageSource: "http://qt-project.org/doc/qt-4.8/images/qml-rssnews-demo-small.png" + imageSource: "http://doc.qt.io/qt-4.8/images/qml-rssnews-demo-small.png" } ListElement { name: "Twitter" description: "This demo shows how to write a mobile Twitter search client in QML. Use it to see what people think about Qt Quick!" - imageSource: "http://qt-project.org/doc/qt-4.8/images/qml-twitter-demo-small.png" + imageSource: "http://doc.qt.io/qt-4.8/images/qml-twitter-demo-small.png" } ListElement { name: "Basic Drawing Example" description: "The Basic Drawing example shows how to display basic graphics primitives in a variety of styles using the QPainter class." - imageSource: "http://qt-project.org/doc/qt-4.8/images/basicdrawing-example.png" + imageSource: "http://doc.qt.io/qt-4.8/images/basicdrawing-example.png" } ListElement { name: "Border Layout Example" description: "The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules. The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules. The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules. The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules." - imageSource: "http://qt-project.org/doc/qt-4.8/images/borderlayout-example.png" + imageSource: "http://doc.qt.io/qt-4.8/images/borderlayout-example.png" } } diff --git a/src/libs/3rdparty/cplusplus/Bind.cpp b/src/libs/3rdparty/cplusplus/Bind.cpp index 58e3815a8f6..a0a0e1a0659 100644 --- a/src/libs/3rdparty/cplusplus/Bind.cpp +++ b/src/libs/3rdparty/cplusplus/Bind.cpp @@ -510,6 +510,24 @@ void calculateConstantValue(const Symbol *symbol, EnumeratorDeclaration *e, Cont } } +const StringLiteral *valueOfEnumerator(const Enum *e, const Identifier *value) { + const int enumMemberCount = e->memberCount(); + for (int i = 0; i < enumMemberCount; ++i) { + const Symbol *member = e->memberAt(i); + if (const Declaration *decl = member->asDeclaration()) { + if (const EnumeratorDeclaration *enumDecl = decl->asEnumeratorDeclarator()) { + if (const Name *enumDeclName = enumDecl->name()) { + if (const Identifier *enumDeclIdentifier = enumDeclName->identifier()) { + if (enumDeclIdentifier->equalTo(value)) + return enumDecl->constantValue(); + } + } + } + } + } + return 0; +} + } // anonymous namespace void Bind::enumerator(EnumeratorAST *ast, Enum *symbol) @@ -528,12 +546,21 @@ void Bind::enumerator(EnumeratorAST *ast, Enum *symbol) EnumeratorDeclaration *e = control()->newEnumeratorDeclaration(ast->identifier_token, name); e->setType(control()->integerType(IntegerType::Int)); // ### introduce IntegerType::Enumerator - if (ExpressionAST *expr = ast->expression) - e->setConstantValue(asStringLiteral(expr->firstToken(), expr->lastToken())); - else if (!symbol->isEmpty()) + if (ExpressionAST *expr = ast->expression) { + const int firstToken = expr->firstToken(); + const int lastToken = expr->lastToken(); + const StringLiteral *constantValue = asStringLiteral(firstToken, lastToken); + const StringLiteral *resolvedValue = 0; + if (lastToken - firstToken == 1) { + if (const Identifier *constantId = identifier(firstToken)) + resolvedValue = valueOfEnumerator(symbol, constantId); + } + e->setConstantValue(resolvedValue ? resolvedValue : constantValue); + } else if (!symbol->isEmpty()) { calculateConstantValue(*(symbol->memberEnd()-1), e, control()); - else + } else { e->setConstantValue(control()->stringLiteral("0", 1)); + } symbol->addMember(e); } diff --git a/src/libs/3rdparty/cplusplus/Keywords.cpp b/src/libs/3rdparty/cplusplus/Keywords.cpp index 9bce1ff3f88..ef122937ce1 100644 --- a/src/libs/3rdparty/cplusplus/Keywords.cpp +++ b/src/libs/3rdparty/cplusplus/Keywords.cpp @@ -674,7 +674,7 @@ static inline int classify7(const char *s, LanguageFeatures features) } } } - else if (features.qtEnabled && s[0] == 's') { + else if (features.qtKeywordsEnabled && s[0] == 's') { if (s[1] == 'i') { if (s[2] == 'g') { if (s[3] == 'n') { diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index 19bcd358b57..4f44d614658 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -5696,7 +5696,13 @@ bool Parser::parseDesignatedInitializer(ExpressionAST *&node) if (LA() == T_EQUAL) { ast->equal_token = consumeToken(); - if (parseAssignmentExpression(ast->initializer)) { + + if (LA() == T_LBRACE) { + if (parseBracedInitList0x(node)) { + node = ast; + return true; + } + } else if (parseAssignmentExpression(ast->initializer)) { node = ast; return true; } diff --git a/src/libs/3rdparty/cplusplus/Templates.cpp b/src/libs/3rdparty/cplusplus/Templates.cpp index c9a2c892bd6..9ebd95e2325 100644 --- a/src/libs/3rdparty/cplusplus/Templates.cpp +++ b/src/libs/3rdparty/cplusplus/Templates.cpp @@ -100,7 +100,7 @@ void CloneType::visit(NamedType *type) const Name *name = _clone->name(type->name(), _subst); FullySpecifiedType ty; if (_subst) - ty = _subst->apply(name); + ty = _clone->type(_subst->apply(name), 0); if (! ty.isValid()) ty = _control->namedType(name); _type.setType(ty.type()); diff --git a/src/libs/cplusplus/BackwardsScanner.cpp b/src/libs/cplusplus/BackwardsScanner.cpp index 9545e4c8d30..e31bfe43a01 100644 --- a/src/libs/cplusplus/BackwardsScanner.cpp +++ b/src/libs/cplusplus/BackwardsScanner.cpp @@ -38,6 +38,7 @@ using namespace CPlusPlus; BackwardsScanner::BackwardsScanner(const QTextCursor &cursor, + const LanguageFeatures &languageFeatures, int maxBlockCount, const QString &suffix, bool skipComments) @@ -46,13 +47,7 @@ BackwardsScanner::BackwardsScanner(const QTextCursor &cursor, , _block(cursor.block()) , _maxBlockCount(maxBlockCount) { - // FIXME: Why these defaults? - LanguageFeatures features; - features.qtMocRunEnabled = true; - features.qtEnabled = true; - features.qtKeywordsEnabled = true; - features.objCEnabled = true; - _tokenize.setLanguageFeatures(features); + _tokenize.setLanguageFeatures(languageFeatures); _tokenize.setSkipComments(skipComments); _text = _block.text().left(cursor.position() - cursor.block().position()); diff --git a/src/libs/cplusplus/BackwardsScanner.h b/src/libs/cplusplus/BackwardsScanner.h index dd7cfef0e58..1f08e73d3c6 100644 --- a/src/libs/cplusplus/BackwardsScanner.h +++ b/src/libs/cplusplus/BackwardsScanner.h @@ -43,10 +43,11 @@ class CPLUSPLUS_EXPORT BackwardsScanner enum { MAX_BLOCK_COUNT = 10 }; public: - explicit BackwardsScanner(const QTextCursor &cursor, - int maxBlockCount = MAX_BLOCK_COUNT, - const QString &suffix = QString(), - bool skipComments = true); + BackwardsScanner(const QTextCursor &cursor, + const LanguageFeatures &languageFeatures, + int maxBlockCount = MAX_BLOCK_COUNT, + const QString &suffix = QString(), + bool skipComments = true); int startToken() const; diff --git a/src/libs/cplusplus/ExpressionUnderCursor.cpp b/src/libs/cplusplus/ExpressionUnderCursor.cpp index e1de7261c29..1181fa37c72 100644 --- a/src/libs/cplusplus/ExpressionUnderCursor.cpp +++ b/src/libs/cplusplus/ExpressionUnderCursor.cpp @@ -40,8 +40,9 @@ using namespace CPlusPlus; -ExpressionUnderCursor::ExpressionUnderCursor() +ExpressionUnderCursor::ExpressionUnderCursor(const LanguageFeatures &languageFeatures) : _jumpedComma(false) + , _languageFeatures(languageFeatures) { } int ExpressionUnderCursor::startOfExpression(BackwardsScanner &tk, int index) @@ -243,7 +244,7 @@ bool ExpressionUnderCursor::isAccessToken(const Token &tk) QString ExpressionUnderCursor::operator()(const QTextCursor &cursor) { - BackwardsScanner scanner(cursor); + BackwardsScanner scanner(cursor, _languageFeatures); _jumpedComma = false; @@ -257,7 +258,7 @@ QString ExpressionUnderCursor::operator()(const QTextCursor &cursor) int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor) const { - BackwardsScanner scanner(cursor); + BackwardsScanner scanner(cursor, _languageFeatures); int index = scanner.startToken(); diff --git a/src/libs/cplusplus/ExpressionUnderCursor.h b/src/libs/cplusplus/ExpressionUnderCursor.h index 8d7ef0419d2..375fc6cfa9e 100644 --- a/src/libs/cplusplus/ExpressionUnderCursor.h +++ b/src/libs/cplusplus/ExpressionUnderCursor.h @@ -32,6 +32,7 @@ #define CPLUSPLUS_EXPRESSIONUNDERCURSOR_H #include +#include #include @@ -47,7 +48,7 @@ class BackwardsScanner; class CPLUSPLUS_EXPORT ExpressionUnderCursor { public: - ExpressionUnderCursor(); + ExpressionUnderCursor(const LanguageFeatures &languageFeatures); QString operator()(const QTextCursor &cursor); int startOfFunctionCall(const QTextCursor &cursor) const; @@ -59,6 +60,7 @@ private: private: bool _jumpedComma; + LanguageFeatures _languageFeatures; }; } // namespace CPlusPlus diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index a844414fc07..512700c016a 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -324,7 +324,7 @@ ClassOrNamespace *LookupContext::globalNamespace() const } ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope, - ClassOrNamespace* enclosingTemplateInstantiation, + ClassOrNamespace *enclosingBinding, QSet typedefsBeingResolved) const { if (! scope || ! name) { @@ -367,7 +367,7 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope, } // try to find it in block (rare case but has priority before enclosing scope) // e.g.: void foo() { struct S {}; S s; } - if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingTemplateInstantiation)) { + if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingBinding)) { if (ClassOrNamespace *classOrNamespaceNestedInNestedBlock = b->lookupType(name, block)) return classOrNamespaceNestedInNestedBlock; } @@ -376,13 +376,13 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope, if (ClassOrNamespace *found = lookupType(name, scope->enclosingScope())) return found; - } else if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingTemplateInstantiation)) { + } else if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingBinding)) { return b->lookupType(name); } else if (Class *scopeAsClass = scope->asClass()) { if (scopeAsClass->enclosingScope()->isBlock()) { if (ClassOrNamespace *b = lookupType(scopeAsClass->name(), scopeAsClass->enclosingScope(), - enclosingTemplateInstantiation, + enclosingBinding, typedefsBeingResolved)) { return b->lookupType(name); } @@ -393,9 +393,9 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope, } ClassOrNamespace *LookupContext::lookupType(Symbol *symbol, - ClassOrNamespace* enclosingTemplateInstantiation) const + ClassOrNamespace *enclosingBinding) const { - return bindings()->lookupType(symbol, enclosingTemplateInstantiation); + return bindings()->lookupType(symbol, enclosingBinding); } QList LookupContext::lookup(const Name *name, Scope *scope) const @@ -1521,19 +1521,20 @@ ClassOrNamespace *CreateBindings::globalNamespace() const return _globalNamespace; } -ClassOrNamespace *CreateBindings::lookupType(Symbol *symbol, ClassOrNamespace* enclosingTemplateInstantiation) +ClassOrNamespace *CreateBindings::lookupType(Symbol *symbol, ClassOrNamespace *enclosingBinding) { const QList path = LookupContext::path(symbol); - return lookupType(path, enclosingTemplateInstantiation); + return lookupType(path, enclosingBinding); } -ClassOrNamespace *CreateBindings::lookupType(const QList &path, ClassOrNamespace* enclosingTemplateInstantiation) +ClassOrNamespace *CreateBindings::lookupType(const QList &path, + ClassOrNamespace *enclosingBinding) { if (path.isEmpty()) return _globalNamespace; - if (enclosingTemplateInstantiation) { - if (ClassOrNamespace *b = enclosingTemplateInstantiation->lookupType(path.last())) + if (enclosingBinding) { + if (ClassOrNamespace *b = enclosingBinding->lookupType(path.last())) return b; } diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h index dbee30afabf..7a75cf9c8f7 100644 --- a/src/libs/cplusplus/LookupContext.h +++ b/src/libs/cplusplus/LookupContext.h @@ -202,10 +202,9 @@ public: ClassOrNamespace *globalNamespace() const; /// Finds the binding associated to the given symbol. - ClassOrNamespace *lookupType(Symbol *symbol, - ClassOrNamespace* enclosingTemplateInstantiation = 0); + ClassOrNamespace *lookupType(Symbol *symbol, ClassOrNamespace *enclosingBinding = 0); ClassOrNamespace *lookupType(const QList &path, - ClassOrNamespace* enclosingTemplateInstantiation = 0); + ClassOrNamespace *enclosingBinding = 0); /// Returns the Control that must be used to create temporary symbols. /// \internal @@ -310,11 +309,11 @@ public: QList lookup(const Name *name, Scope *scope) const; ClassOrNamespace *lookupType(const Name *name, Scope *scope, - ClassOrNamespace* enclosingTemplateInstantiation = 0, + ClassOrNamespace *enclosingBinding = 0, QSet typedefsBeingResolved = QSet()) const; ClassOrNamespace *lookupType(Symbol *symbol, - ClassOrNamespace* enclosingTemplateInstantiation = 0) const; + ClassOrNamespace *enclosingBinding = 0) const; ClassOrNamespace *lookupParent(Symbol *symbol) const; /// \internal diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp index ade49c19aa1..7b354b76d41 100644 --- a/src/libs/cplusplus/MatchingText.cpp +++ b/src/libs/cplusplus/MatchingText.cpp @@ -154,7 +154,8 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri if (text.isEmpty() || !shouldInsertMatchingText(la)) return QString(); - BackwardsScanner tk(tc, MAX_NUM_LINES, textToProcess.left(*skippedChars)); + BackwardsScanner tk(tc, LanguageFeatures::defaultFeatures(), MAX_NUM_LINES, + textToProcess.left(*skippedChars)); const int startToken = tk.startToken(); int index = startToken; @@ -215,7 +216,7 @@ static bool shouldInsertNewline(const QTextCursor &tc) QString MatchingText::insertParagraphSeparator(const QTextCursor &tc) { - BackwardsScanner tk(tc, MAX_NUM_LINES); + BackwardsScanner tk(tc, LanguageFeatures::defaultFeatures(), MAX_NUM_LINES); int index = tk.startToken(); if (tk[index - 1].isNot(T_LBRACE)) diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index c1a277f74e3..adaac12ab5f 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -612,7 +612,7 @@ bool ResolveExpression::visit(UnaryExpressionAST *ast) added = true; } else if (namedTy != 0) { const Name *starOp = control()->operatorNameId(OperatorNameId::StarOp); - if (ClassOrNamespace *b = _context.lookupType(namedTy->name(), p.scope())) { + if (ClassOrNamespace *b = _context.lookupType(namedTy->name(), p.scope(), p.binding())) { foreach (const LookupItem &r, b->find(starOp)) { Symbol *overload = r.declaration(); if (Function *funTy = overload->type()->asFunctionType()) { @@ -730,6 +730,7 @@ bool ResolveExpression::visit(SimpleNameAST *ast) continue; TypeOfExpression exprTyper; + exprTyper.setExpandTemplates(true); Document::Ptr doc = _context.snapshot().document(QString::fromLocal8Bit(decl->fileName())); exprTyper.init(doc, _context.snapshot(), _context.bindings(), QSet(_autoDeclarationsBeingResolved) << decl); @@ -754,10 +755,12 @@ bool ResolveExpression::visit(SimpleNameAST *ast) if (n == 0) { item.setType(newType); item.setScope(typeItems[n].scope()); + item.setBinding(typeItems[n].binding()); } else { LookupItem newItem(item); newItem.setType(newType); newItem.setScope(typeItems[n].scope()); + newItem.setBinding(typeItems[n].binding()); newCandidates.push_back(newItem); } } @@ -1015,20 +1018,20 @@ bool ResolveExpression::visit(MemberAccessAST *ast) } ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &originalTy, Scope *scope, - ClassOrNamespace* enclosingTemplateInstantiation) const + ClassOrNamespace *enclosingBinding) const { FullySpecifiedType ty = originalTy.simplified(); ClassOrNamespace *binding = 0; if (Class *klass = ty->asClassType()) { if (scope->isBlock()) - binding = _context.lookupType(klass->name(), scope, enclosingTemplateInstantiation); + binding = _context.lookupType(klass->name(), scope, enclosingBinding); if (!binding) - binding = _context.lookupType(klass, enclosingTemplateInstantiation); + binding = _context.lookupType(klass, enclosingBinding); } else if (NamedType *namedTy = ty->asNamedType()) - binding = _context.lookupType(namedTy->name(), scope, enclosingTemplateInstantiation); + binding = _context.lookupType(namedTy->name(), scope, enclosingBinding); else if (Function *funTy = ty->asFunctionType()) return findClass(funTy->returnType(), scope); @@ -1078,8 +1081,9 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList &bas ClassOrNamespace *binding = findClassForTemplateParameterInExpressionScope(r.binding(), ty); + if (! binding) - binding = findClass(ty, scope); + binding = findClass(ty, scope, r.binding()); if (binding){ // lookup for overloads of operator-> @@ -1145,13 +1149,13 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList &bas return binding; } - ClassOrNamespace *enclosingTemplateInstantiation = 0; + ClassOrNamespace *enclosingBinding = 0; if (ClassOrNamespace *binding = r.binding()) { if (binding->instantiationOrigin()) - enclosingTemplateInstantiation = binding; + enclosingBinding = binding; } - if (ClassOrNamespace *binding = findClass(ty, scope, enclosingTemplateInstantiation)) + if (ClassOrNamespace *binding = findClass(ty, scope, enclosingBinding)) return binding; } } diff --git a/src/libs/cplusplus/ResolveExpression.h b/src/libs/cplusplus/ResolveExpression.h index e21a207aeb4..aee53c40fae 100644 --- a/src/libs/cplusplus/ResolveExpression.h +++ b/src/libs/cplusplus/ResolveExpression.h @@ -61,7 +61,7 @@ public: protected: ClassOrNamespace *findClass(const FullySpecifiedType &ty, Scope *scope, - ClassOrNamespace* enclosingTemplateInstantiation = 0) const; + ClassOrNamespace *enclosingBinding = 0) const; QList expression(ExpressionAST *ast); diff --git a/src/libs/cplusplus/SimpleLexer.cpp b/src/libs/cplusplus/SimpleLexer.cpp index ff2a5f6468c..373441198c6 100644 --- a/src/libs/cplusplus/SimpleLexer.cpp +++ b/src/libs/cplusplus/SimpleLexer.cpp @@ -129,17 +129,10 @@ int SimpleLexer::tokenAt(const Tokens &tokens, unsigned utf16charsOffset) Token SimpleLexer::tokenAt(const QString &text, unsigned utf16charsOffset, int state, - bool qtMocRunEnabled) + const LanguageFeatures &languageFeatures) { - // FIXME: Check default values. - LanguageFeatures features; - features.qtMocRunEnabled = qtMocRunEnabled; - features.qtEnabled = qtMocRunEnabled; - features.qtKeywordsEnabled = qtMocRunEnabled; - features.objCEnabled = qtMocRunEnabled; - features.cxx11Enabled = qtMocRunEnabled; SimpleLexer tokenize; - tokenize.setLanguageFeatures(features); + tokenize.setLanguageFeatures(languageFeatures); const QVector tokens = tokenize(text, state); const int tokenIdx = tokenAt(tokens, utf16charsOffset); return (tokenIdx == -1) ? Token() : tokens.at(tokenIdx); diff --git a/src/libs/cplusplus/SimpleLexer.h b/src/libs/cplusplus/SimpleLexer.h index ef7fcbf0bdb..bf153eb211b 100644 --- a/src/libs/cplusplus/SimpleLexer.h +++ b/src/libs/cplusplus/SimpleLexer.h @@ -68,7 +68,7 @@ public: static Token tokenAt(const QString &text, unsigned utf16charsOffset, int state, - bool qtMocRunEnabled = false); + const LanguageFeatures &languageFeatures); static int tokenBefore(const Tokens &tokens, unsigned utf16charsOffset); diff --git a/src/libs/timeline/timelineselectionrenderpass.cpp b/src/libs/timeline/timelineselectionrenderpass.cpp index 6fbe69d3012..dbf33a8b070 100644 --- a/src/libs/timeline/timelineselectionrenderpass.cpp +++ b/src/libs/timeline/timelineselectionrenderpass.cpp @@ -103,8 +103,8 @@ TimelineRenderPass::State *TimelineSelectionRenderPass::update( // left and width the error on the left border is inherited by the right border. Like this // they're independent. - QRectF outer(QPointF(qFloor(left * parentState->scale()), top), - QPointF(qCeil(right * parentState->scale()), top + height)); + QRectF outer(QPointF(left * parentState->scale(), top), + QPointF(right * parentState->scale(), top + height)); float scaleConversion = parentState->scale() / spacing; float missing = 3.0 - outer.width() / scaleConversion; diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 2c8baf56249..9979f2d6a6d 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -548,9 +548,9 @@ QFileInfo FileName::toFileInfo() const } /// \returns a QString for passing on to QString based APIs -QString FileName::toString() const +const QString &FileName::toString() const { - return QString(*this); + return *this; } /// \returns a QString to display to the user diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index 1ffea746a70..920bbc70afe 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -71,7 +71,7 @@ public: static FileName fromLatin1(const QByteArray &filename); static FileName fromUserInput(const QString &filename); static FileName fromUtf8(const char *filename, int filenameSize = -1); - QString toString() const; + const QString &toString() const; QString toUserOutput() const; QString fileName(int pathComponents = 0) const; bool exists() const; diff --git a/src/libs/utils/mimetypes/mimedatabase.cpp b/src/libs/utils/mimetypes/mimedatabase.cpp index 47146553512..39f3cf7a2a9 100644 --- a/src/libs/utils/mimetypes/mimedatabase.cpp +++ b/src/libs/utils/mimetypes/mimedatabase.cpp @@ -175,12 +175,16 @@ MimeType MimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileName // Extension is unknown, or matches multiple mimetypes. // Pass 2) Match on content, if we can read the data + const bool openedByUs = !device->isOpen() && device->open(QIODevice::ReadOnly); if (device->isOpen()) { // Read 16K in one go (QIODEVICE_BUFFERSIZE in qiodevice_p.h). // This is much faster than seeking back and forth into QIODevice. const QByteArray data = device->peek(16384); + if (openedByUs) + device->close(); + int magicAccuracy = 0; MimeType candidateByData(findByData(data, &magicAccuracy)); @@ -319,8 +323,11 @@ QString MimeDatabase::allFiltersString(QString *allFilesFilter) { MimeDatabase mdb; QSet uniqueFilters; - foreach (const MimeType &mt, mdb.allMimeTypes()) - uniqueFilters.insert(mt.filterString()); + foreach (const MimeType &mt, mdb.allMimeTypes()) { + const QString &filterString = mt.filterString(); + if (!filterString.isEmpty()) + uniqueFilters.insert(mt.filterString()); + } QStringList filters; foreach (const QString &filter, uniqueFilters) filters.append(filter); @@ -345,79 +352,6 @@ QStringList MimeDatabase::allGlobPatterns() return patterns; } -static MimeType mimeForName(const QList &types, const QString &name) -{ - foreach (const MimeType &mt, types) - if (mt.matchesName(name)) - return mt; - return MimeType(); -} - -MimeType MimeDatabase::bestMatch(const QString &fileName, const QList &types) -{ - // Copied together from mimeTypeForFile(QFileInfo) code path ... - // It would be better to be able to work on a list of mime types directly - - // Check for directory. We just ignore the code path for special unix nodes. - if (fileName.endsWith(QLatin1Char('/'))) - return mimeForName(types, QLatin1String("inode/directory")); - - auto d = MimeDatabasePrivate::instance(); - QMutexLocker locker(&d->mutex); - - QStringList candidatesByName = d->provider()->bestMatchByFileName(QFileInfo(fileName).fileName(), - types); - if (candidatesByName.count() == 1) { - MimeType mt = mimeForName(types, candidatesByName.first()); - if (mt.isValid()) - return mt; - candidatesByName.clear(); - } - // Extension is unknown, or matches multiple mimetypes. - // Pass 2) Match on content, if we can read the data - QFile file(QFileInfo(fileName).absoluteFilePath()); - file.open(QIODevice::ReadOnly); - if (file.isOpen()) { - // Read 16K in one go (QIODEVICE_BUFFERSIZE in qiodevice_p.h). - // This is much faster than seeking back and forth into QIODevice. - const QByteArray data = file.peek(16384); - - int magicAccuracy = 0; - MimeType candidateByData; - if (data.isEmpty()) { - magicAccuracy = 100; - candidateByData = mimeForName(types, QLatin1String("application/x-zerosize")); - } else { - candidateByData = d->provider()->bestMatchByMagic(data, types, &magicAccuracy); - if (!candidateByData.isValid()) { - if (isTextFile(data)) { - magicAccuracy = 5; - candidateByData = mimeForName(types, QLatin1String("text/plain")); - } - } - } - // Disambiguate conflicting extensions (if magic matching found something) - if (candidateByData.isValid() && magicAccuracy > 0) { - // "for glob_match in glob_matches:" - // "if glob_match is subclass or equal to sniffed_type, use glob_match" - const QString sniffedMime = candidateByData.name(); - foreach (const QString &m, candidatesByName) { - if (d->inherits(m, sniffedMime)) { - // We have magic + pattern pointing to this, so it's a pretty good match - return mimeForName(types, m); - } - } - return candidateByData; - } - } - - if (candidatesByName.count() > 1) { - candidatesByName.sort(); - return mimeForName(types, candidatesByName.first()); - } - return MimeType(); -} - /*! \fn MimeType MimeDatabase::mimeTypeForName(const QString &nameOrAlias) const; Returns a MIME type for \a nameOrAlias or an invalid one if none found. @@ -485,7 +419,6 @@ MimeType MimeDatabase::mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode int priority = 0; switch (mode) { case MatchDefault: - file.open(QIODevice::ReadOnly); // isOpen() will be tested by method below return d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority); case MatchExtension: locker.unlock(); @@ -655,10 +588,7 @@ MimeType MimeDatabase::mimeTypeForUrl(const QUrl &url) const MimeType MimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device) const { int accuracy = 0; - const bool openedByUs = !device->isOpen() && device->open(QIODevice::ReadOnly); const MimeType result = d->mimeTypeForFileNameAndData(fileName, device, &accuracy); - if (openedByUs) - device->close(); return result; } diff --git a/src/libs/utils/mimetypes/mimedatabase.h b/src/libs/utils/mimetypes/mimedatabase.h index f894933f769..246a82cec12 100644 --- a/src/libs/utils/mimetypes/mimedatabase.h +++ b/src/libs/utils/mimetypes/mimedatabase.h @@ -87,7 +87,6 @@ public: static void addMimeTypes(const QString &fileName); static QString allFiltersString(QString *allFilesFilter = 0); static QStringList allGlobPatterns(); - static MimeType bestMatch(const QString &fileName, const QList &types); static QMap > magicRulesForMimeType(const MimeType &mimeType); // priority -> rules static void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns); static void setMagicRulesForMimeType(const MimeType &mimeType, diff --git a/src/libs/utils/mimetypes/mimeprovider.cpp b/src/libs/utils/mimetypes/mimeprovider.cpp index a27cd11ea7b..45a081ad206 100644 --- a/src/libs/utils/mimetypes/mimeprovider.cpp +++ b/src/libs/utils/mimetypes/mimeprovider.cpp @@ -719,38 +719,6 @@ QStringList MimeXMLProvider::findByFileName(const QString &fileName, QString *fo return matchingMimeTypes; } -QStringList MimeXMLProvider::bestMatchByFileName(const QString &fileName, const QList &types) -{ - ensureLoaded(); - - // this is slow :( - // this would be much better if MimeType had references to their globs & magics - MimeAllGlobPatterns globs; - // fast patterns are fast (hash lookup), no need to reduce that set - globs.m_fastPatterns = m_mimeTypeGlobs.m_fastPatterns; - // fill highWeight and lowWeight glob lists - QSet names; - foreach (const MimeType &mt, types) - names.insert(mt.name()); - foreach (const MimeGlobPattern &pattern, m_mimeTypeGlobs.m_highWeightGlobs) { - if (names.contains(pattern.mimeType())) - globs.m_highWeightGlobs.append(pattern); - } - foreach (const MimeGlobPattern &pattern, m_mimeTypeGlobs.m_lowWeightGlobs) { - if (names.contains(pattern.mimeType())) - globs.m_lowWeightGlobs.append(pattern); - } - QString foundSuffix; - const QStringList matchingMimeTypes = globs.matchingGlobs(fileName, &foundSuffix); - // result can still contain types that are not in our list, because of the fast patterns - QStringList result; - foreach (const QString &match, matchingMimeTypes) { - if (names.contains(match)) - result.append(match); - } - return result; -} - MimeType MimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr) { ensureLoaded(); @@ -769,30 +737,6 @@ MimeType MimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr) return mimeTypeForName(candidate); } -MimeType MimeXMLProvider::bestMatchByMagic(const QByteArray &data, const QList &types, int *accuracyPtr) -{ - ensureLoaded(); - - QSet names; - foreach (const MimeType &mt, types) - names.insert(mt.name()); - - QString candidate; - - foreach (const MimeMagicRuleMatcher &matcher, m_magicMatchers) { - if (!names.contains(matcher.mimetype())) - continue; - if (matcher.matches(data)) { - const int priority = matcher.priority(); - if (priority > *accuracyPtr) { - *accuracyPtr = priority; - candidate = matcher.mimetype(); - } - } - } - return mimeTypeForName(candidate); -} - QMap > MimeXMLProvider::magicRulesForMimeType(const MimeType &mimeType) { QMap > result; diff --git a/src/libs/utils/mimetypes/mimeprovider_p.h b/src/libs/utils/mimetypes/mimeprovider_p.h index 9a375a018dd..eee3737d4da 100644 --- a/src/libs/utils/mimetypes/mimeprovider_p.h +++ b/src/libs/utils/mimetypes/mimeprovider_p.h @@ -75,8 +75,6 @@ public: virtual void loadGenericIcon(MimeTypePrivate &) {} // Qt Creator additions - virtual QStringList bestMatchByFileName(const QString &fileName, const QList &types) = 0; - virtual MimeType bestMatchByMagic(const QByteArray &data, const QList &types, int *accuracyPtr) = 0; virtual QMap > magicRulesForMimeType(const MimeType &mimeType) = 0; virtual void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns) = 0; virtual void setMagicRulesForMimeType(const MimeType &mimeType, const QMap > &rules) = 0; @@ -158,8 +156,6 @@ public: // Qt Creator additions void addFile(const QString &filePath); - QStringList bestMatchByFileName(const QString &fileName, const QList &types); - MimeType bestMatchByMagic(const QByteArray &data, const QList &types, int *accuracyPtr); QMap > magicRulesForMimeType(const MimeType &mimeType); void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns); void setMagicRulesForMimeType(const MimeType &mimeType, const QMap > &rules); diff --git a/src/libs/utils/mimetypes/mimetype.cpp b/src/libs/utils/mimetypes/mimetype.cpp index ccaee2b6cd1..da76b8b1dff 100644 --- a/src/libs/utils/mimetypes/mimetype.cpp +++ b/src/libs/utils/mimetypes/mimetype.cpp @@ -432,7 +432,9 @@ QString MimeType::filterString() const bool MimeType::matchesName(const QString &nameOrAlias) const { - return d->name == nameOrAlias || aliases().contains(nameOrAlias); + if (d->name == nameOrAlias) + return true; + return MimeDatabasePrivate::instance()->provider()->resolveAlias(nameOrAlias) == d->name; } void MimeType::setPreferredSuffix(const QString &suffix) diff --git a/src/libs/utils/mimetypes/mimetypes.pri b/src/libs/utils/mimetypes/mimetypes.pri index dfa5bfe03a4..87b704e6bf2 100644 --- a/src/libs/utils/mimetypes/mimetypes.pri +++ b/src/libs/utils/mimetypes/mimetypes.pri @@ -20,3 +20,4 @@ SOURCES += \ $$PWD/mimeglobpattern.cpp \ $$PWD/mimeprovider.cpp +OTHER_FILES += $$[QT_HOST_DATA/src]/src/corelib/mimetypes/mime/packages/freedesktop.org.xml diff --git a/src/libs/utils/outputformatter.cpp b/src/libs/utils/outputformatter.cpp index 2235802bab3..d9a70f3040e 100644 --- a/src/libs/utils/outputformatter.cpp +++ b/src/libs/utils/outputformatter.cpp @@ -33,86 +33,101 @@ #include "theme/theme.h" #include +#include -using namespace Utils; +namespace Utils { + +namespace Internal { + +class OutputFormatterPrivate +{ +public: + OutputFormatterPrivate() + : plainTextEdit(0), overwriteOutput(false) + {} + + QPlainTextEdit *plainTextEdit; + QTextCharFormat formats[NumberOfFormats]; + QFont font; + QTextCursor cursor; + AnsiEscapeCodeHandler escapeCodeHandler; + bool overwriteOutput; +}; + +} // namespace Internal OutputFormatter::OutputFormatter() - : QObject() - , m_plainTextEdit(0) - , m_formats(0) - , m_escapeCodeHandler(new AnsiEscapeCodeHandler) - , m_overwriteOutput(false) + : d(new Internal::OutputFormatterPrivate) { - } OutputFormatter::~OutputFormatter() { - delete[] m_formats; - delete m_escapeCodeHandler; + delete d; } QPlainTextEdit *OutputFormatter::plainTextEdit() const { - return m_plainTextEdit; + return d->plainTextEdit; } void OutputFormatter::setPlainTextEdit(QPlainTextEdit *plainText) { - m_plainTextEdit = plainText; + d->plainTextEdit = plainText; + d->cursor = plainText ? plainText->textCursor() : QTextCursor(); initFormats(); } void OutputFormatter::appendMessage(const QString &text, OutputFormat format) { - appendMessage(text, m_formats[format]); + appendMessage(text, d->formats[format]); } void OutputFormatter::appendMessage(const QString &text, const QTextCharFormat &format) { - QTextCursor cursor(m_plainTextEdit->document()); - cursor.movePosition(QTextCursor::End); + if (!d->cursor.atEnd()) + d->cursor.movePosition(QTextCursor::End); foreach (const FormattedText &output, parseAnsi(text, format)) { int startPos = 0; int crPos = -1; while ((crPos = output.text.indexOf(QLatin1Char('\r'), startPos)) >= 0) { - append(cursor, output.text.mid(startPos, crPos - startPos), output.format); + append(d->cursor, output.text.mid(startPos, crPos - startPos), output.format); startPos = crPos + 1; - m_overwriteOutput = true; + d->overwriteOutput = true; } if (startPos < output.text.count()) - append(cursor, output.text.mid(startPos), output.format); + append(d->cursor, output.text.mid(startPos), output.format); } } QTextCharFormat OutputFormatter::charFormat(OutputFormat format) const { - return m_formats[format]; + return d->formats[format]; } QList OutputFormatter::parseAnsi(const QString &text, const QTextCharFormat &format) { - return m_escapeCodeHandler->parseText(FormattedText(text, format)); + return d->escapeCodeHandler.parseText(FormattedText(text, format)); } void OutputFormatter::append(QTextCursor &cursor, const QString &text, const QTextCharFormat &format) { - if (m_overwriteOutput) { + if (d->overwriteOutput) { cursor.clearSelection(); cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); - m_overwriteOutput = false; + d->overwriteOutput = false; } cursor.insertText(text, format); } void OutputFormatter::clearLastLine() { - QTextCursor cursor(m_plainTextEdit->document()); - cursor.movePosition(QTextCursor::End); - cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); - cursor.removeSelectedText(); + if (!d->cursor.atEnd()) + d->cursor.movePosition(QTextCursor::End); + d->cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); + d->cursor.removeSelectedText(); } void OutputFormatter::initFormats() @@ -120,33 +135,31 @@ void OutputFormatter::initFormats() if (!plainTextEdit()) return; - QFont boldFont = m_font; + QFont boldFont = d->font; boldFont.setBold(true); - m_formats = new QTextCharFormat[NumberOfFormats]; - Theme *theme = creatorTheme(); // NormalMessageFormat - m_formats[NormalMessageFormat].setFont(boldFont); - m_formats[NormalMessageFormat].setForeground(theme->color(Theme::OutputFormatter_NormalMessageTextColor)); + d->formats[NormalMessageFormat].setFont(boldFont); + d->formats[NormalMessageFormat].setForeground(theme->color(Theme::OutputFormatter_NormalMessageTextColor)); // ErrorMessageFormat - m_formats[ErrorMessageFormat].setFont(boldFont); - m_formats[ErrorMessageFormat].setForeground(theme->color(Theme::OutputFormatter_ErrorMessageTextColor)); + d->formats[ErrorMessageFormat].setFont(boldFont); + d->formats[ErrorMessageFormat].setForeground(theme->color(Theme::OutputFormatter_ErrorMessageTextColor)); // StdOutFormat - m_formats[StdOutFormat].setFont(m_font); - m_formats[StdOutFormat].setForeground(theme->color(Theme::OutputFormatter_StdOutTextColor)); - m_formats[StdOutFormatSameLine] = m_formats[StdOutFormat]; + d->formats[StdOutFormat].setFont(d->font); + d->formats[StdOutFormat].setForeground(theme->color(Theme::OutputFormatter_StdOutTextColor)); + d->formats[StdOutFormatSameLine] = d->formats[StdOutFormat]; // StdErrFormat - m_formats[StdErrFormat].setFont(m_font); - m_formats[StdErrFormat].setForeground(theme->color(Theme::OutputFormatter_StdErrTextColor)); - m_formats[StdErrFormatSameLine] = m_formats[StdErrFormat]; + d->formats[StdErrFormat].setFont(d->font); + d->formats[StdErrFormat].setForeground(theme->color(Theme::OutputFormatter_StdErrTextColor)); + d->formats[StdErrFormatSameLine] = d->formats[StdErrFormat]; - m_formats[DebugFormat].setFont(m_font); - m_formats[DebugFormat].setForeground(theme->color(Theme::OutputFormatter_DebugTextColor)); + d->formats[DebugFormat].setFont(d->font); + d->formats[DebugFormat].setForeground(theme->color(Theme::OutputFormatter_DebugTextColor)); } void OutputFormatter::handleLink(const QString &href) @@ -156,16 +169,18 @@ void OutputFormatter::handleLink(const QString &href) QFont OutputFormatter::font() const { - return m_font; + return d->font; } void OutputFormatter::setFont(const QFont &font) { - m_font = font; + d->font = font; initFormats(); } void OutputFormatter::flush() { - m_escapeCodeHandler->endFormatScope(); + d->escapeCodeHandler.endFormatScope(); } + +} // namespace Utils diff --git a/src/libs/utils/outputformatter.h b/src/libs/utils/outputformatter.h index 503e73ab73a..eccaf7dce0e 100644 --- a/src/libs/utils/outputformatter.h +++ b/src/libs/utils/outputformatter.h @@ -38,7 +38,6 @@ #include QT_BEGIN_NAMESPACE -class QColor; class QPlainTextEdit; class QTextCharFormat; class QTextCursor; @@ -46,9 +45,10 @@ QT_END_NAMESPACE namespace Utils { -class AnsiEscapeCodeHandler; class FormattedText; +namespace Internal { class OutputFormatterPrivate; } + class QTCREATOR_UTILS_EXPORT OutputFormatter : public QObject { Q_OBJECT @@ -58,7 +58,7 @@ public: virtual ~OutputFormatter(); QPlainTextEdit *plainTextEdit() const; - void setPlainTextEdit(QPlainTextEdit *plainText); + virtual void setPlainTextEdit(QPlainTextEdit *plainText); QFont font() const; void setFont(const QFont &font); @@ -76,11 +76,7 @@ protected: void append(QTextCursor &cursor, const QString &text, const QTextCharFormat &format); private: - QPlainTextEdit *m_plainTextEdit; - QTextCharFormat *m_formats; - QFont m_font; - AnsiEscapeCodeHandler *m_escapeCodeHandler; - bool m_overwriteOutput; + Internal::OutputFormatterPrivate *d; }; } // namespace Utils diff --git a/src/libs/utils/theme/theme.cpp b/src/libs/utils/theme/theme.cpp index 1097b3d7ff2..bd8ee7e4d1f 100644 --- a/src/libs/utils/theme/theme.cpp +++ b/src/libs/utils/theme/theme.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include namespace Utils { diff --git a/src/libs/utils/theme/theme.h b/src/libs/utils/theme/theme.h index aaf27e73bb2..4f63f28c963 100644 --- a/src/libs/utils/theme/theme.h +++ b/src/libs/utils/theme/theme.h @@ -33,11 +33,11 @@ #include "../utils_global.h" -#include -#include -#include +#include // QGradientStops +#include QT_FORWARD_DECLARE_CLASS(QSettings) +QT_FORWARD_DECLARE_CLASS(QPalette) namespace Utils { diff --git a/src/libs/utils/tooltip/tooltip.h b/src/libs/utils/tooltip/tooltip.h index b95d3a32060..aae78da3b55 100644 --- a/src/libs/utils/tooltip/tooltip.h +++ b/src/libs/utils/tooltip/tooltip.h @@ -37,7 +37,6 @@ #include #include #include -#include /* * In its current form QToolTip is not extensible. So this is an attempt to provide a more diff --git a/src/plugins/analyzerbase/analyzermanager.cpp b/src/plugins/analyzerbase/analyzermanager.cpp index d8ed89bf878..4db3caedee7 100644 --- a/src/plugins/analyzerbase/analyzermanager.cpp +++ b/src/plugins/analyzerbase/analyzermanager.cpp @@ -52,6 +52,7 @@ #include #include +#include #include #include #include @@ -93,8 +94,6 @@ const char INITIAL_DOCK_AREA[] = "initial_dock_area"; class AnalyzerMode : public IMode { - Q_OBJECT - public: AnalyzerMode(QObject *parent = 0) : IMode(parent) @@ -123,8 +122,6 @@ public: class AnalyzerManagerPrivate : public QObject { - Q_OBJECT - public: typedef QHash FancyMainWindowSettings; @@ -154,7 +151,7 @@ public: void saveToolSettings(Id toolId); void loadToolSettings(Id toolId); void startTool(); - void selectToolboxAction(int); + void selectToolboxAction(const QString &item); void modeChanged(IMode *mode); void resetLayout(); void updateRunActions(); @@ -180,6 +177,9 @@ public: // list of dock widgets to prevent memory leak typedef QPointer DockPtr; QList m_dockWidgets; + +private: + void rebuildToolBox(); }; AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq): @@ -196,7 +196,7 @@ AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq): m_statusLabel(new StatusLabel) { m_toolBox->setObjectName(QLatin1String("AnalyzerManagerToolBox")); - connect(m_toolBox, static_cast(&QComboBox::activated), + connect(m_toolBox, static_cast(&QComboBox::activated), this, &AnalyzerManagerPrivate::selectToolboxAction); setupActions(); @@ -217,7 +217,6 @@ AnalyzerManagerPrivate::~AnalyzerManagerPrivate() void AnalyzerManagerPrivate::setupActions() { - const Context globalcontext(C_GLOBAL); Command *command = 0; // Menus @@ -236,18 +235,18 @@ void AnalyzerManagerPrivate::setupActions() m_startAction = new QAction(tr("Start"), m_menu); m_startAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_START_ICON))); - ActionManager::registerAction(m_startAction, "Analyzer.Start", globalcontext); + ActionManager::registerAction(m_startAction, "Analyzer.Start"); connect(m_startAction, &QAction::triggered, this, &AnalyzerManagerPrivate::startTool); m_stopAction = new QAction(tr("Stop"), m_menu); m_stopAction->setEnabled(false); m_stopAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_STOP_ICON))); - command = ActionManager::registerAction(m_stopAction, "Analyzer.Stop", globalcontext); + command = ActionManager::registerAction(m_stopAction, "Analyzer.Stop"); m_menu->addAction(command, G_ANALYZER_CONTROL); - m_menu->addSeparator(globalcontext, G_ANALYZER_TOOLS); - m_menu->addSeparator(globalcontext, G_ANALYZER_REMOTE_TOOLS); - m_menu->addSeparator(globalcontext, G_ANALYZER_OPTIONS); + m_menu->addSeparator(G_ANALYZER_TOOLS); + m_menu->addSeparator(G_ANALYZER_REMOTE_TOOLS); + m_menu->addSeparator(G_ANALYZER_OPTIONS); } void AnalyzerManagerPrivate::delayedInit() @@ -378,12 +377,10 @@ void AnalyzerManagerPrivate::activateDock(Qt::DockWidgetArea area, QDockWidget * dockWidget->setParent(m_mainWindow); m_mainWindow->addDockWidget(area, dockWidget); - Context globalContext(C_GLOBAL); - QAction *toggleViewAction = dockWidget->toggleViewAction(); toggleViewAction->setText(dockWidget->windowTitle()); Command *cmd = ActionManager::registerAction(toggleViewAction, - Id("Analyzer.").withSuffix(dockWidget->objectName()), globalContext); + Id("Analyzer.").withSuffix(dockWidget->objectName())); cmd->setAttribute(Command::CA_Hide); ActionContainer *viewsMenu = ActionManager::actionContainer(Id(M_WINDOW_VIEWS)); @@ -456,18 +453,21 @@ void AnalyzerManagerPrivate::selectSavedTool() selectAction(m_actions.first()); } -void AnalyzerManagerPrivate::selectToolboxAction(int index) +void AnalyzerManagerPrivate::selectToolboxAction(const QString &item) { - selectAction(m_actions[index]); + selectAction(Utils::findOrDefault(m_actions, [item](const AnalyzerAction *action) { + return action->text() == item; + })); } void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action) { + QTC_ASSERT(action, return); if (m_currentAction == action) return; - const int actionIndex = m_actions.indexOf(action); - QTC_ASSERT(actionIndex >= 0, return); + const int toolboxIndex = m_toolBox->findText(action->text()); + QTC_ASSERT(toolboxIndex >= 0, return); // Clean up old tool. if (m_currentAction) { @@ -495,34 +495,49 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action) QTC_CHECK(m_controlsWidgetFromTool.contains(toolId)); m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(toolId)); - m_toolBox->setCurrentIndex(actionIndex); + m_toolBox->setCurrentIndex(toolboxIndex); updateRunActions(); } +void AnalyzerManagerPrivate::rebuildToolBox() +{ + const bool blocked = m_toolBox->blockSignals(true); // Do not make current. + QStringList integratedTools; + QStringList externalTools; + foreach (AnalyzerAction * const action, m_actions) { + if (action->menuGroup() == Constants::G_ANALYZER_TOOLS) + integratedTools << action->text(); + else + externalTools << action->text(); + } + m_toolBox->clear(); + m_toolBox->addItems(integratedTools); + m_toolBox->addItems(externalTools); + if (!integratedTools.isEmpty() && !externalTools.isEmpty()) + m_toolBox->insertSeparator(integratedTools.count()); + m_toolBox->blockSignals(blocked); + m_toolBox->setEnabled(true); +} + void AnalyzerManagerPrivate::addAction(AnalyzerAction *action) { delayedInit(); // Make sure that there is a valid IMode instance. - const bool blocked = m_toolBox->blockSignals(true); // Do not make current. - Id menuGroup = action->menuGroup(); if (menuGroup.isValid()) { - Command *command = ActionManager::registerAction(action, action->actionId(), Context(C_GLOBAL)); + Command *command = ActionManager::registerAction(action, action->actionId()); m_menu->addAction(command, menuGroup); } m_actions.append(action); - m_toolBox->addItem(action->text()); - m_toolBox->blockSignals(blocked); + rebuildToolBox(); connect(action, &QAction::triggered, this, [this, action] { AnalyzerManager::showMode(); selectAction(action); startTool(); }); - - m_toolBox->setEnabled(true); } void AnalyzerManagerPrivate::handleToolStarted() @@ -698,5 +713,3 @@ AnalyzerRunControl *AnalyzerManager::createRunControl( } } // namespace Analyzer - -#include "analyzermanager.moc" diff --git a/src/plugins/analyzerbase/analyzerplugin.cpp b/src/plugins/analyzerbase/analyzerplugin.cpp index b5a9b1d3c82..a396dc5056b 100644 --- a/src/plugins/analyzerbase/analyzerplugin.cpp +++ b/src/plugins/analyzerbase/analyzerplugin.cpp @@ -65,6 +65,10 @@ bool AnalyzerPlugin::initialize(const QStringList &arguments, QString *errorStri (void) new AnalyzerManager(this); + // Task integration. + //: Category under which Analyzer tasks are listed in Issues view + ProjectExplorer::TaskHub::addCategory(Constants::ANALYZERTASK_ID, tr("Analyzer")); + return true; } diff --git a/src/plugins/analyzerbase/analyzerutils.cpp b/src/plugins/analyzerbase/analyzerutils.cpp index ed6e9b0c28f..1216f9cfb53 100644 --- a/src/plugins/analyzerbase/analyzerutils.cpp +++ b/src/plugins/analyzerbase/analyzerutils.cpp @@ -34,6 +34,7 @@ #include #include +#include #include @@ -78,7 +79,7 @@ CPlusPlus::Symbol *AnalyzerUtils::findSymbolUnderCursor() QTC_ASSERT(doc, return 0); // fetch the expression's code - CPlusPlus::ExpressionUnderCursor expressionUnderCursor; + CPlusPlus::ExpressionUnderCursor expressionUnderCursor(doc->languageFeatures()); moveCursorToEndOfName(&tc); const QString &expression = expressionUnderCursor(tc); CPlusPlus::Scope *scope = doc->scopeAt(line, column); diff --git a/src/plugins/analyzerbase/detailederrorview.cpp b/src/plugins/analyzerbase/detailederrorview.cpp index 165200523ea..73e94b53ee3 100644 --- a/src/plugins/analyzerbase/detailederrorview.cpp +++ b/src/plugins/analyzerbase/detailederrorview.cpp @@ -225,8 +225,9 @@ void DetailedErrorDelegate::copyToClipboard() QApplication::clipboard()->setText(textualRepresentation()); } -DetailedErrorView::DetailedErrorView(QWidget *parent) - : QListView(parent) +DetailedErrorView::DetailedErrorView(QWidget *parent) : + QListView(parent), + m_copyAction(0) { } diff --git a/src/plugins/analyzerbase/startremotedialog.cpp b/src/plugins/analyzerbase/startremotedialog.cpp index a7cc9c68d9e..e971e6a7ee2 100644 --- a/src/plugins/analyzerbase/startremotedialog.cpp +++ b/src/plugins/analyzerbase/startremotedialog.cpp @@ -46,10 +46,24 @@ using namespace Utils; namespace Analyzer { namespace Internal { +class SshKitChooser : public KitChooser +{ +public: + SshKitChooser(QWidget *parent = 0) : KitChooser(parent) { } + +private: + bool kitMatches(const Kit *kit) const { + if (!KitChooser::kitMatches(kit)) + return false; + const IDevice::ConstPtr device = DeviceKitInformation::device(kit); + return device && !device->sshParameters().host.isEmpty(); + } +}; + class StartRemoteDialogPrivate { public: - KitChooser *kitChooser; + SshKitChooser *kitChooser; QLineEdit *executable; QLineEdit *arguments; QLineEdit *workingDirectory; @@ -65,7 +79,7 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent) setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowTitle(tr("Start Remote Analysis")); - d->kitChooser = new KitChooser(this); + d->kitChooser = new Internal::SshKitChooser(this); d->executable = new QLineEdit(this); d->arguments = new QLineEdit(this); d->workingDirectory = new QLineEdit(this); diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 9e74f386246..557425ade65 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/android/androidmanifestdocument.h b/src/plugins/android/androidmanifestdocument.h index 3c80e57f1bf..c49bdaf2351 100644 --- a/src/plugins/android/androidmanifestdocument.h +++ b/src/plugins/android/androidmanifestdocument.h @@ -31,7 +31,7 @@ #ifndef ANDROIDMANIFESTDOCUMENT_H #define ANDROIDMANIFESTDOCUMENT_H -#include +#include namespace Android { namespace Internal { diff --git a/src/plugins/android/androidmanifesteditor.h b/src/plugins/android/androidmanifesteditor.h index f5b6f0236ab..848a092c622 100644 --- a/src/plugins/android/androidmanifesteditor.h +++ b/src/plugins/android/androidmanifesteditor.h @@ -39,6 +39,7 @@ QT_BEGIN_NAMESPACE class QToolBar; +class QActionGroup; QT_END_NAMESPACE namespace Android { diff --git a/src/plugins/android/javacompletionassistprovider.cpp b/src/plugins/android/javacompletionassistprovider.cpp index 66c55a65d53..0a5165869f5 100644 --- a/src/plugins/android/javacompletionassistprovider.cpp +++ b/src/plugins/android/javacompletionassistprovider.cpp @@ -32,6 +32,7 @@ #include "androidconstants.h" #include +#include using namespace Android; using namespace Android::Internal; diff --git a/src/plugins/bazaar/bazaarclient.cpp b/src/plugins/bazaar/bazaarclient.cpp index 75de80ea9d9..70f94c7bdb5 100644 --- a/src/plugins/bazaar/bazaarclient.cpp +++ b/src/plugins/bazaar/bazaarclient.cpp @@ -30,6 +30,8 @@ #include "bazaarclient.h" #include "constants.h" +#include + #include #include #include diff --git a/src/plugins/bazaar/bazaarcommitwidget.cpp b/src/plugins/bazaar/bazaarcommitwidget.cpp index 99d4f12c639..ad2084be0a5 100644 --- a/src/plugins/bazaar/bazaarcommitwidget.cpp +++ b/src/plugins/bazaar/bazaarcommitwidget.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include diff --git a/src/plugins/bazaar/bazaarcontrol.cpp b/src/plugins/bazaar/bazaarcontrol.cpp index aff54e5814d..c74ba8f0f93 100644 --- a/src/plugins/bazaar/bazaarcontrol.cpp +++ b/src/plugins/bazaar/bazaarcontrol.cpp @@ -32,6 +32,8 @@ #include +#include + #include #include #include diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index 7e7d5dac576..9729f00d97c 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -601,7 +601,7 @@ void BazaarPlugin::showCommitWidget(const QList &stat const QString msg = tr("Commit changes for \"%1\"."). arg(QDir::toNativeSeparators(m_submitRepository)); - commitEditor->document()->setDisplayName(msg); + commitEditor->document()->setPreferredDisplayName(msg); const BranchInfo branch = m_client->synchronousBranchQuery(m_submitRepository); commitEditor->setFields(m_submitRepository, branch, diff --git a/src/plugins/bazaar/commiteditor.cpp b/src/plugins/bazaar/commiteditor.cpp index 885bb6d38ad..332f7539493 100644 --- a/src/plugins/bazaar/commiteditor.cpp +++ b/src/plugins/bazaar/commiteditor.cpp @@ -42,7 +42,7 @@ CommitEditor::CommitEditor(const VcsBase::VcsBaseSubmitEditorParameters *paramet : VcsBase::VcsBaseSubmitEditor(parameters, new BazaarCommitWidget), m_fileModel(0) { - document()->setDisplayName(tr("Commit Editor")); + document()->setPreferredDisplayName(tr("Commit Editor")); } BazaarCommitWidget *CommitEditor::commitWidget() diff --git a/src/plugins/beautifier/artisticstyle/artisticstyle.cpp b/src/plugins/beautifier/artisticstyle/artisticstyle.cpp index af81a9726d9..e6ffd8808c5 100644 --- a/src/plugins/beautifier/artisticstyle/artisticstyle.cpp +++ b/src/plugins/beautifier/artisticstyle/artisticstyle.cpp @@ -79,11 +79,8 @@ bool ArtisticStyle::initialize() menu->menu()->setTitle(QLatin1String(Constants::ArtisticStyle::DISPLAY_NAME)); m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); - Core::Command *cmd - = Core::ActionManager::registerAction(m_formatFile, - Constants::ArtisticStyle::ACTION_FORMATFILE, - Core::Context(Core::Constants::C_GLOBAL)); - menu->addAction(cmd); + menu->addAction(Core::ActionManager::registerAction(m_formatFile, + Constants::ArtisticStyle::ACTION_FORMATFILE)); connect(m_formatFile, &QAction::triggered, this, &ArtisticStyle::formatFile); Core::ActionManager::actionContainer(Constants::MENU_ID)->addMenu(menu); diff --git a/src/plugins/beautifier/clangformat/clangformat.cpp b/src/plugins/beautifier/clangformat/clangformat.cpp index 206b49b4df1..fb04d0756ef 100644 --- a/src/plugins/beautifier/clangformat/clangformat.cpp +++ b/src/plugins/beautifier/clangformat/clangformat.cpp @@ -77,15 +77,13 @@ bool ClangFormat::initialize() m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); Core::Command *cmd = Core::ActionManager::registerAction(m_formatFile, - Constants::ClangFormat::ACTION_FORMATFILE, - Core::Context(Core::Constants::C_GLOBAL)); + Constants::ClangFormat::ACTION_FORMATFILE); menu->addAction(cmd); connect(m_formatFile, &QAction::triggered, this, &ClangFormat::formatFile); m_formatRange = new QAction(BeautifierPlugin::msgFormatSelectedText(), this); cmd = Core::ActionManager::registerAction(m_formatRange, - Constants::ClangFormat::ACTION_FORMATSELECTED, - Core::Context(Core::Constants::C_GLOBAL)); + Constants::ClangFormat::ACTION_FORMATSELECTED); menu->addAction(cmd); connect(m_formatRange, &QAction::triggered, this, &ClangFormat::formatSelectedText); diff --git a/src/plugins/beautifier/uncrustify/uncrustify.cpp b/src/plugins/beautifier/uncrustify/uncrustify.cpp index 656974fbabd..1e8aa673a84 100644 --- a/src/plugins/beautifier/uncrustify/uncrustify.cpp +++ b/src/plugins/beautifier/uncrustify/uncrustify.cpp @@ -80,8 +80,7 @@ bool Uncrustify::initialize() m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); Core::Command *cmd = Core::ActionManager::registerAction(m_formatFile, - Constants::Uncrustify::ACTION_FORMATFILE, - Core::Context(Core::Constants::C_GLOBAL)); + Constants::Uncrustify::ACTION_FORMATFILE); menu->addAction(cmd); connect(m_formatFile, &QAction::triggered, this, &Uncrustify::formatFile); diff --git a/src/plugins/bookmarks/bookmarksplugin.cpp b/src/plugins/bookmarks/bookmarksplugin.cpp index 968861d6f9c..2eed45ab755 100644 --- a/src/plugins/bookmarks/bookmarksplugin.cpp +++ b/src/plugins/bookmarks/bookmarksplugin.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -56,16 +57,22 @@ using namespace TextEditor; namespace Bookmarks { namespace Internal { -BookmarksPlugin::BookmarksPlugin() - : m_bookmarkManager(0), - m_bookmarkMarginActionLineNumber(0) +BookmarksPlugin::BookmarksPlugin() : + m_bookmarkManager(0), + m_toggleAction(0), + m_prevAction(0), + m_nextAction(0), + m_docPrevAction(0), + m_docNextAction(0), + m_editBookmarkAction(0), + m_bookmarkMarginAction(0), + m_bookmarkMarginActionLineNumber(0) { } bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *) { Context textcontext(TextEditor::Constants::C_TEXTEDITOR); - Context globalcontext(Core::Constants::C_GLOBAL); ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS); ActionContainer *mbm = ActionManager::createMenu(Id(BOOKMARKS_MENU)); @@ -82,26 +89,26 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *) //Previous m_prevAction = new QAction(tr("Previous Bookmark"), this); - cmd = ActionManager::registerAction(m_prevAction, BOOKMARKS_PREV_ACTION, globalcontext); + cmd = ActionManager::registerAction(m_prevAction, BOOKMARKS_PREV_ACTION); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+,") : tr("Ctrl+,"))); mbm->addAction(cmd); //Next m_nextAction = new QAction(tr("Next Bookmark"), this); - cmd = ActionManager::registerAction(m_nextAction, BOOKMARKS_NEXT_ACTION, globalcontext); + cmd = ActionManager::registerAction(m_nextAction, BOOKMARKS_NEXT_ACTION); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+.") : tr("Ctrl+."))); mbm->addAction(cmd); - mbm->addSeparator(globalcontext); + mbm->addSeparator(); //Previous Doc m_docPrevAction = new QAction(tr("Previous Bookmark in Document"), this); - cmd = ActionManager::registerAction(m_docPrevAction, BOOKMARKS_PREVDOC_ACTION, globalcontext); + cmd = ActionManager::registerAction(m_docPrevAction, BOOKMARKS_PREVDOC_ACTION); mbm->addAction(cmd); //Next Doc m_docNextAction = new QAction(tr("Next Bookmark in Document"), this); - cmd = ActionManager::registerAction(m_docNextAction, BOOKMARKS_NEXTDOC_ACTION, globalcontext); + cmd = ActionManager::registerAction(m_docNextAction, BOOKMARKS_NEXTDOC_ACTION); mbm->addAction(cmd); m_editBookmarkAction = new QAction(tr("Edit Bookmark"), this); diff --git a/src/plugins/clangcodemodel/clangcompletion.cpp b/src/plugins/clangcodemodel/clangcompletion.cpp index 7d0e53b3ce0..6cc1eba3952 100644 --- a/src/plugins/clangcodemodel/clangcompletion.cpp +++ b/src/plugins/clangcodemodel/clangcompletion.cpp @@ -200,15 +200,14 @@ IAssistProcessor *ClangCompletionAssistProvider::createProcessor() const } AssistInterface *ClangCompletionAssistProvider::createAssistInterface( - const QString &filePath, - QTextDocument *document, bool isObjCEnabled, int position, AssistReason reason) const + const QString &filePath, QTextDocument *document, + const LanguageFeatures &languageFeatures, int position, AssistReason reason) const { - Q_UNUSED(isObjCEnabled); - CppModelManager *modelManager = CppModelManager::instance(); QList parts = modelManager->projectPart(filePath); if (parts.isEmpty()) parts += modelManager->fallbackProjectPart(); + LanguageFeatures features = languageFeatures; ProjectPart::HeaderPaths headerPaths; QStringList options; PchInfo::Ptr pchInfo; @@ -220,13 +219,14 @@ AssistInterface *ClangCompletionAssistProvider::createAssistInterface( if (!pchInfo.isNull()) options.append(Utils::createPCHInclusionOptions(pchInfo->fileName())); headerPaths = part->headerPaths; + features = part->languageFeatures; break; } return new ClangCompletionAssistInterface( m_clangCompletionWrapper, document, position, filePath, reason, - options, headerPaths, pchInfo); + options, headerPaths, pchInfo, features); } // ------------------------ @@ -545,12 +545,14 @@ ClangCompletionAssistInterface::ClangCompletionAssistInterface(ClangCompleter::P AssistReason reason, const QStringList &options, const QList &headerPaths, - const PchInfo::Ptr &pchInfo) + const PchInfo::Ptr &pchInfo, + const LanguageFeatures &features) : AssistInterface(document, position, fileName, reason) , m_clangWrapper(clangWrapper) , m_options(options) , m_headerPaths(headerPaths) , m_savedPchPointer(pchInfo) + , m_languageFeatures(features) { Q_ASSERT(!clangWrapper.isNull()); @@ -637,7 +639,7 @@ int ClangCompletionAssistProcessor::startCompletionHelper() return m_startPosition; } - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(m_interface->languageFeatures()); QTextCursor tc(m_interface->textDocument()); if (m_model->m_completionOperator == T_COMMA) { @@ -703,7 +705,7 @@ int ClangCompletionAssistProcessor::startOfOperator(int pos, } if (*kind == T_COMMA) { - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(m_interface->languageFeatures()); if (expressionUnderCursor.startOfFunctionCall(tc) == -1) { *kind = T_EOF_SYMBOL; start = pos; @@ -711,10 +713,7 @@ int ClangCompletionAssistProcessor::startOfOperator(int pos, } SimpleLexer tokenize; - LanguageFeatures lf = tokenize.languageFeatures(); - lf.qtMocRunEnabled = true; - lf.objCEnabled = true; - tokenize.setLanguageFeatures(lf); + tokenize.setLanguageFeatures(m_interface->languageFeatures()); tokenize.setSkipComments(false); const Tokens &tokens = tokenize(tc.block().text(), BackwardsScanner::previousBlockState(tc.block())); const int tokenIdx = SimpleLexer::tokenBefore(tokens, qMax(0, tc.positionInBlock() - 1)); // get the token at the left of the cursor @@ -932,7 +931,7 @@ int ClangCompletionAssistProcessor::startCompletionInternal(const QString fileNa QTextCursor tc(m_interface->textDocument()); tc.setPosition(index); - ExpressionUnderCursor euc; + ExpressionUnderCursor euc(m_interface->languageFeatures()); index = euc.startOfFunctionCall(tc); int nameStart = findStartOfName(index); QTextCursor tc2(m_interface->textDocument()); diff --git a/src/plugins/clangcodemodel/clangcompletion.h b/src/plugins/clangcodemodel/clangcompletion.h index 65274ff19ae..0a944a08abd 100644 --- a/src/plugins/clangcodemodel/clangcompletion.h +++ b/src/plugins/clangcodemodel/clangcompletion.h @@ -58,9 +58,9 @@ public: virtual TextEditor::IAssistProcessor *createProcessor() const; virtual TextEditor::AssistInterface *createAssistInterface( - const QString &filePath, - QTextDocument *document, bool isObjCEnabled, int position, - TextEditor::AssistReason reason) const; + const QString &filePath, QTextDocument *document, + const CPlusPlus::LanguageFeatures &languageFeatures, + int position, TextEditor::AssistReason reason) const; private: ClangCodeModel::ClangCompleter::Ptr m_clangCompletionWrapper; @@ -78,7 +78,8 @@ public: TextEditor::AssistReason reason, const QStringList &options, const QList &headerPaths, - const Internal::PchInfo::Ptr &pchInfo); + const Internal::PchInfo::Ptr &pchInfo, + const CPlusPlus::LanguageFeatures &features); ClangCodeModel::ClangCompleter::Ptr clangWrapper() const { return m_clangWrapper; } @@ -94,12 +95,16 @@ public: const QList &headerPaths() const { return m_headerPaths; } + CPlusPlus::LanguageFeatures languageFeatures() const + { return m_languageFeatures; } + private: ClangCodeModel::ClangCompleter::Ptr m_clangWrapper; ClangCodeModel::Internal::UnsavedFiles m_unsavedFiles; QStringList m_options; QList m_headerPaths; Internal::PchInfo::Ptr m_savedPchPointer; + CPlusPlus::LanguageFeatures m_languageFeatures; }; class CLANG_EXPORT ClangCompletionAssistProcessor : public CppTools::CppCompletionAssistProcessor diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index 28df2e2d14a..c9aef6eb3e2 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/clearcase/clearcasesettings.cpp b/src/plugins/clearcase/clearcasesettings.cpp index 0815b39e850..abfdcf84c96 100644 --- a/src/plugins/clearcase/clearcasesettings.cpp +++ b/src/plugins/clearcase/clearcasesettings.cpp @@ -70,7 +70,8 @@ ClearCaseSettings::ClearCaseSettings() : autoAssignActivityName(true), autoCheckOut(true), promptToCheckIn(false), - disableIndexer(false) + disableIndexer(false), + extDiffAvailable(false) { } diff --git a/src/plugins/clearcase/clearcasesubmiteditor.cpp b/src/plugins/clearcase/clearcasesubmiteditor.cpp index 2b194ced05e..2f36dabcafb 100644 --- a/src/plugins/clearcase/clearcasesubmiteditor.cpp +++ b/src/plugins/clearcase/clearcasesubmiteditor.cpp @@ -41,7 +41,7 @@ using namespace ClearCase::Internal; ClearCaseSubmitEditor::ClearCaseSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters) : VcsBase::VcsBaseSubmitEditor(parameters, new ClearCaseSubmitEditorWidget) { - document()->setDisplayName(tr("ClearCase Check In")); + document()->setPreferredDisplayName(tr("ClearCase Check In")); } ClearCaseSubmitEditorWidget *ClearCaseSubmitEditor::submitEditorWidget() diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp index 99c738064e2..ef618123d6e 100644 --- a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp +++ b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp @@ -568,4 +568,11 @@ bool MenuBarActionContainer::canBeAddedToMenu() const } } // namespace Internal + +Command *ActionContainer::addSeparator(Id group) +{ + static const Context context(Constants::C_GLOBAL); + return addSeparator(context, group); +} + } // namespace Core diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer.h b/src/plugins/coreplugin/actionmanager/actioncontainer.h index 2bfed0950a7..b5b1a0e2700 100644 --- a/src/plugins/coreplugin/actionmanager/actioncontainer.h +++ b/src/plugins/coreplugin/actionmanager/actioncontainer.h @@ -71,6 +71,7 @@ public: virtual void addAction(Command *action, Id group = Id()) = 0; virtual void addMenu(ActionContainer *menu, Id group = Id()) = 0; virtual void addMenu(ActionContainer *before, ActionContainer *menu, Id group = Id()) = 0; + Command *addSeparator(Id group = Id()); virtual Command *addSeparator(const Context &context, Id group = Id(), QAction **outSeparator = 0) = 0; // This clears this menu and submenus from all actions and submenus. diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.cpp b/src/plugins/coreplugin/actionmanager/actionmanager.cpp index f45645e877f..f189e4b7c2e 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager.cpp +++ b/src/plugins/coreplugin/actionmanager/actionmanager.cpp @@ -243,6 +243,8 @@ ActionContainer *ActionManager::createMenuBar(Id id) same \a id as long as the \a context is different. In this case a trigger of the actual action is forwarded to the registered QAction for the currently active context. + If the optional \a context argument is not specified, the global context + will be assumed. A scriptable action can be called from a script without the need for the user to interact with it. */ @@ -384,8 +386,8 @@ void ActionManager::setContext(const Context &context) \internal */ -ActionManagerPrivate::ActionManagerPrivate() - : m_presentationModeEnabled(false) +ActionManagerPrivate::ActionManagerPrivate() : + m_presentationModeEnabled(false) { } diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.h b/src/plugins/coreplugin/actionmanager/actionmanager.h index eeab8fba9b7..493143cfbb5 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager.h +++ b/src/plugins/coreplugin/actionmanager/actionmanager.h @@ -32,7 +32,8 @@ #define ACTIONMANAGER_H #include "coreplugin/core_global.h" -#include "coreplugin/id.h" +#include "coreplugin/coreconstants.h" +#include "coreplugin/icontext.h" #include #include @@ -62,7 +63,9 @@ public: static ActionContainer *createMenu(Id id); static ActionContainer *createMenuBar(Id id); - static Command *registerAction(QAction *action, Id id, const Context &context, bool scriptable = false); + static Command *registerAction(QAction *action, Id id, + const Context &context = Context(Constants::C_GLOBAL), + bool scriptable = false); static Command *command(Id id); static ActionContainer *actionContainer(Id id); diff --git a/src/plugins/coreplugin/actionmanager/actionmanager_p.h b/src/plugins/coreplugin/actionmanager/actionmanager_p.h index 337cbe135b3..fa106014e44 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager_p.h +++ b/src/plugins/coreplugin/actionmanager/actionmanager_p.h @@ -90,8 +90,6 @@ public: Context m_context; bool m_presentationModeEnabled; - QLabel *m_presentationLabel; - QTimer m_presentationLabelTimer; }; } // namespace Internal diff --git a/src/plugins/coreplugin/editormanager/documentmodel.cpp b/src/plugins/coreplugin/editormanager/documentmodel.cpp index 38f9de1f14f..aa4b7b0401e 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel.cpp +++ b/src/plugins/coreplugin/editormanager/documentmodel.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include namespace Core { @@ -69,16 +70,46 @@ public: int indexOfFilePath(const Utils::FileName &filePath) const; int indexOfDocument(IDocument *document) const; + bool disambiguateDisplayNames(DocumentModel::Entry *entry); + private slots: friend class DocumentModel; void itemChanged(); private: + class DynamicEntry + { + public: + DocumentModel::Entry *entry; + int pathComponents; + + DynamicEntry(DocumentModel::Entry *e) : + entry(e), + pathComponents(0) + { + } + + DocumentModel::Entry *operator->() const { return entry; } + + void disambiguate() + { + entry->document->setUniqueDisplayName(entry->fileName().fileName(++pathComponents)); + } + + void setNumberedName(int number) + { + entry->document->setUniqueDisplayName(QStringLiteral("%1 (%2)") + .arg(entry->document->displayName()) + .arg(number)); + } + }; + const QIcon m_lockedIcon; const QIcon m_unlockedIcon; QList m_entries; QMap > m_editors; + QHash m_entryByFixedPath; }; DocumentModelPrivate::DocumentModelPrivate() : @@ -138,6 +169,11 @@ QString DocumentModel::Entry::displayName() const return document ? document->displayName() : m_displayName; } +QString DocumentModel::Entry::plainDisplayName() const +{ + return document ? document->plainDisplayName() : m_displayName; +} + Id DocumentModel::Entry::id() const { return document ? document->id() : m_id; @@ -191,45 +227,123 @@ DocumentModel::Entry *DocumentModel::firstRestoredEntry() void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry) { const Utils::FileName fileName = entry->fileName(); + QString fixedPath; + if (!fileName.isEmpty()) + fixedPath = DocumentManager::fixFileName(fileName.toString(), DocumentManager::ResolveLinks); // replace a non-loaded entry (aka 'restored') if possible int previousIndex = indexOfFilePath(fileName); if (previousIndex >= 0) { - if (entry->document && m_entries.at(previousIndex)->document == 0) { - DocumentModel::Entry *previousEntry = m_entries.at(previousIndex); - m_entries[previousIndex] = entry; + DocumentModel::Entry *previousEntry = m_entries.at(previousIndex); + const bool replace = entry->document && !previousEntry->document; + if (replace) { delete previousEntry; - connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged())); + m_entries[previousIndex] = entry; + if (!fixedPath.isEmpty()) + m_entryByFixedPath[fixedPath] = entry; } else { delete entry; + entry = previousEntry; } + previousEntry = 0; + disambiguateDisplayNames(entry); + if (replace) + connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged())); return; } int index; - QString displayName = entry->displayName(); + const QString displayName = entry->plainDisplayName(); for (index = 0; index < m_entries.count(); ++index) { - if (displayName.localeAwareCompare(m_entries.at(index)->displayName()) < 0) + int cmp = displayName.localeAwareCompare(m_entries.at(index)->plainDisplayName()); + if (cmp < 0) + break; + if (cmp == 0 && fileName < d->m_entries.at(index)->fileName()) break; } int row = index + 1/**/; beginInsertRows(QModelIndex(), row, row); m_entries.insert(index, entry); + disambiguateDisplayNames(entry); + if (!fixedPath.isEmpty()) + m_entryByFixedPath[fixedPath] = entry; if (entry->document) connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged())); endInsertRows(); } +bool DocumentModelPrivate::disambiguateDisplayNames(DocumentModel::Entry *entry) +{ + const QString displayName = entry->plainDisplayName(); + int minIdx = -1, maxIdx = -1; + + QList dups; + + for (int i = 0, total = m_entries.count(); i < total; ++i) { + DocumentModel::Entry *e = m_entries.at(i); + if (!e->document) + continue; + if (e == entry || e->plainDisplayName() == displayName) { + e->document->setUniqueDisplayName(QString()); + dups += DynamicEntry(e); + maxIdx = i; + if (minIdx < 0) + minIdx = i; + } + } + + const int dupsCount = dups.count(); + if (dupsCount == 0) + return false; + + if (dupsCount > 1) { + int serial = 0; + int count = 0; + // increase uniqueness unless no dups are left + forever { + bool seenDups = false; + for (int i = 0; i < dupsCount - 1; ++i) { + DynamicEntry &e = dups[i]; + const Utils::FileName myFileName = e->document->filePath(); + if (e->document->isTemporary() || myFileName.isEmpty() || count > 10) { + // path-less entry, append number + e.setNumberedName(++serial); + continue; + } + for (int j = i + 1; j < dupsCount; ++j) { + DynamicEntry &e2 = dups[j]; + if (e->displayName() == e2->displayName()) { + const Utils::FileName otherFileName = e2->document->filePath(); + if (otherFileName.isEmpty()) + continue; + seenDups = true; + e2.disambiguate(); + if (j > maxIdx) + maxIdx = j; + } + } + if (seenDups) { + e.disambiguate(); + ++count; + break; + } + } + if (!seenDups) + break; + } + } + + emit dataChanged(index(minIdx + 1, 0), index(maxIdx + 1, 0)); + return true; +} + int DocumentModelPrivate::indexOfFilePath(const Utils::FileName &filePath) const { if (filePath.isEmpty()) return -1; const QString fixedPath = DocumentManager::fixFileName(filePath.toString(), DocumentManager::ResolveLinks); - return Utils::indexOf(m_entries, [&fixedPath](DocumentModel::Entry *entry) { - return DocumentManager::fixFileName(entry->fileName().toString(), - DocumentManager::ResolveLinks) == fixedPath; - }); + return m_entries.indexOf(m_entryByFixedPath.value(fixedPath)); } void DocumentModel::removeEntry(DocumentModel::Entry *entry) @@ -271,8 +385,16 @@ void DocumentModelPrivate::removeDocument(int idx) beginRemoveRows(QModelIndex(), row, row); DocumentModel::Entry *entry = d->m_entries.takeAt(idx); endRemoveRows(); + + const QString fileName = entry->fileName().toString(); + if (!fileName.isEmpty()) { + const QString fixedPath = DocumentManager::fixFileName(fileName, + DocumentManager::ResolveLinks); + m_entryByFixedPath.remove(fixedPath); + } if (IDocument *document = entry->document) disconnect(document, SIGNAL(changed()), this, SLOT(itemChanged())); + disambiguateDisplayNames(entry); delete entry; } @@ -286,6 +408,14 @@ void DocumentModel::removeAllRestoredEntries() d->endRemoveRows(); } } + QSet displayNames; + foreach (DocumentModel::Entry *entry, d->m_entries) { + const QString displayName = entry->plainDisplayName(); + if (displayNames.contains(displayName)) + continue; + displayNames.insert(displayName); + d->disambiguateDisplayNames(entry); + } } QList DocumentModel::editorsForDocument(IDocument *document) @@ -394,10 +524,12 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const } const DocumentModel::Entry *e = m_entries.at(entryIndex); switch (role) { - case Qt::DisplayRole: - return (e->document && e->document->isModified()) - ? e->displayName() + QLatin1Char('*') - : e->displayName(); + case Qt::DisplayRole: { + QString name = e->displayName(); + if (e->document && e->document->isModified()) + name += QLatin1Char('*'); + return name; + } case Qt::DecorationRole: { bool showLock = false; @@ -408,9 +540,7 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const return showLock ? m_lockedIcon : QIcon(); } case Qt::ToolTipRole: - return e->fileName().isEmpty() - ? e->displayName() - : e->fileName().toUserOutput(); + return e->fileName().isEmpty() ? e->displayName() : e->fileName().toUserOutput(); default: return QVariant(); } @@ -451,8 +581,31 @@ void DocumentModelPrivate::itemChanged() int idx = indexOfDocument(document); if (idx < 0) return; - QModelIndex mindex = index(idx + 1/**/, 0); - emit dataChanged(mindex, mindex); + const QString fileName = document->filePath().toString(); + QString fixedPath; + if (!fileName.isEmpty()) + fixedPath = DocumentManager::fixFileName(fileName, DocumentManager::ResolveLinks); + DocumentModel::Entry *entry = d->m_entries.at(idx); + bool found = false; + // The entry's fileName might have changed, so find the previous fileName that was associated + // with it and remove it, then add the new fileName. + for (auto it = m_entryByFixedPath.begin(), end = m_entryByFixedPath.end(); it != end; ++it) { + if (it.value() == entry) { + found = true; + if (it.key() != fixedPath) { + m_entryByFixedPath.remove(it.key()); + if (!fixedPath.isEmpty()) + m_entryByFixedPath[fixedPath] = entry; + } + break; + } + } + if (!found && !fixedPath.isEmpty()) + m_entryByFixedPath[fixedPath] = entry; + if (!disambiguateDisplayNames(d->m_entries.at(idx))) { + QModelIndex mindex = index(idx + 1/**/, 0); + emit dataChanged(mindex, mindex); + } } QList DocumentModel::entries() diff --git a/src/plugins/coreplugin/editormanager/documentmodel.h b/src/plugins/coreplugin/editormanager/documentmodel.h index 8b5f286a66c..daf2996755c 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel.h +++ b/src/plugins/coreplugin/editormanager/documentmodel.h @@ -61,6 +61,8 @@ public: IDocument *document; Utils::FileName fileName() const; QString displayName() const; + QString plainDisplayName() const; + QString uniqueDisplayName() const; Id id() const; Utils::FileName m_fileName; QString m_displayName; diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 83fc2583a8b..e7ff06cff02 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -102,6 +102,8 @@ static const char reloadBehaviorKey[] = "EditorManager/ReloadBehavior"; static const char autoSaveEnabledKey[] = "EditorManager/AutoSaveEnabled"; static const char autoSaveIntervalKey[] = "EditorManager/AutoSaveInterval"; +static const char scratchBufferKey[] = "_q_emScratchBuffer"; + //===================EditorClosingCoreListener====================== namespace Core { @@ -1660,7 +1662,7 @@ bool EditorManagerPrivate::saveDocument(IDocument *document) document->checkPermissions(); - const QString &fileName = document->filePath().toString(); + const QString fileName = document->filePath().toString(); if (fileName.isEmpty()) return saveDocumentAs(document); @@ -2329,20 +2331,8 @@ QStringList EditorManager::getOpenFileNames() return DocumentManager::getOpenFileNames(fileFilters, QString(), &selectedFilter); } - -IEditor *EditorManager::openEditorWithContents(Id editorId, - QString *titlePattern, - const QByteArray &contents, - OpenEditorFlags flags) +static QString makeTitleUnique(QString *titlePattern) { - if (debugEditorManager) - qDebug() << Q_FUNC_INFO << editorId.name() << titlePattern << contents; - - if (flags & EditorManager::OpenInOtherSplit) - EditorManager::gotoOtherSplit(); - - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - QString title; if (titlePattern) { const QChar dollar = QLatin1Char('$'); @@ -2371,8 +2361,42 @@ IEditor *EditorManager::openEditorWithContents(Id editorId, } *titlePattern = title; } + return title; +} - IEditor *edt = EditorManagerPrivate::createEditor(editorId, title); +IEditor *EditorManager::openEditorWithContents(Id editorId, + QString *titlePattern, + const QByteArray &contents, + const QString &uniqueId, + OpenEditorFlags flags) +{ + if (debugEditorManager) + qDebug() << Q_FUNC_INFO << editorId.name() << titlePattern << uniqueId << contents; + + if (flags & EditorManager::OpenInOtherSplit) + EditorManager::gotoOtherSplit(); + + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + + const QString title = makeTitleUnique(titlePattern); + + IEditor *edt = 0; + if (!uniqueId.isEmpty()) { + foreach (IDocument *document, DocumentModel::openedDocuments()) + if (document->property(scratchBufferKey).toString() == uniqueId) { + edt = DocumentModel::editorsForDocument(document).first(); + + document->setContents(contents); + if (!title.isEmpty()) + edt->document()->setPreferredDisplayName(title); + + QApplication::restoreOverrideCursor(); + activateEditor(edt, flags); + return edt; + } + } + + edt = EditorManagerPrivate::createEditor(editorId, title); if (!edt) { QApplication::restoreOverrideCursor(); return 0; @@ -2385,9 +2409,11 @@ IEditor *EditorManager::openEditorWithContents(Id editorId, return 0; } - if (!title.isEmpty()) - edt->document()->setDisplayName(title); + if (!uniqueId.isEmpty()) + edt->document()->setProperty(scratchBufferKey, uniqueId); + if (!title.isEmpty()) + edt->document()->setPreferredDisplayName(title); EditorManagerPrivate::addEditor(edt); QApplication::restoreOverrideCursor(); diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index 2a09104cbb7..f2b123c3baf 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -120,6 +120,7 @@ public: bool *newEditor = 0); static IEditor *openEditorWithContents(Id editorId, QString *titlePattern = 0, const QByteArray &contents = QByteArray(), + const QString &uniqueId = QString(), OpenEditorFlags flags = NoFlags); static bool openExternalEditor(const QString &fileName, Id editorId); diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp index 29962c596f2..b039cedaaa1 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp @@ -225,7 +225,8 @@ void OpenEditorsWindow::addHistoryItems(const QList &history, Edit if (hi.document.isNull() || documentsDone.contains(hi.document)) continue; documentsDone.insert(hi.document.data()); - QString title = hi.document->displayName(); + DocumentModel::Entry *entry = DocumentModel::entryForDocument(hi.document); + QString title = entry ? entry->displayName() : hi.document->displayName(); QTC_ASSERT(!title.isEmpty(), continue); QTreeWidgetItem *item = new QTreeWidgetItem(); if (hi.document->isModified()) diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp index 0806a254631..50853a460b8 100644 --- a/src/plugins/coreplugin/editortoolbar.cpp +++ b/src/plugins/coreplugin/editortoolbar.cpp @@ -97,8 +97,11 @@ EditorToolBarPrivate::EditorToolBarPrivate(QWidget *parent, EditorToolBar *q) : m_closeEditorButton(new QToolButton(q)), m_lockButton(new QToolButton(q)), m_dragHandle(new QToolButton(q)), + m_dragHandleMenu(0), m_goBackAction(new QAction(QIcon(QLatin1String(Constants::ICON_PREV)), EditorManager::tr("Go Back"), parent)), m_goForwardAction(new QAction(QIcon(QLatin1String(Constants::ICON_NEXT)), EditorManager::tr("Go Forward"), parent)), + m_backButton(new QToolButton(q)), + m_forwardButton(new QToolButton(q)), m_splitButton(new QToolButton(q)), m_horizontalSplitAction(new QAction(QIcon(QLatin1String(Constants::ICON_SPLIT_HORIZONTAL)), EditorManager::tr("Split"), parent)), m_verticalSplitAction(new QAction(QIcon(QLatin1String(Constants::ICON_SPLIT_VERTICAL)), EditorManager::tr("Split Side by Side"), parent)), @@ -154,10 +157,8 @@ EditorToolBar::EditorToolBar(QWidget *parent) : d->m_toolBarPlaceholder->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - d->m_backButton = new QToolButton(this); d->m_backButton->setDefaultAction(d->m_goBackAction); - d->m_forwardButton= new QToolButton(this); d->m_forwardButton->setDefaultAction(d->m_goForwardAction); if (Utils::HostOsInfo::isMacHost()) { diff --git a/src/plugins/coreplugin/externaltoolmanager.cpp b/src/plugins/coreplugin/externaltoolmanager.cpp index 9b99c1a4206..72efa03bb29 100644 --- a/src/plugins/coreplugin/externaltoolmanager.cpp +++ b/src/plugins/coreplugin/externaltoolmanager.cpp @@ -244,7 +244,7 @@ void ExternalToolManager::setToolsByCategory(const QMaperrorString()); }); - command = ActionManager::registerAction(action, externalToolsPrefix.withSuffix(toolId), Context(Constants::C_GLOBAL)); + command = ActionManager::registerAction(action, externalToolsPrefix.withSuffix(toolId)); command->setAttribute(Command::CA_UpdateText); } action->setText(tool->displayName()); diff --git a/src/plugins/coreplugin/find/findplugin.cpp b/src/plugins/coreplugin/find/findplugin.cpp index c50213211d8..36b7dc99f14 100644 --- a/src/plugins/coreplugin/find/findplugin.cpp +++ b/src/plugins/coreplugin/find/findplugin.cpp @@ -94,8 +94,10 @@ public: FindPluginPrivate::FindPluginPrivate(FindPlugin *q) : m_currentDocumentFind(0), m_findToolBar(0), m_findDialog(0), + m_searchResultWindow(0), m_findCompletionModel(new QStringListModel(q)), - m_replaceCompletionModel(new QStringListModel(q)) + m_replaceCompletionModel(new QStringListModel(q)), + m_openFindDialog(0) { } @@ -201,17 +203,16 @@ void FindPlugin::setupMenu() mfind->appendGroup(Constants::G_FIND_FILTERS); mfind->appendGroup(Constants::G_FIND_FLAGS); mfind->appendGroup(Constants::G_FIND_ACTIONS); - Context globalcontext(Constants::C_GLOBAL); Command *cmd; - mfind->addSeparator(globalcontext, Constants::G_FIND_FLAGS); - mfind->addSeparator(globalcontext, Constants::G_FIND_ACTIONS); + mfind->addSeparator(Constants::G_FIND_FLAGS); + mfind->addSeparator(Constants::G_FIND_ACTIONS); ActionContainer *mfindadvanced = ActionManager::createMenu(Constants::M_FIND_ADVANCED); mfindadvanced->menu()->setTitle(tr("Advanced Find")); mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS); d->m_openFindDialog = new QAction(tr("Open Advanced Find..."), this); d->m_openFindDialog->setIconText(tr("Advanced...")); - cmd = ActionManager::registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND, globalcontext); + cmd = ActionManager::registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F"))); mfindadvanced->addAction(cmd); connect(d->m_openFindDialog, &QAction::triggered, @@ -223,7 +224,6 @@ void FindPlugin::setupFilterMenuItems() QList findInterfaces = ExtensionSystem::PluginManager::getObjects(); Command *cmd; - Context globalcontext(Constants::C_GLOBAL); ActionContainer *mfindadvanced = ActionManager::actionContainer(Constants::M_FIND_ADVANCED); d->m_filterActions.clear(); @@ -236,8 +236,7 @@ void FindPlugin::setupFilterMenuItems() haveEnabledFilters = true; action->setEnabled(isEnabled); action->setData(qVariantFromValue(filter)); - cmd = ActionManager::registerAction(action, - base.withSuffix(filter->id()), globalcontext); + cmd = ActionManager::registerAction(action, base.withSuffix(filter->id())); cmd->setDefaultKeySequence(filter->defaultShortcut()); mfindadvanced->addAction(cmd); d->m_filterActions.insert(filter, action); diff --git a/src/plugins/coreplugin/find/findtoolbar.cpp b/src/plugins/coreplugin/find/findtoolbar.cpp index 493aea53b40..b21d7c05189 100644 --- a/src/plugins/coreplugin/find/findtoolbar.cpp +++ b/src/plugins/coreplugin/find/findtoolbar.cpp @@ -153,7 +153,6 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen QMetaTypeId::qt_metatype_id(); // register actions - Context globalcontext(Constants::C_GLOBAL); Context findcontext(Constants::C_FINDTOOLBAR); ActionContainer *mfind = ActionManager::actionContainer(Constants::M_FIND); Command *cmd; @@ -168,7 +167,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen QIcon icon = QIcon::fromTheme(QLatin1String("edit-find-replace")); m_findInDocumentAction = new QAction(icon, tr("Find/Replace"), this); - cmd = ActionManager::registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT, globalcontext); + cmd = ActionManager::registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT); cmd->setDefaultKeySequence(QKeySequence::Find); mfind->addAction(cmd, Constants::G_FIND_CURRENTDOCUMENT); connect(m_findInDocumentAction, SIGNAL(triggered()), this, SLOT(openFind())); @@ -183,7 +182,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen if (QApplication::clipboard()->supportsFindBuffer()) { m_enterFindStringAction = new QAction(tr("Enter Find String"), this); - cmd = ActionManager::registerAction(m_enterFindStringAction, "Find.EnterFindString", globalcontext); + cmd = ActionManager::registerAction(m_enterFindStringAction, "Find.EnterFindString"); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E"))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_enterFindStringAction, &QAction::triggered, this, &FindToolBar::putSelectionToFindClipboard); @@ -191,7 +190,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen } m_findNextAction = new QAction(tr("Find Next"), this); - cmd = ActionManager::registerAction(m_findNextAction, Constants::FIND_NEXT, globalcontext); + cmd = ActionManager::registerAction(m_findNextAction, Constants::FIND_NEXT); cmd->setDefaultKeySequence(QKeySequence::FindNext); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_findNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindNext); @@ -202,7 +201,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen m_ui.findNextButton->setDefaultAction(m_localFindNextAction); m_findPreviousAction = new QAction(tr("Find Previous"), this); - cmd = ActionManager::registerAction(m_findPreviousAction, Constants::FIND_PREVIOUS, globalcontext); + cmd = ActionManager::registerAction(m_findPreviousAction, Constants::FIND_PREVIOUS); cmd->setDefaultKeySequence(QKeySequence::FindPrevious); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_findPreviousAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindPrevious); @@ -213,19 +212,19 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen m_ui.findPreviousButton->setDefaultAction(m_localFindPreviousAction); m_findNextSelectedAction = new QAction(tr("Find Next (Selected)"), this); - cmd = ActionManager::registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED, globalcontext); + cmd = ActionManager::registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F3"))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_findNextSelectedAction, &QAction::triggered, this, &FindToolBar::findNextSelected); m_findPreviousSelectedAction = new QAction(tr("Find Previous (Selected)"), this); - cmd = ActionManager::registerAction(m_findPreviousSelectedAction, Constants::FIND_PREV_SELECTED, globalcontext); + cmd = ActionManager::registerAction(m_findPreviousSelectedAction, Constants::FIND_PREV_SELECTED); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F3"))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_findPreviousSelectedAction, &QAction::triggered, this, &FindToolBar::findPreviousSelected); m_replaceAction = new QAction(tr("Replace"), this); - cmd = ActionManager::registerAction(m_replaceAction, Constants::REPLACE, globalcontext); + cmd = ActionManager::registerAction(m_replaceAction, Constants::REPLACE); cmd->setDefaultKeySequence(QKeySequence()); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replaceAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplace); @@ -236,7 +235,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen m_ui.replaceButton->setDefaultAction(m_localReplaceAction); m_replaceNextAction = new QAction(tr("Replace && Find"), this); - cmd = ActionManager::registerAction(m_replaceNextAction, Constants::REPLACE_NEXT, globalcontext); + cmd = ActionManager::registerAction(m_replaceNextAction, Constants::REPLACE_NEXT); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+="))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replaceNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceNext); @@ -248,7 +247,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen m_ui.replaceNextButton->setDefaultAction(m_localReplaceNextAction); m_replacePreviousAction = new QAction(tr("Replace && Find Previous"), this); - cmd = ActionManager::registerAction(m_replacePreviousAction, Constants::REPLACE_PREVIOUS, globalcontext); + cmd = ActionManager::registerAction(m_replacePreviousAction, Constants::REPLACE_PREVIOUS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replacePreviousAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplacePrevious); m_localReplacePreviousAction = new QAction(m_replacePreviousAction->text(), this); @@ -257,7 +256,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen connect(m_localReplacePreviousAction, &QAction::triggered, this, &FindToolBar::invokeReplacePrevious); m_replaceAllAction = new QAction(tr("Replace All"), this); - cmd = ActionManager::registerAction(m_replaceAllAction, Constants::REPLACE_ALL, globalcontext); + cmd = ActionManager::registerAction(m_replaceAllAction, Constants::REPLACE_ALL); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replaceAllAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceAll); m_localReplaceAllAction = new QAction(m_replaceAllAction->text(), this); @@ -270,7 +269,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen m_caseSensitiveAction->setIcon(QIcon(QLatin1String(":/find/images/casesensitively.png"))); m_caseSensitiveAction->setCheckable(true); m_caseSensitiveAction->setChecked(false); - cmd = ActionManager::registerAction(m_caseSensitiveAction, Constants::CASE_SENSITIVE, globalcontext); + cmd = ActionManager::registerAction(m_caseSensitiveAction, Constants::CASE_SENSITIVE); mfind->addAction(cmd, Constants::G_FIND_FLAGS); connect(m_caseSensitiveAction, &QAction::toggled, this, &FindToolBar::setCaseSensitive); @@ -278,7 +277,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen m_wholeWordAction->setIcon(QIcon(QLatin1String(":/find/images/wholewords.png"))); m_wholeWordAction->setCheckable(true); m_wholeWordAction->setChecked(false); - cmd = ActionManager::registerAction(m_wholeWordAction, Constants::WHOLE_WORDS, globalcontext); + cmd = ActionManager::registerAction(m_wholeWordAction, Constants::WHOLE_WORDS); mfind->addAction(cmd, Constants::G_FIND_FLAGS); connect(m_wholeWordAction, &QAction::toggled, this, &FindToolBar::setWholeWord); @@ -286,7 +285,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen m_regularExpressionAction->setIcon(QIcon(QLatin1String(":/find/images/regexp.png"))); m_regularExpressionAction->setCheckable(true); m_regularExpressionAction->setChecked(false); - cmd = ActionManager::registerAction(m_regularExpressionAction, Constants::REGULAR_EXPRESSIONS, globalcontext); + cmd = ActionManager::registerAction(m_regularExpressionAction, Constants::REGULAR_EXPRESSIONS); mfind->addAction(cmd, Constants::G_FIND_FLAGS); connect(m_regularExpressionAction, &QAction::toggled, this, &FindToolBar::setRegularExpressions); @@ -294,7 +293,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen m_preserveCaseAction->setIcon(QPixmap(QLatin1String(":/find/images/preservecase.png"))); m_preserveCaseAction->setCheckable(true); m_preserveCaseAction->setChecked(false); - cmd = ActionManager::registerAction(m_preserveCaseAction, Constants::PRESERVE_CASE, globalcontext); + cmd = ActionManager::registerAction(m_preserveCaseAction, Constants::PRESERVE_CASE); mfind->addAction(cmd, Constants::G_FIND_FLAGS); connect(m_preserveCaseAction, &QAction::toggled, this, &FindToolBar::setPreserveCase); diff --git a/src/plugins/coreplugin/find/searchresultwindow.cpp b/src/plugins/coreplugin/find/searchresultwindow.cpp index db4dd1e4b75..1edc96f4a56 100644 --- a/src/plugins/coreplugin/find/searchresultwindow.cpp +++ b/src/plugins/coreplugin/find/searchresultwindow.cpp @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -79,14 +80,17 @@ namespace Internal { class SearchResultWindowPrivate : public QObject { - Q_OBJECT + Q_DECLARE_TR_FUNCTIONS(Core::SearchResultWindow) public: - SearchResultWindowPrivate(SearchResultWindow *window); - bool isSearchVisible() const; - int visibleSearchIndex() const; + SearchResultWindowPrivate(SearchResultWindow *window, QWidget *newSearchPanel); + bool isSearchVisible() const { return m_currentIndex > 0; } + int visibleSearchIndex() const { return m_currentIndex - 1; } void setCurrentIndex(int index, bool focus); + void setCurrentIndexWithFocus(int index) { setCurrentIndex(index, true); } + void moveWidgetToTop(); + void popupRequested(bool focus); + void handleExpandCollapseToolButton(bool checked); - FindPlugin *m_plugin; SearchResultWindow *q; QList m_searchResultWidgets; QToolButton *m_expandCollapseButton; @@ -103,26 +107,47 @@ namespace Internal { SearchResultColor m_color; int m_tabWidth; - public slots: - void setCurrentIndex(int index); - void moveWidgetToTop(); - void popupRequested(bool focus); }; - SearchResultWindowPrivate::SearchResultWindowPrivate(SearchResultWindow *window) - : q(window), - m_tabWidth(8) + SearchResultWindowPrivate::SearchResultWindowPrivate(SearchResultWindow *window, QWidget *nsp) : + q(window), + m_expandCollapseButton(0), + m_expandCollapseAction(new QAction(tr("Expand All"), window)), + m_spacer(new QWidget), + m_historyLabel(new QLabel(tr("History:"))), + m_spacer2(new QWidget), + m_recentSearchesBox(new QComboBox), + m_widget(new QStackedWidget), + m_currentIndex(0), + m_tabWidth(8) { - } + m_spacer->setMinimumWidth(30); + m_spacer2->setMinimumWidth(5); + m_recentSearchesBox->setProperty("drawleftborder", true); + m_recentSearchesBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); + m_recentSearchesBox->addItem(tr("New Search")); + connect(m_recentSearchesBox, static_cast(&QComboBox::activated), + this, &SearchResultWindowPrivate::setCurrentIndexWithFocus); - bool SearchResultWindowPrivate::isSearchVisible() const - { - return m_currentIndex > 0; - } + m_widget->setWindowTitle(q->displayName()); + + auto newSearchArea = new InternalScrollArea(m_widget); + newSearchArea->setWidget(nsp); + newSearchArea->setFocusProxy(nsp); + m_widget->addWidget(newSearchArea); + + m_expandCollapseButton = new QToolButton(m_widget); + m_expandCollapseButton->setAutoRaise(true); + + m_expandCollapseAction->setCheckable(true); + m_expandCollapseAction->setIcon(QIcon(QLatin1String(":/find/images/expand.png"))); + Command *cmd = ActionManager::registerAction(m_expandCollapseAction, "Find.ExpandAll"); + cmd->setAttribute(Command::CA_UpdateText); + m_expandCollapseButton->setDefaultAction(cmd->action()); + + connect(m_expandCollapseAction, &QAction::toggled, this, + &SearchResultWindowPrivate::handleExpandCollapseToolButton); - int SearchResultWindowPrivate::visibleSearchIndex() const - { - return m_currentIndex - 1; } void SearchResultWindowPrivate::setCurrentIndex(int index, bool focus) @@ -145,11 +170,6 @@ namespace Internal { q->navigateStateChanged(); } - void SearchResultWindowPrivate::setCurrentIndex(int index) - { - setCurrentIndex(index, true/*focus*/); - } - void SearchResultWindowPrivate::moveWidgetToTop() { SearchResultWidget *widget = qobject_cast(sender()); @@ -277,43 +297,9 @@ SearchResultWindow *SearchResultWindow::m_instance = 0; \internal */ SearchResultWindow::SearchResultWindow(QWidget *newSearchPanel) - : d(new SearchResultWindowPrivate(this)) + : d(new SearchResultWindowPrivate(this, newSearchPanel)) { m_instance = this; - - d->m_spacer = new QWidget; - d->m_spacer->setMinimumWidth(30); - d->m_historyLabel = new QLabel(tr("History:")); - d->m_spacer2 = new QWidget; - d->m_spacer2->setMinimumWidth(5); - d->m_recentSearchesBox = new QComboBox; - d->m_recentSearchesBox->setProperty("drawleftborder", true); - d->m_recentSearchesBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); - d->m_recentSearchesBox->addItem(tr("New Search")); - connect(d->m_recentSearchesBox, SIGNAL(activated(int)), d, SLOT(setCurrentIndex(int))); - - d->m_widget = new QStackedWidget; - d->m_widget->setWindowTitle(displayName()); - - InternalScrollArea *newSearchArea = new InternalScrollArea(d->m_widget); - newSearchArea->setWidget(newSearchPanel); - newSearchArea->setFocusProxy(newSearchPanel); - d->m_widget->addWidget(newSearchArea); - d->m_currentIndex = 0; - - d->m_expandCollapseButton = new QToolButton(d->m_widget); - d->m_expandCollapseButton->setAutoRaise(true); - - d->m_expandCollapseAction = new QAction(tr("Expand All"), this); - d->m_expandCollapseAction->setCheckable(true); - d->m_expandCollapseAction->setIcon(QIcon(QLatin1String(":/find/images/expand.png"))); - Command *cmd = ActionManager::registerAction( - d->m_expandCollapseAction, "Find.ExpandAll", - Context(Constants::C_GLOBAL)); - cmd->setAttribute(Command::CA_UpdateText); - d->m_expandCollapseButton->setDefaultAction(cmd->action()); - - connect(d->m_expandCollapseAction, SIGNAL(toggled(bool)), this, SLOT(handleExpandCollapseToolButton(bool))); readSettings(); } @@ -401,12 +387,15 @@ SearchResult *SearchResultWindow::startNewSearch(const QString &label, d->m_currentIndex = d->m_recentSearchesBox->count() - 1; } } - Internal::SearchResultWidget *widget = new Internal::SearchResultWidget; + auto widget = new SearchResultWidget; d->m_searchResultWidgets.prepend(widget); d->m_widget->insertWidget(1, widget); - connect(widget, SIGNAL(navigateStateChanged()), this, SLOT(navigateStateChanged())); - connect(widget, SIGNAL(restarted()), d, SLOT(moveWidgetToTop())); - connect(widget, SIGNAL(requestPopup(bool)), d, SLOT(popupRequested(bool))); + connect(widget, &SearchResultWidget::navigateStateChanged, + this, &SearchResultWindow::navigateStateChanged); + connect(widget, &SearchResultWidget::restarted, + d, &SearchResultWindowPrivate::moveWidgetToTop); + connect(widget, &SearchResultWidget::requestPopup, + d, &SearchResultWindowPrivate::popupRequested); widget->setTextEditorFont(d->m_font, d->m_color); widget->setTabWidth(d->m_tabWidth); widget->setSupportPreserveCase(preserveCaseMode == PreserveCaseEnabled); @@ -415,12 +404,12 @@ SearchResult *SearchResultWindow::startNewSearch(const QString &label, widget->setInfo(label, toolTip, searchTerm); if (searchOrSearchAndReplace == SearchAndReplace) widget->setDontAskAgainGroup(cfgGroup); - SearchResult *result = new SearchResult(widget); + auto result = new SearchResult(widget); d->m_searchResults.prepend(result); d->m_recentSearchesBox->insertItem(1, tr("%1 %2").arg(label, searchTerm)); if (d->m_currentIndex > 0) ++d->m_currentIndex; // so setCurrentIndex still knows about the right "currentIndex" and its widget - d->setCurrentIndex(1); + d->setCurrentIndexWithFocus(1); return result; } @@ -509,24 +498,21 @@ void SearchResultWindow::setTabWidth(int tabWidth) void SearchResultWindow::openNewSearchPanel() { - d->setCurrentIndex(0); + d->setCurrentIndexWithFocus(0); popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus | IOutputPane::EnsureSizeHint); } -/*! - \internal -*/ -void SearchResultWindow::handleExpandCollapseToolButton(bool checked) +void SearchResultWindowPrivate::handleExpandCollapseToolButton(bool checked) { - if (!d->isSearchVisible()) + if (!isSearchVisible()) return; - d->m_searchResultWidgets.at(d->visibleSearchIndex())->setAutoExpandResults(checked); + m_searchResultWidgets.at(visibleSearchIndex())->setAutoExpandResults(checked); if (checked) { - d->m_expandCollapseAction->setText(tr("Collapse All")); - d->m_searchResultWidgets.at(d->visibleSearchIndex())->expandAll(); + m_expandCollapseAction->setText(tr("Collapse All")); + m_searchResultWidgets.at(visibleSearchIndex())->expandAll(); } else { - d->m_expandCollapseAction->setText(tr("Expand All")); - d->m_searchResultWidgets.at(d->visibleSearchIndex())->collapseAll(); + m_expandCollapseAction->setText(tr("Expand All")); + m_searchResultWidgets.at(visibleSearchIndex())->collapseAll(); } } @@ -612,18 +598,15 @@ bool SearchResultWindow::canNavigate() const SearchResult::SearchResult(SearchResultWidget *widget) : m_widget(widget) { - connect(widget, SIGNAL(activated(Core::SearchResultItem)), - this, SIGNAL(activated(Core::SearchResultItem))); - connect(widget, SIGNAL(replaceButtonClicked(QString,QList,bool)), - this, SIGNAL(replaceButtonClicked(QString,QList,bool))); - connect(widget, SIGNAL(cancelled()), - this, SIGNAL(cancelled())); - connect(widget, SIGNAL(paused(bool)), - this, SIGNAL(paused(bool))); - connect(widget, SIGNAL(visibilityChanged(bool)), - this, SIGNAL(visibilityChanged(bool))); - connect(widget, SIGNAL(searchAgainRequested()), - this, SIGNAL(searchAgainRequested())); + connect(widget, &SearchResultWidget::activated, this, &SearchResult::activated); + connect(widget, &SearchResultWidget::replaceButtonClicked, + this, &SearchResult::replaceButtonClicked); + connect(widget, &SearchResultWidget::cancelled, this, &SearchResult::cancelled); + connect(widget, &SearchResultWidget::paused, this, &SearchResult::paused); + connect(widget, &SearchResultWidget::visibilityChanged, + this, &SearchResult::visibilityChanged); + connect(widget, &SearchResultWidget::searchAgainRequested, + this, &SearchResult::searchAgainRequested); } /*! diff --git a/src/plugins/coreplugin/find/searchresultwindow.h b/src/plugins/coreplugin/find/searchresultwindow.h index 0155885b67f..fc34fec54d9 100644 --- a/src/plugins/coreplugin/find/searchresultwindow.h +++ b/src/plugins/coreplugin/find/searchresultwindow.h @@ -186,9 +186,6 @@ public: public slots: void clearContents(); -private slots: - void handleExpandCollapseToolButton(bool checked); - public: // Used by plugin, do not use void writeSettings(); diff --git a/src/plugins/coreplugin/idocument.cpp b/src/plugins/coreplugin/idocument.cpp index 075f13c2382..1425aec53b4 100644 --- a/src/plugins/coreplugin/idocument.cpp +++ b/src/plugins/coreplugin/idocument.cpp @@ -83,7 +83,8 @@ public: QString mimeType; Utils::FileName filePath; - QString displayName; + QString preferredDisplayName; + QString uniqueDisplayName; QString autoSaveName; InfoBar *infoBar; Id id; @@ -128,7 +129,7 @@ bool IDocument::setContents(const QByteArray &contents) return false; } -Utils::FileName IDocument::filePath() const +const Utils::FileName &IDocument::filePath() const { return d->filePath; } @@ -258,13 +259,16 @@ void IDocument::setFilePath(const Utils::FileName &filePath) /*! Returns the string to display for this document, e.g. in the open document combo box and pane. + The returned string has the following priority: + * Unique display name set by the document model + * Preferred display name set by the owner + * Base name of the document's file name + \sa setDisplayName() */ QString IDocument::displayName() const { - if (!d->displayName.isEmpty()) - return d->displayName; - return d->filePath.fileName(); + return d->uniqueDisplayName.isEmpty() ? plainDisplayName() : d->uniqueDisplayName; } /*! @@ -274,12 +278,30 @@ QString IDocument::displayName() const \sa displayName() \sa filePath() */ -void IDocument::setDisplayName(const QString &name) +void IDocument::setPreferredDisplayName(const QString &name) { - if (name == d->displayName) + if (name == d->preferredDisplayName) return; - d->displayName = name; + d->preferredDisplayName = name; emit changed(); } +/*! + \internal + Returns displayName without disambiguation. + */ +QString IDocument::plainDisplayName() const +{ + return d->preferredDisplayName.isEmpty() ? d->filePath.fileName() : d->preferredDisplayName; +} + +/*! + \internal + Sets unique display name for the document. Used by the document model. + */ +void IDocument::setUniqueDisplayName(const QString &name) +{ + d->uniqueDisplayName = name; +} + } // namespace Core diff --git a/src/plugins/coreplugin/idocument.h b/src/plugins/coreplugin/idocument.h index c5e4fa79f9d..450a9bed17b 100644 --- a/src/plugins/coreplugin/idocument.h +++ b/src/plugins/coreplugin/idocument.h @@ -89,10 +89,12 @@ public: virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false) = 0; virtual bool setContents(const QByteArray &contents); - Utils::FileName filePath() const; + const Utils::FileName &filePath() const; virtual void setFilePath(const Utils::FileName &filePath); QString displayName() const; - void setDisplayName(const QString &name); + void setPreferredDisplayName(const QString &name); + QString plainDisplayName() const; + void setUniqueDisplayName(const QString &name); virtual bool isFileReadOnly() const; bool isTemporary() const; diff --git a/src/plugins/coreplugin/locator/locator.cpp b/src/plugins/coreplugin/locator/locator.cpp index f0b60c6ef6e..6e80703cd17 100644 --- a/src/plugins/coreplugin/locator/locator.cpp +++ b/src/plugins/coreplugin/locator/locator.cpp @@ -98,8 +98,7 @@ void Locator::initialize(CorePlugin *corePlugin, const QStringList &, QString *) m_corePlugin->addAutoReleasedObject(view); QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this); - Command *cmd = ActionManager::registerAction(action, Constants::LOCATE, - Context(Constants::C_GLOBAL)); + Command *cmd = ActionManager::registerAction(action, Constants::LOCATE); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+K"))); connect(action, &QAction::triggered, this, &Locator::openLocator); connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePlaceholderText())); diff --git a/src/plugins/coreplugin/locator/locatorwidget.cpp b/src/plugins/coreplugin/locator/locatorwidget.cpp index f05f079770c..5c38f647c81 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.cpp +++ b/src/plugins/coreplugin/locator/locatorwidget.cpp @@ -327,8 +327,7 @@ void LocatorWidget::updateFilterList() if (!actionCopy.contains(filterId)) { // register new action action = new QAction(filter->displayName(), this); - cmd = ActionManager::registerAction(action, locatorId, - Context(Constants::C_GLOBAL)); + cmd = ActionManager::registerAction(action, locatorId); cmd->setAttribute(Command::CA_UpdateText); connect(action, SIGNAL(triggered()), this, SLOT(filterSelected())); action->setData(qVariantFromValue(filter)); diff --git a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp index 8be5d2b6662..68cd2597412 100644 --- a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp +++ b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp @@ -50,10 +50,12 @@ OpenDocumentsFilter::OpenDocumentsFilter() setPriority(High); setIncludedByDefault(true); - connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)), - this, SLOT(refreshInternally())); - connect(EditorManager::instance(), SIGNAL(editorsClosed(QList)), - this, SLOT(refreshInternally())); + connect(DocumentModel::model(), &QAbstractItemModel::dataChanged, + this, &OpenDocumentsFilter::refreshInternally); + connect(DocumentModel::model(), &QAbstractItemModel::rowsInserted, + this, &OpenDocumentsFilter::refreshInternally); + connect(DocumentModel::model(), &QAbstractItemModel::rowsRemoved, + this, &OpenDocumentsFilter::refreshInternally); } QList OpenDocumentsFilter::matchesFor(QFutureInterface &future, const QString &entry_) @@ -78,9 +80,8 @@ QList OpenDocumentsFilter::matchesFor(QFutureInterface &category = displayName.startsWith(entry, caseSensitivityForPrefix) ? betterEntries : goodEntries; diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index dd04c34010e..c8e61cb901b 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -468,30 +468,28 @@ void MainWindow::registerDefaultActions() ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW); ActionContainer *mhelp = ActionManager::actionContainer(Constants::M_HELP); - Context globalContext(Constants::C_GLOBAL); - // File menu separators - mfile->addSeparator(globalContext, Constants::G_FILE_SAVE); - mfile->addSeparator(globalContext, Constants::G_FILE_PRINT); - mfile->addSeparator(globalContext, Constants::G_FILE_CLOSE); - mfile->addSeparator(globalContext, Constants::G_FILE_OTHER); + mfile->addSeparator(Constants::G_FILE_SAVE); + mfile->addSeparator(Constants::G_FILE_PRINT); + mfile->addSeparator(Constants::G_FILE_CLOSE); + mfile->addSeparator(Constants::G_FILE_OTHER); // Edit menu separators - medit->addSeparator(globalContext, Constants::G_EDIT_COPYPASTE); - medit->addSeparator(globalContext, Constants::G_EDIT_SELECTALL); - medit->addSeparator(globalContext, Constants::G_EDIT_FIND); - medit->addSeparator(globalContext, Constants::G_EDIT_ADVANCED); + medit->addSeparator(Constants::G_EDIT_COPYPASTE); + medit->addSeparator(Constants::G_EDIT_SELECTALL); + medit->addSeparator(Constants::G_EDIT_FIND); + medit->addSeparator(Constants::G_EDIT_ADVANCED); // Return to editor shortcut: Note this requires Qt to fix up // handling of shortcut overrides in menus, item views, combos.... m_focusToEditor = new QAction(tr("Return to Editor"), this); - Command *cmd = ActionManager::registerAction(m_focusToEditor, Constants::S_RETURNTOEDITOR, globalContext); + Command *cmd = ActionManager::registerAction(m_focusToEditor, Constants::S_RETURNTOEDITOR); cmd->setDefaultKeySequence(QKeySequence(Qt::Key_Escape)); connect(m_focusToEditor, SIGNAL(triggered()), this, SLOT(setFocusToEditor())); // New File Action QIcon icon = QIcon::fromTheme(QLatin1String("document-new"), QIcon(QLatin1String(Constants::ICON_NEWFILE))); m_newAction = new QAction(icon, tr("&New File or Project..."), this); - cmd = ActionManager::registerAction(m_newAction, Constants::NEW, globalContext); + cmd = ActionManager::registerAction(m_newAction, Constants::NEW); cmd->setDefaultKeySequence(QKeySequence::New); mfile->addAction(cmd, Constants::G_FILE_NEW); connect(m_newAction, SIGNAL(triggered()), this, SLOT(newFile())); @@ -499,14 +497,14 @@ void MainWindow::registerDefaultActions() // Open Action icon = QIcon::fromTheme(QLatin1String("document-open"), QIcon(QLatin1String(Constants::ICON_OPENFILE))); m_openAction = new QAction(icon, tr("&Open File or Project..."), this); - cmd = ActionManager::registerAction(m_openAction, Constants::OPEN, globalContext); + cmd = ActionManager::registerAction(m_openAction, Constants::OPEN); cmd->setDefaultKeySequence(QKeySequence::Open); mfile->addAction(cmd, Constants::G_FILE_OPEN); connect(m_openAction, SIGNAL(triggered()), this, SLOT(openFile())); // Open With Action m_openWithAction = new QAction(tr("Open File &With..."), this); - cmd = ActionManager::registerAction(m_openWithAction, Constants::OPEN_WITH, globalContext); + cmd = ActionManager::registerAction(m_openWithAction, Constants::OPEN_WITH); mfile->addAction(cmd, Constants::G_FILE_OPEN); connect(m_openWithAction, SIGNAL(triggered()), this, SLOT(openFileWith())); @@ -520,7 +518,7 @@ void MainWindow::registerDefaultActions() icon = QIcon::fromTheme(QLatin1String("document-save"), QIcon(QLatin1String(Constants::ICON_SAVEFILE))); QAction *tmpaction = new QAction(icon, tr("&Save"), this); tmpaction->setEnabled(false); - cmd = ActionManager::registerAction(tmpaction, Constants::SAVE, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::SAVE); cmd->setDefaultKeySequence(QKeySequence::Save); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(tr("Save")); @@ -530,7 +528,7 @@ void MainWindow::registerDefaultActions() icon = QIcon::fromTheme(QLatin1String("document-save-as")); tmpaction = new QAction(icon, tr("Save &As..."), this); tmpaction->setEnabled(false); - cmd = ActionManager::registerAction(tmpaction, Constants::SAVEAS, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::SAVEAS); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+S") : QString())); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(tr("Save As...")); @@ -538,7 +536,7 @@ void MainWindow::registerDefaultActions() // SaveAll Action m_saveAllAction = new QAction(tr("Save A&ll"), this); - cmd = ActionManager::registerAction(m_saveAllAction, Constants::SAVEALL, globalContext); + cmd = ActionManager::registerAction(m_saveAllAction, Constants::SAVEALL); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? QString() : tr("Ctrl+Shift+S"))); mfile->addAction(cmd, Constants::G_FILE_SAVE); connect(m_saveAllAction, SIGNAL(triggered()), this, SLOT(saveAll())); @@ -547,7 +545,7 @@ void MainWindow::registerDefaultActions() icon = QIcon::fromTheme(QLatin1String("document-print")); tmpaction = new QAction(icon, tr("&Print..."), this); tmpaction->setEnabled(false); - cmd = ActionManager::registerAction(tmpaction, Constants::PRINT, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::PRINT); cmd->setDefaultKeySequence(QKeySequence::Print); mfile->addAction(cmd, Constants::G_FILE_PRINT); @@ -555,7 +553,7 @@ void MainWindow::registerDefaultActions() icon = QIcon::fromTheme(QLatin1String("application-exit")); m_exitAction = new QAction(icon, tr("E&xit"), this); m_exitAction->setMenuRole(QAction::QuitRole); - cmd = ActionManager::registerAction(m_exitAction, Constants::EXIT, globalContext); + cmd = ActionManager::registerAction(m_exitAction, Constants::EXIT); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Q"))); mfile->addAction(cmd, Constants::G_FILE_OTHER); connect(m_exitAction, SIGNAL(triggered()), this, SLOT(exit())); @@ -563,7 +561,7 @@ void MainWindow::registerDefaultActions() // Undo Action icon = QIcon::fromTheme(QLatin1String("edit-undo"), QIcon(QLatin1String(Constants::ICON_UNDO))); tmpaction = new QAction(icon, tr("&Undo"), this); - cmd = ActionManager::registerAction(tmpaction, Constants::UNDO, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::UNDO); cmd->setDefaultKeySequence(QKeySequence::Undo); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(tr("Undo")); @@ -573,7 +571,7 @@ void MainWindow::registerDefaultActions() // Redo Action icon = QIcon::fromTheme(QLatin1String("edit-redo"), QIcon(QLatin1String(Constants::ICON_REDO))); tmpaction = new QAction(icon, tr("&Redo"), this); - cmd = ActionManager::registerAction(tmpaction, Constants::REDO, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::REDO); cmd->setDefaultKeySequence(QKeySequence::Redo); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(tr("Redo")); @@ -583,7 +581,7 @@ void MainWindow::registerDefaultActions() // Cut Action icon = QIcon::fromTheme(QLatin1String("edit-cut"), QIcon(QLatin1String(Constants::ICON_CUT))); tmpaction = new QAction(icon, tr("Cu&t"), this); - cmd = ActionManager::registerAction(tmpaction, Constants::CUT, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::CUT); cmd->setDefaultKeySequence(QKeySequence::Cut); medit->addAction(cmd, Constants::G_EDIT_COPYPASTE); tmpaction->setEnabled(false); @@ -591,7 +589,7 @@ void MainWindow::registerDefaultActions() // Copy Action icon = QIcon::fromTheme(QLatin1String("edit-copy"), QIcon(QLatin1String(Constants::ICON_COPY))); tmpaction = new QAction(icon, tr("&Copy"), this); - cmd = ActionManager::registerAction(tmpaction, Constants::COPY, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::COPY); cmd->setDefaultKeySequence(QKeySequence::Copy); medit->addAction(cmd, Constants::G_EDIT_COPYPASTE); tmpaction->setEnabled(false); @@ -599,7 +597,7 @@ void MainWindow::registerDefaultActions() // Paste Action icon = QIcon::fromTheme(QLatin1String("edit-paste"), QIcon(QLatin1String(Constants::ICON_PASTE))); tmpaction = new QAction(icon, tr("&Paste"), this); - cmd = ActionManager::registerAction(tmpaction, Constants::PASTE, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::PASTE); cmd->setDefaultKeySequence(QKeySequence::Paste); medit->addAction(cmd, Constants::G_EDIT_COPYPASTE); tmpaction->setEnabled(false); @@ -607,7 +605,7 @@ void MainWindow::registerDefaultActions() // Select All icon = QIcon::fromTheme(QLatin1String("edit-select-all")); tmpaction = new QAction(icon, tr("Select &All"), this); - cmd = ActionManager::registerAction(tmpaction, Constants::SELECTALL, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::SELECTALL); cmd->setDefaultKeySequence(QKeySequence::SelectAll); medit->addAction(cmd, Constants::G_EDIT_SELECTALL); tmpaction->setEnabled(false); @@ -615,36 +613,36 @@ void MainWindow::registerDefaultActions() // Goto Action icon = QIcon::fromTheme(QLatin1String("go-jump")); tmpaction = new QAction(icon, tr("&Go to Line..."), this); - cmd = ActionManager::registerAction(tmpaction, Constants::GOTO, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::GOTO); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+L"))); medit->addAction(cmd, Constants::G_EDIT_OTHER); tmpaction->setEnabled(false); // Options Action mtools->appendGroup(Constants::G_TOOLS_OPTIONS); - mtools->addSeparator(globalContext, Constants::G_TOOLS_OPTIONS); + mtools->addSeparator(Constants::G_TOOLS_OPTIONS); m_optionsAction = new QAction(tr("&Options..."), this); m_optionsAction->setMenuRole(QAction::PreferencesRole); - cmd = ActionManager::registerAction(m_optionsAction, Constants::OPTIONS, globalContext); + cmd = ActionManager::registerAction(m_optionsAction, Constants::OPTIONS); cmd->setDefaultKeySequence(QKeySequence::Preferences); mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS); connect(m_optionsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog())); - mwindow->addSeparator(globalContext, Constants::G_WINDOW_LIST); + mwindow->addSeparator(Constants::G_WINDOW_LIST); if (UseMacShortcuts) { // Minimize Action QAction *minimizeAction = new QAction(tr("Minimize"), this); minimizeAction->setEnabled(false); // actual implementation in WindowSupport - cmd = ActionManager::registerAction(minimizeAction, Constants::MINIMIZE_WINDOW, globalContext); + cmd = ActionManager::registerAction(minimizeAction, Constants::MINIMIZE_WINDOW); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+M"))); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); // Zoom Action QAction *zoomAction = new QAction(tr("Zoom"), this); zoomAction->setEnabled(false); // actual implementation in WindowSupport - cmd = ActionManager::registerAction(zoomAction, Constants::ZOOM_WINDOW, globalContext); + cmd = ActionManager::registerAction(zoomAction, Constants::ZOOM_WINDOW); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); } @@ -652,29 +650,29 @@ void MainWindow::registerDefaultActions() QAction *toggleFullScreenAction = new QAction(tr("Full Screen"), this); toggleFullScreenAction->setCheckable(!HostOsInfo::isMacHost()); toggleFullScreenAction->setEnabled(false); // actual implementation in WindowSupport - cmd = ActionManager::registerAction(toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext); + cmd = ActionManager::registerAction(toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11"))); if (HostOsInfo::isMacHost()) cmd->setAttribute(Command::CA_UpdateText); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); if (UseMacShortcuts) { - mwindow->addSeparator(globalContext, Constants::G_WINDOW_SIZE); + mwindow->addSeparator(Constants::G_WINDOW_SIZE); QAction *closeAction = new QAction(tr("Close Window"), this); closeAction->setEnabled(false); - cmd = ActionManager::registerAction(closeAction, Constants::CLOSE_WINDOW, globalContext); + cmd = ActionManager::registerAction(closeAction, Constants::CLOSE_WINDOW); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Meta+W"))); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); - mwindow->addSeparator(globalContext, Constants::G_WINDOW_SIZE); + mwindow->addSeparator(Constants::G_WINDOW_SIZE); } // Show Sidebar Action m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Constants::ICON_TOGGLE_SIDEBAR)), tr(Constants::TR_SHOW_SIDEBAR), this); m_toggleSideBarAction->setCheckable(true); - cmd = ActionManager::registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR, globalContext); + cmd = ActionManager::registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR); cmd->setAttribute(Command::CA_UpdateText); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+0") : tr("Alt+0"))); connect(m_toggleSideBarAction, &QAction::triggered, this, &MainWindow::setSidebarVisible); @@ -685,7 +683,7 @@ void MainWindow::registerDefaultActions() // Show Mode Selector Action m_toggleModeSelectorAction = new QAction(tr("Show Mode Selector"), this); m_toggleModeSelectorAction->setCheckable(true); - cmd = ActionManager::registerAction(m_toggleModeSelectorAction, Constants::TOGGLE_MODE_SELECTOR, globalContext); + cmd = ActionManager::registerAction(m_toggleModeSelectorAction, Constants::TOGGLE_MODE_SELECTOR); connect(m_toggleModeSelectorAction, &QAction::triggered, ModeManager::instance(), &ModeManager::setModeSelectorVisible); mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS); @@ -695,9 +693,9 @@ void MainWindow::registerDefaultActions() mviews->menu()->setTitle(tr("&Views")); // "Help" separators - mhelp->addSeparator(globalContext, Constants::G_HELP_SUPPORT); + mhelp->addSeparator(Constants::G_HELP_SUPPORT); if (!HostOsInfo::isMacHost()) - mhelp->addSeparator(globalContext, Constants::G_HELP_ABOUT); + mhelp->addSeparator(Constants::G_HELP_ABOUT); // About IDE Action icon = QIcon::fromTheme(QLatin1String("help-about")); @@ -706,7 +704,7 @@ void MainWindow::registerDefaultActions() else tmpaction = new QAction(icon, tr("About &Qt Creator..."), this); tmpaction->setMenuRole(QAction::AboutRole); - cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_QTCREATOR, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_QTCREATOR); mhelp->addAction(cmd, Constants::G_HELP_ABOUT); tmpaction->setEnabled(true); connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutQtCreator); @@ -714,13 +712,13 @@ void MainWindow::registerDefaultActions() //About Plugins Action tmpaction = new QAction(tr("About &Plugins..."), this); tmpaction->setMenuRole(QAction::ApplicationSpecificRole); - cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_PLUGINS, globalContext); + cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_PLUGINS); mhelp->addAction(cmd, Constants::G_HELP_ABOUT); tmpaction->setEnabled(true); connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutPlugins); // About Qt Action // tmpaction = new QAction(tr("About &Qt..."), this); -// cmd = ActionManager::registerAction(tmpaction, Constants:: ABOUT_QT, globalContext); +// cmd = ActionManager::registerAction(tmpaction, Constants:: ABOUT_QT); // mhelp->addAction(cmd, Constants::G_HELP_ABOUT); // tmpaction->setEnabled(true); // connect(tmpaction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); @@ -728,7 +726,7 @@ void MainWindow::registerDefaultActions() if (!HostOsInfo::isMacHost()) { // doesn't have the "About" actions in the Help menu tmpaction = new QAction(this); tmpaction->setSeparator(true); - cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About", globalContext); + cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About"); mhelp->addAction(cmd, Constants::G_HELP_ABOUT); } } diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp index 0b21a24ac78..800d125d212 100644 --- a/src/plugins/coreplugin/modemanager.cpp +++ b/src/plugins/coreplugin/modemanager.cpp @@ -180,7 +180,7 @@ void ModeManager::objectAdded(QObject *obj) // Register mode shortcut const Id actionId = mode->id().withPrefix("QtCreator.Mode."); QAction *action = new QAction(tr("Switch to %1 mode").arg(mode->displayName()), this); - Command *cmd = ActionManager::registerAction(action, actionId, Context(Constants::C_GLOBAL)); + Command *cmd = ActionManager::registerAction(action, actionId); d->m_modeCommands.insert(index, cmd); connect(cmd, SIGNAL(keySequenceChanged()), m_instance, SLOT(updateModeToolTip())); diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp index e95ded4b2ab..14865ff866b 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -203,7 +203,6 @@ static inline int paneShortCut(int number) void OutputPaneManager::init() { ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW); - const Context globalContext(Constants::C_GLOBAL); // Window->Output Panes ActionContainer *mpanes = ActionManager::createMenu(Constants::M_WINDOW_PANES); @@ -214,21 +213,21 @@ void OutputPaneManager::init() Command *cmd; - cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear", globalContext); + cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear"); m_clearButton->setDefaultAction(cmd->action()); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); - cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalContext); + cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem"); cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6"))); m_prevToolButton->setDefaultAction(cmd->action()); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); - cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalContext); + cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem"); m_nextToolButton->setDefaultAction(cmd->action()); cmd->setDefaultKeySequence(QKeySequence(tr("F6"))); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); - cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalContext); + cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax"); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+9") : tr("Alt+9"))); cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateIcon); @@ -236,7 +235,7 @@ void OutputPaneManager::init() connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax())); m_minMaxButton->setDefaultAction(cmd->action()); - mpanes->addSeparator(globalContext, "Coreplugin.OutputPane.ActionsGroup"); + mpanes->addSeparator("Coreplugin.OutputPane.ActionsGroup"); QFontMetrics titleFm = m_titleLabel->fontMetrics(); int minTitleWidth = 0; @@ -278,7 +277,7 @@ void OutputPaneManager::init() suffix.remove(QLatin1Char(' ')); const Id id = baseId.withSuffix(suffix); QAction *action = new QAction(outPane->displayName(), this); - Command *cmd = ActionManager::registerAction(action, id, globalContext); + Command *cmd = ActionManager::registerAction(action, id); mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup"); m_actions.append(action); diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp index 50914b7fc88..030857a7639 100644 --- a/src/plugins/coreplugin/outputwindow.cpp +++ b/src/plugins/coreplugin/outputwindow.cpp @@ -34,6 +34,7 @@ #include "coreconstants.h" #include "icore.h" +#include #include #include @@ -43,16 +44,47 @@ using namespace Utils; namespace Core { +namespace Internal { + +class OutputWindowPrivate +{ +public: + OutputWindowPrivate(QTextDocument *document) + : outputWindowContext(0) + , formatter(0) + , enforceNewline(false) + , scrollToBottom(false) + , linksActive(true) + , mousePressed(false) + , maxLineCount(100000) + , cursor(document) + { + } + + ~OutputWindowPrivate() + { + ICore::removeContextObject(outputWindowContext); + delete outputWindowContext; + } + + IContext *outputWindowContext; + Utils::OutputFormatter *formatter; + + bool enforceNewline; + bool scrollToBottom; + bool linksActive; + bool mousePressed; + int maxLineCount; + QTextCursor cursor; +}; + +} // namespace Internal + /*******************/ OutputWindow::OutputWindow(Context context, QWidget *parent) : QPlainTextEdit(parent) - , m_formatter(0) - , m_enforceNewline(false) - , m_scrollToBottom(false) - , m_linksActive(true) - , m_mousePressed(false) - , m_maxLineCount(100000) + , d(new Internal::OutputWindowPrivate(document())) { setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); //setCenterOnScroll(false); @@ -60,10 +92,10 @@ OutputWindow::OutputWindow(Context context, QWidget *parent) setMouseTracking(true); setUndoRedoEnabled(false); - m_outputWindowContext = new IContext; - m_outputWindowContext->setContext(context); - m_outputWindowContext->setWidget(this); - ICore::addContextObject(m_outputWindowContext); + d->outputWindowContext = new IContext; + d->outputWindowContext->setContext(context); + d->outputWindowContext->setWidget(this); + ICore::addContextObject(d->outputWindowContext); QAction *undoAction = new QAction(this); QAction *redoAction = new QAction(this); @@ -99,28 +131,27 @@ OutputWindow::OutputWindow(Context context, QWidget *parent) OutputWindow::~OutputWindow() { - ICore::removeContextObject(m_outputWindowContext); - delete m_outputWindowContext; + delete d; } void OutputWindow::mousePressEvent(QMouseEvent * e) { - m_mousePressed = true; + d->mousePressed = true; QPlainTextEdit::mousePressEvent(e); } void OutputWindow::mouseReleaseEvent(QMouseEvent *e) { - m_mousePressed = false; + d->mousePressed = false; - if (m_linksActive) { + if (d->linksActive) { const QString href = anchorAt(e->pos()); - if (m_formatter) - m_formatter->handleLink(href); + if (d->formatter) + d->formatter->handleLink(href); } // Mouse was released, activate links again - m_linksActive = true; + d->linksActive = true; QPlainTextEdit::mouseReleaseEvent(e); } @@ -128,10 +159,10 @@ void OutputWindow::mouseReleaseEvent(QMouseEvent *e) void OutputWindow::mouseMoveEvent(QMouseEvent *e) { // Cursor was dragged to make a selection, deactivate links - if (m_mousePressed && textCursor().hasSelection()) - m_linksActive = false; + if (d->mousePressed && textCursor().hasSelection()) + d->linksActive = false; - if (!m_linksActive || anchorAt(e->pos()).isEmpty()) + if (!d->linksActive || anchorAt(e->pos()).isEmpty()) viewport()->setCursor(Qt::IBeamCursor); else viewport()->setCursor(Qt::PointingHandCursor); @@ -161,34 +192,34 @@ void OutputWindow::keyPressEvent(QKeyEvent *ev) OutputFormatter *OutputWindow::formatter() const { - return m_formatter; + return d->formatter; } void OutputWindow::setFormatter(OutputFormatter *formatter) { - m_formatter = formatter; - m_formatter->setPlainTextEdit(this); + d->formatter = formatter; + d->formatter->setPlainTextEdit(this); } void OutputWindow::showEvent(QShowEvent *e) { QPlainTextEdit::showEvent(e); - if (m_scrollToBottom) + if (d->scrollToBottom) verticalScrollBar()->setValue(verticalScrollBar()->maximum()); - m_scrollToBottom = false; + d->scrollToBottom = false; } QString OutputWindow::doNewlineEnforcement(const QString &out) { - m_scrollToBottom = true; + d->scrollToBottom = true; QString s = out; - if (m_enforceNewline) { + if (d->enforceNewline) { s.prepend(QLatin1Char('\n')); - m_enforceNewline = false; + d->enforceNewline = false; } if (s.endsWith(QLatin1Char('\n'))) { - m_enforceNewline = true; // make appendOutputInline put in a newline next time + d->enforceNewline = true; // make appendOutputInline put in a newline next time s.chop(1); } @@ -197,19 +228,24 @@ QString OutputWindow::doNewlineEnforcement(const QString &out) void OutputWindow::setMaxLineCount(int count) { - m_maxLineCount = count; - setMaximumBlockCount(m_maxLineCount); + d->maxLineCount = count; + setMaximumBlockCount(d->maxLineCount); +} + +int OutputWindow::maxLineCount() const +{ + return d->maxLineCount; } void OutputWindow::appendMessage(const QString &output, OutputFormat format) { const QString out = SynchronousProcess::normalizeNewlines(output); - setMaximumBlockCount(m_maxLineCount); + setMaximumBlockCount(d->maxLineCount); const bool atBottom = isScrollbarAtBottom(); if (format == ErrorMessageFormat || format == NormalMessageFormat) { - m_formatter->appendMessage(doNewlineEnforcement(out), format); + d->formatter->appendMessage(doNewlineEnforcement(out), format); } else { @@ -217,31 +253,31 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format) || format == StdErrFormatSameLine; if (sameLine) { - m_scrollToBottom = true; + d->scrollToBottom = true; int newline = -1; - bool enforceNewline = m_enforceNewline; - m_enforceNewline = false; + bool enforceNewline = d->enforceNewline; + d->enforceNewline = false; if (!enforceNewline) { newline = out.indexOf(QLatin1Char('\n')); moveCursor(QTextCursor::End); if (newline != -1) - m_formatter->appendMessage(out.left(newline), format);// doesn't enforce new paragraph like appendPlainText + d->formatter->appendMessage(out.left(newline), format);// doesn't enforce new paragraph like appendPlainText } QString s = out.mid(newline+1); if (s.isEmpty()) { - m_enforceNewline = true; + d->enforceNewline = true; } else { if (s.endsWith(QLatin1Char('\n'))) { - m_enforceNewline = true; + d->enforceNewline = true; s.chop(1); } - m_formatter->appendMessage(QLatin1Char('\n') + s, format); + d->formatter->appendMessage(QLatin1Char('\n') + s, format); } } else { - m_formatter->appendMessage(doNewlineEnforcement(out), format); + d->formatter->appendMessage(doNewlineEnforcement(out), format); } } @@ -254,21 +290,21 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format) void OutputWindow::appendText(const QString &textIn, const QTextCharFormat &format) { const QString text = SynchronousProcess::normalizeNewlines(textIn); - if (m_maxLineCount > 0 && document()->blockCount() >= m_maxLineCount) + if (d->maxLineCount > 0 && document()->blockCount() >= d->maxLineCount) return; const bool atBottom = isScrollbarAtBottom(); - QTextCursor cursor = QTextCursor(document()); - cursor.movePosition(QTextCursor::End); - cursor.beginEditBlock(); - cursor.insertText(doNewlineEnforcement(text), format); + if (!d->cursor.atEnd()) + d->cursor.movePosition(QTextCursor::End); + d->cursor.beginEditBlock(); + d->cursor.insertText(doNewlineEnforcement(text), format); - if (m_maxLineCount > 0 && document()->blockCount() >= m_maxLineCount) { + if (d->maxLineCount > 0 && document()->blockCount() >= d->maxLineCount) { QTextCharFormat tmp; tmp.setFontWeight(QFont::Bold); - cursor.insertText(doNewlineEnforcement(tr("Additional output omitted") + QLatin1Char('\n')), tmp); + d->cursor.insertText(doNewlineEnforcement(tr("Additional output omitted") + QLatin1Char('\n')), tmp); } - cursor.endEditBlock(); + d->cursor.endEditBlock(); if (atBottom) scrollToBottom(); } @@ -280,7 +316,7 @@ bool OutputWindow::isScrollbarAtBottom() const void OutputWindow::clear() { - m_enforceNewline = false; + d->enforceNewline = false; QPlainTextEdit::clear(); } @@ -295,11 +331,11 @@ void OutputWindow::scrollToBottom() void OutputWindow::grayOutOldContent() { - QTextCursor cursor = textCursor(); - cursor.movePosition(QTextCursor::End); - QTextCharFormat endFormat = cursor.charFormat(); + if (!d->cursor.atEnd()) + d->cursor.movePosition(QTextCursor::End); + QTextCharFormat endFormat = d->cursor.charFormat(); - cursor.select(QTextCursor::Document); + d->cursor.select(QTextCursor::Document); QTextCharFormat format; const QColor bkgColor = palette().base().color(); @@ -309,11 +345,12 @@ void OutputWindow::grayOutOldContent() format.setForeground(QColor((bkgFactor * bkgColor.red() + fgdFactor * fgdColor.red()), (bkgFactor * bkgColor.green() + fgdFactor * fgdColor.green()), (bkgFactor * bkgColor.blue() + fgdFactor * fgdColor.blue()) )); - cursor.mergeCharFormat(format); + d->cursor.mergeCharFormat(format); - cursor.movePosition(QTextCursor::End); - cursor.setCharFormat(endFormat); - cursor.insertBlock(QTextBlockFormat()); + if (!d->cursor.atEnd()) + d->cursor.movePosition(QTextCursor::End); + d->cursor.setCharFormat(endFormat); + d->cursor.insertBlock(QTextBlockFormat()); } void OutputWindow::enableUndoRedo() diff --git a/src/plugins/coreplugin/outputwindow.h b/src/plugins/coreplugin/outputwindow.h index aefbc831073..a649a58c677 100644 --- a/src/plugins/coreplugin/outputwindow.h +++ b/src/plugins/coreplugin/outputwindow.h @@ -34,13 +34,15 @@ #include "core_global.h" #include "icontext.h" -#include +#include #include +namespace Utils { class OutputFormatter; } + namespace Core { -class IContext; +namespace Internal { class OutputWindowPrivate; } class CORE_EXPORT OutputWindow : public QPlainTextEdit { @@ -65,7 +67,7 @@ public: void scrollToBottom(); void setMaxLineCount(int count); - int maxLineCount() const { return m_maxLineCount; } + int maxLineCount() const; public slots: void setWordWrapEnabled(bool wrap); @@ -83,14 +85,7 @@ private: void enableUndoRedo(); QString doNewlineEnforcement(const QString &out); - IContext *m_outputWindowContext; - Utils::OutputFormatter *m_formatter; - - bool m_enforceNewline; - bool m_scrollToBottom; - bool m_linksActive; - bool m_mousePressed; - int m_maxLineCount; + Internal::OutputWindowPrivate *d; }; } // namespace Core diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp index 50cf7bc6ab5..dcfd838bcce 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp @@ -341,8 +341,7 @@ void ProgressManagerPrivate::init() p.fill(Qt::transparent); toggleProgressView->setIcon(QIcon(p)); Command *cmd = ActionManager::registerAction(toggleProgressView, - "QtCreator.ToggleProgressDetails", - Context(Constants::C_GLOBAL)); + "QtCreator.ToggleProgressDetails"); cmd->setDefaultKeySequence(QKeySequence(HostOsInfo::isMacHost() ? tr("Ctrl+Shift+0") : tr("Alt+Shift+0"))); diff --git a/src/plugins/coreplugin/themesettingswidget.cpp b/src/plugins/coreplugin/themesettingswidget.cpp index 2e05925e78a..f098762dc24 100644 --- a/src/plugins/coreplugin/themesettingswidget.cpp +++ b/src/plugins/coreplugin/themesettingswidget.cpp @@ -84,7 +84,7 @@ static QString createThemeFileName(const QString &pattern) struct ThemeEntry { - ThemeEntry() {} + ThemeEntry() : m_readOnly(true) {} ThemeEntry(const QString &name, const QString &filePath, bool readOnly): m_name(name), m_filePath(filePath), diff --git a/src/plugins/coreplugin/windowsupport.cpp b/src/plugins/coreplugin/windowsupport.cpp index ae229fef26c..742472e8f7d 100644 --- a/src/plugins/coreplugin/windowsupport.cpp +++ b/src/plugins/coreplugin/windowsupport.cpp @@ -166,8 +166,7 @@ void WindowList::addWindow(QWidget *window) QObject::connect(action, &QAction::triggered, [action]() { WindowList::activateWindow(action); }); action->setCheckable(true); action->setChecked(false); - Command *cmd = ActionManager::registerAction(action, id, - Context(Constants::C_GLOBAL)); + Command *cmd = ActionManager::registerAction(action, id); cmd->setAttribute(Command::CA_UpdateText); ActionManager::actionContainer(Constants::M_WINDOW)->addAction(cmd, Constants::G_WINDOW_LIST); action->setVisible(window->isVisible() || window->isMinimized()); // minimized windows are hidden but should be shown diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index 5e3caad193e..338cb5dab92 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -121,9 +122,6 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *errorMe Q_UNUSED(arguments) Q_UNUSED(errorMessage) - // Create the globalcontext list to register actions accordingly - Context globalcontext(Core::Constants::C_GLOBAL); - // Create the settings Page m_settings->fromSettings(ICore::settings()); SettingsPage *settingsPage = new SettingsPage(m_settings); @@ -162,19 +160,19 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *errorMe Command *command; m_postEditorAction = new QAction(tr("Paste Snippet..."), this); - command = ActionManager::registerAction(m_postEditorAction, "CodePaster.Post", globalcontext); + command = ActionManager::registerAction(m_postEditorAction, "CodePaster.Post"); command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+C,Meta+P") : tr("Alt+C,Alt+P"))); connect(m_postEditorAction, &QAction::triggered, this, &CodepasterPlugin::pasteSnippet); cpContainer->addAction(command); m_fetchAction = new QAction(tr("Fetch Snippet..."), this); - command = ActionManager::registerAction(m_fetchAction, "CodePaster.Fetch", globalcontext); + command = ActionManager::registerAction(m_fetchAction, "CodePaster.Fetch"); command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+C,Meta+F") : tr("Alt+C,Alt+F"))); connect(m_fetchAction, &QAction::triggered, this, &CodepasterPlugin::fetch); cpContainer->addAction(command); m_fetchUrlAction = new QAction(tr("Fetch from URL..."), this); - command = ActionManager::registerAction(m_fetchUrlAction, "CodePaster.FetchUrl", globalcontext); + command = ActionManager::registerAction(m_fetchUrlAction, "CodePaster.FetchUrl"); connect(m_fetchUrlAction, &QAction::triggered, this, &CodepasterPlugin::fetchUrl); cpContainer->addAction(command); @@ -396,7 +394,7 @@ void CodepasterPlugin::finishFetch(const QString &titleDescription, // Open editor with title. IEditor *editor = EditorManager::openEditor(fileName); QTC_ASSERT(editor, return); - editor->document()->setDisplayName(titleDescription); + editor->document()->setPreferredDisplayName(titleDescription); } CodepasterPlugin *CodepasterPlugin::instance() diff --git a/src/plugins/cppeditor/CppEditor.mimetypes.xml b/src/plugins/cppeditor/CppEditor.mimetypes.xml index 253f5d126ff..77d80cc81a5 100644 --- a/src/plugins/cppeditor/CppEditor.mimetypes.xml +++ b/src/plugins/cppeditor/CppEditor.mimetypes.xml @@ -6,6 +6,13 @@ + + C header + + + + + diff --git a/src/plugins/cppeditor/cppcanonicalsymbol.cpp b/src/plugins/cppeditor/cppcanonicalsymbol.cpp index f8dedd6b0de..6f51f284d91 100644 --- a/src/plugins/cppeditor/cppcanonicalsymbol.cpp +++ b/src/plugins/cppeditor/cppcanonicalsymbol.cpp @@ -77,7 +77,7 @@ Scope *CanonicalSymbol::getScopeAndExpression(const QTextCursor &cursor, QString ++pos; tc.setPosition(pos); - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(m_document->languageFeatures()); *code = expressionUnderCursor(tc); return m_document->scopeAt(line, column); } diff --git a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp index 844c33afbcc..37df46a4556 100644 --- a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp +++ b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -175,7 +176,7 @@ bool handleDoxygenCppStyleContinuation(QTextCursor &cursor) return false; QString newLine(QLatin1Char('\n')); - newLine.append(QString(offset, QLatin1Char(' '))); // indent correctly + newLine.append(text.left(offset)); // indent correctly newLine.append(commentMarker); newLine.append(QLatin1Char(' ')); diff --git a/src/plugins/cppeditor/cppdoxygen_test.cpp b/src/plugins/cppeditor/cppdoxygen_test.cpp index 830c67ba973..01fc5bf2a8f 100644 --- a/src/plugins/cppeditor/cppdoxygen_test.cpp +++ b/src/plugins/cppeditor/cppdoxygen_test.cpp @@ -34,6 +34,9 @@ #include +#include +#include + #include #include #include @@ -202,6 +205,17 @@ void DoxygenTest::testBasic_data() " int a;\n" ); + QTest::newRow("cpp_styleA_indented_preserve_mixed_indention_continuation") << _( + "\t bool preventFolding;\n" + "\t /// \brief a|\n" + "\t int a;\n" + ) << _( + "\t bool preventFolding;\n" + "\t /// \brief a\n" + "\t /// \n" + "\t int a;\n" + ); + /// test cpp style doxygen comment continuation when inside a indented scope QTest::newRow("cpp_styleA_indented_continuation") << _( " bool preventFolding;\n" diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 11149398482..c88e4213586 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -45,6 +45,8 @@ #include #include +#include +#include #include #include @@ -610,10 +612,14 @@ AssistInterface *CppEditorWidget::createAssistInterface(AssistKind kind, AssistR if (kind == Completion) { if (CppCompletionAssistProvider *cap = qobject_cast(cppEditorDocument()->completionAssistProvider())) { + LanguageFeatures features = LanguageFeatures::defaultFeatures(); + if (Document::Ptr doc = d->m_lastSemanticInfo.doc) + features = doc->languageFeatures(); + features.objCEnabled = cppEditorDocument()->isObjCEnabled(); return cap->createAssistInterface( textDocument()->filePath().toString(), document(), - cppEditorDocument()->isObjCEnabled(), + features, position(), reason); } diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index f8874787cf0..377d5857039 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -44,6 +44,8 @@ #include "cppsnippetprovider.h" #include "cpptypehierarchy.h" +#include + #ifdef WITH_TESTS # include "cppdoxygen_test.h" #endif @@ -232,10 +234,9 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err cppToolsMenu->addAction(cmd); // Refactoring sub-menu - Context globalContext(Core::Constants::C_GLOBAL); - Command *sep = contextMenu->addSeparator(globalContext); + Command *sep = contextMenu->addSeparator(); sep->action()->setObjectName(QLatin1String(Constants::M_REFACTORING_MENU_INSERTION_POINT)); - contextMenu->addSeparator(globalContext); + contextMenu->addSeparator(); m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol Under Cursor"), this); @@ -248,16 +249,16 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err cppToolsMenu->addAction(cmd); // Update context in global context - cppToolsMenu->addSeparator(globalContext); + cppToolsMenu->addSeparator(); m_reparseExternallyChangedFiles = new QAction(tr("Reparse Externally Changed Files"), this); - cmd = ActionManager::registerAction(m_reparseExternallyChangedFiles, Constants::UPDATE_CODEMODEL, globalContext); + cmd = ActionManager::registerAction(m_reparseExternallyChangedFiles, Constants::UPDATE_CODEMODEL); CppTools::CppModelManager *cppModelManager = CppTools::CppModelManager::instance(); connect(m_reparseExternallyChangedFiles, SIGNAL(triggered()), cppModelManager, SLOT(updateModifiedSourceFiles())); cppToolsMenu->addAction(cmd); - cppToolsMenu->addSeparator(globalContext); + cppToolsMenu->addSeparator(); QAction *inspectCppCodeModel = new QAction(tr("Inspect C++ Code Model..."), this); - cmd = ActionManager::registerAction(inspectCppCodeModel, Constants::INSPECT_CPP_CODEMODEL, globalContext); + cmd = ActionManager::registerAction(inspectCppCodeModel, Constants::INSPECT_CPP_CODEMODEL); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Shift+F12") : tr("Ctrl+Shift+F12"))); connect(inspectCppCodeModel, SIGNAL(triggered()), this, SLOT(inspectCppCodeModel())); cppToolsMenu->addAction(cmd); diff --git a/src/plugins/cppeditor/cppelementevaluator.cpp b/src/plugins/cppeditor/cppelementevaluator.cpp index d2e3544cbcf..29759118fad 100644 --- a/src/plugins/cppeditor/cppelementevaluator.cpp +++ b/src/plugins/cppeditor/cppelementevaluator.cpp @@ -33,6 +33,8 @@ #include #include +#include + #include #include #include @@ -100,7 +102,7 @@ void CppElementEvaluator::execute() CppTools::moveCursorToEndOfIdentifier(&m_tc); // Fetch the expression's code - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(doc->languageFeatures()); const QString &expression = expressionUnderCursor(m_tc); Scope *scope = doc->scopeAt(line, column); diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp index b9fa4460e8f..1f493242463 100644 --- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp +++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp @@ -466,12 +466,9 @@ TextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &curs int beginOfToken = 0; int endOfToken = 0; - LanguageFeatures features; - features.qtEnabled = true; - features.qtKeywordsEnabled = true; - features.qtMocRunEnabled = true; - features.objCEnabled = true; - features.cxx11Enabled = true; + const LanguageFeatures features = documentFromSemanticInfo + ? documentFromSemanticInfo->languageFeatures() + : LanguageFeatures::defaultFeatures(); SimpleLexer tokenize; tokenize.setLanguageFeatures(features); @@ -564,7 +561,8 @@ TextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &curs if (pos > 0 && !isValidIdentifierChar(ch)) --pos; // positionInBlock points to a delimiter character. const Token tk = SimpleLexer::tokenAt(block.text(), pos, - BackwardsScanner::previousBlockState(block), true); + BackwardsScanner::previousBlockState(block), + features); beginOfToken = block.position() + tk.utf16charsBegin(); endOfToken = block.position() + tk.utf16charsEnd(); @@ -615,7 +613,7 @@ TextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &curs return link; // Evaluate the type of the expression under the cursor - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(features); QString expression = expressionUnderCursor(tc); for (int pos = tc.position();; ++pos) { diff --git a/src/plugins/cppeditor/cppincludehierarchy.cpp b/src/plugins/cppeditor/cppincludehierarchy.cpp index f8dda2004c8..07c77ffd5ab 100644 --- a/src/plugins/cppeditor/cppincludehierarchy.cpp +++ b/src/plugins/cppeditor/cppincludehierarchy.cpp @@ -37,6 +37,8 @@ #include "cppincludehierarchymodel.h" #include "cppincludehierarchytreeview.h" +#include + #include #include #include diff --git a/src/plugins/cppeditor/cpplocalrenaming.cpp b/src/plugins/cppeditor/cpplocalrenaming.cpp index e411926b4d2..ab267df0b82 100644 --- a/src/plugins/cppeditor/cpplocalrenaming.cpp +++ b/src/plugins/cppeditor/cpplocalrenaming.cpp @@ -31,6 +31,7 @@ #include "cpplocalrenaming.h" #include +#include #include #include diff --git a/src/plugins/cppeditor/cppoutline.cpp b/src/plugins/cppeditor/cppoutline.cpp index b088b816ba4..5ba2c72c156 100644 --- a/src/plugins/cppeditor/cppoutline.cpp +++ b/src/plugins/cppeditor/cppoutline.cpp @@ -34,7 +34,10 @@ #include +#include + #include +#include #include #include diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index a3be1d7816d..c964e438b2d 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -1471,6 +1471,23 @@ void CppEditorPlugin::test_quickfix_data() " str.clear();\n" "}\n"); + QTest::newRow("ConvertFromPointer_structWithPointer") + << CppQuickFixFactoryPtr(new ConvertFromAndToPointer) + << _("struct Bar{ QString *str; };\n" + "void foo() {\n" + " Bar *@bar = new Bar;\n" + " bar->str = new QString;\n" + " delete bar->str;\n" + " delete bar;\n" + "}\n") + << _("struct Bar{ QString *str; };\n" + "void foo() {\n" + " Bar bar;\n" + " bar.str = new QString;\n" + " delete bar.str;\n" + " // delete bar;\n" + "}\n"); + QTest::newRow("ConvertToPointer_withInitializer") << CppQuickFixFactoryPtr(new ConvertFromAndToPointer) << _("void foo() {\n" diff --git a/src/plugins/cppeditor/cppquickfixassistant.cpp b/src/plugins/cppeditor/cppquickfixassistant.cpp index 12661e0ec3e..eb02f751fa7 100644 --- a/src/plugins/cppeditor/cppquickfixassistant.cpp +++ b/src/plugins/cppeditor/cppquickfixassistant.cpp @@ -33,6 +33,8 @@ #include "cppeditorconstants.h" #include "cppeditor.h" +#include + #include #include diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index baabd0bbda4..d28b33be426 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -4077,6 +4077,8 @@ private: bool starFound = false; int ampersandPos = 0; bool memberAccess = false; + bool deleteCall = false; + for (int i = path.count() - 2; i >= 0; --i) { if (path.at(i) == m_declaratorAST) { declarationFound = true; @@ -4089,6 +4091,11 @@ private: changes.replace(pos, pos + 2, QLatin1String(".")); memberAccess = true; break; + } else if (DeleteExpressionAST *deleteAST = path.at(i)->asDeleteExpression()) { + const int pos = m_file->startOf(deleteAST->delete_token); + changes.insert(pos, QLatin1String("// ")); + deleteCall = true; + break; } else if (UnaryExpressionAST *unaryExprAST = path.at(i)->asUnaryExpression()) { const Token tk = m_file->tokenAt(unaryExprAST->unary_op_token); if (tk.kind() == T_STAR) { @@ -4110,7 +4117,7 @@ private: break; } } - if (!declarationFound && !starFound && !memberAccess) { + if (!declarationFound && !starFound && !memberAccess && !deleteCall) { if (ampersandPos) { changes.insert(ampersandPos, QLatin1String("&(")); changes.insert(m_file->endOf(idAST->firstToken()), QLatin1String(")")); diff --git a/src/plugins/cppeditor/cppsnippetprovider.cpp b/src/plugins/cppeditor/cppsnippetprovider.cpp index cc70ffaf511..30a4753d28f 100644 --- a/src/plugins/cppeditor/cppsnippetprovider.cpp +++ b/src/plugins/cppeditor/cppsnippetprovider.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include diff --git a/src/plugins/cppeditor/cpptypehierarchy.cpp b/src/plugins/cppeditor/cpptypehierarchy.cpp index 2d2304cf3e9..0b27e1360e1 100644 --- a/src/plugins/cppeditor/cpptypehierarchy.cpp +++ b/src/plugins/cppeditor/cpptypehierarchy.cpp @@ -36,6 +36,7 @@ #include "cppeditorplugin.h" #include +#include #include #include #include diff --git a/src/plugins/cppeditor/cppuseselectionsupdater.cpp b/src/plugins/cppeditor/cppuseselectionsupdater.cpp index 49ee7303e10..61ee051d0cd 100644 --- a/src/plugins/cppeditor/cppuseselectionsupdater.cpp +++ b/src/plugins/cppeditor/cppuseselectionsupdater.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/cppeditor/cppvirtualfunctionproposalitem.cpp b/src/plugins/cppeditor/cppvirtualfunctionproposalitem.cpp index ab296f33788..6de2d3dddfa 100644 --- a/src/plugins/cppeditor/cppvirtualfunctionproposalitem.cpp +++ b/src/plugins/cppeditor/cppvirtualfunctionproposalitem.cpp @@ -32,6 +32,8 @@ #include "cppeditorconstants.h" +#include + using namespace CppEditor::Internal; VirtualFunctionProposalItem::VirtualFunctionProposalItem( diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index dfae9a21501..2de53e8e62a 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -41,6 +41,8 @@ #include #include +#include + #include #include diff --git a/src/plugins/cpptools/baseeditordocumentprocessor.h b/src/plugins/cpptools/baseeditordocumentprocessor.h index 0ac944947ae..e3c8dcc6795 100644 --- a/src/plugins/cpptools/baseeditordocumentprocessor.h +++ b/src/plugins/cpptools/baseeditordocumentprocessor.h @@ -36,11 +36,14 @@ #include "cpptools_global.h" #include +#include #include #include +namespace TextEditor { class TextDocument; } + namespace CppTools { class CPPTOOLS_EXPORT BaseEditorDocumentProcessor : public QObject diff --git a/src/plugins/cpptools/builtineditordocumentprocessor.cpp b/src/plugins/cpptools/builtineditordocumentprocessor.cpp index 184563837d7..59f0ff7c171 100644 --- a/src/plugins/cpptools/builtineditordocumentprocessor.cpp +++ b/src/plugins/cpptools/builtineditordocumentprocessor.cpp @@ -78,23 +78,20 @@ CppTools::CheckSymbols *createHighlighter(const CPlusPlus::Document::Ptr &doc, macroUses.append(use); } + const LanguageFeatures features = doc->languageFeatures(); + // Get macro uses foreach (const Document::MacroUse ¯o, doc->macroUses()) { const QString name = macro.macro().nameToQString(); //Filter out QtKeywords - if (isQtKeyword(QStringRef(&name))) + if (features.qtKeywordsEnabled && isQtKeyword(QStringRef(&name))) continue; - // Filter out C++ keywords - // FIXME: Check default values or get from document. - LanguageFeatures features; - features.cxx11Enabled = true; - features.c99Enabled = true; - SimpleLexer tokenize; tokenize.setLanguageFeatures(features); + // Filter out C++ keywords const Tokens tokens = tokenize(name); if (tokens.length() && (tokens.at(0).isKeyword() || tokens.at(0).isObjCAtKeyword())) continue; diff --git a/src/plugins/cpptools/cppcodestylesettingspage.cpp b/src/plugins/cpptools/cppcodestylesettingspage.cpp index 7ed6805ee1d..e1b5807a203 100644 --- a/src/plugins/cpptools/cppcodestylesettingspage.cpp +++ b/src/plugins/cpptools/cppcodestylesettingspage.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index dd5bbe2ecda..fe82a7a1963 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include #include @@ -103,11 +105,14 @@ public: QStringList getCompletions(bool *replaceAccessOperator = 0) const { QStringList completions; + LanguageFeatures languageFeatures = LanguageFeatures::defaultFeatures(); + languageFeatures.objCEnabled = false; CppCompletionAssistInterface *ai = new CppCompletionAssistInterface(m_editorWidget->textDocument()->filePath().toString(), m_editorWidget->document(), m_position, ExplicitlyInvoked, m_snapshot, - ProjectPart::HeaderPaths()); + ProjectPart::HeaderPaths(), + languageFeatures); InternalCppCompletionAssistProcessor processor; const Tests::IAssistProposalScopedPointer proposal(processor.perform(ai)); @@ -2513,6 +2518,109 @@ void CppToolsPlugin::test_completion_data() ) << _("s->") << (QStringList() << QLatin1String("Foo") << QLatin1String("bar")); + + QTest::newRow("dereference_of_nested_type_opertor_*") << _( + "template\n" + "struct QList\n" + "{\n" + " struct iterator\n" + " {\n" + " T &operator*() { return t; }\n" + " T t;\n" + " };\n" + " iterator begin() { return iterator(); }\n" + "};\n" + "struct Foo { int bar; };\n" + "void fun() {\n" + " QList list;\n" + " @\n" + "}\n" + ) << _("(*list.begin()).") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + + QTest::newRow("dereference_of_nested_type_opertor_->") << _( + "template\n" + "struct QList\n" + "{\n" + " struct iterator\n" + " {\n" + " T *operator->() { return &t; }\n" + " T t;\n" + " };\n" + " iterator begin() { return iterator(); }\n" + "};\n" + "struct Foo { int bar; };\n" + "void fun() {\n" + " QList list;\n" + " @\n" + "}\n" + ) << _("list.begin()->") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + + QTest::newRow("dereference_of_nested_type_opertor_*_and_auto") << _( + "template\n" + "struct QList\n" + "{\n" + " struct iterator\n" + " {\n" + " T &operator*() { return t; }\n" + " T t;\n" + " };\n" + " iterator begin() { return iterator(); }\n" + "};\n" + "struct Foo { int bar; };\n" + "void fun() {\n" + " QList list;\n" + " auto a = list.begin();\n" + " @\n" + "}\n" + ) << _("(*a).") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + + QTest::newRow("dereference_of_nested_type_opertor_->_and_auto") << _( + "template\n" + "struct QList\n" + "{\n" + " struct iterator\n" + " {\n" + " T *operator->() { return &t; }\n" + " T t;\n" + " };\n" + " iterator begin() { return iterator(); }\n" + "};\n" + "struct Foo { int bar; };\n" + "void fun() {\n" + " QList list;\n" + " auto a = list.begin();\n" + " @\n" + "}\n" + ) << _("a->") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + + QTest::newRow("direct_nested_template_type_access") << _( + "template\n" + "struct QList\n" + "{\n" + " struct iterator\n" + " {\n" + " T *operator->() { return &t; }\n" + " T t;\n" + " };\n" + " iterator begin() { return iterator(); }\n" + "};\n" + "struct Foo { int bar; };\n" + "void fun() {\n" + " auto a = QList::begin();\n" + " @\n" + "}\n" + ) << _("a.") << (QStringList() + << QLatin1String("operator ->") + << QLatin1String("t") + << QLatin1String("iterator")); } void CppToolsPlugin::test_completion_member_access_operator() diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp index 0ad70a4286f..f07ce5a13ae 100644 --- a/src/plugins/cpptools/cppcompletionassist.cpp +++ b/src/plugins/cpptools/cppcompletionassist.cpp @@ -168,7 +168,7 @@ static bool isDereferenced(TextEditorWidget *editorWidget, int basePosition) QTextCursor cursor = editorWidget->textCursor(); cursor.setPosition(basePosition); - BackwardsScanner scanner(cursor); + BackwardsScanner scanner(cursor, LanguageFeatures()); for (int pos = scanner.startToken()-1; pos >= 0; pos--) { switch (scanner[pos].kind()) { case T_COLON_COLON: @@ -419,12 +419,12 @@ IAssistProcessor *InternalCompletionAssistProvider::createProcessor() const AssistInterface *InternalCompletionAssistProvider::createAssistInterface( const QString &filePath, QTextDocument *document, - bool isObjCEnabled, int position, AssistReason reason) const + const LanguageFeatures &languageFeatures, int position, AssistReason reason) const { QTC_ASSERT(document, return 0); CppModelManager *modelManager = CppModelManager::instance(); - return new CppCompletionAssistInterface(filePath, document, isObjCEnabled, position, reason, + return new CppCompletionAssistInterface(filePath, document, languageFeatures, position, reason, modelManager->workingCopy()); } @@ -670,7 +670,7 @@ private: QTextCursor cursor(m_assistInterface->textDocument()); cursor.setPosition(m_position + 1); - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(m_assistInterface->languageFeatures()); const QString expression = expressionUnderCursor(cursor); if (expression.isEmpty()) return false; @@ -803,11 +803,6 @@ const Name *minimalName(Symbol *symbol, Scope *targetScope, const LookupContext InternalCppCompletionAssistProcessor::InternalCppCompletionAssistProcessor() : m_model(new CppAssistProposalModel) { - // FIXME: C++11? - m_languageFeatures.objCEnabled = true; - m_languageFeatures.qtEnabled = true; - m_languageFeatures.qtKeywordsEnabled = true; - m_languageFeatures.qtMocRunEnabled = true; } InternalCppCompletionAssistProcessor::~InternalCppCompletionAssistProcessor() @@ -858,14 +853,8 @@ bool InternalCppCompletionAssistProcessor::accepts() const QTextCursor tc(m_interface->textDocument()); tc.setPosition(pos); - LanguageFeatures features; - features.qtEnabled = true; - features.qtMocRunEnabled = true; - features.qtKeywordsEnabled = true; - features.objCEnabled = true; - SimpleLexer tokenize; - tokenize.setLanguageFeatures(features); + tokenize.setLanguageFeatures(m_interface->languageFeatures()); tokenize.setSkipComments(false); const Tokens &tokens = tokenize(tc.block().text(), BackwardsScanner::previousBlockState(tc.block())); @@ -885,7 +874,7 @@ bool InternalCppCompletionAssistProcessor::accepts() const idToken.utf16charsEnd() - idToken.utf16charsBegin()); if (identifier == QLatin1String("include") || identifier == QLatin1String("include_next") - || (m_languageFeatures.objCEnabled && identifier == QLatin1String("import"))) { + || (m_interface->languageFeatures().objCEnabled && identifier == QLatin1String("import"))) { return true; } } @@ -962,7 +951,7 @@ int InternalCppCompletionAssistProcessor::startOfOperator(int pos, } if (*kind == T_COMMA) { - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(m_interface->languageFeatures()); if (expressionUnderCursor.startOfFunctionCall(tc) == -1) { *kind = T_EOF_SYMBOL; start = pos; @@ -970,7 +959,7 @@ int InternalCppCompletionAssistProcessor::startOfOperator(int pos, } SimpleLexer tokenize; - tokenize.setLanguageFeatures(m_languageFeatures); + tokenize.setLanguageFeatures(m_interface->languageFeatures()); tokenize.setSkipComments(false); const Tokens &tokens = tokenize(tc.block().text(), BackwardsScanner::previousBlockState(tc.block())); const int tokenIdx = SimpleLexer::tokenBefore(tokens, qMax(0, tc.positionInBlock() - 1)); // get the token at the left of the cursor @@ -1066,7 +1055,7 @@ int InternalCppCompletionAssistProcessor::findStartOfName(int pos) const int InternalCppCompletionAssistProcessor::startCompletionHelper() { - if (m_languageFeatures.objCEnabled) { + if (m_interface->languageFeatures().objCEnabled) { if (tryObjCCompletion()) return m_startPosition; } @@ -1110,7 +1099,7 @@ int InternalCppCompletionAssistProcessor::startCompletionHelper() return m_startPosition; } - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(m_interface->languageFeatures()); QTextCursor tc(m_interface->textDocument()); if (m_model->m_completionOperator == T_COMMA) { @@ -1184,7 +1173,7 @@ bool InternalCppCompletionAssistProcessor::tryObjCCompletion() QTextCursor tc(m_interface->textDocument()); tc.setPosition(end); - BackwardsScanner tokens(tc); + BackwardsScanner tokens(tc, m_interface->languageFeatures()); if (tokens[tokens.startToken() - 1].isNot(T_RBRACKET)) return false; @@ -1387,7 +1376,7 @@ void InternalCppCompletionAssistProcessor::completePreprocessor() bool InternalCppCompletionAssistProcessor::objcKeywordsWanted() const { - if (!m_languageFeatures.objCEnabled) + if (!m_interface->languageFeatures().objCEnabled) return false; const QString fileName = m_interface->fileName(); @@ -1450,7 +1439,7 @@ int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString QTextCursor tc(m_interface->textDocument()); tc.setPosition(index); - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(m_interface->languageFeatures()); const QString baseExpression = expressionUnderCursor(tc); // Resolve the type of this expression @@ -1618,7 +1607,7 @@ bool InternalCppCompletionAssistProcessor::completeMember(const QListisObjCEnabled()) + if (!m_interface->languageFeatures().objCEnabled) replaceDotForArrow = &m_model->m_replaceDotForArrow; if (ClassOrNamespace *binding = @@ -1885,6 +1874,9 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QListsetText(completionText); // fix the completion item. + ci->setIcon(m_icons.iconForSymbol(fun)); + if (wantQt5SignalOrSlot && fun->isSlot()) + ci->setOrder(1); m_completions.append(ci); } @@ -1909,6 +1901,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethodClassName( return false; const LookupContext &context = m_model->m_typeOfExpression->context(); + const QIcon classIcon = m_icons.iconForType(Icons::ClassIconType); Overview overview; foreach (const LookupItem &lookupItem, results) { @@ -1917,11 +1910,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethodClassName( const Name *name = minimalName(klass, cursorScope, context); QTC_ASSERT(name, continue); - AssistProposalItem *item = new CppAssistProposalItem; - item->setText(overview.prettyName(name)); - item->setDetail(overview.prettyType(klass->type(), klass->name())); - item->setData(QVariant::fromValue(static_cast(klass))); - m_completions.append(item); + addCompletionItem(overview.prettyName(name), classIcon); break; } @@ -2097,7 +2086,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q QTextCursor tc(m_interface->textDocument()); tc.setPosition(endOfExpression); - BackwardsScanner bs(tc); + BackwardsScanner bs(tc, m_interface->languageFeatures()); const int startToken = bs.startToken(); int lineStartToken = bs.startOfLine(startToken); // make sure the required tokens are actually available @@ -2181,5 +2170,9 @@ void CppCompletionAssistInterface::getCppSpecifics() const parser->update(m_workingCopy); m_snapshot = parser->snapshot(); m_headerPaths = parser->headerPaths(); + if (Document::Ptr document = parser->document()) + m_languageFeatures = document->languageFeatures(); + else + m_languageFeatures = LanguageFeatures::defaultFeatures(); } } diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h index 0b009e07ea8..585d66eb0cf 100644 --- a/src/plugins/cpptools/cppcompletionassist.h +++ b/src/plugins/cpptools/cppcompletionassist.h @@ -92,7 +92,7 @@ public: TextEditor::AssistInterface *createAssistInterface( const QString &filePath, QTextDocument *document, - bool isObjCEnabled, + const CPlusPlus::LanguageFeatures &languageFeatures, int position, TextEditor::AssistReason reason) const Q_DECL_OVERRIDE; }; @@ -162,7 +162,6 @@ private: CompleteQt5SlotTrigger }; - CPlusPlus::LanguageFeatures m_languageFeatures; QScopedPointer m_interface; QScopedPointer m_model; }; @@ -172,14 +171,14 @@ class CppCompletionAssistInterface : public TextEditor::AssistInterface public: CppCompletionAssistInterface(const QString &filePath, QTextDocument *textDocument, - bool isObjCEnabled, + const CPlusPlus::LanguageFeatures &languageFeatures, int position, TextEditor::AssistReason reason, const WorkingCopy &workingCopy) : TextEditor::AssistInterface(textDocument, position, filePath, reason) - , m_isObjCEnabled(isObjCEnabled) , m_gotCppSpecifics(false) , m_workingCopy(workingCopy) + , m_languageFeatures(languageFeatures) {} CppCompletionAssistInterface(const QString &filePath, @@ -187,28 +186,29 @@ public: int position, TextEditor::AssistReason reason, const CPlusPlus::Snapshot &snapshot, - const ProjectPart::HeaderPaths &headerPaths) + const ProjectPart::HeaderPaths &headerPaths, + const CPlusPlus::LanguageFeatures &features) : TextEditor::AssistInterface(textDocument, position, filePath, reason) - , m_isObjCEnabled(false) , m_gotCppSpecifics(true) , m_snapshot(snapshot) , m_headerPaths(headerPaths) + , m_languageFeatures(features) {} - bool isObjCEnabled() const { return m_isObjCEnabled; } - const CPlusPlus::Snapshot &snapshot() const { getCppSpecifics(); return m_snapshot; } const ProjectPart::HeaderPaths &headerPaths() const { getCppSpecifics(); return m_headerPaths; } + CPlusPlus::LanguageFeatures languageFeatures() const + { getCppSpecifics(); return m_languageFeatures; } private: void getCppSpecifics() const; - mutable bool m_isObjCEnabled; mutable bool m_gotCppSpecifics; WorkingCopy m_workingCopy; mutable CPlusPlus::Snapshot m_snapshot; mutable ProjectPart::HeaderPaths m_headerPaths; + mutable CPlusPlus::LanguageFeatures m_languageFeatures; }; } // Internal diff --git a/src/plugins/cpptools/cppcompletionassistprovider.h b/src/plugins/cpptools/cppcompletionassistprovider.h index fbc86bf2c10..34bc2ae9747 100644 --- a/src/plugins/cpptools/cppcompletionassistprovider.h +++ b/src/plugins/cpptools/cppcompletionassistprovider.h @@ -36,6 +36,7 @@ #include #include +#include QT_BEGIN_NAMESPACE class QTextDocument; @@ -60,7 +61,9 @@ public: virtual TextEditor::AssistInterface *createAssistInterface( const QString &filePath, - QTextDocument *document, bool isObjCEnabled, int position, + QTextDocument *document, + const CPlusPlus::LanguageFeatures &languageFeatures, + int position, TextEditor::AssistReason reason) const = 0; static int activationSequenceChar(const QChar &ch, const QChar &ch2, diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp index 045398189d9..a068820e1c5 100644 --- a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp +++ b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp @@ -32,6 +32,8 @@ #include "cppmodelmanager.h" +#include + #include using namespace CppTools::Internal; diff --git a/src/plugins/cpptools/cppeditoroutline.cpp b/src/plugins/cpptools/cppeditoroutline.cpp index 8102cd8d40e..182e3f6af3b 100644 --- a/src/plugins/cpptools/cppeditoroutline.cpp +++ b/src/plugins/cpptools/cppeditoroutline.cpp @@ -34,10 +34,13 @@ #include #include #include +#include +#include #include #include +#include #include #include diff --git a/src/plugins/cpptools/cpplocatorfilter.cpp b/src/plugins/cpptools/cpplocatorfilter.cpp index 9436736cc94..e1163b413d2 100644 --- a/src/plugins/cpptools/cpplocatorfilter.cpp +++ b/src/plugins/cpptools/cpplocatorfilter.cpp @@ -31,6 +31,8 @@ #include "cpplocatorfilter.h" #include "cppmodelmanager.h" +#include + #include using namespace CppTools; diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index c7a80656965..d52d209a1e1 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -46,6 +46,8 @@ #include #include #include +#include +#include #include #include #include @@ -177,6 +179,8 @@ const char pp_configuration[] = "#define __builtin_va_arg(a,b) ((b)0)\n" + "#define _Pragma(x)\n" // C99 _Pragma operator + // ### add macros for win32 "#define __cdecl\n" "#define __stdcall\n" @@ -191,7 +195,8 @@ const char pp_configuration[] = "#define __except catch\n" "#define __finally\n" "#define __inline inline\n" - "#define __forceinline inline\n"; + "#define __forceinline inline\n" + "#define __pragma(x)\n"; QSet CppModelManager::timeStampModifiedFiles(const QList &documentsToCheck) { diff --git a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp index 90aca43ce9a..b41d66455f4 100644 --- a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp +++ b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include diff --git a/src/plugins/cpptools/cppprojectfile.cpp b/src/plugins/cpptools/cppprojectfile.cpp index 56a035adc70..eceea5f350b 100644 --- a/src/plugins/cpptools/cppprojectfile.cpp +++ b/src/plugins/cpptools/cppprojectfile.cpp @@ -142,8 +142,9 @@ ProjectFileAdder::~ProjectFileAdder() bool ProjectFileAdder::maybeAdd(const QString &path) { - const Utils::MimeType mt = Utils::MimeDatabase::bestMatch(path, m_mimeTypes); - if (mt.isValid()) { + Utils::MimeDatabase mdb; + const Utils::MimeType mt = mdb.mimeTypeForFile(path); + if (m_mimeNameMapping.contains(mt.name())) { m_files << ProjectFile(path, m_mimeNameMapping.value(mt.name())); return true; } @@ -154,10 +155,8 @@ void ProjectFileAdder::addMapping(const char *mimeName, ProjectFile::Kind kind) { Utils::MimeDatabase mdb; Utils::MimeType mimeType = mdb.mimeTypeForName(QLatin1String(mimeName)); - if (mimeType.isValid()) { + if (mimeType.isValid()) m_mimeNameMapping.insert(mimeType.name(), kind); - m_mimeTypes.append(mimeType); - } } } // namespace Internal diff --git a/src/plugins/cpptools/cppprojectfile.h b/src/plugins/cpptools/cppprojectfile.h index c656b70e8b8..cf3b01fe8b5 100644 --- a/src/plugins/cpptools/cppprojectfile.h +++ b/src/plugins/cpptools/cppprojectfile.h @@ -88,7 +88,6 @@ private: QList &m_files; QHash m_mimeNameMapping; - QList m_mimeTypes; }; } // namespace Internal diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index 628a0e122b1..2a352a6b7de 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -48,6 +48,7 @@ #include #include +#include #include #include #include diff --git a/src/plugins/cpptools/symbolsfindfilter.cpp b/src/plugins/cpptools/symbolsfindfilter.cpp index ecb77142c29..da407a4baa2 100644 --- a/src/plugins/cpptools/symbolsfindfilter.cpp +++ b/src/plugins/cpptools/symbolsfindfilter.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/cvs/cvscontrol.cpp b/src/plugins/cvs/cvscontrol.cpp index 2aa38aeaea2..ff274a1390c 100644 --- a/src/plugins/cvs/cvscontrol.cpp +++ b/src/plugins/cvs/cvscontrol.cpp @@ -34,6 +34,8 @@ #include +#include + #include using namespace Cvs; diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index fd5d777f810..1c3b2024f1a 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -43,6 +43,9 @@ #include #include #include + +#include + #include #include #include diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index a13f54326c0..ee60ba1062f 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #if USE_BREAK_MODEL_TEST #include diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index 430f93c698a..25263610fc4 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -32,6 +32,7 @@ #define DEBUGGER_BREAKHANDLER_H #include "breakpoint.h" +#include "debuggerprotocol.h" #include diff --git a/src/plugins/debugger/breakwindow.h b/src/plugins/debugger/breakwindow.h index f66d3e5eead..cce798f28ba 100644 --- a/src/plugins/debugger/breakwindow.h +++ b/src/plugins/debugger/breakwindow.h @@ -46,15 +46,13 @@ public: static void editBreakpoint(Breakpoint bp, QWidget *parent); -private slots: - void showAddressColumn(bool on); - private: void rowActivated(const QModelIndex &index); void contextMenuEvent(QContextMenuEvent *ev); void keyPressEvent(QKeyEvent *ev); void mouseDoubleClickEvent(QMouseEvent *ev); + void showAddressColumn(bool on); void deleteBreakpoints(const Breakpoints &bps); void deleteAllBreakpoints(); void addBreakpoint(); diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 1c0a01527a0..896e69e6d2e 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -812,7 +812,7 @@ void CdbEngine::runEngine() } if (startParameters().startMode == AttachCore) { QTC_ASSERT(!m_coreStopReason.isNull(), return; ); - notifyInferiorUnrunnable(); + notifyEngineRunOkAndInferiorUnrunnable(); processStop(*m_coreStopReason, false); } else { doContinueInferior(); @@ -1874,7 +1874,7 @@ void CdbEngine::handleLocals(const CdbCommandPtr &reply, int flags) } GdbMi root; root.fromString(reply->extensionReply); - QTC_ASSERT(root.isList(), return); + QTC_ASSERT(root.type() == GdbMi::List, return); if (debugLocals) qDebug() << root.toString(true, 4); // Courtesy of GDB engine diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index fd4137f78c4..7b724bad3d0 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -31,6 +31,7 @@ #include "debuggerdialogs.h" #include "debuggerkitinformation.h" +#include "debuggerstartparameters.h" #include "debuggerruncontrol.h" #include "debuggerstringutils.h" #include "cdb/cdbengine.h" @@ -487,7 +488,7 @@ AttachToQmlPortDialog::AttachToQmlPortDialog(QWidget *parent) setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowTitle(tr("Start Debugger")); - d->kitChooser = new DebuggerKitChooser(DebuggerKitChooser::RemoteDebugging, this); + d->kitChooser = new DebuggerKitChooser(DebuggerKitChooser::AnyDebugging, this); d->kitChooser->populate(); d->portSpinBox = new QSpinBox(this); diff --git a/src/plugins/debugger/debuggerdialogs.h b/src/plugins/debugger/debuggerdialogs.h index 32296a1f478..eee9ee11c4a 100644 --- a/src/plugins/debugger/debuggerdialogs.h +++ b/src/plugins/debugger/debuggerdialogs.h @@ -59,12 +59,14 @@ class StartApplicationParameters; class StartApplicationDialogPrivate; class StartRemoteEngineDialogPrivate; -class DebuggerKitChooser : public ProjectExplorer::KitChooser { +class DebuggerKitChooser : public ProjectExplorer::KitChooser +{ Q_OBJECT -public: - enum Mode { RemoteDebugging, LocalDebugging }; - explicit DebuggerKitChooser(Mode mode = RemoteDebugging, QWidget *parent = 0); +public: + enum Mode { AnyDebugging, LocalDebugging }; + + explicit DebuggerKitChooser(Mode mode = AnyDebugging, QWidget *parent = 0); protected: bool kitMatches(const ProjectExplorer::Kit *k) const; diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 5c67aecaf04..70f752d52ac 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -574,16 +574,18 @@ void DebuggerEngine::gotoLocation(const Location &loc) { d->resetLocation(); - if ((hasCapability(OperateByInstructionCapability) && - boolSetting(OperateByInstruction)) || !loc.hasDebugInfo()) { + if (loc.canBeDisassembled() + && ((hasCapability(OperateByInstructionCapability) && boolSetting(OperateByInstruction)) + || !loc.hasDebugInfo()) ) + { d->m_disassemblerAgent.setLocation(loc); return; } - // CDB might hit on breakpoints while shutting down. - //if (m_shuttingDown) - // return; - + if (loc.fileName().isEmpty()) { + showMessage(QLatin1String("CANNOT GO TO THIS LOCATION")); + return; + } const QString file = QDir::cleanPath(loc.fileName()); const int line = loc.lineNumber(); bool newEditor = false; @@ -825,7 +827,7 @@ void DebuggerEnginePrivate::doRunEngine() m_engine->runEngine(); } -void DebuggerEngine::notifyInferiorUnrunnable() +void DebuggerEngine::notifyEngineRunOkAndInferiorUnrunnable() { showMessage(_("NOTE: INFERIOR UNRUNNABLE")); d->m_progress.setProgressValue(1000); @@ -904,16 +906,6 @@ void DebuggerEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &re } } -void DebuggerEngine::notifyEngineRunOkAndInferiorRunRequested() -{ - showMessage(_("NOTE: ENGINE RUN OK AND INFERIOR RUN REQUESTED")); - d->m_progress.setProgressValue(1000); - d->m_progress.reportFinished(); - QTC_ASSERT(state() == EngineRunRequested, qDebug() << this << state()); - showStatusMessage(tr("Running.")); - setState(InferiorRunRequested); -} - void DebuggerEngine::notifyEngineRunAndInferiorRunOk() { showMessage(_("NOTE: ENGINE RUN AND INFERIOR RUN OK")); diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index a7313a9c7c4..2ebe99c70ed 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -33,9 +33,6 @@ #include "debugger_global.h" #include "debuggerconstants.h" -#include "debuggerprotocol.h" -#include "debuggerstartparameters.h" -#include "threaddata.h" // For ThreadId. #include @@ -52,6 +49,7 @@ namespace Debugger { class DebuggerRunControl; class DebuggerStartParameters; +class RemoteSetupResult; DEBUGGER_EXPORT QDebug operator<<(QDebug str, const DebuggerStartParameters &); DEBUGGER_EXPORT QDebug operator<<(QDebug str, DebuggerState state); @@ -77,6 +75,7 @@ class QmlCppEngine; class DebuggerToolTipContext; class MemoryViewSetupData; class Terminal; +class ThreadId; struct WatchUpdateFlags { @@ -104,6 +103,8 @@ public: bool needsRaise() const { return m_needsRaise; } bool needsMarker() const { return m_needsMarker; } bool hasDebugInfo() const { return m_hasDebugInfo; } + bool canBeDisassembled() const + { return m_address != quint64(-1) || !m_functionName.isEmpty(); } quint64 address() const { return m_address; } private: @@ -294,10 +295,9 @@ protected: virtual void notifyInferiorSetupOk(); virtual void notifyInferiorSetupFailed(); - virtual void notifyEngineRunOkAndInferiorRunRequested(); virtual void notifyEngineRunAndInferiorRunOk(); virtual void notifyEngineRunAndInferiorStopOk(); - virtual void notifyInferiorUnrunnable(); // Called by CoreAdapter. + virtual void notifyEngineRunOkAndInferiorUnrunnable(); // Called by CoreAdapter. // Use notifyInferiorRunRequested() plus notifyInferiorRunOk() instead. //virtual void notifyInferiorSpontaneousRun(); diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp index 334be7a6063..971a48e0d58 100644 --- a/src/plugins/debugger/debuggeritem.cpp +++ b/src/plugins/debugger/debuggeritem.cpp @@ -28,6 +28,7 @@ ** ****************************************************************************/ +#include "debuggeritem.h" #include "debuggerkitinformation.h" #include "debuggerkitconfigwidget.h" #include "debuggeroptionspage.h" diff --git a/src/plugins/debugger/debuggeritem.h b/src/plugins/debugger/debuggeritem.h index 6117e6c5f34..fc3f85541be 100644 --- a/src/plugins/debugger/debuggeritem.h +++ b/src/plugins/debugger/debuggeritem.h @@ -37,7 +37,6 @@ #include #include -#include #include #include diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp index f7cad5d96c7..924d493b63b 100644 --- a/src/plugins/debugger/debuggeritemmanager.cpp +++ b/src/plugins/debugger/debuggeritemmanager.cpp @@ -29,6 +29,7 @@ ****************************************************************************/ #include "debuggeritemmanager.h" +#include "debuggeritem.h" #include "debuggerkitinformation.h" #include diff --git a/src/plugins/debugger/debuggeritemmanager.h b/src/plugins/debugger/debuggeritemmanager.h index 25afa1b2df7..237d5363213 100644 --- a/src/plugins/debugger/debuggeritemmanager.h +++ b/src/plugins/debugger/debuggeritemmanager.h @@ -32,13 +32,16 @@ #define DEBUGGER_DEBUGGERITEMMANAGER_H #include "debugger_global.h" -#include "debuggeritem.h" +#include "debuggerconstants.h" #include #include #include +namespace Utils { class FileName; } + namespace Debugger { +class DebuggerItem; // ----------------------------------------------------------------------- // DebuggerItemManager diff --git a/src/plugins/debugger/debuggerkitconfigwidget.cpp b/src/plugins/debugger/debuggerkitconfigwidget.cpp index d97fb4f8bab..bf6009867ce 100644 --- a/src/plugins/debugger/debuggerkitconfigwidget.cpp +++ b/src/plugins/debugger/debuggerkitconfigwidget.cpp @@ -31,6 +31,7 @@ #include "debuggerkitconfigwidget.h" #include "debuggeritemmanager.h" +#include "debuggeritem.h" #include "debuggerkitinformation.h" #include diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp index f41f0edea2e..c477a14c742 100644 --- a/src/plugins/debugger/debuggerkitinformation.cpp +++ b/src/plugins/debugger/debuggerkitinformation.cpp @@ -31,6 +31,7 @@ #include "debuggerkitinformation.h" #include "debuggeritemmanager.h" +#include "debuggeritem.h" #include "debuggerkitconfigwidget.h" #include diff --git a/src/plugins/debugger/debuggerkitinformation.h b/src/plugins/debugger/debuggerkitinformation.h index 197c754c122..eaf8fcdbfca 100644 --- a/src/plugins/debugger/debuggerkitinformation.h +++ b/src/plugins/debugger/debuggerkitinformation.h @@ -33,14 +33,11 @@ #include "debugger_global.h" #include "debuggerconstants.h" -#include "debuggeritem.h" -#include #include -#include - namespace Debugger { +class DebuggerItem; class DEBUGGER_EXPORT DebuggerKitInformation : public ProjectExplorer::KitInformation { diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index b2610ebf439..87075340d73 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -400,11 +400,9 @@ QDockWidget *DebuggerMainWindow::createDockWidget(const DebuggerLanguage &langua if (!(d->m_activeDebugLanguages & language)) dockWidget->hide(); - Context globalContext(Core::Constants::C_GLOBAL); - QAction *toggleViewAction = dockWidget->toggleViewAction(); Command *cmd = ActionManager::registerAction(toggleViewAction, - Id("Debugger.").withSuffix(widget->objectName()), globalContext); + Id("Debugger.").withSuffix(widget->objectName())); cmd->setAttribute(Command::CA_Hide); dockWidget->installEventFilter(&d->m_resizeEventFilter); @@ -471,7 +469,11 @@ QWidget *DebuggerMainWindow::createContents(IMode *mode) debugToolBarLayout->addWidget(new Utils::StyledSeparator); debugToolBarLayout->addWidget(d->m_viewButton); - connect(d->m_viewButton, &QAbstractButton::clicked, this, &DebuggerMainWindow::showViewsMenu); + connect(d->m_viewButton, &QAbstractButton::clicked, [this] { + QMenu menu; + addDockActionsToMenu(&menu); + menu.exec(d->m_viewButton->mapToGlobal(QPoint())); + }); auto dock = new QDockWidget(DebuggerMainWindowPrivate::tr("Debugger Toolbar")); dock->setObjectName(QLatin1String("Debugger Toolbar")); @@ -535,13 +537,6 @@ void DebuggerMainWindow::writeSettings() const settings->endGroup(); } -void DebuggerMainWindow::showViewsMenu() -{ - QMenu menu; - addDockActionsToMenu(&menu); - menu.exec(d->m_viewButton->mapToGlobal(QPoint())); -} - void DebuggerMainWindow::readSettings() { QSettings *settings = ICore::settings(); diff --git a/src/plugins/debugger/debuggermainwindow.h b/src/plugins/debugger/debuggermainwindow.h index c6a0e1118c2..3ee130c996c 100644 --- a/src/plugins/debugger/debuggermainwindow.h +++ b/src/plugins/debugger/debuggermainwindow.h @@ -86,9 +86,6 @@ public: void readSettings(); void writeSettings() const; -private slots: - void showViewsMenu(); - private: friend class Internal::DebuggerMainWindowPrivate; Internal::DebuggerMainWindowPrivate *d; diff --git a/src/plugins/debugger/debuggeroptionspage.cpp b/src/plugins/debugger/debuggeroptionspage.cpp index 0484757ca87..fc343cbfcb7 100644 --- a/src/plugins/debugger/debuggeroptionspage.cpp +++ b/src/plugins/debugger/debuggeroptionspage.cpp @@ -30,6 +30,7 @@ #include "debuggeroptionspage.h" #include "debuggeritemmanager.h" +#include "debuggeritem.h" #include diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 193691d675e..f9ea096e3f5 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -81,6 +81,8 @@ #include #include #include +#include +#include #include #include @@ -101,6 +103,7 @@ #include #include +#include #include #include @@ -128,6 +131,7 @@ #include #include #include +#include #ifdef WITH_TESTS #include @@ -612,7 +616,8 @@ public: m_threadBox->setCurrentIndex(index); m_threadBox->blockSignals(state); } - DebuggerRunControl *attachToRunningProcess(Kit *kit, DeviceProcessItem process); + + DebuggerRunControl *attachToRunningProcess(Kit *kit, DeviceProcessItem process, bool contAfterAttach); void writeSettings() { @@ -710,13 +715,10 @@ public: void startAndDebugApplication(); void startRemoteCdbSession(); - void startRemoteServer(); + void startRemoteServerAndAttachToProcess(); void attachToRemoteServer(); - void attachToProcess(bool startServerOnly); void attachToRunningApplication(); void attachToUnstartedApplicationDialog(); - void attachToFoundProcess(); - void continueOnAttach(Debugger::DebuggerState state); void attachToQmlPort(); Q_SLOT void runScheduled(); void attachCore(); @@ -1400,22 +1402,10 @@ void DebuggerPluginPrivate::attachToRemoteServer() } } -void DebuggerPluginPrivate::startRemoteServer() +void DebuggerPluginPrivate::startRemoteServerAndAttachToProcess() { - attachToProcess(true); -} - -void DebuggerPluginPrivate::attachToRunningApplication() -{ - attachToProcess(false); -} - -void DebuggerPluginPrivate::attachToProcess(bool startServerOnly) -{ - const DebuggerKitChooser::Mode mode = startServerOnly ? - DebuggerKitChooser::RemoteDebugging : DebuggerKitChooser::LocalDebugging; - DebuggerKitChooser *kitChooser = new DebuggerKitChooser(mode); - DeviceProcessesDialog *dlg = new DeviceProcessesDialog(kitChooser, ICore::dialogParent()); + auto kitChooser = new DebuggerKitChooser(DebuggerKitChooser::AnyDebugging); + auto dlg = new DeviceProcessesDialog(kitChooser, ICore::dialogParent()); dlg->addAcceptButton(DeviceProcessesDialog::tr("&Attach to Process")); dlg->showAllDevices(); if (dlg->exec() == QDialog::Rejected) { @@ -1429,62 +1419,63 @@ void DebuggerPluginPrivate::attachToProcess(bool startServerOnly) IDevice::ConstPtr device = DeviceKitInformation::device(kit); QTC_ASSERT(device, return); - if (device->type() != PE::DESKTOP_DEVICE_TYPE) { - GdbServerStarter *starter = new GdbServerStarter(dlg, startServerOnly); - starter->run(); + GdbServerStarter *starter = new GdbServerStarter(dlg, true); + starter->run(); +} + +void DebuggerPluginPrivate::attachToRunningApplication() +{ + auto kitChooser = new DebuggerKitChooser(DebuggerKitChooser::LocalDebugging); + + auto dlg = new DeviceProcessesDialog(kitChooser, ICore::dialogParent()); + dlg->addAcceptButton(DeviceProcessesDialog::tr("&Attach to Process")); + dlg->showAllDevices(); + if (dlg->exec() == QDialog::Rejected) { + delete dlg; + return; + } + + dlg->setAttribute(Qt::WA_DeleteOnClose); + Kit *kit = kitChooser->currentKit(); + QTC_ASSERT(kit, return); + IDevice::ConstPtr device = DeviceKitInformation::device(kit); + QTC_ASSERT(device, return); + + if (device->type() == PE::DESKTOP_DEVICE_TYPE) { + attachToRunningProcess(kit, dlg->currentProcess(), false); } else { - attachToRunningProcess(kit, dlg->currentProcess()); + GdbServerStarter *starter = new GdbServerStarter(dlg, true); + starter->run(); } } void DebuggerPluginPrivate::attachToUnstartedApplicationDialog() { - UnstartedAppWatcherDialog *dlg = new UnstartedAppWatcherDialog(ICore::dialogParent()); + auto dlg = new UnstartedAppWatcherDialog(ICore::dialogParent()); connect(dlg, &QDialog::finished, dlg, &QObject::deleteLater); - connect(dlg, &UnstartedAppWatcherDialog::processFound, this, &DebuggerPluginPrivate::attachToFoundProcess); + connect(dlg, &UnstartedAppWatcherDialog::processFound, this, [this, dlg] { + DebuggerRunControl *rc = attachToRunningProcess(dlg->currentKit(), + dlg->currentProcess(), + dlg->continueOnAttach()); + if (!rc) + return; + + if (dlg->hideOnAttach()) + connect(rc, &RunControl::finished, dlg, &UnstartedAppWatcherDialog::startWatching); + }); + dlg->show(); } -void DebuggerPluginPrivate::attachToFoundProcess() -{ - UnstartedAppWatcherDialog *dlg = qobject_cast(QObject::sender()); - if (!dlg) - return; - - DebuggerRunControl *rc = attachToRunningProcess(dlg->currentKit(), dlg->currentProcess()); - if (!rc) - return; - - if (dlg->hideOnAttach()) - connect(rc, &RunControl::finished, dlg, &UnstartedAppWatcherDialog::startWatching); - - if (dlg->continueOnAttach()) { - connect(currentEngine(), &DebuggerEngine::stateChanged, - this, &DebuggerPluginPrivate::continueOnAttach); - } -} - -void DebuggerPluginPrivate::continueOnAttach(Debugger::DebuggerState state) -{ - // wait for state when we can continue - if (state != InferiorStopOk) - return; - // disconnect and continue - disconnect(currentEngine(), &DebuggerEngine::stateChanged, - this, &DebuggerPluginPrivate::continueOnAttach); - handleExecContinue(); -} - DebuggerRunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit, - DeviceProcessItem process) + DeviceProcessItem process, bool contAfterAttach) { QTC_ASSERT(kit, return 0); IDevice::ConstPtr device = DeviceKitInformation::device(kit); QTC_ASSERT(device, return 0); if (process.pid == 0) { - AsynchronousMessageBox::warning(tr("Warning"), - tr("Cannot attach to process with PID 0")); + AsynchronousMessageBox::warning(tr("Warning"), tr("Cannot attach to process with PID 0")); return 0; } @@ -1512,6 +1503,7 @@ DebuggerRunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit, sp.executable = process.exe; sp.startMode = AttachExternal; sp.closeMode = DetachAtClose; + sp.continueAfterAttach = contAfterAttach; return DebuggerRunControlFactory::createAndScheduleRun(sp); } @@ -2424,7 +2416,6 @@ void DebuggerPluginPrivate::extensionsInitialized() connect(ICore::instance(), &ICore::coreAboutToClose, this, &DebuggerPluginPrivate::coreShutdown); - const Context globalcontext(CC::C_GLOBAL); const Context cppDebuggercontext(C_CPPDEBUGGER); const Context cppeditorcontext(CppEditor::Constants::CPPEDITOR_ID); @@ -2648,7 +2639,7 @@ void DebuggerPluginPrivate::extensionsInitialized() act = m_startRemoteServerAction = new QAction(this); act->setText(tr("Start Remote Debug Server Attached to Process...")); - connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::startRemoteServer); + connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::startRemoteServerAndAttachToProcess); act = m_attachToRunningApplication = new QAction(this); act->setText(tr("Attach to Running Application...")); @@ -2682,7 +2673,7 @@ void DebuggerPluginPrivate::extensionsInitialized() Command *cmd = 0; ActionContainer *mstart = ActionManager::actionContainer(PE::M_DEBUG_STARTDEBUGGING); - cmd = ActionManager::registerAction(m_startAction, Constants::DEBUG, globalcontext); + cmd = ActionManager::registerAction(m_startAction, Constants::DEBUG); cmd->setDescription(tr("Start Debugging")); cmd->setDefaultKeySequence(debugKey); cmd->setAttribute(Command::CA_UpdateText); @@ -2696,102 +2687,92 @@ void DebuggerPluginPrivate::extensionsInitialized() ModeManager::addAction(m_visibleStartAction, Constants::P_ACTION_DEBUG); cmd = ActionManager::registerAction(m_debugWithoutDeployAction, - "Debugger.DebugWithoutDeploy", globalcontext); + "Debugger.DebugWithoutDeploy"); cmd->setAttribute(Command::CA_Hide); mstart->addAction(cmd, CC::G_DEFAULT_ONE); cmd = ActionManager::registerAction(m_attachToRunningApplication, - "Debugger.AttachToRemoteProcess", globalcontext); + "Debugger.AttachToRemoteProcess"); cmd->setDescription(tr("Attach to Running Application")); mstart->addAction(cmd, G_GENERAL); cmd = ActionManager::registerAction(m_attachToUnstartedApplication, - "Debugger.AttachToUnstartedProcess", globalcontext); + "Debugger.AttachToUnstartedProcess"); cmd->setDescription(tr("Attach to Unstarted Application")); mstart->addAction(cmd, G_GENERAL); cmd = ActionManager::registerAction(m_startAndDebugApplicationAction, - "Debugger.StartAndDebugApplication", globalcontext); + "Debugger.StartAndDebugApplication"); cmd->setAttribute(Command::CA_Hide); mstart->addAction(cmd, G_GENERAL); cmd = ActionManager::registerAction(m_attachToCoreAction, - "Debugger.AttachCore", globalcontext); + "Debugger.AttachCore"); cmd->setAttribute(Command::CA_Hide); mstart->addAction(cmd, Constants::G_GENERAL); cmd = ActionManager::registerAction(m_attachToRemoteServerAction, - "Debugger.AttachToRemoteServer", globalcontext); + "Debugger.AttachToRemoteServer"); cmd->setAttribute(Command::CA_Hide); mstart->addAction(cmd, Constants::G_SPECIAL); cmd = ActionManager::registerAction(m_startRemoteServerAction, - "Debugger.StartRemoteServer", globalcontext); + "Debugger.StartRemoteServer"); cmd->setDescription(tr("Start Gdbserver")); mstart->addAction(cmd, Constants::G_SPECIAL); if (m_startRemoteCdbAction) { cmd = ActionManager::registerAction(m_startRemoteCdbAction, - "Debugger.AttachRemoteCdb", globalcontext); + "Debugger.AttachRemoteCdb"); cmd->setAttribute(Command::CA_Hide); mstart->addAction(cmd, Constants::G_SPECIAL); } - mstart->addSeparator(globalcontext, Constants::G_START_QML); + mstart->addSeparator(Context(CC::C_GLOBAL), Constants::G_START_QML); - cmd = ActionManager::registerAction(m_attachToQmlPortAction, - "Debugger.AttachToQmlPort", globalcontext); + cmd = ActionManager::registerAction(m_attachToQmlPortAction, "Debugger.AttachToQmlPort"); cmd->setAttribute(Command::CA_Hide); mstart->addAction(cmd, Constants::G_START_QML); - cmd = ActionManager::registerAction(m_detachAction, - "Debugger.Detach", globalcontext); + cmd = ActionManager::registerAction(m_detachAction, "Debugger.Detach"); cmd->setAttribute(Command::CA_Hide); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); - cmd = ActionManager::registerAction(m_interruptAction, - Constants::INTERRUPT, globalcontext); + cmd = ActionManager::registerAction(m_interruptAction, Constants::INTERRUPT); cmd->setDescription(tr("Interrupt Debugger")); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); - cmd = ActionManager::registerAction(m_continueAction, - Constants::CONTINUE, globalcontext); + cmd = ActionManager::registerAction(m_continueAction, Constants::CONTINUE); cmd->setDefaultKeySequence(debugKey); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); - cmd = ActionManager::registerAction(m_exitAction, - Constants::STOP, globalcontext); + cmd = ActionManager::registerAction(m_exitAction, Constants::STOP); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); m_hiddenStopAction = new ProxyAction(this); m_hiddenStopAction->initialize(cmd->action()); m_hiddenStopAction->setAttribute(ProxyAction::UpdateText); m_hiddenStopAction->setAttribute(ProxyAction::UpdateIcon); - cmd = ActionManager::registerAction(m_hiddenStopAction, - Constants::HIDDEN_STOP, globalcontext); + cmd = ActionManager::registerAction(m_hiddenStopAction, Constants::HIDDEN_STOP); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Shift+Ctrl+Y") : tr("Shift+F5"))); - cmd = ActionManager::registerAction(m_abortAction, - Constants::ABORT, globalcontext); + cmd = ActionManager::registerAction(m_abortAction, Constants::ABORT); cmd->setDescription(tr("Reset Debugger")); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); - cmd = ActionManager::registerAction(m_resetAction, - Constants::RESET, globalcontext); + cmd = ActionManager::registerAction(m_resetAction, Constants::RESET); cmd->setDescription(tr("Restart Debugging")); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); - debugMenu->addSeparator(globalcontext); + debugMenu->addSeparator(); - cmd = ActionManager::registerAction(m_nextAction, - Constants::NEXT, globalcontext); + cmd = ActionManager::registerAction(m_nextAction, Constants::NEXT); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+O") : tr("F10"))); cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_UpdateText); debugMenu->addAction(cmd); - cmd = ActionManager::registerAction(m_stepAction, - Constants::STEP, globalcontext); + cmd = ActionManager::registerAction(m_stepAction, Constants::STEP); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+I") : tr("F11"))); cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_UpdateText); @@ -2833,7 +2814,7 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd->setAttribute(Command::CA_Hide); debugMenu->addAction(cmd); - debugMenu->addSeparator(globalcontext); + debugMenu->addSeparator(); //cmd = ActionManager::registerAction(m_snapshotAction, // "Debugger.Snapshot", cppDebuggercontext); @@ -2854,56 +2835,51 @@ void DebuggerPluginPrivate::extensionsInitialized() if (isNativeMixedEnabled()) { SavedAction *act = action(OperateNativeMixed); act->setValue(true); - cmd = ActionManager::registerAction(act, - Constants::OPERATE_NATIVE_MIXED, globalcontext); + cmd = ActionManager::registerAction(act, Constants::OPERATE_NATIVE_MIXED); cmd->setAttribute(Command::CA_Hide); debugMenu->addAction(cmd); connect(cmd->action(), &QAction::triggered, [this] { currentEngine()->updateAll(); }); } - cmd = ActionManager::registerAction(m_breakAction, - "Debugger.ToggleBreak", globalcontext); + cmd = ActionManager::registerAction(m_breakAction, "Debugger.ToggleBreak"); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("F8") : tr("F9"))); debugMenu->addAction(cmd); connect(m_breakAction, &QAction::triggered, this, &DebuggerPluginPrivate::toggleBreakpoint); - debugMenu->addSeparator(globalcontext); + debugMenu->addSeparator(); // currently broken // QAction *qmlUpdateOnSaveDummyAction = new QAction(tr("Apply Changes on Save"), this); // qmlUpdateOnSaveDummyAction->setCheckable(true); // qmlUpdateOnSaveDummyAction->setIcon(QIcon(_(":/debugger/images/qml/apply-on-save.png"))); // qmlUpdateOnSaveDummyAction->setEnabled(false); -// cmd = ActionManager::registerAction(qmlUpdateOnSaveDummyAction, Constants::QML_UPDATE_ON_SAVE, -// globalcontext); +// cmd = ActionManager::registerAction(qmlUpdateOnSaveDummyAction, Constants::QML_UPDATE_ON_SAVE); // debugMenu->addAction(cmd); QAction *qmlShowAppOnTopDummyAction = new QAction(tr("Show Application on Top"), this); qmlShowAppOnTopDummyAction->setCheckable(true); qmlShowAppOnTopDummyAction->setIcon(QIcon(_(":/debugger/images/qml/app-on-top.png"))); qmlShowAppOnTopDummyAction->setEnabled(false); - cmd = ActionManager::registerAction(qmlShowAppOnTopDummyAction, Constants::QML_SHOW_APP_ON_TOP, - globalcontext); + cmd = ActionManager::registerAction(qmlShowAppOnTopDummyAction, Constants::QML_SHOW_APP_ON_TOP); debugMenu->addAction(cmd); QAction *qmlSelectDummyAction = new QAction(tr("Select"), this); qmlSelectDummyAction->setCheckable(true); qmlSelectDummyAction->setIcon(QIcon(_(":/debugger/images/qml/select.png"))); qmlSelectDummyAction->setEnabled(false); - cmd = ActionManager::registerAction(qmlSelectDummyAction, Constants::QML_SELECTTOOL, - globalcontext); + cmd = ActionManager::registerAction(qmlSelectDummyAction, Constants::QML_SELECTTOOL); debugMenu->addAction(cmd); QAction *qmlZoomDummyAction = new QAction(tr("Zoom"), this); qmlZoomDummyAction->setCheckable(true); qmlZoomDummyAction->setIcon(QIcon(_(":/debugger/images/qml/zoom.png"))); qmlZoomDummyAction->setEnabled(false); - cmd = ActionManager::registerAction(qmlZoomDummyAction, Constants::QML_ZOOMTOOL, globalcontext); + cmd = ActionManager::registerAction(qmlZoomDummyAction, Constants::QML_ZOOMTOOL); debugMenu->addAction(cmd); - debugMenu->addSeparator(globalcontext); + debugMenu->addSeparator(); // Don't add '1' to the string as it shows up in the shortcut dialog. cmd = ActionManager::registerAction(m_watchAction1, @@ -3181,7 +3157,7 @@ void openTextEditor(const QString &titlePattern0, const QString &contents) return; QString titlePattern = titlePattern0; IEditor *editor = EditorManager::openEditorWithContents( - CC::K_DEFAULT_TEXT_EDITOR_ID, &titlePattern, contents.toUtf8(), + CC::K_DEFAULT_TEXT_EDITOR_ID, &titlePattern, contents.toUtf8(), QString(), EditorManager::IgnoreNavigationHistory); QTC_ASSERT(editor, return); } @@ -3291,17 +3267,14 @@ DebuggerPlugin::~DebuggerPlugin() bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMessage) { // Menu groups - const Context globalcontext(CC::C_GLOBAL); - ActionContainer *mstart = ActionManager::actionContainer(PE::M_DEBUG_STARTDEBUGGING); - mstart->appendGroup(Constants::G_GENERAL); mstart->appendGroup(Constants::G_SPECIAL); mstart->appendGroup(Constants::G_START_QML); // Separators - mstart->addSeparator(globalcontext, Constants::G_GENERAL); - mstart->addSeparator(globalcontext, Constants::G_SPECIAL); + mstart->addSeparator(Constants::G_GENERAL); + mstart->addSeparator(Constants::G_SPECIAL); addAutoReleasedObject(new DebuggerItemManager); DebuggerItemManager::restoreDebuggers(); diff --git a/src/plugins/debugger/debuggerplugin.h b/src/plugins/debugger/debuggerplugin.h index 247f6b19e11..ba8241cb03b 100644 --- a/src/plugins/debugger/debuggerplugin.h +++ b/src/plugins/debugger/debuggerplugin.h @@ -54,6 +54,8 @@ private: QObject *remoteCommand(const QStringList &options, const QStringList &arguments); ShutdownFlag aboutToShutdown(); void extensionsInitialized(); + + // Called from AppOutputPane::attachToRunControl(). Q_SLOT void attachExternalApplication(ProjectExplorer::RunControl *rc); #ifdef WITH_TESTS diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index 7621f31ae23..26b0ad1d60e 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -366,12 +366,13 @@ void GdbMi::fromStringMultiple(const QByteArray &ba) parseTuple_helper(from, to); } -GdbMi GdbMi::operator[](const char *name) const +const GdbMi &GdbMi::operator[](const char *name) const { + static GdbMi empty; for (int i = 0, n = int(m_children.size()); i < n; ++i) if (m_children.at(i).m_name == name) return m_children.at(i); - return GdbMi(); + return empty; } qulonglong GdbMi::toAddress() const diff --git a/src/plugins/debugger/debuggerprotocol.h b/src/plugins/debugger/debuggerprotocol.h index 73aa8201b57..3214fdb76e0 100644 --- a/src/plugins/debugger/debuggerprotocol.h +++ b/src/plugins/debugger/debuggerprotocol.h @@ -138,32 +138,23 @@ public: QByteArray m_data; std::vector m_children; - enum Type { - Invalid, - Const, - Tuple, - List - }; + enum Type { Invalid, Const, Tuple, List }; Type m_type; - inline Type type() const { return m_type; } - inline QByteArray name() const { return m_name; } - inline bool hasName(const char *name) const { return m_name == name; } + Type type() const { return m_type; } + const QByteArray &name() const { return m_name; } + bool hasName(const char *name) const { return m_name == name; } - inline bool isValid() const { return m_type != Invalid; } - inline bool isConst() const { return m_type == Const; } - inline bool isTuple() const { return m_type == Tuple; } - inline bool isList() const { return m_type == List; } + bool isValid() const { return m_type != Invalid; } + bool isList() const { return m_type == List; } - - inline QByteArray data() const { return m_data; } - inline const std::vector &children() const { return m_children; } - inline int childCount() const { return int(m_children.size()); } + const QByteArray &data() const { return m_data; } + const std::vector &children() const { return m_children; } + int childCount() const { return int(m_children.size()); } const GdbMi &childAt(int index) const { return m_children[index]; } - GdbMi &childAt(int index) { return m_children[index]; } - GdbMi operator[](const char *name) const; + const GdbMi &operator[](const char *name) const; QByteArray toString(bool multiline = false, int indent = 0) const; qulonglong toAddress() const; @@ -181,6 +172,7 @@ public: void parseTuple_helper(const char *&from, const char *to); void parseList(const char *&from, const char *to); +private: void dumpChildren(QByteArray *str, bool multiline, int indent) const; }; diff --git a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp index 6356815491a..5c8713e4735 100644 --- a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp +++ b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp @@ -50,12 +50,12 @@ #include #include -static const char USE_CPP_DEBUGGER_KEY[] = "RunConfiguration.UseCppDebugger"; -static const char USE_CPP_DEBUGGER_AUTO_KEY[] = "RunConfiguration.UseCppDebuggerAuto"; -static const char USE_QML_DEBUGGER_KEY[] = "RunConfiguration.UseQmlDebugger"; -static const char USE_QML_DEBUGGER_AUTO_KEY[] = "RunConfiguration.UseQmlDebuggerAuto"; -static const char QML_DEBUG_SERVER_PORT_KEY[] = "RunConfiguration.QmlDebugServerPort"; -static const char USE_MULTIPROCESS_KEY[] = "RunConfiguration.UseMultiProcess"; +const char USE_CPP_DEBUGGER_KEY[] = "RunConfiguration.UseCppDebugger"; +const char USE_CPP_DEBUGGER_AUTO_KEY[] = "RunConfiguration.UseCppDebuggerAuto"; +const char USE_QML_DEBUGGER_KEY[] = "RunConfiguration.UseQmlDebugger"; +const char USE_QML_DEBUGGER_AUTO_KEY[] = "RunConfiguration.UseQmlDebuggerAuto"; +const char QML_DEBUG_SERVER_PORT_KEY[] = "RunConfiguration.QmlDebugServerPort"; +const char USE_MULTIPROCESS_KEY[] = "RunConfiguration.UseMultiProcess"; using namespace ProjectExplorer; @@ -70,7 +70,7 @@ namespace Internal { class DebuggerRunConfigWidget : public RunConfigWidget { - Q_OBJECT + Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::RunConfigWidget) public: explicit DebuggerRunConfigWidget(DebuggerRunConfigurationAspect *aspect); @@ -79,7 +79,6 @@ public: void showEvent(QShowEvent *event); void update(); -private slots: void useCppDebuggerClicked(bool on); void useQmlDebuggerToggled(bool on); void useQmlDebuggerClicked(bool on); @@ -120,8 +119,8 @@ DebuggerRunConfigWidget::DebuggerRunConfigWidget(DebuggerRunConfigurationAspect new QCheckBox(tr("Enable Debugging of Subprocesses"), this); m_useMultiProcess->setVisible(env.toInt()); - connect(m_qmlDebuggerInfoLabel, SIGNAL(linkActivated(QString)), - Core::HelpManager::instance(), SLOT(handleHelpRequest(QString))); + connect(m_qmlDebuggerInfoLabel, &QLabel::linkActivated, + [](const QString &link) { Core::HelpManager::handleHelpRequest(link); }); connect(m_useQmlDebugger, &QAbstractButton::toggled, this, &DebuggerRunConfigWidget::useQmlDebuggerToggled); connect(m_useQmlDebugger, &QAbstractButton::clicked, @@ -343,6 +342,3 @@ RunConfigWidget *DebuggerRunConfigurationAspect::createConfigurationWidget() } } // namespace Debugger - - -#include "debuggerrunconfigurationaspect.moc" diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index 9b7b15d8e8c..1f1c43e6043 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -79,10 +79,8 @@ signals: void aboutToNotifyInferiorSetupOk(); void stateChanged(Debugger::DebuggerState state); -private slots: - void handleFinished(); - private: + void handleFinished(); friend class DebuggerRunControlFactory; DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfiguration, Internal::DebuggerEngine *engine); diff --git a/src/plugins/debugger/debuggerstartparameters.h b/src/plugins/debugger/debuggerstartparameters.h index d89af005cc2..cb083d0173b 100644 --- a/src/plugins/debugger/debuggerstartparameters.h +++ b/src/plugins/debugger/debuggerstartparameters.h @@ -34,16 +34,15 @@ #include "debugger_global.h" #include "debuggerconstants.h" -#include #include #include #include -#include #include #include #include #include +#include namespace Debugger { diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index c4fe34872de..2a51e29c7a4 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -31,6 +31,7 @@ #include "debuggertooltipmanager.h" #include "debuggerinternalconstants.h" #include "debuggerengine.h" +#include "debuggerprotocol.h" #include "debuggeractions.h" #include "stackhandler.h" #include "debuggercore.h" @@ -41,7 +42,9 @@ #include #include #include +#include #include +#include #include #include @@ -610,7 +613,7 @@ DebuggerToolTipWidget::DebuggerToolTipWidget() // ///////////////////////////////////////////////////////////////////////// -enum DebuggerTootipState +enum DebuggerTooltipState { New, // All new, widget not shown, not async (yet) PendingUnshown, // Widget not (yet) shown, async. @@ -635,7 +638,7 @@ public: void updateTooltip(DebuggerEngine *engine); - void setState(DebuggerTootipState newState); + void setState(DebuggerTooltipState newState); void destroy(); public: @@ -643,7 +646,7 @@ public: QDate creationDate; DebuggerToolTipContext context; - DebuggerTootipState state; + DebuggerTooltipState state; }; static void hideAllToolTips() @@ -817,7 +820,7 @@ void DebuggerToolTipHolder::updateTooltip(DebuggerEngine *engine) widget->titleLabel->setToolTip(context.toolTip()); } -void DebuggerToolTipHolder::setState(DebuggerTootipState newState) +void DebuggerToolTipHolder::setState(DebuggerTooltipState newState) { bool ok = (state == New && newState == PendingUnshown) || (state == PendingUnshown && newState == PendingShown) diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp index 30c884a1fe1..9269a8aafc1 100644 --- a/src/plugins/debugger/disassembleragent.cpp +++ b/src/plugins/debugger/disassembleragent.cpp @@ -41,7 +41,10 @@ #include #include +#include +#include +#include #include #include @@ -304,7 +307,7 @@ void DisassemblerAgent::setContentsToDocument(const DisassemblerLines &contents) d->document->setPlainText(contents.toString()); - d->document->setDisplayName(_("Disassembler (%1)") + d->document->setPreferredDisplayName(_("Disassembler (%1)") .arg(d->location.functionName())); updateBreakpointMarkers(); diff --git a/src/plugins/debugger/gdb/attachgdbadapter.cpp b/src/plugins/debugger/gdb/attachgdbadapter.cpp index aef3139c49c..53d1604a80f 100644 --- a/src/plugins/debugger/gdb/attachgdbadapter.cpp +++ b/src/plugins/debugger/gdb/attachgdbadapter.cpp @@ -30,6 +30,8 @@ #include "attachgdbadapter.h" +#include + #include #include #include @@ -66,40 +68,55 @@ void GdbAttachEngine::setupEngine() void GdbAttachEngine::setupInferior() { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); - const qint64 pid = startParameters().attachPID; - postCommand("attach " + QByteArray::number(pid), NoFlags, - [this](const DebuggerResponse &r) { handleAttach(r); }); // Task 254674 does not want to remove them //qq->breakHandler()->removeAllBreakpoints(); + handleInferiorPrepared(); } void GdbAttachEngine::runEngine() { QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); + const qint64 pid = startParameters().attachPID; + postCommand("attach " + QByteArray::number(pid), NoFlags, + [this](const DebuggerResponse &r) { handleAttach(r); }); showStatusMessage(tr("Attached to process %1.").arg(inferiorPid())); - notifyEngineRunAndInferiorStopOk(); - handleStop1(GdbMi()); } void GdbAttachEngine::handleAttach(const DebuggerResponse &response) { - QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); + QTC_ASSERT(state() == EngineRunRequested || state() == InferiorStopOk, + qDebug() << state()); switch (response.resultClass) { case ResultDone: case ResultRunning: showMessage(_("INFERIOR ATTACHED")); - showMessage(msgAttachedToStoppedInferior(), StatusBar); - handleInferiorPrepared(); + if (state() == EngineRunRequested) { + // Happens e.g. for "Attach to unstarted application" + // We will get a '*stopped' later that we'll interpret as 'spontaneous' + // So acknowledge the current state and put a delayed 'continue' in the pipe. + showMessage(tr("Attached to running application"), StatusBar); + notifyEngineRunAndInferiorRunOk(); + } else { + // InferiorStopOk, e.g. for "Attach to running application". + // The *stopped came in between sending the 'attach' and + // receiving its '^done'. + if (startParameters().continueAfterAttach) + continueInferiorInternal(); + } break; case ResultError: if (response.data["msg"].data() == "ptrace: Operation not permitted.") { - notifyInferiorSetupFailed(msgPtraceError(startParameters().startMode)); + QString msg = msgPtraceError(startParameters().startMode); + showStatusMessage(tr("Failed to attach to application: %1").arg(msg)); + Core::AsynchronousMessageBox::warning(tr("Debugger Error"), msg); + notifyEngineIll(); break; } // if msg != "ptrace: ..." fall through default: - QString msg = QString::fromLocal8Bit(response.data["msg"].data()); - notifyInferiorSetupFailed(msg); + showStatusMessage(tr("Failed to attach to application: %1") + .arg(QString::fromLocal8Bit(response.data["msg"].data()))); + notifyEngineIll(); } } diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp index aeb404a06ac..1ee58825fff 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.cpp +++ b/src/plugins/debugger/gdb/coregdbadapter.cpp @@ -223,27 +223,29 @@ void GdbCoreEngine::handleFileExecAndSymbols(const DebuggerResponse &response) QString core = coreFileName(); if (response.resultClass == ResultDone) { showMessage(tr("Symbols found."), StatusBar); - postCommand("target core " + core.toLocal8Bit(), NoFlags, - CB(handleTargetCore)); - return; + handleInferiorPrepared(); + } else { + QString msg = tr("No symbols found in core file %1.").arg(core) + + _(" ") + tr("This can be caused by a path length limitation " + "in the core file.") + + _(" ") + tr("Try to specify the binary using the " + "Debug->Start Debugging->Attach to Core dialog."); + notifyInferiorSetupFailed(msg); } - QString msg = tr("No symbols found in core file %1.") - .arg(core); - msg += _(" "); - msg += tr("This can be caused by a path length limitation in the " - "core file."); - msg += _(" "); - msg += tr("Try to specify the binary using the " - "Debug->Start Debugging->Attach to Core dialog."); - notifyInferiorSetupFailed(msg); +} + +void GdbCoreEngine::runEngine() +{ + QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); + postCommand("target core " + coreFileName().toLocal8Bit(), NoFlags, CB(handleTargetCore)); } void GdbCoreEngine::handleTargetCore(const DebuggerResponse &response) { - QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); + QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); + notifyEngineRunOkAndInferiorUnrunnable(); if (response.resultClass == ResultDone) { showMessage(tr("Attached to core."), StatusBar); - handleInferiorPrepared(); // Due to the auto-solib-add off setting, we don't have any // symbols yet. Load them in order of importance. reloadStack(); @@ -251,27 +253,19 @@ void GdbCoreEngine::handleTargetCore(const DebuggerResponse &response) postCommand("p 5", NoFlags, CB(handleRoundTrip)); return; } - QString msg = tr("Attach to core \"%1\" failed:") - .arg(startParameters().coreFile) - + QLatin1Char('\n') - + QString::fromLocal8Bit(response.data["msg"].data()); - notifyInferiorSetupFailed(msg); + showStatusMessage(tr("Attach to core \"%1\" failed:").arg(startParameters().coreFile) + + QLatin1Char('\n') + QString::fromLocal8Bit(response.data["msg"].data())); + notifyEngineIll(); } void GdbCoreEngine::handleRoundTrip(const DebuggerResponse &response) { Q_UNUSED(response); loadSymbolsForStack(); + handleStop2(); QTimer::singleShot(1000, this, SLOT(loadAllSymbols())); } -void GdbCoreEngine::runEngine() -{ - QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); - notifyInferiorUnrunnable(); - updateAll(); -} - void GdbCoreEngine::interruptInferior() { // A core never runs, so this cannot be called. diff --git a/src/plugins/debugger/gdb/coregdbadapter.h b/src/plugins/debugger/gdb/coregdbadapter.h index 965a8bcd1f6..2d6e8c0c078 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.h +++ b/src/plugins/debugger/gdb/coregdbadapter.h @@ -38,12 +38,6 @@ namespace Debugger { namespace Internal { -/////////////////////////////////////////////////////////////////////// -// -// CoreGdbAdapter -// -/////////////////////////////////////////////////////////////////////// - class GdbCoreEngine : public GdbEngine { Q_OBJECT @@ -74,7 +68,6 @@ private: QString coreFileName() const; QString coreName() const; -private slots: void continueSetupEngine(); void writeCoreChunk(); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index a960c2f57c4..38d800b48af 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -98,6 +98,15 @@ enum { debugPending = 0 }; #define CB(callback) [this](const DebuggerResponse &r) { callback(r); } +#define CHECK_STATE(s) \ + do { \ + if (state() != s) { \ + showMessage(QString::fromLatin1("UNEXPECTED STATE: %1 WANTED: %2 IN %3:%4") \ + .arg(state()).arg(s).arg(QLatin1String(__FILE__)).arg(__LINE__), LogError); \ + QTC_ASSERT(false, qDebug() << state() << s); \ + } \ + } while (0) + QByteArray GdbEngine::tooltipIName(const QString &exp) { return "tooltip." + exp.toLatin1().toHex(); @@ -788,8 +797,7 @@ void GdbEngine::readGdbStandardOutput() void GdbEngine::interruptInferior() { - QTC_ASSERT(state() == InferiorStopRequested, - qDebug() << "INTERRUPT INFERIOR: " << state(); return); + CHECK_STATE(InferiorStopRequested); if (terminal()->sendInterrupt()) return; @@ -1222,7 +1230,7 @@ void GdbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages flushCommand(cmd); } -// This is called from CoreAdapter and AttachAdapter. +// This is triggered when switching snapshots. void GdbEngine::updateAll() { //PENDING_DEBUG("UPDATING ALL\n"); @@ -1323,10 +1331,6 @@ void GdbEngine::handleStopResponse(const GdbMi &data) showMessage(_("IGNORING TERMINAL SIGTRAP"), LogMisc); return; } - // This is gdb 7+'s initial *stopped in response to attach. - // For consistency, we just discard it. - if (state() == InferiorSetupRequested) - return; if (isDying()) { notifyInferiorStopOk(); @@ -1337,6 +1341,8 @@ void GdbEngine::handleStopResponse(const GdbMi &data) threadsHandler()->notifyStopped(threads.data()); const QByteArray reason = data["reason"].data(); + const GdbMi frame = data["frame"]; + const QByteArray func = frame["from"].data(); if (isExitedReason(reason)) { // // The user triggered a stop, but meanwhile the app simply exited ... @@ -1358,6 +1364,19 @@ void GdbEngine::handleStopResponse(const GdbMi &data) return; } + // Ignore signals from the process stub. + if (startParameters().useTerminal + && data["reason"].data() == "signal-received" + && data["signal-name"].data() == "SIGSTOP" + && (func.endsWith("/ld-linux.so.2") + || func.endsWith("/ld-linux-x86-64.so.2"))) + { + showMessage(_("INTERNAL CONTINUE AFTER SIGSTOP FROM STUB"), LogMisc); + notifyInferiorSpontaneousStop(); + continueInferiorInternal(); + return; + } + bool gotoHandleStop1 = true; if (!m_fullStartDone) { m_fullStartDone = true; @@ -1367,8 +1386,6 @@ void GdbEngine::handleStopResponse(const GdbMi &data) } BreakpointResponseId rid(data["bkptno"].data()); - const GdbMi frame = data["frame"]; - int lineNumber = 0; QString fullName; QByteArray function; @@ -1410,14 +1427,14 @@ void GdbEngine::handleStopResponse(const GdbMi &data) gotoLocation(Location(fullName, lineNumber)); if (!m_commandsToRunOnTemporaryBreak.isEmpty()) { - QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state()); + CHECK_STATE(InferiorStopRequested); notifyInferiorStopOk(); flushQueuedCommands(); if (state() == InferiorStopOk) { QTC_CHECK(m_commandsDoneCallback == 0); m_commandsDoneCallback = &GdbEngine::autoContinueInferior; } else { - QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state()); + CHECK_STATE(InferiorShutdownRequested); } return; } @@ -1441,12 +1458,18 @@ void GdbEngine::handleStopResponse(const GdbMi &data) notifyInferiorSpontaneousStop(); } else if (state() == InferiorStopOk) { // That's expected. - } else { - QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state()); + } else if (state() == InferiorStopRequested) { notifyInferiorStopOk(); + } else if (state() == EngineRunRequested) { + // This is gdb 7+'s initial *stopped in response to attach that + // appears before the ^done is seen. + notifyEngineRunAndInferiorStopOk(); + return; + } else { + QTC_CHECK(false); } - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); if (gotoHandleStop1) handleStop1(data); @@ -1459,7 +1482,7 @@ static QByteArray stopSignal(const Abi &abi) void GdbEngine::handleStop1(const GdbMi &data) { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); QTC_ASSERT(!isDying(), return); const GdbMi frame = data["frame"]; const QByteArray reason = data["reason"].data(); @@ -1531,7 +1554,7 @@ void GdbEngine::handleStop1(const GdbMi &data) void GdbEngine::handleStop2(const GdbMi &data) { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); QTC_ASSERT(!isDying(), return); // A user initiated stop looks like the following. Note that there is @@ -1560,23 +1583,10 @@ void GdbEngine::handleStop2(const GdbMi &data) // dState changed from InferiorStopRequested(13) to InferiorStopOk(14). const QByteArray reason = data["reason"].data(); - const QByteArray func = data["frame"]["from"].data(); const DebuggerStartParameters &sp = startParameters(); bool isStopperThread = false; - if (sp.useTerminal - && reason == "signal-received" - && data["signal-name"].data() == "SIGSTOP" - && (func.endsWith("/ld-linux.so.2") - || func.endsWith("/ld-linux-x86-64.so.2"))) - { - // Ignore signals from the process stub. - showMessage(_("INTERNAL CONTINUE AFTER SIGSTOP FROM STUB"), LogMisc); - continueInferiorInternal(); - return; - } - if (sp.toolChainAbi.os() == Abi::WindowsOS && sp.useTerminal && reason == "signal-received" @@ -1711,13 +1721,13 @@ void GdbEngine::handleListFeatures(const DebuggerResponse &response) void GdbEngine::handlePythonSetup(const DebuggerResponse &response) { - QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); + CHECK_STATE(EngineSetupRequested); if (response.resultClass == ResultDone) { GdbMi data; data.fromStringMultiple(response.consoleStreamOutput); watchHandler()->addDumpers(data["dumpers"]); loadInitScript(); - QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); + CHECK_STATE(EngineSetupRequested); showMessage(_("ENGINE SUCCESSFULLY STARTED")); notifyEngineSetupOk(); } else { @@ -1740,7 +1750,7 @@ void GdbEngine::showExecutionError(const QString &message) void GdbEngine::handleExecuteContinue(const DebuggerResponse &response) { - QTC_ASSERT(state() == InferiorRunRequested, qDebug() << state()); + CHECK_STATE(InferiorRunRequested); if (response.resultClass == ResultRunning) { // All is fine. Waiting for a *running. notifyInferiorRunOk(); // Only needed for gdb < 7.0. @@ -1753,7 +1763,7 @@ void GdbEngine::handleExecuteContinue(const DebuggerResponse &response) return; if (!m_commandsToRunOnTemporaryBreak.isEmpty()) flushQueuedCommands(); - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); showStatusMessage(tr("Stopped."), 5000); reloadStack(); } else if (msg.startsWith("Cannot access memory at address")) { @@ -1762,7 +1772,7 @@ void GdbEngine::handleExecuteContinue(const DebuggerResponse &response) notifyInferiorRunFailed(); if (isDying()) return; - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); // FIXME: Fix translation in master. showStatusMessage(QString::fromLocal8Bit(msg), 5000); gotoLocation(stackHandler()->currentFrame()); @@ -1837,7 +1847,7 @@ QString GdbEngine::cleanupFullName(const QString &fileName) void GdbEngine::shutdownInferior() { - QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state()); + CHECK_STATE(InferiorShutdownRequested); m_commandsToRunOnTemporaryBreak.clear(); switch (startParameters().closeMode) { case KillAtClose: @@ -1853,7 +1863,7 @@ void GdbEngine::shutdownInferior() void GdbEngine::handleInferiorShutdown(const DebuggerResponse &response) { - QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state()); + CHECK_STATE(InferiorShutdownRequested); if (response.resultClass == ResultDone) { notifyInferiorShutdownOk(); return; @@ -1875,13 +1885,13 @@ void GdbEngine::handleInferiorShutdown(const DebuggerResponse &response) void GdbEngine::notifyAdapterShutdownFailed() { showMessage(_("ADAPTER SHUTDOWN FAILED")); - QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state()); + CHECK_STATE(EngineShutdownRequested); notifyEngineShutdownFailed(); } void GdbEngine::notifyAdapterShutdownOk() { - QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state()); + CHECK_STATE(EngineShutdownRequested); showMessage(_("INITIATE GDBENGINE SHUTDOWN IN STATE %1, PROC: %2") .arg(lastGoodState()).arg(m_gdbProc->state())); m_commandsDoneCallback = 0; @@ -1925,7 +1935,7 @@ void GdbEngine::handleGdbExit(const DebuggerResponse &response) void GdbEngine::detachDebugger() { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); QTC_ASSERT(startMode() != AttachCore, qDebug() << startMode()); postCommand("detach", GdbEngine::ExitRequest, CB(handleDetach)); } @@ -1933,7 +1943,7 @@ void GdbEngine::detachDebugger() void GdbEngine::handleDetach(const DebuggerResponse &response) { Q_UNUSED(response); - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); notifyInferiorExited(); } @@ -2008,10 +2018,10 @@ bool GdbEngine::hasCapability(unsigned cap) const void GdbEngine::continueInferiorInternal() { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); notifyInferiorRunRequested(); showStatusMessage(tr("Running requested..."), 5000); - QTC_ASSERT(state() == InferiorRunRequested, qDebug() << state()); + CHECK_STATE(InferiorRunRequested); postCommand("-exec-continue", RunRequest, CB(handleExecuteContinue)); } @@ -2024,14 +2034,14 @@ void GdbEngine::autoContinueInferior() void GdbEngine::continueInferior() { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); setTokenBarrier(); continueInferiorInternal(); } void GdbEngine::executeStep() { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); setTokenBarrier(); notifyInferiorRunRequested(); showStatusMessage(tr("Step requested..."), 5000); @@ -2054,7 +2064,7 @@ void GdbEngine::handleExecuteStep(const DebuggerResponse &response) QTC_CHECK(state() == InferiorStopOk); return; } - QTC_ASSERT(state() == InferiorRunRequested, qDebug() << state()); + CHECK_STATE(InferiorRunRequested); if (response.resultClass == ResultRunning) { // All is fine. Waiting for a *running. notifyInferiorRunOk(); // Only needed for gdb < 7.0. @@ -2086,7 +2096,7 @@ void GdbEngine::handleExecuteStep(const DebuggerResponse &response) void GdbEngine::executeStepI() { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); setTokenBarrier(); notifyInferiorRunRequested(); showStatusMessage(tr("Step by instruction requested..."), 5000); @@ -2098,7 +2108,7 @@ void GdbEngine::executeStepI() void GdbEngine::executeStepOut() { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); postCommand("-stack-select-frame 0", Discardable); setTokenBarrier(); notifyInferiorRunRequested(); @@ -2108,7 +2118,7 @@ void GdbEngine::executeStepOut() void GdbEngine::executeNext() { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); setTokenBarrier(); notifyInferiorRunRequested(); showStatusMessage(tr("Step next requested..."), 5000); @@ -2132,16 +2142,16 @@ void GdbEngine::handleExecuteNext(const DebuggerResponse &response) if (response.resultClass == ResultDone) { // Step was finishing too quick, and a '*stopped' messages should // have preceded it, so just ignore this result. - QTC_CHECK(state() == InferiorStopOk); + CHECK_STATE(InferiorStopOk); return; } - QTC_ASSERT(state() == InferiorRunRequested, qDebug() << state()); + CHECK_STATE(InferiorRunRequested); if (response.resultClass == ResultRunning) { // All is fine. Waiting for a *running. notifyInferiorRunOk(); // Only needed for gdb < 7.0. return; } - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); QByteArray msg = response.data["msg"].data(); if (msg.startsWith("Cannot find bounds of current function") || msg.contains("Error accessing memory address ")) { @@ -2162,7 +2172,7 @@ void GdbEngine::handleExecuteNext(const DebuggerResponse &response) void GdbEngine::executeNextI() { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); setTokenBarrier(); notifyInferiorRunRequested(); showStatusMessage(tr("Step next instruction requested..."), 5000); @@ -2179,7 +2189,7 @@ static QByteArray addressSpec(quint64 address) void GdbEngine::executeRunToLine(const ContextData &data) { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); setTokenBarrier(); resetLocation(); notifyInferiorRunRequested(); @@ -2204,7 +2214,7 @@ void GdbEngine::executeRunToLine(const ContextData &data) void GdbEngine::executeRunToFunction(const QString &functionName) { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); setTokenBarrier(); resetLocation(); postCommand("-break-insert -t " + functionName.toLatin1()); @@ -2214,7 +2224,7 @@ void GdbEngine::executeRunToFunction(const QString &functionName) void GdbEngine::executeJumpToLine(const ContextData &data) { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); QByteArray loc; if (data.address) loc = addressSpec(data.address); @@ -2234,7 +2244,7 @@ void GdbEngine::executeJumpToLine(const ContextData &data) void GdbEngine::executeReturn() { - QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); + CHECK_STATE(InferiorStopOk); setTokenBarrier(); notifyInferiorRunRequested(); showStatusMessage(tr("Immediate return from function requested..."), 5000); @@ -4417,7 +4427,7 @@ void GdbEngine::resetInferior() void GdbEngine::handleAdapterStartFailed(const QString &msg, Id settingsIdHint) { - QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); + CHECK_STATE(EngineSetupOk); showMessage(_("ADAPTER START FAILED")); if (!msg.isEmpty()) { const QString title = tr("Adapter start failed"); @@ -4442,7 +4452,7 @@ void GdbEngine::handleInferiorPrepared() { const DebuggerStartParameters &sp = startParameters(); - QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); + CHECK_STATE(InferiorSetupRequested); if (!sp.commandsAfterConnect.isEmpty()) { QByteArray commands = globalMacroExpander()->expand(sp.commandsAfterConnect); @@ -4475,7 +4485,7 @@ void GdbEngine::handleInferiorPrepared() void GdbEngine::finishInferiorSetup() { - QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); + CHECK_STATE(InferiorSetupRequested); if (startParameters().startMode == AttachCore) { notifyInferiorSetupOk(); // No breakpoints in core files. diff --git a/src/plugins/debugger/gdb/gdbplainengine.cpp b/src/plugins/debugger/gdb/gdbplainengine.cpp index c19bdde3a82..52b53af71e3 100644 --- a/src/plugins/debugger/gdb/gdbplainengine.cpp +++ b/src/plugins/debugger/gdb/gdbplainengine.cpp @@ -93,7 +93,6 @@ void GdbPlainEngine::handleExecRun(const DebuggerResponse &response) { QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); if (response.resultClass == ResultRunning) { - //notifyEngineRunOkAndInferiorRunRequested(); notifyEngineRunAndInferiorRunOk(); // For gdb < 7.0 //showStatusMessage(tr("Running...")); showMessage(_("INFERIOR STARTED")); diff --git a/src/plugins/debugger/gdb/startgdbserverdialog.cpp b/src/plugins/debugger/gdb/startgdbserverdialog.cpp index 346668ea19e..68a87c9f486 100644 --- a/src/plugins/debugger/gdb/startgdbserverdialog.cpp +++ b/src/plugins/debugger/gdb/startgdbserverdialog.cpp @@ -63,7 +63,7 @@ public: StartGdbServerDialogPrivate() : dialog(0), kit(0) {} DeviceProcessesDialog *dialog; - bool startServerOnly; + bool attachToServer; DeviceProcessItem process; Kit *kit; IDevice::ConstPtr device; @@ -72,7 +72,7 @@ public: SshRemoteProcessRunner runner; }; -GdbServerStarter::GdbServerStarter(DeviceProcessesDialog *dlg, bool startServerOnly) +GdbServerStarter::GdbServerStarter(DeviceProcessesDialog *dlg, bool attachAfterServerStart) : QObject(dlg) { d = new StartGdbServerDialogPrivate; @@ -80,7 +80,7 @@ GdbServerStarter::GdbServerStarter(DeviceProcessesDialog *dlg, bool startServerO d->kit = dlg->kitChooser()->currentKit(); d->process = dlg->currentProcess(); d->device = DeviceKitInformation::device(d->kit); - d->startServerOnly = startServerOnly; + d->attachToServer = attachAfterServerStart; } GdbServerStarter::~GdbServerStarter() @@ -167,7 +167,7 @@ void GdbServerStarter::handleProcessErrorOutput() logMessage(tr("Port %1 is now accessible.").arg(port)); logMessage(tr("Server started on %1:%2") .arg(d->device->sshParameters().host).arg(port)); - if (!d->startServerOnly) + if (d->attachToServer) attach(port); } } diff --git a/src/plugins/debugger/gdb/startgdbserverdialog.h b/src/plugins/debugger/gdb/startgdbserverdialog.h index 99d61aa7434..724d71a9479 100644 --- a/src/plugins/debugger/gdb/startgdbserverdialog.h +++ b/src/plugins/debugger/gdb/startgdbserverdialog.h @@ -45,7 +45,8 @@ class GdbServerStarter : public QObject Q_OBJECT public: - GdbServerStarter(ProjectExplorer::DeviceProcessesDialog *dlg, bool startServerOnly); + GdbServerStarter(ProjectExplorer::DeviceProcessesDialog *dlg, + bool attachAfterServerStart); ~GdbServerStarter(); void run(); diff --git a/src/plugins/debugger/gdb/termgdbadapter.cpp b/src/plugins/debugger/gdb/termgdbadapter.cpp index 8a9b20355b4..27d5f6bafec 100644 --- a/src/plugins/debugger/gdb/termgdbadapter.cpp +++ b/src/plugins/debugger/gdb/termgdbadapter.cpp @@ -140,11 +140,13 @@ void GdbTermEngine::runEngine() void GdbTermEngine::handleStubAttached(const DebuggerResponse &response) { - QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); + // InferiorStopOk can happen if the "*stopped" in response to the + // 'attach' comes in before its '^done' + QTC_ASSERT(state() == EngineRunRequested || state() == InferiorStopOk, + qDebug() << state()); switch (response.resultClass) { case ResultDone: - case ResultRunning: if (startParameters().toolChainAbi.os() != ProjectExplorer::Abi::WindowsOS) { showMessage(_("INFERIOR ATTACHED")); } else { @@ -160,8 +162,19 @@ void GdbTermEngine::handleStubAttached(const DebuggerResponse &response) LogWarning); } } - notifyEngineRunAndInferiorStopOk(); - continueInferiorInternal(); + if (state() == EngineRunRequested) { + // We will get a '*stopped' later that we'll interpret as 'spontaneous' + // So acknowledge the current state and put a delayed 'continue' in the pipe. + notifyEngineRunAndInferiorRunOk(); + } else { + //postCommand("print 43", NoFlags, [this](const DebuggerResponse &) { continueInferiorInternal(); }); + continueInferiorInternal(); + } + break; + case ResultRunning: + // Has anyone seen such a result lately? + showMessage(_("INFERIOR ATTACHED AND RUNNING")); + notifyEngineRunAndInferiorRunOk(); break; case ResultError: if (response.data["msg"].data() == "ptrace: Operation not permitted.") { @@ -170,11 +183,11 @@ void GdbTermEngine::handleStubAttached(const DebuggerResponse &response) break; } showMessage(QString::fromLocal8Bit(response.data["msg"].data())); - notifyEngineRunFailed(); + notifyEngineIll(); break; default: showMessage(QString::fromLatin1("Invalid response %1").arg(response.resultClass)); - notifyEngineRunFailed(); + notifyEngineIll(); break; } } diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index d2425f664cf..ae33c3af0da 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -362,9 +362,15 @@ void LldbEngine::setupInferior() void LldbEngine::runEngine() { + const DebuggerStartParameters &sp = startParameters(); QTC_ASSERT(state() == EngineRunRequested, qDebug() << state(); return); showStatusMessage(tr("Running requested..."), 5000); - runCommand("runEngine"); + DebuggerCommand cmd("runEngine"); + if (sp.startMode == AttachCore) { + cmd.arg("coreFile", sp.coreFile); + cmd.arg("continuation", "updateAll"); + } + runCommand(cmd); } void LldbEngine::interruptInferior() @@ -475,9 +481,11 @@ void LldbEngine::handleContinuation(const GdbMi &data) { if (data.data() == "updateLocals") { updateLocals(); - return; + } else if (data.data() == "updateAll") { + updateAll(); + } else { + QTC_ASSERT(false, qDebug() << "Unknown continuation: " << data.data()); } - QTC_ASSERT(false, qDebug() << "Unknown continuation: " << data.data()); } void LldbEngine::showFullBacktrace(const GdbMi &data) @@ -509,7 +517,6 @@ void LldbEngine::executeRunToFunction(const QString &functionName) void LldbEngine::executeJumpToLine(const ContextData &data) { resetLocation(); - notifyInferiorRunRequested(); DebuggerCommand cmd("executeJumpToLocation"); cmd.arg("file", data.fileName); cmd.arg("line", data.lineNumber); @@ -537,8 +544,6 @@ void LldbEngine::activateFrame(int frameIndex) cmd.arg("thread", threadsHandler()->currentThread().raw()); cmd.arg("continuation", "updateLocals"); runCommand(cmd); - - reloadRegisters(); } void LldbEngine::selectThread(ThreadId threadId) @@ -546,6 +551,7 @@ void LldbEngine::selectThread(ThreadId threadId) DebuggerCommand cmd("selectThread"); cmd.arg("id", threadId.raw()); runCommand(cmd); + updateAll(); } bool LldbEngine::stateAcceptsBreakpointChanges() const @@ -803,8 +809,6 @@ bool LldbEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget void LldbEngine::updateAll() { - reloadRegisters(); - DebuggerCommand cmd("reportStack"); cmd.arg("nativeMixed", isNativeMixedActive()); cmd.arg("stacklimit", action(MaximalStackDepth)->value().toInt()); @@ -851,6 +855,11 @@ void LldbEngine::updateLocals() void LldbEngine::doUpdateLocals(UpdateParameters params) { + if (stackHandler()->stackSize() == 0) { + showMessage(_("SKIPPING LOCALS DUE TO EMPTY STACK")); + return; + } + DebuggerCommand cmd("updateData"); cmd.arg("nativeMixed", isNativeMixedActive()); watchHandler()->appendFormatRequests(&cmd); @@ -1121,6 +1130,8 @@ void LldbEngine::refreshState(const GdbMi &reportedState) notifyEngineRunAndInferiorRunOk(); } else if (newState == "enginerunandinferiorstopok") notifyEngineRunAndInferiorStopOk(); + else if (newState == "enginerunokandinferiorunrunnable") + notifyEngineRunOkAndInferiorUnrunnable(); else if (newState == "inferiorshutdownok") notifyInferiorShutdownOk(); else if (newState == "inferiorshutdownfailed") diff --git a/src/plugins/debugger/lldb/lldbengine.h b/src/plugins/debugger/lldb/lldbengine.h index ca9109d5fbe..695c2e417f0 100644 --- a/src/plugins/debugger/lldb/lldbengine.h +++ b/src/plugins/debugger/lldb/lldbengine.h @@ -36,6 +36,7 @@ #include #include #include +#include #include diff --git a/src/plugins/debugger/loadcoredialog.cpp b/src/plugins/debugger/loadcoredialog.cpp index e2b8063a43c..0998f12a115 100644 --- a/src/plugins/debugger/loadcoredialog.cpp +++ b/src/plugins/debugger/loadcoredialog.cpp @@ -73,7 +73,7 @@ namespace Internal { class SelectRemoteFileDialog : public QDialog { - Q_OBJECT + Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::SelectRemoteFileDialog) public: explicit SelectRemoteFileDialog(QWidget *parent); @@ -263,7 +263,7 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent) d->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); - d->kitChooser = new DebuggerKitChooser(DebuggerKitChooser::RemoteDebugging, this); + d->kitChooser = new DebuggerKitChooser(DebuggerKitChooser::AnyDebugging, this); d->kitChooser->populate(); d->forceLocalCheckBox = new QCheckBox(this); @@ -289,12 +289,12 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent) d->overrideStartScriptFileName->setExpectedKind(PathChooser::File); d->overrideStartScriptFileName->setPromptDialogTitle(tr("Select Startup Script")); - QHBoxLayout *coreLayout = new QHBoxLayout; + auto coreLayout = new QHBoxLayout; coreLayout->addWidget(d->localCoreFileName); coreLayout->addWidget(d->remoteCoreFileName); coreLayout->addWidget(d->selectRemoteCoreButton); - QFormLayout *formLayout = new QFormLayout; + auto formLayout = new QFormLayout; formLayout->setContentsMargins(0, 0, 0, 0); formLayout->setHorizontalSpacing(6); formLayout->setVerticalSpacing(6); @@ -304,13 +304,13 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent) formLayout->addRow(tr("&Executable:"), d->localExecFileName); formLayout->addRow(tr("Override &start script:"), d->overrideStartScriptFileName); - QFrame *line = new QFrame(this); + auto line = new QFrame(this); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); formLayout->addRow(d->buttonBox); - QVBoxLayout *vboxLayout = new QVBoxLayout(this); + auto vboxLayout = new QVBoxLayout(this); vboxLayout->addLayout(formLayout); vboxLayout->addStretch(); vboxLayout->addWidget(line); @@ -474,5 +474,3 @@ void AttachCoreDialog::setOverrideStartScript(const QString &scriptName) } // namespace Internal } // namespace Debugger - -#include "loadcoredialog.moc" diff --git a/src/plugins/debugger/loadcoredialog.h b/src/plugins/debugger/loadcoredialog.h index b8d4693e23b..9973cbe0dcc 100644 --- a/src/plugins/debugger/loadcoredialog.h +++ b/src/plugins/debugger/loadcoredialog.h @@ -68,12 +68,11 @@ public: void setKitId(Core::Id id); void setForceLocalCoreFile(bool on); -private slots: +private: void changed(); void coreFileChanged(const QString &core); void selectRemoteCoreFile(); -private: AttachCoreDialogPrivate *d; }; diff --git a/src/plugins/debugger/localsandexpressionswindow.cpp b/src/plugins/debugger/localsandexpressionswindow.cpp index c88e5d479d7..d957e3f94b5 100644 --- a/src/plugins/debugger/localsandexpressionswindow.cpp +++ b/src/plugins/debugger/localsandexpressionswindow.cpp @@ -35,19 +35,16 @@ #include #include -const int LOCAL_WIDGET_INDEX = 0; -const int INSPECTOR_WIDGET_INDEX = 1; - namespace Debugger { namespace Internal { -LocalsAndExpressionsWindow::LocalsAndExpressionsWindow( - QWidget *locals, QWidget *inspector, QWidget *returnWidget, - QWidget *watchers, QWidget *parent) - : QWidget(parent), - m_showLocals(false) +enum { LocalsIndex = 0, InspectorIndex = 1 }; + +LocalsAndExpressionsWindow::LocalsAndExpressionsWindow(QWidget *locals, + QWidget *inspector, QWidget *returnWidget, QWidget *watchers) + : m_showLocals(false) { - QVBoxLayout *layout = new QVBoxLayout(this); + auto layout = new QVBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); @@ -71,7 +68,9 @@ LocalsAndExpressionsWindow::LocalsAndExpressionsWindow( // when debugger engine changes states. m_timer.setSingleShot(true); m_timer.setInterval(500); // TODO: remove the magic number! - connect(&m_timer, SIGNAL(timeout()), SLOT(showLocals())); + connect(&m_timer, &QTimer::timeout, [this] { + m_localsAndInspector->setCurrentIndex(m_showLocals ? LocalsIndex : InspectorIndex); + }); } void LocalsAndExpressionsWindow::setShowLocals(bool showLocals) @@ -80,16 +79,5 @@ void LocalsAndExpressionsWindow::setShowLocals(bool showLocals) m_timer.start(); } -void LocalsAndExpressionsWindow::showLocals() -{ - m_localsAndInspector->setCurrentIndex(m_showLocals ? LOCAL_WIDGET_INDEX - : INSPECTOR_WIDGET_INDEX); -} - -QWidget *LocalsAndExpressionsWindow::inspectorWidget() const -{ - return m_localsAndInspector->widget(INSPECTOR_WIDGET_INDEX); -} - } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/localsandexpressionswindow.h b/src/plugins/debugger/localsandexpressionswindow.h index 77e849def6f..23e6df87287 100644 --- a/src/plugins/debugger/localsandexpressionswindow.h +++ b/src/plugins/debugger/localsandexpressionswindow.h @@ -45,16 +45,12 @@ namespace Internal { class LocalsAndExpressionsWindow : public QWidget { Q_OBJECT + public: - explicit LocalsAndExpressionsWindow( - QWidget *locals, QWidget *inspector, - QWidget *returnWidget, QWidget *watchers, QWidget *parent = 0); + LocalsAndExpressionsWindow(QWidget *locals, QWidget *inspector, + QWidget *returnWidget, QWidget *watchers); void setShowLocals(bool showLocals); - QWidget *inspectorWidget() const; - -private slots: - void showLocals(); private: QSplitter *m_splitter; diff --git a/src/plugins/debugger/moduleswindow.h b/src/plugins/debugger/moduleswindow.h index b7173a89db3..6bf19348e45 100644 --- a/src/plugins/debugger/moduleswindow.h +++ b/src/plugins/debugger/moduleswindow.h @@ -43,10 +43,8 @@ class ModulesTreeView : public Utils::BaseTreeView public: ModulesTreeView(); -private slots: - void moduleActivated(const QModelIndex &index); - private: + void moduleActivated(const QModelIndex &index); void contextMenuEvent(QContextMenuEvent *ev); }; diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index 80adbd9e3e9..f0f48655625 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/debugger/pdb/pdbengine.h b/src/plugins/debugger/pdb/pdbengine.h index d78ba29343d..a30155627ba 100644 --- a/src/plugins/debugger/pdb/pdbengine.h +++ b/src/plugins/debugger/pdb/pdbengine.h @@ -38,6 +38,8 @@ namespace Debugger { namespace Internal { +class DebuggerCommand; +class GdbMi; /* * A debugger engine for Python using the pdb command line debugger. diff --git a/src/plugins/debugger/qml/qmlcppengine.cpp b/src/plugins/debugger/qml/qmlcppengine.cpp index 1d01a19020d..08bfb8cf0da 100644 --- a/src/plugins/debugger/qml/qmlcppengine.cpp +++ b/src/plugins/debugger/qml/qmlcppengine.cpp @@ -35,10 +35,12 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -533,7 +535,7 @@ void QmlCppEngine::slaveEngineStateChanged } case InferiorUnrunnable: { qmlEngine()->quitDebugger(); - notifyInferiorUnrunnable(); + notifyEngineRunOkAndInferiorUnrunnable(); break; } case InferiorRunRequested: { diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index ee893269256..41a4373517a 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -1154,6 +1155,8 @@ void QmlEngine::updateCurrentContext() } else { QModelIndex currentIndex = inspectorTreeView()->currentIndex(); const WatchData *currentData = watchHandler()->watchData(currentIndex); + if (!currentData) + return; const WatchData *parentData = watchHandler()->watchData(currentIndex.parent()); const WatchData *grandParentData = watchHandler()->watchData( currentIndex.parent().parent()); diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h index baddc4ae65a..cec9556618b 100644 --- a/src/plugins/debugger/qml/qmlengine.h +++ b/src/plugins/debugger/qml/qmlengine.h @@ -41,10 +41,12 @@ #include #include -#include +QT_FORWARD_DECLARE_CLASS(QTextDocument) namespace Core { class IDocument; } +namespace TextEditor { class BaseTextEditor; } + namespace Debugger { namespace Internal { diff --git a/src/plugins/debugger/qml/qmlinspectoradapter.cpp b/src/plugins/debugger/qml/qmlinspectoradapter.cpp index 08edb3588b1..0eb3c88c919 100644 --- a/src/plugins/debugger/qml/qmlinspectoradapter.cpp +++ b/src/plugins/debugger/qml/qmlinspectoradapter.cpp @@ -40,6 +40,9 @@ #include #include +#include +#include +#include #include #include #include diff --git a/src/plugins/debugger/qml/qmllivetextpreview.cpp b/src/plugins/debugger/qml/qmllivetextpreview.cpp index 80ef6220c77..fb6cf9540ca 100644 --- a/src/plugins/debugger/qml/qmllivetextpreview.cpp +++ b/src/plugins/debugger/qml/qmllivetextpreview.cpp @@ -34,6 +34,7 @@ #include "qmlinspectoragent.h" #include +#include #include #include #include diff --git a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp index 67f1a59aed8..26b54be1b1f 100644 --- a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp +++ b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp @@ -42,6 +42,8 @@ #include #include +#include + #include #include diff --git a/src/plugins/debugger/registerhandler.cpp b/src/plugins/debugger/registerhandler.cpp index d40536acbb1..3c2a80e2030 100644 --- a/src/plugins/debugger/registerhandler.cpp +++ b/src/plugins/debugger/registerhandler.cpp @@ -31,10 +31,6 @@ #include "registerhandler.h" #include "watchdelegatewidgets.h" -#if USE_REGISTER_MODEL_TEST -#include -#endif - #include namespace Debugger { @@ -282,6 +278,7 @@ static uint decodeHexChar(unsigned char c) void RegisterValue::operator=(const QByteArray &ba) { + known = !ba.isEmpty(); uint shift = 0; int j = 0; v.u64[1] = v.u64[0] = 0; @@ -318,6 +315,8 @@ static QByteArray format(quint64 v, int base, int size) QByteArray RegisterValue::toByteArray(int base, RegisterKind kind, int size) const { + if (!known) + return "[inaccessible]"; if (kind == FloatRegister) { if (size == 4) return QByteArray::number(v.f[0]); @@ -452,13 +451,13 @@ QVariant RegisterItem::data(int column, int role) const case Qt::DisplayRole: switch (column) { - case 0: { + case RegisterNameColumn: { QByteArray res = m_reg.name; if (!m_reg.description.isEmpty()) res += " (" + m_reg.description + ')'; return res; } - case 1: { + case RegisterValueColumn: { return m_reg.value.toByteArray(m_base, m_reg.kind, m_reg.size); } } @@ -472,7 +471,7 @@ QVariant RegisterItem::data(int column, int role) const return m_reg.value.toByteArray(m_base, m_reg.kind, m_reg.size); case Qt::TextAlignmentRole: - return column == 1 ? QVariant(Qt::AlignRight) : QVariant(); + return column == RegisterValueColumn ? QVariant(Qt::AlignRight) : QVariant(); default: break; @@ -494,9 +493,9 @@ QVariant RegisterSubItem::data(int column, int role) const case Qt::DisplayRole: switch (column) { - case 0: + case RegisterNameColumn: return subTypeName(m_subKind, m_subSize); - case 1: { + case RegisterValueColumn: { QTC_ASSERT(parent(), return QVariant()); RegisterItem *registerItem = static_cast(parent()); RegisterValue value = registerItem->m_reg.value; @@ -526,10 +525,6 @@ RegisterHandler::RegisterHandler() { setObjectName(QLatin1String("RegisterModel")); setHeader(QStringList() << tr("Name") << tr("Value")); - -#if USE_REGISTER_MODEL_TEST - new ModelTest(this, 0); -#endif } void RegisterHandler::updateRegister(const Register &r) diff --git a/src/plugins/debugger/registerhandler.h b/src/plugins/debugger/registerhandler.h index f22b52a14d1..2f3a7b186b6 100644 --- a/src/plugins/debugger/registerhandler.h +++ b/src/plugins/debugger/registerhandler.h @@ -40,6 +40,13 @@ namespace Debugger { namespace Internal { +enum RegisterColumns +{ + RegisterNameColumn, + RegisterValueColumn, + RegisterColumnCount +}; + enum RegisterDataRole { RegisterNameRole = Qt::UserRole, @@ -62,7 +69,7 @@ enum RegisterKind class RegisterValue { public: - RegisterValue() { v.u64[1] = v.u64[0] = 0; } + RegisterValue() { known = false; v.u64[1] = v.u64[0] = 0; } void operator=(const QByteArray &ba); bool operator==(const RegisterValue &other); bool operator!=(const RegisterValue &other) { return !operator==(other); } @@ -77,6 +84,7 @@ public: float f[4]; double d[2]; } v; + bool known; }; class Register diff --git a/src/plugins/debugger/registerwindow.cpp b/src/plugins/debugger/registerwindow.cpp index 724feeb8eba..818301a4ea3 100644 --- a/src/plugins/debugger/registerwindow.cpp +++ b/src/plugins/debugger/registerwindow.cpp @@ -108,7 +108,7 @@ public: void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - if (index.column() == 1) { + if (index.column() == RegisterValueColumn) { const bool paintRed = index.data(RegisterChangedRole).toBool(); QPen oldPen = painter->pen(); const QColor lightColor(140, 140, 140); diff --git a/src/plugins/debugger/snapshothandler.cpp b/src/plugins/debugger/snapshothandler.cpp index 4a00a279781..b69680462f6 100644 --- a/src/plugins/debugger/snapshothandler.cpp +++ b/src/plugins/debugger/snapshothandler.cpp @@ -37,7 +37,9 @@ #include +#include #include +#include namespace Debugger { namespace Internal { diff --git a/src/plugins/debugger/sourceagent.cpp b/src/plugins/debugger/sourceagent.cpp index 937836c2299..3cf6ccea5b9 100644 --- a/src/plugins/debugger/sourceagent.cpp +++ b/src/plugins/debugger/sourceagent.cpp @@ -35,7 +35,11 @@ #include "debuggercore.h" #include "stackhandler.h" +#include +#include + #include +#include #include #include diff --git a/src/plugins/debugger/sourceutils.cpp b/src/plugins/debugger/sourceutils.cpp index 9e1d80bf9b6..0e4ff6ae389 100644 --- a/src/plugins/debugger/sourceutils.cpp +++ b/src/plugins/debugger/sourceutils.cpp @@ -34,6 +34,7 @@ #include "watchutils.h" #include +#include #include #include #include @@ -285,6 +286,9 @@ QString cppExpressionAt(TextEditorWidget *editorWidget, int pos, if (function) function->clear(); + const QString fileName = editorWidget->textDocument()->filePath().toString(); + const Snapshot snapshot = CppModelManager::instance()->snapshot(); + const Document::Ptr document = snapshot.document(fileName); QTextCursor tc = editorWidget->textCursor(); QString expr = tc.selectedText(); if (expr.isEmpty()) { @@ -294,21 +298,18 @@ QString cppExpressionAt(TextEditorWidget *editorWidget, int pos, tc.movePosition(QTextCursor::EndOfWord); // Fetch the expression's code. - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(document ? document->languageFeatures() + : LanguageFeatures::defaultFeatures()); expr = expressionUnderCursor(tc); } *column = tc.positionInBlock(); *line = tc.blockNumber() + 1; - if (!expr.isEmpty()) { - QString fileName = editorWidget->textDocument()->filePath().toString(); - const Snapshot snapshot = CppModelManager::instance()->snapshot(); - if (const Document::Ptr document = snapshot.document(fileName)) { - QString func = document->functionAt(*line, *column, scopeFromLine, scopeToLine); - if (function) - *function = func; - } + if (!expr.isEmpty() && document) { + QString func = document->functionAt(*line, *column, scopeFromLine, scopeToLine); + if (function) + *function = func; } return expr; diff --git a/src/plugins/debugger/stackhandler.h b/src/plugins/debugger/stackhandler.h index 26d94bff4cc..0713042dc15 100644 --- a/src/plugins/debugger/stackhandler.h +++ b/src/plugins/debugger/stackhandler.h @@ -45,7 +45,7 @@ enum StackColumns StackFileNameColumn, StackLineNumberColumn, StackAddressColumn, - StackColumnCount = StackAddressColumn, + StackColumnCount }; //////////////////////////////////////////////////////////////////////// diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp index 4c863307c01..cf07816ae5a 100644 --- a/src/plugins/debugger/stackwindow.cpp +++ b/src/plugins/debugger/stackwindow.cpp @@ -60,18 +60,21 @@ StackTreeView::StackTreeView() { setWindowTitle(tr("Stack")); - connect(action(UseAddressInStackView), SIGNAL(toggled(bool)), - SLOT(showAddressColumn(bool))); - connect(action(ExpandStack), SIGNAL(triggered()), - SLOT(reloadFullStack())); - connect(action(MaximalStackDepth), SIGNAL(triggered()), - SLOT(reloadFullStack())); + connect(action(UseAddressInStackView), &QAction::toggled, + this, &StackTreeView::showAddressColumn); + connect(action(ExpandStack), &QAction::triggered, + this, &StackTreeView::reloadFullStack); + connect(action(MaximalStackDepth), &QAction::triggered, + this, &StackTreeView::reloadFullStack); showAddressColumn(false); } void StackTreeView::showAddressColumn(bool on) { setColumnHidden(StackAddressColumn, !on); + resizeColumnToContents(StackLevelColumn); + resizeColumnToContents(StackLineNumberColumn); + resizeColumnToContents(StackAddressColumn); } void StackTreeView::rowActivated(const QModelIndex &index) diff --git a/src/plugins/debugger/stackwindow.h b/src/plugins/debugger/stackwindow.h index c8f16ee3c45..af637ac3b98 100644 --- a/src/plugins/debugger/stackwindow.h +++ b/src/plugins/debugger/stackwindow.h @@ -38,19 +38,16 @@ namespace Internal { class StackTreeView : public Utils::BaseTreeView { - Q_OBJECT - public: StackTreeView(); -private slots: - void showAddressColumn(bool on); - void reloadFullStack(); - private: void rowActivated(const QModelIndex &index); void setModel(QAbstractItemModel *model); void contextMenuEvent(QContextMenuEvent *ev); + + void showAddressColumn(bool on); + void reloadFullStack(); void copyContentsToClipboard(); }; diff --git a/src/plugins/debugger/threadswindow.cpp b/src/plugins/debugger/threadswindow.cpp index b5ce52126be..4baceac700f 100644 --- a/src/plugins/debugger/threadswindow.cpp +++ b/src/plugins/debugger/threadswindow.cpp @@ -29,6 +29,7 @@ ****************************************************************************/ #include "threadswindow.h" +#include "threaddata.h" #include "debuggeractions.h" #include "debuggercore.h" diff --git a/src/plugins/debugger/unstartedappwatcherdialog.cpp b/src/plugins/debugger/unstartedappwatcherdialog.cpp index 5c683aa40ed..6a6b5cffc53 100644 --- a/src/plugins/debugger/unstartedappwatcherdialog.cpp +++ b/src/plugins/debugger/unstartedappwatcherdialog.cpp @@ -30,6 +30,7 @@ #include "unstartedappwatcherdialog.h" +#include "debuggeritem.h" #include "debuggerdialogs.h" #include "debuggerkitinformation.h" diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp index 42d1e3c3087..5231896b327 100644 --- a/src/plugins/designer/formeditorw.cpp +++ b/src/plugins/designer/formeditorw.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/designer/qtcreatorintegration.cpp b/src/plugins/designer/qtcreatorintegration.cpp index 1376648fd6d..79d2a6e8002 100644 --- a/src/plugins/designer/qtcreatorintegration.cpp +++ b/src/plugins/designer/qtcreatorintegration.cpp @@ -42,7 +42,9 @@ #include #include #include +#include #include +#include #include #include #include diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp index 69a30554218..6058e119f9c 100644 --- a/src/plugins/diffeditor/diffeditor.cpp +++ b/src/plugins/diffeditor/diffeditor.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/diffeditor/diffeditordocument.cpp b/src/plugins/diffeditor/diffeditordocument.cpp index 0049abe8ff3..262e2e9c09a 100644 --- a/src/plugins/diffeditor/diffeditordocument.cpp +++ b/src/plugins/diffeditor/diffeditordocument.cpp @@ -88,7 +88,7 @@ bool DiffEditorDocument::save(QString *errorString, const QString &fileName, boo const QFileInfo fi(fileName); setTemporary(false); setFilePath(Utils::FileName::fromString(fi.absoluteFilePath())); - setDisplayName(QString()); + setPreferredDisplayName(QString()); return true; } diff --git a/src/plugins/diffeditor/diffeditormanager.cpp b/src/plugins/diffeditor/diffeditormanager.cpp index 44621939366..06ec139e99e 100644 --- a/src/plugins/diffeditor/diffeditormanager.cpp +++ b/src/plugins/diffeditor/diffeditormanager.cpp @@ -98,7 +98,7 @@ Core::IDocument *DiffEditorManager::findOrCreate(const QString &vcsId, const QSt document = qobject_cast(diffEditor->document()); QTC_ASSERT(diffEditor, return 0); - document->setDisplayName(displayName); + document->setPreferredDisplayName(displayName); m_instance->m_idToDocument.insert(vcsId, document); diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp index ba78bc8a067..984931dea05 100644 --- a/src/plugins/diffeditor/diffeditorplugin.cpp +++ b/src/plugins/diffeditor/diffeditorplugin.cpp @@ -160,11 +160,9 @@ bool DiffEditorPlugin::initialize(const QStringList &arguments, QString *errorMe toolsContainer->insertGroup(Core::Constants::G_TOOLS_OPTIONS, Constants::G_TOOLS_DIFF); - Core::Context globalcontext(Core::Constants::C_GLOBAL); - QAction *diffAction = new QAction(tr("Diff..."), this); Core::Command *diffCommand = Core::ActionManager::registerAction(diffAction, - "DiffEditor.Diff", globalcontext); + "DiffEditor.Diff"); connect(diffAction, &QAction::triggered, this, &DiffEditorPlugin::diff); toolsContainer->addAction(diffCommand, Constants::G_TOOLS_DIFF); diff --git a/src/plugins/diffeditor/diffview.cpp b/src/plugins/diffeditor/diffview.cpp index 6be3133ac57..cc2478f9c1c 100644 --- a/src/plugins/diffeditor/diffview.cpp +++ b/src/plugins/diffeditor/diffview.cpp @@ -35,6 +35,8 @@ #include +#include + namespace DiffEditor { namespace Internal { diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp index b91c4b81e57..b1a3b4d0bf4 100644 --- a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp +++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp @@ -34,6 +34,8 @@ #include "diffutils.h" #include "diffeditorconstants.h" +#include + #include #include #include @@ -44,6 +46,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp index 17c1bd8c432..31bd0961f87 100644 --- a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp +++ b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -45,6 +46,7 @@ #include #include +#include #include #include #include @@ -56,6 +58,7 @@ #include #include #include +#include #include diff --git a/src/plugins/emacskeys/emacskeysplugin.cpp b/src/plugins/emacskeys/emacskeysplugin.cpp index 69fe6d919b6..ab866149854 100644 --- a/src/plugins/emacskeys/emacskeysplugin.cpp +++ b/src/plugins/emacskeys/emacskeysplugin.cpp @@ -41,6 +41,7 @@ #include #include +#include #include #include diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 2f2dc7ca81f..ff23c967174 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -1207,7 +1207,7 @@ bool FakeVimPluginPrivate::initialize() for (int i = 1; i < 10; ++i) { auto act = new QAction(this); act->setText(Tr::tr("Execute User Action #%1").arg(i)); - cmd = ActionManager::registerAction(act, base.withSuffix(i), globalcontext); + cmd = ActionManager::registerAction(act, base.withSuffix(i)); cmd->setDefaultKeySequence(QKeySequence((UseMacShortcuts ? Tr::tr("Meta+V,%1") : Tr::tr("Alt+V,%1")).arg(i))); connect(act, &QAction::triggered, this, [this, i] { userActionTriggered(i); }); } diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp index ccbc63e148e..209d8647686 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp @@ -34,6 +34,7 @@ #include #include +#include #include diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index 32601b4725e..9baaddedff1 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -297,16 +297,14 @@ bool GerritPlugin::initialize(ActionContainer *ac) QAction *openViewAction = new QAction(tr("Gerrit..."), this); m_gerritCommand = - ActionManager::registerAction(openViewAction, Constants::GERRIT_OPEN_VIEW, - Context(Core::Constants::C_GLOBAL)); + ActionManager::registerAction(openViewAction, Constants::GERRIT_OPEN_VIEW); connect(openViewAction, SIGNAL(triggered()), this, SLOT(openView())); ac->addAction(m_gerritCommand); QAction *pushAction = new QAction(tr("Push to Gerrit..."), this); m_pushToGerritCommand = - ActionManager::registerAction(pushAction, Constants::GERRIT_PUSH, - Context(Core::Constants::C_GLOBAL)); + ActionManager::registerAction(pushAction, Constants::GERRIT_PUSH); connect(pushAction, SIGNAL(triggered()), this, SLOT(push())); ac->addAction(m_pushToGerritCommand); diff --git a/src/plugins/git/gerrit/gerritpushdialog.ui b/src/plugins/git/gerrit/gerritpushdialog.ui index 806ea80a4ab..6988902d5dc 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.ui +++ b/src/plugins/git/gerrit/gerritpushdialog.ui @@ -204,6 +204,15 @@ Partial names can be used if they are unambiguous.
git/gerrit/branchcombobox.h
+ + localBranchComboBox + remoteComboBox + targetBranchComboBox + commitView + topicLineEdit + draftCheckBox + reviewersLineEdit + diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp index e3658150f18..794f59d799a 100644 --- a/src/plugins/git/giteditor.cpp +++ b/src/plugins/git/giteditor.cpp @@ -43,6 +43,8 @@ #include #include +#include + #include #include #include diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 222d76bd72f..4c9f1b9dbde 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -279,9 +279,6 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) initializeVcs(new GitVersionControl(m_gitClient), context); - // Create the contexts to register actions accordingly - Context globalcontext(Core::Constants::C_GLOBAL); - // Create the settings Page addAutoReleasedObject(new SettingsPage()); @@ -631,7 +628,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) m_createRepositryAction = new QAction(tr("Create Repository..."), this); Command *createRepositoryCommand = ActionManager::registerAction( - m_createRepositryAction, "Git.CreateRepository", globalcontext); + m_createRepositryAction, "Git.CreateRepository"); connect(m_createRepositryAction, SIGNAL(triggered()), this, SLOT(createRepository())); gitContainer->addAction(createRepositoryCommand); @@ -1014,7 +1011,7 @@ IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData & title = tr("Git Commit"); } IDocument *document = submitEditor->document(); - document->setDisplayName(title); + document->setPreferredDisplayName(title); VcsBasePlugin::setSource(document, m_submitRepository); connect(submitEditor, SIGNAL(diff(QStringList,QStringList)), this, SLOT(submitEditorDiff(QStringList,QStringList))); connect(submitEditor, SIGNAL(merge(QStringList)), this, SLOT(submitEditorMerge(QStringList))); diff --git a/src/plugins/git/gitsettings.cpp b/src/plugins/git/gitsettings.cpp index aa157433409..89cc06ed9c7 100644 --- a/src/plugins/git/gitsettings.cpp +++ b/src/plugins/git/gitsettings.cpp @@ -30,6 +30,7 @@ #include "gitsettings.h" +#include #include #include diff --git a/src/plugins/git/gitsubmiteditorwidget.cpp b/src/plugins/git/gitsubmiteditorwidget.cpp index 582dea38c7d..f66991d3886 100644 --- a/src/plugins/git/gitsubmiteditorwidget.cpp +++ b/src/plugins/git/gitsubmiteditorwidget.cpp @@ -33,6 +33,8 @@ #include "githighlighters.h" #include "logchangedialog.h" +#include + #include #include diff --git a/src/plugins/glsleditor/glslautocompleter.cpp b/src/plugins/glsleditor/glslautocompleter.cpp index 14b600ce0ff..ff79ed558ba 100644 --- a/src/plugins/glsleditor/glslautocompleter.cpp +++ b/src/plugins/glsleditor/glslautocompleter.cpp @@ -70,7 +70,8 @@ bool GlslCompleter::contextAllowsAutoParentheses(const QTextCursor &cursor, bool GlslCompleter::contextAllowsElectricCharacters(const QTextCursor &cursor) const { const Token tk = SimpleLexer::tokenAt(cursor.block().text(), cursor.positionInBlock(), - BackwardsScanner::previousBlockState(cursor.block())); + BackwardsScanner::previousBlockState(cursor.block()), + LanguageFeatures::defaultFeatures()); // XXX Duplicated from CppEditor::isInComment to avoid tokenizing twice if (tk.isComment()) { @@ -99,7 +100,8 @@ bool GlslCompleter::contextAllowsElectricCharacters(const QTextCursor &cursor) c bool GlslCompleter::isInComment(const QTextCursor &cursor) const { const Token tk = SimpleLexer::tokenAt(cursor.block().text(), cursor.positionInBlock(), - BackwardsScanner::previousBlockState(cursor.block())); + BackwardsScanner::previousBlockState(cursor.block()), + LanguageFeatures::defaultFeatures()); if (tk.isComment()) { const unsigned pos = cursor.selectionEnd() - cursor.block().position(); diff --git a/src/plugins/glsleditor/glslcompletionassist.cpp b/src/plugins/glsleditor/glslcompletionassist.cpp index 003411c5b00..ab0a8520a9d 100644 --- a/src/plugins/glsleditor/glslcompletionassist.cpp +++ b/src/plugins/glsleditor/glslcompletionassist.cpp @@ -263,7 +263,8 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i while (ch.isLetterOrNumber() || ch == QLatin1Char('_')) ch = m_interface->characterAt(--pos); - CPlusPlus::ExpressionUnderCursor expressionUnderCursor; + CPlusPlus::ExpressionUnderCursor expressionUnderCursor( + CPlusPlus::LanguageFeatures::defaultFeatures()); //GLSLTextEditorWidget *edit = qobject_cast(editor->widget()); QList members; diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp index 73901b3db59..aa14a53fcf8 100644 --- a/src/plugins/glsleditor/glsleditor.cpp +++ b/src/plugins/glsleditor/glsleditor.cpp @@ -54,6 +54,7 @@ #include #include +#include #include #include #include diff --git a/src/plugins/glsleditor/glsleditorplugin.cpp b/src/plugins/glsleditor/glsleditorplugin.cpp index bd6c2fde179..3695c0ef831 100644 --- a/src/plugins/glsleditor/glsleditorplugin.cpp +++ b/src/plugins/glsleditor/glsleditorplugin.cpp @@ -138,10 +138,9 @@ bool GlslEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er Command *cmd = 0; // Insert marker for "Refactoring" menu: - Context globalContext(Core::Constants::C_GLOBAL); - Command *sep = contextMenu->addSeparator(globalContext); + Command *sep = contextMenu->addSeparator(); sep->action()->setObjectName(QLatin1String(Constants::M_REFACTORING_MENU_INSERTION_POINT)); - contextMenu->addSeparator(globalContext); + contextMenu->addSeparator(); cmd = ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION); contextMenu->addAction(cmd); diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 12dcbb02eca..5915c9f1022 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -124,7 +124,6 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) { Q_UNUSED(arguments) Q_UNUSED(error) - Context globalcontext(Core::Constants::C_GLOBAL); Context modecontext(Constants::C_MODE_HELP); const QString &locale = ICore::userInterfaceLanguage(); @@ -177,28 +176,28 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) // Add Contents, Index, and Context menu items action = new QAction(QIcon::fromTheme(QLatin1String("help-contents")), tr(Constants::SB_CONTENTS), this); - cmd = ActionManager::registerAction(action, "Help.ContentsMenu", globalcontext); + cmd = ActionManager::registerAction(action, "Help.ContentsMenu"); ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP); connect(action, SIGNAL(triggered()), this, SLOT(activateContents())); action = new QAction(tr(Constants::SB_INDEX), this); - cmd = ActionManager::registerAction(action, "Help.IndexMenu", globalcontext); + cmd = ActionManager::registerAction(action, "Help.IndexMenu"); ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP); connect(action, SIGNAL(triggered()), this, SLOT(activateIndex())); action = new QAction(tr("Context Help"), this); - cmd = ActionManager::registerAction(action, Help::Constants::CONTEXT_HELP, globalcontext); + cmd = ActionManager::registerAction(action, Help::Constants::CONTEXT_HELP); ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP); cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1)); connect(action, SIGNAL(triggered()), this, SLOT(showContextHelp())); action = new QAction(tr("Technical Support"), this); - cmd = ActionManager::registerAction(action, "Help.TechSupport", globalcontext); + cmd = ActionManager::registerAction(action, "Help.TechSupport"); ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_SUPPORT); connect(action, SIGNAL(triggered()), this, SLOT(slotOpenSupportPage())); action = new QAction(tr("Report Bug..."), this); - cmd = ActionManager::registerAction(action, "Help.ReportBug", globalcontext); + cmd = ActionManager::registerAction(action, "Help.ReportBug"); ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_SUPPORT); connect(action, SIGNAL(triggered()), this, SLOT(slotReportBug())); @@ -635,7 +634,7 @@ void HelpPlugin::handleHelpRequest(const QUrl &url, HelpManager::HelpViewerLocat || address.startsWith(QLatin1String("qthelp://com.nokia.")) || address.startsWith(QLatin1String("qthelp://com.trolltech."))) { // local help not installed, resort to external web help - QString urlPrefix = QLatin1String("http://qt-project.org/doc/"); + QString urlPrefix = QLatin1String("http://doc.qt.io/"); if (url.authority() == QLatin1String("org.qt-project.qtcreator")) urlPrefix.append(QString::fromLatin1("qtcreator")); else diff --git a/src/plugins/ios/iosconfigurations.cpp b/src/plugins/ios/iosconfigurations.cpp index 0bc72ed83d9..4c7b692587a 100644 --- a/src/plugins/ios/iosconfigurations.cpp +++ b/src/plugins/ios/iosconfigurations.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/macros/macrosplugin.cpp b/src/plugins/macros/macrosplugin.cpp index 46ee1e5bd66..519cc9a6788 100644 --- a/src/plugins/macros/macrosplugin.cpp +++ b/src/plugins/macros/macrosplugin.cpp @@ -70,7 +70,6 @@ bool MacrosPlugin::initialize(const QStringList &arguments, QString *errorMessag addAutoReleasedObject(new MacroOptionsPage); addAutoReleasedObject(new MacroLocatorFilter); - Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::Context textContext(TextEditor::Constants::C_TEXTEDITOR); m_macroManager = new MacroManager(this); @@ -90,7 +89,7 @@ bool MacrosPlugin::initialize(const QStringList &arguments, QString *errorMessag QAction *endMacro = new QAction(tr("Stop Recording Macro"), this); endMacro->setEnabled(false); - command = Core::ActionManager::registerAction(endMacro, Constants::END_MACRO, globalcontext); + command = Core::ActionManager::registerAction(endMacro, Constants::END_MACRO); command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Ctrl+)") : tr("Alt+)"))); mmacrotools->addAction(command); connect(endMacro, &QAction::triggered, m_macroManager, &MacroManager::endMacro); diff --git a/src/plugins/mercurial/commiteditor.cpp b/src/plugins/mercurial/commiteditor.cpp index 73b9b7ab845..724ce2d100f 100644 --- a/src/plugins/mercurial/commiteditor.cpp +++ b/src/plugins/mercurial/commiteditor.cpp @@ -45,7 +45,7 @@ CommitEditor::CommitEditor(const VcsBaseSubmitEditorParameters *parameters) : VcsBaseSubmitEditor(parameters, new MercurialCommitWidget), fileModel(0) { - document()->setDisplayName(tr("Commit Editor")); + document()->setPreferredDisplayName(tr("Commit Editor")); } MercurialCommitWidget *CommitEditor::commitWidget() diff --git a/src/plugins/mercurial/mercurialclient.cpp b/src/plugins/mercurial/mercurialclient.cpp index ac3eed0eb62..1f51137eedd 100644 --- a/src/plugins/mercurial/mercurialclient.cpp +++ b/src/plugins/mercurial/mercurialclient.cpp @@ -409,7 +409,7 @@ MercurialClient::StatusItem MercurialClient::parseStatusLine(const QString &line //the status line should be similar to "M file_with_changes" //so just should take the file name part and store it - item.file = line.mid(2); + item.file = QDir::fromNativeSeparators(line.mid(2)); } return item; } diff --git a/src/plugins/mercurial/mercurialcommitwidget.cpp b/src/plugins/mercurial/mercurialcommitwidget.cpp index 320e773afd9..cfcbf759d06 100644 --- a/src/plugins/mercurial/mercurialcommitwidget.cpp +++ b/src/plugins/mercurial/mercurialcommitwidget.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/mercurial/mercurialcontrol.cpp b/src/plugins/mercurial/mercurialcontrol.cpp index fbbfe202461..8482d703538 100644 --- a/src/plugins/mercurial/mercurialcontrol.cpp +++ b/src/plugins/mercurial/mercurialcontrol.cpp @@ -36,6 +36,8 @@ #include +#include + #include #include #include diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp index 137a9de51cf..13ada03c798 100644 --- a/src/plugins/mercurial/mercurialplugin.cpp +++ b/src/plugins/mercurial/mercurialplugin.cpp @@ -581,7 +581,7 @@ void MercurialPlugin::showCommitWidget(const QList &s const QString msg = tr("Commit changes for \"%1\"."). arg(QDir::toNativeSeparators(m_submitRepository)); - commitEditor->document()->setDisplayName(msg); + commitEditor->document()->setPreferredDisplayName(msg); QString branch = versionControl()->vcsTopic(m_submitRepository); commitEditor->setFields(m_submitRepository, branch, diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index fb2bba4041d..f9582b03cfa 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/perforce/perforcesubmiteditor.cpp b/src/plugins/perforce/perforcesubmiteditor.cpp index 2155a9b1663..3f595143241 100644 --- a/src/plugins/perforce/perforcesubmiteditor.cpp +++ b/src/plugins/perforce/perforcesubmiteditor.cpp @@ -48,7 +48,7 @@ PerforceSubmitEditor::PerforceSubmitEditor(const VcsBase::VcsBaseSubmitEditorPar VcsBaseSubmitEditor(parameters, new PerforceSubmitEditorWidget), m_fileModel(new VcsBase::SubmitFileModel(this)) { - document()->setDisplayName(tr("Perforce Submit")); + document()->setPreferredDisplayName(tr("Perforce Submit")); setFileModel(m_fileModel); } diff --git a/src/plugins/projectexplorer/allprojectsfind.cpp b/src/plugins/projectexplorer/allprojectsfind.cpp index 7401b76cf0a..5a01c34f028 100644 --- a/src/plugins/projectexplorer/allprojectsfind.cpp +++ b/src/plugins/projectexplorer/allprojectsfind.cpp @@ -36,6 +36,8 @@ #include "editorconfiguration.h" #include +#include +#include #include #include diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index 147cc1f4b5c..aa2877116a2 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -44,8 +44,9 @@ #include #include -#include #include +#include +#include #include #include @@ -160,15 +161,13 @@ AppOutputPane::AppOutputPane() : this, SLOT(reRunRunControl())); // Stop - Core::Context globalcontext(Core::Constants::C_GLOBAL); - QIcon stopIcon = QIcon(QLatin1String(Constants::ICON_STOP)); stopIcon.addFile(QLatin1String(Constants::ICON_STOP_SMALL)); m_stopAction->setIcon(stopIcon); m_stopAction->setToolTip(tr("Stop")); m_stopAction->setEnabled(false); - Core::Command *cmd = Core::ActionManager::registerAction(m_stopAction, Constants::STOP, globalcontext); + Core::Command *cmd = Core::ActionManager::registerAction(m_stopAction, Constants::STOP); m_stopButton->setDefaultAction(cmd->action()); m_stopButton->setAutoRaise(true); diff --git a/src/plugins/projectexplorer/currentprojectfind.cpp b/src/plugins/projectexplorer/currentprojectfind.cpp index a40b7965852..876ab96d005 100644 --- a/src/plugins/projectexplorer/currentprojectfind.cpp +++ b/src/plugins/projectexplorer/currentprojectfind.cpp @@ -44,6 +44,14 @@ using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; using namespace TextEditor; +static Project *currentProject() +{ + Project *p = ProjectTree::currentProject(); + if (p) + return p; + return SessionManager::startupProject(); +} + CurrentProjectFind::CurrentProjectFind() { connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged, @@ -68,12 +76,12 @@ QString CurrentProjectFind::displayName() const bool CurrentProjectFind::isEnabled() const { - return ProjectTree::currentProject() != 0 && BaseFileFind::isEnabled(); + return currentProject() != 0 && BaseFileFind::isEnabled(); } QVariant CurrentProjectFind::additionalParameters() const { - Project *project = ProjectTree::currentProject(); + Project *project = currentProject(); if (project && project->document()) return qVariantFromValue(project->projectFilePath().toString()); return QVariant(); @@ -94,8 +102,9 @@ Utils::FileIterator *CurrentProjectFind::files(const QStringList &nameFilters, QString CurrentProjectFind::label() const { - QTC_ASSERT(ProjectTree::currentProject(), return QString()); - return tr("Project \"%1\":").arg(ProjectTree::currentProject()->displayName()); + Project *p = currentProject(); + QTC_ASSERT(p, return QString()); + return tr("Project \"%1\":").arg(p->displayName()); } void CurrentProjectFind::handleProjectChanged() diff --git a/src/plugins/projectexplorer/editorconfiguration.cpp b/src/plugins/projectexplorer/editorconfiguration.cpp index 82d8ab93e6e..d67adce1467 100644 --- a/src/plugins/projectexplorer/editorconfiguration.cpp +++ b/src/plugins/projectexplorer/editorconfiguration.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index 74bbe7f0b80..05e1de44e8a 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -586,9 +586,12 @@ QList MsvcToolChainFactory::autoDetect() const QString vcvarsAllbat = path + QLatin1String("/vcvarsall.bat"); if (QFileInfo(vcvarsAllbat).isFile()) { QList platforms; // prioritized list + // x86_arm was put before amd64_arm as a workaround for auto detected windows phone + // toolchains. As soon as windows phone builds support x64 cross builds, this change + // can be reverted. platforms << MsvcToolChain::x86 << MsvcToolChain::amd64 << MsvcToolChain::x86_amd64 - << MsvcToolChain::arm << MsvcToolChain::amd64_arm << MsvcToolChain::x86_arm + << MsvcToolChain::arm << MsvcToolChain::x86_arm << MsvcToolChain::amd64_arm << MsvcToolChain::ia64 << MsvcToolChain::x86_ia64; foreach (const MsvcToolChain::Platform &platform, platforms) { if (hostSupportsPlatform(platform) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 55afb599116..faef1ed2cfb 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -541,7 +541,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_proWindow = new ProjectWindow; addAutoReleasedObject(dd->m_proWindow); - Context globalcontext(Core::Constants::C_GLOBAL); Context projecTreeContext(Constants::C_PROJECT_TREE); dd->m_projectsMode = new ProjectsMode(dd->m_proWindow); @@ -735,12 +734,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er msessionContextMenu->addSeparator(projecTreeContext, Constants::G_SESSION_FILES); mprojectContextMenu->addSeparator(projecTreeContext, Constants::G_PROJECT_FILES); msubProjectContextMenu->addSeparator(projecTreeContext, Constants::G_PROJECT_FILES); - mfile->addSeparator(globalcontext, Core::Constants::G_FILE_PROJECT); - mbuild->addSeparator(globalcontext, Constants::G_BUILD_REBUILD); - msessionContextMenu->addSeparator(globalcontext, Constants::G_SESSION_OTHER); - mbuild->addSeparator(globalcontext, Constants::G_BUILD_CANCEL); - mbuild->addSeparator(globalcontext, Constants::G_BUILD_RUN); - mprojectContextMenu->addSeparator(globalcontext, Constants::G_PROJECT_REBUILD); + mfile->addSeparator(Core::Constants::G_FILE_PROJECT); + mbuild->addSeparator(Constants::G_BUILD_REBUILD); + msessionContextMenu->addSeparator(Constants::G_SESSION_OTHER); + mbuild->addSeparator(Constants::G_BUILD_CANCEL); + mbuild->addSeparator(Constants::G_BUILD_RUN); + mprojectContextMenu->addSeparator(Constants::G_PROJECT_REBUILD); // // Actions @@ -748,13 +747,13 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // new action dd->m_newAction = new QAction(tr("New Project..."), this); - cmd = ActionManager::registerAction(dd->m_newAction, Constants::NEWPROJECT, globalcontext); + cmd = ActionManager::registerAction(dd->m_newAction, Constants::NEWPROJECT); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+N"))); msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES); // open action dd->m_loadAction = new QAction(tr("Load Project..."), this); - cmd = ActionManager::registerAction(dd->m_loadAction, Constants::LOAD, globalcontext); + cmd = ActionManager::registerAction(dd->m_loadAction, Constants::LOAD); #ifndef Q_OS_MAC cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+O"))); #endif @@ -809,7 +808,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // session manager action dd->m_sessionManagerAction = new QAction(tr("Session Manager..."), this); - cmd = ActionManager::registerAction(dd->m_sessionManagerAction, Constants::NEWSESSION, globalcontext); + cmd = ActionManager::registerAction(dd->m_sessionManagerAction, Constants::NEWSESSION); mfile->addAction(cmd, Core::Constants::G_FILE_OPEN); cmd->setDefaultKeySequence(QKeySequence()); @@ -817,7 +816,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // unload action dd->m_unloadAction = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - cmd = ActionManager::registerAction(dd->m_unloadAction, Constants::UNLOAD, globalcontext); + cmd = ActionManager::registerAction(dd->m_unloadAction, Constants::UNLOAD); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(dd->m_unloadAction->text()); mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT); @@ -832,7 +831,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // unload session action dd->m_closeAllProjects = new QAction(tr("Close All Projects and Editors"), this); - cmd = ActionManager::registerAction(dd->m_closeAllProjects, Constants::CLEARSESSION, globalcontext); + cmd = ActionManager::registerAction(dd->m_closeAllProjects, Constants::CLEARSESSION); mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT); msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES); @@ -840,14 +839,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er QIcon buildIcon = QIcon(QLatin1String(Constants::ICON_BUILD)); buildIcon.addFile(QLatin1String(Constants::ICON_BUILD_SMALL)); dd->m_buildSessionAction = new QAction(buildIcon, tr("Build All"), this); - cmd = ActionManager::registerAction(dd->m_buildSessionAction, Constants::BUILDSESSION, globalcontext); + cmd = ActionManager::registerAction(dd->m_buildSessionAction, Constants::BUILDSESSION); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+B"))); mbuild->addAction(cmd, Constants::G_BUILD_BUILD); msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD); // deploy session dd->m_deploySessionAction = new QAction(tr("Deploy All"), this); - cmd = ActionManager::registerAction(dd->m_deploySessionAction, Constants::DEPLOYSESSION, globalcontext); + cmd = ActionManager::registerAction(dd->m_deploySessionAction, Constants::DEPLOYSESSION); mbuild->addAction(cmd, Constants::G_BUILD_DEPLOY); msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD); @@ -855,7 +854,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er QIcon rebuildIcon = QIcon(QLatin1String(Constants::ICON_REBUILD)); rebuildIcon.addFile(QLatin1String(Constants::ICON_REBUILD_SMALL)); dd->m_rebuildSessionAction = new QAction(rebuildIcon, tr("Rebuild All"), this); - cmd = ActionManager::registerAction(dd->m_rebuildSessionAction, Constants::REBUILDSESSION, globalcontext); + cmd = ActionManager::registerAction(dd->m_rebuildSessionAction, Constants::REBUILDSESSION); mbuild->addAction(cmd, Constants::G_BUILD_REBUILD); msessionContextMenu->addAction(cmd, Constants::G_SESSION_REBUILD); @@ -863,7 +862,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er QIcon cleanIcon = QIcon(QLatin1String(Constants::ICON_CLEAN)); cleanIcon.addFile(QLatin1String(Constants::ICON_CLEAN_SMALL)); dd->m_cleanSessionAction = new QAction(cleanIcon, tr("Clean All"), this); - cmd = ActionManager::registerAction(dd->m_cleanSessionAction, Constants::CLEANSESSION, globalcontext); + cmd = ActionManager::registerAction(dd->m_cleanSessionAction, Constants::CLEANSESSION); mbuild->addAction(cmd, Constants::G_BUILD_CLEAN); msessionContextMenu->addAction(cmd, Constants::G_SESSION_REBUILD); @@ -871,7 +870,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_buildAction = new Utils::ParameterAction(tr("Build Project"), tr("Build Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); dd->m_buildAction->setIcon(buildIcon); - cmd = ActionManager::registerAction(dd->m_buildAction, Constants::BUILD, globalcontext); + cmd = ActionManager::registerAction(dd->m_buildAction, Constants::BUILD); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(dd->m_buildAction->text()); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+B"))); @@ -883,7 +882,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // deploy action dd->m_deployAction = new Utils::ParameterAction(tr("Deploy Project"), tr("Deploy Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - cmd = ActionManager::registerAction(dd->m_deployAction, Constants::DEPLOY, globalcontext); + cmd = ActionManager::registerAction(dd->m_deployAction, Constants::DEPLOY); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(dd->m_deployAction->text()); mbuild->addAction(cmd, Constants::G_BUILD_DEPLOY); @@ -891,7 +890,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // rebuild action dd->m_rebuildAction = new Utils::ParameterAction(tr("Rebuild Project"), tr("Rebuild Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - cmd = ActionManager::registerAction(dd->m_rebuildAction, Constants::REBUILD, globalcontext); + cmd = ActionManager::registerAction(dd->m_rebuildAction, Constants::REBUILD); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(dd->m_rebuildAction->text()); mbuild->addAction(cmd, Constants::G_BUILD_REBUILD); @@ -899,7 +898,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // clean action dd->m_cleanAction = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - cmd = ActionManager::registerAction(dd->m_cleanAction, Constants::CLEAN, globalcontext); + cmd = ActionManager::registerAction(dd->m_cleanAction, Constants::CLEAN); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(dd->m_cleanAction->text()); mbuild->addAction(cmd, Constants::G_BUILD_CLEAN); @@ -908,12 +907,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er QIcon stopIcon = QIcon(QLatin1String(Constants::ICON_STOP)); stopIcon.addFile(QLatin1String(Constants::ICON_STOP_SMALL)); dd->m_cancelBuildAction = new QAction(stopIcon, tr("Cancel Build"), this); - cmd = ActionManager::registerAction(dd->m_cancelBuildAction, Constants::CANCELBUILD, globalcontext); + cmd = ActionManager::registerAction(dd->m_cancelBuildAction, Constants::CANCELBUILD); mbuild->addAction(cmd, Constants::G_BUILD_CANCEL); // run action dd->m_runAction = new QAction(runIcon, tr("Run"), this); - cmd = ActionManager::registerAction(dd->m_runAction, Constants::RUN, globalcontext); + cmd = ActionManager::registerAction(dd->m_runAction, Constants::RUN); cmd->setAttribute(Command::CA_UpdateText); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+R"))); @@ -923,7 +922,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // Run without deployment action dd->m_runWithoutDeployAction = new QAction(tr("Run Without Deployment"), this); - cmd = ActionManager::registerAction(dd->m_runWithoutDeployAction, Constants::RUNWITHOUTDEPLOY, globalcontext); + cmd = ActionManager::registerAction(dd->m_runWithoutDeployAction, Constants::RUNWITHOUTDEPLOY); mbuild->addAction(cmd, Constants::G_BUILD_RUN); // build action (context menu) @@ -946,19 +945,19 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // build without dependencies action dd->m_buildProjectOnlyAction = new QAction(tr("Build Without Dependencies"), this); - ActionManager::registerAction(dd->m_buildProjectOnlyAction, Constants::BUILDPROJECTONLY, globalcontext); + ActionManager::registerAction(dd->m_buildProjectOnlyAction, Constants::BUILDPROJECTONLY); // rebuild without dependencies action dd->m_rebuildProjectOnlyAction = new QAction(tr("Rebuild Without Dependencies"), this); - ActionManager::registerAction(dd->m_rebuildProjectOnlyAction, Constants::REBUILDPROJECTONLY, globalcontext); + ActionManager::registerAction(dd->m_rebuildProjectOnlyAction, Constants::REBUILDPROJECTONLY); // deploy without dependencies action dd->m_deployProjectOnlyAction = new QAction(tr("Deploy Without Dependencies"), this); - ActionManager::registerAction(dd->m_deployProjectOnlyAction, Constants::DEPLOYPROJECTONLY, globalcontext); + ActionManager::registerAction(dd->m_deployProjectOnlyAction, Constants::DEPLOYPROJECTONLY); // clean without dependencies action dd->m_cleanProjectOnlyAction = new QAction(tr("Clean Without Dependencies"), this); - ActionManager::registerAction(dd->m_cleanProjectOnlyAction, Constants::CLEANPROJECTONLY, globalcontext); + ActionManager::registerAction(dd->m_cleanProjectOnlyAction, Constants::CLEANPROJECTONLY); // deploy action (context menu) dd->m_deployActionContextMenu = new QAction(tr("Deploy"), this); @@ -1005,7 +1004,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // unload project again, in right position dd->m_unloadActionContextMenu = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); - cmd = ActionManager::registerAction(dd->m_unloadActionContextMenu, Constants::UNLOADCM, globalcontext); + cmd = ActionManager::registerAction(dd->m_unloadActionContextMenu, Constants::UNLOADCM); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(dd->m_unloadActionContextMenu->text()); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST); @@ -1055,15 +1054,15 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er cmd = ActionManager::registerAction(dd->m_projectTreeCollapseAllAction, Constants::PROJECTTREE_COLLAPSE_ALL, projecTreeContext); const Id treeGroup = Constants::G_PROJECT_TREE; - mfileContextMenu->addSeparator(globalcontext, treeGroup); + mfileContextMenu->addSeparator(treeGroup); mfileContextMenu->addAction(cmd, treeGroup); - msubProjectContextMenu->addSeparator(globalcontext, treeGroup); + msubProjectContextMenu->addSeparator(treeGroup); msubProjectContextMenu->addAction(cmd, treeGroup); - mfolderContextMenu->addSeparator(globalcontext, treeGroup); + mfolderContextMenu->addSeparator(treeGroup); mfolderContextMenu->addAction(cmd, treeGroup); - mprojectContextMenu->addSeparator(globalcontext, treeGroup); + mprojectContextMenu->addSeparator(treeGroup); mprojectContextMenu->addAction(cmd, treeGroup); - msessionContextMenu->addSeparator(globalcontext, treeGroup); + msessionContextMenu->addSeparator(treeGroup); msessionContextMenu->addAction(cmd, treeGroup); // target selector @@ -1080,8 +1079,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_projectSelectorActionMenu->setText(tr("Open Build and Run Kit Selector...")); connect(dd->m_projectSelectorActionMenu, &QAction::triggered, dd->m_targetSelector, &MiniProjectTargetSelector::toggleVisible); - cmd = ActionManager::registerAction(dd->m_projectSelectorActionMenu, Constants::SELECTTARGET, - globalcontext); + cmd = ActionManager::registerAction(dd->m_projectSelectorActionMenu, Constants::SELECTTARGET); mbuild->addAction(cmd, Constants::G_BUILD_RUN); dd->m_projectSelectorActionQuick = new QAction(this); @@ -1089,7 +1087,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er dd->m_projectSelectorActionQuick->setText(tr("Quick Switch Kit Selector")); connect(dd->m_projectSelectorActionQuick, &QAction::triggered, dd->m_targetSelector, &MiniProjectTargetSelector::nextOrShow); - cmd = ActionManager::registerAction(dd->m_projectSelectorActionQuick, Constants::SELECTTARGETQUICK, globalcontext); + cmd = ActionManager::registerAction(dd->m_projectSelectorActionQuick, Constants::SELECTTARGETQUICK); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+T"))); connect(ICore::instance(), &ICore::saveSettingsRequested, @@ -2042,7 +2040,7 @@ static QString pathOrDirectoryFor(Node *node, bool dir) { Utils::FileName path = node->path(); QString location; - FolderNode *folder = dynamic_cast(node); + FolderNode *folder = node->asFolderNode(); if (node->nodeType() == VirtualFolderNodeType && folder) { // Virtual Folder case // If there are files directly below or no subfolders, take the folder path @@ -2397,7 +2395,8 @@ void ProjectExplorerPluginPrivate::runProjectWithoutDeploy() void ProjectExplorerPluginPrivate::runProjectContextMenu() { - ProjectNode *projectNode = dynamic_cast(ProjectTree::currentNode()); + Node *node = ProjectTree::currentNode(); + ProjectNode *projectNode = node ? node->asProjectNode() : 0; if (projectNode == ProjectTree::currentProject()->rootProjectNode() || !projectNode) { m_instance->runProject(ProjectTree::currentProject(), NormalRunMode); } else { @@ -2916,7 +2915,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions() if (currentNode && currentNode->projectNode()) { QList actions = currentNode->supportedActions(currentNode); - if (ProjectNode *pn = dynamic_cast(currentNode)) { + if (ProjectNode *pn = currentNode->asProjectNode()) { if (ProjectTree::currentProject() && pn == ProjectTree::currentProject()->rootProjectNode()) { m_runActionContextMenu->setVisible(true); } else { @@ -2937,7 +2936,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions() } } } - if (dynamic_cast(currentNode)) { + if (currentNode->asFolderNode()) { // Also handles ProjectNode m_addNewFileAction->setEnabled(actions.contains(AddNewFile) && !ICore::isNewItemDialogRunning()); @@ -2949,7 +2948,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions() m_addExistingFilesAction->setEnabled(actions.contains(AddExistingFile)); m_addExistingDirectoryAction->setEnabled(actions.contains(AddExistingDirectory)); m_renameFileAction->setEnabled(actions.contains(Rename)); - } else if (dynamic_cast(currentNode)) { + } else if (currentNode->asFileNode()) { // Enable and show remove / delete in magic ways: // If both are disabled show Remove // If both are enabled show both (can't happen atm) @@ -3050,7 +3049,8 @@ void ProjectExplorerPluginPrivate::addExistingDirectory() void ProjectExplorerPlugin::addExistingFiles(const QStringList &filePaths) { - FolderNode *folderNode = dynamic_cast(ProjectTree::currentNode()); + Node *node = ProjectTree::currentNode(); + FolderNode *folderNode = node ? node->asFolderNode() : 0; addExistingFiles(folderNode, filePaths); } @@ -3079,8 +3079,13 @@ void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const QStri void ProjectExplorerPluginPrivate::removeProject() { - ProjectNode *subProjectNode = dynamic_cast(ProjectTree::currentNode()->projectNode()); - ProjectNode *projectNode = dynamic_cast(subProjectNode->parentFolderNode()); + Node *node = ProjectTree::currentNode(); + if (!node) + return; + ProjectNode *subProjectNode = node->projectNode(); + if (!subProjectNode) + return; + ProjectNode *projectNode = subProjectNode->parentFolderNode()->asProjectNode(); if (projectNode) { RemoveFileDialog removeFileDialog(subProjectNode->path().toString(), ICore::mainWindow()); removeFileDialog.setDeleteFileVisible(false); @@ -3118,7 +3123,7 @@ void ProjectExplorerPluginPrivate::removeFile() Node *currentNode = ProjectTree::currentNode(); QTC_ASSERT(currentNode && currentNode->nodeType() == FileNodeType, return); - FileNode *fileNode = dynamic_cast(currentNode); + FileNode *fileNode = currentNode->asFileNode(); QString filePath = currentNode->path().toString(); RemoveFileDialog removeFileDialog(filePath, ICore::mainWindow()); @@ -3147,7 +3152,7 @@ void ProjectExplorerPluginPrivate::deleteFile() Node *currentNode = ProjectTree::currentNode(); QTC_ASSERT(currentNode && currentNode->nodeType() == FileNodeType, return); - FileNode *fileNode = dynamic_cast(currentNode); + FileNode *fileNode = currentNode->asFileNode(); QString filePath = currentNode->path().toString(); QMessageBox::StandardButton button = diff --git a/src/plugins/projectexplorer/projectmodels.cpp b/src/plugins/projectexplorer/projectmodels.cpp index 30210bd1554..f99e99d2e8c 100644 --- a/src/plugins/projectexplorer/projectmodels.cpp +++ b/src/plugins/projectexplorer/projectmodels.cpp @@ -59,8 +59,8 @@ bool sortNodes(Node *n1, Node *n2) const NodeType n2Type = n2->nodeType(); // project files - FileNode *file1 = dynamic_cast(n1); - FileNode *file2 = dynamic_cast(n2); + FileNode *file1 = n1->asFileNode(); + FileNode *file2 = n2->asFileNode(); if (file1 && file1->fileType() == ProjectFileType) { if (file2 && file2->fileType() == ProjectFileType) { const QString fileName1 = file1->path().fileName(); @@ -221,7 +221,7 @@ QModelIndex FlatModel::index(int row, int column, const QModelIndex &parent) con if (!parent.isValid() && row == 0 && column == 0) { // session result = createIndex(0, 0, m_rootNode); } else if (parent.isValid() && column == 0) { - FolderNode *parentNode = dynamic_cast(nodeForIndex(parent)); + FolderNode *parentNode = nodeForIndex(parent)->asFolderNode(); Q_ASSERT(parentNode); QHash >::const_iterator it = m_childNodes.constFind(parentNode); if (it == m_childNodes.constEnd()) { @@ -270,7 +270,7 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const QVariant result; if (Node *node = nodeForIndex(index)) { - FolderNode *folderNode = dynamic_cast(node); + FolderNode *folderNode = node->asFolderNode(); switch (role) { case Qt::DisplayRole: { QString name = node->displayName(); @@ -334,11 +334,11 @@ Qt::ItemFlags FlatModel::flags(const QModelIndex &index) const if (Node *node = nodeForIndex(index)) { if (node == m_rootNode) return 0; // no flags for session node... - if (!dynamic_cast(node)) { + if (!node->asProjectNode()) { // either folder or file node if (node->supportedActions(node).contains(Rename)) f = f | Qt::ItemIsEditable; - if (dynamic_cast(node)) + if (node->asFileNode()) f = f | Qt::ItemIsDragEnabled; } } @@ -368,7 +368,7 @@ int FlatModel::rowCount(const QModelIndex &parent) const if (!parent.isValid()) { rows = 1; } else { - FolderNode *folderNode = dynamic_cast(nodeForIndex(parent)); + FolderNode *folderNode = nodeForIndex(parent)->asFolderNode(); if (folderNode && m_childNodes.contains(folderNode)) rows = m_childNodes.value(folderNode).size(); } @@ -385,7 +385,7 @@ bool FlatModel::hasChildren(const QModelIndex &parent) const if (!parent.isValid()) return true; - FolderNode *folderNode = dynamic_cast(nodeForIndex(parent)); + FolderNode *folderNode = nodeForIndex(parent)->asFolderNode(); if (!folderNode) return false; @@ -402,7 +402,7 @@ bool FlatModel::canFetchMore(const QModelIndex & parent) const if (!parent.isValid()) { return false; } else { - if (FolderNode *folderNode = dynamic_cast(nodeForIndex(parent))) + if (FolderNode *folderNode = nodeForIndex(parent)->asFolderNode()) return !m_childNodes.contains(folderNode); else return false; @@ -472,7 +472,7 @@ void FlatModel::fetchMore(FolderNode *folderNode) const void FlatModel::fetchMore(const QModelIndex &parent) { - FolderNode *folderNode = dynamic_cast(nodeForIndex(parent)); + FolderNode *folderNode = nodeForIndex(parent)->asFolderNode(); Q_ASSERT(folderNode); fetchMore(folderNode); @@ -513,7 +513,7 @@ QMimeData *FlatModel::mimeData(const QModelIndexList &indexes) const auto data = new Utils::FileDropMimeData; foreach (const QModelIndex &index, indexes) { Node *node = nodeForIndex(index); - if (dynamic_cast(node)) + if (node->asFileNode()) data->addFile(node->path().toString()); } return data; @@ -600,10 +600,10 @@ FolderNode *FlatModel::visibleFolderNode(FolderNode *node) const bool FlatModel::filter(Node *node) const { bool isHidden = false; - if (FolderNode *folderNode = dynamic_cast(node)) { + if (FolderNode *folderNode = node->asFolderNode()) { if (m_filterProjects) isHidden = !folderNode->showInSimpleTree(); - } else if (FileNode *fileNode = dynamic_cast(node)) { + } else if (FileNode *fileNode = node->asFileNode()) { if (m_filterGeneratedFiles) isHidden = fileNode->isGenerated(); } @@ -802,7 +802,7 @@ void FlatModel::aboutToShowInSimpleTreeChanged(FolderNode* node) QList staleFolders; recursiveAddFolderNodesImpl(node, &staleFolders); foreach (Node *n, staleFolders) - if (FolderNode *fn = dynamic_cast(n)) + if (FolderNode *fn = n->asFolderNode()) m_childNodes.remove(fn); } diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp index ef435670d49..800ccfc9425 100644 --- a/src/plugins/projectexplorer/projectnodes.cpp +++ b/src/plugins/projectexplorer/projectnodes.cpp @@ -155,7 +155,7 @@ FolderNode *Node::parentFolderNode() const /*! The path of the file or folder in the filesystem the node represents. */ -Utils::FileName Node::path() const +const Utils::FileName &Node::path() const { return m_path; } @@ -198,6 +198,26 @@ void Node::emitNodeUpdated() ProjectTree::instance()->emitNodeUpdated(this); } +FileNode *Node::asFileNode() +{ + return 0; +} + +FolderNode *Node::asFolderNode() +{ + return 0; +} + +ProjectNode *Node::asProjectNode() +{ + return 0; +} + +SessionNode *Node::asSessionNode() +{ + return 0; +} + void Node::setParentFolderNode(FolderNode *parentFolder) { m_folderNode = parentFolder; @@ -235,6 +255,11 @@ bool FileNode::isGenerated() const return m_generated; } +FileNode *FileNode::asFileNode() +{ + return this; +} + /*! \class ProjectExplorer::FolderNode @@ -494,6 +519,11 @@ void FolderNode::removeFolderNodes(const QList &subFolders) ProjectTree::instance()->emitFoldersRemoved(this); } +FolderNode *FolderNode::asFolderNode() +{ + return this; +} + bool FolderNode::showInSimpleTree() const { return false; @@ -672,6 +702,11 @@ void ProjectNode::removeProjectNodes(const QList &subProjects) } } +ProjectNode *ProjectNode::asProjectNode() +{ + return this; +} + /*! \class ProjectExplorer::SessionNode @@ -707,6 +742,11 @@ void SessionNode::projectDisplayNameChanged(Node *node) ProjectTree::instance()->emitNodeSortKeyChanged(node); } +SessionNode *SessionNode::asSessionNode() +{ + return this; +} + QList SessionNode::projectNodes() const { return m_projectNodes; diff --git a/src/plugins/projectexplorer/projectnodes.h b/src/plugins/projectexplorer/projectnodes.h index 57c5dc5299c..8e9f6533479 100644 --- a/src/plugins/projectexplorer/projectnodes.h +++ b/src/plugins/projectexplorer/projectnodes.h @@ -100,6 +100,7 @@ class FileNode; class FileContainerNode; class FolderNode; class ProjectNode; +class SessionNode; class NodesVisitor; class SessionManager; @@ -111,7 +112,7 @@ public: NodeType nodeType() const; ProjectNode *projectNode() const; // managing project FolderNode *parentFolderNode() const; // parent folder or project - Utils::FileName path() const; // file system path + const Utils::FileName &path() const; // file system path int line() const; virtual QString displayName() const; virtual QString tooltip() const; @@ -124,6 +125,11 @@ public: void setPathAndLine(const Utils::FileName &path, int line); void emitNodeUpdated(); + virtual FileNode *asFileNode(); + virtual FolderNode *asFolderNode(); + virtual ProjectNode *asProjectNode(); + virtual SessionNode *asSessionNode(); + protected: Node(NodeType nodeType, const Utils::FileName &path, int line = -1); @@ -149,6 +155,8 @@ public: FileType fileType() const; bool isGenerated() const; + FileNode *asFileNode(); + private: // managed by ProjectNode friend class FolderNode; @@ -204,6 +212,7 @@ public: void addFolderNodes(const QList &subFolders); void removeFolderNodes(const QList &subFolders); + FolderNode *asFolderNode(); protected: QList m_subFolderNodes; @@ -256,6 +265,8 @@ public: void addProjectNodes(const QList &subProjects); void removeProjectNodes(const QList &subProjects); + ProjectNode *asProjectNode(); + protected: // this is just the in-memory representation, a subclass // will add the persistent stuff @@ -285,6 +296,8 @@ public: bool showInSimpleTree() const; void projectDisplayNameChanged(Node *node); + + SessionNode *asSessionNode(); protected: void addProjectNodes(const QList &projectNodes); void removeProjectNodes(const QList &projectNodes); diff --git a/src/plugins/projectexplorer/projecttree.cpp b/src/plugins/projectexplorer/projecttree.cpp index 52d40cb1c55..3f7e0a1e6f2 100644 --- a/src/plugins/projectexplorer/projecttree.cpp +++ b/src/plugins/projectexplorer/projecttree.cpp @@ -162,7 +162,7 @@ Project *ProjectTree::projectForNode(Node *node) if (!node) return 0; - FolderNode *rootProjectNode = dynamic_cast(node); + FolderNode *rootProjectNode = node->asFolderNode(); if (!rootProjectNode) rootProjectNode = node->parentFolderNode(); @@ -310,7 +310,7 @@ void ProjectTree::emitFoldersAboutToBeRemoved(FolderNode *parentFolder, const QL Node *n = ProjectTree::currentNode(); while (n) { - if (FolderNode *fn = dynamic_cast(n)) { + if (FolderNode *fn = n->asFolderNode()) { if (staleFolders.contains(fn)) { ProjectNode *pn = n->projectNode(); // Make sure the node we are switching too isn't going to be removed also @@ -363,9 +363,10 @@ void ProjectTree::emitFilesAboutToBeRemoved(FolderNode *folder, const QList(m_currentNode)) - if (staleFiles.contains(fileNode)) - m_resetCurrentNodeFile = true; + if (m_currentNode) + if (FileNode *fileNode = m_currentNode->asFileNode()) + if (staleFiles.contains(fileNode)) + m_resetCurrentNodeFile = true; emit filesAboutToBeRemoved(folder, staleFiles); } diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 7fda8969c46..0d4b91048a4 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -490,7 +490,7 @@ QStringList SessionManagerPrivate::dependenciesOrder() const // copy the map to a temporary list foreach (Project *pro, m_projects) { - const QString &proName = pro->projectFilePath().toString(); + const QString proName = pro->projectFilePath().toString(); unordered << QPair(proName, m_depMap.value(proName)); } @@ -563,7 +563,7 @@ Project *SessionManager::projectForNode(Node *node) if (!node) return 0; - FolderNode *rootProjectNode = dynamic_cast(node); + FolderNode *rootProjectNode = node->asFolderNode(); if (!rootProjectNode) rootProjectNode = node->parentFolderNode(); diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp index 8f7d32684c7..b9a2f234d01 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp @@ -96,7 +96,6 @@ bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString * Q_UNUSED(errorMessage); const Core::Context projectContext(::QbsProjectManager::Constants::PROJECT_ID); - const Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "qbs"); @@ -146,7 +145,7 @@ bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString * m_buildFile = new Utils::ParameterAction(tr("Build File"), tr("Build File \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - command = Core::ActionManager::registerAction(m_buildFile, Constants::ACTION_BUILD_FILE, globalcontext); + command = Core::ActionManager::registerAction(m_buildFile, Constants::ACTION_BUILD_FILE); command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_UpdateText); command->setDescription(m_buildFile->text()); @@ -162,7 +161,7 @@ bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString * m_buildProduct = new Utils::ParameterAction(tr("Build Product"), tr("Build Product \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - command = Core::ActionManager::registerAction(m_buildProduct, Constants::ACTION_BUILD_PRODUCT, globalcontext); + command = Core::ActionManager::registerAction(m_buildProduct, Constants::ACTION_BUILD_PRODUCT); command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_UpdateText); command->setDescription(m_buildFile->text()); @@ -178,7 +177,7 @@ bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString * m_buildSubproject = new Utils::ParameterAction(tr("Build Subproject"), tr("Build Subproject \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - command = Core::ActionManager::registerAction(m_buildSubproject, Constants::ACTION_BUILD_SUBPROJECT, globalcontext); + command = Core::ActionManager::registerAction(m_buildSubproject, Constants::ACTION_BUILD_SUBPROJECT); command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_UpdateText); command->setDescription(m_buildFile->text()); diff --git a/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp b/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp index 09790d4d299..fd8761b47e8 100644 --- a/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp +++ b/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp @@ -753,7 +753,7 @@ void NonInternalLibraryDetailsController::slotLibraryPathChanged() if (parentFolderName != QLatin1String("debug") && parentFolderName != QLatin1String("release")) subfoldersEnabled = false; - const QString baseName = fi.baseName(); + const QString baseName = fi.completeBaseName(); if (baseName.isEmpty() || baseName.at(baseName.size() - 1).toLower() != QLatin1Char('d')) removeSuffixEnabled = false; @@ -786,18 +786,18 @@ QString NonInternalLibraryDetailsController::snippet() const const bool removeSuffix = isWindowsGroupVisible() && libraryDetailsWidget()->removeSuffixCheckBox->isChecked(); if (creatorPlatform() == CreatorWindows) { - libName = fi.baseName(); + libName = fi.completeBaseName(); if (removeSuffix && !libName.isEmpty()) // remove last letter which needs to be "d" libName = libName.left(libName.size() - 1); if (fi.completeSuffix() == QLatin1String("a")) // the mingw lib case libName = libName.mid(3); // cut the "lib" prefix } else if (creatorPlatform() == CreatorMac) { if (macLibraryType() == AddLibraryWizard::FrameworkType) - libName = fi.baseName(); + libName = fi.completeBaseName(); else - libName = fi.baseName().mid(3); // cut the "lib" prefix + libName = fi.completeBaseName().mid(3); // cut the "lib" prefix } else { - libName = fi.baseName().mid(3); // cut the "lib" prefix + libName = fi.completeBaseName().mid(3); // cut the "lib" prefix } QString targetRelativePath; @@ -946,7 +946,7 @@ void ExternalLibraryDetailsController::updateWindowsOptionsEnablement() if (parentFolderName != QLatin1String("debug") && parentFolderName != QLatin1String("release")) subfoldersEnabled = false; - const QString baseName = fi.baseName(); + const QString baseName = fi.completeBaseName(); if (baseName.isEmpty() || baseName.at(baseName.size() - 1).toLower() != QLatin1Char('d')) removeSuffixEnabled = false; diff --git a/src/plugins/qmakeprojectmanager/profilecompletionassist.cpp b/src/plugins/qmakeprojectmanager/profilecompletionassist.cpp index 1466291c579..2ad37aee7f7 100644 --- a/src/plugins/qmakeprojectmanager/profilecompletionassist.cpp +++ b/src/plugins/qmakeprojectmanager/profilecompletionassist.cpp @@ -33,6 +33,8 @@ #include +#include + using namespace QmakeProjectManager::Internal; using namespace TextEditor; diff --git a/src/plugins/qmakeprojectmanager/profileeditor.cpp b/src/plugins/qmakeprojectmanager/profileeditor.cpp index f83994aeaad..66d92e17916 100644 --- a/src/plugins/qmakeprojectmanager/profileeditor.cpp +++ b/src/plugins/qmakeprojectmanager/profileeditor.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp index a043805bb26..874f3b9bcc7 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp @@ -932,7 +932,7 @@ QList QmakePriFileNode::supportedActions(Node *node) const bool addExistingFiles = true; if (node->nodeType() == VirtualFolderNodeType) { // A virtual folder, we do what the projectexplorer does - FolderNode *folder = dynamic_cast(node); + FolderNode *folder = node->asFolderNode(); if (folder) { QStringList list; foreach (FolderNode *f, folder->subFolderNodes()) @@ -956,7 +956,7 @@ QList QmakePriFileNode::supportedActions(Node *node) const break; } - FileNode *fileNode = dynamic_cast(node); + FileNode *fileNode = node->asFileNode(); if ((fileNode && fileNode->fileType() != ProjectFileType) || dynamic_cast(node)) actions << Rename; diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp index c145a00d6df..d7f762e10b2 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp @@ -41,6 +41,7 @@ #include "wizards/qtquickapp.h" #include +#include #include #include #include @@ -232,7 +233,8 @@ void QmakeManager::buildFile() { if (Core::IDocument *currentDocument= Core::EditorManager::currentDocument()) { const Utils::FileName file = currentDocument->filePath(); - FileNode *node = dynamic_cast(SessionManager::nodeForFile(file)); + Node *n = SessionManager::nodeForFile(file); + FileNode *node = n ? n->asFileNode() : 0; Project *project = SessionManager::projectForFile(file); if (project && node) diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp index e5fa4d23639..de5d9168134 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp @@ -218,10 +218,9 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_CLEAN); connect(m_cleanSubProjectAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(cleanSubDirContextMenu())); - const Core::Context globalcontext(Core::Constants::C_GLOBAL); m_buildFileAction = new Utils::ParameterAction(tr("Build File"), tr("Build File \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - command = Core::ActionManager::registerAction(m_buildFileAction, Constants::BUILDFILE, globalcontext); + command = Core::ActionManager::registerAction(m_buildFileAction, Constants::BUILDFILE); command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_UpdateText); command->setDescription(m_buildFileAction->text()); @@ -329,7 +328,7 @@ void QmakeProjectManagerPlugin::updateContextActions(ProjectExplorer::Node *node if (QmakePriFileNode *subPriFileNode = dynamic_cast(node->projectNode())) subProjectNode = subPriFileNode->proFileNode(); } - ProjectExplorer::FileNode *fileNode = dynamic_cast(node); + ProjectExplorer::FileNode *fileNode = node ? node->asFileNode() : 0; bool buildFilePossible = subProjectNode && fileNode && (fileNode->fileType() == ProjectExplorer::SourceType); diff --git a/src/plugins/qmakeprojectmanager/qmakestep.cpp b/src/plugins/qmakeprojectmanager/qmakestep.cpp index 17b28225caf..6e190e2992b 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakestep.cpp @@ -67,6 +67,7 @@ const char QMAKE_BS_ID[] = "QtProjectManager.QMakeBuildStep"; const char QMAKE_ARGUMENTS_KEY[] = "QtProjectManager.QMakeBuildStep.QMakeArguments"; const char QMAKE_FORCED_KEY[] = "QtProjectManager.QMakeBuildStep.QMakeForced"; const char QMAKE_USE_QTQUICKCOMPILER[] = "QtProjectManager.QMakeBuildStep.UseQtQuickCompiler"; +const char QMAKE_SEPARATEDEBUGINFO_KEY[] = "QtProjectManager.QMakeBuildStep.SeparateDebugInfo"; const char QMAKE_QMLDEBUGLIBAUTO_KEY[] = "QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto"; const char QMAKE_QMLDEBUGLIB_KEY[] = "QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary"; } @@ -76,7 +77,8 @@ QMakeStep::QMakeStep(BuildStepList *bsl) : m_forced(false), m_needToRunQMake(false), m_linkQmlDebuggingLibrary(DebugLink), - m_useQtQuickCompiler(false) + m_useQtQuickCompiler(false), + m_separateDebugInfo(false) { ctor(); } @@ -85,7 +87,8 @@ QMakeStep::QMakeStep(BuildStepList *bsl, Core::Id id) : AbstractProcessStep(bsl, id), m_forced(false), m_linkQmlDebuggingLibrary(DebugLink), - m_useQtQuickCompiler(false) + m_useQtQuickCompiler(false), + m_separateDebugInfo(false) { ctor(); } @@ -95,7 +98,8 @@ QMakeStep::QMakeStep(BuildStepList *bsl, QMakeStep *bs) : m_forced(bs->m_forced), m_userArgs(bs->m_userArgs), m_linkQmlDebuggingLibrary(bs->m_linkQmlDebuggingLibrary), - m_useQtQuickCompiler(bs->m_useQtQuickCompiler) + m_useQtQuickCompiler(bs->m_useQtQuickCompiler), + m_separateDebugInfo(bs->m_separateDebugInfo) { ctor(); } @@ -178,7 +182,7 @@ QStringList QMakeStep::deducedArguments() QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); arguments << QmakeBuildConfiguration::deduceArgumentsForTargetAbi(targetAbi, version); - if (linkQmlDebuggingLibrary() && version && !useQtQuickCompiler()) { + if (linkQmlDebuggingLibrary() && version) { arguments << QLatin1String(Constants::QMAKEVAR_QUICK1_DEBUG); if (version->qtVersion().majorVersion >= 5) arguments << QLatin1String(Constants::QMAKEVAR_QUICK2_DEBUG); @@ -187,6 +191,11 @@ QStringList QMakeStep::deducedArguments() if (useQtQuickCompiler() && version) arguments << QLatin1String("CONFIG+=qtquickcompiler"); + if (separateDebugInfo()) { + arguments << QLatin1String("CONFIG+=force_debug_info") + << QLatin1String("CONFIG+=separate_debug_info"); + } + return arguments; } @@ -393,6 +402,23 @@ void QMakeStep::setUseQtQuickCompiler(bool enable) qmakeBuildConfiguration()->emitProFileEvaluateNeeded(); } +bool QMakeStep::separateDebugInfo() const +{ + return m_separateDebugInfo; +} + +void QMakeStep::setSeparateDebugInfo(bool enable) +{ + if (enable == m_separateDebugInfo) + return; + m_separateDebugInfo = enable; + + emit separateDebugInfoChanged(); + + qmakeBuildConfiguration()->emitQMakeBuildConfigurationChanged(); + qmakeBuildConfiguration()->emitProFileEvaluateNeeded(); +} + QStringList QMakeStep::parserArguments() { QStringList result; @@ -428,6 +454,7 @@ QVariantMap QMakeStep::toMap() const map.insert(QLatin1String(QMAKE_QMLDEBUGLIB_KEY), m_linkQmlDebuggingLibrary == DoLink); map.insert(QLatin1String(QMAKE_FORCED_KEY), m_forced); map.insert(QLatin1String(QMAKE_USE_QTQUICKCOMPILER), m_useQtQuickCompiler); + map.insert(QLatin1String(QMAKE_SEPARATEDEBUGINFO_KEY), m_separateDebugInfo); return map; } @@ -444,6 +471,7 @@ bool QMakeStep::fromMap(const QVariantMap &map) else m_linkQmlDebuggingLibrary = DoNotLink; } + m_separateDebugInfo = map.value(QLatin1String(QMAKE_SEPARATEDEBUGINFO_KEY), false).toBool(); return BuildStep::fromMap(map); } @@ -461,6 +489,7 @@ QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step) m_ui->qmakeAdditonalArgumentsLineEdit->setText(m_step->userArguments()); m_ui->qmlDebuggingLibraryCheckBox->setChecked(m_step->linkQmlDebuggingLibrary()); m_ui->qtQuickCompilerCheckBox->setChecked(m_step->useQtQuickCompiler()); + m_ui->separateDebugInfoCheckBox->setChecked(m_step->separateDebugInfo()); qmakeBuildConfigChanged(); @@ -481,6 +510,10 @@ QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step) this, &QMakeStepConfigWidget::useQtQuickCompilerChecked); connect(m_ui->qtQuickCompilerCheckBox, &QCheckBox::clicked, this, &QMakeStepConfigWidget::askForRebuild); + connect(m_ui->separateDebugInfoCheckBox, &QAbstractButton::toggled, + this, &QMakeStepConfigWidget::separateDebugInfoChecked); + connect(m_ui->separateDebugInfoCheckBox, &QCheckBox::clicked, + this, &QMakeStepConfigWidget::askForRebuild); connect(step, SIGNAL(userArgumentsChanged()), this, SLOT(userArgumentsChanged())); connect(step, SIGNAL(linkQmlDebuggingLibraryChanged()), @@ -489,6 +522,8 @@ QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step) this, &QMakeStepConfigWidget::linkQmlDebuggingLibraryChanged); connect(step, &QMakeStep::useQtQuickCompilerChanged, this, &QMakeStepConfigWidget::useQtQuickCompilerChanged); + connect(step, &QMakeStep::separateDebugInfoChanged, + this, &QMakeStepConfigWidget::separateDebugInfoChanged); connect(step->qmakeBuildConfiguration(), SIGNAL(qmakeBuildConfigurationChanged()), this, SLOT(qmakeBuildConfigChanged())); connect(step->target(), SIGNAL(kitChanged()), this, SLOT(qtVersionChanged())); @@ -566,6 +601,15 @@ void QMakeStepConfigWidget::useQtQuickCompilerChanged() updateQmlDebuggingOption(); } +void QMakeStepConfigWidget::separateDebugInfoChanged() +{ + if (m_ignoreChange) + return; + + updateSummaryLabel(); + updateEffectiveQMakeCall(); +} + void QMakeStepConfigWidget::qmakeArgumentsLineEdited() { m_ignoreChange = true; @@ -635,6 +679,19 @@ void QMakeStepConfigWidget::useQtQuickCompilerChecked(bool checked) updateQtQuickCompilerOption(); } +void QMakeStepConfigWidget::separateDebugInfoChecked(bool checked) +{ + if (m_ignoreChange) + return; + + m_ignoreChange = true; + m_step->setSeparateDebugInfo(checked); + m_ignoreChange = false; + + updateSummaryLabel(); + updateEffectiveQMakeCall(); +} + void QMakeStepConfigWidget::updateSummaryLabel() { QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(m_step->target()->kit()); diff --git a/src/plugins/qmakeprojectmanager/qmakestep.h b/src/plugins/qmakeprojectmanager/qmakestep.h index e0c8d741f1d..25109a89a5f 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.h +++ b/src/plugins/qmakeprojectmanager/qmakestep.h @@ -114,6 +114,8 @@ public: void setLinkQmlDebuggingLibrary(bool enable); bool useQtQuickCompiler() const; void setUseQtQuickCompiler(bool enable); + bool separateDebugInfo() const; + void setSeparateDebugInfo(bool enable); QVariantMap toMap() const; @@ -121,6 +123,7 @@ signals: void userArgumentsChanged(); void linkQmlDebuggingLibraryChanged(); void useQtQuickCompilerChanged(); + void separateDebugInfoChanged(); protected: QMakeStep(ProjectExplorer::BuildStepList *parent, QMakeStep *source); @@ -140,6 +143,7 @@ private: QmlLibraryLink m_linkQmlDebuggingLibrary; bool m_useQtQuickCompiler; bool m_scriptTemplate; + bool m_separateDebugInfo; }; @@ -159,12 +163,14 @@ private slots: void userArgumentsChanged(); void linkQmlDebuggingLibraryChanged(); void useQtQuickCompilerChanged(); + void separateDebugInfoChanged(); // slots for dealing with user changes in our UI void qmakeArgumentsLineEdited(); void buildConfigurationSelected(); void linkQmlDebuggingLibraryChecked(bool checked); void useQtQuickCompilerChecked(bool checked); + void separateDebugInfoChecked(bool checked); void askForRebuild(); private slots: diff --git a/src/plugins/qmakeprojectmanager/qmakestep.ui b/src/plugins/qmakeprojectmanager/qmakestep.ui index aa659aa0664..7165a81b0b8 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.ui +++ b/src/plugins/qmakeprojectmanager/qmakestep.ui @@ -7,7 +7,7 @@ 0 0 440 - 201 + 250 @@ -27,7 +27,7 @@ 0 - + qmake build configuration: @@ -35,7 +35,7 @@ - + 0 @@ -95,15 +95,60 @@ + + + Generate separate debug info: + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Link QML debugging library: - - - + + + 0 @@ -138,7 +183,7 @@ - + Qt::Horizontal @@ -153,15 +198,15 @@ - + Use QML compiler: - - + + 0 @@ -197,7 +242,7 @@ - + Qt::Horizontal @@ -212,7 +257,7 @@ - + Effective qmake call: @@ -222,7 +267,7 @@ - + true diff --git a/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp b/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp index 694debe5cba..a05265d98a9 100644 --- a/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp @@ -297,14 +297,15 @@ void LibraryWizardDialog::setupFilesPage() } m_filesPage->setBaseClassInputVisible(true); break; - default: { - // Urrm, figure out a good class name. Use project name this time - QString className = projectName(); - if (!className.isEmpty()) - className[0] = className.at(0).toUpper(); - m_filesPage->setClassName(className); - m_filesPage->setBaseClassInputVisible(false); - } + default: + if (!m_filesPage->isComplete()) { + // Urrm, figure out a good class name. Use project name this time + QString className = projectName(); + if (!className.isEmpty()) + className[0] = className.at(0).toUpper(); + m_filesPage->setClassName(className); + m_filesPage->setBaseClassInputVisible(false); + } break; } } diff --git a/src/plugins/qmldesigner/components/componentcore/crumblebar.cpp b/src/plugins/qmldesigner/components/componentcore/crumblebar.cpp index 1e346a2a47c..d4fcfedb993 100644 --- a/src/plugins/qmldesigner/components/componentcore/crumblebar.cpp +++ b/src/plugins/qmldesigner/components/componentcore/crumblebar.cpp @@ -35,6 +35,8 @@ #include #include +#include +#include #include #include diff --git a/src/plugins/qmldesigner/components/integration/designdocument.cpp b/src/plugins/qmldesigner/components/integration/designdocument.cpp index 73e0942e23a..9b02dd94ed4 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocument.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlwarningdialog.cpp b/src/plugins/qmldesigner/designercore/filemanager/qmlwarningdialog.cpp index 47538502961..654f9e075b4 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/qmlwarningdialog.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/qmlwarningdialog.cpp @@ -33,6 +33,8 @@ #include +#include + #include namespace QmlDesigner { diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp index b93f898ee87..88d96cd40f8 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp @@ -79,6 +79,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp index 0c3cb658ea2..36b00dcaeb6 100644 --- a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp +++ b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp @@ -346,10 +346,14 @@ QProcessEnvironment PuppetCreator::processEnvironment() const environment.set("QML_BAD_GUI_RENDER_LOOP", "true"); environment.set("QML_USE_MOCKUPS", "true"); environment.set("QML_PUPPET_MODE", "true"); - if (m_puppetVersion == Qml1Puppet) - environment.appendOrSet("QML_IMPORT_PATH", m_model->importPaths().join(pathSep), pathSep); - else - environment.appendOrSet("QML2_IMPORT_PATH", m_model->importPaths().join(pathSep), pathSep); + + if (m_availablePuppetType != FallbackPuppet) { + if (m_puppetVersion == Qml1Puppet) + environment.appendOrSet("QML_IMPORT_PATH", m_model->importPaths().join(pathSep), pathSep); + else + environment.appendOrSet("QML2_IMPORT_PATH", m_model->importPaths().join(pathSep), pathSep); + } + return environment.toProcessEnvironment(); } diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp index ef73428d7c3..3efb840e71f 100644 --- a/src/plugins/qmldesigner/designmodewidget.cpp +++ b/src/plugins/qmldesigner/designmodewidget.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp index e005475c0a0..85c355fc03c 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -43,7 +43,9 @@ #include #include #include +#include #include +#include #include #include #include diff --git a/src/plugins/qmldesigner/qmldesignerplugin.h b/src/plugins/qmldesigner/qmldesignerplugin.h index ab8cfb79e34..23f159c14d7 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.h +++ b/src/plugins/qmldesigner/qmldesignerplugin.h @@ -54,6 +54,7 @@ namespace Core { class IEditor; class DesignMode; class EditorManager; + class IMode; } namespace QmlDesigner { diff --git a/src/plugins/qmldesigner/shortcutmanager.cpp b/src/plugins/qmldesigner/shortcutmanager.cpp index baf5252c4eb..5f8ccfcf8f1 100644 --- a/src/plugins/qmldesigner/shortcutmanager.cpp +++ b/src/plugins/qmldesigner/shortcutmanager.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index ed460e4445b..557935896b2 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -126,8 +126,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e ActionContainer *contextMenu = ActionManager::createMenu(Constants::M_CONTEXT); ActionContainer *qmlToolsMenu = ActionManager::actionContainer(Id(QmlJSTools::Constants::M_TOOLS_QMLJS)); - Context globalContext(Core::Constants::C_GLOBAL); - qmlToolsMenu->addSeparator(globalContext); + qmlToolsMenu->addSeparator(); Command *cmd; cmd = ActionManager::command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR); @@ -149,7 +148,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e qmlToolsMenu->addAction(cmd); QAction *semanticScan = new QAction(tr("Run Checks"), this); - cmd = ActionManager::registerAction(semanticScan, Id(Constants::RUN_SEMANTIC_SCAN), globalContext); + cmd = ActionManager::registerAction(semanticScan, Id(Constants::RUN_SEMANTIC_SCAN)); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+C"))); connect(semanticScan, SIGNAL(triggered()), this, SLOT(runSemanticScan())); qmlToolsMenu->addAction(cmd); @@ -168,9 +167,9 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e qmlToolsMenu->addAction(cmd); // Insert marker for "Refactoring" menu: - Command *sep = contextMenu->addSeparator(globalContext); + Command *sep = contextMenu->addSeparator(); sep->action()->setObjectName(QLatin1String(Constants::M_REFACTORING_MENU_INSERTION_POINT)); - contextMenu->addSeparator(globalContext); + contextMenu->addSeparator(); cmd = ActionManager::command(TextEditor::Constants::AUTO_INDENT_SELECTION); contextMenu->addAction(cmd); diff --git a/src/plugins/qmljseditor/quicktoolbar.cpp b/src/plugins/qmljseditor/quicktoolbar.cpp index 00af014ef13..36c6d8bdd82 100644 --- a/src/plugins/qmljseditor/quicktoolbar.cpp +++ b/src/plugins/qmljseditor/quicktoolbar.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index fb8721fe217..b4ef92c6bef 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -34,6 +34,7 @@ #include "qmljsbundleprovider.h" #include +#include #include #include #include @@ -65,34 +66,34 @@ #include #include +using namespace Utils; using namespace Core; +using namespace ProjectExplorer; using namespace QmlJS; -using namespace QmlJSTools; -using namespace QmlJSTools::Internal; +namespace QmlJSTools { +namespace Internal { ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject( - ProjectExplorer::Project *project) const + Project *project) const { ModelManagerInterface::ProjectInfo projectInfo(project); - ProjectExplorer::Target *activeTarget = 0; + Target *activeTarget = 0; if (project) { - Utils::MimeDatabase mdb; - QList qmlTypes; - foreach (const Utils::MimeType &mimeType, mdb.allMimeTypes()) { - if (mimeType.matchesName(QLatin1String(Constants::QML_MIMETYPE)) - || mimeType.allAncestors().contains(QLatin1String(Constants::QML_MIMETYPE))) - qmlTypes.append(mimeType); - } - foreach (const QString &filePath, - project->files(ProjectExplorer::Project::ExcludeGeneratedFiles)) { - if (mdb.bestMatch(filePath, qmlTypes).isValid()) + MimeDatabase mdb; + QSet qmlTypeNames; + qmlTypeNames << QLatin1String(Constants::QML_MIMETYPE) + << QLatin1String(Constants::QBS_MIMETYPE) + << QLatin1String(Constants::QMLPROJECT_MIMETYPE) + << QLatin1String(Constants::QMLTYPES_MIMETYPE) + << QLatin1String(Constants::QMLUI_MIMETYPE); + foreach (const QString &filePath, project->files(Project::ExcludeGeneratedFiles)) { + if (qmlTypeNames.contains(mdb.mimeTypeForFile(filePath).name())) projectInfo.sourceFiles << filePath; } activeTarget = project->activeTarget(); } - ProjectExplorer::Kit *activeKit = activeTarget ? activeTarget->kit() : - ProjectExplorer::KitManager::defaultKit(); + Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit(); QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(activeKit); bool preferDebugDump = false; @@ -100,8 +101,8 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject( projectInfo.tryQmlDump = false; if (activeTarget) { - if (ProjectExplorer::BuildConfiguration *bc = activeTarget->activeBuildConfiguration()) { - preferDebugDump = bc->buildType() == ProjectExplorer::BuildConfiguration::Debug; + if (BuildConfiguration *bc = activeTarget->activeBuildConfiguration()) { + preferDebugDump = bc->buildType() == BuildConfiguration::Debug; setPreferDump = true; } } @@ -121,8 +122,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject( } if (projectInfo.tryQmlDump) { - ProjectExplorer::ToolChain *toolChain = - ProjectExplorer::ToolChainKitInformation::toolChain(activeKit); + ToolChain *toolChain = ToolChainKitInformation::toolChain(activeKit); QtSupport::QmlDumpTool::pathAndEnvironment(project, qtVersion, toolChain, preferDebugDump, &projectInfo.qmlDumpPath, @@ -137,13 +137,14 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject( return projectInfo; } -void QmlJSTools::setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &projectInfo) +} // namespace Internal + +void setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &projectInfo) { - ProjectExplorer::Target *activeTarget = 0; + Target *activeTarget = 0; if (projectInfo.project) activeTarget = projectInfo.project->activeTarget(); - ProjectExplorer::Kit *activeKit = activeTarget - ? activeTarget->kit() : ProjectExplorer::KitManager::defaultKit(); + Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit(); QHash replacements; replacements.insert(QLatin1String("$(QT_INSTALL_IMPORTS)"), projectInfo.qtImportsPath); replacements.insert(QLatin1String("$(QT_INSTALL_QML)"), projectInfo.qtQmlPath); @@ -158,12 +159,12 @@ void QmlJSTools::setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo & projectInfo.extendedBundle = projectInfo.activeBundle; if (projectInfo.project) { - QSet currentKits; - foreach (const ProjectExplorer::Target *t, projectInfo.project->targets()) + QSet currentKits; + foreach (const Target *t, projectInfo.project->targets()) if (t->kit()) currentKits.insert(t->kit()); currentKits.remove(activeKit); - foreach (ProjectExplorer::Kit *kit, currentKits) { + foreach (Kit *kit, currentKits) { foreach (IBundleProvider *bp, bundleProviders) if (bp) bp->mergeBundlesForKit(kit, projectInfo.extendedBundle, replacements); @@ -171,28 +172,30 @@ void QmlJSTools::setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo & } } +namespace Internal { + QHash ModelManager::languageForSuffix() const { QHash res = ModelManagerInterface::languageForSuffix(); if (ICore::instance()) { - Utils::MimeDatabase mdb; - Utils::MimeType jsSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::JS_MIMETYPE)); + MimeDatabase mdb; + MimeType jsSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::JS_MIMETYPE)); foreach (const QString &suffix, jsSourceTy.suffixes()) res[suffix] = Dialect::JavaScript; - Utils::MimeType qmlSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QML_MIMETYPE)); + MimeType qmlSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QML_MIMETYPE)); foreach (const QString &suffix, qmlSourceTy.suffixes()) res[suffix] = Dialect::Qml; - Utils::MimeType qbsSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QBS_MIMETYPE)); + MimeType qbsSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QBS_MIMETYPE)); foreach (const QString &suffix, qbsSourceTy.suffixes()) res[suffix] = Dialect::QmlQbs; - Utils::MimeType qmlProjectSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QMLPROJECT_MIMETYPE)); + MimeType qmlProjectSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QMLPROJECT_MIMETYPE)); foreach (const QString &suffix, qmlProjectSourceTy.suffixes()) res[suffix] = Dialect::QmlProject; - Utils::MimeType qmlUiSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QMLUI_MIMETYPE)); + MimeType qmlUiSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::QMLUI_MIMETYPE)); foreach (const QString &suffix, qmlUiSourceTy.suffixes()) res[suffix] = Dialect::QmlQtQuick2Ui; - Utils::MimeType jsonSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::JSON_MIMETYPE)); + MimeType jsonSourceTy = mdb.mimeTypeForName(QLatin1String(Constants::JSON_MIMETYPE)); foreach (const QString &suffix, jsonSourceTy.suffixes()) res[suffix] = Dialect::Json; } @@ -218,9 +221,9 @@ void ModelManager::delayedInitialization() connect(cppModelManager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)), this, SLOT(maybeQueueCppQmlTypeUpdate(CPlusPlus::Document::Ptr)), Qt::DirectConnection); - connect(ProjectExplorer::SessionManager::instance(), &ProjectExplorer::SessionManager::projectRemoved, + connect(SessionManager::instance(), &SessionManager::projectRemoved, this, &ModelManager::removeProjectInfo); - connect(ProjectExplorer::SessionManager::instance(), &ProjectExplorer::SessionManager::startupProjectChanged, + connect(SessionManager::instance(), &SessionManager::startupProjectChanged, this, &ModelManager::updateDefaultProjectInfo); ViewerContext qbsVContext; @@ -260,7 +263,7 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopyInternal() const void ModelManager::updateDefaultProjectInfo() { // needs to be performed in the ui thread - ProjectExplorer::Project *currentProject = ProjectExplorer::SessionManager::startupProject(); + Project *currentProject = SessionManager::startupProject(); ProjectInfo newDefaultProjectInfo = projectInfo(currentProject, defaultProjectInfoForProject(currentProject)); setDefaultProject(projectInfo(currentProject,newDefaultProjectInfo), currentProject); @@ -271,3 +274,6 @@ void ModelManager::addTaskInternal(QFuture result, const QString &msg, con { ProgressManager::addTask(result, msg, taskId); } + +} // namespace Internal +} // namespace QmlJSTools diff --git a/src/plugins/qmljstools/qmljstoolsplugin.cpp b/src/plugins/qmljstools/qmljstoolsplugin.cpp index 113aa2bce4b..43bdbca48de 100644 --- a/src/plugins/qmljstools/qmljstoolsplugin.cpp +++ b/src/plugins/qmljstools/qmljstoolsplugin.cpp @@ -105,9 +105,8 @@ bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error) // Update context in global context m_resetCodeModelAction = new QAction(tr("Reset Code Model"), this); - Context globalContext(Core::Constants::C_GLOBAL); Command *cmd = ActionManager::registerAction( - m_resetCodeModelAction, Constants::RESET_CODEMODEL, globalContext); + m_resetCodeModelAction, Constants::RESET_CODEMODEL); connect(m_resetCodeModelAction, &QAction::triggered, m_modelManager, &ModelManager::resetCodeModel); mqmljstools->addAction(cmd); diff --git a/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp b/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp index 7789a778149..4fe735257ae 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerstatewidget.cpp @@ -264,13 +264,14 @@ void QmlProfilerStateWidget::profilerStateChanged() if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppStarting) d->appKilled = false; - d->isRecording = d->m_profilerState->serverRecording(); - if (d->isRecording) + if (d->m_profilerState->serverRecording()) { d->profilingTimer.start(); - else { + d->isRecording = true; + } else if (d->isRecording) { // estimated time in ns d->estimatedProfilingTime = d->profilingTimer.elapsed() * 1e6; emit newTimeEstimation(d->estimatedProfilingTime); + d->isRecording = false; } updateDisplay(); } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index cf14fd9af76..3f85f2df3e4 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -157,7 +157,6 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent) d->m_profilerConnections->setModelManager(d->m_profilerModelManager); Command *command = 0; - const Context globalContext(C_GLOBAL); ActionContainer *menu = ActionManager::actionContainer(M_DEBUG_ANALYZER); ActionContainer *options = ActionManager::createMenu(M_DEBUG_ANALYZER_QML_OPTIONS); @@ -166,13 +165,13 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent) options->menu()->setEnabled(true); QAction *act = d->m_loadQmlTrace = new QAction(tr("Load QML Trace"), options); - command = ActionManager::registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.LoadQMLTrace", globalContext); + command = ActionManager::registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.LoadQMLTrace"); connect(act, SIGNAL(triggered()), this, SLOT(showLoadDialog())); options->addAction(command); act = d->m_saveQmlTrace = new QAction(tr("Save QML Trace"), options); d->m_saveQmlTrace->setEnabled(false); - command = ActionManager::registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.SaveQMLTrace", globalContext); + command = ActionManager::registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.SaveQMLTrace"); connect(act, SIGNAL(triggered()), this, SLOT(showSaveDialog())); options->addAction(command); diff --git a/src/plugins/qnx/bardescriptoreditor.cpp b/src/plugins/qnx/bardescriptoreditor.cpp index 863b529b2bf..5274774d30c 100644 --- a/src/plugins/qnx/bardescriptoreditor.cpp +++ b/src/plugins/qnx/bardescriptoreditor.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/qnx/blackberryapilevelconfiguration.cpp b/src/plugins/qnx/blackberryapilevelconfiguration.cpp index ce8dc79f9b1..d96a66dd6a3 100644 --- a/src/plugins/qnx/blackberryapilevelconfiguration.cpp +++ b/src/plugins/qnx/blackberryapilevelconfiguration.cpp @@ -52,6 +52,7 @@ #include #include +#include #include #include diff --git a/src/plugins/qnx/qnxbaseconfiguration.cpp b/src/plugins/qnx/qnxbaseconfiguration.cpp index 34055d0683a..b0509b73517 100644 --- a/src/plugins/qnx/qnxbaseconfiguration.cpp +++ b/src/plugins/qnx/qnxbaseconfiguration.cpp @@ -37,6 +37,7 @@ #include #include +#include #include diff --git a/src/plugins/qnx/qnxplugin.cpp b/src/plugins/qnx/qnxplugin.cpp index 82055c72ace..8bf083d2ec3 100644 --- a/src/plugins/qnx/qnxplugin.cpp +++ b/src/plugins/qnx/qnxplugin.cpp @@ -148,12 +148,11 @@ void QnxPlugin::extensionsInitialized() m_attachToQnxApplication->setText(tr("Attach to remote QNX application...")); connect(m_attachToQnxApplication, SIGNAL(triggered()), debugSupport, SLOT(showProcessesDialog())); - const Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::ActionContainer *mstart = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_DEBUG_STARTDEBUGGING); mstart->appendGroup(Constants::QNX_DEBUGGING_GROUP); - mstart->addSeparator(globalcontext, Constants::QNX_DEBUGGING_GROUP, &m_debugSeparator); + mstart->addSeparator(Core::Context(Core::Constants::C_GLOBAL), Constants::QNX_DEBUGGING_GROUP, &m_debugSeparator); - Core::Command *cmd = Core::ActionManager::registerAction(m_attachToQnxApplication, "Debugger.AttachToQnxApplication", globalcontext); + Core::Command *cmd = Core::ActionManager::registerAction(m_attachToQnxApplication, "Debugger.AttachToQnxApplication"); mstart->addAction(cmd, Constants::QNX_DEBUGGING_GROUP); connect(KitManager::instance(), SIGNAL(kitsChanged()), this, SLOT(updateDebuggerActions())); diff --git a/src/plugins/qtsupport/qtoutputformatter.cpp b/src/plugins/qtsupport/qtoutputformatter.cpp index 646e99b76cd..dc8e40323d6 100644 --- a/src/plugins/qtsupport/qtoutputformatter.cpp +++ b/src/plugins/qtsupport/qtoutputformatter.cpp @@ -33,73 +33,107 @@ #include #include #include +#include #include #include +#include +#include #include #include using namespace ProjectExplorer; -using namespace QtSupport; using namespace Utils; +namespace QtSupport { + // "file" or "qrc", colon, optional '//', '/' and further characters #define QML_URL_REGEXP \ "(?:file|qrc):(?://)?/.+" +namespace Internal { -QtOutputFormatter::QtOutputFormatter(ProjectExplorer::Project *project) - : OutputFormatter() - , m_qmlError(QLatin1String("^(" QML_URL_REGEXP // url - ":\\d+" // colon, line - "(?::\\d+)?)" // colon, column (optional) - "[: \t]")) // colon, space or tab - , m_qtError(QLatin1String("Object::.*in (.*:\\d+)")) - , m_qtAssert(QLatin1String("ASSERT: .* in file (.+, line \\d+)")) - , m_qtAssertX(QLatin1String("ASSERT failure in .*: \".*\", file (.+, line \\d+)")) - , m_qtTestFail(QLatin1String("^ Loc: \\[(.*)\\]")) - , m_project(project) +class QtOutputFormatterPrivate +{ +public: + QtOutputFormatterPrivate(Project *proj) + : qmlError(QLatin1String("^(" QML_URL_REGEXP // url + ":\\d+" // colon, line + "(?::\\d+)?)" // colon, column (optional) + "[: \t]")) // colon, space or tab + , qtError(QLatin1String("Object::.*in (.*:\\d+)")) + , qtAssert(QLatin1String("ASSERT: .* in file (.+, line \\d+)")) + , qtAssertX(QLatin1String("ASSERT failure in .*: \".*\", file (.+, line \\d+)")) + , qtTestFail(QLatin1String("^ Loc: \\[(.*)\\]")) + , project(proj) + { + } + + ~QtOutputFormatterPrivate() + { + } + + QRegExp qmlError; + QRegExp qtError; + QRegExp qtAssert; + QRegExp qtAssertX; + QRegExp qtTestFail; + QPointer project; + QString lastLine; + FileInProjectFinder projectFinder; + QTextCursor cursor; +}; + +} // namespace Internal + +QtOutputFormatter::QtOutputFormatter(Project *project) + : d(new Internal::QtOutputFormatterPrivate(project)) { if (project) { - m_projectFinder.setProjectFiles(project->files(Project::ExcludeGeneratedFiles)); - m_projectFinder.setProjectDirectory(project->projectDirectory().toString()); + d->projectFinder.setProjectFiles(project->files(Project::ExcludeGeneratedFiles)); + d->projectFinder.setProjectDirectory(project->projectDirectory().toString()); connect(project, SIGNAL(fileListChanged()), this, SLOT(updateProjectFileList())); } } +QtOutputFormatter::~QtOutputFormatter() +{ + delete d; +} + LinkResult QtOutputFormatter::matchLine(const QString &line) const { LinkResult lr; lr.start = -1; lr.end = -1; - if (m_qmlError.indexIn(line) != -1) { - lr.href = m_qmlError.cap(1); - lr.start = m_qmlError.pos(1); + if (d->qmlError.indexIn(line) != -1) { + lr.href = d->qmlError.cap(1); + lr.start = d->qmlError.pos(1); lr.end = lr.start + lr.href.length(); - } else if (m_qtError.indexIn(line) != -1) { - lr.href = m_qtError.cap(1); - lr.start = m_qtError.pos(1); + } else if (d->qtError.indexIn(line) != -1) { + lr.href = d->qtError.cap(1); + lr.start = d->qtError.pos(1); lr.end = lr.start + lr.href.length(); - } else if (m_qtAssert.indexIn(line) != -1) { - lr.href = m_qtAssert.cap(1); - lr.start = m_qtAssert.pos(1); + } else if (d->qtAssert.indexIn(line) != -1) { + lr.href = d->qtAssert.cap(1); + lr.start = d->qtAssert.pos(1); lr.end = lr.start + lr.href.length(); - } else if (m_qtAssertX.indexIn(line) != -1) { - lr.href = m_qtAssertX.cap(1); - lr.start = m_qtAssertX.pos(1); + } else if (d->qtAssertX.indexIn(line) != -1) { + lr.href = d->qtAssertX.cap(1); + lr.start = d->qtAssertX.pos(1); lr.end = lr.start + lr.href.length(); - } else if (m_qtTestFail.indexIn(line) != -1) { - lr.href = m_qtTestFail.cap(1); - lr.start = m_qtTestFail.pos(1); + } else if (d->qtTestFail.indexIn(line) != -1) { + lr.href = d->qtTestFail.cap(1); + lr.start = d->qtTestFail.pos(1); lr.end = lr.start + lr.href.length(); } return lr; } -void QtOutputFormatter::appendMessage(const QString &txt, Utils::OutputFormat format) +void QtOutputFormatter::appendMessage(const QString &txt, OutputFormat format) { appendMessage(txt, charFormat(format)); } @@ -113,14 +147,14 @@ void QtOutputFormatter::appendMessagePart(QTextCursor &cursor, const QString &tx for (int start = 0, pos = -1; start < length; start = pos + 1) { pos = txt.indexOf(QLatin1Char('\n'), start); const QString newPart = txt.mid(start, (pos == -1) ? -1 : pos - start + 1); - const QString line = m_lastLine + newPart; + const QString line = d->lastLine + newPart; LinkResult lr = matchLine(line); if (!lr.href.isEmpty()) { // Found something && line continuation cursor.insertText(deferredText, format); deferredText.clear(); - if (!m_lastLine.isEmpty()) + if (!d->lastLine.isEmpty()) clearLastLine(); appendLine(cursor, lr, line, format); } else { @@ -129,28 +163,28 @@ void QtOutputFormatter::appendMessagePart(QTextCursor &cursor, const QString &tx } if (pos == -1) { - m_lastLine = line; + d->lastLine = line; break; } - m_lastLine.clear(); // Handled line continuation + d->lastLine.clear(); // Handled line continuation } cursor.insertText(deferredText, format); } void QtOutputFormatter::appendMessage(const QString &txt, const QTextCharFormat &format) { - QTextCursor cursor(plainTextEdit()->document()); - cursor.movePosition(QTextCursor::End); - cursor.beginEditBlock(); + if (!d->cursor.atEnd()) + d->cursor.movePosition(QTextCursor::End); + d->cursor.beginEditBlock(); foreach (const FormattedText &output, parseAnsi(txt, format)) - appendMessagePart(cursor, output.text, output.format); + appendMessagePart(d->cursor, output.text, output.format); - cursor.endEditBlock(); + d->cursor.endEditBlock(); } void QtOutputFormatter::appendLine(QTextCursor &cursor, const LinkResult &lr, - const QString &line, Utils::OutputFormat format) + const QString &line, OutputFormat format) { appendLine(cursor, lr, line, charFormat(format)); } @@ -186,7 +220,7 @@ void QtOutputFormatter::handleLink(const QString &href) const int line = qmlLineColumnLink.cap(2).toInt(); const int column = qmlLineColumnLink.cap(3).toInt(); - openEditor(m_projectFinder.findFile(fileUrl), line, column - 1); + openEditor(d->projectFinder.findFile(fileUrl), line, column - 1); return; } @@ -197,7 +231,7 @@ void QtOutputFormatter::handleLink(const QString &href) if (qmlLineLink.indexIn(href) != -1) { const QUrl fileUrl = QUrl(qmlLineLink.cap(1)); const int line = qmlLineLink.cap(2).toInt(); - openEditor(m_projectFinder.findFile(m_projectFinder.findFile(fileUrl)), line); + openEditor(d->projectFinder.findFile(d->projectFinder.findFile(fileUrl)), line); return; } @@ -223,17 +257,23 @@ void QtOutputFormatter::handleLink(const QString &href) } if (!fileName.isEmpty()) { - fileName = m_projectFinder.findFile(QUrl::fromLocalFile(fileName)); + fileName = d->projectFinder.findFile(QUrl::fromLocalFile(fileName)); openEditor(fileName, line); return; } } } +void QtOutputFormatter::setPlainTextEdit(QPlainTextEdit *plainText) +{ + OutputFormatter::setPlainTextEdit(plainText); + d->cursor = plainText ? plainText->textCursor() : QTextCursor(); +} + void QtOutputFormatter::clearLastLine() { OutputFormatter::clearLastLine(); - m_lastLine.clear(); + d->lastLine.clear(); } void QtOutputFormatter::openEditor(const QString &fileName, int line, int column) @@ -243,10 +283,12 @@ void QtOutputFormatter::openEditor(const QString &fileName, int line, int column void QtOutputFormatter::updateProjectFileList() { - if (m_project) - m_projectFinder.setProjectFiles(m_project.data()->files(Project::ExcludeGeneratedFiles)); + if (d->project) + d->projectFinder.setProjectFiles(d->project.data()->files(Project::ExcludeGeneratedFiles)); } +} // namespace QtSupport + // Unit tests: #ifdef WITH_TESTS @@ -255,9 +297,11 @@ void QtOutputFormatter::updateProjectFileList() # include "qtsupportplugin.h" -using namespace QtSupport::Internal; +Q_DECLARE_METATYPE(QTextCharFormat) -Q_DECLARE_METATYPE(QTextCharFormat); +namespace QtSupport { + +using namespace QtSupport::Internal; class TestQtOutputFormatter : public QtOutputFormatter { @@ -427,4 +471,6 @@ void QtSupportPlugin::testQtOutputFormatter_appendMixedAssertAndAnsi() QCOMPARE(edit.currentCharFormat(), blueFormat()); } +} // namespace QtSupport + #endif // WITH_TESTS diff --git a/src/plugins/qtsupport/qtoutputformatter.h b/src/plugins/qtsupport/qtoutputformatter.h index 4cdf79be7f0..5adf74f7963 100644 --- a/src/plugins/qtsupport/qtoutputformatter.h +++ b/src/plugins/qtsupport/qtoutputformatter.h @@ -34,10 +34,6 @@ #include "qtsupport_global.h" #include -#include - -#include -#include QT_FORWARD_DECLARE_CLASS(QTextCursor) @@ -53,19 +49,21 @@ struct LinkResult }; namespace Internal { - class QtSupportPlugin; +class QtOutputFormatterPrivate; +class QtSupportPlugin; } -class QTSUPPORT_EXPORT QtOutputFormatter - : public Utils::OutputFormatter +class QTSUPPORT_EXPORT QtOutputFormatter : public Utils::OutputFormatter { Q_OBJECT public: explicit QtOutputFormatter(ProjectExplorer::Project *project); + ~QtOutputFormatter(); void appendMessage(const QString &text, Utils::OutputFormat format); void appendMessage(const QString &text, const QTextCharFormat &format); void handleLink(const QString &href); + void setPlainTextEdit(QPlainTextEdit *plainText); protected: void clearLastLine(); @@ -82,14 +80,7 @@ private: void appendLine(QTextCursor &cursor, const LinkResult &lr, const QString &line, const QTextCharFormat &format); - mutable QRegExp m_qmlError; - mutable QRegExp m_qtError; - mutable QRegExp m_qtAssert; - mutable QRegExp m_qtAssertX; - mutable QRegExp m_qtTestFail; - QPointer m_project; - QString m_lastLine; - Utils::FileInProjectFinder m_projectFinder; + Internal::QtOutputFormatterPrivate *d; // for testing friend class Internal::QtSupportPlugin; diff --git a/src/plugins/qtsupport/qtversionmanager.cpp b/src/plugins/qtsupport/qtversionmanager.cpp index 37881af6c4e..ea1e99851bb 100644 --- a/src/plugins/qtsupport/qtversionmanager.cpp +++ b/src/plugins/qtsupport/qtversionmanager.cpp @@ -351,7 +351,7 @@ void QtVersionManager::updateFromInstaller(bool emitSignal) qDebug() << " Qt version found with same autodetection source" << autoDetectionSource << " => Migrating id:" << id; m_versions.remove(id); qtversionMap[QLatin1String(Constants::QTVERSIONID)] = id; - qtversionMap[QLatin1String(Constants::QTVERSIONNAME)] = v->displayName(); + qtversionMap[QLatin1String(Constants::QTVERSIONNAME)] = v->unexpandedDisplayName(); delete v; if (BaseQtVersion *qtv = factory->restore(type, qtversionMap)) { diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp index d2dcb5fd239..541b8f5dc44 100644 --- a/src/plugins/resourceeditor/resourcenode.cpp +++ b/src/plugins/resourceeditor/resourcenode.cpp @@ -286,7 +286,7 @@ bool ResourceTopLevelNode::showInSimpleTree() const } ResourceFolderNode::ResourceFolderNode(const QString &prefix, const QString &lang, ResourceTopLevelNode *parent) - : ProjectExplorer::FolderNode(parent->path().appendPath(prefix)), + : ProjectExplorer::FolderNode(Utils::FileName(parent->path()).appendPath(prefix)), // TOOD Why add existing directory doesn't work m_topLevelNode(parent), m_prefix(prefix), diff --git a/src/plugins/subversion/subversioncontrol.cpp b/src/plugins/subversion/subversioncontrol.cpp index 928dcb9bcc1..052abac0eb4 100644 --- a/src/plugins/subversion/subversioncontrol.cpp +++ b/src/plugins/subversion/subversioncontrol.cpp @@ -34,6 +34,8 @@ #include +#include + #include namespace Subversion { diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index da2862c2049..5a7ed50758f 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -47,6 +47,8 @@ #include #include +#include + #include #include #include diff --git a/src/plugins/subversion/subversionsubmiteditor.cpp b/src/plugins/subversion/subversionsubmiteditor.cpp index d08e70824d2..9483d720bc6 100644 --- a/src/plugins/subversion/subversionsubmiteditor.cpp +++ b/src/plugins/subversion/subversionsubmiteditor.cpp @@ -39,7 +39,7 @@ using namespace Subversion::Internal; SubversionSubmitEditor::SubversionSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters) : VcsBase::VcsBaseSubmitEditor(parameters, new VcsBase::SubmitEditorWidget) { - document()->setDisplayName(tr("Subversion Submit")); + document()->setPreferredDisplayName(tr("Subversion Submit")); setDescriptionMandatory(false); } diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index 7c13415e46e..9e00297faf5 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -30,6 +30,7 @@ #include "basefilefind.h" #include "basefilefind_p.h" +#include "textdocument.h" #include #include @@ -37,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/texteditor/basehoverhandler.h b/src/plugins/texteditor/basehoverhandler.h index d2a6541e8af..00accf05b7e 100644 --- a/src/plugins/texteditor/basehoverhandler.h +++ b/src/plugins/texteditor/basehoverhandler.h @@ -33,7 +33,8 @@ #include "texteditor_global.h" #include "helpitem.h" -#include + +#include namespace Core { class IEditor; } diff --git a/src/plugins/texteditor/codeassist/codeassistant.cpp b/src/plugins/texteditor/codeassist/codeassistant.cpp index 51b0ab7f880..1dd33bd87ab 100644 --- a/src/plugins/texteditor/codeassist/codeassistant.cpp +++ b/src/plugins/texteditor/codeassist/codeassistant.cpp @@ -32,6 +32,7 @@ #include "completionassistprovider.h" #include "quickfixassistprovider.h" #include "iassistprocessor.h" +#include "textdocument.h" #include "iassistproposal.h" #include "iassistproposalwidget.h" #include "assistinterface.h" diff --git a/src/plugins/texteditor/codeassist/genericproposalmodel.h b/src/plugins/texteditor/codeassist/genericproposalmodel.h index 43cd6494fd2..a147991a524 100644 --- a/src/plugins/texteditor/codeassist/genericproposalmodel.h +++ b/src/plugins/texteditor/codeassist/genericproposalmodel.h @@ -38,9 +38,9 @@ #include -#include #include -#include + +QT_FORWARD_DECLARE_CLASS(QIcon) namespace TextEditor { diff --git a/src/plugins/texteditor/codeassist/iassistprocessor.h b/src/plugins/texteditor/codeassist/iassistprocessor.h index 7d7a7dd7e9b..b9561490666 100644 --- a/src/plugins/texteditor/codeassist/iassistprocessor.h +++ b/src/plugins/texteditor/codeassist/iassistprocessor.h @@ -31,8 +31,6 @@ #ifndef IASSISTPROCESSOR_H #define IASSISTPROCESSOR_H -#include "iassistproposalwidget.h" - #include namespace TextEditor { diff --git a/src/plugins/texteditor/codeassist/iassistproposalmodel.h b/src/plugins/texteditor/codeassist/iassistproposalmodel.h index 4eacabe8537..b881b40cb67 100644 --- a/src/plugins/texteditor/codeassist/iassistproposalmodel.h +++ b/src/plugins/texteditor/codeassist/iassistproposalmodel.h @@ -33,7 +33,7 @@ #include -#include +QT_FORWARD_DECLARE_CLASS(QString) namespace TextEditor { diff --git a/src/plugins/texteditor/codeassist/iassistprovider.h b/src/plugins/texteditor/codeassist/iassistprovider.h index a967a87be44..9ca728789be 100644 --- a/src/plugins/texteditor/codeassist/iassistprovider.h +++ b/src/plugins/texteditor/codeassist/iassistprovider.h @@ -32,10 +32,10 @@ #define IASSISTPROVIDER_H #include -#include #include +namespace Core { class Id; } namespace TextEditor { class IAssistProcessor; diff --git a/src/plugins/texteditor/codestyleeditor.cpp b/src/plugins/texteditor/codestyleeditor.cpp index 08baf759ec5..f4f567c7bf4 100644 --- a/src/plugins/texteditor/codestyleeditor.cpp +++ b/src/plugins/texteditor/codestyleeditor.cpp @@ -30,6 +30,7 @@ #include "codestyleeditor.h" +#include "textdocument.h" #include "icodestylepreferencesfactory.h" #include "icodestylepreferences.h" #include "codestyleselectorwidget.h" diff --git a/src/plugins/texteditor/codestylepool.h b/src/plugins/texteditor/codestylepool.h index 9405877024d..9a20d1d00e7 100644 --- a/src/plugins/texteditor/codestylepool.h +++ b/src/plugins/texteditor/codestylepool.h @@ -33,10 +33,9 @@ #include "texteditor_global.h" -#include - #include +namespace Utils { class FileName; } namespace TextEditor { class ICodeStylePreferences; diff --git a/src/plugins/texteditor/codestyleselectorwidget.cpp b/src/plugins/texteditor/codestyleselectorwidget.cpp index 673bb507b64..6cf09a5ad04 100644 --- a/src/plugins/texteditor/codestyleselectorwidget.cpp +++ b/src/plugins/texteditor/codestyleselectorwidget.cpp @@ -35,6 +35,8 @@ #include "codestylepool.h" #include "tabsettings.h" +#include + #include #include #include diff --git a/src/plugins/texteditor/findincurrentfile.cpp b/src/plugins/texteditor/findincurrentfile.cpp index 6416a8fb2e4..c68b459c0cc 100644 --- a/src/plugins/texteditor/findincurrentfile.cpp +++ b/src/plugins/texteditor/findincurrentfile.cpp @@ -30,6 +30,7 @@ #include "findincurrentfile.h" #include "texteditor.h" +#include "textdocument.h" #include #include diff --git a/src/plugins/texteditor/fontsettingspage.h b/src/plugins/texteditor/fontsettingspage.h index a281436f1de..ee7b7bd7900 100644 --- a/src/plugins/texteditor/fontsettingspage.h +++ b/src/plugins/texteditor/fontsettingspage.h @@ -33,7 +33,8 @@ #include "texteditor_global.h" -#include "fontsettings.h" +#include "texteditorconstants.h" +#include "colorscheme.h" #include "texteditoroptionspage.h" @@ -47,6 +48,8 @@ QT_END_NAMESPACE namespace TextEditor { +class Format; +class FontSettings; namespace Internal { class FontSettingsPagePrivate; } // GUI description of a format consisting of id (settings key) diff --git a/src/plugins/texteditor/icodestylepreferences.h b/src/plugins/texteditor/icodestylepreferences.h index 2388fda8459..6e5d6964a7d 100644 --- a/src/plugins/texteditor/icodestylepreferences.h +++ b/src/plugins/texteditor/icodestylepreferences.h @@ -34,9 +34,9 @@ #include "texteditor_global.h" #include -#include QT_BEGIN_NAMESPACE +class QVariant; class QSettings; QT_END_NAMESPACE diff --git a/src/plugins/texteditor/icodestylepreferencesfactory.h b/src/plugins/texteditor/icodestylepreferencesfactory.h index f3abb383185..b2e6bfd7b83 100644 --- a/src/plugins/texteditor/icodestylepreferencesfactory.h +++ b/src/plugins/texteditor/icodestylepreferencesfactory.h @@ -33,10 +33,9 @@ #include "texteditor_global.h" -#include - #include +namespace Core { class Id; } namespace TextEditor { class ICodeStylePreferences; diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp index 5685e75c881..346b40834c9 100644 --- a/src/plugins/texteditor/refactoringchanges.cpp +++ b/src/plugins/texteditor/refactoringchanges.cpp @@ -30,9 +30,11 @@ #include "refactoringchanges.h" #include "texteditor.h" +#include "textdocument.h" #include #include +#include #include #include diff --git a/src/plugins/texteditor/simplecodestylepreferences.cpp b/src/plugins/texteditor/simplecodestylepreferences.cpp index fa56c4b305e..b19c3c878a5 100644 --- a/src/plugins/texteditor/simplecodestylepreferences.cpp +++ b/src/plugins/texteditor/simplecodestylepreferences.cpp @@ -30,6 +30,8 @@ #include "simplecodestylepreferences.h" +#include + using namespace TextEditor; static const char settingsSuffixKey[] = "TabPreferences"; diff --git a/src/plugins/texteditor/snippets/snippetssettingspage.cpp b/src/plugins/texteditor/snippets/snippetssettingspage.cpp index 45a7afc1871..44bbc6353ab 100644 --- a/src/plugins/texteditor/snippets/snippetssettingspage.cpp +++ b/src/plugins/texteditor/snippets/snippetssettingspage.cpp @@ -34,6 +34,7 @@ #include "snippet.h" #include "snippetscollection.h" #include "snippetssettings.h" +#include "textdocument.h" #include "ui_snippetssettingspage.h" #include diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp index f5a3dd437d7..debb4feddec 100644 --- a/src/plugins/texteditor/syntaxhighlighter.cpp +++ b/src/plugins/texteditor/syntaxhighlighter.cpp @@ -37,6 +37,8 @@ #include #include +#include +#include #include #include diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp index af37bf3d1dc..75e4ad4f085 100644 --- a/src/plugins/texteditor/textdocument.cpp +++ b/src/plugins/texteditor/textdocument.cpp @@ -42,6 +42,8 @@ #include "texteditorconstants.h" #include "typingsettings.h" #include +#include +#include #include #include diff --git a/src/plugins/texteditor/textdocument.h b/src/plugins/texteditor/textdocument.h index 7378807372e..818059e80aa 100644 --- a/src/plugins/texteditor/textdocument.h +++ b/src/plugins/texteditor/textdocument.h @@ -35,8 +35,6 @@ #include #include -#include -#include #include #include diff --git a/src/plugins/texteditor/textdocumentlayout.cpp b/src/plugins/texteditor/textdocumentlayout.cpp index 112d5de7bc6..4187ef31e0b 100644 --- a/src/plugins/texteditor/textdocumentlayout.cpp +++ b/src/plugins/texteditor/textdocumentlayout.cpp @@ -29,6 +29,7 @@ ****************************************************************************/ #include "textdocumentlayout.h" +#include "textdocument.h" #include #include diff --git a/src/plugins/texteditor/textdocumentlayout.h b/src/plugins/texteditor/textdocumentlayout.h index d09a8caac81..eaf018d82a7 100644 --- a/src/plugins/texteditor/textdocumentlayout.h +++ b/src/plugins/texteditor/textdocumentlayout.h @@ -33,8 +33,8 @@ #include "texteditor_global.h" -#include "texteditor.h" #include "textmark.h" +#include "textdocument.h" #include #include diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index bafc47481b8..342eceb8ed1 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -30,6 +30,10 @@ #include "texteditor.h" #include "texteditor_p.h" +#include "displaysettings.h" +#include "marginsettings.h" +#include "fontsettings.h" +#include "texteditoractionhandler.h" #include "autocompleter.h" #include "basehoverhandler.h" @@ -48,6 +52,7 @@ #include "textdocument.h" #include "textdocumentlayout.h" #include "texteditoroverlay.h" +#include "refactoroverlay.h" #include "texteditorsettings.h" #include "typingsettings.h" #include "extraencodingsettings.h" @@ -7196,7 +7201,7 @@ void TextEditorWidget::configureGenericHighlighter() setCodeFoldingSupported(true); } } else { - const QString &fileName = textDocument()->filePath().toString(); + const QString fileName = textDocument()->filePath().toString(); if (TextEditorSettings::highlighterSettings().isIgnoredFilePattern(fileName)) d->m_isMissingSyntaxDefinition = false; } diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h index 1ba72e2b366..9ddaa159d56 100644 --- a/src/plugins/texteditor/texteditor.h +++ b/src/plugins/texteditor/texteditor.h @@ -31,22 +31,17 @@ #ifndef TEXTEDITOR_H #define TEXTEDITOR_H -#include "textdocument.h" -#include "codeassist/assistenums.h" #include "texteditor_global.h" +#include "codeassist/assistenums.h" -#include - -#include -#include #include #include -#include #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -60,11 +55,12 @@ class QTextBlock; QT_END_NAMESPACE namespace TextEditor { - +class TextDocument; class BaseHoverHandler; class TabSettings; class RefactorOverlay; struct RefactorMarker; +class SyntaxHighlighter; class IAssistMonitorInterface; class AssistInterface; class IAssistProvider; @@ -211,9 +207,9 @@ public: TextEditorWidget(QWidget *parent = 0); ~TextEditorWidget(); - void setTextDocument(const TextDocumentPtr &doc); + void setTextDocument(const QSharedPointer &doc); TextDocument *textDocument() const; - TextDocumentPtr textDocumentPtr() const; + QSharedPointer textDocumentPtr() const; // IEditor virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName); diff --git a/src/plugins/texteditor/texteditor_p.h b/src/plugins/texteditor/texteditor_p.h index 15a0419f261..b71600e0221 100644 --- a/src/plugins/texteditor/texteditor_p.h +++ b/src/plugins/texteditor/texteditor_p.h @@ -31,22 +31,10 @@ #ifndef TEXTEDITOR_P_H #define TEXTEDITOR_P_H -#include "texteditor.h" -#include "behaviorsettings.h" -#include "displaysettings.h" -#include "marginsettings.h" -#include "fontsettings.h" -#include "refactoroverlay.h" -#include -#include +#include "texteditor_global.h" -#include -#include -#include -#include -#include -#include +#include namespace TextEditor { diff --git a/src/plugins/texteditor/texteditor_test.cpp b/src/plugins/texteditor/texteditor_test.cpp index fe7295f384d..eabbbb69bfa 100644 --- a/src/plugins/texteditor/texteditor_test.cpp +++ b/src/plugins/texteditor/texteditor_test.cpp @@ -40,6 +40,7 @@ #include "texteditor.h" #include "texteditorplugin.h" +#include "textdocument.h" using namespace TextEditor; diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 586e64ef08f..06fa947cec6 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include #include diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index 11c5b7a2eb5..5ef2c993bc7 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -33,11 +33,12 @@ #include "texteditor_global.h" -#include - #include -namespace Core { class IEditor; } +namespace Core { +class Id; +class IEditor; +} namespace TextEditor { class TextEditorWidget; diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index 8e09907fb31..fd3bf12b1c0 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -30,6 +30,7 @@ #include "texteditorsettings.h" +#include "fontsettings.h" #include "texteditor.h" #include "behaviorsettings.h" #include "behaviorsettingspage.h" diff --git a/src/plugins/texteditor/textmark.h b/src/plugins/texteditor/textmark.h index ddbe872d289..85726d521c3 100644 --- a/src/plugins/texteditor/textmark.h +++ b/src/plugins/texteditor/textmark.h @@ -33,7 +33,6 @@ #include "texteditor_global.h" -#include #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/texteditor/typingsettings.h b/src/plugins/texteditor/typingsettings.h index 5d42db28a3a..6c49feb343b 100644 --- a/src/plugins/texteditor/typingsettings.h +++ b/src/plugins/texteditor/typingsettings.h @@ -33,10 +33,12 @@ #include "texteditor_global.h" -#include +#include QT_BEGIN_NAMESPACE class QSettings; +class QTextDocument; +class QTextCursor; QT_END_NAMESPACE namespace TextEditor { diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 27771bafc51..c658815aaad 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -54,6 +54,7 @@ #include #include +#include #include #include @@ -62,6 +63,7 @@ #include #include +#include #include #include diff --git a/src/plugins/vcsbase/basecheckoutwizardfactory.h b/src/plugins/vcsbase/basecheckoutwizardfactory.h index deeab0b47d6..46dcb74563a 100644 --- a/src/plugins/vcsbase/basecheckoutwizardfactory.h +++ b/src/plugins/vcsbase/basecheckoutwizardfactory.h @@ -34,10 +34,9 @@ #include "vcsbase_global.h" #include -#include - #include +namespace Utils { class FileName; } namespace VcsBase { class BaseCheckoutWizard; class VcsCommand; diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp index d4c9316fb95..2f14a2f33ed 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.cpp +++ b/src/plugins/vcsbase/basevcseditorfactory.cpp @@ -32,6 +32,7 @@ #include "vcsbaseeditor.h" #include +#include #include #include diff --git a/src/plugins/vcsbase/basevcseditorfactory.h b/src/plugins/vcsbase/basevcseditorfactory.h index f166799a23b..8abba89621f 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.h +++ b/src/plugins/vcsbase/basevcseditorfactory.h @@ -32,11 +32,12 @@ #define BASEVCSEDITORFACTORY_H #include "vcsbase_global.h" -#include "vcsbaseeditor.h" #include namespace VcsBase { +class VcsBaseEditor; +class VcsBaseEditorParameters; class VCSBASE_EXPORT VcsEditorFactory : public TextEditor::TextEditorFactory { diff --git a/src/plugins/vcsbase/submiteditorwidget.h b/src/plugins/vcsbase/submiteditorwidget.h index 7f784b2613f..e44082345b7 100644 --- a/src/plugins/vcsbase/submiteditorwidget.h +++ b/src/plugins/vcsbase/submiteditorwidget.h @@ -33,9 +33,6 @@ #include "vcsbase_global.h" -#include - -#include #include QT_BEGIN_NAMESPACE @@ -43,6 +40,7 @@ class QAction; class QModelIndex; QT_END_NAMESPACE +namespace Utils { class CompletingTextEdit; } namespace VcsBase { class SubmitFieldWidget; diff --git a/src/plugins/vcsbase/vcsbase.pro b/src/plugins/vcsbase/vcsbase.pro index 91b4e110136..5f4eae91c02 100644 --- a/src/plugins/vcsbase/vcsbase.pro +++ b/src/plugins/vcsbase/vcsbase.pro @@ -2,6 +2,7 @@ DEFINES += VCSBASE_LIBRARY include(../../qtcreatorplugin.pri) HEADERS += vcsbase_global.h \ vcsbaseconstants.h \ + vcsprojectcache.h \ wizard/vcsconfigurationpage.h \ wizard/vcsjsextension.h \ vcsplugin.h \ @@ -34,6 +35,7 @@ HEADERS += vcsbase_global.h \ SOURCES += vcsplugin.cpp \ vcsbaseplugin.cpp \ + vcsprojectcache.cpp \ wizard/vcsconfigurationpage.cpp \ wizard/vcsjsextension.cpp \ corelistener.cpp \ diff --git a/src/plugins/vcsbase/vcsbase.qbs b/src/plugins/vcsbase/vcsbase.qbs index 36072b9e25b..111ec889628 100644 --- a/src/plugins/vcsbase/vcsbase.qbs +++ b/src/plugins/vcsbase/vcsbase.qbs @@ -76,6 +76,8 @@ QtcPlugin { "vcsoutputwindow.h", "vcsplugin.cpp", "vcsplugin.h", + "vcsprojectcache.cpp", + "vcsprojectcache.h", "images/diff.png", "images/removesubmitfield.png", "images/submit.png", diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index e38abbd3e10..31509def769 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -35,6 +35,9 @@ #include #include +#include +#include +#include #include #include diff --git a/src/plugins/vcsbase/vcsbaseclient.h b/src/plugins/vcsbase/vcsbaseclient.h index dacc51ac94b..37f355e2aeb 100644 --- a/src/plugins/vcsbase/vcsbaseclient.h +++ b/src/plugins/vcsbase/vcsbaseclient.h @@ -32,7 +32,6 @@ #define VCSBASECLIENT_H #include "vcsbase_global.h" -#include #include #include @@ -45,6 +44,8 @@ class QVariant; class QProcessEnvironment; QT_END_NAMESPACE +namespace Core { class Id; } + namespace Utils { struct SynchronousProcessResponse; class ExitCodeInterpreter; diff --git a/src/plugins/vcsbase/vcsbaseclientsettings.h b/src/plugins/vcsbase/vcsbaseclientsettings.h index b999b4d3fcd..7255fb261f9 100644 --- a/src/plugins/vcsbase/vcsbaseclientsettings.h +++ b/src/plugins/vcsbase/vcsbaseclientsettings.h @@ -33,8 +33,6 @@ #include "vcsbase_global.h" -#include - #include #include #include @@ -43,6 +41,7 @@ QT_BEGIN_NAMESPACE class QSettings; QT_END_NAMESPACE +namespace Utils { class FileName; } namespace VcsBase { namespace Internal { class VcsBaseClientSettingsPrivate; } diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 9b40522e355..f3fc5e62f1f 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/vcsbase/vcsbaseplugin.h b/src/plugins/vcsbase/vcsbaseplugin.h index 10dbea73d08..3b92423518d 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.h +++ b/src/plugins/vcsbase/vcsbaseplugin.h @@ -34,7 +34,6 @@ #include "vcsbase_global.h" #include -#include #include #include @@ -45,7 +44,11 @@ class QAction; class QTextCodec; QT_END_NAMESPACE -namespace Utils { struct SynchronousProcessResponse; } +namespace Utils +{ +class FileName; +struct SynchronousProcessResponse; +} namespace Core { class Context; diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp index c383b0d6482..dd9c2cc4439 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp @@ -38,12 +38,14 @@ #include "submitfilemodel.h" #include "vcsoutputwindow.h" #include "vcsplugin.h" +#include "vcsprojectcache.h" #include #include #include #include #include +#include #include #include #include @@ -51,14 +53,13 @@ #include #include -#include #include -#include #include -#include #include #include +#include +#include #include #include #include @@ -143,8 +144,9 @@ static inline QString submitMessageCheckScript() return VcsPlugin::instance()->settings().submitMessageCheckScript; } -struct VcsBaseSubmitEditorPrivate +class VcsBaseSubmitEditorPrivate { +public: VcsBaseSubmitEditorPrivate(const VcsBaseSubmitEditorParameters *parameters, SubmitEditorWidget *editorWidget, VcsBaseSubmitEditor *q); @@ -183,7 +185,7 @@ VcsBaseSubmitEditor::VcsBaseSubmitEditor(const VcsBaseSubmitEditorParameters *pa d(new VcsBaseSubmitEditorPrivate(parameters, editorWidget, this)) { setWidget(d->m_widget); - document()->setDisplayName(QCoreApplication::translate("VCS", d->m_parameters->displayName)); + document()->setPreferredDisplayName(QCoreApplication::translate("VCS", d->m_parameters->displayName)); // Message font according to settings CompletingTextEdit *descriptionEdit = editorWidget->descriptionEdit(); @@ -746,39 +748,27 @@ QIcon VcsBaseSubmitEditor::submitIcon() return QIcon(QLatin1String(":/vcsbase/images/submit.png")); } -// Compile a list if files in the current projects. TODO: Recurse down qrc files? -QStringList VcsBaseSubmitEditor::currentProjectFiles(bool nativeSeparators, QString *name) -{ - if (name) - name->clear(); - - if (const ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectTree::currentProject()) { - QStringList files = currentProject->files(ProjectExplorer::Project::ExcludeGeneratedFiles); - if (name) - *name = currentProject->displayName(); - if (nativeSeparators && !files.empty()) { - const QStringList::iterator end = files.end(); - for (QStringList::iterator it = files.begin(); it != end; ++it) - *it = QDir::toNativeSeparators(*it); - } - return files; - } - return QStringList(); -} - // Reduce a list of untracked files reported by a VCS down to the files // that are actually part of the current project(s). -void VcsBaseSubmitEditor::filterUntrackedFilesOfProject(const QString &repositoryDirectory, QStringList *untrackedFiles) +void VcsBaseSubmitEditor::filterUntrackedFilesOfProject(const QString &repositoryDirectory, + QStringList *untrackedFiles) { if (untrackedFiles->empty()) return; - const QStringList nativeProjectFiles = VcsBaseSubmitEditor::currentProjectFiles(true); - if (nativeProjectFiles.empty()) + + ProjectExplorer::Project *vcsProject = VcsProjectCache::projectFor(repositoryDirectory); + if (!vcsProject) + return; + + const QSet projectFiles + = QSet::fromList(vcsProject->files(ProjectExplorer::Project::ExcludeGeneratedFiles)); + + if (projectFiles.empty()) return; const QDir repoDir(repositoryDirectory); for (QStringList::iterator it = untrackedFiles->begin(); it != untrackedFiles->end(); ) { - const QString path = QDir::toNativeSeparators(repoDir.absoluteFilePath(*it)); - if (nativeProjectFiles.contains(path)) + const QString path = repoDir.absoluteFilePath(*it); + if (projectFiles.contains(path)) ++it; else it = untrackedFiles->erase(it); diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.h b/src/plugins/vcsbase/vcsbasesubmiteditor.h index dfd92bf0f5f..0f7b50bf066 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.h +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.h @@ -42,14 +42,16 @@ class QIcon; class QAction; QT_END_NAMESPACE +namespace ProjectExplorer { class Project; } + namespace VcsBase { namespace Internal { class CommonVcsSettings; class SubmitEditorFile; -} -struct VcsBaseSubmitEditorPrivate; +} // namespace Internal class SubmitEditorWidget; class SubmitFileModel; +class VcsBaseSubmitEditorPrivate; class VCSBASE_EXPORT VcsBaseSubmitEditorParameters { @@ -128,10 +130,6 @@ public: static QIcon diffIcon(); static QIcon submitIcon(); - // Utility returning all project files in case submit lists need to - // be restricted to them - static QStringList currentProjectFiles(bool nativeSeparators, QString *name = 0); - // Reduce a list of untracked files reported by a VCS down to the files // that are actually part of the current project(s). static void filterUntrackedFilesOfProject(const QString &repositoryDirectory, QStringList *untrackedFiles); @@ -168,6 +166,7 @@ private: QString promptForNickName(); VcsBaseSubmitEditorPrivate *d; + friend class Internal::SubmitEditorFile; // for the file contents }; diff --git a/src/plugins/vcsbase/vcscommand.cpp b/src/plugins/vcsbase/vcscommand.cpp index 0cc6bbc6fbe..1f6c3de5334 100644 --- a/src/plugins/vcsbase/vcscommand.cpp +++ b/src/plugins/vcsbase/vcscommand.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/vcsbase/vcscommand.h b/src/plugins/vcsbase/vcscommand.h index acf34d6ed0d..f2eea82553d 100644 --- a/src/plugins/vcsbase/vcscommand.h +++ b/src/plugins/vcsbase/vcscommand.h @@ -33,9 +33,6 @@ #include "vcsbase_global.h" -#include -#include - #include QT_BEGIN_NAMESPACE @@ -47,6 +44,12 @@ template class QFutureInterface; QT_END_NAMESPACE +namespace Utils { +struct SynchronousProcessResponse; +class ExitCodeInterpreter; +class FileName; +} + namespace VcsBase { namespace Internal { class VcsCommandPrivate; } diff --git a/src/plugins/vcsbase/vcsoutputwindow.h b/src/plugins/vcsbase/vcsoutputwindow.h index 9ed45c6ae64..9d481492e48 100644 --- a/src/plugins/vcsbase/vcsoutputwindow.h +++ b/src/plugins/vcsbase/vcsoutputwindow.h @@ -35,8 +35,7 @@ #include -#include - +namespace Utils { class FileName; } namespace VcsBase { class VCSBASE_EXPORT VcsOutputWindow : public Core::IOutputPane diff --git a/src/plugins/vcsbase/vcsplugin.cpp b/src/plugins/vcsbase/vcsplugin.cpp index a70794ad413..433835d8223 100644 --- a/src/plugins/vcsbase/vcsplugin.cpp +++ b/src/plugins/vcsbase/vcsplugin.cpp @@ -35,6 +35,7 @@ #include "commonsettingspage.h" #include "nicknamedialog.h" #include "vcsoutputwindow.h" +#include "vcsprojectcache.h" #include "corelistener.h" #include "wizard/vcsconfigurationpage.h" #include "wizard/vcsjsextension.h" @@ -70,6 +71,7 @@ VcsPlugin::VcsPlugin() : VcsPlugin::~VcsPlugin() { + VcsProjectCache::destroy(); m_instance = 0; } @@ -127,6 +129,7 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage) void VcsPlugin::extensionsInitialized() { + VcsProjectCache::create(); } VcsPlugin *VcsPlugin::instance() diff --git a/src/plugins/vcsbase/vcsprojectcache.cpp b/src/plugins/vcsbase/vcsprojectcache.cpp new file mode 100644 index 00000000000..5ab2c875f72 --- /dev/null +++ b/src/plugins/vcsbase/vcsprojectcache.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "vcsprojectcache.h" + +#include "vcsbasesubmiteditor.h" + +#include +#include + +#include +#include + +#include + +namespace { + +class PathMatcher +{ +public: + PathMatcher() : m_count(std::numeric_limits::max()), m_project(0) { } + ProjectExplorer::Project *project() { return m_project; } + + void match(ProjectExplorer::Project *project, + const Utils::FileName &base, const Utils::FileName &child) { + int count = std::numeric_limits::max(); + if (child.isChildOf(base)) { + const QString relative = child.toString().mid(base.count() + 1); + count = relative.count(QLatin1Char('/')); + } + if (count < m_count) { + m_count = count; + m_project = project; + } + } + +private: + int m_count; + ProjectExplorer::Project *m_project; +}; + +} // namespace + +namespace VcsBase { +namespace Internal { + +VcsProjectCache *VcsProjectCache::m_instance = 0; + +VcsProjectCache::VcsProjectCache() +{ + QTC_ASSERT(!m_instance, return); + m_instance = this; + + connect(ProjectExplorer::SessionManager::instance(), &ProjectExplorer::SessionManager::projectAdded, + this, [this]() { VcsProjectCache::invalidate(); }); + connect(ProjectExplorer::SessionManager::instance(), &ProjectExplorer::SessionManager::projectRemoved, + this, [this]() { VcsProjectCache::invalidate(); }); +} + +VcsProjectCache::~VcsProjectCache() +{ + m_instance = 0; +} + +ProjectExplorer::Project *VcsProjectCache::projectFor(const QString &repo) +{ + ProjectExplorer::Project *project; + + const int pos = Utils::indexOf(m_instance->m_cache, + [repo](const CacheNode &n) { return n.repository == repo; }); + if (pos >= 0) { + if (pos > 0) { + m_instance->m_cache.prepend(m_instance->m_cache.at(pos)); + m_instance->m_cache.removeAt(pos + 1); + } + return m_instance->m_cache.at(0).project; + } + + project = projectForToplevel(Utils::FileName::fromString(repo)); + m_instance->m_cache.prepend(CacheNode(repo, project)); + while (m_instance->m_cache.count() > 10) + m_instance->m_cache.removeLast(); + + return project; +} + +void VcsProjectCache::invalidate() +{ + m_instance->m_cache.clear(); +} + +void VcsProjectCache::create() +{ + new VcsProjectCache; +} + +void VcsProjectCache::destroy() +{ + delete m_instance; +} + +ProjectExplorer::Project *VcsProjectCache::projectForToplevel(const Utils::FileName &vcsTopLevel) +{ + PathMatcher parentMatcher; + PathMatcher childMatcher; + foreach (ProjectExplorer::Project *project, ProjectExplorer::SessionManager::projects()) { + const Utils::FileName projectDir = project->projectDirectory(); + if (projectDir == vcsTopLevel) + return project; + parentMatcher.match(project, vcsTopLevel, projectDir); + childMatcher.match(project, projectDir, vcsTopLevel); + } + + if (parentMatcher.project()) + return parentMatcher.project(); + + return childMatcher.project(); +} + +} // Internal +} // namespace VcsBase diff --git a/src/plugins/vcsbase/vcsprojectcache.h b/src/plugins/vcsbase/vcsprojectcache.h new file mode 100644 index 00000000000..81ae7134ba5 --- /dev/null +++ b/src/plugins/vcsbase/vcsprojectcache.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VCSBASE_PROJECTCACHE_H +#define VCSBASE_PROJECTCACHE_H + +#include + +#include +#include + +namespace ProjectExplorer { class Project; } + +namespace VcsBase { +namespace Internal { + +class VcsPlugin; + +class VcsProjectCache : public QObject { +public: + static ProjectExplorer::Project *projectFor(const QString &repo); + +private: + VcsProjectCache(); + ~VcsProjectCache(); + + static void invalidate(); + static ProjectExplorer::Project *projectForToplevel(const Utils::FileName &vcsTopLevel); + + static void create(); + static void destroy(); + + class CacheNode { + public: + CacheNode(const QString &r, ProjectExplorer::Project *p) : repository(r), project(p) + { } + + QString repository; + ProjectExplorer::Project *project; + }; + QList m_cache; + + static VcsProjectCache *m_instance; + + friend class VcsPlugin; +}; + +} // namespace Internal +} // namespace VcsBase + +#endif // VCSBASE_PROJECTCACHE_H diff --git a/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp b/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp index e477eb7da4a..98bcc3e8867 100644 --- a/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp +++ b/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp @@ -987,7 +987,7 @@ static QString createConstructor(ClassSpecifierAST *classAST) bool checkGenerated(const QTextCursor &cursor, int *doxyStart) { - BackwardsScanner tokens(cursor, 10, QString(), false); + BackwardsScanner tokens(cursor, LanguageFeatures::defaultFeatures(), 10, QString(), false); Token prevToken = tokens.LA(1); if (prevToken.kind() != T_DOXY_COMMENT && prevToken.kind() != T_CPP_DOXY_COMMENT) return false; diff --git a/tests/auto/cplusplus/c99/data/designatedInitializer.1.c b/tests/auto/cplusplus/c99/data/designatedInitializer.1.c index 43db4b66477..dcb482f6d61 100644 --- a/tests/auto/cplusplus/c99/data/designatedInitializer.1.c +++ b/tests/auto/cplusplus/c99/data/designatedInitializer.1.c @@ -7,3 +7,12 @@ int a[10] = {2, 4, [8]=9, 10}; int a[MAX] = { 1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0 }; +struct { + int table [3]; + struct { + int a; + int b; + } parts; +} a[MAX] = { + [2] = { .table = { 8, [1] = 7, 6 }, .parts = { .a = 0, 1 } } +}; diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp index 579c70d2ab5..2011f03e002 100644 --- a/tests/auto/cplusplus/semantic/tst_semantic.cpp +++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp @@ -189,6 +189,7 @@ private slots: void enum_constantValue2(); void enum_constantValue3(); void enum_constantValue4(); + void enum_constantValue5(); }; void tst_Semantic::function_declaration_1() @@ -531,7 +532,7 @@ void tst_Semantic::expression_under_cursor_1() QTextCursor tc(&textDocument); tc.movePosition(QTextCursor::End); - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(LanguageFeatures::defaultFeatures()); const QString expression = expressionUnderCursor(tc); QCOMPARE(expression, QString("bar")); @@ -547,7 +548,7 @@ void tst_Semantic::bracketed_expression_under_cursor_1() QTextCursor tc(&textDocument); tc.movePosition(QTextCursor::End); - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(LanguageFeatures::defaultFeatures()); const QString expression = expressionUnderCursor(tc); QCOMPARE(expression, QString("i")); @@ -563,7 +564,7 @@ void tst_Semantic::bracketed_expression_under_cursor_2() QTextCursor tc(&textDocument); tc.movePosition(QTextCursor::End); - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(LanguageFeatures::defaultFeatures()); const QString expression = expressionUnderCursor(tc); QCOMPARE(expression, plainText); @@ -579,7 +580,7 @@ void tst_Semantic::bracketed_expression_under_cursor_3() QTextCursor tc(&textDocument); tc.movePosition(QTextCursor::End); - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(LanguageFeatures::defaultFeatures()); const QString expression = expressionUnderCursor(tc); QCOMPARE(expression, QString("[receiver message")); @@ -595,7 +596,7 @@ void tst_Semantic::bracketed_expression_under_cursor_4() QTextCursor tc(&textDocument); tc.movePosition(QTextCursor::End); - ExpressionUnderCursor expressionUnderCursor; + ExpressionUnderCursor expressionUnderCursor(LanguageFeatures::defaultFeatures()); const QString expression = expressionUnderCursor(tc); QCOMPARE(expression, QString("i")); @@ -890,5 +891,30 @@ void tst_Semantic::enum_constantValue4() testEnumaratorDeclarator(e, 4, "11"); } +void tst_Semantic::enum_constantValue5() +{ + QSharedPointer doc = document("\n" + "enum {\n" + "E1,\n" + "E2=E1,\n" + "E3,\n" + "E4=E3,\n" + "E5\n" + "};\n" + ); + + QCOMPARE(doc->errorCount, 0U); + QCOMPARE(doc->globals->memberCount(), 1U); + Enum *e = doc->globals->memberAt(0)->asEnum(); + QVERIFY(e); + QCOMPARE(e->memberCount(), 5U); + + testEnumaratorDeclarator(e, 0, "0"); + testEnumaratorDeclarator(e, 1, "0"); + testEnumaratorDeclarator(e, 2, "1"); + testEnumaratorDeclarator(e, 3, "1"); + testEnumaratorDeclarator(e, 4, "2"); +} + QTEST_MAIN(tst_Semantic) #include "tst_semantic.moc" diff --git a/tests/auto/valgrind/memcheck/testapps/leak2/leak2.pro b/tests/auto/valgrind/memcheck/testapps/leak2/leak2.pro index 59397bf849c..aae4b9a45ae 100644 --- a/tests/auto/valgrind/memcheck/testapps/leak2/leak2.pro +++ b/tests/auto/valgrind/memcheck/testapps/leak2/leak2.pro @@ -3,6 +3,7 @@ TARGET = leak2 CONFIG += debug +win32-msvc*:QMAKE_CXXFLAGS += -w44996 QT += core macx:CONFIG -= app_bundle diff --git a/tests/auto/valgrind/memcheck/testapps/leak3/leak3.pro b/tests/auto/valgrind/memcheck/testapps/leak3/leak3.pro index 0076f66a1e3..6eebcbb04ac 100644 --- a/tests/auto/valgrind/memcheck/testapps/leak3/leak3.pro +++ b/tests/auto/valgrind/memcheck/testapps/leak3/leak3.pro @@ -7,6 +7,6 @@ QT += core macx:CONFIG -= app_bundle -win32-msvc*:QMAKE_CXXFLAGS += -w4996 +win32-msvc*:QMAKE_CXXFLAGS += -w44996 SOURCES += main.cpp diff --git a/tests/auto/valgrind/memcheck/testapps/syscall/main.cpp b/tests/auto/valgrind/memcheck/testapps/syscall/main.cpp index f4b33a4d6bc..a0147dc90dc 100644 --- a/tests/auto/valgrind/memcheck/testapps/syscall/main.cpp +++ b/tests/auto/valgrind/memcheck/testapps/syscall/main.cpp @@ -28,8 +28,6 @@ ** ****************************************************************************/ -#pragma GCC diagnostic ignored "-Wuninitialized" - int main() { int i; diff --git a/tests/auto/valgrind/memcheck/testapps/syscall/syscall.pro b/tests/auto/valgrind/memcheck/testapps/syscall/syscall.pro index 108636f6549..026a9fdcdb6 100644 --- a/tests/auto/valgrind/memcheck/testapps/syscall/syscall.pro +++ b/tests/auto/valgrind/memcheck/testapps/syscall/syscall.pro @@ -2,7 +2,8 @@ TEMPLATE = app TARGET = syscall CONFIG += debug -QMAKE_CXXFLAGS = -O0 +win32-msvc*:QMAKE_CXXFLAGS += -w44700 +else:QMAKE_CXXFLAGS = -O0 -Wno-uninitialized QT += core diff --git a/tests/auto/valgrind/memcheck/testapps/testapp.qbs b/tests/auto/valgrind/memcheck/testapps/testapp.qbs index ed0a8573dba..321b6125d65 100644 --- a/tests/auto/valgrind/memcheck/testapps/testapp.qbs +++ b/tests/auto/valgrind/memcheck/testapps/testapp.qbs @@ -3,6 +3,7 @@ import qbs QtcAutotest { type: ["application"] // Not to be executed directly by autotest-runner name: "Memcheck " + testName + " autotest" + cpp.warningLevel: "none" property string testName targetName: testName // Test runner hardcodes the names of the executables destinationDirectory: project.buildDirectory + '/' diff --git a/tests/auto/valgrind/memcheck/testapps/uninit1/uninit1.pro b/tests/auto/valgrind/memcheck/testapps/uninit1/uninit1.pro index 7690b4848b3..4ccd99a5413 100644 --- a/tests/auto/valgrind/memcheck/testapps/uninit1/uninit1.pro +++ b/tests/auto/valgrind/memcheck/testapps/uninit1/uninit1.pro @@ -3,7 +3,7 @@ TARGET = uninit1 CONFIG += debug console CONFIG -= qt -win32-msvc*:QMAKE_CXXFLAGS += -w4700 +win32-msvc*:QMAKE_CXXFLAGS += -w44700 else:QMAKE_CXXFLAGS = -O0 -Wno-uninitialized macx:CONFIG -= app_bundle diff --git a/tests/auto/valgrind/memcheck/testapps/uninit2/uninit2.pro b/tests/auto/valgrind/memcheck/testapps/uninit2/uninit2.pro index a2c3341c15a..26c1ce41fb6 100644 --- a/tests/auto/valgrind/memcheck/testapps/uninit2/uninit2.pro +++ b/tests/auto/valgrind/memcheck/testapps/uninit2/uninit2.pro @@ -3,7 +3,7 @@ TARGET = uninit2 CONFIG += debug console CONFIG -= qt -win32-msvc*:QMAKE_CXXFLAGS += -w4700 +win32-msvc*:QMAKE_CXXFLAGS += -w44700 else:QMAKE_CXXFLAGS = -O0 -Wno-uninitialized macx:CONFIG -= app_bundle diff --git a/tests/auto/valgrind/memcheck/testapps/uninit3/uninit3.pro b/tests/auto/valgrind/memcheck/testapps/uninit3/uninit3.pro index 43fdc08abef..2d7ff256c15 100644 --- a/tests/auto/valgrind/memcheck/testapps/uninit3/uninit3.pro +++ b/tests/auto/valgrind/memcheck/testapps/uninit3/uninit3.pro @@ -3,7 +3,7 @@ TARGET = uninit3 CONFIG += debug console CONFIG -= qt -win32-msvc*:QMAKE_CXXFLAGS += -w4700 +win32-msvc*:QMAKE_CXXFLAGS += -w44700 else:QMAKE_CXXFLAGS = -O0 -Wno-uninitialized macx:CONFIG -= app_bundle diff --git a/tests/system/settings/unix/QtProject/qtcreator/profiles.xml b/tests/system/settings/unix/QtProject/qtcreator/profiles.xml index b515d340477..5e08ff946d0 100644 --- a/tests/system/settings/unix/QtProject/qtcreator/profiles.xml +++ b/tests/system/settings/unix/QtProject/qtcreator/profiles.xml @@ -1,6 +1,6 @@ - + Profile.0 @@ -174,9 +174,33 @@ + + Profile.8 + + false + + + + {70e26273-2c0b-4534-bbc0-eb6ca670821a} + Desktop Device + Desktop + + + ProjectExplorer.ToolChain.Gcc:{c3f59b87-6997-4bd8-8067-ee04dc536371} + + 13 + + :///DESKTOP/// + {8ca91e21-c12e-4876-85b3-4b2141708acb} + + Desktop 541 GCC + false + + + Profile.Count - 8 + 9 Profile.Default diff --git a/tests/system/settings/unix/QtProject/qtcreator/qtversion.xml b/tests/system/settings/unix/QtProject/qtcreator/qtversion.xml index 6ed59e9a931..ce7e0515a43 100644 --- a/tests/system/settings/unix/QtProject/qtcreator/qtversion.xml +++ b/tests/system/settings/unix/QtProject/qtcreator/qtversion.xml @@ -1,6 +1,6 @@ - + QtVersion.0 @@ -72,6 +72,16 @@ false + + QtVersion.7 + + 13 + Qt %{Qt:Version} (SQUISH_DEFAULT_COMPILER) + ~/Qt5.4.1/5.4/SQUISH_DEFAULT_COMPILER/bin/qmake + Qt4ProjectManager.QtVersion.Desktop + false + + Version 1 diff --git a/tests/system/settings/windows/QtProject/QtCreator.ini b/tests/system/settings/windows/QtProject/QtCreator.ini index b77fccec036..1e759b30437 100644 --- a/tests/system/settings/windows/QtProject/QtCreator.ini +++ b/tests/system/settings/windows/QtProject/QtCreator.ini @@ -1,2 +1,5 @@ [%General] OverrideLanguage=C + +[MainWindow] +WindowGeometry=@ByteArray(\x1\xd9\xd0\xcb\0\x1\0\0\0\0\x1H\0\0\0}\0\0\x5\xe0\0\0\x3^\0\0\x1P\0\0\0\x9b\0\0\x5\xd8\0\0\x3V\0\0\0\0\0\0) diff --git a/tests/system/settings/windows/QtProject/qtcreator/debuggers.xml b/tests/system/settings/windows/QtProject/qtcreator/debuggers.xml index f9bac448c4a..6bb8c3101fe 100644 --- a/tests/system/settings/windows/QtProject/qtcreator/debuggers.xml +++ b/tests/system/settings/windows/QtProject/qtcreator/debuggers.xml @@ -1,6 +1,6 @@ - - + + DebuggerItem.0 @@ -9,21 +9,27 @@ x86-windows-msvc2010-pe-64bit true - C:\Program Files\Debugging Tools for Windows (x64)\cdb.exe + + C:/Program Files/Debugging Tools for Windows (x64)/cdb.exe Auto-detected CDB at C:\Program Files\Debugging Tools for Windows (x64)\cdb.exe 4 {811977c9-ea95-4616-bc28-c66d1935ff65} + DebuggerItem.1 - - true - C:\QtSDK\pythongdb\python_2.7based\gdb-i686-pc-mingw32.exe - Extracted from Kit Desktop 474 GCC + + x86-windows-msys-pe-unknown + + false + + C:/Qt/Qt5.4.1/Tools/mingw491_32/bin/gdb.exe + gdb 7.8 1 - {44aee0bd-999d-4abe-82c6-5c7979e7cf01} + {2f8a1f59-ddd7-49f0-ae61-1337223f56a3} + 7.8.0 @@ -33,10 +39,12 @@ arm-linux-generic-elf-32bit true - C:\QtSDK\pythongdb\python_2.7based\gdb-arm-none-linux-gnueabi.exe + + C:/QtSDK/pythongdb/python_2.7based/gdb-arm-none-linux-gnueabi.exe Extracted from Kit Fremantle 1 {5ad1d623-7300-41b4-ba32-99e11bfcb988} + diff --git a/tests/system/settings/windows/QtProject/qtcreator/profiles.xml b/tests/system/settings/windows/QtProject/qtcreator/profiles.xml index f04407b93bb..541183f7b2f 100644 --- a/tests/system/settings/windows/QtProject/qtcreator/profiles.xml +++ b/tests/system/settings/windows/QtProject/qtcreator/profiles.xml @@ -1,16 +1,18 @@ - + Profile.0 false + - {44aee0bd-999d-4abe-82c6-5c7979e7cf01} + {2f8a1f59-ddd7-49f0-ae61-1337223f56a3} Desktop Device Desktop + ProjectExplorer.ToolChain.Mingw:{2729dd3e-84f5-42e1-aed1-6a27163346ce} @@ -21,17 +23,20 @@ Desktop 474 GCC false + Profile.1 false + - {44aee0bd-999d-4abe-82c6-5c7979e7cf01} + {2f8a1f59-ddd7-49f0-ae61-1337223f56a3} Desktop Device Desktop + ProjectExplorer.ToolChain.Mingw:{2729dd3e-84f5-42e1-aed1-6a27163346ce} @@ -42,6 +47,7 @@ Qt Simulator false + @@ -90,11 +96,13 @@ Profile.4 false + {811977c9-ea95-4616-bc28-c66d1935ff65} Desktop Device Desktop + ProjectExplorer.ToolChain.Msvc:{1186dad9-c485-4f69-b7e1-aff54c89ecb2} @@ -105,6 +113,7 @@ Desktop 480 MSVC2010 false + @@ -117,6 +126,7 @@ {811977c9-ea95-4616-bc28-c66d1935ff65} Desktop Device Desktop + ProjectExplorer.ToolChain.Msvc:{1186dad9-c485-4f69-b7e1-aff54c89ecb2} @@ -134,11 +144,13 @@ Profile.6 false + - {44aee0bd-999d-4abe-82c6-5c7979e7cf01} + {2f8a1f59-ddd7-49f0-ae61-1337223f56a3} Desktop Device Desktop + ProjectExplorer.ToolChain.Mingw:{2729dd3e-84f5-42e1-aed1-6a27163346ce} @@ -149,6 +161,7 @@ Desktop 480 GCC false + @@ -161,6 +174,7 @@ {811977c9-ea95-4616-bc28-c66d1935ff65} Desktop Device Desktop + ProjectExplorer.ToolChain.Msvc:{1186dad9-c485-4f69-b7e1-aff54c89ecb2} @@ -171,11 +185,36 @@ Desktop 521 default false + + + + + Profile.8 + + false + + + + {2f8a1f59-ddd7-49f0-ae61-1337223f56a3} + Desktop Device + Desktop + + + ProjectExplorer.ToolChain.Mingw:{44d54392-22ee-4eac-a9f1-2d882ba8a7bb} + + 22 + + :///DESKTOP/// + {10cf33c5-e36d-4a49-a8c7-086f3cf59695} + + Desktop 541 GCC + false + Profile.Count - 8 + 9 Profile.Default diff --git a/tests/system/settings/windows/QtProject/qtcreator/qtversion.xml b/tests/system/settings/windows/QtProject/qtcreator/qtversion.xml index 853d07393c6..a5b67095337 100644 --- a/tests/system/settings/windows/QtProject/qtcreator/qtversion.xml +++ b/tests/system/settings/windows/QtProject/qtcreator/qtversion.xml @@ -1,6 +1,6 @@ - + QtVersion.0 @@ -82,6 +82,16 @@ false + + QtVersion.8 + + 22 + Qt %{Qt:Version} (mingw491_32) + C:/Qt/Qt5.4.1/5.4/mingw491_32/bin/qmake.exe + Qt4ProjectManager.QtVersion.Desktop + false + + Version 1 diff --git a/tests/system/settings/windows/QtProject/qtcreator/toolchains.xml b/tests/system/settings/windows/QtProject/qtcreator/toolchains.xml index e5d2fa114d9..f87f81d9a50 100644 --- a/tests/system/settings/windows/QtProject/qtcreator/toolchains.xml +++ b/tests/system/settings/windows/QtProject/qtcreator/toolchains.xml @@ -1,17 +1,19 @@ - + ToolChain.0 C:/QtSDK/mingw/bin/g++.exe + + x86-windows-msys-pe-32bit x86-windows-msys-pe-32bit false - MinGW + MinGW 4.4 ProjectExplorer.ToolChain.Mingw:{2729dd3e-84f5-42e1-aed1-6a27163346ce} @@ -55,11 +57,16 @@ ToolChain.4 - x86-windows-msvc2008-pe-32bit - c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat + C:/Qt/Qt5.4.1/Tools/mingw491_32/bin/g++.exe + + + + x86-windows-msys-pe-32bit + + x86-windows-msys-pe-32bit false - MSVC 2008 (x86) - ProjectExplorer.ToolChain.Msvc:{b86e54dd-debd-409c-b4d7-1a5c710eaa37} + MinGW 4.9 + ProjectExplorer.ToolChain.Mingw:{44d54392-22ee-4eac-a9f1-2d882ba8a7bb} diff --git a/tests/system/shared/classes.py b/tests/system/shared/classes.py index 9e348c20fa6..e2003fe6b1d 100644 --- a/tests/system/shared/classes.py +++ b/tests/system/shared/classes.py @@ -41,6 +41,7 @@ class Targets: DESKTOP_480_MSVC2010 = 64 DESKTOP_521_DEFAULT = 128 DESKTOP_531_DEFAULT = 256 + DESKTOP_541_GCC = 512 @staticmethod def desktopTargetClasses(): @@ -48,6 +49,8 @@ class Targets: | Targets.DESKTOP_521_DEFAULT | Targets.DESKTOP_531_DEFAULT) if platform.system() in ('Windows', 'Microsoft'): desktopTargets |= Targets.DESKTOP_480_MSVC2010 + if platform.system() != 'Darwin': + desktopTargets |= Targets.DESKTOP_541_GCC return desktopTargets @staticmethod @@ -70,6 +73,8 @@ class Targets: return "Desktop 521 default" elif target == Targets.DESKTOP_531_DEFAULT: return "Desktop 531 default" + elif target == Targets.DESKTOP_541_GCC: + return "Desktop 541 GCC" else: return None @@ -87,7 +92,7 @@ class Targets: def intToArray(targets): available = [Targets.DESKTOP_474_GCC, Targets.DESKTOP_480_GCC, Targets.SIMULATOR, Targets.MAEMO5, Targets.HARMATTAN, Targets.EMBEDDED_LINUX, Targets.DESKTOP_480_MSVC2010, - Targets.DESKTOP_521_DEFAULT, Targets.DESKTOP_531_DEFAULT] + Targets.DESKTOP_521_DEFAULT, Targets.DESKTOP_531_DEFAULT, Targets.DESKTOP_541_GCC] return filter(lambda x: x & targets == x, available) @staticmethod diff --git a/tests/system/shared/project.py b/tests/system/shared/project.py index 765fa176fef..24978cd8288 100644 --- a/tests/system/shared/project.py +++ b/tests/system/shared/project.py @@ -395,6 +395,8 @@ def __chooseTargets__(targets=Targets.DESKTOP_474_GCC, availableTargets=None): if platform.system() in ('Windows', 'Microsoft'): available.remove(Targets.EMBEDDED_LINUX) available.append(Targets.DESKTOP_480_MSVC2010) + if platform.system() != 'Darwin': + available.append(Targets.DESKTOP_541_GCC) for target in filter(lambda x: x in available, (Targets.MAEMO5, Targets.HARMATTAN)): available.remove(target) @@ -625,6 +627,8 @@ def __getSupportedPlatforms__(text, templateName, getAsStrings=False): elif platform.system() in ('Windows', 'Microsoft'): result.append(Targets.DESKTOP_480_MSVC2010) result.extend([Targets.DESKTOP_521_DEFAULT, Targets.DESKTOP_531_DEFAULT]) + if platform.system() != 'Darwin': + result.append(Targets.DESKTOP_541_GCC) if 'MeeGo/Harmattan' in supports: result.append(Targets.HARMATTAN) if 'Maemo/Fremantle' in supports: @@ -637,6 +641,8 @@ def __getSupportedPlatforms__(text, templateName, getAsStrings=False): Targets.DESKTOP_531_DEFAULT, Targets.MAEMO5, Targets.SIMULATOR, Targets.HARMATTAN] if platform.system() in ('Windows', 'Microsoft'): result.append(Targets.DESKTOP_480_MSVC2010) + if platform.system() != 'Darwin': + result.append(Targets.DESKTOP_541_GCC) else: test.warning("Returning None (__getSupportedPlatforms__())", "Parsed text: '%s'" % text) diff --git a/tests/system/suite_CCOM/tst_CCOM01/test.py b/tests/system/suite_CCOM/tst_CCOM01/test.py index 798d29de5f8..54af5775db6 100755 --- a/tests/system/suite_CCOM/tst_CCOM01/test.py +++ b/tests/system/suite_CCOM/tst_CCOM01/test.py @@ -45,7 +45,8 @@ def main(): return # open example project # qmlapplicationviewer of this example supports only Qt version < 5 - targets = Targets.desktopTargetClasses() & ~Targets.DESKTOP_521_DEFAULT & ~Targets.DESKTOP_531_DEFAULT + targets = (Targets.desktopTargetClasses() & ~Targets.DESKTOP_521_DEFAULT + & ~Targets.DESKTOP_531_DEFAULT & ~Targets.DESKTOP_541_GCC) checkedTargets = openQmakeProject(examplePath, targets) if not replaceLine("propertyanimation.Sources.main\\.cpp", "#include ", diff --git a/tests/system/suite_CCOM/tst_CCOM02/test.py b/tests/system/suite_CCOM/tst_CCOM02/test.py index 4bd3c371504..4d42bb8c056 100755 --- a/tests/system/suite_CCOM/tst_CCOM02/test.py +++ b/tests/system/suite_CCOM/tst_CCOM02/test.py @@ -45,7 +45,8 @@ def main(): if not startedWithoutPluginError(): return # open example project - targets = Targets.desktopTargetClasses() & ~Targets.DESKTOP_521_DEFAULT & ~Targets.DESKTOP_531_DEFAULT + targets = (Targets.desktopTargetClasses() & ~Targets.DESKTOP_521_DEFAULT + & ~Targets.DESKTOP_531_DEFAULT & ~Targets.DESKTOP_541_GCC) openQmakeProject(examplePath, targets) # create syntax error openDocument("propertyanimation.QML.qml.property-animation\\.qml")