summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dist/changes-3.1.085
-rw-r--r--doc/api/qtcreator-api.qdoc6
-rw-r--r--doc/src/android/androiddev.qdoc2
-rw-r--r--doc/src/debugger/creator-debugger-setup.qdoc52
-rw-r--r--doc/src/debugger/creator-debugger.qdoc156
-rw-r--r--doc/src/howto/creator-vcs.qdoc46
-rw-r--r--doc/src/qnx/creator-developing-bb10.qdoc4
-rw-r--r--qbs/modules/pluginspec/pluginspec.qbs2
-rw-r--r--qtcreator.pri16
-rw-r--r--qtcreator.qbs4
-rw-r--r--share/qtcreator/cplusplus/qt5-qobjectdefs-injected.h60
-rw-r--r--share/qtcreator/debugger/boosttypes.py7
-rw-r--r--share/qtcreator/debugger/creatortypes.py10
-rw-r--r--share/qtcreator/debugger/dumper.cpp3805
-rw-r--r--share/qtcreator/debugger/dumper.h46
-rw-r--r--share/qtcreator/debugger/dumper.pro30
-rw-r--r--share/qtcreator/debugger/dumper.py131
-rw-r--r--share/qtcreator/debugger/dumper_p.h204
-rw-r--r--share/qtcreator/debugger/gdbbridge.py77
-rw-r--r--share/qtcreator/debugger/lldbbridge.py83
-rw-r--r--share/qtcreator/debugger/misctypes.py76
-rw-r--r--share/qtcreator/debugger/qttypes.py127
-rw-r--r--share/qtcreator/debugger/stdtypes.py281
-rw-r--r--share/qtcreator/debugger/test/dumpertest.pro19
-rw-r--r--share/qtcreator/debugger/test/main.cpp677
-rw-r--r--share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp5
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp5
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pri1
-rw-r--r--share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/objectnodeinstance.cpp5
-rw-r--r--share/qtcreator/qml/qmlpuppet/qmlpuppet/qmlpuppet.pri1
-rw-r--r--share/qtcreator/qml/qmlpuppet/types/enumeration.cpp122
-rw-r--r--share/qtcreator/qml/qmlpuppet/types/enumeration.h (renamed from src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.h)62
-rw-r--r--share/qtcreator/qml/qmlpuppet/types/types.pri5
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ComboBox.qml6
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/StandardTextSection.qml1
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/BorderImageSpecifics.qml2
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/FlowSpecifics.qml2
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GridSpecifics.qml2
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ImageSpecifics.qml1
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RowSpecifics.qml1
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/TextInputSection.qml1
-rw-r--r--share/qtcreator/static.pro3
-rw-r--r--share/qtcreator/templates/qml/qtquick_1_1/template.xml5
-rw-r--r--share/qtcreator/templates/qml/qtquick_2_0/template.xml5
-rw-r--r--share/qtcreator/templates/qml/qtquick_2_1/main.qml17
-rw-r--r--share/qtcreator/templates/qml/qtquick_2_1/main.qmlproject21
-rw-r--r--share/qtcreator/templates/qml/qtquick_2_1/template.xml6
-rw-r--r--share/qtcreator/templates/qml/qtquick_2_2/main.qml17
-rw-r--r--share/qtcreator/templates/qml/qtquick_2_2/main.qmlproject21
-rw-r--r--share/qtcreator/templates/qml/qtquick_2_2/template.xml6
-rw-r--r--share/qtcreator/templates/qml/qtquickcontrols_1_0/template.xml5
-rw-r--r--share/qtcreator/templates/qml/qtquickcontrols_1_1/main.qml25
-rw-r--r--share/qtcreator/templates/qml/qtquickcontrols_1_1/main.qmlproject21
-rw-r--r--share/qtcreator/templates/qml/qtquickcontrols_1_1/template.xml6
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_1_1/app.pro2
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_1_1/template.xml2
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_2_0/app.pro2
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_2_0/template.xml2
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_2_1/app.pro22
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_2_1/main.cpp13
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_2_1/qml/app/main.qml16
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_2_1/template.xml9
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_2_2/app.pro22
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_2_2/main.cpp13
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_2_2/qml/app/main.qml16
-rw-r--r--share/qtcreator/templates/qtquick/qtquick_2_2/template.xml9
-rw-r--r--share/qtcreator/templates/qtquick/qtquickcontrols_1_0/app.pro2
-rw-r--r--share/qtcreator/templates/qtquick/qtquickcontrols_1_0/template.xml2
-rw-r--r--share/qtcreator/templates/qtquick/qtquickcontrols_1_1/app.pro22
-rw-r--r--share/qtcreator/templates/qtquick/qtquickcontrols_1_1/main.cpp12
-rw-r--r--share/qtcreator/templates/qtquick/qtquickcontrols_1_1/qml/app/main.qml23
-rw-r--r--share/qtcreator/templates/qtquick/qtquickcontrols_1_1/template.xml9
-rw-r--r--share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick1applicationviewer/qtquick1applicationviewer.cpp (renamed from share/qtcreator/templates/qtquick/qtquick_1_1/qtquick1applicationviewer/qtquick1applicationviewer.cpp)0
-rw-r--r--share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick1applicationviewer/qtquick1applicationviewer.h (renamed from share/qtcreator/templates/qtquick/qtquick_1_1/qtquick1applicationviewer/qtquick1applicationviewer.h)0
-rw-r--r--share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick1applicationviewer/qtquick1applicationviewer.pri (renamed from share/qtcreator/templates/qtquick/qtquick_1_1/qtquick1applicationviewer/qtquick1applicationviewer.pri)0
-rw-r--r--share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.cpp (renamed from share/qtcreator/templates/qtquick/qtquick_2_0/qtquick2applicationviewer/qtquick2applicationviewer.cpp)0
-rw-r--r--share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.h (renamed from share/qtcreator/templates/qtquick/qtquick_2_0/qtquick2applicationviewer/qtquick2applicationviewer.h)0
-rw-r--r--share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri (renamed from share/qtcreator/templates/qtquick/qtquick_2_0/qtquick2applicationviewer/qtquick2applicationviewer.pri)0
-rw-r--r--share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.cpp (renamed from share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.cpp)0
-rw-r--r--share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.h (renamed from share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.h)0
-rw-r--r--share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri (renamed from share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri)0
-rw-r--r--src/libs/3rdparty/cplusplus/Control.cpp5
-rw-r--r--src/libs/3rdparty/cplusplus/Control.h3
-rw-r--r--src/libs/3rdparty/cplusplus/Lexer.cpp19
-rw-r--r--src/libs/3rdparty/cplusplus/Symbols.cpp25
-rw-r--r--src/libs/3rdparty/cplusplus/Symbols.h2
-rw-r--r--src/libs/3rdparty/cplusplus/Templates.cpp2
-rw-r--r--src/libs/3rdparty/cplusplus/TranslationUnit.h1
-rw-r--r--src/libs/cplusplus/CppRewriter.cpp225
-rw-r--r--src/libs/cplusplus/CppRewriter.h5
-rw-r--r--src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp2
-rw-r--r--src/libs/extensionsystem/extensionsystem.pro2
-rw-r--r--src/libs/extensionsystem/extensionsystem.qbs1
-rw-r--r--src/libs/extensionsystem/pluginview.cpp58
-rw-r--r--src/libs/extensionsystem/pluginview.h9
-rw-r--r--src/libs/extensionsystem/pluginview.ui84
-rw-r--r--src/libs/qmljs/qmljsconstants.h2
-rw-r--r--src/libs/qtcreatorcdbext/containers.cpp32
-rw-r--r--src/libs/qtcreatorcdbext/knowntype.h4
-rw-r--r--src/libs/qtcreatorcdbext/symbolgroupnode.cpp16
-rw-r--r--src/libs/qtcreatorcdbext/symbolgroupvalue.cpp254
-rw-r--r--src/libs/utils/completinglineedit.cpp74
-rw-r--r--src/libs/utils/completinglineedit.h52
-rw-r--r--src/libs/utils/detailswidget.cpp17
-rw-r--r--src/libs/utils/detailswidget.h1
-rw-r--r--src/libs/utils/execmenu.cpp (renamed from src/plugins/qmldesigner/components/propertyeditor/originwidget.h)87
-rw-r--r--src/libs/utils/execmenu.h (renamed from src/plugins/qmldesigner/components/propertyeditor/qlayoutobject.cpp)25
-rw-r--r--src/libs/utils/fancylineedit.cpp48
-rw-r--r--src/libs/utils/fancylineedit.h7
-rw-r--r--src/libs/utils/fileutils.cpp8
-rw-r--r--src/libs/utils/fileutils.h4
-rw-r--r--src/libs/utils/historycompleter.cpp18
-rw-r--r--src/libs/utils/historycompleter.h6
-rw-r--r--src/libs/utils/textfileformat.cpp42
-rw-r--r--src/libs/utils/textfileformat.h2
-rw-r--r--src/libs/utils/utils-lib.pri8
-rw-r--r--src/libs/utils/utils.qbs4
-rw-r--r--src/plugins/analyzerbase/analyzerrunconfigwidget.cpp4
-rw-r--r--src/plugins/android/androidconfigurations.cpp92
-rw-r--r--src/plugins/android/androidconfigurations.h8
-rw-r--r--src/plugins/android/androiddeployqtstep.cpp54
-rw-r--r--src/plugins/android/androiddeployqtstep.h6
-rw-r--r--src/plugins/android/androiddeployqtwidget.cpp12
-rw-r--r--src/plugins/android/androiddeployqtwidget.ui4
-rw-r--r--src/plugins/android/androiddeploystep.cpp5
-rw-r--r--src/plugins/android/androidmanager.cpp4
-rw-r--r--src/plugins/android/androidmanifestdocument.cpp1
-rw-r--r--src/plugins/android/androidmanifesteditorfactory.cpp8
-rw-r--r--src/plugins/android/androidmanifesteditorfactory.h7
-rw-r--r--src/plugins/android/androidmanifesteditorwidget.cpp26
-rw-r--r--src/plugins/android/androidmanifesteditorwidget.h4
-rw-r--r--src/plugins/android/androidpotentialkit.cpp3
-rw-r--r--src/plugins/android/androidrunconfiguration.cpp8
-rw-r--r--src/plugins/android/androidrunconfiguration.h1
-rw-r--r--src/plugins/android/androidruncontrol.cpp2
-rw-r--r--src/plugins/android/androidrunner.cpp4
-rw-r--r--src/plugins/android/androidsettingspage.cpp13
-rw-r--r--src/plugins/android/androidsettingspage.h8
-rw-r--r--src/plugins/android/androidsettingswidget.cpp18
-rw-r--r--src/plugins/android/androidsettingswidget.h3
-rw-r--r--src/plugins/android/androidsettingswidget.ui4
-rw-r--r--src/plugins/android/javaparser.cpp33
-rw-r--r--src/plugins/android/javaparser.h6
-rw-r--r--src/plugins/autotoolsprojectmanager/autotoolsproject.cpp8
-rw-r--r--src/plugins/autotoolsprojectmanager/autotoolsproject.h1
-rw-r--r--src/plugins/bazaar/bazaar.pro9
-rw-r--r--src/plugins/bazaar/bazaar.qbs6
-rw-r--r--src/plugins/bazaar/bazaar_dependencies.pri1
-rw-r--r--src/plugins/bazaar/bazaarclient.cpp19
-rw-r--r--src/plugins/bazaar/bazaarclient.h3
-rw-r--r--src/plugins/bazaar/bazaarplugin.cpp23
-rw-r--r--src/plugins/bazaar/bazaarplugin.h8
-rw-r--r--src/plugins/bazaar/constants.h1
-rw-r--r--src/plugins/bazaar/optionspage.cpp30
-rw-r--r--src/plugins/bazaar/optionspage.h5
-rw-r--r--src/plugins/bazaar/uncommitdialog.cpp83
-rw-r--r--src/plugins/bazaar/uncommitdialog.h62
-rw-r--r--src/plugins/bazaar/uncommitdialog.ui104
-rw-r--r--src/plugins/bineditor/bineditor.qbs1
-rw-r--r--src/plugins/bineditor/bineditor_dependencies.pri1
-rw-r--r--src/plugins/bineditor/bineditorplugin.cpp43
-rw-r--r--src/plugins/bineditor/bineditorplugin.h2
-rw-r--r--src/plugins/bookmarks/bookmarks.qbs2
-rw-r--r--src/plugins/clangcodemodel/ClangCodeModel.pluginspec.in21
-rw-r--r--src/plugins/clangcodemodel/README65
-rw-r--r--src/plugins/clangcodemodel/clang_global.h (renamed from src/plugins/find/find_global.h)14
-rw-r--r--src/plugins/clangcodemodel/clang_installation.pri89
-rw-r--r--src/plugins/clangcodemodel/clangcodemodel.pro124
-rw-r--r--src/plugins/clangcodemodel/clangcodemodel.qbs189
-rw-r--r--src/plugins/clangcodemodel/clangcodemodel_dependencies.pri7
-rw-r--r--src/plugins/clangcodemodel/clangcodemodelplugin.cpp91
-rw-r--r--src/plugins/clangcodemodel/clangcodemodelplugin.h74
-rw-r--r--src/plugins/clangcodemodel/clangcompleter.cpp209
-rw-r--r--src/plugins/clangcodemodel/clangcompleter.h223
-rw-r--r--src/plugins/clangcodemodel/clangcompletion.cpp1221
-rw-r--r--src/plugins/clangcodemodel/clangcompletion.h144
-rw-r--r--src/plugins/clangcodemodel/clanghighlightingsupport.cpp99
-rw-r--r--src/plugins/clangcodemodel/clanghighlightingsupport.h69
-rw-r--r--src/plugins/clangcodemodel/clangindexer.cpp169
-rw-r--r--src/plugins/clangcodemodel/clangindexer.h (renamed from src/plugins/debugger/lldblib/lldbenginehost.h)84
-rw-r--r--src/plugins/clangcodemodel/clangmodelmanagersupport.cpp69
-rw-r--r--src/plugins/clangcodemodel/clangmodelmanagersupport.h64
-rw-r--r--src/plugins/clangcodemodel/clangprojectsettings.cpp108
-rw-r--r--src/plugins/clangcodemodel/clangprojectsettings.h (renamed from src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.h)55
-rw-r--r--src/plugins/clangcodemodel/clangprojectsettingspropertiespage.cpp165
-rw-r--r--src/plugins/clangcodemodel/clangprojectsettingspropertiespage.h72
-rw-r--r--src/plugins/clangcodemodel/clangprojectsettingspropertiespage.ui87
-rw-r--r--src/plugins/clangcodemodel/clangsymbolsearcher.cpp155
-rw-r--r--src/plugins/clangcodemodel/clangsymbolsearcher.h69
-rw-r--r--src/plugins/clangcodemodel/clangutils.cpp322
-rw-r--r--src/plugins/clangcodemodel/clangutils.h58
-rw-r--r--src/plugins/clangcodemodel/completionproposalsbuilder.cpp748
-rw-r--r--src/plugins/clangcodemodel/completionproposalsbuilder.h88
-rw-r--r--src/plugins/clangcodemodel/constants.h61
-rw-r--r--src/plugins/clangcodemodel/cppcreatemarkers.cpp201
-rw-r--r--src/plugins/clangcodemodel/cppcreatemarkers.h106
-rw-r--r--src/plugins/clangcodemodel/cxprettyprinter.cpp550
-rw-r--r--src/plugins/clangcodemodel/cxprettyprinter.h75
-rw-r--r--src/plugins/clangcodemodel/cxraii.h145
-rw-r--r--src/plugins/clangcodemodel/dependencygraph.cpp208
-rw-r--r--src/plugins/clangcodemodel/dependencygraph.h235
-rw-r--r--src/plugins/clangcodemodel/diagnostic.cpp63
-rw-r--r--src/plugins/clangcodemodel/diagnostic.h82
-rw-r--r--src/plugins/clangcodemodel/fastindexer.cpp (renamed from tests/manual/debugger/helper/main.cpp)17
-rw-r--r--src/plugins/clangcodemodel/fastindexer.h49
-rw-r--r--src/plugins/clangcodemodel/index.cpp491
-rw-r--r--src/plugins/clangcodemodel/index.h87
-rw-r--r--src/plugins/clangcodemodel/indexer.cpp1291
-rw-r--r--src/plugins/clangcodemodel/indexer.h103
-rw-r--r--src/plugins/clangcodemodel/pchinfo.cpp62
-rw-r--r--src/plugins/clangcodemodel/pchinfo.h80
-rw-r--r--src/plugins/clangcodemodel/pchmanager.cpp433
-rw-r--r--src/plugins/clangcodemodel/pchmanager.h100
-rw-r--r--src/plugins/clangcodemodel/raii/scopedclangoptions.cpp103
-rw-r--r--src/plugins/clangcodemodel/raii/scopedclangoptions.h (renamed from src/plugins/debugger/lldblib/lldboptionspage.h)56
-rw-r--r--src/plugins/clangcodemodel/semanticmarker.cpp505
-rw-r--r--src/plugins/clangcodemodel/semanticmarker.h86
-rw-r--r--src/plugins/clangcodemodel/sourcelocation.cpp79
-rw-r--r--src/plugins/clangcodemodel/sourcelocation.h69
-rw-r--r--src/plugins/clangcodemodel/sourcemarker.cpp41
-rw-r--r--src/plugins/clangcodemodel/sourcemarker.h97
-rw-r--r--src/plugins/clangcodemodel/symbol.cpp117
-rw-r--r--src/plugins/clangcodemodel/symbol.h (renamed from src/plugins/qtsupport/debugginghelper.h)53
-rw-r--r--src/plugins/clangcodemodel/test/clang_tests_database.qrc20
-rw-r--r--src/plugins/clangcodemodel/test/clangcompletion_test.cpp392
-rw-r--r--src/plugins/clangcodemodel/test/completiontesthelper.cpp148
-rw-r--r--src/plugins/clangcodemodel/test/completiontesthelper.h81
-rw-r--r--src/plugins/clangcodemodel/test/cxx_regression_1.cpp44
-rw-r--r--src/plugins/clangcodemodel/test/cxx_regression_2.cpp50
-rw-r--r--src/plugins/clangcodemodel/test/cxx_regression_3.cpp68
-rw-r--r--src/plugins/clangcodemodel/test/cxx_regression_4.cpp41
-rw-r--r--src/plugins/clangcodemodel/test/cxx_regression_5.cpp61
-rw-r--r--src/plugins/clangcodemodel/test/cxx_regression_6.cpp (renamed from src/plugins/locator/locator_global.h)27
-rw-r--r--src/plugins/clangcodemodel/test/cxx_regression_7.cpp47
-rw-r--r--src/plugins/clangcodemodel/test/cxx_regression_8.cpp46
-rw-r--r--src/plugins/clangcodemodel/test/cxx_regression_9.cpp54
-rw-r--r--src/plugins/clangcodemodel/test/cxx_snippets_1.cpp48
-rw-r--r--src/plugins/clangcodemodel/test/cxx_snippets_2.cpp44
-rw-r--r--src/plugins/clangcodemodel/test/cxx_snippets_3.cpp52
-rw-r--r--src/plugins/clangcodemodel/test/cxx_snippets_4.cpp (renamed from src/plugins/qmldesigner/components/propertyeditor/qlayoutobject.h)48
-rw-r--r--src/plugins/clangcodemodel/test/objc_messages_1.mm57
-rw-r--r--src/plugins/clangcodemodel/test/objc_messages_2.mm42
-rw-r--r--src/plugins/clangcodemodel/test/objc_messages_3.mm54
-rw-r--r--src/plugins/clangcodemodel/unit.cpp357
-rw-r--r--src/plugins/clangcodemodel/unit.h199
-rw-r--r--src/plugins/clangcodemodel/unsavedfiledata.cpp61
-rw-r--r--src/plugins/clangcodemodel/unsavedfiledata.h65
-rw-r--r--src/plugins/clangcodemodel/utils.cpp89
-rw-r--r--src/plugins/clangcodemodel/utils.h (renamed from src/plugins/qmlprofiler/canvas/qmlprofilercanvas.h)65
-rw-r--r--src/plugins/clangcodemodel/utils_p.cpp124
-rw-r--r--src/plugins/clangcodemodel/utils_p.h65
-rw-r--r--src/plugins/classview/classview.pro28
-rw-r--r--src/plugins/classview/classview.qbs32
-rw-r--r--src/plugins/clearcase/clearcase.qbs2
-rw-r--r--src/plugins/clearcase/clearcase_dependencies.pri1
-rw-r--r--src/plugins/clearcase/clearcasecontrol.cpp25
-rw-r--r--src/plugins/clearcase/clearcasecontrol.h2
-rw-r--r--src/plugins/clearcase/clearcaseplugin.cpp384
-rw-r--r--src/plugins/clearcase/clearcaseplugin.h32
-rw-r--r--src/plugins/clearcase/clearcasesync.cpp365
-rw-r--r--src/plugins/clearcase/clearcasesync.h26
-rw-r--r--src/plugins/clearcase/settingspage.cpp32
-rw-r--r--src/plugins/clearcase/settingspage.h10
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditor.cpp31
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditor.h14
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp7
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditorfactory.h5
-rw-r--r--src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp8
-rw-r--r--src/plugins/cmakeprojectmanager/cmakelocatorfilter.h8
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.cpp8
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.h1
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp29
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.h10
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs1
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri1
-rw-r--r--src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp10
-rw-r--r--src/plugins/cmakeprojectmanager/cmakerunconfiguration.h3
-rw-r--r--src/plugins/coreplugin/actionmanager/actionmanager.cpp2
-rw-r--r--src/plugins/coreplugin/actionmanager/commandmappings.cpp72
-rw-r--r--src/plugins/coreplugin/actionmanager/commandmappings.h4
-rw-r--r--src/plugins/coreplugin/coreplugin.cpp14
-rw-r--r--src/plugins/coreplugin/coreplugin.h12
-rw-r--r--src/plugins/coreplugin/coreplugin.pro5
-rw-r--r--src/plugins/coreplugin/coreplugin.qbs87
-rw-r--r--src/plugins/coreplugin/dialogs/ioptionspage.cpp61
-rw-r--r--src/plugins/coreplugin/dialogs/ioptionspage.h12
-rw-r--r--src/plugins/coreplugin/dialogs/newdialog.cpp2
-rw-r--r--src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp26
-rw-r--r--src/plugins/coreplugin/dialogs/settingsdialog.cpp37
-rw-r--r--src/plugins/coreplugin/dialogs/settingsdialog.h1
-rw-r--r--src/plugins/coreplugin/dialogs/shortcutsettings.cpp15
-rw-r--r--src/plugins/coreplugin/dialogs/shortcutsettings.h4
-rw-r--r--src/plugins/coreplugin/documentmanager.cpp5
-rw-r--r--src/plugins/coreplugin/documentmanager.h4
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp15
-rw-r--r--src/plugins/coreplugin/editormanager/ieditor.h2
-rw-r--r--src/plugins/coreplugin/editormanager/ieditorfactory.h2
-rw-r--r--src/plugins/coreplugin/editormanager/systemeditor.cpp2
-rw-r--r--src/plugins/coreplugin/editortoolbar.cpp6
-rw-r--r--src/plugins/coreplugin/find/basetextfind.cpp (renamed from src/plugins/find/basetextfind.cpp)4
-rw-r--r--src/plugins/coreplugin/find/basetextfind.h (renamed from src/plugins/find/basetextfind.h)9
-rw-r--r--src/plugins/coreplugin/find/currentdocumentfind.cpp (renamed from src/plugins/find/currentdocumentfind.cpp)4
-rw-r--r--src/plugins/coreplugin/find/currentdocumentfind.h (renamed from src/plugins/find/currentdocumentfind.h)4
-rw-r--r--src/plugins/coreplugin/find/find.pri42
-rw-r--r--src/plugins/coreplugin/find/find.qrc (renamed from src/plugins/find/find.qrc)0
-rw-r--r--src/plugins/coreplugin/find/finddialog.ui (renamed from src/plugins/find/finddialog.ui)4
-rw-r--r--src/plugins/coreplugin/find/findplugin.cpp394
-rw-r--r--src/plugins/coreplugin/find/findplugin.h (renamed from src/plugins/find/findplugin.h)25
-rw-r--r--src/plugins/coreplugin/find/findtoolbar.cpp (renamed from src/plugins/find/findtoolbar.cpp)9
-rw-r--r--src/plugins/coreplugin/find/findtoolbar.h (renamed from src/plugins/find/findtoolbar.h)6
-rw-r--r--src/plugins/coreplugin/find/findtoolwindow.cpp (renamed from src/plugins/find/findtoolwindow.cpp)4
-rw-r--r--src/plugins/coreplugin/find/findtoolwindow.h (renamed from src/plugins/find/findtoolwindow.h)6
-rw-r--r--src/plugins/coreplugin/find/findwidget.ui (renamed from src/plugins/find/findwidget.ui)4
-rw-r--r--src/plugins/coreplugin/find/ifindfilter.cpp (renamed from src/plugins/find/ifindfilter.cpp)20
-rw-r--r--src/plugins/coreplugin/find/ifindfilter.h (renamed from src/plugins/find/ifindfilter.h)7
-rw-r--r--src/plugins/coreplugin/find/ifindsupport.cpp (renamed from src/plugins/find/ifindsupport.cpp)4
-rw-r--r--src/plugins/coreplugin/find/ifindsupport.h (renamed from src/plugins/find/ifindsupport.h)7
-rw-r--r--src/plugins/coreplugin/find/images/all.png (renamed from src/plugins/find/images/all.png)bin108 -> 108 bytes
-rw-r--r--src/plugins/coreplugin/find/images/casesensitively.png (renamed from src/plugins/find/images/casesensitively.png)bin153 -> 153 bytes
-rw-r--r--src/plugins/coreplugin/find/images/empty.png (renamed from src/plugins/find/images/empty.png)bin75 -> 75 bytes
-rw-r--r--src/plugins/coreplugin/find/images/expand.png (renamed from src/plugins/find/images/expand.png)bin931 -> 931 bytes
-rw-r--r--src/plugins/coreplugin/find/images/next.png (renamed from src/plugins/find/images/next.png)bin109 -> 109 bytes
-rw-r--r--src/plugins/coreplugin/find/images/preservecase.png (renamed from src/plugins/find/images/preservecase.png)bin196 -> 196 bytes
-rw-r--r--src/plugins/coreplugin/find/images/previous.png (renamed from src/plugins/find/images/previous.png)bin103 -> 103 bytes
-rw-r--r--src/plugins/coreplugin/find/images/regexp.png (renamed from src/plugins/find/images/regexp.png)bin152 -> 152 bytes
-rw-r--r--src/plugins/coreplugin/find/images/replace_all.png (renamed from src/plugins/find/images/replace_all.png)bin934 -> 934 bytes
-rw-r--r--src/plugins/coreplugin/find/images/wholewords.png (renamed from src/plugins/find/images/wholewords.png)bin146 -> 146 bytes
-rw-r--r--src/plugins/coreplugin/find/images/wordandcase.png (renamed from src/plugins/find/images/wordandcase.png)bin198 -> 198 bytes
-rw-r--r--src/plugins/coreplugin/find/images/wrapindicator.png (renamed from src/plugins/find/images/wrapindicator.png)bin1949 -> 1949 bytes
-rw-r--r--src/plugins/coreplugin/find/searchresultcolor.h (renamed from src/plugins/find/searchresultcolor.h)4
-rw-r--r--src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp (renamed from src/plugins/find/searchresulttreeitemdelegate.cpp)2
-rw-r--r--src/plugins/coreplugin/find/searchresulttreeitemdelegate.h (renamed from src/plugins/find/searchresulttreeitemdelegate.h)4
-rw-r--r--src/plugins/coreplugin/find/searchresulttreeitemroles.h (renamed from src/plugins/find/searchresulttreeitemroles.h)4
-rw-r--r--src/plugins/coreplugin/find/searchresulttreeitems.cpp (renamed from src/plugins/find/searchresulttreeitems.cpp)4
-rw-r--r--src/plugins/coreplugin/find/searchresulttreeitems.h (renamed from src/plugins/find/searchresulttreeitems.h)4
-rw-r--r--src/plugins/coreplugin/find/searchresulttreemodel.cpp (renamed from src/plugins/find/searchresulttreemodel.cpp)4
-rw-r--r--src/plugins/coreplugin/find/searchresulttreemodel.h (renamed from src/plugins/find/searchresulttreemodel.h)4
-rw-r--r--src/plugins/coreplugin/find/searchresulttreeview.cpp (renamed from src/plugins/find/searchresulttreeview.cpp)4
-rw-r--r--src/plugins/coreplugin/find/searchresulttreeview.h (renamed from src/plugins/find/searchresulttreeview.h)4
-rw-r--r--src/plugins/coreplugin/find/searchresultwidget.cpp (renamed from src/plugins/find/searchresultwidget.cpp)11
-rw-r--r--src/plugins/coreplugin/find/searchresultwidget.h (renamed from src/plugins/find/searchresultwidget.h)6
-rw-r--r--src/plugins/coreplugin/find/searchresultwindow.cpp (renamed from src/plugins/find/searchresultwindow.cpp)27
-rw-r--r--src/plugins/coreplugin/find/searchresultwindow.h (renamed from src/plugins/find/searchresultwindow.h)23
-rw-r--r--src/plugins/coreplugin/find/textfindconstants.h (renamed from src/plugins/find/textfindconstants.h)12
-rw-r--r--src/plugins/coreplugin/find/treeviewfind.cpp (renamed from src/plugins/find/treeviewfind.cpp)4
-rw-r--r--src/plugins/coreplugin/find/treeviewfind.h (renamed from src/plugins/find/treeviewfind.h)6
-rw-r--r--src/plugins/coreplugin/generalsettings.cpp110
-rw-r--r--src/plugins/coreplugin/generalsettings.h4
-rw-r--r--src/plugins/coreplugin/idocument.h6
-rw-r--r--src/plugins/coreplugin/iversioncontrol.cpp57
-rw-r--r--src/plugins/coreplugin/iversioncontrol.h56
-rw-r--r--src/plugins/coreplugin/locator/basefilefilter.cpp (renamed from src/plugins/locator/basefilefilter.cpp)12
-rw-r--r--src/plugins/coreplugin/locator/basefilefilter.h (renamed from src/plugins/locator/basefilefilter.h)11
-rw-r--r--src/plugins/coreplugin/locator/commandlocator.cpp (renamed from src/plugins/locator/commandlocator.cpp)18
-rw-r--r--src/plugins/coreplugin/locator/commandlocator.h (renamed from src/plugins/locator/commandlocator.h)14
-rw-r--r--src/plugins/coreplugin/locator/directoryfilter.cpp (renamed from src/plugins/locator/directoryfilter.cpp)4
-rw-r--r--src/plugins/coreplugin/locator/directoryfilter.h (renamed from src/plugins/locator/directoryfilter.h)4
-rw-r--r--src/plugins/coreplugin/locator/directoryfilter.ui (renamed from src/plugins/locator/directoryfilter.ui)8
-rw-r--r--src/plugins/coreplugin/locator/executefilter.cpp (renamed from src/plugins/locator/executefilter.cpp)18
-rw-r--r--src/plugins/coreplugin/locator/executefilter.h (renamed from src/plugins/locator/executefilter.h)10
-rw-r--r--src/plugins/coreplugin/locator/filesystemfilter.cpp (renamed from src/plugins/locator/filesystemfilter.cpp)24
-rw-r--r--src/plugins/coreplugin/locator/filesystemfilter.h (renamed from src/plugins/locator/filesystemfilter.h)10
-rw-r--r--src/plugins/coreplugin/locator/filesystemfilter.ui (renamed from src/plugins/locator/filesystemfilter.ui)8
-rw-r--r--src/plugins/coreplugin/locator/ilocatorfilter.cpp (renamed from src/plugins/locator/ilocatorfilter.cpp)2
-rw-r--r--src/plugins/coreplugin/locator/ilocatorfilter.h (renamed from src/plugins/locator/ilocatorfilter.h)20
-rw-r--r--src/plugins/coreplugin/locator/images/locator.png (renamed from src/plugins/locator/images/locator.png)bin767 -> 767 bytes
-rw-r--r--src/plugins/coreplugin/locator/images/reload.png (renamed from src/plugins/locator/images/reload.png)bin735 -> 735 bytes
-rw-r--r--src/plugins/coreplugin/locator/locator.pri46
-rw-r--r--src/plugins/coreplugin/locator/locator.qrc (renamed from src/plugins/locator/locator.qrc)0
-rw-r--r--src/plugins/coreplugin/locator/locator_test.cpp (renamed from src/plugins/locator/locator_test.cpp)17
-rw-r--r--src/plugins/coreplugin/locator/locatorconstants.h (renamed from src/plugins/locator/locatorconstants.h)4
-rw-r--r--src/plugins/coreplugin/locator/locatorfiltersfilter.cpp (renamed from src/plugins/locator/locatorfiltersfilter.cpp)12
-rw-r--r--src/plugins/coreplugin/locator/locatorfiltersfilter.h (renamed from src/plugins/locator/locatorfiltersfilter.h)8
-rw-r--r--src/plugins/coreplugin/locator/locatorfiltertest.cpp (renamed from src/plugins/locator/locatorfiltertest.cpp)13
-rw-r--r--src/plugins/coreplugin/locator/locatorfiltertest.h (renamed from src/plugins/locator/locatorfiltertest.h)25
-rw-r--r--src/plugins/coreplugin/locator/locatormanager.cpp (renamed from src/plugins/locator/locatormanager.cpp)2
-rw-r--r--src/plugins/coreplugin/locator/locatormanager.h (renamed from src/plugins/locator/locatormanager.h)8
-rw-r--r--src/plugins/coreplugin/locator/locatorplugin.cpp261
-rw-r--r--src/plugins/coreplugin/locator/locatorplugin.h (renamed from src/plugins/locator/locatorplugin.h)16
-rw-r--r--src/plugins/coreplugin/locator/locatorsearchutils.cpp (renamed from src/plugins/locator/locatorsearchutils.cpp)12
-rw-r--r--src/plugins/coreplugin/locator/locatorsearchutils.h (renamed from src/plugins/locator/locatorsearchutils.h)7
-rw-r--r--src/plugins/coreplugin/locator/locatorwidget.cpp (renamed from src/plugins/locator/locatorwidget.cpp)32
-rw-r--r--src/plugins/coreplugin/locator/locatorwidget.h (renamed from src/plugins/locator/locatorwidget.h)6
-rw-r--r--src/plugins/coreplugin/locator/opendocumentsfilter.cpp (renamed from src/plugins/locator/opendocumentsfilter.cpp)16
-rw-r--r--src/plugins/coreplugin/locator/opendocumentsfilter.h (renamed from src/plugins/locator/opendocumentsfilter.h)10
-rw-r--r--src/plugins/coreplugin/locator/settingspage.cpp (renamed from src/plugins/locator/settingspage.cpp)67
-rw-r--r--src/plugins/coreplugin/locator/settingspage.h (renamed from src/plugins/locator/settingspage.h)17
-rw-r--r--src/plugins/coreplugin/locator/settingspage.ui (renamed from src/plugins/locator/settingspage.ui)4
-rw-r--r--src/plugins/coreplugin/mimetypesettings.cpp19
-rw-r--r--src/plugins/coreplugin/mimetypesettings.h3
-rw-r--r--src/plugins/coreplugin/progressmanager/progressmanager.cpp2
-rw-r--r--src/plugins/coreplugin/testdatadir.cpp2
-rw-r--r--src/plugins/coreplugin/testdatadir.h10
-rw-r--r--src/plugins/coreplugin/toolsettings.cpp16
-rw-r--r--src/plugins/coreplugin/toolsettings.h4
-rw-r--r--src/plugins/coreplugin/vcsmanager.cpp212
-rw-r--r--src/plugins/coreplugin/vcsmanager.h8
-rw-r--r--src/plugins/cpaster/cpasterplugin.cpp2
-rw-r--r--src/plugins/cpaster/fileshareprotocolsettingspage.cpp8
-rw-r--r--src/plugins/cpaster/fileshareprotocolsettingspage.h2
-rw-r--r--src/plugins/cpaster/settingspage.cpp16
-rw-r--r--src/plugins/cpaster/settingspage.h4
-rw-r--r--src/plugins/cppeditor/cppcodemodelinspectordialog.cpp2302
-rw-r--r--src/plugins/cppeditor/cppcodemodelinspectordialog.h129
-rw-r--r--src/plugins/cppeditor/cppcodemodelinspectordialog.ui381
-rw-r--r--src/plugins/cppeditor/cppdoxygen_test.cpp133
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp125
-rw-r--r--src/plugins/cppeditor/cppeditor.h13
-rw-r--r--src/plugins/cppeditor/cppeditor.pro66
-rw-r--r--src/plugins/cppeditor/cppeditor.qbs82
-rw-r--r--src/plugins/cppeditor/cppeditorconstants.h1
-rw-r--r--src/plugins/cppeditor/cppeditorplugin.cpp47
-rw-r--r--src/plugins/cppeditor/cppeditorplugin.h13
-rw-r--r--src/plugins/cppeditor/cppeditortestcase.cpp97
-rw-r--r--src/plugins/cppeditor/cppeditortestcase.h75
-rw-r--r--src/plugins/cppeditor/cppelementevaluator.cpp2
-rw-r--r--src/plugins/cppeditor/cppfollowsymbolundercursor.cpp12
-rw-r--r--src/plugins/cppeditor/cppincludehierarchy.cpp6
-rw-r--r--src/plugins/cppeditor/cppincludehierarchy_test.cpp71
-rw-r--r--src/plugins/cppeditor/cpppreprocessordialog.cpp7
-rw-r--r--src/plugins/cppeditor/cpppreprocessordialog.h4
-rw-r--r--src/plugins/cppeditor/cppquickfix_test.cpp953
-rw-r--r--src/plugins/cppeditor/cppquickfixassistant.cpp2
-rw-r--r--src/plugins/cppeditor/cppquickfixes.cpp154
-rw-r--r--src/plugins/cppeditor/cppquickfixes.h6
-rw-r--r--src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp224
-rw-r--r--src/plugins/cppeditor/cppvirtualfunctionassistprovider.h15
-rw-r--r--src/plugins/cppeditor/fileandtokenactions_test.cpp119
-rw-r--r--src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp322
-rw-r--r--src/plugins/cpptools/builtinindexingsupport.cpp12
-rw-r--r--src/plugins/cpptools/completionsettingspage.cpp111
-rw-r--r--src/plugins/cpptools/completionsettingspage.h7
-rw-r--r--src/plugins/cpptools/completionsettingspage.ui12
-rw-r--r--src/plugins/cpptools/cppclassesfilter.cpp4
-rw-r--r--src/plugins/cpptools/cppclassesfilter.h2
-rw-r--r--src/plugins/cpptools/cppcodegen_test.cpp51
-rw-r--r--src/plugins/cpptools/cppcodemodelsettings.cpp21
-rw-r--r--src/plugins/cpptools/cppcodemodelsettings.h6
-rw-r--r--src/plugins/cpptools/cppcodemodelsettingspage.cpp40
-rw-r--r--src/plugins/cpptools/cppcodemodelsettingspage.h8
-rw-r--r--src/plugins/cpptools/cppcodemodelsettingspage.ui10
-rw-r--r--src/plugins/cpptools/cppcodestylesettingspage.cpp67
-rw-r--r--src/plugins/cpptools/cppcodestylesettingspage.h8
-rw-r--r--src/plugins/cpptools/cppcompletion_test.cpp2503
-rw-r--r--src/plugins/cpptools/cppcompletionassist.cpp21
-rw-r--r--src/plugins/cpptools/cppcurrentdocumentfilter.cpp10
-rw-r--r--src/plugins/cpptools/cppcurrentdocumentfilter.h8
-rw-r--r--src/plugins/cpptools/cppfilesettingspage.cpp30
-rw-r--r--src/plugins/cpptools/cppfilesettingspage.h8
-rw-r--r--src/plugins/cpptools/cppfindreferences.cpp52
-rw-r--r--src/plugins/cpptools/cppfindreferences.h14
-rw-r--r--src/plugins/cpptools/cppfunctionsfilter.cpp4
-rw-r--r--src/plugins/cpptools/cppfunctionsfilter.h2
-rw-r--r--src/plugins/cpptools/cppheadersource_test.cpp4
-rw-r--r--src/plugins/cpptools/cpphighlightingsupport.h3
-rw-r--r--src/plugins/cpptools/cppindexingsupport.h8
-rw-r--r--src/plugins/cpptools/cpplocatorfilter.cpp18
-rw-r--r--src/plugins/cpptools/cpplocatorfilter.h10
-rw-r--r--src/plugins/cpptools/cpplocatorfilter_test.cpp129
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp47
-rw-r--r--src/plugins/cpptools/cppmodelmanager.h3
-rw-r--r--src/plugins/cpptools/cppmodelmanager_test.cpp93
-rw-r--r--src/plugins/cpptools/cppmodelmanagerinterface.cpp11
-rw-r--r--src/plugins/cpptools/cppmodelmanagerinterface.h7
-rw-r--r--src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp125
-rw-r--r--src/plugins/cpptools/cpppreprocessertesthelper.cpp11
-rw-r--r--src/plugins/cpptools/cpppreprocessertesthelper.h6
-rw-r--r--src/plugins/cpptools/cpppreprocessor_test.cpp11
-rw-r--r--src/plugins/cpptools/cppsnapshotupdater.cpp3
-rw-r--r--src/plugins/cpptools/cpptools.pro185
-rw-r--r--src/plugins/cpptools/cpptools.qbs162
-rw-r--r--src/plugins/cpptools/cpptools_dependencies.pri4
-rw-r--r--src/plugins/cpptools/cpptoolseditorsupport.cpp16
-rw-r--r--src/plugins/cpptools/cpptoolseditorsupport.h2
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.h110
-rw-r--r--src/plugins/cpptools/cpptoolstestcase.cpp179
-rw-r--r--src/plugins/cpptools/cpptoolstestcase.h102
-rw-r--r--src/plugins/cpptools/functionutils.cpp323
-rw-r--r--src/plugins/cpptools/functionutils.h68
-rw-r--r--src/plugins/cpptools/modelmanagertesthelper.cpp7
-rw-r--r--src/plugins/cpptools/modelmanagertesthelper.h4
-rw-r--r--src/plugins/cpptools/symbolsearcher_test.cpp89
-rw-r--r--src/plugins/cpptools/symbolsfindfilter.cpp52
-rw-r--r--src/plugins/cpptools/symbolsfindfilter.h18
-rw-r--r--src/plugins/cpptools/typehierarchybuilder.h3
-rw-r--r--src/plugins/cpptools/typehierarchybuilder_test.cpp107
-rw-r--r--src/plugins/cvs/checkoutwizard.cpp2
-rw-r--r--src/plugins/cvs/cvs.pro2
-rw-r--r--src/plugins/cvs/cvs.qbs4
-rw-r--r--src/plugins/cvs/cvs_dependencies.pri1
-rw-r--r--src/plugins/cvs/cvsclient.cpp182
-rw-r--r--src/plugins/cvs/cvsclient.h68
-rw-r--r--src/plugins/cvs/cvscontrol.cpp5
-rw-r--r--src/plugins/cvs/cvscontrol.h2
-rw-r--r--src/plugins/cvs/cvsplugin.cpp183
-rw-r--r--src/plugins/cvs/cvsplugin.h10
-rw-r--r--src/plugins/cvs/cvssettings.cpp83
-rw-r--r--src/plugins/cvs/cvssettings.h38
-rw-r--r--src/plugins/cvs/settingspage.cpp58
-rw-r--r--src/plugins/cvs/settingspage.h12
-rw-r--r--src/plugins/debugger/basewindow.cpp4
-rw-r--r--src/plugins/debugger/breakwindow.cpp1
-rw-r--r--src/plugins/debugger/cdb/cdbengine.cpp8
-rw-r--r--src/plugins/debugger/cdb/cdbengine.h1
-rw-r--r--src/plugins/debugger/cdb/cdboptionspage.cpp52
-rw-r--r--src/plugins/debugger/cdb/cdboptionspage.h10
-rw-r--r--src/plugins/debugger/commonoptionspage.cpp100
-rw-r--r--src/plugins/debugger/commonoptionspage.h10
-rw-r--r--src/plugins/debugger/debugger.pro7
-rw-r--r--src/plugins/debugger/debugger.qbs24
-rw-r--r--src/plugins/debugger/debugger_dependencies.pri1
-rw-r--r--src/plugins/debugger/debuggerconstants.h2
-rw-r--r--src/plugins/debugger/debuggercore.h1
-rw-r--r--src/plugins/debugger/debuggerdialogs.cpp1
-rw-r--r--src/plugins/debugger/debuggerengine.cpp2
-rw-r--r--src/plugins/debugger/debuggerengine.h4
-rw-r--r--src/plugins/debugger/debuggeritem.cpp8
-rw-r--r--src/plugins/debugger/debuggeritem.h4
-rw-r--r--src/plugins/debugger/debuggeroptionspage.cpp119
-rw-r--r--src/plugins/debugger/debuggeroptionspage.h7
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp31
-rw-r--r--src/plugins/debugger/debuggerprotocol.cpp6
-rw-r--r--src/plugins/debugger/debuggerrunner.cpp12
-rw-r--r--src/plugins/debugger/debuggersourcepathmappingwidget.cpp1
-rw-r--r--src/plugins/debugger/debuggerstartparameters.h2
-rw-r--r--src/plugins/debugger/disassembleragent.cpp10
-rw-r--r--src/plugins/debugger/dumper.pro24
-rw-r--r--src/plugins/debugger/gdb/attachgdbadapter.cpp2
-rw-r--r--src/plugins/debugger/gdb/attachgdbadapter.h2
-rw-r--r--src/plugins/debugger/gdb/classicgdbengine.cpp1535
-rw-r--r--src/plugins/debugger/gdb/coregdbadapter.h2
-rw-r--r--src/plugins/debugger/gdb/gdb.pri2
-rw-r--r--src/plugins/debugger/gdb/gdbengine.cpp979
-rw-r--r--src/plugins/debugger/gdb/gdbengine.h208
-rw-r--r--src/plugins/debugger/gdb/gdboptionspage.cpp65
-rw-r--r--src/plugins/debugger/gdb/gdboptionspage.h6
-rw-r--r--src/plugins/debugger/gdb/gdbplainengine.cpp7
-rw-r--r--src/plugins/debugger/gdb/gdbplainengine.h2
-rw-r--r--src/plugins/debugger/gdb/pythongdbengine.cpp227
-rw-r--r--src/plugins/debugger/gdb/remotegdbserveradapter.cpp12
-rw-r--r--src/plugins/debugger/gdb/remotegdbserveradapter.h2
-rw-r--r--src/plugins/debugger/gdb/termgdbadapter.cpp10
-rw-r--r--src/plugins/debugger/gdb/termgdbadapter.h2
-rw-r--r--src/plugins/debugger/lldb/lldbengine.cpp8
-rw-r--r--src/plugins/debugger/lldb/lldbengine.h2
-rw-r--r--src/plugins/debugger/lldblib/guest/README31
-rw-r--r--src/plugins/debugger/lldblib/guest/lldbengineguest.cpp761
-rw-r--r--src/plugins/debugger/lldblib/guest/lldbengineguest.h136
-rw-r--r--src/plugins/debugger/lldblib/guest/main.cpp151
-rw-r--r--src/plugins/debugger/lldblib/guest/qtcreator-lldb.plist21
-rw-r--r--src/plugins/debugger/lldblib/guest/qtcreator-lldb.pri2
-rw-r--r--src/plugins/debugger/lldblib/guest/qtcreator-lldb.pro61
-rw-r--r--src/plugins/debugger/lldblib/ipcengineguest.cpp637
-rw-r--r--src/plugins/debugger/lldblib/ipcengineguest.h191
-rw-r--r--src/plugins/debugger/lldblib/ipcenginehost.cpp661
-rw-r--r--src/plugins/debugger/lldblib/ipcenginehost.h140
-rw-r--r--src/plugins/debugger/lldblib/lldbenginehost.cpp232
-rw-r--r--src/plugins/debugger/lldblib/lldbhost.pri20
-rw-r--r--src/plugins/debugger/lldblib/lldboptionspage.cpp109
-rw-r--r--src/plugins/debugger/lldblib/lldboptionspagewidget.ui59
-rw-r--r--src/plugins/debugger/loadcoredialog.cpp3
-rw-r--r--src/plugins/debugger/localsandexpressionsoptionspage.ui4
-rw-r--r--src/plugins/debugger/logwindow.cpp27
-rw-r--r--src/plugins/debugger/moduleshandler.cpp4
-rw-r--r--src/plugins/debugger/qml/qmllivetextpreview.cpp4
-rw-r--r--src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp1
-rw-r--r--src/plugins/debugger/shared/peutils.cpp13
-rw-r--r--src/plugins/debugger/simplifytype.cpp301
-rw-r--r--src/plugins/debugger/simplifytype.h47
-rw-r--r--src/plugins/debugger/sourceagent.cpp4
-rw-r--r--src/plugins/debugger/stackwindow.cpp35
-rw-r--r--src/plugins/debugger/watchhandler.cpp82
-rw-r--r--src/plugins/debugger/watchhandler.h9
-rw-r--r--src/plugins/designer/cpp/cppsettingspage.cpp28
-rw-r--r--src/plugins/designer/cpp/cppsettingspage.h6
-rw-r--r--src/plugins/designer/designerxmleditorwidget.cpp8
-rw-r--r--src/plugins/designer/designerxmleditorwidget.h1
-rw-r--r--src/plugins/designer/formeditorfactory.cpp4
-rw-r--r--src/plugins/designer/formeditorfactory.h2
-rw-r--r--src/plugins/designer/formeditorw.h2
-rw-r--r--src/plugins/designer/formwindoweditor.h1
-rw-r--r--src/plugins/designer/gotoslot_test.cpp72
-rw-r--r--src/plugins/designer/qtcreatorintegration.cpp2
-rw-r--r--src/plugins/designer/settingspage.cpp48
-rw-r--r--src/plugins/designer/settingspage.h7
-rw-r--r--src/plugins/diffeditor/diffeditor.cpp5
-rw-r--r--src/plugins/diffeditor/diffeditor.h2
-rw-r--r--src/plugins/diffeditor/diffeditor.qbs1
-rw-r--r--src/plugins/diffeditor/diffeditorfactory.cpp4
-rw-r--r--src/plugins/diffeditor/diffeditorfactory.h2
-rw-r--r--src/plugins/diffeditor/diffeditorplugin.cpp6
-rw-r--r--src/plugins/diffeditor/diffeditorwidget.cpp10
-rw-r--r--src/plugins/diffeditor/diffeditorwidget.h4
-rw-r--r--src/plugins/diffeditor/diffshoweditorfactory.cpp4
-rw-r--r--src/plugins/diffeditor/diffshoweditorfactory.h2
-rw-r--r--src/plugins/fakevim/fakevim.qbs1
-rw-r--r--src/plugins/fakevim/fakevim_dependencies.pri3
-rw-r--r--src/plugins/fakevim/fakevim_test.cpp147
-rw-r--r--src/plugins/fakevim/fakevimhandler.cpp304
-rw-r--r--src/plugins/fakevim/fakevimhandler.h1
-rw-r--r--src/plugins/fakevim/fakevimoptions.ui4
-rw-r--r--src/plugins/fakevim/fakevimplugin.cpp269
-rw-r--r--src/plugins/fakevim/fakevimplugin.h1
-rw-r--r--src/plugins/find/Find.pluginspec.in3
-rw-r--r--src/plugins/find/find.pro37
-rw-r--r--src/plugins/find/find.qbs39
-rw-r--r--src/plugins/find/find_dependencies.pri6
-rw-r--r--src/plugins/find/findplugin.cpp398
-rw-r--r--src/plugins/genericprojectmanager/filesselectionwizardpage.cpp7
-rw-r--r--src/plugins/genericprojectmanager/filesselectionwizardpage.h7
-rw-r--r--src/plugins/genericprojectmanager/genericproject.cpp8
-rw-r--r--src/plugins/genericprojectmanager/genericproject.h4
-rw-r--r--src/plugins/genericprojectmanager/genericprojectfileseditor.cpp39
-rw-r--r--src/plugins/genericprojectmanager/genericprojectfileseditor.h23
-rw-r--r--src/plugins/genericprojectmanager/genericprojectmanager.pro2
-rw-r--r--src/plugins/genericprojectmanager/genericprojectmanager.qbs4
-rw-r--r--src/plugins/genericprojectmanager/genericprojectnodes.cpp1
-rw-r--r--src/plugins/genericprojectmanager/genericprojectplugin.cpp11
-rw-r--r--src/plugins/git/branchdialog.cpp15
-rw-r--r--src/plugins/git/changeselectiondialog.cpp53
-rw-r--r--src/plugins/git/changeselectiondialog.h5
-rw-r--r--src/plugins/git/changeselectiondialog.ui9
-rw-r--r--src/plugins/git/gerrit/gerritdialog.cpp1
-rw-r--r--src/plugins/git/gerrit/gerritoptionspage.cpp17
-rw-r--r--src/plugins/git/gerrit/gerritoptionspage.h5
-rw-r--r--src/plugins/git/gerrit/gerritplugin.cpp6
-rw-r--r--src/plugins/git/gerrit/gerritplugin.h5
-rw-r--r--src/plugins/git/gerrit/gerritpushdialog.cpp19
-rw-r--r--src/plugins/git/git.qbs2
-rw-r--r--src/plugins/git/git.qrc1
-rw-r--r--src/plugins/git/git_dependencies.pri1
-rw-r--r--src/plugins/git/gitclient.cpp245
-rw-r--r--src/plugins/git/gitclient.h33
-rw-r--r--src/plugins/git/giteditor.cpp4
-rw-r--r--src/plugins/git/gitplugin.cpp67
-rw-r--r--src/plugins/git/gitplugin.h7
-rw-r--r--src/plugins/git/gitsubmiteditorwidget.cpp2
-rw-r--r--src/plugins/git/images/arrowup.pngbin0 -> 376 bytes
-rw-r--r--src/plugins/git/logchangedialog.cpp65
-rw-r--r--src/plugins/git/logchangedialog.h31
-rw-r--r--src/plugins/git/settingspage.cpp34
-rw-r--r--src/plugins/git/settingspage.h14
-rw-r--r--src/plugins/glsleditor/glsleditor.cpp33
-rw-r--r--src/plugins/glsleditor/glsleditor.h3
-rw-r--r--src/plugins/glsleditor/glsleditoreditable.h2
-rw-r--r--src/plugins/glsleditor/glsleditorfactory.cpp13
-rw-r--r--src/plugins/glsleditor/glsleditorfactory.h2
-rw-r--r--src/plugins/glsleditor/glsleditorplugin.cpp18
-rw-r--r--src/plugins/glsleditor/glsleditorplugin.h2
-rw-r--r--src/plugins/help/centralwidget.cpp2
-rw-r--r--src/plugins/help/centralwidget.h4
-rw-r--r--src/plugins/help/docsettingspage.cpp35
-rw-r--r--src/plugins/help/docsettingspage.h9
-rw-r--r--src/plugins/help/filtersettingspage.cpp45
-rw-r--r--src/plugins/help/filtersettingspage.h7
-rw-r--r--src/plugins/help/generalsettingspage.cpp91
-rw-r--r--src/plugins/help/generalsettingspage.h7
-rw-r--r--src/plugins/help/help.qbs2
-rw-r--r--src/plugins/help/help_dependencies.pri4
-rw-r--r--src/plugins/help/helpfindsupport.cpp33
-rw-r--r--src/plugins/help/helpfindsupport.h22
-rw-r--r--src/plugins/help/helpindexfilter.cpp10
-rw-r--r--src/plugins/help/helpindexfilter.h8
-rw-r--r--src/plugins/help/helpplugin.cpp8
-rw-r--r--src/plugins/help/helpviewer.h4
-rw-r--r--src/plugins/help/helpviewer_qtb.cpp7
-rw-r--r--src/plugins/help/helpviewer_qwv.cpp8
-rw-r--r--src/plugins/help/remotehelpfilter.cpp8
-rw-r--r--src/plugins/help/remotehelpfilter.h8
-rw-r--r--src/plugins/imageviewer/imageviewerfactory.cpp4
-rw-r--r--src/plugins/imageviewer/imageviewerfactory.h2
-rw-r--r--src/plugins/ios/iosdeploystep.h20
-rw-r--r--src/plugins/ios/iossettingspage.cpp13
-rw-r--r--src/plugins/ios/iossettingspage.h8
-rw-r--r--src/plugins/ios/iossettingswidget.cpp8
-rw-r--r--src/plugins/ios/iossettingswidget.h3
-rw-r--r--src/plugins/locator/Locator.pluginspec.in3
-rw-r--r--src/plugins/locator/locator.pro41
-rw-r--r--src/plugins/locator/locator.qbs51
-rw-r--r--src/plugins/locator/locator_dependencies.pri3
-rw-r--r--src/plugins/locator/locatorplugin.cpp268
-rw-r--r--src/plugins/macros/findmacrohandler.cpp47
-rw-r--r--src/plugins/macros/findmacrohandler.h12
-rw-r--r--src/plugins/macros/macrolocatorfilter.cpp12
-rw-r--r--src/plugins/macros/macrolocatorfilter.h8
-rw-r--r--src/plugins/macros/macrooptionspage.cpp7
-rw-r--r--src/plugins/macros/macrooptionspage.h6
-rw-r--r--src/plugins/macros/macros.qbs2
-rw-r--r--src/plugins/macros/macros_dependencies.pri2
-rw-r--r--src/plugins/macros/macrotextfind.cpp22
-rw-r--r--src/plugins/macros/macrotextfind.h32
-rw-r--r--src/plugins/mercurial/mercurial.qbs2
-rw-r--r--src/plugins/mercurial/mercurial_dependencies.pri1
-rw-r--r--src/plugins/mercurial/mercurialplugin.cpp4
-rw-r--r--src/plugins/mercurial/mercurialplugin.h4
-rw-r--r--src/plugins/mercurial/optionspage.cpp28
-rw-r--r--src/plugins/mercurial/optionspage.h7
-rw-r--r--src/plugins/perforce/perforce.qbs2
-rw-r--r--src/plugins/perforce/perforce_dependencies.pri1
-rw-r--r--src/plugins/perforce/perforceplugin.cpp11
-rw-r--r--src/plugins/perforce/perforceplugin.h4
-rw-r--r--src/plugins/perforce/perforceversioncontrol.cpp3
-rw-r--r--src/plugins/perforce/perforceversioncontrol.h2
-rw-r--r--src/plugins/perforce/settingspage.cpp15
-rw-r--r--src/plugins/perforce/settingspage.h10
-rw-r--r--src/plugins/plugins.pro9
-rw-r--r--src/plugins/plugins.qbs1
-rw-r--r--src/plugins/projectexplorer/abstractprocessstep.cpp10
-rw-r--r--src/plugins/projectexplorer/allprojectsfilter.cpp1
-rw-r--r--src/plugins/projectexplorer/allprojectsfilter.h4
-rw-r--r--src/plugins/projectexplorer/allprojectsfind.cpp4
-rw-r--r--src/plugins/projectexplorer/appoutputpane.cpp12
-rw-r--r--src/plugins/projectexplorer/appoutputpane.h6
-rw-r--r--src/plugins/projectexplorer/clangparser.cpp21
-rw-r--r--src/plugins/projectexplorer/clangparser.h2
-rw-r--r--src/plugins/projectexplorer/compileoutputwindow.cpp4
-rw-r--r--src/plugins/projectexplorer/currentprojectfilter.cpp1
-rw-r--r--src/plugins/projectexplorer/currentprojectfilter.h4
-rw-r--r--src/plugins/projectexplorer/currentprojectfind.cpp3
-rw-r--r--src/plugins/projectexplorer/customtoolchain.cpp2
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizardpage.cpp2
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizardparameters.cpp1
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizardparameters.h1
-rw-r--r--src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.cpp4
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicesettingspage.cpp13
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicesettingspage.h8
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicesettingswidget.h2
-rw-r--r--src/plugins/projectexplorer/editorconfiguration.cpp40
-rw-r--r--src/plugins/projectexplorer/editorconfiguration.h7
-rw-r--r--src/plugins/projectexplorer/editorsettingspropertiespage.cpp8
-rw-r--r--src/plugins/projectexplorer/editorsettingspropertiespage.ui65
-rw-r--r--src/plugins/projectexplorer/foldernavigationwidget.cpp2
-rw-r--r--src/plugins/projectexplorer/gccparser.cpp32
-rw-r--r--src/plugins/projectexplorer/gccparser.h2
-rw-r--r--src/plugins/projectexplorer/gcctoolchain.cpp5
-rw-r--r--src/plugins/projectexplorer/importwidget.cpp1
-rw-r--r--src/plugins/projectexplorer/kit.cpp18
-rw-r--r--src/plugins/projectexplorer/kit.h2
-rw-r--r--src/plugins/projectexplorer/kitinformationconfigwidget.cpp1
-rw-r--r--src/plugins/projectexplorer/kitoptionspage.cpp136
-rw-r--r--src/plugins/projectexplorer/kitoptionspage.h7
-rw-r--r--src/plugins/projectexplorer/ldparser.cpp28
-rw-r--r--src/plugins/projectexplorer/linuxiccparser.cpp13
-rw-r--r--src/plugins/projectexplorer/localapplicationrunconfiguration.h2
-rw-r--r--src/plugins/projectexplorer/localapplicationruncontrol.cpp2
-rw-r--r--src/plugins/projectexplorer/msvcparser.cpp14
-rw-r--r--src/plugins/projectexplorer/msvcparser.h2
-rw-r--r--src/plugins/projectexplorer/osparser.h2
-rw-r--r--src/plugins/projectexplorer/processstep.cpp1
-rw-r--r--src/plugins/projectexplorer/project.cpp12
-rw-r--r--src/plugins/projectexplorer/project.h3
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp40
-rw-r--r--src/plugins/projectexplorer/projectexplorer.h1
-rw-r--r--src/plugins/projectexplorer/projectexplorer.pro6
-rw-r--r--src/plugins/projectexplorer/projectexplorer.qbs5
-rw-r--r--src/plugins/projectexplorer/projectexplorer_dependencies.pri2
-rw-r--r--src/plugins/projectexplorer/projectexplorerconstants.h7
-rw-r--r--src/plugins/projectexplorer/projectexplorersettingspage.cpp46
-rw-r--r--src/plugins/projectexplorer/projectexplorersettingspage.h7
-rw-r--r--src/plugins/projectexplorer/projectnodes.h3
-rw-r--r--src/plugins/projectexplorer/selectablefilesmodel.cpp (renamed from src/plugins/genericprojectmanager/selectablefilesmodel.cpp)160
-rw-r--r--src/plugins/projectexplorer/selectablefilesmodel.h (renamed from src/plugins/genericprojectmanager/selectablefilesmodel.h)53
-rw-r--r--src/plugins/projectexplorer/settingsaccessor.cpp2
-rw-r--r--src/plugins/projectexplorer/targetselector.cpp4
-rw-r--r--src/plugins/projectexplorer/targetselector.h2
-rw-r--r--src/plugins/projectexplorer/targetsettingspanel.cpp8
-rw-r--r--src/plugins/projectexplorer/targetsettingswidget.cpp4
-rw-r--r--src/plugins/projectexplorer/targetsettingswidget.h2
-rw-r--r--src/plugins/projectexplorer/targetsetuppage.cpp8
-rw-r--r--src/plugins/projectexplorer/targetsetupwidget.cpp1
-rw-r--r--src/plugins/projectexplorer/task.cpp20
-rw-r--r--src/plugins/projectexplorer/task.h4
-rw-r--r--src/plugins/projectexplorer/taskhub.cpp18
-rw-r--r--src/plugins/projectexplorer/taskhub.h2
-rw-r--r--src/plugins/projectexplorer/taskmodel.cpp2
-rw-r--r--src/plugins/projectexplorer/taskwindow.cpp6
-rw-r--r--src/plugins/projectexplorer/toolchainoptionspage.cpp161
-rw-r--r--src/plugins/projectexplorer/toolchainoptionspage.h7
-rw-r--r--src/plugins/pythoneditor/pythoneditor.cpp10
-rw-r--r--src/plugins/pythoneditor/pythoneditor.h2
-rw-r--r--src/plugins/pythoneditor/pythoneditorfactory.cpp12
-rw-r--r--src/plugins/pythoneditor/pythoneditorfactory.h2
-rw-r--r--src/plugins/pythoneditor/pythoneditorplugin.cpp15
-rw-r--r--src/plugins/pythoneditor/pythoneditorplugin.h4
-rw-r--r--src/plugins/pythoneditor/pythoneditorwidget.cpp15
-rw-r--r--src/plugins/pythoneditor/pythoneditorwidget.h3
-rw-r--r--src/plugins/qbsprojectmanager/qbsbuildstep.cpp29
-rw-r--r--src/plugins/qbsprojectmanager/qbsbuildstep.h3
-rw-r--r--src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui7
-rw-r--r--src/plugins/qbsprojectmanager/qbsinstallstep.cpp1
-rw-r--r--src/plugins/qbsprojectmanager/qbsproject.cpp24
-rw-r--r--src/plugins/qbsprojectmanager/qbsproject.h4
-rw-r--r--src/plugins/qbsprojectmanager/qbsprojectmanager.pro4
-rw-r--r--src/plugins/qbsprojectmanager/qbsprojectmanager.qbs4
-rw-r--r--src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp2
-rw-r--r--src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp11
-rw-r--r--src/plugins/qbsprojectmanager/qbsrunconfiguration.h2
-rw-r--r--src/plugins/qbsprojectmanager/qbsstep.cpp242
-rw-r--r--src/plugins/qbsprojectmanager/qbsstep.h108
-rw-r--r--src/plugins/qmakeprojectmanager/customwidgetwizard/classdefinition.cpp1
-rw-r--r--src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp11
-rw-r--r--src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h2
-rw-r--r--src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp3
-rw-r--r--src/plugins/qmakeprojectmanager/makestep.cpp2
-rw-r--r--src/plugins/qmakeprojectmanager/profileeditor.cpp27
-rw-r--r--src/plugins/qmakeprojectmanager/profileeditor.h18
-rw-r--r--src/plugins/qmakeprojectmanager/profileeditorfactory.cpp13
-rw-r--r--src/plugins/qmakeprojectmanager/profileeditorfactory.h7
-rw-r--r--src/plugins/qmakeprojectmanager/qmakenodes.cpp2
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeparser.cpp1
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeparser.h6
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeproject.cpp8
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeproject.h1
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeprojectconfigwidget.cpp1
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp58
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeprojectmanager.h7
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp7
-rw-r--r--src/plugins/qmakeprojectmanager/wizards/abstractmobileapp.h2
-rw-r--r--src/plugins/qmakeprojectmanager/wizards/abstractmobileappwizard.cpp1
-rw-r--r--src/plugins/qmakeprojectmanager/wizards/consoleappwizarddialog.cpp2
-rw-r--r--src/plugins/qmakeprojectmanager/wizards/html5appwizard.cpp2
-rw-r--r--src/plugins/qmakeprojectmanager/wizards/html5appwizardpages.cpp1
-rw-r--r--src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp2
-rw-r--r--src/plugins/qmakeprojectmanager/wizards/qtquickapp.cpp18
-rw-r--r--src/plugins/qmakeprojectmanager/wizards/qtquickapp.h4
-rw-r--r--src/plugins/qmakeprojectmanager/wizards/qtquickappwizard.cpp2
-rw-r--r--src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.cpp2
-rw-r--r--src/plugins/qmakeprojectmanager/wizards/testwizarddialog.cpp2
-rw-r--r--src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp19
-rw-r--r--src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.cpp2
-rw-r--r--src/plugins/qmldesigner/components/formeditor/contentnoteditableindicator.cpp20
-rw-r--r--src/plugins/qmldesigner/components/formeditor/contentnoteditableindicator.h1
-rw-r--r--src/plugins/qmldesigner/components/formeditor/dragtool.cpp2
-rw-r--r--src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp52
-rw-r--r--src/plugins/qmldesigner/components/formeditor/formeditoritem.h6
-rw-r--r--src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp4
-rw-r--r--src/plugins/qmldesigner/components/formeditor/movetool.cpp2
-rw-r--r--src/plugins/qmldesigner/components/formeditor/resizemanipulator.cpp2
-rw-r--r--src/plugins/qmldesigner/components/formeditor/selectionindicator.cpp8
-rw-r--r--src/plugins/qmldesigner/components/formeditor/selectiontool.cpp1
-rw-r--r--src/plugins/qmldesigner/components/integration/designdocument.cpp6
-rw-r--r--src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp2
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/filewidget.cpp184
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/filewidget.h128
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/fontwidget.cpp172
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/fontwidget.h102
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.cpp188
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp6
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/originwidget.cpp141
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri10
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditortransaction.cpp2
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp11
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h5
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp14
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp36
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.cpp114
-rw-r--r--src/plugins/qmldesigner/designercore/designercore-lib.pri1
-rw-r--r--src/plugins/qmldesigner/designercore/include/abstractview.h2
-rw-r--r--src/plugins/qmldesigner/designercore/include/variantproperty.h6
-rw-r--r--src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp155
-rw-r--r--src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h2
-rw-r--r--src/plugins/qmldesigner/designercore/model/abstractview.cpp4
-rw-r--r--src/plugins/qmldesigner/designercore/model/import.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/model/modelmerger.cpp4
-rw-r--r--src/plugins/qmldesigner/designercore/model/qmlanchors.cpp8
-rw-r--r--src/plugins/qmldesigner/designercore/model/qmlchangeset.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp4
-rw-r--r--src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp5
-rw-r--r--src/plugins/qmldesigner/designercore/model/rewriterview.cpp2
-rw-r--r--src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp5
-rw-r--r--src/plugins/qmldesigner/designercore/model/variantproperty.cpp22
-rw-r--r--src/plugins/qmldesigner/designercore/rewritertransaction.cpp33
-rw-r--r--src/plugins/qmldesigner/designercore/rewritertransaction.h6
-rw-r--r--src/plugins/qmldesigner/qmldesignerplugin.cpp13
-rw-r--r--src/plugins/qmldesigner/qmldesignerplugin.h3
-rw-r--r--src/plugins/qmldesigner/settingspage.cpp26
-rw-r--r--src/plugins/qmldesigner/settingspage.h11
-rw-r--r--src/plugins/qmldesigner/settingspage.ui4
-rw-r--r--src/plugins/qmljseditor/qmljscomponentnamedialog.cpp1
-rw-r--r--src/plugins/qmljseditor/qmljseditor.cpp55
-rw-r--r--src/plugins/qmljseditor/qmljseditor.h4
-rw-r--r--src/plugins/qmljseditor/qmljseditor.qbs1
-rw-r--r--src/plugins/qmljseditor/qmljseditor_dependencies.pri1
-rw-r--r--src/plugins/qmljseditor/qmljseditoreditable.h2
-rw-r--r--src/plugins/qmljseditor/qmljseditorfactory.cpp14
-rw-r--r--src/plugins/qmljseditor/qmljseditorfactory.h2
-rw-r--r--src/plugins/qmljseditor/qmljseditorplugin.cpp29
-rw-r--r--src/plugins/qmljseditor/qmljseditorplugin.h7
-rw-r--r--src/plugins/qmljseditor/qmljsfindreferences.cpp26
-rw-r--r--src/plugins/qmljseditor/qmljsfindreferences.h10
-rw-r--r--src/plugins/qmljseditor/qmljsquickfixassist.cpp2
-rw-r--r--src/plugins/qmljseditor/qmljssemantichighlighter.cpp4
-rw-r--r--src/plugins/qmljseditor/quicktoolbarsettingspage.cpp24
-rw-r--r--src/plugins/qmljseditor/quicktoolbarsettingspage.h10
-rw-r--r--src/plugins/qmljstools/qmlconsolepane.cpp4
-rw-r--r--src/plugins/qmljstools/qmljscodestylesettingspage.cpp38
-rw-r--r--src/plugins/qmljstools/qmljscodestylesettingspage.h7
-rw-r--r--src/plugins/qmljstools/qmljsfunctionfilter.cpp16
-rw-r--r--src/plugins/qmljstools/qmljsfunctionfilter.h8
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.cpp2
-rw-r--r--src/plugins/qmljstools/qmljstools.qbs1
-rw-r--r--src/plugins/qmljstools/qmljstools_dependencies.pri2
-rw-r--r--src/plugins/qmlprofiler/abstracttimelinemodel.cpp20
-rw-r--r--src/plugins/qmlprofiler/abstracttimelinemodel.h7
-rw-r--r--src/plugins/qmlprofiler/canvas/canvas.pri9
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecanvas.cpp242
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecanvas_p.h107
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer.cpp85
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp1134
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecontext2d_p.h326
-rw-r--r--src/plugins/qmlprofiler/canvas/qmlprofilercanvas.cpp105
-rw-r--r--src/plugins/qmlprofiler/qml/CategoryLabel.qml2
-rw-r--r--src/plugins/qmlprofiler/qml/Detail.qml31
-rw-r--r--src/plugins/qmlprofiler/qml/HorizontalGradientBorder.qml40
-rw-r--r--src/plugins/qmlprofiler/qml/MainView.qml80
-rw-r--r--src/plugins/qmlprofiler/qml/Overview.js1
-rw-r--r--src/plugins/qmlprofiler/qml/Overview.qml13
-rw-r--r--src/plugins/qmlprofiler/qml/RangeDetails.qml17
-rw-r--r--src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml35
-rw-r--r--src/plugins/qmlprofiler/qml/TimeDisplay.qml61
-rw-r--r--src/plugins/qmlprofiler/qml/TimeMarks.qml61
-rw-r--r--src/plugins/qmlprofiler/qml/VerticalGradientBorder.qml45
-rw-r--r--src/plugins/qmlprofiler/qml/qmlprofiler.qrc2
-rw-r--r--src/plugins/qmlprofiler/qmlprofiler.pro11
-rw-r--r--src/plugins/qmlprofiler/qmlprofiler.qbs14
-rw-r--r--src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp6
-rw-r--r--src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp4
-rw-r--r--src/plugins/qmlprofiler/qmlprofilermodelmanager.h1
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp169
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h6
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp267
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h18
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertool.cpp8
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertraceview.cpp12
-rw-r--r--src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp2
-rw-r--r--src/plugins/qmlprofiler/qv8profilerdatamodel.cpp12
-rw-r--r--src/plugins/qmlprofiler/sortedtimelinemodel.cpp110
-rw-r--r--src/plugins/qmlprofiler/sortedtimelinemodel.h187
-rw-r--r--src/plugins/qmlprojectmanager/qmlapp.cpp4
-rw-r--r--src/plugins/qmlprojectmanager/qmlapp.h1
-rw-r--r--src/plugins/qmlprojectmanager/qmlproject.cpp6
-rw-r--r--src/plugins/qmlprojectmanager/qmlproject.h1
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectnodes.cpp6
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp10
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h2
-rw-r--r--src/plugins/qnx/bardescriptoreditor.cpp39
-rw-r--r--src/plugins/qnx/bardescriptoreditor.h9
-rw-r--r--src/plugins/qnx/bardescriptoreditorfactory.cpp18
-rw-r--r--src/plugins/qnx/bardescriptoreditorfactory.h10
-rw-r--r--src/plugins/qnx/bardescriptoreditorwidget.cpp20
-rw-r--r--src/plugins/qnx/bardescriptoreditorwidget.h8
-rw-r--r--src/plugins/qnx/blackberrycertificate.cpp2
-rw-r--r--src/plugins/qnx/blackberrycheckdebugtokenstep.cpp156
-rw-r--r--src/plugins/qnx/blackberrycheckdebugtokenstep.h77
-rw-r--r--src/plugins/qnx/blackberrycheckdebugtokenstepconfigwidget.cpp (renamed from src/plugins/qnx/blackberrycheckdevmodestepconfigwidget.cpp)12
-rw-r--r--src/plugins/qnx/blackberrycheckdebugtokenstepconfigwidget.h (renamed from src/plugins/qnx/blackberrycheckdevmodestepconfigwidget.h)8
-rw-r--r--src/plugins/qnx/blackberrycheckdebugtokenstepfactory.cpp (renamed from src/plugins/qnx/blackberrycheckdevmodestepfactory.cpp)34
-rw-r--r--src/plugins/qnx/blackberrycheckdebugtokenstepfactory.h (renamed from src/plugins/qnx/blackberrycheckdevmodestepfactory.h)8
-rw-r--r--src/plugins/qnx/blackberrycheckdevmodestep.cpp110
-rw-r--r--src/plugins/qnx/blackberryconfiguration.cpp166
-rw-r--r--src/plugins/qnx/blackberryconfiguration.h15
-rw-r--r--src/plugins/qnx/blackberryconfigurationmanager.cpp284
-rw-r--r--src/plugins/qnx/blackberryconfigurationmanager.h24
-rw-r--r--src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp24
-rw-r--r--src/plugins/qnx/blackberrydeployconfigurationfactory.cpp4
-rw-r--r--src/plugins/qnx/blackberrydeviceconnection.cpp2
-rw-r--r--src/plugins/qnx/blackberrydeviceinformation.cpp13
-rw-r--r--src/plugins/qnx/blackberrydeviceinformation.h2
-rw-r--r--src/plugins/qnx/blackberrydevicelistdetector.cpp2
-rw-r--r--src/plugins/qnx/blackberryinstallwizardpages.cpp2
-rw-r--r--src/plugins/qnx/blackberrykeyspage.cpp6
-rw-r--r--src/plugins/qnx/blackberrykeyspage.h6
-rw-r--r--src/plugins/qnx/blackberrykeyswidget.cpp25
-rw-r--r--src/plugins/qnx/blackberryndkprocess.cpp6
-rw-r--r--src/plugins/qnx/blackberryndkprocess.h1
-rw-r--r--src/plugins/qnx/blackberryndksettingspage.cpp11
-rw-r--r--src/plugins/qnx/blackberryndksettingspage.h6
-rw-r--r--src/plugins/qnx/blackberryndksettingswidget.cpp166
-rw-r--r--src/plugins/qnx/blackberryndksettingswidget.h6
-rw-r--r--src/plugins/qnx/blackberryndksettingswidget.ui322
-rw-r--r--src/plugins/qnx/blackberrysetupwizard.cpp14
-rw-r--r--src/plugins/qnx/blackberrysetupwizardkeyspage.ui131
-rw-r--r--src/plugins/qnx/blackberrysetupwizardpages.cpp4
-rw-r--r--src/plugins/qnx/blackberrysigningutils.cpp39
-rw-r--r--src/plugins/qnx/blackberrysigningutils.h8
-rw-r--r--src/plugins/qnx/blackberryversionnumber.cpp125
-rw-r--r--src/plugins/qnx/blackberryversionnumber.h (renamed from src/plugins/qnx/blackberrycheckdevmodestep.h)33
-rw-r--r--src/plugins/qnx/cascadesimport/cascadesimport.pri2
-rw-r--r--src/plugins/qnx/cascadesimport/cascadesimportwizard.h2
-rw-r--r--src/plugins/qnx/cascadesimport/srcprojectpathchooser.cpp77
-rw-r--r--src/plugins/qnx/cascadesimport/srcprojectpathchooser.h53
-rw-r--r--src/plugins/qnx/cascadesimport/srcprojectwizardpage.ui10
-rw-r--r--src/plugins/qnx/qnx.pro18
-rw-r--r--src/plugins/qnx/qnx.qbs16
-rw-r--r--src/plugins/qnx/qnxconstants.h4
-rw-r--r--src/plugins/qnx/qnxplugin.cpp5
-rw-r--r--src/plugins/qnx/qnxutils.cpp3
-rw-r--r--src/plugins/qnx/qnxutils.h4
-rw-r--r--src/plugins/qtsupport/baseqtversion.cpp35
-rw-r--r--src/plugins/qtsupport/baseqtversion.h5
-rw-r--r--src/plugins/qtsupport/customexecutableconfigurationwidget.cpp2
-rw-r--r--src/plugins/qtsupport/customexecutablerunconfiguration.cpp10
-rw-r--r--src/plugins/qtsupport/customexecutablerunconfiguration.h2
-rw-r--r--src/plugins/qtsupport/debugginghelper.cpp113
-rw-r--r--src/plugins/qtsupport/debugginghelper.ui30
-rw-r--r--src/plugins/qtsupport/debugginghelperbuildtask.cpp20
-rw-r--r--src/plugins/qtsupport/debugginghelperbuildtask.h3
-rw-r--r--src/plugins/qtsupport/gettingstartedwelcomepage.cpp18
-rw-r--r--src/plugins/qtsupport/qtkitinformation.cpp16
-rw-r--r--src/plugins/qtsupport/qtkitinformation.h5
-rw-r--r--src/plugins/qtsupport/qtoptionspage.cpp60
-rw-r--r--src/plugins/qtsupport/qtoptionspage.h15
-rw-r--r--src/plugins/qtsupport/qtparser.cpp32
-rw-r--r--src/plugins/qtsupport/qtparser.h1
-rw-r--r--src/plugins/qtsupport/qtsupport.pro2
-rw-r--r--src/plugins/qtsupport/qtsupport.qbs2
-rw-r--r--src/plugins/qtsupport/qtversionmanager.cpp5
-rw-r--r--src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp1
-rw-r--r--src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp1
-rw-r--r--src/plugins/resourceeditor/resourceeditor.qbs1
-rw-r--r--src/plugins/resourceeditor/resourceeditor_dependencies.pri1
-rw-r--r--src/plugins/resourceeditor/resourceeditorfactory.cpp4
-rw-r--r--src/plugins/resourceeditor/resourceeditorfactory.h2
-rw-r--r--src/plugins/resourceeditor/resourceeditorw.cpp6
-rw-r--r--src/plugins/subversion/checkoutwizard.cpp3
-rw-r--r--src/plugins/subversion/settingspage.cpp35
-rw-r--r--src/plugins/subversion/settingspage.h10
-rw-r--r--src/plugins/subversion/subversion.pro2
-rw-r--r--src/plugins/subversion/subversion.qbs4
-rw-r--r--src/plugins/subversion/subversion_dependencies.pri1
-rw-r--r--src/plugins/subversion/subversionclient.cpp216
-rw-r--r--src/plugins/subversion/subversionclient.h82
-rw-r--r--src/plugins/subversion/subversionplugin.cpp185
-rw-r--r--src/plugins/subversion/subversionplugin.h30
-rw-r--r--src/plugins/subversion/subversionsettings.cpp2
-rw-r--r--src/plugins/subversion/subversionsettings.h1
-rw-r--r--src/plugins/tasklist/tasklist.qbs2
-rw-r--r--src/plugins/texteditor/basefilefind.cpp71
-rw-r--r--src/plugins/texteditor/basefilefind.h32
-rw-r--r--src/plugins/texteditor/basefilefind_p.h4
-rw-r--r--src/plugins/texteditor/basetextdocument.cpp17
-rw-r--r--src/plugins/texteditor/basetextdocument.h5
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp228
-rw-r--r--src/plugins/texteditor/basetexteditor.h49
-rw-r--r--src/plugins/texteditor/basetexteditor_p.h12
-rw-r--r--src/plugins/texteditor/basetextmark.cpp23
-rw-r--r--src/plugins/texteditor/behaviorsettingspage.cpp54
-rw-r--r--src/plugins/texteditor/behaviorsettingspage.h3
-rw-r--r--src/plugins/texteditor/behaviorsettingswidget.cpp29
-rw-r--r--src/plugins/texteditor/behaviorsettingswidget.h2
-rw-r--r--src/plugins/texteditor/behaviorsettingswidget.ui8
-rw-r--r--src/plugins/texteditor/circularclipboardassist.cpp3
-rw-r--r--src/plugins/texteditor/codeassist/basicproposalitem.cpp2
-rw-r--r--src/plugins/texteditor/codeassist/codeassistant.cpp8
-rw-r--r--src/plugins/texteditor/displaysettings.cpp10
-rw-r--r--src/plugins/texteditor/displaysettings.h2
-rw-r--r--src/plugins/texteditor/displaysettingspage.cpp69
-rw-r--r--src/plugins/texteditor/displaysettingspage.h10
-rw-r--r--src/plugins/texteditor/findincurrentfile.cpp4
-rw-r--r--src/plugins/texteditor/findinfiles.cpp8
-rw-r--r--src/plugins/texteditor/findinfiles.h2
-rw-r--r--src/plugins/texteditor/findinopenfiles.cpp4
-rw-r--r--src/plugins/texteditor/fontsettingspage.cpp76
-rw-r--r--src/plugins/texteditor/fontsettingspage.h3
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp60
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightersettingspage.h3
-rw-r--r--src/plugins/texteditor/itexteditor.cpp6
-rw-r--r--src/plugins/texteditor/itexteditor.h17
-rw-r--r--src/plugins/texteditor/linenumberfilter.cpp9
-rw-r--r--src/plugins/texteditor/linenumberfilter.h8
-rw-r--r--src/plugins/texteditor/marginsettings.cpp89
-rw-r--r--src/plugins/texteditor/marginsettings.h67
-rw-r--r--src/plugins/texteditor/plaintexteditor.cpp43
-rw-r--r--src/plugins/texteditor/plaintexteditor.h9
-rw-r--r--src/plugins/texteditor/plaintexteditorfactory.cpp18
-rw-r--r--src/plugins/texteditor/plaintexteditorfactory.h8
-rw-r--r--src/plugins/texteditor/refactoringchanges.cpp2
-rw-r--r--src/plugins/texteditor/simplecodestylepreferenceswidget.cpp5
-rw-r--r--src/plugins/texteditor/simplecodestylepreferenceswidget.h1
-rw-r--r--src/plugins/texteditor/snippets/snippeteditor.h2
-rw-r--r--src/plugins/texteditor/snippets/snippetssettingspage.cpp27
-rw-r--r--src/plugins/texteditor/snippets/snippetssettingspage.h3
-rw-r--r--src/plugins/texteditor/tabsettingswidget.cpp15
-rw-r--r--src/plugins/texteditor/tabsettingswidget.h1
-rw-r--r--src/plugins/texteditor/texteditor.pro6
-rw-r--r--src/plugins/texteditor/texteditor.qbs9
-rw-r--r--src/plugins/texteditor/texteditor_dependencies.pri2
-rw-r--r--src/plugins/texteditor/texteditoractionhandler.cpp138
-rw-r--r--src/plugins/texteditor/texteditoractionhandler.h28
-rw-r--r--src/plugins/texteditor/texteditorplugin.cpp15
-rw-r--r--src/plugins/texteditor/texteditorplugin.h6
-rw-r--r--src/plugins/texteditor/texteditorsettings.cpp11
-rw-r--r--src/plugins/texteditor/texteditorsettings.h3
-rw-r--r--src/plugins/todo/optionsdialog.ui4
-rw-r--r--src/plugins/todo/optionspage.cpp20
-rw-r--r--src/plugins/todo/optionspage.h7
-rwxr-xr-xsrc/plugins/todo/todooutputpane.cpp8
-rw-r--r--src/plugins/updateinfo/settingspage.cpp24
-rw-r--r--src/plugins/updateinfo/settingspage.h8
-rw-r--r--src/plugins/valgrind/suppressiondialog.cpp1
-rw-r--r--src/plugins/valgrind/valgrindconfigwidget.cpp1
-rw-r--r--src/plugins/valgrind/valgrindplugin.cpp20
-rw-r--r--src/plugins/vcsbase/basecheckoutwizardpage.cpp1
-rw-r--r--src/plugins/vcsbase/basevcseditorfactory.cpp17
-rw-r--r--src/plugins/vcsbase/basevcseditorfactory.h6
-rw-r--r--src/plugins/vcsbase/basevcssubmiteditorfactory.cpp4
-rw-r--r--src/plugins/vcsbase/basevcssubmiteditorfactory.h6
-rw-r--r--src/plugins/vcsbase/commonsettingspage.cpp19
-rw-r--r--src/plugins/vcsbase/commonsettingspage.h9
-rw-r--r--src/plugins/vcsbase/vcsbase.qbs1
-rw-r--r--src/plugins/vcsbase/vcsbase_dependencies.pri1
-rw-r--r--src/plugins/vcsbase/vcsbaseclient.cpp2
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.cpp7
-rw-r--r--src/plugins/vcsbase/vcsbaseplugin.cpp15
-rw-r--r--src/plugins/vcsbase/vcsbaseplugin.h6
-rw-r--r--src/plugins/vcsbase/vcsbasesubmiteditor.cpp4
-rw-r--r--src/qtcreatorplugin.pri10
-rw-r--r--src/qtcreatorplugin2json.xsl (renamed from src/pluginjsonmetadata.xsl)0
-rw-r--r--src/rpath.pri8
-rw-r--r--src/tools/buildoutputparser/buildoutputparser.pro25
-rw-r--r--src/tools/buildoutputparser/buildoutputparser.qbs20
-rw-r--r--src/tools/buildoutputparser/main.cpp107
-rw-r--r--src/tools/buildoutputparser/outputprocessor.cpp98
-rw-r--r--src/tools/buildoutputparser/outputprocessor.h (renamed from src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer_p.h)46
-rw-r--r--src/tools/sdktool/settings.cpp2
-rw-r--r--src/tools/tools.pro3
-rw-r--r--src/tools/tools.qbs1
-rw-r--r--tests/auto/auto.pro13
-rw-r--r--tests/auto/cplusplus/cplusplus.pro1
-rw-r--r--tests/auto/cplusplus/cplusplus.qbs1
-rw-r--r--tests/auto/cplusplus/lexer/tst_lexer.cpp15
-rw-r--r--tests/auto/cplusplus/simplifytypes/simplifytypes.pro2
-rw-r--r--tests/auto/cplusplus/simplifytypes/simplifytypes.qbs7
-rw-r--r--tests/auto/debugger/debugger.pro1
-rw-r--r--tests/auto/debugger/debugger.qbs3
-rw-r--r--tests/auto/debugger/dumpers.pro31
-rw-r--r--tests/auto/debugger/dumpers.qbs3
-rw-r--r--tests/auto/debugger/gdb.pro2
-rw-r--r--tests/auto/debugger/simplifytypes.pro12
-rw-r--r--tests/auto/debugger/simplifytypes.qbs17
-rw-r--r--tests/auto/debugger/tst_dumpers.cpp987
-rw-r--r--tests/auto/debugger/tst_gdb.cpp6
-rw-r--r--tests/auto/debugger/tst_namedemangler.cpp390
-rw-r--r--tests/auto/debugger/tst_simplifytypes.cpp (renamed from tests/auto/cplusplus/simplifytypes/tst_simplifytypestest.cpp)41
-rw-r--r--tests/auto/externaltool/externaltool.pro8
-rw-r--r--tests/auto/externaltool/tst_externaltooltest.cpp6
-rw-r--r--tests/auto/qml/codemodel/check/case-fallthrough.qml2
-rw-r--r--tests/auto/qml/codemodel/check/check.pro5
-rw-r--r--tests/auto/qml/codemodel/check/check.qbs1
-rw-r--r--tests/auto/qml/persistenttrie/persistenttrie.pro8
-rw-r--r--tests/auto/qml/persistenttrie/persistenttrie.qbs14
-rw-r--r--tests/auto/qml/persistenttrie/tst_testtrie.cpp2
-rw-r--r--tests/auto/qml/qml.pro7
-rw-r--r--tests/auto/qml/qml.qbs3
-rw-r--r--tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro18
-rw-r--r--tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.qbs2
-rw-r--r--tests/auto/qml/qmljssimplereader/qmljssimplereader.pro6
-rw-r--r--tests/auto/qml/qmljssimplereader/qmljssimplereader.qbs1
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter1.qmlproject6
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter2.qmlproject7
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter3.qmlproject7
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter4.qmlproject11
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter5.qmlproject8
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter6.qmlproject7
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter7.qmlproject7
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter8.qmlproject7
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/data/testLibraryPaths.qmlproject5
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/data/testMainFile.qmlproject5
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/data/testMatchesFile.qmlproject10
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/fileformat.pro7
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/fileformat.qbs1
-rw-r--r--tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat.cpp240
-rw-r--r--tests/auto/qml/qmlprojectmanager/qmlprojectmanager.qbs1
-rw-r--r--tests/auto/qml/reformatter/reformatter.pro6
-rw-r--r--tests/auto/qml/reformatter/reformatter.qbs1
-rw-r--r--tests/auto/treeviewfind/treeviewfind.pro2
-rw-r--r--tests/auto/treeviewfind/treeviewfind.qbs2
-rw-r--r--tests/auto/treeviewfind/tst_treeviewfind.cpp16
-rw-r--r--tests/manual/debugger/debugger.pro1
-rw-r--r--tests/manual/debugger/helper/helper.pro7
1180 files changed, 32830 insertions, 27477 deletions
diff --git a/dist/changes-3.1.0 b/dist/changes-3.1.0
new file mode 100644
index 0000000000..5d5e5677d0
--- /dev/null
+++ b/dist/changes-3.1.0
@@ -0,0 +1,85 @@
+Qt Creator version 3.1 contains bug fixes and new features.
+
+There is a total of about X changes by N individual contributors.
+
+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 origin/3.0..origin/master
+
+General
+
+Editing
+
+Managing and Building Projects
+
+Compilers
+
+Devices
+
+QMake Projects
+ * Added context menu item "Add Existing Directory" that adds all
+ files from a directory (QTCREATORBUG-9081)
+
+CMake Projects
+
+Qbs Projects
+ * Added option for building with --check-timestamps
+
+Generic Projects
+ * Added context menu item "Add Existing Directory" that adds all
+ files from a directory (QTCREATORBUG-9081)
+ * Made importing files follow directory symlinks (QTCREATORBUG-8897)
+
+Debugging
+ * GDB
+ * CDB
+ * LLDB
+ * QML
+
+Analyzer
+
+C++ Support
+ * Fixed parsing of ??< ??> ??( ??) trigraphs (QTCREATORBUG-2474)
+
+Python Support
+
+GLSL Support
+
+Diff Viewer
+
+Version Control Systems
+ * Git
+ * Added visual indicator for affected commits when resetting and rebasing
+ * Enabled option to push commit directly after fixup
+ * ClearCase
+ * Improved performance of indexing dynamic views
+ * Added warning when editing Derived Objects
+
+FakeVim
+ * Made dot command work for letter case commands in visual mode
+
+Platform Specific
+
+Linux
+
+Qt Support
+
+QNX
+ * Added support for Python based pretty printers when debugging on devices
+ * Added better error messages for common deployment errors
+ (QTCREATORBUG-9673, QTCREATORBUG-9001)
+ * Fixed several issues with certificate password dialog in BlackBerry
+ options (QTCREATORBUG-10948)
+
+Android
+ * Made it possible to cancel waiting for an AVD to boot up
+
+Remote Linux
+
+Bare Metal
+
+Credits for these changes go to:
+
diff --git a/doc/api/qtcreator-api.qdoc b/doc/api/qtcreator-api.qdoc
index d0bc0f36b4..81d8e9f77d 100644
--- a/doc/api/qtcreator-api.qdoc
+++ b/doc/api/qtcreator-api.qdoc
@@ -209,13 +209,13 @@
\row
\li Add a find filter to the \gui Find dialog.
\li Implement any kind of search term based search.
- \li \l{Find::IFindFilter}, \l{Find::SearchResultWindow}
+ \li \l{Find::IFindFilter}, \l{Core::SearchResultWindow}
\row
\li Add support for the find tool bar to a widget.
\li The widget that has focus is asked whether it supports text search. You can
add support for widgets under your control.
- \li \l{Find::IFindSupport}, \l{Find::BaseTextFind}
+ \li \l{Core::IFindSupport}, \l{Find::BaseTextFind}
\row
\li Add a completely new project type.
@@ -231,7 +231,7 @@
\li Add a new filter to the locator.
\li For a text typed in by the user you provide a list of things to show in the popup.
When the user selects an entry you are requested to do whatever you want.
- \li \l{Locator::ILocatorFilter}, \l{Locator::FilterEntry}, \l{Locator::BaseFileFilter}
+ \li \l{Core::ILocatorFilter}, \l{Core::LocatorFilterEntry}, \l{Locator::BaseFileFilter}
\row
\li Show a progress indicator for a concurrently running task.
diff --git a/doc/src/android/androiddev.qdoc b/doc/src/android/androiddev.qdoc
index 884599a859..a58ff6a64c 100644
--- a/doc/src/android/androiddev.qdoc
+++ b/doc/src/android/androiddev.qdoc
@@ -218,7 +218,7 @@
\gui Add. If you run an application without a device connected to the
development PC and without an AVD specified, \QC asks you to add an AVD.
- To manage AVDs, select \gui {Start Android AVD Manager}.
+ To manage AVDs, select \gui {Start AVD Manager}.
\note The Android Emulator has a bug that prevents it from starting on some
systems. If the Android Emulator does not start, you can try starting it
diff --git a/doc/src/debugger/creator-debugger-setup.qdoc b/doc/src/debugger/creator-debugger-setup.qdoc
index 30e5ed32d0..8361be90a6 100644
--- a/doc/src/debugger/creator-debugger-setup.qdoc
+++ b/doc/src/debugger/creator-debugger-setup.qdoc
@@ -96,7 +96,7 @@
\row
\li Mac OS X
\li GCC, Clang
- \li Apple GDB, FSF GDB (experimental), LLDB
+ \li LLDB, FSF GDB (experimental)
\row
\li Windows/MinGW
\li GCC
@@ -109,38 +109,15 @@
\section2 Supported GDB Versions
- GDB comes in two varieties with common roots.
-
- One is used on Mac OS X and does not support Python as scripting language.
- The minimal supported versions in is GDB 6.3.50-20050815, build 1469.
-
- The second is maintained by the Free Software Foundation, and can
- use Python as scripting language. The minimal supported version
- in this case is FSF GDB 7.4.1, using Python version 2.6 or 2.7.
- Note that Python 3.x is not supported by GDB.
-
- The Python enabled versions are very convenient to interface,
- and much of \QC's advanced data display options depend on the
- availability of Python scripting. Since Python enabled versions
- of GDB are bundled with all recent Linux versions, active
- support for non-Python builds has been dropped for platforms
- other than Mac OS X.
-
- The non-Python versions use the compiled version of the debugging
- helpers, that you must enable separately. For more information, see
- \l{Debugging Helpers Based on C++}.
-
- The Python version uses a script version of the debugging helpers
- that does not need any special setup.
-
- FSF GDB can also be compiled for Mac OS, but the build is currently
- unstable, and thererefore, this is not recommended.
+ Starting with version 3.1, \QC requires the Python scripting
+ extension. GDB builds without Python scripting are not supported
+ anymore and will not work. The minimal supported version is GDB 7.4.1,
+ using Python version 2.6, 2.7, or 3.x.
\section2 Supported CDB Versions
- The CDB native debugger has similar functionality to the non-Python GDB
- debugger engine. Specifically, it also uses compiled C++ code for the
- debugging helper library.
+ All versions of CDB targeting platforms supported by Qt
+ are supported by \QC.
\section2 Supported LLDB Versions
@@ -151,7 +128,7 @@
You can use the LLDB version delivered with Xcode, but we recommend that you
build it from sources using Xcode. The minimal supported version is LLDB
- 300.2.51.
+ 179.5.
\omit
@@ -194,16 +171,19 @@
\li Notes
\row
\li GDB
- \li On Linux and Windows, use the Python-enabled GDB versions that
- are installed when you install \QC and Qt SDK. On Mac OS X,
- use the GDB provided with Xcode.
- You can also build your own Python-enabled GDB. Follow the instructions in
+ \li On Windows, use the Python-enabled GDB versions that
+ is bundled with the Qt package or comes with recent
+ versions of MinGW. On most Linux distributions the GDB
+ builds shipped with the system are sufficient. You can
+ also build your own. Follow the instructions in
\l{http://qt-project.org/wiki/QtCreatorBuildGdb}
{Building GDB}.
+ Builds of GDB shipped with Xcode on Mac OS X are no longer
+ supported.
\row
\li Debugging tools for Windows
- \li To use this engine, you must install the
+ \li To use the CDB debugger, you must install the
\e{Debugging tools for Windows}. You can download them from
\l{http://msdn.microsoft.com/en-us/windows/hardware/gg463009/}
{Download and Install Debugging Tools for Windows}.
diff --git a/doc/src/debugger/creator-debugger.qdoc b/doc/src/debugger/creator-debugger.qdoc
index 142a09916c..8707150c72 100644
--- a/doc/src/debugger/creator-debugger.qdoc
+++ b/doc/src/debugger/creator-debugger.qdoc
@@ -62,9 +62,7 @@
\QC is able to show complex data types in a customized,
user-extensible manner. For this purpose, it takes advantage of
two technologies, collectively referred to as \e {debugging
- helpers}. Using the debugging helpers is not essential for
- debugging with \QC, but they provide you with a powerful
- tool to quickly examine complex data.
+ helpers}.
\li \l{Debugging Qt Quick Projects}
@@ -846,75 +844,33 @@
accessible through either sub-structures or pointers.
To give the user simple access also to these items, \QC employs
- so-called Debugging Helpers. Debugging Helpers come in two varieties,
- compiled, and Python based, depending on the selected
- \l{glossary-buildandrun-kit}{kit}.
-
- By default, Debugging Helpers are automatically and transparently used.
- To disable them, select \gui Tools > \gui Options > \gui Debugger >
- \gui {Locals & Expressions}, and deselect the \gui{Use Debugging Helper}
- check box.
-
- \QC ships with Debugging Helpers for about 80 of the most
+ so-called \e{debugging helpers}. Debugging helpers come in two varieties,
+ a compiled one, for use with the CDB backend, and a set of Python
+ scripts for use with the GDB and LLDB backends.
+
+ Debugging helpers are always automatically used. To force a plain
+ C-like display of structures, select \gui Tools > \gui Options >
+ \gui Debugger > \gui {Locals & Expressions}, and then select the
+ \gui{Force Raw Structure Display} check box. For GDB
+ and LLDB this will still use the Python scripts, but generate
+ more basic output. To force plain display for a single object
+ or for all objects of a given type, select the corresponding
+ option from the context menu.
+
+ \QC ships with debugging helpers for more than 130 of the most
popular Qt classes, Standard C++ containers and smart pointers,
covering the usual needs of a C++ application developer out-of-the-box.
- The following sections describe how to extend the debugging helpers
- to your own data types.
-
-
- There are two approaches to displaying complex data types. The first and
- original one is to use debugging helpers based on C++. While it has been
- superseded on most platforms by the more robust and more flexible second
- approch that uses Python scripting, it is the only feasible one on
- Windows/MSVC, Mac OS, and old Linux distributions. Moreover, this approach
- is automatically chosen as fallback if the Python based approach fails.
-
- \section1 Debugging Helpers Based on C++
-
- During debugging with the C++ based debugging helpers,
- \QC dynamically loads a helper library in form of a DLL or a
- shared object into the debugged process.
- The \QSDK package already contains a prebuilt debugging helper
- library. To create your own debugging helper library, select \gui{Tools >
- Options > Build & Run > Qt Versions}. As the internal data
- structures of Qt can change between versions, the debugging helper
- library is built for each Qt version.
+ \section1 Extending GDB and LLDB Debugging Helpers
+ When using either GDB or LLDB as the debugging backend, \QC uses Python
+ scripts to display information in the \gui {Locals and Expressions} view.
- \section1 Debugging Helpers Based on Python
-
- \QC uses GDB builds that enable Python scripting to display
- information in the \gui {Locals and Expressions} view. When Python scripting
- is used, code (Debugging helpers) does not need to be injected into the
- debugged process to nicely display QStringList or \c std::map contents, for
- example.
-
- The code injection caused problems and put an extra stress on the debugged
- process. You can now easily extend the debugging helpers to other types. No
- compilation is required, just adding a few lines of Python.
-
- Python scripting vastly reduces the communication overhead compared
- with the previous solution. However, there are some obstacles:
-
- \list
-
- \li There is no Python-enabled GDB for Mac OS. Mac OS continues
- injection with C++ based debugging helpers.
-
- \li There is no GDB to communicate with MSVC compiled applications on
- Windows. So information can be displayed nicely only in a limited
- fashion by using a CDB extension DLL.
-
- \endlist
-
- \section2 Extending the Python Based Debugging Helpers
-
- On platforms featuring a Python-enabled version of the GDB debugger,
- the data extraction is done by a Python script. This is more robust
- as the script execution is separated from the debugged process. It
- is also easier to extend as the script is less dependent on the
- actual Qt version and does not need compilation.
+ You can easily extend these scripts to cover your own types,
+ using the same code for both the GDB and the LLDB backend.
+ No compilation is required, just adding a few lines of Python.
+ The scripts can address multiple versions of Qt, or of your own
+ library, at the same time.
To extend the shipped Python based debugging helpers for custom
types, add debugging helper implementations to the GDB startup file
@@ -934,45 +890,44 @@
\list
- \li \c d of type \c Dumper
+ \li \c d of type \c Dumper, an object containing current
+ settings and providing facilities to build up an object
+ representing part of the Locals and Expressions view,
- \li \c value of type \c gdb.Value
+ \li \c value of type \c Value, wrapping either a
+ \l{https://sourceware.org/gdb/onlinedocs/gdb/Values-From-Inferior.html}{gdb.Value}
+ or an
+ \l{http://lldb.llvm.org/cpp_reference/html/classlldb_1_1SBValue.html}{lldb.SBValue}.
\endlist
- The function has to feed the Dumper object with certain information
- which is used to build up the object and its children's display in the
- \gui{Locals and Expressions} view.
+ The \c{qdump__*} function has to feed the Dumper object with certain
+ information which is used to build up the object and its children's
+ display in the \gui{Locals and Expressions} view.
Example:
\code
- def qdump__QVector(d, value):
- d_ptr = value["d"]
- p_ptr = value["p"]
- alloc = d_ptr["alloc"]
- size = d_ptr["size"]
-
- innerType = templateArgument(value.type, 0)
+ def qdump__QFiniteStack(d, value):
+ alloc = int(value["_alloc"])
+ size = int(value["_size"])
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
- p = gdb.Value(p_ptr["array"]).cast(innerType.pointer())
- charPtr = lookupType("char").pointer()
- d.putField("size", size)
- with Children(d, size, maxNumChild=2000, childType=innerType, addrBase=p,
- addrStep=(p+1).cast(charPtr) - p.cast(charPtr)):
- for i in d.childRange():
- d.putSubItem(i, p.dereference())
- p += 1
+ innerType = d.templateArgument(value.type, 0)
+ d.putArrayData(innerType, value["_array"], size)
\endcode
+ \note To create dumper functions usable with both LLDB and GDB
+ backends, avoid direct access to the \c gdb.* and \c lldb.* namespaces
+ and use functions of the \c Dumper class instead.
+
\section2 Dumper Class
For each line in the \gui{Locals and Expressions} view, a string like the
following needs to be created and channeled to the debugger plugin.
\code
- "{iname='some internal name', # optional
+ {iname='some internal name', # optional
addr='object address in memory', # optional
name='contents of the name column', # optional
value='contents of the value column',
@@ -986,7 +941,7 @@
{iname='internal name of second child',
},
- ]}"
+ ]}
\endcode
The value of the \c iname field is the internal name of the object,
@@ -999,7 +954,7 @@
of the view. If it is not specified, a simple number in brackets
is used instead.
- While in theory, you can build up the entire string above manually, it is
+ While in theory you can build up the entire string above manually, it is
easier to employ the Dumper Python class for that purpose. The Dumper
Python class contains a complete framework to take care of the \c iname and
\c addr fields, to handle children of simple types, references, pointers,
@@ -1024,11 +979,6 @@
\li \c{putItemCount(self, count)} - Appends a field
\c {value='<%d items'} to the output.
- \li \c{putEllipsis(self)} - Appends fields
- \c {'{name="<incomplete>",value="",type="",numchild="0"}'}. This is
- automatically done by \c endChildren if the number of children to
- print is smaller than the number of actual children.
-
\li \c{putName(self, name)} - Appends a \c {name=''} field.
\li \c{putType(self, type, priority=0)} - Appends a field \c {type=''}
@@ -1110,6 +1060,10 @@
and have the potential to change the state of the debugged
program.
+ \li \c{putArrayData(self, type, address, size)} - Creates \c size
+ children of type \c type of an array-like object located at
+ \c address.
+
\li \c{putItem(self, value)} - The "master function", handling
basic types, references, pointers and enums directly, iterates
over base classes and class members of compound types and calls
@@ -1215,7 +1169,7 @@
\list 1
- \li Make sure you use at least \QC 2.1.
+ \li Make sure you use at least \QC 3.0.1
\li Make sure the debugger is set up properly. For more information,
see \l{Setting Up Debugger}.
@@ -1256,16 +1210,6 @@
and the evaluation of expressions after each step. We recommend that
you minimize the number of breakpoints and watched expressions.
- \section1 Debugger Displays <not in scope> Message
-
- The message is created by the debugging helpers. \QC posts an
- expression to the GDB command line to invoke the debugging helpers.
- The expression includes the address of the object to examine. This
- address might be modified by GDB before the helper function is called. It
- is unclear why and when this happens, but if it happens, the debugging
- helpers operate on wrong data and come to wrong conclusions. Most likely,
- they find garbage and declare the variable to be <not in scope>.
-
\section1 Application Crashes when Debugging on Mac OS X Snow Leopard
You must use a workaround to use the DYLD_IMAGE_SUFFIX option in the
diff --git a/doc/src/howto/creator-vcs.qdoc b/doc/src/howto/creator-vcs.qdoc
index daff05eeba..faec850b9f 100644
--- a/doc/src/howto/creator-vcs.qdoc
+++ b/doc/src/howto/creator-vcs.qdoc
@@ -312,10 +312,42 @@
Bazaar is a free version control system sponsored by Canonical.
- In addition to the standard version control system functions, you can
- select \gui Tools > \gui Bazaar > \gui Pull to turn the branch into a
- mirror of another branch. To update a mirror of the branch, select
- \gui Push.
+ The \gui Bazaar submenu contains the following additional items:
+
+ \table
+ \header
+ \li Menu Item
+ \li Description
+ \row
+ \li \gui Pull
+ \li Turn the branch into a mirror of another branch.
+ \row
+ \li \gui Push
+ \li Update a mirror of the branch.
+ \row
+ \li \gui Uncommit
+ \li Remove the last committed revision.
+ \endtable
+
+ \section3 Uncommitting Revisions
+
+ In Bazaar, committing changes to a branch creates a new revision that holds
+ a snapshot of the state of the working tree. To remove the last committed
+ revision, select \gui Tools > \gui Bazaar > \gui Uncommit.
+
+ In the \gui Uncommit dialog, select options to keep tags that point to
+ removed revisions and to only remove the commits from the local branch when
+ in a checkout.
+
+ To remove all commits up to an entry in the revision log, specify the
+ revision in the \gui Revision field.
+
+ To test the outcome of the \gui Uncommit command without actually removing
+ anything, select \gui {Dry Run}.
+
+ \gui Uncommit leaves the working tree ready for a new commit. The only
+ change it might make is restoring pending merges that were present before
+ the commit.
\section2 Using Additional ClearCase Functions
@@ -449,6 +481,12 @@
\row
\li \gui Merge
\li Join the development histories in two branches together.
+
+ If the commit you are merging can be reached by following the
+ first commit's history, there is no divergent work to merge
+ together. To allow Git to move the branch pointer forward,
+ select \gui {Fast-Forward}. If you do not want to fast-forward
+ the branch, select \gui {No Fast-Forward}.
\row
\li \gui Rebase
\li Copy local commits to the updated upstream head.
diff --git a/doc/src/qnx/creator-developing-bb10.qdoc b/doc/src/qnx/creator-developing-bb10.qdoc
index 1e406a98e1..6d90b2169d 100644
--- a/doc/src/qnx/creator-developing-bb10.qdoc
+++ b/doc/src/qnx/creator-developing-bb10.qdoc
@@ -49,7 +49,9 @@
\li Set up API Levels:
\list 1
- \li Select \gui Tools > \gui Options > \gui BlackBerry > \gui NDK to list all registered API Levels automatically detected by \QC.
+ \li Select \gui Tools > \gui Options > \gui BlackBerry >
+ \gui {API Level} to list all registered API Levels automatically
+ detected by \QC.
\li The API Levels printed with a bold font are active. Use \gui Activate and \gui Deactivate to change it. When an API Level is active, \QC registers kits, Qt versions, tool chains, and debuggers to enable BlackBerry 10 development against the API Level.
\li Use \gui Add to install a new API Level or to register an existing one.
\li It is recommended to install the latest API Level too even though you are not going to use it. This will enable all \QC features including device auto-detection and the new BlackBerry Signing Keys process.
diff --git a/qbs/modules/pluginspec/pluginspec.qbs b/qbs/modules/pluginspec/pluginspec.qbs
index ca8fdae8f4..f854014197 100644
--- a/qbs/modules/pluginspec/pluginspec.qbs
+++ b/qbs/modules/pluginspec/pluginspec.qbs
@@ -80,7 +80,7 @@ Module {
}
prepare: {
- var xslFile = project.path + "/../pluginjsonmetadata.xsl"; // project is "Plugins"
+ var xslFile = project.path + "/../qtcreatorplugin2json.xsl"; // project is "Plugins"
var xmlPatternsPath = product.moduleProperty("Qt/core", "binPath") + "/xmlpatterns";
var args = [
"-no-format",
diff --git a/qtcreator.pri b/qtcreator.pri
index 261fadef77..175070567f 100644
--- a/qtcreator.pri
+++ b/qtcreator.pri
@@ -1,9 +1,9 @@
!isEmpty(QTCREATOR_PRI_INCLUDED):error("qtcreator.pri already included")
QTCREATOR_PRI_INCLUDED = 1
-QTCREATOR_VERSION = 3.0.0
-QTCREATOR_COMPAT_VERSION = 3.0.0
-BINARY_ARTIFACTS_BRANCH = 3.0
+QTCREATOR_VERSION = 3.0.81
+QTCREATOR_COMPAT_VERSION = 3.0.81
+BINARY_ARTIFACTS_BRANCH = master
isEqual(QT_MAJOR_VERSION, 5) {
@@ -130,13 +130,11 @@ macx {
IDE_DOC_PATH = $$IDE_DATA_PATH/doc
IDE_BIN_PATH = $$IDE_APP_PATH/$${IDE_APP_TARGET}.app/Contents/MacOS
copydata = 1
- isEmpty(TIGER_COMPAT_MODE):TIGER_COMPAT_MODE=$$(QTC_TIGER_COMPAT)
!isEqual(QT_MAJOR_VERSION, 5) {
- # Qt5 doesn't support 10.5, and will set the minimum version correctly to 10.6 or 10.7.
- isEmpty(TIGER_COMPAT_MODE) {
- QMAKE_CXXFLAGS *= -mmacosx-version-min=10.5
- QMAKE_LFLAGS *= -mmacosx-version-min=10.5
- }
+ # we use @rpath which is 10.5+
+ # Qt5 doesn't support 10.5, and will set the minimum version to 10.6 or 10.7.
+ QMAKE_CXXFLAGS *= -mmacosx-version-min=10.5
+ QMAKE_LFLAGS *= -mmacosx-version-min=10.5
}
} else {
contains(TEMPLATE, vc.*):vcproj = 1
diff --git a/qtcreator.qbs b/qtcreator.qbs
index 9cce364395..6228a1b53d 100644
--- a/qtcreator.qbs
+++ b/qtcreator.qbs
@@ -4,11 +4,11 @@ Project {
property bool withAutotests: qbs.buildVariant === "debug"
property string ide_version_major: '3'
property string ide_version_minor: '0'
- property string ide_version_release: '0'
+ property string ide_version_release: '81'
property string qtcreator_version: ide_version_major + '.' + ide_version_minor + '.' + ide_version_release
property string ide_compat_version_major: '3'
property string ide_compat_version_minor: '0'
- property string ide_compat_version_release: '0'
+ property string ide_compat_version_release: '81'
property string qtcreator_compat_version: ide_compat_version_major + '.' + ide_compat_version_minor + '.' + ide_compat_version_release
property path ide_source_tree: path
property string ide_app_path: qbs.targetOS.contains("osx") ? "" : "bin"
diff --git a/share/qtcreator/cplusplus/qt5-qobjectdefs-injected.h b/share/qtcreator/cplusplus/qt5-qobjectdefs-injected.h
new file mode 100644
index 0000000000..a46ee25ade
--- /dev/null
+++ b/share/qtcreator/cplusplus/qt5-qobjectdefs-injected.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#define QT_NO_META_MACROS
+
+#define signals public __attribute__((annotate("qt_signal")))
+#define slots __attribute__((annotate("qt_slot")))
+#define Q_SIGNALS signals
+#define Q_SLOTS slots
+#define Q_SIGNAL __attribute__((annotate("qt_signal")))
+#define Q_SLOT __attribute__((annotate("qt_slot")))
+# define Q_PRIVATE_SLOT(d, signature)
+
+#define Q_EMIT
+#define emit
+#define Q_CLASSINFO(name, value)
+#define Q_PLUGIN_METADATA(x)
+#define Q_INTERFACES(x)
+#define Q_PROPERTY(text)
+#define Q_PRIVATE_PROPERTY(d, text)
+#define Q_REVISION(v)
+#define Q_OVERRIDE(text)
+#define Q_ENUMS(x)
+#define Q_FLAGS(x)
+#define Q_SCRIPTABLE
+#define Q_INVOKABLE
+
+#define Q_GADGET \
+public: \
+ static const QMetaObject staticMetaObject; \
+private:
+
+#define SIGNAL(a) #a
+#define SLOT(a) #a
diff --git a/share/qtcreator/debugger/boosttypes.py b/share/qtcreator/debugger/boosttypes.py
index 778bbf1429..fb725c4f22 100644
--- a/share/qtcreator/debugger/boosttypes.py
+++ b/share/qtcreator/debugger/boosttypes.py
@@ -75,7 +75,12 @@ def qdump__boost__shared_ptr(d, value):
d.check(usecount <= 10*1000*1000)
val = value["px"].dereference()
- if d.isSimpleType(val.type):
+ type = val.type
+ # handle boost::shared_ptr<int>::element_type as int
+ if str(type).endswith(">::element_type"):
+ type = type.strip_typedefs()
+
+ if d.isSimpleType(type):
d.putNumChild(3)
d.putItem(val)
d.putBetterType(value.type)
diff --git a/share/qtcreator/debugger/creatortypes.py b/share/qtcreator/debugger/creatortypes.py
index 3bd2e15467..593386a037 100644
--- a/share/qtcreator/debugger/creatortypes.py
+++ b/share/qtcreator/debugger/creatortypes.py
@@ -104,21 +104,19 @@ def qdump__Utils__ElfSection(d, value):
d.putPlainChildren(value)
def qdump__CPlusPlus__Token(d, value):
- k = int(value["f"]["kind"])
+ k = value["f"]["kind"]
if int(k) == 6:
d.putValue("T_IDENTIFIER. offset: %d, len: %d"
% (value["offset"], value["f"]["length"]))
elif int(k) == 7:
d.putValue("T_NUMERIC_LITERAL. offset: %d, value: %d"
% (value["offset"], value["f"]["length"]))
- elif int(k) == 60:
- d.putValue("T_RPAREN")
else:
- d.putValue("Type: %s" % k)
+ val = str(k.cast(d.lookupType("CPlusPlus::Kind")))
+ d.putValue(val[11:]) # Strip "CPlusPlus::"
d.putPlainChildren(value)
def qdump__CPlusPlus__Internal__PPToken(d, value):
- k = value["f"]["kind"];
data, size, alloc = d.byteArrayData(value["m_src"])
length = int(value["f"]["length"])
offset = int(value["offset"])
@@ -127,5 +125,3 @@ def qdump__CPlusPlus__Internal__PPToken(d, value):
d.putValue(d.readMemory(data + offset, min(100, length)),
Hex2EncodedLatin1)
d.putPlainChildren(value)
-
-
diff --git a/share/qtcreator/debugger/dumper.cpp b/share/qtcreator/debugger/dumper.cpp
deleted file mode 100644
index 1215155475..0000000000
--- a/share/qtcreator/debugger/dumper.cpp
+++ /dev/null
@@ -1,3805 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include <qglobal.h>
-
-#if USE_QT_CORE
-#include <QDateTime>
-#include <QDebug>
-#include <QDir>
-#include <QFile>
-#include <QFileInfo>
-#include <QHash>
-#include <QLinkedList>
-#include <QList>
-#include <QQueue>
-#include <QLocale>
-#include <QMap>
-#include <QMetaEnum>
-#include <QMetaObject>
-#include <QMetaProperty>
-#include <QPoint>
-#include <QPointF>
-#include <QPointer>
-#include <QRect>
-#include <QRectF>
-#include <QStack>
-#include <QSize>
-#include <QSizeF>
-#include <QString>
-#include <QStringList>
-#include <QTextCodec>
-#include <QTextStream>
-#include <QVector>
-
-#ifndef QT_BOOTSTRAPPED
-
-#include <QModelIndex>
-
-#if QT_VERSION >= 0x040500
-#include <QSharedPointer>
-#include <QSharedDataPointer>
-#include <QSharedData>
-#include <QWeakPointer>
-#endif
-
-#ifndef USE_QT_GUI
-# ifdef QT_GUI_LIB
-# define USE_QT_GUI 1
-# endif
-#endif
-
-#ifndef USE_QT_WIDGETS
-# if defined(QT_WIDGETS_LIB) || ((QT_VERSION < 0x050000) && defined(USE_QT_GUI))
-# define USE_QT_WIDGETS 1
-# endif
-#endif
-
-#ifdef USE_QT_GUI
-# include <QImage>
-# include <QRegion>
-# include <QPixmap>
-# include <QFont>
-# include <QColor>
-# include <QKeySequence>
-#endif
-
-#ifdef USE_QT_WIDGETS
-# include <QSizePolicy>
-# include <QWidget>
-# include <QApplication>
-#endif
-
-#endif // QT_BOOTSTRAPPED
-
-#endif // USE_QT_CORE
-
-
-#ifdef Q_OS_WIN
-# include <windows.h>
-#endif
-
-#include <list>
-#include <map>
-#include <string>
-#include <set>
-#include <vector>
-
-#include <stdio.h>
-
-#ifdef QT_BOOTSTRAPPED
-
-# define NS ""
-# define NSX "'"
-# define NSY "'"
-
-#else
-
-# include "dumper_p.h"
-
-#endif // QT_BOOTSTRAPPED
-
-
-#if QT_VERSION >= 0x050000
-# define MAP_WORKS 0
-#else
-# define MAP_WORKS 1
-#endif
-
-int qtGhVersion = QT_VERSION;
-
-/*!
- \class QDumper
- \brief Helper class for producing "nice" output in Qt Creator's debugger.
-
- \internal
-
- The whole "custom dumper" implementation is currently far less modular
- than it could be. But as the code is still in a flux, making it nicer
- from a pure archtectural point of view seems still be a waste of resources.
-
- Some hints:
-
- New dumpers for non-templated classes should be mentioned in
- \c{qDumpObjectData440()} in the \c{protocolVersion == 1} branch.
-
- Templated classes need extra support on the IDE level
- (see plugins/debugger/gdbengine.cpp) and should not be mentiond in
- \c{qDumpObjectData440()}.
-
- In any case, dumper processesing should end up in
- \c{handleProtocolVersion2and3()} and needs an entry in the big switch there.
-
- Next step is to create a suitable \c{static void qDumpFoo(QDumper &d)}
- function. At the bare minimum it should contain something like this:
-
-
- \c{
- const Foo &foo = *reinterpret_cast<const Foo *>(d.data);
-
- d.putItem("value", ...);
- d.putItem("type", "Foo");
- d.putItem("numchild", "0");
- }
-
-
- 'd.putItem(name, value)' roughly expands to:
- d.put((name)).put("=\"").put(value).put("\"";
-
- Useful (i.e. understood by the IDE) names include:
-
- \list
- \o "name" shows up in the first column in the Locals&Watchers view.
- \o "value" shows up in the second column.
- \o "valueencoded" should be set to "1" if the value is base64 encoded.
- Always base64-encode values that might use unprintable or otherwise
- "confuse" the protocol (like spaces and quotes). [A-Za-z0-9] is "safe".
- A value of "3" is used for base64-encoded UCS4, "2" denotes
- base64-encoded UTF16.
- \o "numchild" return the number of children in the view. Effectively, only
- 0 and != 0 will be used, so don't try too hard to get the number right.
- \endlist
-
- If the current item has children, it might be queried to produce information
- about these children. In this case the dumper should use something like this:
-
- \c{
- if (d.dumpChildren) {
- d.beginChildren();
- [...]
- d.endChildren();
- }
-
- */
-
-#if defined(QT_BEGIN_NAMESPACE)
-QT_BEGIN_NAMESPACE
-#endif
-
-const char stdStringTypeC[] = "std::basic_string<char,std::char_traits<char>,std::allocator<char> >";
-const char stdWideStringTypeUShortC[] = "std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >";
-
-#if defined(QT_BEGIN_NAMESPACE)
-QT_END_NAMESPACE
-#endif
-
-
-// This can be mangled typenames of nested templates, each char-by-char
-// comma-separated integer list...
-// The output buffer.
-#ifdef MACROSDEBUG
- Q_DECL_EXPORT char xDumpInBuffer[10000];
- Q_DECL_EXPORT char xDumpOutBuffer[1000000];
-# define inBuffer xDumpInBuffer
-# define outBuffer xDumpOutBuffer
-#else
- Q_DECL_EXPORT char qDumpInBuffer[10000];
- Q_DECL_EXPORT char qDumpOutBuffer[1000000];
-# define inBuffer qDumpInBuffer
-# define outBuffer qDumpOutBuffer
-#endif
-
-namespace {
-
-static QByteArray strPtrConst = "* const";
-
-static bool isPointerType(const QByteArray &type)
-{
- return type.endsWith('*') || type.endsWith(strPtrConst);
-}
-
-static QByteArray stripPointerType(const QByteArray &_type)
-{
- QByteArray type = _type;
- if (type.endsWith('*'))
- type.chop(1);
- if (type.endsWith(strPtrConst))
- type.chop(7);
- if (type.endsWith(' '))
- type.chop(1);
- return type;
-}
-
-// This is used to abort evaluation of custom data dumpers in a "coordinated"
-// way. Abortion will happen at the latest when we try to access a non-initialized
-// non-trivial object, so there is no way to prevent this from occurring at all
-// conceptually. Gdb will catch SIGSEGV and return to the calling frame.
-// This is just fine provided we only _read_ memory in the custom handlers below.
-// We don't use this code for MSVC/CDB anymore.
-
-volatile int qProvokeSegFaultHelper;
-
-static const void *addOffset(const void *p, int offset)
-{
- return offset + reinterpret_cast<const char *>(p);
-}
-
-static const void *deref(const void *p)
-{
- return *reinterpret_cast<const char* const*>(p);
-}
-
-#if USE_QT_CORE
-static const void *skipvtable(const void *p)
-{
- return sizeof(void *) + reinterpret_cast<const char *>(p);
-}
-
-static const void *dfunc(const void *p)
-{
- return deref(skipvtable(p));
-}
-#endif
-
-static bool isEqual(const char *s, const char *t)
-{
- return qstrcmp(s, t) == 0;
-}
-
-static bool startsWith(const char *s, const char *t)
-{
- while (char c = *t++)
- if (c != *s++)
- return false;
- return true;
-}
-
-// Check memory for read access and provoke segfault if nothing else helps.
-// On Windows, try to be less crash-prone by checking memory using WinAPI
-
-#ifdef Q_OS_WIN
-
-# define qCheckAccess(d) do { \
- if (IsBadReadPtr(d, 1)) \
- return; \
- qProvokeSegFaultHelper = *(char*)d; \
- } while (0)
-# define qCheckPointer(d) do { \
- if (d && IsBadReadPtr(d, 1)) \
- return; \
- if (d) qProvokeSegFaultHelper = *(char*)d; \
- } while (0)
-
-#else
-
-# define qCheckAccess(d) do { \
- if (!couldBePointer(d) && d != 0) \
- return; \
- qProvokeSegFaultHelper = *(char*)d; \
- } while (0)
-# define qCheckPointer(d) do { \
- if (!couldBePointer(d)) \
- return; \
- if (d) \
- qProvokeSegFaultHelper = *(char*)d; \
- } while (0)
-
-static bool couldBePointer(const void *p)
-{
- // we assume valid pointer to be 4-aligned at least.
- // So use this check only when this is guaranteed.
- // FIXME: this breaks e.g. in the QString dumper...
- const quintptr d = quintptr(p);
- //qDebug() << "CHECKING : " << p << ((d & 3) == 0 && (d > 1000 || d == 0));
- //return (d & 3) == 0 && (d > 1000 || d == 0);
- return d > 1000 || d == 0;
-}
-
-#endif
-
-#ifdef QT_NAMESPACE
-const char *stripNamespace(const char *type)
-{
- static const size_t nslen = strlen(NS);
- return startsWith(type, NS) ? type + nslen : type;
-}
-#else
-inline const char *stripNamespace(const char *type)
-{
- return type;
-}
-#endif
-
-static bool isSimpleType(const char *type)
-{
- switch (type[0]) {
- case 'c':
- return isEqual(type, "char");
- case 'd':
- return isEqual(type, "double");
- case 'f':
- return isEqual(type, "float");
- case 'i':
- return isEqual(type, "int");
- case 'l':
- return isEqual(type, "long") || startsWith(type, "long ");
- case 's':
- return isEqual(type, "short") || startsWith(type, "short ")
- || isEqual(type, "signed") || startsWith(type, "signed ");
- case 'u':
- return isEqual(type, "unsigned") || startsWith(type, "unsigned ");
- }
- return false;
-}
-
-static bool isStringType(const char *type)
-{
- return isEqual(type, NS "QString")
- || isEqual(type, NS "QByteArray")
- || isEqual(type, "std::string")
- || isEqual(type, "std::wstring")
- || isEqual(type, "wstring");
-}
-
-#if USE_QT_CORE
-static bool isMovableType(const char *type)
-{
- if (isPointerType(type))
- return true;
-
- if (isSimpleType(type))
- return true;
-
- type = stripNamespace(type);
-
- switch (type[1]) {
- case 'B':
- return isEqual(type, "QBrush")
- || isEqual(type, "QBitArray")
- || isEqual(type, "QByteArray") ;
- case 'C':
- return isEqual(type, "QCustomTypeInfo")
- || isEqual(type, "QChar");
- case 'D':
- return isEqual(type, "QDate")
- || isEqual(type, "QDateTime");
- case 'F':
- return isEqual(type, "QFileInfo")
- || isEqual(type, "QFixed")
- || isEqual(type, "QFixedPoint")
- || isEqual(type, "QFixedSize");
- case 'H':
- return isEqual(type, "QHashDummyValue");
- case 'I':
- return isEqual(type, "QIcon")
- || isEqual(type, "QImage");
- case 'L':
- return isEqual(type, "QLine")
- || isEqual(type, "QLineF")
- || isEqual(type, "QLatin1Char")
- || isEqual(type, "QLocal");
- case 'M':
- return isEqual(type, "QMatrix")
- || isEqual(type, "QModelIndex");
- case 'P':
- return isEqual(type, "QPoint")
- || isEqual(type, "QPointF")
- || isEqual(type, "QPen")
- || isEqual(type, "QPersistentModelIndex");
- case 'R':
- return isEqual(type, "QResourceRoot")
- || isEqual(type, "QRect")
- || isEqual(type, "QRectF")
- || isEqual(type, "QRegExp");
- case 'S':
- return isEqual(type, "QSize")
- || isEqual(type, "QSizeF")
- || isEqual(type, "QString");
- case 'T':
- return isEqual(type, "QTime")
- || isEqual(type, "QTextBlock");
- case 'U':
- return isEqual(type, "QUrl");
- case 'V':
- return isEqual(type, "QVariant");
- case 'X':
- return isEqual(type, "QXmlStreamAttribute")
- || isEqual(type, "QXmlStreamNamespaceDeclaration")
- || isEqual(type, "QXmlStreamNotationDeclaration")
- || isEqual(type, "QXmlStreamEntityDeclaration");
- }
- return false;
-}
-#endif
-
-struct QDumper
-{
- explicit QDumper();
- ~QDumper();
-
- // direct write to the output
- QDumper &put(long c);
- QDumper &put(int i);
- QDumper &put(double d);
- QDumper &put(float d);
- QDumper &put(unsigned long c);
- QDumper &put(unsigned int i);
- QDumper &put(const void *p);
- QDumper &put(qulonglong c);
- QDumper &put(long long c);
- QDumper &put(const char *str);
- QDumper &put(const QByteArray &ba);
- QDumper &put(const QString &str);
- QDumper &put(char c);
-
- // convienience functions for writing key="value" pairs:
- template <class Value>
- void putItem(const char *name, const Value &value)
- {
- putCommaIfNeeded();
- put(name).put('=').put('"').put(value).put('"');
- }
-
- void putItem(const char *name, const char *value, const char *setvalue)
- {
- if (!isEqual(value, setvalue))
- putItem(name, value);
- }
- // convienience functions for writing typical properties.
- // roughly equivalent to
- // beginHash();
- // putItem("name", name);
- // putItem("value", value);
- // putItem("type", NS "QString");
- // putItem("numchild", "0");
- // putItem("valueencoded", "2");
- // endHash();
- void putHash(const char *name, const QString &value);
- void putHash(const char *name, const QByteArray &value);
- void putHash(const char *name, int value);
- void putHash(const char *name, long value);
- void putHash(const char *name, bool value);
- void putHash(const char *name, QChar value);
- void putHash(const char *name, float value);
- void putHash(const char *name, double value);
- void putStringValue(const QString &value);
-
- void beginHash(); // start of data hash output
- void endHash(); // start of data hash output
-
- void beginChildren(const char *mainInnerType = 0); // start of children list
- void endChildren(); // end of children list
-
- void beginItem(const char *name); // start of named item, ready to accept value
- void endItem(); // end of named item, used after value output is complete
-
- // convenience for putting "<n items>"
- void putItemCount(const char *name, int count);
- // convenience for putting "<>n items>" (more than X items)
- void putTruncatedItemCount(const char *name, int count);
- void putCommaIfNeeded();
- // convienience function for writing the last item of an abbreviated list
- void putEllipsis();
- void disarm();
-
- void putBase64Encoded(const char *buf, int n);
- void checkFill();
-
- // the dumper arguments
- int protocolVersion; // dumper protocol version
- int token; // some token to show on success
- const char *outerType; // object type
- const char *iname; // object name used for display
- const char *exp; // object expression
- const char *innerType; // 'inner type' for class templates
- const void *data; // pointer to raw data
- bool dumpChildren; // do we want to see children?
-
- // handling of nested templates
- void setupTemplateParameters();
- enum { maxTemplateParameters = 10 };
- const char *templateParameters[maxTemplateParameters + 1];
-
- // internal state
- int extraInt[4];
-
- bool success; // are we finished?
- bool full;
- int pos;
-
- const char *currentChildType;
- const char *currentChildNumChild;
-};
-
-
-QDumper::QDumper()
-{
- success = false;
- full = false;
- outBuffer[0] = 'f'; // marks output as 'wrong'
- pos = 1;
- currentChildType = 0;
- currentChildNumChild = 0;
-}
-
-QDumper::~QDumper()
-{
- outBuffer[pos++] = '\0';
- if (success)
- outBuffer[0] = (full ? '+' : 't');
-}
-
-void QDumper::setupTemplateParameters()
-{
- char *s = const_cast<char *>(innerType);
-
- int templateParametersCount = 1;
- templateParameters[0] = s;
- for (int i = 1; i != maxTemplateParameters + 1; ++i)
- templateParameters[i] = 0;
-
- while (*s) {
- while (*s && *s != '@')
- ++s;
- if (*s) {
- *s = '\0';
- ++s;
- templateParameters[templateParametersCount++] = s;
- }
- }
- while (templateParametersCount < maxTemplateParameters)
- templateParameters[templateParametersCount++] = 0;
-}
-
-QDumper &QDumper::put(char c)
-{
- checkFill();
- if (!full)
- outBuffer[pos++] = c;
- return *this;
-}
-
-QDumper &QDumper::put(unsigned long long c)
-{
- checkFill();
- pos += sprintf(outBuffer + pos, "%llu", c);
- return *this;
-}
-
-QDumper &QDumper::put(long long c)
-{
- checkFill();
- pos += sprintf(outBuffer + pos, "%lld", c);
- return *this;
-}
-
-QDumper &QDumper::put(unsigned long c)
-{
- checkFill();
- pos += sprintf(outBuffer + pos, "%lu", c);
- return *this;
-}
-
-QDumper &QDumper::put(float d)
-{
- checkFill();
- pos += sprintf(outBuffer + pos, "%f", d);
- return *this;
-}
-
-QDumper &QDumper::put(double d)
-{
- checkFill();
- pos += sprintf(outBuffer + pos, "%f", d);
- return *this;
-}
-
-QDumper &QDumper::put(unsigned int i)
-{
- checkFill();
- pos += sprintf(outBuffer + pos, "%u", i);
- return *this;
-}
-
-QDumper &QDumper::put(long c)
-{
- checkFill();
- pos += sprintf(outBuffer + pos, "%ld", c);
- return *this;
-}
-
-QDumper &QDumper::put(int i)
-{
- checkFill();
- pos += sprintf(outBuffer + pos, "%d", i);
- return *this;
-}
-
-QDumper &QDumper::put(const void *p)
-{
- if (p) {
- // Pointer is 'long long' on WIN_64, only
- static const char *printFormat = sizeof(void *) == sizeof(long) ? "0x%lx" : "0x%llx";
- pos += sprintf(outBuffer + pos, printFormat, p);
- } else {
- pos += sprintf(outBuffer + pos, "<null>");
- }
- return *this;
-}
-
-QDumper &QDumper::put(const char *str)
-{
- if (!str)
- return put("<null>");
- while (*str)
- put(*(str++));
- return *this;
-}
-
-QDumper &QDumper::put(const QByteArray &ba)
-{
- putBase64Encoded(ba.constData(), ba.size());
- return *this;
-}
-
-QDumper &QDumper::put(const QString &str)
-{
- putBase64Encoded((const char *)str.constData(), 2 * str.size());
- return *this;
-}
-
-void QDumper::checkFill()
-{
- if (pos >= int(sizeof(outBuffer)) - 100)
- full = true;
-}
-
-void QDumper::putCommaIfNeeded()
-{
- if (pos == 0)
- return;
- char c = outBuffer[pos - 1];
- if (c == '}' || c == '"' || c == ']')
- put(',');
-}
-
-void QDumper::putBase64Encoded(const char *buf, int n)
-{
- const char alphabet[] = "ABCDEFGH" "IJKLMNOP" "QRSTUVWX" "YZabcdef"
- "ghijklmn" "opqrstuv" "wxyz0123" "456789+/";
- const char padchar = '=';
- int padlen = 0;
-
- //int tmpsize = ((n * 4) / 3) + 3;
-
- int i = 0;
- while (i < n) {
- int chunk = 0;
- chunk |= int(uchar(buf[i++])) << 16;
- if (i == n) {
- padlen = 2;
- } else {
- chunk |= int(uchar(buf[i++])) << 8;
- if (i == n)
- padlen = 1;
- else
- chunk |= int(uchar(buf[i++]));
- }
-
- int j = (chunk & 0x00fc0000) >> 18;
- int k = (chunk & 0x0003f000) >> 12;
- int l = (chunk & 0x00000fc0) >> 6;
- int m = (chunk & 0x0000003f);
- put(alphabet[j]);
- put(alphabet[k]);
- put(padlen > 1 ? padchar : alphabet[l]);
- put(padlen > 0 ? padchar : alphabet[m]);
- }
-}
-
-void QDumper::putStringValue(const QString &str)
-{
- if (str.isNull()) {
- beginItem("value");
- putBase64Encoded("\"\" (null)", 9);
- endItem();
- putItem("valueencoded", "5");
- } else {
- putItem("value", str);
- putItem("valueencoded", "2");
- }
-}
-
-void QDumper::disarm()
-{
- success = true;
-}
-
-void QDumper::beginHash()
-{
- putCommaIfNeeded();
- put('{');
-}
-
-void QDumper::endHash()
-{
- put('}');
-}
-
-void QDumper::putEllipsis()
-{
- putCommaIfNeeded();
- put("{name=\"<incomplete>\",value=\"\",type=\"").put(innerType).put("\"}");
-}
-
-void QDumper::putItemCount(const char *name, int count)
-{
- putCommaIfNeeded();
- put(name).put("=\"<").put(count).put(" items>\"");
-}
-
-void QDumper::putTruncatedItemCount(const char *name, int count)
-{
- putCommaIfNeeded();
- put(name).put("=\"<>").put(count).put(" items>\"");
-}
-
-//
-// Some helpers to keep the dumper code short
-//
-
-void QDumper::beginItem(const char *name)
-{
- putCommaIfNeeded();
- put(name).put('=').put('"');
-}
-
-void QDumper::endItem()
-{
- put('"');
-}
-
-void QDumper::beginChildren(const char *mainInnerType)
-{
- if (mainInnerType) {
- putItem("childtype", mainInnerType);
- currentChildType = mainInnerType;
- if (isSimpleType(mainInnerType) || isStringType(mainInnerType)) {
- putItem("childnumchild", "0");
- currentChildNumChild = "0";
- } else if (isPointerType(mainInnerType)) {
- putItem("childnumchild", "1");
- currentChildNumChild = "1";
- }
- }
-
- putCommaIfNeeded();
- put("children=[");
-}
-
-void QDumper::endChildren()
-{
- put(']');
- currentChildType = 0;
- currentChildNumChild = 0;
-}
-
-// simple string property
-void QDumper::putHash(const char *name, const QString &value)
-{
- beginHash();
- putItem("name", name);
- putStringValue(value);
- putItem("type", NS "QString");
- putItem("numchild", "0");
- endHash();
-}
-
-void QDumper::putHash(const char *name, const QByteArray &value)
-{
- beginHash();
- putItem("name", name);
- putItem("value", value);
- putItem("type", NS "QByteArray");
- putItem("numchild", "0");
- putItem("valueencoded", "1");
- endHash();
-}
-
-// simple integer property
-void QDumper::putHash(const char *name, int value)
-{
- beginHash();
- putItem("name", name);
- putItem("value", value);
- putItem("type", "int");
- putItem("numchild", "0");
- endHash();
-}
-
-void QDumper::putHash(const char *name, long value)
-{
- beginHash();
- putItem("name", name);
- putItem("value", value);
- putItem("type", "long");
- putItem("numchild", "0");
- endHash();
-}
-
-void QDumper::putHash(const char *name, float value)
-{
- beginHash();
- putItem("name", name);
- putItem("value", value);
- putItem("type", "float");
- putItem("numchild", "0");
- endHash();
-}
-
-void QDumper::putHash(const char *name, double value)
-{
- beginHash();
- putItem("name", name);
- putItem("value", value);
- putItem("type", "double");
- putItem("numchild", "0");
- endHash();
-}
-
-// simple boolean property
-void QDumper::putHash(const char *name, bool value)
-{
- beginHash();
- putItem("name", name);
- putItem("value", (value ? "true" : "false"));
- putItem("type", "bool");
- putItem("numchild", "0");
- endHash();
-}
-
-// a single QChar
-void QDumper::putHash(const char *name, QChar value)
-{
- beginHash();
- putItem("name", name);
- putStringValue(QString(QLatin1String("'%1' (%2, 0x%3)"))
- .arg(value).arg(value.unicode()).arg(value.unicode(), 0, 16));
- putItem("type", NS "QChar");
- putItem("numchild", "0");
- endHash();
-}
-
-#define DUMPUNKNOWN_MESSAGE "<not in scope>"
-static void qDumpUnknown(QDumper &d, const char *why = 0)
-{
- if (!why)
- why = DUMPUNKNOWN_MESSAGE;
- d.putItem("value", why);
- d.putItem("valueeditable", "false");
- d.putItem("valueenabled", "false");
- d.putItem("numchild", "0", d.currentChildNumChild);
- d.disarm();
-}
-
-static void qDumpStdStringValue(QDumper &d, const std::string &str)
-{
- d.beginItem("value");
- d.putBase64Encoded(str.c_str(), str.size());
- d.endItem();
- d.putItem("valueencoded", "1");
- d.putItem("type", "std::string");
- d.putItem("numchild", "0", d.currentChildNumChild);
-}
-
-static void qDumpStdWStringValue(QDumper &d, const std::wstring &str)
-{
- d.beginItem("value");
- d.putBase64Encoded((const char *)str.c_str(), str.size() * sizeof(wchar_t));
- d.endItem();
- d.putItem("valueencoded", (sizeof(wchar_t) == 2 ? "2" : "3"));
- d.putItem("type", "std::wstring", d.currentChildType);
- d.putItem("numchild", "0", d.currentChildNumChild);
-}
-
-// Called by templates, so, not static.
-static void qDumpInnerQCharValue(QDumper &d, QChar c, const char *field)
-{
- char buf[30];
- sprintf(buf, "'?', ucs=%d", c.unicode());
- if (c.isPrint() && c.unicode() < 127)
- buf[1] = char(c.unicode());
- d.putCommaIfNeeded();
- d.putItem(field, buf);
- d.putItem("numchild", "0", d.currentChildNumChild);
-}
-
-static void qDumpInnerCharValue(QDumper &d, char c, const char *field)
-{
- char buf[30];
- sprintf(buf, "'?', ascii=%d", c);
- if (QChar(QLatin1Char(c)).isPrint() && c < 127)
- buf[1] = c;
- d.putCommaIfNeeded();
- d.putItem(field, buf);
- d.putItem("numchild", "0", d.currentChildNumChild);
-}
-
-void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr,
- const char *field = "value")
-{
- type = stripNamespace(type);
- switch (type[1]) {
- case 'h':
- if (isEqual(type, "char"))
- qDumpInnerCharValue(d, *(char *)addr, field);
- break;
- case 'l':
- if (isEqual(type, "float"))
- d.putItem(field, *(float*)addr);
- break;
- case 'n':
- if (isEqual(type, "int"))
- d.putItem(field, *(int*)addr);
- else if (isEqual(type, "unsigned") || isEqual(type, "unsigned int"))
- d.putItem(field, *(unsigned int*)addr);
- else if (isEqual(type, "unsigned char"))
- qDumpInnerCharValue(d, *(char *)addr, field);
- else if (isEqual(type, "unsigned long"))
- d.putItem(field, *(unsigned long*)addr);
- else if (isEqual(type, "unsigned long long"))
- d.putItem(field, *(qulonglong*)addr);
- break;
- case 'o':
- if (isEqual(type, "bool")) {
- switch (*(unsigned char*)addr) {
- case 0: d.putItem(field, "false"); break;
- case 1: d.putItem(field, "true"); break;
- default: d.putItem(field, *(unsigned char*)addr); break;
- }
- } else if (isEqual(type, "double"))
- d.putItem(field, *(double*)addr);
- else if (isEqual(type, "long"))
- d.putItem(field, *(long*)addr);
- else if (isEqual(type, "long long"))
- d.putItem(field, *(qulonglong*)addr);
- break;
- case 'B':
- if (isEqual(type, "QByteArray")) {
- d.putCommaIfNeeded();
- d.put(field).put("encoded=\"1\",");
- d.putItem(field, *(QByteArray*)addr);
- }
- break;
- case 'C':
- if (isEqual(type, "QChar"))
- qDumpInnerQCharValue(d, *(QChar*)addr, field);
- break;
- case 'L':
- if (startsWith(type, "QList<")) {
- const QListData *ldata = reinterpret_cast<const QListData*>(addr);
- d.putItemCount("value", ldata->size());
- d.putItem("valueeditable", "false");
- d.putItem("numchild", ldata->size());
- }
- break;
- case 'O':
-# ifndef QT_BOOTSTRAPPED
- if (isEqual(type, "QObject *")) {
- if (addr) {
- const QObject *ob = reinterpret_cast<const QObject *>(addr);
- d.putItem("addr", ob);
- d.putItem("value", ob->objectName());
- d.putItem("valueencoded", "2");
- d.putItem("type", NS "QObject");
- d.putItem("displayedtype", ob->metaObject()->className());
- d.putItem("numchild", 1);
- } else {
- d.putItem("value", "0x0");
- d.putItem("type", NS "QObject *");
- d.putItem("numchild", 0);
- }
- }
-# endif
- break;
- case 'S':
- if (isEqual(type, "QString")) {
- d.putCommaIfNeeded();
- d.putItem(field, *(QString*)addr);
- d.put(',').put(field).put("encoded=\"2\"");
- }
- break;
- case 't':
- if (isEqual(type, "std::string")
- || isEqual(type, stdStringTypeC)) {
- d.putCommaIfNeeded();
- qDumpStdStringValue(d, *reinterpret_cast<const std::string*>(addr));
- } else if (isEqual(type, "std::wstring")
- || isEqual(type, stdWideStringTypeUShortC)) {
- qDumpStdWStringValue(d, *reinterpret_cast<const std::wstring*>(addr));
- }
- break;
- default:
- break;
- }
-}
-
-#if USE_QT_CORE
-static void qDumpInnerValue(QDumper &d, const char *type, const void *addr)
-{
- d.putItem("addr", addr);
- d.putItem("type", type, d.currentChildType);
-
- if (!type[0])
- return;
-
- return qDumpInnerValueHelper(d, type, addr);
-}
-#endif
-
-static void qDumpInnerValueOrPointer(QDumper &d,
- const char *type, const char *strippedtype, const void *addr)
-{
- if (strippedtype) {
- if (deref(addr)) {
- d.putItem("addr", deref(addr));
- d.putItem("type", strippedtype, d.currentChildType);
- qDumpInnerValueHelper(d, strippedtype, deref(addr));
- } else {
- d.putItem("addr", addr);
- d.putItem("type", strippedtype);
- d.putItem("value", "<null>");
- d.putItem("numchild", "0");
- }
- } else {
- d.putItem("addr", addr);
- d.putItem("type", type, d.currentChildType);
- qDumpInnerValueHelper(d, type, addr);
- }
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-#if USE_QT_CORE
-
-#ifndef QT_BOOTSTRAPPED
-struct ModelIndex { int r; int c; void *p; void *m; };
-
-static void qDumpQAbstractItem(QDumper &d)
-{
- QModelIndex mi;
- {
- ModelIndex *mm = reinterpret_cast<ModelIndex *>(&mi);
- memset(&mi, 0, sizeof(mi));
- static const char *printFormat = sizeof(void *) == sizeof(long) ?
- "%d,%d,0x%lx,0x%lx" : "%d,%d,0x%llx,0x%llx";
- sscanf(d.templateParameters[0], printFormat, &mm->r, &mm->c, &mm->p, &mm->m);
- }
- const QAbstractItemModel *m = mi.model();
- const int rowCount = m->rowCount(mi);
- if (rowCount < 0)
- return;
- const int columnCount = m->columnCount(mi);
- if (columnCount < 0)
- return;
- d.putItem("type", NS "QAbstractItem");
- d.beginItem("addr");
- d.put('$').put(mi.row()).put(',').put(mi.column()).put(',')
- .put(mi.internalPointer()).put(',').put(mi.model());
- d.endItem();
- //d.putItem("value", "(").put(rowCount).put(",").put(columnCount).put(")");
- d.putItem("value", m->data(mi, Qt::DisplayRole).toString());
- d.putItem("valueencoded", "2");
- d.putItem("numchild", rowCount * columnCount);
- if (d.dumpChildren) {
- d.beginChildren();
- for (int row = 0; row < rowCount; ++row) {
- for (int column = 0; column < columnCount; ++column) {
- QModelIndex child = m->index(row, column, mi);
- d.beginHash();
- d.beginItem("name");
- d.put("[").put(row).put(",").put(column).put("]");
- d.endItem();
- //d.putItem("numchild", (m->hasChildren(child) ? "1" : "0"));
- d.putItem("numchild", m->rowCount(child) * m->columnCount(child));
- d.beginItem("addr");
- d.put("$").put(child.row()).put(",").put(child.column()).put(",")
- .put(child.internalPointer()).put(",").put(child.model());
- d.endItem();
- d.putItem("type", NS "QAbstractItem");
- d.putItem("value", m->data(child, Qt::DisplayRole).toString());
- d.putItem("valueencoded", "2");
- d.endHash();
- }
- }
-/*
- d.beginHash();
- d.putItem("name", "DisplayRole");
- d.putItem("numchild", 0);
- d.putItem("value", m->data(mi, Qt::DisplayRole).toString());
- d.putItem("valueencoded", 2);
- d.putItem("type", NS "QString");
- d.endHash();
-*/
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQAbstractItemModel(QDumper &d)
-{
- const QAbstractItemModel &m = *reinterpret_cast<const QAbstractItemModel *>(d.data);
-
- const int rowCount = m.rowCount();
- if (rowCount < 0)
- return;
- const int columnCount = m.columnCount();
- if (columnCount < 0)
- return;
-
- d.putItem("type", NS "QAbstractItemModel");
- d.beginItem("value");
- d.put("(").put(rowCount).put(",").put(columnCount).put(")");
- d.endItem();
- d.putItem("numchild", "1");
- if (d.dumpChildren) {
- d.beginChildren();
- d.beginHash();
- d.putItem("numchild", "1");
- d.putItem("name", NS "QObject");
- d.putItem("addr", d.data);
- d.putItem("value", m.objectName());
- d.putItem("valueencoded", "2");
- d.putItem("type", NS "QObject");
- d.putItem("displayedtype", m.metaObject()->className());
- d.endHash();
- for (int row = 0; row < rowCount; ++row) {
- for (int column = 0; column < columnCount; ++column) {
- QModelIndex mi = m.index(row, column);
- d.beginHash();
- d.beginItem("name");
- d.put("[").put(row).put(",").put(column).put("]");
- d.endItem();
- d.putItem("value", m.data(mi, Qt::DisplayRole).toString());
- d.putItem("valueencoded", "2");
- //d.putItem("numchild", (m.hasChildren(mi) ? "1" : "0"));
- d.putItem("numchild", m.rowCount(mi) * m.columnCount(mi));
- d.beginItem("addr");
- d.put("$").put(mi.row()).put(",").put(mi.column()).put(",");
- d.put(mi.internalPointer()).put(",").put(mi.model());
- d.endItem();
- d.putItem("type", NS "QAbstractItem");
- d.endHash();
- }
- }
- d.endChildren();
- }
- d.disarm();
-}
-#endif // QT_BOOTSTRAPPED
-
-static void qDumpQByteArray(QDumper &d)
-{
- qCheckAccess(deref(d.data)); // is the d-ptr de-referenceable and valid
- const QByteArray &ba = *reinterpret_cast<const QByteArray *>(d.data);
-
- const int size = ba.size();
- if (size < 0)
- return;
-
- if (!ba.isEmpty()) {
- qCheckAccess(ba.constData());
- qCheckAccess(ba.constData() + size);
- }
-
- d.beginItem("value");
- if (size <= 100)
- d.put(ba);
- else
- d.put(ba.left(100)).put(" <size: ").put(size).put(", cut...>");
- d.endItem();
- d.putItem("valueencoded", "1");
- d.putItem("type", NS "QByteArray");
- d.putItem("numchild", size);
- if (d.dumpChildren) {
- d.putItem("childtype", "char");
- d.putItem("childnumchild", "0");
- d.beginChildren();
- char buf[20];
- for (int i = 0; i != size; ++i) {
- unsigned char c = ba.at(i);
- unsigned char u = (isprint(c) && c != '\'' && c != '"') ? c : '?';
- sprintf(buf, "%02x (%u '%c')", c, c, u);
- d.beginHash();
- d.putItem("value", buf);
- d.endHash();
- }
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQChar(QDumper &d)
-{
- qDumpInnerQCharValue(d, *reinterpret_cast<const QChar *>(d.data), "value");
- d.disarm();
-}
-
-static void qDumpQDate(QDumper &d)
-{
-#ifdef QT_NO_DATESTRING
- qDumpUnknown(d);
-#else
- const QDate &date = *reinterpret_cast<const QDate *>(d.data);
- if (date.isNull()) {
- d.putItem("value", "(null)");
- d.putItem("type", NS "QDate");
- d.putItem("numchild", "0");
- return;
- }
- d.putItem("value", date.toString());
- d.putItem("valueencoded", "2");
- d.putItem("type", NS "QDate");
- d.putItem("numchild", "1");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("isNull", date.isNull());
- d.putHash("toString", date.toString());
-# if QT_VERSION >= 0x040500
- d.putHash("toString_(ISO)", date.toString(Qt::ISODate));
- d.putHash("toString_(SystemLocale)", date.toString(Qt::SystemLocaleDate));
- d.putHash("toString_(Locale)", date.toString(Qt::LocaleDate));
-# endif
- d.endChildren();
- }
- d.disarm();
-#endif // ifdef QT_NO_DATESTRING
-}
-
-static void qDumpQTime(QDumper &d)
-{
-#ifdef QT_NO_DATESTRING
- qDumpUnknown(d);
-#else
- const QTime &date = *reinterpret_cast<const QTime *>(d.data);
- if (date.isNull()) {
- d.putItem("value", "(null)");
- d.putItem("type", NS "QTime");
- d.putItem("numchild", "0");
- return;
- }
- d.putItem("value", date.toString());
- d.putItem("valueencoded", "2");
- d.putItem("type", NS "QTime");
- d.putItem("numchild", "1");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("isNull", date.isNull());
- d.putHash("toString", date.toString());
-# if QT_VERSION >= 0x040500
- d.putHash("toString_(ISO)", date.toString(Qt::ISODate));
- d.putHash("toString_(SystemLocale)", date.toString(Qt::SystemLocaleDate));
- d.putHash("toString_(Locale)", date.toString(Qt::LocaleDate));
-# endif
- d.endChildren();
- }
- d.disarm();
-#endif // ifdef QT_NO_DATESTRING
-}
-
-static void qDumpQDateTime(QDumper &d)
-{
-#ifdef QT_NO_DATESTRING
- qDumpUnknown(d);
-#else
- const QDateTime &date = *reinterpret_cast<const QDateTime *>(d.data);
- if (date.isNull()) {
- d.putItem("value", "(null)");
- d.putItem("type", NS "QDateTime");
- d.putItem("numchild", "0");
- d.disarm();
- return;
- }
- d.putItem("value", date.toString());
- d.putItem("valueencoded", "2");
- d.putItem("type", NS "QDateTime");
- d.putItem("numchild", "1");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("toTime_t", (long)date.toTime_t());
- d.putHash("toString", date.toString());
-# if QT_VERSION >= 0x040500
- d.putHash("toString_(ISO)", date.toString(Qt::ISODate));
- d.putHash("toString_(SystemLocale)", date.toString(Qt::SystemLocaleDate));
- d.putHash("toString_(Locale)", date.toString(Qt::LocaleDate));
-# endif
-
-# if 0
- d.beginHash();
- d.putItem("name", "toUTC");
- d.putItem("exp", "((" NSX "QDateTime" NSY "*)").put(d.data).put(")"
- "->toTimeSpec('" NS "Qt::UTC')");
- d.putItem("type", NS "QDateTime");
- d.putItem("numchild", "1");
- d.endHash();
-# endif
-
-# if 0
- d.beginHash();
- d.putItem("name", "toLocalTime");
- d.putItem("exp", "((" NSX "QDateTime" NSY "*)").put(d.data).put(")"
- "->toTimeSpec('" NS "Qt::LocalTime')");
- d.putItem("type", NS "QDateTime");
- d.putItem("numchild", "1");
- d.endHash();
-# endif
-
- d.endChildren();
- }
- d.disarm();
-#endif // ifdef QT_NO_DATESTRING
-}
-
-static void qDumpQDir(QDumper &d)
-{
- const QDir &dir = *reinterpret_cast<const QDir *>(d.data);
- d.putItem("value", dir.path());
- d.putItem("valueencoded", "2");
- d.putItem("type", NS "QDir");
- d.putItem("numchild", "3");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("absolutePath", dir.absolutePath());
- d.putHash("canonicalPath", dir.canonicalPath());
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQFile(QDumper &d)
-{
- const QFile &file = *reinterpret_cast<const QFile *>(d.data);
- d.putItem("value", file.fileName());
- d.putItem("valueencoded", "2");
- d.putItem("type", NS "QFile");
- d.putItem("numchild", "2");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("fileName", file.fileName());
- d.putHash("exists", file.exists());
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQFileInfo(QDumper &d)
-{
- const QFileInfo &info = *reinterpret_cast<const QFileInfo *>(d.data);
- d.putItem("value", info.filePath());
- d.putItem("valueencoded", "2");
- d.putItem("type", NS "QFileInfo");
- d.putItem("numchild", "3");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("absolutePath", info.absolutePath());
- d.putHash("absoluteFilePath", info.absoluteFilePath());
- d.putHash("canonicalPath", info.canonicalPath());
- d.putHash("canonicalFilePath", info.canonicalFilePath());
- d.putHash("completeBaseName", info.completeBaseName());
- d.putHash("completeSuffix", info.completeSuffix());
- d.putHash("baseName", info.baseName());
-#ifdef Q_OS_MACX
- d.putHash("isBundle", info.isBundle());
- d.putHash("bundleName", info.bundleName());
-#endif
- d.putHash("fileName", info.fileName());
- d.putHash("filePath", info.filePath());
- d.putHash("group", info.group());
- d.putHash("owner", info.owner());
- d.putHash("path", info.path());
-
- d.putHash("groupid", (long)info.groupId());
- d.putHash("ownerid", (long)info.ownerId());
- //QFile::Permissions permissions () const
- long perms = info.permissions();
- d.beginHash();
- d.putItem("name", "permissions");
- d.putItem("value", " ");
- d.putItem("type", NS "QFile::Permissions");
- d.putItem("numchild", 10);
- d.beginChildren();
- d.putHash("ReadOwner", bool(perms & QFile::ReadOwner));
- d.putHash("WriteOwner", bool(perms & QFile::WriteOwner));
- d.putHash("ExeOwner", bool(perms & QFile::ExeOwner));
- d.putHash("ReadUser", bool(perms & QFile::ReadUser));
- d.putHash("WriteUser", bool(perms & QFile::WriteUser));
- d.putHash("ExeUser", bool(perms & QFile::ExeUser));
- d.putHash("ReadGroup", bool(perms & QFile::ReadGroup));
- d.putHash("WriteGroup", bool(perms & QFile::WriteGroup));
- d.putHash("ExeGroup", bool(perms & QFile::ExeGroup));
- d.putHash("ReadOther", bool(perms & QFile::ReadOther));
- d.putHash("WriteOther", bool(perms & QFile::WriteOther));
- d.putHash("ExeOther", bool(perms & QFile::ExeOther));
- d.endChildren();
- d.endHash();
- //QDir absoluteDir () const
- //QDir dir () const
- d.putHash("caching", info.caching());
- d.putHash("exists", info.exists());
- d.putHash("isAbsolute", info.isAbsolute());
- d.putHash("isDir", info.isDir());
- d.putHash("isExecutable", info.isExecutable());
- d.putHash("isFile", info.isFile());
- d.putHash("isHidden", info.isHidden());
- d.putHash("isReadable", info.isReadable());
- d.putHash("isRelative", info.isRelative());
- d.putHash("isRoot", info.isRoot());
- d.putHash("isSymLink", info.isSymLink());
- d.putHash("isWritable", info.isWritable());
-
- d.beginHash();
- d.putItem("name", "created");
- d.putItem("value", info.created().toString());
- d.putItem("valueencoded", "2");
- d.beginItem("exp");
- d.put("((" NSX "QFileInfo" NSY "*)").put(d.data).put(")->created()");
- d.endItem();
- d.putItem("type", NS "QDateTime");
- d.putItem("numchild", "1");
- d.endHash();
-
- d.beginHash();
- d.putItem("name", "lastModified");
- d.putItem("value", info.lastModified().toString());
- d.putItem("valueencoded", "2");
- d.beginItem("exp");
- d.put("((" NSX "QFileInfo" NSY "*)").put(d.data).put(")->lastModified()");
- d.endItem();
- d.putItem("type", NS "QDateTime");
- d.putItem("numchild", "1");
- d.endHash();
-
- d.beginHash();
- d.putItem("name", "lastRead");
- d.putItem("value", info.lastRead().toString());
- d.putItem("valueencoded", "2");
- d.beginItem("exp");
- d.put("((" NSX "QFileInfo" NSY "*)").put(d.data).put(")->lastRead()");
- d.endItem();
- d.putItem("type", NS "QDateTime");
- d.putItem("numchild", "1");
- d.endHash();
-
- d.endChildren();
- }
- d.disarm();
-}
-
-bool isOptimizedIntKey(const char *keyType)
-{
- return isEqual(keyType, "int")
-#if defined(Q_BYTE_ORDER) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN
- || isEqual(keyType, "short")
- || isEqual(keyType, "ushort")
-#endif
- || isEqual(keyType, "uint");
-}
-
-int hashOffset(bool optimizedIntKey, bool forKey, unsigned keySize, unsigned valueSize)
-{
- // int-key optimization, small value
- struct NodeOS { void *next; uint k; uint v; } nodeOS;
- // int-key optimiatzion, large value
- struct NodeOL { void *next; uint k; void *v; } nodeOL;
- // no optimization, small value
- struct NodeNS { void *next; uint h; uint k; uint v; } nodeNS;
- // no optimization, large value
- struct NodeNL { void *next; uint h; uint k; void *v; } nodeNL;
- // complex key
- struct NodeL { void *next; uint h; void *k; void *v; } nodeL;
-
- if (forKey) {
- // offsetof(...,...) not yet in Standard C++
- const ulong nodeOSk ( (char *)&nodeOS.k - (char *)&nodeOS );
- const ulong nodeOLk ( (char *)&nodeOL.k - (char *)&nodeOL );
- const ulong nodeNSk ( (char *)&nodeNS.k - (char *)&nodeNS );
- const ulong nodeNLk ( (char *)&nodeNL.k - (char *)&nodeNL );
- const ulong nodeLk ( (char *)&nodeL.k - (char *)&nodeL );
- if (optimizedIntKey)
- return valueSize > sizeof(int) ? nodeOLk : nodeOSk;
- if (keySize > sizeof(int))
- return nodeLk;
- return valueSize > sizeof(int) ? nodeNLk : nodeNSk;
- } else {
- const ulong nodeOSv ( (char *)&nodeOS.v - (char *)&nodeOS );
- const ulong nodeOLv ( (char *)&nodeOL.v - (char *)&nodeOL );
- const ulong nodeNSv ( (char *)&nodeNS.v - (char *)&nodeNS );
- const ulong nodeNLv ( (char *)&nodeNL.v - (char *)&nodeNL );
- const ulong nodeLv ( (char *)&nodeL.v - (char *)&nodeL );
- if (optimizedIntKey)
- return valueSize > sizeof(int) ? nodeOLv : nodeOSv;
- if (keySize > sizeof(int))
- return nodeLv;
- return valueSize > sizeof(int) ? nodeNLv : nodeNSv;
- }
-}
-
-static void qDumpQHash(QDumper &d)
-{
- qCheckAccess(deref(d.data)); // is the d-ptr de-referenceable and valid
- const char *keyType = d.templateParameters[0];
- const char *valueType = d.templateParameters[1];
-
- QHashData *h = *reinterpret_cast<QHashData *const*>(d.data);
- qCheckPointer(h->fakeNext);
- qCheckPointer(h->buckets);
-
- unsigned keySize = d.extraInt[0];
- unsigned valueSize = d.extraInt[1];
-
- int n = h->size;
-
- if (n < 0)
- return;
- if (n > 0) {
- qCheckPointer(h->fakeNext);
- qCheckPointer(*h->buckets);
- }
-
- d.putItemCount("value", n);
- d.putItem("numchild", n);
-
- if (d.dumpChildren) {
- const bool isSimpleKey = isSimpleType(keyType);
- const bool isSimpleValue = isSimpleType(valueType);
- const bool opt = isOptimizedIntKey(keyType);
- const int keyOffset = hashOffset(opt, true, keySize, valueSize);
- const int valueOffset = hashOffset(opt, false, keySize, valueSize);
-
-#if 0
- d.beginItem("extra");
- d.put("isSimpleKey: ").put(isSimpleKey);
- d.put(" isSimpleValue: ").put(isSimpleValue);
- d.put(" valueType: '").put(isSimpleValue);
- d.put(" keySize: ").put(keyOffset);
- d.put(" valueOffset: ").put(valueOffset);
- d.put(" opt: ").put(opt);
- d.endItem();
-#endif
- QHashData::Node *node = h->firstNode();
- QHashData::Node *end = reinterpret_cast<QHashData::Node *>(h);
- int i = 0;
-
- d.beginChildren();
- while (node != end) {
- d.beginHash();
- qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
- qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
- if (isSimpleKey && isSimpleValue) {
- d.putItem("type", valueType);
- d.putItem("addr", addOffset(node, valueOffset));
- } else {
- d.putItem("addr", node);
- d.beginItem("type");
- d.put(NS "QHashNode<").put(keyType).put(",")
- .put(valueType).put(" >");
- d.endItem();
- }
- d.endHash();
- ++i;
- node = QHashData::nextNode(node);
- }
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQHashNode(QDumper &d)
-{
- const QHashData *h = reinterpret_cast<const QHashData *>(d.data);
- const char *keyType = d.templateParameters[0];
- const char *valueType = d.templateParameters[1];
-
- unsigned keySize = d.extraInt[0];
- unsigned valueSize = d.extraInt[1];
- bool opt = isOptimizedIntKey(keyType);
- int keyOffset = hashOffset(opt, true, keySize, valueSize);
- int valueOffset = hashOffset(opt, false, keySize, valueSize);
- if (isSimpleType(valueType))
- qDumpInnerValueHelper(d, valueType, addOffset(h, valueOffset));
- else
- d.putItem("value", "");
-
- d.putItem("numchild", 2);
- if (d.dumpChildren) {
- // there is a hash specialization in case the keys are integers or shorts
- d.beginChildren();
- d.beginHash();
- d.putItem("name", "key");
- d.putItem("type", keyType);
- d.putItem("addr", addOffset(h, keyOffset));
- d.endHash();
- d.beginHash();
- d.putItem("name", "value");
- d.putItem("type", valueType);
- d.putItem("addr", addOffset(h, valueOffset));
- d.endHash();
- d.endChildren();
- }
- d.disarm();
-}
-
-#if USE_QT_GUI
-static void qDumpQImage(QDumper &d)
-{
- qCheckAccess(deref(d.data)); // is the d-ptr de-referenceable and valid
- const QImage &im = *reinterpret_cast<const QImage *>(d.data);
- d.beginItem("value");
- d.put("(").put(im.width()).put("x").put(im.height()).put(")");
- d.endItem();
- d.putItem("type", NS "QImage");
- d.putItem("numchild", "0");
-#if 0
- if (d.dumpChildren) {
- d.beginChildren();
- d.beginHash();
- d.putItem("name", "data");
- d.putItem("type", NS "QImageData");
- d.putItem("addr", d.data);
- d.endHash();
- d.endChildren();
- }
-#endif
- d.disarm();
-}
-#endif
-
-#if USE_QT_GUI
-static void qDumpQImageData(QDumper &d)
-{
- const QImage &im = *reinterpret_cast<const QImage *>(d.data);
- const QByteArray ba(QByteArray::fromRawData((const char*)im.bits(), im.byteCount()));
- d.putItem("type", NS "QImageData");
- d.putItem("numchild", "0");
-#if 1
- d.putItem("value", "<hover here>");
- d.putItem("valuetooltipencoded", "1");
- d.putItem("valuetooltipsize", ba.size());
- d.putItem("valuetooltip", ba);
-#else
- d.putItem("valueencoded", "1");
- d.putItem("value", ba);
-#endif
- d.disarm();
-}
-#endif
-
-static void qDumpQList(QDumper &d)
-{
- qCheckAccess(deref(d.data)); // is the d-ptr de-referenceable and valid
- // This uses the knowledge that QList<T> has only a single member
- // of type union { QListData p; QListData::Data *d; };
-
- const QListData &pdata = *reinterpret_cast<const QListData*>(d.data);
- const int nn = pdata.size();
- if (nn < 0)
- return;
- const bool innerTypeIsPointer = isPointerType(d.innerType);
- const int n = qMin(nn, 1000);
- if (nn > 0) {
- if (pdata.d->begin < 0)
- return;
- if (pdata.d->begin > pdata.d->end)
- return;
-#if QT_VERSION >= 0x050000
- if (pdata.d->ref.atomic._q_value <= 0)
- return;
-#elif QT_VERSION >= 0x040400
- if (pdata.d->ref._q_value <= 0)
- return;
-#endif
- qCheckAccess(pdata.d->array);
- // Additional checks on pointer arrays
- if (innerTypeIsPointer)
- for (int i = 0; i != n; ++i)
- if (const void *p = pdata.d->array + i + pdata.d->begin)
- qCheckPointer(deref(p));
- }
-
- d.putItemCount("value", nn);
- d.putItem("valueeditable", "false");
- d.putItem("numchild", n);
- if (d.dumpChildren) {
- const unsigned innerSize = d.extraInt[0];
- QByteArray strippedInnerType = stripPointerType(d.innerType);
-
- // The exact condition here is:
- // QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic
- // but this data is available neither in the compiled binary nor
- // in the frontend.
- // So as first approximation only do the 'isLarge' check:
- bool isInternal = innerSize <= int(sizeof(void*))
- && isMovableType(d.innerType);
- d.putItem("internal", (int)isInternal);
- d.beginChildren(n ? d.innerType : 0);
- for (int i = 0; i != n; ++i) {
- d.beginHash();
- if (innerTypeIsPointer) {
- void *p = pdata.d->array + i + pdata.d->begin;
- if (*(void**)p) {
- //d.putItem("value","@").put(p);
- qDumpInnerValue(d, strippedInnerType.data(), deref(p));
- } else {
- d.putItem("value", "<null>");
- d.putItem("numchild", "0");
- }
- } else {
- void *p = pdata.d->array + i + pdata.d->begin;
- if (isInternal) {
- //qDumpInnerValue(d, d.innerType, p);
- d.putItem("addr", p);
- qDumpInnerValueHelper(d, d.innerType, p);
- } else {
- //qDumpInnerValue(d, d.innerType, deref(p));
- d.putItem("addr", deref(p));
- qDumpInnerValueHelper(d, d.innerType, deref(p));
- }
- }
- d.endHash();
- }
- if (n < nn)
- d.putEllipsis();
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQLinkedList(QDumper &d)
-{
- qCheckAccess(deref(d.data)); // is the d-ptr de-referenceable and valid
- // This uses the knowledge that QLinkedList<T> has only a single member
- // of type union { QLinkedListData *d; QLinkedListNode<T> *e; };
- const QLinkedListData *ldata =
- reinterpret_cast<const QLinkedListData*>(deref(d.data));
- int nn = ldata->size;
- if (nn < 0)
- return;
-
- int n = nn;
- d.putItemCount("value", n);
- d.putItem("valueeditable", "false");
- d.putItem("numchild", n);
- if (d.dumpChildren) {
- //unsigned innerSize = d.extraInt[0];
- //bool innerTypeIsPointer = isPointerType(d.innerType);
- QByteArray strippedInnerType = stripPointerType(d.innerType);
- const char *stripped =
- isPointerType(d.innerType) ? strippedInnerType.data() : 0;
-
- if (n > 1000)
- n = 1000;
- d.beginChildren(d.innerType);
- const void *p = deref(ldata);
- for (int i = 0; i != n; ++i) {
- d.beginHash();
- const void *addr = addOffset(p, 2 * sizeof(void*));
- qDumpInnerValueOrPointer(d, d.innerType, stripped, addr);
- p = deref(p);
- d.endHash();
- }
- if (n < nn)
- d.putEllipsis();
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQLocale(QDumper &d)
-{
- const QLocale &locale = *reinterpret_cast<const QLocale *>(d.data);
- d.putItem("value", locale.name());
- d.putItem("valueencoded", "2");
- d.putItem("type", NS "QLocale");
- d.putItem("numchild", "8");
- if (d.dumpChildren) {
- d.beginChildren();
-
- d.beginHash();
- d.putItem("name", "country");
- d.beginItem("exp");
- d.put("((" NSX "QLocale" NSY "*)").put(d.data).put(")->country()");
- d.endItem();
- d.endHash();
-
- d.beginHash();
- d.putItem("name", "language");
- d.beginItem("exp");
- d.put("((" NSX "QLocale" NSY "*)").put(d.data).put(")->language()");
- d.endItem();
- d.endHash();
-
- d.beginHash();
- d.putItem("name", "measurementSystem");
- d.beginItem("exp");
- d.put("((" NSX "QLocale" NSY "*)").put(d.data).put(")->measurementSystem()");
- d.endItem();
- d.endHash();
-
- d.beginHash();
- d.putItem("name", "numberOptions");
- d.beginItem("exp");
- d.put("((" NSX "QLocale" NSY "*)").put(d.data).put(")->numberOptions()");
- d.endItem();
- d.endHash();
-
- d.putHash("timeFormat_(short)", locale.timeFormat(QLocale::ShortFormat));
- d.putHash("timeFormat_(long)", locale.timeFormat(QLocale::LongFormat));
-
- d.putHash("decimalPoint", locale.decimalPoint());
- d.putHash("exponential", locale.exponential());
- d.putHash("percent", locale.percent());
- d.putHash("zeroDigit", locale.zeroDigit());
- d.putHash("groupSeparator", locale.groupSeparator());
- d.putHash("negativeSign", locale.negativeSign());
-
- d.endChildren();
- }
- d.disarm();
-}
-
-#if MAP_WORKS
-static void qDumpQMapNode(QDumper &d)
-{
- const QMapData *h = reinterpret_cast<const QMapData *>(d.data);
- const char *keyType = d.templateParameters[0];
- const char *valueType = d.templateParameters[1];
-
- qCheckAccess(h->backward);
- qCheckAccess(h->forward[0]);
-
- d.putItem("value", "");
- d.putItem("numchild", 2);
- if (d.dumpChildren) {
- unsigned mapnodesize = d.extraInt[2];
- unsigned valueOff = d.extraInt[3];
-
- unsigned keyOffset = 2 * sizeof(void*) - mapnodesize;
- unsigned valueOffset = 2 * sizeof(void*) - mapnodesize + valueOff;
-
- d.beginChildren();
- d.beginHash();
- d.putItem("name", "key");
- qDumpInnerValue(d, keyType, addOffset(h, keyOffset));
-
- d.endHash();
- d.beginHash();
- d.putItem("name", "value");
- qDumpInnerValue(d, valueType, addOffset(h, valueOffset));
- d.endHash();
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQMap(QDumper &d)
-{
- qCheckAccess(deref(d.data)); // is the d-ptr de-referenceable and valid
- QMapData *h = *reinterpret_cast<QMapData *const*>(d.data);
- const char *keyType = d.templateParameters[0];
- const char *valueType = d.templateParameters[1];
-
- int n = h->size;
-
- if (n < 0)
- return;
- if (n > 0) {
- qCheckAccess(h->backward);
- qCheckAccess(h->forward[0]);
- qCheckPointer(h->backward->backward);
- qCheckPointer(h->forward[0]->backward);
- }
-
- d.putItemCount("value", n);
- d.putItem("numchild", n);
- if (d.dumpChildren) {
- //unsigned keySize = d.extraInt[0];
- //unsigned valueSize = d.extraInt[1];
- unsigned mapnodesize = d.extraInt[2];
- unsigned valueOff = d.extraInt[3];
-
- bool isSimpleKey = isSimpleType(keyType);
- bool isSimpleValue = isSimpleType(valueType);
- // both negative:
- int keyOffset = 2 * sizeof(void*) - int(mapnodesize);
- int valueOffset = 2 * sizeof(void*) - int(mapnodesize) + valueOff;
-
- d.beginItem("extra");
- d.put("simplekey: ").put(isSimpleKey).put(" isSimpleValue: ").put(isSimpleValue);
- d.put(" keyOffset: ").put(keyOffset).put(" valueOffset: ").put(valueOffset);
- d.put(" mapnodesize: ").put(mapnodesize);
- d.endItem();
- d.beginChildren();
-
- QMapData::Node *node = reinterpret_cast<QMapData::Node *>(h->forward[0]);
- QMapData::Node *end = reinterpret_cast<QMapData::Node *>(h);
- int i = 0;
-
- while (node != end) {
- d.beginHash();
- qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
- qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
- if (isSimpleKey && isSimpleValue) {
- d.putItem("type", valueType);
- d.putItem("addr", addOffset(node, valueOffset));
- } else {
-#if QT_VERSION >= 0x040500
- d.putItem("addr", node);
- // actually, any type (even 'char') will do...
- d.beginItem("type");
- d.put(NS "QMapNode<").put(keyType).put(",");
- d.put(valueType).put(" >");
- d.endItem();
-#else
- d.beginItem("type");
- d.put(NS "QMapData::Node<").put(keyType).put(",");
- d.put(valueType).put(" >");
- d.endItem();
- d.beginItem("exp");
- d.put("*('" NS "QMapData::Node<").put(keyType).put(",");
- d.put(valueType).put(" >'*)").put(node);
- d.endItem();
-#endif
- }
- d.endHash();
-
- ++i;
- node = node->forward[0];
- }
- d.endChildren();
- }
-
- d.disarm();
-}
-
-static void qDumpQMultiMap(QDumper &d)
-{
- qDumpQMap(d);
-}
-#endif // MAP_WORKS
-
-#ifndef QT_BOOTSTRAPPED
-static void qDumpQModelIndex(QDumper &d)
-{
- const QModelIndex *mi = reinterpret_cast<const QModelIndex *>(d.data);
-
- d.putItem("type", NS "QModelIndex");
- if (mi->isValid()) {
- d.beginItem("value");
- d.put("(").put(mi->row()).put(", ").put(mi->column()).put(")");
- d.endItem();
- d.putItem("numchild", 5);
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("row", mi->row());
- d.putHash("column", mi->column());
-
- d.beginHash();
- d.putItem("name", "parent");
- const QModelIndex parent = mi->parent();
- d.beginItem("value");
- if (parent.isValid())
- d.put("(").put(parent.row()).put(", ").put(parent.column()).put(")");
- else
- d.put("<invalid>");
- d.endItem();
- d.beginItem("exp");
- d.put("((" NSX "QModelIndex" NSY "*)").put(d.data).put(")->parent()");
- d.endItem();
- d.putItem("type", NS "QModelIndex");
- d.putItem("numchild", "1");
- d.endHash();
-
- d.putHash("internalId", QString::number(mi->internalId(), 10));
-
- d.beginHash();
- d.putItem("name", "model");
- d.putItem("value", static_cast<const void *>(mi->model()));
- d.putItem("type", NS "QAbstractItemModel*");
- d.putItem("numchild", "1");
- d.endHash();
-
- d.endChildren();
- }
- } else {
- d.putItem("value", "<invalid>");
- d.putItem("numchild", 0);
- }
-
- d.disarm();
-}
-
-static void qDumpQObject(QDumper &d)
-{
- qCheckAccess(deref(d.data)); // is the d-ptr de-referenceable and valid
- const QObject *ob = reinterpret_cast<const QObject *>(d.data);
- const QMetaObject *mo = ob->metaObject();
- d.putItem("value", ob->objectName());
- d.putItem("valueencoded", "2");
- d.putItem("type", NS "QObject");
- d.putItem("displayedtype", mo->className());
- d.putItem("numchild", 4);
- if (d.dumpChildren) {
- int slotCount = 0;
- int signalCount = 0;
- for (int i = mo->methodCount(); --i >= 0; ) {
- QMetaMethod::MethodType mt = mo->method(i).methodType();
- signalCount += (mt == QMetaMethod::Signal);
- slotCount += (mt == QMetaMethod::Slot);
- }
- d.beginChildren();
- d.beginHash();
- d.putItem("name", "properties");
- // using 'addr' does not work in gdb as 'exp' is recreated as
- // (type *)addr, and here we have different 'types':
- // QObject vs QObjectPropertyList!
- d.putItem("addr", d.data);
- d.putItem("type", NS "QObjectPropertyList");
- d.putItemCount("value", mo->propertyCount());
- d.putItem("numchild", mo->propertyCount());
- d.endHash();
- d.beginHash();
- d.putItem("name", "signals");
- d.putItem("addr", d.data);
- d.putItem("type", NS "QObjectSignalList");
- d.putItemCount("value", signalCount);
- d.putItem("numchild", signalCount);
- d.endHash();
- d.beginHash();
- d.putItem("name", "slots");
- d.putItem("addr", d.data);
- d.putItem("type", NS "QObjectSlotList");
- d.putItemCount("value", slotCount);
- d.putItem("numchild", slotCount);
- d.endHash();
- const QObjectList objectChildren = ob->children();
- if (!objectChildren.empty()) {
- d.beginHash();
- d.putItem("name", "children");
- d.putItem("addr", d.data);
- d.putItem("type", NS "QObjectChildList");
- d.putItemCount("value", objectChildren.size());
- d.putItem("numchild", objectChildren.size());
- d.endHash();
- }
- d.beginHash();
- d.putItem("name", "parent");
- qDumpInnerValueHelper(d, NS "QObject *", ob->parent());
- d.endHash();
-#if 1
- d.beginHash();
- d.putItem("name", "className");
- d.putItem("value", ob->metaObject()->className());
- d.putItem("type", "");
- d.putItem("numchild", "0");
- d.endHash();
-#endif
- d.endChildren();
- }
- d.disarm();
-}
-#endif // QT_BOOTSTRAPPED
-
-#if USE_QT_GUI
-static const char *sizePolicyEnumValue(QSizePolicy::Policy p)
-{
- switch (p) {
- case QSizePolicy::Fixed:
- return "Fixed";
- case QSizePolicy::Minimum:
- return "Minimum";
- case QSizePolicy::Maximum:
- return "Maximum";
- case QSizePolicy::Preferred:
- return "Preferred";
- case QSizePolicy::Expanding:
- return "Expanding";
- case QSizePolicy::MinimumExpanding:
- return "MinimumExpanding";
- case QSizePolicy::Ignored:
- break;
- }
- return "Ignored";
-}
-
-static QString sizePolicyValue(const QSizePolicy &sp)
-{
- QString rc;
- QTextStream str(&rc);
- // Display as in Designer
- str << '[' << sizePolicyEnumValue(sp.horizontalPolicy())
- << ", " << sizePolicyEnumValue(sp.verticalPolicy())
- << ", " << sp.horizontalStretch() << ", " << sp.verticalStretch() << ']';
- return rc;
-}
-#endif
-
-static void qDumpQVariantHelper(const QVariant *v, QString *value,
- QString *exp, int *numchild)
-{
- switch (v->type()) {
- case QVariant::Invalid:
- *value = QLatin1String("<invalid>");
- *numchild = 0;
- break;
- case QVariant::String:
- *value = QLatin1Char('"') + v->toString() + QLatin1Char('"');
- *numchild = 0;
- break;
-# if QT_VERSION >= 0x040500
- case QVariant::StringList:
- *exp = QString(QLatin1String("(*('" NS "QStringList'*)%1)"))
- .arg((quintptr)v);
- *numchild = v->toStringList().size();
- break;
-# endif
- case QVariant::Int:
- *value = QString::number(v->toInt());
- *numchild= 0;
- break;
- case QVariant::Double:
- *value = QString::number(v->toDouble());
- *numchild = 0;
- break;
-# ifndef QT_BOOTSTRAPPED
- case QVariant::Point: {
- const QPoint p = v->toPoint();
- *value = QString::fromLatin1("%1, %2").arg(p.x()).arg(p.y());
- }
- *numchild = 0;
- break;
- case QVariant::Size: {
- const QSize size = v->toSize();
- *value = QString::fromLatin1("%1x%2")
- .arg(size.width()).arg(size.height());
- }
- *numchild = 0;
- break;
- case QVariant::Rect: {
- const QRect rect = v->toRect();
- *value = QString::fromLatin1("%1x%2+%3+%4")
- .arg(rect.width()).arg(rect.height())
- .arg(rect.x()).arg(rect.y());
- }
- *numchild = 0;
- break;
- case QVariant::PointF: {
- const QPointF p = v->toPointF();
- *value = QString::fromLatin1("%1, %2").arg(p.x()).arg(p.y());
- }
- *numchild = 0;
- break;
-
- case QVariant::SizeF: {
- const QSizeF size = v->toSizeF();
- *value = QString::fromLatin1("%1x%2")
- .arg(size.width()).arg(size.height());
- }
- *numchild = 0;
- break;
- case QVariant::RectF: {
- const QRectF rect = v->toRectF();
- *value = QString::fromLatin1("%1x%2+%3+%4")
- .arg(rect.width()).arg(rect.height())
- .arg(rect.x()).arg(rect.y());
- }
- *numchild = 0;
- break;
-# endif // QT_BOOTSTRAPPED
-# if USE_QT_GUI
- case QVariant::Font:
- *value = qvariant_cast<QFont>(*v).toString();
- break;
- case QVariant::Color:
- *value = qvariant_cast<QColor>(*v).name();
- break;
- case QVariant::KeySequence:
-# ifndef QT_NO_SHORTCUT
- *value = qvariant_cast<QKeySequence>(*v).toString();
-# else
- *value = QString::fromLatin1("Disabled by QT_NO_SHORTCUT");
-# endif
- break;
- case QVariant::SizePolicy:
- *value = sizePolicyValue(qvariant_cast<QSizePolicy>(*v));
- break;
-# endif
- default: {
- static const char *qTypeFormat = sizeof(void *) == sizeof(long)
- ? "'" NS "%s " NS "qvariant_cast<" NS "%s >'(*('" NS "QVariant'*)0x%lx)"
- : "'" NS "%s " NS "qvariant_cast<" NS "%s >'(*('" NS "QVariant'*)0x%llx)";
- static const char *nonQTypeFormat = sizeof(void *) == sizeof(long)
- ? "'%s " NS "qvariant_cast<%s >'(*('" NS "QVariant'*)0x%lx)"
- : "'%s " NS "qvariant_cast<%s >'(*('" NS "QVariant'*)0x%llx)";
- char buf[1000];
- const char *format = (v->typeName()[0] == 'Q') ? qTypeFormat : nonQTypeFormat;
- qsnprintf(buf, sizeof(buf) - 1, format, v->typeName(), v->typeName(), v);
- *exp = QLatin1String(buf);
- *numchild = 1;
- break;
- }
- }
-}
-
-static void qDumpQVariant(QDumper &d, const QVariant *v)
-{
- QString value;
- QString exp;
- int numchild = 0;
- qDumpQVariantHelper(v, &value, &exp, &numchild);
- bool isInvalid = (v->typeName() == 0);
- if (isInvalid) {
- d.putItem("value", "(invalid)");
- } else if (value.isEmpty()) {
- d.beginItem("value");
- d.put("(").put(v->typeName()).put(") ");
- d.endItem();
- } else {
- QByteArray ba;
- ba += '(';
- ba += v->typeName();
- ba += ") ";
- ba += qPrintable(value);
- d.putItem("value", ba);
- d.putItem("valueencoded", "5");
- }
- d.putItem("type", NS "QVariant");
- if (isInvalid || !numchild) {
- d.putItem("numchild", "0");
- } else {
- d.putItem("numchild", "1");
- if (d.dumpChildren) {
- d.beginChildren();
- d.beginHash();
- d.putItem("name", "value");
- if (!exp.isEmpty())
- d.putItem("exp", qPrintable(exp));
- if (!value.isEmpty()) {
- d.putItem("value", value);
- d.putItem("valueencoded", "4");
- }
- d.putItem("type", v->typeName());
- d.putItem("numchild", numchild);
- d.endHash();
- d.endChildren();
- }
- }
- d.disarm();
-}
-
-static inline void qDumpQVariant(QDumper &d)
-{
- qCheckAccess(d.data);
- qDumpQVariant(d, reinterpret_cast<const QVariant *>(d.data));
-}
-
-// Meta enumeration helpers
-static inline void dumpMetaEnumType(QDumper &d, const QMetaEnum &me)
-{
- QByteArray type = me.scope();
- if (!type.isEmpty())
- type += "::";
- type += me.name();
- d.putItem("type", type.constData());
-}
-
-static inline void dumpMetaEnumValue(QDumper &d, const QMetaProperty &mop,
- int value)
-{
-
- const QMetaEnum me = mop.enumerator();
- dumpMetaEnumType(d, me);
- if (const char *enumValue = me.valueToKey(value)) {
- d.putItem("value", enumValue);
- } else {
- d.putItem("value", value);
- }
- d.putItem("numchild", 0);
-}
-
-static inline void dumpMetaFlagValue(QDumper &d, const QMetaProperty &mop,
- int value)
-{
- const QMetaEnum me = mop.enumerator();
- dumpMetaEnumType(d, me);
- const QByteArray flagsValue = me.valueToKeys(value);
- if (flagsValue.isEmpty()) {
- d.putItem("value", value);
- } else {
- d.putItem("value", flagsValue.constData());
- }
- d.putItem("numchild", 0);
-}
-
-#ifndef QT_BOOTSTRAPPED
-static void qDumpQObjectProperty(QDumper &d)
-{
- const QObject *ob = (const QObject *)d.data;
- const QMetaObject *mob = ob->metaObject();
- // extract "local.Object.property"
- QString iname = d.iname;
- const int dotPos = iname.lastIndexOf(QLatin1Char('.'));
- if (dotPos == -1)
- return;
- iname.remove(0, dotPos + 1);
- const int index = mob->indexOfProperty(iname.toLatin1());
- if (index == -1)
- return;
- const QMetaProperty mop = mob->property(index);
- const QVariant value = mop.read(ob);
- const bool isInteger = value.type() == QVariant::Int;
- if (isInteger && mop.isEnumType()) {
- dumpMetaEnumValue(d, mop, value.toInt());
- } else if (isInteger && mop.isFlagType()) {
- dumpMetaFlagValue(d, mop, value.toInt());
- } else {
- qDumpQVariant(d, &value);
- }
- d.disarm();
-}
-
-static void qDumpQObjectPropertyList(QDumper &d)
-{
- const QObject *ob = (const QObject *)d.data;
- const QMetaObject *mo = ob->metaObject();
- const int propertyCount = mo->propertyCount();
- d.putItem("addr", "<synthetic>");
- d.putItem("type", NS "QObjectPropertyList");
- d.putItem("numchild", propertyCount);
- d.putItemCount("value", propertyCount);
- if (d.dumpChildren) {
- d.beginChildren();
- for (int i = propertyCount; --i >= 0; ) {
- const QMetaProperty & prop = mo->property(i);
- d.beginHash();
- d.putItem("name", prop.name());
- switch (prop.type()) {
- case QVariant::String:
- d.putItem("type", prop.typeName());
- d.putItem("value", prop.read(ob).toString());
- d.putItem("valueencoded", "2");
- d.putItem("numchild", "0");
- break;
- case QVariant::Bool:
- d.putItem("type", prop.typeName());
- d.putItem("value", (prop.read(ob).toBool() ? "true" : "false"));
- d.putItem("numchild", "0");
- break;
- case QVariant::Int:
- if (prop.isEnumType()) {
- dumpMetaEnumValue(d, prop, prop.read(ob).toInt());
- } else if (prop.isFlagType()) {
- dumpMetaFlagValue(d, prop, prop.read(ob).toInt());
- } else {
- d.putItem("value", prop.read(ob).toInt());
- d.putItem("numchild", "0");
- }
- break;
- default:
- d.putItem("addr", d.data);
- d.putItem("type", NS "QObjectProperty");
- d.putItem("numchild", "1");
- break;
- }
- d.endHash();
- }
- d.endChildren();
- }
- d.disarm();
-}
-
-static QByteArray methodSignature(const QMetaMethod &method)
-{
-#if QT_VERSION >= 0x050000
- return method.methodSignature();
-#else
- return QByteArray(method.signature());
-#endif
-}
-
-static void qDumpQObjectMethodList(QDumper &d)
-{
- const QObject *ob = (const QObject *)d.data;
- const QMetaObject *mo = ob->metaObject();
- d.putItem("addr", "<synthetic>");
- d.putItem("type", NS "QObjectMethodList");
- d.putItem("numchild", mo->methodCount());
- if (d.dumpChildren) {
- d.putItem("childtype", NS "QMetaMethod::Method");
- d.putItem("childnumchild", "0");
- d.beginChildren();
- for (int i = 0; i != mo->methodCount(); ++i) {
- const QMetaMethod & method = mo->method(i);
- int mt = method.methodType();
- const QByteArray sig = methodSignature(method);
- d.beginHash();
- d.beginItem("name");
- d.put(i).put(" ").put(mo->indexOfMethod(sig));
- d.put(" ").put(sig);
- d.endItem();
- d.beginItem("value");
- d.put((mt == QMetaMethod::Signal ? "<Signal>" : "<Slot>"));
- d.put(" (").put(mt).put(")");
- d.endItem();
- d.endHash();
- }
- d.endChildren();
- }
- d.disarm();
-}
-
-static const char *qConnectionType(uint type)
-{
- Qt::ConnectionType connType = static_cast<Qt::ConnectionType>(type);
- const char *output = "unknown";
- switch (connType) {
- case Qt::AutoConnection: output = "auto"; break;
- case Qt::DirectConnection: output = "direct"; break;
- case Qt::QueuedConnection: output = "queued"; break;
- case Qt::BlockingQueuedConnection: output = "blockingqueued"; break;
-#if QT_VERSION < 0x050000
- case 3: output = "autocompat"; break;
-#endif
-#if QT_VERSION >= 0x040600
- case Qt::UniqueConnection: break; // Can't happen.
-#endif
- };
- return output;
-}
-
-#if QT_VERSION < 0x040400
-
-#else
-static const ConnectionList &qConnectionList(const QObject *ob, int signalNumber)
-{
- static const ConnectionList emptyList;
- const ObjectPrivate *p = reinterpret_cast<const ObjectPrivate *>(dfunc(ob));
- if (!p->connectionLists)
- return emptyList;
- typedef QVector<ConnectionList> ConnLists;
- const ConnLists *lists = reinterpret_cast<const ConnLists *>(p->connectionLists);
- // there's an optimization making the lists only large enough to hold the
- // last non-empty item
- if (signalNumber >= lists->size())
- return emptyList;
- return lists->at(signalNumber);
-}
-#endif
-
-// Write party involved in a slot/signal element,
-// avoid to recursion to self.
-static inline void qDumpQObjectConnectionPart(QDumper &d,
- const QObject *owner,
- const QObject *partner,
- int number, const char *namePostfix)
-{
- d.beginHash();
- d.beginItem("name");
- d.put(number).put(namePostfix);
- d.endItem();
- if (partner == owner) {
- d.putItem("value", "<this>");
- d.putItem("type", owner->metaObject()->className());
- d.putItem("numchild", 0);
- d.putItem("addr", owner);
- } else {
- qDumpInnerValueHelper(d, NS "QObject *", partner);
- }
- d.endHash();
-}
-
-static void qDumpQObjectSignal(QDumper &d)
-{
- unsigned signalNumber = d.extraInt[0];
-
- d.putItem("addr", "<synthetic>");
- d.putItem("numchild", "1");
- d.putItem("type", NS "QObjectSignal");
-
-#if QT_VERSION >= 0x040400
- if (d.dumpChildren) {
- const QObject *ob = reinterpret_cast<const QObject *>(d.data);
- d.beginChildren();
- const ConnectionList &connList = qConnectionList(ob, signalNumber);
- for (int i = 0; i != connList.size(); ++i) {
- const Connection &conn = connectionAt(connList, i);
- qDumpQObjectConnectionPart(d, ob, conn.receiver, i, " receiver");
- d.beginHash();
- d.beginItem("name");
- d.put(i).put(" slot");
- d.endItem();
- d.putItem("type", "");
- if (conn.receiver)
- d.putItem("value", methodSignature(conn.receiver->metaObject()
- ->method(conn.method_())));
- else
- d.putItem("value", "<invalid receiver>");
- d.putItem("numchild", "0");
- d.endHash();
- d.beginHash();
- d.beginItem("name");
- d.put(i).put(" type");
- d.endItem();
- d.putItem("type", "");
- d.beginItem("value");
- d.put("<").put(qConnectionType(conn.connectionType)).put(" connection>");
- d.endItem();
- d.putItem("numchild", "0");
- d.endHash();
- }
- d.endChildren();
- d.putItem("numchild", connList.size());
- }
-#endif
- d.disarm();
-}
-
-static void qDumpQObjectSignalList(QDumper &d)
-{
- const QObject *ob = reinterpret_cast<const QObject *>(d.data);
- const QMetaObject *mo = ob->metaObject();
- int count = 0;
- const int methodCount = mo->methodCount();
- for (int i = methodCount; --i >= 0; )
- count += (mo->method(i).methodType() == QMetaMethod::Signal);
- d.putItem("type", NS "QObjectSignalList");
- d.putItemCount("value", count);
- d.putItem("addr", d.data);
- d.putItem("numchild", count);
-#if QT_VERSION >= 0x040400
- if (d.dumpChildren) {
- d.beginChildren();
- for (int i = 0; i != methodCount; ++i) {
- const QMetaMethod & method = mo->method(i);
- if (method.methodType() == QMetaMethod::Signal) {
- int k = mo->indexOfSignal(methodSignature(method));
- const ConnectionList &connList = qConnectionList(ob, k);
- d.beginHash();
- d.putItem("name", k);
- d.putItem("value", methodSignature(method));
- d.putItem("numchild", connList.size());
- d.putItem("addr", d.data);
- d.putItem("type", NS "QObjectSignal");
- d.endHash();
- }
- }
- d.endChildren();
- }
-#endif
- d.disarm();
-}
-
-static void qDumpQObjectSlot(QDumper &d)
-{
- int slotNumber = d.extraInt[0];
-
- d.putItem("addr", d.data);
- d.putItem("numchild", "1");
- d.putItem("type", NS "QObjectSlot");
-
-#if QT_VERSION >= 0x040400
- if (d.dumpChildren) {
- d.beginChildren();
- int numchild = 0;
- const QObject *ob = reinterpret_cast<const QObject *>(d.data);
- const ObjectPrivate *p = reinterpret_cast<const ObjectPrivate *>(dfunc(ob));
-#if QT_VERSION >= 0x040600
- int s = 0;
- for (SenderList senderList = p->senders; senderList != 0;
- senderList = senderList->next, ++s) {
- const QObject *sender = senderList->sender;
- int signal = senderList->method_(); // FIXME: 'method' is wrong.
-#else
- for (int s = 0; s != p->senders.size(); ++s) {
- const QObject *sender = senderAt(p->senders, s);
- int signal = signalAt(p->senders, s);
-#endif
- const ConnectionList &connList = qConnectionList(sender, signal);
- for (int i = 0; i != connList.size(); ++i) {
- const Connection &conn = connectionAt(connList, i);
- if (conn.receiver == ob && conn.method_() == slotNumber) {
- ++numchild;
- QMetaMethod method = sender->metaObject()->method(signal);
- qDumpQObjectConnectionPart(d, ob, sender, s, " sender");
- d.beginHash();
- d.beginItem("name");
- d.put(s).put(" signal");
- d.endItem();
- d.putItem("type", "");
- d.putItem("value", methodSignature(method));
- d.putItem("numchild", "0");
- d.endHash();
- d.beginHash();
- d.beginItem("name");
- d.put(s).put(" type");
- d.endItem();
- d.putItem("type", "");
- d.beginItem("value");
- d.put("<").put(qConnectionType(conn.method_()));
- d.put(" connection>");
- d.endItem();
- d.putItem("numchild", "0");
- d.endHash();
- }
- }
- }
- d.endChildren();
- d.putItem("numchild", numchild);
- }
-#endif
- d.disarm();
-}
-
-static void qDumpQObjectSlotList(QDumper &d)
-{
- const QObject *ob = reinterpret_cast<const QObject *>(d.data);
-#if QT_VERSION >= 0x040400
- const ObjectPrivate *p = reinterpret_cast<const ObjectPrivate *>(dfunc(ob));
-#endif
- const QMetaObject *mo = ob->metaObject();
-
- int count = 0;
- const int methodCount = mo->methodCount();
- for (int i = methodCount; --i >= 0; )
- count += (mo->method(i).methodType() == QMetaMethod::Slot);
-
- d.putItem("numchild", count);
- d.putItemCount("value", count);
- d.putItem("type", NS "QObjectSlotList");
- if (d.dumpChildren) {
- d.beginChildren();
-#if QT_VERSION >= 0x040400
- for (int i = 0; i != methodCount; ++i) {
- QMetaMethod method = mo->method(i);
- if (method.methodType() == QMetaMethod::Slot) {
- d.beginHash();
- QByteArray sig = methodSignature(method);
- int k = mo->indexOfSlot(sig);
- d.putItem("name", k);
- d.putItem("value", sig);
-
- // count senders. expensive...
- int numchild = 0;
-#if QT_VERSION >= 0x040600
- int s = 0;
- for (SenderList senderList = p->senders; senderList != 0;
- senderList = senderList->next, ++s) {
- const QObject *sender = senderList->sender;
- int signal = senderList->method_(); // FIXME: 'method' is wrong.
-#else
- for (int s = 0; s != p->senders.size(); ++s) {
- const QObject *sender = senderAt(p->senders, s);
- int signal = signalAt(p->senders, s);
-#endif
- const ConnectionList &connList = qConnectionList(sender, signal);
- for (int c = 0; c != connList.size(); ++c) {
- const Connection &conn = connectionAt(connList, c);
- if (conn.receiver == ob && conn.method_() == k)
- ++numchild;
- }
- }
- d.putItem("numchild", numchild);
- d.putItem("addr", d.data);
- d.putItem("type", NS "QObjectSlot");
- d.endHash();
- }
- }
-#endif
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQObjectChildList(QDumper &d)
-{
- const QObject *ob = reinterpret_cast<const QObject *>(d.data);
- const QObjectList children = ob->children();
- const int size = children.size();
-
- d.putItem("numchild", size);
- d.putItemCount("value", size);
- d.putItem("type", NS "QObjectChildList");
- if (d.dumpChildren) {
- d.beginChildren();
- for (int i = 0; i != size; ++i) {
- d.beginHash();
- qDumpInnerValueHelper(d, NS "QObject *", children.at(i));
- d.endHash();
- }
- d.endChildren();
- }
- d.disarm();
-}
-#endif // QT_BOOTSTRAPPED
-
-#if USE_QT_GUI
-static void qDumpQPixmap(QDumper &d)
-{
- const QPixmap &im = *reinterpret_cast<const QPixmap *>(d.data);
- d.beginItem("value");
- d.put("(").put(im.width()).put("x").put(im.height()).put(")");
- d.endItem();
- d.putItem("type", NS "QPixmap");
- d.putItem("numchild", "0");
- d.disarm();
-}
-#endif
-
-#ifndef QT_BOOTSTRAPPED
-static void qDumpQPoint(QDumper &d)
-{
- const QPoint &pnt = *reinterpret_cast<const QPoint *>(d.data);
- d.beginItem("value");
- d.put("(").put(pnt.x()).put(", ").put(pnt.y()).put(")");
- d.endItem();
- d.putItem("type", NS "QPoint");
- d.putItem("numchild", "2");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("x", pnt.x());
- d.putHash("y", pnt.y());
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQPointF(QDumper &d)
-{
- const QPointF &pnt = *reinterpret_cast<const QPointF *>(d.data);
- d.beginItem("value");
- d.put("(").put(pnt.x()).put(", ").put(pnt.y()).put(")");
- d.endItem();
- d.putItem("type", NS "QPointF");
- d.putItem("numchild", "2");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("x", pnt.x());
- d.putHash("y", pnt.y());
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQRect(QDumper &d)
-{
- const QRect &rc = *reinterpret_cast<const QRect *>(d.data);
- d.beginItem("value");
- d.put("(").put(rc.width()).put("x").put(rc.height());
- if (rc.x() >= 0)
- d.put("+");
- d.put(rc.x());
- if (rc.y() >= 0)
- d.put("+");
- d.put(rc.y());
- d.put(")");
- d.endItem();
- d.putItem("type", NS "QRect");
- d.putItem("numchild", "4");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("x", rc.x());
- d.putHash("y", rc.y());
- d.putHash("width", rc.width());
- d.putHash("height", rc.height());
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQRectF(QDumper &d)
-{
- const QRectF &rc = *reinterpret_cast<const QRectF *>(d.data);
- d.beginItem("value");
- d.put("(").put(rc.width()).put("x").put(rc.height());
- if (rc.x() >= 0)
- d.put("+");
- d.put(rc.x());
- if (rc.y() >= 0)
- d.put("+");
- d.put(rc.y());
- d.put(")");
- d.endItem();
- d.putItem("type", NS "QRectF");
- d.putItem("numchild", "4");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("x", rc.x());
- d.putHash("y", rc.y());
- d.putHash("width", rc.width());
- d.putHash("height", rc.height());
- d.endChildren();
- }
- d.disarm();
-}
-#endif
-
-static void qDumpQSet(QDumper &d)
-{
- // This uses the knowledge that QHash<T> has only a single member
- // of union { QHashData *d; QHashNode<Key, T> *e; };
- QHashData *hd = *(QHashData**)d.data;
- QHashData::Node *node = hd->firstNode();
-
- int n = hd->size;
- if (n < 0)
- return;
- if (n > 0) {
- qCheckAccess(node);
- qCheckPointer(node->next);
- }
-
- d.putItemCount("value", n);
- d.putItem("valueeditable", "false");
- d.putItem("numchild", 2 * n);
- if (d.dumpChildren) {
- d.beginChildren();
- int i = 0;
- for (int bucket = 0; bucket != hd->numBuckets && i <= 10000; ++bucket) {
- for (node = hd->buckets[bucket]; node->next; node = node->next) {
- d.beginHash();
- d.putItem("type", d.innerType);
- d.beginItem("exp");
- d.put("(('" NS "QHashNode<").put(d.innerType
- ).put("," NS "QHashDummyValue>'*)"
- ).put(static_cast<const void*>(node)).put(")->key");
- d.endItem();
- d.endHash();
- ++i;
- if (i > 10000) {
- d.putEllipsis();
- break;
- }
- }
- }
- d.endChildren();
- }
- d.disarm();
-}
-
-#ifndef QT_BOOTSTRAPPED
-#if QT_VERSION >= 0x040500
-static void qDumpQSharedPointer(QDumper &d)
-{
- const QSharedPointer<int> &ptr =
- *reinterpret_cast<const QSharedPointer<int> *>(d.data);
-
- if (ptr.isNull()) {
- d.putItem("value", "<null>");
- d.putItem("valueeditable", "false");
- d.putItem("numchild", 0);
- d.disarm();
- return;
- }
-
- if (isSimpleType(d.innerType))
- qDumpInnerValueHelper(d, d.innerType, ptr.data());
- else
- d.putItem("value", "");
- d.putItem("valueeditable", "false");
- d.putItem("numchild", 1);
- if (d.dumpChildren) {
- d.beginChildren();
- d.beginHash();
- d.putItem("name", "data");
- qDumpInnerValue(d, d.innerType, ptr.data());
- d.endHash();
- const int v = sizeof(void *);
- d.beginHash();
- const void *weak = addOffset(deref(addOffset(d.data, v)), v);
- d.putItem("name", "weakref");
- d.putItem("value", *static_cast<const int *>(weak));
- d.putItem("type", "int");
- d.putItem("addr", weak);
- d.putItem("numchild", "0");
- d.endHash();
- d.beginHash();
- const void *strong = addOffset(weak, sizeof(int));
- d.putItem("name", "strongref");
- d.putItem("value", *static_cast<const int *>(strong));
- d.putItem("type", "int");
- d.putItem("addr", strong);
- d.putItem("numchild", "0");
- d.endHash();
- d.endChildren();
- }
- d.disarm();
-}
-#endif // QT_VERSION >= 0x040500
-#endif // QT_BOOTSTRAPPED
-
-static void qDumpQSize(QDumper &d)
-{
- const QSize s = *reinterpret_cast<const QSize *>(d.data);
- d.beginItem("value");
- d.put("(").put(s.width()).put("x").put(s.height()).put(")");
- d.endItem();
- d.putItem("type", NS "QSize");
- d.putItem("numchild", "2");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("w", s.width());
- d.putHash("h", s.height());
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQSizeF(QDumper &d)
-{
- const QSizeF s = *reinterpret_cast<const QSizeF *>(d.data);
- d.beginItem("value");
- d.put("(").put(s.width()).put("x").put(s.height()).put(")");
- d.endItem();
- d.putItem("type", NS "QSizeF");
- d.putItem("numchild", "2");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("w", s.width());
- d.putHash("h", s.height());
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQString(QDumper &d)
-{
- //qCheckAccess(deref(d.data)); // is the d-ptr de-referenceable and valid
- const QString &str = *reinterpret_cast<const QString *>(d.data);
-
- const int size = str.size();
- if (size < 0)
- return;
- if (size) {
- const QChar *unicode = str.unicode();
- qCheckAccess(unicode);
- qCheckAccess(unicode + size);
- if (!unicode[size].isNull()) // must be '\0' terminated
- return;
- }
-
- d.putStringValue(str);
- d.putItem("type", NS "QString");
- //d.putItem("editvalue", str); // handled generically below
- d.putItem("numchild", "0");
-
- d.disarm();
-}
-
-static void qDumpQStringList(QDumper &d)
-{
- qCheckAccess(deref(d.data)); // is the d-ptr de-referenceable and valid
- const QStringList &list = *reinterpret_cast<const QStringList *>(d.data);
- int n = list.size();
- if (n < 0)
- return;
- if (n > 0) {
- qCheckAccess(&list.front());
- qCheckAccess(&list.back());
- }
-
- d.putItemCount("value", n);
- d.putItem("valueeditable", "false");
- d.putItem("numchild", n);
- if (d.dumpChildren) {
- if (n > 1000)
- n = 1000;
- d.beginChildren(n ? NS "QString" : 0);
- for (int i = 0; i != n; ++i) {
- d.beginHash();
- d.putStringValue(list.at(i));
- d.endHash();
- }
- if (n < list.size())
- d.putEllipsis();
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQTextCodec(QDumper &d)
-{
- qCheckPointer(deref(d.data));
- const QTextCodec &codec = *reinterpret_cast<const QTextCodec *>(d.data);
- d.putItem("value", codec.name());
- d.putItem("valueencoded", "1");
- d.putItem("type", NS "QTextCodec");
- d.putItem("numchild", "2");
- if (d.dumpChildren) {
- d.beginChildren();
- d.putHash("name", codec.name());
- d.putHash("mibEnum", codec.mibEnum());
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpQVector(QDumper &d)
-{
- qCheckAccess(deref(d.data)); // is the d-ptr de-referenceable and valid
-
-#if QT_VERSION >= 0x050000
- QArrayData *v = *reinterpret_cast<QArrayData *const*>(d.data);
- const unsigned typeddatasize = (char *)(&v->offset) - (char *)v;
-#else
- QVectorData *v = *reinterpret_cast<QVectorData *const*>(d.data);
- QVectorTypedData<int> *dummy = 0;
- const unsigned typeddatasize = (char*)(&dummy->array) - (char*)dummy;
-#endif
-
- // Try to provoke segfaults early to prevent the frontend
- // from asking for unavailable child details
- int nn = v->size;
- if (nn < 0)
- return;
- const bool innerIsPointerType = isPointerType(d.innerType);
- const unsigned innersize = d.extraInt[0];
- const int n = qMin(nn, 1000);
- // Check pointers
- if (innerIsPointerType && nn > 0)
- for (int i = 0; i != n; ++i)
- if (const void *p = addOffset(v, i * innersize + typeddatasize))
- qCheckPointer(deref(p));
-
- d.putItemCount("value", nn);
- d.putItem("valueeditable", "false");
- d.putItem("numchild", nn);
- if (d.dumpChildren) {
- QByteArray strippedInnerType = stripPointerType(d.innerType);
- const char *stripped = innerIsPointerType ? strippedInnerType.data() : 0;
- d.beginChildren(d.innerType);
- for (int i = 0; i != n; ++i) {
- d.beginHash();
- qDumpInnerValueOrPointer(d, d.innerType, stripped,
- addOffset(v, i * innersize + typeddatasize));
- d.endHash();
- }
- if (n < nn)
- d.putEllipsis();
- d.endChildren();
- }
- d.disarm();
-}
-
-#ifndef QT_BOOTSTRAPPED
-#if QT_VERSION >= 0x040500
-static void qDumpQWeakPointer(QDumper &d)
-{
- const int v = sizeof(void *);
- const void *value = deref(addOffset(d.data, v));
- const void *data = deref(d.data);
-
- if (value == 0 || data == 0) {
- d.putItem("value", "<null>");
- d.putItem("valueeditable", "false");
- d.putItem("numchild", 0);
- d.disarm();
- return;
- }
-
- if (isSimpleType(d.innerType))
- qDumpInnerValueHelper(d, d.innerType, value);
- else
- d.putItem("value", "");
- d.putItem("valueeditable", "false");
- d.putItem("numchild", 1);
- if (d.dumpChildren) {
- d.beginChildren();
- d.beginHash();
- d.putItem("name", "data");
- qDumpInnerValue(d, d.innerType, value);
- d.endHash();
- d.beginHash();
- const void *weak = addOffset(deref(d.data), v);
- d.putItem("name", "weakref");
- d.putItem("value", *static_cast<const int *>(weak));
- d.putItem("type", "int");
- d.putItem("addr", weak);
- d.putItem("numchild", "0");
- d.endHash();
- d.beginHash();
- const void *strong = addOffset(weak, sizeof(int));
- d.putItem("name", "strongref");
- d.putItem("value", *static_cast<const int *>(strong));
- d.putItem("type", "int");
- d.putItem("addr", strong);
- d.putItem("numchild", "0");
- d.endHash();
- d.endChildren();
- }
- d.disarm();
-}
-#endif // QT_VERSION >= 0x040500
-#endif // QT_BOOTSTRAPPED
-
-#endif // QT_CORE
-
-static void qDumpStdList(QDumper &d)
-{
- const std::list<int> &list = *reinterpret_cast<const std::list<int> *>(d.data);
- const void *p = d.data;
- qCheckAccess(p);
- p = deref(p);
- qCheckAccess(p);
- p = deref(p);
- qCheckAccess(p);
- p = deref(addOffset(d.data, sizeof(void*)));
- qCheckAccess(p);
- p = deref(addOffset(p, sizeof(void*)));
- qCheckAccess(p);
- p = deref(addOffset(p, sizeof(void*)));
- qCheckAccess(p);
- std::list<int>::size_type nn = 0;
- const std::list<int>::size_type maxItems = 100;
- std::list<int>::const_iterator it = list.begin();
- const std::list<int>::const_iterator cend = list.end();
- for (; nn < maxItems && it != cend; ++nn, ++it)
- qCheckAccess(it.operator->());
-
- if (it != cend) {
- d.putTruncatedItemCount("value", nn);
- } else {
- d.putItemCount("value", nn);
- }
- d.putItem("numchild", nn);
-
- d.putItem("valueeditable", "false");
- if (d.dumpChildren) {
- QByteArray strippedInnerType = stripPointerType(d.innerType);
- const char *stripped =
- isPointerType(d.innerType) ? strippedInnerType.data() : 0;
- d.beginChildren(d.innerType);
- it = list.begin();
- for (std::list<int>::size_type i = 0; i < maxItems && it != cend; ++i, ++it) {
- d.beginHash();
- qDumpInnerValueOrPointer(d, d.innerType, stripped, it.operator->());
- d.endHash();
- }
- if (it != list.end())
- d.putEllipsis();
- d.endChildren();
- }
- d.disarm();
-}
-
-/* Dump out an arbitrary map. To iterate the map,
- * it is cast to a map of <KeyType,Value>. 'int' can be used for both
- * for all types if the implementation does not depend on the types
- * which is the case for GNU STL. The implementation used by MS VC, however,
- * does depend on the key/value type, so, special cases need to be hardcoded. */
-
-template <class KeyType, class ValueType>
-static void qDumpStdMapHelper(QDumper &d)
-{
- typedef std::map<KeyType, ValueType> DummyType;
- const DummyType &map = *reinterpret_cast<const DummyType*>(d.data);
- const char *keyType = d.templateParameters[0];
- const char *valueType = d.templateParameters[1];
- const void *p = d.data;
- qCheckAccess(p);
-
- const int nn = map.size();
- if (nn < 0)
- return;
- typename DummyType::const_iterator it = map.begin();
- const typename DummyType::const_iterator cend = map.end();
- for (int i = 0; i < nn && i < 10 && it != cend; ++i, ++it)
- qCheckAccess(it.operator->());
-
- d.putItem("numchild", nn);
- d.putItemCount("value", nn);
- d.putItem("valueeditable", "false");
- d.putItem("valueoffset", d.extraInt[2]);
-
- // HACK: we need a properly const qualified version of the
- // std::pair used. We extract it from the allocator parameter
- // (#4, "std::allocator<std::pair<key, value> >")
- // as it is there, and, equally importantly, in an order that
- // gdb accepts when fed with it.
- char *pairType = (char *)(d.templateParameters[3]) + 15;
- pairType[strlen(pairType) - 2] = 0;
- d.putItem("pairtype", pairType);
-
- if (d.dumpChildren) {
- bool isSimpleKey = isSimpleType(keyType);
- bool isSimpleValue = isSimpleType(valueType);
- int valueOffset = d.extraInt[2];
-
- d.beginItem("extra");
- d.put("isSimpleKey: ").put(isSimpleKey);
- d.put(" isSimpleValue: ").put(isSimpleValue);
- d.put(" valueType: '").put(valueType);
- d.put(" valueOffset: ").put(valueOffset);
- d.endItem();
-
- d.beginChildren(d.innerType);
- it = map.begin();
- for (int i = 0; i < 1000 && it != cend; ++i, ++it) {
- d.beginHash();
- const void *node = it.operator->();
- qDumpInnerValueHelper(d, keyType, node, "key");
- qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
- if (isSimpleKey && isSimpleValue) {
- d.putItem("type", valueType);
- d.putItem("addr", addOffset(node, valueOffset));
- d.putItem("numchild", 0);
- } else {
- d.putItem("addr", node);
- d.putItem("type", pairType);
- d.putItem("numchild", 2);
- }
- d.endHash();
- }
- if (it != map.end())
- d.putEllipsis();
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpStdMap(QDumper &d)
-{
- qDumpStdMapHelper<int,int>(d);
-}
-
-/* Dump out an arbitrary set. To iterate the set,
- * it is cast to a set of <KeyType>. 'int' can be used
- * for all types if the implementation does not depend on the key type
- * which is the case for GNU STL. The implementation used by MS VC, however,
- * does depend on the key type, so, special cases need to be hardcoded. */
-
-template <class KeyType>
-static void qDumpStdSetHelper(QDumper &d)
-{
- typedef std::set<KeyType> DummyType;
- const DummyType &set = *reinterpret_cast<const DummyType*>(d.data);
- const void *p = d.data;
- qCheckAccess(p);
-
- const int nn = set.size();
- if (nn < 0)
- return;
- typename DummyType::const_iterator it = set.begin();
- const typename DummyType::const_iterator cend = set.end();
- for (int i = 0; i < nn && i < 10 && it != cend; ++i, ++it)
- qCheckAccess(it.operator->());
-
- d.putItemCount("value", nn);
- d.putItem("valueeditable", "false");
- d.putItem("numchild", nn);
- d.putItem("valueoffset", d.extraInt[0]);
-
- if (d.dumpChildren) {
- int valueOffset = 0; // d.extraInt[0];
- QByteArray strippedInnerType = stripPointerType(d.innerType);
- const char *stripped =
- isPointerType(d.innerType) ? strippedInnerType.data() : 0;
-
- d.beginItem("extra");
- d.put("valueOffset: ").put(valueOffset);
- d.endItem();
-
- d.beginChildren(d.innerType);
- it = set.begin();
- for (int i = 0; i < 1000 && it != cend; ++i, ++it) {
- const void *node = it.operator->();
- d.beginHash();
- qDumpInnerValueOrPointer(d, d.innerType, stripped, node);
- d.endHash();
- }
- if (it != set.end())
- d.putEllipsis();
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpStdSet(QDumper &d)
-{
- qDumpStdSetHelper<int>(d);
-}
-
-static void qDumpStdString(QDumper &d)
-{
- const std::string &str = *reinterpret_cast<const std::string *>(d.data);
-
- const std::string::size_type size = str.size();
- if (int(size) < 0)
- return;
- if (size) {
- qCheckAccess(str.c_str());
- qCheckAccess(str.c_str() + size - 1);
- }
- qDumpStdStringValue(d, str);
- d.disarm();
-}
-
-static void qDumpStdWString(QDumper &d)
-{
- const std::wstring &str = *reinterpret_cast<const std::wstring *>(d.data);
- const std::wstring::size_type size = str.size();
- if (int(size) < 0)
- return;
- if (size) {
- qCheckAccess(str.c_str());
- qCheckAccess(str.c_str() + size - 1);
- }
- qDumpStdWStringValue(d, str);
- d.disarm();
-}
-
-static void qDumpStdVector(QDumper &d)
-{
- // Correct type would be something like:
- // std::_Vector_base<int,std::allocator<int, std::allocator<int> >>::_Vector_impl
- struct VectorImpl {
- char *start;
- char *finish;
- char *end_of_storage;
- };
- const VectorImpl *v = static_cast<const VectorImpl *>(d.data);
- // Try to provoke segfaults early to prevent the frontend
- // from asking for unavailable child details
- int nn = (v->finish - v->start) / d.extraInt[0];
- if (nn < 0)
- return;
- if (nn > 0) {
- qCheckAccess(v->start);
- qCheckAccess(v->finish);
- qCheckAccess(v->end_of_storage);
- }
-
- int n = nn;
- d.putItemCount("value", n);
- d.putItem("valueeditable", "false");
- d.putItem("numchild", n);
- if (d.dumpChildren) {
- unsigned innersize = d.extraInt[0];
- QByteArray strippedInnerType = stripPointerType(d.innerType);
- const char *stripped =
- isPointerType(d.innerType) ? strippedInnerType.data() : 0;
- if (n > 1000)
- n = 1000;
- d.beginChildren(n ? d.innerType : 0);
- for (int i = 0; i != n; ++i) {
- d.beginHash();
- qDumpInnerValueOrPointer(d, d.innerType, stripped,
- addOffset(v->start, i * innersize));
- d.endHash();
- }
- if (n < nn)
- d.putEllipsis();
- d.endChildren();
- }
- d.disarm();
-}
-
-static void qDumpStdVectorBool(QDumper &d)
-{
- // FIXME
- return qDumpStdVector(d);
-}
-
-static void handleProtocolVersion2and3(QDumper &d)
-{
- if (!d.outerType[0]) {
- qDumpUnknown(d);
- return;
- }
-
- d.setupTemplateParameters();
- d.putItem("iname", d.iname);
- if (d.data)
- d.putItem("addr", d.data);
-
-#ifdef QT_NO_QDATASTREAM
- if (d.protocolVersion == 3) {
- QVariant::Type type = QVariant::nameToType(d.outerType);
- if (type != QVariant::Invalid) {
- QVariant v(type, d.data);
- QByteArray ba;
- QDataStream ds(&ba, QIODevice::WriteOnly);
- ds << v;
- d.putItem("editvalue", ba);
- }
- }
-#endif
-
- const char *type = stripNamespace(d.outerType);
- // type[0] is usually 'Q', so don't use it
- switch (type[1]) {
- case 'a':
- if (isEqual(type, "map"))
- qDumpStdMap(d);
- break;
- case 'e':
- if (isEqual(type, "vector"))
- qDumpStdVector(d);
- else if (isEqual(type, "set"))
- qDumpStdSet(d);
- break;
- case 'i':
- if (isEqual(type, "list"))
- qDumpStdList(d);
- break;
- case 's':
- if (isEqual(type, "wstring"))
- qDumpStdWString(d);
- break;
- case 't':
- if (isEqual(type, "std::vector"))
- qDumpStdVector(d);
- else if (isEqual(type, "std::vector::bool"))
- qDumpStdVectorBool(d);
- else if (isEqual(type, "std::list"))
- qDumpStdList(d);
- else if (isEqual(type, "std::map"))
- qDumpStdMap(d);
- else if (isEqual(type, "std::set"))
- qDumpStdSet(d);
- else if (isEqual(type, "std::string") || isEqual(type, "string"))
- qDumpStdString(d);
- else if (isEqual(type, "std::wstring"))
- qDumpStdWString(d);
- break;
-#if USE_QT_CORE
- case 'A':
-# ifndef QT_BOOTSTRAPPED
- if (isEqual(type, "QAbstractItemModel"))
- qDumpQAbstractItemModel(d);
- else if (isEqual(type, "QAbstractItem"))
- qDumpQAbstractItem(d);
-# endif
- break;
- case 'B':
- if (isEqual(type, "QByteArray"))
- qDumpQByteArray(d);
- break;
- case 'C':
- if (isEqual(type, "QChar"))
- qDumpQChar(d);
- break;
- case 'D':
- if (isEqual(type, "QDate"))
- qDumpQDate(d);
- else if (isEqual(type, "QDateTime"))
- qDumpQDateTime(d);
- else if (isEqual(type, "QDir"))
- qDumpQDir(d);
- break;
- case 'F':
-# ifndef QT_BOOTSTRAPPED
- if (isEqual(type, "QFile"))
- qDumpQFile(d);
- else if (isEqual(type, "QFileInfo"))
- qDumpQFileInfo(d);
-# endif
- break;
- case 'H':
- if (isEqual(type, "QHash"))
- qDumpQHash(d);
- else if (isEqual(type, "QHashNode"))
- qDumpQHashNode(d);
- break;
- case 'I':
-# if USE_QT_GUI
- if (isEqual(type, "QImage"))
- qDumpQImage(d);
- else if (isEqual(type, "QImageData"))
- qDumpQImageData(d);
-# endif
- break;
- case 'L':
-# ifndef QT_BOOTSTRAPPED
- if (isEqual(type, "QList"))
- qDumpQList(d);
- else if (isEqual(type, "QLinkedList"))
- qDumpQLinkedList(d);
- else if (isEqual(type, "QLocale"))
- qDumpQLocale(d);
-# endif
- break;
- case 'M':
-# ifndef QT_BOOTSTRAPPED
- if (isEqual(type, "QModelIndex"))
- qDumpQModelIndex(d);
-# if MAP_WORKS
- else if (isEqual(type, "QMap"))
- qDumpQMap(d);
- else if (isEqual(type, "QMapNode"))
- qDumpQMapNode(d);
- else if (isEqual(type, "QMultiMap"))
- qDumpQMultiMap(d);
-# endif
-# endif
- break;
- case 'O':
-# ifndef QT_BOOTSTRAPPED
- if (isEqual(type, "QObject"))
- qDumpQObject(d);
- else if (isEqual(type, "QObjectPropertyList"))
- qDumpQObjectPropertyList(d);
- else if (isEqual(type, "QObjectProperty"))
- qDumpQObjectProperty(d);
- else if (isEqual(type, "QObjectMethodList"))
- qDumpQObjectMethodList(d);
- else if (isEqual(type, "QObjectSignalList"))
- qDumpQObjectSignalList(d);
- else if (isEqual(type, "QObjectSignal"))
- qDumpQObjectSignal(d);
- else if (isEqual(type, "QObjectSlot"))
- qDumpQObjectSlot(d);
- else if (isEqual(type, "QObjectSlotList"))
- qDumpQObjectSlotList(d);
- else if (isEqual(type, "QObjectChildList"))
- qDumpQObjectChildList(d);
-# endif
- break;
- case 'P':
-# if USE_QT_GUI
- if (isEqual(type, "QPixmap"))
- qDumpQPixmap(d);
-# endif
-# ifndef QT_BOOTSTRAPPED
- if (isEqual(type, "QPoint"))
- qDumpQPoint(d);
- else if (isEqual(type, "QPointF"))
- qDumpQPointF(d);
-# endif
- break;
- case 'R':
-# ifndef QT_BOOTSTRAPPED
- if (isEqual(type, "QRect"))
- qDumpQRect(d);
- else if (isEqual(type, "QRectF"))
- qDumpQRectF(d);
-# endif
- break;
- case 'S':
- if (isEqual(type, "QString"))
- qDumpQString(d);
- else if (isEqual(type, "QStringList"))
- qDumpQStringList(d);
-# ifndef QT_BOOTSTRAPPED
- else if (isEqual(type, "QSet"))
- qDumpQSet(d);
- else if (isEqual(type, "QStack"))
- qDumpQVector(d);
-# if QT_VERSION >= 0x040500
- else if (isEqual(type, "QSharedPointer"))
- qDumpQSharedPointer(d);
-# endif
-# endif // QT_BOOTSTRAPPED
- else if (isEqual(type, "QSize"))
- qDumpQSize(d);
- else if (isEqual(type, "QSizeF"))
- qDumpQSizeF(d);
- break;
- case 'T':
-# ifndef QT_BOOTSTRAPPED
- if (isEqual(type, "QTextCodec"))
- qDumpQTextCodec(d);
-# endif
- if (isEqual(type, "QTime"))
- qDumpQTime(d);
- break;
- case 'V':
-# ifndef QT_BOOTSTRAPPED
- if (isEqual(type, "QVariantList")) { // resolve typedef
- d.outerType = "QList";
- d.innerType = "QVariant";
- d.extraInt[0] = sizeof(QVariant);
- qDumpQList(d);
- } else if (isEqual(type, "QVariant")) {
- qDumpQVariant(d);
- } else if (isEqual(type, "QVector")) {
- qDumpQVector(d);
- }
-# endif
- break;
- case 'W':
-# ifndef QT_BOOTSTRAPPED
-# if QT_VERSION >= 0x040500
- if (isEqual(type, "QWeakPointer"))
- qDumpQWeakPointer(d);
-# endif
-# endif
- break;
-#endif
- }
-
- if (!d.success)
- qDumpUnknown(d);
-}
-
-} // anonymous namespace
-
-
-#if USE_QT_GUI
-extern "C" Q_DECL_EXPORT
-void *watchPoint(int x, int y)
-{
- return QApplication::widgetAt(x, y);
-}
-#endif
-
-extern "C" Q_DECL_EXPORT
-void *qDumpObjectData440(
- int protocolVersion,
- int token,
- const void *data,
- int dumpChildren,
- int extraInt0,
- int extraInt1,
- int extraInt2,
- int extraInt3)
-{
- //sleep(20);
- if (protocolVersion == 1) {
- QDumper d;
- d.protocolVersion = protocolVersion;
- d.token = token;
-
- // This is a list of all available dumpers. Note that some templates
- // currently require special hardcoded handling in the debugger plugin.
- // They are mentioned here nevertheless. For types that are not listed
- // here, dumpers won't be used.
- d.put("dumpers=["
- "\"" NS "QAbstractItem\","
- "\"" NS "QAbstractItemModel\","
- "\"" NS "QByteArray\","
- "\"" NS "QChar\","
- "\"" NS "QDate\","
- "\"" NS "QDateTime\","
- "\"" NS "QDir\","
- "\"" NS "QFile\","
- "\"" NS "QFileInfo\","
- "\"" NS "QHash\","
- "\"" NS "QHashNode\","
- "\"" NS "QImage\","
- //"\"" NS "QImageData\","
- "\"" NS "QLinkedList\","
- "\"" NS "QList\","
- "\"" NS "QLocale\","
-#if MAP_WORKS
- "\"" NS "QMap\","
- "\"" NS "QMapNode\","
-#endif
- "\"" NS "QModelIndex\","
- "\"" NS "QObject\","
- "\"" NS "QObjectMethodList\"," // hack to get nested properties display
- "\"" NS "QObjectProperty\","
- "\"" NS "QObjectPropertyList\","
- "\"" NS "QObjectSignal\","
- "\"" NS "QObjectSignalList\","
- "\"" NS "QObjectSlot\","
- "\"" NS "QObjectSlotList\","
- "\"" NS "QObjectChildList\","
- "\"" NS "QPoint\","
- "\"" NS "QPointF\","
- "\"" NS "QRect\","
- "\"" NS "QRectF\","
- //"\"" NS "QRegion\","
- "\"" NS "QSet\","
- "\"" NS "QSize\","
- "\"" NS "QSizeF\","
- "\"" NS "QStack\","
- "\"" NS "QString\","
- "\"" NS "QStringList\","
- "\"" NS "QTextCodec\","
- "\"" NS "QTime\","
- "\"" NS "QVariant\","
- "\"" NS "QVariantList\","
- "\"" NS "QVector\","
-#if QT_VERSION >= 0x040500
-#if MAP_WORKS
- "\"" NS "QMultiMap\","
-#endif
- "\"" NS "QSharedPointer\","
- "\"" NS "QWeakPointer\","
-#endif
-#if USE_QT_GUI
- "\"" NS "QPixmap\","
- "\"" NS "QWidget\","
-#endif
-#ifdef Q_OS_WIN
- "\"basic_string\","
- "\"list\","
- "\"map\","
- "\"set\","
- "\"vector\","
-#endif
- "\"string\","
- "\"wstring\","
- "\"std::basic_string\","
- "\"std::list\","
- "\"std::map\","
- "\"std::set\","
- "\"std::string\","
- "\"std::vector\","
- "\"std::wstring\","
- "]");
- d.put(",qtversion=["
- "\"").put(((QT_VERSION >> 16) & 255)).put("\","
- "\"").put(((QT_VERSION >> 8) & 255)).put("\","
- "\"").put(((QT_VERSION) & 255)).put("\"]");
- d.put(",namespace=\"" NS "\",");
- d.put("dumperversion=\"1.3\",");
- d.disarm();
- } else if (protocolVersion == 2 || protocolVersion == 3) {
- QDumper d;
-
- d.protocolVersion = protocolVersion;
- d.token = token;
- d.data = data;
- d.dumpChildren = dumpChildren;
- d.extraInt[0] = extraInt0;
- d.extraInt[1] = extraInt1;
- d.extraInt[2] = extraInt2;
- d.extraInt[3] = extraInt3;
-
- const char *inbuffer = inBuffer;
- d.outerType = inbuffer; while (*inbuffer) ++inbuffer; ++inbuffer;
- d.iname = inbuffer; while (*inbuffer) ++inbuffer; ++inbuffer;
- d.exp = inbuffer; while (*inbuffer) ++inbuffer; ++inbuffer;
- d.innerType = inbuffer; while (*inbuffer) ++inbuffer; ++inbuffer;
- d.iname = inbuffer; while (*inbuffer) ++inbuffer; ++inbuffer;
-#if 0
- qDebug() << "data=" << d.data << "dumpChildren=" << d.dumpChildren
- << " extra=" << d.extraInt[0] << d.extraInt[1] << d.extraInt[2] << d.extraInt[3]
- << d.outerType << d.iname << d.exp << d.iname;
-#endif
- handleProtocolVersion2and3(d);
- } else {
-#if USE_QT_CORE
-# ifndef QT_BOOTSTRAPPED
- qDebug() << "Unsupported protocol version" << protocolVersion;
-# endif
-#endif
- }
- return outBuffer;
-}
diff --git a/share/qtcreator/debugger/dumper.h b/share/qtcreator/debugger/dumper.h
deleted file mode 100644
index 49ca6ca51f..0000000000
--- a/share/qtcreator/debugger/dumper.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef DUMPER_H
-#define DUMPER_H
-
-#ifdef MACROSDEBUG
-Q_DECL_EXPORT extern char xDumpInBuffer[];
-Q_DECL_EXPORT extern char xDumpOutBuffer[];
-#else
-Q_DECL_EXPORT extern char qDumpInBuffer[];
-Q_DECL_EXPORT extern char qDumpOutBuffer[];
-#endif
-
-extern "C" Q_DECL_EXPORT
-void *qDumpObjectData440(int protocolVersion, int token, const void *data,
- int dumpChildren, int extraInt0, int extraInt1, int extraInt2, int extraInt3);
-
-
-#endif // DUMPER_H
diff --git a/share/qtcreator/debugger/dumper.pro b/share/qtcreator/debugger/dumper.pro
deleted file mode 100644
index f3176a1c04..0000000000
--- a/share/qtcreator/debugger/dumper.pro
+++ /dev/null
@@ -1,30 +0,0 @@
-TEMPLATE = lib
-CONFIG += shared
-linux-* {
- CONFIG -= release
- CONFIG += debug
-}
-
-HEADERS += dumper.h
-SOURCES = dumper.cpp
-
-false {
- DEFINES += USE_QT_GUI=0
- DEFINES += USE_QT_CORE=0
- QT=
- # We need a few convenience macros.
- #CONFIG -= qt
-}
-false {
- DEFINES += USE_QT_CORE=1
- DEFINES += USE_QT_GUI=0
- QT = core
- exists($$QMAKE_INCDIR_QT/QtCore/private/qobject_p.h):DEFINES += HAS_QOBJECT_P_H
-}
-true {
- DEFINES += USE_QT_CORE=1
- DEFINES += USE_QT_GUI=1
- QT = core gui
- greaterThan(QT_MAJOR_VERSION, 4):QT *= widgets
- exists($$QMAKE_INCDIR_QT/QtCore/private/qobject_p.h):DEFINES += HAS_QOBJECT_P_H
-}
diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py
index eb1436774e..525e75e9f4 100644
--- a/share/qtcreator/debugger/dumper.py
+++ b/share/qtcreator/debugger/dumper.py
@@ -181,6 +181,34 @@ class Children:
self.d.put('],')
return True
+class PairedChildrenData:
+ def __init__(self, d, pairType):
+ self.pairType = pairType
+ self.keyType = d.templateArgument(pairType, 0).unqualified()
+ self.valueType = d.templateArgument(pairType, 1)
+ self.isCompact = d.isMapCompact(self.keyType, self.valueType)
+ self.childNumChild = None if self.isCompact else 2
+ self.childType = self.valueType if self.isCompact else self.pairType
+ ns = d.qtNamespace()
+ self.keyIsQString = str(self.keyType) == ns + "QString"
+ self.keyIsQByteArray = str(self.keyType) == ns + "QByteArray"
+
+class PairedChildren(Children):
+ def __init__(self, d, numChild, pairType, maxNumChild = None):
+ self.d = d
+ d.pairData = PairedChildrenData(d, pairType)
+ Children.__init__(self, d, numChild,
+ d.pairData.childType, d.pairData.childNumChild,
+ maxNumChild, addrBase = None, addrStep = None)
+
+ def __enter__(self):
+ self.savedPairData = self.d.pairData if hasattr(self.d, "pairData") else None
+ Children.__enter__(self)
+
+ def __exit__(self, exType, exValue, exTraceBack):
+ Children.__exit__(self, exType, exValue, exTraceBack)
+ self.d.pairData = self.savedPairData if self.savedPairData else None
+
class SubItem:
def __init__(self, d, component):
@@ -260,10 +288,19 @@ class DumperBase:
self.cachedFormats[typeName] = stripped
return stripped
+ def isArmArchitecture(self):
+ return False
+
+ def isQnxTarget(self):
+ return False
def is32bit(self):
return self.ptrSize() == 4
+ def isQt3Support(self):
+ # assume no Qt 3 support by default
+ return False
+
def computeLimit(self, size, limit):
if limit is None:
return size
@@ -400,7 +437,7 @@ class DumperBase:
self.putNumChild(0)
- def putMapName(self, value):
+ def putMapName(self, value, index = -1):
ns = self.qtNamespace()
if str(value.type) == ns + "QString":
self.put('key="%s",' % self.encodeString(value))
@@ -409,10 +446,35 @@ class DumperBase:
self.put('key="%s",' % self.encodeByteArray(value))
self.put('keyencoded="%s",' % Hex2EncodedLatin1)
else:
- if self.isLldb:
- self.put('name="%s",' % value.GetValue())
+ val = str(value.GetValue()) if self.isLldb else str(value)
+ if index == -1:
+ self.put('name="%s",' % val)
else:
- self.put('name="%s",' % value)
+ self.put('key="[%d] %s",' % (index, val))
+
+ def putPair(self, pair, index = -1):
+ key = pair["first"]
+ value = pair["second"]
+ if self.pairData.isCompact:
+ if self.pairData.keyIsQString:
+ self.put('key="%s",' % self.encodeString(key))
+ self.put('keyencoded="%s",' % Hex4EncodedLittleEndian)
+ elif self.pairData.keyIsQByteArray:
+ self.put('key="%s",' % self.encodeByteArray(key))
+ self.put('keyencoded="%s",' % Hex2EncodedLatin1)
+ else:
+ name = str(key.GetValue()) if self.isLldb else str(key)
+ if index == -1:
+ self.put('name="%s",' % name)
+ else:
+ self.put('key="[%d] %s",' % (index, name))
+ self.putItem(value)
+ else:
+ self.putEmptyValue()
+ if self.isExpanded():
+ with Children(self, 2):
+ self.putSubItem("first", key)
+ self.putSubItem("second", value)
def isMapCompact(self, keyType, valueType):
format = self.currentItemFormat()
@@ -596,7 +658,7 @@ class DumperBase:
if format == 0:
# Explicitly requested bald pointer.
self.putType(typeName)
- self.putPointerValue(value)
+ self.putValue(b16encode(str(value)), Hex2EncodedUtf8WithoutQuotes)
self.putNumChild(1)
if self.currentIName in self.expandedINames:
with Children(self):
@@ -639,20 +701,13 @@ class DumperBase:
self.putNumChild(0)
return True
- if format == 6:
- # Explicitly requested formatting as array of 10 items.
- self.putType(typeName)
- self.putItemCount(10)
- self.putNumChild(10)
- self.putArrayData(innerType, value, 10)
- return True
-
- if format == 7:
- # Explicitly requested formatting as array of 1000 items.
+ if not format is None and format >= 6 and format <= 9:
+ # Explicitly requested formatting as array of n items.
+ n = (10, 100, 1000, 10000)[format - 6]
self.putType(typeName)
- self.putItemCount(1000)
- self.putNumChild(1000)
- self.putArrayData(innerType, value, 1000)
+ self.putItemCount(n)
+ self.putNumChild(n)
+ self.putArrayData(innerType, value, n)
return True
if self.isFunctionType(innerType):
@@ -777,6 +832,46 @@ class DumperBase:
format = self.typeformats.get(needle)
return format
+ def putPlotData(self, type, base, n, plotFormat = 2):
+ if self.isExpanded():
+ self.putArrayData(type, base, n)
+ if not hasPlot():
+ return
+ if not self.isSimpleType(type):
+ #self.putValue(self.currentValue + " (not plottable)")
+ self.putValue(self.currentValue)
+ self.putField("plottable", "0")
+ return
+ global gnuplotPipe
+ global gnuplotPid
+ format = self.currentItemFormat()
+ iname = self.currentIName
+ if format != plotFormat:
+ if iname in gnuplotPipe:
+ os.kill(gnuplotPid[iname], 9)
+ del gnuplotPid[iname]
+ gnuplotPipe[iname].terminate()
+ del gnuplotPipe[iname]
+ return
+ base = self.createPointerValue(base, type)
+ if not iname in gnuplotPipe:
+ gnuplotPipe[iname] = subprocess.Popen(["gnuplot"],
+ stdin=subprocess.PIPE)
+ gnuplotPid[iname] = gnuplotPipe[iname].pid
+ f = gnuplotPipe[iname].stdin;
+ # On Ubuntu install gnuplot-x11
+ f.write("set term wxt noraise\n")
+ f.write("set title 'Data fields'\n")
+ f.write("set xlabel 'Index'\n")
+ f.write("set ylabel 'Value'\n")
+ f.write("set grid\n")
+ f.write("set style data lines;\n")
+ f.write("plot '-' title '%s'\n" % iname)
+ for i in range(0, n):
+ f.write(" %s\n" % base.dereference())
+ base += 1
+ f.write("e\n")
+
def cleanAddress(addr):
if addr is None:
return "<no address>"
diff --git a/share/qtcreator/debugger/dumper_p.h b/share/qtcreator/debugger/dumper_p.h
deleted file mode 100644
index c9ce0ea9ab..0000000000
--- a/share/qtcreator/debugger/dumper_p.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef DUMPER_P_H
-#define DUMPER_P_H
-
-#include <QObject>
-#include <QPointer>
-
-#ifndef QT_BOOTSTRAPPED
-
-#undef NS
-#ifdef QT_NAMESPACE
-# define STRINGIFY0(s) #s
-# define STRINGIFY1(s) STRINGIFY0(s)
-# define NS STRINGIFY1(QT_NAMESPACE) "::"
-# define NSX "'" STRINGIFY1(QT_NAMESPACE) "::"
-# define NSY "'"
-#else
-# define NS ""
-# define NSX "'"
-# define NSY "'"
-#endif
-
-#if defined(QT_BEGIN_NAMESPACE)
-QT_BEGIN_NAMESPACE
-#endif
-
-struct Sender { QObject *sender; int signal; int ref; };
-
-#if QT_VERSION < 0x040600
- struct Connection
- {
- QObject *receiver;
- int method;
- uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
- QBasicAtomicPointer<int> argumentTypes;
- int method_() const { return method; }
- };
-#elif QT_VERSION < 0x040800
- struct Connection
- {
- QObject *sender;
- QObject *receiver;
- int method;
- uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
- QBasicAtomicPointer<int> argumentTypes;
- Connection *nextConnectionList;
- //senders linked list
- Connection *next;
- Connection **prev;
- int method_() const { return method; }
- };
-#else
- typedef void (*StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **);
- struct Connection
- {
- QObject *sender;
- QObject *receiver;
- StaticMetaCallFunction callFunction;
- // The next pointer for the singly-linked ConnectionList
- Connection *nextConnectionList;
- //senders linked list
- Connection *next;
- Connection **prev;
- QBasicAtomicPointer<int> argumentTypes;
- ushort method_offset;
- ushort method_relative;
- ushort connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
- ~Connection();
- int method() const { return method_offset + method_relative; }
- int method_() const { return method(); }
- };
-#endif
-
-#if QT_VERSION < 0x040600
- typedef QList<Connection> ConnectionList;
- typedef QList<Sender> SenderList;
-
- static inline const Connection &connectionAt(const ConnectionList &l, int i)
- {
- return l.at(i);
- }
- static inline const QObject *senderAt(const SenderList &l, int i)
- {
- return l.at(i).sender;
- }
- static inline int signalAt(const SenderList &l, int i)
- {
- return l.at(i).signal;
- }
-//#elif QT_VERSION < 0x040800
-#else
- struct ConnectionList
- {
- ConnectionList() : first(0), last(0) { }
- int size() const
- {
- int count = 0;
- for (Connection *c = first; c != 0; c = c->nextConnectionList)
- ++count;
- return count;
- }
-
- Connection *first;
- Connection *last;
- };
-
- typedef Connection *SenderList;
-
- static inline const Connection &connectionAt(const ConnectionList &l, int i)
- {
- Connection *conn = l.first;
- for (int cnt = 0; cnt < i; ++cnt)
- conn = conn->nextConnectionList;
- return *conn;
- }
-#endif
-
-class ObjectPrivate : public QObjectData
-{
-public:
- ObjectPrivate() {}
- virtual ~ObjectPrivate() {}
-
-#if QT_VERSION < 0x040600
- QList<QObject *> pendingChildInsertedEvents;
- void *threadData;
- void *currentSender;
- void *currentChildBeingDeleted;
- QList<QPointer<QObject> > eventFilters;
- void *extraData;
- mutable quint32 connectedSignals;
- QString objectName;
- void *connectionLists;
- SenderList senders;
- int *deleteWatch;
-#elif QT_VERSION < 0x040800
- QString objectName;
- void *extraData;
- void *threadData;
- void *connectionLists;
- SenderList senders;
- void *currentSender;
- mutable quint32 connectedSignals[2];
- QList<QObject *> pendingChildInsertedEvents;
- QList<QPointer<QObject> > eventFilters;
- void *currentChildBeingDeleted;
- QAtomicPointer<void> sharedRefcount;
- int *deleteWatch;
-#else
- QString objectName;
- void *extraData;
- void *threadData;
- void *connectionLists;
- Connection *senders;
- Sender *currentSender;
- mutable quint32 connectedSignals[2];
- void *unused;
- QList<QPointer<QObject> > eventFilters;
- union {
- QObject *currentChildBeingDeleted;
- void *declarativeData;
- };
- QAtomicPointer<void> sharedRefcount;
- #ifdef QT_JAMBI_BUILD
- int *deleteWatch;
- #endif
-#endif
-};
-
-#endif // QT_BOOTSTRAPPED
-
-#if defined(QT_BEGIN_NAMESPACE)
-QT_END_NAMESPACE
-#endif
-
-#endif // DUMPER_P_H
diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py
index 8308028a9a..dad14c02b7 100644
--- a/share/qtcreator/debugger/gdbbridge.py
+++ b/share/qtcreator/debugger/gdbbridge.py
@@ -515,13 +515,11 @@ class Dumper(DumperBase):
self.autoDerefPointers = "autoderef" in options
self.partialUpdate = "partial" in options
self.tooltipOnly = "tooltiponly" in options
- self.noLocals = "nolocals" in options
#warn("NAMESPACE: '%s'" % self.qtNamespace())
#warn("VARIABLES: %s" % varList)
#warn("EXPANDED INAMES: %s" % self.expandedINames)
#warn("WATCHERS: %s" % watchers)
#warn("PARTIAL: %s" % self.partialUpdate)
- #warn("NO LOCALS: %s" % self.noLocals)
#
# Locals
@@ -548,7 +546,7 @@ class Dumper(DumperBase):
pass
varList = []
- if fullUpdateNeeded and not self.tooltipOnly and not self.noLocals:
+ if fullUpdateNeeded and not self.tooltipOnly:
locals = listOfLocals(varList)
# Take care of the return value of the last function call.
@@ -611,7 +609,6 @@ class Dumper(DumperBase):
#
with OutputSafer(self):
if len(watchers) > 0:
- self.put(",")
for watcher in watchers.split("##"):
(exp, iname) = watcher.split("#")
self.handleWatch(exp, iname)
@@ -999,6 +996,12 @@ class Dumper(DumperBase):
return xrange(0, toInteger(self.currentNumChild))
return xrange(min(toInteger(self.currentMaxNumChild), toInteger(self.currentNumChild)))
+ def isArmArchitecture(self):
+ return 'arm' in gdb.TARGET_CONFIG.lower()
+
+ def isQnxTarget(self):
+ return 'qnx' in gdb.TARGET_CONFIG.lower()
+
def qtVersion(self):
try:
version = str(gdb.parse_and_eval("qVersion()"))
@@ -1007,7 +1010,7 @@ class Dumper(DumperBase):
except:
try:
# This will fail on Qt 5
- gdb.execute("ptype QString::shared_empty", to_string=True)
+ gdb.execute("ptype QString::shared_null", to_string=True)
self.cachedQtVersion = 0x040800
except:
#self.cachedQtVersion = 0x050000
@@ -1018,6 +1021,21 @@ class Dumper(DumperBase):
self.qtVersion = lambda: self.cachedQtVersion
return self.cachedQtVersion
+ def isQt3Support(self):
+ if self.qtVersion() >= 0x050000:
+ return False
+ else:
+ try:
+ # This will fail on Qt 4 without Qt 3 support
+ gdb.execute("ptype QChar::null", to_string=True)
+ self.cachedIsQt3Suport = True
+ except:
+ self.cachedIsQt3Suport = False
+
+ # Memoize good results.
+ self.isQt3Support = lambda: self.cachedIsQt3Suport
+ return self.cachedIsQt3Suport
+
def putBetterType(self, type):
self.currentType = str(type)
self.currentTypePriority = self.currentTypePriority + 1
@@ -1142,48 +1160,6 @@ class Dumper(DumperBase):
def isStructType(self, typeobj):
return typeobj.code == gdb.TYPE_CODE_STRUCT
- def putPlotData(self, type, base, n, plotFormat):
- if self.isExpanded():
- self.putArrayData(type, base, n)
- if not hasPlot():
- return
- if not self.isSimpleType(type):
- #self.putValue(self.currentValue + " (not plottable)")
- self.putValue(self.currentValue)
- self.putField("plottable", "0")
- return
- global gnuplotPipe
- global gnuplotPid
- format = self.currentItemFormat()
- iname = self.currentIName
- #if False:
- if format != plotFormat:
- if iname in gnuplotPipe:
- os.kill(gnuplotPid[iname], 9)
- del gnuplotPid[iname]
- gnuplotPipe[iname].terminate()
- del gnuplotPipe[iname]
- return
- base = base.cast(type.pointer())
- if not iname in gnuplotPipe:
- gnuplotPipe[iname] = subprocess.Popen(["gnuplot"],
- stdin=subprocess.PIPE)
- gnuplotPid[iname] = gnuplotPipe[iname].pid
- f = gnuplotPipe[iname].stdin;
- # On Ubuntu install gnuplot-x11
- f.write("set term wxt noraise\n")
- f.write("set title 'Data fields'\n")
- f.write("set xlabel 'Index'\n")
- f.write("set ylabel 'Value'\n")
- f.write("set grid\n")
- f.write("set style data lines;\n")
- f.write("plot '-' title '%s'\n" % iname)
- for i in range(0, n):
- f.write(" %s\n" % base.dereference())
- base += 1
- f.write("e\n")
-
-
def putArrayData(self, type, base, n,
childNumChild = None, maxNumChild = 10000):
if not self.tryPutArrayContents(type, base, n):
@@ -1489,9 +1465,11 @@ class Dumper(DumperBase):
if dumpBase:
baseNumber += 1
with UnnamedSubItem(self, "@%d" % baseNumber):
+ baseValue = value.cast(field.type)
self.put('iname="%s",' % self.currentIName)
self.put('name="[%s]",' % field.name)
- self.putItem(value.cast(field.type), False)
+ self.putAddress(baseValue.address)
+ self.putItem(baseValue, False)
elif len(field.name) == 0:
# Anonymous union. We need a dummy name to distinguish
# multiple anonymous unions in the struct.
@@ -1743,6 +1721,9 @@ class Dumper(DumperBase):
self.typesReported[typename] = True
self.typesToReport[typename] = type
+ def enumExpression(self, enumType, enumValue):
+ return self.qtNamespace() + "Qt::" + enumValue
+
def lookupType(self, typestring):
type = self.typeCache.get(typestring)
#warn("LOOKUP 1: %s -> %s" % (typestring, type))
diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py
index fd7fef4fb9..d88bed7bdb 100644
--- a/share/qtcreator/debugger/lldbbridge.py
+++ b/share/qtcreator/debugger/lldbbridge.py
@@ -357,7 +357,7 @@ class Dumper(DumperBase):
self.put('value="<not accessible>",numchild="0",')
else:
if not self.currentValueEncoding is None:
- self.put('valueencoded="%d",' % self.currentValueEncoding)
+ self.put('valueencoded="%s",' % self.currentValueEncoding)
self.put('value="%s",' % self.currentValue)
except:
pass
@@ -386,6 +386,11 @@ class Dumper(DumperBase):
def pointerValue(self, value):
return value.GetValueAsUnsigned()
+ def enumExpression(self, enumType, enumValue):
+ ns = self.qtNamespace()
+ return ns + "Qt::" + enumType + "(" \
+ + ns + "Qt::" + enumType + "::" + enumValue + ")"
+
def call2(self, value, func, args):
# args is a tuple.
arg = ','.join(args)
@@ -432,22 +437,55 @@ class Dumper(DumperBase):
def isStructType(self, typeobj):
return typeobj.GetTypeClass() in (lldb.eTypeClassStruct, lldb.eTypeClassClass)
- def qtVersion(self):
+ def qtVersionAndNamespace(self):
+ self.cachedQtNamespace = ""
self.cachedQtVersion = 0x0
+
coreExpression = re.compile(r"(lib)?Qt5?Core")
for n in range(0, self.target.GetNumModules()):
module = self.target.GetModuleAtIndex(n)
- if coreExpression.match(module.GetFileSpec().GetFilename()):
+ fileName = module.GetFileSpec().GetFilename()
+ if coreExpression.match(fileName):
+ # Extract version.
reverseVersion = module.GetVersion()
- reverseVersion.reverse()
- shift = 0
- for v in reverseVersion:
- self.cachedQtVersion += v << shift
- shift += 8
+ if len(reverseVersion):
+ # Mac, Clang?
+ reverseVersion.reverse()
+ shift = 0
+ for v in reverseVersion:
+ self.cachedQtVersion += v << shift
+ shift += 8
+ else:
+ # Linux, gcc?
+ if fileName.endswith(".5"):
+ self.cachedQtVersion = 0x50000
+ elif fileName.endswith(".4"):
+ self.cachedQtVersion = 0x40800
+ else:
+ warn("CANNOT GUESS QT VERSION")
+
+
+ # Look for some Qt symbol to extract namespace.
+ for symbol in module.symbols:
+ name = symbol.GetName()
+ pos = name.find("QString")
+ if pos >= 0:
+ name = name[:pos]
+ if name.endswith("::"):
+ self.cachedQtNamespace = re.sub('^.*[^\w]([\w]+)::$', '\\1', name) + '::'
+ break
break
# Memoize good results.
+ self.qtNamespace = lambda: self.cachedQtNamespace
self.qtVersion = lambda: self.cachedQtVersion
+
+ def qtNamespace(self):
+ self.qtVersionAndNamespace()
+ return self.cachedQtNamespace
+
+ def qtVersion(self):
+ self.qtVersionAndNamespace()
return self.cachedQtVersion
def intSize(self):
@@ -543,13 +581,6 @@ class Dumper(DumperBase):
self.put('",')
return True
- def putPlotData(self, type, base, n, plotFormat):
- #warn("PLOTDATA: %s %s" % (type, n))
- if self.isExpanded():
- self.putArrayData(type, base, n)
- self.putValue(self.currentValue)
- self.putField("plottable", "0")
-
def putArrayData(self, type, base, n,
childNumChild = None, maxNumChild = 10000):
if not self.tryPutArrayContents(type, base, n):
@@ -797,16 +828,12 @@ class Dumper(DumperBase):
except:
return False
- def qtNamespace(self):
- # FIXME
- return ""
-
def stripNamespaceFromType(self, typeName):
#type = stripClassTag(typeName)
type = typeName
- #ns = qtNamespace()
- #if len(ns) > 0 and type.startswith(ns):
- # type = type[len(ns):]
+ ns = self.qtNamespace()
+ if len(ns) > 0 and type.startswith(ns):
+ type = type[len(ns):]
pos = type.find("<")
# FIXME: make it recognize foo<A>::bar<B>::iterator?
while pos != -1:
@@ -838,7 +865,7 @@ class Dumper(DumperBase):
def putItem(self, value, tryDynamic=True):
#value = value.GetDynamicValue(lldb.eDynamicCanRunTarget)
- typeName = value.GetTypeName()
+ typeName = value.GetType().GetUnqualifiedType().GetName()
value.SetPreferDynamicValue(tryDynamic)
typeClass = value.GetType().GetTypeClass()
@@ -879,10 +906,10 @@ class Dumper(DumperBase):
return
realType = value.GetType()
if hasattr(realType, 'GetCanonicalType'):
- realType = realType.GetCanonicalType()
- value = value.Cast(realType.unqualified())
- self.putItem(value)
- self.putBetterType(typeName)
+ baseType = realType.GetCanonicalType()
+ baseValue = value.Cast(baseType.unqualified())
+ self.putItem(baseValue)
+ self.putBetterType(realType)
return
# Our turf now.
@@ -1507,7 +1534,9 @@ def testit():
None, None, 0, False, error)
db.report = savedReport
+ ns = db.qtNamespace()
db.reportVariables()
+ db.report("@NS@%s@" % ns)
#db.report("DUMPER=%s" % qqDumpers)
if __name__ == "__main__":
diff --git a/share/qtcreator/debugger/misctypes.py b/share/qtcreator/debugger/misctypes.py
index 4738313a57..d818534ae9 100644
--- a/share/qtcreator/debugger/misctypes.py
+++ b/share/qtcreator/debugger/misctypes.py
@@ -35,19 +35,79 @@ from dumper import *
#
#######################################################################
-def qform____m128():
- return "As Floats,As Doubles"
-
def qdump____m128(d, value):
d.putEmptyValue()
d.putNumChild(1)
if d.isExpanded():
- format = d.currentItemFormat()
- if format == 2: # As Double
- d.putArrayData(d.lookupType("double"), value.address, 2)
- else: # Default, As float
- d.putArrayData(d.lookupType("float"), value.address, 4)
+ d.putArrayData(d.lookupType("float"), value.address, 4)
+
+def qdump____m256(d, value):
+ d.putEmptyValue()
+ d.putNumChild(1)
+ if d.isExpanded():
+ d.putArrayData(d.lookupType("float"), value.address, 8)
+
+def qdump____m128d(d, value):
+ d.putEmptyValue()
+ d.putNumChild(1)
+ if d.isExpanded():
+ d.putArrayData(d.lookupType("double"), value.address, 2)
+
+def qdump____m256d(d, value):
+ d.putEmptyValue()
+ d.putNumChild(1)
+ if d.isExpanded():
+ d.putArrayData(d.lookupType("double"), value.address, 4)
+def qdump____m128i(d, value):
+ data = d.readMemory(value.address, 16)
+ d.putValue(':'.join("%04x" % int(data[i:i+4], 16) for i in xrange(0, 32, 4)))
+ d.putNumChild(4)
+ if d.isExpanded():
+ # fake 4 children as arrays
+ with Children(d):
+ with SubItem(d, "uint8x16"):
+ d.putEmptyValue()
+ d.putType("unsigned char [16]")
+ d.putArrayData(d.lookupType("unsigned char"), value.address, 16)
+ d.putAddress(value.address)
+ with SubItem(d, "uint16x8"):
+ d.putEmptyValue()
+ d.putType("unsigned short [8]")
+ d.putArrayData(d.lookupType("unsigned short"), value.address, 8)
+ with SubItem(d, "uint32x4"):
+ d.putEmptyValue()
+ d.putType("unsigned int [4]")
+ d.putArrayData(d.lookupType("unsigned int"), value.address, 4)
+ with SubItem(d, "uint64x2"):
+ d.putEmptyValue()
+ d.putType("unsigned long long [2]")
+ d.putArrayData(d.lookupType("unsigned long long"), value.address, 2)
+
+def qdump____m256i(d, value):
+ data = d.readMemory(value.address, 32)
+ d.putValue(':'.join("%04x" % int(data[i:i+4], 16) for i in xrange(0, 64, 4)))
+ d.putNumChild(4)
+ if d.isExpanded():
+ # fake 4 children as arrays
+ with Children(d):
+ with SubItem(d, "uint8x32"):
+ d.putEmptyValue()
+ d.putType("unsigned char [32]")
+ d.putArrayData(d.lookupType("unsigned char"), value.address, 32)
+ d.putAddress(value.address)
+ with SubItem(d, "uint16x8"):
+ d.putEmptyValue()
+ d.putType("unsigned short [16]")
+ d.putArrayData(d.lookupType("unsigned short"), value.address, 16)
+ with SubItem(d, "uint32x8"):
+ d.putEmptyValue()
+ d.putType("unsigned int [8]")
+ d.putArrayData(d.lookupType("unsigned int"), value.address, 8)
+ with SubItem(d, "uint64x4"):
+ d.putEmptyValue()
+ d.putType("unsigned long long [4]")
+ d.putArrayData(d.lookupType("unsigned long long"), value.address, 4)
#######################################################################
#
diff --git a/share/qtcreator/debugger/qttypes.py b/share/qtcreator/debugger/qttypes.py
index a2d356bd95..4a9256c06e 100644
--- a/share/qtcreator/debugger/qttypes.py
+++ b/share/qtcreator/debugger/qttypes.py
@@ -189,20 +189,20 @@ def qdump__QModelIndex(d, value):
def qdump__QDate(d, value):
jd = int(value["jd"])
- if int(jd):
+ if jd:
d.putValue(jd, JulianDate)
d.putNumChild(1)
if d.isExpanded():
- qt = d.qtNamespace() + "Qt::"
- if d.isLldb:
- qt += "DateFormat::" # FIXME: Bug?...
# FIXME: This improperly uses complex return values.
with Children(d):
- d.putCallItem("toString", value, "toString", qt + "TextDate")
- d.putCallItem("(ISO)", value, "toString", qt + "ISODate")
+ d.putCallItem("toString", value, "toString",
+ d.enumExpression("DateFormat", "TextDate"))
+ d.putCallItem("(ISO)", value, "toString",
+ d.enumExpression("DateFormat", "ISODate"))
d.putCallItem("(SystemLocale)", value, "toString",
- qt + "SystemLocaleDate")
- d.putCallItem("(Locale)", value, "toString", qt + "LocaleDate")
+ d.enumExpression("DateFormat", "SystemLocaleDate"))
+ d.putCallItem("(Locale)", value, "toString",
+ d.enumExpression("DateFormat", "LocaleDate"))
else:
d.putValue("(invalid)")
d.putNumChild(0)
@@ -214,18 +214,16 @@ def qdump__QTime(d, value):
d.putValue(mds, MillisecondsSinceMidnight)
d.putNumChild(1)
if d.isExpanded():
- ns = d.qtNamespace()
- qtdate = ns + "Qt::"
- qttime = ns + "Qt::"
- if d.isLldb:
- qtdate += "DateFormat::" # FIXME: Bug?...
# FIXME: This improperly uses complex return values.
with Children(d):
- d.putCallItem("toString", value, "toString", qtdate + "TextDate")
- d.putCallItem("(ISO)", value, "toString", qtdate + "ISODate")
+ d.putCallItem("toString", value, "toString",
+ d.enumExpression("DateFormat", "TextDate"))
+ d.putCallItem("(ISO)", value, "toString",
+ d.enumExpression("DateFormat", "ISODate"))
d.putCallItem("(SystemLocale)", value, "toString",
- qtdate + "SystemLocaleDate")
- d.putCallItem("(Locale)", value, "toString", qtdate + "LocaleDate")
+ d.enumExpression("DateFormat", "SystemLocaleDate"))
+ d.putCallItem("(Locale)", value, "toString",
+ d.enumExpression("DateFormat", "LocaleDate"))
else:
d.putValue("(invalid)")
d.putNumChild(0)
@@ -233,7 +231,7 @@ def qdump__QTime(d, value):
def qdump__QTimeZone(d, value):
base = d.dereferenceValue(value)
- if d.isNull(base):
+ if base == 0:
d.putValue("(null)")
d.putNumChild(0)
return
@@ -256,7 +254,7 @@ def qdump__QDateTime(d, value):
# QTimeZone m_timeZone // only #ifndef QT_BOOTSTRAPPED
# StatusFlags m_status
status = d.extractInt(dateBase + 16 + d.ptrSize())
- if int(status & 0x10): # ValidDateTime
+ if int(status & 0x0c == 0x0c): # ValidDate and ValidTime
isValid = True
msecs = d.extractInt64(dateBase)
spec = d.extractInt(dateBase + 8)
@@ -294,18 +292,19 @@ def qdump__QDateTime(d, value):
if d.isExpanded():
# FIXME: This improperly uses complex return values.
with Children(d):
- qtdate = d.qtNamespace() + "Qt::"
- qttime = qtdate
- if d.isLldb:
- qtdate += "DateFormat::" # FIXME: Bug?...
- qttime += "TimeSpec::" # FIXME: Bug?...
d.putCallItem("toTime_t", value, "toTime_t")
- d.putCallItem("toString", value, "toString", qtdate + "TextDate")
- d.putCallItem("(ISO)", value, "toString", qtdate + "ISODate")
- d.putCallItem("(SystemLocale)", value, "toString", qtdate + "SystemLocaleDate")
- d.putCallItem("(Locale)", value, "toString", qtdate + "LocaleDate")
- d.putCallItem("toUTC", value, "toTimeSpec", qttime + "UTC")
- d.putCallItem("toLocalTime", value, "toTimeSpec", qttime + "LocalTime")
+ d.putCallItem("toString", value, "toString",
+ d.enumExpression("DateFormat", "TextDate"))
+ d.putCallItem("(ISO)", value, "toString",
+ d.enumExpression("DateFormat", "ISODate"))
+ d.putCallItem("(SystemLocale)", value, "toString",
+ d.enumExpression("DateFormat", "SystemLocaleDate"))
+ d.putCallItem("(Locale)", value, "toString",
+ d.enumExpression("DateFormat", "LocaleDate"))
+ d.putCallItem("toUTC", value, "toTimeSpec",
+ d.enumExpression("TimeSpec", "UTC"))
+ d.putCallItem("toLocalTime", value, "toTimeSpec",
+ d.enumExpression("TimeSpec", "LocalTime"))
else:
d.putValue("(invalid)")
d.putNumChild(0)
@@ -316,6 +315,16 @@ def qdump__QDir(d, value):
privAddress = d.dereferenceValue(value)
bit32 = d.is32bit()
qt5 = d.qtVersion() >= 0x050000
+
+ # Change 9fc0965 reorders members again.
+ # bool fileListsInitialized;\n"
+ # QStringList files;\n"
+ # QFileInfoList fileInfos;\n"
+ # QStringList nameFilters;\n"
+ # QDir::SortFlags sort;\n"
+ # QDir::Filters filters;\n"
+
+ # Before 9fc0965:
# QDirPrivate:
# QAtomicInt ref
# QStringList nameFilters;
@@ -331,10 +340,7 @@ def qdump__QDir(d, value):
# QFileInfoList fileInfos;
# QFileSystemEntry dirEntry;
# QFileSystemEntry absoluteDirEntry;
- qt3SupportAddition = 0 if qt5 else d.ptrSize() # qt5 doesn't have qt3support
- filesOffset = (24 if bit32 else 40) + qt3SupportAddition
- fileInfosOffset = filesOffset + d.ptrSize()
- dirEntryOffset = fileInfosOffset + d.ptrSize()
+
# QFileSystemEntry:
# QString m_filePath
# QByteArray m_nativeFilePath
@@ -343,7 +349,33 @@ def qdump__QDir(d, value):
# qint16 m_lastDotInFileName
# + 2 byte padding
fileSystemEntrySize = 2 * d.ptrSize() + 8
- absoluteDirEntryOffset = dirEntryOffset + fileSystemEntrySize
+
+ done = False
+ if d.qtVersion() >= 0x050200:
+ # Try to distinguish bool vs QStringList at the beginning:
+ firstValue = d.extractInt(privAddress)
+ if firstValue == 0 or firstValue == 1:
+ # Looks like a bool. Assume this is after 9fc0965.
+ done = True
+ if bit32:
+ filesOffset = 4
+ fileInfosOffset = 8
+ dirEntryOffset = 0x20
+ absoluteDirEntryOffset = 0x30
+ else:
+ filesOffset = 0x08
+ fileInfosOffset = 0x10
+ dirEntryOffset = 0x30
+ absoluteDirEntryOffset = 0x48
+ if not done:
+ # Assume this is before 9fc0965.
+ qt3support = d.isQt3Support()
+ qt3SupportAddition = d.ptrSize() if qt3support else 0
+ filesOffset = (24 if bit32 else 40) + qt3SupportAddition
+ fileInfosOffset = filesOffset + d.ptrSize()
+ dirEntryOffset = fileInfosOffset + d.ptrSize()
+ absoluteDirEntryOffset = dirEntryOffset + fileSystemEntrySize
+
d.putStringValueByAddress(privAddress + dirEntryOffset)
if d.isExpanded():
with Children(d):
@@ -471,6 +503,9 @@ def qdump__QFixed(d, value):
d.putNumChild(0)
+def qform__QFiniteStack():
+ return arrayForms()
+
def qdump__QFiniteStack(d, value):
alloc = int(value["_alloc"])
size = int(value["_size"])
@@ -479,7 +514,7 @@ def qdump__QFiniteStack(d, value):
d.putNumChild(size)
if d.isExpanded():
innerType = d.templateArgument(value.type, 0)
- d.putArrayData(innerType, value["_array"], size)
+ d.putPlotData(innerType, value["_array"], size)
# Stock gdb 7.2 seems to have a problem with types here:
#
@@ -758,6 +793,7 @@ def qdump__QImage(d, value):
ptrSize = d.ptrSize()
isQt5 = d.qtVersion() >= 0x050000
+ qt3Support = d.isQt3Support()
offset = (3 if isQt5 else 2) * ptrSize
base = d.dereference(d.addressOf(value) + offset)
width = d.extractInt(base + 4)
@@ -765,7 +801,7 @@ def qdump__QImage(d, value):
nbytes = d.extractInt(base + 16)
padding = d.ptrSize() - d.intSize()
pixelRatioSize = 8 if isQt5 else 0
- jumpTableSize = ptrSize if not isQt5 else 0 # FIXME: Assumes Qt3 Support
+ jumpTableSize = ptrSize if qt3Support else 0
bits = d.dereference(base + 20 + padding + pixelRatioSize + ptrSize)
iformat = d.extractInt(base + 20 + padding + pixelRatioSize + jumpTableSize + 2 * ptrSize)
d.putValue("(%dx%d)" % (width, height))
@@ -893,9 +929,17 @@ def qdumpHelper__Qt4_QMap(d, value, forceLong):
# QMapPayloadNode is QMapNode except for the 'forward' member, so
# its size is most likely the offset of the 'forward' member therein.
# Or possibly 2 * sizeof(void *)
- nodeType = d.lookupType(d.qtNamespace() + "QMapNode<%s,%s>" % (keyType, valueType))
+ # Note: Keeping the spacing in the type lookup
+ # below is important for LLDB.
+ needle = str(value.type).replace("QMap", "QMapNode", 1)
+ needle = d.qtNamespace() + "QMapNode<%s,%s>" % (keyType, valueType)
+ nodeType = d.lookupType(needle)
nodePointerType = nodeType.pointer()
- payloadSize = nodeType.sizeof - 2 * nodePointerType.sizeof
+ # symbols reports payload size at wrong size 24
+ if d.isArmArchitecture() and d.isQnxTarget() and str(valueType) == 'QVariant':
+ payloadSize = 28
+ else:
+ payloadSize = nodeType.sizeof - 2 * nodePointerType.sizeof
if isCompact:
innerType = valueType
@@ -1656,6 +1700,9 @@ def qdump__QSizeF(d, value):
d.putPlainChildren(value)
+def qform__QStack():
+ return arrayForms()
+
def qdump__QStack(d, value):
qdump__QVector(d, value)
@@ -2035,7 +2082,7 @@ def qdump__QVector(d, value):
d.check(0 <= size and size <= alloc and alloc <= 1000 * 1000 * 1000)
d.putItemCount(size)
d.putNumChild(size)
- d.putPlotData(innerType, p, size, 2)
+ d.putPlotData(innerType, p, size)
def qdump__QWeakPointer(d, value):
diff --git a/share/qtcreator/debugger/stdtypes.py b/share/qtcreator/debugger/stdtypes.py
index 8734a0cf43..c36292a721 100644
--- a/share/qtcreator/debugger/stdtypes.py
+++ b/share/qtcreator/debugger/stdtypes.py
@@ -29,14 +29,20 @@
from dumper import *
+def qform__std__array():
+ return arrayForms()
+
def qdump__std__array(d, value):
size = d.numericTemplateArgument(value.type, 1)
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
innerType = d.templateArgument(value.type, 0)
- d.putArrayData(innerType, d.addressOf(value), size)
+ d.putPlotData(innerType, d.addressOf(value), size)
+
+def qform__std____1__array():
+ return arrayForms()
def qdump__std____1__array(d, value):
qdump__std__array(d, value)
@@ -55,6 +61,10 @@ def qdump__std__complex(d, value):
def qdump__std__deque(d, value):
+ if d.isQnxTarget():
+ qdump__std__deque__QNX(d, value)
+ return
+
innerType = d.templateArgument(value.type, 0)
innerSize = innerType.sizeof
bufsize = 1
@@ -87,11 +97,47 @@ def qdump__std__deque(d, value):
plast = pfirst + bufsize
pcur = pfirst
+def qdump__std__deque__QNX(d, value):
+ innerType = d.templateArgument(value.type, 0)
+ innerSize = innerType.sizeof
+ if innerSize <= 1:
+ bufsize = 16
+ elif innerSize <= 2:
+ bufsize = 8
+ elif innerSize <= 4:
+ bufsize = 4
+ elif innerSize <= 8:
+ bufsize = 2
+ else:
+ bufsize = 1
+
+ myoff = value['_Myoff']
+ mysize = value['_Mysize']
+ mapsize = value['_Mapsize']
+
+ d.check(0 <= mapsize and mapsize <= 1000 * 1000 * 1000)
+ d.putItemCount(mysize)
+ d.putNumChild(mysize)
+ if d.isExpanded():
+ with Children(d, mysize, maxNumChild=2000, childType=innerType):
+ map = value['_Map']
+ for i in d.childRange():
+ block = myoff / bufsize
+ offset = myoff - (block * bufsize)
+ if mapsize <= block:
+ block -= mapsize
+ d.putSubItem(i, map[block][offset])
+ myoff += 1;
+
def qdump__std____debug__deque(d, value):
qdump__std__deque(d, value)
def qdump__std__list(d, value):
+ if d.isQnxTarget():
+ qdump__std__list__QNX(d, value)
+ return
+
impl = value["_M_impl"]
node = impl["_M_node"]
head = d.addressOf(node)
@@ -113,6 +159,21 @@ def qdump__std__list(d, value):
d.putSubItem(i, (p + 1).cast(innerPointer).dereference())
p = p["_M_next"]
+def qdump__std__list__QNX(d, value):
+ node = value["_Myhead"]
+ size = value["_Mysize"]
+
+ d.putItemCount(size, 1000)
+ d.putNumChild(size)
+
+ if d.isExpanded():
+ p = node["_Next"]
+ innerType = d.templateArgument(value.type, 0)
+ with Children(d, size, maxNumChild=1000, childType=innerType):
+ for i in d.childRange():
+ d.putSubItem(i, p['_Myval'])
+ p = p["_Next"]
+
def qdump__std____debug__list(d, value):
qdump__std__list(d, value)
@@ -120,6 +181,10 @@ def qform__std__map():
return mapForms()
def qdump__std__map(d, value):
+ if d.isQnxTarget():
+ qdump__std__map__QNX(d, value)
+ return
+
impl = value["_M_t"]["_M_impl"]
size = int(impl["_M_node_count"])
d.check(0 <= size and size <= 100*1000*1000)
@@ -127,6 +192,33 @@ def qdump__std__map(d, value):
d.putNumChild(size)
if d.isExpanded():
+ pairType = d.templateArgument(d.templateArgument(value.type, 3), 0)
+ pairPointer = pairType.pointer()
+ with PairedChildren(d, size, pairType, maxNumChild=1000):
+ node = impl["_M_header"]["_M_left"]
+ for i in d.childRange():
+ with SubItem(d, i):
+ pair = (node + 1).cast(pairPointer).dereference()
+ d.putPair(pair)
+ if d.isNull(node["_M_right"]):
+ parent = node["_M_parent"]
+ while node == parent["_M_right"]:
+ node = parent
+ parent = parent["_M_parent"]
+ if node["_M_right"] != parent:
+ node = parent
+ else:
+ node = node["_M_right"]
+ while not d.isNull(node["_M_left"]):
+ node = node["_M_left"]
+
+def qdump__std__map__QNX(d, value):
+ size = value['_Mysize']
+ d.check(0 <= size and size <= 100*1000*1000)
+ d.putItemCount(size)
+ d.putNumChild(size)
+
+ if d.isExpanded():
keyType = d.templateArgument(value.type, 0)
valueType = d.templateArgument(value.type, 1)
try:
@@ -142,7 +234,9 @@ def qdump__std__map(d, value):
innerType = pairType
if isCompact:
innerType = valueType
- node = impl["_M_header"]["_M_left"]
+ head = value['_Myhead']
+ node = head['_Left']
+ nodeType = head.type
childType = innerType
if size == 0:
childType = pairType
@@ -153,7 +247,7 @@ def qdump__std__map(d, value):
childType=childType, childNumChild=childNumChild):
for i in d.childRange():
with SubItem(d, i):
- pair = (node + 1).cast(pairPointer).dereference()
+ pair = node.cast(nodeType).dereference()['_Myval']
if isCompact:
d.putMapName(pair["first"])
d.putItem(pair["second"])
@@ -163,17 +257,17 @@ def qdump__std__map(d, value):
with Children(d, 2):
d.putSubItem("first", pair["first"])
d.putSubItem("second", pair["second"])
- if d.isNull(node["_M_right"]):
- parent = node["_M_parent"]
- while node == parent["_M_right"]:
+ if not node['_Right']['_Isnil']:
+ node = node['_Right']
+ while not node['_Left']['_Isnil']:
+ node = node['_Left']
+ else:
+ parent = node['_Parent']
+ while node == parent['_Right']['_Isnil']:
node = parent
- parent = parent["_M_parent"]
- if node["_M_right"] != parent:
+ parent = parent['_Parent']
+ if node['_Right'] != parent:
node = parent
- else:
- node = node["_M_right"]
- while not d.isNull(node["_M_left"]):
- node = node["_M_left"]
def qdump__std____debug__map(d, value):
qdump__std__map(d, value)
@@ -236,6 +330,10 @@ def qdump__std____cxx1998__set(d, value):
qdump__std__set(d, value)
def qdump__std__set(d, value):
+ if d.isQnxTarget():
+ qdump__std__set__QNX(d, value)
+ return
+
impl = value["_M_t"]["_M_impl"]
size = int(impl["_M_node_count"])
d.check(0 <= size and size <= 100*1000*1000)
@@ -259,9 +357,34 @@ def qdump__std__set(d, value):
while not d.isNull(node["_M_left"]):
node = node["_M_left"]
+def qdump__std__set__QNX(d, value):
+ size = value['_Mysize']
+ d.check(0 <= size and size <= 100*1000*1000)
+ d.putItemCount(size)
+ d.putNumChild(size)
+ if d.isExpanded():
+ valueType = d.templateArgument(value.type, 0)
+ head = value['_Myhead']
+ node = head['_Left']
+ nodeType = head.type
+ with Children(d, size, maxNumChild=1000, childType=valueType):
+ for i in d.childRange():
+ d.putSubItem(i, node.cast(nodeType).dereference()['_Myval'])
+ if not node['_Right']['_Isnil']:
+ node = node['_Right']
+ while not node['_Left']['_Isnil']:
+ node = node['_Left']
+ else:
+ parent = node['_Parent']
+ while node == parent['_Right']['_Isnil']:
+ node = parent
+ parent = parent['_Parent']
+ if node['_Right'] != parent:
+ node = parent
def qdump__std__stack(d, value):
- qdump__std__deque(d, value["c"])
+ d.putItem(value["c"])
+ d.putType(str(value.type))
def qdump__std____debug__stack(d, value):
qdump__std__stack(d, value)
@@ -273,6 +396,10 @@ def qdump__std__string(d, value):
qdump__std__stringHelper1(d, value, 1)
def qdump__std__stringHelper1(d, value, charSize):
+ if d.isQnxTarget():
+ qdump__std__stringHelper1__QNX(d, value, charSize)
+ return
+
data = value["_M_dataplus"]["_M_p"]
# We can't lookup the std::string::_Rep type without crashing LLDB,
# so hard-code assumption on member position
@@ -285,6 +412,20 @@ def qdump__std__stringHelper1(d, value, charSize):
d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000)
qdump_stringHelper(d, sizePtr, size * charSize, charSize)
+def qdump__std__stringHelper1__QNX(d, value, charSize):
+ size = value['_Mysize']
+ alloc = value['_Myres']
+ _BUF_SIZE = 16 / charSize
+ if _BUF_SIZE <= alloc: #(_BUF_SIZE <= _Myres ? _Bx._Ptr : _Bx._Buf);
+ data = value['_Bx']['_Ptr']
+ else:
+ data = value['_Bx']['_Buf']
+ sizePtr = data.cast(d.charType().pointer())
+ refcount = int(sizePtr[-1])
+ d.check(refcount >= -1) # Can be -1 accoring to docs.
+ d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000)
+ qdump_stringHelper(d, sizePtr, size * charSize, charSize)
+
def qdump_stringHelper(d, data, size, charSize):
cutoff = min(size, d.stringCutOff)
mem = d.readMemory(data, cutoff)
@@ -310,21 +451,33 @@ def qdump_stringHelper(d, data, size, charSize):
def qdump__std____1__string(d, value):
- inner = d.childAt(d.childAt(value["__r_"]["__first_"], 0), 0)
- size = int(inner["__size_"])
- alloc = int(inner["__cap_"])
- data = d.pointerValue(inner["__data_"])
+ base = d.addressOf(value)
+ firstByte = d.extractByte(base)
+ if firstByte & 1:
+ # Long/external.
+ data = d.dereference(base + 2 * d.ptrSize())
+ size = d.extractInt(base + d.ptrSize())
+ else:
+ # Short/internal.
+ size = firstByte / 2
+ data = base + 1
qdump_stringHelper(d, data, size, 1)
d.putType("std::string")
def qdump__std____1__wstring(d, value):
- inner = d.childAt(d.childAt(value["__r_"]["__first_"], 0), 0)
- size = int(inner["__size_"]) * 4
- alloc = int(inner["__cap_"])
- data = d.pointerValue(inner["__data_"])
- qdump_stringHelper(d, data, size, 4)
- d.putType("std::wstring")
+ base = d.addressOf(value)
+ firstByte = d.extractByte(base)
+ if firstByte & 1:
+ # Long/external.
+ data = d.dereference(base + 2 * d.ptrSize())
+ size = d.extractInt(base + d.ptrSize())
+ else:
+ # Short/internal.
+ size = firstByte / 2
+ data = base + 4
+ qdump_stringHelper(d, data, size * 4, 4)
+ d.putType("std::xxwstring")
def qdump__std__shared_ptr(d, value):
@@ -487,16 +640,37 @@ def qform__std____1__unordered_map():
return mapForms()
def qdump__std____1__unordered_map(d, value):
- n = toInteger(value["__table_"]["__p2_"]["__first_"])
- d.putItemCount(n)
+ size = int(value["__table_"]["__p2_"]["__first_"])
+ d.putItemCount(size)
if d.isExpanded():
- with Children(d, 1):
- d.putFields(value)
+ node = value["__table_"]["__p1_"]["__first_"]["__next_"]
+ pairType = node["__value_"].type
+ with PairedChildren(d, size, pairType, maxNumChild=1000):
+ for i in d.childRange():
+ with SubItem(d, i):
+ d.putPair(node["__value_"], i)
+ node = node["__next_"]
+
+
+def qdump__std____1__unordered_set(d, value):
+ size = int(value["__table_"]["__p2_"]["__first_"])
+ d.putItemCount(size)
+ if d.isExpanded():
+ node = value["__table_"]["__p1_"]["__first_"]["__next_"]
+ valueType = d.templateArgument(value.type, 0)
+ with Children(d, size, childType=valueType, maxNumChild=1000):
+ for i in d.childRange():
+ d.putSubItem(i, node["__value_"])
+ node = node["__next_"]
+
def qdump__std____debug__unordered_set(d, value):
qdump__std__unordered_set(d, value)
+def qform__std__vector():
+ return arrayForms()
+
def qedit__std__vector(d, value, data):
import gdb
values = data.split(',')
@@ -510,6 +684,10 @@ def qedit__std__vector(d, value, data):
gdb.execute(cmd)
def qdump__std__vector(d, value):
+ if d.isQnxTarget():
+ qdump__std__vector__QNX(d, value)
+ return
+
impl = value["_M_impl"]
type = d.templateArgument(value.type, 0)
alloc = impl["_M_end_of_storage"]
@@ -546,6 +724,40 @@ def qdump__std__vector(d, value):
d.putBoolItem(str(i),
(int(d.dereference(q)) >> (i % 8)) & 1)
else:
+ d.putPlotData(type, start, size)
+
+def qdump__std__vector__QNX(d, value):
+ type = d.templateArgument(value.type, 0)
+ isBool = str(type) == 'bool'
+ if isBool:
+ impl = value['_Myvec']
+ start = impl['_Myfirst']
+ last = impl['_Mylast']
+ end = impl['_Myend']
+ size = value['_Mysize']
+ storagesize = start.dereference().type.sizeof * 8
+ else:
+ start = value['_Myfirst']
+ last = value['_Mylast']
+ end = value['_Myend']
+ size = int (last - start)
+ alloc = int (end - start)
+
+ d.check(0 <= size and size <= 1000 * 1000 * 1000)
+ d.check(last <= end)
+ d.checkPointer(start)
+ d.checkPointer(last)
+ d.checkPointer(end)
+
+ d.putItemCount(size)
+ d.putNumChild(size)
+ if d.isExpanded():
+ if isBool:
+ with Children(d, size, maxNumChild=10000, childType=type):
+ for i in d.childRange():
+ q = start + int(i / storagesize)
+ d.putBoolItem(str(i), (q.dereference() >> (i % storagesize)) & 1)
+ else:
d.putArrayData(type, start, size)
def qdump__std____1__vector(d, value):
@@ -563,12 +775,16 @@ def qdump__std____1__vector(d, value):
d.putItemCount(size)
d.putNumChild(size)
if d.isExpanded():
- d.putArrayData(innerType, begin, size)
+ d.putPlotData(innerType, begin, size)
+
+def qform__std____debug__vector():
+ return arrayForms()
def qdump__std____debug__vector(d, value):
qdump__std__vector(d, value)
+
def qedit__std__string(d, value, data):
d.call(value, "assign", '"%s"' % data.replace('"', '\\"'))
@@ -586,6 +802,15 @@ def qdump__std__basic_string(d, value):
innerType = d.templateArgument(value.type, 0)
qdump__std__stringHelper1(d, value, innerType.sizeof)
+def qdump__std____1__basic_string(d, value):
+ innerType = str(d.templateArgument(value.type, 0))
+ if innerType == "char":
+ qdump__std____1__string(d, value)
+ elif innerType == "wchar_t":
+ qdump__std____1__wstring(d, value)
+ else:
+ warn("UNKNOWN INNER TYPE %s" % innerType)
+
def qdump__wstring(d, value):
qdump__std__wstring(d, value)
diff --git a/share/qtcreator/debugger/test/dumpertest.pro b/share/qtcreator/debugger/test/dumpertest.pro
deleted file mode 100644
index 95546a6f26..0000000000
--- a/share/qtcreator/debugger/test/dumpertest.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2009-05-05T11:16:25
-#
-#-------------------------------------------------
-
-TARGET = dumpertest
-CONFIG += console
-CONFIG -= app_bundle
-greaterThan(QT_MAJOR_VERSION, 4):QT *= widgets
-TEMPLATE = app
-
-SOURCES += main.cpp \
-../dumper.cpp
-
-exists($$QMAKE_INCDIR_QT/QtCore/private/qobject_p.h) {
- DEFINES+=HAS_QOBJECT_P_H
-}
-
diff --git a/share/qtcreator/debugger/test/main.cpp b/share/qtcreator/debugger/test/main.cpp
deleted file mode 100644
index 2fcfcaebfb..0000000000
--- a/share/qtcreator/debugger/test/main.cpp
+++ /dev/null
@@ -1,677 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include <QStringList>
-#include <QLinkedList>
-#include <QVector>
-#include <QSharedPointer>
-#include <QTimer>
-#include <QMap>
-#include <QSet>
-#include <QVariant>
-#include <QFileInfo>
-#include <QCoreApplication>
-#include <QAction>
-
-#include <string>
-#include <list>
-#include <vector>
-#include <set>
-#include <map>
-
-#include <stdio.h>
-#include <string.h>
-
-// Test uninitialized variables allocing memory
-bool optTestUninitialized = false;
-bool optTestAll = false;
-bool optEmptyContainers = false;
-unsigned optVerbose = 0;
-const char *appPath = 0;
-
-// Provide address of type of be tested.
-// When testing uninitialized memory, allocate at random.
-template <class T>
- inline T* testAddress(T* in)
-{
- unsigned char *mem = 0;
- if (optTestUninitialized) {
- mem = new unsigned char[sizeof(T)];
- for (unsigned int i = 0; i < sizeof(T); i++) {
- mem[i] = char(rand() % 255u);
- }
- } else {
- mem = reinterpret_cast<unsigned char*>(in);
- }
- if (optVerbose) {
- for (unsigned int i = 0; i < sizeof(T); i++) {
- unsigned int b = mem[i];
- printf("%2u %2x %3u\n", i, b, b);
- }
- fflush(stdout);
- }
- return reinterpret_cast<T*>(mem);
-}
-
-/* Test program for Dumper development/porting.
- * Takes the type as first argument. */
-
-// --------------- Dumper symbols
-extern char qDumpInBuffer[10000];
-extern char qDumpOutBuffer[100000];
-
-extern "C" void *qDumpObjectData440(
- int protocolVersion,
- int token,
- void *data,
-#ifdef Q_CC_MSVC // CDB cannot handle boolean parameters
- int dumpChildren,
-#else
- bool dumpChildren,
-#endif
- int extraInt0, int extraInt1, int extraInt2, int extraInt3);
-
-static void prepareInBuffer(const char *outerType,
- const char *iname,
- const char *expr,
- const char *innerType)
-{
- // Leave trailing '\0'
- char *ptr = qDumpInBuffer;
- strcpy(ptr, outerType);
- ptr += strlen(outerType);
- ptr++;
- strcpy(ptr, iname);
- ptr += strlen(iname);
- ptr++;
- strcpy(ptr, expr);
- ptr += strlen(expr);
- ptr++;
- strcpy(ptr, innerType);
- ptr += strlen(innerType);
- ptr++;
- strcpy(ptr, iname);
-}
-
-// --------------- Qt types
-static int dumpQString()
-{
- QString test = QLatin1String("hallo");
- prepareInBuffer("QString", "local.qstring", "local.qstring", "");
- qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- QString uninitialized;
- return 0;
-}
-
-static int dumpQSharedPointerQString()
-{
- QSharedPointer<QString> test(new QString(QLatin1String("hallo")));
- prepareInBuffer("QSharedPointer", "local.sharedpointerqstring", "local.local.sharedpointerqstring", "QString");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- QString uninitialized;
- return 0;
-}
-
-static int dumpQStringList()
-{
- QStringList test = QStringList() << QLatin1String("item1") << QLatin1String("item2");
- prepareInBuffer("QList", "local.qstringlist", "local.qstringlist", "QString");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpQIntList()
-{
- QList<int> test = QList<int>() << 1 << 2;
- prepareInBuffer("QList", "local.qintlist", "local.qintlist", "int");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpQIntLinkedList()
-{
- QLinkedList<int> test = QLinkedList<int>() << 1 << 2;
- prepareInBuffer("QLinkedList", "local.qintlinkedlist", "local.qlinkedintlist", "int");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpQIntVector()
-{
- QVector<int> test = QVector<int>() << 42 << 43;
- prepareInBuffer("QVector", "local.qintvector", "local.qintvector", "int");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpQQStringVector()
-{
- QVector<QString> test = QVector<QString>() << "42s" << "43s";
- prepareInBuffer("QVector", "local.qstringvector", "local.qstringvector", "QString");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpQMapIntInt()
-{
- QMap<int,int> test;
- QMapNode<int,int> mapNode;
- const int valueOffset = (char*)&(mapNode.value) - (char*)&mapNode;
- if (!optEmptyContainers) {
- test.insert(42, 43);
- test.insert(43, 44);
- }
- prepareInBuffer("QMap", "local.qmapintint", "local.qmapintint", "int@int");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(int), sizeof(mapNode), valueOffset);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpQMapIntString()
-{
- QMap<int,QString> test;
- QMapNode<int,QString> mapNode;
- const int valueOffset = (char*)&(mapNode.value) - (char*)&mapNode;
- if (!optEmptyContainers) {
- test.insert(42, QLatin1String("fortytwo"));
- test.insert(43, QLatin1String("fortytree"));
- }
- prepareInBuffer("QMap", "local.qmapintqstring", "local.qmapintqstring", "int@QString");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(QString), sizeof(mapNode), valueOffset);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpQSetInt()
-{
- QSet<int> test;
- if (!optEmptyContainers) {
- test.insert(42);
- test.insert(43);
- }
- prepareInBuffer("QSet", "local.qsetint", "local.qsetint", "int");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-
-static int dumpQMapQStringString()
-{
- QMap<QString,QString> test;
- QMapNode<QString,QString> mapNode;
- const int valueOffset = (char*)&(mapNode.value) - (char*)&mapNode;
- if (!optEmptyContainers) {
- test.insert(QLatin1String("42s"), QLatin1String("fortytwo"));
- test.insert(QLatin1String("423"), QLatin1String("fortytree"));
- }
- prepareInBuffer("QMap", "local.qmapqstringqstring", "local.qmapqstringqstring", "QString@QString");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), sizeof(QString), sizeof(mapNode), valueOffset);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpQVariant()
-{
- QVariant test = QLatin1String("item");
- prepareInBuffer("QVariant", "local.qvariant", "local.qvariant", "");
- qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0,0 ,0);
- fputs(qDumpOutBuffer, stdout);
- fputs("\n\n", stdout);
- test = QVariant(int(42));
- prepareInBuffer("QVariant", "local.qvariant", "local.qvariant", "");
- qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0,0 ,0);
- fputs(qDumpOutBuffer, stdout);
- fputs("\n\n", stdout);
- test = QVariant(double(3.141));
- prepareInBuffer("QVariant", "local.qvariant", "local.qvariant", "");
- qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0,0 ,0);
- fputs(qDumpOutBuffer, stdout);
- fputs("\n\n", stdout);
- test = QVariant(QStringList(QLatin1String("item1")));
- prepareInBuffer("QVariant", "local.qvariant", "local.qvariant", "");
- qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0,0 ,0);
- fputs(qDumpOutBuffer, stdout);
- test = QVariant(QRect(1,2, 3, 4));
- prepareInBuffer("QVariant", "local.qvariant", "local.qvariant", "");
- qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0,0 ,0);
- fputs(qDumpOutBuffer, stdout);
- return 0;
-}
-
-static int dumpQVariantList()
-{
- QVariantList test;
- if (!optEmptyContainers) {
- test.push_back(QVariant(QLatin1String("hallo")));
- test.push_back(QVariant(42));
- test.push_back(QVariant(3.141));
- }
- // As a list
- prepareInBuffer("QList", "local.qvariantlist", "local.qvariantlist", "QVariant");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QVariant), 0,0 ,0);
- fputs(qDumpOutBuffer, stdout);
- // As typedef
- fputs("\n\n", stdout);
- prepareInBuffer("QVariantList", "local.qvariantlist", "local.qvariantlist", "");
- qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0,0 ,0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-// --------------- std types
-
-static int dumpStdString()
-{
- std::string test = "hallo";
- prepareInBuffer("std::string", "local.string", "local.string", "");
- qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdWString()
-{
- std::wstring test = L"hallo";
- prepareInBuffer("std::wstring", "local.wstring", "local.wstring", "");
- qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdStringList()
-{
- std::list<std::string> test;
- if (!optEmptyContainers) {
- test.push_back("item1");
- test.push_back("item2");
- }
- prepareInBuffer("std::list", "local.stringlist", "local.stringlist", "std::string");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::list<std::string>::allocator_type), 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdStringQList()
-{
- QList<std::string> test;
- if (!optEmptyContainers) {
- test.push_back("item1");
- test.push_back("item2");
- }
- prepareInBuffer("QList", "local.stringqlist", "local.stringqlist", "std::string");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdIntList()
-{
- std::list<int> test;
- if (!optEmptyContainers) {
- test.push_back(1);
- test.push_back(2);
- }
- prepareInBuffer("std::list", "local.intlist", "local.intlist", "int");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(std::list<int>::allocator_type), 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdIntVector()
-{
- std::vector<int> test;
- if (!optEmptyContainers) {
- test.push_back(1);
- test.push_back(2);
- }
- prepareInBuffer("std::vector", "local.intvector", "local.intvector", "int");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(std::list<int>::allocator_type), 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdStringVector()
-{
- std::vector<std::string> test;
- if (!optEmptyContainers) {
- test.push_back("item1");
- test.push_back("item2");
- }
- prepareInBuffer("std::vector", "local.stringvector", "local.stringvector", "std::string");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::list<int>::allocator_type), 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdWStringVector()
-{
- std::vector<std::wstring> test;
- if (!optEmptyContainers) {
- test.push_back(L"item1");
- test.push_back(L"item2");
- }
- prepareInBuffer("std::vector", "local.wstringvector", "local.wstringvector", "std::wstring");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::wstring), sizeof(std::list<int>::allocator_type), 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdIntSet()
-{
- std::set<int> test;
- if (!optEmptyContainers) {
- test.insert(1);
- test.insert(2);
- }
- prepareInBuffer("std::set", "local.intset", "local.intset", "int");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(std::list<int>::allocator_type), 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdStringSet()
-{
- std::set<std::string> test;
- if (!optEmptyContainers) {
- test.insert("item1");
- test.insert("item2");
- }
- prepareInBuffer("std::set", "local.stringset", "local.stringset", "std::string");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::list<int>::allocator_type), 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdQStringSet()
-{
- std::set<QString> test;
- if (!optEmptyContainers) {
- test.insert(QLatin1String("item1"));
- test.insert(QLatin1String("item2"));
- }
- prepareInBuffer("std::set", "local.stringset", "local.stringset", "QString");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), sizeof(std::list<int>::allocator_type), 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdMapIntString()
-{
- std::map<int,std::string> test;
- std::map<int,std::string>::value_type entry(42, std::string("fortytwo"));
- if (!optEmptyContainers) {
- test.insert(entry);
- }
- const int valueOffset = (char*)&(entry.second) - (char*)&entry;
- prepareInBuffer("std::map", "local.stdmapintstring", "local.stdmapintstring",
- "int@std::basic_string<char,std::char_traits<char>,std::allocator<char> >@std::less<int>@std::allocator<std::pair<const int,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(std::string), valueOffset, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpStdMapStringString()
-{
- typedef std::map<std::string,std::string> TestType;
- TestType test;
- const TestType::value_type entry("K", "V");
- if (!optEmptyContainers) {
- test.insert(entry);
- }
- const int valueOffset = (char*)&(entry.second) - (char*)&entry;
- prepareInBuffer("std::map", "local.stdmapstringstring", "local.stdmapstringstring",
- "std::basic_string<char,std::char_traits<char>,std::allocator<char> >@std::basic_string<char,std::char_traits<char>,std::allocator<char> >@std::less<int>@std::allocator<std::pair<const std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >");
- qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::string), valueOffset, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpQObject()
-{
- // Requires the childOffset to be know, but that is not critical
- QAction action(0);
- QObject x;
- QAction *a2= new QAction(&action);
- a2->setObjectName(QLatin1String("a2"));
- action.setObjectName(QLatin1String("action"));
- QObject::connect(&action, SIGNAL(triggered()), &x, SLOT(deleteLater()));
- prepareInBuffer("QObject", "local.qobject", "local.qobject", "");
- qDumpObjectData440(2, 42, testAddress(&action), 1, 0, 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputs("\n\n", stdout);
- // Property list
- prepareInBuffer("QObjectPropertyList", "local.qobjectpropertylist", "local.qobjectpropertylist", "");
- qDumpObjectData440(2, 42, testAddress(&action), 1, 0, 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputs("\n\n", stdout);
- // Signal list
- prepareInBuffer("QObjectSignalList", "local.qobjectsignallist", "local.qobjectsignallist", "");
- qDumpObjectData440(2, 42, testAddress(&action), 1, 0, 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- // Slot list
- prepareInBuffer("QObjectSlotList", "local.qobjectslotlist", "local.qobjectslotlist", "");
- qDumpObjectData440(2, 42, testAddress(&action), 1, 0, 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputs("\n\n", stdout);
- // Signal list
- prepareInBuffer("QObjectChildList", "local.qobjectchildlist", "local.qobjectchildlist", "");
- qDumpObjectData440(2, 42, testAddress(&action), 1, 0, 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- return 0;
-}
-
-static int dumpQFileInfo()
-{
- QFileInfo test(QString::fromLatin1(appPath));
- prepareInBuffer("QFileInfo", "local.qfileinfo", "local.qfileinfo","");
- qDumpObjectData440(2, 42, testAddress(&test), 1, 0, 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- return 0;
-}
-
-static int dumpQObjectList()
-{
- // Requires the childOffset to be know, but that is not critical
- QObject *root = new QObject;
- root ->setObjectName("root");
- QTimer *t1 = new QTimer;
- t1 ->setObjectName("t1");
- QTimer *t2 = new QTimer;
- t2 ->setObjectName("t2");
- QObjectList test;
- test << root << t1 << t2;
- prepareInBuffer("QList", "local.qobjectlist", "local.qobjectlist", "QObject *");
- qDumpObjectData440(2, 42, testAddress(&test), sizeof(QObject*), 0, 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- delete root;
- return 0;
-}
-
-typedef int (*DumpFunction)();
-typedef QMap<QString, DumpFunction> TypeDumpFunctionMap;
-
-static TypeDumpFunctionMap registerTypes()
-{
- TypeDumpFunctionMap rc;
- rc.insert("QString", dumpQString);
- rc.insert("QSharedPointer<QString>", dumpQSharedPointerQString);
- rc.insert("QStringList", dumpQStringList);
- rc.insert("QList<int>", dumpQIntList);
- rc.insert("QLinkedList<int>", dumpQIntLinkedList);
- rc.insert("QList<std::string>", dumpStdStringQList);
- rc.insert("QVector<int>", dumpQIntVector);
- rc.insert("QVector<QString>", dumpQQStringVector);
- rc.insert("QMap<int,QString>", dumpQMapIntString);
- rc.insert("QMap<QString,QString>", dumpQMapQStringString);
- rc.insert("QMap<int,int>", dumpQMapIntInt);
- rc.insert("QSet<int>", dumpQSetInt);
- rc.insert("string", dumpStdString);
- rc.insert("wstring", dumpStdWString);
- rc.insert("list<int>", dumpStdIntList);
- rc.insert("list<string>", dumpStdStringList);
- rc.insert("vector<int>", dumpStdIntVector);
- rc.insert("vector<string>", dumpStdStringVector);
- rc.insert("vector<wstring>", dumpStdWStringVector);
- rc.insert("set<int>", dumpStdIntSet);
- rc.insert("set<string>", dumpStdStringSet);
- rc.insert("set<QString>", dumpStdQStringSet);
- rc.insert("map<int,string>", dumpStdMapIntString);
- rc.insert("map<string,string>", dumpStdMapStringString);
- rc.insert("QFileInfo", dumpQFileInfo);
- rc.insert("QObject", dumpQObject);
- rc.insert("QObjectList", dumpQObjectList);
- rc.insert("QVariant", dumpQVariant);
- rc.insert("QVariantList", dumpQVariantList);
- return rc;
-}
-
-static void usage(const char *b, const TypeDumpFunctionMap &tdm)
-{
- printf("Usage: %s [-v][-u][-e] <type1> <type2..>\n", b);
- printf("Usage: %s [-v][-u][-e] -a excluded_type1 <excluded_type2...>\n", b);
- printf("Options: -u Test uninitialized memory\n");
- printf(" -e Empty containers\n");
- printf(" -v Verbose\n");
- printf(" -a Test all available types\n");
- printf("Supported types: ");
- const TypeDumpFunctionMap::const_iterator cend = tdm.constEnd();
- for (TypeDumpFunctionMap::const_iterator it = tdm.constBegin(); it != cend; ++it) {
- fputs(qPrintable(it.key()), stdout);
- fputc(' ', stdout);
- }
- fputc('\n', stdout);
-}
-
-int main(int argc, char *argv[])
-{
- appPath = argv[0];
- printf("\nQt Creator Debugging Helper testing tool\n\n");
- printf("Running query protocol\n");
- qDumpObjectData440(1, 42, 0, 1, 0, 0, 0, 0);
- fputs(qDumpOutBuffer, stdout);
- fputc('\n', stdout);
- fputc('\n', stdout);
-
- const TypeDumpFunctionMap tdm = registerTypes();
- const TypeDumpFunctionMap::const_iterator cend = tdm.constEnd();
-
- if (argc < 2) {
- usage(argv[0], tdm);
- return 0;
- }
- // Parse args
- QStringList tests;
- for (int a = 1; a < argc; a++) {
- const char *arg = argv[a];
- if (arg[0] == '-') {
- switch (arg[1]) {
- case 'a':
- optTestAll = true;
- break;
- case 'u':
- optTestUninitialized = true;
- break;
- case 'v':
- optVerbose++;
- break;
- case 'e':
- optEmptyContainers = true;
- break;
- default:
- fprintf(stderr, "Invalid option %s\n", arg);
- usage(argv[0], tdm);
- return -1;
- }
- } else {
- tests.push_back(QLatin1String(arg));
- }
- }
- // Go
- int rc = 0;
- if (optTestAll) {
- for (TypeDumpFunctionMap::const_iterator it = tdm.constBegin(); it != cend; ++it) {
- const QString test = it.key();
- if (tests.contains(test)) {
- printf("\nSkipping: %s\n", qPrintable(test));
- } else {
- printf("\nTesting: %s\n", qPrintable(test));
- rc += (*it.value())();
- if (optTestUninitialized)
- printf("Survived: %s\n", qPrintable(test));
- }
- }
- } else {
- foreach(const QString &test, tests) {
- printf("\nTesting: %s\n", qPrintable(test));
- const TypeDumpFunctionMap::const_iterator it = tdm.constFind(test);
- if (it == cend) {
- rc = -1;
- fprintf(stderr, "\nUnhandled type: %s\n", qPrintable(test));
- } else {
- rc = (*it.value())();
- }
- }
- }
- return rc;
-}
diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp
index 50fb037761..791e9d23eb 100644
--- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp
+++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp
@@ -63,6 +63,8 @@
#include "endpuppetcommand.h"
#include "debugoutputcommand.h"
+#include <enumeration.h>
+
namespace QmlDesigner {
static bool isRegistered=false;
@@ -181,6 +183,9 @@ void NodeInstanceServerInterface::registerCommands()
qRegisterMetaType<DebugOutputCommand>("DebugOutputCommand");
qRegisterMetaTypeStreamOperators<DebugOutputCommand>("DebugOutputCommand");
+
+ qRegisterMetaType<Enumeration>("Enumeration");
+ qRegisterMetaTypeStreamOperators<Enumeration>("Enumeration");
}
}
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
index ae32a7e5b4..f40414700f 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
@@ -29,7 +29,7 @@
#include "objectnodeinstance.h"
-
+#include <enumeration.h>
#include <QEvent>
#include <QQmlContext>
@@ -472,6 +472,9 @@ void ObjectNodeInstance::setPropertyVariant(const PropertyName &name, const QVar
QVariant fixedValue = fixResourcePaths(value);
+ if (value.canConvert<Enumeration>())
+ fixedValue = QVariant::fromValue(value.value<Enumeration>().nameToString());
+
QVariant oldValue = property.read();
if (oldValue.type() == QVariant::Url) {
QUrl url = oldValue.toUrl();
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pri
index 68324e6a79..4ce25e1e59 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pri
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pri
@@ -26,6 +26,7 @@ include (instances/instances.pri)
include (../commands/commands.pri)
include (../container/container.pri)
include (../interfaces/interfaces.pri)
+include (../types/types.pri)
QT_BREAKPAD_ROOT_PATH = $$(QT_BREAKPAD_ROOT_PATH)
!isEmpty(QT_BREAKPAD_ROOT_PATH) {
diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/objectnodeinstance.cpp
index 77d24d4ea2..afd3778e9c 100644
--- a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/objectnodeinstance.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/objectnodeinstance.cpp
@@ -29,7 +29,7 @@
#include "objectnodeinstance.h"
-
+#include <enumeration.h>
#include <QEvent>
#include <QGraphicsScene>
@@ -443,6 +443,9 @@ void ObjectNodeInstance::setPropertyVariant(const PropertyName &name, const QVar
QVariant fixedValue = fixResourcePaths(value);
+ if (value.canConvert<Enumeration>())
+ fixedValue = QVariant::fromValue(value.value<Enumeration>().nameToString());
+
QVariant oldValue = property.read();
if (oldValue.type() == QVariant::Url) {
QUrl url = oldValue.toUrl();
diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet/qmlpuppet.pri b/share/qtcreator/qml/qmlpuppet/qmlpuppet/qmlpuppet.pri
index a4332bdc35..f54d0170e6 100644
--- a/share/qtcreator/qml/qmlpuppet/qmlpuppet/qmlpuppet.pri
+++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet/qmlpuppet.pri
@@ -16,6 +16,7 @@ include (instances/instances.pri)
include (../commands/commands.pri)
include (../container/container.pri)
include (../interfaces/interfaces.pri)
+include (../types/types.pri)
SOURCES += $$PWD/qmlpuppetmain.cpp
RESOURCES += $$PWD/../qmlpuppet.qrc
diff --git a/share/qtcreator/qml/qmlpuppet/types/enumeration.cpp b/share/qtcreator/qml/qmlpuppet/types/enumeration.cpp
new file mode 100644
index 0000000000..effe379a81
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/types/enumeration.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "enumeration.h"
+
+#include <QString>
+#include <QList>
+#include <QtDebug>
+
+namespace QmlDesigner {
+
+Enumeration::Enumeration()
+{
+}
+
+Enumeration::Enumeration(const EnumerationName &enumerationName)
+ : m_enumerationName(enumerationName)
+{
+}
+
+Enumeration::Enumeration(const QString &enumerationName)
+ : m_enumerationName(enumerationName.toUtf8())
+{
+}
+
+Enumeration::Enumeration(const QString &scope, const QString &name)
+{
+ QString enumerationString = scope + QLatin1Char('.') + name;
+
+ m_enumerationName = enumerationString.toUtf8();
+}
+
+QmlDesigner::EnumerationName QmlDesigner::Enumeration::scope() const
+{
+ return m_enumerationName.split('.').first();
+}
+
+EnumerationName Enumeration::name() const
+{
+ return m_enumerationName.split('.').last();
+}
+
+EnumerationName Enumeration::toEnumerationName() const
+{
+ return m_enumerationName;
+}
+
+QString Enumeration::toString() const
+{
+ return QString::fromUtf8(m_enumerationName);
+}
+
+QString Enumeration::nameToString()
+{
+ return QString::fromUtf8(name());
+}
+
+QDataStream &operator<<(QDataStream &out, const Enumeration &enumeration)
+{
+ out << enumeration.toEnumerationName();
+
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, Enumeration &enumeration)
+{
+ in >> enumeration.m_enumerationName;
+
+ return in;
+}
+
+
+bool operator ==(const Enumeration &first, const Enumeration &second)
+{
+ return first.m_enumerationName == second.m_enumerationName;
+}
+
+bool operator <(const Enumeration &first, const Enumeration &second)
+{
+ return first.m_enumerationName < second.m_enumerationName;
+}
+
+QDebug operator <<(QDebug debug, const Enumeration &enumeration)
+{
+ debug.nospace() << "Enumeration("
+ << enumeration.toString()
+ << ")";
+
+ return debug;
+}
+
+
+} // namespace QmlDesigner
+
+
+
diff --git a/src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.h b/share/qtcreator/qml/qmlpuppet/types/enumeration.h
index 599cef5b49..252fd54812 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.h
+++ b/share/qtcreator/qml/qmlpuppet/types/enumeration.h
@@ -27,49 +27,51 @@
**
****************************************************************************/
-#ifndef SIBLINGCOMBOBOX_H
-#define SIBLINGCOMBOBOX_H
+#ifndef QMLDESIGNER_ENUMERATION_H
+#define QMLDESIGNER_ENUMERATION_H
-#include <QComboBox>
-
-#include <qmlitemnode.h>
+#include <QByteArray>
+#include <QDataStream>
+#include <QMetaType>
+#include <QVariant>
namespace QmlDesigner {
-class SiblingComboBox : public QComboBox
+typedef QByteArray EnumerationName;
+
+class Enumeration
{
- Q_OBJECT
- Q_PROPERTY(QVariant itemNode READ itemNode WRITE setItemNode NOTIFY itemNodeChanged)
- Q_PROPERTY(QVariant selectedItemNode READ selectedItemNode WRITE setSelectedItemNode NOTIFY selectedItemNodeChanged)
+ friend bool operator ==(const Enumeration &first, const Enumeration &second);
+ friend bool operator <(const Enumeration &first, const Enumeration &second);
+ friend QDataStream &operator>>(QDataStream &in, Enumeration &enumeration);
public:
- SiblingComboBox(QWidget *parent = 0) : QComboBox(parent) { }
-
- QVariant itemNode() const { return QVariant::fromValue(m_itemNode.modelNode()); }
- QVariant selectedItemNode() const { return QVariant::fromValue(m_selectedItemNode.modelNode()); }
-
- void setItemNode(const QVariant &itemNode);
- void setSelectedItemNode(const QVariant &itemNode);
+ Enumeration();
+ Enumeration(const EnumerationName &enumerationName);
+ Enumeration(const QString &enumerationName);
+ Enumeration(const QString &scope, const QString &name);
- static void registerDeclarativeTypes();
+ EnumerationName scope() const;
+ EnumerationName name() const;
+ EnumerationName toEnumerationName() const;
+ QString toString() const;
+ QString nameToString();
-signals:
- void selectedItemNodeChanged();
- void itemNodeChanged();
+private:
+ EnumerationName m_enumerationName;
+};
-private slots:
- void changeSelection(int i);
+QDataStream &operator<<(QDataStream &out, const Enumeration &enumeration);
+QDataStream &operator>>(QDataStream &in, Enumeration &enumeration);
-private:
- void setup();
- QmlItemNode m_itemNode;
- QmlItemNode m_selectedItemNode;
- QList<QmlItemNode> m_itemList;
+bool operator ==(const Enumeration &first, const Enumeration &second);
+bool operator <(const Enumeration &first, const Enumeration &second);
+QDebug operator <<(QDebug debug, const Enumeration &enumeration);
-};
-}
+} // namespace QmlDesigner
-#endif //SIBLINGCOMBOBOX_H
+Q_DECLARE_METATYPE(QmlDesigner::Enumeration)
+#endif // QMLDESIGNER_ENUMERATION_H
diff --git a/share/qtcreator/qml/qmlpuppet/types/types.pri b/share/qtcreator/qml/qmlpuppet/types/types.pri
new file mode 100644
index 0000000000..87425205e6
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/types/types.pri
@@ -0,0 +1,5 @@
+INCLUDEPATH += $$PWD/
+
+HEADERS += $$PWD/enumeration.h
+
+SOURCES += $$PWD/enumeration.cpp
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ComboBox.qml
index 8c17b4a40b..9dababf709 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ComboBox.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ComboBox.qml
@@ -37,12 +37,13 @@ Controls.ComboBox {
property variant backendValue
property color textColor: colorLogic.textColor
+ property string scope: "Qt"
ColorLogic {
id: colorLogic
backendValue: comboBox.backendValue
onValueFromBackendChanged: {
- comboBox.currentIndex = comboBox.find(comboBox.backendValue.valueToString);
+ comboBox.currentIndex = comboBox.find(comboBox.backendValue.enumeration);
}
}
@@ -50,8 +51,7 @@ Controls.ComboBox {
if (backendValue === undefined)
return;
- if (backendValue.value !== currentText)
- backendValue.value = currentText;
+ backendValue.setEnumeration(comboBox.scope, comboBox.currentText)
}
onFocusChanged: {
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/StandardTextSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/StandardTextSection.qml
index dac63cbc24..3d08234c56 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/StandardTextSection.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/StandardTextSection.qml
@@ -72,6 +72,7 @@ Section {
visible: showVerticalAlignment
Layout.fillWidth: true
backendValue: backendValues.wrapMode
+ scope: "Text"
model: ["NoWrap", "WordWrap", "WrapAnywhere", "WrapAtWordBoundaryOrAnywhere"]
}
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/BorderImageSpecifics.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/BorderImageSpecifics.qml
index 9517146508..e5ea40efd7 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/BorderImageSpecifics.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/BorderImageSpecifics.qml
@@ -137,6 +137,7 @@ Column {
backendValue: backendValues.horizontalTileMode
implicitWidth: 180
Layout.fillWidth: true
+ scope: "BorderImage"
}
}
@@ -150,6 +151,7 @@ Column {
backendValue: backendValues.verticalTileMode
implicitWidth: 180
Layout.fillWidth: true
+ scope: "BorderImage"
}
}
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/FlowSpecifics.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/FlowSpecifics.qml
index 1a242d0aae..08fb6e40aa 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/FlowSpecifics.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/FlowSpecifics.qml
@@ -49,6 +49,7 @@ Column {
ComboBox {
model: ["LeftToRight", "TopToBottom"]
backendValue: backendValues.flow
+ scope: "Qt"
}
ExpandingSpacer {
@@ -65,6 +66,7 @@ Column {
model: ["LeftToRight", "RightToLeft"]
backendValue: backendValues.layoutDirection
Layout.fillWidth: true
+ scope: "Qt"
}
}
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GridSpecifics.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GridSpecifics.qml
index 6aa751bab6..793bee9010 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GridSpecifics.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GridSpecifics.qml
@@ -84,6 +84,7 @@ Column {
model: ["LeftToRight", "TopToBottom"]
backendValue: backendValues.flow
Layout.fillWidth: true
+ scope: "Qt"
}
}
@@ -96,6 +97,7 @@ Column {
model: ["LeftToRight", "RightToLeft"]
backendValue: backendValues.layoutDirection
Layout.fillWidth: true
+ scope: "Qt"
}
}
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ImageSpecifics.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ImageSpecifics.qml
index cc03f88797..9902565c1d 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ImageSpecifics.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ImageSpecifics.qml
@@ -66,6 +66,7 @@ Column {
backendValue: backendValues.fillMode
implicitWidth: 180
Layout.fillWidth: true
+ scope: "Image"
}
ExpandingSpacer {
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RowSpecifics.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RowSpecifics.qml
index 99ee0b4cff..81b4a93202 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RowSpecifics.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RowSpecifics.qml
@@ -50,6 +50,7 @@ Column {
model: ["LeftToRight", "RightToLeft"]
backendValue: backendValues.layoutDirection
Layout.fillWidth: true
+ scope: "Qt"
}
}
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/TextInputSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/TextInputSection.qml
index 1dbace86eb..a7df36e09f 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/TextInputSection.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/TextInputSection.qml
@@ -60,6 +60,7 @@ Section {
visible: showVerticalAlignment
Layout.fillWidth: true
backendValue: backendValues.echoMode
+ scope: "TextInput"
model: ["Normal", "Password", "PasswordEchoOnEdit", "NoEcho"]
}
diff --git a/share/qtcreator/static.pro b/share/qtcreator/static.pro
index 7795d9cec3..7e417cd9bc 100644
--- a/share/qtcreator/static.pro
+++ b/share/qtcreator/static.pro
@@ -38,7 +38,8 @@ DATA_DIRS = \
qml \
qml-type-descriptions \
generic-highlighter \
- glsl
+ glsl \
+ cplusplus
macx: DATA_DIRS += scripts
for(data_dir, DATA_DIRS) {
diff --git a/share/qtcreator/templates/qml/qtquick_1_1/template.xml b/share/qtcreator/templates/qml/qtquick_1_1/template.xml
index ee2868b0af..51b653bafe 100644
--- a/share/qtcreator/templates/qml/qtquick_1_1/template.xml
+++ b/share/qtcreator/templates/qml/qtquick_1_1/template.xml
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<template openeditor="main.qml" priority="C"
- featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.1.1"
- id="QB.QML Application for Qt Quick 1.1">
+<template openeditor="main.qml" priority="F"
+ featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.1.1">
<displayname>Qt Quick 1.1</displayname>
<description>Creates a Qt Quick 1 UI project with a single QML file that contains the main view. You can review Qt Quick 1 UI projects in the QML Viewer and you need not build them. You do not need to have the development environment installed on your computer to create and run this type of project. Requires Qt 4.8 or newer.</description>
</template>
diff --git a/share/qtcreator/templates/qml/qtquick_2_0/template.xml b/share/qtcreator/templates/qml/qtquick_2_0/template.xml
index b7efc7c355..9caad365ea 100644
--- a/share/qtcreator/templates/qml/qtquick_2_0/template.xml
+++ b/share/qtcreator/templates/qml/qtquick_2_0/template.xml
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<template openeditor="main.qml" priority="A"
- featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2"
- id="QB.QML Application for Qt Quick 2.0">
+<template openeditor="main.qml" priority="E"
+ featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2">
<displayname>Qt Quick 2.0</displayname>
<description>Creates a Qt Quick 2 UI project with a single QML file that contains the main view. You can review Qt Quick 2 UI projects in the QML Scene and you need not build them. You do not need to have the development environment installed on your computer to create and run this type of project. Requires Qt 5.0 or newer.</description>
</template>
diff --git a/share/qtcreator/templates/qml/qtquick_2_1/main.qml b/share/qtcreator/templates/qml/qtquick_2_1/main.qml
new file mode 100644
index 0000000000..88ea490076
--- /dev/null
+++ b/share/qtcreator/templates/qml/qtquick_2_1/main.qml
@@ -0,0 +1,17 @@
+import QtQuick 2.1
+
+Rectangle {
+ width: 360
+ height: 360
+ Text {
+ anchors.centerIn: parent
+ text: "Hello World"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ Qt.quit();
+ }
+ }
+}
+
diff --git a/share/qtcreator/templates/qml/qtquick_2_1/main.qmlproject b/share/qtcreator/templates/qml/qtquick_2_1/main.qmlproject
new file mode 100644
index 0000000000..558f68d035
--- /dev/null
+++ b/share/qtcreator/templates/qml/qtquick_2_1/main.qmlproject
@@ -0,0 +1,21 @@
+/* File generated by Qt Creator, version 2.7.0 */
+
+import QmlProject 1.1
+
+Project {
+// QTC_REPLACE main.qml WITH main
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ "../exampleplugin" ]
+}
diff --git a/share/qtcreator/templates/qml/qtquick_2_1/template.xml b/share/qtcreator/templates/qml/qtquick_2_1/template.xml
new file mode 100644
index 0000000000..86e9074adb
--- /dev/null
+++ b/share/qtcreator/templates/qml/qtquick_2_1/template.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template openeditor="main.qml" priority="C"
+ featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2">
+ <displayname>Qt Quick 2.1</displayname>
+ <description>Creates a Qt Quick 2 UI project with a single QML file that contains the main view. You can review Qt Quick 2 UI projects in the QML Scene and you need not build them. You do not need to have the development environment installed on your computer to create and run this type of project. Requires Qt 5.1 or newer.</description>
+</template>
diff --git a/share/qtcreator/templates/qml/qtquick_2_2/main.qml b/share/qtcreator/templates/qml/qtquick_2_2/main.qml
new file mode 100644
index 0000000000..0190f166d3
--- /dev/null
+++ b/share/qtcreator/templates/qml/qtquick_2_2/main.qml
@@ -0,0 +1,17 @@
+import QtQuick 2.2
+
+Rectangle {
+ width: 360
+ height: 360
+ Text {
+ anchors.centerIn: parent
+ text: "Hello World"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ Qt.quit();
+ }
+ }
+}
+
diff --git a/share/qtcreator/templates/qml/qtquick_2_2/main.qmlproject b/share/qtcreator/templates/qml/qtquick_2_2/main.qmlproject
new file mode 100644
index 0000000000..558f68d035
--- /dev/null
+++ b/share/qtcreator/templates/qml/qtquick_2_2/main.qmlproject
@@ -0,0 +1,21 @@
+/* File generated by Qt Creator, version 2.7.0 */
+
+import QmlProject 1.1
+
+Project {
+// QTC_REPLACE main.qml WITH main
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ "../exampleplugin" ]
+}
diff --git a/share/qtcreator/templates/qml/qtquick_2_2/template.xml b/share/qtcreator/templates/qml/qtquick_2_2/template.xml
new file mode 100644
index 0000000000..c070ec2158
--- /dev/null
+++ b/share/qtcreator/templates/qml/qtquick_2_2/template.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template openeditor="main.qml" priority="A"
+ featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2">
+ <displayname>Qt Quick 2.2</displayname>
+ <description>Creates a Qt Quick 2 UI project with a single QML file that contains the main view. You can review Qt Quick 2 UI projects in the QML Scene and you need not build them. You do not need to have the development environment installed on your computer to create and run this type of project. Requires Qt 5.2 or newer.</description>
+</template>
diff --git a/share/qtcreator/templates/qml/qtquickcontrols_1_0/template.xml b/share/qtcreator/templates/qml/qtquickcontrols_1_0/template.xml
index b76fdfb026..a0f35614d1 100644
--- a/share/qtcreator/templates/qml/qtquickcontrols_1_0/template.xml
+++ b/share/qtcreator/templates/qml/qtquickcontrols_1_0/template.xml
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<template openeditor="main.qml" priority="B"
- featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2, QtSupport.Wizards.FeatureQtQuick.Controls"
- id="QB.QML Application for Qt Quick 2.0">
+<template openeditor="main.qml" priority="D"
+ featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2, QtSupport.Wizards.FeatureQtQuick.Controls">
<displayname>Qt Quick Controls 1.0</displayname>
<description>Creates a Qt Quick 2 UI project with a single QML file that contains the main view and uses Qt Quick Controls. You can review Qt Quick 2 UI projects in the QML Scene and you need not build them. This project requires that you have installed Qt Quick Controls for your Qt version. Requires Qt 5.1 or newer.</description>
</template>
diff --git a/share/qtcreator/templates/qml/qtquickcontrols_1_1/main.qml b/share/qtcreator/templates/qml/qtquickcontrols_1_1/main.qml
new file mode 100644
index 0000000000..74609d82c8
--- /dev/null
+++ b/share/qtcreator/templates/qml/qtquickcontrols_1_1/main.qml
@@ -0,0 +1,25 @@
+import QtQuick 2.2
+import QtQuick.Controls 1.1
+import QtQuick.Window 2.0
+
+ApplicationWindow {
+ title: qsTr("Hello World")
+ width: 640
+ height: 480
+
+ menuBar: MenuBar {
+ Menu {
+ title: qsTr("File")
+ MenuItem {
+ text: qsTr("Exit")
+ onTriggered: Qt.quit();
+ }
+ }
+ }
+
+ Button {
+ text: qsTr("Hello World")
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ }
+}
diff --git a/share/qtcreator/templates/qml/qtquickcontrols_1_1/main.qmlproject b/share/qtcreator/templates/qml/qtquickcontrols_1_1/main.qmlproject
new file mode 100644
index 0000000000..558f68d035
--- /dev/null
+++ b/share/qtcreator/templates/qml/qtquickcontrols_1_1/main.qmlproject
@@ -0,0 +1,21 @@
+/* File generated by Qt Creator, version 2.7.0 */
+
+import QmlProject 1.1
+
+Project {
+// QTC_REPLACE main.qml WITH main
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ "../exampleplugin" ]
+}
diff --git a/share/qtcreator/templates/qml/qtquickcontrols_1_1/template.xml b/share/qtcreator/templates/qml/qtquickcontrols_1_1/template.xml
new file mode 100644
index 0000000000..a2c09247b3
--- /dev/null
+++ b/share/qtcreator/templates/qml/qtquickcontrols_1_1/template.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template openeditor="main.qml" priority="B"
+ featuresRequired="QtSupport.Wizards.FeatureQtQuickProject, QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2, QtSupport.Wizards.FeatureQtQuick.Controls">
+ <displayname>Qt Quick Controls 1.1</displayname>
+ <description>Creates a Qt Quick 2 UI project with a single QML file that contains the main view and uses Qt Quick Controls. You can review Qt Quick 2 UI projects in the QML Scene and you need not build them. This project requires that you have installed Qt Quick Controls for your Qt version. Requires Qt 5.2 or newer.</description>
+</template>
diff --git a/share/qtcreator/templates/qtquick/qtquick_1_1/app.pro b/share/qtcreator/templates/qtquick/qtquick_1_1/app.pro
index 0fd73e63dd..1c990093fb 100644
--- a/share/qtcreator/templates/qtquick/qtquick_1_1/app.pro
+++ b/share/qtcreator/templates/qtquick/qtquick_1_1/app.pro
@@ -16,7 +16,7 @@ SOURCES += main.cpp
# target.path =
# Please do not modify the following two lines. Required for deployment.
-include(qtquick1applicationviewer/qtquick1applicationviewer.pri)
+include(../../shared/qtquickapplicationviewer/qtquick1applicationviewer/qtquick1applicationviewer.pri)
# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qtquick1applicationviewer.pri, instead) #
include(../../shared/deployment.pri)
qtcAddDeployment()
diff --git a/share/qtcreator/templates/qtquick/qtquick_1_1/template.xml b/share/qtcreator/templates/qtquick/qtquick_1_1/template.xml
index 3a39b42d35..e9ab8b2956 100644
--- a/share/qtcreator/templates/qtquick/qtquick_1_1/template.xml
+++ b/share/qtcreator/templates/qtquick/qtquick_1_1/template.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<template openeditor="main.qml" priority="C"
+<template openeditor="main.qml" priority="F"
featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.1.1"
viewerdir="qtquick1applicationviewer"
viewerclassname="QtQuick1ApplicationViewer"
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_0/app.pro b/share/qtcreator/templates/qtquick/qtquick_2_0/app.pro
index d0247c4bcd..c9e32a3c26 100644
--- a/share/qtcreator/templates/qtquick/qtquick_2_0/app.pro
+++ b/share/qtcreator/templates/qtquick/qtquick_2_0/app.pro
@@ -16,7 +16,7 @@ SOURCES += main.cpp
# target.path =
# Please do not modify the following two lines. Required for deployment.
-include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
+include(../../shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri)
# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) #
include(../../shared/deployment.pri)
qtcAddDeployment()
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_0/template.xml b/share/qtcreator/templates/qtquick/qtquick_2_0/template.xml
index ba341d2c55..2c29847412 100644
--- a/share/qtcreator/templates/qtquick/qtquick_2_0/template.xml
+++ b/share/qtcreator/templates/qtquick/qtquick_2_0/template.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<template openeditor="main.qml" priority="A"
+<template openeditor="main.qml" priority="E"
featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2"
viewerdir="qtquick2applicationviewer"
viewerclassname="QtQuick2ApplicationViewer"
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_1/app.pro b/share/qtcreator/templates/qtquick/qtquick_2_1/app.pro
new file mode 100644
index 0000000000..c9e32a3c26
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquick_2_1/app.pro
@@ -0,0 +1,22 @@
+# Add more folders to ship with the application, here
+# DEPLOYMENTFOLDERS #
+folder_01.source = qml/app
+folder_01.target = qml
+DEPLOYMENTFOLDERS = folder_01
+# DEPLOYMENTFOLDERS_END #
+
+# Additional import path used to resolve QML modules in Creator's code model
+# QML_IMPORT_PATH #
+QML_IMPORT_PATH =
+
+# The .cpp file which was generated for your project. Feel free to hack it.
+SOURCES += main.cpp
+
+# Installation path
+# target.path =
+
+# Please do not modify the following two lines. Required for deployment.
+include(../../shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri)
+# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) #
+include(../../shared/deployment.pri)
+qtcAddDeployment()
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_1/main.cpp b/share/qtcreator/templates/qtquick/qtquick_2_1/main.cpp
new file mode 100644
index 0000000000..fd46906328
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquick_2_1/main.cpp
@@ -0,0 +1,13 @@
+#include <QtGui/QGuiApplication>
+#include "qtquick2applicationviewer.h"
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QtQuick2ApplicationViewer viewer;
+ viewer.setMainQmlFile(QStringLiteral("qml/app/main.qml")); // MAINQML
+ viewer.showExpanded();
+
+ return app.exec();
+}
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_1/qml/app/main.qml b/share/qtcreator/templates/qtquick/qtquick_2_1/qml/app/main.qml
new file mode 100644
index 0000000000..20ec49e4ff
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquick_2_1/qml/app/main.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.1
+
+Rectangle {
+ width: 360
+ height: 360
+ Text {
+ text: qsTr("Hello World")
+ anchors.centerIn: parent
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ Qt.quit();
+ }
+ }
+}
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_1/template.xml b/share/qtcreator/templates/qtquick/qtquick_2_1/template.xml
new file mode 100644
index 0000000000..4db5883e43
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquick_2_1/template.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template openeditor="main.qml" priority="C"
+ featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2"
+ viewerdir="qtquick2applicationviewer"
+ viewerclassname="QtQuick2ApplicationViewer"
+ stubversionminor="5">
+ <displayname>Qt Quick 2.1</displayname>
+ <description>Creates a deployable Qt Quick 2 application using the QtQuick 2.1 import. Requires Qt 5.1 or newer.</description>
+</template>
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_2/app.pro b/share/qtcreator/templates/qtquick/qtquick_2_2/app.pro
new file mode 100644
index 0000000000..c9e32a3c26
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquick_2_2/app.pro
@@ -0,0 +1,22 @@
+# Add more folders to ship with the application, here
+# DEPLOYMENTFOLDERS #
+folder_01.source = qml/app
+folder_01.target = qml
+DEPLOYMENTFOLDERS = folder_01
+# DEPLOYMENTFOLDERS_END #
+
+# Additional import path used to resolve QML modules in Creator's code model
+# QML_IMPORT_PATH #
+QML_IMPORT_PATH =
+
+# The .cpp file which was generated for your project. Feel free to hack it.
+SOURCES += main.cpp
+
+# Installation path
+# target.path =
+
+# Please do not modify the following two lines. Required for deployment.
+include(../../shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri)
+# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) #
+include(../../shared/deployment.pri)
+qtcAddDeployment()
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_2/main.cpp b/share/qtcreator/templates/qtquick/qtquick_2_2/main.cpp
new file mode 100644
index 0000000000..fd46906328
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquick_2_2/main.cpp
@@ -0,0 +1,13 @@
+#include <QtGui/QGuiApplication>
+#include "qtquick2applicationviewer.h"
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QtQuick2ApplicationViewer viewer;
+ viewer.setMainQmlFile(QStringLiteral("qml/app/main.qml")); // MAINQML
+ viewer.showExpanded();
+
+ return app.exec();
+}
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_2/qml/app/main.qml b/share/qtcreator/templates/qtquick/qtquick_2_2/qml/app/main.qml
new file mode 100644
index 0000000000..7f67d2c235
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquick_2_2/qml/app/main.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.2
+
+Rectangle {
+ width: 360
+ height: 360
+ Text {
+ text: qsTr("Hello World")
+ anchors.centerIn: parent
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ Qt.quit();
+ }
+ }
+}
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_2/template.xml b/share/qtcreator/templates/qtquick/qtquick_2_2/template.xml
new file mode 100644
index 0000000000..9416267e46
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquick_2_2/template.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template openeditor="main.qml" priority="A"
+ featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2"
+ viewerdir="qtquick2applicationviewer"
+ viewerclassname="QtQuick2ApplicationViewer"
+ stubversionminor="5">
+ <displayname>Qt Quick 2.2</displayname>
+ <description>Creates a deployable Qt Quick 2 application using the QtQuick 2.2 import. Requires Qt 5.2 or newer.</description>
+</template>
diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/app.pro b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/app.pro
index d1cfc6b2b5..89f1ed5fe9 100644
--- a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/app.pro
+++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/app.pro
@@ -16,7 +16,7 @@ SOURCES += main.cpp
# target.path =
# Please do not modify the following two lines. Required for deployment.
-include(qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri)
+include(../../shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri)
# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) #
include(../../shared/deployment.pri)
qtcAddDeployment()
diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/template.xml b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/template.xml
index 886e530395..b294c81d62 100644
--- a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/template.xml
+++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/template.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<template openeditor="main.qml" priority="B"
+<template openeditor="main.qml" priority="D"
featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2, QtSupport.Wizards.FeatureQtQuick.Controls"
viewerdir="qtquick2controlsapplicationviewer"
viewerclassname="QtQuick2ControlsApplicationViewer"
diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/app.pro b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/app.pro
new file mode 100644
index 0000000000..89f1ed5fe9
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/app.pro
@@ -0,0 +1,22 @@
+# Add more folders to ship with the application, here
+# DEPLOYMENTFOLDERS #
+folder_01.source = qml/app
+folder_01.target = qml
+DEPLOYMENTFOLDERS = folder_01
+# DEPLOYMENTFOLDERS_END #
+
+# Additional import path used to resolve QML modules in Creator's code model
+# QML_IMPORT_PATH #
+QML_IMPORT_PATH =
+
+# The .cpp file which was generated for your project. Feel free to hack it.
+SOURCES += main.cpp
+
+# Installation path
+# target.path =
+
+# Please do not modify the following two lines. Required for deployment.
+include(../../shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri)
+# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) #
+include(../../shared/deployment.pri)
+qtcAddDeployment()
diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/main.cpp b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/main.cpp
new file mode 100644
index 0000000000..18fd2076cf
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/main.cpp
@@ -0,0 +1,12 @@
+#include "qtquick2controlsapplicationviewer.h"
+
+int main(int argc, char *argv[])
+{
+ Application app(argc, argv);
+
+ QtQuick2ControlsApplicationViewer viewer;
+ viewer.setMainQmlFile(QStringLiteral("qml/app/main.qml")); // MAINQML
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/qml/app/main.qml b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/qml/app/main.qml
new file mode 100644
index 0000000000..b257de0b83
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/qml/app/main.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.2
+import QtQuick.Controls 1.1
+
+ApplicationWindow {
+ title: qsTr("Hello World")
+ width: 640
+ height: 480
+
+ menuBar: MenuBar {
+ Menu {
+ title: qsTr("File")
+ MenuItem {
+ text: qsTr("Exit")
+ onTriggered: Qt.quit();
+ }
+ }
+ }
+
+ Button {
+ text: qsTr("Hello World")
+ anchors.centerIn: parent
+ }
+}
diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/template.xml b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/template.xml
new file mode 100644
index 0000000000..a9e6f828bf
--- /dev/null
+++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/template.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template openeditor="main.qml" priority="B"
+ featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2, QtSupport.Wizards.FeatureQtQuick.Controls"
+ viewerdir="qtquick2controlsapplicationviewer"
+ viewerclassname="QtQuick2ControlsApplicationViewer"
+ stubversionminor="1">
+ <displayname>Qt Quick Controls 1.1</displayname>
+ <description>Creates a deployable Qt Quick 2 application using Qt Quick Controls. Requires Qt 5.2 or newer.</description>
+</template>
diff --git a/share/qtcreator/templates/qtquick/qtquick_1_1/qtquick1applicationviewer/qtquick1applicationviewer.cpp b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick1applicationviewer/qtquick1applicationviewer.cpp
index 0b7ffe85da..0b7ffe85da 100644
--- a/share/qtcreator/templates/qtquick/qtquick_1_1/qtquick1applicationviewer/qtquick1applicationviewer.cpp
+++ b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick1applicationviewer/qtquick1applicationviewer.cpp
diff --git a/share/qtcreator/templates/qtquick/qtquick_1_1/qtquick1applicationviewer/qtquick1applicationviewer.h b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick1applicationviewer/qtquick1applicationviewer.h
index b9dc3a9fee..b9dc3a9fee 100644
--- a/share/qtcreator/templates/qtquick/qtquick_1_1/qtquick1applicationviewer/qtquick1applicationviewer.h
+++ b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick1applicationviewer/qtquick1applicationviewer.h
diff --git a/share/qtcreator/templates/qtquick/qtquick_1_1/qtquick1applicationviewer/qtquick1applicationviewer.pri b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick1applicationviewer/qtquick1applicationviewer.pri
index 030edc1d01..030edc1d01 100644
--- a/share/qtcreator/templates/qtquick/qtquick_1_1/qtquick1applicationviewer/qtquick1applicationviewer.pri
+++ b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick1applicationviewer/qtquick1applicationviewer.pri
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_0/qtquick2applicationviewer/qtquick2applicationviewer.cpp b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.cpp
index 2a62ca97b6..2a62ca97b6 100644
--- a/share/qtcreator/templates/qtquick/qtquick_2_0/qtquick2applicationviewer/qtquick2applicationviewer.cpp
+++ b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.cpp
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_0/qtquick2applicationviewer/qtquick2applicationviewer.h b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.h
index 6eee3c89b9..6eee3c89b9 100644
--- a/share/qtcreator/templates/qtquick/qtquick_2_0/qtquick2applicationviewer/qtquick2applicationviewer.h
+++ b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.h
diff --git a/share/qtcreator/templates/qtquick/qtquick_2_0/qtquick2applicationviewer/qtquick2applicationviewer.pri b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri
index 5123a2567e..5123a2567e 100644
--- a/share/qtcreator/templates/qtquick/qtquick_2_0/qtquick2applicationviewer/qtquick2applicationviewer.pri
+++ b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri
diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.cpp b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.cpp
index bbce9d70bf..bbce9d70bf 100644
--- a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.cpp
+++ b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.cpp
diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.h b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.h
index 76c12b7720..76c12b7720 100644
--- a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.h
+++ b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.h
diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri
index 32007f73fd..32007f73fd 100644
--- a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri
+++ b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri
diff --git a/src/libs/3rdparty/cplusplus/Control.cpp b/src/libs/3rdparty/cplusplus/Control.cpp
index 42028ae4ed..1b04f04c19 100644
--- a/src/libs/3rdparty/cplusplus/Control.cpp
+++ b/src/libs/3rdparty/cplusplus/Control.cpp
@@ -808,6 +808,11 @@ Symbol **Control::lastSymbol() const
return &*d->symbols.begin() + d->symbols.size();
}
+unsigned Control::symbolCount() const
+{
+ return unsigned(d->symbols.size());
+}
+
bool Control::hasSymbol(Symbol *symbol) const
{
return std::find(d->symbols.begin(), d->symbols.end(), symbol) != d->symbols.end();
diff --git a/src/libs/3rdparty/cplusplus/Control.h b/src/libs/3rdparty/cplusplus/Control.h
index 538ecc2766..85b8c3d3d7 100644
--- a/src/libs/3rdparty/cplusplus/Control.h
+++ b/src/libs/3rdparty/cplusplus/Control.h
@@ -91,7 +91,7 @@ public:
PointerType *pointerType(const FullySpecifiedType &elementType);
/// Returns a Type object of type ReferenceType.
- ReferenceType *referenceType(const FullySpecifiedType &elementType, bool rvalueRef = false);
+ ReferenceType *referenceType(const FullySpecifiedType &elementType, bool rvalueRef);
/// Retruns a Type object of type ArrayType.
ArrayType *arrayType(const FullySpecifiedType &elementType, unsigned size = 0);
@@ -213,6 +213,7 @@ public:
Symbol **firstSymbol() const;
Symbol **lastSymbol() const;
+ unsigned symbolCount() const;
bool hasSymbol(Symbol *symbol) const;
void addSymbol(Symbol *symbol);
diff --git a/src/libs/3rdparty/cplusplus/Lexer.cpp b/src/libs/3rdparty/cplusplus/Lexer.cpp
index 6e6e6c2feb..0e0d1f4330 100644
--- a/src/libs/3rdparty/cplusplus/Lexer.cpp
+++ b/src/libs/3rdparty/cplusplus/Lexer.cpp
@@ -297,7 +297,24 @@ void Lexer::scan_helper(Token *tok)
break;
case '?':
- tok->f.kind = T_QUESTION;
+ if (_yychar == '?') {
+ yyinp();
+ if (_yychar == '(') {
+ yyinp();
+ tok->f.kind = T_LBRACKET;
+ } else if (_yychar == ')') {
+ yyinp();
+ tok->f.kind = T_RBRACKET;
+ } else if (_yychar == '<') {
+ yyinp();
+ tok->f.kind = T_LBRACE;
+ } else if (_yychar == '>') {
+ yyinp();
+ tok->f.kind = T_RBRACE;
+ }
+ } else {
+ tok->f.kind = T_QUESTION;
+ }
break;
case '+':
diff --git a/src/libs/3rdparty/cplusplus/Symbols.cpp b/src/libs/3rdparty/cplusplus/Symbols.cpp
index dc20da15aa..bae2992293 100644
--- a/src/libs/3rdparty/cplusplus/Symbols.cpp
+++ b/src/libs/3rdparty/cplusplus/Symbols.cpp
@@ -222,27 +222,24 @@ int Function::methodKey() const
void Function::setMethodKey(int key)
{ f._methodKey = key; }
-bool Function::isEqualTo(const Type *other) const
+bool Function::isSignatureEqualTo(const Function *other) const
{
- const Function *o = other->asFunctionType();
- if (! o)
+ if (! other)
return false;
- else if (isConst() != o->isConst())
+ else if (isConst() != other->isConst())
return false;
- else if (isVolatile() != o->isVolatile())
+ else if (isVolatile() != other->isVolatile())
return false;
const Name *l = unqualifiedName();
- const Name *r = o->unqualifiedName();
+ const Name *r = other->unqualifiedName();
if (l == r || (l && l->isEqualTo(r))) {
const unsigned argc = argumentCount();
- if (argc != o->argumentCount())
- return false;
- else if (! _returnType.isEqualTo(o->_returnType))
+ if (argc != other->argumentCount())
return false;
for (unsigned i = 0; i < argc; ++i) {
Symbol *l = argumentAt(i);
- Symbol *r = o->argumentAt(i);
+ Symbol *r = other->argumentAt(i);
if (! l->type().isEqualTo(r->type()))
return false;
}
@@ -251,6 +248,14 @@ bool Function::isEqualTo(const Type *other) const
return false;
}
+bool Function::isEqualTo(const Type *other) const
+{
+ const Function *o = other->asFunctionType();
+ if (!isSignatureEqualTo(o))
+ return false;
+ return _returnType.isEqualTo(o->_returnType);
+}
+
void Function::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }
diff --git a/src/libs/3rdparty/cplusplus/Symbols.h b/src/libs/3rdparty/cplusplus/Symbols.h
index 6551dc7616..63432e33f1 100644
--- a/src/libs/3rdparty/cplusplus/Symbols.h
+++ b/src/libs/3rdparty/cplusplus/Symbols.h
@@ -347,6 +347,8 @@ public:
bool isPureVirtual() const;
void setPureVirtual(bool isPureVirtual);
+ bool isSignatureEqualTo(const Function *other) const;
+
// Symbol's interface
virtual FullySpecifiedType type() const;
diff --git a/src/libs/3rdparty/cplusplus/Templates.cpp b/src/libs/3rdparty/cplusplus/Templates.cpp
index 2e9772e191..c9a2c892bd 100644
--- a/src/libs/3rdparty/cplusplus/Templates.cpp
+++ b/src/libs/3rdparty/cplusplus/Templates.cpp
@@ -87,7 +87,7 @@ void CloneType::visit(PointerType *type)
void CloneType::visit(ReferenceType *type)
{
- _type.setType(_control->referenceType(_clone->type(type->elementType(), _subst)));
+ _type.setType(_control->referenceType(_clone->type(type->elementType(), _subst), type->isRvalueReference()));
}
void CloneType::visit(ArrayType *type)
diff --git a/src/libs/3rdparty/cplusplus/TranslationUnit.h b/src/libs/3rdparty/cplusplus/TranslationUnit.h
index 81df75f2aa..d5682cd1b3 100644
--- a/src/libs/3rdparty/cplusplus/TranslationUnit.h
+++ b/src/libs/3rdparty/cplusplus/TranslationUnit.h
@@ -82,6 +82,7 @@ public:
MemoryPool *memoryPool() const;
AST *ast() const;
+ bool blockErrors() const { return f._blockErrors; }
bool blockErrors(bool block)
{
const bool previous = f._blockErrors;
diff --git a/src/libs/cplusplus/CppRewriter.cpp b/src/libs/cplusplus/CppRewriter.cpp
index 6e50721493..4b6ba9a437 100644
--- a/src/libs/cplusplus/CppRewriter.cpp
+++ b/src/libs/cplusplus/CppRewriter.cpp
@@ -40,14 +40,8 @@
#include <cplusplus/Scope.h>
#include <QVarLengthArray>
-#include <QRegExp>
#include <QDebug>
-#define QTC_ASSERT_STRINGIFY_HELPER(x) #x
-#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x)
-#define QTC_ASSERT_STRING(cond) qDebug("SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__))
-#define QTC_ASSERT(cond, action) if (cond) {} else { QTC_ASSERT_STRING(#cond); action; } do {} while (0)
-
namespace CPlusPlus {
class Rewrite
@@ -117,7 +111,7 @@ public:
virtual void visit(ReferenceType *type)
{
const FullySpecifiedType elementType = rewrite->rewriteType(type->elementType());
- temps.append(control()->referenceType(elementType));
+ temps.append(control()->referenceType(elementType, type->isRvalueReference()));
}
virtual void visit(ArrayType *type)
@@ -448,221 +442,4 @@ const Name *rewriteName(const Name *name,
return rewrite.rewriteName(name);
}
-// Simplify complicated STL template types,
-// such as 'std::basic_string<char,std::char_traits<char>,std::allocator<char> >'
-// -> 'std::string' and helpers.
-
-static QString chopConst(QString type)
-{
- while (1) {
- if (type.startsWith(QLatin1String("const")))
- type = type.mid(5);
- else if (type.startsWith(QLatin1Char(' ')))
- type = type.mid(1);
- else if (type.endsWith(QLatin1String("const")))
- type.chop(5);
- else if (type.endsWith(QLatin1Char(' ')))
- type.chop(1);
- else
- break;
- }
- return type;
-}
-
-static inline QRegExp stdStringRegExp(const QString &charType)
-{
- QString rc = QLatin1String("basic_string<");
- rc += charType;
- rc += QLatin1String(",[ ]?std::char_traits<");
- rc += charType;
- rc += QLatin1String(">,[ ]?std::allocator<");
- rc += charType;
- rc += QLatin1String("> >");
- const QRegExp re(rc);
- QTC_ASSERT(re.isValid(), /**/);
- return re;
-}
-
-// Simplify string types in a type
-// 'std::set<std::basic_string<char... > >' -> std::set<std::string>'
-static inline void simplifyStdString(const QString &charType, const QString &replacement,
- QString *type)
-{
- QRegExp stringRegexp = stdStringRegExp(charType);
- const int replacementSize = replacement.size();
- for (int pos = 0; pos < type->size(); ) {
- // Check next match
- const int matchPos = stringRegexp.indexIn(*type, pos);
- if (matchPos == -1)
- break;
- const int matchedLength = stringRegexp.matchedLength();
- type->replace(matchPos, matchedLength, replacement);
- pos = matchPos + replacementSize;
- // If we were inside an 'allocator<std::basic_string..char > >'
- // kill the following blank -> 'allocator<std::string>'
- if (pos + 1 < type->size() && type->at(pos) == QLatin1Char(' ')
- && type->at(pos + 1) == QLatin1Char('>'))
- type->remove(pos, 1);
- }
-}
-
-// Fix 'std::allocator<std::string >' -> 'std::allocator<std::string>',
-// which can happen when replacing/simplifying
-static inline QString fixNestedTemplates(QString s)
-{
- const int size = s.size();
- if (size > 3
- && s.at(size - 1) == QLatin1Char('>')
- && s.at(size - 2) == QLatin1Char(' ')
- && s.at(size - 3) != QLatin1Char('>'))
- s.remove(size - 2, 1);
- return s;
-}
-
-CPLUSPLUS_EXPORT QString simplifySTLType(const QString &typeIn)
-{
- QString type = typeIn;
- if (type.startsWith(QLatin1String("class "))) // MSVC prepends class,struct
- type.remove(0, 6);
- if (type.startsWith(QLatin1String("struct ")))
- type.remove(0, 7);
-
- type.replace(QLatin1String("std::__1::"), QLatin1String("std::"));
- type.replace(QLatin1String("std::__debug::"), QLatin1String("std::"));
- type.replace(QLatin1Char('*'), QLatin1Char('@'));
-
- for (int i = 0; i < 10; ++i) {
- // std::ifstream
- QRegExp ifstreamRE(QLatin1String("std::basic_ifstream<char,\\s*std::char_traits<char>\\s*>"));
- ifstreamRE.setMinimal(true);
- QTC_ASSERT(ifstreamRE.isValid(), return typeIn);
- if (ifstreamRE.indexIn(type) != -1)
- type.replace(ifstreamRE.cap(0), QLatin1String("std::ifstream"));
-
- // Anything with a std::allocator
- int start = type.indexOf(QLatin1String("std::allocator<"));
- if (start == -1)
- break;
- // search for matching '>'
- int pos;
- int level = 0;
- for (pos = start + 12; pos < type.size(); ++pos) {
- int c = type.at(pos).unicode();
- if (c == '<') {
- ++level;
- } else if (c == '>') {
- --level;
- if (level == 0)
- break;
- }
- }
- const QString alloc = fixNestedTemplates(type.mid(start, pos + 1 - start).trimmed());
- const QString inner = fixNestedTemplates(alloc.mid(15, alloc.size() - 16).trimmed());
- const QString allocEsc = QRegExp::escape(alloc);
- const QString innerEsc = QRegExp::escape(inner);
- if (inner == QLatin1String("char")) { // std::string
- simplifyStdString(QLatin1String("char"), QLatin1String("string"), &type);
- } else if (inner == QLatin1String("wchar_t")) { // std::wstring
- simplifyStdString(QLatin1String("wchar_t"), QLatin1String("wstring"), &type);
- } else if (inner == QLatin1String("unsigned short")) { // std::wstring/MSVC
- simplifyStdString(QLatin1String("unsigned short"), QLatin1String("wstring"), &type);
- }
- // std::vector, std::deque, std::list
- QRegExp re1(QString::fromLatin1("(vector|list|deque)<%1, ?%2\\s*>").arg(innerEsc, allocEsc));
- QTC_ASSERT(re1.isValid(), return typeIn);
- if (re1.indexIn(type) != -1)
- type.replace(re1.cap(0), QString::fromLatin1("%1<%2>").arg(re1.cap(1), inner));
-
- // std::stack
- QRegExp stackRE(QString::fromLatin1("stack<%1, ?std::deque<%2> >").arg(innerEsc, innerEsc));
- stackRE.setMinimal(true);
- QTC_ASSERT(stackRE.isValid(), return typeIn);
- if (stackRE.indexIn(type) != -1)
- type.replace(stackRE.cap(0), QString::fromLatin1("stack<%1>").arg(inner));
-
- // std::set
- QRegExp setRE(QString::fromLatin1("set<%1, ?std::less<%2>, ?%3\\s*>").arg(innerEsc, innerEsc, allocEsc));
- setRE.setMinimal(true);
- QTC_ASSERT(setRE.isValid(), return typeIn);
- if (setRE.indexIn(type) != -1)
- type.replace(setRE.cap(0), QString::fromLatin1("set<%1>").arg(inner));
-
- // std::unordered_set
- QRegExp unorderedSetRE(QString::fromLatin1("unordered_set<%1, ?std::hash<%2>, ?std::equal_to<%3>, ?%4\\s*>")
- .arg(innerEsc, innerEsc, innerEsc, allocEsc));
- unorderedSetRE.setMinimal(true);
- QTC_ASSERT(unorderedSetRE.isValid(), return typeIn);
- if (unorderedSetRE.indexIn(type) != -1)
- type.replace(unorderedSetRE.cap(0), QString::fromLatin1("unordered_set<%1>").arg(inner));
-
- // std::map
- if (inner.startsWith(QLatin1String("std::pair<"))) {
- // search for outermost ',', split key and value
- int pos;
- int level = 0;
- for (pos = 10; pos < inner.size(); ++pos) {
- int c = inner.at(pos).unicode();
- if (c == '<')
- ++level;
- else if (c == '>')
- --level;
- else if (c == ',' && level == 0)
- break;
- }
- const QString key = chopConst(inner.mid(10, pos - 10));
- const QString keyEsc = QRegExp::escape(key);
- // Get value: MSVC: 'pair<a const ,b>', gcc: 'pair<const a, b>'
- if (inner.at(++pos) == QLatin1Char(' '))
- pos++;
- const QString value = inner.mid(pos, inner.size() - pos - 1).trimmed();
- const QString valueEsc = QRegExp::escape(value);
- QRegExp mapRE1(QString::fromLatin1("map<%1, ?%2, ?std::less<%3 ?>, ?%4\\s*>")
- .arg(keyEsc, valueEsc, keyEsc, allocEsc));
- mapRE1.setMinimal(true);
- QTC_ASSERT(mapRE1.isValid(), return typeIn);
- if (mapRE1.indexIn(type) != -1) {
- type.replace(mapRE1.cap(0), QString::fromLatin1("map<%1, %2>").arg(key, value));
- } else {
- QRegExp mapRE2(QString::fromLatin1("map<const %1, ?%2, ?std::less<const %3>, ?%4\\s*>")
- .arg(keyEsc, valueEsc, keyEsc, allocEsc));
- mapRE2.setMinimal(true);
- if (mapRE2.indexIn(type) != -1)
- type.replace(mapRE2.cap(0), QString::fromLatin1("map<const %1, %2>").arg(key, value));
- }
- }
-
- // std::unordered_map
- if (inner.startsWith(QLatin1String("std::pair<"))) {
- // search for outermost ',', split key and value
- int pos;
- int level = 0;
- for (pos = 10; pos < inner.size(); ++pos) {
- int c = inner.at(pos).unicode();
- if (c == '<')
- ++level;
- else if (c == '>')
- --level;
- else if (c == ',' && level == 0)
- break;
- }
- const QString key = chopConst(inner.mid(10, pos - 10));
- const QString keyEsc = QRegExp::escape(key);
- // Get value: MSVC: 'pair<a const ,b>', gcc: 'pair<const a, b>'
- if (inner.at(++pos) == QLatin1Char(' '))
- pos++;
- const QString value = inner.mid(pos, inner.size() - pos - 1).trimmed();
- const QString valueEsc = QRegExp::escape(value);
- QRegExp mapRE1(QString::fromLatin1("unordered_map<%1, ?%2, ?std::hash<%3 ?>, ?std::equal_to<%4 ?>, ?%5\\s*>")
- .arg(keyEsc, valueEsc, keyEsc, keyEsc, allocEsc));
- mapRE1.setMinimal(true);
- QTC_ASSERT(mapRE1.isValid(), return typeIn);
- if (mapRE1.indexIn(type) != -1)
- type.replace(mapRE1.cap(0), QString::fromLatin1("unordered_map<%1, %2>").arg(key, value));
- }
- }
- type.replace(QLatin1Char('@'), QLatin1Char('*'));
- type.replace(QLatin1String(" >"), QLatin1String(">"));
- return type;
-}
-
} // namespace CPlusPlus
diff --git a/src/libs/cplusplus/CppRewriter.h b/src/libs/cplusplus/CppRewriter.h
index 8c787db4a9..a4c38a2443 100644
--- a/src/libs/cplusplus/CppRewriter.h
+++ b/src/libs/cplusplus/CppRewriter.h
@@ -113,11 +113,6 @@ CPLUSPLUS_EXPORT const Name *rewriteName(const Name *name,
SubstitutionEnvironment *env,
Control *control);
-// Simplify complicated STL template types, such as
-// 'std::basic_string<char,std::char_traits<char>,std::allocator<char> > '->
-// 'std::string'.
-CPLUSPLUS_EXPORT QString simplifySTLType(const QString &typeIn);
-
} // namespace CPlusPlus
#endif // CPPREWRITER_H
diff --git a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp
index f33804a4f4..66b135766b 100644
--- a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp
+++ b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp
@@ -112,7 +112,7 @@ private:
virtual void visit(ReferenceType *refTy)
{
- _type.setType(control()->referenceType(q->apply(refTy->elementType())));
+ _type.setType(control()->referenceType(q->apply(refTy->elementType()), refTy->isRvalueReference()));
}
virtual void visit(ArrayType *arrayTy)
diff --git a/src/libs/extensionsystem/extensionsystem.pro b/src/libs/extensionsystem/extensionsystem.pro
index cd492543a3..ec147aec93 100644
--- a/src/libs/extensionsystem/extensionsystem.pro
+++ b/src/libs/extensionsystem/extensionsystem.pro
@@ -33,7 +33,7 @@ SOURCES += pluginerrorview.cpp \
optionsparser.cpp \
plugincollection.cpp \
pluginerroroverview.cpp
-FORMS += pluginview.ui \
+FORMS += \
pluginerrorview.ui \
plugindetailsview.ui \
pluginerroroverview.ui
diff --git a/src/libs/extensionsystem/extensionsystem.qbs b/src/libs/extensionsystem/extensionsystem.qbs
index 9b654b0b03..2a5b12a6c7 100644
--- a/src/libs/extensionsystem/extensionsystem.qbs
+++ b/src/libs/extensionsystem/extensionsystem.qbs
@@ -41,7 +41,6 @@ QtcLibrary {
"pluginview.cpp",
"pluginview.h",
"pluginview.qrc",
- "pluginview.ui",
"images/error.png",
"images/notloaded.png",
"images/ok.png",
diff --git a/src/libs/extensionsystem/pluginview.cpp b/src/libs/extensionsystem/pluginview.cpp
index 0e07264776..d2da0bdff0 100644
--- a/src/libs/extensionsystem/pluginview.cpp
+++ b/src/libs/extensionsystem/pluginview.cpp
@@ -31,14 +31,13 @@
#include "pluginmanager.h"
#include "pluginspec.h"
#include "plugincollection.h"
-#include "ui_pluginview.h"
+#include <QDebug>
#include <QDir>
+#include <QGridLayout>
#include <QHeaderView>
-#include <QTreeWidgetItem>
#include <QPalette>
-
-#include <QDebug>
+#include <QTreeWidgetItem>
/*!
\class ExtensionSystem::PluginView
@@ -76,12 +75,30 @@ Q_DECLARE_METATYPE(ExtensionSystem::PluginCollection*)
*/
PluginView::PluginView(QWidget *parent)
: QWidget(parent),
- m_ui(new Internal::Ui::PluginView),
m_allowCheckStateUpdate(true),
C_LOAD(1)
{
- m_ui->setupUi(this);
- QHeaderView *header = m_ui->categoryWidget->header();
+ m_categoryWidget = new QTreeWidget(this);
+ m_categoryWidget->setAlternatingRowColors(true);
+ m_categoryWidget->setIndentation(20);
+ m_categoryWidget->setUniformRowHeights(true);
+ m_categoryWidget->setSortingEnabled(true);
+ m_categoryWidget->setColumnCount(4);
+ m_categoryWidget->setColumnWidth(C_LOAD, 40);
+ m_categoryWidget->header()->setDefaultSectionSize(120);
+ m_categoryWidget->header()->setMinimumSectionSize(35);
+
+ QTreeWidgetItem *headerItem = m_categoryWidget->headerItem();
+ headerItem->setText(0, tr("Name"));
+ headerItem->setText(1, tr("Load"));
+ headerItem->setText(2, tr("Version"));
+ headerItem->setText(3, tr("Vendor"));
+
+ QGridLayout *gridLayout = new QGridLayout(this);
+ gridLayout->setContentsMargins(2, 2, 2, 2);
+ gridLayout->addWidget(m_categoryWidget, 1, 0, 1, 1);
+
+ QHeaderView *header = m_categoryWidget->header();
header->setResizeMode(0, QHeaderView::ResizeToContents);
header->setResizeMode(2, QHeaderView::ResizeToContents);
@@ -89,16 +106,14 @@ PluginView::PluginView(QWidget *parent)
m_errorIcon = QIcon(QLatin1String(":/extensionsystem/images/error.png"));
m_notLoadedIcon = QIcon(QLatin1String(":/extensionsystem/images/notloaded.png"));
- m_ui->categoryWidget->setColumnWidth(C_LOAD, 40);
-
// cannot disable these
m_whitelist << QString::fromLatin1("Core") << QString::fromLatin1("Locator")
<< QString::fromLatin1("Find") << QString::fromLatin1("TextEditor");
connect(PluginManager::instance(), SIGNAL(pluginsChanged()), this, SLOT(updateList()));
- connect(m_ui->categoryWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
+ connect(m_categoryWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
this, SLOT(selectPlugin(QTreeWidgetItem*)));
- connect(m_ui->categoryWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
+ connect(m_categoryWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
this, SLOT(activatePlugin(QTreeWidgetItem*)));
updateList();
@@ -109,7 +124,6 @@ PluginView::PluginView(QWidget *parent)
*/
PluginView::~PluginView()
{
- delete m_ui;
}
/*!
@@ -117,16 +131,16 @@ PluginView::~PluginView()
*/
PluginSpec *PluginView::currentPlugin() const
{
- if (!m_ui->categoryWidget->currentItem())
+ if (!m_categoryWidget->currentItem())
return 0;
- if (!m_ui->categoryWidget->currentItem()->data(0, Qt::UserRole).isNull())
- return m_ui->categoryWidget->currentItem()->data(0, Qt::UserRole).value<PluginSpec *>();
+ if (!m_categoryWidget->currentItem()->data(0, Qt::UserRole).isNull())
+ return m_categoryWidget->currentItem()->data(0, Qt::UserRole).value<PluginSpec *>();
return 0;
}
void PluginView::updateList()
{
- connect(m_ui->categoryWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
+ connect(m_categoryWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
this, SLOT(updatePluginSettings(QTreeWidgetItem*,int)));
PluginCollection *defaultCollection = 0;
@@ -176,15 +190,15 @@ void PluginView::updateList()
updatePluginDependencies();
- m_ui->categoryWidget->clear();
+ m_categoryWidget->clear();
if (!m_items.isEmpty()) {
- m_ui->categoryWidget->addTopLevelItems(m_items);
- m_ui->categoryWidget->expandAll();
+ m_categoryWidget->addTopLevelItems(m_items);
+ m_categoryWidget->expandAll();
}
- m_ui->categoryWidget->sortItems(0, Qt::AscendingOrder);
- if (m_ui->categoryWidget->topLevelItemCount())
- m_ui->categoryWidget->setCurrentItem(m_ui->categoryWidget->topLevelItem(0));
+ m_categoryWidget->sortItems(0, Qt::AscendingOrder);
+ if (m_categoryWidget->topLevelItemCount())
+ m_categoryWidget->setCurrentItem(m_categoryWidget->topLevelItem(0));
}
int PluginView::parsePluginSpecs(QTreeWidgetItem *parentItem, Qt::CheckState &groupState, QList<PluginSpec*> plugins)
diff --git a/src/libs/extensionsystem/pluginview.h b/src/libs/extensionsystem/pluginview.h
index 4a4fd92a04..cba796c6ab 100644
--- a/src/libs/extensionsystem/pluginview.h
+++ b/src/libs/extensionsystem/pluginview.h
@@ -37,6 +37,7 @@
#include <QIcon>
QT_BEGIN_NAMESPACE
+class QTreeWidget;
class QTreeWidgetItem;
QT_END_NAMESPACE
@@ -46,12 +47,6 @@ class PluginManager;
class PluginSpec;
class PluginCollection;
-namespace Internal {
-namespace Ui {
- class PluginView;
-} // namespace Ui
-} // namespace Internal
-
class EXTENSIONSYSTEM_EXPORT PluginView : public QWidget
{
Q_OBJECT
@@ -79,7 +74,7 @@ private:
void updatePluginDependencies();
int parsePluginSpecs(QTreeWidgetItem *parentItem, Qt::CheckState &groupState, QList<PluginSpec*> plugins);
- Internal::Ui::PluginView *m_ui;
+ QTreeWidget *m_categoryWidget;
QList<QTreeWidgetItem*> m_items;
QHash<PluginSpec*, QTreeWidgetItem*> m_specToItem;
diff --git a/src/libs/extensionsystem/pluginview.ui b/src/libs/extensionsystem/pluginview.ui
deleted file mode 100644
index 8dfb08ae2c..0000000000
--- a/src/libs/extensionsystem/pluginview.ui
+++ /dev/null
@@ -1,84 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ExtensionSystem::Internal::PluginView</class>
- <widget class="QWidget" name="ExtensionSystem::Internal::PluginView">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>773</width>
- <height>304</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <property name="margin">
- <number>2</number>
- </property>
- <item row="1" column="0">
- <widget class="QTreeWidget" name="categoryWidget">
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="indentation">
- <number>20</number>
- </property>
- <property name="rootIsDecorated">
- <bool>true</bool>
- </property>
- <property name="uniformRowHeights">
- <bool>false</bool>
- </property>
- <property name="itemsExpandable">
- <bool>true</bool>
- </property>
- <property name="sortingEnabled">
- <bool>true</bool>
- </property>
- <property name="columnCount">
- <number>4</number>
- </property>
- <attribute name="headerDefaultSectionSize">
- <number>120</number>
- </attribute>
- <attribute name="headerHighlightSections">
- <bool>false</bool>
- </attribute>
- <attribute name="headerMinimumSectionSize">
- <number>35</number>
- </attribute>
- <attribute name="headerDefaultSectionSize">
- <number>120</number>
- </attribute>
- <attribute name="headerMinimumSectionSize">
- <number>35</number>
- </attribute>
- <attribute name="headerHighlightSections">
- <bool>false</bool>
- </attribute>
- <column>
- <property name="text">
- <string>Name</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Load</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Version</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Vendor</string>
- </property>
- </column>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/src/libs/qmljs/qmljsconstants.h b/src/libs/qmljs/qmljsconstants.h
index 1df423b8a3..3ddb014754 100644
--- a/src/libs/qmljs/qmljsconstants.h
+++ b/src/libs/qmljs/qmljsconstants.h
@@ -50,7 +50,7 @@ enum Enum {
Invalid,
Library,
Path,
- QrcPath,
+ QrcPath
};
}
diff --git a/src/libs/qtcreatorcdbext/containers.cpp b/src/libs/qtcreatorcdbext/containers.cpp
index 40484fbf24..17655117be 100644
--- a/src/libs/qtcreatorcdbext/containers.cpp
+++ b/src/libs/qtcreatorcdbext/containers.cpp
@@ -203,7 +203,21 @@ int containerSize(KnownType kt, const SymbolGroupValue &v)
if (const SymbolGroupValue deque = v[unsigned(0)])
return containerSize(KT_StdDeque, deque);
break;
+ case KT_StdArray: {
+ std::string::size_type arraySizeStart = v.type().find(',');
+ if (arraySizeStart != std::string::npos) {
+ ++arraySizeStart;
+ std::string::size_type arraySizeEnd = v.type().find('>', arraySizeStart);
+ if (arraySizeEnd != std::string::npos) {
+ int rc = 0;
+ if (integerFromString(v.type().substr(arraySizeStart, arraySizeEnd - arraySizeStart), &rc))
+ return rc;
+ }
+ }
+ break;
+ }
}
+
return -1;
}
@@ -253,6 +267,22 @@ static inline AbstractSymbolGroupNodePtrVector stdListChildList(SymbolGroupNode
return AbstractSymbolGroupNodePtrVector();
}
+static inline AbstractSymbolGroupNodePtrVector stdArrayChildList(SymbolGroupNode *n, int count,
+ const SymbolGroupValueContext &ctx)
+{
+ AbstractSymbolGroupNodePtrVector rc;
+ if (SymbolGroupValue elems = SymbolGroupValue(n, ctx)["_Elems"]) {
+ rc.reserve(count);
+ for (int i = 0; i < count; ++i) {
+ if (const SymbolGroupValue value = elems[i])
+ rc.push_back(ReferenceSymbolGroupNode::createArrayNode(i, value.node()));
+ else
+ break;
+ }
+ }
+ return rc;
+}
+
// QLinkedList<T>: Dummy head node and then a linked list of "n", "t".
static inline AbstractSymbolGroupNodePtrVector qLinkedListChildList(SymbolGroupNode *n, int count,
const SymbolGroupValueContext &ctx)
@@ -1109,6 +1139,8 @@ AbstractSymbolGroupNodePtrVector containerChildren(SymbolGroupNode *node, int ty
break;
case KT_StdList:
return stdListChildList(node, size , ctx);
+ case KT_StdArray:
+ return stdArrayChildList(node, size , ctx);
case KT_StdDeque:
return stdDequeChildList(SymbolGroupValue(node, ctx), size);
case KT_StdStack:
diff --git a/src/libs/qtcreatorcdbext/knowntype.h b/src/libs/qtcreatorcdbext/knowntype.h
index 31882025ca..053858df77 100644
--- a/src/libs/qtcreatorcdbext/knowntype.h
+++ b/src/libs/qtcreatorcdbext/knowntype.h
@@ -167,6 +167,7 @@ enum KnownType
// Types: STL
KT_StdString = KT_STL_Type + KT_Editable + KT_HasSimpleDumper + 1,
KT_StdWString = KT_STL_Type + KT_Editable + KT_HasSimpleDumper + 2,
+ KT_StdComplex = KT_STL_Type + KT_HasSimpleDumper + 3,
// Types: STL containers
KT_StdVector = KT_STL_Type + KT_ContainerType + KT_HasSimpleDumper + 1,
KT_StdList = KT_STL_Type + KT_ContainerType + KT_HasSimpleDumper + 2,
@@ -174,7 +175,8 @@ enum KnownType
KT_StdDeque = KT_STL_Type + KT_ContainerType + KT_HasSimpleDumper + 4,
KT_StdSet = KT_STL_Type + KT_ContainerType + KT_HasSimpleDumper + 5,
KT_StdMap = KT_STL_Type + KT_ContainerType + KT_HasSimpleDumper + 6,
- KT_StdMultiMap = KT_STL_Type + KT_ContainerType + KT_HasSimpleDumper + 7
+ KT_StdMultiMap = KT_STL_Type + KT_ContainerType + KT_HasSimpleDumper + 7,
+ KT_StdArray = KT_STL_Type + KT_ContainerType + KT_HasSimpleDumper + 8
};
#endif // KNOWNTYPE_H
diff --git a/src/libs/qtcreatorcdbext/symbolgroupnode.cpp b/src/libs/qtcreatorcdbext/symbolgroupnode.cpp
index 20db155c93..ce67deb698 100644
--- a/src/libs/qtcreatorcdbext/symbolgroupnode.cpp
+++ b/src/libs/qtcreatorcdbext/symbolgroupnode.cpp
@@ -1101,13 +1101,15 @@ int SymbolGroupNode::dumpNode(std::ostream &str,
if (addr) {
str << std::hex << std::showbase << ",addr=\"" << addr << '"';
- if (!value.compare(0, 2u, L"0x")) {
- // Determine referenced address of pointers?
- ULONG64 referencedAddr = 0;
- std::wistringstream istr(value.substr(2u, value.size() - 2u));
- istr >> std::hex >> referencedAddr;
- if (referencedAddr)
- str << ",origaddr=\"" << referencedAddr << '"';
+ if (SymbolGroupValue::isPointerType(t)) {
+ std::string::size_type pointerPos = value.rfind(L"0x");
+ if (pointerPos != std::string::npos) {
+ ULONG64 referencedAddr = 0;
+ std::wistringstream istr(value.substr(pointerPos + 2u));
+ istr >> std::hex >> referencedAddr;
+ if (referencedAddr)
+ str << ",origaddr=\"" << referencedAddr << '"';
+ }
}
str << std::noshowbase << std::dec;
}
diff --git a/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp b/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp
index 1514d768b9..77e1642c8a 100644
--- a/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp
+++ b/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp
@@ -1078,11 +1078,17 @@ static KnownType knownClassTypeHelper(const std::string &type,
return KT_StdStack;
if (!type.compare(hPos, 5, "deque"))
return KT_StdDeque;
+ if (!type.compare(hPos, 5, "array"))
+ return KT_StdArray;
break;
case 6:
if (!type.compare(hPos, 6, "vector"))
return KT_StdVector;
break;
+ case 7:
+ if (!type.compare(hPos, 7, "complex"))
+ return KT_StdComplex;
+ break;
case 8:
if (!type.compare(hPos, 8, "multimap"))
return KT_StdMultiMap;
@@ -2430,6 +2436,21 @@ static bool dumpStd_W_String(const SymbolGroupValue &v, int type, std::wostream
return true;
}
+// Dump a std::complex.
+static bool dumpStd_Complex(const SymbolGroupValue &v, std::wostream &str)
+{
+ if (const SymbolGroupValue &valArray = v[0u][0u]["_Val"]) {
+ if (const SymbolGroupValue &val0 = valArray["0"]) {
+ str << L'(' << val0.value();
+ if (const SymbolGroupValue &val1 = valArray["1"]) {
+ str << L", " << val1.value() << L')';
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
// QVariant employs a template for storage where anything bigger than the data union
// is pointed to by data.shared.ptr, else it is put into the data struct (pointer size)
// itself (notably Qt types consisting of a d-ptr only).
@@ -2690,10 +2711,8 @@ unsigned dumpSimpleType(SymbolGroupNode *n, const SymbolGroupValueContext &ctx,
const SymbolGroupValue v(n, ctx);
if (!v) // Value as such has memory read error?
return SymbolGroupNode::SimpleDumperFailed;
- if (SymbolGroupValue::isPointerType(v.type()))
- if (const ULONG64 pointerValue = v.pointerValue())
- str << std::showbase << std::hex << pointerValue << std::dec << std::noshowbase << ' ';
+ unsigned rc = SymbolGroupNode::SimpleDumperNotApplicable;
// Simple dump of size for containers
if (kt & KT_ContainerType) {
const int size = containerSize(kt, v);
@@ -2703,120 +2722,125 @@ unsigned dumpSimpleType(SymbolGroupNode *n, const SymbolGroupValueContext &ctx,
*containerSizeIn = size;
if (size >= 0) {
str << L'<' << size << L" items>";
- *s = str.str();
- return SymbolGroupNode::SimpleDumperOk;
+ rc = SymbolGroupNode::SimpleDumperOk;
+ } else {
+ rc = SymbolGroupNode::SimpleDumperFailed;
+ }
+ } else {
+ switch (kt) {
+ case KT_QChar:
+ rc = dumpQChar(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QByteArray:
+ rc = dumpQByteArray(v, str, memoryHandleIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QFileInfo:
+ rc = dumpQFileInfo(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QFile:
+ rc = dumpQFile(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QDir:
+ rc = dumpQDir(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QRegExp:
+ rc = dumpQRegExp(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QUrl:
+ rc = dumpQUrl(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QHostAddress:
+ rc = dumpQHostAddress(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QProcess:
+ rc = dumpQProcess(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QScriptValue:
+ rc = dumpQScriptValue(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QString:
+ rc = dumpQString(v, str, memoryHandleIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QStringRef:
+ rc = dumpQStringRef(v, str, memoryHandleIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QColor:
+ rc = dumpQColor(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QFlags:
+ rc = dumpQFlags(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QDate:
+ rc = dumpQDate(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QTime:
+ rc = dumpQTime(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QDateTime:
+ rc = dumpQDateTime(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QPoint:
+ case KT_QPointF:
+ rc = dumpQPoint_F(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QSize:
+ case KT_QSizeF:
+ rc = dumpQSize_F(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QLine:
+ case KT_QLineF:
+ rc = dumpQLine_F(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QPixmap:
+ rc = dumpQPixmap(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QImage:
+ rc = dumpQImage(v, str, memoryHandleIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QRect:
+ rc = dumpQRect(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QRectF:
+ rc = dumpQRectF(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QVariant:
+ rc = dumpQVariant(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QAtomicInt:
+ rc = dumpQAtomicInt(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QBasicAtomicInt:
+ rc = dumpQBasicAtomicInt(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QObject:
+ rc = dumpQObject(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QWidget:
+ rc = dumpQWidget(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QWindow:
+ rc = dumpQWindow(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QSharedPointer:
+ rc = dumpQSharedPointer(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_StdString:
+ case KT_StdWString:
+ rc = dumpStd_W_String(v, kt, str, memoryHandleIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_StdComplex:
+ rc = dumpStd_Complex(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ case KT_QTextCursor:
+ rc = dumpQTextCursor(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
+ break;
+ default:
+ break;
}
- return SymbolGroupNode::SimpleDumperFailed;
- }
- unsigned rc = SymbolGroupNode::SimpleDumperNotApplicable;
- switch (kt) {
- case KT_QChar:
- rc = dumpQChar(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QByteArray:
- rc = dumpQByteArray(v, str, memoryHandleIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QFileInfo:
- rc = dumpQFileInfo(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QFile:
- rc = dumpQFile(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QDir:
- rc = dumpQDir(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QRegExp:
- rc = dumpQRegExp(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QUrl:
- rc = dumpQUrl(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QHostAddress:
- rc = dumpQHostAddress(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QProcess:
- rc = dumpQProcess(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QScriptValue:
- rc = dumpQScriptValue(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QString:
- rc = dumpQString(v, str, memoryHandleIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QStringRef:
- rc = dumpQStringRef(v, str, memoryHandleIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QColor:
- rc = dumpQColor(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QFlags:
- rc = dumpQFlags(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QDate:
- rc = dumpQDate(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QTime:
- rc = dumpQTime(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QDateTime:
- rc = dumpQDateTime(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QPoint:
- case KT_QPointF:
- rc = dumpQPoint_F(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QSize:
- case KT_QSizeF:
- rc = dumpQSize_F(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QLine:
- case KT_QLineF:
- rc = dumpQLine_F(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QPixmap:
- rc = dumpQPixmap(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QImage:
- rc = dumpQImage(v, str, memoryHandleIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QRect:
- rc = dumpQRect(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QRectF:
- rc = dumpQRectF(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QVariant:
- rc = dumpQVariant(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QAtomicInt:
- rc = dumpQAtomicInt(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QBasicAtomicInt:
- rc = dumpQBasicAtomicInt(v, str) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QObject:
- rc = dumpQObject(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QWidget:
- rc = dumpQWidget(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QWindow:
- rc = dumpQWindow(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QSharedPointer:
- rc = dumpQSharedPointer(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_StdString:
- case KT_StdWString:
- rc = dumpStd_W_String(v, kt, str, memoryHandleIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed;
- break;
- case KT_QTextCursor:
- rc = dumpQTextCursor(v, str) ? SymbolGroupNode::SimpleDumperOk
- : SymbolGroupNode::SimpleDumperFailed;
- break;
- default:
- break;
}
+ if (rc != SymbolGroupNode::SimpleDumperFailed && SymbolGroupValue::isPointerType(v.type()))
+ str << L" @" << std::showbase << std::hex << v.pointerValue() << std::dec << std::noshowbase;
+
if (rc == SymbolGroupNode::SimpleDumperOk)
*s = str.str();
QTC_TRACE_OUT
diff --git a/src/libs/utils/completinglineedit.cpp b/src/libs/utils/completinglineedit.cpp
new file mode 100644
index 0000000000..e6536e54e9
--- /dev/null
+++ b/src/libs/utils/completinglineedit.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Orgad Shaneh <orgads@gmail.com>.
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "completinglineedit.h"
+
+#include <QAbstractItemView>
+#include <QCompleter>
+#include <QEvent>
+#include <QKeyEvent>
+
+namespace Utils {
+
+CompletingLineEdit::CompletingLineEdit(QWidget *parent) :
+ QLineEdit(parent)
+{
+}
+
+bool CompletingLineEdit::event(QEvent *e)
+{
+ // workaround for QTCREATORBUG-9453
+ if (e->type() == QEvent::ShortcutOverride) {
+ if (QCompleter *comp = completer()) {
+ if (comp->popup() && comp->popup()->isVisible()) {
+ QKeyEvent *ke = static_cast<QKeyEvent *>(e);
+ if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
+ ke->accept();
+ return true;
+ }
+ }
+ }
+ }
+ return QLineEdit::event(e);
+}
+
+void CompletingLineEdit::keyPressEvent(QKeyEvent *e)
+{
+ if (e->key() == Qt::Key_Down && !e->modifiers()) {
+ if (QCompleter *comp = completer()) {
+ if (text().isEmpty() && !comp->popup()->isVisible()) {
+ comp->setCompletionPrefix(QString());
+ comp->complete();
+ }
+ }
+ }
+ return QLineEdit::keyPressEvent(e);
+}
+
+} // namespace Utils
diff --git a/src/libs/utils/completinglineedit.h b/src/libs/utils/completinglineedit.h
new file mode 100644
index 0000000000..26ebc39f0a
--- /dev/null
+++ b/src/libs/utils/completinglineedit.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Orgad Shaneh <orgads@gmail.com>.
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef COMPLETINGLINEEDIT_H
+#define COMPLETINGLINEEDIT_H
+
+#include "utils_global.h"
+#include <QLineEdit>
+
+namespace Utils {
+
+class QTCREATOR_UTILS_EXPORT CompletingLineEdit : public QLineEdit
+{
+ Q_OBJECT
+
+public:
+ explicit CompletingLineEdit(QWidget *parent = 0);
+
+protected:
+ bool event(QEvent *e);
+ void keyPressEvent(QKeyEvent *e);
+};
+
+} // namespace Utils
+
+#endif // COMPLETINGLINEEDIT_H
diff --git a/src/libs/utils/detailswidget.cpp b/src/libs/utils/detailswidget.cpp
index 8dd42a529a..53cda0dda4 100644
--- a/src/libs/utils/detailswidget.cpp
+++ b/src/libs/utils/detailswidget.cpp
@@ -37,6 +37,7 @@
#include <QPainter>
#include <QScrollArea>
#include <QApplication>
+#include <QStyle>
/*!
\class Utils::DetailsWidget
@@ -73,6 +74,7 @@ public:
QWidget *q;
DetailsButton *m_detailsButton;
QGridLayout *m_grid;
+ QLabel *m_summaryLabelIcon;
QLabel *m_summaryLabel;
QCheckBox *m_summaryCheckBox;
QLabel *m_additionalSummaryLabel;
@@ -91,6 +93,7 @@ DetailsWidgetPrivate::DetailsWidgetPrivate(QWidget *parent) :
q(parent),
m_detailsButton(new DetailsButton),
m_grid(new QGridLayout),
+ m_summaryLabelIcon(new QLabel(parent)),
m_summaryLabel(new QLabel(parent)),
m_summaryCheckBox(new QCheckBox(parent)),
m_additionalSummaryLabel(new QLabel(parent)),
@@ -104,6 +107,11 @@ DetailsWidgetPrivate::DetailsWidgetPrivate(QWidget *parent) :
summaryLayout->setContentsMargins(MARGIN, MARGIN, MARGIN, MARGIN);
summaryLayout->setSpacing(0);
+ m_summaryLabelIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ m_summaryLabelIcon->setContentsMargins(0, 0, 0, 0);
+ m_summaryLabelIcon->setFixedWidth(0);
+ summaryLayout->addWidget(m_summaryLabelIcon);
+
m_summaryLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
m_summaryLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
m_summaryLabel->setContentsMargins(0, 0, 0, 0);
@@ -164,6 +172,7 @@ void DetailsWidgetPrivate::updateControls()
m_widget->setVisible(m_state == DetailsWidget::Expanded || m_state == DetailsWidget::NoSummary);
m_detailsButton->setChecked(m_state == DetailsWidget::Expanded && m_widget);
m_detailsButton->setVisible(m_state == DetailsWidget::Expanded || m_state == DetailsWidget::Collapsed);
+ m_summaryLabelIcon->setVisible(m_state != DetailsWidget::NoSummary && !m_useCheckBox);
m_summaryLabel->setVisible(m_state != DetailsWidget::NoSummary && !m_useCheckBox);
m_summaryCheckBox->setVisible(m_state != DetailsWidget::NoSummary && m_useCheckBox);
@@ -219,8 +228,7 @@ bool DetailsWidget::useCheckBox()
void DetailsWidget::setUseCheckBox(bool b)
{
d->m_useCheckBox = b;
- d->m_summaryLabel->setVisible(b);
- d->m_summaryCheckBox->setVisible(!b);
+ d->updateControls();
}
void DetailsWidget::setChecked(bool b)
@@ -243,6 +251,9 @@ void DetailsWidget::setSummaryFontBold(bool b)
void DetailsWidget::setIcon(const QIcon &icon)
{
+ int iconSize = style()->pixelMetric(QStyle::PM_ButtonIconSize, 0, this);
+ d->m_summaryLabelIcon->setFixedWidth(icon.isNull() ? 0 : iconSize);
+ d->m_summaryLabelIcon->setPixmap(icon.pixmap(iconSize, iconSize));
d->m_summaryCheckBox->setIcon(icon);
}
@@ -252,7 +263,7 @@ void DetailsWidget::paintEvent(QPaintEvent *paintEvent)
QPainter p(this);
- QWidget *topLeftWidget = d->m_useCheckBox ? static_cast<QWidget *>(d->m_summaryCheckBox) : static_cast<QWidget *>(d->m_summaryLabel);
+ QWidget *topLeftWidget = d->m_useCheckBox ? static_cast<QWidget *>(d->m_summaryCheckBox) : static_cast<QWidget *>(d->m_summaryLabelIcon);
QPoint topLeft(topLeftWidget->geometry().left() - MARGIN, contentsRect().top());
const QRect paintArea(topLeft, contentsRect().bottomRight());
diff --git a/src/libs/utils/detailswidget.h b/src/libs/utils/detailswidget.h
index fd4a251c4f..0b18c077b1 100644
--- a/src/libs/utils/detailswidget.h
+++ b/src/libs/utils/detailswidget.h
@@ -83,7 +83,6 @@ public:
bool useCheckBox();
void setUseCheckBox(bool b);
- /// Sets an icon, only supported if useCheckBox is true
void setIcon(const QIcon &icon);
static QPixmap createBackground(const QSize &size, int topHeight, QWidget *widget);
diff --git a/src/plugins/qmldesigner/components/propertyeditor/originwidget.h b/src/libs/utils/execmenu.cpp
index de4588ead2..5d4eb09ec9 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/originwidget.h
+++ b/src/libs/utils/execmenu.cpp
@@ -27,52 +27,45 @@
**
****************************************************************************/
-#ifndef ORIGINWIDGET_H
-#define ORIGINWIDGET_H
-
+#include "execmenu.h"
+
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QMenu>
+#include <QPoint>
+#include <QRect>
+#include <QSize>
#include <QWidget>
-namespace QmlDesigner {
-
-class OriginWidget: public QWidget {
-
-Q_OBJECT
-
-Q_PROPERTY(QString origin READ origin WRITE setOrigin NOTIFY originChanged)
-Q_PROPERTY(bool marked READ marked WRITE setMarked)
-
-public:
- OriginWidget(QWidget *parent = 0);
-
- QString origin() const
- { return m_originString; }
-
- void setOrigin(const QString& newOrigin);
-
- bool marked() const
- { return m_marked; }
-
- void setMarked(bool newMarked)
- { m_marked = newMarked; }
-
- static void registerDeclarativeType();
-
-signals:
- void originChanged();
-
-protected:
- void paintEvent(QPaintEvent *event);
- void mouseReleaseEvent(QMouseEvent * event);
- void mousePressEvent(QMouseEvent * event);
- bool event(QEvent *event);
-private:
- QString m_originString;
- bool m_pressed;
- int m_index;
- bool m_marked;
-};
-
-} // QmlDesigner
-
-
-#endif //ORIGINWIDGET_H
+namespace Utils {
+
+/*!
+ * Opens \a menu at the specified \a widget position.
+ * This function computes the position where to show the menu, and opens it with
+ * QMenu::exec().
+ */
+QAction *execMenuAtWidget(QMenu *menu, QWidget *widget)
+{
+ QPoint p;
+ QRect screen = qApp->desktop()->availableGeometry(widget);
+ QSize sh = menu->sizeHint();
+ QRect rect = widget->rect();
+ if (widget->isRightToLeft()) {
+ if (widget->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height())
+ p = widget->mapToGlobal(rect.bottomRight());
+ else
+ p = widget->mapToGlobal(rect.topRight() - QPoint(0, sh.height()));
+ p.rx() -= sh.width();
+ } else {
+ if (widget->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height())
+ p = widget->mapToGlobal(rect.bottomLeft());
+ else
+ p = widget->mapToGlobal(rect.topLeft() - QPoint(0, sh.height()));
+ }
+ p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width()));
+ p.ry() += 1;
+
+ return menu->exec(p);
+}
+
+} // namespace Utils
diff --git a/src/plugins/qmldesigner/components/propertyeditor/qlayoutobject.cpp b/src/libs/utils/execmenu.h
index b6bfe9b881..44d49d7bf7 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/qlayoutobject.cpp
+++ b/src/libs/utils/execmenu.h
@@ -27,24 +27,21 @@
**
****************************************************************************/
-#include "qlayoutobject.h"
+#ifndef EXECMENU_H
+#define EXECMENU_H
+#include "utils_global.h"
QT_BEGIN_NAMESPACE
+class QAction;
+class QMenu;
+class QWidget;
+QT_END_NAMESPACE
-void QLayoutObject::registerDeclarativeType()
-{
- qmlRegisterType<QLayoutObject>("Bauhaus",1,0,"QLayoutObject");
-}
+namespace Utils {
-QLayoutObject::QLayoutObject(QObject *parent)
-: QObject(parent)
-{
-}
+QTCREATOR_UTILS_EXPORT QAction *execMenuAtWidget(QMenu *menu, QWidget *widget);
-QLayout *QLayoutObject::layout() const
-{
- return 0;
-}
+} // namespace Utils
-QT_END_NAMESPACE
+#endif // EXECMENU_H
diff --git a/src/libs/utils/fancylineedit.cpp b/src/libs/utils/fancylineedit.cpp
index 3b92b47b11..5956884f9a 100644
--- a/src/libs/utils/fancylineedit.cpp
+++ b/src/libs/utils/fancylineedit.cpp
@@ -27,14 +27,13 @@
**
****************************************************************************/
+#include "execmenu.h"
#include "fancylineedit.h"
#include "historycompleter.h"
#include "qtcassert.h"
#include <QAbstractItemView>
-#include <QApplication>
#include <QDebug>
-#include <QDesktopWidget>
#include <QKeyEvent>
#include <QMenu>
#include <QPainter>
@@ -42,35 +41,6 @@
#include <QStyle>
/*!
- * Opens \a menu at the specified \a widget position.
- * This function computes the position where to show the menu, and opens it with
- * QMenu::exec().
- */
-static void execMenuAtWidget(QMenu *menu, QWidget *widget)
-{
- QPoint p;
- QRect screen = qApp->desktop()->availableGeometry(widget);
- QSize sh = menu->sizeHint();
- QRect rect = widget->rect();
- if (widget->isRightToLeft()) {
- if (widget->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height())
- p = widget->mapToGlobal(rect.bottomRight());
- else
- p = widget->mapToGlobal(rect.topRight() - QPoint(0, sh.height()));
- p.rx() -= sh.width();
- } else {
- if (widget->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height())
- p = widget->mapToGlobal(rect.bottomLeft());
- else
- p = widget->mapToGlobal(rect.topLeft() - QPoint(0, sh.height()));
- }
- p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width()));
- p.ry() += 1;
-
- menu->exec(p);
-}
-
-/*!
\class Utils::FancyLineEdit
\brief The FancyLineEdit class is a line edit with an embedded pixmap on
@@ -151,7 +121,7 @@ bool FancyLineEditPrivate::eventFilter(QObject *obj, QEvent *event)
// --------- FancyLineEdit
FancyLineEdit::FancyLineEdit(QWidget *parent) :
- QLineEdit(parent),
+ CompletingLineEdit(parent),
d(new FancyLineEditPrivate(this))
{
ensurePolished();
@@ -252,20 +222,6 @@ void FancyLineEdit::resizeEvent(QResizeEvent *)
updateButtonPositions();
}
-bool FancyLineEdit::event(QEvent *e)
-{
- // workaround for QTCREATORBUG-9453
- if (e->type() == QEvent::ShortcutOverride && completer()
- && completer()->popup() && completer()->popup()->isVisible()) {
- QKeyEvent *ke = static_cast<QKeyEvent *>(e);
- if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
- ke->accept();
- return true;
- }
- }
- return QLineEdit::event(e);
-}
-
void FancyLineEdit::setButtonPixmap(Side side, const QPixmap &buttonPixmap)
{
d->m_iconbutton[side]->setPixmap(buttonPixmap);
diff --git a/src/libs/utils/fancylineedit.h b/src/libs/utils/fancylineedit.h
index 7ad7d6ee70..23571c51fc 100644
--- a/src/libs/utils/fancylineedit.h
+++ b/src/libs/utils/fancylineedit.h
@@ -31,8 +31,8 @@
#define FANCYLINEEDIT_H
#include "utils_global.h"
+#include "completinglineedit.h"
-#include <QLineEdit>
#include <QAbstractButton>
QT_BEGIN_NAMESPACE
@@ -66,7 +66,7 @@ private:
QPixmap m_pixmap;
};
-class QTCREATOR_UTILS_EXPORT FancyLineEdit : public QLineEdit
+class QTCREATOR_UTILS_EXPORT FancyLineEdit : public CompletingLineEdit
{
Q_OBJECT
Q_ENUMS(Side)
@@ -114,11 +114,10 @@ private slots:
protected:
void resizeEvent(QResizeEvent *e);
- bool event(QEvent *e);
private:
// Unimplemented, to force the user to make a decision on
- // whether to use setHistoryKey() or setSpecialCompleter().
+ // whether to use setHistoryCompleter() or setSpecialCompleter().
void setCompleter(QCompleter *);
void updateMargins();
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp
index 1451f6fa79..4d7756b293 100644
--- a/src/libs/utils/fileutils.cpp
+++ b/src/libs/utils/fileutils.cpp
@@ -635,18 +635,18 @@ FileName FileName::relativeChildPath(const FileName &parent) const
FileName &FileName::appendPath(const QString &s)
{
if (!isEmpty() && !QString::endsWith(QLatin1Char('/')))
- append(QLatin1Char('/'));
- append(s);
+ appendString(QLatin1Char('/'));
+ appendString(s);
return *this;
}
-FileName &FileName::append(const QString &str)
+FileName &FileName::appendString(const QString &str)
{
QString::append(str);
return *this;
}
-FileName &FileName::append(QChar str)
+FileName &FileName::appendString(QChar str)
{
QString::append(str);
return *this;
diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h
index 026152d2ea..96c1d46991 100644
--- a/src/libs/utils/fileutils.h
+++ b/src/libs/utils/fileutils.h
@@ -75,8 +75,8 @@ public:
Utils::FileName relativeChildPath(const FileName &parent) const;
Utils::FileName &appendPath(const QString &s);
- Utils::FileName &append(const QString &str);
- Utils::FileName &append(QChar str);
+ Utils::FileName &appendString(const QString &str);
+ Utils::FileName &appendString(QChar str);
using QString::size;
using QString::count;
diff --git a/src/libs/utils/historycompleter.cpp b/src/libs/utils/historycompleter.cpp
index df31af96a6..e47037379d 100644
--- a/src/libs/utils/historycompleter.cpp
+++ b/src/libs/utils/historycompleter.cpp
@@ -28,6 +28,7 @@
****************************************************************************/
#include "historycompleter.h"
+#include "fancylineedit.h"
#include "qtcassert.h"
@@ -35,7 +36,6 @@
#include <QItemDelegate>
#include <QKeyEvent>
-#include <QLineEdit>
#include <QListView>
#include <QPainter>
@@ -59,7 +59,7 @@ public:
QStringList list;
QString historyKey;
int maxLines;
- QLineEdit *lineEdit;
+ FancyLineEdit *lineEdit;
};
class HistoryLineDelegate : public QItemDelegate
@@ -160,7 +160,7 @@ void HistoryCompleterPrivate::saveEntry(const QString &str)
theSettings->setValue(historyKey, list);
}
-HistoryCompleter::HistoryCompleter(QLineEdit *lineEdit, const QString &historyKey, QObject *parent)
+HistoryCompleter::HistoryCompleter(FancyLineEdit *lineEdit, const QString &historyKey, QObject *parent)
: QCompleter(parent),
d(new HistoryCompleterPrivate)
{
@@ -176,7 +176,6 @@ HistoryCompleter::HistoryCompleter(QLineEdit *lineEdit, const QString &historyKe
setModel(d);
setPopup(new HistoryLineView(d));
- lineEdit->installEventFilter(this);
connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(saveHistory()));
}
@@ -191,17 +190,6 @@ HistoryCompleter::~HistoryCompleter()
delete d;
}
-bool HistoryCompleter::eventFilter(QObject *obj, QEvent *event)
-{
- if (event->type() == QEvent::KeyPress
- && static_cast<QKeyEvent *>(event)->key() == Qt::Key_Down
- && !popup()->isVisible()) {
- setCompletionPrefix(QString());
- complete();
- }
- return QCompleter::eventFilter(obj, event);
-}
-
int HistoryCompleter::historySize() const
{
return d->rowCount();
diff --git a/src/libs/utils/historycompleter.h b/src/libs/utils/historycompleter.h
index 3d9352a6ae..41cb01cb3f 100644
--- a/src/libs/utils/historycompleter.h
+++ b/src/libs/utils/historycompleter.h
@@ -35,11 +35,12 @@
#include <QCompleter>
QT_BEGIN_NAMESPACE
-class QLineEdit;
class QSettings;
QT_END_NAMESPACE
namespace Utils {
+
+class FancyLineEdit;
namespace Internal { class HistoryCompleterPrivate; }
class QTCREATOR_UTILS_EXPORT HistoryCompleter : public QCompleter
@@ -48,7 +49,7 @@ class QTCREATOR_UTILS_EXPORT HistoryCompleter : public QCompleter
public:
static void setSettings(QSettings *settings);
- HistoryCompleter(QLineEdit *lineEdit, const QString &historyKey, QObject *parent = 0);
+ HistoryCompleter(FancyLineEdit *lineEdit, const QString &historyKey, QObject *parent = 0);
bool removeHistoryItem(int index);
private:
@@ -56,7 +57,6 @@ private:
int historySize() const;
int maximalHistorySize() const;
void setMaximalHistorySize(int numberOfEntries);
- bool eventFilter(QObject *obj, QEvent *event);
public Q_SLOTS:
void clearHistory();
diff --git a/src/libs/utils/textfileformat.cpp b/src/libs/utils/textfileformat.cpp
index 9585c64597..f9a2e21c86 100644
--- a/src/libs/utils/textfileformat.cpp
+++ b/src/libs/utils/textfileformat.cpp
@@ -272,39 +272,6 @@ TextFileFormat::ReadResult
}
TextFileFormat::ReadResult TextFileFormat::readFileUTF8(const QString &fileName,
- QByteArray *plainText, QString *errorString)
-{
- QByteArray data;
- try {
- Utils::FileReader reader;
- if (!reader.fetch(fileName, errorString))
- return TextFileFormat::ReadIOError;
- data = reader.data();
- } catch (const std::bad_alloc &) {
- *errorString = QCoreApplication::translate("Utils::TextFileFormat", "Out of memory.");
- return TextFileFormat::ReadMemoryAllocationError;
- }
-
- TextFileFormat format = TextFileFormat::detect(data);
- if (!format.codec)
- format.codec = QTextCodec::codecForLocale();
- if (format.codec->name() == "UTF-8") {
- if (format.hasUtf8Bom)
- data.remove(0, 3);
- *plainText = data;
- return TextFileFormat::ReadSuccess;
- }
-
- QString target;
- if (!format.decode(data, &target)) {
- *errorString = QCoreApplication::translate("Utils::TextFileFormat", "An encoding error was encountered.");
- return TextFileFormat::ReadEncodingError;
- }
- *plainText = target.toUtf8();
- return TextFileFormat::ReadSuccess;
-}
-
-TextFileFormat::ReadResult TextFileFormat::readFileUTF8(const QString &fileName,
const QTextCodec *defaultCodec,
QByteArray *plainText, QString *errorString)
{
@@ -322,18 +289,13 @@ TextFileFormat::ReadResult TextFileFormat::readFileUTF8(const QString &fileName,
Utils::TextFileFormat format = Utils::TextFileFormat::detect(data);
if (!format.codec)
format.codec = defaultCodec ? defaultCodec : QTextCodec::codecForLocale();
- if (format.codec->name() == "UTF-8") {
+ QString target;
+ if (format.codec->name() == "UTF-8" || !format.decode(data, &target)) {
if (format.hasUtf8Bom)
data.remove(0, 3);
*plainText = data;
return Utils::TextFileFormat::ReadSuccess;
}
-
- QString target;
- if (!format.decode(data, &target)) {
- *errorString = QCoreApplication::translate("Utils::TextFileFormat", "An encoding error was encountered.");
- return Utils::TextFileFormat::ReadEncodingError;
- }
*plainText = target.toUtf8();
return Utils::TextFileFormat::ReadSuccess;
}
diff --git a/src/libs/utils/textfileformat.h b/src/libs/utils/textfileformat.h
index d75d56413f..0db34278e8 100644
--- a/src/libs/utils/textfileformat.h
+++ b/src/libs/utils/textfileformat.h
@@ -76,8 +76,6 @@ public:
static ReadResult readFile(const QString &fileName, const QTextCodec *defaultCodec,
QString *plainText, TextFileFormat *format, QString *errorString,
QByteArray *decodingErrorSample = 0);
- static ReadResult readFileUTF8(const QString &fileName, QByteArray *plainText,
- QString *errorString); // TODO: Remove this version.
static ReadResult readFileUTF8(const QString &fileName, const QTextCodec *defaultCodec,
QByteArray *plainText, QString *errorString);
diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri
index 97833eb8e7..319e2be935 100644
--- a/src/libs/utils/utils-lib.pri
+++ b/src/libs/utils/utils-lib.pri
@@ -86,7 +86,9 @@ SOURCES += $$PWD/environment.cpp \
$$PWD/tooltip/tipcontents.cpp \
$$PWD/unixutils.cpp \
$$PWD/function.cpp \
- $$PWD/ansiescapecodehandler.cpp
+ $$PWD/ansiescapecodehandler.cpp \
+ $$PWD/execmenu.cpp \
+ $$PWD/completinglineedit.cpp
win32 {
SOURCES += \
@@ -180,7 +182,9 @@ HEADERS += \
$$PWD/unixutils.h \
$$PWD/qtcoverride.h \
$$PWD/function.h \
- $$PWD/ansiescapecodehandler.h
+ $$PWD/ansiescapecodehandler.h \
+ $$PWD/execmenu.h \
+ $$PWD/completinglineedit.h
FORMS += $$PWD/filewizardpage.ui \
$$PWD/projectintropage.ui \
diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs
index c40db11a3e..5fc781e7d8 100644
--- a/src/libs/utils/utils.qbs
+++ b/src/libs/utils/utils.qbs
@@ -45,6 +45,8 @@ QtcLibrary {
"classnamevalidatinglineedit.h",
"codegeneration.cpp",
"codegeneration.h",
+ "completinglineedit.cpp",
+ "completinglineedit.h",
"completingtextedit.cpp",
"completingtextedit.h",
"consoleprocess.cpp",
@@ -64,6 +66,8 @@ QtcLibrary {
"environment.h",
"environmentmodel.cpp",
"environmentmodel.h",
+ "execmenu.cpp",
+ "execmenu.h",
"faketooltip.cpp",
"faketooltip.h",
"fancylineedit.cpp",
diff --git a/src/plugins/analyzerbase/analyzerrunconfigwidget.cpp b/src/plugins/analyzerbase/analyzerrunconfigwidget.cpp
index 47510bd5f7..35ace48a98 100644
--- a/src/plugins/analyzerbase/analyzerrunconfigwidget.cpp
+++ b/src/plugins/analyzerbase/analyzerrunconfigwidget.cpp
@@ -98,8 +98,8 @@ void AnalyzerRunConfigWidget::chooseSettings(int setting)
m_configWidget->setEnabled(isCustom);
m_restoreButton->setEnabled(isCustom);
m_details->setSummaryText(isCustom
- ? tr("Use <strong>Customized Settings<strong>")
- : tr("Use <strong>Global Settings<strong>"));
+ ? tr("Use <strong>Customized Settings</strong>")
+ : tr("Use <strong>Global Settings</strong>"));
}
void AnalyzerRunConfigWidget::restoreGlobal()
diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp
index ec27cc34d5..44d06d8310 100644
--- a/src/plugins/android/androidconfigurations.cpp
+++ b/src/plugins/android/androidconfigurations.cpp
@@ -37,6 +37,7 @@
#include "androiddevicedialog.h"
#include <coreplugin/icore.h>
+#include <coreplugin/messagemanager.h>
#include <utils/hostosinfo.h>
#include <utils/persistentsettings.h>
#include <projectexplorer/kitmanager.h>
@@ -248,7 +249,7 @@ void AndroidConfigurations::updateAvailableSdkPlatforms()
QProcess proc;
proc.setProcessEnvironment(androidToolEnvironment().toProcessEnvironment());
proc.start(androidToolPath().toString(), QStringList() << QLatin1String("list") << QLatin1String("target")); // list avaialbe AVDs
- if (!proc.waitForFinished(-1)) {
+ if (!proc.waitForFinished(5000)) {
proc.terminate();
return;
}
@@ -333,22 +334,22 @@ FileName AndroidConfigurations::toolPath(Abi::Architecture architecture, const Q
FileName AndroidConfigurations::stripPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
{
- return toolPath(architecture, ndkToolChainVersion).append(QLatin1String("-strip" QTC_HOST_EXE_SUFFIX));
+ return toolPath(architecture, ndkToolChainVersion).appendString(QLatin1String("-strip" QTC_HOST_EXE_SUFFIX));
}
FileName AndroidConfigurations::readelfPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
{
- return toolPath(architecture, ndkToolChainVersion).append(QLatin1String("-readelf" QTC_HOST_EXE_SUFFIX));
+ return toolPath(architecture, ndkToolChainVersion).appendString(QLatin1String("-readelf" QTC_HOST_EXE_SUFFIX));
}
FileName AndroidConfigurations::gccPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
{
- return toolPath(architecture, ndkToolChainVersion).append(QLatin1String("-gcc" QTC_HOST_EXE_SUFFIX));
+ return toolPath(architecture, ndkToolChainVersion).appendString(QLatin1String("-gcc" QTC_HOST_EXE_SUFFIX));
}
FileName AndroidConfigurations::gdbPath(Abi::Architecture architecture, const QString &ndkToolChainVersion) const
{
- return toolPath(architecture, ndkToolChainVersion).append(QLatin1String("-gdb" QTC_HOST_EXE_SUFFIX));
+ return toolPath(architecture, ndkToolChainVersion).appendString(QLatin1String("-gdb" QTC_HOST_EXE_SUFFIX));
}
FileName AndroidConfigurations::openJDKPath() const
@@ -458,7 +459,7 @@ QVector<AndroidDeviceInfo> AndroidConfigurations::connectedDevices(QString *erro
QVector<AndroidDeviceInfo> devices;
QProcess adbProc;
adbProc.start(adbToolPath().toString(), QStringList() << QLatin1String("devices"));
- if (!adbProc.waitForFinished(-1)) {
+ if (!adbProc.waitForFinished(5000)) {
adbProc.kill();
if (error)
*error = tr("Could not run: %1").arg(adbToolPath().toString() + QLatin1String(" devices"));
@@ -563,6 +564,8 @@ QString AndroidConfigurations::createAVD(const QString &target, const QString &n
break;
}
+ Core::MessageManager::write(QString::fromLocal8Bit(question), Core::MessageManager::Flash);
+
proc.waitForFinished();
if (proc.exitCode()) // error!
@@ -577,7 +580,7 @@ bool AndroidConfigurations::removeAVD(const QString &name) const
proc.start(androidToolPath().toString(),
QStringList() << QLatin1String("delete") << QLatin1String("avd")
<< QLatin1String("-n") << name);
- if (!proc.waitForFinished(-1)) {
+ if (!proc.waitForFinished(5000)) {
proc.terminate();
return false;
}
@@ -591,7 +594,7 @@ QVector<AndroidDeviceInfo> AndroidConfigurations::androidVirtualDevices() const
proc.setProcessEnvironment(androidToolEnvironment().toProcessEnvironment());
proc.start(androidToolPath().toString(),
QStringList() << QLatin1String("list") << QLatin1String("avd")); // list available AVDs
- if (!proc.waitForFinished(-1)) {
+ if (!proc.waitForFinished(5000)) {
proc.terminate();
return devices;
}
@@ -634,7 +637,7 @@ QVector<AndroidDeviceInfo> AndroidConfigurations::androidVirtualDevices() const
QString AndroidConfigurations::startAVD(const QString &name, int apiLevel, QString cpuAbi) const
{
- if (findAvd(apiLevel, cpuAbi) || startAVDAsync(name))
+ if (!findAvd(apiLevel, cpuAbi).isEmpty() || startAVDAsync(name))
return waitForAvd(apiLevel, cpuAbi);
return QString();
}
@@ -656,7 +659,7 @@ bool AndroidConfigurations::startAVDAsync(const QString &avdName) const
return true;
}
-bool AndroidConfigurations::findAvd(int apiLevel, const QString &cpuAbi) const
+QString AndroidConfigurations::findAvd(int apiLevel, const QString &cpuAbi) const
{
QVector<AndroidDeviceInfo> devices = connectedDevices();
foreach (AndroidDeviceInfo device, devices) {
@@ -666,37 +669,50 @@ bool AndroidConfigurations::findAvd(int apiLevel, const QString &cpuAbi) const
continue;
if (device.sdk != apiLevel)
continue;
- return true;
+ return device.serialNumber;
+ }
+ return QString();
+}
+
+bool AndroidConfigurations::isConnected(const QString &serialNumber) const
+{
+ QVector<AndroidDeviceInfo> devices = connectedDevices();
+ foreach (AndroidDeviceInfo device, devices) {
+ if (device.serialNumber == serialNumber)
+ return true;
}
return false;
}
-QString AndroidConfigurations::waitForAvd(int apiLevel, const QString &cpuAbi) const
+bool AndroidConfigurations::waitForBooted(const QString &serialNumber, const QFutureInterface<bool> &fi) const
{
- // we cannot use adb -e wait-for-device, since that doesn't work if a emulator is already running
+ // found a serial number, now wait until it's done booting...
+ for (int i = 0; i < 60; ++i) {
+ if (fi.isCanceled())
+ return false;
+ if (hasFinishedBooting(serialNumber)) {
+ return true;
+ } else {
+ Utils::sleep(2000);
+ if (!isConnected(serialNumber)) // device was disconnected
+ return false;
+ }
+ }
+ return false;
+}
- // 15 rounds of 8s sleeping, a minute for the avd to start
+QString AndroidConfigurations::waitForAvd(int apiLevel, const QString &cpuAbi, const QFutureInterface<bool> &fi) const
+{
+ // we cannot use adb -e wait-for-device, since that doesn't work if a emulator is already running
+ // 60 rounds of 2s sleeping, two minutes for the avd to start
QString serialNumber;
- for (int i = 0; i < 15; ++i) {
- QVector<AndroidDeviceInfo> devices = connectedDevices();
- foreach (AndroidDeviceInfo device, devices) {
- if (!device.serialNumber.startsWith(QLatin1String("emulator")))
- continue;
- if (!device.cpuAbi.contains(cpuAbi))
- continue;
- if (device.sdk != apiLevel)
- continue;
- serialNumber = device.serialNumber;
- // found a serial number, now wait until it's done booting...
- for (int i = 0; i < 15; ++i) {
- if (hasFinishedBooting(serialNumber))
- return serialNumber;
- else
- Utils::sleep(8000);
- }
+ for (int i = 0; i < 60; ++i) {
+ if (fi.isCanceled())
return QString();
- }
- Utils::sleep(8000);
+ serialNumber = findAvd(apiLevel, cpuAbi);
+ if (!serialNumber.isEmpty())
+ return waitForBooted(serialNumber, fi) ? serialNumber : QString();
+ Utils::sleep(2000);
}
return QString();
}
@@ -710,7 +726,7 @@ bool AndroidConfigurations::isBootToQt(const QString &device) const
QProcess adbProc;
adbProc.start(adbToolPath().toString(), arguments);
- if (!adbProc.waitForFinished(-1)) {
+ if (!adbProc.waitForFinished(5000)) {
adbProc.kill();
return false;
}
@@ -726,7 +742,7 @@ int AndroidConfigurations::getSDKVersion(const QString &device) const
QProcess adbProc;
adbProc.start(adbToolPath().toString(), arguments);
- if (!adbProc.waitForFinished(-1)) {
+ if (!adbProc.waitForFinished(5000)) {
adbProc.kill();
return -1;
}
@@ -749,7 +765,7 @@ QString AndroidConfigurations::getProductModel(const QString &device) const
QProcess adbProc;
adbProc.start(adbToolPath().toString(), arguments);
- if (!adbProc.waitForFinished(-1)) {
+ if (!adbProc.waitForFinished(5000)) {
adbProc.kill();
return device;
}
@@ -769,7 +785,7 @@ bool AndroidConfigurations::hasFinishedBooting(const QString &device) const
QProcess adbProc;
adbProc.start(adbToolPath().toString(), arguments);
- if (!adbProc.waitForFinished(-1)) {
+ if (!adbProc.waitForFinished(5000)) {
adbProc.kill();
return false;
}
@@ -792,7 +808,7 @@ QStringList AndroidConfigurations::getAbis(const QString &device) const
QProcess adbProc;
adbProc.start(adbToolPath().toString(), arguments);
- if (!adbProc.waitForFinished(-1)) {
+ if (!adbProc.waitForFinished(5000)) {
adbProc.kill();
return result;
}
diff --git a/src/plugins/android/androidconfigurations.h b/src/plugins/android/androidconfigurations.h
index 41ba97dbc4..bf7feb298e 100644
--- a/src/plugins/android/androidconfigurations.h
+++ b/src/plugins/android/androidconfigurations.h
@@ -36,6 +36,7 @@
#include <QVector>
#include <QHash>
#include <QMap>
+#include <QFutureInterface>
#include <projectexplorer/abi.h>
#include <utils/fileutils.h>
#include <utils/environment.h>
@@ -108,8 +109,9 @@ public:
QVector<AndroidDeviceInfo> androidVirtualDevices() const;
QString startAVD(const QString &name, int apiLevel, QString cpuAbi) const;
bool startAVDAsync(const QString &avdName) const;
- bool findAvd(int apiLevel, const QString &cpuAbi) const;
- QString waitForAvd(int apiLevel, const QString &cpuAbi) const;
+ QString findAvd(int apiLevel, const QString &cpuAbi) const;
+ QString waitForAvd(int apiLevel, const QString &cpuAbi, const QFutureInterface<bool> &fi = QFutureInterface<bool>()) const;
+ // special version for AndroidDeployQt::run
QString bestNdkPlatformMatch(const QString &targetAPI) const;
QStringList makeExtraSearchDirectories() const;
@@ -123,6 +125,8 @@ public:
QString getProductModel(const QString &device) const;
bool hasFinishedBooting(const QString &device) const;
+ bool waitForBooted(const QString &serialNumber, const QFutureInterface<bool> &fi) const;
+ bool isConnected(const QString &serialNumber) const;
AndroidDeviceInfo showDeviceDialog(ProjectExplorer::Project *project, int apiLevel, const QString &abi);
void setDefaultDevice(ProjectExplorer::Project *project, const QString &abi, const QString &serialNumber); // serial number or avd name
diff --git a/src/plugins/android/androiddeployqtstep.cpp b/src/plugins/android/androiddeployqtstep.cpp
index 7e87a7bfb5..03a7284ff5 100644
--- a/src/plugins/android/androiddeployqtstep.cpp
+++ b/src/plugins/android/androiddeployqtstep.cpp
@@ -61,6 +61,7 @@ const QLatin1String SignPackageKey("SignPackage");
const QLatin1String BuildTargetSdkKey("BuildTargetSdk");
const QLatin1String VerboseOutputKey("VerboseOutput");
const QLatin1String InputFile("InputFile");
+const QLatin1String ProFilePathForInputFile("ProFilePathForInputFile");
const Core::Id AndroidDeployQtStep::Id("Qt4ProjectManager.AndroidDeployQtStep");
//////////////////
@@ -213,9 +214,9 @@ bool AndroidDeployQtStep::init()
if (!version)
return false;
- ProjectExplorer::Project *project = target()->project();
+ QmakeProjectManager::QmakeProject *pro = static_cast<QmakeProjectManager::QmakeProject *>(project());
JavaParser *parser = new JavaParser;
- parser->setProjectFileList(project->files(ProjectExplorer::Project::AllFiles));
+ parser->setProjectFileList(pro->files(ProjectExplorer::Project::AllFiles));
setOutputParser(parser);
QString command = version->qmakeProperty("QT_HOST_BINS");
@@ -234,10 +235,21 @@ bool AndroidDeployQtStep::init()
deploymentMethod = QLatin1String("bundled");
QString outputDir = bc->buildDirectory().appendPath(QLatin1String(Constants::ANDROID_BUILDDIRECTORY)).toString();
+ const QmakeProjectManager::QmakeProFileNode *node = pro->rootQmakeProjectNode()->findProFileFor(m_proFilePathForInputFile);
+ if (!node) { // should never happen
+ emit addOutput(tr("Internal Error: Could not find .pro file."), BuildStep::ErrorMessageOutput);
+ return false;
+ }
+
+ QString inputFile = node->singleVariableValue(QmakeProjectManager::AndroidDeploySettingsFile);
+ if (inputFile.isEmpty()) { // should never happen
+ emit addOutput(tr("Internal Error: Unknown android deployment json file location"), BuildStep::ErrorMessageOutput);
+ return false;
+ }
QStringList arguments;
arguments << QLatin1String("--input")
- << m_inputFile
+ << inputFile
<< QLatin1String("--output")
<< outputDir
<< QLatin1String("--deployment")
@@ -250,6 +262,9 @@ bool AndroidDeployQtStep::init()
<< QLatin1String("--jdk")
<< AndroidConfigurations::instance().openJDKPath().toString();
+ parser->setSourceDirectory(Utils::FileName::fromString(node->singleVariableValue(QmakeProjectManager::AndroidPackageSourceDir)));
+ parser->setBuildDirectory(Utils::FileName::fromString(outputDir));
+
if (m_verbose)
arguments << QLatin1String("--verbose");
if (m_avdName.isEmpty())
@@ -285,7 +300,7 @@ bool AndroidDeployQtStep::init()
if (!result)
return false;
- if (!AndroidConfigurations::instance().findAvd(m_deviceAPILevel, m_targetArch))
+ if (AndroidConfigurations::instance().findAvd(m_deviceAPILevel, m_targetArch).isEmpty())
AndroidConfigurations::instance().startAVDAsync(m_avdName);
return true;
}
@@ -293,7 +308,7 @@ bool AndroidDeployQtStep::init()
void AndroidDeployQtStep::run(QFutureInterface<bool> &fi)
{
if (!m_avdName.isEmpty()) {
- QString serialNumber = AndroidConfigurations::instance().waitForAvd(m_deviceAPILevel, m_targetArch);
+ QString serialNumber = AndroidConfigurations::instance().waitForAvd(m_deviceAPILevel, m_targetArch, fi);
if (serialNumber.isEmpty()) {
fi.reportResult(false);
emit finished();
@@ -347,17 +362,12 @@ void AndroidDeployQtStep::updateInputFile()
QmakeProjectManager::QmakeProject *pro = static_cast<QmakeProjectManager::QmakeProject *>(project());
QList<QmakeProjectManager::QmakeProFileNode *> nodes = pro->applicationProFiles();
- QStringList inputFiles;
- foreach (QmakeProjectManager::QmakeProFileNode *node, nodes)
- inputFiles << node->singleVariableValue(QmakeProjectManager::AndroidDeploySettingsFile);
-
- if (!inputFiles.contains(m_inputFile))
- m_inputFile.clear();
-
- if (m_inputFile.isEmpty()) {
- // not yet selected one or no longer exists
- if (!inputFiles.isEmpty())
- m_inputFile = inputFiles.first();
+ const QmakeProjectManager::QmakeProFileNode *node = pro->rootQmakeProjectNode()->findProFileFor(m_proFilePathForInputFile);
+ if (!nodes.contains(const_cast<QmakeProjectManager::QmakeProFileNode *>(node))) {
+ if (!nodes.isEmpty())
+ m_proFilePathForInputFile = nodes.first()->path();
+ else
+ m_proFilePathForInputFile.clear();
}
emit inputFileChanged();
@@ -388,7 +398,7 @@ bool AndroidDeployQtStep::fromMap(const QVariantMap &map)
m_signPackage = false; // don't restore this
m_buildTargetSdk = map.value(BuildTargetSdkKey).toString();
m_verbose = map.value(VerboseOutputKey).toBool();
- m_inputFile = map.value(InputFile).toString();
+ m_proFilePathForInputFile = map.value(ProFilePathForInputFile).toString();
return ProjectExplorer::BuildStep::fromMap(map);
}
@@ -400,7 +410,7 @@ QVariantMap AndroidDeployQtStep::toMap() const
map.insert(SignPackageKey, m_signPackage);
map.insert(BuildTargetSdkKey, m_buildTargetSdk);
map.insert(VerboseOutputKey, m_verbose);
- map.insert(InputFile, m_inputFile);
+ map.insert(ProFilePathForInputFile, m_proFilePathForInputFile);
return map;
}
@@ -481,14 +491,14 @@ void AndroidDeployQtStep::setVerboseOutput(bool verbose)
m_verbose = verbose;
}
-QString AndroidDeployQtStep::inputFile() const
+QString AndroidDeployQtStep::proFilePathForInputFile() const
{
- return m_inputFile;
+ return m_proFilePathForInputFile;
}
-void AndroidDeployQtStep::setInputFile(const QString &file)
+void AndroidDeployQtStep::setProFilePathForInputFile(const QString &path)
{
- m_inputFile = file;
+ m_proFilePathForInputFile = path;
}
bool AndroidDeployQtStep::runInGuiThread() const
diff --git a/src/plugins/android/androiddeployqtstep.h b/src/plugins/android/androiddeployqtstep.h
index a6ab5d3372..194dd256eb 100644
--- a/src/plugins/android/androiddeployqtstep.h
+++ b/src/plugins/android/androiddeployqtstep.h
@@ -104,8 +104,8 @@ public:
bool verboseOutput() const;
void setVerboseOutput(bool verbose);
- QString inputFile() const;
- void setInputFile(const QString &file);
+ QString proFilePathForInputFile() const;
+ void setProFilePathForInputFile(const QString &path);
bool runInGuiThread() const;
@@ -150,7 +150,7 @@ private:
QString m_avdName;
QString m_apkPath;
QString m_targetArch;
- QString m_inputFile;
+ QString m_proFilePathForInputFile;
int m_deviceAPILevel;
static const Core::Id Id;
diff --git a/src/plugins/android/androiddeployqtwidget.cpp b/src/plugins/android/androiddeployqtwidget.cpp
index 9bf0d0afea..b84d4589eb 100644
--- a/src/plugins/android/androiddeployqtwidget.cpp
+++ b/src/plugins/android/androiddeployqtwidget.cpp
@@ -187,12 +187,10 @@ void AndroidDeployQtWidget::updateInputFileUi()
m_ui->inputFileComboBox->setVisible(true);
m_ui->inputFileComboBox->clear();
- foreach (QmakeProjectManager::QmakeProFileNode *node, nodes) {
- QString file = node->singleVariableValue(QmakeProjectManager::AndroidDeploySettingsFile);
- m_ui->inputFileComboBox->addItem(node->displayName(), file);
- }
+ foreach (QmakeProjectManager::QmakeProFileNode *node, nodes)
+ m_ui->inputFileComboBox->addItem(node->displayName(), node->path());
- int index = m_ui->inputFileComboBox->findData(m_step->inputFile());
+ int index = m_ui->inputFileComboBox->findData(m_step->proFilePathForInputFile());
m_ui->inputFileComboBox->setCurrentIndex(index);
m_ignoreChange = false;
}
@@ -202,8 +200,8 @@ void AndroidDeployQtWidget::inputFileComboBoxIndexChanged()
{
if (m_ignoreChange)
return;
- QString text = m_ui->inputFileComboBox->itemData(m_ui->inputFileComboBox->currentIndex()).toString();
- m_step->setInputFile(text);
+ QString proFilePath = m_ui->inputFileComboBox->itemData(m_ui->inputFileComboBox->currentIndex()).toString();
+ m_step->setProFilePathForInputFile(proFilePath);
}
QString AndroidDeployQtWidget::displayName() const
diff --git a/src/plugins/android/androiddeployqtwidget.ui b/src/plugins/android/androiddeployqtwidget.ui
index a726f9134f..180bccc3b7 100644
--- a/src/plugins/android/androiddeployqtwidget.ui
+++ b/src/plugins/android/androiddeployqtwidget.ui
@@ -200,7 +200,7 @@
<item row="1" column="0">
<widget class="QLabel" name="targetSDKLabel">
<property name="text">
- <string>Android target SDK:</string>
+ <string>Android build SDK:</string>
</property>
</widget>
</item>
@@ -241,7 +241,7 @@
<item>
<widget class="QLabel" name="oldFilesWarningLabel">
<property name="text">
- <string>Qt no longer uses the folder "android" in the project's source directory.</string>
+ <string>Qt no longer uses the folder &quot;android&quot; in the project's source directory.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
diff --git a/src/plugins/android/androiddeploystep.cpp b/src/plugins/android/androiddeploystep.cpp
index 8916d46b17..7c3374795f 100644
--- a/src/plugins/android/androiddeploystep.cpp
+++ b/src/plugins/android/androiddeploystep.cpp
@@ -281,8 +281,7 @@ unsigned int AndroidDeployStep::remoteModificationTime(const QString &fullDestin
QStringList arguments = AndroidDeviceInfo::adbSelector(m_deviceSerialNumber);
arguments << QLatin1String("ls") << destination;
process.start(AndroidConfigurations::instance().adbToolPath().toString(), arguments);
- process.waitForFinished(-1);
- if (process.error() != QProcess::UnknownError
+ if (!process.waitForFinished(5000)
|| process.exitCode() != 0)
return 0;
QByteArray output = process.readAll();
@@ -389,7 +388,7 @@ void AndroidDeployStep::deployFiles(QProcess *process, const QList<DeployItem> &
bool AndroidDeployStep::deployPackage()
{
if (!m_avdName.isEmpty()) {
- if (!AndroidConfigurations::instance().findAvd(m_deviceAPILevel, m_targetArch)
+ if (AndroidConfigurations::instance().findAvd(m_deviceAPILevel, m_targetArch).isEmpty()
&& !AndroidConfigurations::instance().startAVDAsync(m_avdName))
return false;
m_deviceSerialNumber = AndroidConfigurations::instance().waitForAvd(m_deviceAPILevel, m_targetArch);
diff --git a/src/plugins/android/androidmanager.cpp b/src/plugins/android/androidmanager.cpp
index 3e83c3a282..0328cb64ad 100644
--- a/src/plugins/android/androidmanager.cpp
+++ b/src/plugins/android/androidmanager.cpp
@@ -288,7 +288,7 @@ Utils::FileName AndroidManager::libsPath(ProjectExplorer::Target *target)
Utils::FileName AndroidManager::stringsPath(ProjectExplorer::Target *target)
{
- return dirPath(target).append(AndroidStringsFileName);
+ return dirPath(target).appendString(AndroidStringsFileName);
}
Utils::FileName AndroidManager::defaultPropertiesPath(ProjectExplorer::Target *target)
@@ -791,7 +791,7 @@ QString AndroidManager::androidNameForApiLevel(int x)
case 19:
return QLatin1String("Android 4.4");
default:
- return QLatin1String("Unknown Android version.");
+ return tr("Unknown Android version.");
}
}
diff --git a/src/plugins/android/androidmanifestdocument.cpp b/src/plugins/android/androidmanifestdocument.cpp
index b1f1552a8d..fd1d484ecf 100644
--- a/src/plugins/android/androidmanifestdocument.cpp
+++ b/src/plugins/android/androidmanifestdocument.cpp
@@ -44,6 +44,7 @@ AndroidManifestDocument::AndroidManifestDocument(AndroidManifestEditorWidget *ed
: TextEditor::BaseTextDocument(),
m_editorWidget(editorWidget)
{
+ setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
}
bool AndroidManifestDocument::save(QString *errorString, const QString &fileName, bool autoSave)
diff --git a/src/plugins/android/androidmanifesteditorfactory.cpp b/src/plugins/android/androidmanifesteditorfactory.cpp
index e6e5b0ed0b..b5767e2edd 100644
--- a/src/plugins/android/androidmanifesteditorfactory.cpp
+++ b/src/plugins/android/androidmanifesteditorfactory.cpp
@@ -41,17 +41,17 @@ using namespace Android::Internal;
AndroidManifestEditorFactory::AndroidManifestEditorFactory(QObject *parent)
- : Core::IEditorFactory(parent),
- m_actionHandler(new TextEditor::TextEditorActionHandler(Constants::ANDROID_MANIFEST_EDITOR_CONTEXT))
+ : Core::IEditorFactory(parent)
{
setId(Constants::ANDROID_MANIFEST_EDITOR_ID);
setDisplayName(tr("Android Manifest editor"));
addMimeType(Constants::ANDROID_MANIFEST_MIME_TYPE);
+ new TextEditor::TextEditorActionHandler(this, Constants::ANDROID_MANIFEST_EDITOR_CONTEXT);
}
-Core::IEditor *AndroidManifestEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *AndroidManifestEditorFactory::createEditor()
{
- AndroidManifestEditorWidget *editor = new AndroidManifestEditorWidget(parent, m_actionHandler);
+ AndroidManifestEditorWidget *editor = new AndroidManifestEditorWidget();
TextEditor::TextEditorSettings::initializeEditor(editor);
return editor->editor();
}
diff --git a/src/plugins/android/androidmanifesteditorfactory.h b/src/plugins/android/androidmanifesteditorfactory.h
index 47f1b44762..7b62f0ad57 100644
--- a/src/plugins/android/androidmanifesteditorfactory.h
+++ b/src/plugins/android/androidmanifesteditorfactory.h
@@ -32,8 +32,6 @@
#include <coreplugin/editormanager/ieditorfactory.h>
-namespace TextEditor { class TextEditorActionHandler; }
-
namespace Android {
namespace Internal {
@@ -44,10 +42,7 @@ class AndroidManifestEditorFactory : public Core::IEditorFactory
public:
explicit AndroidManifestEditorFactory(QObject *parent = 0);
- Core::IEditor *createEditor(QWidget *parent);
-
-private:
- TextEditor::TextEditorActionHandler *m_actionHandler;
+ Core::IEditor *createEditor();
};
} // namespace Internal
diff --git a/src/plugins/android/androidmanifesteditorwidget.cpp b/src/plugins/android/androidmanifesteditorwidget.cpp
index 1e50a4987e..2ded8d8635 100644
--- a/src/plugins/android/androidmanifesteditorwidget.cpp
+++ b/src/plugins/android/androidmanifesteditorwidget.cpp
@@ -95,18 +95,13 @@ Project *androidProject(const QString &file)
} // anonymous namespace
-AndroidManifestEditorWidget::AndroidManifestEditorWidget(QWidget *parent, TextEditor::TextEditorActionHandler *ah)
- : TextEditor::PlainTextEditorWidget(parent),
+AndroidManifestEditorWidget::AndroidManifestEditorWidget(QWidget *parent)
+ : TextEditor::PlainTextEditorWidget(new AndroidManifestDocument(this), parent),
m_dirty(false),
m_stayClean(false),
m_setAppName(false),
m_appNameInStringsXml(false)
{
- QSharedPointer<AndroidManifestDocument> doc(new AndroidManifestDocument(this));
- doc->setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
- setBaseTextDocument(doc);
-
- ah->setupActions(this);
configure(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
initializePage();
@@ -129,7 +124,6 @@ TextEditor::BaseTextEditor *AndroidManifestEditorWidget::createEditor()
return new AndroidManifestEditor(this);
}
-
void AndroidManifestEditorWidget::initializePage()
{
QWidget *mainWidget = new QWidget(this);
@@ -203,7 +197,7 @@ void AndroidManifestEditorWidget::initializePage()
m_androidTargetSdkVersion = new QComboBox(packageGroupBox);
m_androidTargetSdkVersion->setToolTip(
- tr("Sets the target SDK. Set this to the highest tested version."
+ tr("Sets the target SDK. Set this to the highest tested version. "
"This disables compatibility behavior of the system for your application."));
m_androidTargetSdkVersion->addItem(tr("Not set"), 0);
@@ -471,7 +465,7 @@ bool AndroidManifestEditorWidget::eventFilter(QObject *obj, QEvent *event)
void AndroidManifestEditorWidget::updateTargetComboBox()
{
- const QString docPath(static_cast<AndroidManifestDocument *>(editor()->document())->filePath());
+ const QString docPath(baseTextDocument()->filePath());
ProjectExplorer::Project *project = androidProject(docPath);
QStringList items;
if (project) {
@@ -588,7 +582,7 @@ void AndroidManifestEditorWidget::preSave()
syncToEditor();
if (m_setAppName && m_appNameInStringsXml) {
- QString baseDir = QFileInfo(static_cast<AndroidManifestDocument *>(editor()->document())->filePath()).absolutePath();
+ QString baseDir = QFileInfo(baseTextDocument()->filePath()).absolutePath();
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
QFile f(fileName);
if (f.open(QIODevice::ReadOnly)) {
@@ -612,7 +606,7 @@ void AndroidManifestEditorWidget::preSave()
m_setAppName = false;
}
- QString baseDir = QFileInfo(static_cast<AndroidManifestDocument *>(editor()->document())->filePath()).absolutePath();
+ QString baseDir = QFileInfo(baseTextDocument()->filePath()).absolutePath();
if (!m_lIconPath.isEmpty()) {
copyIcon(LowDPI, baseDir, m_lIconPath);
m_lIconPath.clear();
@@ -696,7 +690,7 @@ void AndroidManifestEditorWidget::updateInfoBar()
void AndroidManifestEditorWidget::updateSdkVersions()
{
- const QString docPath(static_cast<AndroidManifestDocument *>(editor()->document())->filePath());
+ const QString docPath(baseTextDocument()->filePath());
Project *project = androidProject(docPath);
QPair<int, int> apiLevels = AndroidManager::apiLevelRange(project ? project->activeTarget() : 0);
for (int i = apiLevels.first; i < apiLevels.second + 1; ++i)
@@ -714,7 +708,7 @@ void AndroidManifestEditorWidget::updateSdkVersions()
void AndroidManifestEditorWidget::updateInfoBar(const QString &errorMessage, int line, int column)
{
- Core::InfoBar *infoBar = editorDocument()->infoBar();
+ Core::InfoBar *infoBar = baseTextDocument()->infoBar();
QString text;
if (line < 0)
text = tr("Could not parse file: '%1'.").arg(errorMessage);
@@ -732,7 +726,7 @@ void AndroidManifestEditorWidget::updateInfoBar(const QString &errorMessage, int
void AndroidManifestEditorWidget::hideInfoBar()
{
- Core::InfoBar *infoBar = editorDocument()->infoBar();
+ Core::InfoBar *infoBar = baseTextDocument()->infoBar();
infoBar->removeInfo(infoBarId);
m_timerParseCheck.stop();
}
@@ -771,7 +765,7 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
setApiLevel(m_androidMinSdkVersion, usesSdkElement, QLatin1String("android:minSdkVersion"));
setApiLevel(m_androidTargetSdkVersion, usesSdkElement, QLatin1String("android:targetSdkVersion"));
- QString baseDir = QFileInfo(static_cast<AndroidManifestDocument *>(editor()->document())->filePath()).absolutePath();
+ QString baseDir = QFileInfo(baseTextDocument()->filePath()).absolutePath();
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
QDomElement applicationElement = manifest.firstChildElement(QLatin1String("application"));
diff --git a/src/plugins/android/androidmanifesteditorwidget.h b/src/plugins/android/androidmanifesteditorwidget.h
index 74b9862cc7..1f5932f590 100644
--- a/src/plugins/android/androidmanifesteditorwidget.h
+++ b/src/plugins/android/androidmanifesteditorwidget.h
@@ -51,8 +51,6 @@ QT_END_NAMESPACE
namespace Core { class IEditor; }
-namespace TextEditor { class TextEditorActionHandler; }
-
namespace Android {
namespace Internal {
class AndroidManifestEditor;
@@ -86,7 +84,7 @@ public:
Source
};
- explicit AndroidManifestEditorWidget(QWidget *parent, TextEditor::TextEditorActionHandler *ah);
+ explicit AndroidManifestEditorWidget(QWidget *parent = 0);
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
diff --git a/src/plugins/android/androidpotentialkit.cpp b/src/plugins/android/androidpotentialkit.cpp
index 6eb93201c4..06aea43f10 100644
--- a/src/plugins/android/androidpotentialkit.cpp
+++ b/src/plugins/android/androidpotentialkit.cpp
@@ -76,6 +76,7 @@ AndroidPotentialKitWidget::AndroidPotentialKitWidget(QWidget *parent)
: Utils::DetailsWidget(parent)
{
setSummaryText(QLatin1String("<b>Create Android Kits</b>"));
+ setIcon(QIcon(QLatin1String(Constants::ANDROID_SETTINGS_CATEGORY_ICON)));
//detailsWidget->setState(Utils::DetailsWidget::NoSummary);
QWidget *mainWidget = new QWidget(this);
setWidget(mainWidget);
@@ -84,7 +85,7 @@ AndroidPotentialKitWidget::AndroidPotentialKitWidget(QWidget *parent)
layout->setMargin(0);
QLabel *label = new QLabel;
label->setText(tr("Qt Creator needs additional settings to enable Android support."
- "You can configure those settings in the Options dialog."));
+ " You can configure those settings in the Options dialog."));
label->setWordWrap(true);
layout->addWidget(label, 0, 0, 1, 2);
diff --git a/src/plugins/android/androidrunconfiguration.cpp b/src/plugins/android/androidrunconfiguration.cpp
index 523981646a..5e45f39f5c 100644
--- a/src/plugins/android/androidrunconfiguration.cpp
+++ b/src/plugins/android/androidrunconfiguration.cpp
@@ -150,14 +150,6 @@ const QString AndroidRunConfiguration::remoteChannel() const
return QLatin1String(":5039");
}
-const QString AndroidRunConfiguration::dumperLib() const
-{
- QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
- if (!version)
- return QString();
- return version->gdbDebuggingHelperLibrary();
-}
-
QString AndroidRunConfiguration::proFilePath() const
{
return m_proFilePath;
diff --git a/src/plugins/android/androidrunconfiguration.h b/src/plugins/android/androidrunconfiguration.h
index 6b8faa3e6a..0263386567 100644
--- a/src/plugins/android/androidrunconfiguration.h
+++ b/src/plugins/android/androidrunconfiguration.h
@@ -59,7 +59,6 @@ public:
QString proFilePath() const;
const QString remoteChannel() const;
- const QString dumperLib() const;
bool isEnabled() const;
QString disabledReason() const;
diff --git a/src/plugins/android/androidruncontrol.cpp b/src/plugins/android/androidruncontrol.cpp
index 4134507d2a..a3563c9125 100644
--- a/src/plugins/android/androidruncontrol.cpp
+++ b/src/plugins/android/androidruncontrol.cpp
@@ -107,7 +107,7 @@ QString AndroidRunControl::displayName() const
QIcon AndroidRunControl::icon() const
{
- return QIcon(QLatin1String(ProjectExplorer::Constants::ICON_DEBUG_SMALL));
+ return QIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL));
}
} // namespace Internal
diff --git a/src/plugins/android/androidrunner.cpp b/src/plugins/android/androidrunner.cpp
index 7370d89c5c..8045dd6dbe 100644
--- a/src/plugins/android/androidrunner.cpp
+++ b/src/plugins/android/androidrunner.cpp
@@ -217,7 +217,7 @@ void AndroidRunner::asyncStart()
emit remoteProcessFinished(tr("Failed to forward C++ debugging ports. Reason: %1.").arg(adb.errorString()));
return;
}
- if (!adb.waitForFinished(-1)) {
+ if (!adb.waitForFinished(5000)) {
emit remoteProcessFinished(tr("Failed to forward C++ debugging ports."));
return;
}
@@ -260,7 +260,7 @@ void AndroidRunner::asyncStart()
emit remoteProcessFinished(tr("Failed to start the activity. Reason: %1.").arg(adb.errorString()));
return;
}
- if (!adb.waitForFinished(-1)) {
+ if (!adb.waitForFinished(5000)) {
adb.terminate();
emit remoteProcessFinished(tr("Unable to start '%1'.").arg(m_packageName));
return;
diff --git a/src/plugins/android/androidsettingspage.cpp b/src/plugins/android/androidsettingspage.cpp
index a38d81877f..09053b532a 100644
--- a/src/plugins/android/androidsettingspage.cpp
+++ b/src/plugins/android/androidsettingspage.cpp
@@ -52,16 +52,10 @@ AndroidSettingsPage::AndroidSettingsPage(QObject *parent)
setCategoryIcon(QLatin1String(Constants::ANDROID_SETTINGS_CATEGORY_ICON));
}
-bool AndroidSettingsPage::matches(const QString &searchKeyWord) const
+QWidget *AndroidSettingsPage::widget()
{
- return m_keywords.contains(searchKeyWord, Qt::CaseInsensitive);
-}
-
-QWidget *AndroidSettingsPage::createPage(QWidget *parent)
-{
- m_widget = new AndroidSettingsWidget(parent);
- if (m_keywords.isEmpty())
- m_keywords = m_widget->searchKeywords();
+ if (!m_widget)
+ m_widget = new AndroidSettingsWidget;
return m_widget;
}
@@ -97,6 +91,7 @@ void AndroidSettingsPage::apply()
void AndroidSettingsPage::finish()
{
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/android/androidsettingspage.h b/src/plugins/android/androidsettingspage.h
index 1cecf78e36..05ac1be110 100644
--- a/src/plugins/android/androidsettingspage.h
+++ b/src/plugins/android/androidsettingspage.h
@@ -32,6 +32,8 @@
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
namespace Android {
namespace Internal {
@@ -44,14 +46,12 @@ class AndroidSettingsPage : public Core::IOptionsPage
public:
explicit AndroidSettingsPage(QObject *parent = 0);
- bool matches(const QString &searchKeyWord) const;
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
private:
- QString m_keywords;
- AndroidSettingsWidget *m_widget;
+ QPointer<AndroidSettingsWidget> m_widget;
};
} // namespace Internal
diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp
index 1c16ccda17..3b8a16844f 100644
--- a/src/plugins/android/androidsettingswidget.cpp
+++ b/src/plugins/android/androidsettingswidget.cpp
@@ -129,24 +129,6 @@ AndroidSettingsWidget::~AndroidSettingsWidget()
delete m_ui;
}
-QString AndroidSettingsWidget::searchKeywords() const
-{
- QString rc;
- QTextStream(&rc) << m_ui->SDKLocationLabel->text()
- << ' ' << m_ui->SDKLocationLineEdit->text()
- << ' ' << m_ui->NDKLocationLabel->text()
- << ' ' << m_ui->NDKLocationLineEdit->text()
- << ' ' << m_ui->AntLocationLabel->text()
- << ' ' << m_ui->AntLocationLineEdit->text()
- << ' ' << m_ui->OpenJDKLocationLabel->text()
- << ' ' << m_ui->OpenJDKLocationLineEdit->text()
- << ' ' << m_ui->AVDManagerLabel->text()
- << ' ' << m_ui->DataPartitionSizeLable->text()
- << ' ' << m_ui->DataPartitionSizeSpinBox->text();
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
void AndroidSettingsWidget::initGui()
{
m_ui->setupUi(this);
diff --git a/src/plugins/android/androidsettingswidget.h b/src/plugins/android/androidsettingswidget.h
index 145785ab40..fd2aa9dafb 100644
--- a/src/plugins/android/androidsettingswidget.h
+++ b/src/plugins/android/androidsettingswidget.h
@@ -66,11 +66,10 @@ class AndroidSettingsWidget : public QWidget
Q_OBJECT
public:
// Todo: This would be so much simpler if it just used Utils::PathChooser!!!
- AndroidSettingsWidget(QWidget *parent);
+ AndroidSettingsWidget(QWidget *parent = 0);
~AndroidSettingsWidget();
void saveSettings(bool saveNow = false);
- QString searchKeywords() const;
private slots:
void sdkLocationEditingFinished();
diff --git a/src/plugins/android/androidsettingswidget.ui b/src/plugins/android/androidsettingswidget.ui
index 4c4c1d8bd0..985ccde98c 100644
--- a/src/plugins/android/androidsettingswidget.ui
+++ b/src/plugins/android/androidsettingswidget.ui
@@ -214,7 +214,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Ant location:</string>
+ <string>Ant executable:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -323,7 +323,7 @@
<item>
<widget class="QPushButton" name="manageAVDPushButton">
<property name="text">
- <string>Start Android AVD Manager</string>
+ <string>Start AVD Manager</string>
</property>
</widget>
</item>
diff --git a/src/plugins/android/javaparser.cpp b/src/plugins/android/javaparser.cpp
index 6f8183d715..a91110b34a 100644
--- a/src/plugins/android/javaparser.cpp
+++ b/src/plugins/android/javaparser.cpp
@@ -31,6 +31,7 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/task.h>
+#include <QFileInfo>
using namespace Android::Internal;
using namespace ProjectExplorer;
@@ -56,6 +57,16 @@ void JavaParser::setProjectFileList(const QStringList &fileList)
m_fileList = fileList;
}
+void JavaParser::setBuildDirectory(const Utils::FileName &buildDirectory)
+{
+ m_buildDirectory = buildDirectory;
+}
+
+void JavaParser::setSourceDirectory(const Utils::FileName &sourceDirectory)
+{
+ m_sourceDirectory = sourceDirectory;
+}
+
void JavaParser::parse(const QString &line)
{
if (m_javaRegExp.indexIn(line) > -1) {
@@ -63,16 +74,24 @@ void JavaParser::parse(const QString &line)
int lineno = m_javaRegExp.cap(3).toInt(&ok);
if (!ok)
lineno = -1;
- QString file = m_javaRegExp.cap(2);
- for (int i = 0; i < m_fileList.size(); i++)
- if (m_fileList[i].endsWith(file)) {
- file = m_fileList[i];
- break;
- }
+ Utils::FileName file = Utils::FileName::fromUserInput(m_javaRegExp.cap(2));
+ if (file.isChildOf(m_buildDirectory)) {
+ Utils::FileName relativePath = file.relativeChildPath(m_buildDirectory);
+ file = m_sourceDirectory;
+ file.appendPath(relativePath.toString());
+ }
+
+ if (file.toFileInfo().isRelative()) {
+ for (int i = 0; i < m_fileList.size(); i++)
+ if (m_fileList[i].endsWith(file.toString())) {
+ file = Utils::FileName::fromString(m_fileList[i]);
+ break;
+ }
+ }
Task task(Task::Error,
m_javaRegExp.cap(4).trimmed(),
- Utils::FileName::fromString(file) /* filename */,
+ file /* filename */,
lineno,
Constants::TASK_CATEGORY_COMPILE);
emit addTask(task);
diff --git a/src/plugins/android/javaparser.h b/src/plugins/android/javaparser.h
index 90ae8e8b91..55ea992cfc 100644
--- a/src/plugins/android/javaparser.h
+++ b/src/plugins/android/javaparser.h
@@ -31,6 +31,7 @@
#define JAVAPARSER_H
#include <projectexplorer/ioutputparser.h>
+#include <utils/fileutils.h>
namespace Android {
namespace Internal {
@@ -45,11 +46,16 @@ public:
void stdError(const QString &line);
void setProjectFileList(const QStringList &fileList);
+ void setBuildDirectory(const Utils::FileName &buildDirectory);
+ void setSourceDirectory(const Utils::FileName &sourceDirectory);
+
private:
void parse(const QString &line);
QRegExp m_javaRegExp;
QStringList m_fileList;
+ Utils::FileName m_sourceDirectory;
+ Utils::FileName m_buildDirectory;
};
} // namespace Internal
diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
index 8877a661f6..9f86d71425 100644
--- a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
+++ b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
@@ -78,6 +78,7 @@ AutotoolsProject::AutotoolsProject(AutotoolsManager *manager, const QString &fil
m_watchedFiles(),
m_makefileParserThread(0)
{
+ setId(Constants::AUTOTOOLS_PROJECT_ID);
setProjectContext(Core::Context(Constants::PROJECT_CONTEXT));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX));
@@ -108,11 +109,6 @@ QString AutotoolsProject::displayName() const
return m_projectName;
}
-Core::Id AutotoolsProject::id() const
-{
- return Core::Id(Constants::AUTOTOOLS_PROJECT_ID);
-}
-
Core::IDocument *AutotoolsProject::document() const
{
return m_file;
@@ -437,7 +433,7 @@ void AutotoolsProject::updateCppCodeModel()
part->files << CppTools::ProjectFile(file, CppTools::ProjectFile::CXXSource);
part->includePaths += m_makefileParserThread->includePaths();
- part->defines += m_makefileParserThread->defines();
+ part->projectDefines += m_makefileParserThread->defines();
pinfo.appendProjectPart(part);
modelManager->updateProjectInfo(pinfo);
diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.h b/src/plugins/autotoolsprojectmanager/autotoolsproject.h
index 862e1204d7..2ba726f6ef 100644
--- a/src/plugins/autotoolsprojectmanager/autotoolsproject.h
+++ b/src/plugins/autotoolsprojectmanager/autotoolsproject.h
@@ -73,7 +73,6 @@ public:
~AutotoolsProject();
QString displayName() const;
- Core::Id id() const;
Core::IDocument *document() const;
ProjectExplorer::IProjectManager *projectManager() const;
ProjectExplorer::ProjectNode *rootProjectNode() const;
diff --git a/src/plugins/bazaar/bazaar.pro b/src/plugins/bazaar/bazaar.pro
index 06259346df..f3a266221b 100644
--- a/src/plugins/bazaar/bazaar.pro
+++ b/src/plugins/bazaar/bazaar.pro
@@ -13,7 +13,8 @@ SOURCES += \
branchinfo.cpp \
clonewizardpage.cpp \
clonewizard.cpp \
- cloneoptionspanel.cpp
+ cloneoptionspanel.cpp \
+ uncommitdialog.cpp
HEADERS += \
bazaarclient.h \
constants.h \
@@ -29,11 +30,13 @@ HEADERS += \
branchinfo.h \
clonewizard.h \
clonewizardpage.h \
- cloneoptionspanel.h
+ cloneoptionspanel.h \
+ uncommitdialog.h
FORMS += \
optionspage.ui \
revertdialog.ui \
bazaarcommitpanel.ui \
pullorpushdialog.ui \
- cloneoptionspanel.ui
+ cloneoptionspanel.ui \
+ uncommitdialog.ui
RESOURCES += bazaar.qrc
diff --git a/src/plugins/bazaar/bazaar.qbs b/src/plugins/bazaar/bazaar.qbs
index 8a5791e6be..7ecf5b8b0f 100644
--- a/src/plugins/bazaar/bazaar.qbs
+++ b/src/plugins/bazaar/bazaar.qbs
@@ -8,10 +8,7 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
Depends { name: "TextEditor" }
- Depends { name: "Find" }
Depends { name: "VcsBase" }
- Depends { name: "Locator" }
-
files: [
"annotationhighlighter.cpp",
@@ -49,6 +46,9 @@ QtcPlugin {
"pullorpushdialog.h",
"pullorpushdialog.ui",
"revertdialog.ui",
+ "uncommitdialog.cpp",
+ "uncommitdialog.h",
+ "uncommitdialog.ui",
"images/bazaar.png",
]
}
diff --git a/src/plugins/bazaar/bazaar_dependencies.pri b/src/plugins/bazaar/bazaar_dependencies.pri
index a7c268a0d7..1009c58f69 100644
--- a/src/plugins/bazaar/bazaar_dependencies.pri
+++ b/src/plugins/bazaar/bazaar_dependencies.pri
@@ -2,7 +2,6 @@ QTC_PLUGIN_NAME = Bazaar
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
- locator \
texteditor \
coreplugin \
vcsbase
diff --git a/src/plugins/bazaar/bazaarclient.cpp b/src/plugins/bazaar/bazaarclient.cpp
index d7af1e4e73..943da0fdb8 100644
--- a/src/plugins/bazaar/bazaarclient.cpp
+++ b/src/plugins/bazaar/bazaarclient.cpp
@@ -30,6 +30,7 @@
#include "constants.h"
#include <vcsbase/vcsbaseplugin.h>
+#include <vcsbase/vcsbaseoutputwindow.h>
#include <vcsbase/vcsbaseeditorparameterwidget.h>
#include <utils/synchronousprocess.h>
@@ -102,6 +103,24 @@ BranchInfo BazaarClient::synchronousBranchQuery(const QString &repositoryRoot) c
return BranchInfo(repositoryRoot, false);
}
+//! Removes the last committed revision(s)
+bool BazaarClient::synchronousUncommit(const QString &workingDir,
+ const QString &revision,
+ const QStringList &extraOptions)
+{
+ QStringList args;
+ args << QLatin1String("uncommit")
+ << QLatin1String("--force") // Say yes to all questions
+ << QLatin1String("--verbose") // Will print out what is being removed
+ << revisionSpec(revision)
+ << extraOptions;
+ QByteArray stdOut;
+ const bool success = vcsFullySynchronousExec(workingDir, args, &stdOut);
+ if (!stdOut.isEmpty())
+ VcsBase::VcsBaseOutputWindow::instance()->append(QString::fromUtf8(stdOut));
+ return success;
+}
+
void BazaarClient::commit(const QString &repositoryRoot, const QStringList &files,
const QString &commitMessageFile, const QStringList &extraOptions)
{
diff --git a/src/plugins/bazaar/bazaarclient.h b/src/plugins/bazaar/bazaarclient.h
index 1612034989..b0dc2d5bae 100644
--- a/src/plugins/bazaar/bazaarclient.h
+++ b/src/plugins/bazaar/bazaarclient.h
@@ -49,6 +49,9 @@ public:
bool synchronousSetUserId();
BranchInfo synchronousBranchQuery(const QString &repositoryRoot) const;
+ bool synchronousUncommit(const QString &workingDir,
+ const QString& revision = QString(),
+ const QStringList &extraOptions = QStringList());
void commit(const QString &repositoryRoot, const QStringList &files,
const QString &commitMessageFile, const QStringList &extraOptions = QStringList());
void annotate(const QString &workingDir, const QString &file,
diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp
index 3e7f238ee1..9479fb7496 100644
--- a/src/plugins/bazaar/bazaarplugin.cpp
+++ b/src/plugins/bazaar/bazaarplugin.cpp
@@ -34,6 +34,7 @@
#include "bazaarcommitwidget.h"
#include "bazaareditor.h"
#include "pullorpushdialog.h"
+#include "uncommitdialog.h"
#include "commiteditor.h"
#include "clonewizard.h"
@@ -47,8 +48,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/editormanager.h>
-
-#include <locator/commandlocator.h>
+#include <coreplugin/locator/commandlocator.h>
#include <utils/parameteraction.h>
#include <utils/qtcassert.h>
@@ -148,7 +148,7 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag
addAutoReleasedObject(new CloneWizard);
const QString prefix = QLatin1String("bzr");
- m_commandLocator = new Locator::CommandLocator("Bazaar", prefix, prefix);
+ m_commandLocator = new Core::CommandLocator("Bazaar", prefix, prefix);
addAutoReleasedObject(m_commandLocator);
createMenu();
@@ -421,6 +421,13 @@ void BazaarPlugin::createRepositoryActions(const Core::Context &context)
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
+ action = new QAction(tr("Uncommit..."), this);
+ m_repositoryActionList.append(action);
+ command = Core::ActionManager::registerAction(action, Core::Id(Constants::UNCOMMIT), context);
+ connect(action, SIGNAL(triggered()), this, SLOT(uncommit()));
+ m_bazaarContainer->addAction(command);
+ m_commandLocator->appendCommand(command);
+
QAction *createRepositoryAction = new QAction(tr("Create Repository..."), this);
command = Core::ActionManager::registerAction(createRepositoryAction, Core::Id(Constants::CREATE_REPOSITORY), context);
connect(createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository()));
@@ -640,6 +647,16 @@ void BazaarPlugin::commitFromEditor()
Core::EditorManager::closeEditor();
}
+void BazaarPlugin::uncommit()
+{
+ const VcsBase::VcsBasePluginState state = currentState();
+ QTC_ASSERT(state.hasTopLevel(), return);
+
+ UnCommitDialog dialog;
+ if (dialog.exec() == QDialog::Accepted)
+ m_client->synchronousUncommit(state.topLevel(), dialog.revision(), dialog.extraOptions());
+}
+
bool BazaarPlugin::submitEditorAboutToClose()
{
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor());
diff --git a/src/plugins/bazaar/bazaarplugin.h b/src/plugins/bazaar/bazaarplugin.h
index 955795dd3d..7a2ee3c181 100644
--- a/src/plugins/bazaar/bazaarplugin.h
+++ b/src/plugins/bazaar/bazaarplugin.h
@@ -42,6 +42,7 @@ QT_END_NAMESPACE
namespace Core {
class ActionManager;
class ActionContainer;
+class CommandLocator;
class Id;
class IVersionControl;
class IEditorFactory;
@@ -56,10 +57,6 @@ namespace VcsBase {
class VcsBaseSubmitEditor;
}
-namespace Locator {
-class CommandLocator;
-}
-
namespace Bazaar {
namespace Internal {
@@ -106,6 +103,7 @@ private slots:
void commit();
void showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusItem> &status);
void commitFromEditor();
+ void uncommit();
void diffFromEditorSelected(const QStringList &files);
#ifdef WITH_TESTS
void testDiffFileResolving_data();
@@ -131,7 +129,7 @@ private:
OptionsPage *m_optionsPage;
BazaarClient *m_client;
- Locator::CommandLocator *m_commandLocator;
+ Core::CommandLocator *m_commandLocator;
Core::ActionContainer *m_bazaarContainer;
QList<QAction *> m_repositoryActionList;
diff --git a/src/plugins/bazaar/constants.h b/src/plugins/bazaar/constants.h
index 5848733672..54e9505004 100644
--- a/src/plugins/bazaar/constants.h
+++ b/src/plugins/bazaar/constants.h
@@ -87,6 +87,7 @@ const char PULL[] = "Bazaar.Action.Pull";
const char PUSH[] = "Bazaar.Action.Push";
const char UPDATE[] = "Bazaar.Action.Update";
const char COMMIT[] = "Bazaar.Action.Commit";
+const char UNCOMMIT[] = "Bazaar.Action.UnCommit";
const char CREATE_REPOSITORY[] = "Bazaar.Action.CreateRepository";
// Submit editor actions
diff --git a/src/plugins/bazaar/optionspage.cpp b/src/plugins/bazaar/optionspage.cpp
index 376a7b9871..e58e30b810 100644
--- a/src/plugins/bazaar/optionspage.cpp
+++ b/src/plugins/bazaar/optionspage.cpp
@@ -44,6 +44,7 @@ OptionsPageWidget::OptionsPageWidget(QWidget *parent)
m_ui.setupUi(this);
m_ui.commandChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_ui.commandChooser->setPromptDialogTitle(tr("Bazaar Command"));
+ m_ui.commandChooser->setHistoryCompleter(QLatin1String("Bazaar.Command.History"));
}
BazaarSettings OptionsPageWidget::settings() const
@@ -66,37 +67,17 @@ void OptionsPageWidget::setSettings(const BazaarSettings &s)
m_ui.timeout->setValue(s.intValue(BazaarSettings::timeoutKey));
}
-QString OptionsPageWidget::searchKeywords() const
-{
- QString rc;
- QLatin1Char sep(' ');
- QTextStream(&rc)
- << sep << m_ui.configGroupBox->title()
- << sep << m_ui.commandLabel->text()
- << sep << m_ui.userGroupBox->title()
- << sep << m_ui.defaultUsernameLabel->text()
- << sep << m_ui.defaultEmailLabel->text()
- << sep << m_ui.miscGroupBox->title()
- << sep << m_ui.showLogEntriesLabel->text()
- << sep << m_ui.timeoutSecondsLabel->text()
- ;
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
OptionsPage::OptionsPage()
{
setId(VcsBase::Constants::VCS_ID_BAZAAR);
setDisplayName(tr("Bazaar"));
}
-QWidget *OptionsPage::createPage(QWidget *parent)
+QWidget *OptionsPage::widget()
{
if (!m_optionsPageWidget)
- m_optionsPageWidget = new OptionsPageWidget(parent);
+ m_optionsPageWidget = new OptionsPageWidget;
m_optionsPageWidget->setSettings(BazaarPlugin::instance()->settings());
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_optionsPageWidget->searchKeywords();
return m_optionsPageWidget;
}
@@ -113,8 +94,3 @@ void OptionsPage::apply()
emit settingsChanged();
}
}
-
-bool OptionsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
diff --git a/src/plugins/bazaar/optionspage.h b/src/plugins/bazaar/optionspage.h
index fe87c38150..c0493480d8 100644
--- a/src/plugins/bazaar/optionspage.h
+++ b/src/plugins/bazaar/optionspage.h
@@ -50,7 +50,6 @@ public:
BazaarSettings settings() const;
void setSettings(const BazaarSettings &s);
- QString searchKeywords() const;
private:
Ui::OptionsPage m_ui;
@@ -64,16 +63,14 @@ class OptionsPage : public VcsBase::VcsBaseOptionsPage
public:
OptionsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish() { }
- bool matches(const QString &s) const;
signals:
void settingsChanged();
private:
- QString m_searchKeywords;
QPointer<OptionsPageWidget> m_optionsPageWidget;
};
diff --git a/src/plugins/bazaar/uncommitdialog.cpp b/src/plugins/bazaar/uncommitdialog.cpp
new file mode 100644
index 0000000000..2e9f665a4d
--- /dev/null
+++ b/src/plugins/bazaar/uncommitdialog.cpp
@@ -0,0 +1,83 @@
+/**************************************************************************
+**
+** Copyright (c) 2014 Hugues Delorme
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+#include "uncommitdialog.h"
+
+#include "ui_uncommitdialog.h"
+#include "bazaarclient.h"
+#include "bazaarplugin.h"
+#include <utils/qtcassert.h>
+
+#include <QPushButton>
+
+namespace Bazaar {
+namespace Internal {
+
+UnCommitDialog::UnCommitDialog(QWidget *parent)
+ : QDialog(parent),
+ m_ui(new Ui::UnCommitDialog)
+{
+ m_ui->setupUi(this);
+
+ QPushButton* dryRunBtn = new QPushButton(tr("Dry Run"));
+ dryRunBtn->setToolTip(tr("Test the outcome of removing the last committed revision, without actually removing anything."));
+ m_ui->buttonBox->addButton(dryRunBtn, QDialogButtonBox::ApplyRole);
+ connect(dryRunBtn, SIGNAL(clicked()), this, SLOT(dryRun()));
+}
+
+UnCommitDialog::~UnCommitDialog()
+{
+ delete m_ui;
+}
+
+QStringList UnCommitDialog::extraOptions() const
+{
+ QStringList opts;
+ if (m_ui->keepTagsCheckBox->isChecked())
+ opts += QLatin1String("--keep-tags");
+ if (m_ui->localCheckBox->isChecked())
+ opts += QLatin1String("--local");
+ return opts;
+}
+
+QString UnCommitDialog::revision() const
+{
+ return m_ui->revisionLineEdit->text().trimmed();
+}
+
+void UnCommitDialog::dryRun()
+{
+ BazaarPlugin* bzrPlugin = BazaarPlugin::instance();
+ QTC_ASSERT(bzrPlugin->currentState().hasTopLevel(), return);
+ bzrPlugin->client()->synchronousUncommit(bzrPlugin->currentState().topLevel(),
+ revision(),
+ extraOptions() << QLatin1String("--dry-run"));
+}
+
+} // namespace Internal
+} // namespace Bazaar
diff --git a/src/plugins/bazaar/uncommitdialog.h b/src/plugins/bazaar/uncommitdialog.h
new file mode 100644
index 0000000000..865f1b02a1
--- /dev/null
+++ b/src/plugins/bazaar/uncommitdialog.h
@@ -0,0 +1,62 @@
+/**************************************************************************
+**
+** Copyright (c) 2014 Hugues Delorme
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+#ifndef UNCOMMITDIALOG_H
+#define UNCOMMITDIALOG_H
+
+#include <QDialog>
+
+namespace Bazaar {
+namespace Internal {
+
+namespace Ui {
+class UnCommitDialog;
+}
+
+class UnCommitDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit UnCommitDialog(QWidget *parent = 0);
+ ~UnCommitDialog();
+
+ QStringList extraOptions() const;
+ QString revision() const;
+
+private slots:
+ void dryRun();
+
+private:
+ Ui::UnCommitDialog *m_ui;
+};
+
+} // namespace Internal
+} // namespace Bazaar
+
+#endif // UNCOMMITDIALOG_H
diff --git a/src/plugins/bazaar/uncommitdialog.ui b/src/plugins/bazaar/uncommitdialog.ui
new file mode 100644
index 0000000000..f08a8c8a7a
--- /dev/null
+++ b/src/plugins/bazaar/uncommitdialog.ui
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Bazaar::Internal::UnCommitDialog</class>
+ <widget class="QDialog" name="Bazaar::Internal::UnCommitDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>412</width>
+ <height>124</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Uncommit</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QCheckBox" name="keepTagsCheckBox">
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="text">
+ <string>Keep tags that point to removed revisions</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QCheckBox" name="localCheckBox">
+ <property name="text">
+ <string>Only remove the commits from the local branch when in a checkout</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="revisionLabel">
+ <property name="text">
+ <string>Revision:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="revisionLineEdit">
+ <property name="toolTip">
+ <string>If a revision is specified, uncommits revisions to leave the branch at the specified revision.
+For example, &quot;Revision: 15&quot; will leave the branch at revision 15.</string>
+ </property>
+ <property name="placeholderText">
+ <string>Last committed</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ <zorder>buttonBox</zorder>
+ <zorder>revisionLabel</zorder>
+ <zorder>revisionLineEdit</zorder>
+ <zorder>keepTagsCheckBox</zorder>
+ <zorder>localCheckBox</zorder>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>Bazaar::Internal::UnCommitDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>Bazaar::Internal::UnCommitDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/plugins/bineditor/bineditor.qbs b/src/plugins/bineditor/bineditor.qbs
index f18676ea80..a63bcc183f 100644
--- a/src/plugins/bineditor/bineditor.qbs
+++ b/src/plugins/bineditor/bineditor.qbs
@@ -8,7 +8,6 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
Depends { name: "TextEditor" }
- Depends { name: "Find" }
files: [
"bineditor.cpp",
diff --git a/src/plugins/bineditor/bineditor_dependencies.pri b/src/plugins/bineditor/bineditor_dependencies.pri
index cbc6861ca1..825c980e92 100644
--- a/src/plugins/bineditor/bineditor_dependencies.pri
+++ b/src/plugins/bineditor/bineditor_dependencies.pri
@@ -2,6 +2,5 @@ QTC_PLUGIN_NAME = BinEditor
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
- find \
texteditor \
coreplugin
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp
index 7f853340e2..62a233706e 100644
--- a/src/plugins/bineditor/bineditorplugin.cpp
+++ b/src/plugins/bineditor/bineditorplugin.cpp
@@ -53,18 +53,19 @@
#include <coreplugin/id.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
+#include <coreplugin/find/ifindsupport.h>
#include <coreplugin/idocument.h>
#include <coreplugin/mimedatabase.h>
#include <extensionsystem/pluginmanager.h>
-#include <find/ifindsupport.h>
#include <utils/reloadpromptutils.h>
#include <utils/qtcassert.h>
+using namespace Core;
using namespace BINEditor;
using namespace BINEditor::Internal;
-class BinEditorFind : public Find::IFindSupport
+class BinEditorFind : public Core::IFindSupport
{
Q_OBJECT
@@ -80,9 +81,9 @@ public:
QString currentFindString() const { return QString(); }
QString completedFindString() const { return QString(); }
- Find::FindFlags supportedFindFlags() const
+ Core::FindFlags supportedFindFlags() const
{
- return Find::FindBackward | Find::FindCaseSensitively;
+ return FindBackward | FindCaseSensitively;
}
void resetIncrementalSearch()
@@ -91,9 +92,9 @@ public:
m_incrementalWrappedState = false;
}
- virtual void highlightAll(const QString &txt, Find::FindFlags findFlags)
+ virtual void highlightAll(const QString &txt, Core::FindFlags findFlags)
{
- m_widget->highlightSearchResults(txt.toLatin1(), Find::textDocumentFlagsForFindFlags(findFlags));
+ m_widget->highlightSearchResults(txt.toLatin1(), textDocumentFlagsForFindFlags(findFlags));
}
void clearResults()
@@ -101,7 +102,7 @@ public:
m_widget->highlightSearchResults(QByteArray());
}
- int find(const QByteArray &pattern, int pos, Find::FindFlags findFlags, bool *wrapped)
+ int find(const QByteArray &pattern, int pos, Core::FindFlags findFlags, bool *wrapped)
{
if (wrapped)
*wrapped = false;
@@ -110,10 +111,10 @@ public:
return pos;
}
- int res = m_widget->find(pattern, pos, Find::textDocumentFlagsForFindFlags(findFlags));
+ int res = m_widget->find(pattern, pos, textDocumentFlagsForFindFlags(findFlags));
if (res < 0) {
- pos = (findFlags & Find::FindBackward) ? -1 : 0;
- res = m_widget->find(pattern, pos, Find::textDocumentFlagsForFindFlags(findFlags));
+ pos = (findFlags & FindBackward) ? -1 : 0;
+ res = m_widget->find(pattern, pos, textDocumentFlagsForFindFlags(findFlags));
if (res < 0)
return res;
if (wrapped)
@@ -122,7 +123,7 @@ public:
return res;
}
- Result findIncremental(const QString &txt, Find::FindFlags findFlags) {
+ Result findIncremental(const QString &txt, Core::FindFlags findFlags) {
QByteArray pattern = txt.toLatin1();
if (pattern != m_lastPattern)
resetIncrementalSearch(); // Because we don't search for nibbles.
@@ -140,13 +141,13 @@ public:
Result result;
if (found >= 0) {
result = Found;
- m_widget->highlightSearchResults(pattern, Find::textDocumentFlagsForFindFlags(findFlags));
+ m_widget->highlightSearchResults(pattern, textDocumentFlagsForFindFlags(findFlags));
m_contPos = -1;
} else {
if (found == -2) {
result = NotYetFound;
m_contPos +=
- findFlags & Find::FindBackward
+ findFlags & FindBackward
? -BinEditorWidget::SearchStride : BinEditorWidget::SearchStride;
} else {
result = NotFound;
@@ -157,12 +158,12 @@ public:
return result;
}
- Result findStep(const QString &txt, Find::FindFlags findFlags) {
+ Result findStep(const QString &txt, Core::FindFlags findFlags) {
QByteArray pattern = txt.toLatin1();
bool wasReset = (m_incrementalStartPos < 0);
if (m_contPos == -1) {
m_contPos = m_widget->cursorPosition();
- if (findFlags & Find::FindBackward)
+ if (findFlags & FindBackward)
m_contPos = m_widget->selectionStart()-1;
}
bool wrapped;
@@ -175,10 +176,10 @@ public:
m_incrementalStartPos = found;
m_contPos = -1;
if (wasReset)
- m_widget->highlightSearchResults(pattern, Find::textDocumentFlagsForFindFlags(findFlags));
+ m_widget->highlightSearchResults(pattern, textDocumentFlagsForFindFlags(findFlags));
} else if (found == -2) {
result = NotYetFound;
- m_contPos += findFlags & Find::FindBackward
+ m_contPos += findFlags & FindBackward
? -BinEditorWidget::SearchStride : BinEditorWidget::SearchStride;
} else {
result = NotFound;
@@ -213,7 +214,7 @@ public:
~BinEditorDocument() {}
QString mimeType() const {
- return QLatin1String(Constants::C_BINEDITOR_MIMETYPE);
+ return QLatin1String(BINEditor::Constants::C_BINEDITOR_MIMETYPE);
}
bool setContents(const QByteArray &contents)
@@ -340,7 +341,7 @@ public:
m_widget = widget;
m_file = new BinEditorDocument(m_widget);
m_context.add(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
- m_context.add(Constants::C_BINEDITOR);
+ m_context.add(BINEditor::Constants::C_BINEDITOR);
m_addressEdit = new QLineEdit;
QRegExpValidator * const addressValidator
= new QRegExpValidator(QRegExp(QLatin1String("[0-9a-fA-F]{1,16}")),
@@ -409,9 +410,9 @@ BinEditorFactory::BinEditorFactory(BinEditorPlugin *owner) :
addMimeType(Constants::C_BINEDITOR_MIMETYPE);
}
-Core::IEditor *BinEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *BinEditorFactory::createEditor()
{
- BinEditorWidget *widget = new BinEditorWidget(parent);
+ BinEditorWidget *widget = new BinEditorWidget();
BinEditor *editor = new BinEditor(widget);
m_owner->initializeEditor(widget);
diff --git a/src/plugins/bineditor/bineditorplugin.h b/src/plugins/bineditor/bineditorplugin.h
index 66c8adf7ed..c1b0e8fd99 100644
--- a/src/plugins/bineditor/bineditorplugin.h
+++ b/src/plugins/bineditor/bineditorplugin.h
@@ -102,7 +102,7 @@ class BinEditorFactory : public Core::IEditorFactory
public:
explicit BinEditorFactory(BinEditorPlugin *owner);
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
private:
BinEditorPlugin *m_owner;
diff --git a/src/plugins/bookmarks/bookmarks.qbs b/src/plugins/bookmarks/bookmarks.qbs
index 4264356767..b92b06d072 100644
--- a/src/plugins/bookmarks/bookmarks.qbs
+++ b/src/plugins/bookmarks/bookmarks.qbs
@@ -9,8 +9,6 @@ QtcPlugin {
Depends { name: "Core" }
Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" }
- Depends { name: "Find" }
- Depends { name: "Locator" }
files: [
"bookmark.cpp",
diff --git a/src/plugins/clangcodemodel/ClangCodeModel.pluginspec.in b/src/plugins/clangcodemodel/ClangCodeModel.pluginspec.in
new file mode 100644
index 0000000000..b4161ae8c3
--- /dev/null
+++ b/src/plugins/clangcodemodel/ClangCodeModel.pluginspec.in
@@ -0,0 +1,21 @@
+<plugin name=\"ClangCodeModel\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_VERSION\" experimental=\"true\">
+ <vendor>Digia Plc</vendor>
+ <copyright>(C) 2014 Digia Plc</copyright>
+ <license>
+Commercial Usage
+
+Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
+
+GNU Lesser General Public License Usage
+
+Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. Please review the following information to ensure the GNU Lesser General Public License version 2.1 requirements will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ </license>
+ <category>C++</category>
+ <description>Clang Code Model plugin.</description>
+ <url>http://www.qt-project.org</url>
+ <dependencyList>
+ <dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
+ <dependency name=\"CppTools\" version=\"$$QTCREATOR_VERSION\"/>
+ <dependency name=\"TextEditor\" version=\"$$QTCREATOR_VERSION\"/>
+ </dependencyList>
+</plugin>
diff --git a/src/plugins/clangcodemodel/README b/src/plugins/clangcodemodel/README
new file mode 100644
index 0000000000..8612113270
--- /dev/null
+++ b/src/plugins/clangcodemodel/README
@@ -0,0 +1,65 @@
+The ClangCodeModel plugin
+=========================
+
+The ClangCodeModel plugin integrates the clang frontend into Qt Creator. Clang
+is "a C language family frontend for LLVM". You can find more information at
+http://clang.llvm.org/.
+
+At the time of writing the plugin can replace the following functionality of
+the built-in code model:
+ * Highlighting
+ * Completion
+
+All other functionality relies on the built-in code model (indexing, quick
+fixes, follow symbol, find usages, ...).
+
+Setup
+=====
+
+Compile the plugin
+------------------
+
+1. Get libclang
+
+You need to have libclang (and thus llvm) installed on your system. Either
+build llvm/clang yourself [1], install some ready-to-use package [2] or use the
+package manager of your system.
+
+ [1] http://clang.llvm.org/get_started.html
+ See http://llvm.org/docs/GettingStarted.html#git-mirror for git mirrors.
+ [2] http://llvm.org/releases/ or http://llvm.org/builds/
+
+If you are building llvm/clang yourself, make sure to build it in release mode.
+
+2. Set LLVM_INSTALL_DIR and (re)build Qt Creator
+
+Point the LLVM_INSTALL_DIR variable to the build/installation directory of
+llvm, e.g.:
+
+ Installed via package manager on GNU/Linux:
+ LLVM_INSTALL_DIR=/usr/lib/llvm-3.4
+ Manually build on Unix in release mode:
+ LLVM_INSTALL_DIR=$HOME/llvm-build/Release+Asserts
+ Installed a snapshot on Windows:
+ LLVM_INSTALL_DIR=C:\llvm
+
+Set the variable either as part of the build environment or pass it directly to
+qmake and rebuild Qt Creator. Watch out for a message like
+
+ Project MESSAGE: Building ClangCodeModel plugin with Clang from /usr/lib/llvm-3.4
+ Project MESSAGE: INCLUDEPATH += /usr/lib/llvm-3.4/include
+ Project MESSAGE: LIBS += -L/usr/lib/llvm-3.4/lib -lclang
+
+This indicates that the ClangCodeModel plugin will be build.
+
+Enable the plugin
+-----------------
+
+Enable the "ClangCodeModel" plugin in the dialog "Menu: Help -> About Plugins"
+and restart Qt Creator.
+
+Select the file types you want to use the ClangCodeModel for in "Menu: Tools ->
+Options -> C++ -> Tab: Code Model". For the next opened file matching the
+selected file types the ClangCodeModel will be used (see limitations at the
+start of this README).
+
diff --git a/src/plugins/find/find_global.h b/src/plugins/clangcodemodel/clang_global.h
index 68d06d5145..199b62aaf5 100644
--- a/src/plugins/find/find_global.h
+++ b/src/plugins/clangcodemodel/clang_global.h
@@ -26,15 +26,17 @@
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
-#ifndef FIND_GLOBAL_H
-#define FIND_GLOBAL_H
+
+#ifndef CLANG_GLOBAL_H
+#define CLANG_GLOBAL_H
#include <qglobal.h>
-#if defined(FIND_LIBRARY)
-# define FIND_EXPORT Q_DECL_EXPORT
+#if defined(CLANGCODEMODEL_LIBRARY)
+# define CLANG_EXPORT Q_DECL_EXPORT
#else
-# define FIND_EXPORT Q_DECL_IMPORT
+# define CLANG_EXPORT Q_DECL_IMPORT
#endif
-#endif // FIND_GLOBAL_H
+
+#endif // CLANG_GLOBAL_H
diff --git a/src/plugins/clangcodemodel/clang_installation.pri b/src/plugins/clangcodemodel/clang_installation.pri
new file mode 100644
index 0000000000..5cc4638738
--- /dev/null
+++ b/src/plugins/clangcodemodel/clang_installation.pri
@@ -0,0 +1,89 @@
+isEmpty(LLVM_INSTALL_DIR):LLVM_INSTALL_DIR=$$(LLVM_INSTALL_DIR)
+
+DEFINES += CLANG_COMPLETION
+DEFINES += CLANG_HIGHLIGHTING
+#DEFINES += CLANG_INDEXING
+
+defineReplace(findLLVMConfig) {
+ LLVM_CONFIG_VARIANTS = \
+ llvm-config llvm-config-3.2 llvm-config-3.3 llvm-config-3.4 \
+ llvm-config-3.5 llvm-config-3.6 llvm-config-4.0 llvm-config-4.1
+
+ # Prefer llvm-config* from LLVM_INSTALL_DIR
+ !isEmpty(LLVM_INSTALL_DIR) {
+ for (variant, LLVM_CONFIG_VARIANTS) {
+ variant=$$LLVM_INSTALL_DIR/bin/$$variant
+ exists($$variant) {
+ return($$variant)
+ }
+ }
+ }
+
+ # Find llvm-config* in PATH
+ ENV_PATH = $$(PATH)
+ win32 {
+ ENV_PATH = $$split($$ENV_PATH, ;)
+ } else {
+ ENV_PATH = $$split($$ENV_PATH, :)
+ }
+ for (variant, LLVM_CONFIG_VARIANTS) {
+ for (path, ENV_PATH) {
+ subvariant = $$path/$$variant
+ exists($$subvariant) {
+ return($$subvariant)
+ }
+ }
+ }
+
+ # Fallback
+ return(llvm-config)
+}
+
+win32 {
+ LLVM_INCLUDEPATH = $$LLVM_INSTALL_DIR/include
+ exists ($${LLVM_INSTALL_DIR}/lib/clang.*) {
+ CLANG_LIB = clang
+ } else {
+ exists ($${LLVM_INSTALL_DIR}/lib/libclang.*) {
+ CLANG_LIB = libclang
+ } else {
+ error("Cannot find Clang shared library!")
+ }
+ }
+ LLVM_LIBS = \
+ -L$$LLVM_INSTALL_DIR/bin \
+ -L$$LLVM_INSTALL_DIR/lib \
+ -l$${CLANG_LIB}
+ LLVM_LIBS += -ladvapi32 -lshell32
+}
+
+unix {
+ LLVM_CONFIG = $$findLLVMConfig()
+
+ LLVM_INCLUDEPATH = $$system($$LLVM_CONFIG --includedir)
+ isEmpty(LLVM_INCLUDEPATH):LLVM_INCLUDEPATH=$$LLVM_INSTALL_DIR/include
+ LLVM_LIBDIR = $$system($$LLVM_CONFIG --libdir)
+ isEmpty(LLVM_LIBDIR):LLVM_LIBDIR=$$LLVM_INSTALL_DIR/lib
+
+ exists ($${LLVM_LIBDIR}/libclang.*) {
+ #message("LLVM was build with autotools")
+ CLANG_LIB = clang
+ } else {
+ exists ($${LLVM_LIBDIR}/liblibclang.*) {
+ #message("LLVM was build with CMake")
+ CLANG_LIB = libclang
+ } else {
+ exists ($${LLVM_INSTALL_DIR}/lib/libclang.*) {
+ #message("libclang placed separately from LLVM")
+ CLANG_LIB = clang
+ LLVM_LIBDIR = $${LLVM_INSTALL_DIR}/lib
+ LLVM_INCLUDEPATH=$${LLVM_INSTALL_DIR}/include
+ } else {
+ error("Cannot find Clang shared library!")
+ }
+ }
+ }
+
+ LLVM_LIBS = -L$${LLVM_LIBDIR}
+ LLVM_LIBS += -l$${CLANG_LIB}
+}
diff --git a/src/plugins/clangcodemodel/clangcodemodel.pro b/src/plugins/clangcodemodel/clangcodemodel.pro
new file mode 100644
index 0000000000..28b111b42e
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangcodemodel.pro
@@ -0,0 +1,124 @@
+include(../../qtcreatorplugin.pri)
+include(clang_installation.pri)
+
+message("Building ClangCodeModel plugin with Clang from $$LLVM_INSTALL_DIR")
+message(" INCLUDEPATH += $$LLVM_INCLUDEPATH")
+message(" LIBS += $$LLVM_LIBS")
+
+LIBS += $$LLVM_LIBS
+INCLUDEPATH += $$LLVM_INCLUDEPATH
+DEFINES += CLANGCODEMODEL_LIBRARY
+
+unix:QMAKE_LFLAGS += -Wl,-rpath,\'$$LLVM_LIBDIR\'
+
+contains(DEFINES, CLANG_COMPLETION) {
+ HEADERS += clangcompletion.h clangcompleter.h completionproposalsbuilder.h
+ SOURCES += clangcompletion.cpp clangcompleter.cpp completionproposalsbuilder.cpp
+}
+
+contains(DEFINES, CLANG_HIGHLIGHTING) {
+ HEADERS += cppcreatemarkers.h clanghighlightingsupport.h
+ SOURCES += cppcreatemarkers.cpp clanghighlightingsupport.cpp
+}
+
+HEADERS += clangutils.h \
+ cxprettyprinter.h
+
+SOURCES += clangutils.cpp \
+ cxprettyprinter.cpp
+
+SOURCES += \
+ $$PWD/clangcodemodelplugin.cpp \
+ $$PWD/sourcemarker.cpp \
+ $$PWD/symbol.cpp \
+ $$PWD/sourcelocation.cpp \
+ $$PWD/unit.cpp \
+ $$PWD/utils.cpp \
+ $$PWD/utils_p.cpp \
+ $$PWD/semanticmarker.cpp \
+ $$PWD/diagnostic.cpp \
+ $$PWD/unsavedfiledata.cpp \
+ $$PWD/fastindexer.cpp \
+ $$PWD/pchinfo.cpp \
+ $$PWD/pchmanager.cpp \
+ $$PWD/clangprojectsettings.cpp \
+ $$PWD/clangprojectsettingspropertiespage.cpp \
+ $$PWD/raii/scopedclangoptions.cpp \
+ $$PWD/clangmodelmanagersupport.cpp
+
+HEADERS += \
+ $$PWD/clangcodemodelplugin.h \
+ $$PWD/clang_global.h \
+ $$PWD/sourcemarker.h \
+ $$PWD/constants.h \
+ $$PWD/symbol.h \
+ $$PWD/cxraii.h \
+ $$PWD/sourcelocation.h \
+ $$PWD/unit.h \
+ $$PWD/utils.h \
+ $$PWD/utils_p.h \
+ $$PWD/semanticmarker.h \
+ $$PWD/diagnostic.h \
+ $$PWD/unsavedfiledata.h \
+ $$PWD/fastindexer.h \
+ $$PWD/pchinfo.h \
+ $$PWD/pchmanager.h \
+ $$PWD/clangprojectsettings.h \
+ $$PWD/clangprojectsettingspropertiespage.h \
+ $$PWD/raii/scopedclangoptions.h \
+ $$PWD/clangmodelmanagersupport.h
+
+contains(DEFINES, CLANG_INDEXING) {
+ HEADERS += \
+ $$PWD/clangindexer.h \
+ $$PWD/clangsymbolsearcher.h \
+ $$PWD/index.h \
+ $$PWD/indexer.h
+# $$PWD/dependencygraph.h \
+
+ SOURCES += \
+ $$PWD/clangindexer.cpp \
+ $$PWD/clangsymbolsearcher.cpp \
+ $$PWD/index.cpp \
+ $$PWD/indexer.cpp
+# $$PWD/dependencygraph.cpp \
+}
+
+equals(TEST, 1) {
+ RESOURCES += \
+ $$PWD/test/clang_tests_database.qrc
+
+ HEADERS += \
+ $$PWD/test/completiontesthelper.h
+
+ SOURCES += \
+ $$PWD/test/completiontesthelper.cpp \
+ $$PWD/test/clangcompletion_test.cpp
+
+ OTHER_FILES += \
+ $$PWD/test/cxx_regression_1.cpp \
+ $$PWD/test/cxx_regression_2.cpp \
+ $$PWD/test/cxx_regression_3.cpp \
+ $$PWD/test/cxx_regression_4.cpp \
+ $$PWD/test/cxx_regression_5.cpp \
+ $$PWD/test/cxx_regression_6.cpp \
+ $$PWD/test/cxx_regression_7.cpp \
+ $$PWD/test/cxx_regression_8.cpp \
+ $$PWD/test/cxx_regression_9.cpp \
+ $$PWD/test/cxx_snippets_1.cpp \
+ $$PWD/test/cxx_snippets_2.cpp \
+ $$PWD/test/cxx_snippets_3.cpp \
+ test/cxx_snippets_4.cpp \
+ test/objc_messages_1.mm \
+ test/objc_messages_2.mm \
+ test/objc_messages_3.mm
+}
+
+FORMS += $$PWD/clangprojectsettingspropertiespage.ui
+
+macx {
+ LIBCLANG_VERSION=3.3
+ POSTL = install_name_tool -change "@executable_path/../lib/libclang.$${LIBCLANG_VERSION}.dylib" "$$LLVM_INSTALL_DIR/lib/libclang.$${LIBCLANG_VERSION}.dylib" "\"$${DESTDIR}/lib$${TARGET}.dylib\"" $$escape_expand(\\n\\t)
+ !isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK = $$escape_expand(\\n\\t)$$QMAKE_POST_LINK
+ QMAKE_POST_LINK = $$POSTL $$QMAKE_POST_LINK
+}
diff --git a/src/plugins/clangcodemodel/clangcodemodel.qbs b/src/plugins/clangcodemodel/clangcodemodel.qbs
new file mode 100644
index 0000000000..170b720c4b
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangcodemodel.qbs
@@ -0,0 +1,189 @@
+import qbs
+import qbs.File
+
+QtcPlugin {
+ name: "ClangCodeModel"
+
+ Depends { name: "Qt"; submodules: ["concurrent", "widgets"] }
+ Depends { name: "Core" }
+ Depends { name: "CppTools" }
+ Depends { name: "ProjectExplorer" }
+ Depends { name: "TextEditor" }
+ Depends { name: "Utils" }
+
+ property string llvmInstallDir: qbs.getenv("LLVM_INSTALL_DIR")
+ condition: llvmInstallDir && !llvmInstallDir.isEmpty
+
+ property bool clangCompletion: true
+ property bool clangHighlighting: true
+ property bool clangIndexing: false
+
+ // Not used atm; we just rely on the LLVM_INSTALL_DIR environment variable.
+ property string llvmConfig: {
+ var llvmConfigVariants = [
+ "llvm-config", "llvm-config-3.2", "llvm-config-3.3", "llvm-config-3.4",
+ "llvm-config-3.5", "llvm-config-3.6", "llvm-config-4.0", "llvm-config-4.1"
+ ];
+
+ // Prefer llvm-config* from LLVM_INSTALL_DIR
+ for (var i = 0; i < llvmConfigVariants.length; ++i) {
+ var variant = llvmInstallDir + "/bin/" + llvmConfigVariants[i];
+ if (File.exists(variant))
+ return variant;
+ }
+
+ // Find llvm-config* in PATH
+ var pathListString = qbs.getenv("PATH");
+ var separator = qbs.hostOS.contains("windows") ? ";" : ":";
+ var pathList = pathListString.split(separator);
+ for (var i = 0; i < llvmConfigVariants.length; ++i) {
+ for (var j = 0; j < pathList.length; ++j) {
+ var variant = pathList[j] + "/" + llvmConfigVariants[i];
+ if (File.exists(variant))
+ return variant;
+ }
+ }
+
+ // Fallback
+ return "llvm-config";
+ }
+
+ property string llvmIncludeDir: llvmInstallDir + "/include"
+ cpp.includePaths: base.concat(llvmIncludeDir)
+
+ property stringList llvmLibDirs: {
+ var list = [llvmInstallDir + "/lib"];
+ if (qbs.targetOS.contains("windows"))
+ list.push(llvmInstallDir + "/bin");
+ return list;
+ }
+ cpp.libraryPaths: base.concat(llvmLibDirs)
+ cpp.rpaths: cpp.libraryPaths
+
+ property string llvmLib: "clang"
+ property stringList additionalLibraries: qbs.targetOS.contains("windows")
+ ? ["advapi32", "shell32"] : []
+ cpp.dynamicLibraries: base.concat(llvmLib).concat(additionalLibraries)
+
+ Group {
+ name: "Completion support"
+ condition: product.clangCompletion
+ files: [
+ "clangcompleter.cpp",
+ "clangcompleter.h",
+ "clangcompletion.cpp",
+ "clangcompletion.h",
+ "completionproposalsbuilder.cpp",
+ "completionproposalsbuilder.h",
+ ]
+ }
+
+ Group {
+ name: "Highlighting support"
+ condition: product.clangHighlighting
+ files: [
+ "clanghighlightingsupport.cpp",
+ "clanghighlightingsupport.h",
+ "cppcreatemarkers.cpp",
+ "cppcreatemarkers.h",
+ ]
+ }
+
+ Group {
+ name: "Indexing support"
+ condition: product.clangIndexing
+ files: [
+ "clangindexer.cpp",
+ "clangindexer.h",
+ "clangsymbolsearcher.cpp",
+ "clangsymbolsearcher.h",
+ "index.cpp",
+ "index.h",
+ "indexer.cpp",
+ "indexer.h",
+ // "dependencygraph.h",
+ // "dependencygraph.cpp"
+ ]
+ }
+
+ Group {
+ name: "Tests"
+ condition: project.testsEnabled
+ prefix: "test/"
+ files: [
+ "clang_tests_database.qrc",
+ "clangcompletion_test.cpp",
+ "completiontesthelper.cpp",
+ "completiontesthelper.h",
+ ]
+ }
+
+ Group {
+ name: "Test resources"
+ prefix: "test/"
+ fileTags: "none"
+ files: [
+ "cxx_regression_1.cpp",
+ "cxx_regression_2.cpp",
+ "cxx_regression_3.cpp",
+ "cxx_regression_4.cpp",
+ "cxx_regression_5.cpp",
+ "cxx_regression_6.cpp",
+ "cxx_regression_7.cpp",
+ "cxx_regression_8.cpp",
+ "cxx_regression_9.cpp",
+ "cxx_snippets_1.cpp",
+ "cxx_snippets_2.cpp",
+ "cxx_snippets_3.cpp",
+ "cxx_snippets_4.cpp",
+ "objc_messages_1.mm",
+ "objc_messages_2.mm",
+ "objc_messages_3.mm",
+ ]
+ }
+
+ files: [
+ "clang_global.h",
+ "clangmodelmanagersupport.cpp",
+ "clangmodelmanagersupport.h",
+ "clangcodemodelplugin.cpp",
+ "clangcodemodelplugin.h",
+ "clangprojectsettings.cpp",
+ "clangprojectsettings.h",
+ "clangprojectsettingspropertiespage.cpp",
+ "clangprojectsettingspropertiespage.h",
+ "clangprojectsettingspropertiespage.ui",
+ "clangutils.cpp",
+ "clangutils.h",
+ "constants.h",
+ "cxprettyprinter.cpp",
+ "cxprettyprinter.h",
+ "cxraii.h",
+ "diagnostic.cpp",
+ "diagnostic.h",
+ "fastindexer.cpp",
+ "fastindexer.h",
+ "pchinfo.cpp",
+ "pchinfo.h",
+ "pchmanager.cpp",
+ "pchmanager.h",
+ "semanticmarker.cpp",
+ "semanticmarker.h",
+ "sourcelocation.cpp",
+ "sourcelocation.h",
+ "sourcemarker.cpp",
+ "sourcemarker.h",
+ "symbol.cpp",
+ "symbol.h",
+ "unit.cpp",
+ "unit.h",
+ "unsavedfiledata.cpp",
+ "unsavedfiledata.h",
+ "utils.cpp",
+ "utils.h",
+ "utils_p.cpp",
+ "utils_p.h",
+ "raii/scopedclangoptions.cpp",
+ "raii/scopedclangoptions.h",
+ ]
+}
diff --git a/src/plugins/clangcodemodel/clangcodemodel_dependencies.pri b/src/plugins/clangcodemodel/clangcodemodel_dependencies.pri
new file mode 100644
index 0000000000..dea57152d0
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangcodemodel_dependencies.pri
@@ -0,0 +1,7 @@
+QTC_PLUGIN_NAME = ClangCodeModel
+QTC_LIB_DEPENDS += \
+ utils
+QTC_PLUGIN_DEPENDS += \
+ coreplugin \
+ cpptools \
+ texteditor
diff --git a/src/plugins/clangcodemodel/clangcodemodelplugin.cpp b/src/plugins/clangcodemodel/clangcodemodelplugin.cpp
new file mode 100644
index 0000000000..e652f5ffa6
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangcodemodelplugin.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangcodemodelplugin.h"
+#include "clangprojectsettingspropertiespage.h"
+#include "fastindexer.h"
+#include "pchmanager.h"
+#include "utils.h"
+
+#include <coreplugin/coreconstants.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/imode.h>
+#include <coreplugin/modemanager.h>
+#include <coreplugin/id.h>
+
+#include <cpptools/cppmodelmanager.h>
+
+#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/session.h>
+
+#include <QtPlugin>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+bool ClangCodeModelPlugin::initialize(const QStringList &arguments, QString *errorMessage)
+{
+ Q_UNUSED(arguments)
+ Q_UNUSED(errorMessage)
+
+ addAutoReleasedObject(new ClangProjectSettingsPanelFactory);
+
+ ClangCodeModel::Internal::initializeClang();
+
+ PCHManager *pchManager = new PCHManager(this);
+ FastIndexer *fastIndexer = 0;
+
+#ifdef CLANG_INDEXING
+ m_indexer.reset(new ClangIndexer);
+ fastIndexer = m_indexer.data();
+ CppTools::CppModelManagerInterface::instance()->setIndexingSupport(m_indexer->indexingSupport());
+#endif // CLANG_INDEXING
+
+ // wire up the pch manager
+ QObject *session = ProjectExplorer::SessionManager::instance();
+ connect(session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
+ pchManager, SLOT(onAboutToRemoveProject(ProjectExplorer::Project*)));
+ connect(CppTools::CppModelManagerInterface::instance(), SIGNAL(projectPartsUpdated(ProjectExplorer::Project*)),
+ pchManager, SLOT(onProjectPartsUpdated(ProjectExplorer::Project*)));
+
+ m_modelManagerSupport.reset(new ModelManagerSupport(fastIndexer));
+ CppTools::CppModelManagerInterface::instance()->addModelManagerSupport(
+ m_modelManagerSupport.data());
+
+ return true;
+}
+
+void ClangCodeModelPlugin::extensionsInitialized()
+{
+}
+
+} // namespace Internal
+} // namespace Clang
+
+Q_EXPORT_PLUGIN(ClangCodeModel::Internal::ClangCodeModelPlugin)
diff --git a/src/plugins/clangcodemodel/clangcodemodelplugin.h b/src/plugins/clangcodemodel/clangcodemodelplugin.h
new file mode 100644
index 0000000000..8faaef44c5
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangcodemodelplugin.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANGPLUGIN_H
+#define CLANGPLUGIN_H
+
+#include "clangmodelmanagersupport.h"
+
+#ifdef CLANG_INDEXING
+# include "clangindexer.h"
+#endif // CLANG_INDEXING
+
+#include <extensionsystem/iplugin.h>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class ClangCodeModelPlugin: public ExtensionSystem::IPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ClangCodeModel.json")
+
+public:
+ bool initialize(const QStringList &arguments, QString *errorMessage);
+
+ void extensionsInitialized();
+
+private:
+ QScopedPointer<ModelManagerSupport> m_modelManagerSupport;
+#ifdef CLANG_INDEXING
+ QScopedPointer<ClangIndexer> m_indexer;
+#endif // CLANG_INDEXING
+
+#ifdef WITH_TESTS
+private slots:
+ void test_CXX_regressions();
+ void test_CXX_regressions_data();
+ void test_CXX_snippets();
+ void test_CXX_snippets_data();
+ void test_ObjC_hints();
+ void test_ObjC_hints_data();
+#endif
+};
+
+} // namespace Internal
+} // namespace Clang
+
+#endif // CLANGPLUGIN_H
diff --git a/src/plugins/clangcodemodel/clangcompleter.cpp b/src/plugins/clangcodemodel/clangcompleter.cpp
new file mode 100644
index 0000000000..452385fad5
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangcompleter.cpp
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangcompleter.h"
+#include "sourcemarker.h"
+#include "unsavedfiledata.h"
+#include "utils_p.h"
+#include "completionproposalsbuilder.h"
+#include "raii/scopedclangoptions.h"
+#include "unit.h"
+
+#include <QDebug>
+#include <QFile>
+#include <QMutex>
+#include <QMutexLocker>
+#include <QTime>
+
+#include <clang-c/Index.h>
+
+//#define TIME_COMPLETION
+
+class ClangCodeModel::ClangCompleter::PrivateData
+{
+public:
+ PrivateData()
+ : m_mutex(QMutex::Recursive)
+ , m_unit(Internal::Unit::create())
+ , m_isSignalSlotCompletion(false)
+ {
+ }
+
+ ~PrivateData()
+ {
+ }
+
+ bool parseFromFile(const Internal::UnsavedFiles &unsavedFiles)
+ {
+ Q_ASSERT(!m_unit->isLoaded());
+ if (m_unit->fileName().isEmpty())
+ return false;
+
+ unsigned opts = clang_defaultEditingTranslationUnitOptions();
+#if defined(CINDEX_VERSION) && (CINDEX_VERSION > 5)
+ opts |= CXTranslationUnit_CacheCompletionResults;
+ opts |= CXTranslationUnit_IncludeBriefCommentsInCodeCompletion;
+#endif
+ m_unit->setManagementOptions(opts);
+
+ m_unit->setUnsavedFiles(unsavedFiles);
+ m_unit->parse();
+ return m_unit->isLoaded();
+ }
+
+public:
+ QMutex m_mutex;
+ Internal::Unit::Ptr m_unit;
+ bool m_isSignalSlotCompletion;
+};
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+
+/**
+ * @brief Constructs with highest possible priority
+ */
+CodeCompletionResult::CodeCompletionResult()
+ : m_priority(SHRT_MAX)
+ , m_completionKind(Other)
+ , m_availability(Available)
+ , m_hasParameters(false)
+{}
+
+/**
+ * @brief Constructs with given priority
+ * @param priority Will be reversed, because clang's highest priority is 0,
+ * but inside QtCreator it is the lowest priority
+ */
+CodeCompletionResult::CodeCompletionResult(unsigned priority)
+ : m_priority(SHRT_MAX - priority)
+ , m_completionKind(Other)
+ , m_availability(Available)
+ , m_hasParameters(false)
+{
+}
+
+ClangCompleter::ClangCompleter()
+ : d(new PrivateData)
+{
+}
+
+ClangCompleter::~ClangCompleter()
+{
+}
+
+QString ClangCompleter::fileName() const
+{
+ return d->m_unit->fileName();
+}
+
+void ClangCompleter::setFileName(const QString &fileName)
+{
+ if (d->m_unit->fileName() != fileName) {
+ d->m_unit = Internal::Unit::create(fileName);
+ }
+}
+
+QStringList ClangCompleter::options() const
+{
+ return d->m_unit->compilationOptions();
+}
+
+void ClangCompleter::setOptions(const QStringList &options) const
+{
+ if (d->m_unit->compilationOptions() != options) {
+ d->m_unit->setCompilationOptions(options);
+ d->m_unit->unload();
+ }
+}
+
+bool ClangCompleter::isSignalSlotCompletion() const
+{
+ return d->m_isSignalSlotCompletion;
+}
+
+void ClangCompleter::setSignalSlotCompletion(bool isSignalSlot)
+{
+ d->m_isSignalSlotCompletion = isSignalSlot;
+}
+
+bool ClangCompleter::reparse(const UnsavedFiles &unsavedFiles)
+{
+ if (!d->m_unit->isLoaded())
+ return d->parseFromFile(unsavedFiles);
+
+ d->m_unit->setUnsavedFiles(unsavedFiles);
+ d->m_unit->reparse();
+ return d->m_unit->isLoaded();
+}
+
+QList<CodeCompletionResult> ClangCompleter::codeCompleteAt(unsigned line,
+ unsigned column,
+ const UnsavedFiles &unsavedFiles)
+{
+#ifdef TIME_COMPLETION
+ QTime t;t.start();
+#endif // TIME_COMPLETION
+
+ if (!d->m_unit->isLoaded())
+ if (!d->parseFromFile(unsavedFiles))
+ return QList<CodeCompletionResult>();
+
+ ScopedCXCodeCompleteResults results;
+ d->m_unit->setUnsavedFiles(unsavedFiles);
+ d->m_unit->codeCompleteAt(line, column, results);
+
+ QList<CodeCompletionResult> completions;
+ if (results) {
+ const quint64 contexts = clang_codeCompleteGetContexts(results);
+ CompletionProposalsBuilder builder(completions, contexts, d->m_isSignalSlotCompletion);
+ for (unsigned i = 0; i < results.size(); ++i)
+ builder(results.completionAt(i));
+ }
+
+#ifdef TIME_COMPLETION
+ qDebug() << "Completion timing:" << completions.size() << "results in" << t.elapsed() << "ms.";
+#endif // TIME_COMPLETION
+
+ return completions;
+}
+
+bool ClangCompleter::objcEnabled() const
+{
+ static const QString objcppOption = QLatin1String("-ObjC++");
+ static const QString objcOption = QLatin1String("-ObjC");
+
+ QStringList options = d->m_unit->compilationOptions();
+ return options.contains(objcOption) || options.contains(objcppOption);
+}
+
+QMutex *ClangCompleter::mutex() const
+{
+ return &d->m_mutex;
+}
diff --git a/src/plugins/clangcodemodel/clangcompleter.h b/src/plugins/clangcodemodel/clangcompleter.h
new file mode 100644
index 0000000000..0aa3adff21
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangcompleter.h
@@ -0,0 +1,223 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANGCOMPLETER_H
+#define CLANGCOMPLETER_H
+
+#include "clang_global.h"
+#include "diagnostic.h"
+#include "sourcelocation.h"
+#include "utils.h"
+
+#include <QList>
+#include <QMap>
+#include <QMutex>
+#include <QPair>
+#include <QSharedPointer>
+#include <QString>
+#include <QStringList>
+#include <QVariant>
+
+namespace ClangCodeModel {
+
+class SourceMarker;
+
+class CLANG_EXPORT CodeCompletionResult
+{
+public:
+ enum Kind {
+ Other = 0,
+ FunctionCompletionKind,
+ ConstructorCompletionKind,
+ DestructorCompletionKind,
+ VariableCompletionKind,
+ ClassCompletionKind,
+ EnumCompletionKind,
+ EnumeratorCompletionKind,
+ NamespaceCompletionKind,
+ PreProcessorCompletionKind,
+ SignalCompletionKind,
+ SlotCompletionKind,
+ ObjCMessageCompletionKind,
+ KeywordCompletionKind,
+ ClangSnippetKind
+ };
+
+ enum Availability {
+ Available,
+ Deprecated,
+ NotAvailable,
+ NotAccessible
+ };
+
+public:
+ CodeCompletionResult();
+ CodeCompletionResult(unsigned priority);
+
+ unsigned priority() const
+ { return m_priority; }
+
+ bool isValid() const
+ { return !m_text.isEmpty(); }
+
+ QString text() const
+ { return m_text; }
+ void setText(const QString &text)
+ { m_text = text; }
+
+ QString hint() const
+ { return m_hint; }
+ void setHint(const QString &hint)
+ { m_hint = hint; }
+
+ QString snippet() const
+ { return m_snippet; }
+ void setSnippet(const QString &snippet)
+ { m_snippet = snippet; }
+
+ Kind completionKind() const
+ { return m_completionKind; }
+ void setCompletionKind(Kind type)
+ { m_completionKind = type; }
+
+ int compare(const CodeCompletionResult &other) const
+ {
+ if (m_priority < other.m_priority)
+ return -1;
+ else if (m_priority > other.m_priority)
+ return 1;
+
+ if (m_completionKind < other.m_completionKind)
+ return -1;
+ else if (m_completionKind > other.m_completionKind)
+ return 1;
+
+ if (m_text < other.m_text)
+ return -1;
+ else if (m_text > other.m_text)
+ return 1;
+
+ if (m_hint < other.m_hint)
+ return -1;
+ else if (m_hint > other.m_hint)
+ return 1;
+
+ if (!m_hasParameters && other.m_hasParameters)
+ return -1;
+ else if (m_hasParameters && !other.m_hasParameters)
+ return 1;
+
+ if (m_availability < other.m_availability)
+ return -1;
+ else if (m_availability > other.m_availability)
+ return 1;
+
+ return 0;
+ }
+
+ bool hasParameters() const
+ { return m_hasParameters; }
+ void setHasParameters(bool hasParameters)
+ { m_hasParameters = hasParameters; }
+
+ Availability availability() const
+ { return m_availability; }
+ void setAvailability(Availability availability)
+ { m_availability = availability; }
+
+private:
+ unsigned m_priority;
+ Kind m_completionKind;
+ QString m_text;
+ QString m_hint;
+ QString m_snippet;
+ Availability m_availability;
+ bool m_hasParameters;
+};
+
+inline CLANG_EXPORT uint qHash(const CodeCompletionResult &ccr)
+{ return ccr.completionKind() ^ qHash(ccr.text()); }
+
+inline CLANG_EXPORT bool operator==(const CodeCompletionResult &ccr1, const CodeCompletionResult &ccr2)
+{ return ccr1.compare(ccr2) == 0; }
+
+inline CLANG_EXPORT bool operator<(const CodeCompletionResult &ccr1, const CodeCompletionResult &ccr2)
+{
+ return ccr1.compare(ccr2) < 0;
+}
+
+class CLANG_EXPORT ClangCompleter
+{
+ Q_DISABLE_COPY(ClangCompleter)
+
+ class PrivateData;
+
+public: // data structures
+ typedef QSharedPointer<ClangCompleter> Ptr;
+
+public: // methods
+ ClangCompleter();
+ ~ClangCompleter();
+
+ QString fileName() const;
+ void setFileName(const QString &fileName);
+
+ QStringList options() const;
+ void setOptions(const QStringList &options) const;
+
+ bool isSignalSlotCompletion() const;
+ void setSignalSlotCompletion(bool isSignalSlot);
+
+ bool reparse(const Internal::UnsavedFiles &unsavedFiles);
+
+ /**
+ * Do code-completion at the specified position.
+ *
+ * \param line The line number on which to do code-completion. The first
+ * line of a file has line number 1.
+ * \param column The column number where to do code-completion. Column
+ * numbers start with 1.
+ */
+ QList<CodeCompletionResult> codeCompleteAt(unsigned line,
+ unsigned column,
+ const Internal::UnsavedFiles &unsavedFiles);
+
+ bool objcEnabled() const;
+
+ QMutex *mutex() const;
+
+private: // instance fields
+ QScopedPointer<PrivateData> d;
+};
+
+} // namespace Clang
+
+Q_DECLARE_METATYPE(ClangCodeModel::CodeCompletionResult)
+
+#endif // CLANGCOMPLETER_H
diff --git a/src/plugins/clangcodemodel/clangcompletion.cpp b/src/plugins/clangcodemodel/clangcompletion.cpp
new file mode 100644
index 0000000000..b00660915c
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangcompletion.cpp
@@ -0,0 +1,1221 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangcompletion.h"
+#include "clangutils.h"
+#include "pchmanager.h"
+
+#include <coreplugin/icore.h>
+#include <coreplugin/idocument.h>
+#include <coreplugin/mimedatabase.h>
+
+#include <cplusplus/BackwardsScanner.h>
+#include <cplusplus/ExpressionUnderCursor.h>
+#include <cplusplus/Token.h>
+#include <cplusplus/MatchingText.h>
+
+#include <cppeditor/cppeditorconstants.h>
+
+#include <cpptools/cppdoxygen.h>
+#include <cpptools/cppmodelmanagerinterface.h>
+
+#include <texteditor/basetexteditor.h>
+#include <texteditor/convenience.h>
+#include <texteditor/codeassist/basicproposalitemlistmodel.h>
+#include <texteditor/codeassist/basicproposalitem.h>
+#include <texteditor/codeassist/functionhintproposal.h>
+#include <texteditor/codeassist/genericproposal.h>
+#include <texteditor/codeassist/ifunctionhintproposalmodel.h>
+#include <texteditor/texteditorsettings.h>
+#include <texteditor/completionsettings.h>
+
+#include <QCoreApplication>
+#include <QDirIterator>
+#include <QTextCursor>
+#include <QTextDocument>
+
+static const bool DebugTiming = !qgetenv("QTC_CLANG_VERBOSE").isEmpty();
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+using namespace CPlusPlus;
+using namespace CppTools;
+using namespace TextEditor;
+
+static const char SNIPPET_ICON_PATH[] = ":/texteditor/images/snippet.png";
+
+namespace {
+
+int activationSequenceChar(const QChar &ch,
+ const QChar &ch2,
+ const QChar &ch3,
+ unsigned *kind,
+ bool wantFunctionCall)
+{
+ int referencePosition = 0;
+ int completionKind = T_EOF_SYMBOL;
+ switch (ch.toLatin1()) {
+ case '.':
+ if (ch2 != QLatin1Char('.')) {
+ completionKind = T_DOT;
+ referencePosition = 1;
+ }
+ break;
+ case ',':
+ completionKind = T_COMMA;
+ referencePosition = 1;
+ break;
+ case '(':
+ if (wantFunctionCall) {
+ completionKind = T_LPAREN;
+ referencePosition = 1;
+ }
+ break;
+ case ':':
+ if (ch3 != QLatin1Char(':') && ch2 == QLatin1Char(':')) {
+ completionKind = T_COLON_COLON;
+ referencePosition = 2;
+ }
+ break;
+ case '>':
+ if (ch2 == QLatin1Char('-')) {
+ completionKind = T_ARROW;
+ referencePosition = 2;
+ }
+ break;
+ case '*':
+ if (ch2 == QLatin1Char('.')) {
+ completionKind = T_DOT_STAR;
+ referencePosition = 2;
+ } else if (ch3 == QLatin1Char('-') && ch2 == QLatin1Char('>')) {
+ completionKind = T_ARROW_STAR;
+ referencePosition = 3;
+ }
+ break;
+ case '\\':
+ case '@':
+ if (ch2.isNull() || ch2.isSpace()) {
+ completionKind = T_DOXY_COMMENT;
+ referencePosition = 1;
+ }
+ break;
+ case '<':
+ completionKind = T_ANGLE_STRING_LITERAL;
+ referencePosition = 1;
+ break;
+ case '"':
+ completionKind = T_STRING_LITERAL;
+ referencePosition = 1;
+ break;
+ case '/':
+ completionKind = T_SLASH;
+ referencePosition = 1;
+ break;
+ case '#':
+ completionKind = T_POUND;
+ referencePosition = 1;
+ break;
+ }
+
+ if (kind)
+ *kind = completionKind;
+
+ return referencePosition;
+}
+
+static QList<CodeCompletionResult> unfilteredCompletion(const ClangCompletionAssistInterface* interface,
+ const QString &fileName,
+ unsigned line, unsigned column,
+ QByteArray modifiedInput = QByteArray(),
+ bool isSignalSlotCompletion = false)
+{
+ ClangCompleter::Ptr wrapper = interface->clangWrapper();
+ QMutexLocker lock(wrapper->mutex());
+ //### TODO: check if we're cancelled after we managed to acquire the mutex
+
+ wrapper->setFileName(fileName);
+ wrapper->setOptions(interface->options());
+ wrapper->setSignalSlotCompletion(isSignalSlotCompletion);
+ UnsavedFiles unsavedFiles = interface->unsavedFiles();
+ if (!modifiedInput.isEmpty())
+ unsavedFiles.insert(fileName, modifiedInput);
+
+ QTime t;
+ if (DebugTiming) {
+ qDebug() << "Here we go with ClangCompletionAssistProcessor....";
+ t.start();
+ }
+
+ QList<CodeCompletionResult> result = wrapper->codeCompleteAt(line, column + 1, unsavedFiles);
+ qSort(result);
+
+ if (DebugTiming)
+ qDebug() << "... Completion done in" << t.elapsed() << "ms, with" << result.count() << "items.";
+
+ return result;
+}
+
+} // Anonymous
+
+namespace ClangCodeModel {
+namespace Internal {
+
+// -----------------------------
+// ClangCompletionAssistProvider
+// -----------------------------
+ClangCompletionAssistProvider::ClangCompletionAssistProvider()
+ : m_clangCompletionWrapper(new ClangCodeModel::ClangCompleter)
+{
+}
+
+IAssistProcessor *ClangCompletionAssistProvider::createProcessor() const
+{
+ return new ClangCompletionAssistProcessor;
+}
+
+IAssistInterface *ClangCompletionAssistProvider::createAssistInterface(
+ ProjectExplorer::Project *project, TextEditor::BaseTextEditor *editor,
+ QTextDocument *document, int position, AssistReason reason) const
+{
+ Q_UNUSED(project);
+
+ QString fileName = editor->document()->filePath();
+ CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
+ QList<ProjectPart::Ptr> parts = modelManager->projectPart(fileName);
+ if (parts.isEmpty())
+ parts += modelManager->fallbackProjectPart();
+ QStringList includePaths, frameworkPaths, options;
+ PchInfo::Ptr pchInfo;
+ foreach (ProjectPart::Ptr part, parts) {
+ if (part.isNull())
+ continue;
+ options = ClangCodeModel::Utils::createClangOptions(part, fileName);
+ pchInfo = PCHManager::instance()->pchInfo(part);
+ if (!pchInfo.isNull())
+ options.append(ClangCodeModel::Utils::createPCHInclusionOptions(pchInfo->fileName()));
+ includePaths = part->includePaths;
+ frameworkPaths = part->frameworkPaths;
+ break;
+ }
+
+ return new ClangCodeModel::ClangCompletionAssistInterface(
+ m_clangCompletionWrapper,
+ document, position, fileName, reason,
+ options, includePaths, frameworkPaths, pchInfo);
+}
+
+// ------------------------
+// ClangAssistProposalModel
+// ------------------------
+class ClangAssistProposalModel : public TextEditor::BasicProposalItemListModel
+{
+public:
+ ClangAssistProposalModel()
+ : TextEditor::BasicProposalItemListModel()
+ , m_sortable(false)
+ , m_completionOperator(T_EOF_SYMBOL)
+ , m_replaceDotForArrow(false)
+ {}
+
+ virtual bool isSortable(const QString &prefix) const;
+ bool m_sortable;
+ unsigned m_completionOperator;
+ bool m_replaceDotForArrow;
+};
+
+// -------------------
+// ClangAssistProposal
+// -------------------
+class ClangAssistProposal : public TextEditor::GenericProposal
+{
+public:
+ ClangAssistProposal(int cursorPos, TextEditor::IGenericProposalModel *model)
+ : TextEditor::GenericProposal(cursorPos, model)
+ , m_replaceDotForArrow(static_cast<ClangAssistProposalModel *>(model)->m_replaceDotForArrow)
+ {}
+
+ virtual bool isCorrective() const { return m_replaceDotForArrow; }
+ virtual void makeCorrection(BaseTextEditor *editor)
+ {
+ editor->setCursorPosition(basePosition() - 1);
+ editor->replace(1, QLatin1String("->"));
+ moveBasePosition(1);
+ }
+
+private:
+ bool m_replaceDotForArrow;
+};
+
+// ----------------------
+// ClangFunctionHintModel
+// ----------------------
+class ClangFunctionHintModel : public TextEditor::IFunctionHintProposalModel
+{
+public:
+ ClangFunctionHintModel(const QList<CodeCompletionResult> functionSymbols)
+ : m_functionSymbols(functionSymbols)
+ , m_currentArg(-1)
+ {}
+
+ virtual void reset() {}
+ virtual int size() const { return m_functionSymbols.size(); }
+ virtual QString text(int index) const;
+ virtual int activeArgument(const QString &prefix) const;
+
+private:
+ QList<ClangCodeModel::CodeCompletionResult> m_functionSymbols;
+ mutable int m_currentArg;
+};
+
+QString ClangFunctionHintModel::text(int index) const
+{
+#if 0
+ // TODO: add the boldening to the result
+ Overview overview;
+ overview.setShowReturnTypes(true);
+ overview.setShowArgumentNames(true);
+ overview.setMarkedArgument(m_currentArg + 1);
+ Function *f = m_functionSymbols.at(index);
+
+ const QString prettyMethod = overview(f->type(), f->name());
+ const int begin = overview.markedArgumentBegin();
+ const int end = overview.markedArgumentEnd();
+
+ QString hintText;
+ hintText += Qt::escape(prettyMethod.left(begin));
+ hintText += "<b>";
+ hintText += Qt::escape(prettyMethod.mid(begin, end - begin));
+ hintText += "</b>";
+ hintText += Qt::escape(prettyMethod.mid(end));
+ return hintText;
+#endif
+ return m_functionSymbols.at(index).hint();
+}
+
+int ClangFunctionHintModel::activeArgument(const QString &prefix) const
+{
+ int argnr = 0;
+ int parcount = 0;
+ SimpleLexer tokenize;
+ QList<CPlusPlus::Token> tokens = tokenize(prefix);
+ for (int i = 0; i < tokens.count(); ++i) {
+ const CPlusPlus::Token &tk = tokens.at(i);
+ if (tk.is(T_LPAREN))
+ ++parcount;
+ else if (tk.is(T_RPAREN))
+ --parcount;
+ else if (! parcount && tk.is(T_COMMA))
+ ++argnr;
+ }
+
+ if (parcount < 0)
+ return -1;
+
+ if (argnr != m_currentArg)
+ m_currentArg = argnr;
+
+ return argnr;
+}
+
+class ClangAssistProposalItem : public TextEditor::BasicProposalItem
+{
+public:
+ ClangAssistProposalItem() {}
+
+ virtual bool prematurelyApplies(const QChar &c) const;
+ virtual void applyContextualContent(TextEditor::BaseTextEditor *editor,
+ int basePosition) const;
+
+ void keepCompletionOperator(unsigned compOp) { m_completionOperator = compOp; }
+
+ bool isOverloaded() const
+ { return !m_overloads.isEmpty(); }
+ void addOverload(const CodeCompletionResult &ccr)
+ { m_overloads.append(ccr); }
+
+ CodeCompletionResult originalItem() const
+ {
+ const QVariant &v = data();
+ if (v.canConvert<CodeCompletionResult>())
+ return v.value<CodeCompletionResult>();
+ else
+ return CodeCompletionResult();
+ }
+
+ bool isCodeCompletionResult() const
+ { return data().canConvert<CodeCompletionResult>(); }
+
+private:
+ unsigned m_completionOperator;
+ mutable QChar m_typedChar;
+ QList<CodeCompletionResult> m_overloads;
+};
+
+/// @return True, because clang always returns priorities for sorting
+bool ClangAssistProposalModel::isSortable(const QString &prefix) const
+{
+ Q_UNUSED(prefix)
+ return true;
+}
+
+} // namespace Internal
+} // namespace ClangCodeModel
+
+bool ClangAssistProposalItem::prematurelyApplies(const QChar &typedChar) const
+{
+ bool ok = false;
+
+ if (m_completionOperator == T_SIGNAL || m_completionOperator == T_SLOT)
+ ok = QString::fromLatin1("(,").contains(typedChar);
+ else if (m_completionOperator == T_STRING_LITERAL || m_completionOperator == T_ANGLE_STRING_LITERAL)
+ ok = (typedChar == QLatin1Char('/')) && text().endsWith(QLatin1Char('/'));
+ else if (!isCodeCompletionResult())
+ ok = (typedChar == QLatin1Char('(')); /* && data().canConvert<CompleteFunctionDeclaration>()*/ //###
+ else if (originalItem().completionKind() == CodeCompletionResult::ObjCMessageCompletionKind)
+ ok = QString::fromLatin1(";.,").contains(typedChar);
+ else
+ ok = QString::fromLatin1(";.,:(").contains(typedChar);
+
+ if (ok)
+ m_typedChar = typedChar;
+
+ return ok;
+}
+
+void ClangAssistProposalItem::applyContextualContent(TextEditor::BaseTextEditor *editor,
+ int basePosition) const
+{
+ const CodeCompletionResult ccr = originalItem();
+
+ QString toInsert = text();
+ QString extraChars;
+ int extraLength = 0;
+ int cursorOffset = 0;
+
+ bool autoParenthesesEnabled = true;
+ if (m_completionOperator == T_SIGNAL || m_completionOperator == T_SLOT) {
+ extraChars += QLatin1Char(')');
+ if (m_typedChar == QLatin1Char('(')) // Eat the opening parenthesis
+ m_typedChar = QChar();
+ } else if (m_completionOperator == T_STRING_LITERAL || m_completionOperator == T_ANGLE_STRING_LITERAL) {
+ if (!toInsert.endsWith(QLatin1Char('/'))) {
+ extraChars += QLatin1Char((m_completionOperator == T_ANGLE_STRING_LITERAL) ? '>' : '"');
+ } else {
+ if (m_typedChar == QLatin1Char('/')) // Eat the slash
+ m_typedChar = QChar();
+ }
+ } else if (ccr.isValid()) {
+ const CompletionSettings &completionSettings =
+ TextEditorSettings::instance()->completionSettings();
+ const bool autoInsertBrackets = completionSettings.m_autoInsertBrackets;
+
+ if (autoInsertBrackets &&
+ (ccr.completionKind() == CodeCompletionResult::FunctionCompletionKind
+ || ccr.completionKind() == CodeCompletionResult::DestructorCompletionKind
+ || ccr.completionKind() == CodeCompletionResult::SignalCompletionKind
+ || ccr.completionKind() == CodeCompletionResult::SlotCompletionKind)) {
+ // When the user typed the opening parenthesis, he'll likely also type the closing one,
+ // in which case it would be annoying if we put the cursor after the already automatically
+ // inserted closing parenthesis.
+ const bool skipClosingParenthesis = m_typedChar != QLatin1Char('(');
+
+ if (completionSettings.m_spaceAfterFunctionName)
+ extraChars += QLatin1Char(' ');
+ extraChars += QLatin1Char('(');
+ if (m_typedChar == QLatin1Char('('))
+ m_typedChar = QChar();
+
+ // If the function doesn't return anything, automatically place the semicolon,
+ // unless we're doing a scope completion (then it might be function definition).
+ const QChar characterAtCursor = editor->textDocument()->characterAt(editor->position());
+ bool endWithSemicolon = m_typedChar == QLatin1Char(';')/*
+ || (function->returnType()->isVoidType() && m_completionOperator != T_COLON_COLON)*/; //###
+ const QChar semicolon = m_typedChar.isNull() ? QLatin1Char(';') : m_typedChar;
+
+ if (endWithSemicolon && characterAtCursor == semicolon) {
+ endWithSemicolon = false;
+ m_typedChar = QChar();
+ }
+
+ // If the function takes no arguments, automatically place the closing parenthesis
+ if (!isOverloaded() && !ccr.hasParameters() && skipClosingParenthesis) {
+ extraChars += QLatin1Char(')');
+ if (endWithSemicolon) {
+ extraChars += semicolon;
+ m_typedChar = QChar();
+ }
+ } else if (autoParenthesesEnabled) {
+ const QChar lookAhead = editor->textDocument()->characterAt(editor->position() + 1);
+ if (MatchingText::shouldInsertMatchingText(lookAhead)) {
+ extraChars += QLatin1Char(')');
+ --cursorOffset;
+ if (endWithSemicolon) {
+ extraChars += semicolon;
+ --cursorOffset;
+ m_typedChar = QChar();
+ }
+ }
+ }
+ }
+
+#if 0
+ if (autoInsertBrackets && data().canConvert<CompleteFunctionDeclaration>()) {
+ if (m_typedChar == QLatin1Char('('))
+ m_typedChar = QChar();
+
+ // everything from the closing parenthesis on are extra chars, to
+ // make sure an auto-inserted ")" gets replaced by ") const" if necessary
+ int closingParen = toInsert.lastIndexOf(QLatin1Char(')'));
+ extraChars = toInsert.mid(closingParen);
+ toInsert.truncate(closingParen);
+ }
+#endif
+ }
+
+ // Append an unhandled typed character, adjusting cursor offset when it had been adjusted before
+ if (!m_typedChar.isNull()) {
+ extraChars += m_typedChar;
+ if (cursorOffset != 0)
+ --cursorOffset;
+ }
+
+ // Avoid inserting characters that are already there
+ const int endsPosition = editor->position(TextEditor::ITextEditor::EndOfLine);
+ const QString existingText = editor->textDocument()->textAt(editor->position(),
+ endsPosition - editor->position());
+ int existLength = 0;
+ if (!existingText.isEmpty()) {
+ // Calculate the exist length in front of the extra chars
+ existLength = toInsert.length() - (editor->position() - basePosition);
+ while (!existingText.startsWith(toInsert.right(existLength))) {
+ if (--existLength == 0)
+ break;
+ }
+ }
+ for (int i = 0; i < extraChars.length(); ++i) {
+ const QChar a = extraChars.at(i);
+ const QChar b = editor->textDocument()->characterAt(editor->position() + i + existLength);
+ if (a == b)
+ ++extraLength;
+ else
+ break;
+ }
+ toInsert += extraChars;
+
+ // Insert the remainder of the name
+ const int length = editor->position() - basePosition + existLength + extraLength;
+ editor->setCursorPosition(basePosition);
+ editor->replace(length, toInsert);
+ if (cursorOffset)
+ editor->setCursorPosition(editor->position() + cursorOffset);
+}
+
+bool ClangCompletionAssistInterface::objcEnabled() const
+{
+ return m_clangWrapper->objcEnabled();
+}
+
+ClangCompletionAssistInterface::ClangCompletionAssistInterface(ClangCompleter::Ptr clangWrapper,
+ QTextDocument *document,
+ int position,
+ const QString &fileName,
+ AssistReason reason,
+ const QStringList &options,
+ const QStringList &includePaths,
+ const QStringList &frameworkPaths,
+ const PchInfo::Ptr &pchInfo)
+ : DefaultAssistInterface(document, position, fileName, reason)
+ , m_clangWrapper(clangWrapper)
+ , m_options(options)
+ , m_includePaths(includePaths)
+ , m_frameworkPaths(frameworkPaths)
+ , m_savedPchPointer(pchInfo)
+{
+ Q_ASSERT(!clangWrapper.isNull());
+
+ CppModelManagerInterface *mmi = CppModelManagerInterface::instance();
+ Q_ASSERT(mmi);
+ m_unsavedFiles = Utils::createUnsavedFiles(mmi->workingCopy());
+}
+
+ClangCompletionAssistProcessor::ClangCompletionAssistProcessor()
+ : m_preprocessorCompletions(QStringList()
+ << QLatin1String("define")
+ << QLatin1String("error")
+ << QLatin1String("include")
+ << QLatin1String("line")
+ << QLatin1String("pragma")
+ << QLatin1String("pragma once")
+ << QLatin1String("pragma omp atomic")
+ << QLatin1String("pragma omp parallel")
+ << QLatin1String("pragma omp for")
+ << QLatin1String("pragma omp ordered")
+ << QLatin1String("pragma omp parallel for")
+ << QLatin1String("pragma omp section")
+ << QLatin1String("pragma omp sections")
+ << QLatin1String("pragma omp parallel sections")
+ << QLatin1String("pragma omp single")
+ << QLatin1String("pragma omp master")
+ << QLatin1String("pragma omp critical")
+ << QLatin1String("pragma omp barrier")
+ << QLatin1String("pragma omp flush")
+ << QLatin1String("pragma omp threadprivate")
+ << QLatin1String("undef")
+ << QLatin1String("if")
+ << QLatin1String("ifdef")
+ << QLatin1String("ifndef")
+ << QLatin1String("elif")
+ << QLatin1String("else")
+ << QLatin1String("endif"))
+ , m_model(new ClangAssistProposalModel)
+ , m_hintProposal(0)
+
+{
+}
+
+ClangCompletionAssistProcessor::~ClangCompletionAssistProcessor()
+{
+}
+
+IAssistProposal *ClangCompletionAssistProcessor::perform(const IAssistInterface *interface)
+{
+ m_interface.reset(static_cast<const ClangCompletionAssistInterface *>(interface));
+
+ if (interface->reason() != ExplicitlyInvoked && !accepts())
+ return 0;
+
+ int index = startCompletionHelper();
+ if (index != -1) {
+ if (m_hintProposal)
+ return m_hintProposal;
+
+ m_model->m_sortable = (m_model->m_completionOperator != T_EOF_SYMBOL);
+ return createContentProposal();
+ }
+
+ return 0;
+}
+
+int ClangCompletionAssistProcessor::startCompletionHelper()
+{
+ //### TODO: clean-up this method, some calculated values might not be used anymore.
+
+ Q_ASSERT(m_model);
+
+ const int startOfName = findStartOfName();
+ m_startPosition = startOfName;
+ m_model->m_completionOperator = T_EOF_SYMBOL;
+
+ int endOfOperator = m_startPosition;
+
+ // Skip whitespace preceding this position
+ while (m_interface->characterAt(endOfOperator - 1).isSpace())
+ --endOfOperator;
+
+ const QString fileName = m_interface->fileName();
+
+ int endOfExpression = startOfOperator(endOfOperator,
+ &m_model->m_completionOperator,
+ /*want function call =*/ true);
+
+ if (m_model->m_completionOperator == T_EOF_SYMBOL) {
+ endOfOperator = m_startPosition;
+ } else if (m_model->m_completionOperator == T_DOXY_COMMENT) {
+ for (int i = 1; i < T_DOXY_LAST_TAG; ++i)
+ addCompletionItem(QString::fromLatin1(doxygenTagSpell(i)),
+ m_icons.keywordIcon());
+ return m_startPosition;
+ }
+
+ // Pre-processor completion
+ //### TODO: check if clang can do pp completion
+ if (m_model->m_completionOperator == T_POUND) {
+ completePreprocessor();
+ m_startPosition = startOfName;
+ return m_startPosition;
+ }
+
+ // Include completion
+ if (m_model->m_completionOperator == T_STRING_LITERAL
+ || m_model->m_completionOperator == T_ANGLE_STRING_LITERAL
+ || m_model->m_completionOperator == T_SLASH) {
+
+ QTextCursor c(m_interface->textDocument());
+ c.setPosition(endOfExpression);
+ if (completeInclude(c))
+ m_startPosition = startOfName;
+ return m_startPosition;
+ }
+
+ ExpressionUnderCursor expressionUnderCursor;
+ QTextCursor tc(m_interface->textDocument());
+
+ if (m_model->m_completionOperator == T_COMMA) {
+ tc.setPosition(endOfExpression);
+ const int start = expressionUnderCursor.startOfFunctionCall(tc);
+ if (start == -1) {
+ m_model->m_completionOperator = T_EOF_SYMBOL;
+ return -1;
+ }
+
+ endOfExpression = start;
+ m_startPosition = start + 1;
+ m_model->m_completionOperator = T_LPAREN;
+ }
+
+ QString expression;
+ int startOfExpression = m_interface->position();
+ tc.setPosition(endOfExpression);
+
+ if (m_model->m_completionOperator) {
+ expression = expressionUnderCursor(tc);
+ startOfExpression = endOfExpression - expression.length();
+
+ if (m_model->m_completionOperator == T_LPAREN) {
+ if (expression.endsWith(QLatin1String("SIGNAL")))
+ m_model->m_completionOperator = T_SIGNAL;
+
+ else if (expression.endsWith(QLatin1String("SLOT")))
+ m_model->m_completionOperator = T_SLOT;
+
+ else if (m_interface->position() != endOfOperator) {
+ // We don't want a function completion when the cursor isn't at the opening brace
+ expression.clear();
+ m_model->m_completionOperator = T_EOF_SYMBOL;
+ m_startPosition = startOfName;
+ startOfExpression = m_interface->position();
+ }
+ }
+ } else if (expression.isEmpty()) {
+ while (startOfExpression > 0 && m_interface->characterAt(startOfExpression).isSpace())
+ --startOfExpression;
+ }
+
+ int line = 0, column = 0;
+// Convenience::convertPosition(m_interface->document(), startOfExpression, &line, &column);
+ Convenience::convertPosition(m_interface->textDocument(), endOfOperator, &line, &column);
+ return startCompletionInternal(fileName, line, column, endOfOperator);
+}
+
+int ClangCompletionAssistProcessor::startOfOperator(int pos,
+ unsigned *kind,
+ bool wantFunctionCall) const
+{
+ const QChar ch = pos > -1 ? m_interface->characterAt(pos - 1) : QChar();
+ const QChar ch2 = pos > 0 ? m_interface->characterAt(pos - 2) : QChar();
+ const QChar ch3 = pos > 1 ? m_interface->characterAt(pos - 3) : QChar();
+
+ int start = pos - activationSequenceChar(ch, ch2, ch3, kind, wantFunctionCall);
+ if (start != pos) {
+ QTextCursor tc(m_interface->textDocument());
+ tc.setPosition(pos);
+
+ // Include completion: make sure the quote character is the first one on the line
+ if (*kind == T_STRING_LITERAL) {
+ QTextCursor s = tc;
+ s.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
+ QString sel = s.selectedText();
+ if (sel.indexOf(QLatin1Char('"')) < sel.length() - 1) {
+ *kind = T_EOF_SYMBOL;
+ start = pos;
+ }
+ }
+
+ if (*kind == T_COMMA) {
+ ExpressionUnderCursor expressionUnderCursor;
+ if (expressionUnderCursor.startOfFunctionCall(tc) == -1) {
+ *kind = T_EOF_SYMBOL;
+ start = pos;
+ }
+ }
+
+ SimpleLexer tokenize;
+ LanguageFeatures lf = tokenize.languageFeatures();
+ lf.qtMocRunEnabled = true;
+ lf.objCEnabled = true;
+ tokenize.setLanguageFeatures(lf);
+ tokenize.setSkipComments(false);
+ const QList<CPlusPlus::Token> &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
+ const CPlusPlus::Token tk = (tokenIdx == -1) ? CPlusPlus::Token() : tokens.at(tokenIdx);
+
+ if (*kind == T_DOXY_COMMENT && !(tk.is(T_DOXY_COMMENT) || tk.is(T_CPP_DOXY_COMMENT))) {
+ *kind = T_EOF_SYMBOL;
+ start = pos;
+ }
+ // Don't complete in comments or strings, but still check for include completion
+ else if (tk.is(T_COMMENT) || tk.is(T_CPP_COMMENT) ||
+ (tk.isLiteral() && (*kind != T_STRING_LITERAL
+ && *kind != T_ANGLE_STRING_LITERAL
+ && *kind != T_SLASH))) {
+ *kind = T_EOF_SYMBOL;
+ start = pos;
+ }
+ // Include completion: can be triggered by slash, but only in a string
+ else if (*kind == T_SLASH && (tk.isNot(T_STRING_LITERAL) && tk.isNot(T_ANGLE_STRING_LITERAL))) {
+ *kind = T_EOF_SYMBOL;
+ start = pos;
+ }
+ else if (*kind == T_LPAREN) {
+ if (tokenIdx > 0) {
+ const CPlusPlus::Token &previousToken = tokens.at(tokenIdx - 1); // look at the token at the left of T_LPAREN
+ switch (previousToken.kind()) {
+ case T_IDENTIFIER:
+ case T_GREATER:
+ case T_SIGNAL:
+ case T_SLOT:
+ break; // good
+
+ default:
+ // that's a bad token :)
+ *kind = T_EOF_SYMBOL;
+ start = pos;
+ }
+ }
+ }
+ // Check for include preprocessor directive
+ else if (*kind == T_STRING_LITERAL || *kind == T_ANGLE_STRING_LITERAL || *kind == T_SLASH) {
+ bool include = false;
+ if (tokens.size() >= 3) {
+ if (tokens.at(0).is(T_POUND) && tokens.at(1).is(T_IDENTIFIER) && (tokens.at(2).is(T_STRING_LITERAL) ||
+ tokens.at(2).is(T_ANGLE_STRING_LITERAL))) {
+ const CPlusPlus::Token &directiveToken = tokens.at(1);
+ QString directive = tc.block().text().mid(directiveToken.begin(),
+ directiveToken.length());
+ if (directive == QLatin1String("include") ||
+ directive == QLatin1String("include_next") ||
+ directive == QLatin1String("import")) {
+ include = true;
+ }
+ }
+ }
+
+ if (!include) {
+ *kind = T_EOF_SYMBOL;
+ start = pos;
+ }
+ }
+ }
+
+ return start;
+}
+
+int ClangCompletionAssistProcessor::findStartOfName(int pos) const
+{
+ if (pos == -1)
+ pos = m_interface->position();
+ QChar chr;
+
+ // Skip to the start of a name
+ do {
+ chr = m_interface->characterAt(--pos);
+ } while (chr.isLetterOrNumber() || chr == QLatin1Char('_'));
+
+ return pos + 1;
+}
+
+bool ClangCompletionAssistProcessor::accepts() const
+{
+ const int pos = m_interface->position();
+ unsigned token = T_EOF_SYMBOL;
+
+ const int start = startOfOperator(pos, &token, /*want function call=*/ true);
+ if (start != pos) {
+ if (token == T_POUND) {
+ const int column = pos - m_interface->textDocument()->findBlock(start).position();
+ if (column != 1)
+ return false;
+ }
+
+ return true;
+ } else {
+ // Trigger completion after three characters of a name have been typed, when not editing an existing name
+ QChar characterUnderCursor = m_interface->characterAt(pos);
+ if (!characterUnderCursor.isLetterOrNumber() && characterUnderCursor != QLatin1Char('_')) {
+ const int startOfName = findStartOfName(pos);
+ if (pos - startOfName >= 3) {
+ const QChar firstCharacter = m_interface->characterAt(startOfName);
+ if (firstCharacter.isLetter() || firstCharacter == QLatin1Char('_')) {
+ // Finally check that we're not inside a comment or string (code copied from startOfOperator)
+ QTextCursor tc(m_interface->textDocument());
+ tc.setPosition(pos);
+
+ SimpleLexer tokenize;
+ LanguageFeatures lf = tokenize.languageFeatures();
+ lf.qtMocRunEnabled = true;
+ lf.objCEnabled = true;
+ tokenize.setLanguageFeatures(lf);
+ tokenize.setSkipComments(false);
+ const QList<CPlusPlus::Token> &tokens = tokenize(tc.block().text(), BackwardsScanner::previousBlockState(tc.block()));
+ const int tokenIdx = SimpleLexer::tokenBefore(tokens, qMax(0, tc.positionInBlock() - 1));
+ const CPlusPlus::Token tk = (tokenIdx == -1) ? CPlusPlus::Token() : tokens.at(tokenIdx);
+
+ if (!tk.isComment() && !tk.isLiteral()) {
+ return true;
+ } else if (tk.isLiteral()
+ && tokens.size() == 3
+ && tokens.at(0).kind() == T_POUND
+ && tokens.at(1).kind() == T_IDENTIFIER) {
+ const QString &line = tc.block().text();
+ const CPlusPlus::Token &idToken = tokens.at(1);
+ const QStringRef &identifier =
+ line.midRef(idToken.begin(), idToken.end() - idToken.begin());
+ if (identifier == QLatin1String("include")
+ || identifier == QLatin1String("include_next")
+ || (m_interface->objcEnabled() && identifier == QLatin1String("import"))) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+IAssistProposal *ClangCompletionAssistProcessor::createContentProposal()
+{
+ m_model->loadContent(m_completions);
+ return new ClangAssistProposal(m_startPosition, m_model.take());
+}
+
+/// Seach backwards in the document starting from pos to find the first opening
+/// parenthesis. Nested parenthesis are skipped.
+static int findOpenParen(QTextDocument *doc, int start)
+{
+ unsigned parenCount = 1;
+ for (int pos = start; pos >= 0; --pos) {
+ const QChar ch = doc->characterAt(pos);
+ if (ch == QLatin1Char('(')) {
+ --parenCount;
+ if (parenCount == 0)
+ return pos;
+ } else if (ch == QLatin1Char(')')) {
+ ++parenCount;
+ }
+ }
+ return -1;
+}
+
+static QByteArray modifyInput(QTextDocument *doc, int endOfExpression) {
+ int comma = endOfExpression;
+ while (comma > 0) {
+ const QChar ch = doc->characterAt(comma);
+ if (ch == QLatin1Char(','))
+ break;
+ if (ch == QLatin1Char(';') || ch == QLatin1Char('{') || ch == QLatin1Char('}')) {
+ // Safety net: we don't seem to have "connect(pointer, SIGNAL(" as
+ // input, so stop searching.
+ comma = -1;
+ break;
+ }
+ --comma;
+ }
+ if (comma < 0)
+ return QByteArray();
+ const int openBrace = findOpenParen(doc, comma);
+ if (openBrace < 0)
+ return QByteArray();
+
+ QByteArray modifiedInput = doc->toPlainText().toUtf8();
+ const int len = endOfExpression - comma;
+ QByteArray replacement(len - 4, ' ');
+ replacement.append(")->");
+ modifiedInput.replace(comma, len, replacement);
+ modifiedInput.insert(openBrace, '(');
+ return modifiedInput;
+}
+
+int ClangCompletionAssistProcessor::startCompletionInternal(const QString fileName,
+ unsigned line,
+ unsigned column,
+ int endOfExpression)
+{
+ bool signalCompletion = false;
+ bool slotCompletion = false;
+ QByteArray modifiedInput;
+
+ if (m_model->m_completionOperator == T_SIGNAL) {
+ signalCompletion = true;
+ modifiedInput = modifyInput(m_interface->textDocument(), endOfExpression);
+ } else if (m_model->m_completionOperator == T_SLOT) {
+ slotCompletion = true;
+ modifiedInput = modifyInput(m_interface->textDocument(), endOfExpression);
+ } else if (m_model->m_completionOperator == T_LPAREN) {
+ // Find the expression that precedes the current name
+ int index = endOfExpression;
+ while (m_interface->characterAt(index - 1).isSpace())
+ --index;
+
+ QTextCursor tc(m_interface->textDocument());
+ tc.setPosition(index);
+ ExpressionUnderCursor euc;
+ index = euc.startOfFunctionCall(tc);
+ int nameStart = findStartOfName(index);
+ QTextCursor tc2(m_interface->textDocument());
+ tc2.setPosition(nameStart);
+ tc2.setPosition(index, QTextCursor::KeepAnchor);
+ const QString functionName = tc2.selectedText().trimmed();
+ int l = line, c = column;
+ Convenience::convertPosition(m_interface->textDocument(), nameStart, &l, &c);
+
+ if (DebugTiming)
+ qDebug()<<"complete constructor or function @" << line<<":"<<column << "->"<<l<<":"<<c;
+
+ const QList<CodeCompletionResult> completions = unfilteredCompletion(
+ m_interface.data(), fileName, l, c, QByteArray(), signalCompletion || slotCompletion);
+ QList<CodeCompletionResult> functionCompletions;
+ foreach (const CodeCompletionResult &ccr, completions) {
+ if (ccr.completionKind() == CodeCompletionResult::FunctionCompletionKind
+ || ccr.completionKind() == CodeCompletionResult::ConstructorCompletionKind
+ || ccr.completionKind() == CodeCompletionResult::DestructorCompletionKind
+ || ccr.completionKind() == CodeCompletionResult::SignalCompletionKind
+ || ccr.completionKind() == CodeCompletionResult::SlotCompletionKind)
+ if (ccr.text() == functionName)
+ functionCompletions.append(ccr);
+ }
+
+ if (!functionCompletions.isEmpty()) {
+ IFunctionHintProposalModel *model = new ClangFunctionHintModel(functionCompletions);
+ m_hintProposal = new FunctionHintProposal(m_startPosition, model);
+ return m_startPosition;
+ }
+ }
+
+ const QIcon snippetIcon = QIcon(QLatin1String(SNIPPET_ICON_PATH));
+ QList<CodeCompletionResult> completions = unfilteredCompletion(
+ m_interface.data(), fileName, line, column, modifiedInput, signalCompletion || slotCompletion);
+ QHash<QString, ClangAssistProposalItem *> items;
+ foreach (const CodeCompletionResult &ccr, completions) {
+ if (!ccr.isValid())
+ continue;
+ if (signalCompletion && ccr.completionKind() != CodeCompletionResult::SignalCompletionKind)
+ continue;
+ if (slotCompletion && ccr.completionKind() != CodeCompletionResult::SlotCompletionKind)
+ continue;
+
+ const QString txt(ccr.text());
+ ClangAssistProposalItem *item = items.value(txt, 0);
+ if (item) {
+ item->addOverload(ccr);
+ } else {
+ item = new ClangAssistProposalItem;
+ items.insert(txt, item);
+ item->setText(txt);
+ item->setDetail(ccr.hint());
+ item->setOrder(ccr.priority());
+
+ const QString snippet = ccr.snippet();
+ if (!snippet.isEmpty())
+ item->setData(snippet);
+ else
+ item->setData(qVariantFromValue(ccr));
+ }
+
+ // FIXME: show the effective accessebility instead of availability
+ switch (ccr.completionKind()) {
+ case CodeCompletionResult::ClassCompletionKind: item->setIcon(m_icons.iconForType(Icons::ClassIconType)); break;
+ case CodeCompletionResult::EnumCompletionKind: item->setIcon(m_icons.iconForType(Icons::EnumIconType)); break;
+ case CodeCompletionResult::EnumeratorCompletionKind: item->setIcon(m_icons.iconForType(Icons::EnumeratorIconType)); break;
+
+ case CodeCompletionResult::ConstructorCompletionKind: // fall through
+ case CodeCompletionResult::DestructorCompletionKind: // fall through
+ case CodeCompletionResult::FunctionCompletionKind:
+ case CodeCompletionResult::ObjCMessageCompletionKind:
+ switch (ccr.availability()) {
+ case CodeCompletionResult::Available:
+ case CodeCompletionResult::Deprecated:
+ item->setIcon(m_icons.iconForType(Icons::FuncPublicIconType));
+ break;
+ default:
+ item->setIcon(m_icons.iconForType(Icons::FuncPrivateIconType));
+ break;
+ }
+ break;
+
+ case CodeCompletionResult::SignalCompletionKind:
+ item->setIcon(m_icons.iconForType(Icons::SignalIconType));
+ break;
+
+ case CodeCompletionResult::SlotCompletionKind:
+ switch (ccr.availability()) {
+ case CodeCompletionResult::Available:
+ case CodeCompletionResult::Deprecated:
+ item->setIcon(m_icons.iconForType(Icons::SlotPublicIconType));
+ break;
+ case CodeCompletionResult::NotAccessible:
+ case CodeCompletionResult::NotAvailable:
+ item->setIcon(m_icons.iconForType(Icons::SlotPrivateIconType));
+ break;
+ }
+ break;
+
+ case CodeCompletionResult::NamespaceCompletionKind: item->setIcon(m_icons.iconForType(Icons::NamespaceIconType)); break;
+ case CodeCompletionResult::PreProcessorCompletionKind: item->setIcon(m_icons.iconForType(Icons::MacroIconType)); break;
+ case CodeCompletionResult::VariableCompletionKind:
+ switch (ccr.availability()) {
+ case CodeCompletionResult::Available:
+ case CodeCompletionResult::Deprecated:
+ item->setIcon(m_icons.iconForType(Icons::VarPublicIconType));
+ break;
+ default:
+ item->setIcon(m_icons.iconForType(Icons::VarPrivateIconType));
+ break;
+ }
+ break;
+
+ case CodeCompletionResult::KeywordCompletionKind:
+ item->setIcon(m_icons.iconForType(Icons::KeywordIconType));
+ break;
+
+ case CodeCompletionResult::ClangSnippetKind:
+ item->setIcon(snippetIcon);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ foreach (ClangAssistProposalItem *item, items.values())
+ m_completions.append(item);
+
+ return m_startPosition;
+}
+
+/**
+ * @brief Creates completion proposals for #include and given cursor
+ * @param cursor - cursor placed after opening bracked or quote
+ * @return false if completions list is empty
+ */
+bool ClangCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
+{
+ QString directoryPrefix;
+ if (m_model->m_completionOperator == T_SLASH) {
+ QTextCursor c = cursor;
+ c.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
+ QString sel = c.selectedText();
+ int startCharPos = sel.indexOf(QLatin1Char('"'));
+ if (startCharPos == -1) {
+ startCharPos = sel.indexOf(QLatin1Char('<'));
+ m_model->m_completionOperator = T_ANGLE_STRING_LITERAL;
+ } else {
+ m_model->m_completionOperator = T_STRING_LITERAL;
+ }
+ if (startCharPos != -1)
+ directoryPrefix = sel.mid(startCharPos + 1, sel.length() - 1);
+ }
+
+ // Make completion for all relevant includes
+ QStringList includePaths = m_interface->includePaths();
+ const QString &currentFilePath = QFileInfo(m_interface->fileName()).path();
+ if (!includePaths.contains(currentFilePath))
+ includePaths.append(currentFilePath);
+
+ const Core::MimeType mimeType = Core::MimeDatabase::findByType(QLatin1String("text/x-c++hdr"));
+ const QStringList suffixes = mimeType.suffixes();
+
+ foreach (const QString &includePath, includePaths) {
+ QString realPath = includePath;
+ if (!directoryPrefix.isEmpty()) {
+ realPath += QLatin1Char('/');
+ realPath += directoryPrefix;
+ }
+ completeIncludePath(realPath, suffixes);
+ }
+
+ foreach (const QString &frameworkPath, m_interface->frameworkPaths()) {
+ QString realPath = frameworkPath;
+ if (!directoryPrefix.isEmpty()) {
+ realPath += QLatin1Char('/');
+ realPath += directoryPrefix;
+ realPath += QLatin1String(".framework/Headers");
+ }
+ completeIncludePath(realPath, suffixes);
+ }
+
+ return !m_completions.isEmpty();
+}
+
+/**
+ * @brief Adds #include completion proposals using given include path
+ * @param realPath - one of directories where compiler searches includes
+ * @param suffixes - file suffixes for C/C++ header files
+ */
+void ClangCompletionAssistProcessor::completeIncludePath(const QString &realPath,
+ const QStringList &suffixes)
+{
+ QDirIterator i(realPath, QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
+ const QString hint =
+ QObject::tr("Location: ", "Parent folder for proposed #include completion")
+ + QDir::cleanPath(realPath);
+ while (i.hasNext()) {
+ const QString fileName = i.next();
+ const QFileInfo fileInfo = i.fileInfo();
+ const QString suffix = fileInfo.suffix();
+ if (suffix.isEmpty() || suffixes.contains(suffix)) {
+ QString text = fileName.mid(realPath.length() + 1);
+ if (fileInfo.isDir())
+ text += QLatin1Char('/');
+
+ ClangAssistProposalItem *item = new ClangAssistProposalItem;
+ item->setText(text);
+ item->setDetail(hint);
+ item->setIcon(m_icons.keywordIcon());
+ item->keepCompletionOperator(m_model->m_completionOperator);
+ m_completions.append(item);
+ }
+ }
+}
+
+void ClangCompletionAssistProcessor::completePreprocessor()
+{
+ foreach (const QString &preprocessorCompletion, m_preprocessorCompletions)
+ addCompletionItem(preprocessorCompletion,
+ m_icons.iconForType(Icons::MacroIconType));
+
+ if (m_interface->objcEnabled())
+ addCompletionItem(QLatin1String("import"),
+ m_icons.iconForType(Icons::MacroIconType));
+}
+
+void ClangCompletionAssistProcessor::addCompletionItem(const QString &text,
+ const QIcon &icon,
+ int order,
+ const QVariant &data)
+{
+ ClangAssistProposalItem *item = new ClangAssistProposalItem;
+ item->setText(text);
+ item->setIcon(icon);
+ item->setOrder(order);
+ item->setData(data);
+ item->keepCompletionOperator(m_model->m_completionOperator);
+ m_completions.append(item);
+}
diff --git a/src/plugins/clangcodemodel/clangcompletion.h b/src/plugins/clangcodemodel/clangcompletion.h
new file mode 100644
index 0000000000..2ef11fe9e9
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangcompletion.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CPPEDITOR_INTERNAL_CLANGCOMPLETION_H
+#define CPPEDITOR_INTERNAL_CLANGCOMPLETION_H
+
+#include "clangcompleter.h"
+
+#include <cplusplus/Icons.h>
+
+#include <cpptools/cppcompletionassistprovider.h>
+
+#include <texteditor/codeassist/basicproposalitem.h>
+#include <texteditor/codeassist/completionassistprovider.h>
+#include <texteditor/codeassist/defaultassistinterface.h>
+#include <texteditor/codeassist/iassistprocessor.h>
+
+#include <QStringList>
+#include <QTextCursor>
+
+namespace ClangCodeModel {
+
+namespace Internal {
+class ClangAssistProposalModel;
+
+class ClangCompletionAssistProvider : public CppTools::CppCompletionAssistProvider
+{
+public:
+ ClangCompletionAssistProvider();
+
+ virtual TextEditor::IAssistProcessor *createProcessor() const;
+ virtual TextEditor::IAssistInterface *createAssistInterface(
+ ProjectExplorer::Project *project, TextEditor::BaseTextEditor *editor,
+ QTextDocument *document, int position, TextEditor::AssistReason reason) const;
+
+private:
+ ClangCodeModel::ClangCompleter::Ptr m_clangCompletionWrapper;
+};
+
+} // namespace Internal
+
+class CLANG_EXPORT ClangCompletionAssistInterface: public TextEditor::DefaultAssistInterface
+{
+public:
+ ClangCompletionAssistInterface(ClangCodeModel::ClangCompleter::Ptr clangWrapper,
+ QTextDocument *document,
+ int position,
+ const QString &fileName,
+ TextEditor::AssistReason reason,
+ const QStringList &options,
+ const QStringList &includePaths,
+ const QStringList &frameworkPaths,
+ const Internal::PchInfo::Ptr &pchInfo);
+
+ ClangCodeModel::ClangCompleter::Ptr clangWrapper() const
+ { return m_clangWrapper; }
+
+ const ClangCodeModel::Internal::UnsavedFiles &unsavedFiles() const
+ { return m_unsavedFiles; }
+
+ bool objcEnabled() const;
+
+ const QStringList &options() const
+ { return m_options; }
+
+ const QStringList &includePaths() const
+ { return m_includePaths; }
+
+ const QStringList &frameworkPaths() const
+ { return m_frameworkPaths; }
+
+private:
+ ClangCodeModel::ClangCompleter::Ptr m_clangWrapper;
+ ClangCodeModel::Internal::UnsavedFiles m_unsavedFiles;
+ QStringList m_options, m_includePaths, m_frameworkPaths;
+ Internal::PchInfo::Ptr m_savedPchPointer;
+};
+
+class CLANG_EXPORT ClangCompletionAssistProcessor : public TextEditor::IAssistProcessor
+{
+public:
+ ClangCompletionAssistProcessor();
+ virtual ~ClangCompletionAssistProcessor();
+
+ virtual TextEditor::IAssistProposal *perform(const TextEditor::IAssistInterface *interface);
+
+private:
+ int startCompletionHelper();
+ int startOfOperator(int pos, unsigned *kind, bool wantFunctionCall) const;
+ int findStartOfName(int pos = -1) const;
+ bool accepts() const;
+ TextEditor::IAssistProposal *createContentProposal();
+
+ int startCompletionInternal(const QString fileName,
+ unsigned line, unsigned column,
+ int endOfExpression);
+
+ bool completeInclude(const QTextCursor &cursor);
+ void completeIncludePath(const QString &realPath, const QStringList &suffixes);
+ void completePreprocessor();
+ void addCompletionItem(const QString &text,
+ const QIcon &icon = QIcon(),
+ int order = 0,
+ const QVariant &data = QVariant());
+
+private:
+ int m_startPosition;
+ QScopedPointer<const ClangCompletionAssistInterface> m_interface;
+ QList<TextEditor::BasicProposalItem *> m_completions;
+ CPlusPlus::Icons m_icons;
+ QStringList m_preprocessorCompletions;
+ QScopedPointer<Internal::ClangAssistProposalModel> m_model;
+ TextEditor::IAssistProposal *m_hintProposal;
+};
+
+} // namespace Clang
+
+#endif // CPPEDITOR_INTERNAL_CLANGCOMPLETION_H
diff --git a/src/plugins/clangcodemodel/clanghighlightingsupport.cpp b/src/plugins/clangcodemodel/clanghighlightingsupport.cpp
new file mode 100644
index 0000000000..ef127054ae
--- /dev/null
+++ b/src/plugins/clangcodemodel/clanghighlightingsupport.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clanghighlightingsupport.h"
+
+#include <coreplugin/idocument.h>
+#include <texteditor/basetexteditor.h>
+#include <texteditor/itexteditor.h>
+
+#include <QTextBlock>
+#include <QTextEdit>
+#include "pchmanager.h"
+
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+using namespace CppTools;
+
+ClangHighlightingSupport::ClangHighlightingSupport(TextEditor::ITextEditor *textEditor, FastIndexer *fastIndexer)
+ : CppHighlightingSupport(textEditor)
+ , m_fastIndexer(fastIndexer)
+ , m_semanticMarker(new ClangCodeModel::SemanticMarker)
+{
+}
+
+ClangHighlightingSupport::~ClangHighlightingSupport()
+{
+}
+
+bool ClangHighlightingSupport::hightlighterHandlesIfdefedOutBlocks() const
+{
+#if CINDEX_VERSION_MINOR >= 21
+ return true;
+#else
+ return false;
+#endif
+}
+
+QFuture<TextEditor::HighlightingResult> ClangHighlightingSupport::highlightingFuture(
+ const CPlusPlus::Document::Ptr &doc,
+ const CPlusPlus::Snapshot &snapshot) const
+{
+ Q_UNUSED(doc);
+ Q_UNUSED(snapshot);
+
+ TextEditor::BaseTextEditorWidget *ed = qobject_cast<TextEditor::BaseTextEditorWidget *>(editor()->widget());
+ int firstLine = 1;
+ int lastLine = ed->document()->blockCount();
+
+ const QString fileName = editor()->document()->filePath();
+ CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
+ QList<ProjectPart::Ptr> parts = modelManager->projectPart(fileName);
+ if (parts.isEmpty())
+ parts += modelManager->fallbackProjectPart();
+ QStringList options;
+ PchInfo::Ptr pchInfo;
+ foreach (const ProjectPart::Ptr &part, parts) {
+ if (part.isNull())
+ continue;
+ options = Utils::createClangOptions(part, fileName);
+ pchInfo = PCHManager::instance()->pchInfo(part);
+ if (!pchInfo.isNull())
+ options.append(ClangCodeModel::Utils::createPCHInclusionOptions(pchInfo->fileName()));
+ if (!options.isEmpty())
+ break;
+ }
+
+ CreateMarkers *createMarkers = CreateMarkers::create(m_semanticMarker,
+ fileName, options,
+ firstLine, lastLine,
+ m_fastIndexer, pchInfo);
+ return createMarkers->start();
+}
diff --git a/src/plugins/clangcodemodel/clanghighlightingsupport.h b/src/plugins/clangcodemodel/clanghighlightingsupport.h
new file mode 100644
index 0000000000..04280d88f2
--- /dev/null
+++ b/src/plugins/clangcodemodel/clanghighlightingsupport.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANG_CLANGHIGHLIGHTINGSUPPORT_H
+#define CLANG_CLANGHIGHLIGHTINGSUPPORT_H
+
+#include "clangutils.h"
+#include "cppcreatemarkers.h"
+#include "fastindexer.h"
+
+#include <cpptools/cpphighlightingsupport.h>
+
+#include <QObject>
+#include <QScopedPointer>
+
+namespace ClangCodeModel {
+
+class ClangHighlightingSupport: public CppTools::CppHighlightingSupport
+{
+public:
+ ClangHighlightingSupport(TextEditor::ITextEditor *textEditor,
+ Internal::FastIndexer *fastIndexer);
+ ~ClangHighlightingSupport();
+
+ virtual bool requiresSemanticInfo() const
+ { return false; }
+
+ virtual bool hightlighterHandlesDiagnostics() const
+ { return true; }
+
+ virtual bool hightlighterHandlesIfdefedOutBlocks() const;
+
+ virtual QFuture<TextEditor::HighlightingResult> highlightingFuture(
+ const CPlusPlus::Document::Ptr &doc, const CPlusPlus::Snapshot &snapshot) const;
+
+private:
+ Internal::FastIndexer *m_fastIndexer;
+ ClangCodeModel::SemanticMarker::Ptr m_semanticMarker;
+};
+
+} // namespace ClangCodeModel
+
+#endif // CLANG_CLANGHIGHLIGHTINGSUPPORT_H
diff --git a/src/plugins/clangcodemodel/clangindexer.cpp b/src/plugins/clangcodemodel/clangindexer.cpp
new file mode 100644
index 0000000000..34449b2f3c
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangindexer.cpp
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangindexer.h"
+#include "clangsymbolsearcher.h"
+#include "clangutils.h"
+#include "indexer.h"
+#include "liveunitsmanager.h"
+
+#include <coreplugin/icore.h>
+#include <coreplugin/progressmanager/progressmanager.h>
+#include <cpptools/cppmodelmanagerinterface.h>
+#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/session.h>
+
+#include <QDir>
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+
+ClangIndexingSupport::ClangIndexingSupport(ClangIndexer *indexer)
+ : m_indexer(indexer)
+{
+}
+
+ClangIndexingSupport::~ClangIndexingSupport()
+{
+}
+
+QFuture<void> ClangIndexingSupport::refreshSourceFiles(const QStringList &sourceFiles)
+{
+ return m_indexer->refreshSourceFiles(sourceFiles);
+}
+
+CppTools::SymbolSearcher *ClangIndexingSupport::createSymbolSearcher(CppTools::SymbolSearcher::Parameters parameters, QSet<QString> fileNames)
+{
+ return new ClangSymbolSearcher(m_indexer, parameters, fileNames);
+}
+
+ClangIndexer::ClangIndexer()
+ : QObject(0)
+ , m_indexingSupport(new ClangIndexingSupport(this))
+ , m_isLoadingSession(false)
+ , m_clangIndexer(new Indexer(this))
+{
+ connect(m_clangIndexer, SIGNAL(indexingStarted(QFuture<void>)),
+ this, SLOT(onIndexingStarted(QFuture<void>)));
+
+ ProjectExplorer::ProjectExplorerPlugin *pe =
+ ProjectExplorer::ProjectExplorerPlugin::instance();
+
+ ProjectExplorer::SessionManager *session = pe->session();
+ connect(session, SIGNAL(aboutToLoadSession(QString)),
+ this, SLOT(onAboutToLoadSession(QString)));
+ connect(session, SIGNAL(sessionLoaded(QString)),
+ this, SLOT(onSessionLoaded(QString)));
+ connect(session, SIGNAL(aboutToSaveSession()),
+ this, SLOT(onAboutToSaveSession()));
+}
+
+ClangIndexer::~ClangIndexer()
+{
+ m_clangIndexer->cancel(true);
+}
+
+CppTools::CppIndexingSupport *ClangIndexer::indexingSupport()
+{
+ return m_indexingSupport.data();
+}
+
+QFuture<void> ClangIndexer::refreshSourceFiles(const QStringList &sourceFiles)
+{
+ typedef CppTools::ProjectPart ProjectPart;
+ CppTools::CppModelManagerInterface *mmi = CppTools::CppModelManagerInterface::instance();
+ LiveUnitsManager *lum = LiveUnitsManager::instance();
+
+ if (m_clangIndexer->isBusy())
+ m_clangIndexer->cancel(true);
+
+ foreach (const QString &file, sourceFiles) {
+ if (lum->isTracking(file))
+ continue; // we get notified separately about open files.
+ const QList<ProjectPart::Ptr> &parts = mmi->projectPart(file);
+ if (!parts.isEmpty())
+ m_clangIndexer->addFile(file, parts.at(0));
+ else
+ m_clangIndexer->addFile(file, ProjectPart::Ptr());
+ }
+
+ if (!m_isLoadingSession)
+ m_clangIndexer->regenerate();
+
+ return QFuture<void>();
+}
+
+void ClangIndexer::match(ClangSymbolSearcher *searcher) const
+{
+ m_clangIndexer->match(searcher);
+}
+
+void ClangIndexer::onAboutToLoadSession(const QString &sessionName)
+{
+ m_isLoadingSession = true;
+
+ if (sessionName == QLatin1String("default"))
+ return;
+
+ QString path = Core::ICore::instance()->userResourcePath() + QLatin1String("/codemodel/");
+ if (QFile::exists(path) || QDir().mkpath(path))
+ m_clangIndexer->initialize(path + sessionName + QLatin1String(".qci"));
+}
+
+void ClangIndexer::onSessionLoaded(QString)
+{
+ m_isLoadingSession = false;
+ m_clangIndexer->regenerate();
+}
+
+void ClangIndexer::onAboutToSaveSession()
+{
+ m_clangIndexer->finalize();
+}
+
+void ClangIndexer::indexNow(Unit::Ptr unit)
+{
+ typedef CppTools::ProjectPart ProjectPart;
+
+ QString file = unit->fileName();
+ CppTools::CppModelManagerInterface *mmi = CppTools::CppModelManagerInterface::instance();
+ const QList<ProjectPart::Ptr> &parts = mmi->projectPart(file);
+ ProjectPart::Ptr part;
+ if (!parts.isEmpty())
+ part = parts.at(0);
+ if (!m_isLoadingSession)
+ m_clangIndexer->runQuickIndexing(unit, part);
+}
+
+void ClangIndexer::onIndexingStarted(QFuture<void> indexingFuture)
+{
+ Core::ICore::instance()->progressManager()->addTask(indexingFuture,
+ tr("C++ Indexing"),
+ QLatin1String("Key.Temp.Indexing"));
+}
diff --git a/src/plugins/debugger/lldblib/lldbenginehost.h b/src/plugins/clangcodemodel/clangindexer.h
index d39f6748a9..ec86f954ce 100644
--- a/src/plugins/debugger/lldblib/lldbenginehost.h
+++ b/src/plugins/clangcodemodel/clangindexer.h
@@ -27,62 +27,68 @@
**
****************************************************************************/
-#ifndef DEBUGGER_LLDBENGINE_HOST_H
-#define DEBUGGER_LLDBENGINE_HOST_H
+#ifndef CLANGINDEXER_H
+#define CLANGINDEXER_H
-#include "ipcenginehost.h"
-#include <ssh/ssherrors.h>
-#include <ssh/sshconnection.h>
-#include <ssh/sshremoteprocess.h>
-#include <ssh/sshremoteprocessrunner.h>
+#include "fastindexer.h"
-#include <QProcess>
-#include <QQueue>
+#include <cpptools/cppindexingsupport.h>
+
+#include <QObject>
+
+namespace ClangCodeModel {
+
+class Indexer;
-namespace Debugger {
namespace Internal {
-class SshIODevice : public QIODevice
+class ClangIndexer;
+class ClangSymbolSearcher;
+
+class ClangIndexingSupport: public CppTools::CppIndexingSupport
{
-Q_OBJECT
public:
- SshIODevice(QSsh::SshRemoteProcessRunner *r);
- ~SshIODevice();
- virtual qint64 bytesAvailable () const;
- virtual qint64 writeData (const char * data, qint64 maxSize);
- virtual qint64 readData (char * data, qint64 maxSize);
-private slots:
- void processStarted();
- void outputAvailable();
- void errorOutputAvailable();
+ ClangIndexingSupport(ClangIndexer *indexer);
+ virtual ~ClangIndexingSupport();
+
+ virtual QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
+ virtual CppTools::SymbolSearcher *createSymbolSearcher(CppTools::SymbolSearcher::Parameters parameters, QSet<QString> fileNames);
+
private:
- QSsh::SshRemoteProcessRunner *runner;
- QSsh::SshRemoteProcess::Ptr proc;
- int buckethead;
- QQueue<QByteArray> buckets;
- QByteArray startupbuffer;
+ ClangIndexer *m_indexer;
};
-class LldbEngineHost : public IPCEngineHost
+class ClangIndexer: public QObject, public FastIndexer
{
Q_OBJECT
public:
- explicit LldbEngineHost(const DebuggerStartParameters &startParameters);
- ~LldbEngineHost();
+ ClangIndexer();
+ ~ClangIndexer();
+
+ CppTools::CppIndexingSupport *indexingSupport();
+
+ QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
+
+ void match(ClangSymbolSearcher *searcher) const;
+
+ void indexNow(Unit::Ptr unit);
+
+public slots:
+ void onAboutToLoadSession(const QString &sessionName);
+ void onSessionLoaded(QString);
+ void onAboutToSaveSession();
-private:
- QProcess *m_guestProcess;
- QSsh::SshRemoteProcessRunner *m_ssh;
-protected:
- void nuke();
private slots:
- void sshConnectionError(QSsh::SshError);
- void finished(int, QProcess::ExitStatus);
- void stderrReady();
+ void onIndexingStarted(QFuture<void> indexingFuture);
+
+private:
+ QScopedPointer<ClangIndexingSupport> m_indexingSupport;
+ bool m_isLoadingSession;
+ Indexer *m_clangIndexer;
};
} // namespace Internal
-} // namespace Debugger
+} // namespace ClangCodeModel
-#endif // DEBUGGER_LLDBENGINE_HOST_H
+#endif // CLANGINDEXER_H
diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp
new file mode 100644
index 0000000000..1e53a0f2e5
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangcompletion.h"
+#include "clanghighlightingsupport.h"
+#include "clangmodelmanagersupport.h"
+
+#include <QCoreApplication>
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+
+ModelManagerSupport::ModelManagerSupport(FastIndexer *fastIndexer)
+ : m_completionAssistProvider(new ClangCompletionAssistProvider)
+ , m_fastIndexer(fastIndexer)
+{
+}
+
+ModelManagerSupport::~ModelManagerSupport()
+{
+}
+
+QString ModelManagerSupport::id() const
+{
+ return QLatin1String("ClangCodeMode.ClangCodeMode");
+}
+
+QString ModelManagerSupport::displayName() const
+{
+ return QCoreApplication::translate("ModelManagerSupport::displayName",
+ "Clang");
+}
+
+CppTools::CppCompletionAssistProvider *ModelManagerSupport::completionAssistProvider()
+{
+ return m_completionAssistProvider.data();
+}
+
+CppTools::CppHighlightingSupport *ModelManagerSupport::highlightingSupport(
+ TextEditor::ITextEditor *editor)
+{
+ return new ClangHighlightingSupport(editor, m_fastIndexer);
+}
diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.h b/src/plugins/clangcodemodel/clangmodelmanagersupport.h
new file mode 100644
index 0000000000..3180732d4e
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANGCODEMODEL_INTERNAL_CLANGMODELMANAGERSUPPORT_H
+#define CLANGCODEMODEL_INTERNAL_CLANGMODELMANAGERSUPPORT_H
+
+#include <cpptools/cppmodelmanagersupport.h>
+
+#include <QScopedPointer>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class FastIndexer;
+
+class ModelManagerSupport: public CppTools::ModelManagerSupport
+{
+ Q_DISABLE_COPY(ModelManagerSupport)
+
+public:
+ ModelManagerSupport(FastIndexer *fastIndexer);
+ virtual ~ModelManagerSupport();
+
+ virtual QString id() const;
+ virtual QString displayName() const;
+
+ virtual CppTools::CppCompletionAssistProvider *completionAssistProvider();
+ virtual CppTools::CppHighlightingSupport *highlightingSupport(TextEditor::ITextEditor *editor);
+
+private:
+ QScopedPointer<CppTools::CppCompletionAssistProvider> m_completionAssistProvider;
+ FastIndexer *m_fastIndexer;
+};
+
+} // namespace Internal
+} // namespace ClangCodeModel
+
+#endif // CLANGCODEMODEL_INTERNAL_CLANGMODELMANAGERSUPPORT_H
diff --git a/src/plugins/clangcodemodel/clangprojectsettings.cpp b/src/plugins/clangcodemodel/clangprojectsettings.cpp
new file mode 100644
index 0000000000..2915050dc8
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangprojectsettings.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangprojectsettings.h"
+
+using namespace ClangCodeModel;
+
+ClangProjectSettings::ClangProjectSettings(ProjectExplorer::Project *project)
+ : m_project(project)
+ , m_pchUsage(PchUse_None)
+{
+ Q_ASSERT(project);
+
+ connect(project, SIGNAL(settingsLoaded()),
+ this, SLOT(pullSettings()));
+ connect(project, SIGNAL(aboutToSaveSettings()),
+ this, SLOT(pushSettings()));
+}
+
+ClangProjectSettings::~ClangProjectSettings()
+{
+}
+
+ProjectExplorer::Project *ClangProjectSettings::project() const
+{
+ return m_project;
+}
+
+ClangProjectSettings::PchUsage ClangProjectSettings::pchUsage() const
+{
+ return m_pchUsage;
+}
+
+void ClangProjectSettings::setPchUsage(ClangProjectSettings::PchUsage pchUsage)
+{
+ if (pchUsage < PchUse_None || pchUsage > PchUse_Custom)
+ return;
+
+ if (m_pchUsage != pchUsage) {
+ m_pchUsage = pchUsage;
+ emit pchSettingsChanged();
+ }
+}
+
+QString ClangProjectSettings::customPchFile() const
+{
+ return m_customPchFile;
+}
+
+void ClangProjectSettings::setCustomPchFile(const QString &customPchFile)
+{
+ if (m_customPchFile != customPchFile) {
+ m_customPchFile = customPchFile;
+ emit pchSettingsChanged();
+ }
+}
+
+static QLatin1String PchUsageKey("PchUsage");
+static QLatin1String CustomPchFileKey("CustomPchFile");
+static QLatin1String SettingsNameKey("ClangProjectSettings");
+
+void ClangProjectSettings::pushSettings()
+{
+ QVariantMap settings;
+ settings[PchUsageKey] = m_pchUsage;
+ settings[CustomPchFileKey] = m_customPchFile;
+
+ QVariant s(settings);
+ m_project->setNamedSettings(SettingsNameKey, s);
+}
+
+void ClangProjectSettings::pullSettings()
+{
+ QVariant s = m_project->namedSettings(SettingsNameKey);
+ QVariantMap settings = s.toMap();
+
+ const PchUsage storedPchUsage = static_cast<PchUsage>(
+ settings.value(PchUsageKey, PchUse_Unknown).toInt());
+ if (storedPchUsage != PchUse_Unknown)
+ setPchUsage(storedPchUsage);
+ setCustomPchFile(settings.value(CustomPchFileKey).toString());
+}
diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.h b/src/plugins/clangcodemodel/clangprojectsettings.h
index cf1f82cb7f..c1ced58fae 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.h
+++ b/src/plugins/clangcodemodel/clangprojectsettings.h
@@ -27,41 +27,56 @@
**
****************************************************************************/
-#ifndef GRADIENTLINEQMLADAPTOR_H
-#define GRADIENTLINEQMLADAPTOR_H
+#ifndef CLANGPROJECTSETTINGS_H
+#define CLANGPROJECTSETTINGS_H
-#include <qmleditorwidgets/gradientline.h>
-#include <qmlitemnode.h>
+#include "clang_global.h"
-namespace QmlDesigner {
+#include <projectexplorer/project.h>
-class GradientLineQmlAdaptor : public QmlEditorWidgets::GradientLine
+#include <QObject>
+#include <QString>
+
+namespace ClangCodeModel {
+
+class CLANG_EXPORT ClangProjectSettings: public QObject
{
Q_OBJECT
- Q_PROPERTY(QVariant itemNode READ itemNode WRITE setItemNode NOTIFY itemNodeChanged)
+public:
+ enum PchUsage {
+ PchUse_Unknown = 0,
+ PchUse_None = 1,
+ PchUse_BuildSystem_Exact = 2,
+ PchUse_BuildSystem_Fuzzy = 3,
+ PchUse_Custom = 4
+ };
public:
- explicit GradientLineQmlAdaptor(QWidget *parent = 0);
+ ClangProjectSettings(ProjectExplorer::Project *project);
+ virtual ~ClangProjectSettings();
+
+ ProjectExplorer::Project *project() const;
- static void registerDeclarativeType();
+ PchUsage pchUsage() const;
+ void setPchUsage(PchUsage pchUsage);
+
+ QString customPchFile() const;
+ void setCustomPchFile(const QString &customPchFile);
signals:
- void itemNodeChanged();
+ void pchSettingsChanged();
public slots:
- void setupGradient();
- void writeGradient();
- void deleteGradient();
+ void pullSettings();
+ void pushSettings();
private:
- QVariant itemNode() const { return QVariant::fromValue(m_itemNode.modelNode()); }
- void setItemNode(const QVariant &itemNode);
-
- QmlItemNode m_itemNode;
-
+ ProjectExplorer::Project *m_project;
+ PchUsage m_pchUsage;
+ QString m_customPchFile;
};
-} //QmlDesigner
+} // ClangCodeModel namespace
-#endif // GRADIENTLINEQMLADAPTOR_H
+#endif // CLANGPROJECTSETTINGS_H
diff --git a/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.cpp b/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.cpp
new file mode 100644
index 0000000000..d1def6e0de
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangprojectsettings.h"
+#include "clangprojectsettingspropertiespage.h"
+#include "pchmanager.h"
+
+#include <QButtonGroup>
+#include <QCoreApplication>
+#include <QFileDialog>
+
+using namespace ProjectExplorer;
+using namespace ClangCodeModel::Internal;
+
+static const char CLANGPROJECTSETTINGS_PANEL_ID[] = "ClangCodeModel.ProjectPanel";
+
+
+QString ClangProjectSettingsPanelFactory::id() const
+{
+ return QLatin1String(CLANGPROJECTSETTINGS_PANEL_ID);
+}
+
+QString ClangProjectSettingsPanelFactory::displayName() const
+{
+ return QCoreApplication::translate("ClangProjectSettingsPropertiesPage",
+ "Clang Settings");
+}
+
+int ClangProjectSettingsPanelFactory::priority() const
+{
+ return 60;
+}
+
+bool ClangProjectSettingsPanelFactory::supports(Project *project)
+{
+ Q_UNUSED(project);
+
+ return true;
+}
+
+PropertiesPanel *ClangProjectSettingsPanelFactory::createPanel(Project *project)
+{
+ PropertiesPanel *panel = new PropertiesPanel;
+ panel->setDisplayName(QCoreApplication::translate(
+ "ClangProjectSettingsPropertiesPage",
+ "Clang Settings"));
+ panel->setWidget(new ClangProjectSettingsWidget(project));
+ return panel;
+}
+
+ClangProjectSettingsWidget::ClangProjectSettingsWidget(Project *project)
+ : m_project(project)
+{
+ m_ui.setupUi(this);
+
+ ClangProjectSettings *cps = PCHManager::instance()->settingsForProject(project);
+ Q_ASSERT(cps);
+
+ QButtonGroup *pchGroup = new QButtonGroup(this);
+ pchGroup->addButton(m_ui.noneButton, ClangProjectSettings::PchUse_None);
+ pchGroup->addButton(m_ui.exactButton, ClangProjectSettings::PchUse_BuildSystem_Exact);
+ pchGroup->addButton(m_ui.fuzzyButton, ClangProjectSettings::PchUse_BuildSystem_Fuzzy);
+ pchGroup->addButton(m_ui.customButton, ClangProjectSettings::PchUse_Custom);
+ switch (cps->pchUsage()) {
+ case ClangProjectSettings::PchUse_None:
+ case ClangProjectSettings::PchUse_BuildSystem_Exact:
+ case ClangProjectSettings::PchUse_BuildSystem_Fuzzy:
+ case ClangProjectSettings::PchUse_Custom:
+ pchGroup->button(cps->pchUsage())->setChecked(true);
+ break;
+ default: break;
+ }
+ pchUsageChanged(cps->pchUsage());
+ connect(pchGroup, SIGNAL(buttonClicked(int)),
+ this, SLOT(pchUsageChanged(int)));
+
+ m_ui.customField->setText(cps->customPchFile());
+ connect(m_ui.customField, SIGNAL(editingFinished()),
+ this, SLOT(customPchFileChanged()));
+ connect(m_ui.customButton, SIGNAL(clicked()),
+ this, SLOT(customPchButtonClicked()));
+}
+
+void ClangProjectSettingsWidget::pchUsageChanged(int id)
+{
+ ClangProjectSettings *cps = PCHManager::instance()->settingsForProject(m_project);
+ Q_ASSERT(cps);
+ cps->setPchUsage(static_cast<ClangProjectSettings::PchUsage>(id));
+
+ switch (id) {
+ case ClangProjectSettings::PchUse_None:
+ case ClangProjectSettings::PchUse_BuildSystem_Fuzzy:
+ case ClangProjectSettings::PchUse_BuildSystem_Exact:
+ m_ui.customField->setEnabled(false);
+ m_ui.chooseButton->setEnabled(false);
+ break;
+
+ case ClangProjectSettings::PchUse_Custom:
+ m_ui.customField->setEnabled(true);
+ m_ui.chooseButton->setEnabled(true);
+ break;
+
+ default:
+ break;
+ }
+}
+
+void ClangProjectSettingsWidget::customPchFileChanged()
+{
+ ClangProjectSettings *cps = PCHManager::instance()->settingsForProject(m_project);
+ Q_ASSERT(cps);
+ if (cps->pchUsage() != ClangProjectSettings::PchUse_Custom)
+ return;
+ QString fileName = m_ui.customField->text();
+ if (!QFile(fileName).exists())
+ return;
+
+ cps->setCustomPchFile(fileName);
+}
+
+void ClangProjectSettingsWidget::customPchButtonClicked()
+{
+ ClangProjectSettings *cps = PCHManager::instance()->settingsForProject(m_project);
+ Q_ASSERT(cps);
+
+ QFileDialog d(this);
+ d.setNameFilters(QStringList() << tr("Header Files (*.h)")
+ << tr("All Files (*)"));
+ d.setFileMode(QFileDialog::ExistingFile);
+ d.setDirectory(m_project->projectDirectory());
+ if (!d.exec())
+ return;
+ const QStringList fileNames = d.selectedFiles();
+ if (fileNames.isEmpty() || fileNames.first().isEmpty())
+ return;
+
+ m_ui.customField->setText(fileNames.first());
+ cps->setCustomPchFile(fileNames.first());
+}
diff --git a/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.h b/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.h
new file mode 100644
index 0000000000..7f826a4830
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANGPROJECTSETTINGSPROPERTIESPAGE_H
+#define CLANGPROJECTSETTINGSPROPERTIESPAGE_H
+
+#include "ui_clangprojectsettingspropertiespage.h"
+
+#include <projectexplorer/iprojectproperties.h>
+
+#include <QString>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class ClangProjectSettingsPanelFactory: public ProjectExplorer::IProjectPanelFactory
+{
+public:
+ QString id() const;
+ QString displayName() const;
+ int priority() const;
+ bool supports(ProjectExplorer::Project *project);
+ ProjectExplorer::PropertiesPanel *createPanel(ProjectExplorer::Project *project);
+};
+
+class ClangProjectSettingsWidget: public QWidget
+{
+ Q_OBJECT
+
+public:
+ ClangProjectSettingsWidget(ProjectExplorer::Project *project);
+
+protected slots:
+ void pchUsageChanged(int id);
+ void customPchFileChanged();
+ void customPchButtonClicked();
+
+private:
+ Ui::ClangProjectSettingsPropertiesPage m_ui;
+ ProjectExplorer::Project *m_project;
+};
+
+} // ClangCodeModel namespace
+} // Internal namespace
+
+#endif // CLANGPROJECTSETTINGSPROPERTIESPAGE_H
diff --git a/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.ui b/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.ui
new file mode 100644
index 0000000000..66dcf45c5b
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangprojectsettingspropertiespage.ui
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ClangCodeModel::Internal::ClangProjectSettingsPropertiesPage</class>
+ <widget class="QWidget" name="ClangCodeModel::Internal::ClangProjectSettingsPropertiesPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>814</width>
+ <height>330</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Pre-compiled headers:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QRadioButton" name="noneButton">
+ <property name="text">
+ <string>None</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QRadioButton" name="exactButton">
+ <property name="text">
+ <string>Build system (exact)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QRadioButton" name="fuzzyButton">
+ <property name="text">
+ <string>Build system (fuzzy)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QRadioButton" name="customButton">
+ <property name="text">
+ <string>Custom</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QLineEdit" name="customField">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QPushButton" name="chooseButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Choose...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>12</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/plugins/clangcodemodel/clangsymbolsearcher.cpp b/src/plugins/clangcodemodel/clangsymbolsearcher.cpp
new file mode 100644
index 0000000000..d603a745f2
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangsymbolsearcher.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangsymbolsearcher.h"
+#include "symbol.h"
+
+#include <cpptools/searchsymbols.h>
+
+#include <cassert>
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+
+ClangSymbolSearcher::ClangSymbolSearcher(ClangIndexer *indexer, const Parameters &parameters, QSet<QString> fileNames, QObject *parent)
+ : CppTools::SymbolSearcher(parent)
+ , m_indexer(indexer)
+ , m_parameters(parameters)
+ , m_fileNames(fileNames)
+ , m_future(0)
+{
+ assert(indexer);
+}
+
+ClangSymbolSearcher::~ClangSymbolSearcher()
+{
+}
+
+void ClangSymbolSearcher::runSearch(QFutureInterface<SearchResultItem> &future)
+{
+ m_future = &future;
+ m_indexer->match(this);
+ m_future = 0;
+}
+
+void ClangSymbolSearcher::search(const QLinkedList<Symbol> &allSymbols)
+{
+ QString findString = (m_parameters.flags & Find::FindRegularExpression
+ ? m_parameters.text : QRegExp::escape(m_parameters.text));
+ if (m_parameters.flags & Find::FindWholeWords)
+ findString = QString::fromLatin1("\\b%1\\b").arg(findString);
+ QRegExp matcher(findString, (m_parameters.flags & Find::FindCaseSensitively
+ ? Qt::CaseSensitive : Qt::CaseInsensitive));
+
+ const int chunkSize = 10;
+ QVector<Core::SearchResultItem> resultItems;
+ resultItems.reserve(100);
+
+ m_future->setProgressRange(0, allSymbols.size() % chunkSize);
+ m_future->setProgressValue(0);
+
+ int symbolNr = 0;
+ foreach (const Symbol &s, allSymbols) {
+ if (symbolNr % chunkSize == 0) {
+ m_future->setProgressValue(symbolNr / chunkSize);
+ m_future->reportResults(resultItems);
+ resultItems.clear();
+
+ if (m_future->isPaused())
+ m_future->waitForResume();
+ if (m_future->isCanceled())
+ return;
+ }
+ ++symbolNr;
+
+ CppTools::ModelItemInfo info;
+
+ switch (s.m_kind) {
+ case Symbol::Enum:
+ if (m_parameters.types & SymbolSearcher::Enums) {
+ info.type = CppTools::ModelItemInfo::Enum;
+ info.symbolType = QLatin1String("enum");
+ break;
+ } else {
+ continue;
+ }
+ case Symbol::Class:
+ if (m_parameters.types & SymbolSearcher::Classes) {
+ info.type = CppTools::ModelItemInfo::Class;
+ info.symbolType = QLatin1String("class");
+ break;
+ } else {
+ continue;
+ }
+ case Symbol::Method:
+ case Symbol::Function:
+ case Symbol::Constructor:
+ case Symbol::Destructor:
+ if (m_parameters.types & SymbolSearcher::Functions) {
+ info.type = CppTools::ModelItemInfo::Method;
+ break;
+ } else {
+ continue;
+ }
+ case Symbol::Declaration:
+ if (m_parameters.types & SymbolSearcher::Declarations) {
+ info.type = CppTools::ModelItemInfo::Declaration;
+ break;
+ } else {
+ continue;
+ }
+
+ default: continue;
+ }
+
+ if (matcher.indexIn(s.m_name) == -1)
+ continue;
+
+ info.symbolName = s.m_name;
+ info.fullyQualifiedName = s.m_qualification.split(QLatin1String("::")) << s.m_name;
+ info.fileName = s.m_location.fileName();
+ info.icon = s.iconForSymbol();
+ info.line = s.m_location.line();
+ info.column = s.m_location.column() - 1;
+
+ Core::SearchResultItem item;
+ item.path << s.m_qualification;
+ item.text = s.m_name;
+ item.icon = info.icon;
+ item.textMarkPos = -1;
+ item.textMarkLength = 0;
+ item.lineNumber = -1;
+ item.userData = qVariantFromValue(info);
+
+ resultItems << item;
+ }
+
+ if (!resultItems.isEmpty())
+ m_future->reportResults(resultItems);
+}
diff --git a/src/plugins/clangcodemodel/clangsymbolsearcher.h b/src/plugins/clangcodemodel/clangsymbolsearcher.h
new file mode 100644
index 0000000000..ff59e211c4
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangsymbolsearcher.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANGSYMBOLSEARCHER_H
+#define CLANGSYMBOLSEARCHER_H
+
+#include "clangindexer.h"
+
+#include <cpptools/cppindexingsupport.h>
+
+#include <QLinkedList>
+
+namespace ClangCodeModel {
+
+class Symbol;
+
+namespace Internal {
+
+class ClangSymbolSearcher: public CppTools::SymbolSearcher
+{
+ Q_OBJECT
+
+ typedef CppTools::SymbolSearcher::Parameters Parameters;
+ typedef Core::SearchResultItem SearchResultItem;
+
+public:
+ ClangSymbolSearcher(ClangIndexer *indexer, const Parameters &parameters, QSet<QString> fileNames, QObject *parent = 0);
+ virtual ~ClangSymbolSearcher();
+ virtual void runSearch(QFutureInterface<SearchResultItem> &future);
+
+ void search(const QLinkedList<Symbol> &allSymbols);
+
+private:
+ ClangIndexer *m_indexer;
+ const Parameters m_parameters;
+ const QSet<QString> m_fileNames;
+ QFutureInterface<SearchResultItem> *m_future;
+};
+
+} // namespace Internal
+} // namespace ClangCodeModel
+
+#endif // CLANGSYMBOLSEARCHER_H
diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp
new file mode 100644
index 0000000000..1d11c238dd
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangutils.cpp
@@ -0,0 +1,322 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangutils.h"
+
+#include <clang-c/Index.h>
+
+#include <coreplugin/documentmanager.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/idocument.h>
+
+#include <QFile>
+#include <QSet>
+#include <QString>
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+using namespace Core;
+using namespace CppTools;
+
+namespace ClangCodeModel {
+namespace Utils {
+
+namespace {
+bool isBlacklisted(const QString &path)
+{
+ static QStringList blacklistedPaths = QStringList()
+ << QLatin1String("lib/gcc/i686-apple-darwin");
+
+ foreach (const QString &blacklisted, blacklistedPaths)
+ if (path.contains(blacklisted))
+ return true;
+
+ return false;
+}
+} // anonymous namespace
+
+UnsavedFiles createUnsavedFiles(CppModelManagerInterface::WorkingCopy workingCopy)
+{
+ // TODO: change the modelmanager to hold one working copy, and amend it every time we ask for one.
+ // TODO: Reason: the UnsavedFile needs a QByteArray.
+
+ QSet<QString> modifiedFiles;
+ foreach (IDocument *doc, Core::DocumentManager::modifiedDocuments())
+ modifiedFiles.insert(doc->filePath());
+
+ UnsavedFiles result;
+ QHashIterator<QString, QPair<QByteArray, unsigned> > wcIter = workingCopy.iterator();
+ while (wcIter.hasNext()) {
+ wcIter.next();
+ const QString &fileName = wcIter.key();
+ if (modifiedFiles.contains(fileName) && QFile(fileName).exists())
+ result.insert(fileName, wcIter.value().first);
+ }
+
+ return result;
+}
+
+/**
+ * @brief Creates list of command-line arguments required for correct parsing
+ * @param pPart Null if file isn't part of any project
+ * @param fileName Path to file, non-empty
+ */
+QStringList createClangOptions(const ProjectPart::Ptr &pPart, const QString &fileName)
+{
+ ProjectFile::Kind fileKind = ProjectFile::Unclassified;
+ if (!pPart.isNull())
+ foreach (const ProjectFile &file, pPart->files)
+ if (file.path == fileName) {
+ fileKind = file.kind;
+ break;
+ }
+ if (fileKind == ProjectFile::Unclassified)
+ fileKind = ProjectFile::classify(fileName);
+
+ return createClangOptions(pPart, fileKind);
+}
+
+static QStringList buildDefines(const QByteArray &defines, bool toolchainDefines)
+{
+ QStringList result;
+
+ foreach (QByteArray def, defines.split('\n')) {
+ if (def.isEmpty())
+ continue;
+
+ if (toolchainDefines) {
+ //### FIXME: the next 3 check shouldn't be needed: we probably don't want to get the compiler-defined defines in.
+ if (!def.startsWith("#define "))
+ continue;
+ if (def.startsWith("#define _"))
+ continue;
+ if (def.startsWith("#define OBJC_NEW_PROPERTIES"))
+ continue;
+ }
+
+ QByteArray str = def.mid(8);
+ int spaceIdx = str.indexOf(' ');
+ QString arg;
+ if (spaceIdx != -1) {
+ arg = QLatin1String("-D" + str.left(spaceIdx) + "=" + str.mid(spaceIdx + 1));
+ } else {
+ arg = QLatin1String("-D" + str);
+ }
+ arg = arg.replace(QLatin1String("\\\""), QLatin1String("\""));
+ arg = arg.replace(QLatin1String("\""), QLatin1String(""));
+ if (!result.contains(arg))
+ result.append(arg);
+ }
+
+ return result;
+}
+
+/**
+ * @brief Creates list of command-line arguments required for correct parsing
+ * @param pPart Null if file isn't part of any project
+ * @param fileKind Determines language and source/header state
+ */
+QStringList createClangOptions(const ProjectPart::Ptr &pPart, ProjectFile::Kind fileKind)
+{
+ QStringList result = clangLanguageOption(fileKind);
+ switch (fileKind) {
+ default:
+ case CppTools::ProjectFile::CXXHeader:
+ case CppTools::ProjectFile::CXXSource:
+ case CppTools::ProjectFile::ObjCXXHeader:
+ case CppTools::ProjectFile::ObjCXXSource:
+ case CppTools::ProjectFile::CudaSource:
+ case CppTools::ProjectFile::OpenCLSource:
+ result << clangOptionsForCxx(pPart->qtVersion,
+ pPart->cxxVersion,
+ pPart->cxxExtensions);
+ break;
+ case CppTools::ProjectFile::CHeader:
+ case CppTools::ProjectFile::CSource:
+ case CppTools::ProjectFile::ObjCHeader:
+ case CppTools::ProjectFile::ObjCSource:
+ result << clangOptionsForC(pPart->cVersion,
+ pPart->cxxExtensions);
+ break;
+ }
+
+ if (pPart.isNull())
+ return result;
+
+ result << QLatin1String("-nostdinc");
+
+ result << buildDefines(pPart->toolchainDefines, true);
+ result << buildDefines(pPart->projectDefines, false);
+
+ foreach (const QString &frameworkPath, pPart->frameworkPaths)
+ result.append(QLatin1String("-F") + frameworkPath);
+ foreach (const QString &inc, pPart->includePaths)
+ if (!inc.isEmpty() && !isBlacklisted(inc))
+ result << (QLatin1String("-I") + inc);
+
+#if 0
+ qDebug() << "--- m_args:";
+ foreach (const QString &arg, result)
+ qDebug() << "\t" << qPrintable(arg);
+ qDebug() << "---";
+#endif
+
+ return result;
+}
+
+/// @return Option to speed up parsing with precompiled header
+QStringList createPCHInclusionOptions(const QStringList &pchFiles)
+{
+ QStringList opts;
+
+ foreach (const QString &pchFile, pchFiles) {
+ if (QFile(pchFile).exists()) {
+ opts += QLatin1String("-include-pch");
+ opts += pchFile;
+ }
+ }
+
+ return opts;
+}
+
+/// @return Option to speed up parsing with precompiled header
+QStringList createPCHInclusionOptions(const QString &pchFile)
+{
+ return createPCHInclusionOptions(QStringList() << pchFile);
+}
+
+/// @return "-std" flag to select standard, flags for C extensions
+QStringList clangOptionsForC(ProjectPart::CVersion cVersion, ProjectPart::CXXExtensions cxxExtensions)
+{
+ QStringList opts;
+ bool gnuExpensions = cxxExtensions & ProjectPart::GnuExtensions;
+ switch (cVersion) {
+ case ProjectPart::C89:
+ opts << (gnuExpensions ? QLatin1String("-std=gnu89") : QLatin1String("-std=c89"));
+ break;
+ case ProjectPart::C99:
+ opts << (gnuExpensions ? QLatin1String("-std=gnu99") : QLatin1String("-std=c99"));
+ break;
+ case ProjectPart::C11:
+ opts << (gnuExpensions ? QLatin1String("-std=gnu11") : QLatin1String("-std=c11"));
+ break;
+ }
+
+ if (cxxExtensions & ProjectPart::MicrosoftExtensions) {
+ opts << QLatin1String("-fms-extensions");
+ }
+
+#if defined(CINDEX_VERSION) // clang 3.2 or higher
+ if (cxxExtensions & ProjectPart::BorlandExtensions)
+ opts << QLatin1String("-fborland-extensions");
+#endif
+
+ return opts;
+}
+
+/// @return "-std" flag to select standard, flags for C++ extensions, Qt injections
+QStringList clangOptionsForCxx(ProjectPart::QtVersion qtVersion,
+ ProjectPart::CXXVersion cxxVersion,
+ ProjectPart::CXXExtensions cxxExtensions)
+{
+ QStringList opts;
+ bool gnuExpensions = cxxExtensions & ProjectPart::GnuExtensions;
+ switch (cxxVersion) {
+ case ProjectPart::CXX11:
+ opts << (gnuExpensions ? QLatin1String("-std=gnu++11") : QLatin1String("-std=c++11"));
+ break;
+ case ProjectPart::CXX98:
+ opts << (gnuExpensions ? QLatin1String("-std=gnu++98") : QLatin1String("-std=c++98"));
+ break;
+ }
+
+ if (cxxExtensions & ProjectPart::MicrosoftExtensions) {
+ opts << QLatin1String("-fms-extensions")
+ << QLatin1String("-fdelayed-template-parsing");
+ }
+
+#if defined(CINDEX_VERSION) // clang 3.2 or higher
+ if (cxxExtensions & ProjectPart::BorlandExtensions)
+ opts << QLatin1String("-fborland-extensions");
+#endif
+
+ static const QString injectedHeader(Core::ICore::instance()->resourcePath() + QLatin1String("/cplusplus/qt%1-qobjectdefs-injected.h"));
+// if (qtVersion == ProjectPart::Qt4)
+// opts << QLatin1String("-include") << injectedHeader.arg(QLatin1Char('4'));
+ if (qtVersion == ProjectPart::Qt5)
+ opts << QLatin1String("-include") << injectedHeader.arg(QLatin1Char('5'));
+
+ return opts;
+}
+
+/// @return "-x language-code"
+QStringList clangLanguageOption(ProjectFile::Kind fileKind)
+{
+ QStringList opts;
+ opts += QLatin1String("-x");
+
+ switch (fileKind) {
+ case ProjectFile::CHeader:
+// opts += QLatin1String("c-header");
+// break;
+ case ProjectFile::CXXHeader:
+ default:
+ opts += QLatin1String("c++-header");
+ break;
+ case ProjectFile::CXXSource:
+ opts += QLatin1String("c++");
+ break;
+ case ProjectFile::CSource:
+ opts += QLatin1String("c");
+ break;
+ case ProjectFile::ObjCHeader:
+// opts += QLatin1String("objective-c-header");
+// break;
+ case ProjectFile::ObjCXXHeader:
+ opts += QLatin1String("objective-c++-header");
+ break;
+ case ProjectFile::ObjCSource:
+ opts += QLatin1String("objective-c");
+ break;
+ case ProjectFile::ObjCXXSource:
+ opts += QLatin1String("objective-c++");
+ break;
+ case ProjectFile::OpenCLSource:
+ opts += QLatin1String("cl");
+ break;
+ case ProjectFile::CudaSource:
+ opts += QLatin1String("cuda");
+ break;
+ }
+
+ return opts;
+}
+
+} // namespace Utils
+} // namespace Clang
diff --git a/src/plugins/clangcodemodel/clangutils.h b/src/plugins/clangcodemodel/clangutils.h
new file mode 100644
index 0000000000..bedafe2e0c
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangutils.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CPPTOOLS_CLANGUTILS_H
+#define CPPTOOLS_CLANGUTILS_H
+
+#include "utils.h"
+
+#include <cpptools/cppmodelmanagerinterface.h>
+
+namespace ClangCodeModel {
+namespace Utils {
+
+ClangCodeModel::Internal::UnsavedFiles createUnsavedFiles(CppTools::CppModelManagerInterface::WorkingCopy workingCopy);
+
+QStringList createClangOptions(const CppTools::ProjectPart::Ptr &pPart, CppTools::ProjectFile::Kind fileKind);
+QStringList createClangOptions(const CppTools::ProjectPart::Ptr &pPart, const QString &fileName = QString());
+QStringList clangNonProjectFileOptions(CppTools::ProjectFile::Kind kind);
+QStringList createPCHInclusionOptions(const QStringList &pchFiles);
+QStringList createPCHInclusionOptions(const QString &pchFile);
+
+QStringList clangLanguageOption(CppTools::ProjectFile::Kind fileKind);
+QStringList clangOptionsForC(CppTools::ProjectPart::CVersion cVersion,
+ CppTools::ProjectPart::CXXExtensions cxxExtensions);
+QStringList clangOptionsForCxx(CppTools::ProjectPart::QtVersion qtVersion,
+ CppTools::ProjectPart::CXXVersion cxxVersion,
+ CppTools::ProjectPart::CXXExtensions cxxExtensions);
+
+} // namespace Utils
+} // namespace Clang
+
+#endif // CPPTOOLS_CLANGUTILS_H
diff --git a/src/plugins/clangcodemodel/completionproposalsbuilder.cpp b/src/plugins/clangcodemodel/completionproposalsbuilder.cpp
new file mode 100644
index 0000000000..80b0ee95c2
--- /dev/null
+++ b/src/plugins/clangcodemodel/completionproposalsbuilder.cpp
@@ -0,0 +1,748 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "completionproposalsbuilder.h"
+#include "utils_p.h"
+
+#include <QTextDocument>
+#include <QCoreApplication>
+
+enum PriorityFixes {
+ PriorityFix_ExplicitDestructorCall = 10
+};
+
+namespace ClangCodeModel {
+
+namespace {
+struct ObjCMessagePart {
+ QString text;
+ int signatureLen; // length of "setScale:" in "setScale: 13"
+
+ ObjCMessagePart() : signatureLen(0) {}
+
+ ObjCMessagePart(const QString &signature, int &indentBonus)
+ : text(signature)
+ , signatureLen(signature.length() + indentBonus)
+ {
+ indentBonus = 0;
+ }
+
+ void addToSignature(const QString &signature)
+ {
+ text += signature;
+ signatureLen += signature.length();
+ }
+};
+} // anonymous namespace
+
+/**
+ * @class ClangCodeModel::CompletionProposalsBuilder
+ * @brief Captures completion lists and than processes sequence of completion chunks
+ *
+ * Can produce several completion proposals for one CXCompletionResult, if and
+ * only if result contains chunks with kind 'Optional'
+ * Different proposals can have the same text, it's normal behavior.
+ *
+ * @note Unit tests are in \a clangcompletion_test.cpp
+ *
+ * @note Unresolved problems:
+ * Function hint not appear after space: "foo(1, ";
+ * Slot can have optional arguments, that produces 2 slots.
+ *
+ */
+
+CompletionProposalsBuilder::CompletionProposalsBuilder(QList<CodeCompletionResult> &results, quint64 contexts, bool isSignalSlotCompletion)
+ : m_results(results)
+ , m_contexts(contexts)
+ , m_isSignalSlotCompletion(isSignalSlotCompletion)
+{
+}
+
+void CompletionProposalsBuilder::operator ()(const CXCompletionResult &cxResult)
+{
+ resetWithResult(cxResult);
+
+#if defined(CINDEX_VERSION) && (CINDEX_VERSION > 5)
+ const QString brief = Internal::getQString(clang_getCompletionBriefComment(cxResult.CompletionString));
+ if (!brief.isEmpty())
+ m_comment += QLatin1String("<b>Brief:</b> ") + Qt::escape(brief);
+#endif
+
+ if (m_resultAvailability == CodeCompletionResult::Deprecated) {
+ m_comment += QLatin1String("<b>@note</b> ");
+ m_comment += QCoreApplication::translate("deprecated C++ symbol", "Is deprecated");
+ }
+
+ m_hint = QLatin1String("<p>");
+ switch (m_resultKind) {
+ case CodeCompletionResult::ObjCMessageCompletionKind:
+ concatChunksForObjectiveCMessage(cxResult);
+ break;
+ case CodeCompletionResult::ClassCompletionKind:
+ case CodeCompletionResult::NamespaceCompletionKind:
+ case CodeCompletionResult::EnumeratorCompletionKind:
+ concatChunksForNestedName(cxResult.CompletionString);
+ break;
+ case CodeCompletionResult::ClangSnippetKind:
+ concatChunksAsSnippet(cxResult.CompletionString);
+ break;
+ case CodeCompletionResult::SlotCompletionKind:
+ case CodeCompletionResult::SignalCompletionKind:
+ if (m_isSignalSlotCompletion)
+ concatSlotSignalSignature(cxResult.CompletionString);
+ else
+ concatChunksOnlyTypedText(cxResult.CompletionString);
+ break;
+ default:
+ concatChunksOnlyTypedText(cxResult.CompletionString);
+ break;
+ }
+ m_hint += QLatin1String("</p>");
+ m_hint += m_comment;
+
+ finalize();
+ foreach (const OptionalChunk &chunk, m_optionalChunks) {
+ m_hint.insert(chunk.positionInHint, chunk.hint);
+ finalize();
+ }
+}
+
+/**
+ * @return Internal ClangCodeModel's completion kind, that affects further postprocessing
+ */
+CodeCompletionResult::Kind CompletionProposalsBuilder::getKind(const CXCompletionResult &cxResult)
+{
+ CXCompletionString complStr = cxResult.CompletionString;
+ CXCursorKind cursorKind = cxResult.CursorKind;
+
+ switch (cursorKind) {
+ case CXCursor_Constructor:
+ return CodeCompletionResult::ConstructorCompletionKind;
+
+ case CXCursor_Destructor:
+ return CodeCompletionResult::DestructorCompletionKind;
+
+ case CXCursor_CXXMethod: {
+ const unsigned numAnnotations = clang_getCompletionNumAnnotations(complStr);
+ bool isSignal = false, isSlot = false;
+ for (unsigned i = 0; i < numAnnotations && !isSignal && !isSlot; ++i) {
+ CXString cxAnn = clang_getCompletionAnnotation(complStr, i);
+ QString ann = Internal::getQString(cxAnn);
+ isSignal = ann == QLatin1String("qt_signal");
+ isSlot = ann == QLatin1String("qt_slot");
+ }
+ if (isSignal)
+ return CodeCompletionResult::SignalCompletionKind;
+ if (isSlot)
+ return CodeCompletionResult::SlotCompletionKind;
+ } // intentional fall-through!
+ case CXCursor_ConversionFunction:
+ case CXCursor_FunctionDecl:
+ case CXCursor_FunctionTemplate:
+ case CXCursor_MemberRef:
+ case CXCursor_MemberRefExpr:
+ return CodeCompletionResult::FunctionCompletionKind;
+ break;
+
+ case CXCursor_FieldDecl:
+ case CXCursor_VarDecl:
+ case CXCursor_ParmDecl:
+ case CXCursor_ObjCIvarDecl:
+ case CXCursor_ObjCPropertyDecl:
+ case CXCursor_ObjCSynthesizeDecl:
+ case CXCursor_NonTypeTemplateParameter:
+ return CodeCompletionResult::VariableCompletionKind;
+
+ case CXCursor_Namespace:
+ case CXCursor_NamespaceAlias:
+ case CXCursor_NamespaceRef:
+ return CodeCompletionResult::NamespaceCompletionKind;
+
+ case CXCursor_StructDecl:
+ case CXCursor_UnionDecl:
+ case CXCursor_ClassDecl:
+ case CXCursor_TypeRef:
+ case CXCursor_TemplateRef:
+ case CXCursor_TypedefDecl:
+ case CXCursor_ClassTemplate:
+ case CXCursor_ClassTemplatePartialSpecialization:
+ case CXCursor_ObjCClassRef:
+ case CXCursor_ObjCInterfaceDecl:
+ case CXCursor_ObjCImplementationDecl:
+ case CXCursor_ObjCCategoryDecl:
+ case CXCursor_ObjCCategoryImplDecl:
+ case CXCursor_ObjCProtocolDecl:
+ case CXCursor_ObjCProtocolRef:
+ case CXCursor_TemplateTypeParameter:
+ case CXCursor_TemplateTemplateParameter:
+ return CodeCompletionResult::ClassCompletionKind;
+
+ case CXCursor_EnumConstantDecl:
+ return CodeCompletionResult::EnumeratorCompletionKind;
+
+ case CXCursor_EnumDecl:
+ return CodeCompletionResult::EnumCompletionKind;
+
+ case CXCursor_MacroDefinition: {
+ const unsigned numChunks = clang_getNumCompletionChunks(complStr);
+ for (unsigned i = 0; i < numChunks; ++i) {
+ CXCompletionChunkKind kind = clang_getCompletionChunkKind(complStr, i);
+ if (kind == CXCompletionChunk_Placeholder) {
+ return CodeCompletionResult::FunctionCompletionKind;
+ }
+ }
+ return CodeCompletionResult::PreProcessorCompletionKind;
+ }
+
+ case CXCursor_PreprocessingDirective:
+ case CXCursor_MacroExpansion:
+ case CXCursor_InclusionDirective:
+ return CodeCompletionResult::PreProcessorCompletionKind;
+
+ case CXCursor_ObjCClassMethodDecl:
+ case CXCursor_ObjCInstanceMethodDecl:
+ return CodeCompletionResult::ObjCMessageCompletionKind;
+
+ case CXCursor_NotImplemented: {
+ const unsigned numChunks = clang_getNumCompletionChunks(complStr);
+ for (unsigned i = 0; i < numChunks; ++i) {
+ CXCompletionChunkKind kind = clang_getCompletionChunkKind(complStr, i);
+ if (kind == CXCompletionChunk_Placeholder) {
+ return CodeCompletionResult::ClangSnippetKind;
+ }
+ }
+ return CodeCompletionResult::KeywordCompletionKind;
+ }
+
+ default:
+ break;
+ }
+
+ return CodeCompletionResult::Other;
+}
+
+/**
+ * @return Symbol availability, which is almost unused
+ */
+CodeCompletionResult::Availability CompletionProposalsBuilder::getAvailability(const CXCompletionResult &cxResult)
+{
+ CXCompletionString complStr = cxResult.CompletionString;
+ switch (clang_getCompletionAvailability(complStr)) {
+ case CXAvailability_Deprecated:
+ return CodeCompletionResult::Deprecated;
+
+ case CXAvailability_NotAvailable:
+ return CodeCompletionResult::NotAvailable;
+
+ case CXAvailability_NotAccessible:
+ return CodeCompletionResult::NotAccessible;
+
+ default:
+ return CodeCompletionResult::Available;
+ }
+}
+
+/**
+ * @return Start index of name, which is unused in Qt signal/slot signature
+ * @param text Text of Placeholder completion string chunk
+ */
+int CompletionProposalsBuilder::findNameInPlaceholder(const QString &text)
+{
+ bool firstIdPassed = false;
+ bool isInIdentifier = false;
+ int bracesCounter = 0;
+ int idStart = 0;
+
+ for (int i = 0, n = text.size(); i < n; ++i) {
+ const QChar ch = text[i];
+
+ if (ch == QLatin1Char(':')) {
+ firstIdPassed = false;
+ isInIdentifier = false;
+ }
+
+ if (ch == QLatin1Char('<') || ch == QLatin1Char('(')) {
+ if (isInIdentifier && text.mid(idStart, i - idStart) == QLatin1String("const"))
+ firstIdPassed = false;
+ ++bracesCounter;
+ isInIdentifier = false;
+ } else if (ch == QLatin1Char('>') || ch == QLatin1Char(')')) {
+ if (isInIdentifier && text.mid(idStart, i - idStart) == QLatin1String("const"))
+ firstIdPassed = false;
+ --bracesCounter;
+ isInIdentifier = false;
+ } else if (bracesCounter == 0) {
+ if (isInIdentifier) {
+ isInIdentifier = ch.isLetterOrNumber() || (ch == QLatin1Char('_'));
+ if (!isInIdentifier && text.mid(idStart, i - idStart) == QLatin1String("const"))
+ firstIdPassed = false;
+ } else if (ch.isLetter() || (ch == QLatin1Char('_'))) {
+ if (firstIdPassed)
+ return i;
+ isInIdentifier = true;
+ idStart = i;
+ firstIdPassed = true;
+ }
+ }
+ }
+ return text.size();
+}
+
+void CompletionProposalsBuilder::resetWithResult(const CXCompletionResult &cxResult)
+{
+ m_priority = clang_getCompletionPriority(cxResult.CompletionString);
+ m_resultKind = getKind(cxResult);
+ m_resultAvailability = getAvailability(cxResult);
+ m_hasParameters = false;
+ m_hint.clear();
+ m_text.clear();
+ m_snippet.clear();
+ m_comment.clear();
+ m_optionalChunks.clear();
+}
+
+/**
+ * @brief Appends completion proposal initialized with collected data
+ */
+void CompletionProposalsBuilder::finalize()
+{
+ // Fixes code completion: operator and destructor cases
+ if ((m_contexts & CXCompletionContext_DotMemberAccess)
+ || (m_contexts & CXCompletionContext_ArrowMemberAccess)
+ || (m_contexts & CXCompletionContext_AnyValue)) {
+ if (m_resultKind == CodeCompletionResult::DestructorCompletionKind)
+ m_priority *= PriorityFix_ExplicitDestructorCall;
+ else if (m_resultKind == CodeCompletionResult::FunctionCompletionKind
+ && m_text.startsWith(QLatin1String("operator")))
+ return;
+ }
+
+ CodeCompletionResult ccr(m_priority);
+ ccr.setCompletionKind(m_resultKind);
+ ccr.setAvailability(m_resultAvailability);
+ ccr.setHasParameters(m_hasParameters);
+ ccr.setHint(m_hint);
+ ccr.setText(m_text);
+ ccr.setSnippet(m_snippet);
+ m_results.append(ccr);
+}
+
+/**
+ * @brief Creates text, hint and snippet
+ *
+ * Text is just signature, e.g. 'length' for [NSString length] or 'respondsToSelector:'
+ * for [id respondsToSelector:(SEL)sel].
+ * Snippet is actual text, where any message parameter becames snippet part:
+ * 'respondsToSelector:$(SEL)sel$'.
+ * Hint consists of snippet preview and doxygen 'return' entry with returned type.
+ */
+void CompletionProposalsBuilder::concatChunksForObjectiveCMessage(const CXCompletionResult &cxResult)
+{
+ CXCompletionString cxString = cxResult.CompletionString;
+ const unsigned count = clang_getNumCompletionChunks(cxString);
+ unsigned index = 0;
+ QString hintPrefix;
+ if (cxResult.CursorKind == CXCursor_ObjCClassMethodDecl)
+ hintPrefix += QLatin1Char('+');
+ else
+ hintPrefix += QLatin1Char('-');
+ int indentBonus = 1;
+
+ bool addSpaceAtPrefixEnd = true;
+ for (; index < count; ++index) {
+ CXCompletionChunkKind chunkKind = clang_getCompletionChunkKind(cxString, index);
+ if (chunkKind == CXCompletionChunk_TypedText || chunkKind == CXCompletionChunk_Informative) {
+ break;
+ }
+ const QString text = Internal::getQString(clang_getCompletionChunkText(cxString, index), false);
+ if (chunkKind == CXCompletionChunk_ResultType) {
+ hintPrefix += QLatin1String("(");
+ hintPrefix += Qt::escape(text);
+ hintPrefix += QLatin1String(") ");
+ indentBonus += 3 + text.length();
+ addSpaceAtPrefixEnd = false;
+ } else {
+ hintPrefix += Qt::escape(text);
+ indentBonus += text.length();
+ m_snippet += text;
+ }
+ }
+ if (addSpaceAtPrefixEnd) {
+ m_snippet += QLatin1Char(' ');
+ hintPrefix += QLatin1Char(' ');
+ indentBonus += 1;
+ }
+
+ m_hint += hintPrefix;
+
+ QList<ObjCMessagePart> parts;
+ bool previousWasTypedText = false;
+ for (; index < count; ++index) {
+ CXCompletionChunkKind chunkKind = clang_getCompletionChunkKind(cxString, index);
+ const QString text = Internal::getQString(clang_getCompletionChunkText(cxString, index), false);
+
+ switch (chunkKind) {
+ case CXCompletionChunk_TypedText:
+ if (previousWasTypedText)
+ parts.back().addToSignature(text);
+ else
+ parts.append(ObjCMessagePart(text, indentBonus));
+ m_snippet += text;
+ m_text += text;
+ break;
+ case CXCompletionChunk_Informative:
+ parts.append(ObjCMessagePart(text, indentBonus));
+ break;
+ case CXCompletionChunk_Text:
+ case CXCompletionChunk_LeftParen:
+ case CXCompletionChunk_RightParen:
+ case CXCompletionChunk_Comma:
+ case CXCompletionChunk_HorizontalSpace:
+ m_snippet += text;
+ parts.back().text += Qt::escape(text);
+ break;
+ case CXCompletionChunk_Placeholder:
+ appendSnippet(text);
+ parts.back().text += QLatin1String("<b>");
+ parts.back().text += Qt::escape(text);
+ parts.back().text += QLatin1String("</b>");
+ break;
+ case CXCompletionChunk_LeftAngle:
+ m_snippet += text;
+ parts.back().text += QLatin1String("&lt;");
+ break;
+ case CXCompletionChunk_RightAngle:
+ m_snippet += text;
+ parts.back().text += QLatin1String("&gt;");
+ break;
+ default:
+ break;
+ }
+
+ previousWasTypedText = (chunkKind == CXCompletionChunk_TypedText);
+ }
+
+ int indent = 0;
+ foreach (const ObjCMessagePart &part, parts)
+ indent = qMax(indent, part.signatureLen);
+ bool isFirstPart = true;
+ foreach (const ObjCMessagePart &part, parts) {
+ if (!isFirstPart)
+ m_hint += QLatin1String("<br/>");
+ isFirstPart = false;
+ for (int i = 0; i < indent - part.signatureLen; ++i)
+ m_hint += QLatin1String("&nbsp;");
+ m_hint += part.text;
+ }
+}
+
+/**
+ * @brief Creates entries like 'MyClass', 'MyNamespace::', 'MyEnumClass::Value1'
+ */
+void CompletionProposalsBuilder::concatChunksForNestedName(const CXCompletionString &cxString)
+{
+ bool hasPlaceholder = false;
+ unsigned count = clang_getNumCompletionChunks(cxString);
+ for (unsigned i = 0; i < count; ++i) {
+ CXCompletionChunkKind chunkKind = clang_getCompletionChunkKind(cxString, i);
+ QString text = Internal::getQString(clang_getCompletionChunkText(cxString, i), false);
+
+ switch (chunkKind) {
+ case CXCompletionChunk_TypedText:
+ case CXCompletionChunk_Text:
+ m_text += text;
+ m_snippet += text;
+ m_hint += text;
+ break;
+
+ case CXCompletionChunk_LeftAngle:
+ case CXCompletionChunk_RightAngle:
+ case CXCompletionChunk_Comma:
+ case CXCompletionChunk_HorizontalSpace:
+ m_snippet += text;
+ m_hint += Qt::escape(text);
+ break;
+
+ case CXCompletionChunk_Placeholder:
+ hasPlaceholder = true;
+ appendSnippet(text);
+ appendHintBold(text);
+ break;
+
+ default:
+ break;
+ }
+ }
+ if (!hasPlaceholder)
+ m_snippet.clear();
+}
+
+/**
+ * @brief Creates text, snippet and hint for snippet preview
+ *
+ * Text is copy of snippet without '$' marks.
+ * Hint also have 'return' doxygen entry if applicable (e.g. 'typeid...')
+ */
+void CompletionProposalsBuilder::concatChunksAsSnippet(const CXCompletionString &cxString)
+{
+ unsigned count = clang_getNumCompletionChunks(cxString);
+ for (unsigned i = 0; i < count; ++i) {
+ CXCompletionChunkKind chunkKind = clang_getCompletionChunkKind(cxString, i);
+ const QString text = Internal::getQString(clang_getCompletionChunkText(cxString, i), false);
+
+ switch (chunkKind) {
+ case CXCompletionChunk_ResultType:
+ attachResultTypeToComment(text);
+ break;
+
+ case CXCompletionChunk_Placeholder:
+ m_text += text;
+ appendSnippet(text);
+ appendHintBold(text);
+ break;
+ case CXCompletionChunk_LeftAngle:
+ m_snippet += text;
+ m_text += text;
+ m_hint += QLatin1String("&lt;");
+ break;
+ case CXCompletionChunk_RightAngle:
+ m_snippet += text;
+ m_text += text;
+ m_hint += QLatin1String("&gt;");
+ break;
+
+ case CXCompletionChunk_VerticalSpace:
+ m_snippet += QLatin1Char('\n');
+ m_text += QLatin1Char(' ');
+ m_hint += QLatin1String("<br/>");
+ break;
+
+ default:
+ m_snippet += text;
+ m_text += text;
+ m_hint += text;
+ break;
+ }
+ }
+}
+
+/**
+ * @brief Creates short text and hint with details
+ *
+ * Text is just function or variable name. Hint also contains function signature
+ * or variable type.
+ */
+void CompletionProposalsBuilder::concatChunksOnlyTypedText(const CXCompletionString &cxString)
+{
+ bool previousChunkWasLParen = false;
+ bool isInsideTemplateSpec = false;
+
+ unsigned count = clang_getNumCompletionChunks(cxString);
+ for (unsigned i = 0; i < count; ++i) {
+ CXCompletionChunkKind chunkKind = clang_getCompletionChunkKind(cxString, i);
+ QString text = Internal::getQString(clang_getCompletionChunkText(cxString, i), false);
+
+ switch (chunkKind) {
+ case CXCompletionChunk_LeftParen:
+ case CXCompletionChunk_RightParen:
+ case CXCompletionChunk_Text:
+ case CXCompletionChunk_LeftAngle:
+ case CXCompletionChunk_RightAngle:
+ m_hint += Qt::escape(text);
+ break;
+
+ case CXCompletionChunk_HorizontalSpace:
+ case CXCompletionChunk_Comma:
+ if (isInsideTemplateSpec) {
+ m_snippet += text;
+ }
+ m_hint += Qt::escape(text);
+ break;
+
+ case CXCompletionChunk_Placeholder:
+ if (isInsideTemplateSpec) {
+ appendSnippet(text);
+ }
+ m_hint += Qt::escape(text);
+ break;
+
+ case CXCompletionChunk_TypedText:
+ m_text = text;
+ appendHintBold(text);
+ break;
+
+ case CXCompletionChunk_ResultType: {
+ m_hint += Qt::escape(text);
+ QChar last = text[text.size() - 1];
+ if (last != QLatin1Char('*') && last != QLatin1Char('&'))
+ m_hint += QLatin1Char(' ');
+ }
+ break;
+
+ case CXCompletionChunk_Informative:
+ if (text == QLatin1String(" const"))
+ m_hint += text;
+ break;
+
+ case CXCompletionChunk_Optional:
+ appendOptionalChunks(clang_getCompletionChunkCompletionString(cxString, i),
+ m_hint.size());
+ break;
+
+ default:
+ break;
+ }
+
+ if (chunkKind == CXCompletionChunk_RightParen && previousChunkWasLParen)
+ m_hasParameters = false;
+
+ if (chunkKind == CXCompletionChunk_LeftParen) {
+ previousChunkWasLParen = true;
+ m_hasParameters = true;
+ } else {
+ previousChunkWasLParen = false;
+ }
+
+ if (chunkKind == CXCompletionChunk_LeftAngle) {
+ m_snippet = m_text;
+ m_snippet += text;
+ isInsideTemplateSpec = true;
+ } else if (chunkKind == CXCompletionChunk_RightAngle) {
+ isInsideTemplateSpec = false;
+ m_snippet += text;
+ }
+ }
+}
+
+/**
+ * @brief Produces signal/slot signatures for 'connect' methods family
+ */
+void CompletionProposalsBuilder::concatSlotSignalSignature(const CXCompletionString &cxString)
+{
+ QString resultType;
+
+ unsigned count = clang_getNumCompletionChunks(cxString);
+ for (unsigned i = 0; i < count; ++i) {
+ CXCompletionChunkKind chunkKind = clang_getCompletionChunkKind(cxString, i);
+ QString text = Internal::getQString(clang_getCompletionChunkText(cxString, i), false);
+
+ switch (chunkKind) {
+ case CXCompletionChunk_Placeholder:
+ text.truncate(findNameInPlaceholder(text));
+ // fall-through
+ case CXCompletionChunk_TypedText:
+ case CXCompletionChunk_LeftParen:
+ case CXCompletionChunk_RightParen:
+ case CXCompletionChunk_Comma:
+ case CXCompletionChunk_Text:
+ m_text += text;
+ break;
+ case CXCompletionChunk_ResultType:
+ resultType += text;
+ resultType += QLatin1Char(' ');
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ const QString parent = Internal::getQString(clang_getCompletionParent(cxString, NULL));
+ if (m_resultKind == CodeCompletionResult::SlotCompletionKind)
+ m_hint += QObject::tr("Slot of %1, returns %2").arg(parent).arg(resultType);
+ else
+ m_hint += QObject::tr("Signal of %1, returns %2").arg(parent).arg(resultType);
+}
+
+/**
+ * @brief Stores optional part for further postprocessing in \a finalize()
+ * @param insertionIndex Index where to insert optional chunk into hint
+ */
+void CompletionProposalsBuilder::appendOptionalChunks(const CXCompletionString &cxString,
+ int insertionIndex)
+{
+ OptionalChunk chunk;
+ chunk.positionInHint = insertionIndex;
+
+ unsigned count = clang_getNumCompletionChunks(cxString);
+ for (unsigned i = 0; i < count; ++i) {
+ CXCompletionChunkKind chunkKind = clang_getCompletionChunkKind(cxString, i);
+ QString text = Internal::getQString(clang_getCompletionChunkText(cxString, i), false);
+
+ switch (chunkKind) {
+ case CXCompletionChunk_Placeholder:
+ chunk.hint += Qt::escape(text);
+ break;
+
+ case CXCompletionChunk_Comma:
+ chunk.hint += text;
+ chunk.hint += QLatin1Char(' ');
+ break;
+
+ case CXCompletionChunk_Optional:
+ m_optionalChunks.append(chunk);
+ appendOptionalChunks(clang_getCompletionChunkCompletionString(cxString, i),
+ insertionIndex + chunk.hint.size());
+ return;
+
+ default:
+ break;
+ }
+ }
+
+ m_optionalChunks.append(chunk);
+}
+
+void CompletionProposalsBuilder::attachResultTypeToComment(const QString &resultType)
+{
+ if (resultType.isEmpty())
+ return;
+
+ if (!m_comment.isEmpty())
+ m_comment += QLatin1String("<br/>");
+
+ m_comment += QLatin1String("<b>@return</b> ");
+ m_comment += resultType;
+}
+
+void CompletionProposalsBuilder::appendSnippet(const QString &text)
+{
+ m_snippet += QLatin1Char('$');
+ m_snippet += text;
+ m_snippet += QLatin1Char('$');
+}
+
+void CompletionProposalsBuilder::appendHintBold(const QString &text)
+{
+ m_hint += QLatin1String("<b>");
+ m_hint += Qt::escape(text);
+ m_hint += QLatin1String("</b>");
+}
+
+} // namespace ClangCodeModel
diff --git a/src/plugins/clangcodemodel/completionproposalsbuilder.h b/src/plugins/clangcodemodel/completionproposalsbuilder.h
new file mode 100644
index 0000000000..5526446e2c
--- /dev/null
+++ b/src/plugins/clangcodemodel/completionproposalsbuilder.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANGCODEMODEL_COMPLETIONPROPOSALSBUILDER_H
+#define CLANGCODEMODEL_COMPLETIONPROPOSALSBUILDER_H
+
+#include "clangcompleter.h"
+#include "clang_global.h"
+#include <clang-c/Index.h>
+
+namespace ClangCodeModel {
+
+class CLANG_EXPORT CompletionProposalsBuilder
+{
+public:
+ CompletionProposalsBuilder(QList<CodeCompletionResult> &results, quint64 contexts, bool isSignalSlotCompletion);
+ void operator ()(const CXCompletionResult &cxResult);
+
+private:
+ struct OptionalChunk {
+ int positionInHint;
+ QString hint;
+
+ OptionalChunk() : positionInHint(0) {}
+ };
+
+ static CodeCompletionResult::Kind getKind(const CXCompletionResult &cxResult);
+ static CodeCompletionResult::Availability getAvailability(const CXCompletionResult &cxResult);
+ static int findNameInPlaceholder(const QString &text);
+ void resetWithResult(const CXCompletionResult &cxResult);
+ void finalize();
+
+ void concatChunksForObjectiveCMessage(const CXCompletionResult &cxResult);
+ void concatChunksForNestedName(const CXCompletionString &cxString);
+ void concatChunksAsSnippet(const CXCompletionString &cxString);
+ void concatChunksOnlyTypedText(const CXCompletionString &cxString);
+ void concatSlotSignalSignature(const CXCompletionString &cxString);
+ void appendOptionalChunks(const CXCompletionString &cxString,
+ int insertionIndex);
+ void attachResultTypeToComment(const QString &text);
+
+ void appendSnippet(const QString &text);
+ void appendHintBold(const QString &text);
+
+ QList<CodeCompletionResult> &m_results;
+ const quint64 m_contexts;
+ const bool m_isSignalSlotCompletion;
+
+ unsigned m_priority;
+ CodeCompletionResult::Kind m_resultKind;
+ CodeCompletionResult::Availability m_resultAvailability;
+ bool m_hasParameters;
+ QString m_hint;
+ QString m_text;
+ QString m_snippet;
+ QString m_comment;
+ QList<OptionalChunk> m_optionalChunks;
+};
+
+} // namespace ClangCodeModel
+
+#endif // CLANGCODEMODEL_COMPLETIONPROPOSALSBUILDER_H
diff --git a/src/plugins/clangcodemodel/constants.h b/src/plugins/clangcodemodel/constants.h
new file mode 100644
index 0000000000..164276f194
--- /dev/null
+++ b/src/plugins/clangcodemodel/constants.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CONSTANTS_H
+#define CONSTANTS_H
+
+#include <QtCore/QLatin1Char>
+#include <QtCore/QLatin1Char>
+
+namespace ClangCodeModel {
+namespace Constants {
+
+static const QLatin1Char kLParen('(');
+static const QLatin1Char kRParen(')');
+static const QLatin1Char kLBrace('{');
+static const QLatin1Char kRBrace('}');
+static const QLatin1Char kLBracket('[');
+static const QLatin1Char kRBracket(']');
+static const QLatin1Char kLABracket('<');
+static const QLatin1Char kRABracket('>');
+static const QLatin1Char kSemiColon(';');
+static const QLatin1Char kPound('#');
+static const QLatin1Char kColon(':');
+static const QLatin1Char kExclamation('!');
+static const QLatin1Char kSpace(' ');
+static const QLatin1Char kSlash('/');
+static const QLatin1Char kStar('*');
+static const QLatin1Char kDoubleQuote('"');
+static const QLatin1Char kNewLine('\n');
+static const QLatin1Char kHorizontalTab('\t');
+
+}
+}
+
+#endif // CONSTANTS_H
diff --git a/src/plugins/clangcodemodel/cppcreatemarkers.cpp b/src/plugins/clangcodemodel/cppcreatemarkers.cpp
new file mode 100644
index 0000000000..aadf3b6b7e
--- /dev/null
+++ b/src/plugins/clangcodemodel/cppcreatemarkers.cpp
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangutils.h"
+#include "cppcreatemarkers.h"
+
+#include <cplusplus/CppDocument.h>
+#include <cpptools/cppmodelmanagerinterface.h>
+#include <utils/runextensions.h>
+
+#include <QCoreApplication>
+#include <QMutexLocker>
+#include <QThreadPool>
+
+#include <QDebug>
+
+static const bool DebugTiming = !qgetenv("QTC_CLANG_VERBOSE").isEmpty();
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+using namespace CppTools;
+
+CreateMarkers *CreateMarkers::create(SemanticMarker::Ptr semanticMarker,
+ const QString &fileName,
+ const QStringList &options,
+ unsigned firstLine, unsigned lastLine,
+ FastIndexer *fastIndexer,
+ const Internal::PchInfo::Ptr &pchInfo)
+{
+ if (semanticMarker.isNull())
+ return 0;
+ else
+ return new CreateMarkers(semanticMarker, fileName, options, firstLine, lastLine, fastIndexer, pchInfo);
+}
+
+CreateMarkers::CreateMarkers(SemanticMarker::Ptr semanticMarker,
+ const QString &fileName,
+ const QStringList &options,
+ unsigned firstLine, unsigned lastLine,
+ FastIndexer *fastIndexer,
+ const Internal::PchInfo::Ptr &pchInfo)
+ : m_marker(semanticMarker)
+ , m_pchInfo(pchInfo)
+ , m_fileName(fileName)
+ , m_options(options)
+ , m_firstLine(firstLine)
+ , m_lastLine(lastLine)
+ , m_fastIndexer(fastIndexer)
+{
+ Q_ASSERT(!semanticMarker.isNull());
+
+ m_flushRequested = false;
+ m_flushLine = 0;
+
+ m_unsavedFiles = Utils::createUnsavedFiles(CppModelManagerInterface::instance()->workingCopy());
+}
+
+CreateMarkers::~CreateMarkers()
+{ }
+
+void CreateMarkers::run()
+{
+ QMutexLocker lock(m_marker->mutex());
+ if (isCanceled())
+ return;
+
+ m_options += QLatin1String("-fspell-checking");
+
+ QTime t;
+ if (DebugTiming) {
+ qDebug() << "*** Highlighting from" << m_firstLine << "to" << m_lastLine << "of" << m_fileName;
+ qDebug() << "***** Options: " << m_options.join(QLatin1String(" "));
+ t.start();
+ }
+
+ m_usages.clear();
+ m_marker->setFileName(m_fileName);
+ m_marker->setCompilationOptions(m_options);
+
+ m_marker->reparse(m_unsavedFiles);
+
+ if (DebugTiming)
+ qDebug() << "*** Reparse for highlighting took" << t.elapsed() << "ms.";
+
+ m_pchInfo.clear();
+
+ typedef CPlusPlus::Document::DiagnosticMessage OtherDiagnostic;
+ QList<OtherDiagnostic> msgs;
+ foreach (const ClangCodeModel::Diagnostic &d, m_marker->diagnostics()) {
+ if (DebugTiming)
+ qDebug() << d.severityAsString() << d.location() << d.spelling();
+
+ if (d.location().fileName() != m_marker->fileName())
+ continue;
+
+ // TODO: retrieve fix-its for this diagnostic
+
+ int level;
+ switch (d.severity()) {
+ case Diagnostic::Fatal: level = OtherDiagnostic::Fatal; break;
+ case Diagnostic::Error: level = OtherDiagnostic::Error; break;
+ case Diagnostic::Warning: level = OtherDiagnostic::Warning; break;
+ default: continue;
+ }
+ msgs.append(OtherDiagnostic(level, d.location().fileName(), d.location().line(),
+ d.location().column(), d.spelling(), d.length()));
+ }
+ if (isCanceled()) {
+ reportFinished();
+ return;
+ }
+
+ CppModelManagerInterface *mmi = CppModelManagerInterface::instance();
+ static const QString key = QLatin1String("ClangCodeModel.Diagnostics");
+ mmi->setExtraDiagnostics(m_marker->fileName(), key, msgs);
+#if CINDEX_VERSION_MINOR >= 21
+ mmi->setIfdefedOutBlocks(m_marker->fileName(), m_marker->ifdefedOutBlocks());
+#endif
+
+ if (isCanceled()) {
+ reportFinished();
+ return;
+ }
+
+ QList<ClangCodeModel::SourceMarker> markers = m_marker->sourceMarkersInRange(m_firstLine, m_lastLine);
+ foreach (const ClangCodeModel::SourceMarker &m, markers)
+ addUse(SourceMarker(m.location().line(), m.location().column(), m.length(), m.kind()));
+
+ if (isCanceled()) {
+ reportFinished();
+ return;
+ }
+
+ flush();
+ reportFinished();
+
+ if (DebugTiming) {
+ qDebug() << "*** Highlighting took" << t.elapsed() << "ms in total.";
+ t.restart();
+ }
+
+ if (m_fastIndexer)
+ m_fastIndexer->indexNow(m_marker->unit());
+
+ if (DebugTiming)
+ qDebug() << "*** Fast re-indexing took" << t.elapsed() << "ms in total.";
+}
+
+void CreateMarkers::addUse(const SourceMarker &marker)
+{
+// if (! enclosingFunctionDefinition()) {
+ if (m_usages.size() >= 100) {
+ if (m_flushRequested && marker.line != m_flushLine)
+ flush();
+ else if (! m_flushRequested) {
+ m_flushRequested = true;
+ m_flushLine = marker.line;
+ }
+ }
+// }
+
+ m_usages.append(marker);
+}
+
+void CreateMarkers::flush()
+{
+ m_flushRequested = false;
+ m_flushLine = 0;
+
+ if (m_usages.isEmpty())
+ return;
+
+ reportResults(m_usages);
+ m_usages.clear();
+}
diff --git a/src/plugins/clangcodemodel/cppcreatemarkers.h b/src/plugins/clangcodemodel/cppcreatemarkers.h
new file mode 100644
index 0000000000..c372e4b08e
--- /dev/null
+++ b/src/plugins/clangcodemodel/cppcreatemarkers.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CPPCREATEMARKERS_H
+#define CPPCREATEMARKERS_H
+
+#include "fastindexer.h"
+#include "sourcemarker.h"
+#include "semanticmarker.h"
+#include "pchinfo.h"
+
+#include <texteditor/semantichighlighter.h>
+
+#include <QSet>
+#include <QFuture>
+#include <QtConcurrentRun>
+
+namespace ClangCodeModel {
+
+class CreateMarkers:
+ public QObject,
+ public QRunnable,
+ public QFutureInterface<TextEditor::HighlightingResult>
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(CreateMarkers)
+
+public:
+ virtual ~CreateMarkers();
+
+ virtual void run();
+
+ typedef TextEditor::HighlightingResult SourceMarker;
+
+ typedef QFuture<SourceMarker> Future;
+
+ Future start()
+ {
+ this->setRunnable(this);
+ this->reportStarted();
+ Future future = this->future();
+ QThreadPool::globalInstance()->start(this, QThread::LowestPriority);
+ return future;
+ }
+
+ static CreateMarkers *create(ClangCodeModel::SemanticMarker::Ptr semanticMarker,
+ const QString &fileName,
+ const QStringList &options,
+ unsigned firstLine, unsigned lastLine,
+ Internal::FastIndexer *fastIndexer,
+ const Internal::PchInfo::Ptr &pchInfo);
+
+ void addUse(const SourceMarker &marker);
+ void flush();
+
+protected:
+ CreateMarkers(ClangCodeModel::SemanticMarker::Ptr semanticMarker,
+ const QString &fileName, const QStringList &options,
+ unsigned firstLine, unsigned lastLine,
+ Internal::FastIndexer *fastIndexer,
+ const Internal::PchInfo::Ptr &pchInfo);
+
+private:
+ ClangCodeModel::SemanticMarker::Ptr m_marker;
+ Internal::PchInfo::Ptr m_pchInfo;
+ QString m_fileName;
+ QStringList m_options;
+ unsigned m_firstLine;
+ unsigned m_lastLine;
+ Internal::FastIndexer *m_fastIndexer;
+ QVector<SourceMarker> m_usages;
+ bool m_flushRequested;
+ unsigned m_flushLine;
+
+ ClangCodeModel::Internal::UnsavedFiles m_unsavedFiles;
+};
+
+} // namespace ClangCodeModel
+
+#endif // CPPCREATEMARKERS_H
diff --git a/src/plugins/clangcodemodel/cxprettyprinter.cpp b/src/plugins/clangcodemodel/cxprettyprinter.cpp
new file mode 100644
index 0000000000..60157f0df1
--- /dev/null
+++ b/src/plugins/clangcodemodel/cxprettyprinter.cpp
@@ -0,0 +1,550 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "cxprettyprinter.h"
+#include "utils_p.h"
+#include "cxraii.h"
+#include <QStringList>
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+
+CXPrettyPrinter::CXPrettyPrinter()
+ : m_indent(0)
+{
+}
+
+QString CXPrettyPrinter::toString(CXCompletionChunkKind kind) const
+{
+ switch (kind) {
+ case CXCompletionChunk_Optional:
+ return QLatin1String("Optional");
+ case CXCompletionChunk_TypedText:
+ return QLatin1String("TypedText");
+ case CXCompletionChunk_Text:
+ return QLatin1String("Text");
+ case CXCompletionChunk_Placeholder:
+ return QLatin1String("Placeholder");
+ case CXCompletionChunk_Informative:
+ return QLatin1String("Informative");
+ case CXCompletionChunk_CurrentParameter:
+ return QLatin1String("CurrentParameter");
+ case CXCompletionChunk_LeftParen:
+ return QLatin1String("LeftParen");
+ case CXCompletionChunk_RightParen:
+ return QLatin1String("RightParen");
+ case CXCompletionChunk_LeftBracket:
+ return QLatin1String("LeftBracket");
+ case CXCompletionChunk_RightBracket:
+ return QLatin1String("RightBracket");
+ case CXCompletionChunk_LeftBrace:
+ return QLatin1String("LeftBrace");
+ case CXCompletionChunk_RightBrace:
+ return QLatin1String("RightBrace");
+ case CXCompletionChunk_LeftAngle:
+ return QLatin1String("LeftAngle");
+ case CXCompletionChunk_RightAngle:
+ return QLatin1String("RightAngle");
+ case CXCompletionChunk_Comma:
+ return QLatin1String("Comma");
+ case CXCompletionChunk_ResultType:
+ return QLatin1String("ResultType");
+ case CXCompletionChunk_Colon:
+ return QLatin1String("Colon");
+ case CXCompletionChunk_SemiColon:
+ return QLatin1String("SemiColon");
+ case CXCompletionChunk_Equal:
+ return QLatin1String("Equal");
+ case CXCompletionChunk_HorizontalSpace:
+ return QLatin1String("HorizontalSpace");
+ case CXCompletionChunk_VerticalSpace:
+ return QLatin1String("VerticalSpace");
+ default:
+ return QLatin1String("<UNKNOWN>");
+ }
+}
+
+QString CXPrettyPrinter::toString(CXAvailabilityKind kind) const
+{
+ switch (kind) {
+ case CXAvailability_Available:
+ return QLatin1String("Available");
+ case CXAvailability_Deprecated:
+ return QLatin1String("Deprecated");
+ case CXAvailability_NotAccessible:
+ return QLatin1String("NotAccessible");
+ case CXAvailability_NotAvailable:
+ return QLatin1String("NotAvailable");
+ default:
+ return QLatin1String("<UNKNOWN>");
+ }
+}
+
+QString CXPrettyPrinter::toString(CXCursorKind kind) const
+{
+ return getQString(clang_getCursorKindSpelling(kind));
+}
+
+QString CXPrettyPrinter::toString(CXDiagnosticSeverity severity) const
+{
+ switch (severity)
+ {
+ case CXDiagnostic_Ignored:
+ return QLatin1String("Ignored");
+ case CXDiagnostic_Note:
+ return QLatin1String("Note");
+ case CXDiagnostic_Warning:
+ return QLatin1String("Warning");
+ case CXDiagnostic_Error:
+ return QLatin1String("Error");
+ case CXDiagnostic_Fatal:
+ return QLatin1String("Fatal");
+ default:
+ return QLatin1String("<UNKNOWN>");
+ }
+}
+
+QString CXPrettyPrinter::jsonForCompletionMeta(CXCodeCompleteResults *results)
+{
+ QString json;
+ m_printed.swap(json);
+ m_indent = 0;
+
+ m_printed += QLatin1String("CXCodeCompleteResults {");
+ m_indent += 4;
+
+ CXCursorKind containerKind = clang_codeCompleteGetContainerKind(results, NULL);
+ writeLineEnd();
+ m_printed += QLatin1String("'container CursorKind': ");
+ m_printed += toString(containerKind);
+ m_printed += QLatin1Char(',');
+
+ QString containerUSR(Internal::getQString(clang_codeCompleteGetContainerUSR(results)));
+ if (!containerUSR.isEmpty()) {
+ writeLineEnd();
+ m_printed += QLatin1String("'container USR': ");
+ m_printed += containerUSR;
+ m_printed += QLatin1Char(',');
+ }
+
+ QString objCSelector(Internal::getQString(clang_codeCompleteGetObjCSelector(results)));
+ if (!objCSelector.isEmpty()) {
+ writeLineEnd();
+ m_printed += QLatin1String("'Objective-C selector': ");
+ m_printed += objCSelector;
+ m_printed += QLatin1Char(',');
+ }
+
+ writeLineEnd();
+ m_printed += QLatin1String("'contexts': [");
+ m_indent += 4;
+ writeCompletionContexts(results);
+ m_indent -= 4;
+ writeLineEnd();
+ m_printed += QLatin1Char(']');
+
+ m_indent -= 4;
+ writeLineEnd();
+ m_printed += QLatin1Char('}');
+
+ m_printed.swap(json);
+ return json;
+}
+
+QString CXPrettyPrinter::jsonForCompletionString(const CXCompletionString &string)
+{
+ QString json;
+ m_printed.swap(json);
+ m_indent = 0;
+
+ m_printed += QLatin1String("CXCompletionString: ");
+ writeCompletionStringJson(string);
+
+ m_printed.swap(json);
+ return json;
+}
+
+QString CXPrettyPrinter::jsonForCompletion(const CXCompletionResult &result)
+{
+ QString json;
+ m_printed.swap(json);
+ m_indent = 4;
+
+ m_printed += QLatin1String("CXCompletionResult: {\n"
+ " CompletionString: ");
+ writeCompletionStringJson(result.CompletionString);
+ m_printed += QLatin1Char('\n');
+
+ m_printed += QLatin1String(" CursorKind: ");
+ m_printed += toString(result.CursorKind);
+ m_printed += QLatin1String(";\n}");
+
+ m_printed.swap(json);
+ return json;
+}
+
+/**
+ * @brief CXPrettyPrinter::jsonForDiagnsotic
+ * @param diagnostic
+ * @return
+ *
+ * List of used clang-c API calls:
+ * CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D);
+ * CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic);
+ * CXString clang_getDiagnosticOption(CXDiagnostic Diag,
+ * CXString *Disable);
+ * unsigned clang_getDiagnosticCategory(CXDiagnostic);
+ * CXString clang_getDiagnosticCategoryText(CXDiagnostic);
+ * unsigned clang_getDiagnosticNumRanges(CXDiagnostic);
+ * CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic,
+ * unsigned Range);
+ * unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
+ * CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
+ * unsigned FixIt,
+ * CXSourceRange *ReplacementRange);
+ */
+QString CXPrettyPrinter::jsonForDiagnsotic(const CXDiagnostic &diagnostic)
+{
+ QString json;
+ m_printed.swap(json);
+ m_indent = 0;
+
+ m_printed += QLatin1String("CXDiagnostic: ");
+ writeDiagnosticJson(diagnostic);
+
+ m_printed.swap(json);
+ return json;
+}
+
+void CXPrettyPrinter::writeCompletionContexts(CXCodeCompleteResults *results)
+{
+ quint64 contexts = clang_codeCompleteGetContexts(results);
+ QStringList lines;
+
+ if (contexts & CXCompletionContext_AnyType)
+ lines << QLatin1String("'any type'");
+ if (contexts & CXCompletionContext_AnyValue)
+ lines << QLatin1String("'any value'");
+ if (contexts & CXCompletionContext_ObjCObjectValue)
+ lines << QLatin1String("'Objective-C object'");
+ if (contexts & CXCompletionContext_ObjCSelectorValue)
+ lines << QLatin1String("'Objective-C selector'");
+ if (contexts & CXCompletionContext_CXXClassTypeValue)
+ lines << QLatin1String("'C++ class'");
+ if (contexts & CXCompletionContext_DotMemberAccess)
+ lines << QLatin1String("'. member access'");
+ if (contexts & CXCompletionContext_ArrowMemberAccess)
+ lines << QLatin1String("'-> member access'");
+ if (contexts & CXCompletionContext_ObjCPropertyAccess)
+ lines << QLatin1String("'. Objective-C property access'");
+ if (contexts & CXCompletionContext_EnumTag)
+ lines << QLatin1String("'enum tag'");
+ if (contexts & CXCompletionContext_UnionTag)
+ lines << QLatin1String("'union tag'");
+ if (contexts & CXCompletionContext_StructTag)
+ lines << QLatin1String("'struct tag'");
+ if (contexts & CXCompletionContext_ClassTag)
+ lines << QLatin1String("'C++ class tag'");
+ if (contexts & CXCompletionContext_Namespace)
+ lines << QLatin1String("'namespace tag'");
+ if (contexts & CXCompletionContext_NestedNameSpecifier)
+ lines << QLatin1String("'C++ nested name specifier'");
+ if (contexts & CXCompletionContext_ObjCInterface)
+ lines << QLatin1String("'Objective-C interface'");
+ if (contexts & CXCompletionContext_ObjCProtocol)
+ lines << QLatin1String("'Objective-C protocol'");
+ if (contexts & CXCompletionContext_ObjCCategory)
+ lines << QLatin1String("'Objective-C category'");
+ if (contexts & CXCompletionContext_ObjCInstanceMessage)
+ lines << QLatin1String("'Objective-C instance message'");
+ if (contexts & CXCompletionContext_ObjCClassMessage)
+ lines << QLatin1String("'Objective-C class message'");
+ if (contexts & CXCompletionContext_ObjCSelectorName)
+ lines << QLatin1String("'Objective-C selector name'");
+ if (contexts & CXCompletionContext_MacroName)
+ lines << QLatin1String("'macro name'");
+ if (contexts & CXCompletionContext_NaturalLanguage)
+ lines << QLatin1String("'natural language'");
+
+ foreach (const QString &line, lines) {
+ writeLineEnd();
+ m_printed += line + QLatin1String(",");
+ }
+}
+
+void CXPrettyPrinter::writeCompletionStringJson(const CXCompletionString &string)
+{
+ m_printed += QLatin1Char('{');
+ writeLineEnd();
+
+ // availability
+ m_printed += QLatin1String("availability: ");
+ m_printed += toString(clang_getCompletionAvailability(string));
+ m_printed += QLatin1Char(';');
+ writeLineEnd();
+
+ // priority
+ m_printed += QLatin1String("priority: ");
+ m_printed += QString::number(clang_getCompletionPriority(string));
+ m_printed += QLatin1Char(';');
+ writeLineEnd();
+
+ // parent
+ m_printed += QLatin1String("parent: \'");
+ m_printed += getQString(clang_getCompletionParent(string, NULL));
+ m_printed += QLatin1String("\';");
+ writeLineEnd();
+
+ // chunks
+ m_printed += QLatin1String("chunks: [");
+ m_indent += 4;
+ unsigned numChunks = clang_getNumCompletionChunks(string);
+ for (unsigned i = 0; i < numChunks; ++i) {
+ writeLineEnd();
+ writeCompletionChunkJson(string, i);
+ }
+ m_indent -= 4;
+ writeLineEnd();
+ m_printed += QLatin1Char(']');
+ writeLineEnd();
+
+ // annotation
+ m_printed += QLatin1String("annotations: [");
+ m_indent += 4;
+ unsigned numAnns = clang_getCompletionNumAnnotations(string);
+ for (unsigned i = 0; i < numAnns; ++i) {
+ writeLineEnd();
+ writeCompletionAnnotationJson(string, i);
+ }
+ m_indent -= 4;
+ writeLineEnd();
+ m_printed += QLatin1Char(']');
+ writeLineEnd();
+
+ m_printed += QLatin1Char('}');
+}
+
+void CXPrettyPrinter::writeCompletionChunkJson(const CXCompletionString &string, unsigned i)
+{
+ QString text = getQString(clang_getCompletionChunkText(string, i));
+ QString kind = toString(clang_getCompletionChunkKind(string, i));
+ CXCompletionString optional = clang_getCompletionChunkCompletionString(string, i);
+
+ m_printed += kind;
+ m_printed += QLatin1String(": ");
+ if (!text.isEmpty()) {
+ m_printed += QLatin1Char('\'');
+ m_printed += text;
+ m_printed += QLatin1Char('\'');
+ }
+ if (optional != NULL) {
+ if (!text.isEmpty())
+ m_printed += QLatin1String(", ");
+ m_indent += 4;
+ writeCompletionStringJson(optional);
+ m_indent -= 4;
+ }
+}
+
+void CXPrettyPrinter::writeCompletionAnnotationJson(const CXCompletionString &string, unsigned i)
+{
+ m_printed += QLatin1Char('\'');
+ m_printed += getQString(clang_getCompletionAnnotation(string, i));
+ m_printed += QLatin1Char('\'');
+}
+
+void CXPrettyPrinter::writeDiagnosticJson(const CXDiagnostic &diag)
+{
+ m_printed += QLatin1String("{");
+ m_indent += 4;
+ writeLineEnd();
+
+ // message
+ m_printed += QLatin1Char('\'');
+ m_printed += getQString(clang_formatDiagnostic(diag, /*options*/ 0));
+ m_printed += QLatin1Char('\'');
+ writeLineEnd();
+
+ // severity
+ m_printed += QLatin1String("severity: ");
+ m_printed += toString(clang_getDiagnosticSeverity(diag));
+ writeLineEnd();
+
+ // location
+ m_printed += QLatin1String("location: ");
+ writeLocationJson(clang_getDiagnosticLocation(diag));
+ writeLineEnd();
+
+ // fix-its
+ unsigned numFixIts = clang_getDiagnosticNumFixIts(diag);
+ if (numFixIts > 0) {
+ m_printed += QLatin1String("FixIts: [");
+ writeLineEnd();
+ for (unsigned i = 0; i < numFixIts; ++i) {
+ writeFixItJson(diag, i);
+ writeLineEnd();
+ }
+ m_printed += QLatin1String("]");
+ writeLineEnd();
+ }
+
+ // clang CLI options
+ CXString cxDisabler;
+ QString enabler = getQString(clang_getDiagnosticOption(diag, &cxDisabler));
+ QString disabler = getQString(cxDisabler);
+ if (!enabler.isEmpty()) {
+ m_printed += QLatin1String("enabledBy: \'");
+ m_printed += enabler;
+ m_printed += QLatin1String("';");
+ writeLineEnd();
+ }
+ if (!disabler.isEmpty()) {
+ m_printed += QLatin1String("disabledBy: \'");
+ m_printed += disabler;
+ m_printed += QLatin1String("';");
+ writeLineEnd();
+ }
+
+ // diagnostic category
+ m_printed += QLatin1String("category: \'");
+ m_printed += getQString(clang_getDiagnosticCategoryText(diag));
+ m_printed += QLatin1String("';");
+
+ // ranges
+ unsigned numRanges = clang_getDiagnosticNumRanges(diag);
+ if (numRanges > 0) {
+ writeLineEnd();
+ m_printed += QLatin1String("ranges: [");
+ m_indent += 4;
+ for (unsigned i = 0; i < numRanges; ++i) {
+ writeLineEnd();
+ writeRangeJson(clang_getDiagnosticRange(diag, i));
+ }
+ m_indent -= 4;
+ writeLineEnd();
+ m_printed += QLatin1String("]");
+ }
+
+ // children
+ CXDiagnosticSet set(clang_getChildDiagnostics(diag));
+ unsigned numChildren = clang_getNumDiagnosticsInSet(set);
+ if (numChildren > 0) {
+ writeLineEnd();
+ m_printed += QLatin1String("children: [");
+ m_indent += 4;
+ for (unsigned i = 0; i < numChildren; ++i) {
+ writeLineEnd();
+ ScopedCXDiagnostic child(clang_getDiagnosticInSet(set, i));
+ writeDiagnosticJson(child);
+ }
+ m_indent -= 4;
+ writeLineEnd();
+ m_printed += QLatin1String("]");
+ }
+
+ m_indent -= 4;
+ writeLineEnd();
+ m_printed += QLatin1String("}");
+}
+
+void CXPrettyPrinter::writeFixItJson(const CXDiagnostic &diag, unsigned i)
+{
+ CXSourceRange range; // half-open range [a, b)
+ QString text = getQString(clang_getDiagnosticFixIt(diag, i, &range));
+
+ m_printed += QLatin1String("{ newText: ");
+ m_printed += QLatin1String("\'");
+ m_printed += text;
+ m_printed += QLatin1String("\', range: ");
+ writeRangeJson(range);
+ m_printed += QLatin1String("}");
+}
+
+void CXPrettyPrinter::writeRangeJson(const CXSourceRange &range)
+{
+ SourceLocation start = getSpellingLocation(clang_getRangeStart(range));
+ SourceLocation end = getSpellingLocation(clang_getRangeEnd(range));
+
+ m_printed += QLatin1Char('{');
+ m_indent += 4;
+ writeLineEnd();
+
+ m_printed += QLatin1String("file: \'");
+ m_printed += start.fileName();
+ m_printed += QLatin1String("\',");
+ writeLineEnd();
+
+ m_printed += QLatin1String("from: {");
+ m_printed += QString::number(start.line());
+ m_printed += QLatin1String(", ");
+ m_printed += QString::number(start.column());
+ m_printed += QLatin1String("},");
+
+ m_printed += QLatin1String("to: {");
+ m_printed += QString::number(end.line());
+ m_printed += QLatin1String(", ");
+ m_printed += QString::number(end.column());
+ m_printed += QLatin1Char('}');
+
+ m_indent -= 4;
+ writeLineEnd();
+ m_printed += QLatin1Char('}');
+}
+
+void CXPrettyPrinter::writeLocationJson(const CXSourceLocation &location)
+{
+ SourceLocation loc = getSpellingLocation(location);
+ m_printed += QLatin1Char('{');
+ m_indent += 4;
+ writeLineEnd();
+
+ m_printed += QLatin1String("file: \'");
+ m_printed += loc.fileName();
+ m_printed += QLatin1String("\',");
+ writeLineEnd();
+
+ m_printed += QLatin1String("line: ");
+ m_printed += QString::number(loc.line());
+ m_printed += QLatin1String(",");
+ writeLineEnd();
+
+ m_printed += QLatin1String("column: ");
+ m_printed += QString::number(loc.column());
+
+ m_indent -= 4;
+ writeLineEnd();
+ m_printed += QLatin1String("}");
+}
+
+void CXPrettyPrinter::writeLineEnd()
+{
+ m_printed += QLatin1Char('\n');
+ for (int i = 0; i < m_indent; ++i)
+ m_printed += QLatin1Char(' ');
+}
diff --git a/src/plugins/clangcodemodel/cxprettyprinter.h b/src/plugins/clangcodemodel/cxprettyprinter.h
new file mode 100644
index 0000000000..b2ad5b97a1
--- /dev/null
+++ b/src/plugins/clangcodemodel/cxprettyprinter.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CXPRETTYPRINTER_H
+#define CXPRETTYPRINTER_H
+
+#include <clang-c/Index.h>
+#include <QString>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class CXPrettyPrinter
+{
+public:
+ CXPrettyPrinter();
+
+ QString toString(CXCompletionChunkKind kind) const;
+ QString toString(CXAvailabilityKind kind) const;
+ QString toString(CXCursorKind kind) const;
+ QString toString(CXDiagnosticSeverity severity) const;
+
+ QString jsonForCompletionMeta(CXCodeCompleteResults *results);
+ QString jsonForCompletionString(const CXCompletionString &string);
+ QString jsonForCompletion(const CXCompletionResult &result);
+ QString jsonForDiagnsotic(const CXDiagnostic &diagnostic);
+
+private:
+ int m_indent;
+ QString m_printed;
+
+ void writeCompletionContexts(CXCodeCompleteResults *results);
+ void writeCompletionStringJson(const CXCompletionString &string);
+ void writeCompletionChunkJson(const CXCompletionString &string, unsigned i);
+ void writeCompletionAnnotationJson(const CXCompletionString &string, unsigned i);
+
+ void writeDiagnosticJson(const CXDiagnostic &diag);
+ void writeFixItJson(const CXDiagnostic &diag, unsigned i);
+
+ void writeRangeJson(const CXSourceRange &range);
+ void writeLocationJson(const CXSourceLocation &location);
+
+ void writeLineEnd();
+};
+
+} // namespace Internal
+} // namespace ClangCodeModel
+
+#endif // CXPRETTYPRINTER_H
diff --git a/src/plugins/clangcodemodel/cxraii.h b/src/plugins/clangcodemodel/cxraii.h
new file mode 100644
index 0000000000..bfc5189ded
--- /dev/null
+++ b/src/plugins/clangcodemodel/cxraii.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CXRAII_H
+#define CXRAII_H
+
+#include <clang-c/Index.h>
+
+// Simple RAII types for their CX correspondings
+
+namespace ClangCodeModel {
+namespace Internal {
+
+template <class CXType_T>
+struct ScopedCXType
+{
+protected:
+ typedef void (*DisposeFunction)(CXType_T);
+
+ ScopedCXType(DisposeFunction f)
+ : m_cx(0), m_disposeFunction(f)
+ {}
+ ScopedCXType(const CXType_T &cx, DisposeFunction f)
+ : m_cx(cx) , m_disposeFunction(f)
+ {}
+
+public:
+ ~ScopedCXType()
+ {
+ dispose();
+ }
+
+ operator CXType_T() const { return m_cx; }
+ bool operator!() const { return !m_cx; }
+ bool isNull() const { return !m_cx; }
+ void reset(const CXType_T &cx)
+ {
+ dispose();
+ m_cx = cx;
+ }
+
+private:
+ ScopedCXType(const ScopedCXType &);
+ const ScopedCXType &operator=(const ScopedCXType &);
+
+ void dispose()
+ {
+ if (m_cx)
+ m_disposeFunction(m_cx);
+ }
+
+ CXType_T m_cx;
+ DisposeFunction m_disposeFunction;
+};
+
+struct ScopedCXIndex : ScopedCXType<CXIndex>
+{
+ ScopedCXIndex()
+ : ScopedCXType<CXIndex>(&clang_disposeIndex)
+ {}
+ ScopedCXIndex(const CXIndex &index)
+ : ScopedCXType<CXIndex>(index, &clang_disposeIndex)
+ {}
+};
+
+struct ScopedCXTranslationUnit : ScopedCXType<CXTranslationUnit>
+{
+ ScopedCXTranslationUnit()
+ : ScopedCXType<CXTranslationUnit>(&clang_disposeTranslationUnit)
+ {}
+ ScopedCXTranslationUnit(const CXTranslationUnit &unit)
+ : ScopedCXType<CXTranslationUnit>(unit, &clang_disposeTranslationUnit)
+ {}
+};
+
+struct ScopedCXDiagnostic : ScopedCXType<CXDiagnostic>
+{
+ ScopedCXDiagnostic()
+ : ScopedCXType<CXDiagnostic>(&clang_disposeDiagnostic)
+ {}
+ ScopedCXDiagnostic(const CXDiagnostic &diagnostic)
+ : ScopedCXType<CXDiagnostic>(diagnostic, &clang_disposeDiagnostic)
+ {}
+};
+
+struct ScopedCXDiagnosticSet : ScopedCXType<CXDiagnostic>
+{
+ ScopedCXDiagnosticSet()
+ : ScopedCXType<CXDiagnosticSet>(&clang_disposeDiagnosticSet)
+ {}
+ ScopedCXDiagnosticSet(const CXDiagnostic &diagnostic)
+ : ScopedCXType<CXDiagnosticSet>(diagnostic, &clang_disposeDiagnosticSet)
+ {}
+};
+
+struct ScopedCXCodeCompleteResults : ScopedCXType<CXCodeCompleteResults*>
+{
+ ScopedCXCodeCompleteResults()
+ : ScopedCXType<CXCodeCompleteResults*>(&clang_disposeCodeCompleteResults)
+ {}
+ ScopedCXCodeCompleteResults(CXCodeCompleteResults *results)
+ : ScopedCXType<CXCodeCompleteResults*>(results, &clang_disposeCodeCompleteResults)
+ {}
+
+ unsigned size() const
+ {
+ return static_cast<CXCodeCompleteResults *>(*this)->NumResults;
+ }
+
+ const CXCompletionResult &completionAt(unsigned i)
+ {
+ return static_cast<CXCodeCompleteResults *>(*this)->Results[i];
+ }
+};
+
+} // Internal
+} // ClangCodeModel
+
+#endif // CXRAII_H
diff --git a/src/plugins/clangcodemodel/dependencygraph.cpp b/src/plugins/clangcodemodel/dependencygraph.cpp
new file mode 100644
index 0000000000..29c6f20f35
--- /dev/null
+++ b/src/plugins/clangcodemodel/dependencygraph.cpp
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "dependencygraph.h"
+
+#include <QtCore/QtConcurrentRun>
+
+using namespace ClangCodeModel;
+using namespace Internal;
+
+DependencyGraph::DependencyGraph()
+{
+ m_includeTracker.setResolutionMode(IncludeTracker::EveryMatchResolution);
+}
+
+DependencyGraph::~DependencyGraph()
+{
+ discard();
+}
+
+void DependencyGraph::cancel()
+{
+ if (m_computeWatcher.isRunning()) {
+ m_computeWatcher.cancel();
+ m_computeWatcher.waitForFinished();
+ }
+}
+
+void DependencyGraph::addFile(const QString &fileName, const QStringList &compilationOptions)
+{
+ cancel();
+
+ m_files.append(qMakePair(fileName, compilationOptions));
+}
+
+QFuture<void> DependencyGraph::compute()
+{
+ QFuture<void> future = QtConcurrent::run(this, &DependencyGraph::computeCore);
+ m_computeWatcher.setFuture(future);
+ return future;
+}
+
+void DependencyGraph::computeCore()
+{
+ for (int i = 0; i < m_files.size(); ++i) {
+ if (m_computeWatcher.isCanceled())
+ break;
+
+ const QPair<QString, QStringList> &p = m_files.at(i);
+ const QString &currentFile = p.first;
+ const QStringList &options = p.second;
+ const QPair<bool, NodeRefSetIt> &v = findVertex(currentFile);
+ if (!v.first)
+ processIncludes(insertVertex(currentFile), options);
+ }
+
+ emit dependencyGraphAvailable();
+}
+
+void DependencyGraph::processIncludes(NodeRefSetIt currentIt,
+ const QStringList &compilationOptions)
+{
+ const QString &currentFile = currentIt.key();
+ const QStringList &includes = m_includeTracker.directIncludes(currentFile, compilationOptions);
+ foreach (const QString &include, includes) {
+ if (m_computeWatcher.isCanceled())
+ return;
+
+ QPair<bool, NodeRefSetIt> v = findVertex(include);
+ if (!v.first) {
+ v.second = insertVertex(include);
+ processIncludes(v.second, compilationOptions);
+ }
+ insertEdge(currentIt, v.second);
+ }
+}
+
+namespace {
+
+struct SimpleVisitor
+{
+ bool acceptFile(const QString &fileName)
+ {
+ m_allFiles.append(fileName);
+ return false;
+ }
+
+ QStringList m_allFiles;
+};
+
+}
+
+QStringList DependencyGraph::collectDependencies(const QString &referenceFile,
+ DependencyRole role) const
+{
+ SimpleVisitor visitor;
+ collectDependencies(referenceFile, role, &visitor);
+
+ return visitor.m_allFiles;
+}
+
+bool DependencyGraph::hasDependency(const QString &referenceFile, DependencyRole role) const
+{
+ QPair<bool, NodeRefSetIt> v = findVertex(referenceFile);
+ if (!v.first)
+ return false;
+
+ NodeListIt nodeIt = v.second.value();
+
+ if (role == FilesDirectlyIncludedBy || role == FilesIncludedBy)
+ return nodeIt->m_out != 0;
+
+ return nodeIt->m_in != 0;
+}
+
+void DependencyGraph::discard()
+{
+ cancel();
+
+ for (NodeListIt it = m_nodes.begin(); it != m_nodes.end(); ++it) {
+ deleteAdjacencies(it->m_out);
+ deleteAdjacencies(it->m_in);
+ }
+ m_nodes.clear();
+ m_nodesRefs.clear();
+ m_files.clear();
+}
+
+
+DependencyGraph::Node::Node(const QString &fileName)
+ : m_fileName(fileName)
+ , m_out(0)
+ , m_in(0)
+{}
+
+DependencyGraph::AdjacencyNode::AdjacencyNode(NodeListIt it)
+ : m_next(0)
+ , m_nodeIt(it)
+{}
+
+QPair<bool, DependencyGraph::NodeRefSetIt> DependencyGraph::findVertex(const QString &s) const
+{
+ bool found = false;
+ NodeRefSetIt it = const_cast<NodeRefSet &>(m_nodesRefs).find(s);
+ if (it != m_nodesRefs.end())
+ found = true;
+ return qMakePair(found, it);
+}
+
+DependencyGraph::NodeRefSetIt DependencyGraph::insertVertex(const QString &s)
+{
+ Q_ASSERT(m_nodesRefs.find(s) == m_nodesRefs.end());
+
+ m_nodes.append(Node(s));
+ return m_nodesRefs.insert(s, m_nodes.end() - 1);
+}
+
+void DependencyGraph::insertEdge(DependencyGraph::NodeRefSetIt fromIt,
+ DependencyGraph::NodeRefSetIt toIt)
+{
+ NodeListIt nodeFromIt = fromIt.value();
+ NodeListIt nodeToIt = toIt.value();
+
+ createAdjacency(&nodeFromIt->m_out, new AdjacencyNode(nodeToIt));
+ createAdjacency(&nodeToIt->m_in, new AdjacencyNode(nodeFromIt));
+}
+
+void DependencyGraph::deleteAdjacencies(AdjacencyNode *node)
+{
+ while (node) {
+ AdjacencyNode *next = node->m_next;
+ delete node;
+ node = next;
+ }
+}
+
+void DependencyGraph::createAdjacency(AdjacencyNode **node, AdjacencyNode *newNode)
+{
+ if (*node)
+ newNode->m_next = *node;
+ *node = newNode;
+}
diff --git a/src/plugins/clangcodemodel/dependencygraph.h b/src/plugins/clangcodemodel/dependencygraph.h
new file mode 100644
index 0000000000..93a98455e1
--- /dev/null
+++ b/src/plugins/clangcodemodel/dependencygraph.h
@@ -0,0 +1,235 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef DEPENDENCYGRAPH_H
+#define DEPENDENCYGRAPH_H
+
+#include "includetracker.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QStringList>
+#include <QtCore/QLinkedList>
+#include <QtCore/QHash>
+#include <QtCore/QPair>
+#include <QtCore/QQueue>
+#include <QtCore/QFuture>
+#include <QtCore/QFutureWatcher>
+#include <QtCore/QDebug>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class DependencyGraph : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(DependencyGraph)
+
+public:
+ DependencyGraph();
+ ~DependencyGraph();
+
+ void addFile(const QString &fileName, const QStringList &compilationOptions);
+
+ QFuture<void> compute();
+
+ enum DependencyRole
+ {
+ FilesDirectlyIncludedBy, // Only direct inclusions
+ FilesIncludedBy, // Both direct and indirect inclusions
+ FilesWhichDirectlyInclude, // This one is directly included from...
+ FilesWhichInclude // This one is directly or indirectly included from...
+ };
+
+ /*
+ * You should use this version if you simply want all the dependencies, no matter what.
+ */
+ QStringList collectDependencies(const QString &referenceFile, DependencyRole role) const;
+
+ /*
+ * You should use this version if you might be interested on a particular dependency
+ * and don't want to continue the search once you have found it. In this case you need
+ * supply a visitor. Currently the visitor concept simply requires that a type Visitor_T
+ * models a function that will receive a file string s and indicate whether or not to
+ * continue:
+ *
+ * Visitor_T().acceptFile(s) must be a valid expression.
+ *
+ */
+ template <class Visitor_T>
+ void collectDependencies(const QString &referenceFile,
+ DependencyRole role,
+ Visitor_T *visitor) const;
+
+ bool hasDependency(const QString &referenceFile, DependencyRole role) const;
+
+ void discard();
+
+signals:
+ void dependencyGraphAvailable();
+
+private:
+ QList<QPair<QString, QStringList> > m_files;
+ IncludeTracker m_includeTracker;
+ QFutureWatcher<void> m_computeWatcher;
+
+ void cancel();
+ void computeCore();
+
+ // The dependency graph is represent as an adjacency list. The vertices contains
+ // a list of *out* edges and a list of *in* edges. Each vertex corresponds to a file.
+ // Its out edges correspond to the files which get directly included by this one, while
+ // its in edges correspond to files that directly include this one.
+ //
+ // For better space efficiency, the adjacency nodes doen't explicitly store the file
+ // names themselves, but rather an iterator to the corresponding vertex. In addition,
+ // for speed efficiency we keep track of a hash table that contains iterators to the
+ // actual vertex storage container, which actually contains the strings for the file
+ // names. The vertex container itself is a linked list, it has the semantics we need,
+ // in particular regarding iterator invalidation.
+
+ struct AdjacencyNode;
+ struct Node
+ {
+ Node(const QString &fileName);
+
+ QString m_fileName;
+ AdjacencyNode *m_out;
+ AdjacencyNode *m_in;
+ };
+
+ typedef QLinkedList<Node> NodeList;
+ typedef NodeList::iterator NodeListIt;
+ typedef QHash<QString, NodeListIt> NodeRefSet;
+ typedef NodeRefSet::iterator NodeRefSetIt;
+
+ struct AdjacencyNode
+ {
+ AdjacencyNode(NodeListIt it);
+
+ AdjacencyNode *m_next;
+ NodeListIt m_nodeIt;
+ };
+
+
+ void processIncludes(NodeRefSetIt currentFileIt,
+ const QStringList &compilationOptions);
+
+ template <class Visitor_T>
+ void collectFilesBFS(NodeListIt nodeIt, DependencyRole role, Visitor_T *visitor) const;
+
+
+ // Core graph operations and data
+
+ QPair<bool, NodeRefSetIt> findVertex(const QString &s) const;
+ NodeRefSetIt insertVertex(const QString &s);
+ void insertEdge(NodeRefSetIt fromIt, NodeRefSetIt toIt);
+
+ void deleteAdjacencies(AdjacencyNode *node);
+ void createAdjacency(AdjacencyNode **node, AdjacencyNode *newNode);
+
+ NodeList m_nodes;
+ NodeRefSet m_nodesRefs;
+};
+
+template <class Visitor_T>
+void DependencyGraph::collectDependencies(const QString &referenceFile,
+ DependencyRole role,
+ Visitor_T *visitor) const
+{
+ if (m_computeWatcher.isRunning())
+ return;
+
+ QPair<bool, NodeRefSetIt> v = findVertex(referenceFile);
+ if (!v.first)
+ return;
+
+ NodeListIt nodeIt = v.second.value();
+
+ if (role == FilesDirectlyIncludedBy || role == FilesWhichDirectlyInclude) {
+ AdjacencyNode *adj;
+ if (role == FilesDirectlyIncludedBy)
+ adj = nodeIt->m_out;
+ else
+ adj = nodeIt->m_in;
+
+ for (; adj; adj = adj->m_next) {
+ NodeListIt dependentIt = adj->m_nodeIt;
+ if (visitor->acceptFile(dependentIt->m_fileName))
+ return;
+ }
+ } else {
+ collectFilesBFS(nodeIt, role, visitor);
+ }
+}
+
+template <class Visitor_T>
+void DependencyGraph::collectFilesBFS(NodeListIt nodeIt,
+ DependencyRole role,
+ Visitor_T *visitor) const
+{
+ Q_ASSERT(role == FilesIncludedBy || role == FilesWhichInclude);
+
+ if (m_computeWatcher.isRunning())
+ return;
+
+ QQueue<NodeListIt> q;
+ q.enqueue(nodeIt);
+
+ QSet<QString> visited;
+ visited.insert(nodeIt->m_fileName);
+
+ while (!q.isEmpty()) {
+ NodeListIt currentIt = q.dequeue();
+ AdjacencyNode *adj;
+ if (role == FilesIncludedBy)
+ adj = currentIt->m_out;
+ else
+ adj = currentIt->m_in;
+ while (adj) {
+ NodeListIt adjNodeIt = adj->m_nodeIt;
+ adj = adj->m_next;
+
+ const QString &adjFileName = adjNodeIt->m_fileName;
+ if (visited.contains(adjFileName))
+ continue;
+
+ if (visitor->acceptFile(adjFileName))
+ return;
+
+ visited.insert(adjFileName);
+ q.enqueue(adjNodeIt);
+ }
+ }
+}
+
+
+} // Internal
+} // ClangCodeModel
+
+#endif // DEPENDENCYGRAPH_H
diff --git a/src/plugins/clangcodemodel/diagnostic.cpp b/src/plugins/clangcodemodel/diagnostic.cpp
new file mode 100644
index 0000000000..07db56a862
--- /dev/null
+++ b/src/plugins/clangcodemodel/diagnostic.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "diagnostic.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QStringList>
+
+using namespace ClangCodeModel;
+
+Diagnostic::Diagnostic()
+ : m_severity(Unknown)
+ , m_length(0)
+{}
+
+Diagnostic::Diagnostic(Severity severity, const SourceLocation &location, unsigned length, const QString &spelling)
+ : m_severity(severity)
+ , m_loc(location)
+ , m_length(length)
+ , m_spelling(spelling)
+{}
+
+const QString Diagnostic::severityAsString() const
+{
+ if (m_severity == Unknown)
+ return QString();
+
+ static QStringList strs = QStringList()
+ << QCoreApplication::translate("Diagnostic", "ignored")
+ << QCoreApplication::translate("Diagnostic", "note")
+ << QCoreApplication::translate("Diagnostic", "warning")
+ << QCoreApplication::translate("Diagnostic", "error")
+ << QCoreApplication::translate("Diagnostic", "fatal")
+ ;
+
+ return strs.at(m_severity);
+}
diff --git a/src/plugins/clangcodemodel/diagnostic.h b/src/plugins/clangcodemodel/diagnostic.h
new file mode 100644
index 0000000000..24d6c448bd
--- /dev/null
+++ b/src/plugins/clangcodemodel/diagnostic.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANG_DIAGNOSTIC_H
+#define CLANG_DIAGNOSTIC_H
+
+#include "clang_global.h"
+#include "sourcelocation.h"
+
+#include <QMetaType>
+
+namespace ClangCodeModel {
+
+class CLANG_EXPORT Diagnostic
+{
+public:
+ enum Severity {
+ Unknown = -1,
+ Ignored = 0,
+ Note = 1,
+ Warning = 2,
+ Error = 3,
+ Fatal = 4
+ };
+
+public:
+ Diagnostic();
+ Diagnostic(Severity severity, const SourceLocation &location, unsigned length, const QString &spelling);
+
+ Severity severity() const
+ { return m_severity; }
+
+ const QString severityAsString() const;
+
+ const SourceLocation &location() const
+ { return m_loc; }
+
+ unsigned length() const
+ { return m_length; }
+
+ const QString &spelling() const
+ { return m_spelling; }
+
+private:
+ Severity m_severity;
+ SourceLocation m_loc;
+ unsigned m_length;
+ QString m_spelling;
+};
+
+} // namespace ClangCodeModel
+
+Q_DECLARE_METATYPE(ClangCodeModel::Diagnostic)
+Q_DECLARE_METATYPE(QList<ClangCodeModel::Diagnostic>)
+
+#endif // CLANG_DIAGNOSTIC_H
diff --git a/tests/manual/debugger/helper/main.cpp b/src/plugins/clangcodemodel/fastindexer.cpp
index 14f9f6aed1..fcf369dfec 100644
--- a/tests/manual/debugger/helper/main.cpp
+++ b/src/plugins/clangcodemodel/fastindexer.cpp
@@ -27,21 +27,10 @@
**
****************************************************************************/
-#include <QApplication>
+#include "fastindexer.h"
-extern "C"
-void qDumpObjectData440(
- int protocolVersion,
- int token,
- void *data,
- bool dumpChildren,
- int extraInt0,
- int extraInt1,
- int extraInt2,
- int extraInt3);
+using namespace ClangCodeModel::Internal;
-int main(int argc, char *argv[])
+FastIndexer::~FastIndexer()
{
- QApplication app(argc, argv);
- return 0;
}
diff --git a/src/plugins/clangcodemodel/fastindexer.h b/src/plugins/clangcodemodel/fastindexer.h
new file mode 100644
index 0000000000..1e269ec381
--- /dev/null
+++ b/src/plugins/clangcodemodel/fastindexer.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef FASTINDEXER_H
+#define FASTINDEXER_H
+
+#include "unit.h"
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class FastIndexer
+{
+public:
+ virtual ~FastIndexer() = 0;
+
+ virtual void indexNow(Unit::Ptr unit) = 0;
+};
+
+} // Internal namespace
+} // ClangCodeModel namespace
+
+#endif // FASTINDEXER_H
diff --git a/src/plugins/clangcodemodel/index.cpp b/src/plugins/clangcodemodel/index.cpp
new file mode 100644
index 0000000000..cf85e6385b
--- /dev/null
+++ b/src/plugins/clangcodemodel/index.cpp
@@ -0,0 +1,491 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangsymbolsearcher.h"
+#include "index.h"
+
+#include <QStringList>
+#include <QLinkedList>
+#include <QHash>
+#include <QDataStream>
+#include <QPair>
+#include <QFileInfo>
+#include <QMutex>
+#include <QMutexLocker>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class ClangSymbolSearcher;
+
+class IndexPrivate
+{
+public:
+ IndexPrivate();
+
+ void insertSymbol(const Symbol &symbol, const QDateTime &timeStamp);
+ QList<Symbol> symbols(const QString &fileName) const;
+ QList<Symbol> symbols(const QString &fileName, Symbol::Kind kind) const;
+ QList<Symbol> symbols(const QString &fileName, Symbol::Kind kind, const QString &uqName) const;
+ QList<Symbol> symbols(const QString &fileName, const QString &uqName) const;
+ QList<Symbol> symbols(Symbol::Kind kind) const;
+
+ void match(ClangSymbolSearcher *searcher) const;
+
+ void insertFile(const QString &fileName, const QDateTime &timeStamp);
+ void removeFile(const QString &fileName);
+ void removeFiles(const QStringList &fileNames);
+ bool containsFile(const QString &fileName) const;
+ QStringList files() const;
+
+ void clear();
+
+ bool isEmpty() const;
+
+ void trackTimeStamp(const Symbol &symbol, const QDateTime &timeStamp);
+ void trackTimeStamp(const QString &fileName, const QDateTime &timeStamp);
+
+ bool validate(const QString &fileName) const;
+
+ QByteArray serialize() const;
+ void deserialize(const QByteArray &data);
+
+private:
+ typedef QLinkedList<Symbol> SymbolCont;
+ typedef SymbolCont::iterator SymbolIt;
+
+ typedef QHash<QString, QList<SymbolIt> > NameIndex;
+ typedef QHash<Symbol::Kind, NameIndex> KindIndex;
+ typedef QHash<QString, KindIndex> FileIndex;
+
+ typedef QList<SymbolIt>::iterator SymbolIndexIt;
+ typedef NameIndex::iterator NameIndexIt;
+ typedef KindIndex::iterator KindIndexIt;
+ typedef FileIndex::iterator FileIndexIt;
+ typedef FileIndex::const_iterator FileIndexCIt;
+
+ void insertSymbol(const Symbol &symbol);
+ void removeSymbol(SymbolIndexIt it);
+
+ QPair<bool, SymbolIndexIt> findEquivalentSymbol(const Symbol &symbol);
+ void updateEquivalentSymbol(SymbolIndexIt it, const Symbol &symbol);
+
+ void createIndexes(SymbolIt it);
+ QList<SymbolIt> removeIndexes(const QString &fileName);
+
+ static QList<Symbol> symbolsFromIterators(const QList<SymbolIt> &symbolList);
+
+ // @TODO: Sharing of compilation options...
+
+ mutable QMutex m_mutex;
+ SymbolCont m_container;
+ FileIndex m_files;
+ QHash<QString, QDateTime> m_timeStamps;
+};
+
+} // namespace Internal
+} // namespace ClangCodeModel
+
+using namespace ClangCodeModel;
+using namespace Internal;
+
+IndexPrivate::IndexPrivate()
+ : m_mutex(QMutex::Recursive)
+{
+}
+
+void IndexPrivate::createIndexes(SymbolIt it)
+{
+ m_files[it->m_location.fileName()][it->m_kind][it->m_name].append(it);
+}
+
+QList<QLinkedList<Symbol>::iterator> IndexPrivate::removeIndexes(const QString &fileName)
+{
+ QList<SymbolIt> iterators;
+ KindIndex kindIndex = m_files.take(fileName);
+ KindIndexIt it = kindIndex.begin();
+ KindIndexIt eit = kindIndex.end();
+ for (; it != eit; ++it) {
+ NameIndex nameIndex = *it;
+ NameIndexIt nit = nameIndex.begin();
+ NameIndexIt neit = nameIndex.end();
+ for (; nit != neit; ++nit)
+ iterators.append(*nit);
+ }
+ return iterators;
+}
+
+void IndexPrivate::insertSymbol(const Symbol &symbol)
+{
+ QMutexLocker locker(&m_mutex);
+
+ SymbolIt it = m_container.insert(m_container.begin(), symbol);
+ createIndexes(it);
+}
+
+void IndexPrivate::insertSymbol(const Symbol &symbol, const QDateTime &timeStamp)
+{
+ const QPair<bool, SymbolIndexIt> &find = findEquivalentSymbol(symbol);
+ if (find.first)
+ updateEquivalentSymbol(find.second, symbol);
+ else
+ insertSymbol(symbol);
+
+ trackTimeStamp(symbol, timeStamp);
+}
+
+QPair<bool, IndexPrivate::SymbolIndexIt> IndexPrivate::findEquivalentSymbol(const Symbol &symbol)
+{
+ // Despite the loop below finding a symbol should be efficient, since we already filter
+ // the file name, the kind, and the qualified name through the indexing mechanism. In many
+ // cases it will iterate only once.
+ QList<SymbolIt> &byName = m_files[symbol.m_location.fileName()][symbol.m_kind][symbol.m_name];
+ for (SymbolIndexIt it = byName.begin(); it != byName.end(); ++it) {
+ const Symbol &candidateSymbol = *(*it);
+ // @TODO: Overloads, template specializations
+ if (candidateSymbol.m_qualification == symbol.m_qualification)
+ return qMakePair(true, it);
+ }
+
+ return qMakePair(false, QList<SymbolIt>::iterator());
+}
+
+void IndexPrivate::updateEquivalentSymbol(SymbolIndexIt it, const Symbol &symbol)
+{
+ SymbolIt symbolIt = *it;
+
+ Q_ASSERT(symbolIt->m_kind == symbol.m_kind);
+ Q_ASSERT(symbolIt->m_qualification == symbol.m_qualification);
+ Q_ASSERT(symbolIt->m_name == symbol.m_name);
+ Q_ASSERT(symbolIt->m_location.fileName() == symbol.m_location.fileName());
+
+ symbolIt->m_location = symbol.m_location;
+}
+
+void IndexPrivate::removeSymbol(SymbolIndexIt it)
+{
+ SymbolIt symbolIt = *it;
+
+ m_container.erase(symbolIt);
+
+ KindIndex &kindIndex = m_files[symbolIt->m_location.fileName()];
+ NameIndex &nameIndex = kindIndex[symbolIt->m_kind];
+ QList<SymbolIt> &byName = nameIndex[symbolIt->m_name];
+ byName.erase(it);
+ if (byName.isEmpty()) {
+ nameIndex.remove(symbolIt->m_name);
+ if (nameIndex.isEmpty()) {
+ kindIndex.remove(symbolIt->m_kind);
+ if (kindIndex.isEmpty())
+ m_files.remove(symbolIt->m_location.fileName());
+ }
+ }
+}
+
+QList<Symbol> IndexPrivate::symbols(const QString &fileName) const
+{
+ QMutexLocker locker(&m_mutex);
+
+ QList<Symbol> all;
+ const QList<NameIndex> &byKind = m_files.value(fileName).values();
+ foreach (const NameIndex &nameIndex, byKind) {
+ const QList<QList<SymbolIt> > &byName = nameIndex.values();
+ foreach (const QList<SymbolIt> &symbols, byName)
+ all.append(symbolsFromIterators(symbols));
+ }
+ return all;
+}
+
+QList<Symbol> IndexPrivate::symbols(const QString &fileName, Symbol::Kind kind) const
+{
+ QMutexLocker locker(&m_mutex);
+
+ QList<Symbol> all;
+ const QList<QList<SymbolIt> > &byName = m_files.value(fileName).value(kind).values();
+ foreach (const QList<SymbolIt> &symbols, byName)
+ all.append(symbolsFromIterators(symbols));
+ return all;
+}
+
+QList<Symbol> IndexPrivate::symbols(const QString &fileName,
+ Symbol::Kind kind,
+ const QString &uqName) const
+{
+ QMutexLocker locker(&m_mutex);
+
+ return symbolsFromIterators(m_files.value(fileName).value(kind).value(uqName));
+}
+
+QList<Symbol> IndexPrivate::symbols(Symbol::Kind kind) const
+{
+ QMutexLocker locker(&m_mutex);
+
+ QList<Symbol> all;
+ FileIndexCIt it = m_files.begin();
+ FileIndexCIt eit = m_files.end();
+ for (; it != eit; ++it)
+ all.append(symbols(it.key(), kind));
+ return all;
+}
+
+void IndexPrivate::match(ClangSymbolSearcher *searcher) const
+{
+ QMutexLocker locker(&m_mutex);
+
+ searcher->search(m_container);
+}
+
+QList<Symbol> IndexPrivate::symbolsFromIterators(const QList<SymbolIt> &symbolList)
+{
+ QList<Symbol> all;
+ foreach (SymbolIt symbolIt, symbolList)
+ all.append(*symbolIt);
+ return all;
+}
+
+void IndexPrivate::trackTimeStamp(const Symbol &symbol, const QDateTime &timeStamp)
+{
+ QMutexLocker locker(&m_mutex);
+
+ trackTimeStamp(symbol.m_location.fileName(), timeStamp);
+}
+
+void IndexPrivate::trackTimeStamp(const QString &fileName, const QDateTime &timeStamp)
+{
+ QMutexLocker locker(&m_mutex);
+
+ // We keep track of time stamps on a per file basis (most recent one).
+ m_timeStamps[fileName] = timeStamp;
+}
+
+bool IndexPrivate::validate(const QString &fileName) const
+{
+ QMutexLocker locker(&m_mutex);
+
+ const QDateTime &timeStamp = m_timeStamps.value(fileName);
+ if (!timeStamp.isValid())
+ return false;
+
+ QFileInfo fileInfo(fileName);
+ if (fileInfo.lastModified() > timeStamp)
+ return false;
+
+ return true;
+}
+
+void IndexPrivate::insertFile(const QString &fileName, const QDateTime &timeStamp)
+{
+ QMutexLocker locker(&m_mutex);
+
+ trackTimeStamp(fileName, timeStamp);
+}
+
+QStringList IndexPrivate::files() const
+{
+ QMutexLocker locker(&m_mutex);
+
+ return m_timeStamps.keys();
+}
+
+bool IndexPrivate::containsFile(const QString &fileName) const
+{
+ QMutexLocker locker(&m_mutex);
+
+ return m_timeStamps.contains(fileName);
+}
+
+void IndexPrivate::removeFile(const QString &fileName)
+{
+ QMutexLocker locker(&m_mutex);
+
+ const QList<SymbolIt> &iterators = removeIndexes(fileName);
+ foreach (SymbolIt it, iterators)
+ m_container.erase(it);
+
+ m_timeStamps.remove(fileName);
+}
+
+void IndexPrivate::removeFiles(const QStringList &fileNames)
+{
+ QMutexLocker locker(&m_mutex);
+
+ foreach (const QString &fileName, fileNames)
+ removeFile(fileName);
+}
+
+void IndexPrivate::clear()
+{
+ QMutexLocker locker(&m_mutex);
+
+ m_container.clear();
+ m_files.clear();
+ m_timeStamps.clear();
+}
+
+bool IndexPrivate::isEmpty() const
+{
+ QMutexLocker locker(&m_mutex);
+
+ return m_timeStamps.isEmpty();
+}
+
+QByteArray IndexPrivate::serialize() const
+{
+ QMutexLocker locker(&m_mutex);
+
+ QByteArray data;
+ QDataStream stream(&data, QIODevice::WriteOnly);
+
+ stream << (quint32)0x0A0BFFEE;
+ stream << (quint16)1;
+ stream.setVersion(QDataStream::Qt_4_7);
+ stream << m_container;
+ stream << m_timeStamps;
+
+ return data;
+}
+
+void IndexPrivate::deserialize(const QByteArray &data)
+{
+ QMutexLocker locker(&m_mutex);
+
+ clear();
+
+ // @TODO: Version compatibility handling.
+
+ QDataStream stream(data);
+
+ quint32 header;
+ stream >> header;
+ if (header != 0x0A0BFFEE)
+ return;
+
+ quint16 indexVersion;
+ stream >> indexVersion;
+ if (indexVersion != 1)
+ return;
+
+ stream.setVersion(QDataStream::Qt_4_7);
+
+ SymbolCont symbols;
+ stream >> symbols;
+ stream >> m_timeStamps;
+
+ // @TODO: Overload the related functions with batch versions.
+ foreach (const Symbol &symbol, symbols)
+ insertSymbol(symbol);
+}
+
+
+Index::Index()
+ : d(new IndexPrivate)
+{}
+
+Index::~Index()
+{}
+
+void Index::insertSymbol(const Symbol &symbol, const QDateTime &timeStamp)
+{
+ d->insertSymbol(symbol, timeStamp);
+}
+
+QList<Symbol> Index::symbols(const QString &fileName) const
+{
+ return d->symbols(fileName);
+}
+
+QList<Symbol> Index::symbols(const QString &fileName, Symbol::Kind kind) const
+{
+ return d->symbols(fileName, kind);
+}
+
+QList<Symbol> Index::symbols(const QString &fileName, Symbol::Kind kind, const QString &uqName) const
+{
+ return d->symbols(fileName, kind, uqName);
+}
+
+QList<Symbol> Index::symbols(Symbol::Kind kind) const
+{
+ return d->symbols(kind);
+}
+
+void Index::match(ClangSymbolSearcher *searcher) const
+{
+ d->match(searcher);
+}
+
+void Index::insertFile(const QString &fileName, const QDateTime &timeStamp)
+{
+ d->insertFile(fileName, timeStamp);
+}
+
+QStringList Index::files() const
+{
+ return d->files();
+}
+
+bool Index::containsFile(const QString &fileName) const
+{
+ return d->containsFile(fileName);
+}
+
+void Index::removeFile(const QString &fileName)
+{
+ d->removeFile(fileName);
+}
+
+void Index::removeFiles(const QStringList &fileNames)
+{
+ d->removeFiles(fileNames);
+}
+
+void Index::clear()
+{
+ d->clear();
+}
+
+bool Index::isEmpty() const
+{
+ return d->isEmpty();
+}
+
+bool Index::validate(const QString &fileName) const
+{
+ return d->validate(fileName);
+}
+
+QByteArray Index::serialize() const
+{
+ return d->serialize();
+}
+
+void Index::deserialize(const QByteArray &data)
+{
+ d->deserialize(data);
+}
diff --git a/src/plugins/clangcodemodel/index.h b/src/plugins/clangcodemodel/index.h
new file mode 100644
index 0000000000..18abb47ea8
--- /dev/null
+++ b/src/plugins/clangcodemodel/index.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef INDEX_H
+#define INDEX_H
+
+#include "symbol.h"
+
+#include <QtCore/QByteArray>
+#include <QtCore/QString>
+#include <QtCore/QList>
+#include <QtCore/QScopedPointer>
+#include <QtCore/QDateTime>
+#include <QStringList>
+
+namespace ClangCodeModel {
+
+class Symbol;
+
+namespace Internal {
+
+class ClangSymbolSearcher;
+class IndexPrivate;
+
+class Index
+{
+public:
+ Index();
+ ~Index();
+
+ void insertSymbol(const Symbol &symbol, const QDateTime &timeStamp);
+ QList<Symbol> symbols(const QString &fileName) const;
+ QList<Symbol> symbols(const QString &fileName, Symbol::Kind kind) const;
+ QList<Symbol> symbols(const QString &fileName, Symbol::Kind kind, const QString &uqName) const;
+ QList<Symbol> symbols(Symbol::Kind kind) const;
+
+ void match(ClangSymbolSearcher *searcher) const;
+
+ void insertFile(const QString &fileName, const QDateTime &timeStamp);
+ void removeFile(const QString &fileName);
+ void removeFiles(const QStringList &fileNames);
+ bool containsFile(const QString &fileName) const;
+ QStringList files() const;
+
+ bool validate(const QString &fileName) const;
+
+ void clear();
+
+ bool isEmpty() const;
+
+ QByteArray serialize() const;
+ void deserialize(const QByteArray &data);
+
+private:
+ QScopedPointer<IndexPrivate> d;
+};
+
+} // Internal
+} // ClangCodeModel
+
+#endif // INDEX_H
diff --git a/src/plugins/clangcodemodel/indexer.cpp b/src/plugins/clangcodemodel/indexer.cpp
new file mode 100644
index 0000000000..2666121bb1
--- /dev/null
+++ b/src/plugins/clangcodemodel/indexer.cpp
@@ -0,0 +1,1291 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangutils.h"
+#include "indexer.h"
+#include "index.h"
+#include "cxraii.h"
+#include "sourcelocation.h"
+#include "liveunitsmanager.h"
+#include "utils_p.h"
+#include "clangsymbolsearcher.h"
+#include "pchmanager.h"
+#include "raii/scopedclangoptions.h"
+
+#include <clang-c/Index.h>
+
+#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/progressmanager/progressmanager.h>
+#include <utils/fileutils.h>
+#include <utils/QtConcurrentTools>
+
+#include <QDebug>
+#include <QVector>
+#include <QHash>
+#include <QSet>
+#include <QFile>
+#include <QFileInfo>
+#include <QFutureWatcher>
+#include <QDir>
+#include <QFuture>
+#include <QTime>
+#include <QRunnable>
+#include <QThreadPool>
+#include <QDateTime>
+#include <QStringBuilder>
+
+#include <cassert>
+
+//#define DEBUG
+//#define DEBUG_DIAGNOSTICS
+
+#ifdef DEBUG
+ #define BEGIN_PROFILE_SCOPE(ID) { ScopepTimer t(ID);
+ #define END_PROFILE_SCOPE }
+#else
+ #define BEGIN_PROFILE_SCOPE(ID)
+ #define END_PROFILE_SCOPE
+#endif
+
+using namespace Utils;
+using namespace ClangCodeModel;
+using namespace Internal;
+
+namespace ClangCodeModel {
+
+// The indexing result, containing the symbols found, reported by the indexer processor.
+struct IndexingResult
+{
+ typedef CppTools::ProjectPart ProjectPart;
+
+ IndexingResult()
+ : m_unit(Unit::create())
+ {}
+
+ IndexingResult(const QVector<Symbol> &symbol,
+ const QSet<QString> &processedFiles,
+ const Unit::Ptr &unit,
+ const ProjectPart::Ptr &projectPart)
+ : m_symbolsInfo(symbol)
+ , m_processedFiles(processedFiles)
+ , m_unit(unit)
+ , m_projectPart(projectPart)
+ {}
+
+ QVector<Symbol> m_symbolsInfo;
+ QSet<QString> m_processedFiles;
+ Unit::Ptr m_unit;
+ ProjectPart::Ptr m_projectPart;
+};
+
+class LibClangIndexer;
+
+class IndexerPrivate : public QObject
+{
+ Q_OBJECT
+
+public:
+ typedef CppTools::ProjectPart ProjectPart;
+
+public:
+ IndexerPrivate(Indexer *indexer);
+ ~IndexerPrivate()
+ { cancel(true); }
+
+ // This enumeration is used to index a vector. So be careful when changing.
+ enum FileType {
+ ImplementationFile = 0,
+ HeaderFile,
+ TotalFileTypes
+ };
+
+ struct FileData
+ {
+ FileData() : m_upToDate(false) {}
+ FileData(const QString &fileName,
+ const ProjectPart::Ptr &projectPart,
+ bool upToDate = false)
+ : m_fileName(fileName)
+ , m_projectPart(projectPart)
+ , m_upToDate(upToDate)
+ , m_managementOptions(CXTranslationUnit_DetailedPreprocessingRecord
+ | CXTranslationUnit_Incomplete)
+ {}
+
+ QString m_fileName;
+ ProjectPart::Ptr m_projectPart;
+ bool m_upToDate;
+ unsigned m_managementOptions;
+ };
+
+ void synchronize(const QVector<IndexingResult> &results);
+ void finished(LibClangIndexer *indexer);
+ bool noIndexersRunning() const;
+
+private:
+ mutable QMutex m_mutex;
+
+ void indexingFinished();
+ void cancelIndexing();
+ int runningIndexerCount() const;
+
+public slots:
+ void dependencyGraphComputed();
+ void restoredSymbolsAnalysed();
+
+public:
+ enum IndexingMode {
+ RelaxedIndexing, // Index symbols from any file.
+ ConstrainedIndexing // Index symbols only from the requested files.
+ };
+
+ void startLoading();
+ void concludeLoading();
+
+ void computeDependencyGraph();
+ void analyzeRestoredSymbols();
+
+ void runQuickIndexing(const Unit &unit, const ProjectPart::Ptr &part);
+ void run();
+ void run(const QStringList &fileNames);
+ void runCore(const QHash<QString, FileData> &headers,
+ const QHash<QString, FileData> &impls,
+ IndexingMode mode);
+ void watchIndexingThreads(QFutureInterface<void> &future);
+ bool isBusy() const;
+ void cancel(bool wait);
+ void reset();
+
+ bool addFile(const QString &fileName,
+ ProjectPart::Ptr projectPart);
+ void addOrUpdateFileData(const QString &fileName,
+ ProjectPart::Ptr projectPart,
+ bool upToDate);
+ QStringList allFiles() const;
+ bool isTrackingFile(const QString &fileName, FileType type) const;
+ static FileType identifyFileType(const QString &fileName);
+ static void populateFileNames(QStringList *all, const QList<FileData> &data);
+ QStringList compilationOptions(const QString &fileName) const;
+
+ bool deserealizeSymbols();
+ void serializeSymbols() const;
+
+ QList<Symbol> symbols(Symbol::Kind kind) const;
+ QList<Symbol> symbols(const QString &fileName, const Symbol::Kind kind) const;
+ void match(ClangSymbolSearcher *searcher) const;
+
+ Indexer *m_q;
+ QVector<QHash<QString, FileData> > m_files;
+ Index m_index;
+ bool m_hasQueuedFullRun;
+ QSet<QString> m_queuedFilesRun;
+ QString m_storagePath;
+ bool m_isLoaded;
+// DependencyGraph m_dependencyGraph;
+ QScopedPointer<QFutureWatcher<void> >m_loadingWatcher;
+ QScopedPointer<QFutureWatcher<void> >m_indexingWatcher;
+ QThreadPool m_indexingPool;
+ QSet<LibClangIndexer *> m_runningIndexers;
+};
+
+} // ClangCodeModel
+
+Q_DECLARE_METATYPE(IndexingResult)
+
+namespace {
+
+struct ScopepTimer
+{
+ ScopepTimer(int id = 0) : m_id(id) { m_t.start(); }
+ ~ScopepTimer() { qDebug() << "\t#Timer" << m_id << ":" << m_t.elapsed() << "ms"; }
+ int m_id;
+ QTime m_t;
+};
+
+} // Anonymous
+
+namespace ClangCodeModel {
+
+class LibClangIndexer: public QRunnable
+{
+protected:
+ typedef CppTools::ProjectPart ProjectPart;
+
+public:
+ LibClangIndexer(IndexerPrivate *indexer)
+ : m_indexer(indexer)
+ , m_isCanceled(false)
+ {}
+
+ virtual ~LibClangIndexer()
+ {}
+
+ void cancel()
+ { m_isCanceled = true; }
+
+protected:
+ void propagateResults(const ProjectPart::Ptr &projectPart)
+ {
+ if (!isCanceled()) {
+ QVector<IndexingResult> indexingResults;
+ indexingResults.reserve(m_allFiles.size());
+
+ foreach (const QString &fn, m_allFiles.keys()) {
+ QVector<ClangCodeModel::Symbol> symbols; unfoldSymbols(symbols, fn);
+ QSet<QString> processedFiles = QSet<QString>::fromList(m_allFiles.keys());
+ Unit::Ptr unit = Unit::create(fn);
+ IndexingResult indexingResult(symbols, processedFiles, unit, projectPart);
+ indexingResults.append(indexingResult);
+
+ // TODO: includes need to be propagated to the dependency table.
+ }
+ m_indexer->synchronize(indexingResults);
+ }
+
+ qDeleteAll(m_allFiles.values());
+ m_allFiles.clear();
+ qDeleteAll(m_allSymbols);
+ m_allSymbols.clear();
+ }
+
+protected:
+ static inline LibClangIndexer *indexer(CXClientData d)
+ { return static_cast<LibClangIndexer *>(d); }
+
+ static int abortQuery(CXClientData client_data, void *reserved) {
+ Q_UNUSED(reserved);
+
+ return indexer(client_data)->isCanceled();
+ }
+
+ static void diagnostic(CXClientData client_data, CXDiagnosticSet diagSet, void *reserved) {
+ Q_UNUSED(client_data);
+ Q_UNUSED(diagSet);
+ Q_UNUSED(reserved);
+ }
+
+ static CXIdxClientFile enteredMainFile(CXClientData client_data, CXFile file, void *reserved) {
+ Q_UNUSED(client_data);
+ Q_UNUSED(reserved);
+
+ const QString fileName = getQString(clang_getFileName(file));
+// qDebug() << "enteredMainFile:" << fileName;
+ LibClangIndexer *lci = indexer(client_data);
+ File *f = lci->file(fileName);
+ f->setMainFile();
+
+ return f;
+ }
+
+ static CXIdxClientFile includedFile(CXClientData client_data, const CXIdxIncludedFileInfo *info) {
+ Q_UNUSED(client_data);
+
+ File *includingFile = 0;
+ clang_indexLoc_getFileLocation(info->hashLoc, reinterpret_cast<CXIdxClientFile*>(&includingFile), 0, 0, 0, 0);
+
+ const QString fileName = getQString(clang_getFileName(info->file));
+ File *f = indexer(client_data)->file(fileName);
+
+ if (includingFile)
+ includingFile->addInclude(f);
+
+ return f;
+ }
+
+ static CXIdxClientFile importedASTFile(CXClientData client_data, const CXIdxImportedASTFileInfo *info) {
+ const QString fileName = getQString(clang_getFileName(info->file));
+
+// qDebug() << "importedASTFile:" << fileName;
+
+ indexer(client_data)->m_importedASTs.insert(fileName, false);
+
+ return info->file;
+ }
+
+ static CXIdxClientContainer startedTranslationUnit(CXClientData client_data, void *reserved) {
+ Q_UNUSED(client_data);
+ Q_UNUSED(reserved);
+
+// qDebug() << "startedTranslationUnit";
+ return 0;
+ }
+
+ static void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo *info) {
+ LibClangIndexer *lci = indexer(client_data);
+
+ File *includingFile = 0;
+ unsigned line = 0, column = 0, offset = 0;
+ clang_indexLoc_getFileLocation(info->loc, reinterpret_cast<CXIdxClientFile*>(&includingFile), 0, &line, &column, &offset);
+
+ QString kind = getQString(clang_getCursorKindSpelling(info->cursor.kind));
+ QString displayName = getQString(clang_getCursorDisplayName(info->cursor));
+ QString spellingName = getQString(clang_getCursorSpelling(info->cursor));
+// qDebug() << (includingFile ? includingFile->name() : QLatin1String("<UNKNOWN FILE>")) << ":"<<line<<":"<<column<<": display name ="<<displayName<<"spelling name ="<<spellingName<<"of kind"<<kind;
+
+ Symbol *sym = lci->newSymbol(info->cursor.kind, displayName, spellingName, includingFile, line, column, offset);
+
+ // TODO: add to decl container...
+ if (includingFile) // TODO: check why includingFile can be null...
+ includingFile->addSymbol(sym);
+
+ if (const CXIdxContainerInfo *semanticContainer = info->semanticContainer) {
+ if (Symbol *container = static_cast<Symbol *>(clang_index_getClientContainer(semanticContainer))) {
+ sym->semanticContainer = container;
+ container->addSymbol(sym);
+ }
+ }
+
+ // TODO: ObjC containers
+ // TODO: index forward decls too?
+
+ if (info->declAsContainer)
+ clang_index_setClientContainer(info->declAsContainer, sym);
+ }
+
+ static void indexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo *info) {
+ Q_UNUSED(client_data);
+ Q_UNUSED(info);
+
+ // TODO: well, we do get the info, so why not (optionally?) remember all references?
+ }
+
+protected:
+ struct File;
+ struct Symbol;
+
+ typedef QHash<QString, File *> FilesByName;
+ struct File
+ {
+ File(const QString &fileName)
+ : m_fileName(fileName)
+ {}
+
+ void addInclude(File *f)
+ {
+ assert(f);
+ m_includes.insert(f->name(), f);
+ }
+
+ QList<File *> includes() const
+ { return m_includes.values(); }
+
+ QString name() const
+ { return m_fileName; }
+
+ void setMainFile(bool isMainFile = true)
+ { m_isMainFile = isMainFile; }
+
+ bool isMainFile() const
+ { return m_isMainFile; }
+
+ void addSymbol(Symbol *symbol)
+ {
+ assert(symbol);
+ m_symbols.append(symbol);
+ }
+
+ QVector<Symbol *> symbols() const
+ { return m_symbols; }
+
+ private:
+ QString m_fileName;
+ FilesByName m_includes;
+ bool m_isMainFile;
+ QVector<Symbol *> m_symbols;
+ };
+
+ struct Symbol
+ {
+ Symbol(enum CXCursorKind kind, const QString &displayName, const QString &spellingName, File *file, unsigned line, unsigned column, unsigned offset)
+ : kind(kind)
+ , displayName(displayName)
+ , spellingName(spellingName)
+ , file(file)
+ , line(line)
+ , column(column)
+ , offset(offset)
+ , semanticContainer(0)
+ {}
+
+ QString spellKind() const
+ { return getQString(clang_getCursorKindSpelling(kind)); }
+
+ void addSymbol(Symbol *symbol)
+ { symbols.append(symbol); }
+
+ enum CXCursorKind kind;
+ QString displayName, spellingName;
+ File *file;
+ unsigned line, column, offset;
+ Symbol *semanticContainer;
+ QVector<Symbol *> symbols;
+ };
+
+protected:
+ bool isCanceled() const
+ { return m_isCanceled; }
+
+ void finish()
+ { m_indexer->finished(this); }
+
+ File *file(const QString &fileName)
+ {
+ File *f = m_allFiles[fileName];
+ if (!f) {
+ f = new File(fileName);
+ m_allFiles.insert(fileName, f);
+ }
+ return f;
+ }
+
+ Symbol *newSymbol(enum CXCursorKind kind, const QString &displayName, const QString &spellingName, File *file, unsigned line, unsigned column, unsigned offset)
+ {
+ Symbol *s = new Symbol(kind, displayName, spellingName, file, line, column, offset);
+ m_allSymbols.append(s);
+ return s;
+ }
+
+ void dumpInfo()
+ {
+ qDebug() << "=== indexing info dump ===";
+ qDebug() << "indexed" << m_allFiles.size() << "files. Main files:";
+ foreach (const File *f, m_allFiles) {
+ if (!f->isMainFile())
+ continue;
+ qDebug() << f->name() << ":";
+ foreach (const File *inc, f->includes())
+ qDebug() << " includes" << inc->name();
+ dumpSymbols(f->symbols(), QByteArray(" "));
+ }
+
+ qDebug() << "=== end of dump ===";
+ }
+
+ void dumpSymbols(const QVector<Symbol *> &symbols, const QByteArray &indent)
+ {
+ if (symbols.isEmpty())
+ return;
+
+ qDebug("%scontained symbols:", indent.constData());
+ QByteArray newIndent = indent + " ";
+ foreach (const Symbol *s, symbols) {
+ qDebug("%s%s (%s)", newIndent.constData(), s->spellingName.toUtf8().constData(), s->spellKind().toUtf8().constData());
+ dumpSymbols(s->symbols, newIndent);
+ }
+ }
+
+ void unfoldSymbols(QVector<ClangCodeModel::Symbol> &result, const QString &fileName) {
+ const QVector<Symbol *> symbolsForFile = file(fileName)->symbols();
+ foreach (const Symbol *s, symbolsForFile) {
+ unfoldSymbols(s, result);
+ }
+ }
+
+ void unfoldSymbols(const Symbol *s, QVector<ClangCodeModel::Symbol> &result) {
+ if (!s->file)
+ return;
+
+ ClangCodeModel::Symbol sym;
+ sym.m_name = s->spellingName;
+ sym.m_qualification = s->spellingName;
+
+ static QLatin1String sep("::");
+ for (Symbol *parent = s->semanticContainer; parent; parent = parent->semanticContainer)
+ sym.m_qualification = parent->spellingName + sep + sym.m_qualification;
+
+ sym.m_location = SourceLocation(s->file->name(), s->line, s->column, s->offset);
+
+ switch (s->kind) {
+ case CXCursor_EnumDecl: sym.m_kind = ClangCodeModel::Symbol::Enum; break;
+ case CXCursor_StructDecl:
+ case CXCursor_ClassDecl: sym.m_kind = ClangCodeModel::Symbol::Class; break;
+ case CXCursor_CXXMethod: sym.m_kind = ClangCodeModel::Symbol::Method; break;
+ case CXCursor_FunctionTemplate:
+ case CXCursor_FunctionDecl: sym.m_kind = ClangCodeModel::Symbol::Function; break;
+ case CXCursor_DeclStmt: sym.m_kind = ClangCodeModel::Symbol::Declaration; break;
+ case CXCursor_Constructor: sym.m_kind = ClangCodeModel::Symbol::Constructor; break;
+ case CXCursor_Destructor: sym.m_kind = ClangCodeModel::Symbol::Destructor; break;
+ default: sym.m_kind = ClangCodeModel::Symbol::Unknown; break;
+ }
+
+ result.append(sym);
+ }
+
+protected:
+ static IndexerCallbacks IndexCB;
+
+protected:
+ IndexerPrivate *m_indexer;
+ bool m_isCanceled;
+ QHash<QString, bool> m_importedASTs;
+ FilesByName m_allFiles;
+ QVector<Symbol *> m_allSymbols;
+};
+
+IndexerCallbacks LibClangIndexer::IndexCB = {
+ abortQuery,
+ diagnostic,
+ enteredMainFile,
+ includedFile,
+ importedASTFile,
+ startedTranslationUnit,
+ indexDeclaration,
+ indexEntityReference
+};
+
+class ProjectPartIndexer: public LibClangIndexer
+{
+public:
+ ProjectPartIndexer(IndexerPrivate *indexer, const QList<IndexerPrivate::FileData> &todo)
+ : LibClangIndexer(indexer)
+ , m_todo(todo)
+ {}
+
+ void run()
+ {
+ if (isCanceled() || m_todo.isEmpty()) {
+ finish();
+ return;
+ }
+
+ const ProjectPart::Ptr &pPart = m_todo[0].m_projectPart;
+
+restart:
+ CXIndex idx;
+ if (!(idx = clang_createIndex(/* excludeDeclsFromPCH */ 1,
+ /* displayDiagnosics=*/1))) {
+ qDebug() << "Could not create Index";
+ return;
+ }
+
+ CXIndexAction idxAction = clang_IndexAction_create(idx);
+ const unsigned index_opts = CXIndexOpt_SuppressWarnings;
+
+ PCHManager *pchManager = PCHManager::instance();
+ PchInfo::Ptr pchInfo = pchManager->pchInfo(pPart);
+
+ for (int i = 0, ei = m_todo.size(); i < ei; ++i) {
+ const IndexerPrivate::FileData &fd = m_todo.at(i);
+ if (fd.m_upToDate)
+ continue;
+
+ if (pchManager->pchInfo(pPart) != pchInfo) {
+ clang_IndexAction_dispose(idxAction);
+ clang_disposeIndex(idx);
+ goto restart;
+ }
+
+ QStringList opts = ClangCodeModel::Utils::createClangOptions(pPart, fd.m_fileName);
+ if (!pchInfo.isNull())
+ opts.append(Utils::createPCHInclusionOptions(pchInfo->fileName()));
+
+ ScopedClangOptions scopedOpts(opts);
+ QByteArray fileName = fd.m_fileName.toUtf8();
+
+// qDebug() << "Indexing file" << fd.m_fileName << "with options" << opts;
+ unsigned parsingOptions = fd.m_managementOptions;
+ parsingOptions |= CXTranslationUnit_SkipFunctionBodies;
+
+ /*int result =*/ clang_indexSourceFile(idxAction, this,
+ &IndexCB, sizeof(IndexCB),
+ index_opts, fileName.constData(),
+ scopedOpts.data(), scopedOpts.size(), 0, 0, 0,
+ parsingOptions);
+
+ // index imported ASTs:
+ foreach (const QString &astFile, m_importedASTs.keys()) {
+ if (m_importedASTs.value(astFile))
+ continue;
+
+ if (CXTranslationUnit TU = clang_createTranslationUnit(
+ idx, astFile.toUtf8().constData())) {
+ /*result =*/ clang_indexTranslationUnit(idxAction, this,
+ &IndexCB,
+ sizeof(IndexCB),
+ index_opts, TU);
+ clang_disposeTranslationUnit(TU);
+ }
+
+ m_importedASTs[astFile] = true;
+ }
+
+ propagateResults(fd.m_projectPart);
+ if (isCanceled())
+ break;
+ }
+
+// dumpInfo();
+
+ clang_IndexAction_dispose(idxAction);
+ clang_disposeIndex(idx);
+
+ finish();
+ }
+
+private:
+ QList<IndexerPrivate::FileData> m_todo;
+};
+
+class QuickIndexer: public LibClangIndexer
+{
+public:
+ QuickIndexer(IndexerPrivate *indexer, const Unit &unit, const ProjectPart::Ptr &projectPart)
+ : LibClangIndexer(indexer)
+ , m_unit(unit)
+ , m_projectPart(projectPart)
+ {}
+
+ void run()
+ {
+ if (isCanceled() || !m_unit.isLoaded()) {
+ finish();
+ return;
+ }
+
+ CXIndexAction idxAction = clang_IndexAction_create(m_unit.clangIndex());
+ const unsigned index_opts = CXIndexOpt_SuppressWarnings;
+
+// qDebug() << "Indexing TU" << m_unit.fileName() << "...";
+ /*int result =*/ clang_indexTranslationUnit(idxAction, this,
+ &IndexCB, sizeof(IndexCB),
+ index_opts,
+ m_unit.clangTranslationUnit());
+
+ propagateResults(m_projectPart);
+
+ clang_IndexAction_dispose(idxAction);
+ finish();
+ }
+
+private:
+ Unit m_unit;
+ ProjectPart::Ptr m_projectPart;
+};
+
+} // ClangCodeModel
+
+IndexerPrivate::IndexerPrivate(Indexer *indexer)
+ : m_mutex(QMutex::Recursive)
+ , m_q(indexer)
+ , m_files(TotalFileTypes)
+ , m_hasQueuedFullRun(false)
+ , m_isLoaded(false)
+ , m_loadingWatcher(new QFutureWatcher<void>)
+ , m_indexingWatcher(new QFutureWatcher<void>)
+{
+// const int magicThreadCount = QThread::idealThreadCount() * 4 / 3;
+ const int magicThreadCount = QThread::idealThreadCount() - 1;
+ m_indexingPool.setMaxThreadCount(std::max(magicThreadCount, 1));
+ m_indexingPool.setExpiryTimeout(1000);
+}
+
+void IndexerPrivate::runCore(const QHash<QString, FileData> & /*headers*/,
+ const QHash<QString, FileData> &impls,
+ IndexingMode /*mode*/)
+{
+ QMutexLocker locker(&m_mutex);
+
+ typedef QHash<QString, FileData>::const_iterator FileContIt;
+ QHash<ProjectPart::Ptr, QList<IndexerPrivate::FileData> > parts;
+ typedef QHash<ProjectPart::Ptr, QList<IndexerPrivate::FileData> >::Iterator PartIter;
+
+ QList<Core::IDocument *> docs = Core::EditorManager::documentModel()->openedDocuments();
+ QSet<QString> openDocs;
+ foreach (Core::IDocument *doc, docs)
+ openDocs.insert(doc->filePath());
+
+ for (FileContIt tit = impls.begin(), eit = impls.end(); tit != eit; ++tit) {
+ if (!tit->m_upToDate && openDocs.contains(tit.key())) {
+ const IndexerPrivate::FileData &fd = tit.value();
+ parts[fd.m_projectPart].append(fd);
+ }
+ }
+
+ if (parts.isEmpty())
+ return;
+
+ for (PartIter i = parts.begin(), ei = parts.end(); i != ei; ++i) {
+ ProjectPartIndexer *ppi = new ProjectPartIndexer(this, i.value());
+ m_runningIndexers.insert(ppi);
+ m_indexingPool.start(ppi);
+ }
+
+ QFuture<void> task = QtConcurrent::run(&IndexerPrivate::watchIndexingThreads, this);
+ m_indexingWatcher->setFuture(task);
+ emit m_q->indexingStarted(task);
+}
+
+void IndexerPrivate::watchIndexingThreads(QFutureInterface<void> &future)
+{
+ int maxTodo = runningIndexerCount();
+ future.setProgressRange(0, maxTodo);
+
+ int todo = -1;
+ while (todo) {
+ int newTodo = runningIndexerCount();
+ if (todo != newTodo)
+ future.setProgressValue(maxTodo - newTodo);
+ todo = newTodo;
+ if (future.isCanceled()) {
+ cancelIndexing();
+ return;
+ }
+ m_indexingPool.waitForDone(500);
+ }
+}
+
+void IndexerPrivate::run()
+{
+ Q_ASSERT(m_isLoaded);
+
+ QMutexLocker locker(&m_mutex);
+
+ if (m_runningIndexers.isEmpty()) {
+ runCore(m_files.value(HeaderFile),
+ m_files.value(ImplementationFile),
+ RelaxedIndexing);
+ } else {
+ m_hasQueuedFullRun = true;
+ cancelIndexing();
+ }
+}
+
+void IndexerPrivate::run(const QStringList &fileNames)
+{
+ Q_ASSERT(m_isLoaded);
+ QMutexLocker locker(&m_mutex);
+
+ if (noIndexersRunning()) {
+ QVector<QHash<QString, FileData> > files(TotalFileTypes);
+ foreach (const QString &fileName, fileNames) {
+ FileType type = identifyFileType(fileName);
+ if (!isTrackingFile(fileName, type)) {
+ // @TODO
+ continue;
+ }
+
+ FileData *data = &m_files[type][fileName];
+ data->m_upToDate = false;
+ files[type].insert(fileName, *data);
+ m_index.removeFile(fileName);
+ }
+ runCore(files.value(HeaderFile),
+ files.value(ImplementationFile),
+ ConstrainedIndexing);
+ } else {
+ m_queuedFilesRun.unite(fileNames.toSet());
+ }
+}
+
+bool IndexerPrivate::isBusy() const
+{
+ return !noIndexersRunning() || m_loadingWatcher->isRunning();
+}
+
+void IndexerPrivate::cancel(bool wait)
+{
+// m_dependencyGraph.discard();
+
+ m_loadingWatcher->cancel();
+ cancelIndexing();
+ if (wait) {
+ m_loadingWatcher->waitForFinished();
+ m_indexingWatcher->waitForFinished();
+ while (!noIndexersRunning())
+ m_indexingPool.waitForDone(100);
+ }
+}
+
+void IndexerPrivate::reset()
+{
+ cancel(true);
+ serializeSymbols();
+
+ for (int i = 0; i < TotalFileTypes; ++i)
+ m_files[i].clear();
+ m_hasQueuedFullRun = false;
+ m_queuedFilesRun.clear();
+ m_storagePath.clear();
+ m_index.clear();
+ m_isLoaded = false;
+}
+
+void IndexerPrivate::synchronize(const QVector<IndexingResult> &results)
+{
+ foreach (IndexingResult result, results) {
+ QMutexLocker locker(&m_mutex);
+
+ result.m_unit.makeUnique();
+
+ foreach (const Symbol &symbol, result.m_symbolsInfo) {
+ addOrUpdateFileData(symbol.m_location.fileName(),
+ result.m_projectPart,
+ true);
+
+ // Make the symbol available in the database.
+ m_index.insertSymbol(symbol, result.m_unit.timeStamp());
+ }
+
+ // There might be files which were processed but did not "generate" any indexable symbol,
+ // but we still need to make the index aware of them.
+ result.m_processedFiles.insert(result.m_unit.fileName());
+ foreach (const QString &fileName, result.m_processedFiles) {
+ if (!m_index.containsFile(fileName))
+ m_index.insertFile(fileName, result.m_unit.timeStamp());
+ }
+
+ // If this unit is being kept alive, update in the manager.
+ if (LiveUnitsManager::instance()->isTracking(result.m_unit.fileName()))
+ LiveUnitsManager::instance()->updateUnit(result.m_unit.fileName(), result.m_unit);
+ }
+}
+
+void IndexerPrivate::finished(LibClangIndexer *indexer)
+{
+ QMutexLocker locker(&m_mutex);
+
+ m_runningIndexers.remove(indexer);
+ if (noIndexersRunning())
+ indexingFinished();
+}
+
+bool IndexerPrivate::noIndexersRunning() const
+{
+ QMutexLocker locker(&m_mutex);
+
+ return m_runningIndexers.isEmpty();
+}
+
+void IndexerPrivate::indexingFinished()
+{
+ if (m_hasQueuedFullRun) {
+ m_hasQueuedFullRun = false;
+ run();
+ } else if (!m_queuedFilesRun.isEmpty()) {
+ const QStringList &files = m_queuedFilesRun.toList();
+ m_queuedFilesRun.clear();
+ run(files);
+ }
+
+ emit m_q->indexingFinished();
+}
+
+void IndexerPrivate::cancelIndexing()
+{
+ QMutexLocker locker(&m_mutex);
+
+ foreach (LibClangIndexer* partIndexer, m_runningIndexers) {
+ partIndexer->cancel();
+ }
+}
+
+int IndexerPrivate::runningIndexerCount() const
+{
+ QMutexLocker locker(&m_mutex);
+ return m_runningIndexers.size();
+}
+
+void IndexerPrivate::addOrUpdateFileData(const QString &fileName,
+ ProjectPart::Ptr projectPart,
+ bool upToDate)
+{
+ Q_ASSERT(QDir::isAbsolutePath(fileName));
+
+ QString cleanFileName(normalizeFileName(fileName));
+
+ FileType fileType = identifyFileType(cleanFileName);
+ if (isTrackingFile(cleanFileName, fileType)) {
+ m_files[fileType][cleanFileName].m_projectPart = projectPart;
+ m_files[fileType][cleanFileName].m_upToDate = upToDate;
+ } else {
+ m_files[fileType].insert(cleanFileName,
+ FileData(cleanFileName, projectPart, upToDate));
+ }
+
+ if (!upToDate)
+ m_index.removeFile(cleanFileName);
+}
+
+bool IndexerPrivate::addFile(const QString &fileName,
+ ProjectPart::Ptr projectPart)
+{
+ if (isBusy()
+ || fileName.trimmed().isEmpty()
+ || !QFileInfo(fileName).isFile())
+ return false;
+
+ addOrUpdateFileData(fileName, projectPart, false);
+
+ return true;
+}
+
+QStringList IndexerPrivate::allFiles() const
+{
+ QStringList all;
+ populateFileNames(&all, m_files.at(ImplementationFile).values());
+ populateFileNames(&all, m_files.at(HeaderFile).values());
+ return all;
+}
+
+bool IndexerPrivate::isTrackingFile(const QString &fileName, FileType type) const
+{
+ return m_files.value(type).contains(normalizeFileName(fileName));
+}
+
+QStringList IndexerPrivate::compilationOptions(const QString &fileName) const
+{
+ FileType type = identifyFileType(fileName);
+ return Utils::createClangOptions(m_files.value(type).value(normalizeFileName(fileName)).m_projectPart);
+}
+
+IndexerPrivate::FileType IndexerPrivate::identifyFileType(const QString &fileName)
+{
+ const QString fn = fileName.toLower();
+ if (fn.endsWith(QLatin1String(".cpp"))
+ || fn.endsWith(QLatin1String(".cxx"))
+ || fn.endsWith(QLatin1String(".cc"))
+ || fn.endsWith(QLatin1String(".c"))
+ || fn.endsWith(QLatin1String(".m"))
+ || fn.endsWith(QLatin1String(".mm"))) {
+ return ImplementationFile;
+ }
+
+ // Everything that is not an implementation file is treated as a header. This makes things
+ // easier when handling standard library files and any other file that does not use
+ // conventional suffixes.
+ return HeaderFile;
+}
+
+void IndexerPrivate::populateFileNames(QStringList *all, const QList<FileData> &data)
+{
+ foreach (const FileData &fileData, data)
+ all->append(fileData.m_fileName);
+}
+
+
+namespace {
+
+struct DepedencyVisitor
+{
+ DepedencyVisitor(IndexerPrivate *indexer) : m_indexer(indexer) {}
+
+ bool acceptFile(const QString &includer)
+ {
+ IndexerPrivate::FileType fileType = IndexerPrivate::identifyFileType(includer);
+ if (m_indexer->isTrackingFile(includer, fileType)) {
+ m_match = m_indexer->m_files.at(fileType).value(includer);
+ return true;
+ }
+ return false;
+ }
+
+ IndexerPrivate *m_indexer;
+ IndexerPrivate::FileData m_match;
+};
+
+} // Anonymous
+
+void IndexerPrivate::startLoading()
+{
+ // In the case of existent persisted symbols, we restore them and make them visible
+ // to the indexer. However, we need a dependency graph in order to identify the proper
+ // options.
+
+ if (deserealizeSymbols() && !m_index.isEmpty())
+ computeDependencyGraph();
+ else
+ concludeLoading();
+}
+
+void IndexerPrivate::concludeLoading()
+{
+ m_isLoaded = true;
+ run();
+}
+
+void IndexerPrivate::computeDependencyGraph()
+{
+ // FIXME
+// for (int fileType = ImplementationFile; fileType < TotalFileTypes; ++fileType) {
+// QHash<QString, FileData>::iterator it = m_files[fileType].begin();
+// for (; it != m_files[fileType].end(); ++it)
+// m_dependencyGraph.addFile(it.value().m_fileName, it.value().m_compilationOptions);
+// }
+
+ m_loadingWatcher.reset(new QFutureWatcher<void>);
+ connect(m_loadingWatcher.data(), SIGNAL(finished()), this, SLOT(dependencyGraphComputed()));
+// m_loadingWatcher->setFuture(m_dependencyGraph.compute());
+}
+
+void IndexerPrivate::dependencyGraphComputed()
+{
+ if (m_loadingWatcher->isCanceled())
+ return;
+
+ m_loadingWatcher.reset(new QFutureWatcher<void>);
+ connect(m_loadingWatcher.data(), SIGNAL(finished()), this, SLOT(restoredSymbolsAnalysed()));
+ m_loadingWatcher->setFuture(QtConcurrent::run(this, &IndexerPrivate::analyzeRestoredSymbols));
+}
+
+void IndexerPrivate::analyzeRestoredSymbols()
+{
+ // @TODO: We only check for time stamps, so we still need to handle somehow the case in
+ // which the project options (for example a .pro file) changed while "outside" a Creator
+ // session.
+
+ foreach (const QString &fileName, m_index.files()) {
+ bool upToDate = m_index.validate(fileName);
+
+ FileType fileType = identifyFileType(fileName);
+ if (isTrackingFile(fileName, fileType)) {
+ // When the file is already being tracked we simply need to update its state.
+ if (upToDate)
+ m_files[fileType][fileName].m_upToDate = true;
+ } else {
+ // If it's not being tracked we need to find at least one tracked dependency
+ // so we can use its options.
+ DepedencyVisitor visitor(this);
+// m_dependencyGraph.collectDependencies(fileName,
+// DependencyGraph::FilesWhichInclude,
+// &visitor);
+ if (!visitor.m_match.m_fileName.isEmpty()) {
+ addOrUpdateFileData(fileName,
+ visitor.m_match.m_projectPart,
+ upToDate);
+ } else {
+ m_index.removeFile(fileName);
+ }
+ }
+
+ if (!upToDate && m_index.containsFile(fileName))
+ m_index.removeFile(fileName);
+ }
+}
+
+void IndexerPrivate::runQuickIndexing(const Unit &unit, const CppTools::ProjectPart::Ptr &part)
+{
+ QMutexLocker locker(&m_mutex);
+
+ addOrUpdateFileData(unit.fileName(), part, false);
+
+ QuickIndexer indexer(this, unit, part);
+ indexer.run();
+}
+
+void IndexerPrivate::restoredSymbolsAnalysed()
+{
+ if (m_loadingWatcher->isCanceled())
+ return;
+
+ concludeLoading();
+}
+
+bool IndexerPrivate::deserealizeSymbols()
+{
+ if (m_storagePath.isEmpty())
+ return false;
+
+ ::Utils::FileReader reader;
+ if (reader.fetch(m_storagePath)) {
+ m_index.deserialize(reader.data());
+ return true;
+ }
+
+ return false;
+}
+
+void IndexerPrivate::serializeSymbols() const
+{
+ if (m_storagePath.isEmpty())
+ return;
+
+ ::Utils::FileSaver saver(m_storagePath);
+ saver.write(m_index.serialize());
+ if (!saver.finalize())
+ qWarning("Failed to serialize index");
+}
+
+QList<Symbol> IndexerPrivate::symbols(Symbol::Kind kind) const
+{
+ if (m_loadingWatcher->isRunning())
+ return QList<Symbol>();
+
+ return m_index.symbols(kind);
+}
+
+QList<Symbol> IndexerPrivate::symbols(const QString &fileName, const Symbol::Kind kind) const
+{
+ if (m_loadingWatcher->isRunning())
+ return QList<Symbol>();
+
+ if (kind == Symbol::Unknown)
+ return m_index.symbols(fileName);
+
+ return m_index.symbols(fileName, kind);
+}
+
+void IndexerPrivate::match(ClangSymbolSearcher *searcher) const
+{
+ if (m_loadingWatcher->isRunning())
+ return;
+
+ m_index.match(searcher);
+}
+
+Indexer::Indexer(QObject *parent)
+ : QObject(parent)
+ , m_d(new IndexerPrivate(this))
+{}
+
+Indexer::~Indexer()
+{}
+
+void Indexer::regenerate()
+{
+ if (!m_d->m_isLoaded) {
+ if (m_d->m_loadingWatcher->isRunning())
+ return;
+ m_d->startLoading();
+ } else {
+ m_d->run();
+ }
+}
+
+void Indexer::initialize(const QString &storagePath)
+{
+ Q_ASSERT(!m_d->m_isLoaded);
+
+ m_d->m_storagePath = storagePath;
+}
+
+void Indexer::evaluateFile(const QString &fileName)
+{
+ if (!m_d->m_isLoaded)
+ return;
+
+ m_d->run(QStringList(normalizeFileName(fileName)));
+}
+
+bool Indexer::isBusy() const
+{
+ return m_d->isBusy();
+}
+
+void Indexer::cancel(bool waitForFinished)
+{
+ return m_d->cancel(waitForFinished);
+}
+
+void Indexer::finalize()
+{
+ m_d->reset();
+}
+
+bool Indexer::addFile(const QString &fileName, ProjectPart::Ptr projectPart)
+{
+ return m_d->addFile(fileName, projectPart);
+}
+
+QStringList Indexer::allFiles() const
+{
+ return m_d->allFiles();
+}
+
+QStringList Indexer::compilationOptions(const QString &fileName) const
+{
+ return m_d->compilationOptions(fileName);
+}
+
+QList<Symbol> Indexer::allFunctions() const
+{
+ return m_d->symbols(Symbol::Function);
+}
+
+QList<Symbol> Indexer::allClasses() const
+{
+ return m_d->symbols(Symbol::Class);
+}
+
+QList<Symbol> Indexer::allMethods() const
+{
+ return m_d->symbols(Symbol::Method);
+}
+
+QList<Symbol> Indexer::allConstructors() const
+{
+ return m_d->symbols(Symbol::Constructor);
+}
+
+QList<Symbol> Indexer::allDestructors() const
+{
+ return m_d->symbols(Symbol::Destructor);
+}
+
+QList<Symbol> Indexer::functionsFromFile(const QString &fileName) const
+{
+ return m_d->symbols(fileName, Symbol::Function);
+}
+
+QList<Symbol> Indexer::classesFromFile(const QString &fileName) const
+{
+ return m_d->symbols(fileName, Symbol::Class);
+}
+
+QList<Symbol> Indexer::methodsFromFile(const QString &fileName) const
+{
+ return m_d->symbols(fileName, Symbol::Method);
+}
+
+QList<Symbol> Indexer::constructorsFromFile(const QString &fileName) const
+{
+ return m_d->symbols(fileName, Symbol::Constructor);
+}
+
+QList<Symbol> Indexer::destructorsFromFile(const QString &fileName) const
+{
+ return m_d->symbols(fileName, Symbol::Destructor);
+}
+
+QList<Symbol> Indexer::allFromFile(const QString &fileName) const
+{
+ return m_d->symbols(fileName, Symbol::Unknown);
+}
+
+void Indexer::match(ClangSymbolSearcher *searcher) const
+{
+ m_d->match(searcher);
+}
+
+void Indexer::runQuickIndexing(Unit::Ptr unit, const CppTools::ProjectPart::Ptr &part)
+{
+ m_d->runQuickIndexing(unit, part);
+}
+
+#include "indexer.moc"
diff --git a/src/plugins/clangcodemodel/indexer.h b/src/plugins/clangcodemodel/indexer.h
new file mode 100644
index 0000000000..e40afaaca9
--- /dev/null
+++ b/src/plugins/clangcodemodel/indexer.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef INDEXER_H
+#define INDEXER_H
+
+#include "clang_global.h"
+#include "symbol.h"
+#include "unit.h"
+
+#include <cpptools/cppmodelmanagerinterface.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QScopedPointer>
+#include <QtCore/QFuture>
+
+namespace ClangCodeModel {
+
+namespace Internal {
+class ClangSymbolSearcher;
+} // namespace Internal
+
+class IndexerPrivate;
+
+class CLANG_EXPORT Indexer : public QObject
+{
+ Q_OBJECT
+
+public:
+ typedef CppTools::ProjectPart ProjectPart;
+
+public:
+ Indexer(QObject *parent = 0);
+ ~Indexer();
+
+ void initialize(const QString &storagePath);
+ void finalize();
+
+ void regenerate();
+ void evaluateFile(const QString &fileName);
+ bool isBusy() const;
+ void cancel(bool waitForFinished);
+
+ bool addFile(const QString &fileName, ProjectPart::Ptr projectPart);
+ QStringList allFiles() const;
+ QStringList compilationOptions(const QString &fileName) const;
+
+ QList<Symbol> allFunctions() const;
+ QList<Symbol> allClasses() const;
+ QList<Symbol> allMethods() const;
+ QList<Symbol> allConstructors() const;
+ QList<Symbol> allDestructors() const;
+ QList<Symbol> functionsFromFile(const QString &fileName) const;
+ QList<Symbol> classesFromFile(const QString &fileName) const;
+ QList<Symbol> methodsFromFile(const QString &fileName) const;
+ QList<Symbol> constructorsFromFile(const QString &fileName) const;
+ QList<Symbol> destructorsFromFile(const QString &fileName) const;
+ QList<Symbol> allFromFile(const QString &fileName) const;
+
+ void match(Internal::ClangSymbolSearcher *searcher) const;
+
+ void runQuickIndexing(Internal::Unit::Ptr unit, const ProjectPart::Ptr &part);
+
+signals:
+ void indexingStarted(QFuture<void> future);
+ void indexingFinished();
+
+private:
+ friend class IndexerPrivate;
+ QScopedPointer<IndexerPrivate> m_d;
+};
+
+} // ClangCodeModel
+
+#endif // INDEXER_H
diff --git a/src/plugins/clangcodemodel/pchinfo.cpp b/src/plugins/clangcodemodel/pchinfo.cpp
new file mode 100644
index 0000000000..1d245ae248
--- /dev/null
+++ b/src/plugins/clangcodemodel/pchinfo.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "pchinfo.h"
+
+#include <QDir>
+
+using namespace ClangCodeModel::Internal;
+
+PchInfo::PchInfo()
+{
+}
+
+PchInfo::~PchInfo()
+{
+}
+
+PchInfo::Ptr PchInfo::createEmpty()
+{
+ return Ptr(new PchInfo);
+}
+
+PchInfo::Ptr PchInfo::createWithFileName(const QString &inputFileName,
+ const QStringList &options,
+ bool objcEnabled)
+{
+ Ptr result(new PchInfo);
+ result->m_inputFileName = inputFileName;
+ result->m_options = options;
+ result->m_objcEnabled = objcEnabled;
+
+ // The next 2 lines are just here to generate the file name....
+ result->m_file.open();
+ result->m_file.close();
+ return result;
+}
diff --git a/src/plugins/clangcodemodel/pchinfo.h b/src/plugins/clangcodemodel/pchinfo.h
new file mode 100644
index 0000000000..2cf5d1b05e
--- /dev/null
+++ b/src/plugins/clangcodemodel/pchinfo.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef PCHINFO_H
+#define PCHINFO_H
+
+#include <QString>
+#include <QStringList>
+#include <QSharedPointer>
+#include <QTemporaryFile>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class PchInfo
+{
+ PchInfo();
+
+public:
+ typedef QSharedPointer<PchInfo> Ptr;
+
+public:
+ ~PchInfo();
+
+ static Ptr createEmpty();
+ static Ptr createWithFileName(const QString &inputFileName,
+ const QStringList &options, bool objcEnabled);
+
+ /// \return the (temporary) file name for the PCH file.
+ QString fileName() const
+ { return m_file.fileName(); }
+
+ /// \return the input file for the PCH compilation.
+ QString inputFileName() const
+ { return m_inputFileName; }
+
+ /// \return the options used to generate this PCH file.
+ QStringList options() const
+ { return m_options; }
+
+ bool objcWasEnabled() const
+ { return m_objcEnabled; }
+
+private:
+ QString m_inputFileName;
+ QStringList m_options;
+ bool m_objcEnabled;
+ QTemporaryFile m_file;
+};
+
+} // Internal namespace
+} // ClangCodeModel namespace
+
+#endif // PCHINFO_H
diff --git a/src/plugins/clangcodemodel/pchmanager.cpp b/src/plugins/clangcodemodel/pchmanager.cpp
new file mode 100644
index 0000000000..ec0bb2591a
--- /dev/null
+++ b/src/plugins/clangcodemodel/pchmanager.cpp
@@ -0,0 +1,433 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "pchmanager.h"
+#include "utils.h"
+#include "clangutils.h"
+
+#include <coreplugin/icore.h>
+#include <coreplugin/progressmanager/progressmanager.h>
+
+#include <utils/runextensions.h>
+
+#include <QFile>
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+using namespace CPlusPlus;
+
+PCHManager *PCHManager::m_instance = 0;
+
+PCHManager::PCHManager(QObject *parent)
+ : QObject(parent)
+{
+ Q_ASSERT(!m_instance);
+ m_instance = this;
+
+ QObject *msgMgr = Core::MessageManager::instance();
+ connect(this, SIGNAL(pchMessage(QString, Core::MessageManager::PrintToOutputPaneFlags)),
+ msgMgr, SLOT(write(QString, Core::MessageManager::PrintToOutputPaneFlags)));
+
+ connect(&m_pchGenerationWatcher, SIGNAL(finished()),
+ this, SLOT(updateActivePCHFiles()));
+}
+
+PCHManager::~PCHManager()
+{
+ Q_ASSERT(m_instance);
+ m_instance = 0;
+ qDeleteAll(m_projectSettings.values());
+ m_projectSettings.clear();
+}
+
+PCHManager *PCHManager::instance()
+{
+ return m_instance;
+}
+
+PchInfo::Ptr PCHManager::pchInfo(const ProjectPart::Ptr &projectPart) const
+{
+ QMutexLocker locker(&m_mutex);
+
+ return m_activePCHFiles[projectPart];
+}
+
+ClangProjectSettings *PCHManager::settingsForProject(ProjectExplorer::Project *project)
+{
+ QMutexLocker locker(&m_mutex);
+
+ ClangProjectSettings *cps = m_projectSettings.value(project);
+ if (!cps) {
+ cps = new ClangProjectSettings(project);
+ m_projectSettings.insert(project, cps);
+ cps->pullSettings();
+ connect(cps, SIGNAL(pchSettingsChanged()),
+ this, SLOT(clangProjectSettingsChanged()));
+ }
+ return cps;
+}
+
+void PCHManager::setPCHInfo(const QList<ProjectPart::Ptr> &projectParts,
+ const PchInfo::Ptr &pchInfo,
+ const QPair<bool, QStringList> &msgs)
+{
+ QMutexLocker locker(&m_mutex);
+
+ foreach (ProjectPart::Ptr pPart, projectParts)
+ m_activePCHFiles[pPart] = pchInfo;
+
+ if (pchInfo) {
+ if (msgs.first) {
+ if (!pchInfo->fileName().isEmpty())
+ emit pchMessage(tr("Successfully generated PCH file \"%1\".").arg(
+ pchInfo->fileName()), Core::MessageManager::Silent);
+ } else {
+ emit pchMessage(tr("Failed to generate PCH file \"%1\".").arg(
+ pchInfo->fileName()), Core::MessageManager::Silent);
+ }
+ if (!msgs.second.isEmpty())
+ emit pchMessage(msgs.second.join(QLatin1String("\n")), Core::MessageManager::Flash);
+ }
+}
+
+void PCHManager::clangProjectSettingsChanged()
+{
+ ClangProjectSettings *cps = qobject_cast<ClangProjectSettings *>(sender());
+ if (!cps)
+ return;
+
+ onProjectPartsUpdated(cps->project());
+}
+
+void PCHManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
+{
+ Q_UNUSED(project);
+
+ // we cannot ask the ModelManager for the parts, because, depending on
+ // the order of signal delivery, it might already have wiped any information
+ // about the project.
+
+ updateActivePCHFiles();
+}
+
+void PCHManager::onProjectPartsUpdated(ProjectExplorer::Project *project)
+{
+ ClangProjectSettings *cps = settingsForProject(project);
+ Q_ASSERT(cps);
+
+ CppTools::CppModelManagerInterface *mmi = CppTools::CppModelManagerInterface::instance();
+ const QList<ProjectPart::Ptr> projectParts = mmi->projectInfo(
+ cps->project()).projectParts();
+ updatePchInfo(cps, projectParts);
+
+ emit pchInfoUpdated();
+}
+
+void PCHManager::updatePchInfo(ClangProjectSettings *cps,
+ const QList<ProjectPart::Ptr> &projectParts)
+{
+ if (m_pchGenerationWatcher.isRunning()) {
+// m_pchGenerationWatcher.cancel();
+ m_pchGenerationWatcher.waitForFinished();
+ }
+
+ QFuture<void> future = QtConcurrent::run(&PCHManager::doPchInfoUpdate,
+ cps->pchUsage(),
+ cps->customPchFile(),
+ projectParts);
+ m_pchGenerationWatcher.setFuture(future);
+ Core::ProgressManager::addTask(future, tr("Precompiling..."), "Key.Tmp.Precompiling");
+}
+
+namespace {
+
+bool hasObjCFiles(const CppTools::ProjectPart::Ptr &projectPart)
+{
+ foreach (const CppTools::ProjectFile &file, projectPart->files) {
+ switch (file.kind) {
+ case CppTools::ProjectFile::ObjCHeader:
+ case CppTools::ProjectFile::ObjCSource:
+ case CppTools::ProjectFile::ObjCXXHeader:
+ case CppTools::ProjectFile::ObjCXXSource:
+ return true;
+ default:
+ break;
+ }
+ }
+ return false;
+}
+
+bool hasCppFiles(const CppTools::ProjectPart::Ptr &projectPart)
+{
+ foreach (const CppTools::ProjectFile &file, projectPart->files) {
+ switch (file.kind) {
+ case CppTools::ProjectFile::CudaSource:
+ case CppTools::ProjectFile::CXXHeader:
+ case CppTools::ProjectFile::CXXSource:
+ case CppTools::ProjectFile::OpenCLSource:
+ case CppTools::ProjectFile::ObjCXXHeader:
+ case CppTools::ProjectFile::ObjCXXSource:
+ return true;
+ default:
+ break;
+ }
+ }
+ return false;
+}
+
+CppTools::ProjectFile::Kind getPrefixFileKind(bool hasObjectiveC, bool hasCPlusPlus)
+{
+ if (hasObjectiveC && hasCPlusPlus)
+ return CppTools::ProjectFile::ObjCXXHeader;
+ else if (hasObjectiveC)
+ return CppTools::ProjectFile::ObjCHeader;
+ else if (hasCPlusPlus)
+ return CppTools::ProjectFile::CXXHeader;
+ return CppTools::ProjectFile::CHeader;
+}
+
+}
+
+void PCHManager::doPchInfoUpdate(QFutureInterface<void> &future,
+ ClangProjectSettings::PchUsage pchUsage,
+ const QString customPchFile,
+ const QList<ProjectPart::Ptr> projectParts)
+{
+ PCHManager *pchManager = PCHManager::instance();
+
+// qDebug() << "switching to" << pchUsage;
+
+ if (pchUsage == ClangProjectSettings::PchUse_None
+ || (pchUsage == ClangProjectSettings::PchUse_Custom && customPchFile.isEmpty())) {
+ future.setProgressRange(0, 2);
+ Core::MessageManager::write(QLatin1String("updatePchInfo: switching to none"),
+ Core::MessageManager::Silent);
+ PchInfo::Ptr emptyPch = PchInfo::createEmpty();
+ pchManager->setPCHInfo(projectParts, emptyPch, qMakePair(true, QStringList()));
+ future.setProgressValue(1);
+ } else if (pchUsage == ClangProjectSettings::PchUse_BuildSystem_Fuzzy) {
+ Core::MessageManager::write(
+ QLatin1String("updatePchInfo: switching to build system (fuzzy)"),
+ Core::MessageManager::Silent);
+ QHash<QString, QSet<QString> > includes, frameworks;
+ QHash<QString, QSet<QByteArray> > definesPerPCH;
+ QHash<QString, bool> objc;
+ QHash<QString, bool> cplusplus;
+ QHash<QString, ProjectPart::QtVersion> qtVersions;
+ QHash<QString, ProjectPart::CVersion> cVersions;
+ QHash<QString, ProjectPart::CXXVersion> cxxVersions;
+ QHash<QString, ProjectPart::CXXExtensions> cxxExtensionsMap;
+ QHash<QString, QList<ProjectPart::Ptr> > inputToParts;
+ foreach (const ProjectPart::Ptr &projectPart, projectParts) {
+ if (projectPart->precompiledHeaders.isEmpty())
+ continue;
+ const QString &pch = projectPart->precompiledHeaders.first(); // TODO: support more than 1 PCH file.
+ if (!QFile(pch).exists())
+ continue;
+ inputToParts[pch].append(projectPart);
+
+ includes[pch].unite(QSet<QString>::fromList(projectPart->includePaths));
+ frameworks[pch].unite(QSet<QString>::fromList(projectPart->frameworkPaths));
+ cVersions[pch] = std::max(cVersions.value(pch, ProjectPart::C89), projectPart->cVersion);
+ cxxVersions[pch] = std::max(cxxVersions.value(pch, ProjectPart::CXX98), projectPart->cxxVersion);
+ cxxExtensionsMap[pch] = cxxExtensionsMap[pch] | projectPart->cxxExtensions;
+
+ if (hasObjCFiles(projectPart))
+ objc[pch] = true;
+ if (hasCppFiles(projectPart))
+ cplusplus[pch] = true;
+
+ QSet<QByteArray> projectDefines = QSet<QByteArray>::fromList(projectPart->toolchainDefines.split('\n'));
+ QMutableSetIterator<QByteArray> iter(projectDefines);
+ while (iter.hasNext()){
+ QByteArray v = iter.next();
+ if (v.startsWith("#define _") || v.isEmpty()) // TODO: see ProjectPart::createClangOptions
+ iter.remove();
+ }
+ projectDefines.unite(QSet<QByteArray>::fromList(projectPart->projectDefines.split('\n')));
+
+ if (definesPerPCH.contains(pch)) {
+ definesPerPCH[pch].intersect(projectDefines);
+ } else {
+ definesPerPCH[pch] = projectDefines;
+ }
+
+ qtVersions[pch] = projectPart->qtVersion;
+ }
+
+ future.setProgressRange(0, definesPerPCH.size() + 1);
+ future.setProgressValue(0);
+
+ foreach (const QString &pch, inputToParts.keys()) {
+ if (future.isCanceled())
+ return;
+ ProjectPart::Ptr projectPart(new ProjectPart);
+ projectPart->qtVersion = qtVersions[pch];
+ projectPart->cVersion = cVersions[pch];
+ projectPart->cxxVersion = cxxVersions[pch];
+ projectPart->cxxExtensions = cxxExtensionsMap[pch];
+ projectPart->includePaths = includes[pch].toList();
+ projectPart->frameworkPaths = frameworks[pch].toList();
+
+ QList<QByteArray> defines = definesPerPCH[pch].toList();
+ if (!defines.isEmpty()) {
+ projectPart->projectDefines = defines[0];
+ for (int i = 1; i < defines.size(); ++i) {
+ projectPart->projectDefines += '\n';
+ projectPart->projectDefines += defines[i];
+ }
+ }
+
+ CppTools::ProjectFile::Kind prefixFileKind =
+ getPrefixFileKind(objc.value(pch, false), cplusplus.value(pch, false));
+
+ QStringList options = Utils::createClangOptions(projectPart, prefixFileKind);
+ projectPart.reset();
+
+ PchInfo::Ptr pchInfo = pchManager->findMatchingPCH(pch, options, true);
+ QPair<bool, QStringList> msgs = qMakePair(true, QStringList());
+ if (pchInfo.isNull()) {
+
+ pchInfo = PchInfo::createWithFileName(pch, options, objc[pch]);
+ msgs = precompile(pchInfo);
+ }
+ pchManager->setPCHInfo(inputToParts[pch], pchInfo, msgs);
+ future.setProgressValue(future.progressValue() + 1);
+ }
+ } else if (pchUsage == ClangProjectSettings::PchUse_BuildSystem_Exact) {
+ future.setProgressRange(0, projectParts.size() + 1);
+ future.setProgressValue(0);
+ Core::MessageManager::write(
+ QLatin1String("updatePchInfo: switching to build system (exact)"),
+ Core::MessageManager::Silent);
+ foreach (const ProjectPart::Ptr &projectPart, projectParts) {
+ if (future.isCanceled())
+ return;
+ if (projectPart->precompiledHeaders.isEmpty())
+ continue;
+ const QString &pch = projectPart->precompiledHeaders.first(); // TODO: support more than 1 PCH file.
+ if (!QFile(pch).exists())
+ continue;
+
+ const bool hasObjC = hasObjCFiles(projectPart);
+ QStringList options = Utils::createClangOptions(
+ projectPart, getPrefixFileKind(hasObjC, hasCppFiles(projectPart)));
+
+ PchInfo::Ptr pchInfo = pchManager->findMatchingPCH(pch, options, false);
+ QPair<bool, QStringList> msgs = qMakePair(true, QStringList());
+ if (pchInfo.isNull()) {
+ pchInfo = PchInfo::createWithFileName(pch, options, hasObjC);
+ msgs = precompile(pchInfo);
+ }
+ pchManager->setPCHInfo(QList<ProjectPart::Ptr>() << projectPart,
+ pchInfo, msgs);
+ future.setProgressValue(future.progressValue() + 1);
+ }
+ } else if (pchUsage == ClangProjectSettings::PchUse_Custom) {
+ future.setProgressRange(0, 2);
+ future.setProgressValue(0);
+ Core::MessageManager::write(
+ QLatin1String("updatePchInfo: switching to custom") + customPchFile,
+ Core::MessageManager::Silent);
+
+ QSet<QString> includes, frameworks;
+ bool objc = false;
+ bool cplusplus = false;
+ ProjectPart::Ptr united(new ProjectPart());
+ united->cxxVersion = ProjectPart::CXX98;
+ foreach (const ProjectPart::Ptr &projectPart, projectParts) {
+ includes.unite(QSet<QString>::fromList(projectPart->includePaths));
+ frameworks.unite(QSet<QString>::fromList(projectPart->frameworkPaths));
+ united->cVersion = std::max(united->cVersion, projectPart->cVersion);
+ united->cxxVersion = std::max(united->cxxVersion, projectPart->cxxVersion);
+ united->qtVersion = std::max(united->qtVersion, projectPart->qtVersion);
+ objc |= hasObjCFiles(projectPart);
+ cplusplus |= hasCppFiles(projectPart);
+ }
+ united->frameworkPaths = frameworks.toList();
+ united->includePaths = includes.toList();
+ QStringList opts = Utils::createClangOptions(
+ united, getPrefixFileKind(objc, cplusplus));
+ united.clear();
+
+ PchInfo::Ptr pchInfo = pchManager->findMatchingPCH(customPchFile, opts, true);
+ QPair<bool, QStringList> msgs = qMakePair(true, QStringList());;
+ if (future.isCanceled())
+ return;
+ if (pchInfo.isNull()) {
+ pchInfo = PchInfo::createWithFileName(customPchFile, opts, objc);
+ msgs = precompile(pchInfo);
+ }
+ pchManager->setPCHInfo(projectParts, pchInfo, msgs);
+ future.setProgressValue(1);
+ }
+
+ future.setProgressValue(future.progressValue() + 1);
+}
+
+PchInfo::Ptr PCHManager::findMatchingPCH(const QString &inputFileName,
+ const QStringList &options,
+ bool fuzzyMatching) const
+{
+ QMutexLocker locker(&m_mutex);
+
+ if (fuzzyMatching) {
+ QStringList opts = options;
+ opts.sort();
+ foreach (PchInfo::Ptr pchInfo, m_activePCHFiles.values()) {
+ if (pchInfo->inputFileName() != inputFileName)
+ continue;
+ QStringList pchOpts = pchInfo->options();
+ pchOpts.sort();
+ if (pchOpts == opts)
+ return pchInfo;
+ }
+ } else {
+ foreach (PchInfo::Ptr pchInfo, m_activePCHFiles.values())
+ if (pchInfo->inputFileName() == inputFileName
+ && pchInfo->options() == options)
+ return pchInfo;
+ }
+
+ return PchInfo::Ptr();
+}
+
+void PCHManager::updateActivePCHFiles()
+{
+ QMutexLocker locker(&m_mutex);
+
+ QSet<ProjectPart::Ptr> activeParts;
+ CppTools::CppModelManagerInterface *mmi = CppTools::CppModelManagerInterface::instance();
+ foreach (const CppTools::CppModelManagerInterface::ProjectInfo &pi, mmi->projectInfos())
+ activeParts.unite(QSet<ProjectPart::Ptr>::fromList(pi.projectParts()));
+ QList<ProjectPart::Ptr> partsWithPCHFiles = m_activePCHFiles.keys();
+ foreach (ProjectPart::Ptr pPart, partsWithPCHFiles)
+ if (!activeParts.contains(pPart))
+ m_activePCHFiles.remove(pPart);
+}
diff --git a/src/plugins/clangcodemodel/pchmanager.h b/src/plugins/clangcodemodel/pchmanager.h
new file mode 100644
index 0000000000..c638f7b8a9
--- /dev/null
+++ b/src/plugins/clangcodemodel/pchmanager.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef PCHMANAGER_H
+#define PCHMANAGER_H
+
+#include "clangprojectsettings.h"
+#include "pchinfo.h"
+
+#include <cpptools/cppmodelmanagerinterface.h>
+#include <projectexplorer/project.h>
+#include <coreplugin/messagemanager.h>
+
+#include <QFutureWatcher>
+#include <QHash>
+#include <QMutex>
+#include <QObject>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class PCHManager: public QObject
+{
+ Q_OBJECT
+
+ typedef CppTools::ProjectPart ProjectPart;
+
+ static PCHManager *m_instance;
+
+public:
+ PCHManager(QObject *parent = 0);
+ virtual ~PCHManager();
+
+ static PCHManager *instance();
+
+ PchInfo::Ptr pchInfo(const ProjectPart::Ptr &projectPart) const;
+ ClangProjectSettings *settingsForProject(ProjectExplorer::Project *project);
+
+signals:
+ void pchInfoUpdated(); // TODO: check if this is used
+ void pchMessage(const QString &message, Core::MessageManager::PrintToOutputPaneFlags flags);
+
+public slots:
+ void clangProjectSettingsChanged();
+ void onAboutToRemoveProject(ProjectExplorer::Project *project);
+ void onProjectPartsUpdated(ProjectExplorer::Project *project);
+
+private slots:
+ void updateActivePCHFiles();
+
+private:
+ void updatePchInfo(ClangProjectSettings *cps,
+ const QList<ProjectPart::Ptr> &projectParts);
+ static void doPchInfoUpdate(QFutureInterface<void> &future,
+ ClangProjectSettings::PchUsage pchUsage,
+ const QString customPchFile,
+ const QList<ProjectPart::Ptr> projectParts);
+ void setPCHInfo(const QList<ProjectPart::Ptr> &projectParts,
+ const PchInfo::Ptr &pchInfo,
+ const QPair<bool, QStringList> &msgs);
+ PchInfo::Ptr findMatchingPCH(const QString &inputFileName, const QStringList &options,
+ bool fuzzyMatching) const;
+
+private:
+ mutable QMutex m_mutex;
+ QHash<ProjectPart::Ptr, PchInfo::Ptr> m_activePCHFiles;
+ QHash<ProjectExplorer::Project *, ClangProjectSettings *> m_projectSettings;
+ QFutureWatcher<void> m_pchGenerationWatcher;
+};
+
+} // namespace Internal
+} // namespace ClangCodeModel
+
+#endif // PCHMANAGER_H
diff --git a/src/plugins/clangcodemodel/raii/scopedclangoptions.cpp b/src/plugins/clangcodemodel/raii/scopedclangoptions.cpp
new file mode 100644
index 0000000000..acb9a76c9a
--- /dev/null
+++ b/src/plugins/clangcodemodel/raii/scopedclangoptions.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "scopedclangoptions.h"
+
+namespace ClangCodeModel {
+
+/**
+ * @class ClangCodeModel::ScopedClangOptions
+ * @brief Converts QStringList to raw options, acceptable by clang-c parsing and indexing API
+ */
+
+ScopedClangOptions::ScopedClangOptions(const QStringList &options)
+ : m_size(options.size())
+ , m_rawOptions(new const char*[options.size()])
+{
+ for (int i = 0 ; i < m_size; ++i)
+ m_rawOptions[i] = qstrdup(options[i].toUtf8());
+}
+
+ScopedClangOptions::~ScopedClangOptions()
+{
+ for (int i = 0; i < m_size; ++i)
+ delete[] m_rawOptions[i];
+ delete[] m_rawOptions;
+}
+
+const char **ScopedClangOptions::data() const
+{
+ return m_rawOptions;
+}
+
+int ScopedClangOptions::size() const
+{
+ return m_size;
+}
+
+/**
+ * @class ClangCodeModel::SharedClangOptions
+ * @brief Shared wrapper around \a {ClangCodeModel::ScopedClangOptions} ScopedClangOptions
+ */
+
+SharedClangOptions::SharedClangOptions()
+ : d(0)
+{
+}
+
+SharedClangOptions::SharedClangOptions(const QStringList &options)
+ : d(new ScopedClangOptions(options))
+{
+}
+
+/**
+ * @return Replaces options with new options list
+ */
+void SharedClangOptions::reloadOptions(const QStringList &options)
+{
+ d = QSharedPointer<ScopedClangOptions>(new ScopedClangOptions(options));
+}
+
+/**
+ * @return Pointer to clang raw options or NULL if uninitialized
+ */
+const char **SharedClangOptions::data() const
+{
+ return d ? d->data() : 0;
+}
+
+/**
+ * @return Options count or 0 if uninitialized
+ */
+int SharedClangOptions::size() const
+{
+ return d ? d->size() : 0;
+}
+
+} // namespace ClangCodeModel
diff --git a/src/plugins/debugger/lldblib/lldboptionspage.h b/src/plugins/clangcodemodel/raii/scopedclangoptions.h
index 71d5d05088..0f1020dead 100644
--- a/src/plugins/debugger/lldblib/lldboptionspage.h
+++ b/src/plugins/clangcodemodel/raii/scopedclangoptions.h
@@ -27,54 +27,46 @@
**
****************************************************************************/
-#ifndef LLDBOPTIONSPAGE_H
-#define LLDBOPTIONSPAGE_H
+#ifndef CLANGCODEMODEL_SCOPEDCLANGOPTIONS_H
+#define CLANGCODEMODEL_SCOPEDCLANGOPTIONS_H
-#include <coreplugin/dialogs/ioptionspage.h>
-#include "ui_lldboptionspagewidget.h"
-
-#include <QWidget>
-#include <QPointer>
+#include "../clang_global.h"
+#include <QStringList>
#include <QSharedPointer>
-#include <QSettings>
-namespace Debugger {
-namespace Internal {
+namespace ClangCodeModel {
-class LldbOptionsPageWidget : public QWidget
+class CLANG_EXPORT ScopedClangOptions
{
- Q_OBJECT
-
public:
- explicit LldbOptionsPageWidget(QWidget *parent, QSettings *s);
+ ScopedClangOptions(const QStringList &options);
+ ~ScopedClangOptions();
-public slots:
- void save();
- void load();
+ const char **data() const;
+ int size() const;
private:
- Ui::LldbOptionsPageWidget m_ui;
- QSettings *s;
+ void release();
+
+ int m_size;
+ const char **m_rawOptions;
};
-class LldbOptionsPage : public Core::IOptionsPage
+class CLANG_EXPORT SharedClangOptions
{
- Q_OBJECT
-
public:
- LldbOptionsPage();
+ SharedClangOptions();
+ SharedClangOptions(const QStringList &options);
+
+ void reloadOptions(const QStringList &options);
- // IOptionsPage
- QWidget *createPage(QWidget *parent);
- void apply();
- void finish();
- bool matches(const QString &) const;
+ const char **data() const;
+ int size() const;
private:
- QPointer<LldbOptionsPageWidget> m_widget;
+ QSharedPointer<ScopedClangOptions> d;
};
-} // namespace Internal
-} // namespace Debugger
+} // namespace ClangCodeModel
-#endif // LLDBOPTIONSPAGE_H
+#endif // CLANGCODEMODEL_SCOPEDCLANGOPTIONS_H
diff --git a/src/plugins/clangcodemodel/semanticmarker.cpp b/src/plugins/clangcodemodel/semanticmarker.cpp
new file mode 100644
index 0000000000..fda7700bd3
--- /dev/null
+++ b/src/plugins/clangcodemodel/semanticmarker.cpp
@@ -0,0 +1,505 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "semanticmarker.h"
+#include "unit.h"
+#include "utils_p.h"
+#include "cxraii.h"
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+
+static const unsigned ATTACHED_NOTES_LIMIT = 10;
+
+SemanticMarker::SemanticMarker()
+{
+}
+
+SemanticMarker::~SemanticMarker()
+{
+}
+
+QString SemanticMarker::fileName() const
+{
+ if (!m_unit)
+ return QString();
+
+ return m_unit->fileName();
+}
+
+void SemanticMarker::setFileName(const QString &fileName)
+{
+ if (this->fileName() == fileName)
+ return;
+
+ QStringList oldOptions;
+ if (m_unit)
+ oldOptions = m_unit->compilationOptions();
+ m_unit = Unit::create(fileName);
+ if (!oldOptions.isEmpty())
+ m_unit->setCompilationOptions(oldOptions);
+
+ unsigned clangOpts = clang_defaultEditingTranslationUnitOptions();
+ clangOpts |= CXTranslationUnit_DetailedPreprocessingRecord;
+ clangOpts &= ~CXTranslationUnit_CacheCompletionResults;
+ m_unit->setManagementOptions(clangOpts);
+}
+
+void SemanticMarker::setCompilationOptions(const QStringList &options)
+{
+ Q_ASSERT(m_unit);
+
+ if (m_unit->compilationOptions() == options)
+ return;
+
+ m_unit->setCompilationOptions(options);
+}
+
+void SemanticMarker::reparse(const UnsavedFiles &unsavedFiles)
+{
+ Q_ASSERT(m_unit);
+
+ m_unit->setUnsavedFiles(unsavedFiles);
+ if (m_unit->isLoaded())
+ m_unit->reparse();
+ else
+ m_unit->parse();
+}
+
+/**
+ * \brief Calculate one or several ranges and append diagnostic for each range
+ * Extracted from SemanticMarker::diagnostics() to reuse code
+ */
+static void appendDiagnostic(const CXDiagnostic &diag,
+ const CXSourceLocation &cxLocation,
+ Diagnostic::Severity severity,
+ const QString &spelling,
+ QList<Diagnostic> &diagnostics)
+{
+ const unsigned rangeCount = clang_getDiagnosticNumRanges(diag);
+ bool expandLocation = true;
+
+ for (unsigned i = 0; i < rangeCount; ++i) {
+ CXSourceRange r = clang_getDiagnosticRange(diag, i);
+ const SourceLocation &spellBegin = Internal::getSpellingLocation(clang_getRangeStart(r));
+ const SourceLocation &spellEnd = Internal::getSpellingLocation(clang_getRangeEnd(r));
+ unsigned length = spellEnd.offset() - spellBegin.offset();
+
+ // File name can be empty due clang bug
+ if (!spellBegin.fileName().isEmpty()) {
+ Diagnostic d(severity, spellBegin, length, spelling);
+ diagnostics.append(d);
+ expandLocation = false;
+ }
+ }
+
+ if (expandLocation) {
+ const SourceLocation &location = Internal::getExpansionLocation(cxLocation);
+ Diagnostic d(severity, location, 0, spelling);
+ diagnostics.append(d);
+ }
+}
+
+QList<Diagnostic> SemanticMarker::diagnostics() const
+{
+ QList<Diagnostic> diagnostics;
+ if (!m_unit || !m_unit->isLoaded())
+ return diagnostics;
+
+ const unsigned diagCount = m_unit->getNumDiagnostics();
+ for (unsigned i = 0; i < diagCount; ++i) {
+ ScopedCXDiagnostic diag(m_unit->getDiagnostic(i));
+
+ Diagnostic::Severity severity = static_cast<Diagnostic::Severity>(clang_getDiagnosticSeverity(diag));
+ if (severity == Diagnostic::Ignored || severity == Diagnostic::Note)
+ continue;
+
+ CXSourceLocation cxLocation = clang_getDiagnosticLocation(diag);
+ QString spelling = Internal::getQString(clang_getDiagnosticSpelling(diag));
+
+ // Attach messages with Diagnostic::Note severity
+ ScopedCXDiagnosticSet cxChildren(clang_getChildDiagnostics(diag));
+ const unsigned numChildren = clang_getNumDiagnosticsInSet(cxChildren);
+ const unsigned size = qMin(ATTACHED_NOTES_LIMIT, numChildren);
+ for (unsigned di = 0; di < size; ++di) {
+ ScopedCXDiagnostic child(clang_getDiagnosticInSet(cxChildren, di));
+ spelling.append(QLatin1String("\n "));
+ spelling.append(Internal::getQString(clang_getDiagnosticSpelling(child)));
+ }
+
+ // Fatal error may occur in another file, but it breaks whole parsing
+ // Typical fatal error is unresolved #include
+ if (severity == Diagnostic::Fatal) {
+ for (unsigned di = 0; di < numChildren; ++di) {
+ ScopedCXDiagnostic child(clang_getDiagnosticInSet(cxChildren, di));
+ appendDiagnostic(child, clang_getDiagnosticLocation(child), Diagnostic::Warning, spelling, diagnostics);
+ }
+ }
+
+ appendDiagnostic(diag, cxLocation, severity, spelling, diagnostics);
+ }
+
+ return diagnostics;
+}
+
+QList<TextEditor::BlockRange> SemanticMarker::ifdefedOutBlocks() const
+{
+ QList<TextEditor::BlockRange> blocks;
+
+ if (!m_unit || !m_unit->isLoaded())
+ return blocks;
+
+#if CINDEX_VERSION_MINOR >= 21
+ CXSourceRangeList *skippedRanges = clang_getSkippedRanges(m_unit->clangTranslationUnit(),
+ m_unit->getFile());
+ blocks.reserve(skippedRanges->count);
+ for (unsigned i = 0; i < skippedRanges->count; ++i) {
+ const CXSourceRange &r = skippedRanges->ranges[i];
+ const SourceLocation &spellBegin = Internal::getSpellingLocation(clang_getRangeStart(r));
+ if (spellBegin.fileName() != fileName())
+ continue;
+ const SourceLocation &spellEnd = Internal::getSpellingLocation(clang_getRangeEnd(r));
+ const int begin = spellBegin.offset() + 1;
+ const int end = spellEnd.offset() - spellEnd.column();
+ blocks.append(TextEditor::BlockRange(begin, end));
+ }
+ clang_disposeSourceRangeList(skippedRanges);
+#endif
+
+ return blocks;
+}
+
+namespace {
+static void add(QList<SourceMarker> &markers,
+ const CXSourceRange &extent,
+ SourceMarker::Kind kind)
+{
+ CXSourceLocation start = clang_getRangeStart(extent);
+ CXSourceLocation end = clang_getRangeEnd(extent);
+ const SourceLocation &location = Internal::getExpansionLocation(start);
+ const SourceLocation &locationEnd = Internal::getExpansionLocation(end);
+
+ if (location.offset() < locationEnd.offset()) {
+ const unsigned length = locationEnd.offset() - location.offset();
+ markers.append(SourceMarker(location, length, kind));
+ }
+}
+
+/**
+ * @brief Selects correct highlighting for cursor that is reference
+ * @return SourceMarker::Unknown if cannot select highlighting
+ */
+static SourceMarker::Kind getKindByReferencedCursor(const CXCursor &cursor)
+{
+ const CXCursor referenced = clang_getCursorReferenced(cursor);
+ switch (clang_getCursorKind(referenced)) {
+ case CXCursor_EnumConstantDecl:
+ return SourceMarker::Enumeration;
+
+ case CXCursor_FieldDecl:
+ case CXCursor_ObjCIvarDecl:
+ case CXCursor_ObjCPropertyDecl:
+ return SourceMarker::Field;
+
+ case CXCursor_FunctionDecl:
+ case CXCursor_FunctionTemplate:
+ case CXCursor_Constructor:
+ return SourceMarker::Function;
+
+ case CXCursor_VarDecl:
+ case CXCursor_ParmDecl:
+ case CXCursor_NonTypeTemplateParameter:
+ return SourceMarker::Local;
+
+ case CXCursor_CXXMethod:
+ if (clang_CXXMethod_isVirtual(referenced))
+ return SourceMarker::VirtualMethod;
+ else
+ return SourceMarker::Function;
+
+ case CXCursor_ObjCClassMethodDecl:
+ case CXCursor_ObjCInstanceMethodDecl:
+ // calling method as property, e.h. "layer.shouldRasterize = YES"
+ return SourceMarker::Field;
+
+ case CXCursor_UnexposedDecl:
+ // NSObject "self" method which is a pseudo keyword
+ if (clang_getCursorLanguage(referenced) == CXLanguage_ObjC)
+ return SourceMarker::PseudoKeyword;
+ break;
+
+ default:
+ break;
+ }
+ return SourceMarker::Unknown;
+}
+
+static const QSet<QString> ObjcPseudoKeywords = QSet<QString>()
+ << QLatin1String("end")
+ << QLatin1String("try")
+ << QLatin1String("defs")
+ << QLatin1String("throw")
+ << QLatin1String("class")
+ << QLatin1String("catch")
+ << QLatin1String("encode")
+ << QLatin1String("public")
+ << QLatin1String("dynamic")
+ << QLatin1String("finally")
+ << QLatin1String("package")
+ << QLatin1String("private")
+ << QLatin1String("optional")
+ << QLatin1String("property")
+ << QLatin1String("protocol")
+ << QLatin1String("required")
+ << QLatin1String("selector")
+ << QLatin1String("interface")
+ << QLatin1String("protected")
+ << QLatin1String("synthesize")
+ << QLatin1String("not_keyword")
+ << QLatin1String("synchronized")
+ << QLatin1String("implementation")
+ << QLatin1String("compatibility_alias")
+ ;
+
+} // Anonymous namespace
+
+/**
+ * @brief SemanticMarker::sourceMarkersInRange
+ * @param firstLine - first line where to generate highlighting markers
+ * @param lastLine - last line where to generate highlighting markers
+ *
+ * There still two kinds of problems:
+ * - clang_annotateTokens() can return wrong cursor, and it's normal behavior
+ * - some cases no handled
+ *
+ * Problems caused by wrong cursors:
+ * - range-based for from C++ 2011
+ * - identifiers in some compound statements have type DeclStmt
+ * or CompoundStmt which refers to top-level construction.
+ * - CXCursor_ObjCIvarDecl mapped to field, but instance variable have
+ * incorrect cursor kind if it declared in private interface
+ * @interface MyApplication() {
+ * NSArray* _items;
+ * }
+ *
+ * Missed cases:
+ * - global variables highlighted as locals
+ * - appropriate marker had not been selected for listed cursors:
+ * CXCursor_ObjCProtocolExpr, CXCursor_ObjCEncodeExpr,
+ * CXCursor_ObjCDynamicDecl, CXCursor_ObjCBridgedCastExpr,
+ * CXCursor_ObjCSuperClassRef
+ * - template members of template classes&functions always highlighted
+ * as members, even if they are functions - no way to differ found.
+ * - @1, @{}, @[]
+ */
+QList<SourceMarker> SemanticMarker::sourceMarkersInRange(unsigned firstLine,
+ unsigned lastLine)
+{
+ Q_ASSERT(m_unit);
+
+ QList<SourceMarker> result;
+
+ if (!m_unit->isLoaded())
+ return result;
+
+ // Highlighting called asynchronously, and a few lines at the end can be deleted for this time.
+ CXSourceRange unitRange = clang_getCursorExtent(m_unit->getTranslationUnitCursor());
+ SourceLocation unitEnd = getExpansionLocation(clang_getRangeEnd(unitRange));
+ if (lastLine > unitEnd.line())
+ lastLine = unitEnd.line();
+
+ if (firstLine > lastLine)
+ return result;
+
+ IdentifierTokens idTokens(*m_unit, firstLine, lastLine);
+
+ const CXSourceRange *atTokenExtent = 0;
+ for (unsigned i = 0; i < idTokens.count(); ++i) {
+ const CXToken &tok = idTokens.token(i);
+ CXTokenKind kind = clang_getTokenKind(tok);
+ if (atTokenExtent) {
+ if (CXToken_Literal == kind) {
+ if (m_unit->getTokenSpelling(tok).startsWith(QLatin1Char('"')))
+ add(result, *atTokenExtent, SourceMarker::ObjCString);
+ atTokenExtent = 0;
+ continue;
+ } else {
+ add(result, *atTokenExtent, SourceMarker::PseudoKeyword);
+ atTokenExtent = 0;
+ }
+ }
+
+ const CXSourceRange &tokenExtent = idTokens.extent(i);
+
+ if (CXToken_Keyword == kind) {
+ QString spell = m_unit->getTokenSpelling(tok);
+ if (ObjcPseudoKeywords.contains(spell))
+ add(result, tokenExtent, SourceMarker::PseudoKeyword);
+ continue;
+ }
+
+ if (CXToken_Punctuation == kind) {
+ static const QLatin1String at("@");
+ if (m_unit->getTokenSpelling(tok) == at)
+ atTokenExtent = &tokenExtent;
+ continue;
+ }
+
+ if (CXToken_Identifier != kind)
+ continue;
+
+ const CXCursor &cursor = idTokens.cursor(i);
+ const CXCursorKind cursorKind = clang_getCursorKind(cursor);
+ if (clang_isInvalid(cursorKind))
+ continue;
+
+ switch (cursorKind) {
+ case CXCursor_EnumConstantDecl:
+ add(result, tokenExtent, SourceMarker::Enumeration);
+ break;
+
+ case CXCursor_ClassDecl:
+ case CXCursor_UnionDecl:
+ case CXCursor_ClassTemplate:
+ case CXCursor_ClassTemplatePartialSpecialization:
+ case CXCursor_EnumDecl:
+ case CXCursor_Namespace:
+ case CXCursor_NamespaceRef:
+ case CXCursor_NamespaceAlias:
+ case CXCursor_StructDecl:
+ case CXCursor_TemplateRef:
+ case CXCursor_TypeRef:
+ case CXCursor_TypedefDecl:
+ case CXCursor_Constructor:
+ case CXCursor_TemplateTypeParameter:
+ case CXCursor_TemplateTemplateParameter:
+ case CXCursor_UnexposedDecl: /* friend class MyClass; */
+ add(result, tokenExtent, SourceMarker::Type);
+ break;
+
+ case CXCursor_ParmDecl:
+ case CXCursor_VariableRef:
+ case CXCursor_VarDecl:
+ case CXCursor_NonTypeTemplateParameter:
+ add(result, tokenExtent, SourceMarker::Local);
+ break;
+
+ case CXCursor_MemberRefExpr:
+ case CXCursor_MemberRef:
+ case CXCursor_DeclRefExpr:
+ case CXCursor_CallExpr: {
+ SourceMarker::Kind kind = getKindByReferencedCursor(cursor);
+ if (kind == SourceMarker::Unknown && cursorKind == CXCursor_MemberRefExpr) {
+ /* template class member in template function */
+ kind = SourceMarker::Field;
+ }
+ if (kind != SourceMarker::Unknown)
+ add(result, tokenExtent, kind);
+ } break;
+
+ case CXCursor_FieldDecl:
+ add(result, tokenExtent, SourceMarker::Field);
+ break;
+
+ case CXCursor_Destructor:
+ case CXCursor_CXXMethod: {
+ if (clang_CXXMethod_isVirtual(cursor))
+ add(result, tokenExtent, SourceMarker::VirtualMethod);
+ else
+ add(result, tokenExtent, SourceMarker::Function);
+ } break;
+
+ case CXCursor_CXXOverrideAttr:
+ case CXCursor_CXXFinalAttr:
+ case CXCursor_AnnotateAttr: // 'annotate' in '__attribute__((annotate("AnyComment")))'
+ case CXCursor_UnexposedAttr: // 'align' in '__declspec(align(8))'
+ add(result, tokenExtent, SourceMarker::PseudoKeyword);
+ break;
+
+ case CXCursor_FunctionDecl:
+ case CXCursor_FunctionTemplate:
+ case CXCursor_OverloadedDeclRef:
+ add(result, tokenExtent, SourceMarker::Function);
+ break;
+
+ case CXCursor_ObjCInstanceMethodDecl:
+ case CXCursor_ObjCClassMethodDecl:
+ case CXCursor_ObjCSelectorExpr:
+ add(result, tokenExtent, SourceMarker::ObjectiveCMessage);
+ break;
+
+ case CXCursor_ObjCMessageExpr: {
+ static const QLatin1String super("super");
+ if (m_unit->getTokenSpelling(tok) == super)
+ add(result, tokenExtent, SourceMarker::PseudoKeyword);
+ else
+ add(result, tokenExtent, SourceMarker::ObjectiveCMessage);
+ } break;
+
+ case CXCursor_ObjCCategoryDecl:
+ case CXCursor_ObjCCategoryImplDecl:
+ case CXCursor_ObjCImplementationDecl:
+ case CXCursor_ObjCInterfaceDecl:
+ case CXCursor_ObjCProtocolDecl:
+ case CXCursor_ObjCProtocolRef:
+ case CXCursor_ObjCClassRef:
+ case CXCursor_ObjCSuperClassRef:
+ case CXCursor_TypeAliasDecl: // C++11 type alias: 'using value_t = T'
+ add(result, tokenExtent, SourceMarker::Type);
+ break;
+
+ case CXCursor_ObjCSynthesizeDecl:
+ case CXCursor_ObjCDynamicDecl:
+ case CXCursor_ObjCPropertyDecl:
+ case CXCursor_ObjCIvarDecl:
+ add(result, tokenExtent, SourceMarker::Field);
+ break;
+
+ case CXCursor_MacroDefinition:
+ case CXCursor_MacroExpansion:
+ add(result, tokenExtent, SourceMarker::Macro);
+ break;
+
+ case CXCursor_LabelRef:
+ case CXCursor_LabelStmt:
+ add(result, tokenExtent, SourceMarker::Label);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return result;
+}
+
+Unit::Ptr SemanticMarker::unit() const
+{
+ return m_unit;
+}
diff --git a/src/plugins/clangcodemodel/semanticmarker.h b/src/plugins/clangcodemodel/semanticmarker.h
new file mode 100644
index 0000000000..43959b4e27
--- /dev/null
+++ b/src/plugins/clangcodemodel/semanticmarker.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANG_SEMANTICMARKER_H
+#define CLANG_SEMANTICMARKER_H
+
+#include "clang_global.h"
+#include "diagnostic.h"
+#include "fastindexer.h"
+#include "sourcemarker.h"
+#include "utils.h"
+
+#include <texteditor/itexteditor.h>
+
+#include <QMutex>
+#include <QScopedPointer>
+#include <QSharedPointer>
+#include <QString>
+#include <QStringList>
+
+namespace ClangCodeModel {
+
+class CLANG_EXPORT SemanticMarker
+{
+ Q_DISABLE_COPY(SemanticMarker)
+
+public:
+ typedef QSharedPointer<SemanticMarker> Ptr;
+
+public:
+ SemanticMarker();
+ ~SemanticMarker();
+
+ QMutex *mutex() const
+ { return &m_mutex; }
+
+ QString fileName() const;
+ void setFileName(const QString &fileName);
+
+ void setCompilationOptions(const QStringList &options);
+
+ void reparse(const Internal::UnsavedFiles &unsavedFiles);
+
+ QList<Diagnostic> diagnostics() const;
+
+ QList<TextEditor::BlockRange> ifdefedOutBlocks() const;
+
+ QList<SourceMarker> sourceMarkersInRange(unsigned firstLine,
+ unsigned lastLine);
+
+ Internal::Unit::Ptr unit() const;
+
+private:
+ mutable QMutex m_mutex;
+ Internal::Unit::Ptr m_unit;
+};
+
+} // namespace ClangCodeModel
+
+#endif // CLANG_SEMANTICMARKER_H
diff --git a/src/plugins/clangcodemodel/sourcelocation.cpp b/src/plugins/clangcodemodel/sourcelocation.cpp
new file mode 100644
index 0000000000..f2e15425cd
--- /dev/null
+++ b/src/plugins/clangcodemodel/sourcelocation.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "sourcelocation.h"
+
+using namespace ClangCodeModel;
+
+SourceLocation::SourceLocation()
+ : m_line(0)
+ , m_column(0)
+ , m_offset(0)
+{}
+
+SourceLocation::SourceLocation(const QString &fileName,
+ unsigned line,
+ unsigned column,
+ unsigned offset)
+ : m_fileName(fileName)
+ , m_line(line)
+ , m_column(column)
+ , m_offset(offset)
+{}
+
+namespace ClangCodeModel {
+
+bool operator==(const SourceLocation &a, const SourceLocation &b)
+{
+ return a.line() == b.line()
+ && a.column() == b.column()
+ && a.offset() == b.offset()
+ && a.fileName() == b.fileName()
+ ;
+}
+
+bool operator!=(const SourceLocation &a, const SourceLocation &b)
+{
+ return !(a == b);
+}
+
+QDebug operator<<(QDebug dbg, const SourceLocation &location)
+{
+ dbg.nospace() << location.fileName()
+ << " ["
+ << location.line()
+ << ":"
+ << location.column()
+ << "("
+ << location.offset()
+ << ")]";
+ return dbg.space();
+}
+
+} // ClangCodeModel
diff --git a/src/plugins/clangcodemodel/sourcelocation.h b/src/plugins/clangcodemodel/sourcelocation.h
new file mode 100644
index 0000000000..33c2a4f313
--- /dev/null
+++ b/src/plugins/clangcodemodel/sourcelocation.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef SOURCELOCATION_H
+#define SOURCELOCATION_H
+
+#include "clang_global.h"
+
+#include <QtCore/QString>
+#include <QtCore/QDebug>
+
+namespace ClangCodeModel {
+
+class CLANG_EXPORT SourceLocation
+{
+public:
+ SourceLocation();
+ SourceLocation(const QString &fileName,
+ unsigned line = 0,
+ unsigned column = 0,
+ unsigned offset = 0);
+
+ bool isNull() const { return m_fileName.isEmpty(); }
+ const QString &fileName() const { return m_fileName; }
+ unsigned line() const { return m_line; }
+ unsigned column() const { return m_column; }
+ unsigned offset() const { return m_offset; }
+
+private:
+ QString m_fileName;
+ unsigned m_line;
+ unsigned m_column;
+ unsigned m_offset;
+};
+
+bool operator==(const SourceLocation &a, const SourceLocation &b);
+bool operator!=(const SourceLocation &a, const SourceLocation &b);
+
+QDebug operator<<(QDebug dbg, const SourceLocation &location);
+
+} // ClangCodeModel
+
+#endif // SOURCELOCATION_H
diff --git a/src/plugins/clangcodemodel/sourcemarker.cpp b/src/plugins/clangcodemodel/sourcemarker.cpp
new file mode 100644
index 0000000000..bef7c99f40
--- /dev/null
+++ b/src/plugins/clangcodemodel/sourcemarker.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "sourcemarker.h"
+
+using namespace ClangCodeModel;
+
+SourceMarker::SourceMarker()
+ : m_length(0), m_kind(Unknown)
+{}
+
+SourceMarker::SourceMarker(const SourceLocation &location, unsigned length, Kind kind)
+ : m_loc(location), m_length(length), m_kind(kind)
+{
+}
diff --git a/src/plugins/clangcodemodel/sourcemarker.h b/src/plugins/clangcodemodel/sourcemarker.h
new file mode 100644
index 0000000000..ed91d5e4fa
--- /dev/null
+++ b/src/plugins/clangcodemodel/sourcemarker.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANG_SOURCEMARKER_H
+#define CLANG_SOURCEMARKER_H
+
+#include "clang_global.h"
+#include "sourcelocation.h"
+
+namespace ClangCodeModel {
+
+class CLANG_EXPORT SourceMarker
+{
+public: // TODO: remove this, it's about the same as the TextEditor::SemanticHighlighter::Result
+ enum Kind {
+ Unknown = 0,
+ Type = 1,
+ Local,
+ Field,
+ Enumeration,
+ VirtualMethod,
+ Label,
+ Macro,
+ Function,
+ PseudoKeyword,
+ ObjCString,
+
+ ObjectiveCMessage = VirtualMethod
+ };
+
+ SourceMarker();
+ SourceMarker(const SourceLocation &location,
+ unsigned length,
+ Kind kind);
+
+ bool isValid() const
+ { return m_loc.line() != 0; }
+
+ bool isInvalid() const
+ { return m_loc.line() == 0; }
+
+ const SourceLocation &location() const
+ { return m_loc; }
+
+ unsigned length() const
+ { return m_length; }
+
+ Kind kind() const
+ { return m_kind; }
+
+ bool lessThan(const SourceMarker &other) const
+ {
+ if (m_loc.line() != other.m_loc.line())
+ return m_loc.line() < other.m_loc.line();
+ if (m_loc.column() != other.m_loc.column())
+ return m_loc.column() < other.m_loc.column();
+ return m_length < other.m_length;
+ }
+
+private:
+ SourceLocation m_loc;
+ unsigned m_length;
+ Kind m_kind;
+};
+
+CLANG_EXPORT inline bool operator<(const SourceMarker &one, const SourceMarker &two)
+{ return one.lessThan(two); }
+
+} // namespace Clang
+
+#endif // CLANG_SOURCEMARKER_H
diff --git a/src/plugins/clangcodemodel/symbol.cpp b/src/plugins/clangcodemodel/symbol.cpp
new file mode 100644
index 0000000000..4d7f58850e
--- /dev/null
+++ b/src/plugins/clangcodemodel/symbol.cpp
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "symbol.h"
+
+#include <cplusplus/Icons.h>
+
+using namespace ClangCodeModel;
+
+Symbol::Symbol()
+ : m_kind(Unknown)
+{}
+
+Symbol::Symbol(const QString &name,
+ const QString &qualification,
+ Kind type,
+ const SourceLocation &location)
+ : m_name(name)
+ , m_qualification(qualification)
+ , m_location(location)
+ , m_kind(type)
+{}
+
+QIcon Symbol::iconForSymbol() const
+{
+ CPlusPlus::Icons icons;
+ switch (m_kind) {
+ case Enum:
+ return icons.iconForType(CPlusPlus::Icons::EnumIconType);
+ case Class:
+ return icons.iconForType(CPlusPlus::Icons::ClassIconType);
+ case Method:
+ case Function:
+ case Declaration:
+ case Constructor:
+ case Destructor:
+ return icons.iconForType(CPlusPlus::Icons::FuncPublicIconType);
+ default:
+ return icons.iconForType(CPlusPlus::Icons::UnknownIconType);
+ }
+}
+
+namespace ClangCodeModel {
+
+QDataStream &operator<<(QDataStream &stream, const Symbol &symbol)
+{
+ stream << symbol.m_name
+ << symbol.m_qualification
+ << symbol.m_location.fileName()
+ << (quint32)symbol.m_location.line()
+ << (quint16)symbol.m_location.column()
+ << (quint32)symbol.m_location.offset()
+ << (qint8)symbol.m_kind;
+
+ return stream;
+}
+
+QDataStream &operator>>(QDataStream &stream, Symbol &symbol)
+{
+ QString fileName;
+ quint32 line;
+ quint16 column;
+ quint32 offset;
+ quint8 kind;
+ stream >> symbol.m_name
+ >> symbol.m_qualification
+ >> fileName
+ >> line
+ >> column
+ >> offset
+ >> kind;
+ symbol.m_location = SourceLocation(fileName, line, column, offset);
+ symbol.m_kind = Symbol::Kind(kind);
+
+ return stream;
+}
+
+bool operator==(const Symbol &a, const Symbol &b)
+{
+ return a.m_name == b.m_name
+ && a.m_qualification == b.m_qualification
+ && a.m_location == b.m_location
+ && a.m_kind == b.m_kind;
+}
+
+bool operator!=(const Symbol &a, const Symbol &b)
+{
+ return !(a == b);
+}
+
+} // ClangCodeModel
diff --git a/src/plugins/qtsupport/debugginghelper.h b/src/plugins/clangcodemodel/symbol.h
index 2786622811..0084bf3ce3 100644
--- a/src/plugins/qtsupport/debugginghelper.h
+++ b/src/plugins/clangcodemodel/symbol.h
@@ -27,32 +27,51 @@
**
****************************************************************************/
-#ifndef DEBUGGINGHELPER_H
-#define DEBUGGINGHELPER_H
+#ifndef INDEXEDSYMBOLINFO_H
+#define INDEXEDSYMBOLINFO_H
-#include "qtsupport_global.h"
-
-#include <utils/buildablehelperlibrary.h>
+#include "sourcelocation.h"
#include <QString>
+#include <QDataStream>
+#include <QIcon>
-QT_FORWARD_DECLARE_CLASS(QStringList)
-
-namespace QtSupport {
+namespace ClangCodeModel {
-class QTSUPPORT_EXPORT DebuggingHelperLibrary : public Utils::BuildableHelperLibrary
+class Symbol
{
public:
- static QString debuggingHelperLibraryByInstallData(const QString &qtInstallData);
- static QStringList debuggingHelperLibraryDirectories(const QString &qtInstallData);
+ enum Kind {
+ Enum,
+ Class,
+ Method, // A member-function.
+ Function, // A free-function (global or within a namespace).
+ Declaration,
+ Constructor,
+ Destructor,
+ Unknown
+ };
- // Build the helpers and return the output log/errormessage.
- static bool build(BuildHelperArguments arguments, QString *log, QString *errorMessage);
+ Symbol();
+ Symbol(const QString &name,
+ const QString &qualification,
+ Kind type,
+ const SourceLocation &location);
- // Copy the source files to a target location and return the chosen target location.
- static QString copy(const QString &qtInstallData, QString *errorMessage);
+ QString m_name;
+ QString m_qualification;
+ SourceLocation m_location;
+ Kind m_kind;
+ QIcon iconForSymbol() const;
};
-} // namespace QtSupport
-#endif // DEBUGGINGHELPER_H
+QDataStream &operator<<(QDataStream &stream, const Symbol &symbol);
+QDataStream &operator>>(QDataStream &stream, Symbol &symbol);
+
+bool operator==(const Symbol &a, const Symbol &b);
+bool operator!=(const Symbol &a, const Symbol &b);
+
+} // Clang
+
+#endif // INDEXEDSYMBOLINFO_H
diff --git a/src/plugins/clangcodemodel/test/clang_tests_database.qrc b/src/plugins/clangcodemodel/test/clang_tests_database.qrc
new file mode 100644
index 0000000000..0014d36087
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/clang_tests_database.qrc
@@ -0,0 +1,20 @@
+<RCC>
+ <qresource prefix="/unittests/ClangCodeModel">
+ <file>cxx_regression_1.cpp</file>
+ <file>cxx_regression_2.cpp</file>
+ <file>cxx_regression_3.cpp</file>
+ <file>cxx_regression_4.cpp</file>
+ <file>cxx_regression_5.cpp</file>
+ <file>cxx_regression_6.cpp</file>
+ <file>cxx_regression_7.cpp</file>
+ <file>cxx_regression_8.cpp</file>
+ <file>cxx_regression_9.cpp</file>
+ <file>cxx_snippets_1.cpp</file>
+ <file>cxx_snippets_2.cpp</file>
+ <file>cxx_snippets_3.cpp</file>
+ <file>cxx_snippets_4.cpp</file>
+ <file>objc_messages_1.mm</file>
+ <file>objc_messages_2.mm</file>
+ <file>objc_messages_3.mm</file>
+ </qresource>
+</RCC>
diff --git a/src/plugins/clangcodemodel/test/clangcompletion_test.cpp b/src/plugins/clangcodemodel/test/clangcompletion_test.cpp
new file mode 100644
index 0000000000..c9f3bc8217
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/clangcompletion_test.cpp
@@ -0,0 +1,392 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/**
+ * @file clangcompletion_test.cpp
+ * @brief Performs test for C/C++ code completion
+ *
+ * All test cases given as strings with @ character that points to completion
+ * location.
+ */
+
+#ifdef WITH_TESTS
+
+// Disabled because there still no tool to detect system Objective-C headers
+#define ENABLE_OBJC_TESTS 0
+
+#include <QtTest>
+#include <QDebug>
+#undef interface // Canceling "#DEFINE interface struct" on Windows
+
+#include "completiontesthelper.h"
+#include "../clangcodemodelplugin.h"
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+
+////////////////////////////////////////////////////////////////////////////////
+// Test cases
+
+/**
+ * \defgroup Regression tests
+ *
+ * This group tests possible regressions in non-standard completion chunks
+ * handling: for example, macro arguments and clang's code snippets.
+ *
+ * @{
+ */
+
+void ClangCodeModelPlugin::test_CXX_regressions()
+{
+ QFETCH(QString, file);
+ QFETCH(QStringList, unexpected);
+ QFETCH(QStringList, mustHave);
+
+ CompletionTestHelper helper;
+ helper << file;
+
+ QStringList proposals = helper.codeCompleteTexts();
+
+ foreach (const QString &p, unexpected)
+ QTEST_ASSERT(false == proposals.contains(p));
+
+ foreach (const QString &p, mustHave)
+ QTEST_ASSERT(true == proposals.contains(p));
+}
+
+void ClangCodeModelPlugin::test_CXX_regressions_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QStringList>("unexpected");
+ QTest::addColumn<QStringList>("mustHave");
+
+ QString file;
+ QStringList unexpected;
+ QStringList mustHave;
+
+ file = QLatin1String("cxx_regression_1.cpp");
+ mustHave << QLatin1String("sqr");
+ mustHave << QLatin1String("~Math");
+ unexpected << QLatin1String("operator=");
+ QTest::newRow("case 1: method call completion") << file << unexpected << mustHave;
+ mustHave.clear();
+ unexpected.clear();
+
+ file = QLatin1String("cxx_regression_2.cpp");
+ unexpected << QLatin1String("i_second");
+ unexpected << QLatin1String("c_second");
+ unexpected << QLatin1String("f_second");
+ mustHave << QLatin1String("i_first");
+ mustHave << QLatin1String("c_first");
+ QTest::newRow("case 2: multiple anonymous structs") << file << unexpected << mustHave;
+ mustHave.clear();
+ unexpected.clear();
+
+ file = QLatin1String("cxx_regression_3.cpp");
+ mustHave << QLatin1String("i8");
+ mustHave << QLatin1String("i64");
+ mustHave << QLatin1String("~Priv");
+ unexpected << QLatin1String("operator=");
+ QTest::newRow("case 3: nested class resolution") << file << unexpected << mustHave;
+ mustHave.clear();
+ unexpected.clear();
+
+ file = QLatin1String("cxx_regression_4.cpp");
+ mustHave << QLatin1String("action");
+ QTest::newRow("case 4: local (in function) class resolution") << file << unexpected << mustHave;
+ mustHave.clear();
+ unexpected.clear();
+
+ file = QLatin1String("cxx_regression_5.cpp");
+ mustHave << QLatin1String("doB");
+ unexpected << QLatin1String("doA");
+ QTest::newRow("case 5: nested template class resolution") << file << unexpected << mustHave;
+ mustHave.clear();
+ unexpected.clear();
+
+ file = QLatin1String("cxx_regression_6.cpp");
+ mustHave << QLatin1String("OwningPtr");
+ QTest::newRow("case 6: using particular symbol from namespace") << file << unexpected << mustHave;
+ mustHave.clear();
+ unexpected.clear();
+
+ file = QLatin1String("cxx_regression_7.cpp");
+ mustHave << QLatin1String("dataMember");
+ mustHave << QLatin1String("anotherMember");
+ QTest::newRow("case 7: template class inherited from template parameter") << file << unexpected << mustHave;
+ mustHave.clear();
+ unexpected.clear();
+
+ file = QLatin1String("cxx_regression_8.cpp");
+ mustHave << QLatin1String("utils::");
+ unexpected << QLatin1String("utils");
+ QTest::newRow("case 8: namespace completion in function body") << file << unexpected << mustHave;
+ mustHave.clear();
+ unexpected.clear();
+
+ file = QLatin1String("cxx_regression_9.cpp");
+ mustHave << QLatin1String("EnumScoped::Value1");
+ mustHave << QLatin1String("EnumScoped::Value2");
+ mustHave << QLatin1String("EnumScoped::Value3");
+ unexpected << QLatin1String("Value1");
+ unexpected << QLatin1String("EnumScoped");
+ QTest::newRow("case 9: c++11 enum class, value used in switch and 'case' completed")
+ << file << unexpected << mustHave;
+ mustHave.clear();
+ unexpected.clear();
+}
+
+void ClangCodeModelPlugin::test_CXX_snippets()
+{
+ QFETCH(QString, file);
+ QFETCH(QStringList, texts);
+ QFETCH(QStringList, snippets);
+ Q_ASSERT(texts.size() == snippets.size());
+
+ CompletionTestHelper helper;
+ helper << file;
+
+ QList<CodeCompletionResult> proposals = helper.codeComplete();
+
+ for (int i = 0, n = texts.size(); i < n; ++i) {
+ const QString &text = texts[i];
+ const QString &snippet = snippets[i];
+ const QString snippetError =
+ QLatin1String("Text and snippet mismatch: text '") + text
+ + QLatin1String("', snippet '") + snippet
+ + QLatin1String("', got snippet '%1'");
+
+ bool hasText = false;
+ foreach (const CodeCompletionResult &ccr, proposals) {
+ if (ccr.text() != text)
+ continue;
+ hasText = true;
+ QVERIFY2(snippet == ccr.snippet(), snippetError.arg(ccr.snippet()).toAscii());
+ }
+ const QString textError(QLatin1String("Text not found:") + text);
+ QVERIFY2(hasText, textError.toAscii());
+ }
+}
+
+void ClangCodeModelPlugin::test_CXX_snippets_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QStringList>("texts");
+ QTest::addColumn<QStringList>("snippets");
+
+ QString file;
+ QStringList texts;
+ QStringList snippets;
+
+ file = QLatin1String("cxx_snippets_1.cpp");
+ texts << QLatin1String("reinterpret_cast<type>(expression)");
+ snippets << QLatin1String("reinterpret_cast<$type$>($expression$)");
+
+ texts << QLatin1String("static_cast<type>(expression)");
+ snippets << QLatin1String("static_cast<$type$>($expression$)");
+
+ texts << QLatin1String("new type(expressions)");
+ snippets << QLatin1String("new $type$($expressions$)");
+
+ QTest::newRow("case: snippets for var declaration") << file << texts << snippets;
+ texts.clear();
+ snippets.clear();
+
+ file = QLatin1String("cxx_snippets_2.cpp");
+ texts << QLatin1String("private");
+ snippets << QLatin1String("");
+
+ texts << QLatin1String("protected");
+ snippets << QLatin1String("");
+
+ texts << QLatin1String("public");
+ snippets << QLatin1String("");
+
+ texts << QLatin1String("friend");
+ snippets << QLatin1String("");
+
+ texts << QLatin1String("virtual");
+ snippets << QLatin1String("");
+
+ texts << QLatin1String("typedef type name");
+ snippets << QLatin1String("typedef $type$ $name$");
+
+ QTest::newRow("case: snippets inside class declaration") << file << texts << snippets;
+ texts.clear();
+ snippets.clear();
+
+ file = QLatin1String("cxx_snippets_3.cpp");
+ texts << QLatin1String("List");
+ snippets << QLatin1String("List<$class Item$>");
+
+ texts << QLatin1String("Tuple");
+ snippets << QLatin1String("Tuple<$class First$, $class Second$, $typename Third$>");
+
+ QTest::newRow("case: template class insertion as snippet") << file << texts << snippets;
+ texts.clear();
+ snippets.clear();
+
+ file = QLatin1String("cxx_snippets_4.cpp");
+ texts << QLatin1String("clamp");
+ snippets << QLatin1String("");
+
+ texts << QLatin1String("perform");
+ snippets << QLatin1String("perform<$class T$>");
+
+ QTest::newRow("case: template function insertion as snippet") << file << texts << snippets;
+ texts.clear();
+ snippets.clear();
+}
+
+void ClangCodeModelPlugin::test_ObjC_hints()
+{
+ QFETCH(QString, file);
+ QFETCH(QStringList, texts);
+ QFETCH(QStringList, snippets);
+ QFETCH(QStringList, hints);
+ Q_ASSERT(texts.size() == snippets.size());
+ Q_ASSERT(texts.size() == hints.size());
+
+ CompletionTestHelper helper;
+ helper << file;
+
+ QList<CodeCompletionResult> proposals = helper.codeComplete();
+
+ for (int i = 0, n = texts.size(); i < n; ++i) {
+ const QString &text = texts[i];
+ const QString &snippet = snippets[i];
+ const QString &hint = hints[i];
+ const QString snippetError =
+ QLatin1String("Text and snippet mismatch: text '") + text
+ + QLatin1String("', snippet '") + snippet
+ + QLatin1String("', got snippet '%1'");
+ const QString hintError =
+ QLatin1String("Text and hint mismatch: text '") + text
+ + QLatin1String("', hint\n'") + hint
+ + QLatin1String(", got hint\n'%1'");
+
+ bool hasText = false;
+ QStringList texts;
+ foreach (const CodeCompletionResult &ccr, proposals) {
+ texts << ccr.text();
+ if (ccr.text() != text)
+ continue;
+ hasText = true;
+ QVERIFY2(snippet == ccr.snippet(), snippetError.arg(ccr.snippet()).toAscii());
+ QVERIFY2(hint == ccr.hint(), hintError.arg(ccr.hint()).toAscii());
+ }
+ const QString textError(QString::fromLatin1("Text '%1' not found in set %2")
+ .arg(text).arg(texts.join(QLatin1Char(','))));
+ QVERIFY2(hasText, textError.toAscii());
+ }
+}
+
+static QString makeObjCHint(const char *cHintPattern)
+{
+ QString hintPattern(QString::fromUtf8(cHintPattern));
+ QStringList lines = hintPattern.split(QLatin1Char('\n'));
+ QString hint = QLatin1String("<p>");
+ bool prependNewline = false;
+ foreach (const QString &line, lines) {
+ if (prependNewline)
+ hint += QLatin1String("<br/>");
+ prependNewline = true;
+ int i = 0;
+ while (i < line.size() && line[i] == QLatin1Char(' ')) {
+ ++i;
+ hint += QLatin1String("&nbsp;");
+ }
+ hint += line.mid(i);
+ }
+ hint += QLatin1String("</p>");
+ return hint;
+}
+
+void ClangCodeModelPlugin::test_ObjC_hints_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QStringList>("texts");
+ QTest::addColumn<QStringList>("snippets");
+ QTest::addColumn<QStringList>("hints");
+
+ QString file;
+ QStringList texts;
+ QStringList snippets;
+ QStringList hints;
+
+ file = QLatin1String("objc_messages_1.mm");
+ texts << QLatin1String("spectacleQuality:");
+ snippets << QLatin1String("spectacleQuality:$(bool)$");
+ hints << makeObjCHint("-(int) spectacleQuality:<b>(bool)</b>");
+ texts << QLatin1String("desiredAmountForDramaDose:andPersonsCount:");
+ snippets << QLatin1String("desiredAmountForDramaDose:$(int)$ andPersonsCount:$(int)$");
+ hints << makeObjCHint("-(int) desiredAmountForDramaDose:<b>(int)</b> \n"
+ " andPersonsCount:<b>(int)</b>");
+
+ QTest::newRow("case: objective-c instance messages call") << file << texts << snippets << hints;
+ texts.clear();
+ snippets.clear();
+ hints.clear();
+
+ file = QLatin1String("objc_messages_2.mm");
+ texts << QLatin1String("eatenAmount");
+ snippets << QLatin1String("(int) eatenAmount");
+ hints << makeObjCHint("+(int) eatenAmount");
+ texts << QLatin1String("desiredAmountForDramaDose:andPersonsCount:");
+ snippets << QLatin1String("(int) desiredAmountForDramaDose:(int)dose andPersonsCount:(int)count");
+ hints << makeObjCHint("+(int) desiredAmountForDramaDose:(int)dose \n"
+ " andPersonsCount:(int)count");
+
+ QTest::newRow("case: objective-c class messages in @implementation") << file << texts << snippets << hints;
+ texts.clear();
+ snippets.clear();
+ hints.clear();
+
+ file = QLatin1String("objc_messages_3.mm");
+ texts << QLatin1String("eatenAmount");
+ snippets << QLatin1String("(int) eatenAmount");
+ hints << makeObjCHint("-(int) eatenAmount");
+ texts << QLatin1String("spectacleQuality");
+ snippets << QLatin1String("(int) spectacleQuality");
+ hints << makeObjCHint("-(int) spectacleQuality");
+ texts << QLatin1String("desiredAmountForDramaDose:andPersonsCount:");
+ snippets << QLatin1String("(int) desiredAmountForDramaDose:(int)dose andPersonsCount:(int)count");
+ hints << makeObjCHint("-(int) desiredAmountForDramaDose:(int)dose \n"
+ " andPersonsCount:(int)count");
+ texts << QLatin1String("initWithOldTracker:");
+ snippets << QLatin1String("(id) initWithOldTracker:(Bbbb<Aaaa> *)aabb");
+ hints << makeObjCHint("-(id) initWithOldTracker:(Bbbb&lt;Aaaa&gt; *)aabb");
+
+ QTest::newRow("case: objective-c class messages from base class") << file << texts << snippets << hints;
+ texts.clear();
+ snippets.clear();
+ hints.clear();
+}
+
+#endif
diff --git a/src/plugins/clangcodemodel/test/completiontesthelper.cpp b/src/plugins/clangcodemodel/test/completiontesthelper.cpp
new file mode 100644
index 0000000000..16c627301d
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/completiontesthelper.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifdef WITH_TESTS
+
+#include "completiontesthelper.h"
+#include "../clangcompletion.h"
+#include "../clangcompleter.h"
+#include "../clangcodemodelplugin.h"
+
+#include <cpptools/cppcompletionassist.h>
+
+#include <texteditor/basetextdocument.h>
+#include <texteditor/plaintexteditor.h>
+#include <texteditor/codeassist/iassistproposal.h>
+#include <texteditor/codeassist/iassistproposalmodel.h>
+#include <texteditor/codeassist/basicproposalitemlistmodel.h>
+
+#include <utils/fileutils.h>
+#include <utils/changeset.h>
+
+#include <QDir>
+#include <QtTest>
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+using namespace TextEditor;
+using namespace CPlusPlus;
+using namespace CppTools::Internal;
+
+namespace ClangCodeModel {
+namespace Internal {
+
+CompletionTestHelper::CompletionTestHelper(QObject *parent) :
+ QObject(parent),
+ m_completer(new ClangCompleter()),
+ m_position(m_line),
+ m_line(0),
+ m_column(0)
+{
+ m_clangOptions << QLatin1String("-std=c++0x")
+ << QLatin1String("-ObjC++");
+}
+
+CompletionTestHelper::~CompletionTestHelper()
+{
+}
+
+void CompletionTestHelper::operator <<(const QString &fileName)
+{
+ QResource res(QLatin1String(":/unittests/ClangCodeModel/") + fileName);
+ m_sourceCode = QByteArray(reinterpret_cast<const char*>(res.data()), res.size());
+ findCompletionPos();
+
+ QString path = QDir::tempPath() + QLatin1String("/file.h");
+ ::Utils::FileSaver srcSaver(path);
+ srcSaver.write(m_sourceCode);
+ srcSaver.finalize();
+
+ m_completer->setFileName(path);
+ m_completer->setOptions(m_clangOptions);
+}
+
+QStringList CompletionTestHelper::codeCompleteTexts()
+{
+ QList<CodeCompletionResult> results =
+ m_completer->codeCompleteAt(m_line, m_column, m_unsavedFiles);
+
+ QStringList completions;
+ foreach (const CodeCompletionResult& ccr, results)
+ completions << ccr.text();
+ return completions;
+}
+
+QList<CodeCompletionResult> CompletionTestHelper::codeComplete()
+{
+ return m_completer->codeCompleteAt(m_line, m_column, m_unsavedFiles);
+}
+
+int CompletionTestHelper::position() const
+{
+ return m_position;
+}
+
+const QByteArray &CompletionTestHelper::source() const
+{
+ return m_sourceCode;
+}
+
+void CompletionTestHelper::addOption(const QString &option)
+{
+ m_clangOptions << option;
+}
+
+void CompletionTestHelper::findCompletionPos()
+{
+ m_position = m_sourceCode.indexOf("<<<<");
+ QVERIFY(m_position != -1);
+ m_sourceCode[m_position] = ' ';
+ m_sourceCode[m_position + 1] = ' ';
+ m_sourceCode[m_position + 2] = ' ';
+ m_sourceCode[m_position + 3] = ' ';
+
+ // substring from 0 to '@' position
+ QByteArray substr(m_sourceCode.data(), m_position);
+
+ m_line = 1;
+ m_column = 1;
+ for (int i = 0; i < substr.size(); ++i) {
+ if (substr[i] == '\n') {
+ ++m_line;
+ m_column = 1;
+ } else {
+ ++m_column;
+ }
+ }
+}
+
+} // namespace Internal
+} // namespace ClangCodeModel
+
+#endif
diff --git a/src/plugins/clangcodemodel/test/completiontesthelper.h b/src/plugins/clangcodemodel/test/completiontesthelper.h
new file mode 100644
index 0000000000..ebdc60ddec
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/completiontesthelper.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANGCODEMODEL_TESTS_COMPLETIONTESTHELPER_H
+#define CLANGCODEMODEL_TESTS_COMPLETIONTESTHELPER_H
+
+#ifdef WITH_TESTS
+
+#include "../clangcompleter.h"
+
+#include <QObject>
+#include <QTextDocument>
+#include <texteditor/basetexteditor.h>
+#include <cplusplus/CppDocument.h>
+
+namespace TextEditor { class IAssistProposal; }
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class CompletionTestHelper : public QObject
+{
+ Q_OBJECT
+public:
+ explicit CompletionTestHelper(QObject *parent = 0);
+ ~CompletionTestHelper();
+
+ void operator <<(const QString &fileName);
+ QStringList codeCompleteTexts();
+ QList<CodeCompletionResult> codeComplete();
+
+ int position() const;
+ const QByteArray &source() const;
+
+ void addOption(const QString &option);
+
+private:
+ void findCompletionPos();
+
+ UnsavedFiles m_unsavedFiles;
+ ClangCompleter::Ptr m_completer;
+ QStringList m_clangOptions;
+
+ QByteArray m_sourceCode;
+ int m_position;
+ int m_line;
+ int m_column;
+};
+
+} // namespace Internal
+} // namespace ClangCodeModel
+
+#endif
+
+#endif // CLANGCODEMODEL_TESTS_COMPLETIONTESTHELPER_H
diff --git a/src/plugins/clangcodemodel/test/cxx_regression_1.cpp b/src/plugins/clangcodemodel/test/cxx_regression_1.cpp
new file mode 100644
index 0000000000..50b2cfb404
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/cxx_regression_1.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*
+ * Expected: 'sqr'
+ * Not expected: '~Math', 'operator='s
+ */
+
+class Math
+{
+ int sqr(int a);
+};
+
+void foo()
+{
+ Math math;
+ int sqr = math.<<<<;
+}
diff --git a/src/plugins/clangcodemodel/test/cxx_regression_2.cpp b/src/plugins/clangcodemodel/test/cxx_regression_2.cpp
new file mode 100644
index 0000000000..22b9696825
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/cxx_regression_2.cpp
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*
+ * Expected: 'i_first' 'c_first'
+ * Not expected: 'i_second' 'c_second' 'f_second'
+ */
+
+typedef struct {
+ int i_first;
+ char c_first;
+} S1;
+
+typedef struct {
+ int i_second;
+ char c_second;
+ float f_second;
+} S2;
+
+void foo()
+{
+ S1 s;
+ s.<<<<;
+}
diff --git a/src/plugins/clangcodemodel/test/cxx_regression_3.cpp b/src/plugins/clangcodemodel/test/cxx_regression_3.cpp
new file mode 100644
index 0000000000..67016f81ba
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/cxx_regression_3.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*
+ * Expected: 'i8' 'i64'
+ * Unexpected: 'Priv' 'operator='
+ */
+
+class Example
+{
+public:
+ Example();
+ ~Example();
+
+private:
+ class Priv;
+ Priv *d;
+};
+
+class Example::Priv
+{
+public:
+ int i8;
+ int i64;
+
+ Priv() : i8(8), i64(64) {}
+};
+
+Example::Example()
+ : d(new Example::Priv())
+{
+ d-><<<<;
+}
+
+Example::~Example()
+{
+}
+
+void f()
+{
+ Example w;
+}
diff --git a/src/plugins/clangcodemodel/test/cxx_regression_4.cpp b/src/plugins/clangcodemodel/test/cxx_regression_4.cpp
new file mode 100644
index 0000000000..f40fe5efe3
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/cxx_regression_4.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*
+ * Expected: 'action'
+ */
+
+void func()
+{
+ struct impl
+ {
+ static void action() {}
+ };
+ impl::<<<<;
+}
diff --git a/src/plugins/clangcodemodel/test/cxx_regression_5.cpp b/src/plugins/clangcodemodel/test/cxx_regression_5.cpp
new file mode 100644
index 0000000000..2e061617f5
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/cxx_regression_5.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*
+ * Expected: 'doB'
+ * Not expected: 'doA'
+ */
+
+struct A {
+ struct Inside {
+ void doA() {}
+ };
+};
+
+struct B {
+ struct Inside {
+ void doB() {}
+ };
+};
+
+template<class T> class C {
+public:
+ typename T::Inside inner;
+};
+
+int main()
+{
+ C<A> ca;
+ C<B> cb;
+ ca.inner.doA();
+ cb.inner.<<<<;
+
+ return 0;
+}
+
diff --git a/src/plugins/locator/locator_global.h b/src/plugins/clangcodemodel/test/cxx_regression_6.cpp
index 751f7c17b5..61d2ceeb88 100644
--- a/src/plugins/locator/locator_global.h
+++ b/src/plugins/clangcodemodel/test/cxx_regression_6.cpp
@@ -27,15 +27,24 @@
**
****************************************************************************/
-#ifndef LOCATOR_GLOBAL_H
-#define LOCATOR_GLOBAL_H
+/*
+ * Expected: 'OwningPtr'
+ */
-#include <qglobal.h>
+namespace llvm {
+class OwningPtr;
+}
-#if defined(LOCATOR_LIBRARY)
-# define LOCATOR_EXPORT Q_DECL_EXPORT
-#else
-# define LOCATOR_EXPORT Q_DECL_IMPORT
-#endif
+namespace clang {
+using llvm::OwningPtr;
+}
-#endif // LOCATOR_GLOBAL_H
+class llvm::OwningPtr
+{
+};
+
+void foo()
+{
+ clang::<<<< ptr;
+ (void)ptr;
+}
diff --git a/src/plugins/clangcodemodel/test/cxx_regression_7.cpp b/src/plugins/clangcodemodel/test/cxx_regression_7.cpp
new file mode 100644
index 0000000000..79947e182b
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/cxx_regression_7.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*
+ * Expected: 'dataMember', 'anotherMember'
+ */
+
+class Data {
+ int dataMember;
+};
+
+template <class T> class Other : public T
+{
+ int anotherMember;
+};
+
+void func()
+{
+ Other<Data> c;
+ c.<<<<;
+}
diff --git a/src/plugins/clangcodemodel/test/cxx_regression_8.cpp b/src/plugins/clangcodemodel/test/cxx_regression_8.cpp
new file mode 100644
index 0000000000..b697ad4b82
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/cxx_regression_8.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*
+ * Expected: 'utils::'
+ * Not expected: 'utils'
+ */
+
+namespace utils
+{
+int sqr(int a)
+{
+ return a * a;
+}
+}
+
+void foo()
+{
+ <<<<
+}
diff --git a/src/plugins/clangcodemodel/test/cxx_regression_9.cpp b/src/plugins/clangcodemodel/test/cxx_regression_9.cpp
new file mode 100644
index 0000000000..844cc1917b
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/cxx_regression_9.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*
+ * Expected: 'EnumScoped::Value1', 'EnumScoped::Value2', 'EnumScoped::Value3'
+ * Unexpected: 'Value1'
+ */
+
+enum class EnumScoped
+{
+ Value1,
+ Value2,
+ Value3
+};
+
+class ClassOwnsEnum
+{
+};
+
+int main()
+{
+ EnumScoped scoped = ;
+ switch (scoped) {
+ default:
+ break;
+ case <<<<
+ }
+}
diff --git a/src/plugins/clangcodemodel/test/cxx_snippets_1.cpp b/src/plugins/clangcodemodel/test/cxx_snippets_1.cpp
new file mode 100644
index 0000000000..03c592bb18
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/cxx_snippets_1.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*
+ Expected:
+ text 'reinterpret_cast<type>(expression)'
+ snippet 'reinterpret_cast<$type$>($expression$)'
+
+ text 'static_cast<type>(expression)'
+ snippet 'static_cast<$type$>($expression$)'
+
+ text 'new type(expressions)'
+ snippet 'new $type$($expressions$)'
+ */
+
+void foo()
+{
+ int data[] = {
+ 1, 2, 3
+ };
+ char *cdata = <<<<;
+}
diff --git a/src/plugins/clangcodemodel/test/cxx_snippets_2.cpp b/src/plugins/clangcodemodel/test/cxx_snippets_2.cpp
new file mode 100644
index 0000000000..7176827d82
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/cxx_snippets_2.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*
+ Expected:
+ text 'private',
+ text 'protected',
+ text 'public',
+ text 'friend',
+ text 'virtual'
+
+ text 'typedef type name', snippet 'typedef $type$ $name$'
+ */
+
+class A
+{
+ <<<<
+};
diff --git a/src/plugins/clangcodemodel/test/cxx_snippets_3.cpp b/src/plugins/clangcodemodel/test/cxx_snippets_3.cpp
new file mode 100644
index 0000000000..0f702523e1
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/cxx_snippets_3.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+// Expected:
+// (List, List<$class Item$>),
+// (Tuple, Tuple<$class First$, $class Second$, $typename Third$>)
+
+template <class Item>
+class List
+{
+ Item *data;
+};
+
+template <class First, class Second, typename Third>
+class Tuple
+{
+ First *data;
+ Second *data2;
+ Third *data3;
+};
+
+void check()
+{
+ <<<<
+}
+
diff --git a/src/plugins/qmldesigner/components/propertyeditor/qlayoutobject.h b/src/plugins/clangcodemodel/test/cxx_snippets_4.cpp
index 46da9bb5e1..39a95b1a36 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/qlayoutobject.h
+++ b/src/plugins/clangcodemodel/test/cxx_snippets_4.cpp
@@ -27,30 +27,34 @@
**
****************************************************************************/
-#ifndef QLAYOUTOBJECT_H
-#define QLAYOUTOBJECT_H
+// Expected:
+// (clamp, ),
+// (perform, perform<$class T$>)
+// (perform3, perform3<$class T$, $int E$, $class D$>)
-#include <QObject>
-#include <QLayout>
-#include <qdeclarative.h>
+// note: clang understands if parameter is redundant
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QLayoutObject : public QObject
+template<class T>
+T clamp(T value, T a = 0.0, T b = 1.0)
{
-Q_OBJECT
-public:
- QLayoutObject(QObject *parent = 0);
-
- virtual QLayout *layout() const;
-
- static void registerDeclarativeType();
-};
-
-QT_END_NAMESPACE
+ if (value < a)
+ return a;
+ if (value > b)
+ return b;
+ return value;
+}
+
+template<class T>
+void perform()
+{
+}
-QML_DECLARE_TYPE(QLayoutObject)
+template<class T, int E, class D>
+void perform3()
+{
+}
-#endif // QLAYOUTOBJECT_H
+void check()
+{
+ <<<<
+}
diff --git a/src/plugins/clangcodemodel/test/objc_messages_1.mm b/src/plugins/clangcodemodel/test/objc_messages_1.mm
new file mode 100644
index 0000000000..bbb7804c86
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/objc_messages_1.mm
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*
+ * Expected texts:
+ * eatenAmount
+ * spectacleQuality:
+ * desiredAmountForDramaDose:andPersonsCount:
+ *
+ * Expected hints:
+ * -(int) eatenAmount
+ *
+ * -(int) spectacleQuality:(bool)unused
+ */
+
+@interface PopCornTracker {
+ int _quality;
+ int _eatenAmount;
+ int _remainedAmount;
+}
++ (int) eatenAmount;
+- (int) spectacleQuality : (bool)unused;
+- (int) desiredAmountForDramaDose: (int)dose andPersonsCount: (int) count;
+@end
+
+@implementation PopCornTracker
+- (int) desiredAmountForDramaDose: (int)dose andPersonsCount: (int) count
+{
+ [self <<<<];
+}
+@end
diff --git a/src/plugins/clangcodemodel/test/objc_messages_2.mm b/src/plugins/clangcodemodel/test/objc_messages_2.mm
new file mode 100644
index 0000000000..e2db928bb3
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/objc_messages_2.mm
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+@interface PopCornTracker {
+ int _quality;
+ int _eatenAmount;
+ int _remainedAmount;
+}
++ (int) eatenAmount;
+- (int) spectacleQuality;
++ (int) desiredAmountForDramaDose: (int)dose andPersonsCount: (int) count;
+@end
+
+@implementation PopCornTracker
++ <<<<
+@end
diff --git a/src/plugins/clangcodemodel/test/objc_messages_3.mm b/src/plugins/clangcodemodel/test/objc_messages_3.mm
new file mode 100644
index 0000000000..82a8a7e2c8
--- /dev/null
+++ b/src/plugins/clangcodemodel/test/objc_messages_3.mm
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+@protocol Aaaa
+@end
+
+@interface Bbbb
+@end
+
+@interface PopCornTracker {
+ int _quality;
+ int _eatenAmount;
+ int _remainedAmount;
+}
+- (int) eatenAmount;
+- (int) spectacleQuality;
+- (int) desiredAmountForDramaDose: (int)dose andPersonsCount: (int) count;
++ (id) createNewTracker;
++ (id) createOldTracker:(Bbbb<Aaaa> *) aabb;
+- (id) initWithOldTracker:(Bbbb<Aaaa> *) aabb;
+@end
+
+@interface AdvancedPopCornTracker : PopCornTracker {
+}
+
+- <<<<
+
+@end
diff --git a/src/plugins/clangcodemodel/unit.cpp b/src/plugins/clangcodemodel/unit.cpp
new file mode 100644
index 0000000000..f9423465b7
--- /dev/null
+++ b/src/plugins/clangcodemodel/unit.cpp
@@ -0,0 +1,357 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "unit.h"
+#include "unsavedfiledata.h"
+#include "utils_p.h"
+
+#include <clang-c/Index.h>
+
+#include <QtCore/QByteArray>
+#include <QtCore/QVector>
+#include <QtCore/QSharedData>
+#include <QtAlgorithms>
+
+#ifdef DEBUG_UNIT_COUNT
+# include <QAtomicInt>
+# include <QDebug>
+static QBasicAtomicInt unitDataCount = Q_BASIC_ATOMIC_INITIALIZER(0);
+#endif // DEBUG_UNIT_COUNT
+
+using namespace ClangCodeModel;
+using namespace ClangCodeModel::Internal;
+
+static const int DisplayDiagnostics = qgetenv("QTC_CLANG_VERBOSE").isEmpty() ? 0 : 1;
+
+Unit::Unit()
+ : m_index(0)
+ , m_tu(0)
+ , m_managementOptions(0)
+{}
+
+Unit::Unit(const QString &fileName)
+ : m_index(clang_createIndex(/*excludeDeclsFromPCH*/ 1, DisplayDiagnostics))
+ , m_tu(0)
+ , m_fileName(fileName.toUtf8())
+ , m_managementOptions(0)
+{}
+
+Unit::~Unit()
+{
+ unload();
+ clang_disposeIndex(m_index);
+ m_index = 0;
+}
+
+Unit::Ptr Unit::create()
+{
+ return Unit::Ptr(new Unit);
+}
+
+Unit::Ptr Unit::create(const QString &fileName)
+{
+ return Unit::Ptr(new Unit(fileName));
+}
+
+const QString Unit::fileName() const
+{
+ return QString::fromUtf8(m_fileName.data(), m_fileName.size());
+}
+
+bool Unit::isLoaded() const
+{
+ return m_tu && m_index;
+}
+
+const QDateTime &Unit::timeStamp() const
+{
+ return m_timeStamp;
+}
+
+QStringList Unit::compilationOptions() const
+{
+ return m_compOptions;
+}
+
+void Unit::setCompilationOptions(const QStringList &compOptions)
+{
+ m_compOptions = compOptions;
+ m_sharedCompOptions.reloadOptions(compOptions);
+}
+
+UnsavedFiles Unit::unsavedFiles() const
+{
+ return m_unsaved;
+}
+
+void Unit::setUnsavedFiles(const UnsavedFiles &unsavedFiles)
+{
+ m_unsaved = unsavedFiles;
+}
+
+unsigned Unit::managementOptions() const
+{
+ return m_managementOptions;
+}
+
+void Unit::setManagementOptions(unsigned managementOptions)
+{
+ m_managementOptions = managementOptions;
+}
+
+void Unit::parse()
+{
+ unload();
+
+ updateTimeStamp();
+
+ UnsavedFileData unsaved(m_unsaved);
+ m_tu = clang_parseTranslationUnit(m_index, m_fileName.constData(),
+ m_sharedCompOptions.data(), m_sharedCompOptions.size(),
+ unsaved.files(), unsaved.count(),
+ m_managementOptions);
+}
+
+void Unit::reparse()
+{
+ Q_ASSERT(isLoaded());
+
+ UnsavedFileData unsaved(m_unsaved);
+ const unsigned opts = clang_defaultReparseOptions(m_tu);
+ if (clang_reparseTranslationUnit(m_tu, unsaved.count(), unsaved.files(), opts) != 0)
+ unload();
+}
+
+int Unit::save(const QString &unitFileName)
+{
+ Q_ASSERT(isLoaded());
+
+ return clang_saveTranslationUnit(m_tu, unitFileName.toUtf8().constData(),
+ clang_defaultSaveOptions(m_tu));
+}
+
+void Unit::unload()
+{
+ if (m_tu) {
+ clang_disposeTranslationUnit(m_tu);
+ m_tu = 0;
+
+#ifdef DEBUG_UNIT_COUNT
+ qDebug() << "# translation units:" << (unitDataCount.fetchAndAddOrdered(-1) - 1);
+#endif // DEBUG_UNIT_COUNT
+ }
+}
+
+CXFile Unit::getFile() const
+{
+ Q_ASSERT(isLoaded());
+
+ return clang_getFile(m_tu, m_fileName.constData());
+}
+
+CXCursor Unit::getCursor(const CXSourceLocation &location) const
+{
+ Q_ASSERT(isLoaded());
+
+ return clang_getCursor(m_tu, location);
+}
+
+CXSourceLocation Unit::getLocation(const CXFile &file, unsigned line, unsigned column) const
+{
+ Q_ASSERT(isLoaded());
+
+ return clang_getLocation(m_tu, file, line, column);
+}
+
+void Unit::codeCompleteAt(unsigned line, unsigned column, ScopedCXCodeCompleteResults &results)
+{
+ unsigned flags = clang_defaultCodeCompleteOptions();
+#if defined(CINDEX_VERSION) && (CINDEX_VERSION > 5)
+ flags |= CXCodeComplete_IncludeBriefComments;
+#endif
+
+ UnsavedFileData unsaved(m_unsaved);
+ results.reset(clang_codeCompleteAt(m_tu, m_fileName.constData(),
+ line, column,
+ unsaved.files(), unsaved.count(),
+ flags));
+}
+
+void Unit::tokenize(CXSourceRange range, CXToken **tokens, unsigned *tokenCount) const
+{
+ Q_ASSERT(isLoaded());
+ Q_ASSERT(tokens);
+ Q_ASSERT(tokenCount);
+ Q_ASSERT(!clang_Range_isNull(range));
+
+ clang_tokenize(m_tu, range, tokens, tokenCount);
+}
+
+void Unit::disposeTokens(CXToken *tokens, unsigned tokenCount) const
+{
+ Q_ASSERT(isLoaded());
+
+ clang_disposeTokens(m_tu, tokens, tokenCount);
+}
+
+CXSourceRange Unit::getTokenExtent(const CXToken &token) const
+{
+ Q_ASSERT(isLoaded());
+
+ return clang_getTokenExtent(m_tu, token);
+}
+
+void Unit::annotateTokens(CXToken *tokens, unsigned tokenCount, CXCursor *cursors) const
+{
+ Q_ASSERT(isLoaded());
+ Q_ASSERT(tokens);
+ Q_ASSERT(cursors);
+
+ clang_annotateTokens(m_tu, tokens, tokenCount, cursors);
+}
+
+CXTranslationUnit Unit::clangTranslationUnit() const
+{
+ Q_ASSERT(isLoaded());
+
+ return m_tu;
+}
+
+CXIndex Unit::clangIndex() const
+{
+ Q_ASSERT(isLoaded());
+
+ return m_index;
+}
+
+QString Unit::getTokenSpelling(const CXToken &tok) const
+{
+ Q_ASSERT(isLoaded());
+
+ return getQString(clang_getTokenSpelling(m_tu, tok));
+}
+
+CXCursor Unit::getTranslationUnitCursor() const
+{
+ Q_ASSERT(isLoaded());
+
+ return clang_getTranslationUnitCursor(m_tu);
+}
+
+CXString Unit::getTranslationUnitSpelling() const
+{
+ Q_ASSERT(isLoaded());
+
+ return clang_getTranslationUnitSpelling(m_tu);
+}
+
+void Unit::getInclusions(CXInclusionVisitor visitor, CXClientData clientData) const
+{
+ Q_ASSERT(isLoaded());
+
+ clang_getInclusions(m_tu, visitor, clientData);
+}
+
+unsigned Unit::getNumDiagnostics() const
+{
+ Q_ASSERT(isLoaded());
+
+ return clang_getNumDiagnostics(m_tu);
+}
+
+CXDiagnostic Unit::getDiagnostic(unsigned index) const
+{
+ Q_ASSERT(isLoaded());
+
+ return clang_getDiagnostic(m_tu, index);
+}
+
+void Unit::updateTimeStamp()
+{
+ m_timeStamp = QDateTime::currentDateTime();
+}
+
+IdentifierTokens::IdentifierTokens(const Unit &unit, unsigned firstLine, unsigned lastLine)
+ : m_unit(unit)
+ , m_tokenCount(0)
+ , m_tokens(0)
+ , m_cursors(0)
+ , m_extents(0)
+{
+ Q_ASSERT(unit.isLoaded());
+
+ // Calculate the range:
+ CXFile file = unit.getFile();
+ CXSourceLocation startLocation = unit.getLocation(file, firstLine, 1);
+ CXSourceLocation endLocation = unit.getLocation(file, lastLine, 1);
+ CXSourceRange range = clang_getRange(startLocation, endLocation);
+
+ // Retrieve all identifier tokens:
+ unit.tokenize(range, &m_tokens, &m_tokenCount);
+ if (m_tokenCount == 0)
+ return;
+
+ // Get the cursors for the tokens:
+ m_cursors = new CXCursor[m_tokenCount];
+ unit.annotateTokens(m_tokens,
+ m_tokenCount,
+ m_cursors);
+
+ m_extents = new CXSourceRange[m_tokenCount];
+ // Create the markers using the cursor to check the types:
+ for (unsigned i = 0; i < m_tokenCount; ++i)
+ m_extents[i] = unit.getTokenExtent(m_tokens[i]);
+}
+
+IdentifierTokens::~IdentifierTokens()
+{
+ dispose();
+}
+
+void IdentifierTokens::dispose()
+{
+ if (!m_unit.isLoaded())
+ return;
+
+ if (m_tokenCount && m_tokens) {
+ m_unit.disposeTokens(m_tokens, m_tokenCount);
+ m_tokens = 0;
+ m_tokenCount = 0;
+ }
+
+ if (m_cursors) {
+ delete[] m_cursors;
+ m_cursors = 0;
+ }
+
+ if (m_extents) {
+ delete[] m_extents;
+ m_extents = 0;
+ }
+}
diff --git a/src/plugins/clangcodemodel/unit.h b/src/plugins/clangcodemodel/unit.h
new file mode 100644
index 0000000000..7326040128
--- /dev/null
+++ b/src/plugins/clangcodemodel/unit.h
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef UNIT_H
+#define UNIT_H
+
+#include "utils.h"
+#include "raii/scopedclangoptions.h"
+#include "cxraii.h"
+
+#include <QtCore/QDateTime>
+#include <QSharedPointer>
+#include <QMetaType>
+#include <QString>
+#include <QStringList>
+#include <QVarLengthArray>
+
+QT_BEGIN_NAMESPACE
+class QDateTime;
+QT_END_NAMESPACE
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class UnitData;
+
+/*
+ * This is a minimal wrapper around clang's translation unit functionality.
+ * It should should contain only the very basic primitives which allow other
+ * components such as code completion, code navigation, and others to access
+ * data which directly depends on the translation unit.
+ *
+ * In other words, what's wrapped here is only the functions that receive a
+ * CXTranslationUnit as a parameter. And this class itself is then the corresponding
+ * abstraction of the CXTranslationUnit.
+ *
+ * Notes:
+ * - This class is not thread-safe.
+ * - It's responsibility of the client to make sure that the wrapped translation
+ * unit is consistent with the other data such as cursor and locations being used.
+ *
+ * @TODO: This is similar but not exactly the same as the current ClangWrapper class.
+ * That class is now tuned to specific features, so it's not generic enough to be used
+ * an underlying component and aslo don't provide the data in a fine granularity as
+ * needed here. At some point we should split ClangWrapper into its different logical
+ * components and use this is the underlying structure.
+ */
+class Unit
+{
+ Q_DISABLE_COPY(Unit)
+
+ Unit();
+ explicit Unit(const QString &fileName);
+
+public:
+ ~Unit();
+
+ typedef QSharedPointer<Unit> Ptr;
+ static Ptr create();
+ static Ptr create(const QString &fileName);
+
+ bool isLoaded() const;
+
+ const QString fileName() const;
+
+ const QDateTime &timeStamp() const;
+
+ QStringList compilationOptions() const;
+ void setCompilationOptions(const QStringList &compOptions);
+
+ UnsavedFiles unsavedFiles() const;
+ void setUnsavedFiles(const UnsavedFiles &unsavedFiles);
+
+ unsigned managementOptions() const;
+ void setManagementOptions(unsigned managementOptions);
+
+ // Methods for generating the TU. Name mappings are direct, for example:
+ // - parse corresponds to clang_parseTranslationUnit
+ // - createFromSourceFile corresponds to clang_createTranslationUnitFromSourceFile
+ void parse();
+ void reparse();
+ int save(const QString &unitFileName);
+ void unload();
+
+ // Simple forwarding methods, separated by clang categories for convenience.
+ // As above, the names are directly mapped. Separated by categories as clang for convenience.
+ // Note that only methods that take the TU as a parameter should be wrapped.
+
+ // - Diagnostic reporting
+ unsigned getNumDiagnostics() const;
+ CXDiagnostic getDiagnostic(unsigned index) const;
+
+ // - Translation unit manipulation
+ CXString getTranslationUnitSpelling() const;
+
+ // - File manipulation routines
+ CXFile getFile() const;
+
+ // - Mapping between cursors and source code
+ CXCursor getCursor(const CXSourceLocation &location) const;
+
+ // - Miscellaneous utility functions
+ void getInclusions(CXInclusionVisitor visitor, CXClientData clientData) const;
+
+ // - Cursor manipulations
+ CXCursor getTranslationUnitCursor() const;
+
+ // - Physical source locations
+ CXSourceLocation getLocation(const CXFile &file, unsigned line, unsigned column) const;
+
+ void codeCompleteAt(unsigned line, unsigned column, ScopedCXCodeCompleteResults &results);
+
+ void tokenize(CXSourceRange range, CXToken **tokens, unsigned *tokenCount) const;
+ void disposeTokens(CXToken *tokens, unsigned tokenCount) const;
+ CXSourceRange getTokenExtent(const CXToken &token) const;
+ void annotateTokens(CXToken *tokens, unsigned tokenCount, CXCursor *cursors) const;
+
+ CXTranslationUnit clangTranslationUnit() const;
+ CXIndex clangIndex() const;
+
+ QString getTokenSpelling(const CXToken &tok) const;
+
+private:
+ void updateTimeStamp();
+
+ CXIndex m_index;
+ CXTranslationUnit m_tu;
+ QByteArray m_fileName;
+ QStringList m_compOptions;
+ SharedClangOptions m_sharedCompOptions;
+ unsigned m_managementOptions;
+ UnsavedFiles m_unsaved;
+ QDateTime m_timeStamp;
+};
+
+class IdentifierTokens
+{
+ Q_DISABLE_COPY(IdentifierTokens)
+
+public:
+ IdentifierTokens(const Unit &m_unit, unsigned firstLine, unsigned lastLine);
+ ~IdentifierTokens();
+
+ unsigned count() const
+ { return m_tokenCount; }
+
+ const CXToken &token(unsigned nr) const
+ { Q_ASSERT(nr < count()); return m_tokens[nr]; }
+
+ const CXCursor &cursor(unsigned nr) const
+ { Q_ASSERT(nr < count()); return m_cursors[nr]; }
+
+ const CXSourceRange &extent(unsigned nr) const
+ { Q_ASSERT(nr < count()); return m_extents[nr]; }
+
+private:
+ void dispose();
+
+private:
+ const Unit &m_unit;
+ unsigned m_tokenCount;
+ CXToken *m_tokens;
+
+ CXCursor *m_cursors;
+ CXSourceRange *m_extents;
+};
+
+} // Internal
+} // Clang
+
+Q_DECLARE_METATYPE(ClangCodeModel::Internal::Unit::Ptr)
+
+#endif // UNIT_H
diff --git a/src/plugins/clangcodemodel/unsavedfiledata.cpp b/src/plugins/clangcodemodel/unsavedfiledata.cpp
new file mode 100644
index 0000000000..d0dbdf7f3e
--- /dev/null
+++ b/src/plugins/clangcodemodel/unsavedfiledata.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "unsavedfiledata.h"
+
+using namespace ClangCodeModel::Internal;
+
+UnsavedFileData::UnsavedFileData(const UnsavedFiles &unsavedFiles)
+ : m_count(unsavedFiles.count())
+ , m_files(0)
+{
+ if (m_count) {
+ m_files = new CXUnsavedFile[m_count];
+ unsigned idx = 0;
+ for (UnsavedFiles::const_iterator it = unsavedFiles.begin(); it != unsavedFiles.end(); ++it, ++idx) {
+ QByteArray contents = it.value();
+ const char *contentChars = qstrdup(contents.constData());
+ m_files[idx].Contents = contentChars;
+ m_files[idx].Length = contents.size();
+
+ const char *fileName = qstrdup(it.key().toUtf8().constData());
+ m_files[idx].Filename = fileName;
+ }
+ }
+}
+
+UnsavedFileData::~UnsavedFileData()
+{
+ for (unsigned i = 0; i < m_count; ++i) {
+ delete[] m_files[i].Contents;
+ delete[] m_files[i].Filename;
+ }
+
+ delete[] m_files;
+}
diff --git a/src/plugins/clangcodemodel/unsavedfiledata.h b/src/plugins/clangcodemodel/unsavedfiledata.h
new file mode 100644
index 0000000000..52b38bf031
--- /dev/null
+++ b/src/plugins/clangcodemodel/unsavedfiledata.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANG_INTERNAL_UNSAVEDFILEDATA_H
+#define CLANG_INTERNAL_UNSAVEDFILEDATA_H
+
+#include "utils.h"
+
+#include <clang-c/Index.h>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+class UnsavedFileData
+{
+ UnsavedFileData(const UnsavedFileData &);
+ UnsavedFileData &operator=(const UnsavedFileData &);
+
+ typedef ClangCodeModel::Internal::UnsavedFiles UnsavedFiles;
+
+public:
+ UnsavedFileData(const UnsavedFiles &unsavedFiles);
+ ~UnsavedFileData();
+
+ unsigned count() const
+ { return m_count; }
+
+ CXUnsavedFile *files() const
+ { return m_files; }
+
+private:
+ unsigned m_count;
+ CXUnsavedFile *m_files;
+};
+
+} // namespace Internal
+} // namespace ClangCodeModel
+
+#endif // CLANG_INTERNAL_UNSAVEDFILEDATA_H
diff --git a/src/plugins/clangcodemodel/utils.cpp b/src/plugins/clangcodemodel/utils.cpp
new file mode 100644
index 0000000000..6b2872718e
--- /dev/null
+++ b/src/plugins/clangcodemodel/utils.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "diagnostic.h"
+#include "unit.h"
+#include "utils.h"
+#include "utils_p.h"
+
+#include <clang-c/Index.h>
+
+#include <QMutex>
+#include <QMutexLocker>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+QPair<bool, QStringList> precompile(const PchInfo::Ptr &pchInfo)
+{
+// qDebug() << "*** Precompiling" << pchInfo->inputFileName()
+// << "into" << pchInfo->fileName()
+// << "with options" << pchInfo->options();
+
+ bool ok = false;
+
+ Internal::Unit::Ptr unit = Internal::Unit::create(pchInfo->inputFileName());
+ unit->setCompilationOptions(pchInfo->options());
+
+ unsigned parseOpts = CXTranslationUnit_ForSerialization
+ | CXTranslationUnit_Incomplete;
+ unit->setManagementOptions(parseOpts);
+
+ unit->parse();
+ if (unit->isLoaded())
+ ok = CXSaveError_None == unit->save(pchInfo->fileName());
+
+ return qMakePair(ok, Internal::formattedDiagnostics(unit));
+}
+
+namespace {
+static bool clangInitialised = false;
+static QMutex initialisationMutex;
+} // anonymous namespace
+
+void initializeClang()
+{
+ if (clangInitialised)
+ return;
+
+ QMutexLocker locker(&initialisationMutex);
+ if (clangInitialised)
+ return;
+
+ clang_toggleCrashRecovery(1);
+ clang_enableStackTraces();
+ clangInitialised = true;
+
+ qRegisterMetaType<ClangCodeModel::Diagnostic>();
+ qRegisterMetaType<QList<ClangCodeModel::Diagnostic> >();
+}
+
+} // Internal namespace
+} // ClangCodeModel namespace
+
diff --git a/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.h b/src/plugins/clangcodemodel/utils.h
index ac7f863220..d1a8abb4a0 100644
--- a/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.h
+++ b/src/plugins/clangcodemodel/utils.h
@@ -27,50 +27,39 @@
**
****************************************************************************/
-#ifndef QMLPROFILERCANVAS_H
-#define QMLPROFILERCANVAS_H
+#ifndef UTILS_H
+#define UTILS_H
-#include <QQuickPaintedItem>
-#include <QTimer>
-#include <QMutex>
+#include "pchinfo.h"
-QT_BEGIN_NAMESPACE
-class Context2D;
-QT_END_NAMESPACE
+#include <QString>
+#include <QStringList>
+#include <QByteArray>
+#include <QMap>
+#include <QPair>
-namespace QmlProfiler {
+/*
+ * A header for globally visible typedefs. This is particularly useful
+ * so we don't have to #include files simply because of a typedef. Still,
+ * not every typedef should go in here, only the minimal subset of the
+ * ones which are needed quite often.
+ */
+namespace ClangCodeModel {
namespace Internal {
-class QmlProfilerCanvas : public QQuickPaintedItem
-{
- Q_OBJECT
+typedef QMap<QString, QByteArray> UnsavedFiles;
-public:
- QmlProfilerCanvas();
+/**
+ * Utility method to create a PCH file from a header file.
+ *
+ * \returns a boolean indicating success (true) or failure (false), and a
+ * list of diagnostic messages.
+ */
+QPair<bool, QStringList> precompile(const PchInfo::Ptr &pchInfo);
-signals:
- void drawRegion(Context2D *ctxt, const QRect &region);
+void initializeClang();
-public slots:
- void requestPaint();
- void requestRedraw();
+} // Internal namespace
+} // ClangCodeModel namespace
-private slots:
- void draw();
-
-protected:
- virtual void paint(QPainter *);
- virtual void componentComplete();
- virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
-
-private:
- Context2D *m_context2d;
-
- QTimer m_drawTimer;
- QMutex m_pixmapMutex;
-};
-
-}
-}
-
-#endif // QMLPROFILERCANVAS_H
+#endif // UTILS_H
diff --git a/src/plugins/clangcodemodel/utils_p.cpp b/src/plugins/clangcodemodel/utils_p.cpp
new file mode 100644
index 0000000000..c9658d9f38
--- /dev/null
+++ b/src/plugins/clangcodemodel/utils_p.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "unit.h"
+#include "utils_p.h"
+
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+
+namespace ClangCodeModel {
+namespace Internal {
+
+QString getQString(const CXString &cxString, bool disposeCXString)
+{
+ QString s = QString::fromUtf8(clang_getCString(cxString));
+ if (disposeCXString)
+ clang_disposeString(cxString);
+ return s;
+}
+
+namespace {
+
+SourceLocation getLocation(const CXSourceLocation &loc,
+ void (*clangFunction)(CXSourceLocation,
+ CXFile *,
+ unsigned *,
+ unsigned *,
+ unsigned *))
+{
+ CXFile file;
+ unsigned line, column, offset;
+ (*clangFunction)(loc, &file, &line, &column, &offset);
+ return SourceLocation(normalizeFileName(getQString(clang_getFileName(file))),
+ line,
+ column,
+ offset);
+}
+
+} // Anonymous
+
+SourceLocation getInstantiationLocation(const CXSourceLocation &loc)
+{
+ return getLocation(loc, &clang_getInstantiationLocation);
+}
+
+SourceLocation getSpellingLocation(const CXSourceLocation &loc)
+{
+ return getLocation(loc, &clang_getSpellingLocation);
+}
+
+SourceLocation getExpansionLocation(const CXSourceLocation &loc)
+{
+// return getLocation(loc, &clang_getExpansionLocation);
+ return getLocation(loc, &clang_getInstantiationLocation);
+}
+
+QString normalizeFileName(const QString &fileName)
+{
+ if (fileName.isEmpty())
+ return fileName;
+
+ return normalizeFileName(QFileInfo(fileName));
+}
+
+QString normalizeFileName(const QFileInfo &fileInfo)
+{
+ if (!fileInfo.isFile())
+ return QString();
+
+ return QDir::cleanPath(fileInfo.absoluteFilePath());
+}
+
+QStringList formattedDiagnostics(const Unit::Ptr &unit)
+{
+ QStringList diags;
+ if (!unit->isLoaded())
+ return diags;
+
+ const unsigned count = unit->getNumDiagnostics();
+ for (unsigned i = 0; i < count; ++i) {
+ CXDiagnostic diag = unit->getDiagnostic(i);
+
+ unsigned opt = CXDiagnostic_DisplaySourceLocation
+ | CXDiagnostic_DisplayColumn
+ | CXDiagnostic_DisplaySourceRanges
+ | CXDiagnostic_DisplayOption
+ | CXDiagnostic_DisplayCategoryId
+ | CXDiagnostic_DisplayCategoryName
+ ;
+ diags << getQString(clang_formatDiagnostic(diag, opt));
+ clang_disposeDiagnostic(diag);
+ }
+
+ return diags;
+}
+
+} // Internal
+} // ClangCodeModel
diff --git a/src/plugins/clangcodemodel/utils_p.h b/src/plugins/clangcodemodel/utils_p.h
new file mode 100644
index 0000000000..d352d4a484
--- /dev/null
+++ b/src/plugins/clangcodemodel/utils_p.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CLANG_REUSE_H
+#define CLANG_REUSE_H
+
+#include "sourcelocation.h"
+#include "unit.h"
+
+#include <clang-c/Index.h>
+
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+class QFileInfo;
+QT_END_NAMESPACE
+
+namespace ClangCodeModel {
+namespace Internal {
+
+QString getQString(const CXString &cxString, bool disposeCXString = true);
+
+SourceLocation getInstantiatonLocation(const CXSourceLocation &loc); // Deprecated
+SourceLocation getSpellingLocation(const CXSourceLocation &loc);
+SourceLocation getExpansionLocation(const CXSourceLocation &loc);
+
+// There are slight differences of behavior from apparently similar Qt file processing functions.
+// For instance, QFileInfo::absoluteFilePath will uppercase driver letters, while the corresponding
+// QDir function will not do so. Besides, we need to keep paths clean. So in order to avoid
+// inconsistencies the functions below should be used for any indexing related task.
+QString normalizeFileName(const QString &fileName);
+QString normalizeFileName(const QFileInfo &fileInfo);
+
+QStringList formattedDiagnostics(const Unit::Ptr &unit);
+
+} // Internal
+} // ClangCodeModel
+
+#endif // CLANG_REUSE_H
diff --git a/src/plugins/classview/classview.pro b/src/plugins/classview/classview.pro
index 86352ed98f..a2c22df521 100644
--- a/src/plugins/classview/classview.pro
+++ b/src/plugins/classview/classview.pro
@@ -1,29 +1,29 @@
include(../../qtcreatorplugin.pri)
HEADERS += \
- classviewplugin.h \
- classviewnavigationwidgetfactory.h \
classviewconstants.h \
+ classviewmanager.h \
classviewnavigationwidget.h \
+ classviewnavigationwidgetfactory.h \
classviewparser.h \
- classviewmanager.h \
- classviewsymbollocation.h \
- classviewsymbolinformation.h \
classviewparsertreeitem.h \
- classviewutils.h \
- classviewtreeitemmodel.h
+ classviewplugin.h \
+ classviewsymbolinformation.h \
+ classviewsymbollocation.h \
+ classviewtreeitemmodel.h \
+ classviewutils.h
SOURCES += \
- classviewplugin.cpp \
- classviewnavigationwidgetfactory.cpp \
+ classviewmanager.cpp \
classviewnavigationwidget.cpp \
+ classviewnavigationwidgetfactory.cpp \
classviewparser.cpp \
- classviewmanager.cpp \
- classviewsymbollocation.cpp \
- classviewsymbolinformation.cpp \
classviewparsertreeitem.cpp \
- classviewutils.cpp \
- classviewtreeitemmodel.cpp
+ classviewplugin.cpp \
+ classviewsymbolinformation.cpp \
+ classviewsymbollocation.cpp \
+ classviewtreeitemmodel.cpp \
+ classviewutils.cpp
FORMS += \
classviewnavigationwidget.ui
diff --git a/src/plugins/classview/classview.qbs b/src/plugins/classview/classview.qbs
index a3699245d0..a80e8837ce 100644
--- a/src/plugins/classview/classview.qbs
+++ b/src/plugins/classview/classview.qbs
@@ -12,31 +12,19 @@ QtcPlugin {
Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" }
-
files: [
"classview.qrc",
"classviewconstants.h",
- "classviewmanager.cpp",
- "classviewmanager.h",
- "classviewnavigationwidget.cpp",
- "classviewnavigationwidget.h",
- "classviewnavigationwidget.ui",
- "classviewnavigationwidgetfactory.cpp",
- "classviewnavigationwidgetfactory.h",
- "classviewparser.cpp",
- "classviewparser.h",
- "classviewparsertreeitem.cpp",
- "classviewparsertreeitem.h",
- "classviewplugin.cpp",
- "classviewplugin.h",
- "classviewsymbolinformation.cpp",
- "classviewsymbolinformation.h",
- "classviewsymbollocation.cpp",
- "classviewsymbollocation.h",
- "classviewtreeitemmodel.cpp",
- "classviewtreeitemmodel.h",
- "classviewutils.cpp",
- "classviewutils.h",
+ "classviewmanager.cpp", "classviewmanager.h",
+ "classviewnavigationwidget.cpp", "classviewnavigationwidget.h", "classviewnavigationwidget.ui",
+ "classviewnavigationwidgetfactory.cpp", "classviewnavigationwidgetfactory.h",
+ "classviewparser.cpp", "classviewparser.h",
+ "classviewparsertreeitem.cpp", "classviewparsertreeitem.h",
+ "classviewplugin.cpp", "classviewplugin.h",
+ "classviewsymbolinformation.cpp", "classviewsymbolinformation.h",
+ "classviewsymbollocation.cpp", "classviewsymbollocation.h",
+ "classviewtreeitemmodel.cpp", "classviewtreeitemmodel.h",
+ "classviewutils.cpp", "classviewutils.h",
]
}
diff --git a/src/plugins/clearcase/clearcase.qbs b/src/plugins/clearcase/clearcase.qbs
index 72edcc26b8..8389ef5673 100644
--- a/src/plugins/clearcase/clearcase.qbs
+++ b/src/plugins/clearcase/clearcase.qbs
@@ -12,9 +12,7 @@ QtcPlugin {
Depends { name: "Core" }
Depends { name: "TextEditor" }
Depends { name: "ProjectExplorer" }
- Depends { name: "Find" }
Depends { name: "VcsBase" }
- Depends { name: "Locator" }
files: [
"activityselector.cpp",
diff --git a/src/plugins/clearcase/clearcase_dependencies.pri b/src/plugins/clearcase/clearcase_dependencies.pri
index 3b39e2730e..52d7309af5 100644
--- a/src/plugins/clearcase/clearcase_dependencies.pri
+++ b/src/plugins/clearcase/clearcase_dependencies.pri
@@ -2,7 +2,6 @@ QTC_PLUGIN_NAME = ClearCase
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
- locator \
projectexplorer \
texteditor \
coreplugin \
diff --git a/src/plugins/clearcase/clearcasecontrol.cpp b/src/plugins/clearcase/clearcasecontrol.cpp
index 8036c95743..93910c9a52 100644
--- a/src/plugins/clearcase/clearcasecontrol.cpp
+++ b/src/plugins/clearcase/clearcasecontrol.cpp
@@ -57,6 +57,10 @@ Core::Id ClearCaseControl::id() const
bool ClearCaseControl::isConfigured() const
{
+#ifdef WITH_TESTS
+ if (m_plugin->isFakeCleartool())
+ return true;
+#endif
const QString binary = m_plugin->settings().ccBinaryPath;
if (binary.isEmpty())
return false;
@@ -83,12 +87,23 @@ bool ClearCaseControl::supportsOperation(Operation operation) const
return rc;
}
-Core::IVersionControl::OpenSupportMode ClearCaseControl::openSupportMode() const
+Core::IVersionControl::OpenSupportMode ClearCaseControl::openSupportMode(const QString &fileName) const
{
- if (m_plugin->isDynamic())
- return IVersionControl::OpenMandatory; // Checkout is the only option for dynamic views
- else
+ if (m_plugin->isDynamic()) {
+ // NB! Has to use managesFile() and not vcsStatus() since the index can only be guaranteed
+ // to be up to date if the file has been explicitly opened, which is not the case when
+ // doing a search and replace as a part of a refactoring.
+ if (m_plugin->managesFile(QFileInfo(fileName).absolutePath(), fileName)) {
+ // Checkout is the only option for managed files in dynamic views
+ return IVersionControl::OpenMandatory;
+ } else {
+ // Not managed files can be edited without noticing the VCS
+ return IVersionControl::NoOpen;
+ }
+
+ } else {
return IVersionControl::OpenOptional; // Snapshot views supports Hijack and check out
+ }
}
bool ClearCaseControl::vcsOpen(const QString &fileName)
@@ -153,6 +168,8 @@ QString ClearCaseControl::vcsOpenText() const
QString ClearCaseControl::vcsMakeWritableText() const
{
+ if (m_plugin->isDynamic())
+ return QString();
return tr("&Hijack");
}
diff --git a/src/plugins/clearcase/clearcasecontrol.h b/src/plugins/clearcase/clearcasecontrol.h
index b5d673ce38..258c3a7929 100644
--- a/src/plugins/clearcase/clearcasecontrol.h
+++ b/src/plugins/clearcase/clearcasecontrol.h
@@ -53,7 +53,7 @@ public:
bool isConfigured() const;
bool supportsOperation(Operation operation) const;
- OpenSupportMode openSupportMode() const;
+ OpenSupportMode openSupportMode(const QString &fileName) const;
bool vcsOpen(const QString &fileName);
SettingsFlags settingsFlags() const;
bool vcsAdd(const QString &fileName);
diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp
index c971374207..80d335619c 100644
--- a/src/plugins/clearcase/clearcaseplugin.cpp
+++ b/src/plugins/clearcase/clearcaseplugin.cpp
@@ -48,10 +48,11 @@
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
+#include <coreplugin/infobar.h>
#include <coreplugin/messagemanager.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/progressmanager/progressmanager.h>
-#include <locator/commandlocator.h>
+#include <coreplugin/locator/commandlocator.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
#include <projectexplorer/iprojectmanager.h>
@@ -186,6 +187,9 @@ ClearCasePlugin::ClearCasePlugin() :
m_submitActionTriggered(false),
m_activityMutex(new QMutex),
m_statusMap(new StatusMap)
+ #ifdef WITH_TESTS
+ ,m_fakeClearTool(false)
+ #endif
{
qRegisterMetaType<ClearCase::Internal::FileStatus::Status>("ClearCase::Internal::FileStatus::Status");
}
@@ -236,6 +240,76 @@ QString ClearCasePlugin::getDriveLetterOfPath(const QString &directory)
return dir.path();
}
+void ClearCasePlugin::updateStatusForFile(const QString &absFile)
+{
+ setStatus(absFile, getFileStatus(absFile), false);
+}
+
+/// Give warning if a derived object is edited
+void ClearCasePlugin::updateEditDerivedObjectWarning(const QString &fileName,
+ const FileStatus::Status status)
+{
+ if (!isDynamic())
+ return;
+
+ Core::IDocument *curDocument = Core::EditorManager::currentDocument();
+ if (!curDocument)
+ return;
+
+ Core::InfoBar *infoBar = curDocument->infoBar();
+ const Core::Id derivedObjectWarning("ClearCase.DerivedObjectWarning");
+
+ if (status == FileStatus::Derived) {
+ if (!infoBar->canInfoBeAdded(derivedObjectWarning))
+ return;
+
+ infoBar->addInfo(Core::InfoBarEntry(derivedObjectWarning,
+ tr("Editing Derived Object: %1")
+ .arg(fileName)));
+ } else {
+ infoBar->removeInfo(derivedObjectWarning);
+ }
+}
+
+FileStatus::Status ClearCasePlugin::getFileStatus(const QString &fileName) const
+{
+ QTC_CHECK(!fileName.isEmpty());
+
+ const QDir viewRootDir = QFileInfo(fileName).dir();
+ const QString viewRoot = viewRootDir.path();
+
+ QStringList args(QLatin1String("ls"));
+ args << fileName;
+ QString buffer = runCleartoolSync(viewRoot, args);
+
+ const int atatpos = buffer.indexOf(QLatin1String("@@"));
+ if (atatpos != -1) { // probably a managed file
+ const QString absFile =
+ viewRootDir.absoluteFilePath(
+ QDir::fromNativeSeparators(buffer.left(atatpos)));
+ QTC_CHECK(QFile(absFile).exists());
+ QTC_CHECK(!absFile.isEmpty());
+
+ // "cleartool ls" of a derived object looks like this:
+ // /path/to/file/export/MyFile.h@@--11-13T19:52.266580
+ const QChar c = buffer.at(atatpos + 2);
+ const bool isDerivedObject = c != QLatin1Char('/') && c != QLatin1Char('\\');
+ if (isDerivedObject)
+ return FileStatus::Derived;
+
+ // find first whitespace. anything before that is not interesting
+ const int wspos = buffer.indexOf(QRegExp(QLatin1String("\\s")));
+ if (buffer.lastIndexOf(QLatin1String("CHECKEDOUT"), wspos) != -1)
+ return FileStatus::CheckedOut;
+ else
+ return FileStatus::CheckedIn;
+ } else {
+ QTC_CHECK(QFile(fileName).exists());
+ QTC_CHECK(!fileName.isEmpty());
+ return FileStatus::NotManaged;
+ }
+}
+
///
/// Check if the directory is managed by ClearCase.
///
@@ -397,7 +471,7 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
const QString description = QLatin1String("ClearCase");
const QString prefix = QLatin1String("cc");
// register cc prefix in Locator
- m_commandLocator = new Locator::CommandLocator("cc", description, prefix);
+ m_commandLocator = new Core::CommandLocator("cc", description, prefix);
addAutoReleasedObject(m_commandLocator);
//register actions
@@ -483,12 +557,14 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
clearcaseMenu->addSeparator(globalcontext);
m_diffActivityAction = new QAction(tr("Diff A&ctivity..."), this);
+ m_diffActivityAction->setEnabled(false);
command = ActionManager::registerAction(m_diffActivityAction, CMD_ID_DIFF_ACTIVITY, globalcontext);
connect(m_diffActivityAction, SIGNAL(triggered()), this, SLOT(diffActivity()));
clearcaseMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_checkInActivityAction = new Utils::ParameterAction(tr("Ch&eck In Activity"), tr("Chec&k In Activity \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
+ m_checkInActivityAction->setEnabled(false);
command = ActionManager::registerAction(m_checkInActivityAction, CMD_ID_CHECKIN_ACTIVITY, globalcontext);
connect(m_checkInActivityAction, SIGNAL(triggered()), this, SLOT(startCheckInActivity()));
command->setAttribute(Command::CA_UpdateText);
@@ -671,7 +747,16 @@ QStringList ClearCasePlugin::ccGetActiveVobs() const
return res;
}
-// file must be relative to topLevel, and using '/' path separator
+void ClearCasePlugin::checkAndReIndexUnknownFile(const QString &file)
+{
+ if (isDynamic()) {
+ // reindex unknown files
+ if (m_statusMap->value(file, FileStatus(FileStatus::Unknown)).status == FileStatus::Unknown)
+ updateStatusForFile(file);
+ }
+}
+
+// file must be absolute, and using '/' path separator
FileStatus ClearCasePlugin::vcsStatus(const QString &file) const
{
return m_statusMap->value(file, FileStatus(FileStatus::Unknown));
@@ -700,16 +785,41 @@ ClearCaseSubmitEditor *ClearCasePlugin::openClearCaseSubmitEditor(const QString
return submitEditor;
}
+QString fileStatusToText(FileStatus fileStatus)
+{
+ switch (fileStatus.status)
+ {
+ case FileStatus::CheckedIn:
+ return QLatin1String("CheckedIn");
+ case FileStatus::CheckedOut:
+ return QLatin1String("CheckedOut");
+ case FileStatus::Hijacked:
+ return QLatin1String("Hijacked");
+ case FileStatus::Missing:
+ return QLatin1String("Missing");
+ case FileStatus::NotManaged:
+ return QLatin1String("ViewPrivate");
+ case FileStatus::Unknown:
+ return QLatin1String("Unknown");
+ default:
+ return QLatin1String("default");
+ }
+}
+
void ClearCasePlugin::updateStatusActions()
{
FileStatus fileStatus = FileStatus::Unknown;
bool hasFile = currentState().hasFile();
if (hasFile) {
QString absoluteFileName = currentState().currentFile();
- fileStatus = m_statusMap->value(absoluteFileName, FileStatus(FileStatus::Unknown));
+ checkAndReIndexUnknownFile(absoluteFileName);
+ fileStatus = vcsStatus(absoluteFileName);
+
+ updateEditDerivedObjectWarning(absoluteFileName, fileStatus.status);
if (Constants::debug)
- qDebug() << Q_FUNC_INFO << absoluteFileName << ", status = " << fileStatus.status;
+ qDebug() << Q_FUNC_INFO << absoluteFileName << ", status = "
+ << fileStatusToText(fileStatus.status) << "(" << fileStatus.status << ")";
}
m_checkOutAction->setEnabled(hasFile && (fileStatus.status & (FileStatus::CheckedIn | FileStatus::Hijacked)));
@@ -717,6 +827,9 @@ void ClearCasePlugin::updateStatusActions()
m_undoHijackAction->setEnabled(!m_viewData.isDynamic && hasFile && (fileStatus.status & FileStatus::Hijacked));
m_checkInCurrentAction->setEnabled(hasFile && (fileStatus.status & FileStatus::CheckedOut));
m_addFileAction->setEnabled(hasFile && (fileStatus.status & FileStatus::NotManaged));
+ m_diffCurrentAction->setEnabled(hasFile && (fileStatus.status != FileStatus::NotManaged));
+ m_historyCurrentAction->setEnabled(hasFile && (fileStatus.status != FileStatus::NotManaged));
+ m_annotateCurrentAction->setEnabled(hasFile && (fileStatus.status != FileStatus::NotManaged));
m_checkInActivityAction->setEnabled(m_viewData.isUcm);
m_diffActivityAction->setEnabled(m_viewData.isUcm);
@@ -746,6 +859,7 @@ void ClearCasePlugin::updateActions(VcsBase::VcsBasePlugin::ActionState as)
m_annotateCurrentAction->setParameter(fileName);
m_addFileAction->setParameter(fileName);
m_updateIndexAction->setEnabled(!m_settings.disableIndexer);
+
updateStatusActions();
}
@@ -766,6 +880,7 @@ void ClearCasePlugin::addCurrentFile()
// Set the FileStatus of file given in absolute path
void ClearCasePlugin::setStatus(const QString &file, FileStatus::Status status, bool update)
{
+ QTC_CHECK(!file.isEmpty());
m_statusMap->insert(file, FileStatus(status, QFileInfo(file).permissions()));
if (update && currentState().currentFile() == file)
@@ -904,7 +1019,7 @@ void ClearCasePlugin::ccDiffWithPred(const QString &workingDir, const QStringLis
if ((m_settings.diffType == GraphicalDiff) && (files.count() == 1)) {
const QString file = files.first();
const QString absFilePath = workingDir + QLatin1Char('/') + file;
- if (m_statusMap->value(absFilePath).status == FileStatus::Hijacked)
+ if (vcsStatus(absFilePath).status == FileStatus::Hijacked)
diffGraphical(ccGetFileVersion(workingDir, file), file);
else
diffGraphical(file);
@@ -918,7 +1033,7 @@ void ClearCasePlugin::ccDiffWithPred(const QString &workingDir, const QStringLis
QString result;
foreach (const QString &file, files) {
const QString absFilePath = workingDir + QLatin1Char('/') + file;
- if (m_statusMap->value(QDir::fromNativeSeparators(absFilePath)).status == FileStatus::Hijacked)
+ if (vcsStatus(QDir::fromNativeSeparators(absFilePath)).status == FileStatus::Hijacked)
result += diffExternal(ccGetFileVersion(workingDir, file), file);
else
result += diffExternal(file);
@@ -1210,7 +1325,8 @@ void ClearCasePlugin::viewStatus()
m_viewData = ccGetView(m_topLevel);
QTC_ASSERT(!m_viewData.name.isEmpty() && !m_settings.disableIndexer, return);
VcsBase::VcsBaseOutputWindow *outputwindow = VcsBase::VcsBaseOutputWindow::instance();
- outputwindow->appendCommand(QLatin1String("Indexed files status (C=Checked Out, H=Hijacked, ?=Missing)"));
+ outputwindow->appendCommand(QLatin1String("Indexed files status (C=Checked Out, "
+ "H=Hijacked, ?=Missing)"));
bool anymod = false;
for (StatusMap::ConstIterator it = m_statusMap->constBegin();
it != m_statusMap->constEnd();
@@ -1409,14 +1525,13 @@ IEditor *ClearCasePlugin::showOutputInEditor(const QString& title, const QString
return 0;
e->setForceReadOnly(true);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
- e->setSuggestedFileName(s);
+ e->baseTextDocument()->setSuggestedFileName(s);
if (!source.isEmpty())
e->setSource(source);
if (codec)
e->setCodec(codec);
- IEditor *ie = e->editor();
- EditorManager::activateEditor(ie);
- return ie;
+ EditorManager::activateEditor(editor);
+ return editor;
}
const ClearCaseSettings &ClearCasePlugin::settings() const
@@ -1456,14 +1571,14 @@ bool ClearCasePlugin::vcsOpen(const QString &workingDir, const QString &fileName
CheckOutDialog coDialog(title, m_viewData.isUcm);
if (!m_settings.disableIndexer &&
- (fi.isWritable() || m_statusMap->value(absPath).status == FileStatus::Unknown))
+ (fi.isWritable() || vcsStatus(absPath).status == FileStatus::Unknown))
QtConcurrent::run(&sync, QStringList(absPath)).waitForFinished();
- if (m_statusMap->value(absPath).status == FileStatus::CheckedOut) {
+ if (vcsStatus(absPath).status == FileStatus::CheckedOut) {
QMessageBox::information(0, tr("ClearCase Checkout"), tr("File is already checked out."));
return true;
}
// Only snapshot views can have hijacked files
- bool isHijacked = (!m_viewData.isDynamic && (m_statusMap->value(absPath).status & FileStatus::Hijacked));
+ bool isHijacked = (!m_viewData.isDynamic && (vcsStatus(absPath).status & FileStatus::Hijacked));
if (!isHijacked)
coDialog.hideHijack();
if (coDialog.exec() == QDialog::Accepted) {
@@ -1735,7 +1850,13 @@ QString ClearCasePlugin::vcsGetRepositoryURL(const QString & /*directory*/)
///
bool ClearCasePlugin::managesDirectory(const QString &directory, QString *topLevel /* = 0 */) const
{
+#ifdef WITH_TESTS
+ // If running with tests and fake ClearTool is enabled, then pretend we manage every directory
+ QString topLevelFound = m_fakeClearTool ? directory : findTopLevel(directory);
+#else
QString topLevelFound = findTopLevel(directory);
+#endif
+
if (topLevel)
*topLevel = topLevelFound;
return !topLevelFound.isEmpty();
@@ -1852,9 +1973,9 @@ bool ClearCasePlugin::ccCheckUcm(const QString &viewname, const QString &working
bool ClearCasePlugin::managesFile(const QString &workingDirectory, const QString &fileName) const
{
- QStringList args;
- args << QLatin1String("ls") << fileName;
- return runCleartoolSync(workingDirectory, args).contains(QLatin1String("@@"));
+ QString absFile = QFileInfo(QDir(workingDirectory), fileName).absoluteFilePath();
+ const FileStatus::Status status = getFileStatus(absFile);
+ return status != FileStatus::NotManaged && status != FileStatus::Derived;
}
ViewData ClearCasePlugin::ccGetView(const QString &workingDir) const
@@ -2117,6 +2238,233 @@ void ClearCasePlugin::testLogResolving()
"src/plugins/clearcase/clearcaseeditor.h@@/main/branch1/branch2/9",
"src/plugins/clearcase/clearcaseeditor.h@@/main/branch1/branch2/8");
}
+
+void ClearCasePlugin::initTestCase()
+{
+ m_tempFile = QDir::currentPath() + QLatin1String("/cc_file.cpp");
+ Utils::FileSaver srcSaver(m_tempFile);
+ srcSaver.write(QByteArray());
+ srcSaver.finalize();
+}
+
+void ClearCasePlugin::cleanupTestCase()
+{
+ QVERIFY(QFile::remove(m_tempFile));
+}
+
+void ClearCasePlugin::testFileStatusParsing_data()
+{
+ QTest::addColumn<QString>("filename");
+ QTest::addColumn<QString>("cleartoolLsLine");
+ QTest::addColumn<int>("status");
+
+ QTest::newRow("CheckedOut")
+ << m_tempFile
+ << QString(m_tempFile + QLatin1String("@@/main/branch1/CHECKEDOUT from /main/branch1/0 Rule: CHECKEDOUT"))
+ << static_cast<int>(FileStatus::CheckedOut);
+
+ QTest::newRow("CheckedIn")
+ << m_tempFile
+ << QString(m_tempFile + QLatin1String("@@/main/9 Rule: MY_LABEL_1.6.4 [-mkbranch branch1]"))
+ << static_cast<int>(FileStatus::CheckedIn);
+
+ QTest::newRow("Hijacked")
+ << m_tempFile
+ << QString(m_tempFile + QLatin1String("@@/main/9 [hijacked] Rule: MY_LABEL_1.5.33 [-mkbranch myview1]"))
+ << static_cast<int>(FileStatus::Hijacked);
+
+
+ QTest::newRow("Missing")
+ << m_tempFile
+ << QString(m_tempFile + QLatin1String("@@/main/9 [loaded but missing] Rule: MY_LABEL_1.5.33 [-mkbranch myview1]"))
+ << static_cast<int>(FileStatus::Missing);
+}
+
+void ClearCasePlugin::testFileStatusParsing()
+{
+ ClearCasePlugin *plugin = ClearCasePlugin::instance();
+ plugin->m_statusMap = QSharedPointer<StatusMap>(new StatusMap);
+
+ QFETCH(QString, filename);
+ QFETCH(QString, cleartoolLsLine);
+ QFETCH(int, status);
+
+ ClearCaseSync ccSync(plugin, plugin->m_statusMap);
+ ccSync.verifyParseStatus(filename, cleartoolLsLine, static_cast<FileStatus::Status>(status));
+}
+
+void ClearCasePlugin::testFileNotManaged()
+{
+ ClearCasePlugin *plugin = ClearCasePlugin::instance();
+ plugin->m_statusMap = QSharedPointer<StatusMap>(new StatusMap);
+ ClearCaseSync ccSync(plugin, plugin->m_statusMap);
+ ccSync.verifyFileNotManaged();
+}
+
+void ClearCasePlugin::testFileCheckedOutDynamicView()
+{
+ ClearCasePlugin *plugin = ClearCasePlugin::instance();
+ plugin->m_statusMap = QSharedPointer<StatusMap>(new StatusMap);
+
+ ClearCaseSync ccSync(plugin, plugin->m_statusMap);
+ ccSync.verifyFileCheckedOutDynamicView();
+}
+
+void ClearCasePlugin::testFileCheckedInDynamicView()
+{
+ ClearCasePlugin *plugin = ClearCasePlugin::instance();
+ plugin->m_statusMap = QSharedPointer<StatusMap>(new StatusMap);
+ ClearCaseSync ccSync(plugin, plugin->m_statusMap);
+ ccSync.verifyFileCheckedInDynamicView();
+}
+
+void ClearCasePlugin::testFileNotManagedDynamicView()
+{
+ ClearCasePlugin *plugin = ClearCasePlugin::instance();
+ plugin->m_statusMap = QSharedPointer<StatusMap>(new StatusMap);
+ ClearCaseSync ccSync(plugin, plugin->m_statusMap);
+ ccSync.verifyFileNotManagedDynamicView();
+}
+
+namespace {
+/**
+ * @brief Convenience class which also properly cleans up editors and temp files
+ */
+class TestCase
+{
+public:
+ TestCase(const QString &fileName) :
+ m_fileName(fileName) ,
+ m_editor(0)
+ {
+ ClearCasePlugin::instance()->setFakeCleartool(true);
+ Utils::FileSaver srcSaver(fileName);
+ srcSaver.write(QByteArray());
+ srcSaver.finalize();
+
+ m_editor = Core::EditorManager::openEditor(fileName);
+
+ QCoreApplication::processEvents(); // process any pending events
+ }
+
+ ViewData dummyViewData() const
+ {
+ ViewData viewData;
+ viewData.name = QLatin1String("fake_view");
+ viewData.root = QDir::currentPath();
+ viewData.isUcm = false;
+ return viewData;
+ }
+
+ ~TestCase()
+ {
+ Core::EditorManager::closeEditor(m_editor, false);
+ QCoreApplication::processEvents(); // process any pending events
+
+ QFile file(m_fileName);
+ if (!file.isWritable()) // Windows can't delete read only files
+ file.setPermissions(file.permissions() | QFile::WriteUser);
+ QVERIFY(file.remove());
+ ClearCasePlugin::instance()->setFakeCleartool(false);
+ }
+
+private:
+ QString m_fileName;
+ Core::IEditor *m_editor;
+};
+}
+
+void ClearCasePlugin::testStatusActions_data()
+{
+ QTest::addColumn<int>("status");
+ QTest::addColumn<bool>("checkOutAction");
+ QTest::addColumn<bool>("undoCheckOutAction");
+ QTest::addColumn<bool>("undoHijackAction");
+ QTest::addColumn<bool>("checkInCurrentAction");
+ QTest::addColumn<bool>("addFileAction");
+ QTest::addColumn<bool>("checkInActivityAction");
+ QTest::addColumn<bool>("diffActivityAction");
+
+ QTest::newRow("Unknown") << static_cast<int>(FileStatus::Unknown)
+ << true << true << true << true << true << false << false;
+ QTest::newRow("CheckedOut") << static_cast<int>(FileStatus::CheckedOut)
+ << false << true << false << true << false << false << false;
+ QTest::newRow("CheckedIn") << static_cast<int>(FileStatus::CheckedIn)
+ << true << false << false << false << false << false << false;
+ QTest::newRow("NotManaged") << static_cast<int>(FileStatus::NotManaged)
+ << false << false << false << false << true << false << false;
+}
+
+void ClearCasePlugin::testStatusActions()
+{
+ const QString fileName = QDir::currentPath() + QLatin1String("/clearcase_file.cpp");
+ TestCase testCase(fileName);
+
+ m_viewData = testCase.dummyViewData();
+
+ QFETCH(int, status);
+ FileStatus::Status tempStatus = static_cast<FileStatus::Status>(status);
+
+ // special case: file should appear as "Unknown" since there is no entry in the index
+ // and we don't want to explicitly set the status for this test case
+ if (tempStatus != FileStatus::Unknown)
+ setStatus(fileName, tempStatus, true);
+
+ QFETCH(bool, checkOutAction);
+ QFETCH(bool, undoCheckOutAction);
+ QFETCH(bool, undoHijackAction);
+ QFETCH(bool, checkInCurrentAction);
+ QFETCH(bool, addFileAction);
+ QFETCH(bool, checkInActivityAction);
+ QFETCH(bool, diffActivityAction);
+
+ QCOMPARE(m_checkOutAction->isEnabled(), checkOutAction);
+ QCOMPARE(m_undoCheckOutAction->isEnabled(), undoCheckOutAction);
+ QCOMPARE(m_undoHijackAction->isEnabled(), undoHijackAction);
+ QCOMPARE(m_checkInCurrentAction->isEnabled(), checkInCurrentAction);
+ QCOMPARE(m_addFileAction->isEnabled(), addFileAction);
+ QCOMPARE(m_checkInActivityAction->isEnabled(), checkInActivityAction);
+ QCOMPARE(m_diffActivityAction->isEnabled(), diffActivityAction);
+}
+
+void ClearCasePlugin::testVcsStatusDynamicReadonlyNotManaged()
+{
+ // File is not in map, and is read-only
+ ClearCasePlugin::instance();
+ m_statusMap = QSharedPointer<StatusMap>(new StatusMap);
+
+ const QString fileName = QDir::currentPath() + QLatin1String("/readonly_notmanaged_file.cpp");
+
+ m_viewData.isDynamic = true;
+ TestCase testCase(fileName);
+
+ QFile::setPermissions(fileName, QFile::ReadOwner |
+ QFile::ReadUser |
+ QFile::ReadGroup |
+ QFile::ReadOther);
+
+ m_viewData = testCase.dummyViewData();
+ m_viewData.isDynamic = true;
+
+ QCOMPARE(vcsStatus(fileName).status, FileStatus::NotManaged);
+
+}
+
+void ClearCasePlugin::testVcsStatusDynamicNotManaged()
+{
+ ClearCasePlugin::instance();
+ m_statusMap = QSharedPointer<StatusMap>(new StatusMap);
+
+ const QString fileName = QDir::currentPath() + QLatin1String("/notmanaged_file.cpp");
+
+ m_viewData.isDynamic = true;
+ TestCase testCase(fileName);
+
+ m_viewData = testCase.dummyViewData();
+ m_viewData.isDynamic = true;
+
+ QCOMPARE(vcsStatus(fileName).status, FileStatus::NotManaged);
+}
#endif
} // namespace Internal
diff --git a/src/plugins/clearcase/clearcaseplugin.h b/src/plugins/clearcase/clearcaseplugin.h
index c6588db05e..2b47de944f 100644
--- a/src/plugins/clearcase/clearcaseplugin.h
+++ b/src/plugins/clearcase/clearcaseplugin.h
@@ -54,13 +54,13 @@ class QTextCodec;
QT_END_NAMESPACE
namespace Core {
+class CommandLocator;
class IVersionControl;
class IEditor;
} // namespace Core
namespace Utils { class ParameterAction; }
namespace VcsBase { class VcsBaseSubmitEditor; }
-namespace Locator { class CommandLocator; }
namespace ProjectExplorer { class Project; }
namespace ClearCase {
@@ -89,7 +89,8 @@ public:
CheckedOut = 0x02,
Hijacked = 0x04,
NotManaged = 0x08,
- Missing = 0x10
+ Missing = 0x10,
+ Derived = 0x20
} status;
QFile::Permissions permissions;
@@ -158,6 +159,7 @@ public:
bool ccFileOp(const QString &workingDir, const QString &title, const QStringList &args,
const QString &fileName, const QString &file2 = QString());
FileStatus vcsStatus(const QString &file) const;
+ void checkAndReIndexUnknownFile(const QString &file);
QString currentView() const { return m_viewData.name; }
QString viewRoot() const { return m_viewData.root; }
void refreshActivities();
@@ -167,6 +169,10 @@ public:
bool ccCheckUcm(const QString &viewname, const QString &workingDir) const;
bool managesFile(const QString &workingDirectory, const QString &fileName) const;
+#ifdef WITH_TESTS
+ inline void setFakeCleartool(const bool b = true) { m_fakeClearTool = b; }
+ inline bool isFakeCleartool() const { return m_fakeClearTool; }
+#endif
public slots:
void vcsAnnotate(const QString &workingDir, const QString &file,
@@ -199,9 +205,21 @@ private slots:
void closing();
void updateStatusActions();
#ifdef WITH_TESTS
+ void initTestCase();
+ void cleanupTestCase();
void testDiffFileResolving_data();
void testDiffFileResolving();
void testLogResolving();
+ void testFileStatusParsing_data();
+ void testFileStatusParsing();
+ void testFileNotManaged();
+ void testFileCheckedOutDynamicView();
+ void testFileCheckedInDynamicView();
+ void testFileNotManagedDynamicView();
+ void testStatusActions_data();
+ void testStatusActions();
+ void testVcsStatusDynamicReadonlyNotManaged();
+ void testVcsStatusDynamicNotManaged();
#endif
protected:
@@ -244,6 +262,10 @@ private:
int timeOut, QTextCodec *outputCodec = 0);
static QString getDriveLetterOfPath(const QString &directory);
+ FileStatus::Status getFileStatus(const QString &fileName) const;
+ void updateStatusForFile(const QString &absFile);
+ void updateEditDerivedObjectWarning(const QString &fileName, const FileStatus::Status status);
+
ClearCaseSettings m_settings;
QString m_checkInMessageFileName;
@@ -255,7 +277,7 @@ private:
QString m_activity;
QString m_diffPrefix;
- Locator::CommandLocator *m_commandLocator;
+ Core::CommandLocator *m_commandLocator;
Utils::ParameterAction *m_checkOutAction;
Utils::ParameterAction *m_checkInCurrentAction;
Utils::ParameterAction *m_undoCheckOutAction;
@@ -282,6 +304,10 @@ private:
QSharedPointer<StatusMap> m_statusMap;
static ClearCasePlugin *m_clearcasePluginInstance;
+#ifdef WITH_TESTS
+ bool m_fakeClearTool;
+ QString m_tempFile;
+#endif
};
} // namespace Internal
diff --git a/src/plugins/clearcase/clearcasesync.cpp b/src/plugins/clearcase/clearcasesync.cpp
index 2560672ea9..d34f20e19b 100644
--- a/src/plugins/clearcase/clearcasesync.cpp
+++ b/src/plugins/clearcase/clearcasesync.cpp
@@ -34,6 +34,12 @@
#include <QFutureInterface>
#include <QProcess>
#include <QStringList>
+#include <utils/qtcassert.h>
+
+#ifdef WITH_TESTS
+#include <QTest>
+#include <utils/fileutils.h>
+#endif
namespace ClearCase {
namespace Internal {
@@ -44,60 +50,108 @@ ClearCaseSync::ClearCaseSync(ClearCasePlugin *plugin, QSharedPointer<StatusMap>
{
}
-void ClearCaseSync::run(QFutureInterface<void> &future, QStringList &files)
+QStringList ClearCaseSync::updateStatusHotFiles(const QString &viewRoot, int &total)
{
- ClearCaseSettings settings = m_plugin->settings();
- const QString program = settings.ccBinaryPath;
- if (program.isEmpty())
- return;
- int total = files.size();
- const bool hot = (total < 10);
- int processed = 0;
- QString view = m_plugin->currentView();
- if (view.isEmpty())
- emit updateStreamAndView();
- if (!hot)
- total = settings.totalFiles.value(view, total);
+ QStringList hotFiles;
+ // find all files whose permissions changed OR hijacked files
+ // (might have become checked out)
+ const StatusMap::Iterator send = m_statusMap->end();
+ for (StatusMap::Iterator it = m_statusMap->begin(); it != send; ++it) {
+ const QFileInfo fi(viewRoot, it.key());
+ const bool permChanged = it.value().permissions != fi.permissions();
+ if (permChanged || it.value().status == FileStatus::Hijacked) {
+ hotFiles.append(it.key());
+ it.value().status = FileStatus::Unknown;
+ ++total;
+ }
+ }
+ return hotFiles;
+}
- // refresh activities list
- if (m_plugin->isUcm())
- m_plugin->refreshActivities();
+// Set status for all files to unknown until we're done indexing
+void ClearCaseSync::invalidateStatus(const QDir &viewRootDir,
+ const QStringList &files)
+{
+ foreach (const QString &file, files) {
+ m_plugin->setStatus(viewRootDir.absoluteFilePath(file), FileStatus::Unknown, false);
+ }
+}
- if (settings.disableIndexer)
+void ClearCaseSync::invalidateStatusAllFiles()
+{
+ const StatusMap::ConstIterator send = m_statusMap->end();
+ for (StatusMap::ConstIterator it = m_statusMap->begin(); it != send; ++it)
+ m_plugin->setStatus(it.key(), FileStatus::Unknown, false);
+}
+
+void ClearCaseSync::processCleartoolLsLine(const QDir &viewRootDir, const QString &buffer)
+{
+ const int atatpos = buffer.indexOf(QLatin1String("@@"));
+
+ if (atatpos == -1)
return;
- const bool isDynamic = m_plugin->isDynamic();
+ // find first whitespace. anything before that is not interesting
+ const int wspos = buffer.indexOf(QRegExp(QLatin1String("\\s")));
+ const QString absFile =
+ viewRootDir.absoluteFilePath(
+ QDir::fromNativeSeparators(buffer.left(atatpos)));
+ QTC_CHECK(QFile(absFile).exists());
+ QTC_CHECK(!absFile.isEmpty());
+
+ QString ccState;
+ const QRegExp reState(QLatin1String("^\\s*\\[[^\\]]*\\]")); // [hijacked]; [loaded but missing]
+ if (reState.indexIn(buffer, wspos + 1, QRegExp::CaretAtOffset) != -1) {
+ ccState = reState.cap();
+ if (ccState.indexOf(QLatin1String("hijacked")) != -1)
+ m_plugin->setStatus(absFile, FileStatus::Hijacked, true);
+ else if (ccState.indexOf(QLatin1String("loaded but missing")) != -1)
+ m_plugin->setStatus(absFile, FileStatus::Missing, false);
+ }
+ else if (buffer.lastIndexOf(QLatin1String("CHECKEDOUT"), wspos) != -1)
+ m_plugin->setStatus(absFile, FileStatus::CheckedOut, true);
+ // don't care about checked-in files not listed in project
+ else if (m_statusMap->contains(absFile))
+ m_plugin->setStatus(absFile, FileStatus::CheckedIn, true);
+}
+
+void ClearCaseSync::updateTotalFilesCount(const QString view, ClearCaseSettings settings,
+ const int processed)
+{
+ settings = m_plugin->settings(); // Might have changed while task was running
+ settings.totalFiles[view] = processed;
+ m_plugin->setSettings(settings);
+}
+
+void ClearCaseSync::updateStatusForNotManagedFiles(const QStringList &files)
+{
+ foreach (const QString &file, files) {
+ QString absFile = QFileInfo(file).absoluteFilePath();
+ if (!m_statusMap->contains(absFile))
+ m_plugin->setStatus(absFile, FileStatus::NotManaged, false);
+ }
+}
+
+void ClearCaseSync::syncSnapshotView(QFutureInterface<void> &future, QStringList &files,
+ const ClearCaseSettings &settings)
+{
+ QString view = m_plugin->currentView();
+
+ int totalFileCount = files.size();
+ const bool hot = (totalFileCount < 10);
+ int processed = 0;
+ if (!hot)
+ totalFileCount = settings.totalFiles.value(view, totalFileCount);
+
const QString viewRoot = m_plugin->viewRoot();
const QDir viewRootDir(viewRoot);
QStringList args(QLatin1String("ls"));
if (hot) {
- // find all files whose permissions changed OR hijacked files
- // (might have become checked out)
- const StatusMap::Iterator send = m_statusMap->end();
- for (StatusMap::Iterator it = m_statusMap->begin(); it != send; ++it) {
- const QFileInfo fi(viewRoot, it.key());
- const bool permChanged = it.value().permissions != fi.permissions();
- if (permChanged || it.value().status == FileStatus::Hijacked) {
- files.append(it.key());
- it.value().status = FileStatus::Unknown;
- ++total;
- } else if (isDynamic && !fi.isWritable()) { // assume a read only file is checked in
- it.value().status = FileStatus::CheckedIn;
- ++total;
- }
- }
+ files << updateStatusHotFiles(viewRoot, totalFileCount);
args << files;
} else {
- foreach (const QString &file, files) {
- if (isDynamic) { // assume a read only file is checked in
- const QFileInfo fi(viewRootDir, file);
- if (!fi.isWritable())
- m_plugin->setStatus(fi.absoluteFilePath(), FileStatus::CheckedIn, false);
- } else {
- m_plugin->setStatus(viewRootDir.absoluteFilePath(file), FileStatus::Unknown, false);
- }
- }
+ invalidateStatus(viewRootDir, files);
args << QLatin1String("-recurse");
QStringList vobs;
@@ -111,10 +165,12 @@ void ClearCaseSync::run(QFutureInterface<void> &future, QStringList &files)
// adding 1 for initial sync in which total is not accurate, to prevent finishing
// (we don't want it to become green)
- future.setProgressRange(0, total + 1);
+ future.setProgressRange(0, totalFileCount + 1);
QProcess process;
process.setWorkingDirectory(viewRoot);
+ const QString program = settings.ccBinaryPath;
+
process.start(program, args);
if (!process.waitForStarted())
return;
@@ -124,55 +180,208 @@ void ClearCaseSync::run(QFutureInterface<void> &future, QStringList &files)
process.bytesAvailable() && !future.isCanceled())
{
const QString line = QString::fromLocal8Bit(process.readLine().constData());
-
buffer += line;
if (buffer.endsWith(QLatin1Char('\n')) || process.atEnd()) {
- const int atatpos = buffer.indexOf(QLatin1String("@@"));
- if (atatpos != -1) { // probably managed file
- // find first whitespace. anything before that is not interesting
- const int wspos = buffer.indexOf(QRegExp(QLatin1String("\\s")));
- const QString absFile =
- viewRootDir.absoluteFilePath(
- QDir::fromNativeSeparators(buffer.left(atatpos)));
-
- QString ccState;
- const QRegExp reState(QLatin1String("^\\s*\\[[^\\]]*\\]")); // [hijacked]; [loaded but missing]
- if (reState.indexIn(buffer, wspos + 1, QRegExp::CaretAtOffset) != -1) {
- ccState = reState.cap();
- if (ccState.indexOf(QLatin1String("hijacked")) != -1)
- m_plugin->setStatus(absFile, FileStatus::Hijacked, true);
- else if (ccState.indexOf(QLatin1String("loaded but missing")) != -1)
- m_plugin->setStatus(absFile, FileStatus::Missing, false);
- }
- else if (buffer.lastIndexOf(QLatin1String("CHECKEDOUT"), wspos) != -1)
- m_plugin->setStatus(absFile, FileStatus::CheckedOut, true);
- // don't care about checked-in files not listed in project
- else if (m_statusMap->contains(absFile))
- m_plugin->setStatus(absFile, FileStatus::CheckedIn, true);
- }
+ processCleartoolLsLine(viewRootDir, buffer);
buffer.clear();
- future.setProgressValue(qMin(total, ++processed));
+ future.setProgressValue(qMin(totalFileCount, ++processed));
}
}
}
if (!future.isCanceled()) {
- foreach (const QString &file, files) {
- QString absFile = QFileInfo(file).absoluteFilePath();
- if (!m_statusMap->contains(absFile))
- m_plugin->setStatus(absFile, FileStatus::NotManaged, false);
- }
- future.setProgressValue(total + 1);
- if (!hot) {
- settings = m_plugin->settings(); // Might have changed while task was running
- settings.totalFiles[view] = processed;
- m_plugin->setSettings(settings);
+ updateStatusForNotManagedFiles(files);
+ future.setProgressValue(totalFileCount + 1);
+ if (!hot)
+ updateTotalFilesCount(view, settings, processed);
+ }
+
+ if (process.state() == QProcess::Running)
+ process.kill();
+
+ process.waitForFinished();
+}
+
+void ClearCaseSync::processCleartoolLscheckoutLine(const QString &buffer)
+{
+ QString absFile = buffer.trimmed();
+ m_plugin->setStatus(absFile, FileStatus::CheckedOut, true);
+}
+
+///
+/// Update the file status for dynamic views.
+///
+void ClearCaseSync::syncDynamicView(QFutureInterface<void> &future,
+ const ClearCaseSettings& settings)
+{
+ // Always invalidate status for all files
+ invalidateStatusAllFiles();
+
+ QStringList args(QLatin1String("lscheckout"));
+ args << QLatin1String("-avobs")
+ << QLatin1String("-me")
+ << QLatin1String("-cview")
+ << QLatin1String("-s");
+
+ const QString viewRoot = m_plugin->viewRoot();
+
+ QProcess process;
+ process.setWorkingDirectory(viewRoot);
+
+ const QString program = settings.ccBinaryPath;
+ process.start(program, args);
+ if (!process.waitForStarted())
+ return;
+
+ QString buffer;
+ int processed = 0;
+ while (process.waitForReadyRead() && !future.isCanceled()) {
+ while (process.state() == QProcess::Running &&
+ process.bytesAvailable() && !future.isCanceled()) {
+ const QString line = QString::fromLocal8Bit(process.readLine().constData());
+ buffer += line;
+ if (buffer.endsWith(QLatin1Char('\n')) || process.atEnd()) {
+ processCleartoolLscheckoutLine(buffer);
+ buffer.clear();
+ future.setProgressValue(++processed);
+ }
}
}
+
if (process.state() == QProcess::Running)
process.kill();
+
process.waitForFinished();
}
+void ClearCaseSync::run(QFutureInterface<void> &future, QStringList &files)
+{
+ ClearCaseSettings settings = m_plugin->settings();
+ if (settings.disableIndexer)
+ return;
+
+ const QString program = settings.ccBinaryPath;
+ if (program.isEmpty())
+ return;
+
+ // refresh activities list
+ if (m_plugin->isUcm())
+ m_plugin->refreshActivities();
+
+ QString view = m_plugin->currentView();
+ if (view.isEmpty())
+ emit updateStreamAndView();
+
+ if (m_plugin->isDynamic())
+ syncDynamicView(future, settings);
+ else
+ syncSnapshotView(future, files, settings);
+}
+
+#ifdef WITH_TESTS
+namespace {
+class TempFile
+{
+public:
+ TempFile(const QString &fileName)
+ : m_fileName(fileName)
+ {
+ Utils::FileSaver srcSaver(fileName);
+ srcSaver.write(QByteArray());
+ srcSaver.finalize();
+
+ }
+
+ QString fileName() const { return m_fileName; }
+
+ ~TempFile()
+ {
+ QVERIFY(QFile::remove(m_fileName));
+ }
+
+private:
+ const QString m_fileName;
+};
+}
+
+void ClearCaseSync::verifyParseStatus(const QString &fileName,
+ const QString &cleartoolLsLine,
+ const FileStatus::Status status)
+{
+ QCOMPARE(m_statusMap->count(), 0);
+ processCleartoolLsLine(QDir(QLatin1String("/")), cleartoolLsLine);
+
+ if (status == FileStatus::CheckedIn) {
+ // The algorithm doesn't store checked in files in the index, unless it was there already
+ QCOMPARE(m_statusMap->count(), 0);
+ QCOMPARE(m_statusMap->contains(fileName), false);
+ m_plugin->setStatus(fileName, FileStatus::Unknown, false);
+ processCleartoolLsLine(QDir(QLatin1String("/")), cleartoolLsLine);
+ }
+
+ QCOMPARE(m_statusMap->count(), 1);
+ QCOMPARE(m_statusMap->contains(fileName), true);
+ QCOMPARE(m_statusMap->value(fileName).status, status);
+
+ QCOMPARE(m_statusMap->contains(QLatin1String(("notexisting"))), false);
+}
+
+void ClearCaseSync::verifyFileNotManaged()
+{
+ QCOMPARE(m_statusMap->count(), 0);
+ TempFile temp(QDir::currentPath() + QLatin1String("/notmanaged.cpp"));
+ const QString fileName = temp.fileName();
+
+ updateStatusForNotManagedFiles(QStringList(fileName));
+
+ QCOMPARE(m_statusMap->count(), 1);
+
+ QCOMPARE(m_statusMap->contains(fileName), true);
+ QCOMPARE(m_statusMap->value(fileName).status, FileStatus::NotManaged);
+}
+
+void ClearCaseSync::verifyFileCheckedOutDynamicView()
+{
+ QCOMPARE(m_statusMap->count(), 0);
+
+ QString fileName(QLatin1String("/hello.C"));
+ processCleartoolLscheckoutLine(fileName);
+
+ QCOMPARE(m_statusMap->count(), 1);
+
+ QVERIFY(m_statusMap->contains(fileName));
+ QCOMPARE(m_statusMap->value(fileName).status, FileStatus::CheckedOut);
+
+ QVERIFY(!m_statusMap->contains(QLatin1String(("notexisting"))));
+}
+
+void ClearCaseSync::verifyFileCheckedInDynamicView()
+{
+ QCOMPARE(m_statusMap->count(), 0);
+
+ QString fileName(QLatin1String("/hello.C"));
+
+ // checked in files are not kept in the index
+ QCOMPARE(m_statusMap->count(), 0);
+ QCOMPARE(m_statusMap->contains(fileName), false);
+}
+
+void ClearCaseSync::verifyFileNotManagedDynamicView()
+{
+ QCOMPARE(m_statusMap->count(), 0);
+ TempFile temp(QDir::currentPath() + QLatin1String("/notmanaged.cpp"));
+ const QString fileName = temp.fileName();
+
+ updateStatusForNotManagedFiles(QStringList(fileName));
+
+ QCOMPARE(m_statusMap->count(), 1);
+
+ QVERIFY(m_statusMap->contains(fileName));
+ QCOMPARE(m_statusMap->value(fileName).status, FileStatus::NotManaged);
+}
+
+#endif
+
+
} // namespace Internal
} // namespace ClearCase
diff --git a/src/plugins/clearcase/clearcasesync.h b/src/plugins/clearcase/clearcasesync.h
index b2e0250b92..6b0279029e 100644
--- a/src/plugins/clearcase/clearcasesync.h
+++ b/src/plugins/clearcase/clearcasesync.h
@@ -42,12 +42,38 @@ public:
explicit ClearCaseSync(ClearCasePlugin *plugin, QSharedPointer<StatusMap> statusMap);
void run(QFutureInterface<void> &future, QStringList &files);
+ QStringList updateStatusHotFiles(const QString &viewRoot, int &total);
+ void invalidateStatus(const QDir &viewRootDir, const QStringList &files);
+ void invalidateStatusAllFiles();
+ void processCleartoolLsLine(const QDir &viewRootDir, const QString &buffer);
+ void updateTotalFilesCount(const QString view, ClearCaseSettings settings, const int processed);
+ void updateStatusForNotManagedFiles(const QStringList &files);
+
+ void syncDynamicView(QFutureInterface<void> &future,
+ const ClearCaseSettings &settings);
+ void syncSnapshotView(QFutureInterface<void> &future, QStringList &files,
+ const ClearCaseSettings &settings);
+
+ void processCleartoolLscheckoutLine(const QString &buffer);
signals:
void updateStreamAndView();
private:
ClearCasePlugin *m_plugin;
QSharedPointer<StatusMap> m_statusMap;
+
+public slots:
+#ifdef WITH_TESTS
+ void verifyParseStatus(const QString &fileName, const QString &cleartoolLsLine,
+ const FileStatus::Status);
+ void verifyFileNotManaged();
+
+ void verifyFileCheckedOutDynamicView();
+ void verifyFileCheckedInDynamicView();
+ void verifyFileNotManagedDynamicView();
+
+#endif
+
};
} // namespace Internal
diff --git a/src/plugins/clearcase/settingspage.cpp b/src/plugins/clearcase/settingspage.cpp
index cf646ad6dc..9433648f0e 100644
--- a/src/plugins/clearcase/settingspage.cpp
+++ b/src/plugins/clearcase/settingspage.cpp
@@ -52,6 +52,7 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
m_ui.setupUi(this);
m_ui.commandPathChooser->setPromptDialogTitle(tr("ClearCase Command"));
m_ui.commandPathChooser->setExpectedKind(PathChooser::ExistingCommand);
+ m_ui.commandPathChooser->setHistoryCompleter(QLatin1String("ClearCase.Command.History"));
}
ClearCaseSettings SettingsPageWidget::settings() const
@@ -106,25 +107,6 @@ void SettingsPageWidget::setSettings(const ClearCaseSettings &s)
m_ui.indexOnlyVOBsEdit->setText(s.indexOnlyVOBs);
}
-QString SettingsPageWidget::searchKeywords() const
-{
- QString rc;
- QLatin1Char sep(' ');
- QTextStream(&rc) << m_ui.commandLabel->text()
- << sep << m_ui.autoCheckOutCheckBox->text()
- << sep << m_ui.externalDiffRadioButton->text()
- << sep << m_ui.graphicalDiffRadioButton->text()
- << sep << m_ui.diffArgsLabel->text()
- << sep << m_ui.historyCountLabel->text()
- << sep << m_ui.promptCheckBox->text()
- << sep << m_ui.disableIndexerCheckBox->text()
- << sep << m_ui.timeOutLabel->text()
- << sep << m_ui.indexOnlyVOBsLabel->text()
- ;
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
SettingsPage::SettingsPage() :
m_widget(0)
{
@@ -132,12 +114,11 @@ SettingsPage::SettingsPage() :
setDisplayName(tr("ClearCase"));
}
-QWidget *SettingsPage::createPage(QWidget *parent)
+QWidget *SettingsPage::widget()
{
- m_widget = new SettingsPageWidget(parent);
+ if (!m_widget)
+ m_widget = new SettingsPageWidget;
m_widget->setSettings(ClearCasePlugin::instance()->settings());
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
return m_widget;
}
@@ -145,8 +126,3 @@ void SettingsPage::apply()
{
ClearCasePlugin::instance()->setSettings(m_widget->settings());
}
-
-bool SettingsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
diff --git a/src/plugins/clearcase/settingspage.h b/src/plugins/clearcase/settingspage.h
index 95258ca84d..ba5ea95594 100644
--- a/src/plugins/clearcase/settingspage.h
+++ b/src/plugins/clearcase/settingspage.h
@@ -35,6 +35,8 @@
#include "ui_settingspage.h"
+#include <QPointer>
+
namespace ClearCase {
namespace Internal {
@@ -50,8 +52,6 @@ public:
ClearCaseSettings settings() const;
void setSettings(const ClearCaseSettings &);
- QString searchKeywords() const;
-
private:
Ui::SettingsPage m_ui;
};
@@ -64,14 +64,12 @@ class SettingsPage : public VcsBase::VcsBaseOptionsPage
public:
SettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish() { }
- bool matches(const QString &) const;
private:
- QString m_searchKeywords;
- SettingsPageWidget* m_widget;
+ QPointer<SettingsPageWidget> m_widget;
};
} // namespace ClearCase
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
index 4d63e422d5..760c4d32a0 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
@@ -31,7 +31,6 @@
#include "cmakefilecompletionassist.h"
#include "cmakehighlighter.h"
-#include "cmakeeditorfactory.h"
#include "cmakeprojectconstants.h"
#include "cmakeproject.h"
@@ -65,11 +64,10 @@ CMakeEditor::CMakeEditor(CMakeEditorWidget *editor)
connect(document(), SIGNAL(changed()), this, SLOT(markAsChanged()));
}
-Core::IEditor *CMakeEditor::duplicate(QWidget *parent)
+Core::IEditor *CMakeEditor::duplicate()
{
- CMakeEditorWidget *w = qobject_cast<CMakeEditorWidget*>(widget());
- CMakeEditorWidget *ret = new CMakeEditorWidget(parent, w->factory(), w->actionHandler());
- ret->duplicateFrom(w);
+ CMakeEditorWidget *ret = new CMakeEditorWidget(
+ qobject_cast<CMakeEditorWidget *>(editorWidget()));
TextEditor::TextEditorSettings::initializeEditor(ret);
return ret->editor();
}
@@ -116,19 +114,23 @@ void CMakeEditor::build()
// CMakeEditor
//
-CMakeEditorWidget::CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah)
- : BaseTextEditorWidget(parent), m_factory(factory), m_ah(ah)
+CMakeEditorWidget::CMakeEditorWidget(QWidget *parent)
+ : BaseTextEditorWidget(new CMakeDocument(), parent)
{
- QSharedPointer<CMakeDocument> doc(new CMakeDocument);
- doc->setMimeType(QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE));
- setBaseTextDocument(doc);
+ ctor();
+}
- baseTextDocument()->setSyntaxHighlighter(new CMakeHighlighter);
+CMakeEditorWidget::CMakeEditorWidget(CMakeEditorWidget *other)
+ : BaseTextEditorWidget(other)
+{
+ ctor();
+}
+void CMakeEditorWidget::ctor()
+{
+ baseTextDocument()->setSyntaxHighlighter(new CMakeHighlighter);
m_commentDefinition.clearCommentStyles();
m_commentDefinition.singleLine = QLatin1Char('#');
-
- ah->setupActions(this);
}
TextEditor::BaseTextEditor *CMakeEditorWidget::createEditor()
@@ -203,7 +205,7 @@ CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
// TODO: Resolve variables
- QDir dir(QFileInfo(editorDocument()->filePath()).absolutePath());
+ QDir dir(QFileInfo(baseTextDocument()->filePath()).absolutePath());
QString fileName = dir.filePath(buffer);
QFileInfo fi(fileName);
if (fi.exists()) {
@@ -230,6 +232,7 @@ CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
CMakeDocument::CMakeDocument()
: TextEditor::BaseTextDocument()
{
+ setMimeType(QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE));
}
QString CMakeDocument::defaultPath() const
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.h b/src/plugins/cmakeprojectmanager/cmakeeditor.h
index a508c7b391..dffc1e95d8 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.h
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.h
@@ -30,8 +30,6 @@
#ifndef CMAKEEDITOR_H
#define CMAKEEDITOR_H
-#include "cmakeeditorfactory.h"
-
#include <texteditor/basetextdocument.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/codeassist/completionassistprovider.h>
@@ -57,7 +55,7 @@ public:
CMakeEditor(CMakeEditorWidget *);
bool duplicateSupported() const { return true; }
- Core::IEditor *duplicate(QWidget *parent);
+ Core::IEditor *duplicate();
Core::Id id() const;
TextEditor::CompletionAssistProvider *completionAssistProvider();
@@ -71,13 +69,11 @@ class CMakeEditorWidget : public TextEditor::BaseTextEditorWidget
Q_OBJECT
public:
- CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah);
+ CMakeEditorWidget(QWidget *parent = 0);
+ CMakeEditorWidget(CMakeEditorWidget *other);
bool save(const QString &fileName = QString());
- CMakeEditorFactory *factory() { return m_factory; }
- TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; }
-
Link findLinkAt(const QTextCursor &cursor, bool resolveTarget = true, bool inNextSplit = false);
protected:
@@ -88,8 +84,8 @@ public slots:
void unCommentSelection();
private:
- CMakeEditorFactory *m_factory;
- TextEditor::TextEditorActionHandler *m_ah;
+ CMakeEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
+ void ctor();
Utils::CommentDefinition m_commentDefinition;
};
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp
index f3035d3204..de86d401b9 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp
@@ -52,8 +52,7 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager)
setDisplayName(tr(CMakeProjectManager::Constants::CMAKE_EDITOR_DISPLAY_NAME));
addMimeType(CMakeProjectManager::Constants::CMAKEMIMETYPE);
- m_actionHandler =
- new TextEditorActionHandler(Constants::C_CMAKEEDITOR,
+ new TextEditorActionHandler(this, Constants::C_CMAKEEDITOR,
TextEditorActionHandler::UnCommentSelection
| TextEditorActionHandler::JumpToFileUnderCursor);
@@ -70,9 +69,9 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager)
contextMenu->addAction(cmd);
}
-Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *CMakeEditorFactory::createEditor()
{
- CMakeEditorWidget *rc = new CMakeEditorWidget(parent, this, m_actionHandler);
+ CMakeEditorWidget *rc = new CMakeEditorWidget();
TextEditor::TextEditorSettings::initializeEditor(rc);
return rc->editor();
}
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h
index a73f127f6f..4d6b4fae95 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h
+++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h
@@ -34,8 +34,6 @@
#include <coreplugin/editormanager/ieditorfactory.h>
-namespace TextEditor { class TextEditorActionHandler; }
-
namespace CMakeProjectManager {
namespace Internal {
@@ -45,12 +43,11 @@ class CMakeEditorFactory : public Core::IEditorFactory
public:
CMakeEditorFactory(CMakeManager *parent);
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
private:
const QStringList m_mimeTypes;
CMakeManager *m_manager;
- TextEditor::TextEditorActionHandler *m_actionHandler;
};
} // namespace Internal
diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp
index 39ac8bc91d..6e498b317c 100644
--- a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp
@@ -64,17 +64,17 @@ CMakeLocatorFilter::~CMakeLocatorFilter()
}
-QList<Locator::FilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
+QList<Core::LocatorFilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry)
{
Q_UNUSED(future)
- QList<Locator::FilterEntry> result;
+ QList<Core::LocatorFilterEntry> result;
foreach (Project *p, SessionManager::projects()) {
CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p);
if (cmakeProject) {
foreach (const CMakeBuildTarget &ct, cmakeProject->buildTargets()) {
if (ct.title.contains(entry)) {
- Locator::FilterEntry entry(this, ct.title, cmakeProject->projectFilePath());
+ Core::LocatorFilterEntry entry(this, ct.title, cmakeProject->projectFilePath());
entry.extraInfo = FileUtils::shortNativePath(
FileName::fromString(cmakeProject->projectFilePath()));
result.append(entry);
@@ -86,7 +86,7 @@ QList<Locator::FilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Loca
return result;
}
-void CMakeLocatorFilter::accept(Locator::FilterEntry selection) const
+void CMakeLocatorFilter::accept(Core::LocatorFilterEntry selection) const
{
// Get the project containing the target selected
CMakeProject *cmakeProject = 0;
diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h
index a2476d7a8e..c50c52dcd2 100644
--- a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h
+++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h
@@ -30,14 +30,14 @@
#ifndef CMAKELOCATORFILTER_H
#define CMAKELOCATORFILTER_H
-#include <locator/ilocatorfilter.h>
+#include <coreplugin/locator/ilocatorfilter.h>
#include <QIcon>
namespace CMakeProjectManager {
namespace Internal {
-class CMakeLocatorFilter : public Locator::ILocatorFilter
+class CMakeLocatorFilter : public Core::ILocatorFilter
{
Q_OBJECT
@@ -45,8 +45,8 @@ public:
CMakeLocatorFilter();
~CMakeLocatorFilter();
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
private slots:
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index c86f3d47cc..7c75de5ac2 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -92,6 +92,7 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
m_rootNode(new CMakeProjectNode(fileName)),
m_watcher(new QFileSystemWatcher(this))
{
+ setId(Constants::CMAKEPROJECT_ID);
setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX));
@@ -349,7 +350,7 @@ bool CMakeProject::parseCMakeLists()
// This explicitly adds -I. to the include paths
part->includePaths += projectDirectory();
part->includePaths += cbpparser.includeFiles();
- part->defines += cbpparser.defines();
+ part->projectDefines += cbpparser.defines();
CppTools::ProjectFileAdder adder(part->files);
foreach (const QString &file, m_files)
@@ -512,11 +513,6 @@ QString CMakeProject::displayName() const
return m_projectName;
}
-Core::Id CMakeProject::id() const
-{
- return Core::Id(Constants::CMAKEPROJECT_ID);
-}
-
Core::IDocument *CMakeProject::document() const
{
return m_file;
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h
index 67d420fa2d..1ba92dd82b 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.h
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.h
@@ -80,7 +80,6 @@ public:
~CMakeProject();
QString displayName() const;
- Core::Id id() const;
Core::IDocument *document() const;
CMakeManager *projectManager() const;
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
index 42d35eba6f..c587850c8a 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
@@ -291,22 +291,23 @@ QString CMakeSettingsPage::findCmakeExecutable() const
return Utils::Environment::systemEnvironment().searchInPath(QLatin1String("cmake"));
}
-QWidget *CMakeSettingsPage::createPage(QWidget *parent)
+QWidget *CMakeSettingsPage::widget()
{
- QWidget *outerWidget = new QWidget(parent);
- QFormLayout *formLayout = new QFormLayout(outerWidget);
- formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
- m_pathchooser = new Utils::PathChooser;
- m_pathchooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
- formLayout->addRow(tr("Executable:"), m_pathchooser);
- formLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
+ if (!m_widget) {
+ m_widget = new QWidget;
+ QFormLayout *formLayout = new QFormLayout(m_widget);
+ formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
+ m_pathchooser = new Utils::PathChooser;
+ m_pathchooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
+ formLayout->addRow(tr("Executable:"), m_pathchooser);
+ formLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
+
+ m_preferNinja = new QCheckBox(tr("Prefer Ninja generator (CMake 2.8.9 or higher required)"));
+ formLayout->addRow(m_preferNinja);
+ }
m_pathchooser->setPath(m_cmakeValidatorForUser.cmakeExecutable());
-
- m_preferNinja = new QCheckBox(tr("Prefer Ninja generator (CMake 2.8.9 or higher required)"));
m_preferNinja->setChecked(preferNinja());
- formLayout->addRow(m_preferNinja);
-
- return outerWidget;
+ return m_widget;
}
void CMakeSettingsPage::saveSettings() const
@@ -329,7 +330,7 @@ void CMakeSettingsPage::apply()
void CMakeSettingsPage::finish()
{
-
+ delete m_widget;
}
QString CMakeSettingsPage::cmakeExecutable() const
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
index 930e60bd4a..ae7e59b5d3 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h
@@ -40,12 +40,13 @@
#include <utils/environment.h>
#include <utils/pathchooser.h>
-#include <QFuture>
-#include <QStringList>
+#include <QAction>
#include <QCheckBox>
#include <QDir>
+#include <QFuture>
+#include <QPointer>
+#include <QStringList>
#include <QVector>
-#include <QAction>
#include "cmakevalidator.h"
@@ -108,7 +109,7 @@ public:
CMakeSettingsPage();
~CMakeSettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
@@ -125,6 +126,7 @@ private:
void saveSettings() const;
QString findCmakeExecutable() const;
+ QPointer<QWidget> m_widget;
Utils::PathChooser *m_pathchooser;
QCheckBox *m_preferNinja;
CMakeValidator m_cmakeValidatorForUser;
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs
index 42eafccae7..9232f5d60a 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs
@@ -9,7 +9,6 @@ QtcPlugin {
Depends { name: "Core" }
Depends { name: "CppTools" }
Depends { name: "CPlusPlus" }
- Depends { name: "Locator" }
Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" }
Depends { name: "QtSupport" }
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri b/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri
index 7ae1e8c822..25940e7260 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri
@@ -1,7 +1,6 @@
QTC_PLUGIN_NAME = CMakeProjectManager
QTC_PLUGIN_DEPENDS += \
coreplugin \
- locator \
projectexplorer \
cpptools \
texteditor \
diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp
index 4178d718bb..d2de5a46ba 100644
--- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp
@@ -212,16 +212,6 @@ void CMakeRunConfiguration::setCommandLineArguments(const QString &newText)
m_arguments = newText;
}
-QString CMakeRunConfiguration::dumperLibrary() const
-{
- return QtSupport::QtKitInformation::dumperLibrary(target()->kit());
-}
-
-QStringList CMakeRunConfiguration::dumperLibraryLocations() const
-{
- return QtSupport::QtKitInformation::dumperLibraryLocations(target()->kit());
-}
-
void CMakeRunConfiguration::setEnabled(bool b)
{
if (m_enabled == b)
diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h
index 9963057392..32669debf2 100644
--- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h
+++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h
@@ -70,9 +70,6 @@ public:
QString title() const;
- QString dumperLibrary() const;
- QStringList dumperLibraryLocations() const;
-
QVariantMap toMap() const;
void setEnabled(bool b);
diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.cpp b/src/plugins/coreplugin/actionmanager/actionmanager.cpp
index b219546ace..2b87746c85 100644
--- a/src/plugins/coreplugin/actionmanager/actionmanager.cpp
+++ b/src/plugins/coreplugin/actionmanager/actionmanager.cpp
@@ -336,7 +336,7 @@ QList<Command *> ActionManager::commands()
{
// transform list of CommandPrivate into list of Command
QList<Command *> result;
- foreach (Command *cmd, d->m_idCmdMap.values())
+ foreach (Command *cmd, d->m_idCmdMap)
result << cmd;
return result;
}
diff --git a/src/plugins/coreplugin/actionmanager/commandmappings.cpp b/src/plugins/coreplugin/actionmanager/commandmappings.cpp
index 85099285a0..53a96cbab4 100644
--- a/src/plugins/coreplugin/actionmanager/commandmappings.cpp
+++ b/src/plugins/coreplugin/actionmanager/commandmappings.cpp
@@ -50,42 +50,43 @@ CommandMappings::CommandMappings(QObject *parent)
// IOptionsPage
-QWidget *CommandMappings::createPage(QWidget *parent)
+QWidget *CommandMappings::widget()
{
- m_page = new Ui::CommandMappings();
- QWidget *w = new QWidget(parent);
- m_page->setupUi(w);
- m_page->targetEdit->setAutoHideButton(Utils::FancyLineEdit::Right, true);
- m_page->targetEdit->setPlaceholderText(QString());
- m_page->targetEdit->installEventFilter(this);
-
- connect(m_page->targetEdit, SIGNAL(buttonClicked(Utils::FancyLineEdit::Side)),
- this, SLOT(removeTargetIdentifier()));
- connect(m_page->resetButton, SIGNAL(clicked()),
- this, SLOT(resetTargetIdentifier()));
- connect(m_page->exportButton, SIGNAL(clicked()),
- this, SLOT(exportAction()));
- connect(m_page->importButton, SIGNAL(clicked()),
- this, SLOT(importAction()));
- connect(m_page->defaultButton, SIGNAL(clicked()),
- this, SLOT(defaultAction()));
-
- initialize();
-
- m_page->commandList->sortByColumn(0, Qt::AscendingOrder);
-
- connect(m_page->filterEdit, SIGNAL(textChanged(QString)),
- this, SLOT(filterChanged(QString)));
- connect(m_page->commandList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
- this, SLOT(commandChanged(QTreeWidgetItem*)));
- connect(m_page->targetEdit, SIGNAL(textChanged(QString)),
- this, SLOT(targetIdentifierChanged()));
-
- new Utils::HeaderViewStretcher(m_page->commandList->header(), 1);
-
- commandChanged(0);
-
- return w;
+ if (!m_widget) {
+ m_page = new Ui::CommandMappings();
+ m_widget = new QWidget;
+ m_page->setupUi(m_widget);
+ m_page->targetEdit->setAutoHideButton(Utils::FancyLineEdit::Right, true);
+ m_page->targetEdit->setPlaceholderText(QString());
+ m_page->targetEdit->installEventFilter(this);
+
+ connect(m_page->targetEdit, SIGNAL(buttonClicked(Utils::FancyLineEdit::Side)),
+ this, SLOT(removeTargetIdentifier()));
+ connect(m_page->resetButton, SIGNAL(clicked()),
+ this, SLOT(resetTargetIdentifier()));
+ connect(m_page->exportButton, SIGNAL(clicked()),
+ this, SLOT(exportAction()));
+ connect(m_page->importButton, SIGNAL(clicked()),
+ this, SLOT(importAction()));
+ connect(m_page->defaultButton, SIGNAL(clicked()),
+ this, SLOT(defaultAction()));
+
+ initialize();
+
+ m_page->commandList->sortByColumn(0, Qt::AscendingOrder);
+
+ connect(m_page->filterEdit, SIGNAL(textChanged(QString)),
+ this, SLOT(filterChanged(QString)));
+ connect(m_page->commandList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
+ this, SLOT(commandChanged(QTreeWidgetItem*)));
+ connect(m_page->targetEdit, SIGNAL(textChanged(QString)),
+ this, SLOT(targetIdentifierChanged()));
+
+ new Utils::HeaderViewStretcher(m_page->commandList->header(), 1);
+
+ commandChanged(0);
+ }
+ return m_widget;
}
void CommandMappings::setImportExportEnabled(bool enabled)
@@ -126,6 +127,7 @@ void CommandMappings::setTargetHeader(const QString &s)
void CommandMappings::finish()
{
+ delete m_widget;
if (!m_page) // page was never shown
return;
delete m_page;
diff --git a/src/plugins/coreplugin/actionmanager/commandmappings.h b/src/plugins/coreplugin/actionmanager/commandmappings.h
index db1296dfb6..df3ce639c9 100644
--- a/src/plugins/coreplugin/actionmanager/commandmappings.h
+++ b/src/plugins/coreplugin/actionmanager/commandmappings.h
@@ -33,6 +33,7 @@
#include <coreplugin/dialogs/ioptionspage.h>
#include <QObject>
+#include <QPointer>
QT_BEGIN_NAMESPACE
class QLineEdit;
@@ -60,7 +61,7 @@ protected slots:
protected:
// IOptionsPage
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
virtual void apply() {}
virtual void finish();
@@ -80,6 +81,7 @@ protected:
virtual void markPossibleCollisions(QTreeWidgetItem *) {}
virtual void resetCollisionMarkers() {}
private:
+ QPointer<QWidget> m_widget;
Internal::Ui::CommandMappings *m_page;
};
diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp
index c6869dd175..e16a4e7f96 100644
--- a/src/plugins/coreplugin/coreplugin.cpp
+++ b/src/plugins/coreplugin/coreplugin.cpp
@@ -35,8 +35,11 @@
#include "mimedatabase.h"
#include "modemanager.h"
#include "infobar.h"
+
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/find/findplugin.h>
+#include <coreplugin/locator/locatorplugin.h>
#include <utils/savefile.h>
@@ -51,10 +54,15 @@ CorePlugin::CorePlugin() : m_editMode(0), m_designMode(0)
{
qRegisterMetaType<Core::Id>();
m_mainWindow = new MainWindow;
+ m_findPlugin = new FindPlugin;
+ m_locatorPlugin = new LocatorPlugin;
}
CorePlugin::~CorePlugin()
{
+ delete m_findPlugin;
+ delete m_locatorPlugin;
+
if (m_editMode) {
removeObject(m_editMode);
delete m_editMode;
@@ -98,6 +106,9 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
// Make sure we respect the process's umask when creating new files
Utils::SaveFile::initializeUmask();
+ m_findPlugin->initialize(arguments, errorMessage);
+ m_locatorPlugin->initialize(this, arguments, errorMessage);
+
return success;
}
@@ -107,11 +118,14 @@ void CorePlugin::extensionsInitialized()
if (m_designMode->designModeIsRequired())
addObject(m_designMode);
m_mainWindow->extensionsInitialized();
+ m_findPlugin->extensionsInitialized();
+ m_locatorPlugin->extensionsInitialized();
}
bool CorePlugin::delayedInitialize()
{
HelpManager::setupHelpManager();
+ m_locatorPlugin->delayedInitialize();
return true;
}
diff --git a/src/plugins/coreplugin/coreplugin.h b/src/plugins/coreplugin/coreplugin.h
index 6a50bc0960..fd6d1ad662 100644
--- a/src/plugins/coreplugin/coreplugin.h
+++ b/src/plugins/coreplugin/coreplugin.h
@@ -33,11 +33,15 @@
#include <extensionsystem/iplugin.h>
namespace Core {
+
class DesignMode;
+class FindPlugin;
+
namespace Internal {
class EditMode;
class MainWindow;
+class LocatorPlugin;
class CorePlugin : public ExtensionSystem::IPlugin
{
@@ -57,12 +61,20 @@ public:
public slots:
void fileOpenRequest(const QString&);
+private slots:
+#if defined(WITH_TESTS)
+ void testVcsManager_data();
+ void testVcsManager();
+#endif
+
private:
void parseArguments(const QStringList & arguments);
MainWindow *m_mainWindow;
EditMode *m_editMode;
DesignMode *m_designMode;
+ FindPlugin *m_findPlugin;
+ LocatorPlugin *m_locatorPlugin;
};
} // namespace Internal
diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro
index 10b4087a43..3b68f06f26 100644
--- a/src/plugins/coreplugin/coreplugin.pro
+++ b/src/plugins/coreplugin/coreplugin.pro
@@ -206,11 +206,14 @@ FORMS += dialogs/newdialog.ui \
mimetypesettingspage.ui \
mimetypemagicdialog.ui \
removefiledialog.ui \
- dialogs/addtovcsdialog.ui
+ dialogs/addtovcsdialog.ui
RESOURCES += core.qrc \
fancyactionbar.qrc
+include(find/find.pri)
+include(locator/locator.pri)
+
win32 {
SOURCES += progressmanager/progressmanager_win.cpp
greaterThan(QT_MAJOR_VERSION, 4): QT += gui-private # Uses QPlatformNativeInterface.
diff --git a/src/plugins/coreplugin/coreplugin.qbs b/src/plugins/coreplugin/coreplugin.qbs
index b7b6c93b38..a18785cdd3 100644
--- a/src/plugins/coreplugin/coreplugin.qbs
+++ b/src/plugins/coreplugin/coreplugin.qbs
@@ -1,4 +1,5 @@
import qbs.base 1.0
+import qbs.FileInfo
import QtcPlugin
QtcPlugin {
@@ -183,6 +184,92 @@ QtcPlugin {
files: [
"testdatadir.cpp",
"testdatadir.h",
+ "locator/locatorfiltertest.cpp",
+ "locator/locatorfiltertest.h",
+ "locator/locator_test.cpp"
+ ]
+
+ cpp.defines: outer.concat(['SRCDIR="' + FileInfo.path(filePath) + '"'])
+ }
+
+ Group {
+ name: "Find"
+ prefix: "find/"
+ files: [
+ "basetextfind.cpp",
+ "basetextfind.h",
+ "currentdocumentfind.cpp",
+ "currentdocumentfind.h",
+ "find.qrc",
+ "finddialog.ui",
+ "findplugin.cpp",
+ "findplugin.h",
+ "findtoolbar.cpp",
+ "findtoolbar.h",
+ "findtoolwindow.cpp",
+ "findtoolwindow.h",
+ "findwidget.ui",
+ "ifindfilter.cpp",
+ "ifindfilter.h",
+ "ifindsupport.cpp",
+ "ifindsupport.h",
+ "searchresultcolor.h",
+ "searchresulttreeitemdelegate.cpp",
+ "searchresulttreeitemdelegate.h",
+ "searchresulttreeitemroles.h",
+ "searchresulttreeitems.cpp",
+ "searchresulttreeitems.h",
+ "searchresulttreemodel.cpp",
+ "searchresulttreemodel.h",
+ "searchresulttreeview.cpp",
+ "searchresulttreeview.h",
+ "searchresultwidget.cpp",
+ "searchresultwidget.h",
+ "searchresultwindow.cpp",
+ "searchresultwindow.h",
+ "textfindconstants.h",
+ "treeviewfind.cpp",
+ "treeviewfind.h",
+ ]
+ }
+
+ Group {
+ name: "Locator"
+ prefix: "locator/"
+ files: [
+ "basefilefilter.cpp",
+ "basefilefilter.h",
+ "commandlocator.cpp",
+ "commandlocator.h",
+ "directoryfilter.cpp",
+ "directoryfilter.h",
+ "directoryfilter.ui",
+ "executefilter.cpp",
+ "executefilter.h",
+ "filesystemfilter.cpp",
+ "filesystemfilter.h",
+ "filesystemfilter.ui",
+ "ilocatorfilter.cpp",
+ "ilocatorfilter.h",
+ "locator.qrc",
+ "locatorconstants.h",
+ "locatorfiltersfilter.cpp",
+ "locatorfiltersfilter.h",
+ "locatormanager.cpp",
+ "locatormanager.h",
+ "locatorplugin.cpp",
+ "locatorplugin.h",
+ "locatorsearchutils.cpp",
+ "locatorsearchutils.h",
+ "locatorwidget.cpp",
+ "locatorwidget.h",
+ "opendocumentsfilter.cpp",
+ "opendocumentsfilter.h",
+ "settingspage.cpp",
+ "settingspage.h",
+ "settingspage.ui",
+ "images/locator.png",
+ "images/reload.png",
]
}
diff --git a/src/plugins/coreplugin/dialogs/ioptionspage.cpp b/src/plugins/coreplugin/dialogs/ioptionspage.cpp
index 73ab549563..276fc86646 100644
--- a/src/plugins/coreplugin/dialogs/ioptionspage.cpp
+++ b/src/plugins/coreplugin/dialogs/ioptionspage.cpp
@@ -29,6 +29,11 @@
#include "ioptionspage.h"
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QPushButton>
+
/*!
\class Core::IOptionsPage
\mainclass
@@ -43,12 +48,58 @@
\li \c displayName() is the (translated) name for display
\li \c category() is the unique id for the category that the page should be displayed in
\li \c displayCategory() is the translated name of the category
- \li \c createPage() is called to retrieve the widget to show in the
- \gui Options dialog
- The widget will be destroyed by the widget hierarchy when the dialog closes
+ \li \c widget() is called to retrieve the widget to show in the
+ \gui Options dialog. You should create a widget lazily here, and delete it again in the
+ finish() method. This method can be called multiple times, so you should only create a new
+ widget if the old one was deleted.
\li \c apply() is called to store the settings. It should detect if any changes have been
made and store those
- \li \c finish() is called directly before the \gui Options dialog closes
- \li \c matches() is used for the \gui Options dialog search filter
+ \li \c finish() is called directly before the \gui Options dialog closes. Here you should delete
+ the widget that was created in widget() to free resources.
+ \li \c matches() is used for the \gui Options dialog search filter. The default implementation
+ takes the widget() and searches for all labels, buttons, checkboxes and group boxes,
+ and matches on their texts/titles. You can implement your own matching algorithm, but
+ usually the default implementation will work fine.
\endlist
*/
+
+
+Core::IOptionsPage::IOptionsPage(QObject *parent)
+ : QObject(parent),
+ m_keywordsInitialized(false)
+{
+
+}
+
+Core::IOptionsPage::~IOptionsPage()
+{
+}
+
+bool Core::IOptionsPage::matches(const QString &searchKeyWord) const
+{
+ if (!m_keywordsInitialized) {
+ IOptionsPage *that = const_cast<IOptionsPage *>(this);
+ QWidget *widget = that->widget();
+ if (!widget)
+ return false;
+ // find common subwidgets
+ foreach (const QLabel *label, widget->findChildren<QLabel *>())
+ m_keywords << label->text();
+ foreach (const QCheckBox *checkbox, widget->findChildren<QCheckBox *>())
+ m_keywords << checkbox->text();
+ foreach (const QPushButton *pushButton, widget->findChildren<QPushButton *>())
+ m_keywords << pushButton->text();
+ foreach (const QGroupBox *groupBox, widget->findChildren<QGroupBox *>())
+ m_keywords << groupBox->title();
+
+ // clean up accelerators
+ QMutableStringListIterator it(m_keywords);
+ while (it.hasNext())
+ it.next().remove(QLatin1Char('&'));
+ m_keywordsInitialized = true;
+ }
+ foreach (const QString &keyword, m_keywords)
+ if (keyword.contains(searchKeyWord, Qt::CaseInsensitive))
+ return true;
+ return false;
+}
diff --git a/src/plugins/coreplugin/dialogs/ioptionspage.h b/src/plugins/coreplugin/dialogs/ioptionspage.h
index aa468ef828..915b8b0462 100644
--- a/src/plugins/coreplugin/dialogs/ioptionspage.h
+++ b/src/plugins/coreplugin/dialogs/ioptionspage.h
@@ -34,6 +34,7 @@
#include <QIcon>
#include <QObject>
+#include <QStringList>
namespace Core {
@@ -42,7 +43,8 @@ class CORE_EXPORT IOptionsPage : public QObject
Q_OBJECT
public:
- IOptionsPage(QObject *parent = 0) : QObject(parent) {}
+ IOptionsPage(QObject *parent = 0);
+ virtual ~IOptionsPage();
Id id() const { return m_id; }
QString displayName() const { return m_displayName; }
@@ -50,8 +52,8 @@ public:
QString displayCategory() const { return m_displayCategory; }
QIcon categoryIcon() const { return QIcon(m_categoryIcon); }
- virtual bool matches(const QString & /* searchKeyWord*/) const { return false; }
- virtual QWidget *createPage(QWidget *parent) = 0;
+ virtual bool matches(const QString &searchKeyWord) const;
+ virtual QWidget *widget() = 0;
virtual void apply() = 0;
virtual void finish() = 0;
@@ -67,6 +69,9 @@ protected:
QString m_displayName;
QString m_displayCategory;
QString m_categoryIcon;
+
+ mutable bool m_keywordsInitialized;
+ mutable QStringList m_keywords;
};
/*
@@ -89,6 +94,7 @@ public:
QIcon categoryIcon() const { return QIcon(m_categoryIcon); }
virtual QList<IOptionsPage *> pages() const = 0;
+ virtual bool matches(const QString & /* searchKeyWord*/) const = 0;
protected:
void setCategory(Core::Id category) { m_category = category; }
diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp
index 363b9195cb..5ea4bfe624 100644
--- a/src/plugins/coreplugin/dialogs/newdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/newdialog.cpp
@@ -194,7 +194,7 @@ NewDialog::NewDialog(QWidget *parent) :
m_ui->frame->setPalette(p);
m_okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok);
m_okButton->setDefault(true);
- m_okButton->setText(tr("&Choose..."));
+ m_okButton->setText(tr("Choose..."));
m_model = new QStandardItemModel(this);
m_twoLevelProxyModel = new TwoLevelProxyModel(this);
diff --git a/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp b/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp
index 33ebb692f1..78b50547f1 100644
--- a/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp
@@ -257,33 +257,33 @@ int ReadOnlyFilesDialog::exec()
ReadOnlyResult result = RO_Cancel;
QStringList failedToMakeWritable;
- foreach (ReadOnlyFilesDialogPrivate::ButtonGroupForFile buttengroup, d->buttonGroups) {
- result = static_cast<ReadOnlyResult>(buttengroup.group->checkedId());
+ foreach (ReadOnlyFilesDialogPrivate::ButtonGroupForFile buttongroup, d->buttonGroups) {
+ result = static_cast<ReadOnlyResult>(buttongroup.group->checkedId());
switch (result) {
case RO_MakeWritable:
- if (!Utils::FileUtils::makeWritable(Utils::FileName(QFileInfo(buttengroup.fileName)))) {
- failedToMakeWritable << buttengroup.fileName;
+ if (!Utils::FileUtils::makeWritable(Utils::FileName(QFileInfo(buttongroup.fileName)))) {
+ failedToMakeWritable << buttongroup.fileName;
continue;
}
break;
case RO_OpenVCS:
- if (!d->versionControls[buttengroup.fileName]->vcsOpen(buttengroup.fileName)) {
- failedToMakeWritable << buttengroup.fileName;
+ if (!d->versionControls[buttongroup.fileName]->vcsOpen(buttongroup.fileName)) {
+ failedToMakeWritable << buttongroup.fileName;
continue;
}
break;
case RO_SaveAs:
if (!EditorManager::saveDocumentAs(d->document)) {
- failedToMakeWritable << buttengroup.fileName;
+ failedToMakeWritable << buttongroup.fileName;
continue;
}
break;
default:
- failedToMakeWritable << buttengroup.fileName;
+ failedToMakeWritable << buttongroup.fileName;
continue;
}
- if (!QFileInfo(buttengroup.fileName).isWritable())
- failedToMakeWritable << buttengroup.fileName;
+ if (!QFileInfo(buttongroup.fileName).isWritable())
+ failedToMakeWritable << buttongroup.fileName;
}
if (!failedToMakeWritable.isEmpty()) {
if (d->showWarnings)
@@ -366,7 +366,7 @@ void ReadOnlyFilesDialog::updateSelectAll()
void ReadOnlyFilesDialog::initDialog(const QStringList &fileNames)
{
ui->setupUi(this);
- ui->buttonBox->addButton(tr("&Change Permission"), QDialogButtonBox::AcceptRole);
+ ui->buttonBox->addButton(tr("Change &Permission"), QDialogButtonBox::AcceptRole);
ui->buttonBox->addButton(QDialogButtonBox::Cancel);
QString vcsOpenTextForAll;
@@ -389,7 +389,7 @@ void ReadOnlyFilesDialog::initDialog(const QStringList &fileNames)
IVersionControl *versionControlForFile =
VcsManager::findVersionControlForDirectory(directory);
const bool fileManagedByVCS = versionControlForFile
- && versionControlForFile->openSupportMode() != IVersionControl::NoOpen;
+ && versionControlForFile->openSupportMode(fileName) != IVersionControl::NoOpen;
if (fileManagedByVCS) {
const QString vcsOpenTextForFile =
versionControlForFile->vcsOpenText().remove(QLatin1Char('&'));
@@ -407,7 +407,7 @@ void ReadOnlyFilesDialog::initDialog(const QStringList &fileNames)
vcsMakeWritableTextForAll.clear();
}
// Add make writable if it is supported by the reposetory.
- if (versionControlForFile->openSupportMode() == IVersionControl::OpenOptional) {
+ if (versionControlForFile->openSupportMode(fileName) == IVersionControl::OpenOptional) {
useMakeWritable = true;
createRadioButtonForItem(item, radioButtonGroup, MakeWritable);
}
diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp
index ae3c8c47c3..e2de47cf98 100644
--- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp
@@ -66,12 +66,15 @@ static QPointer<SettingsDialog> m_instance = 0;
class Category
{
public:
+ Category() : index(-1), providerPagesCreated(false) { }
+
Id id;
int index;
QString displayName;
QIcon icon;
QList<IOptionsPage *> pages;
QList<IOptionsPageProvider *> providers;
+ bool providerPagesCreated;
QTabWidget *tabWidget;
};
@@ -210,15 +213,23 @@ bool CategoryFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sou
if (QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent))
return true;
+ const QString pattern = filterRegExp().pattern();
const CategoryModel *cm = static_cast<CategoryModel*>(sourceModel());
- foreach (const IOptionsPage *page, cm->categories().at(sourceRow)->pages) {
- const QString pattern = filterRegExp().pattern();
+ const Category *category = cm->categories().at(sourceRow);
+ foreach (const IOptionsPage *page, category->pages) {
if (page->displayCategory().contains(pattern, Qt::CaseInsensitive)
- || page->displayName().contains(pattern, Qt::CaseInsensitive)
- || page->matches(pattern))
+ || page->displayName().contains(pattern, Qt::CaseInsensitive)
+ || page->matches(pattern))
return true;
}
+ if (!category->providerPagesCreated) {
+ foreach (const IOptionsPageProvider *provider, category->providers) {
+ if (provider->matches(pattern))
+ return true;
+ }
+ }
+
return false;
}
@@ -325,8 +336,6 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
// The order of the slot connection matters here, the filter slot
// opens the matching page after the model has filtered.
connect(m_filterLineEdit, SIGNAL(filterChanged(QString)),
- this, SLOT(ensureAllCategoryWidgets()));
- connect(m_filterLineEdit, SIGNAL(filterChanged(QString)),
m_proxyModel, SLOT(setFilterFixedString(QString)));
connect(m_filterLineEdit, SIGNAL(filterChanged(QString)), this, SLOT(filter(QString)));
m_categoryList->setFocus();
@@ -432,15 +441,18 @@ void SettingsDialog::ensureCategoryWidget(Category *category)
{
if (category->tabWidget != 0)
return;
- foreach (const IOptionsPageProvider *provider, category->providers) {
- category->pages += provider->pages();
+ if (!category->providerPagesCreated) {
+ foreach (const IOptionsPageProvider *provider, category->providers)
+ category->pages += provider->pages();
+ category->providerPagesCreated = true;
}
+
qStableSort(category->pages.begin(), category->pages.end(), optionsPageLessThan);
QTabWidget *tabWidget = new QTabWidget;
for (int j = 0; j < category->pages.size(); ++j) {
IOptionsPage *page = category->pages.at(j);
- QWidget *widget = page->createPage(0);
+ QWidget *widget = page->widget();
tabWidget->addTab(widget, page->displayName());
}
@@ -451,12 +463,6 @@ void SettingsDialog::ensureCategoryWidget(Category *category)
category->index = m_stackedLayout->addWidget(tabWidget);
}
-void SettingsDialog::ensureAllCategoryWidgets()
-{
- foreach (Category *category, m_model->categories())
- ensureCategoryWidget(category);
-}
-
void SettingsDialog::disconnectTabWidgets()
{
foreach (Category *category, m_model->categories()) {
@@ -514,7 +520,6 @@ void SettingsDialog::currentTabChanged(int index)
void SettingsDialog::filter(const QString &text)
{
- ensureAllCategoryWidgets();
// When there is no current index, select the first one when possible
if (!m_categoryList->currentIndex().isValid() && m_model->rowCount() > 0)
m_categoryList->setCurrentIndex(m_proxyModel->index(0, 0));
diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.h b/src/plugins/coreplugin/dialogs/settingsdialog.h
index 240f9fe279..ce0d62de40 100644
--- a/src/plugins/coreplugin/dialogs/settingsdialog.h
+++ b/src/plugins/coreplugin/dialogs/settingsdialog.h
@@ -79,7 +79,6 @@ private slots:
void currentChanged(const QModelIndex &current);
void currentTabChanged(int);
void filter(const QString &text);
- void ensureAllCategoryWidgets();
private:
SettingsDialog(QWidget *parent);
diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
index 696a661889..6db5e843b1 100644
--- a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
+++ b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
@@ -61,12 +61,12 @@ ShortcutSettings::ShortcutSettings(QObject *parent)
setCategoryIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
}
-QWidget *ShortcutSettings::createPage(QWidget *parent)
+QWidget *ShortcutSettings::widget()
{
m_initialized = true;
m_keyNum = m_key[0] = m_key[1] = m_key[2] = m_key[3] = 0;
- QWidget *w = CommandMappings::createPage(parent);
+ QWidget *w = CommandMappings::widget();
const QString pageTitle = tr("Keyboard Shortcuts");
const QString targetLabelText = tr("Key sequence:");
@@ -78,12 +78,6 @@ QWidget *ShortcutSettings::createPage(QWidget *parent)
setTargetHeader(editTitle);
targetEdit()->setPlaceholderText(tr("Type to set shortcut"));
- if (m_searchKeywords.isEmpty()) {
- QTextStream(&m_searchKeywords) << ' ' << pageTitle
- << ' ' << targetLabelText
- << ' ' << editTitle;
- }
-
return w;
}
@@ -102,11 +96,6 @@ void ShortcutSettings::finish()
m_initialized = false;
}
-bool ShortcutSettings::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
bool ShortcutSettings::eventFilter(QObject *o, QEvent *e)
{
Q_UNUSED(o)
diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.h b/src/plugins/coreplugin/dialogs/shortcutsettings.h
index 23c7a21bfc..26681bd250 100644
--- a/src/plugins/coreplugin/dialogs/shortcutsettings.h
+++ b/src/plugins/coreplugin/dialogs/shortcutsettings.h
@@ -62,10 +62,9 @@ class ShortcutSettings : public Core::CommandMappings
public:
ShortcutSettings(QObject *parent = 0);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &s) const;
protected:
bool eventFilter(QObject *o, QEvent *e);
@@ -94,7 +93,6 @@ private:
QList<ShortcutItem *> m_scitems;
int m_key[4], m_keyNum;
- QString m_searchKeywords;
bool m_initialized;
};
diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp
index ec6348263e..4df60a9d12 100644
--- a/src/plugins/coreplugin/documentmanager.cpp
+++ b/src/plugins/coreplugin/documentmanager.cpp
@@ -1367,11 +1367,6 @@ void DocumentManager::executeOpenWithMenuAction(QAction *action)
EditorManager::openExternalEditor(entry.fileName, entry.externalEditor->id());
}
-void DocumentManager::slotExecuteOpenWithMenuAction(QAction *action)
-{
- executeOpenWithMenuAction(action);
-}
-
bool DocumentManager::eventFilter(QObject *obj, QEvent *e)
{
if (obj == qApp && e->type() == QEvent::ApplicationActivate) {
diff --git a/src/plugins/coreplugin/documentmanager.h b/src/plugins/coreplugin/documentmanager.h
index adf3e7e7dc..2bd7439da0 100644
--- a/src/plugins/coreplugin/documentmanager.h
+++ b/src/plugins/coreplugin/documentmanager.h
@@ -126,10 +126,8 @@ public:
lead to any editors to reload or any other editor manager actions. */
static void notifyFilesChangedInternally(const QStringList &files);
- static void executeOpenWithMenuAction(QAction *action);
-
public slots:
- void slotExecuteOpenWithMenuAction(QAction *action);
+ static void executeOpenWithMenuAction(QAction *action);
signals:
void currentFileChanged(const QString &filePath);
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 60bd9e27db..4c2e9c9bbd 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -1416,7 +1416,7 @@ IEditor *EditorManager::createEditor(const Id &editorId, const QString &fileName
return 0;
}
- IEditor *editor = factories.front()->createEditor(m_instance);
+ IEditor *editor = factories.front()->createEditor();
if (editor)
connect(editor->document(), SIGNAL(changed()), m_instance, SLOT(handleDocumentStateChange()));
if (editor)
@@ -1894,7 +1894,7 @@ void EditorManager::vcsOpenCurrentEditor()
const QString directory = QFileInfo(document->filePath()).absolutePath();
IVersionControl *versionControl = VcsManager::findVersionControlForDirectory(directory);
- if (!versionControl || versionControl->openSupportMode() == IVersionControl::NoOpen)
+ if (!versionControl || versionControl->openSupportMode(document->filePath()) == IVersionControl::NoOpen)
return;
if (!versionControl->vcsOpen(document->filePath())) {
@@ -1956,7 +1956,7 @@ void EditorManager::updateMakeWritableWarning()
bool promptVCS = false;
const QString directory = QFileInfo(document->filePath()).absolutePath();
IVersionControl *versionControl = VcsManager::findVersionControlForDirectory(directory);
- if (versionControl && versionControl->openSupportMode() != IVersionControl::NoOpen) {
+ if (versionControl && versionControl->openSupportMode(document->filePath()) != IVersionControl::NoOpen) {
if (versionControl->settingsFlags() & IVersionControl::AutoOpen) {
vcsOpenCurrentEditor();
ww = false;
@@ -1989,8 +1989,7 @@ void EditorManager::setupSaveActions(IDocument *document, QAction *saveAction, Q
{
saveAction->setEnabled(document != 0 && document->isModified());
saveAsAction->setEnabled(document != 0 && document->isSaveAsAllowed());
- revertToSavedAction->setEnabled(document != 0
- && !document->filePath().isEmpty() && document->isModified());
+ revertToSavedAction->setEnabled(document != 0 && !document->filePath().isEmpty());
const QString documentName = document ? document->displayName() : QString();
QString quotedName;
@@ -1999,7 +1998,9 @@ void EditorManager::setupSaveActions(IDocument *document, QAction *saveAction, Q
quotedName = QLatin1Char('"') + documentName + QLatin1Char('"');
saveAction->setText(tr("&Save %1").arg(quotedName));
saveAsAction->setText(tr("Save %1 &As...").arg(quotedName));
- revertToSavedAction->setText(tr("Revert %1 to Saved").arg(quotedName));
+ revertToSavedAction->setText(document->isModified()
+ ? tr("Revert %1 to Saved").arg(quotedName)
+ : tr("Reload %1").arg(quotedName));
}
}
@@ -2409,7 +2410,7 @@ Core::IEditor *EditorManager::duplicateEditor(Core::IEditor *editor)
if (!editor->duplicateSupported())
return 0;
- IEditor *duplicate = editor->duplicate(0);
+ IEditor *duplicate = editor->duplicate();
duplicate->restoreState(editor->saveState());
emit m_instance->editorCreated(duplicate, duplicate->document()->filePath());
addEditor(duplicate);
diff --git a/src/plugins/coreplugin/editormanager/ieditor.h b/src/plugins/coreplugin/editormanager/ieditor.h
index c38aa84e98..75ba8ddf4b 100644
--- a/src/plugins/coreplugin/editormanager/ieditor.h
+++ b/src/plugins/coreplugin/editormanager/ieditor.h
@@ -52,7 +52,7 @@ public:
virtual Core::Id id() const = 0;
virtual bool duplicateSupported() const { return false; }
- virtual IEditor *duplicate(QWidget * /*parent*/) { return 0; }
+ virtual IEditor *duplicate() { return 0; }
virtual QByteArray saveState() const { return QByteArray(); }
virtual bool restoreState(const QByteArray &/*state*/) { return true; }
diff --git a/src/plugins/coreplugin/editormanager/ieditorfactory.h b/src/plugins/coreplugin/editormanager/ieditorfactory.h
index e4f4f31849..6a08caf9c5 100644
--- a/src/plugins/coreplugin/editormanager/ieditorfactory.h
+++ b/src/plugins/coreplugin/editormanager/ieditorfactory.h
@@ -43,7 +43,7 @@ class CORE_EXPORT IEditorFactory : public Core::IDocumentFactory
public:
IEditorFactory(QObject *parent = 0) : IDocumentFactory(parent) {}
- virtual IEditor *createEditor(QWidget *parent) = 0;
+ virtual IEditor *createEditor() = 0;
virtual IDocument *open(const QString &);
};
diff --git a/src/plugins/coreplugin/editormanager/systemeditor.cpp b/src/plugins/coreplugin/editormanager/systemeditor.cpp
index ec4b78c2c4..d8cac7b423 100644
--- a/src/plugins/coreplugin/editormanager/systemeditor.cpp
+++ b/src/plugins/coreplugin/editormanager/systemeditor.cpp
@@ -54,7 +54,7 @@ Id SystemEditor::id() const
QString SystemEditor::displayName() const
{
- return QLatin1String("System Editor");
+ return tr("System Editor");
}
bool SystemEditor::startEditor(const QString &fileName, QString *errorMessage)
diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp
index 4bdbbfd5ca..3d647a9f89 100644
--- a/src/plugins/coreplugin/editortoolbar.cpp
+++ b/src/plugins/coreplugin/editortoolbar.cpp
@@ -317,10 +317,12 @@ void EditorToolBar::listContextMenu(QPoint pos)
DocumentModel::Entry *entry = EditorManager::documentModel()->documentAtRow(
d->m_editorList->currentIndex());
QString fileName = entry ? entry->fileName() : QString();
- if (fileName.isEmpty())
+ QString shortFileName = entry ? QFileInfo(fileName).fileName() : QString();
+ if (fileName.isEmpty() || shortFileName.isEmpty())
return;
QMenu menu;
QAction *copyPath = menu.addAction(tr("Copy Full Path to Clipboard"));
+ QAction *copyFileName = menu.addAction(tr("Copy File Name to Clipboard"));
menu.addSeparator();
EditorManager::addSaveAndCloseEditorActions(&menu, entry);
menu.addSeparator();
@@ -328,6 +330,8 @@ void EditorToolBar::listContextMenu(QPoint pos)
QAction *result = menu.exec(d->m_editorList->mapToGlobal(pos));
if (result == copyPath)
QApplication::clipboard()->setText(QDir::toNativeSeparators(fileName));
+ if (result == copyFileName)
+ QApplication::clipboard()->setText(shortFileName);
}
void EditorToolBar::makeEditorWritable()
diff --git a/src/plugins/find/basetextfind.cpp b/src/plugins/coreplugin/find/basetextfind.cpp
index 7fa257cfa4..70fdef51bd 100644
--- a/src/plugins/find/basetextfind.cpp
+++ b/src/plugins/coreplugin/find/basetextfind.cpp
@@ -38,7 +38,7 @@
#include <QPlainTextEdit>
#include <QTextCursor>
-namespace Find {
+namespace Core {
struct BaseTextFindPrivate
{
@@ -424,4 +424,4 @@ void BaseTextFind::clearFindScope()
d->m_findScopeVerticalBlockSelectionLastColumn);
}
-} // namespace Find
+} // namespace Core
diff --git a/src/plugins/find/basetextfind.h b/src/plugins/coreplugin/find/basetextfind.h
index b576922302..1d1d54d9ef 100644
--- a/src/plugins/find/basetextfind.h
+++ b/src/plugins/coreplugin/find/basetextfind.h
@@ -30,7 +30,6 @@
#ifndef BASETEXTFIND_H
#define BASETEXTFIND_H
-#include "find_global.h"
#include "ifindsupport.h"
QT_BEGIN_NAMESPACE
@@ -39,10 +38,10 @@ class QTextEdit;
class QTextCursor;
QT_END_NAMESPACE
-namespace Find {
+namespace Core {
struct BaseTextFindPrivate;
-class FIND_EXPORT BaseTextFind : public IFindSupport
+class CORE_EXPORT BaseTextFind : public IFindSupport
{
Q_OBJECT
@@ -68,7 +67,7 @@ public:
void clearFindScope();
signals:
- void highlightAll(const QString &txt, Find::FindFlags findFlags);
+ void highlightAll(const QString &txt, Core::FindFlags findFlags);
void findScopeChanged(const QTextCursor &start, const QTextCursor &end,
int verticalBlockSelectionFirstColumn,
int verticalBlockSelectionLastColumn);
@@ -87,6 +86,6 @@ private:
BaseTextFindPrivate *d;
};
-} // namespace Find
+} // namespace Core
#endif // BASETEXTFIND_H
diff --git a/src/plugins/find/currentdocumentfind.cpp b/src/plugins/coreplugin/find/currentdocumentfind.cpp
index 48723e1535..854a391003 100644
--- a/src/plugins/find/currentdocumentfind.cpp
+++ b/src/plugins/coreplugin/find/currentdocumentfind.cpp
@@ -38,8 +38,8 @@
#include <QWidget>
using namespace Core;
-using namespace Find;
-using namespace Find::Internal;
+using namespace Core;
+using namespace Core::Internal;
CurrentDocumentFind::CurrentDocumentFind()
: m_currentFind(0)
diff --git a/src/plugins/find/currentdocumentfind.h b/src/plugins/coreplugin/find/currentdocumentfind.h
index 2c79ab36ae..2b428e0583 100644
--- a/src/plugins/find/currentdocumentfind.h
+++ b/src/plugins/coreplugin/find/currentdocumentfind.h
@@ -34,7 +34,7 @@
#include <QPointer>
-namespace Find {
+namespace Core {
namespace Internal {
class CurrentDocumentFind : public QObject
@@ -88,6 +88,6 @@ private:
};
} // namespace Internal
-} // namespace Find
+} // namespace Core
#endif // CURRENTDOCUMENTFIND_H
diff --git a/src/plugins/coreplugin/find/find.pri b/src/plugins/coreplugin/find/find.pri
new file mode 100644
index 0000000000..c7e8c836bc
--- /dev/null
+++ b/src/plugins/coreplugin/find/find.pri
@@ -0,0 +1,42 @@
+HEADERS += \
+ $$PWD/findtoolwindow.h \
+ $$PWD/textfindconstants.h \
+ $$PWD/ifindsupport.h \
+ $$PWD/ifindfilter.h \
+ $$PWD/currentdocumentfind.h \
+ $$PWD/basetextfind.h \
+ $$PWD/findtoolbar.h \
+ $$PWD/findplugin.h \
+ $$PWD/searchresultcolor.h \
+ $$PWD/searchresulttreeitemdelegate.h \
+ $$PWD/searchresulttreeitemroles.h \
+ $$PWD/searchresulttreeitems.h \
+ $$PWD/searchresulttreemodel.h \
+ $$PWD/searchresulttreeview.h \
+ $$PWD/searchresultwindow.h \
+ $$PWD/searchresultwidget.h \
+ $$PWD/treeviewfind.h
+
+SOURCES += \
+ $$PWD/findtoolwindow.cpp \
+ $$PWD/currentdocumentfind.cpp \
+ $$PWD/basetextfind.cpp \
+ $$PWD/findtoolbar.cpp \
+ $$PWD/findplugin.cpp \
+ $$PWD/searchresulttreeitemdelegate.cpp \
+ $$PWD/searchresulttreeitems.cpp \
+ $$PWD/searchresulttreemodel.cpp \
+ $$PWD/searchresulttreeview.cpp \
+ $$PWD/searchresultwindow.cpp \
+ $$PWD/ifindfilter.cpp \
+ $$PWD/ifindsupport.cpp \
+ $$PWD/searchresultwidget.cpp \
+ $$PWD/treeviewfind.cpp
+
+FORMS += \
+ $$PWD/findwidget.ui \
+ $$PWD/finddialog.ui
+
+RESOURCES += \
+ $$PWD/find.qrc
+
diff --git a/src/plugins/find/find.qrc b/src/plugins/coreplugin/find/find.qrc
index 0c4e128101..0c4e128101 100644
--- a/src/plugins/find/find.qrc
+++ b/src/plugins/coreplugin/find/find.qrc
diff --git a/src/plugins/find/finddialog.ui b/src/plugins/coreplugin/find/finddialog.ui
index c7eddf9dad..19d41c938c 100644
--- a/src/plugins/find/finddialog.ui
+++ b/src/plugins/coreplugin/find/finddialog.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>Find::Internal::FindDialog</class>
- <widget class="QWidget" name="Find::Internal::FindDialog">
+ <class>Core::Internal::FindDialog</class>
+ <widget class="QWidget" name="Core::Internal::FindDialog">
<property name="geometry">
<rect>
<x>0</x>
diff --git a/src/plugins/coreplugin/find/findplugin.cpp b/src/plugins/coreplugin/find/findplugin.cpp
new file mode 100644
index 0000000000..ebb9f4b183
--- /dev/null
+++ b/src/plugins/coreplugin/find/findplugin.cpp
@@ -0,0 +1,394 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "findplugin.h"
+
+#include "currentdocumentfind.h"
+#include "findtoolbar.h"
+#include "findtoolwindow.h"
+#include "searchresultwindow.h"
+#include "ifindfilter.h"
+
+#include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/actionmanager/actioncontainer.h>
+#include <coreplugin/coreconstants.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/id.h>
+#include <coreplugin/coreplugin.h>
+
+#include <extensionsystem/pluginmanager.h>
+
+#include <utils/qtcassert.h>
+
+#include <QMenu>
+#include <QStringListModel>
+#include <QAction>
+
+#include <QtPlugin>
+#include <QSettings>
+
+/*!
+ \namespace Core::Internal
+ \internal
+*/
+/*!
+ \namespace Core::Internal::ItemDataRoles
+ \internal
+*/
+
+Q_DECLARE_METATYPE(Core::IFindFilter*)
+
+namespace {
+ const int MAX_COMPLETIONS = 50;
+}
+
+namespace Core {
+
+class FindPluginPrivate {
+public:
+ explicit FindPluginPrivate(FindPlugin *q);
+
+ //variables
+ static FindPlugin *m_instance;
+
+ QHash<IFindFilter *, QAction *> m_filterActions;
+
+ Internal::CurrentDocumentFind *m_currentDocumentFind;
+ Internal::FindToolBar *m_findToolBar;
+ Internal::FindToolWindow *m_findDialog;
+ SearchResultWindow *m_searchResultWindow;
+ FindFlags m_findFlags;
+ QStringListModel *m_findCompletionModel;
+ QStringListModel *m_replaceCompletionModel;
+ QStringList m_findCompletions;
+ QStringList m_replaceCompletions;
+ QAction *m_openFindDialog;
+};
+
+FindPluginPrivate::FindPluginPrivate(FindPlugin *q) :
+ m_currentDocumentFind(0), m_findToolBar(0), m_findDialog(0),
+ m_findCompletionModel(new QStringListModel(q)),
+ m_replaceCompletionModel(new QStringListModel(q))
+{
+}
+
+FindPlugin *FindPluginPrivate::m_instance = 0;
+
+FindPlugin::FindPlugin() : d(new FindPluginPrivate(this))
+{
+ QTC_ASSERT(!FindPluginPrivate::m_instance, return);
+ FindPluginPrivate::m_instance = this;
+}
+
+FindPlugin::~FindPlugin()
+{
+ FindPluginPrivate::m_instance = 0;
+ delete d->m_currentDocumentFind;
+ delete d->m_findToolBar;
+ delete d->m_findDialog;
+ ExtensionSystem::PluginManager::removeObject(d->m_searchResultWindow);
+ delete d->m_searchResultWindow;
+ delete d;
+}
+
+FindPlugin *FindPlugin::instance()
+{
+ return FindPluginPrivate::m_instance;
+}
+
+void FindPlugin::initialize(const QStringList &, QString *)
+{
+ setupMenu();
+
+ d->m_currentDocumentFind = new Internal::CurrentDocumentFind;
+
+ d->m_findToolBar = new Internal::FindToolBar(this, d->m_currentDocumentFind);
+ d->m_findDialog = new Internal::FindToolWindow(this);
+ d->m_searchResultWindow = new SearchResultWindow(d->m_findDialog);
+ ExtensionSystem::PluginManager::addObject(d->m_searchResultWindow);
+}
+
+void FindPlugin::extensionsInitialized()
+{
+ setupFilterMenuItems();
+ readSettings();
+}
+
+void FindPlugin::aboutToShutdown()
+{
+ d->m_findToolBar->setVisible(false);
+ d->m_findToolBar->setParent(0);
+ d->m_currentDocumentFind->removeConnections();
+ writeSettings();
+}
+
+void FindPlugin::filterChanged()
+{
+ IFindFilter *changedFilter = qobject_cast<IFindFilter *>(sender());
+ QAction *action = d->m_filterActions.value(changedFilter);
+ QTC_ASSERT(changedFilter, return);
+ QTC_ASSERT(action, return);
+ action->setEnabled(changedFilter->isEnabled());
+ bool haveEnabledFilters = false;
+ foreach (const IFindFilter *filter, d->m_filterActions.keys()) {
+ if (filter->isEnabled()) {
+ haveEnabledFilters = true;
+ break;
+ }
+ }
+ d->m_openFindDialog->setEnabled(haveEnabledFilters);
+}
+
+void FindPlugin::openFindFilter()
+{
+ QAction *action = qobject_cast<QAction*>(sender());
+ QTC_ASSERT(action, return);
+ IFindFilter *filter = action->data().value<IFindFilter *>();
+ openFindDialog(filter);
+}
+
+void FindPlugin::openFindDialog(IFindFilter *filter)
+{
+ if (d->m_currentDocumentFind->candidateIsEnabled())
+ d->m_currentDocumentFind->acceptCandidate();
+ const QString currentFindString =
+ d->m_currentDocumentFind->isEnabled() ?
+ d->m_currentDocumentFind->currentFindString() : QString();
+ if (!currentFindString.isEmpty())
+ d->m_findDialog->setFindText(currentFindString);
+ d->m_findDialog->setCurrentFilter(filter);
+ SearchResultWindow::instance()->openNewSearchPanel();
+}
+
+void FindPlugin::setupMenu()
+{
+ Core::ActionContainer *medit = Core::ActionManager::actionContainer(Core::Constants::M_EDIT);
+ Core::ActionContainer *mfind = Core::ActionManager::createMenu(Constants::M_FIND);
+ medit->addMenu(mfind, Core::Constants::G_EDIT_FIND);
+ mfind->menu()->setTitle(tr("&Find/Replace"));
+ mfind->appendGroup(Constants::G_FIND_CURRENTDOCUMENT);
+ mfind->appendGroup(Constants::G_FIND_FILTERS);
+ mfind->appendGroup(Constants::G_FIND_FLAGS);
+ mfind->appendGroup(Constants::G_FIND_ACTIONS);
+ Core::Context globalcontext(Core::Constants::C_GLOBAL);
+ Core::Command *cmd;
+ mfind->addSeparator(globalcontext, Constants::G_FIND_FLAGS);
+ mfind->addSeparator(globalcontext, Constants::G_FIND_ACTIONS);
+
+ Core::ActionContainer *mfindadvanced = Core::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 = Core::ActionManager::registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND, globalcontext);
+ cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F")));
+ mfindadvanced->addAction(cmd);
+ connect(d->m_openFindDialog, SIGNAL(triggered()), this, SLOT(openFindFilter()));
+}
+
+void FindPlugin::setupFilterMenuItems()
+{
+ QList<IFindFilter*> findInterfaces =
+ ExtensionSystem::PluginManager::getObjects<IFindFilter>();
+ Core::Command *cmd;
+ Core::Context globalcontext(Core::Constants::C_GLOBAL);
+
+ Core::ActionContainer *mfindadvanced = Core::ActionManager::actionContainer(Constants::M_FIND_ADVANCED);
+ d->m_filterActions.clear();
+ bool haveEnabledFilters = false;
+ const Core::Id base("FindFilter.");
+ foreach (IFindFilter *filter, findInterfaces) {
+ QAction *action = new QAction(QLatin1String(" ") + filter->displayName(), this);
+ bool isEnabled = filter->isEnabled();
+ if (isEnabled)
+ haveEnabledFilters = true;
+ action->setEnabled(isEnabled);
+ action->setData(qVariantFromValue(filter));
+ cmd = Core::ActionManager::registerAction(action,
+ base.withSuffix(filter->id()), globalcontext);
+ cmd->setDefaultKeySequence(filter->defaultShortcut());
+ mfindadvanced->addAction(cmd);
+ d->m_filterActions.insert(filter, action);
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(openFindFilter()));
+ connect(filter, SIGNAL(enabledChanged(bool)), this, SLOT(filterChanged()));
+ }
+ d->m_findDialog->setFindFilters(findInterfaces);
+ d->m_openFindDialog->setEnabled(haveEnabledFilters);
+}
+
+FindFlags FindPlugin::findFlags() const
+{
+ return d->m_findFlags;
+}
+
+void FindPlugin::setCaseSensitive(bool sensitive)
+{
+ setFindFlag(FindCaseSensitively, sensitive);
+}
+
+void FindPlugin::setWholeWord(bool wholeOnly)
+{
+ setFindFlag(FindWholeWords, wholeOnly);
+}
+
+void FindPlugin::setBackward(bool backward)
+{
+ setFindFlag(FindBackward, backward);
+}
+
+void FindPlugin::setRegularExpression(bool regExp)
+{
+ setFindFlag(FindRegularExpression, regExp);
+}
+
+void FindPlugin::setPreserveCase(bool preserveCase)
+{
+ setFindFlag(FindPreserveCase, preserveCase);
+}
+
+void FindPlugin::setFindFlag(FindFlag flag, bool enabled)
+{
+ bool hasFlag = hasFindFlag(flag);
+ if ((hasFlag && enabled) || (!hasFlag && !enabled))
+ return;
+ if (enabled)
+ d->m_findFlags |= flag;
+ else
+ d->m_findFlags &= ~flag;
+ if (flag != FindBackward)
+ emit findFlagsChanged();
+}
+
+bool FindPlugin::hasFindFlag(FindFlag flag)
+{
+ return d->m_findFlags & flag;
+}
+
+void FindPlugin::writeSettings()
+{
+ QSettings *settings = Core::ICore::settings();
+ settings->beginGroup(QLatin1String("Find"));
+ settings->setValue(QLatin1String("Backward"), hasFindFlag(FindBackward));
+ settings->setValue(QLatin1String("CaseSensitively"), hasFindFlag(FindCaseSensitively));
+ settings->setValue(QLatin1String("WholeWords"), hasFindFlag(FindWholeWords));
+ settings->setValue(QLatin1String("RegularExpression"), hasFindFlag(FindRegularExpression));
+ settings->setValue(QLatin1String("PreserveCase"), hasFindFlag(FindPreserveCase));
+ settings->setValue(QLatin1String("FindStrings"), d->m_findCompletions);
+ settings->setValue(QLatin1String("ReplaceStrings"), d->m_replaceCompletions);
+ settings->endGroup();
+ d->m_findToolBar->writeSettings();
+ d->m_findDialog->writeSettings();
+ d->m_searchResultWindow->writeSettings();
+}
+
+void FindPlugin::readSettings()
+{
+ QSettings *settings = Core::ICore::settings();
+ settings->beginGroup(QLatin1String("Find"));
+ bool block = blockSignals(true);
+ setBackward(settings->value(QLatin1String("Backward"), false).toBool());
+ setCaseSensitive(settings->value(QLatin1String("CaseSensitively"), false).toBool());
+ setWholeWord(settings->value(QLatin1String("WholeWords"), false).toBool());
+ setRegularExpression(settings->value(QLatin1String("RegularExpression"), false).toBool());
+ setPreserveCase(settings->value(QLatin1String("PreserveCase"), false).toBool());
+ blockSignals(block);
+ d->m_findCompletions = settings->value(QLatin1String("FindStrings")).toStringList();
+ d->m_replaceCompletions = settings->value(QLatin1String("ReplaceStrings")).toStringList();
+ d->m_findCompletionModel->setStringList(d->m_findCompletions);
+ d->m_replaceCompletionModel->setStringList(d->m_replaceCompletions);
+ settings->endGroup();
+ d->m_findToolBar->readSettings();
+ d->m_findDialog->readSettings();
+ emit findFlagsChanged(); // would have been done in the setXXX methods above
+}
+
+void FindPlugin::updateFindCompletion(const QString &text)
+{
+ updateCompletion(text, d->m_findCompletions, d->m_findCompletionModel);
+}
+
+void FindPlugin::updateReplaceCompletion(const QString &text)
+{
+ updateCompletion(text, d->m_replaceCompletions, d->m_replaceCompletionModel);
+}
+
+void FindPlugin::updateCompletion(const QString &text, QStringList &completions, QStringListModel *model)
+{
+ if (text.isEmpty())
+ return;
+ completions.removeAll(text);
+ completions.prepend(text);
+ while (completions.size() > MAX_COMPLETIONS)
+ completions.removeLast();
+ model->setStringList(completions);
+}
+
+void FindPlugin::setUseFakeVim(bool on)
+{
+ if (d->m_findToolBar)
+ d->m_findToolBar->setUseFakeVim(on);
+}
+
+void FindPlugin::openFindToolBar(FindDirection direction)
+{
+ if (d->m_findToolBar) {
+ d->m_findToolBar->setBackward(direction == FindBackwardDirection);
+ d->m_findToolBar->openFindToolBar();
+ }
+}
+
+QStringListModel *FindPlugin::findCompletionModel() const
+{
+ return d->m_findCompletionModel;
+}
+
+QStringListModel *FindPlugin::replaceCompletionModel() const
+{
+ return d->m_replaceCompletionModel;
+}
+
+QKeySequence IFindFilter::defaultShortcut() const
+{
+ return QKeySequence();
+}
+
+// declared in textfindconstants.h
+QTextDocument::FindFlags textDocumentFlagsForFindFlags(FindFlags flags)
+{
+ QTextDocument::FindFlags textDocFlags;
+ if (flags & FindBackward)
+ textDocFlags |= QTextDocument::FindBackward;
+ if (flags & FindCaseSensitively)
+ textDocFlags |= QTextDocument::FindCaseSensitively;
+ if (flags & FindWholeWords)
+ textDocFlags |= QTextDocument::FindWholeWords;
+ return textDocFlags;
+}
+
+} // namespace Core
diff --git a/src/plugins/find/findplugin.h b/src/plugins/coreplugin/find/findplugin.h
index 872ae87ea2..0c8298052f 100644
--- a/src/plugins/find/findplugin.h
+++ b/src/plugins/coreplugin/find/findplugin.h
@@ -30,7 +30,6 @@
#ifndef FINDPLUGIN_H
#define FINDPLUGIN_H
-#include "find_global.h"
#include "textfindconstants.h"
#include <extensionsystem/iplugin.h>
@@ -39,23 +38,24 @@ QT_BEGIN_NAMESPACE
class QStringListModel;
QT_END_NAMESPACE
-namespace Find {
+namespace Core {
class IFindFilter;
class FindPluginPrivate;
namespace Internal {
+class CorePlugin;
class FindToolBar;
class CurrentDocumentFind;
} // namespace Internal
-class FIND_EXPORT FindPlugin : public ExtensionSystem::IPlugin
+class CORE_EXPORT FindPlugin : public QObject
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Find.json")
public:
FindPlugin();
virtual ~FindPlugin();
+
static FindPlugin *instance();
enum FindDirection {
@@ -63,13 +63,8 @@ public:
FindBackwardDirection
};
- // IPlugin
- bool initialize(const QStringList &arguments, QString *errorMessage);
- void extensionsInitialized();
- ShutdownFlag aboutToShutdown();
-
- FindFlags findFlags() const;
- bool hasFindFlag(FindFlag flag);
+ Core::FindFlags findFlags() const;
+ bool hasFindFlag(Core::FindFlag flag);
void updateFindCompletion(const QString &text);
void updateReplaceCompletion(const QString &text);
QStringListModel *findCompletionModel() const;
@@ -78,6 +73,10 @@ public:
void openFindToolBar(FindDirection direction);
void openFindDialog(IFindFilter *filter);
+ void initialize(const QStringList &, QString *);
+ void extensionsInitialized();
+ void aboutToShutdown();
+
public slots:
void setCaseSensitive(bool sensitive);
void setWholeWord(bool wholeOnly);
@@ -93,7 +92,7 @@ private slots:
void openFindFilter();
private:
- void setFindFlag(FindFlag flag, bool enabled);
+ void setFindFlag(Core::FindFlag flag, bool enabled);
void updateCompletion(const QString &text, QStringList &completions, QStringListModel *model);
void setupMenu();
void setupFilterMenuItems();
@@ -104,6 +103,6 @@ private:
FindPluginPrivate *d;
};
-} // namespace Find
+} // namespace Core
#endif // FINDPLUGIN_H
diff --git a/src/plugins/find/findtoolbar.cpp b/src/plugins/coreplugin/find/findtoolbar.cpp
index bfb9158d84..e686c3fd48 100644
--- a/src/plugins/find/findtoolbar.cpp
+++ b/src/plugins/coreplugin/find/findtoolbar.cpp
@@ -28,10 +28,11 @@
****************************************************************************/
#include "findtoolbar.h"
-#include "findplugin.h"
#include "ifindfilter.h"
+#include "findplugin.h"
#include <coreplugin/coreconstants.h>
+#include <coreplugin/coreplugin.h>
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
@@ -53,10 +54,10 @@
#include <QStringListModel>
Q_DECLARE_METATYPE(QStringList)
-Q_DECLARE_METATYPE(Find::IFindFilter*)
+Q_DECLARE_METATYPE(Core::IFindFilter*)
-using namespace Find;
-using namespace Find::Internal;
+using namespace Core;
+using namespace Core::Internal;
FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumentFind)
: m_plugin(plugin),
diff --git a/src/plugins/find/findtoolbar.h b/src/plugins/coreplugin/find/findtoolbar.h
index a5e2fcade7..fb90dfbf1f 100644
--- a/src/plugins/find/findtoolbar.h
+++ b/src/plugins/coreplugin/find/findtoolbar.h
@@ -38,10 +38,8 @@
#include <QTimer>
namespace Core {
-class FindToolBarPlaceHolder;
-}
-namespace Find {
+class FindToolBarPlaceHolder;
class FindPlugin;
namespace Internal {
@@ -146,6 +144,6 @@ private:
};
} // namespace Internal
-} // namespace Find
+} // namespace Core
#endif // FINDTOOLBAR_H
diff --git a/src/plugins/find/findtoolwindow.cpp b/src/plugins/coreplugin/find/findtoolwindow.cpp
index 77b48d2866..66521dc32b 100644
--- a/src/plugins/find/findtoolwindow.cpp
+++ b/src/plugins/coreplugin/find/findtoolwindow.cpp
@@ -39,8 +39,8 @@
#include <QKeyEvent>
#include <QScrollArea>
-using namespace Find;
-using namespace Find::Internal;
+using namespace Core;
+using namespace Core::Internal;
static FindToolWindow *m_instance = 0;
diff --git a/src/plugins/find/findtoolwindow.h b/src/plugins/coreplugin/find/findtoolwindow.h
index 49cb5211cb..e78d0075ec 100644
--- a/src/plugins/find/findtoolwindow.h
+++ b/src/plugins/coreplugin/find/findtoolwindow.h
@@ -31,13 +31,13 @@
#define FINDTOOLWINDOW_H
#include "ui_finddialog.h"
+#include "findplugin.h"
#include <QList>
QT_FORWARD_DECLARE_CLASS(QCompleter)
-namespace Find {
-class FindPlugin;
+namespace Core {
class IFindFilter;
namespace Internal {
@@ -82,6 +82,6 @@ private:
};
} // namespace Internal
-} // namespace Find
+} // namespace Core
#endif // FINDTOOLWINDOW_H
diff --git a/src/plugins/find/findwidget.ui b/src/plugins/coreplugin/find/findwidget.ui
index 7ff9c28f0f..4472102781 100644
--- a/src/plugins/find/findwidget.ui
+++ b/src/plugins/coreplugin/find/findwidget.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>Find::Internal::FindWidget</class>
- <widget class="QWidget" name="Find::Internal::FindWidget">
+ <class>Core::Internal::FindWidget</class>
+ <widget class="QWidget" name="Core::Internal::FindWidget">
<property name="geometry">
<rect>
<x>0</x>
diff --git a/src/plugins/find/ifindfilter.cpp b/src/plugins/coreplugin/find/ifindfilter.cpp
index bcd8e8d2c4..c9fda43f2a 100644
--- a/src/plugins/find/ifindfilter.cpp
+++ b/src/plugins/coreplugin/find/ifindfilter.cpp
@@ -85,7 +85,7 @@
In the find filter's find/replaceAll function, get the shared
\gui{Search Results} window, initiate a new search and connect the
signals for handling selection of results and the replace action
- (see the Find::SearchResultWindow class for details).
+ (see the Core::SearchResultWindow class for details).
Start your search implementation via the corresponding QtConcurrent
functions. Add the returned QFuture object to the Core::ProgressManager.
Use a QFutureWatcher on the returned QFuture object to receive a signal
@@ -143,7 +143,7 @@
*/
/*!
- \fn void IFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
+ \fn void IFindFilter::findAll(const QString &txt, Core::FindFlags findFlags)
This function is called when the user selected this find scope and
initiated a search.
@@ -152,15 +152,15 @@
(add it to Core::ProgressManager for a progress bar!) and presents the
search results to the user (using the \gui{Search Results} output pane).
For more information, see the descriptions of this class,
- Core::ProgressManager, and Find::SearchResultWindow.
+ Core::ProgressManager, and Core::SearchResultWindow.
\sa replaceAll()
\sa Core::ProgressManager
- \sa Find::SearchResultWindow
+ \sa Core::SearchResultWindow
*/
/*!
- \fn void IFindFilter::replaceAll(const QString &txt, Find::FindFlags findFlags)
+ \fn void IFindFilter::replaceAll(const QString &txt, Core::FindFlags findFlags)
Override this function if you want to support search and replace.
This function is called when the user selected this find scope and
@@ -172,11 +172,11 @@
(add it to Core::ProgressManager for a progress bar!) and presents the
search results to the user (using the \gui{Search Results} output pane).
For more information see the descriptions of this class,
- Core::ProgressManager, and Find::SearchResultWindow.
+ Core::ProgressManager, and Core::SearchResultWindow.
\sa findAll()
\sa Core::ProgressManager
- \sa Find::SearchResultWindow
+ \sa Core::SearchResultWindow
*/
/*!
@@ -207,7 +207,7 @@
*/
/*!
- \fn Find::FindFlags BaseTextFind::supportedFindFlags() const
+ \fn Core::FindFlags BaseTextFind::supportedFindFlags() const
Returns the find flags, like whole words or regular expressions,
that this find filter supports.
@@ -217,7 +217,7 @@
and Find::FindWholeWords
*/
-namespace Find {
+namespace Core {
FindFlags IFindFilter::supportedFindFlags() const
{
@@ -282,4 +282,4 @@ QString IFindFilter::descriptionForFindFlags(FindFlags flags)
return description;
}
-} // namespace Find
+} // namespace Core
diff --git a/src/plugins/find/ifindfilter.h b/src/plugins/coreplugin/find/ifindfilter.h
index 378762c04d..00bb66a04e 100644
--- a/src/plugins/find/ifindfilter.h
+++ b/src/plugins/coreplugin/find/ifindfilter.h
@@ -30,7 +30,6 @@
#ifndef IFINDFILTER_H
#define IFINDFILTER_H
-#include "find_global.h"
#include "textfindconstants.h"
QT_BEGIN_NAMESPACE
@@ -40,9 +39,9 @@ class QKeySequence;
class Pixmap;
QT_END_NAMESPACE
-namespace Find {
+namespace Core {
-class FIND_EXPORT IFindFilter : public QObject
+class CORE_EXPORT IFindFilter : public QObject
{
Q_OBJECT
public:
@@ -71,6 +70,6 @@ signals:
void enabledChanged(bool enabled);
};
-} // namespace Find
+} // namespace Core
#endif // IFINDFILTER_H
diff --git a/src/plugins/find/ifindsupport.cpp b/src/plugins/coreplugin/find/ifindsupport.cpp
index a001fc0866..f057352de6 100644
--- a/src/plugins/find/ifindsupport.cpp
+++ b/src/plugins/coreplugin/find/ifindsupport.cpp
@@ -35,7 +35,7 @@
#include <QPaintEvent>
#include <QPainter>
-namespace Find {
+namespace Core {
namespace Internal {
class WrapIndicator : public QWidget
@@ -88,7 +88,7 @@ private:
} // Internal
} // Find
-using namespace Find;
+using namespace Core;
void IFindSupport::replace(const QString &before, const QString &after, FindFlags findFlags)
{
diff --git a/src/plugins/find/ifindsupport.h b/src/plugins/coreplugin/find/ifindsupport.h
index d5b8002367..041de57fdd 100644
--- a/src/plugins/find/ifindsupport.h
+++ b/src/plugins/coreplugin/find/ifindsupport.h
@@ -30,15 +30,14 @@
#ifndef IFINDSUPPORT_H
#define IFINDSUPPORT_H
-#include "find_global.h"
#include "textfindconstants.h"
#include <QObject>
#include <QString>
-namespace Find {
+namespace Core {
-class FIND_EXPORT IFindSupport : public QObject
+class CORE_EXPORT IFindSupport : public QObject
{
Q_OBJECT
@@ -76,6 +75,6 @@ signals:
inline void IFindSupport::highlightAll(const QString &, FindFlags) {}
-} // namespace Find
+} // namespace Core
#endif // IFINDSUPPORT_H
diff --git a/src/plugins/find/images/all.png b/src/plugins/coreplugin/find/images/all.png
index f5c1c1f767..f5c1c1f767 100644
--- a/src/plugins/find/images/all.png
+++ b/src/plugins/coreplugin/find/images/all.png
Binary files differ
diff --git a/src/plugins/find/images/casesensitively.png b/src/plugins/coreplugin/find/images/casesensitively.png
index 029b41faa4..029b41faa4 100644
--- a/src/plugins/find/images/casesensitively.png
+++ b/src/plugins/coreplugin/find/images/casesensitively.png
Binary files differ
diff --git a/src/plugins/find/images/empty.png b/src/plugins/coreplugin/find/images/empty.png
index f02154247c..f02154247c 100644
--- a/src/plugins/find/images/empty.png
+++ b/src/plugins/coreplugin/find/images/empty.png
Binary files differ
diff --git a/src/plugins/find/images/expand.png b/src/plugins/coreplugin/find/images/expand.png
index 48fcb9b703..48fcb9b703 100644
--- a/src/plugins/find/images/expand.png
+++ b/src/plugins/coreplugin/find/images/expand.png
Binary files differ
diff --git a/src/plugins/find/images/next.png b/src/plugins/coreplugin/find/images/next.png
index 1844929119..1844929119 100644
--- a/src/plugins/find/images/next.png
+++ b/src/plugins/coreplugin/find/images/next.png
Binary files differ
diff --git a/src/plugins/find/images/preservecase.png b/src/plugins/coreplugin/find/images/preservecase.png
index 4869aabd71..4869aabd71 100644
--- a/src/plugins/find/images/preservecase.png
+++ b/src/plugins/coreplugin/find/images/preservecase.png
Binary files differ
diff --git a/src/plugins/find/images/previous.png b/src/plugins/coreplugin/find/images/previous.png
index 4fe50af9a8..4fe50af9a8 100644
--- a/src/plugins/find/images/previous.png
+++ b/src/plugins/coreplugin/find/images/previous.png
Binary files differ
diff --git a/src/plugins/find/images/regexp.png b/src/plugins/coreplugin/find/images/regexp.png
index be8a5cc48c..be8a5cc48c 100644
--- a/src/plugins/find/images/regexp.png
+++ b/src/plugins/coreplugin/find/images/regexp.png
Binary files differ
diff --git a/src/plugins/find/images/replace_all.png b/src/plugins/coreplugin/find/images/replace_all.png
index d2298a8aad..d2298a8aad 100644
--- a/src/plugins/find/images/replace_all.png
+++ b/src/plugins/coreplugin/find/images/replace_all.png
Binary files differ
diff --git a/src/plugins/find/images/wholewords.png b/src/plugins/coreplugin/find/images/wholewords.png
index 0ffcecd963..0ffcecd963 100644
--- a/src/plugins/find/images/wholewords.png
+++ b/src/plugins/coreplugin/find/images/wholewords.png
Binary files differ
diff --git a/src/plugins/find/images/wordandcase.png b/src/plugins/coreplugin/find/images/wordandcase.png
index 34c0ac3190..34c0ac3190 100644
--- a/src/plugins/find/images/wordandcase.png
+++ b/src/plugins/coreplugin/find/images/wordandcase.png
Binary files differ
diff --git a/src/plugins/find/images/wrapindicator.png b/src/plugins/coreplugin/find/images/wrapindicator.png
index a4f8ddf417..a4f8ddf417 100644
--- a/src/plugins/find/images/wrapindicator.png
+++ b/src/plugins/coreplugin/find/images/wrapindicator.png
Binary files differ
diff --git a/src/plugins/find/searchresultcolor.h b/src/plugins/coreplugin/find/searchresultcolor.h
index fab3e06bb2..0547f07749 100644
--- a/src/plugins/find/searchresultcolor.h
+++ b/src/plugins/coreplugin/find/searchresultcolor.h
@@ -3,7 +3,7 @@
#include <QColor>
-namespace Find {
+namespace Core {
namespace Internal {
class SearchResultColor{
@@ -15,6 +15,6 @@ public:
};
} // namespace Internal
-} // namespace Find
+} // namespace Core
#endif // SEARCHRESULTCOLOR_H
diff --git a/src/plugins/find/searchresulttreeitemdelegate.cpp b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp
index 3f9e9b2098..949a298f62 100644
--- a/src/plugins/find/searchresulttreeitemdelegate.cpp
+++ b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp
@@ -36,7 +36,7 @@
#include <QModelIndex>
#include <QDebug>
-using namespace Find::Internal;
+using namespace Core::Internal;
SearchResultTreeItemDelegate::SearchResultTreeItemDelegate(QObject *parent)
: QItemDelegate(parent)
diff --git a/src/plugins/find/searchresulttreeitemdelegate.h b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.h
index e91882bd79..af46024ede 100644
--- a/src/plugins/find/searchresulttreeitemdelegate.h
+++ b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.h
@@ -32,7 +32,7 @@
#include <QItemDelegate>
-namespace Find {
+namespace Core {
namespace Internal {
class SearchResultTreeItemDelegate: public QItemDelegate
@@ -50,6 +50,6 @@ private:
};
} // namespace Internal
-} // namespace Find
+} // namespace Core
#endif // SEARCHRESULTTREEITEMDELEGATE_H
diff --git a/src/plugins/find/searchresulttreeitemroles.h b/src/plugins/coreplugin/find/searchresulttreeitemroles.h
index 80cda671ca..bd771d7c6a 100644
--- a/src/plugins/find/searchresulttreeitemroles.h
+++ b/src/plugins/coreplugin/find/searchresulttreeitemroles.h
@@ -32,7 +32,7 @@
#include <QAbstractItemView>
-namespace Find {
+namespace Core {
namespace Internal {
namespace ItemDataRoles {
@@ -50,7 +50,7 @@ enum Roles
};
} // namespace Internal
-} // namespace Find
+} // namespace Core
} // namespace ItemDataRoles
#endif // SEARCHRESULTTREEITEMROLES_H
diff --git a/src/plugins/find/searchresulttreeitems.cpp b/src/plugins/coreplugin/find/searchresulttreeitems.cpp
index a49e4d03e1..d9f941bd02 100644
--- a/src/plugins/find/searchresulttreeitems.cpp
+++ b/src/plugins/coreplugin/find/searchresulttreeitems.cpp
@@ -29,7 +29,7 @@
#include "searchresulttreeitems.h"
-namespace Find {
+namespace Core {
namespace Internal {
SearchResultTreeItem::SearchResultTreeItem(const SearchResultItem &item,
@@ -142,4 +142,4 @@ void SearchResultTreeItem::appendChild(const SearchResultItem &item)
}
} // namespace Internal
-} // namespace Find
+} // namespace Core
diff --git a/src/plugins/find/searchresulttreeitems.h b/src/plugins/coreplugin/find/searchresulttreeitems.h
index e64c93e759..3f41818ee1 100644
--- a/src/plugins/find/searchresulttreeitems.h
+++ b/src/plugins/coreplugin/find/searchresulttreeitems.h
@@ -35,7 +35,7 @@
#include <QString>
#include <QList>
-namespace Find {
+namespace Core {
namespace Internal {
class SearchResultTreeItem
@@ -77,6 +77,6 @@ private:
};
} // namespace Internal
-} // namespace Find
+} // namespace Core
#endif // SEARCHRESULTTREEITEMS_H
diff --git a/src/plugins/find/searchresulttreemodel.cpp b/src/plugins/coreplugin/find/searchresulttreemodel.cpp
index feca87cc39..7aafe033bb 100644
--- a/src/plugins/find/searchresulttreemodel.cpp
+++ b/src/plugins/coreplugin/find/searchresulttreemodel.cpp
@@ -36,8 +36,8 @@
#include <QFontMetrics>
#include <QDebug>
-using namespace Find;
-using namespace Find::Internal;
+using namespace Core;
+using namespace Core::Internal;
SearchResultTreeModel::SearchResultTreeModel(QObject *parent)
: QAbstractItemModel(parent)
diff --git a/src/plugins/find/searchresulttreemodel.h b/src/plugins/coreplugin/find/searchresulttreemodel.h
index ad45c6f4b6..36ca6d94ac 100644
--- a/src/plugins/find/searchresulttreemodel.h
+++ b/src/plugins/coreplugin/find/searchresulttreemodel.h
@@ -36,7 +36,7 @@
#include <QAbstractItemModel>
#include <QFont>
-namespace Find {
+namespace Core {
namespace Internal {
class SearchResultTreeItem;
@@ -94,6 +94,6 @@ private:
};
} // namespace Internal
-} // namespace Find
+} // namespace Core
#endif // SEARCHRESULTTREEMODEL_H
diff --git a/src/plugins/find/searchresulttreeview.cpp b/src/plugins/coreplugin/find/searchresulttreeview.cpp
index 8b96176264..d48efabd97 100644
--- a/src/plugins/find/searchresulttreeview.cpp
+++ b/src/plugins/coreplugin/find/searchresulttreeview.cpp
@@ -35,7 +35,7 @@
#include <QHeaderView>
#include <QKeyEvent>
-namespace Find {
+namespace Core {
namespace Internal {
SearchResultTreeView::SearchResultTreeView(QWidget *parent)
@@ -106,4 +106,4 @@ SearchResultTreeModel *SearchResultTreeView::model() const
}
} // namespace Internal
-} // namespace Find
+} // namespace Core
diff --git a/src/plugins/find/searchresulttreeview.h b/src/plugins/coreplugin/find/searchresulttreeview.h
index ecf290c90d..b5dcd792d3 100644
--- a/src/plugins/find/searchresulttreeview.h
+++ b/src/plugins/coreplugin/find/searchresulttreeview.h
@@ -34,7 +34,7 @@
#include <QTreeView>
-namespace Find {
+namespace Core {
namespace Internal {
class SearchResultTreeModel;
@@ -68,6 +68,6 @@ protected:
};
} // namespace Internal
-} // namespace Find
+} // namespace Core
#endif // SEARCHRESULTTREEVIEW_H
diff --git a/src/plugins/find/searchresultwidget.cpp b/src/plugins/coreplugin/find/searchresultwidget.cpp
index bbdfe3d138..6539cebdad 100644
--- a/src/plugins/find/searchresultwidget.cpp
+++ b/src/plugins/coreplugin/find/searchresultwidget.cpp
@@ -37,6 +37,7 @@
#include "treeviewfind.h"
#include <aggregation/aggregate.h>
+#include <coreplugin/coreplugin.h>
#include <QDir>
#include <QFrame>
@@ -50,7 +51,7 @@
static const int SEARCHRESULT_WARNING_LIMIT = 200000;
static const char SIZE_WARNING_ID[] = "sizeWarningLabel";
-namespace Find {
+namespace Core {
namespace Internal {
class WideEnoughLineEdit : public QLineEdit {
@@ -71,11 +72,11 @@ public slots:
void updateGeometry() { QLineEdit::updateGeometry(); }
};
-} // Internal
-} // Find
+} // namespace Internal
+} // namespace Core
-using namespace Find;
-using namespace Find::Internal;
+using namespace Core;
+using namespace Core::Internal;
SearchResultWidget::SearchResultWidget(QWidget *parent) :
QWidget(parent),
diff --git a/src/plugins/find/searchresultwidget.h b/src/plugins/coreplugin/find/searchresultwidget.h
index 76ec7da935..e9f64b4164 100644
--- a/src/plugins/find/searchresultwidget.h
+++ b/src/plugins/coreplugin/find/searchresultwidget.h
@@ -44,7 +44,7 @@ class QToolButton;
class QCheckBox;
QT_END_NAMESPACE
-namespace Find {
+namespace Core {
namespace Internal {
class SearchResultTreeView;
@@ -97,8 +97,8 @@ public slots:
void sendRequestPopup();
signals:
- void activated(const Find::SearchResultItem &item);
- void replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems, bool preserveCase);
+ void activated(const Core::SearchResultItem &item);
+ void replaceButtonClicked(const QString &replaceText, const QList<Core::SearchResultItem> &checkedItems, bool preserveCase);
void searchAgainRequested();
void cancelled();
void paused(bool paused);
diff --git a/src/plugins/find/searchresultwindow.cpp b/src/plugins/coreplugin/find/searchresultwindow.cpp
index a5dce4791d..dd4f87475f 100644
--- a/src/plugins/find/searchresultwindow.cpp
+++ b/src/plugins/coreplugin/find/searchresultwindow.cpp
@@ -50,7 +50,7 @@ static const char SETTINGSKEYSECTIONNAME[] = "SearchResults";
static const char SETTINGSKEYEXPANDRESULTS[] = "ExpandResults";
static const int MAX_SEARCH_HISTORY = 12;
-namespace Find {
+namespace Core {
namespace Internal {
@@ -83,6 +83,7 @@ namespace Internal {
int visibleSearchIndex() const;
void setCurrentIndex(int index, bool focus);
+ FindPlugin *m_plugin;
SearchResultWindow *q;
QList<Internal::SearchResultWidget *> m_searchResultWidgets;
QToolButton *m_expandCollapseButton;
@@ -187,10 +188,10 @@ namespace Internal {
}
}
-using namespace Find::Internal;
+using namespace Core::Internal;
/*!
- \enum Find::SearchResultWindow::SearchMode
+ \enum Core::SearchResultWindow::SearchMode
This enum type specifies whether a search should show the replace UI or not:
\value SearchOnly
@@ -200,7 +201,7 @@ using namespace Find::Internal;
*/
/*!
- \class Find::SearchResult
+ \class Core::SearchResult
\brief The SearchResult class reports user interaction, such as the
activation of a search result item.
@@ -210,13 +211,13 @@ using namespace Find::Internal;
*/
/*!
- \fn void SearchResult::activated(const Find::SearchResultItem &item)
+ \fn void SearchResult::activated(const Core::SearchResultItem &item)
Indicates that the user activated the search result \a item by
double-clicking it, for example.
*/
/*!
- \fn void SearchResult::replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems, bool preserveCase)
+ \fn void SearchResult::replaceButtonClicked(const QString &replaceText, const QList<Core::SearchResultItem> &checkedItems, bool preserveCase)
Indicates that the user initiated a text replace by selecting
\gui {Replace All}, for example.
@@ -228,7 +229,7 @@ using namespace Find::Internal;
*/
/*!
- \class Find::SearchResultWindow
+ \class Core::SearchResultWindow
\brief The SearchResultWindow class is the implementation of a commonly
shared \gui{Search Results} output pane. Use it to show search results
to a user.
@@ -272,6 +273,7 @@ SearchResultWindow::SearchResultWindow(QWidget *newSearchPanel)
: d(new SearchResultWindowPrivate(this))
{
m_instance = this;
+
d->m_spacer = new QWidget;
d->m_spacer->setMinimumWidth(30);
d->m_recentSearchesBox = new QComboBox;
@@ -309,7 +311,6 @@ SearchResultWindow::SearchResultWindow(QWidget *newSearchPanel)
*/
SearchResultWindow::~SearchResultWindow()
{
- writeSettings();
qDeleteAll(d->m_searchResults);
delete d->m_widget;
d->m_widget = 0;
@@ -586,10 +587,10 @@ bool SearchResultWindow::canNavigate() const
SearchResult::SearchResult(SearchResultWidget *widget)
: m_widget(widget)
{
- connect(widget, SIGNAL(activated(Find::SearchResultItem)),
- this, SIGNAL(activated(Find::SearchResultItem)));
- connect(widget, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)),
- this, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)));
+ connect(widget, SIGNAL(activated(Core::SearchResultItem)),
+ this, SIGNAL(activated(Core::SearchResultItem)));
+ connect(widget, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)),
+ this, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)));
connect(widget, SIGNAL(cancelled()),
this, SIGNAL(cancelled()));
connect(widget, SIGNAL(paused(bool)),
@@ -709,6 +710,6 @@ void SearchResult::popup()
m_widget->sendRequestPopup();
}
-} // namespace Find
+} // namespace Core
#include "searchresultwindow.moc"
diff --git a/src/plugins/find/searchresultwindow.h b/src/plugins/coreplugin/find/searchresultwindow.h
index 8c7f052c01..c13b9ce32f 100644
--- a/src/plugins/find/searchresultwindow.h
+++ b/src/plugins/coreplugin/find/searchresultwindow.h
@@ -30,8 +30,6 @@
#ifndef SEARCHRESULTWINDOW_H
#define SEARCHRESULTWINDOW_H
-#include "find_global.h"
-
#include <coreplugin/ioutputpane.h>
#include <QVariant>
@@ -42,15 +40,16 @@ QT_BEGIN_NAMESPACE
class QFont;
QT_END_NAMESPACE
-namespace Find {
+namespace Core {
namespace Internal {
class SearchResultTreeView;
class SearchResultWindowPrivate;
class SearchResultWidget;
}
+class FindPlugin;
class SearchResultWindow;
-class FIND_EXPORT SearchResultItem
+class CORE_EXPORT SearchResultItem
{
public:
SearchResultItem()
@@ -83,7 +82,7 @@ public:
QVariant userData; // user data for identification of the item
};
-class FIND_EXPORT SearchResult : public QObject
+class CORE_EXPORT SearchResult : public QObject
{
Q_OBJECT
@@ -110,8 +109,8 @@ public slots:
void popup();
signals:
- void activated(const Find::SearchResultItem &item);
- void replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems, bool preserveCase);
+ void activated(const Core::SearchResultItem &item);
+ void replaceButtonClicked(const QString &replaceText, const QList<Core::SearchResultItem> &checkedItems, bool preserveCase);
void cancelled();
void paused(bool paused);
void visibilityChanged(bool visible);
@@ -128,7 +127,7 @@ private:
QVariant m_userData;
};
-class FIND_EXPORT SearchResultWindow : public Core::IOutputPane
+class CORE_EXPORT SearchResultWindow : public Core::IOutputPane
{
Q_OBJECT
@@ -182,16 +181,18 @@ public slots:
private slots:
void handleExpandCollapseToolButton(bool checked);
+public: // Used by plugin, do not use
+ void writeSettings();
+
private:
void readSettings();
- void writeSettings();
Internal::SearchResultWindowPrivate *d;
static SearchResultWindow *m_instance;
};
-} // namespace Find
+} // namespace Core
-Q_DECLARE_METATYPE(Find::SearchResultItem)
+Q_DECLARE_METATYPE(Core::SearchResultItem)
#endif // SEARCHRESULTWINDOW_H
diff --git a/src/plugins/find/textfindconstants.h b/src/plugins/coreplugin/find/textfindconstants.h
index 0100df7d2d..53292327b3 100644
--- a/src/plugins/find/textfindconstants.h
+++ b/src/plugins/coreplugin/find/textfindconstants.h
@@ -30,13 +30,13 @@
#ifndef TEXTFINDCONSTANTS_H
#define TEXTFINDCONSTANTS_H
-#include "find_global.h"
+#include <coreplugin/core_global.h>
#include <QMetaType>
#include <QFlags>
#include <QTextDocument>
-namespace Find {
+namespace Core {
namespace Constants {
const char M_FIND[] = "Find.FindMenu";
@@ -74,11 +74,11 @@ enum FindFlag {
Q_DECLARE_FLAGS(FindFlags, FindFlag)
// defined in findplugin.cpp
-QTextDocument::FindFlags FIND_EXPORT textDocumentFlagsForFindFlags(FindFlags flags);
+QTextDocument::FindFlags CORE_EXPORT textDocumentFlagsForFindFlags(FindFlags flags);
-} // namespace Find
+} // namespace Core
-Q_DECLARE_OPERATORS_FOR_FLAGS(Find::FindFlags)
-Q_DECLARE_METATYPE(Find::FindFlags)
+Q_DECLARE_OPERATORS_FOR_FLAGS(Core::FindFlags)
+Q_DECLARE_METATYPE(Core::FindFlags)
#endif // TEXTFINDCONSTANTS_H
diff --git a/src/plugins/find/treeviewfind.cpp b/src/plugins/coreplugin/find/treeviewfind.cpp
index 24ac4e7e37..6a1c937557 100644
--- a/src/plugins/find/treeviewfind.cpp
+++ b/src/plugins/coreplugin/find/treeviewfind.cpp
@@ -33,7 +33,7 @@
#include <QTextCursor>
#include <QModelIndex>
-namespace Find {
+namespace Core {
class ItemModelFindPrivate
{
@@ -274,4 +274,4 @@ QModelIndex TreeViewFind::followingIndex(const QModelIndex &idx, bool backward,
return nextIndex(idx, wrapped);
}
-} // namespace Find
+} // namespace Core
diff --git a/src/plugins/find/treeviewfind.h b/src/plugins/coreplugin/find/treeviewfind.h
index b7ac19468f..06842d2b79 100644
--- a/src/plugins/find/treeviewfind.h
+++ b/src/plugins/coreplugin/find/treeviewfind.h
@@ -37,10 +37,10 @@ class QTreeView;
class QModelIndex;
QT_END_NAMESPACE
-namespace Find {
+namespace Core {
class ItemModelFindPrivate;
-class FIND_EXPORT TreeViewFind : public IFindSupport
+class CORE_EXPORT TreeViewFind : public IFindSupport
{
Q_OBJECT
public:
@@ -70,6 +70,6 @@ private:
ItemModelFindPrivate *d;
};
-} // namespace Find
+} // namespace Core
#endif // TREEVIEWFIND_H
diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp
index eb6da5d961..f1f3fe4625 100644
--- a/src/plugins/coreplugin/generalsettings.cpp
+++ b/src/plugins/coreplugin/generalsettings.cpp
@@ -102,76 +102,61 @@ void GeneralSettings::fillLanguageBox() const
}
}
-QWidget *GeneralSettings::createPage(QWidget *parent)
+QWidget *GeneralSettings::widget()
{
- m_page = new Ui::GeneralSettings();
- m_widget = new QWidget(parent);
- m_page->setupUi(m_widget);
-
- fillLanguageBox();
-
- m_page->colorButton->setColor(StyleHelper::requestedBaseColor());
- m_page->reloadBehavior->setCurrentIndex(EditorManager::reloadSetting());
- if (HostOsInfo::isAnyUnixHost()) {
- QSettings *settings = Core::ICore::settings();
- const QStringList availableTerminals = ConsoleProcess::availableTerminalEmulators();
- const QString currentTerminal = ConsoleProcess::terminalEmulator(settings, false);
- m_page->terminalComboBox->addItems(availableTerminals);
- m_page->terminalComboBox->lineEdit()->setText(currentTerminal);
- m_page->terminalComboBox->lineEdit()->setPlaceholderText(ConsoleProcess::defaultTerminalEmulator());
- } else {
- m_page->terminalLabel->hide();
- m_page->terminalComboBox->hide();
- m_page->resetTerminalButton->hide();
- }
-
- if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost()) {
- QSettings *settings = Core::ICore::settings();
- m_page->externalFileBrowserEdit->setText(UnixUtils::fileBrowser(settings));
- } else {
- m_page->externalFileBrowserLabel->hide();
- m_page->externalFileBrowserEdit->hide();
- m_page->resetFileBrowserButton->hide();
- m_page->helpExternalFileBrowserButton->hide();
- }
-
- m_page->autoSaveCheckBox->setChecked(EditorManager::autoSaveEnabled());
- m_page->autoSaveInterval->setValue(EditorManager::autoSaveInterval());
- m_page->resetWarningsButton->setEnabled(Core::InfoBar::anyGloballySuppressed()
- || Utils::CheckableMessageBox::hasSuppressedQuestions(ICore::settings()));
+ if (!m_widget) {
+ m_page = new Ui::GeneralSettings();
+ m_widget = new QWidget;
+ m_page->setupUi(m_widget);
+
+ fillLanguageBox();
+
+ m_page->colorButton->setColor(StyleHelper::requestedBaseColor());
+ m_page->reloadBehavior->setCurrentIndex(EditorManager::reloadSetting());
+ if (HostOsInfo::isAnyUnixHost()) {
+ QSettings *settings = Core::ICore::settings();
+ const QStringList availableTerminals = ConsoleProcess::availableTerminalEmulators();
+ const QString currentTerminal = ConsoleProcess::terminalEmulator(settings, false);
+ m_page->terminalComboBox->addItems(availableTerminals);
+ m_page->terminalComboBox->lineEdit()->setText(currentTerminal);
+ m_page->terminalComboBox->lineEdit()->setPlaceholderText(ConsoleProcess::defaultTerminalEmulator());
+ } else {
+ m_page->terminalLabel->hide();
+ m_page->terminalComboBox->hide();
+ m_page->resetTerminalButton->hide();
+ }
- connect(m_page->resetColorButton, SIGNAL(clicked()),
- this, SLOT(resetInterfaceColor()));
- connect(m_page->resetWarningsButton, SIGNAL(clicked()),
- this, SLOT(resetWarnings()));
- if (HostOsInfo::isAnyUnixHost()) {
- connect(m_page->resetTerminalButton, SIGNAL(clicked()), this, SLOT(resetTerminal()));
- if (!HostOsInfo::isMacHost()) {
- connect(m_page->resetFileBrowserButton, SIGNAL(clicked()), this, SLOT(resetFileBrowser()));
- connect(m_page->helpExternalFileBrowserButton, SIGNAL(clicked()),
- this, SLOT(showHelpForFileBrowser()));
+ if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost()) {
+ QSettings *settings = Core::ICore::settings();
+ m_page->externalFileBrowserEdit->setText(UnixUtils::fileBrowser(settings));
+ } else {
+ m_page->externalFileBrowserLabel->hide();
+ m_page->externalFileBrowserEdit->hide();
+ m_page->resetFileBrowserButton->hide();
+ m_page->helpExternalFileBrowserButton->hide();
}
- }
- if (m_searchKeywords.isEmpty()) {
- QLatin1Char sep(' ');
- QTextStream(&m_searchKeywords)
- << m_page->interfaceBox->title() << sep
- << m_page->colorLabel->text() << sep
- << m_page->languageLabel->text() << sep
- << m_page->systemBox->title() << sep
- << m_page->terminalLabel->text() << sep
- << m_page->modifiedLabel->text();
- m_searchKeywords.remove(QLatin1Char('&'));
+ m_page->autoSaveCheckBox->setChecked(EditorManager::autoSaveEnabled());
+ m_page->autoSaveInterval->setValue(EditorManager::autoSaveInterval());
+ m_page->resetWarningsButton->setEnabled(Core::InfoBar::anyGloballySuppressed()
+ || Utils::CheckableMessageBox::hasSuppressedQuestions(ICore::settings()));
+
+ connect(m_page->resetColorButton, SIGNAL(clicked()),
+ this, SLOT(resetInterfaceColor()));
+ connect(m_page->resetWarningsButton, SIGNAL(clicked()),
+ this, SLOT(resetWarnings()));
+ if (HostOsInfo::isAnyUnixHost()) {
+ connect(m_page->resetTerminalButton, SIGNAL(clicked()), this, SLOT(resetTerminal()));
+ if (!HostOsInfo::isMacHost()) {
+ connect(m_page->resetFileBrowserButton, SIGNAL(clicked()), this, SLOT(resetFileBrowser()));
+ connect(m_page->helpExternalFileBrowserButton, SIGNAL(clicked()),
+ this, SLOT(showHelpForFileBrowser()));
+ }
+ }
}
return m_widget;
}
-bool GeneralSettings::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
void GeneralSettings::apply()
{
if (!m_page) // wasn't shown, can't be changed
@@ -195,6 +180,7 @@ void GeneralSettings::apply()
void GeneralSettings::finish()
{
+ delete m_widget;
if (!m_page) // page was never shown
return;
delete m_page;
diff --git a/src/plugins/coreplugin/generalsettings.h b/src/plugins/coreplugin/generalsettings.h
index c6b868ea0a..d51a7a8ecd 100644
--- a/src/plugins/coreplugin/generalsettings.h
+++ b/src/plugins/coreplugin/generalsettings.h
@@ -51,10 +51,9 @@ class GeneralSettings : public IOptionsPage
public:
GeneralSettings();
- QWidget* createPage(QWidget *parent);
+ QWidget* widget();
void apply();
void finish();
- virtual bool matches(const QString &) const;
private slots:
void resetInterfaceColor();
@@ -70,7 +69,6 @@ private:
QString language() const;
void setLanguage(const QString&);
Ui::GeneralSettings *m_page;
- QString m_searchKeywords;
QPointer<QMessageBox> m_dialog;
QPointer<QWidget> m_widget;
};
diff --git a/src/plugins/coreplugin/idocument.h b/src/plugins/coreplugin/idocument.h
index e37a2c7fae..483c7a8daa 100644
--- a/src/plugins/coreplugin/idocument.h
+++ b/src/plugins/coreplugin/idocument.h
@@ -51,12 +51,6 @@ public:
IgnoreAll = 2
};
- enum Utf8BomSetting {
- AlwaysAdd = 0,
- OnlyKeep = 1,
- AlwaysDelete = 2
- };
-
enum ChangeTrigger {
TriggerInternal,
TriggerExternal
diff --git a/src/plugins/coreplugin/iversioncontrol.cpp b/src/plugins/coreplugin/iversioncontrol.cpp
index 9559695c14..a798a78291 100644
--- a/src/plugins/coreplugin/iversioncontrol.cpp
+++ b/src/plugins/coreplugin/iversioncontrol.cpp
@@ -46,9 +46,64 @@ QString IVersionControl::vcsTopic(const QString &)
return QString();
}
-IVersionControl::OpenSupportMode IVersionControl::openSupportMode() const
+IVersionControl::OpenSupportMode IVersionControl::openSupportMode(const QString &fileName) const
{
+ Q_UNUSED(fileName);
return NoOpen;
}
+} // namespace Core
+
+#if defined(WITH_TESTS)
+
+#include "vcsmanager.h"
+
+#include <QFileInfo>
+
+namespace Core {
+
+TestVersionControl::~TestVersionControl()
+{
+ VcsManager::instance()->clearVersionControlCache();
+}
+
+void TestVersionControl::setManagedDirectories(const QHash<QString, QString> &dirs)
+{
+ m_managedDirs = dirs;
+ m_dirCount = 0;
+ VcsManager::instance()->clearVersionControlCache();
+}
+
+void TestVersionControl::setManagedFiles(const QSet<QString> &files)
+{
+ m_managedFiles = files;
+ m_fileCount = 0;
+ VcsManager::instance()->clearVersionControlCache();
+}
+
+bool TestVersionControl::managesDirectory(const QString &filename, QString *topLevel) const
+{
+ ++m_dirCount;
+
+ if (m_managedDirs.contains(filename)) {
+ if (topLevel)
+ *topLevel = m_managedDirs.value(filename);
+ return true;
+ }
+ return false;
}
+
+bool TestVersionControl::managesFile(const QString &workingDirectory, const QString &fileName) const
+{
+ ++m_fileCount;
+
+ QFileInfo fi(workingDirectory + QLatin1Char('/') + fileName);
+ QString dir = fi.absolutePath();
+ if (!managesDirectory(dir, 0))
+ return false;
+ QString file = fi.absoluteFilePath();
+ return m_managedFiles.contains(file);
+}
+
+} // namespace Core
+#endif
diff --git a/src/plugins/coreplugin/iversioncontrol.h b/src/plugins/coreplugin/iversioncontrol.h
index 86114e7992..1d7ed25360 100644
--- a/src/plugins/coreplugin/iversioncontrol.h
+++ b/src/plugins/coreplugin/iversioncontrol.h
@@ -100,9 +100,9 @@ public:
virtual bool supportsOperation(Operation operation) const = 0;
/*!
- * Returns the open support mode.
+ * Returns the open support mode for \a fileName.
*/
- virtual OpenSupportMode openSupportMode() const;
+ virtual OpenSupportMode openSupportMode(const QString &fileName) const;
/*!
* Called prior to save, if the file is read only. Should be implemented if
@@ -153,7 +153,7 @@ public:
/*!
* Called to get the version control repository root.
*/
- virtual QString vcsGetRepositoryURL(const QString &director) = 0;
+ virtual QString vcsGetRepositoryURL(const QString &directory) = 0;
/*!
* Topic (e.g. name of the current branch)
@@ -188,4 +188,54 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IVersionControl::SettingsFlags)
} // namespace Core
+#if defined(WITH_TESTS)
+
+#include <QSet>
+
+namespace Core {
+
+class CORE_EXPORT TestVersionControl : public IVersionControl
+{
+ Q_OBJECT
+public:
+ TestVersionControl(Core::Id id, const QString &name) :
+ m_id(id), m_displayName(name), m_dirCount(0), m_fileCount(0)
+ { }
+ ~TestVersionControl();
+
+ void setManagedDirectories(const QHash<QString, QString> &dirs);
+ void setManagedFiles(const QSet<QString> &files);
+
+ int dirCount() const { return m_dirCount; }
+ int fileCount() const { return m_fileCount; }
+
+ // IVersionControl interface
+ QString displayName() const { return m_displayName; }
+ Id id() const { return m_id; }
+ bool managesDirectory(const QString &filename, QString *topLevel) const;
+ bool managesFile(const QString &workingDirectory, const QString &fileName) const;
+ bool isConfigured() const { return true; }
+ bool supportsOperation(Operation) const { return false; }
+ bool vcsOpen(const QString &) { return false; }
+ bool vcsAdd(const QString &) { return false; }
+ bool vcsDelete(const QString &) { return false; }
+ bool vcsMove(const QString &, const QString &) { return false; }
+ bool vcsCreateRepository(const QString &) { return false; }
+ bool vcsCheckout(const QString &, const QByteArray &) { return false; }
+ QString vcsGetRepositoryURL(const QString &) { return QString(); }
+ bool vcsAnnotate(const QString &, int) { return false; }
+
+private:
+ Id m_id;
+ QString m_displayName;
+ QHash<QString, QString> m_managedDirs;
+ QSet<QString> m_managedFiles;
+ mutable int m_dirCount;
+ mutable int m_fileCount;
+};
+
+} // namespace Core
+#endif
+
+
#endif // IVERSIONCONTROL_H
diff --git a/src/plugins/locator/basefilefilter.cpp b/src/plugins/coreplugin/locator/basefilefilter.cpp
index c802014f1e..920f5b570d 100644
--- a/src/plugins/locator/basefilefilter.cpp
+++ b/src/plugins/coreplugin/locator/basefilefilter.cpp
@@ -36,7 +36,7 @@
#include <QStringMatcher>
using namespace Core;
-using namespace Locator;
+using namespace Core;
using namespace Utils;
BaseFileFilter::BaseFileFilter()
@@ -44,11 +44,11 @@ BaseFileFilter::BaseFileFilter()
{
}
-QList<FilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &origEntry)
+QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &origEntry)
{
updateFiles();
- QList<FilterEntry> betterEntries;
- QList<FilterEntry> goodEntries;
+ QList<LocatorFilterEntry> betterEntries;
+ QList<LocatorFilterEntry> goodEntries;
QString needle = trimWildcards(origEntry);
const QString lineNoSuffix = EditorManager::splitLineNumber(&needle);
QStringMatcher matcher(needle, Qt::CaseInsensitive);
@@ -89,7 +89,7 @@ QList<FilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Locator::FilterEn
if ((hasWildcard && regexp.exactMatch(matchText))
|| (!hasWildcard && matcher.indexIn(matchText) != -1)) {
QFileInfo fi(path);
- FilterEntry entry(this, fi.fileName(), QString(path + lineNoSuffix));
+ LocatorFilterEntry entry(this, fi.fileName(), QString(path + lineNoSuffix));
entry.extraInfo = FileUtils::shortNativePath(FileName(fi));
entry.fileName = path;
if (matchText.startsWith(needle, caseSensitivityForPrefix))
@@ -105,7 +105,7 @@ QList<FilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Locator::FilterEn
return betterEntries;
}
-void BaseFileFilter::accept(Locator::FilterEntry selection) const
+void BaseFileFilter::accept(Core::LocatorFilterEntry selection) const
{
EditorManager::openEditor(selection.internalData.toString(), Id(),
EditorManager::CanContainLineNumber);
diff --git a/src/plugins/locator/basefilefilter.h b/src/plugins/coreplugin/locator/basefilefilter.h
index 7e7c7fe786..44102b30e4 100644
--- a/src/plugins/locator/basefilefilter.h
+++ b/src/plugins/coreplugin/locator/basefilefilter.h
@@ -30,21 +30,20 @@
#ifndef BASEFILEFILTER_H
#define BASEFILEFILTER_H
-#include "locator_global.h"
#include "ilocatorfilter.h"
#include <QStringList>
-namespace Locator {
+namespace Core {
-class LOCATOR_EXPORT BaseFileFilter : public Locator::ILocatorFilter
+class CORE_EXPORT BaseFileFilter : public Core::ILocatorFilter
{
Q_OBJECT
public:
BaseFileFilter();
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(Core::LocatorFilterEntry selection) const;
protected:
virtual void updateFiles();
@@ -62,6 +61,6 @@ private:
QString m_previousEntry;
};
-} // namespace Locator
+} // namespace Core
#endif // BASEFILEFILTER_H
diff --git a/src/plugins/locator/commandlocator.cpp b/src/plugins/coreplugin/locator/commandlocator.cpp
index bf9e2eed8b..13b4ec1485 100644
--- a/src/plugins/locator/commandlocator.cpp
+++ b/src/plugins/coreplugin/locator/commandlocator.cpp
@@ -35,7 +35,7 @@
#include <QAction>
-namespace Locator {
+namespace Core {
struct CommandLocatorPrivate
{
@@ -46,7 +46,7 @@ CommandLocator::CommandLocator(Core::Id id,
const QString &displayName,
const QString &shortCutString,
QObject *parent) :
- Locator::ILocatorFilter(parent),
+ Core::ILocatorFilter(parent),
d(new CommandLocatorPrivate)
{
setId(id);
@@ -64,10 +64,10 @@ void CommandLocator::appendCommand(Core::Command *cmd)
d->commands.push_back(cmd);
}
-QList<Locator::FilterEntry> CommandLocator::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
+QList<Core::LocatorFilterEntry> CommandLocator::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry)
{
- QList<FilterEntry> goodEntries;
- QList<FilterEntry> betterEntries;
+ QList<LocatorFilterEntry> goodEntries;
+ QList<LocatorFilterEntry> betterEntries;
// Get active, enabled actions matching text, store in list.
// Reference via index in extraInfo.
const QChar ampersand = QLatin1Char('&');
@@ -82,9 +82,9 @@ QList<Locator::FilterEntry> CommandLocator::matchesFor(QFutureInterface<Locator:
QString text = action->text();
text.remove(ampersand);
if (text.startsWith(entry, caseSensitivity_))
- betterEntries.append(FilterEntry(this, text, QVariant(i)));
+ betterEntries.append(LocatorFilterEntry(this, text, QVariant(i)));
else if (text.contains(entry, caseSensitivity_))
- goodEntries.append(FilterEntry(this, text, QVariant(i)));
+ goodEntries.append(LocatorFilterEntry(this, text, QVariant(i)));
}
}
}
@@ -92,7 +92,7 @@ QList<Locator::FilterEntry> CommandLocator::matchesFor(QFutureInterface<Locator:
return betterEntries;
}
-void CommandLocator::accept(Locator::FilterEntry entry) const
+void CommandLocator::accept(Core::LocatorFilterEntry entry) const
{
// Retrieve action via index.
const int index = entry.internalData.toInt();
@@ -106,4 +106,4 @@ void CommandLocator::refresh(QFutureInterface<void> &)
{
}
-} // namespace Locator
+} // namespace Core
diff --git a/src/plugins/locator/commandlocator.h b/src/plugins/coreplugin/locator/commandlocator.h
index 3943c49282..d62f5bdfd4 100644
--- a/src/plugins/locator/commandlocator.h
+++ b/src/plugins/coreplugin/locator/commandlocator.h
@@ -30,18 +30,16 @@
#ifndef COMMANDLOCATOR_H
#define COMMANDLOCATOR_H
-#include "locator_global.h"
#include "ilocatorfilter.h"
-namespace Core { class Command; }
+namespace Core {
-namespace Locator {
/* Command locators: Provides completion for a set of
* Core::Command's by sub-string of their action's text. */
-
+class Command;
struct CommandLocatorPrivate;
-class LOCATOR_EXPORT CommandLocator : public Locator::ILocatorFilter
+class CORE_EXPORT CommandLocator : public Core::ILocatorFilter
{
Q_OBJECT
@@ -52,14 +50,14 @@ public:
void appendCommand(Core::Command *cmd);
- QList<FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(FilterEntry selection) const;
+ QList<LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
private:
CommandLocatorPrivate *d;
};
-} // namespace Locator
+} // namespace Core
#endif // COMMANDLOCATOR_H
diff --git a/src/plugins/locator/directoryfilter.cpp b/src/plugins/coreplugin/locator/directoryfilter.cpp
index f920c3de62..dd7639cfe4 100644
--- a/src/plugins/locator/directoryfilter.cpp
+++ b/src/plugins/coreplugin/locator/directoryfilter.cpp
@@ -32,8 +32,8 @@
#include <QFileDialog>
#include <utils/filesearch.h>
-using namespace Locator;
-using namespace Locator::Internal;
+using namespace Core;
+using namespace Core::Internal;
DirectoryFilter::DirectoryFilter()
: m_name(tr("Generic Directory Filter")),
diff --git a/src/plugins/locator/directoryfilter.h b/src/plugins/coreplugin/locator/directoryfilter.h
index 021a516792..67e97a6e30 100644
--- a/src/plugins/locator/directoryfilter.h
+++ b/src/plugins/coreplugin/locator/directoryfilter.h
@@ -38,7 +38,7 @@
#include <QFutureInterface>
#include <QMutex>
-namespace Locator {
+namespace Core {
namespace Internal {
class DirectoryFilter : public BaseFileFilter
@@ -70,6 +70,6 @@ private:
};
} // namespace Internal
-} // namespace Locator
+} // namespace Core
#endif // DIRECTORYFILTER_H
diff --git a/src/plugins/locator/directoryfilter.ui b/src/plugins/coreplugin/locator/directoryfilter.ui
index d2b954ace1..051f7c5104 100644
--- a/src/plugins/locator/directoryfilter.ui
+++ b/src/plugins/coreplugin/locator/directoryfilter.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>Locator::Internal::DirectoryFilterOptions</class>
- <widget class="QDialog" name="Locator::Internal::DirectoryFilterOptions">
+ <class>Core::Internal::DirectoryFilterOptions</class>
+ <widget class="QDialog" name="Core::Internal::DirectoryFilterOptions">
<property name="geometry">
<rect>
<x>0</x>
@@ -162,7 +162,7 @@ To do this, you type this shortcut and a space in the Locator entry field, and t
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
- <receiver>Locator::Internal::DirectoryFilterOptions</receiver>
+ <receiver>Core::Internal::DirectoryFilterOptions</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
@@ -178,7 +178,7 @@ To do this, you type this shortcut and a space in the Locator entry field, and t
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
- <receiver>Locator::Internal::DirectoryFilterOptions</receiver>
+ <receiver>Core::Internal::DirectoryFilterOptions</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
diff --git a/src/plugins/locator/executefilter.cpp b/src/plugins/coreplugin/locator/executefilter.cpp
index 4f7cc7404e..6c2e5f83bd 100644
--- a/src/plugins/locator/executefilter.cpp
+++ b/src/plugins/coreplugin/locator/executefilter.cpp
@@ -36,8 +36,8 @@
#include <QMessageBox>
using namespace Core;
-using namespace Locator;
-using namespace Locator::Internal;
+using namespace Core;
+using namespace Core::Internal;
ExecuteFilter::ExecuteFilter()
{
@@ -57,13 +57,13 @@ ExecuteFilter::ExecuteFilter()
connect(&m_runTimer, SIGNAL(timeout()), this, SLOT(runHeadCommand()));
}
-QList<FilterEntry> ExecuteFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future,
+QList<LocatorFilterEntry> ExecuteFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry)
{
- QList<FilterEntry> value;
+ QList<LocatorFilterEntry> value;
if (!entry.isEmpty()) // avoid empty entry
- value.append(FilterEntry(this, entry, QVariant()));
- QList<FilterEntry> others;
+ value.append(LocatorFilterEntry(this, entry, QVariant()));
+ QList<LocatorFilterEntry> others;
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
foreach (const QString &i, m_commandHistory) {
if (future.isCanceled())
@@ -71,15 +71,15 @@ QList<FilterEntry> ExecuteFilter::matchesFor(QFutureInterface<Locator::FilterEnt
if (i == entry) // avoid repeated entry
continue;
if (i.startsWith(entry, caseSensitivityForPrefix))
- value.append(FilterEntry(this, i, QVariant()));
+ value.append(LocatorFilterEntry(this, i, QVariant()));
else
- others.append(FilterEntry(this, i, QVariant()));
+ others.append(LocatorFilterEntry(this, i, QVariant()));
}
value.append(others);
return value;
}
-void ExecuteFilter::accept(FilterEntry selection) const
+void ExecuteFilter::accept(LocatorFilterEntry selection) const
{
ExecuteFilter *p = const_cast<ExecuteFilter *>(this);
diff --git a/src/plugins/locator/executefilter.h b/src/plugins/coreplugin/locator/executefilter.h
index 9d2f0e946c..719d8514c8 100644
--- a/src/plugins/locator/executefilter.h
+++ b/src/plugins/coreplugin/locator/executefilter.h
@@ -39,10 +39,10 @@
#include <QTimer>
#include <QTextCodec>
-namespace Locator {
+namespace Core {
namespace Internal {
-class ExecuteFilter : public Locator::ILocatorFilter
+class ExecuteFilter : public Core::ILocatorFilter
{
Q_OBJECT
struct ExecuteData
@@ -54,9 +54,9 @@ class ExecuteFilter : public Locator::ILocatorFilter
public:
ExecuteFilter();
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future,
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &) {}
private slots:
@@ -78,6 +78,6 @@ private:
};
} // namespace Internal
-} // namespace Locator
+} // namespace Core
#endif // EXECUTEFILTER_H
diff --git a/src/plugins/locator/filesystemfilter.cpp b/src/plugins/coreplugin/locator/filesystemfilter.cpp
index b5a1139964..84b05cfd5e 100644
--- a/src/plugins/locator/filesystemfilter.cpp
+++ b/src/plugins/coreplugin/locator/filesystemfilter.cpp
@@ -35,14 +35,14 @@
#include <QDir>
using namespace Core;
-using namespace Locator;
-using namespace Locator::Internal;
+using namespace Core;
+using namespace Core::Internal;
namespace {
-QList<FilterEntry> *categorize(const QString &entry, const QString &candidate,
+QList<LocatorFilterEntry> *categorize(const QString &entry, const QString &candidate,
Qt::CaseSensitivity caseSensitivity,
- QList<FilterEntry> *betterEntries, QList<FilterEntry> *goodEntries)
+ QList<LocatorFilterEntry> *betterEntries, QList<LocatorFilterEntry> *goodEntries)
{
if (entry.isEmpty() || candidate.startsWith(entry, caseSensitivity))
return betterEntries;
@@ -62,10 +62,10 @@ FileSystemFilter::FileSystemFilter(LocatorWidget *locatorWidget)
setIncludedByDefault(false);
}
-QList<FilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
+QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry)
{
- QList<FilterEntry> goodEntries;
- QList<FilterEntry> betterEntries;
+ QList<LocatorFilterEntry> goodEntries;
+ QList<LocatorFilterEntry> betterEntries;
QFileInfo entryInfo(entry);
QString name = entryInfo.fileName();
QString directory = entryInfo.path();
@@ -96,10 +96,10 @@ QList<FilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Locator::Filter
foreach (const QString &dir, dirs) {
if (future.isCanceled())
break;
- if (QList<FilterEntry> *category = categorize(name, dir, caseSensitivity_, &betterEntries,
+ if (QList<LocatorFilterEntry> *category = categorize(name, dir, caseSensitivity_, &betterEntries,
&goodEntries)) {
const QString fullPath = dirInfo.filePath(dir);
- FilterEntry filterEntry(this, dir, QVariant());
+ LocatorFilterEntry filterEntry(this, dir, QVariant());
filterEntry.fileName = fullPath;
category->append(filterEntry);
}
@@ -111,10 +111,10 @@ QList<FilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Locator::Filter
foreach (const QString &file, files) {
if (future.isCanceled())
break;
- if (QList<FilterEntry> *category = categorize(name, file, caseSensitivity_, &betterEntries,
+ if (QList<LocatorFilterEntry> *category = categorize(name, file, caseSensitivity_, &betterEntries,
&goodEntries)) {
const QString fullPath = dirInfo.filePath(file);
- FilterEntry filterEntry(this, file, QString(fullPath + lineNoSuffix));
+ LocatorFilterEntry filterEntry(this, file, QString(fullPath + lineNoSuffix));
filterEntry.fileName = fullPath;
category->append(filterEntry);
}
@@ -123,7 +123,7 @@ QList<FilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Locator::Filter
return betterEntries;
}
-void FileSystemFilter::accept(FilterEntry selection) const
+void FileSystemFilter::accept(LocatorFilterEntry selection) const
{
QString fileName = selection.fileName;
QFileInfo info(fileName);
diff --git a/src/plugins/locator/filesystemfilter.h b/src/plugins/coreplugin/locator/filesystemfilter.h
index 9708dca489..a6f0283065 100644
--- a/src/plugins/locator/filesystemfilter.h
+++ b/src/plugins/coreplugin/locator/filesystemfilter.h
@@ -38,19 +38,19 @@
#include <QByteArray>
#include <QFutureInterface>
-namespace Locator {
+namespace Core {
namespace Internal {
class LocatorWidget;
-class FileSystemFilter : public Locator::ILocatorFilter
+class FileSystemFilter : public Core::ILocatorFilter
{
Q_OBJECT
public:
explicit FileSystemFilter(LocatorWidget *locatorWidget);
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(Core::LocatorFilterEntry selection) const;
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
bool openConfigDialog(QWidget *parent, bool &needsRefresh);
@@ -62,6 +62,6 @@ private:
};
} // namespace Internal
-} // namespace Locator
+} // namespace Core
#endif // FILESYSTEMFILTER_H
diff --git a/src/plugins/locator/filesystemfilter.ui b/src/plugins/coreplugin/locator/filesystemfilter.ui
index 8fa9a0af01..b6a8944c70 100644
--- a/src/plugins/locator/filesystemfilter.ui
+++ b/src/plugins/coreplugin/locator/filesystemfilter.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>Locator::Internal::FileSystemFilterOptions</class>
- <widget class="QDialog" name="Locator::Internal::FileSystemFilterOptions">
+ <class>Core::Internal::FileSystemFilterOptions</class>
+ <widget class="QDialog" name="Core::Internal::FileSystemFilterOptions">
<property name="geometry">
<rect>
<x>0</x>
@@ -78,7 +78,7 @@
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
- <receiver>Locator::Internal::FileSystemFilterOptions</receiver>
+ <receiver>Core::Internal::FileSystemFilterOptions</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
@@ -94,7 +94,7 @@
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
- <receiver>Locator::Internal::FileSystemFilterOptions</receiver>
+ <receiver>Core::Internal::FileSystemFilterOptions</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
diff --git a/src/plugins/locator/ilocatorfilter.cpp b/src/plugins/coreplugin/locator/ilocatorfilter.cpp
index 70e8374c3b..ea91197cc6 100644
--- a/src/plugins/locator/ilocatorfilter.cpp
+++ b/src/plugins/coreplugin/locator/ilocatorfilter.cpp
@@ -36,7 +36,7 @@
#include <QLabel>
#include <QLineEdit>
-using namespace Locator;
+using namespace Core;
ILocatorFilter::ILocatorFilter(QObject *parent):
QObject(parent),
diff --git a/src/plugins/locator/ilocatorfilter.h b/src/plugins/coreplugin/locator/ilocatorfilter.h
index b3ca3039fc..3c6e213fa0 100644
--- a/src/plugins/locator/ilocatorfilter.h
+++ b/src/plugins/coreplugin/locator/ilocatorfilter.h
@@ -30,26 +30,24 @@
#ifndef ILOCATORFILTER_H
#define ILOCATORFILTER_H
-#include "locator_global.h"
-
#include <coreplugin/id.h>
#include <QVariant>
#include <QFutureInterface>
#include <QIcon>
-namespace Locator {
+namespace Core {
class ILocatorFilter;
-struct FilterEntry
+struct LocatorFilterEntry
{
- FilterEntry()
+ LocatorFilterEntry()
: filter(0)
, fileIconResolved(false)
{}
- FilterEntry(ILocatorFilter *fromFilter, const QString &name, const QVariant &data,
+ LocatorFilterEntry(ILocatorFilter *fromFilter, const QString &name, const QVariant &data,
const QIcon &icon = QIcon())
: filter(fromFilter)
, displayName(name)
@@ -58,7 +56,7 @@ struct FilterEntry
, fileIconResolved(false)
{}
- bool operator==(const FilterEntry &other) const {
+ bool operator==(const LocatorFilterEntry &other) const {
if (internalData.canConvert(QVariant::String))
return (internalData.toString() == other.internalData.toString());
return internalData.constData() == other.internalData.constData();
@@ -80,7 +78,7 @@ struct FilterEntry
bool fileIconResolved;
};
-class LOCATOR_EXPORT ILocatorFilter : public QObject
+class CORE_EXPORT ILocatorFilter : public QObject
{
Q_OBJECT
@@ -103,10 +101,10 @@ public:
QString shortcutString() const;
/* List of matches for the given user entry. */
- virtual QList<FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry) = 0;
+ virtual QList<LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry) = 0;
/* User has selected the given entry that belongs to this filter. */
- virtual void accept(FilterEntry selection) const = 0;
+ virtual void accept(LocatorFilterEntry selection) const = 0;
/* Implement to update caches on user request, if that's a long operation. */
virtual void refresh(QFutureInterface<void> &future) = 0;
@@ -164,6 +162,6 @@ private:
bool m_isConfigurable;
};
-} // namespace Locator
+} // namespace Core
#endif // ILOCATORFILTER_H
diff --git a/src/plugins/locator/images/locator.png b/src/plugins/coreplugin/locator/images/locator.png
index 000ee1c018..000ee1c018 100644
--- a/src/plugins/locator/images/locator.png
+++ b/src/plugins/coreplugin/locator/images/locator.png
Binary files differ
diff --git a/src/plugins/locator/images/reload.png b/src/plugins/coreplugin/locator/images/reload.png
index b5afefb32b..b5afefb32b 100644
--- a/src/plugins/locator/images/reload.png
+++ b/src/plugins/coreplugin/locator/images/reload.png
Binary files differ
diff --git a/src/plugins/coreplugin/locator/locator.pri b/src/plugins/coreplugin/locator/locator.pri
new file mode 100644
index 0000000000..174e1684fe
--- /dev/null
+++ b/src/plugins/coreplugin/locator/locator.pri
@@ -0,0 +1,46 @@
+HEADERS += \
+ $$PWD/locatorplugin.h \
+ $$PWD/commandlocator.h \
+ $$PWD/locatorwidget.h \
+ $$PWD/locatorfiltersfilter.h \
+ $$PWD/settingspage.h \
+ $$PWD/ilocatorfilter.h \
+ $$PWD/opendocumentsfilter.h \
+ $$PWD/filesystemfilter.h \
+ $$PWD/locatorconstants.h \
+ $$PWD/directoryfilter.h \
+ $$PWD/locatormanager.h \
+ $$PWD/basefilefilter.h \
+ $$PWD/executefilter.h \
+ $$PWD/locatorsearchutils.h
+
+SOURCES += \
+ $$PWD/locatorplugin.cpp \
+ $$PWD/commandlocator.cpp \
+ $$PWD/locatorwidget.cpp \
+ $$PWD/locatorfiltersfilter.cpp \
+ $$PWD/opendocumentsfilter.cpp \
+ $$PWD/filesystemfilter.cpp \
+ $$PWD/settingspage.cpp \
+ $$PWD/directoryfilter.cpp \
+ $$PWD/locatormanager.cpp \
+ $$PWD/basefilefilter.cpp \
+ $$PWD/ilocatorfilter.cpp \
+ $$PWD/executefilter.cpp \
+ $$PWD/locatorsearchutils.cpp
+
+FORMS += \
+ $$PWD/settingspage.ui \
+ $$PWD/filesystemfilter.ui \
+ $$PWD/directoryfilter.ui
+
+RESOURCES += \
+ $$PWD/locator.qrc
+
+equals(TEST, 1) {
+ HEADERS += $$PWD/locatorfiltertest.h
+ SOURCES += \
+ $$PWD/locatorfiltertest.cpp \
+ $$PWD/locator_test.cpp
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
+}
diff --git a/src/plugins/locator/locator.qrc b/src/plugins/coreplugin/locator/locator.qrc
index 4cd5df4f13..4cd5df4f13 100644
--- a/src/plugins/locator/locator.qrc
+++ b/src/plugins/coreplugin/locator/locator.qrc
diff --git a/src/plugins/locator/locator_test.cpp b/src/plugins/coreplugin/locator/locator_test.cpp
index e9532fb36a..35640285ec 100644
--- a/src/plugins/locator/locator_test.cpp
+++ b/src/plugins/coreplugin/locator/locator_test.cpp
@@ -40,18 +40,13 @@
#include <QTextStream>
#include <QtTest>
-using namespace Locator::Internal::Tests;
+using namespace Core::Tests;
namespace {
-class MyTestDataDir : public Core::Internal::Tests::TestDataDir
-{
-public:
- MyTestDataDir(const QString &testDataDirectory)
- : TestDataDir(QLatin1String(SRCDIR "/../../../tests/locators/") + testDataDirectory) {}
-};
+QTC_DECLARE_MYTESTDATADIR("../../../tests/locators/")
-class MyBaseFileFilter : public Locator::BaseFileFilter
+class MyBaseFileFilter : public Core::BaseFileFilter
{
public:
MyBaseFileFilter(const QStringList &theFiles)
@@ -85,7 +80,7 @@ public:
Q_DECLARE_METATYPE(ReferenceData)
Q_DECLARE_METATYPE(QList<ReferenceData>)
-void Locator::Internal::LocatorPlugin::test_basefilefilter()
+void Core::Internal::LocatorPlugin::test_basefilefilter()
{
QFETCH(QStringList, testFiles);
QFETCH(QList<ReferenceData>, referenceDataList);
@@ -94,7 +89,7 @@ void Locator::Internal::LocatorPlugin::test_basefilefilter()
BasicLocatorFilterTest test(&filter);
foreach (const ReferenceData &reference, referenceDataList) {
- const QList<FilterEntry> filterEntries = test.matchesFor(reference.searchText);
+ const QList<LocatorFilterEntry> filterEntries = test.matchesFor(reference.searchText);
const ResultDataList results = ResultData::fromFilterEntryList(filterEntries);
// QTextStream(stdout) << "----" << endl;
// ResultData::printFilterEntries(results);
@@ -102,7 +97,7 @@ void Locator::Internal::LocatorPlugin::test_basefilefilter()
}
}
-void Locator::Internal::LocatorPlugin::test_basefilefilter_data()
+void Core::Internal::LocatorPlugin::test_basefilefilter_data()
{
QTest::addColumn<QStringList>("testFiles");
QTest::addColumn<QList<ReferenceData> >("referenceDataList");
diff --git a/src/plugins/locator/locatorconstants.h b/src/plugins/coreplugin/locator/locatorconstants.h
index 71bca5f0af..bd39b411d3 100644
--- a/src/plugins/locator/locatorconstants.h
+++ b/src/plugins/coreplugin/locator/locatorconstants.h
@@ -32,13 +32,13 @@
#include <QtGlobal>
-namespace Locator {
+namespace Core {
namespace Constants {
const char FILTER_OPTIONS_PAGE[] = QT_TRANSLATE_NOOP("Locator", "Locator");
const char TASK_INDEX[] = "Locator.Task.Index";
} // namespace Constants
-} // namespace Locator
+} // namespace Core
#endif // LOCATORCONSTANTS_H
diff --git a/src/plugins/locator/locatorfiltersfilter.cpp b/src/plugins/coreplugin/locator/locatorfiltersfilter.cpp
index ff69e2a3fe..3c52ad72d9 100644
--- a/src/plugins/locator/locatorfiltersfilter.cpp
+++ b/src/plugins/coreplugin/locator/locatorfiltersfilter.cpp
@@ -33,8 +33,8 @@
#include <coreplugin/coreconstants.h>
-using namespace Locator;
-using namespace Locator::Internal;
+using namespace Core;
+using namespace Core::Internal;
Q_DECLARE_METATYPE(ILocatorFilter*)
@@ -52,9 +52,9 @@ LocatorFiltersFilter::LocatorFiltersFilter(LocatorPlugin *plugin,
setConfigurable(false);
}
-QList<FilterEntry> LocatorFiltersFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
+QList<LocatorFilterEntry> LocatorFiltersFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry)
{
- QList<FilterEntry> entries;
+ QList<LocatorFilterEntry> entries;
if (!entry.isEmpty())
return entries;
@@ -68,7 +68,7 @@ QList<FilterEntry> LocatorFiltersFilter::matchesFor(QFutureInterface<Locator::Fi
if (future.isCanceled())
break;
if (!filter->shortcutString().isEmpty() && !filter->isHidden() && filter->isEnabled()) {
- FilterEntry filterEntry(this,
+ LocatorFilterEntry filterEntry(this,
filter->shortcutString(),
QVariant::fromValue(filter),
m_icon);
@@ -80,7 +80,7 @@ QList<FilterEntry> LocatorFiltersFilter::matchesFor(QFutureInterface<Locator::Fi
return entries;
}
-void LocatorFiltersFilter::accept(FilterEntry selection) const
+void LocatorFiltersFilter::accept(LocatorFilterEntry selection) const
{
ILocatorFilter *filter = selection.internalData.value<ILocatorFilter *>();
if (filter)
diff --git a/src/plugins/locator/locatorfiltersfilter.h b/src/plugins/coreplugin/locator/locatorfiltersfilter.h
index 8fb7bab8e3..c775c3a824 100644
--- a/src/plugins/locator/locatorfiltersfilter.h
+++ b/src/plugins/coreplugin/locator/locatorfiltersfilter.h
@@ -34,7 +34,7 @@
#include <QIcon>
-namespace Locator {
+namespace Core {
namespace Internal {
class LocatorPlugin;
@@ -53,8 +53,8 @@ public:
LocatorWidget *locatorWidget);
// ILocatorFilter
- QList<FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(FilterEntry selection) const;
+ QList<LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
private:
@@ -64,6 +64,6 @@ private:
};
} // namespace Internal
-} // namespace Locator
+} // namespace Core
#endif // LOCATORFILTERSFILTER_H
diff --git a/src/plugins/locator/locatorfiltertest.cpp b/src/plugins/coreplugin/locator/locatorfiltertest.cpp
index a552594e3e..1bdf4998e0 100644
--- a/src/plugins/locator/locatorfiltertest.cpp
+++ b/src/plugins/coreplugin/locator/locatorfiltertest.cpp
@@ -38,19 +38,18 @@
#include <QString>
#include <QTextStream>
-using namespace Locator;
-using namespace Locator::Internal;
-using namespace Locator::Internal::Tests;
+using namespace Core;
+using namespace Core::Tests;
BasicLocatorFilterTest::BasicLocatorFilterTest(ILocatorFilter *filter) : m_filter(filter)
{
}
-QList<FilterEntry> BasicLocatorFilterTest::matchesFor(const QString &searchText)
+QList<LocatorFilterEntry> BasicLocatorFilterTest::matchesFor(const QString &searchText)
{
doBeforeLocatorRun();
const QList<ILocatorFilter *> filters = QList<ILocatorFilter *>() << m_filter;
- QFuture<FilterEntry> locatorSearch = QtConcurrent::run(Locator::Internal::runSearch,
+ QFuture<LocatorFilterEntry> locatorSearch = QtConcurrent::run(Core::Internal::runSearch,
filters, searchText);
locatorSearch.waitForFinished();
doAfterLocatorRun();
@@ -71,10 +70,10 @@ bool ResultData::operator==(const ResultData &other) const
return textColumn1 == other.textColumn1 && textColumn2 == other.textColumn2;
}
-ResultData::ResultDataList ResultData::fromFilterEntryList(const QList<FilterEntry> &entries)
+ResultData::ResultDataList ResultData::fromFilterEntryList(const QList<LocatorFilterEntry> &entries)
{
ResultDataList result;
- foreach (const FilterEntry &entry, entries)
+ foreach (const LocatorFilterEntry &entry, entries)
result << ResultData(entry.displayName, entry.extraInfo);
return result;
}
diff --git a/src/plugins/locator/locatorfiltertest.h b/src/plugins/coreplugin/locator/locatorfiltertest.h
index a2ddbf12fb..6cbf1e115c 100644
--- a/src/plugins/locator/locatorfiltertest.h
+++ b/src/plugins/coreplugin/locator/locatorfiltertest.h
@@ -31,31 +31,29 @@
#ifndef LOCATORFILTERTEST_H
#define LOCATORFILTERTEST_H
-#include "locator_global.h"
#include "ilocatorfilter.h"
#include <QTest>
-namespace Locator {
-namespace Internal {
+namespace Core {
namespace Tests {
/// Runs a locator filter for a search text and returns the results.
-class LOCATOR_EXPORT BasicLocatorFilterTest
+class CORE_EXPORT BasicLocatorFilterTest
{
public:
- BasicLocatorFilterTest(Locator::ILocatorFilter *filter);
+ BasicLocatorFilterTest(Core::ILocatorFilter *filter);
- QList<Locator::FilterEntry> matchesFor(const QString &searchText = QString());
+ QList<Core::LocatorFilterEntry> matchesFor(const QString &searchText = QString());
private:
virtual void doBeforeLocatorRun() {}
virtual void doAfterLocatorRun() {}
- Locator::ILocatorFilter *m_filter;
+ Core::ILocatorFilter *m_filter;
};
-class LOCATOR_EXPORT ResultData
+class CORE_EXPORT ResultData
{
public:
typedef QList<ResultData> ResultDataList;
@@ -65,7 +63,7 @@ public:
bool operator==(const ResultData &other) const;
- static ResultDataList fromFilterEntryList(const QList<FilterEntry> &entries);
+ static ResultDataList fromFilterEntryList(const QList<LocatorFilterEntry> &entries);
/// For debugging and creating reference data
static void printFilterEntries(const ResultDataList &entries);
@@ -77,16 +75,15 @@ public:
typedef ResultData::ResultDataList ResultDataList;
} // namespace Tests
-} // namespace Internal
-} // namespace Locator
+} // namespace Core
-Q_DECLARE_METATYPE(Locator::Internal::Tests::ResultData)
-Q_DECLARE_METATYPE(Locator::Internal::Tests::ResultDataList)
+Q_DECLARE_METATYPE(Core::Tests::ResultData)
+Q_DECLARE_METATYPE(Core::Tests::ResultDataList)
QT_BEGIN_NAMESPACE
namespace QTest {
-template<> inline char *toString(const Locator::Internal::Tests::ResultData &data)
+template<> inline char *toString(const Core::Tests::ResultData &data)
{
QByteArray ba = "\"" + data.textColumn1.toUtf8() + "\", \"" + data.textColumn2.toUtf8() + "\"";
return qstrdup(ba.data());
diff --git a/src/plugins/locator/locatormanager.cpp b/src/plugins/coreplugin/locator/locatormanager.cpp
index 279cecaaae..9cc893f5f6 100644
--- a/src/plugins/locator/locatormanager.cpp
+++ b/src/plugins/coreplugin/locator/locatormanager.cpp
@@ -33,7 +33,7 @@
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
-namespace Locator {
+namespace Core {
static Internal::LocatorWidget *m_locatorWidget = 0;
diff --git a/src/plugins/locator/locatormanager.h b/src/plugins/coreplugin/locator/locatormanager.h
index 9affcf8e61..67d2106c04 100644
--- a/src/plugins/locator/locatormanager.h
+++ b/src/plugins/coreplugin/locator/locatormanager.h
@@ -30,15 +30,15 @@
#ifndef LOCATORMANAGER_H
#define LOCATORMANAGER_H
-#include "locator_global.h"
+#include <coreplugin/core_global.h>
#include <QObject>
-namespace Locator {
+namespace Core {
namespace Internal { class LocatorWidget; }
-class LOCATOR_EXPORT LocatorManager : public QObject
+class CORE_EXPORT LocatorManager : public QObject
{
Q_OBJECT
@@ -49,6 +49,6 @@ public:
static void show(const QString &text, int selectionStart = -1, int selectionLength = 0);
};
-} // namespace Locator
+} // namespace Core
#endif // LOCATORMANAGER_H
diff --git a/src/plugins/coreplugin/locator/locatorplugin.cpp b/src/plugins/coreplugin/locator/locatorplugin.cpp
new file mode 100644
index 0000000000..085c0071d2
--- /dev/null
+++ b/src/plugins/coreplugin/locator/locatorplugin.cpp
@@ -0,0 +1,261 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "locatorplugin.h"
+#include "locatorconstants.h"
+#include "locatorfiltersfilter.h"
+#include "locatormanager.h"
+#include "locatorwidget.h"
+#include "opendocumentsfilter.h"
+#include "filesystemfilter.h"
+#include "settingspage.h"
+
+#include <coreplugin/coreplugin.h>
+#include <coreplugin/statusbarwidget.h>
+#include <coreplugin/coreconstants.h>
+#include <coreplugin/settingsdatabase.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/actionmanager/actioncontainer.h>
+#include <coreplugin/progressmanager/progressmanager.h>
+#include <coreplugin/progressmanager/futureprogress.h>
+#include <extensionsystem/pluginmanager.h>
+#include <utils/QtConcurrentTools>
+#include <utils/qtcassert.h>
+
+#include <QSettings>
+#include <QtPlugin>
+#include <QFuture>
+#include <QAction>
+
+namespace Core {
+namespace Internal {
+
+namespace {
+ static bool filterLessThan(const ILocatorFilter *first, const ILocatorFilter *second)
+ {
+ if (first->priority() < second->priority())
+ return true;
+ if (first->priority() > second->priority())
+ return false;
+ return first->id().alphabeticallyBefore(second->id());
+ }
+}
+
+LocatorPlugin::LocatorPlugin()
+ : m_settingsInitialized(false)
+{
+ m_corePlugin = 0;
+ m_refreshTimer.setSingleShot(false);
+ connect(&m_refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
+}
+
+LocatorPlugin::~LocatorPlugin()
+{
+ m_corePlugin->removeObject(m_openDocumentsFilter);
+ m_corePlugin->removeObject(m_fileSystemFilter);
+ m_corePlugin->removeObject(m_executeFilter);
+ m_corePlugin->removeObject(m_settingsPage);
+ delete m_openDocumentsFilter;
+ delete m_fileSystemFilter;
+ delete m_executeFilter;
+ delete m_settingsPage;
+ qDeleteAll(m_customFilters);
+}
+
+void LocatorPlugin::initialize(CorePlugin *corePlugin, const QStringList &, QString *)
+{
+ m_corePlugin = corePlugin;
+
+ m_settingsPage = new SettingsPage(this);
+ m_corePlugin->addObject(m_settingsPage);
+
+ m_locatorWidget = new LocatorWidget(this);
+ m_locatorWidget->setEnabled(false);
+ StatusBarWidget *view = new StatusBarWidget;
+ view->setWidget(m_locatorWidget);
+ view->setContext(Context("LocatorWidget"));
+ view->setPosition(StatusBarWidget::First);
+ m_corePlugin->addAutoReleasedObject(view);
+
+ QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this);
+ Command *cmd = ActionManager::registerAction(action, "QtCreator.Locate",
+ Context(Core::Constants::C_GLOBAL));
+ cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+K")));
+ connect(action, SIGNAL(triggered()), this, SLOT(openLocator()));
+ connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePlaceholderText()));
+ updatePlaceholderText(cmd);
+
+ ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
+ mtools->addAction(cmd);
+
+ m_corePlugin->addObject(new LocatorManager(m_locatorWidget));
+
+ m_openDocumentsFilter = new OpenDocumentsFilter;
+ m_corePlugin->addObject(m_openDocumentsFilter);
+
+ m_fileSystemFilter = new FileSystemFilter(m_locatorWidget);
+ m_corePlugin->addObject(m_fileSystemFilter);
+
+ m_executeFilter = new ExecuteFilter();
+ m_corePlugin->addObject(m_executeFilter);
+
+ m_corePlugin->addAutoReleasedObject(new LocatorFiltersFilter(this, m_locatorWidget));
+}
+
+void LocatorPlugin::updatePlaceholderText(Command *command)
+{
+ if (!command)
+ command = qobject_cast<Command *>(sender());
+ QTC_ASSERT(command, return);
+ if (command->keySequence().isEmpty())
+ m_locatorWidget->setPlaceholderText(tr("Type to locate"));
+ else
+ m_locatorWidget->setPlaceholderText(tr("Type to locate (%1)").arg(
+ command->keySequence().toString(QKeySequence::NativeText)));
+}
+
+void LocatorPlugin::openLocator()
+{
+ m_locatorWidget->show(QString());
+}
+
+void LocatorPlugin::extensionsInitialized()
+{
+ m_filters = ExtensionSystem::PluginManager::getObjects<ILocatorFilter>();
+ qSort(m_filters.begin(), m_filters.end(), filterLessThan);
+ setFilters(m_filters);
+}
+
+bool LocatorPlugin::delayedInitialize()
+{
+ loadSettings();
+ return true;
+}
+
+void LocatorPlugin::loadSettings()
+{
+ QSettings *qs = ICore::settings();
+
+ // Backwards compatibility to old settings location
+ if (qs->contains(QLatin1String("QuickOpen/FiltersFilter"))) {
+ loadSettingsHelper(qs);
+ } else {
+ SettingsDatabase *settings = ICore::settingsDatabase();
+ loadSettingsHelper(settings);
+ }
+
+ qs->remove(QLatin1String("QuickOpen"));
+
+ m_locatorWidget->updateFilterList();
+ m_locatorWidget->setEnabled(true);
+ if (m_refreshTimer.interval() > 0)
+ m_refreshTimer.start();
+ m_settingsInitialized = true;
+}
+
+void LocatorPlugin::saveSettings()
+{
+ if (m_settingsInitialized) {
+ SettingsDatabase *s = ICore::settingsDatabase();
+ s->beginGroup(QLatin1String("QuickOpen"));
+ s->remove(QString());
+ s->setValue(QLatin1String("RefreshInterval"), refreshInterval());
+ foreach (ILocatorFilter *filter, m_filters) {
+ if (!m_customFilters.contains(filter))
+ s->setValue(filter->id().toString(), filter->saveState());
+ }
+ s->beginGroup(QLatin1String("CustomFilters"));
+ int i = 0;
+ foreach (ILocatorFilter *filter, m_customFilters) {
+ s->setValue(QLatin1String("directory") + QString::number(i),
+ filter->saveState());
+ ++i;
+ }
+ s->endGroup();
+ s->endGroup();
+ }
+}
+
+/*!
+ Return all filters, including the ones created by the user.
+*/
+QList<ILocatorFilter *> LocatorPlugin::filters()
+{
+ return m_filters;
+}
+
+/*!
+ This returns a subset of all the filters, that contains only the filters that
+ have been created by the user at some point (maybe in a previous session).
+ */
+QList<ILocatorFilter *> LocatorPlugin::customFilters()
+{
+ return m_customFilters;
+}
+
+void LocatorPlugin::setFilters(QList<ILocatorFilter *> f)
+{
+ m_filters = f;
+ m_locatorWidget->updateFilterList();
+}
+
+void LocatorPlugin::setCustomFilters(QList<ILocatorFilter *> filters)
+{
+ m_customFilters = filters;
+}
+
+int LocatorPlugin::refreshInterval()
+{
+ return m_refreshTimer.interval() / 60000;
+}
+
+void LocatorPlugin::setRefreshInterval(int interval)
+{
+ if (interval < 1) {
+ m_refreshTimer.stop();
+ m_refreshTimer.setInterval(0);
+ return;
+ }
+ m_refreshTimer.setInterval(interval * 60000);
+ m_refreshTimer.start();
+}
+
+void LocatorPlugin::refresh(QList<ILocatorFilter *> filters)
+{
+ if (filters.isEmpty())
+ filters = m_filters;
+ QFuture<void> task = QtConcurrent::run(&ILocatorFilter::refresh, filters);
+ FutureProgress *progress =
+ ProgressManager::addTask(task, tr("Indexing"), Core::Constants::TASK_INDEX);
+ connect(progress, SIGNAL(finished()), this, SLOT(saveSettings()));
+}
+
+} // namespace Internal
+} // namespace Core
diff --git a/src/plugins/locator/locatorplugin.h b/src/plugins/coreplugin/locator/locatorplugin.h
index f9268e12f1..f0a8a719b2 100644
--- a/src/plugins/locator/locatorplugin.h
+++ b/src/plugins/coreplugin/locator/locatorplugin.h
@@ -40,29 +40,24 @@
#include <QTimer>
#include <QFutureWatcher>
-#if QT_VERSION >= 0x050000
-# include <QtPlugin>
-#endif
-
-namespace Locator {
+namespace Core {
namespace Internal {
+class CorePlugin;
class LocatorWidget;
class OpenDocumentsFilter;
class FileSystemFilter;
class SettingsPage;
-class LocatorPlugin;
-class LocatorPlugin : public ExtensionSystem::IPlugin
+class LocatorPlugin : public QObject
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Locator.json")
public:
LocatorPlugin();
~LocatorPlugin();
- bool initialize(const QStringList &arguments, QString *errorMessage);
+ void initialize(CorePlugin *corePlugin, const QStringList &arguments, QString *errorMessage);
void extensionsInitialized();
bool delayedInitialize();
@@ -103,6 +98,7 @@ private:
OpenDocumentsFilter *m_openDocumentsFilter;
FileSystemFilter *m_fileSystemFilter;
ExecuteFilter *m_executeFilter;
+ CorePlugin *m_corePlugin;
};
template <typename S>
@@ -133,6 +129,6 @@ void LocatorPlugin::loadSettingsHelper(S *settings)
}
} // namespace Internal
-} // namespace Locator
+} // namespace Core
#endif // LOCATORPLUGIN_H
diff --git a/src/plugins/locator/locatorsearchutils.cpp b/src/plugins/coreplugin/locator/locatorsearchutils.cpp
index 51c37f31c0..189449fc66 100644
--- a/src/plugins/locator/locatorsearchutils.cpp
+++ b/src/plugins/coreplugin/locator/locatorsearchutils.cpp
@@ -34,27 +34,27 @@
#include <QString>
#include <QVariant>
-namespace Locator {
+namespace Core {
-uint qHash(const Locator::FilterEntry &entry)
+uint qHash(const Core::LocatorFilterEntry &entry)
{
if (entry.internalData.canConvert(QVariant::String))
return QT_PREPEND_NAMESPACE(qHash)(entry.internalData.toString());
return QT_PREPEND_NAMESPACE(qHash)(entry.internalData.constData());
}
-} // namespace Locator
+} // namespace Core
-void Locator::Internal::runSearch(QFutureInterface<Locator::FilterEntry> &entries,
+void Core::Internal::runSearch(QFutureInterface<Core::LocatorFilterEntry> &entries,
QList<ILocatorFilter *> filters, QString searchText)
{
- QSet<FilterEntry> alreadyAdded;
+ QSet<LocatorFilterEntry> alreadyAdded;
const bool checkDuplicates = (filters.size() > 1);
foreach (ILocatorFilter *filter, filters) {
if (entries.isCanceled())
break;
- foreach (const FilterEntry &entry, filter->matchesFor(entries, searchText)) {
+ foreach (const LocatorFilterEntry &entry, filter->matchesFor(entries, searchText)) {
if (checkDuplicates && alreadyAdded.contains(entry))
continue;
entries.reportResult(entry);
diff --git a/src/plugins/locator/locatorsearchutils.h b/src/plugins/coreplugin/locator/locatorsearchutils.h
index 59d90cdda3..1abf03a8fd 100644
--- a/src/plugins/locator/locatorsearchutils.h
+++ b/src/plugins/coreplugin/locator/locatorsearchutils.h
@@ -30,18 +30,17 @@
#ifndef LOCATORSEARCHUTILS_H
#define LOCATORSEARCHUTILS_H
-#include "locator_global.h"
#include "ilocatorfilter.h"
-namespace Locator {
+namespace Core {
namespace Internal {
-void LOCATOR_EXPORT runSearch(QFutureInterface<Locator::FilterEntry> &entries,
+void CORE_EXPORT runSearch(QFutureInterface<LocatorFilterEntry> &entries,
QList<ILocatorFilter *> filters,
QString searchText);
} // namespace Internal
-} // namespace Locator
+} // namespace Core
#endif // LOCATORSEARCHUTILS_H
diff --git a/src/plugins/locator/locatorwidget.cpp b/src/plugins/coreplugin/locator/locatorwidget.cpp
index d592b459a1..483ebe1a3f 100644
--- a/src/plugins/locator/locatorwidget.cpp
+++ b/src/plugins/coreplugin/locator/locatorwidget.cpp
@@ -59,12 +59,10 @@
#include <QTreeView>
#include <QToolTip>
-Q_DECLARE_METATYPE(Locator::ILocatorFilter*)
-Q_DECLARE_METATYPE(Locator::FilterEntry)
+Q_DECLARE_METATYPE(Core::ILocatorFilter*)
+Q_DECLARE_METATYPE(Core::LocatorFilterEntry)
-using namespace Core;
-
-namespace Locator {
+namespace Core {
namespace Internal {
/* A model to represent the Locator results. */
@@ -80,11 +78,11 @@ public:
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- void setEntries(const QList<FilterEntry> &entries);
+ void setEntries(const QList<LocatorFilterEntry> &entries);
//void setDisplayCount(int count);
private:
- mutable QList<FilterEntry> mEntries;
+ mutable QList<LocatorFilterEntry> mEntries;
//int mDisplayCount;
};
@@ -129,11 +127,7 @@ private:
} // namespace Internal
-
-} // namespace Locator
-
-using namespace Locator;
-using namespace Locator::Internal;
+using namespace Core::Internal;
// =========== LocatorModel ===========
@@ -170,7 +164,7 @@ QVariant LocatorModel::data(const QModelIndex &index, int role) const
return QVariant(mEntries.at(index.row()).displayName
+ QLatin1String("\n\n") + mEntries.at(index.row()).extraInfo);
} else if (role == Qt::DecorationRole && index.column() == 0) {
- FilterEntry &entry = mEntries[index.row()];
+ LocatorFilterEntry &entry = mEntries[index.row()];
if (!entry.fileIconResolved && !entry.fileName.isEmpty() && entry.displayIcon.isNull()) {
entry.fileIconResolved = true;
entry.displayIcon = FileIconProvider::icon(entry.fileName);
@@ -185,7 +179,7 @@ QVariant LocatorModel::data(const QModelIndex &index, int role) const
return QVariant();
}
-void LocatorModel::setEntries(const QList<FilterEntry> &entries)
+void LocatorModel::setEntries(const QList<LocatorFilterEntry> &entries)
{
beginResetModel();
mEntries = entries;
@@ -282,7 +276,7 @@ LocatorWidget::LocatorWidget(LocatorPlugin *qop) :
connect(m_completionList, SIGNAL(activated(QModelIndex)),
this, SLOT(scheduleAcceptCurrentEntry()));
- m_entriesWatcher = new QFutureWatcher<FilterEntry>(this);
+ m_entriesWatcher = new QFutureWatcher<LocatorFilterEntry>(this);
connect(m_entriesWatcher, SIGNAL(finished()), SLOT(updateEntries()));
m_showPopupTimer = new QTimer(this);
@@ -490,7 +484,7 @@ void LocatorWidget::updateCompletionList(const QString &text)
m_entriesWatcher->future().cancel();
m_entriesWatcher->future().waitForFinished();
- QFuture<FilterEntry> future = QtConcurrent::run(runSearch, filters, searchText);
+ QFuture<LocatorFilterEntry> future = QtConcurrent::run(runSearch, filters, searchText);
m_entriesWatcher->setFuture(future);
}
@@ -503,7 +497,7 @@ void LocatorWidget::updateEntries()
return;
}
- const QList<FilterEntry> entries = m_entriesWatcher->future().results();
+ const QList<LocatorFilterEntry> entries = m_entriesWatcher->future().results();
m_locatorModel->setEntries(entries);
if (m_locatorModel->rowCount() > 0)
m_completionList->setCurrentIndex(m_locatorModel->index(0, 0));
@@ -533,7 +527,7 @@ void LocatorWidget::acceptCurrentEntry()
const QModelIndex index = m_completionList->currentIndex();
if (!index.isValid())
return;
- const FilterEntry entry = m_locatorModel->data(index, Qt::UserRole).value<FilterEntry>();
+ const LocatorFilterEntry entry = m_locatorModel->data(index, Qt::UserRole).value<LocatorFilterEntry>();
m_completionList->hide();
m_fileLineEdit->clearFocus();
entry.filter->accept(entry);
@@ -592,3 +586,5 @@ void LocatorWidget::showConfigureDialog()
{
ICore::showOptionsDialog(Core::Constants::SETTINGS_CATEGORY_CORE, Constants::FILTER_OPTIONS_PAGE);
}
+
+} // namespace Core
diff --git a/src/plugins/locator/locatorwidget.h b/src/plugins/coreplugin/locator/locatorwidget.h
index aefa335a10..5bc150b362 100644
--- a/src/plugins/locator/locatorwidget.h
+++ b/src/plugins/coreplugin/locator/locatorwidget.h
@@ -46,7 +46,7 @@ namespace Utils {
class FilterLineEdit;
}
-namespace Locator {
+namespace Core {
namespace Internal {
class LocatorModel;
@@ -94,7 +94,7 @@ private:
QAction *m_configureAction;
Utils::FilterLineEdit *m_fileLineEdit;
QTimer *m_showPopupTimer;
- QFutureWatcher<FilterEntry> *m_entriesWatcher;
+ QFutureWatcher<LocatorFilterEntry> *m_entriesWatcher;
QMap<Core::Id, QAction *> m_filterActionMap;
bool m_updateRequested;
bool m_acceptRequested;
@@ -102,6 +102,6 @@ private:
};
} // namespace Internal
-} // namespace Locator
+} // namespace Core
#endif // LOCATORWIDGET_H
diff --git a/src/plugins/locator/opendocumentsfilter.cpp b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp
index f0e4549590..61fb946c0a 100644
--- a/src/plugins/locator/opendocumentsfilter.cpp
+++ b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp
@@ -36,8 +36,8 @@
#include <QFileInfo>
using namespace Core;
-using namespace Locator;
-using namespace Locator::Internal;
+using namespace Core;
+using namespace Core::Internal;
using namespace Utils;
OpenDocumentsFilter::OpenDocumentsFilter()
@@ -53,10 +53,10 @@ OpenDocumentsFilter::OpenDocumentsFilter()
this, SLOT(refreshInternally()));
}
-QList<FilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry_)
+QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry_)
{
- QList<FilterEntry> goodEntries;
- QList<FilterEntry> betterEntries;
+ QList<LocatorFilterEntry> goodEntries;
+ QList<LocatorFilterEntry> betterEntries;
QString entry = entry_;
const QString lineNoSuffix = EditorManager::splitLineNumber(&entry);
const QChar asterisk = QLatin1Char('*');
@@ -76,10 +76,10 @@ QList<FilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Locator::Fil
QString displayName = editorEntry.displayName();
if (regexp.exactMatch(displayName)) {
QFileInfo fi(fileName);
- FilterEntry fiEntry(this, fi.fileName(), QString(fileName + lineNoSuffix));
+ LocatorFilterEntry fiEntry(this, fi.fileName(), QString(fileName + lineNoSuffix));
fiEntry.extraInfo = FileUtils::shortNativePath(FileName(fi));
fiEntry.fileName = fileName;
- QList<FilterEntry> &category = displayName.startsWith(entry, caseSensitivityForPrefix)
+ QList<LocatorFilterEntry> &category = displayName.startsWith(entry, caseSensitivityForPrefix)
? betterEntries : goodEntries;
category.append(fiEntry);
}
@@ -107,7 +107,7 @@ void OpenDocumentsFilter::refresh(QFutureInterface<void> &future)
QMetaObject::invokeMethod(this, "refreshInternally", Qt::BlockingQueuedConnection);
}
-void OpenDocumentsFilter::accept(FilterEntry selection) const
+void OpenDocumentsFilter::accept(LocatorFilterEntry selection) const
{
EditorManager::openEditor(selection.internalData.toString(), Id(),
EditorManager::CanContainLineNumber);
diff --git a/src/plugins/locator/opendocumentsfilter.h b/src/plugins/coreplugin/locator/opendocumentsfilter.h
index e567d5b291..b16ca7144b 100644
--- a/src/plugins/locator/opendocumentsfilter.h
+++ b/src/plugins/coreplugin/locator/opendocumentsfilter.h
@@ -38,17 +38,17 @@
#include <QList>
#include <QFutureInterface>
-namespace Locator {
+namespace Core {
namespace Internal {
-class OpenDocumentsFilter : public Locator::ILocatorFilter
+class OpenDocumentsFilter : public Core::ILocatorFilter
{
Q_OBJECT
public:
OpenDocumentsFilter();
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
public slots:
@@ -59,6 +59,6 @@ private:
};
} // namespace Internal
-} // namespace Locator
+} // namespace Core
#endif // OPENDOCUMENTSFILTER_H
diff --git a/src/plugins/locator/settingspage.cpp b/src/plugins/coreplugin/locator/settingspage.cpp
index 1813cbcb5e..abdec8be5d 100644
--- a/src/plugins/locator/settingspage.cpp
+++ b/src/plugins/coreplugin/locator/settingspage.cpp
@@ -39,48 +39,45 @@
#include <QCoreApplication>
-Q_DECLARE_METATYPE(Locator::ILocatorFilter*)
+Q_DECLARE_METATYPE(Core::ILocatorFilter*)
-using namespace Locator;
-using namespace Locator::Internal;
+using namespace Core;
+using namespace Core::Internal;
SettingsPage::SettingsPage(LocatorPlugin *plugin)
- : m_plugin(plugin), m_page(0)
+ : m_plugin(plugin), m_widget(0)
{
setId(Constants::FILTER_OPTIONS_PAGE);
- setDisplayName(QCoreApplication::translate("Locator", Locator::Constants::FILTER_OPTIONS_PAGE));
+ setDisplayName(QCoreApplication::translate("Locator", Core::Constants::FILTER_OPTIONS_PAGE));
setCategory(Core::Constants::SETTINGS_CATEGORY_CORE);
setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE));
setCategoryIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
}
-QWidget *SettingsPage::createPage(QWidget *parent)
+QWidget *SettingsPage::widget()
{
-
- m_page = new QWidget(parent);
- m_ui.setupUi(m_page);
- m_ui.refreshInterval->setToolTip(m_ui.refreshIntervalLabel->toolTip());
- connect(m_ui.filterList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
- this, SLOT(updateButtonStates()));
- connect(m_ui.filterList, SIGNAL(itemActivated(QListWidgetItem*)),
- this, SLOT(configureFilter(QListWidgetItem*)));
- connect(m_ui.editButton, SIGNAL(clicked()),
- this, SLOT(configureFilter()));
- connect(m_ui.addButton, SIGNAL(clicked()),
- this, SLOT(addCustomFilter()));
- connect(m_ui.removeButton, SIGNAL(clicked()),
- this, SLOT(removeCustomFilter()));
-
- m_ui.refreshInterval->setValue(m_plugin->refreshInterval());
- m_filters = m_plugin->filters();
- m_customFilters = m_plugin->customFilters();
- saveFilterStates();
- updateFilterList();
- if (m_searchKeywords.isEmpty()) {
- m_searchKeywords = m_ui.refreshIntervalLabel->text();
- m_searchKeywords.remove(QLatin1Char('&'));
+ if (!m_widget) {
+ m_widget = new QWidget;
+ m_ui.setupUi(m_widget);
+ m_ui.refreshInterval->setToolTip(m_ui.refreshIntervalLabel->toolTip());
+ connect(m_ui.filterList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
+ this, SLOT(updateButtonStates()));
+ connect(m_ui.filterList, SIGNAL(itemActivated(QListWidgetItem*)),
+ this, SLOT(configureFilter(QListWidgetItem*)));
+ connect(m_ui.editButton, SIGNAL(clicked()),
+ this, SLOT(configureFilter()));
+ connect(m_ui.addButton, SIGNAL(clicked()),
+ this, SLOT(addCustomFilter()));
+ connect(m_ui.removeButton, SIGNAL(clicked()),
+ this, SLOT(removeCustomFilter()));
+
+ m_ui.refreshInterval->setValue(m_plugin->refreshInterval());
+ m_filters = m_plugin->filters();
+ m_customFilters = m_plugin->customFilters();
+ saveFilterStates();
+ updateFilterList();
}
- return m_page;
+ return m_widget;
}
void SettingsPage::apply()
@@ -114,6 +111,7 @@ void SettingsPage::finish()
m_filters.clear();
m_customFilters.clear();
m_refreshFilters.clear();
+ delete m_widget;
}
void SettingsPage::requestRefresh()
@@ -174,7 +172,7 @@ void SettingsPage::configureFilter(QListWidgetItem *item)
if (!filter->isConfigurable())
return;
bool needsRefresh = false;
- filter->openConfigDialog(m_page, needsRefresh);
+ filter->openConfigDialog(m_widget, needsRefresh);
if (needsRefresh && !m_refreshFilters.contains(filter))
m_refreshFilters.append(filter);
updateFilterList();
@@ -184,7 +182,7 @@ void SettingsPage::addCustomFilter()
{
ILocatorFilter *filter = new DirectoryFilter;
bool needsRefresh = false;
- if (filter->openConfigDialog(m_page, needsRefresh)) {
+ if (filter->openConfigDialog(m_widget, needsRefresh)) {
m_filters.append(filter);
m_addedFilters.append(filter);
m_customFilters.append(filter);
@@ -210,8 +208,3 @@ void SettingsPage::removeCustomFilter()
}
updateFilterList();
}
-
-bool SettingsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
diff --git a/src/plugins/locator/settingspage.h b/src/plugins/coreplugin/locator/settingspage.h
index ea8e5dd523..86ddb9d1a5 100644
--- a/src/plugins/locator/settingspage.h
+++ b/src/plugins/coreplugin/locator/settingspage.h
@@ -32,15 +32,16 @@
#include "ui_settingspage.h"
-#include <QHash>
-
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QHash>
+#include <QPointer>
+
QT_BEGIN_NAMESPACE
class QListWidgetItem;
QT_END_NAMESPACE
-namespace Locator {
+namespace Core {
class ILocatorFilter;
@@ -55,10 +56,9 @@ class SettingsPage : public Core::IOptionsPage
public:
explicit SettingsPage(LocatorPlugin *plugin);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &) const;
private slots:
void updateButtonStates();
@@ -72,19 +72,18 @@ private:
void restoreFilterStates();
void requestRefresh();
- Ui::SettingsWidget m_ui;
+ Ui::LocatorSettingsWidget m_ui;
LocatorPlugin *m_plugin;
- QWidget *m_page;
+ QPointer<QWidget> m_widget;
QList<ILocatorFilter *> m_filters;
QList<ILocatorFilter *> m_addedFilters;
QList<ILocatorFilter *> m_removedFilters;
QList<ILocatorFilter *> m_customFilters;
QList<ILocatorFilter *> m_refreshFilters;
QHash<ILocatorFilter *, QByteArray> m_filterStates;
- QString m_searchKeywords;
};
} // namespace Internal
-} // namespace Locator
+} // namespace Core
#endif // SETTINGSPAGE_H
diff --git a/src/plugins/locator/settingspage.ui b/src/plugins/coreplugin/locator/settingspage.ui
index e600ca1ced..797b650269 100644
--- a/src/plugins/locator/settingspage.ui
+++ b/src/plugins/coreplugin/locator/settingspage.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>Locator::Internal::SettingsWidget</class>
- <widget class="QWidget" name="Locator::Internal::SettingsWidget">
+ <class>Core::Internal::LocatorSettingsWidget</class>
+ <widget class="QWidget" name="Core::Internal::LocatorSettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
diff --git a/src/plugins/coreplugin/mimetypesettings.cpp b/src/plugins/coreplugin/mimetypesettings.cpp
index 3d466dc437..0275e99816 100644
--- a/src/plugins/coreplugin/mimetypesettings.cpp
+++ b/src/plugins/coreplugin/mimetypesettings.cpp
@@ -41,6 +41,7 @@
#include <QCoreApplication>
#include <QHash>
#include <QMessageBox>
+#include <QPointer>
#include <QScopedPointer>
#include <QSet>
#include <QStringList>
@@ -239,7 +240,6 @@ private slots:
public:
static const QChar kSemiColon;
- QString m_keywords;
MimeTypeSettingsModel *m_model;
QSortFilterProxyModel *m_filterModel;
int m_mimeForPatternSync;
@@ -249,6 +249,7 @@ public:
QList<int> m_modifiedMimeTypes;
QString m_filterPattern;
Ui::MimeTypeSettingsPage m_ui;
+ QPointer<QWidget> m_widget;
};
const QChar MimeTypeSettingsPrivate::kSemiColon(QLatin1Char(';'));
@@ -586,16 +587,13 @@ MimeTypeSettings::~MimeTypeSettings()
delete d;
}
-bool MimeTypeSettings::matches(const QString &s) const
+QWidget *MimeTypeSettings::widget()
{
- return d->m_keywords.contains(s, Qt::CaseInsensitive);
-}
-
-QWidget *MimeTypeSettings::createPage(QWidget *parent)
-{
- QWidget *w = new QWidget(parent);
- d->configureUi(w);
- return w;
+ if (!d->m_widget) {
+ d->m_widget = new QWidget;
+ d->configureUi(d->m_widget);
+ }
+ return d->m_widget;
}
void MimeTypeSettings::apply()
@@ -625,6 +623,7 @@ void MimeTypeSettings::finish()
d->updateMimeDatabase();
}
d->resetState();
+ delete d->m_widget;
}
} // Internal
diff --git a/src/plugins/coreplugin/mimetypesettings.h b/src/plugins/coreplugin/mimetypesettings.h
index d65ecf8cdb..244c188396 100644
--- a/src/plugins/coreplugin/mimetypesettings.h
+++ b/src/plugins/coreplugin/mimetypesettings.h
@@ -45,8 +45,7 @@ public:
MimeTypeSettings(QObject *parent = 0);
virtual ~MimeTypeSettings();
- virtual bool matches(const QString &s) const;
- virtual QWidget *createPage(QWidget *parent);
+ virtual QWidget *widget();
virtual void apply();
virtual void finish();
diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp
index 89818a6d31..5180a37411 100644
--- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp
+++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp
@@ -129,7 +129,7 @@ using namespace Core::Internal;
\c QFuture object. This is what you want to give the
ProgressManager in the addTask() function.
- Have a look at e.g Locator::ILocatorFilter. Locator filters implement
+ Have a look at e.g Core::ILocatorFilter. Locator filters implement
a function \c refresh which takes a \c QFutureInterface object
as a parameter. These functions look something like:
\code
diff --git a/src/plugins/coreplugin/testdatadir.cpp b/src/plugins/coreplugin/testdatadir.cpp
index e6f08f26a6..5bbc946f88 100644
--- a/src/plugins/coreplugin/testdatadir.cpp
+++ b/src/plugins/coreplugin/testdatadir.cpp
@@ -35,7 +35,7 @@
#include <QString>
#include <QTest>
-using namespace Core::Internal::Tests;
+using namespace Core::Tests;
static void maybeAppendSlash(QString *string)
{
diff --git a/src/plugins/coreplugin/testdatadir.h b/src/plugins/coreplugin/testdatadir.h
index fdd3bc6128..2b77cf2646 100644
--- a/src/plugins/coreplugin/testdatadir.h
+++ b/src/plugins/coreplugin/testdatadir.h
@@ -35,8 +35,15 @@
#include <QString>
+#define QTC_DECLARE_MYTESTDATADIR(PATH) \
+ class MyTestDataDir : public Core::Tests::TestDataDir \
+ { \
+ public: \
+ MyTestDataDir(const QString &testDataDirectory = QString()) \
+ : TestDataDir(QLatin1String(SRCDIR "/" PATH) + testDataDirectory) {} \
+ };
+
namespace Core {
-namespace Internal {
namespace Tests {
class CORE_EXPORT TestDataDir
@@ -53,7 +60,6 @@ private:
};
} // namespace Tests
-} // namespace Internal
} // namespace Core
#endif // TESTDATADIR_H
diff --git a/src/plugins/coreplugin/toolsettings.cpp b/src/plugins/coreplugin/toolsettings.cpp
index 24ecd95fcc..3da1264020 100644
--- a/src/plugins/coreplugin/toolsettings.cpp
+++ b/src/plugins/coreplugin/toolsettings.cpp
@@ -56,17 +56,12 @@ ToolSettings::ToolSettings(QObject *parent) :
}
-bool ToolSettings::matches(const QString & searchKeyWord) const
+QWidget *ToolSettings::widget()
{
- return m_searchKeywords.contains(searchKeyWord, Qt::CaseInsensitive);
-}
-
-QWidget *ToolSettings::createPage(QWidget *parent)
-{
- m_widget = new ExternalToolConfig(parent);
- m_widget->setTools(ExternalToolManager::toolsByCategory());
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new ExternalToolConfig;
+ m_widget->setTools(ExternalToolManager::toolsByCategory());
+ }
return m_widget;
}
@@ -206,4 +201,5 @@ void ToolSettings::apply()
void ToolSettings::finish()
{
+ delete m_widget;
}
diff --git a/src/plugins/coreplugin/toolsettings.h b/src/plugins/coreplugin/toolsettings.h
index cf59f08a14..3d6934cdef 100644
--- a/src/plugins/coreplugin/toolsettings.h
+++ b/src/plugins/coreplugin/toolsettings.h
@@ -46,13 +46,11 @@ class ToolSettings : public IOptionsPage
public:
explicit ToolSettings(QObject *parent = 0);
- bool matches(const QString & searchKeyWord) const;
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
private:
- QString m_searchKeywords;
QPointer<ExternalToolConfig> m_widget;
};
diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp
index 080922d734..2293e034a8 100644
--- a/src/plugins/coreplugin/vcsmanager.cpp
+++ b/src/plugins/coreplugin/vcsmanager.cpp
@@ -59,6 +59,10 @@ static inline VersionControlList allVersionControls()
return ExtensionSystem::PluginManager::getObjects<IVersionControl>();
}
+#if defined(WITH_TESTS)
+const char TEST_PREFIX[] = "/8E3A9BA0-0B97-40DF-AEC1-2BDF9FC9EDBE/";
+#endif
+
// ---- VCSManagerPrivate:
// Maintains a cache of top-level directory->version control.
@@ -196,7 +200,7 @@ VcsManager::~VcsManager()
delete d;
}
-QObject *VcsManager::instance()
+VcsManager *VcsManager::instance()
{
return m_instance;
}
@@ -233,8 +237,11 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
{
typedef QPair<QString, IVersionControl *> StringVersionControlPair;
typedef QList<StringVersionControlPair> StringVersionControlPairs;
- if (inputDirectory.isEmpty())
+ if (inputDirectory.isEmpty()) {
+ if (topLevelDirectory)
+ topLevelDirectory->clear();
return 0;
+ }
// Make sure we an absolute path:
const QString directory = QDir(inputDirectory).absolutePath();
@@ -271,6 +278,11 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
// Register Vcs(s) with the cache
QString tmpDir = QFileInfo(directory).canonicalFilePath();
+#if defined WITH_TESTS
+ // Force caching of test directories (even though they do not exist):
+ if (directory.startsWith(QLatin1String(TEST_PREFIX)))
+ tmpDir = directory;
+#endif
// directory might refer to a historical directory which doesn't exist.
// In this case, don't cache it.
if (!tmpDir.isEmpty()) {
@@ -352,24 +364,6 @@ IVersionControl *VcsManager::checkout(const QString &versionControlType,
return 0;
}
-bool VcsManager::findVersionControl(const QString &versionControlType)
-{
- foreach (IVersionControl * versionControl, allVersionControls()) {
- if (versionControl->displayName() == versionControlType)
- return true;
- }
- return false;
-}
-
-QString VcsManager::repositoryUrl(const QString &directory)
-{
- IVersionControl *vc = findVersionControlForDirectory(directory);
-
- if (vc && vc->supportsOperation(Core::IVersionControl::GetRepositoryRootOperation))
- return vc->vcsGetRepositoryURL(directory);
- return QString();
-}
-
bool VcsManager::promptToDelete(IVersionControl *vc, const QString &fileName)
{
QTC_ASSERT(vc, return true);
@@ -465,3 +459,181 @@ void VcsManager::configureVcs()
}
} // namespace Core
+
+#if defined(WITH_TESTS)
+
+#include <QtTest>
+
+#include "coreplugin.h"
+#include "iversioncontrol.h"
+
+#include <extensionsystem/pluginmanager.h>
+
+namespace Core {
+namespace Internal {
+
+const char ID_VCS_A[] = "A";
+const char ID_VCS_B[] = "B";
+
+typedef QHash<QString, QString> FileHash;
+
+template<class T>
+class ObjectPoolGuard
+{
+public:
+ ObjectPoolGuard(T *watch) : m_watched(watch)
+ {
+ ExtensionSystem::PluginManager::addObject(watch);
+ }
+
+ operator bool() { return m_watched; }
+ bool operator !() { return !m_watched; }
+ T &operator*() { return *m_watched; }
+ T *operator->() { return m_watched; }
+ T *value() { return m_watched; }
+
+ ~ObjectPoolGuard()
+ {
+ ExtensionSystem::PluginManager::removeObject(m_watched);
+ delete m_watched;
+ }
+
+private:
+ T *m_watched;
+};
+
+static FileHash makeHash(const QStringList &list)
+{
+ FileHash result;
+ foreach (const QString &i, list) {
+ QStringList parts = i.split(QLatin1Char(':'));
+ QTC_ASSERT(parts.count() == 2, continue);
+ result.insert(QString::fromLatin1(TEST_PREFIX) + parts.at(0),
+ QString::fromLatin1(TEST_PREFIX) + parts.at(1));
+ }
+ return result;
+}
+
+static QString makeString(const QString &s)
+{
+ if (s.isEmpty())
+ return QString();
+ return QString::fromLatin1(TEST_PREFIX) + s;
+}
+
+void CorePlugin::testVcsManager_data()
+{
+ // avoid conflicts with real files and directories:
+
+ QTest::addColumn<QStringList>("dirsVcsA"); // <directory>:<toplevel>
+ QTest::addColumn<QStringList>("dirsVcsB"); // <directory>:<toplevel>
+ // <directory>:<toplevel>:<vcsid>:<- from cache, * from VCS>
+ QTest::addColumn<QStringList>("results");
+
+ QTest::newRow("A and B next to each other")
+ << (QStringList()
+ << QLatin1String("a:a") << QLatin1String("a/1:a") << QLatin1String("a/2:a")
+ << QLatin1String("a/2/5:a") << QLatin1String("a/2/5/6:a"))
+ << (QStringList()
+ << QLatin1String("b:b") << QLatin1String("b/3:b") << QLatin1String("b/4:b"))
+ << (QStringList()
+ << QLatin1String(":::-") // empty directory to look up
+ << QLatin1String("c:::*") // Neither in A nor B
+ << QLatin1String("a:a:A:*") // in A
+ << QLatin1String("b:b:B:*") // in B
+ << QLatin1String("b/3:b:B:*") // in B
+ << QLatin1String("b/4:b:B:*") // in B
+ << QLatin1String("a/1:a:A:*") // in A
+ << QLatin1String("a/2:a:A:*") // in A
+ << QLatin1String(":::-") // empty directory to look up
+ << QLatin1String("a/2/5/6:a:A:*") // in A
+ << QLatin1String("a/2/5:a:A:-") // in A (cached from before!)
+ // repeat: These need to come from the cache now:
+ << QLatin1String("c:::-") // Neither in A nor B
+ << QLatin1String("a:a:A:-") // in A
+ << QLatin1String("b:b:B:-") // in B
+ << QLatin1String("b/3:b:B:-") // in B
+ << QLatin1String("b/4:b:B:-") // in B
+ << QLatin1String("a/1:a:A:-") // in A
+ << QLatin1String("a/2:a:A:-") // in A
+ << QLatin1String("a/2/5/6:a:A:-") // in A
+ << QLatin1String("a/2/5:a:A:-") // in A
+ );
+ QTest::newRow("B in A")
+ << (QStringList()
+ << QLatin1String("a:a") << QLatin1String("a/1:a") << QLatin1String("a/2:a")
+ << QLatin1String("a/2/5:a") << QLatin1String("a/2/5/6:a"))
+ << (QStringList()
+ << QLatin1String("a/1/b:a/1/b") << QLatin1String("a/1/b/3:a/1/b")
+ << QLatin1String("a/1/b/4:a/1/b") << QLatin1String("a/1/b/3/5:a/1/b")
+ << QLatin1String("a/1/b/3/5/6:a/1/b"))
+ << (QStringList()
+ << QLatin1String("a:a:A:*") // in A
+ << QLatin1String("c:::*") // Neither in A nor B
+ << QLatin1String("a/3:::*") // Neither in A nor B
+ << QLatin1String("a/1/b/x:::*") // Neither in A nor B
+ << QLatin1String("a/1/b:a/1/b:B:*") // in B
+ << QLatin1String("a/1:a:A:*") // in A
+ << QLatin1String("a/1/b/../../2:a:A:*") // in A
+ );
+ QTest::newRow("A and B") // first one wins...
+ << (QStringList() << QLatin1String("a:a") << QLatin1String("a/1:a") << QLatin1String("a/2:a"))
+ << (QStringList() << QLatin1String("a:a") << QLatin1String("a/1:a") << QLatin1String("a/2:a"))
+ << (QStringList() << QLatin1String("a/2:a:A:*"));
+}
+
+void CorePlugin::testVcsManager()
+{
+ // setup:
+ ObjectPoolGuard<TestVersionControl> vcsA(new TestVersionControl(ID_VCS_A, QLatin1String("A")));
+ ObjectPoolGuard<TestVersionControl> vcsB(new TestVersionControl(ID_VCS_B, QLatin1String("B")));
+
+ // test:
+ QFETCH(QStringList, dirsVcsA);
+ QFETCH(QStringList, dirsVcsB);
+ QFETCH(QStringList, results);
+
+ vcsA->setManagedDirectories(makeHash(dirsVcsA));
+ vcsB->setManagedDirectories(makeHash(dirsVcsB));
+
+ QString realTopLevel = QLatin1String("ABC"); // Make sure this gets cleared if needed.
+
+ // From VCSes:
+ int expectedCount = 0;
+ foreach (const QString &result, results) {
+ // qDebug() << "Expecting:" << result;
+
+ QStringList split = result.split(QLatin1String(":"));
+ QCOMPARE(split.count(), 4);
+ QVERIFY(split.at(3) == QLatin1String("*") || split.at(3) == QLatin1String("-"));
+
+
+ const QString directory = split.at(0);
+ const QString topLevel = split.at(1);
+ const QString vcsId = split.at(2);
+ bool fromCache = split.at(3) == QLatin1String("-");
+
+ if (!fromCache && !directory.isEmpty())
+ ++expectedCount;
+
+ IVersionControl *vcs;
+ vcs = VcsManager::findVersionControlForDirectory(makeString(directory), &realTopLevel);
+ QCOMPARE(realTopLevel, makeString(topLevel));
+ if (vcs)
+ QCOMPARE(vcs->id().toString(), vcsId);
+ else
+ QCOMPARE(QString(), vcsId);
+ QCOMPARE(vcsA->dirCount(), expectedCount);
+ QCOMPARE(vcsA->fileCount(), 0);
+ QCOMPARE(vcsB->dirCount(), expectedCount);
+ QCOMPARE(vcsB->fileCount(), 0);
+ }
+
+ // teardown:
+ // handled by guards
+}
+
+} // namespace Internal
+} // namespace Core
+
+#endif
diff --git a/src/plugins/coreplugin/vcsmanager.h b/src/plugins/coreplugin/vcsmanager.h
index 8bc78de714..cb27af193c 100644
--- a/src/plugins/coreplugin/vcsmanager.h
+++ b/src/plugins/coreplugin/vcsmanager.h
@@ -58,23 +58,19 @@ class CORE_EXPORT VcsManager : public QObject
Q_OBJECT
public:
- static QObject *instance();
+ static VcsManager *instance();
static void extensionsInitialized();
static void resetVersionControlForDirectory(const QString &inputDirectory);
static IVersionControl *findVersionControlForDirectory(const QString &directory,
- QString *topLevelDirectory = 0);
+ QString *topLevelDirectory = 0);
static QStringList repositories(const IVersionControl *);
static IVersionControl *checkout(const QString &versionControlType,
const QString &directory,
const QByteArray &url);
- // Used only by Trac plugin.
- bool findVersionControl(const QString &versionControl);
- // Used only by Trac plugin.
- static QString repositoryUrl(const QString &directory);
// Shows a confirmation dialog, whether the file should also be deleted
// from revision control. Calls vcsDelete on the file. Returns false
diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp
index b5d544e9a7..2916193889 100644
--- a/src/plugins/cpaster/cpasterplugin.cpp
+++ b/src/plugins/cpaster/cpasterplugin.cpp
@@ -211,7 +211,7 @@ void CodepasterPlugin::postEditor()
if (ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor)) {
data = textEditor->selectedText();
if (data.isEmpty())
- data = textEditor->textDocument()->contents();
+ data = textEditor->textDocument()->plainText();
mimeType = textEditor->document()->mimeType();
}
}
diff --git a/src/plugins/cpaster/fileshareprotocolsettingspage.cpp b/src/plugins/cpaster/fileshareprotocolsettingspage.cpp
index 66c94ace1f..168afef539 100644
--- a/src/plugins/cpaster/fileshareprotocolsettingspage.cpp
+++ b/src/plugins/cpaster/fileshareprotocolsettingspage.cpp
@@ -104,10 +104,12 @@ FileShareProtocolSettingsPage::FileShareProtocolSettingsPage(const QSharedPointe
setDisplayCategory(QCoreApplication::translate("CodePaster", Constants::CPASTER_SETTINGS_TR_CATEGORY));
}
-QWidget *FileShareProtocolSettingsPage::createPage(QWidget *parent)
+QWidget *FileShareProtocolSettingsPage::widget()
{
- m_widget = new FileShareProtocolSettingsWidget(parent);
- m_widget->setSettings(*m_settings);
+ if (!m_widget) {
+ m_widget = new FileShareProtocolSettingsWidget;
+ m_widget->setSettings(*m_settings);
+ }
return m_widget;
}
diff --git a/src/plugins/cpaster/fileshareprotocolsettingspage.h b/src/plugins/cpaster/fileshareprotocolsettingspage.h
index 33c66736f8..feb6befea7 100644
--- a/src/plugins/cpaster/fileshareprotocolsettingspage.h
+++ b/src/plugins/cpaster/fileshareprotocolsettingspage.h
@@ -78,7 +78,7 @@ public:
explicit FileShareProtocolSettingsPage(const QSharedPointer<FileShareProtocolSettings> &s,
QObject *parent = 0);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish() { }
diff --git a/src/plugins/cpaster/settingspage.cpp b/src/plugins/cpaster/settingspage.cpp
index c9ae150add..f1df7d4bf9 100644
--- a/src/plugins/cpaster/settingspage.cpp
+++ b/src/plugins/cpaster/settingspage.cpp
@@ -90,13 +90,12 @@ SettingsPage::~SettingsPage()
{
}
-QWidget *SettingsPage::createPage(QWidget *parent)
+QWidget *SettingsPage::widget()
{
- m_widget = new SettingsWidget(m_protocols, parent);
- m_widget->setSettings(*m_settings);
-
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new SettingsWidget(m_protocols);
+ m_widget->setSettings(*m_settings);
+ }
return m_widget;
}
@@ -111,11 +110,6 @@ void SettingsPage::apply()
}
}
-bool SettingsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
void SettingsPage::addProtocol(const QString &name)
{
m_protocols.append(name);
diff --git a/src/plugins/cpaster/settingspage.h b/src/plugins/cpaster/settingspage.h
index ecb66f335c..98f19a19db 100644
--- a/src/plugins/cpaster/settingspage.h
+++ b/src/plugins/cpaster/settingspage.h
@@ -66,10 +66,9 @@ public:
explicit SettingsPage(const QSharedPointer<Settings> &settings);
~SettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish() { }
- bool matches(const QString &) const;
void addProtocol(const QString& name);
@@ -78,7 +77,6 @@ private:
QPointer<SettingsWidget> m_widget;
QStringList m_protocols;
- QString m_searchKeywords;
};
} // namespace CodePaster
diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp
new file mode 100644
index 0000000000..201fb9ebbb
--- /dev/null
+++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp
@@ -0,0 +1,2302 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "cppcodemodelinspectordialog.h"
+#include "cppeditor.h"
+#include "ui_cppcodemodelinspectordialog.h"
+
+#include <app/app_version.h>
+#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/icore.h>
+#include <cpptools/cppmodelmanagerinterface.h>
+#include <cpptools/cppprojectfile.h>
+#include <cpptools/cpptoolseditorsupport.h>
+#include <projectexplorer/project.h>
+
+#include <cplusplus/CppDocument.h>
+#include <cplusplus/Overview.h>
+#include <cplusplus/Token.h>
+#include <utils/qtcassert.h>
+
+#include <QAbstractTableModel>
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QSortFilterProxyModel>
+
+using namespace CppTools;
+
+namespace {
+
+// --- Utils --------------------------------------------------------------------------------------
+
+QString toString(bool value)
+{
+ return value ? QLatin1String("Yes") : QLatin1String("No");
+}
+
+QString toString(unsigned value)
+{
+ return QString::number(value);
+}
+
+QString toString(const QDateTime &dateTime)
+{
+ return dateTime.toString(QLatin1String("hh:mm:ss dd.MM.yy"));
+}
+
+QString toString(CPlusPlus::Document::CheckMode checkMode)
+{
+#define CASE_CHECKMODE(x) case CPlusPlus::Document::x: return QLatin1String(#x)
+ switch (checkMode) {
+ CASE_CHECKMODE(Unchecked);
+ CASE_CHECKMODE(FullCheck);
+ CASE_CHECKMODE(FastCheck);
+ // no default to get a compiler warning if anything is added
+ }
+#undef CASE_CHECKMODE
+ return QString();
+}
+
+QString toString(CPlusPlus::Document::DiagnosticMessage::Level level)
+{
+#define CASE_LEVEL(x) case CPlusPlus::Document::DiagnosticMessage::x: return QLatin1String(#x)
+ switch (level) {
+ CASE_LEVEL(Warning);
+ CASE_LEVEL(Error);
+ CASE_LEVEL(Fatal);
+ // no default to get a compiler warning if anything is added
+ }
+#undef CASE_LEVEL
+ return QString();
+}
+
+QString toString(ProjectPart::CVersion cVersion)
+{
+#define CASE_CVERSION(x) case ProjectPart::x: return QLatin1String(#x)
+ switch (cVersion) {
+ CASE_CVERSION(C89);
+ CASE_CVERSION(C99);
+ CASE_CVERSION(C11);
+ // no default to get a compiler warning if anything is added
+ }
+#undef CASE_CVERSION
+ return QString();
+}
+
+QString toString(ProjectPart::CXXVersion cxxVersion)
+{
+#define CASE_CXXVERSION(x) case ProjectPart::x: return QLatin1String(#x)
+ switch (cxxVersion) {
+ CASE_CXXVERSION(CXX98);
+ CASE_CXXVERSION(CXX11);
+ // no default to get a compiler warning if anything is added
+ }
+#undef CASE_CXXVERSION
+ return QString();
+}
+
+QString toString(ProjectPart::CXXExtensions cxxExtension)
+{
+ QString result;
+
+#define CASE_CXXEXTENSION(ext) if (cxxExtension & ProjectPart::ext) \
+ result += QLatin1String(#ext ", ");
+
+ CASE_CXXEXTENSION(NoExtensions);
+ CASE_CXXEXTENSION(GnuExtensions);
+ CASE_CXXEXTENSION(MicrosoftExtensions);
+ CASE_CXXEXTENSION(BorlandExtensions);
+ CASE_CXXEXTENSION(OpenMPExtensions);
+#undef CASE_CXXEXTENSION
+ if (result.endsWith(QLatin1String(", ")))
+ result.chop(2);
+ return result;
+}
+
+QString toString(ProjectPart::QtVersion qtVersion)
+{
+#define CASE_QTVERSION(x) case ProjectPart::x: return QLatin1String(#x)
+ switch (qtVersion) {
+ CASE_QTVERSION(UnknownQt);
+ CASE_QTVERSION(NoQt);
+ CASE_QTVERSION(Qt4);
+ CASE_QTVERSION(Qt5);
+ // no default to get a compiler warning if anything is added
+ }
+#undef CASE_QTVERSION
+ return QString();
+}
+
+QString toString(const QList<ProjectFile> &projectFiles)
+{
+ QStringList filesList;
+ foreach (const ProjectFile &projectFile, projectFiles)
+ filesList << QDir::toNativeSeparators(projectFile.path);
+ qSort(filesList);
+ return filesList.join(QLatin1String("\n"));
+}
+
+QString toString(ProjectFile::Kind kind)
+{
+#define CASE_PROFECTFILEKIND(x) case ProjectFile::x: return QLatin1String(#x)
+ switch (kind) {
+ CASE_PROFECTFILEKIND(Unclassified);
+ CASE_PROFECTFILEKIND(CHeader);
+ CASE_PROFECTFILEKIND(CSource);
+ CASE_PROFECTFILEKIND(CXXHeader);
+ CASE_PROFECTFILEKIND(CXXSource);
+ CASE_PROFECTFILEKIND(ObjCHeader);
+ CASE_PROFECTFILEKIND(ObjCSource);
+ CASE_PROFECTFILEKIND(ObjCXXHeader);
+ CASE_PROFECTFILEKIND(ObjCXXSource);
+ CASE_PROFECTFILEKIND(CudaSource);
+ CASE_PROFECTFILEKIND(OpenCLSource);
+ // no default to get a compiler warning if anything is added
+ }
+#undef CASE_PROFECTFILEKIND
+ return QString();
+}
+
+QString toString(CPlusPlus::Kind kind)
+{
+ using namespace CPlusPlus;
+#define TOKEN(x) case x: return QLatin1String(#x)
+#define TOKEN_AND_ALIASES(x,y) case x: return QLatin1String(#x "/" #y)
+ switch (kind) {
+ TOKEN(T_EOF_SYMBOL);
+ TOKEN(T_ERROR);
+ TOKEN(T_CPP_COMMENT);
+ TOKEN(T_CPP_DOXY_COMMENT);
+ TOKEN(T_COMMENT);
+ TOKEN(T_DOXY_COMMENT);
+ TOKEN(T_IDENTIFIER);
+ TOKEN(T_NUMERIC_LITERAL);
+ TOKEN(T_CHAR_LITERAL);
+ TOKEN(T_WIDE_CHAR_LITERAL);
+ TOKEN(T_UTF16_CHAR_LITERAL);
+ TOKEN(T_UTF32_CHAR_LITERAL);
+ TOKEN(T_STRING_LITERAL);
+ TOKEN(T_WIDE_STRING_LITERAL);
+ TOKEN(T_UTF8_STRING_LITERAL);
+ TOKEN(T_UTF16_STRING_LITERAL);
+ TOKEN(T_UTF32_STRING_LITERAL);
+ TOKEN(T_RAW_STRING_LITERAL);
+ TOKEN(T_RAW_WIDE_STRING_LITERAL);
+ TOKEN(T_RAW_UTF8_STRING_LITERAL);
+ TOKEN(T_RAW_UTF16_STRING_LITERAL);
+ TOKEN(T_RAW_UTF32_STRING_LITERAL);
+ TOKEN(T_AT_STRING_LITERAL);
+ TOKEN(T_ANGLE_STRING_LITERAL);
+ TOKEN_AND_ALIASES(T_AMPER, T_BITAND);
+ TOKEN_AND_ALIASES(T_AMPER_AMPER, T_AND);
+ TOKEN_AND_ALIASES(T_AMPER_EQUAL, T_AND_EQ);
+ TOKEN(T_ARROW);
+ TOKEN(T_ARROW_STAR);
+ TOKEN_AND_ALIASES(T_CARET, T_XOR);
+ TOKEN_AND_ALIASES(T_CARET_EQUAL, T_XOR_EQ);
+ TOKEN(T_COLON);
+ TOKEN(T_COLON_COLON);
+ TOKEN(T_COMMA);
+ TOKEN(T_SLASH);
+ TOKEN(T_SLASH_EQUAL);
+ TOKEN(T_DOT);
+ TOKEN(T_DOT_DOT_DOT);
+ TOKEN(T_DOT_STAR);
+ TOKEN(T_EQUAL);
+ TOKEN(T_EQUAL_EQUAL);
+ TOKEN_AND_ALIASES(T_EXCLAIM, T_NOT);
+ TOKEN_AND_ALIASES(T_EXCLAIM_EQUAL, T_NOT_EQ);
+ TOKEN(T_GREATER);
+ TOKEN(T_GREATER_EQUAL);
+ TOKEN(T_GREATER_GREATER);
+ TOKEN(T_GREATER_GREATER_EQUAL);
+ TOKEN(T_LBRACE);
+ TOKEN(T_LBRACKET);
+ TOKEN(T_LESS);
+ TOKEN(T_LESS_EQUAL);
+ TOKEN(T_LESS_LESS);
+ TOKEN(T_LESS_LESS_EQUAL);
+ TOKEN(T_LPAREN);
+ TOKEN(T_MINUS);
+ TOKEN(T_MINUS_EQUAL);
+ TOKEN(T_MINUS_MINUS);
+ TOKEN(T_PERCENT);
+ TOKEN(T_PERCENT_EQUAL);
+ TOKEN_AND_ALIASES(T_PIPE, T_BITOR);
+ TOKEN_AND_ALIASES(T_PIPE_EQUAL, T_OR_EQ);
+ TOKEN_AND_ALIASES(T_PIPE_PIPE, T_OR);
+ TOKEN(T_PLUS);
+ TOKEN(T_PLUS_EQUAL);
+ TOKEN(T_PLUS_PLUS);
+ TOKEN(T_POUND);
+ TOKEN(T_POUND_POUND);
+ TOKEN(T_QUESTION);
+ TOKEN(T_RBRACE);
+ TOKEN(T_RBRACKET);
+ TOKEN(T_RPAREN);
+ TOKEN(T_SEMICOLON);
+ TOKEN(T_STAR);
+ TOKEN(T_STAR_EQUAL);
+ TOKEN_AND_ALIASES(T_TILDE, T_COMPL);
+ TOKEN(T_TILDE_EQUAL);
+ TOKEN(T_ALIGNAS);
+ TOKEN(T_ALIGNOF);
+ TOKEN_AND_ALIASES(T_ASM, T___ASM/T___ASM__);
+ TOKEN(T_AUTO);
+ TOKEN(T_BOOL);
+ TOKEN(T_BREAK);
+ TOKEN(T_CASE);
+ TOKEN(T_CATCH);
+ TOKEN(T_CHAR);
+ TOKEN(T_CHAR16_T);
+ TOKEN(T_CHAR32_T);
+ TOKEN(T_CLASS);
+ TOKEN_AND_ALIASES(T_CONST, T___CONST/T___CONST__);
+ TOKEN(T_CONST_CAST);
+ TOKEN(T_CONSTEXPR);
+ TOKEN(T_CONTINUE);
+ TOKEN_AND_ALIASES(T_DECLTYPE, T___DECLTYPE);
+ TOKEN(T_DEFAULT);
+ TOKEN(T_DELETE);
+ TOKEN(T_DO);
+ TOKEN(T_DOUBLE);
+ TOKEN(T_DYNAMIC_CAST);
+ TOKEN(T_ELSE);
+ TOKEN(T_ENUM);
+ TOKEN(T_EXPLICIT);
+ TOKEN(T_EXPORT);
+ TOKEN(T_EXTERN);
+ TOKEN(T_FALSE);
+ TOKEN(T_FLOAT);
+ TOKEN(T_FOR);
+ TOKEN(T_FRIEND);
+ TOKEN(T_GOTO);
+ TOKEN(T_IF);
+ TOKEN_AND_ALIASES(T_INLINE, T___INLINE/T___INLINE__);
+ TOKEN(T_INT);
+ TOKEN(T_LONG);
+ TOKEN(T_MUTABLE);
+ TOKEN(T_NAMESPACE);
+ TOKEN(T_NEW);
+ TOKEN(T_NOEXCEPT);
+ TOKEN(T_NULLPTR);
+ TOKEN(T_OPERATOR);
+ TOKEN(T_PRIVATE);
+ TOKEN(T_PROTECTED);
+ TOKEN(T_PUBLIC);
+ TOKEN(T_REGISTER);
+ TOKEN(T_REINTERPRET_CAST);
+ TOKEN(T_RETURN);
+ TOKEN(T_SHORT);
+ TOKEN(T_SIGNED);
+ TOKEN(T_SIZEOF);
+ TOKEN(T_STATIC);
+ TOKEN(T_STATIC_ASSERT);
+ TOKEN(T_STATIC_CAST);
+ TOKEN(T_STRUCT);
+ TOKEN(T_SWITCH);
+ TOKEN(T_TEMPLATE);
+ TOKEN(T_THIS);
+ TOKEN(T_THREAD_LOCAL);
+ TOKEN(T_THROW);
+ TOKEN(T_TRUE);
+ TOKEN(T_TRY);
+ TOKEN(T_TYPEDEF);
+ TOKEN(T_TYPEID);
+ TOKEN(T_TYPENAME);
+ TOKEN(T_UNION);
+ TOKEN(T_UNSIGNED);
+ TOKEN(T_USING);
+ TOKEN(T_VIRTUAL);
+ TOKEN(T_VOID);
+ TOKEN_AND_ALIASES(T_VOLATILE, T___VOLATILE/T___VOLATILE__);
+ TOKEN(T_WCHAR_T);
+ TOKEN(T_WHILE);
+ TOKEN_AND_ALIASES(T___ATTRIBUTE__, T___ATTRIBUTE);
+ TOKEN(T___THREAD);
+ TOKEN_AND_ALIASES(T___TYPEOF__, T_TYPEOF/T___TYPEOF);
+ TOKEN(T_AT_CATCH);
+ TOKEN(T_AT_CLASS);
+ TOKEN(T_AT_COMPATIBILITY_ALIAS);
+ TOKEN(T_AT_DEFS);
+ TOKEN(T_AT_DYNAMIC);
+ TOKEN(T_AT_ENCODE);
+ TOKEN(T_AT_END);
+ TOKEN(T_AT_FINALLY);
+ TOKEN(T_AT_IMPLEMENTATION);
+ TOKEN(T_AT_INTERFACE);
+ TOKEN(T_AT_NOT_KEYWORD);
+ TOKEN(T_AT_OPTIONAL);
+ TOKEN(T_AT_PACKAGE);
+ TOKEN(T_AT_PRIVATE);
+ TOKEN(T_AT_PROPERTY);
+ TOKEN(T_AT_PROTECTED);
+ TOKEN(T_AT_PROTOCOL);
+ TOKEN(T_AT_PUBLIC);
+ TOKEN(T_AT_REQUIRED);
+ TOKEN(T_AT_SELECTOR);
+ TOKEN(T_AT_SYNCHRONIZED);
+ TOKEN(T_AT_SYNTHESIZE);
+ TOKEN(T_AT_THROW);
+ TOKEN(T_AT_TRY);
+ TOKEN(T_EMIT);
+ TOKEN(T_SIGNAL);
+ TOKEN(T_SLOT);
+ TOKEN(T_Q_SIGNAL);
+ TOKEN(T_Q_SLOT);
+ TOKEN(T_Q_SIGNALS);
+ TOKEN(T_Q_SLOTS);
+ TOKEN(T_Q_FOREACH);
+ TOKEN(T_Q_D);
+ TOKEN(T_Q_Q);
+ TOKEN(T_Q_INVOKABLE);
+ TOKEN(T_Q_PROPERTY);
+ TOKEN(T_Q_PRIVATE_PROPERTY);
+ TOKEN(T_Q_INTERFACES);
+ TOKEN(T_Q_EMIT);
+ TOKEN(T_Q_ENUMS);
+ TOKEN(T_Q_FLAGS);
+ TOKEN(T_Q_PRIVATE_SLOT);
+ TOKEN(T_Q_DECLARE_INTERFACE);
+ TOKEN(T_Q_OBJECT);
+ TOKEN(T_Q_GADGET);
+ // no default to get a compiler warning if anything is added
+ }
+#undef TOKEN
+#undef TOKEN_AND_ALIASES
+ return QString();
+}
+
+QString partsForFile(const QString &fileName)
+{
+ const QList<ProjectPart::Ptr> parts
+ = CppModelManagerInterface::instance()->projectPart(fileName);
+ QString result;
+ foreach (const ProjectPart::Ptr &part, parts)
+ result += part->displayName + QLatin1Char(',');
+ if (result.endsWith(QLatin1Char(',')))
+ result.chop(1);
+ return result;
+}
+
+QString unresolvedFileNameWithDelimiters(const CPlusPlus::Document::Include &include)
+{
+ const QString unresolvedFileName = include.unresolvedFileName();
+ if (include.type() == CPlusPlus::Client::IncludeLocal)
+ return QLatin1Char('"') + unresolvedFileName + QLatin1Char('"');
+ return QLatin1Char('<') + unresolvedFileName + QLatin1Char('>');
+}
+
+QString pathListToString(const QStringList &pathList)
+{
+ QStringList result;
+ foreach (const QString &path, pathList)
+ result << QDir::toNativeSeparators(path);
+ return result.join(QLatin1String("\n"));
+}
+
+QList<CPlusPlus::Document::Ptr> snapshotToList(const CPlusPlus::Snapshot &snapshot)
+{
+ QList<CPlusPlus::Document::Ptr> documents;
+ CPlusPlus::Snapshot::const_iterator it = snapshot.begin(), end = snapshot.end();
+ for (; it != end; ++it)
+ documents.append(it.value());
+ return documents;
+}
+
+template <class T> void resizeColumns(QTreeView *view)
+{
+ for (int column = 0; column < T::ColumnCount - 1; ++column)
+ view->resizeColumnToContents(column);
+}
+
+TextEditor::BaseTextEditor *currentEditor()
+{
+ return qobject_cast<TextEditor::BaseTextEditor*>(Core::EditorManager::currentEditor());
+}
+
+QString fileInCurrentEditor()
+{
+ if (TextEditor::BaseTextEditor *editor = currentEditor())
+ return editor->document()->filePath();
+ return QString();
+}
+
+class DepthFinder : public CPlusPlus::SymbolVisitor {
+public:
+ DepthFinder() : m_symbol(0), m_depth(-1), m_foundDepth(-1), m_stop(false) {}
+
+ int operator()(const CPlusPlus::Document::Ptr &document, CPlusPlus::Symbol *symbol)
+ {
+ m_symbol = symbol;
+ accept(document->globalNamespace());
+ return m_foundDepth;
+ }
+
+ bool preVisit(CPlusPlus::Symbol *symbol)
+ {
+ if (m_stop)
+ return false;
+
+ if (symbol->asScope()) {
+ ++m_depth;
+ if (symbol == m_symbol) {
+ m_foundDepth = m_depth;
+ m_stop = true;
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ void postVisit(CPlusPlus::Symbol *symbol)
+ {
+ if (symbol->asScope())
+ --m_depth;
+ }
+
+private:
+ CPlusPlus::Symbol *m_symbol;
+ int m_depth;
+ int m_foundDepth;
+ bool m_stop;
+};
+
+class CppCodeModelInspectorDumper
+{
+public:
+ explicit CppCodeModelInspectorDumper(const CPlusPlus::Snapshot &globalSnapshot);
+ ~CppCodeModelInspectorDumper();
+
+ void dumpProjectInfos(const QList<CppModelManagerInterface::ProjectInfo> &projectInfos);
+ void dumpSnapshot(const CPlusPlus::Snapshot &snapshot, const QString &title,
+ bool isGlobalSnapshot = false);
+ void dumpWorkingCopy(const CppModelManagerInterface::WorkingCopy &workingCopy);
+
+private:
+ void dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents,
+ bool skipDetails = false);
+ static QByteArray indent(int level);
+
+ CPlusPlus::Snapshot m_globalSnapshot;
+ QFile m_logFile;
+ QTextStream m_out;
+};
+
+CppCodeModelInspectorDumper::CppCodeModelInspectorDumper(const CPlusPlus::Snapshot &globalSnapshot)
+ : m_globalSnapshot(globalSnapshot), m_out(stderr)
+{
+ const QString logFileName = QDir::tempPath()
+ + QString::fromLatin1("/qtc-codemodelinspection.txt");
+ m_logFile.setFileName(logFileName);
+ if (m_logFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ m_out << "Code model inspection log file is \"" << QDir::toNativeSeparators(logFileName)
+ << "\".\n";
+ m_out.setDevice(&m_logFile);
+ }
+ m_out << "*** START Code Model Inspection Report for ";
+ QString ideRevision;
+#ifdef IDE_REVISION
+ ideRevision = QLatin1String(" from revision ")
+ + QString::fromLatin1(Core::Constants::IDE_REVISION_STR).left(10);
+#endif
+ m_out << Core::ICore::versionString() << ideRevision << "\n";
+ m_out << "Note: This file contains vim fold markers (\"{{{n\"). "
+ "Make use of them via \":set foldmethod=marker\".\n";
+}
+
+CppCodeModelInspectorDumper::~CppCodeModelInspectorDumper()
+{
+ m_out << "*** END Code Model Inspection Report\n";
+}
+
+void CppCodeModelInspectorDumper::dumpProjectInfos(
+ const QList<CppModelManagerInterface::ProjectInfo> &projectInfos)
+{
+ const QByteArray i1 = indent(1);
+ const QByteArray i2 = indent(2);
+ const QByteArray i3 = indent(3);
+ const QByteArray i4 = indent(4);
+
+ m_out << "Projects loaded: " << projectInfos.size() << "{{{1\n";
+ foreach (const CppModelManagerInterface::ProjectInfo &info, projectInfos) {
+ const QPointer<ProjectExplorer::Project> project = info.project();
+ m_out << i1 << "Project " << project->displayName() << " (" << project->projectFilePath()
+ << "){{{2\n";
+
+ const QList<ProjectPart::Ptr> projectParts = info.projectParts();
+ foreach (const ProjectPart::Ptr &part, projectParts) {
+ QString projectName = QLatin1String("<None>");
+ QString projectFilePath = QLatin1String("<None>");
+ if (ProjectExplorer::Project *project = part->project) {
+ projectName = project->displayName();
+ projectFilePath = project->projectFilePath();
+ }
+ m_out << i2 << "Project Part \"" << part->projectFile << "\"{{{3\n";
+ m_out << i3 << "Project Part Name: " << part->displayName << "\n";
+ m_out << i3 << "Project Name : " << projectName << "\n";
+ m_out << i3 << "Project File : " << projectFilePath << "\n";
+ m_out << i3 << "C Version : " << toString(part->cVersion) << "\n";
+ m_out << i3 << "CXX Version : " << toString(part->cxxVersion) << "\n";
+ m_out << i3 << "CXX Extensions : " << toString(part->cxxExtensions) << "\n";
+ m_out << i3 << "Qt Version : " << toString(part->qtVersion) << "\n";
+
+ if (!part->files.isEmpty()) {
+ m_out << i3 << "Files:{{{4\n";
+ foreach (const ProjectFile &projectFile, part->files) {
+ m_out << i4 << toString(projectFile.kind) << ": " << projectFile.path
+ << "\n";
+ }
+ }
+
+ if (!part->toolchainDefines.isEmpty()) {
+ m_out << i3 << "Toolchain Defines:{{{4\n";
+ const QList<QByteArray> defineLines = part->toolchainDefines.split('\n');
+ foreach (const QByteArray &defineLine, defineLines)
+ m_out << i4 << defineLine << "\n";
+ }
+ if (!part->projectDefines.isEmpty()) {
+ m_out << i3 << "Project Defines:{{{4\n";
+ const QList<QByteArray> defineLines = part->projectDefines.split('\n');
+ foreach (const QByteArray &defineLine, defineLines)
+ m_out << i4 << defineLine << "\n";
+ }
+
+ if (!part->includePaths.isEmpty()) {
+ m_out << i3 << "Include Paths:{{{4\n";
+ foreach (const QString &includePath, part->includePaths)
+ m_out << i4 << includePath << "\n";
+ }
+
+ if (!part->frameworkPaths.isEmpty()) {
+ m_out << i3 << "Framework Paths:{{{4\n";
+ foreach (const QString &frameworkPath, part->frameworkPaths)
+ m_out << i4 << frameworkPath << "\n";
+ }
+
+ if (!part->precompiledHeaders.isEmpty()) {
+ m_out << i3 << "Precompiled Headers:{{{4\n";
+ foreach (const QString &precompiledHeader, part->precompiledHeaders)
+ m_out << i4 << precompiledHeader << "\n";
+ }
+ } // for part
+ } // for project Info
+}
+
+void CppCodeModelInspectorDumper::dumpSnapshot(const CPlusPlus::Snapshot &snapshot,
+ const QString &title, bool isGlobalSnapshot)
+{
+ m_out << "Snapshot \"" << title << "\"{{{1\n";
+
+ const QByteArray i1 = indent(1);
+ const QList<CPlusPlus::Document::Ptr> documents = snapshotToList(snapshot);
+
+ if (isGlobalSnapshot) {
+ if (!documents.isEmpty()) {
+ m_out << i1 << "Globally-Shared documents{{{2\n";
+ dumpDocuments(documents, false);
+ }
+ } else {
+ // Divide into shared and not shared
+ QList<CPlusPlus::Document::Ptr> globallyShared;
+ QList<CPlusPlus::Document::Ptr> notGloballyShared;
+ foreach (const CPlusPlus::Document::Ptr &document, documents) {
+ CPlusPlus::Document::Ptr globalDocument = m_globalSnapshot.document(document->fileName());
+ if (globalDocument && globalDocument->fingerprint() == document->fingerprint())
+ globallyShared.append(document);
+ else
+ notGloballyShared.append(document);
+ }
+
+ if (!notGloballyShared.isEmpty()) {
+ m_out << i1 << "Not-Globally-Shared documents:{{{2\n";
+ dumpDocuments(notGloballyShared);
+ }
+ if (!globallyShared.isEmpty()) {
+ m_out << i1 << "Globally-Shared documents{{{2\n";
+ dumpDocuments(globallyShared, true);
+ }
+ }
+}
+
+void CppCodeModelInspectorDumper::dumpWorkingCopy(
+ const CppModelManagerInterface::WorkingCopy &workingCopy)
+{
+ m_out << "Working Copy contains " << workingCopy.size() << " entries{{{1\n";
+
+ const QByteArray i1 = indent(1);
+ QHashIterator<QString, QPair<QByteArray, unsigned> > it = workingCopy.iterator();
+ while (it.hasNext()) {
+ it.next();
+ const QString filePath = it.key();
+ unsigned sourcRevision = it.value().second;
+ m_out << i1 << "rev=" << sourcRevision << ", " << filePath << "\n";
+ }
+}
+
+void CppCodeModelInspectorDumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents,
+ bool skipDetails)
+{
+ const QByteArray i2 = indent(2);
+ const QByteArray i3 = indent(3);
+ const QByteArray i4 = indent(4);
+ foreach (const CPlusPlus::Document::Ptr &document, documents) {
+ if (skipDetails) {
+ m_out << i2 << "\"" << document->fileName() << "\"\n";
+ continue;
+ }
+
+ m_out << i2 << "Document \"" << document->fileName() << "\"{{{3\n";
+ m_out << i3 << "Last Modified : " << toString(document->lastModified()) << "\n";
+ m_out << i3 << "Revision : " << toString(document->revision()) << "\n";
+ m_out << i3 << "Editor Revision: " << toString(document->editorRevision()) << "\n";
+ m_out << i3 << "Check Mode : " << toString(document->checkMode()) << "\n";
+ m_out << i3 << "Tokenized : " << toString(document->isTokenized()) << "\n";
+ m_out << i3 << "Parsed : " << toString(document->isParsed()) << "\n";
+ m_out << i3 << "Project Parts : " << partsForFile(document->fileName()) << "\n";
+
+ const QList<CPlusPlus::Document::Include> includes = document->unresolvedIncludes()
+ + document->resolvedIncludes();
+ if (!includes.isEmpty()) {
+ m_out << i3 << "Includes:{{{4\n";
+ foreach (const CPlusPlus::Document::Include &include, includes) {
+ m_out << i4 << "at line " << include.line() << ": "
+ << unresolvedFileNameWithDelimiters(include) << " ==> "
+ << include.resolvedFileName() << "\n";
+ }
+ }
+
+ const QList<CPlusPlus::Document::DiagnosticMessage> diagnosticMessages
+ = document->diagnosticMessages();
+ if (!diagnosticMessages.isEmpty()) {
+ m_out << i3 << "Diagnostic Messages:{{{4\n";
+ foreach (const CPlusPlus::Document::DiagnosticMessage &msg, diagnosticMessages) {
+ const CPlusPlus::Document::DiagnosticMessage::Level level
+ = static_cast<CPlusPlus::Document::DiagnosticMessage::Level>(msg.level());
+ m_out << i4 << "at " << msg.line() << ":" << msg.column() << ", " << toString(level)
+ << ": " << msg.text() << "\n";
+ }
+ }
+
+ const QList<CPlusPlus::Macro> macroDefinitions = document->definedMacros();
+ if (!macroDefinitions.isEmpty()) {
+ m_out << i3 << "(Un)Defined Macros:{{{4\n";
+ foreach (const CPlusPlus::Macro &macro, macroDefinitions)
+ m_out << i4 << "at line " << macro.line() << ": " << macro.toString() << "\n";
+ }
+
+ const QList<CPlusPlus::Document::MacroUse> macroUses = document->macroUses();
+ if (!macroUses.isEmpty()) {
+ m_out << i3 << "Macro Uses:{{{4\n";
+ foreach (const CPlusPlus::Document::MacroUse &use, macroUses) {
+ const QString type = use.isFunctionLike()
+ ? QLatin1String("function-like") : QLatin1String("object-like");
+ m_out << i4 << "at line " << use.beginLine() << ", "
+ << QString::fromUtf8(use.macro().name()) << ", begin=" << use.begin()
+ << ", end=" << use.end() << ", " << type << ", args="
+ << use.arguments().size() << "\n";
+ }
+ }
+
+ const QString source = QString::fromUtf8(document->utf8Source());
+ if (!source.isEmpty()) {
+ m_out << i4 << "Source:{{{4\n";
+ m_out << source;
+ m_out << "\n<<<EOF\n";
+ }
+ }
+}
+
+QByteArray CppCodeModelInspectorDumper::indent(int level)
+{
+ const QByteArray basicIndent(" ");
+ QByteArray indent = basicIndent;
+ while (level-- > 1)
+ indent += basicIndent;
+ return indent;
+}
+
+} // anonymous namespace
+
+namespace CppEditor {
+namespace Internal {
+
+// --- FilterableView -----------------------------------------------------------------------------
+
+class FilterableView : public QWidget
+{
+ Q_OBJECT
+public:
+ FilterableView(QWidget *parent);
+
+ void setModel(QAbstractItemModel *model);
+ QItemSelectionModel *selectionModel() const;
+ void selectIndex(const QModelIndex &index);
+ void resizeColumns(int columnCount);
+
+signals:
+ void filterChanged(const QString &filterText);
+
+public slots:
+ void clearFilter();
+
+private:
+ QTreeView *view;
+ QLineEdit *lineEdit;
+};
+
+FilterableView::FilterableView(QWidget *parent)
+ : QWidget(parent)
+{
+ view = new QTreeView(this);
+ view->setAlternatingRowColors(true);
+ view->setTextElideMode(Qt::ElideMiddle);
+ view->setSortingEnabled(true);
+
+ lineEdit = new QLineEdit(this);
+ lineEdit->setPlaceholderText(QLatin1String("File Path"));
+ QObject::connect(lineEdit, SIGNAL(textChanged(QString)), SIGNAL(filterChanged(QString)));
+
+ QLabel *label = new QLabel(QLatin1String("&Filter:"), this);
+ label->setBuddy(lineEdit);
+
+ QPushButton *clearButton = new QPushButton(QLatin1String("&Clear"), this);
+ QObject::connect(clearButton, SIGNAL(clicked()), SLOT(clearFilter()));
+
+ QHBoxLayout *filterBarLayout = new QHBoxLayout();
+ filterBarLayout->addWidget(label);
+ filterBarLayout->addWidget(lineEdit);
+ filterBarLayout->addWidget(clearButton);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout();
+ mainLayout->addWidget(view);
+ mainLayout->addLayout(filterBarLayout);
+
+ setLayout(mainLayout);
+}
+
+void FilterableView::setModel(QAbstractItemModel *model)
+{
+ view->setModel(model);
+}
+
+QItemSelectionModel *FilterableView::selectionModel() const
+{
+ return view->selectionModel();
+}
+
+void FilterableView::selectIndex(const QModelIndex &index)
+{
+ if (index.isValid()) {
+ view->selectionModel()->setCurrentIndex(index,
+ QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+ }
+}
+
+void FilterableView::resizeColumns(int columnCount)
+{
+ for (int column = 0; column < columnCount - 1; ++column)
+ view->resizeColumnToContents(column);
+}
+
+void FilterableView::clearFilter()
+{
+ lineEdit->clear();
+}
+
+// --- KeyValueModel ------------------------------------------------------------------------------
+
+class KeyValueModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ typedef QList<QPair<QString, QString> > Table;
+
+ KeyValueModel(QObject *parent);
+ void configure(const Table &table);
+ void clear();
+
+ enum Columns { KeyColumn, ValueColumn, ColumnCount };
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+private:
+ Table m_table;
+};
+
+KeyValueModel::KeyValueModel(QObject *parent) : QAbstractListModel(parent)
+{
+}
+
+void KeyValueModel::configure(const Table &table)
+{
+ emit layoutAboutToBeChanged();
+ m_table = table;
+ emit layoutChanged();
+}
+
+void KeyValueModel::clear()
+{
+ emit layoutAboutToBeChanged();
+ m_table.clear();
+ emit layoutChanged();
+}
+
+int KeyValueModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return m_table.size();
+}
+
+int KeyValueModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return KeyValueModel::ColumnCount;
+}
+
+QVariant KeyValueModel::data(const QModelIndex &index, int role) const
+{
+ if (role == Qt::DisplayRole) {
+ const int row = index.row();
+ const int column = index.column();
+ if (column == KeyColumn) {
+ return m_table.at(row).first;
+ } else if (column == ValueColumn) {
+ return m_table.at(row).second;
+ }
+ }
+ return QVariant();
+}
+
+QVariant KeyValueModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) {
+ case KeyColumn:
+ return QLatin1String("Key");
+ case ValueColumn:
+ return QLatin1String("Value");
+ default:
+ return QVariant();
+ }
+ }
+ return QVariant();
+}
+
+// --- SnapshotModel ------------------------------------------------------------------------------
+
+class SnapshotModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ SnapshotModel(QObject *parent);
+ void configure(const CPlusPlus::Snapshot &snapshot);
+ void setGlobalSnapshot(const CPlusPlus::Snapshot &snapshot);
+
+ QModelIndex indexForDocument(const QString &filePath);
+
+ enum Columns { SymbolCountColumn, SharedColumn, FilePathColumn, ColumnCount };
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+private:
+ QList<CPlusPlus::Document::Ptr> m_documents;
+ CPlusPlus::Snapshot m_globalSnapshot;
+};
+
+SnapshotModel::SnapshotModel(QObject *parent) : QAbstractListModel(parent)
+{
+}
+
+void SnapshotModel::configure(const CPlusPlus::Snapshot &snapshot)
+{
+ emit layoutAboutToBeChanged();
+ m_documents = snapshotToList(snapshot);
+ emit layoutChanged();
+}
+
+void SnapshotModel::setGlobalSnapshot(const CPlusPlus::Snapshot &snapshot)
+{
+ m_globalSnapshot = snapshot;
+}
+
+QModelIndex SnapshotModel::indexForDocument(const QString &filePath)
+{
+ for (int i = 0, total = m_documents.size(); i < total; ++i) {
+ const CPlusPlus::Document::Ptr document = m_documents.at(i);
+ if (document->fileName() == filePath)
+ return index(i, FilePathColumn);
+ }
+ return QModelIndex();
+}
+
+int SnapshotModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return m_documents.size();
+}
+
+int SnapshotModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return SnapshotModel::ColumnCount;
+}
+
+QVariant SnapshotModel::data(const QModelIndex &index, int role) const
+{
+ if (role == Qt::DisplayRole) {
+ const int column = index.column();
+ CPlusPlus::Document::Ptr document = m_documents.at(index.row());
+ if (column == SymbolCountColumn) {
+ return document->control()->symbolCount();
+ } else if (column == SharedColumn) {
+ CPlusPlus::Document::Ptr globalDocument = m_globalSnapshot.document(document->fileName());
+ const bool isShared
+ = globalDocument && globalDocument->fingerprint() == document->fingerprint();
+ return toString(isShared);
+ } else if (column == FilePathColumn) {
+ return QDir::toNativeSeparators(document->fileName());
+ }
+ }
+ return QVariant();
+}
+
+QVariant SnapshotModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) {
+ case SymbolCountColumn:
+ return QLatin1String("Symbols");
+ case SharedColumn:
+ return QLatin1String("Shared");
+ case FilePathColumn:
+ return QLatin1String("File Path");
+ default:
+ return QVariant();
+ }
+ }
+ return QVariant();
+}
+
+// --- IncludesModel ------------------------------------------------------------------------------
+
+static bool includesSorter(const CPlusPlus::Document::Include &i1,
+ const CPlusPlus::Document::Include &i2)
+{
+ return i1.line() < i2.line();
+}
+
+class IncludesModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ IncludesModel(QObject *parent);
+ void configure(const QList<CPlusPlus::Document::Include> &includes);
+ void clear();
+
+ enum Columns { ResolvedOrNotColumn, LineNumberColumn, FilePathsColumn, ColumnCount };
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+private:
+ QList<CPlusPlus::Document::Include> m_includes;
+};
+
+IncludesModel::IncludesModel(QObject *parent) : QAbstractListModel(parent)
+{
+}
+
+void IncludesModel::configure(const QList<CPlusPlus::Document::Include> &includes)
+{
+ emit layoutAboutToBeChanged();
+ m_includes = includes;
+ qStableSort(m_includes.begin(), m_includes.end(), includesSorter);
+ emit layoutChanged();
+}
+
+void IncludesModel::clear()
+{
+ emit layoutAboutToBeChanged();
+ m_includes.clear();
+ emit layoutChanged();
+}
+
+int IncludesModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return m_includes.size();
+}
+
+int IncludesModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return IncludesModel::ColumnCount;
+}
+
+QVariant IncludesModel::data(const QModelIndex &index, int role) const
+{
+ if (role != Qt::DisplayRole && role != Qt::ForegroundRole)
+ return QVariant();
+
+ static const QBrush greenBrush(QColor(0, 139, 69));
+ static const QBrush redBrush(QColor(205, 38, 38));
+
+ const CPlusPlus::Document::Include include = m_includes.at(index.row());
+ const QString resolvedFileName = QDir::toNativeSeparators(include.resolvedFileName());
+ const bool isResolved = !resolvedFileName.isEmpty();
+
+ if (role == Qt::DisplayRole) {
+ const int column = index.column();
+ if (column == ResolvedOrNotColumn) {
+ return toString(isResolved);
+ } else if (column == LineNumberColumn) {
+ return include.line();
+ } else if (column == FilePathsColumn) {
+ return QVariant(unresolvedFileNameWithDelimiters(include) + QLatin1String(" --> ")
+ + resolvedFileName);
+ }
+ } else if (role == Qt::ForegroundRole) {
+ return isResolved ? greenBrush : redBrush;
+ }
+
+ return QVariant();
+}
+
+QVariant IncludesModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) {
+ case ResolvedOrNotColumn:
+ return QLatin1String("Resolved");
+ case LineNumberColumn:
+ return QLatin1String("Line");
+ case FilePathsColumn:
+ return QLatin1String("File Paths");
+ default:
+ return QVariant();
+ }
+ }
+ return QVariant();
+}
+
+// --- DiagnosticMessagesModel --------------------------------------------------------------------
+
+static bool diagnosticMessagesModelSorter(const CPlusPlus::Document::DiagnosticMessage &m1,
+ const CPlusPlus::Document::DiagnosticMessage &m2)
+{
+ return m1.line() < m2.line();
+}
+
+class DiagnosticMessagesModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ DiagnosticMessagesModel(QObject *parent);
+ void configure(const QList<CPlusPlus::Document::DiagnosticMessage> &messages);
+ void clear();
+
+ enum Columns { LevelColumn, LineColumnNumberColumn, MessageColumn, ColumnCount };
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+private:
+ QList<CPlusPlus::Document::DiagnosticMessage> m_messages;
+};
+
+DiagnosticMessagesModel::DiagnosticMessagesModel(QObject *parent) : QAbstractListModel(parent)
+{
+}
+
+void DiagnosticMessagesModel::configure(
+ const QList<CPlusPlus::Document::DiagnosticMessage> &messages)
+{
+ emit layoutAboutToBeChanged();
+ m_messages = messages;
+ qStableSort(m_messages.begin(), m_messages.end(), diagnosticMessagesModelSorter);
+ emit layoutChanged();
+}
+
+void DiagnosticMessagesModel::clear()
+{
+ emit layoutAboutToBeChanged();
+ m_messages.clear();
+ emit layoutChanged();
+}
+
+int DiagnosticMessagesModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return m_messages.size();
+}
+
+int DiagnosticMessagesModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return DiagnosticMessagesModel::ColumnCount;
+}
+
+QVariant DiagnosticMessagesModel::data(const QModelIndex &index, int role) const
+{
+ if (role != Qt::DisplayRole && role != Qt::ForegroundRole)
+ return QVariant();
+
+ static const QBrush yellowOrangeBrush(QColor(237, 145, 33));
+ static const QBrush redBrush(QColor(205, 38, 38));
+ static const QBrush darkRedBrushQColor(QColor(139, 0, 0));
+
+ const CPlusPlus::Document::DiagnosticMessage message = m_messages.at(index.row());
+ const CPlusPlus::Document::DiagnosticMessage::Level level
+ = static_cast<CPlusPlus::Document::DiagnosticMessage::Level>(message.level());
+
+ if (role == Qt::DisplayRole) {
+ const int column = index.column();
+ if (column == LevelColumn) {
+ return toString(level);
+ } else if (column == LineColumnNumberColumn) {
+ return QVariant(QString::number(message.line()) + QLatin1Char(':')
+ + QString::number(message.column()));
+ } else if (column == MessageColumn) {
+ return message.text();
+ }
+ } else if (role == Qt::ForegroundRole) {
+ switch (level) {
+ case CPlusPlus::Document::DiagnosticMessage::Warning:
+ return yellowOrangeBrush;
+ case CPlusPlus::Document::DiagnosticMessage::Error:
+ return redBrush;
+ case CPlusPlus::Document::DiagnosticMessage::Fatal:
+ return darkRedBrushQColor;
+ default:
+ return QVariant();
+ }
+ }
+
+ return QVariant();
+}
+
+QVariant DiagnosticMessagesModel::headerData(int section, Qt::Orientation orientation, int role)
+ const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) {
+ case LevelColumn:
+ return QLatin1String("Level");
+ case LineColumnNumberColumn:
+ return QLatin1String("Line:Column");
+ case MessageColumn:
+ return QLatin1String("Message");
+ default:
+ return QVariant();
+ }
+ }
+ return QVariant();
+}
+
+// --- MacrosModel --------------------------------------------------------------------------------
+
+class MacrosModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ MacrosModel(QObject *parent);
+ void configure(const QList<CPlusPlus::Macro> &macros);
+ void clear();
+
+ enum Columns { LineNumberColumn, MacroColumn, ColumnCount };
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+private:
+ QList<CPlusPlus::Macro> m_macros;
+};
+
+MacrosModel::MacrosModel(QObject *parent) : QAbstractListModel(parent)
+{
+}
+
+void MacrosModel::configure(const QList<CPlusPlus::Macro> &macros)
+{
+ emit layoutAboutToBeChanged();
+ m_macros = macros;
+ emit layoutChanged();
+}
+
+void MacrosModel::clear()
+{
+ emit layoutAboutToBeChanged();
+ m_macros.clear();
+ emit layoutChanged();
+}
+
+int MacrosModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return m_macros.size();
+}
+
+int MacrosModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return MacrosModel::ColumnCount;
+}
+
+QVariant MacrosModel::data(const QModelIndex &index, int role) const
+{
+ const int column = index.column();
+ if (role == Qt::DisplayRole || (role == Qt::ToolTipRole && column == MacroColumn)) {
+ const CPlusPlus::Macro macro = m_macros.at(index.row());
+ if (column == LineNumberColumn)
+ return macro.line();
+ else if (column == MacroColumn)
+ return macro.toString();
+ } else if (role == Qt::TextAlignmentRole) {
+ return Qt::AlignTop + Qt::AlignLeft;
+ }
+ return QVariant();
+}
+
+QVariant MacrosModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) {
+ case LineNumberColumn:
+ return QLatin1String("Line");
+ case MacroColumn:
+ return QLatin1String("Macro");
+ default:
+ return QVariant();
+ }
+ }
+ return QVariant();
+}
+
+// --- SymbolsModel -------------------------------------------------------------------------------
+
+class SymbolsModel : public QAbstractItemModel
+{
+ Q_OBJECT
+public:
+ SymbolsModel(QObject *parent);
+ void configure(const CPlusPlus::Document::Ptr &document);
+ void clear();
+
+ enum Columns { SymbolColumn, LineNumberColumn, ColumnCount };
+
+ QModelIndex index(int row, int column, const QModelIndex &parent) const;
+ QModelIndex parent(const QModelIndex &child) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+private:
+ CPlusPlus::Document::Ptr m_document;
+};
+
+SymbolsModel::SymbolsModel(QObject *parent) : QAbstractItemModel(parent)
+{
+}
+
+void SymbolsModel::configure(const CPlusPlus::Document::Ptr &document)
+{
+ QTC_CHECK(document);
+ emit layoutAboutToBeChanged();
+ m_document = document;
+ emit layoutChanged();
+}
+
+void SymbolsModel::clear()
+{
+ emit layoutAboutToBeChanged();
+ m_document.clear();
+ emit layoutChanged();
+}
+
+static CPlusPlus::Symbol *indexToSymbol(const QModelIndex &index)
+{
+ if (CPlusPlus::Symbol *symbol = static_cast<CPlusPlus::Symbol*>(index.internalPointer()))
+ return symbol;
+ return 0;
+}
+
+static CPlusPlus::Scope *indexToScope(const QModelIndex &index)
+{
+ if (CPlusPlus::Symbol *symbol = indexToSymbol(index))
+ return symbol->asScope();
+ return 0;
+}
+
+QModelIndex SymbolsModel::index(int row, int column, const QModelIndex &parent) const
+{
+ CPlusPlus::Scope *scope = 0;
+ if (parent.isValid())
+ scope = indexToScope(parent);
+ else if (m_document)
+ scope = m_document->globalNamespace();
+
+ if (scope) {
+ if ((unsigned)row < scope->memberCount())
+ return createIndex(row, column, scope->memberAt(row));
+ }
+
+ return QModelIndex();
+}
+
+QModelIndex SymbolsModel::parent(const QModelIndex &child) const
+{
+ if (!child.isValid())
+ return QModelIndex();
+
+ if (CPlusPlus::Symbol *symbol = indexToSymbol(child)) {
+ if (CPlusPlus::Scope *scope = symbol->enclosingScope()) {
+ const int row = DepthFinder()(m_document, scope);
+ return createIndex(row, 0, scope);
+ }
+ }
+
+ return QModelIndex();
+}
+
+int SymbolsModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid()) {
+ if (CPlusPlus::Scope *scope = indexToScope(parent))
+ return scope->memberCount();
+ } else {
+ if (m_document)
+ return m_document->globalNamespace()->memberCount();
+ }
+ return 0;
+}
+
+int SymbolsModel::columnCount(const QModelIndex &) const
+{
+ return ColumnCount;
+}
+
+QVariant SymbolsModel::data(const QModelIndex &index, int role) const
+{
+ const int column = index.column();
+ if (role == Qt::DisplayRole) {
+ CPlusPlus::Symbol *symbol = indexToSymbol(index);
+ if (!symbol)
+ return QVariant();
+ if (column == LineNumberColumn) {
+ return symbol->line();
+ } else if (column == SymbolColumn) {
+ QString name = CPlusPlus::Overview().prettyName(symbol->name());
+ if (name.isEmpty())
+ name = QLatin1String("<no name>");
+ return name;
+ }
+ }
+ return QVariant();
+}
+
+QVariant SymbolsModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) {
+ case SymbolColumn:
+ return QLatin1String("Symbol");
+ case LineNumberColumn:
+ return QLatin1String("Line");
+ default:
+ return QVariant();
+ }
+ }
+ return QVariant();
+}
+
+// --- TokensModel --------------------------------------------------------------------------------
+
+class TokensModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ TokensModel(QObject *parent);
+ void configure(CPlusPlus::TranslationUnit *translationUnit);
+ void clear();
+
+ enum Columns { SpelledColumn, KindColumn, IndexColumn, OffsetColumn, LineColumnNumberColumn,
+ LengthColumn, GeneratedColumn, ExpandedColumn, WhiteSpaceColumn, NewlineColumn,
+ ColumnCount };
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+private:
+ struct TokenInfo {
+ CPlusPlus::Token token;
+ unsigned line;
+ unsigned column;
+ };
+ QList<TokenInfo> m_tokenInfos;
+};
+
+TokensModel::TokensModel(QObject *parent) : QAbstractListModel(parent)
+{
+}
+
+void TokensModel::configure(CPlusPlus::TranslationUnit *translationUnit)
+{
+ if (!translationUnit)
+ return;
+
+ emit layoutAboutToBeChanged();
+ m_tokenInfos.clear();
+ for (int i = 0, total = translationUnit->tokenCount(); i < total; ++i) {
+ TokenInfo info;
+ info.token = translationUnit->tokenAt(i);
+ translationUnit->getPosition(info.token.offset, &info.line, &info.column);
+ m_tokenInfos.append(info);
+ }
+ emit layoutChanged();
+}
+
+void TokensModel::clear()
+{
+ emit layoutAboutToBeChanged();
+ m_tokenInfos.clear();
+ emit layoutChanged();
+}
+
+int TokensModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return m_tokenInfos.size();
+}
+
+int TokensModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return TokensModel::ColumnCount;
+}
+
+QVariant TokensModel::data(const QModelIndex &index, int role) const
+{
+ const int column = index.column();
+ if (role == Qt::DisplayRole) {
+ const TokenInfo info = m_tokenInfos.at(index.row());
+ const CPlusPlus::Token token = info.token;
+ if (column == SpelledColumn)
+ return QString::fromUtf8(token.spell());
+ else if (column == KindColumn)
+ return toString(static_cast<CPlusPlus::Kind>(token.kind()));
+ else if (column == IndexColumn)
+ return index.row();
+ else if (column == OffsetColumn)
+ return token.offset;
+ else if (column == LineColumnNumberColumn)
+ return QString::fromLatin1("%1:%2").arg(toString(info.line), toString(info.column));
+ else if (column == LengthColumn)
+ return toString(token.length());
+ else if (column == GeneratedColumn)
+ return toString(token.generated());
+ else if (column == ExpandedColumn)
+ return toString(token.expanded());
+ else if (column == WhiteSpaceColumn)
+ return toString(token.whitespace());
+ else if (column == NewlineColumn)
+ return toString(token.newline());
+ } else if (role == Qt::TextAlignmentRole) {
+ return Qt::AlignTop + Qt::AlignLeft;
+ }
+ return QVariant();
+}
+
+QVariant TokensModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) {
+ case SpelledColumn:
+ return QLatin1String("Spelled");
+ case KindColumn:
+ return QLatin1String("Kind");
+ case IndexColumn:
+ return QLatin1String("Index");
+ case OffsetColumn:
+ return QLatin1String("Offset");
+ case LineColumnNumberColumn:
+ return QLatin1String("Line:Column");
+ case LengthColumn:
+ return QLatin1String("Length");
+ case GeneratedColumn:
+ return QLatin1String("Generated");
+ case ExpandedColumn:
+ return QLatin1String("Expanded");
+ case WhiteSpaceColumn:
+ return QLatin1String("Whitespace");
+ case NewlineColumn:
+ return QLatin1String("Newline");
+ default:
+ return QVariant();
+ }
+ }
+ return QVariant();
+}
+
+// --- ProjectPartsModel --------------------------------------------------------------------------
+
+class ProjectPartsModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ ProjectPartsModel(QObject *parent);
+
+ void configure(const QList<CppModelManagerInterface::ProjectInfo> &projectInfos,
+ const ProjectPart::Ptr &currentEditorsProjectPart);
+
+ QModelIndex indexForCurrentEditorsProjectPart() const;
+ ProjectPart::Ptr projectPartForProjectFile(const QString &projectFilePath) const;
+
+ enum Columns { PartNameColumn, PartFilePathColumn, ColumnCount };
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+private:
+ QList<ProjectPart::Ptr> m_projectPartsList;
+ int m_currentEditorsProjectPartIndex;
+};
+
+ProjectPartsModel::ProjectPartsModel(QObject *parent)
+ : QAbstractListModel(parent), m_currentEditorsProjectPartIndex(-1)
+{
+}
+
+void ProjectPartsModel::configure(const QList<CppModelManagerInterface::ProjectInfo> &projectInfos,
+ const ProjectPart::Ptr &currentEditorsProjectPart)
+{
+ emit layoutAboutToBeChanged();
+ m_projectPartsList.clear();
+ foreach (const CppModelManagerInterface::ProjectInfo &info, projectInfos) {
+ foreach (const ProjectPart::Ptr &projectPart, info.projectParts()) {
+ if (!m_projectPartsList.contains(projectPart)) {
+ m_projectPartsList << projectPart;
+ if (projectPart == currentEditorsProjectPart)
+ m_currentEditorsProjectPartIndex = m_projectPartsList.size() - 1;
+ }
+ }
+ }
+ emit layoutChanged();
+}
+
+QModelIndex ProjectPartsModel::indexForCurrentEditorsProjectPart() const
+{
+ if (m_currentEditorsProjectPartIndex == -1)
+ return QModelIndex();
+ return createIndex(m_currentEditorsProjectPartIndex, PartFilePathColumn);
+}
+
+ProjectPart::Ptr ProjectPartsModel::projectPartForProjectFile(const QString &projectFilePath) const
+{
+ foreach (const ProjectPart::Ptr &part, m_projectPartsList) {
+ if (part->projectFile == projectFilePath)
+ return part;
+ }
+ return ProjectPart::Ptr();
+}
+
+int ProjectPartsModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return m_projectPartsList.size();
+}
+
+int ProjectPartsModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return ProjectPartsModel::ColumnCount;
+}
+
+QVariant ProjectPartsModel::data(const QModelIndex &index, int role) const
+{
+ const int row = index.row();
+ if (role == Qt::DisplayRole) {
+ const int column = index.column();
+ if (column == PartNameColumn)
+ return m_projectPartsList.at(row)->displayName;
+ else if (column == PartFilePathColumn)
+ return QDir::toNativeSeparators(m_projectPartsList.at(row)->projectFile);
+ }
+ return QVariant();
+}
+
+QVariant ProjectPartsModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) {
+ case PartNameColumn:
+ return QLatin1String("Name");
+ case PartFilePathColumn:
+ return QLatin1String("Project File Path");
+ default:
+ return QVariant();
+ }
+ }
+ return QVariant();
+}
+
+// --- WorkingCopyModel ---------------------------------------------------------------------------
+
+class WorkingCopyModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ WorkingCopyModel(QObject *parent);
+
+ void configure(const CppModelManagerInterface::WorkingCopy &workingCopy);
+ QModelIndex indexForFile(const QString &filePath);
+
+ enum Columns { RevisionColumn, FilePathColumn, ColumnCount };
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+private:
+ struct WorkingCopyEntry {
+ WorkingCopyEntry(const QString &filePath, const QByteArray &source, unsigned revision)
+ : filePath(filePath), source(source), revision(revision)
+ {}
+
+ QString filePath;
+ QByteArray source;
+ unsigned revision;
+ };
+
+ QList<WorkingCopyEntry> m_workingCopyList;
+};
+
+WorkingCopyModel::WorkingCopyModel(QObject *parent) : QAbstractListModel(parent)
+{
+}
+
+void WorkingCopyModel::configure(const CppModelManagerInterface::WorkingCopy &workingCopy)
+{
+ emit layoutAboutToBeChanged();
+ m_workingCopyList.clear();
+ QHashIterator<QString, QPair<QByteArray, unsigned> > it = workingCopy.iterator();
+ while (it.hasNext()) {
+ it.next();
+ m_workingCopyList << WorkingCopyEntry(it.key(), it.value().first, it.value().second);
+ }
+ emit layoutChanged();
+}
+
+QModelIndex WorkingCopyModel::indexForFile(const QString &filePath)
+{
+ for (int i = 0, total = m_workingCopyList.size(); i < total; ++i) {
+ const WorkingCopyEntry entry = m_workingCopyList.at(i);
+ if (entry.filePath == filePath)
+ return index(i, FilePathColumn);
+ }
+ return QModelIndex();
+}
+
+int WorkingCopyModel::rowCount(const QModelIndex &/*parent*/) const
+{
+ return m_workingCopyList.size();
+}
+
+int WorkingCopyModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return WorkingCopyModel::ColumnCount;
+}
+
+QVariant WorkingCopyModel::data(const QModelIndex &index, int role) const
+{
+ const int row = index.row();
+ if (role == Qt::DisplayRole) {
+ const int column = index.column();
+ if (column == RevisionColumn)
+ return m_workingCopyList.at(row).revision;
+ else if (column == FilePathColumn)
+ return m_workingCopyList.at(row).filePath;
+ } else if (role == Qt::UserRole) {
+ return m_workingCopyList.at(row).source;
+ }
+ return QVariant();
+}
+
+QVariant WorkingCopyModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ switch (section) {
+ case RevisionColumn:
+ return QLatin1String("Revision");
+ case FilePathColumn:
+ return QLatin1String("File Path");
+ default:
+ return QVariant();
+ }
+ }
+ return QVariant();
+}
+
+// --- SnapshotInfo -------------------------------------------------------------------------------
+
+class SnapshotInfo
+{
+public:
+ enum Type { GlobalSnapshot, EditorSnapshot };
+ SnapshotInfo(const CPlusPlus::Snapshot &snapshot, Type type)
+ : snapshot(snapshot), type(type) {}
+
+ CPlusPlus::Snapshot snapshot;
+ Type type;
+};
+
+// --- CppCodeModelInspectorDialog ----------------------------------------------------------------
+
+CppCodeModelInspectorDialog::CppCodeModelInspectorDialog(QWidget *parent)
+ : QDialog(parent)
+ , m_ui(new Ui::CppCodeModelInspectorDialog)
+ , m_snapshotInfos(new QList<SnapshotInfo>())
+ , m_snapshotView(new FilterableView(this))
+ , m_snapshotModel(new SnapshotModel(this))
+ , m_proxySnapshotModel(new QSortFilterProxyModel(this))
+ , m_docGenericInfoModel(new KeyValueModel(this))
+ , m_docIncludesModel(new IncludesModel(this))
+ , m_docDiagnosticMessagesModel(new DiagnosticMessagesModel(this))
+ , m_docMacrosModel(new MacrosModel(this))
+ , m_docSymbolsModel(new SymbolsModel(this))
+ , m_docTokensModel(new TokensModel(this))
+ , m_projectPartsView(new FilterableView(this))
+ , m_projectPartsModel(new ProjectPartsModel(this))
+ , m_proxyProjectPartsModel(new QSortFilterProxyModel(this))
+ , m_partGenericInfoModel(new KeyValueModel(this))
+ , m_workingCopyView(new FilterableView(this))
+ , m_workingCopyModel(new WorkingCopyModel(this))
+ , m_proxyWorkingCopyModel(new QSortFilterProxyModel(this))
+{
+ m_ui->setupUi(this);
+ m_ui->snapshotSelectorAndViewLayout->addWidget(m_snapshotView);
+ m_ui->projectPartsSplitter->insertWidget(0, m_projectPartsView);
+ m_ui->workingCopySplitter->insertWidget(0, m_workingCopyView);
+
+ setAttribute(Qt::WA_DeleteOnClose);
+ connect(Core::ICore::instance(), SIGNAL(coreAboutToClose()), SLOT(close()));
+
+ m_proxySnapshotModel->setSourceModel(m_snapshotModel);
+ m_proxySnapshotModel->setFilterKeyColumn(SnapshotModel::FilePathColumn);
+ m_snapshotView->setModel(m_proxySnapshotModel);
+ m_ui->docGeneralView->setModel(m_docGenericInfoModel);
+ m_ui->docIncludesView->setModel(m_docIncludesModel);
+ m_ui->docDiagnosticMessagesView->setModel(m_docDiagnosticMessagesModel);
+ m_ui->docDefinedMacrosView->setModel(m_docMacrosModel);
+ m_ui->docSymbolsView->setModel(m_docSymbolsModel);
+ m_ui->docTokensView->setModel(m_docTokensModel);
+
+ m_proxyProjectPartsModel->setSourceModel(m_projectPartsModel);
+ m_proxyProjectPartsModel->setFilterKeyColumn(ProjectPartsModel::PartFilePathColumn);
+ m_projectPartsView->setModel(m_proxyProjectPartsModel);
+ m_ui->partGeneralView->setModel(m_partGenericInfoModel);
+
+ m_proxyWorkingCopyModel->setSourceModel(m_workingCopyModel);
+ m_proxyWorkingCopyModel->setFilterKeyColumn(WorkingCopyModel::FilePathColumn);
+ m_workingCopyView->setModel(m_proxyWorkingCopyModel);
+
+ connect(m_snapshotView->selectionModel(),
+ SIGNAL(currentRowChanged(QModelIndex ,QModelIndex)),
+ SLOT(onDocumentSelected(QModelIndex, QModelIndex)));
+ connect(m_snapshotView, SIGNAL(filterChanged(QString)),
+ SLOT(onSnapshotFilterChanged(QString)));
+ connect(m_ui->snapshotSelector, SIGNAL(currentIndexChanged(int)),
+ SLOT(onSnapshotSelected(int)));
+ connect(m_ui->docSymbolsView, SIGNAL(expanded(QModelIndex)),
+ SLOT(onSymbolsViewExpandedOrCollapsed(QModelIndex)));
+ connect(m_ui->docSymbolsView, SIGNAL(collapsed(QModelIndex)),
+ SLOT(onSymbolsViewExpandedOrCollapsed(QModelIndex)));
+
+ connect(m_projectPartsView->selectionModel(),
+ SIGNAL(currentRowChanged(QModelIndex ,QModelIndex)),
+ SLOT(onProjectPartSelected(QModelIndex, QModelIndex)));
+ connect(m_projectPartsView, SIGNAL(filterChanged(QString)),
+ SLOT(onProjectPartFilterChanged(QString)));
+
+ connect(m_workingCopyView->selectionModel(),
+ SIGNAL(currentRowChanged(QModelIndex ,QModelIndex)),
+ SLOT(onWorkingCopyDocumentSelected(QModelIndex, QModelIndex)));
+ connect(m_workingCopyView, SIGNAL(filterChanged(QString)),
+ SLOT(onWorkingCopyFilterChanged(QString)));
+
+ connect(m_ui->refreshButton, SIGNAL(clicked()), SLOT(onRefreshRequested()));
+ connect(m_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
+
+ refresh();
+}
+
+CppCodeModelInspectorDialog::~CppCodeModelInspectorDialog()
+{
+ delete m_snapshotInfos;
+ delete m_ui;
+}
+
+void CppCodeModelInspectorDialog::onRefreshRequested()
+{
+ refresh();
+}
+
+void CppCodeModelInspectorDialog::onSnapshotFilterChanged(const QString &pattern)
+{
+ m_proxySnapshotModel->setFilterWildcard(pattern);
+}
+
+void CppCodeModelInspectorDialog::onSnapshotSelected(int row)
+{
+ if (row < 0 || row >= m_snapshotInfos->size())
+ return;
+
+ m_snapshotView->clearFilter();
+ const SnapshotInfo info = m_snapshotInfos->at(row);
+ m_snapshotModel->configure(info.snapshot);
+ m_snapshotView->resizeColumns(SnapshotModel::ColumnCount);
+
+ if (info.type == SnapshotInfo::GlobalSnapshot) {
+ // Select first document
+ const QModelIndex index = m_proxySnapshotModel->index(0, SnapshotModel::FilePathColumn);
+ m_snapshotView->selectIndex(index);
+ } else if (info.type == SnapshotInfo::EditorSnapshot) {
+ // Select first document, unless we can find the editor document
+ QModelIndex index = m_snapshotModel->indexForDocument(fileInCurrentEditor());
+ index = m_proxySnapshotModel->mapFromSource(index);
+ if (!index.isValid())
+ index = m_proxySnapshotModel->index(0, SnapshotModel::FilePathColumn);
+ m_snapshotView->selectIndex(index);
+ }
+}
+
+void CppCodeModelInspectorDialog::onDocumentSelected(const QModelIndex &current,
+ const QModelIndex &)
+{
+ if (current.isValid()) {
+ const QModelIndex index = m_proxySnapshotModel->index(current.row(),
+ SnapshotModel::FilePathColumn);
+ const QString filePath = QDir::fromNativeSeparators(
+ m_proxySnapshotModel->data(index, Qt::DisplayRole).toString());
+ const SnapshotInfo info = m_snapshotInfos->at(m_ui->snapshotSelector->currentIndex());
+ updateDocumentData(info.snapshot.document(filePath));
+ } else {
+ clearDocumentData();
+ }
+}
+
+void CppCodeModelInspectorDialog::onSymbolsViewExpandedOrCollapsed(const QModelIndex &)
+{
+ resizeColumns<SymbolsModel>(m_ui->docSymbolsView);
+}
+
+void CppCodeModelInspectorDialog::onProjectPartFilterChanged(const QString &pattern)
+{
+ m_proxyProjectPartsModel->setFilterWildcard(pattern);
+}
+
+void CppCodeModelInspectorDialog::onProjectPartSelected(const QModelIndex &current,
+ const QModelIndex &)
+{
+ if (current.isValid()) {
+ QModelIndex index = m_proxyProjectPartsModel->mapToSource(current);
+ if (index.isValid()) {
+ index = m_projectPartsModel->index(index.row(), ProjectPartsModel::PartFilePathColumn);
+ const QString projectFilePath = QDir::fromNativeSeparators(
+ m_projectPartsModel->data(index, Qt::DisplayRole).toString());
+ updateProjectPartData(m_projectPartsModel->projectPartForProjectFile(projectFilePath));
+ }
+ } else {
+ clearProjectPartData();
+ }
+}
+
+void CppCodeModelInspectorDialog::onWorkingCopyFilterChanged(const QString &pattern)
+{
+ m_proxyWorkingCopyModel->setFilterWildcard(pattern);
+}
+
+void CppCodeModelInspectorDialog::onWorkingCopyDocumentSelected(const QModelIndex &current,
+ const QModelIndex &)
+{
+ if (current.isValid()) {
+ const QModelIndex index = m_proxyWorkingCopyModel->mapToSource(current);
+ if (index.isValid()) {
+ const QString source
+ = QString::fromUtf8(m_workingCopyModel->data(index, Qt::UserRole).toByteArray());
+ m_ui->workingCopySourceEdit->setPlainText(source);
+ }
+ } else {
+ m_ui->workingCopySourceEdit->setPlainText(QString());
+ }
+}
+
+void CppCodeModelInspectorDialog::refresh()
+{
+ CppModelManagerInterface *cmm = CppModelManagerInterface::instance();
+
+ const int oldSnapshotIndex = m_ui->snapshotSelector->currentIndex();
+ const bool selectEditorRelevant
+ = m_ui->selectEditorRelevantEntriesAfterRefreshCheckBox->isChecked();
+
+ // Snapshots and Documents
+ m_snapshotInfos->clear();
+ m_ui->snapshotSelector->clear();
+
+ const CPlusPlus::Snapshot globalSnapshot = cmm->snapshot();
+ CppCodeModelInspectorDumper dumper(globalSnapshot);
+ m_snapshotModel->setGlobalSnapshot(globalSnapshot);
+
+ m_snapshotInfos->append(SnapshotInfo(globalSnapshot, SnapshotInfo::GlobalSnapshot));
+ const QString globalSnapshotTitle
+ = QString::fromLatin1("Global/Indexing Snapshot (%1 Documents)").arg(globalSnapshot.size());
+ m_ui->snapshotSelector->addItem(globalSnapshotTitle);
+ dumper.dumpSnapshot(globalSnapshot, globalSnapshotTitle, /*isGlobalSnapshot=*/ true);
+
+ TextEditor::BaseTextEditor *editor = currentEditor();
+ CppEditorSupport *editorSupport = 0;
+ if (editor) {
+ editorSupport = cmm->cppEditorSupport(editor);
+ if (editorSupport) {
+ const CPlusPlus::Snapshot editorSnapshot = editorSupport->snapshotUpdater()->snapshot();
+ m_snapshotInfos->append(SnapshotInfo(editorSnapshot, SnapshotInfo::EditorSnapshot));
+ const QString editorSnapshotTitle
+ = QString::fromLatin1("Current Editor's Snapshot (%1 Documents)")
+ .arg(editorSnapshot.size());
+ dumper.dumpSnapshot(editorSnapshot, editorSnapshotTitle);
+ m_ui->snapshotSelector->addItem(editorSnapshotTitle);
+ }
+ CppEditor::Internal::CPPEditorWidget *cppEditorWidget
+ = qobject_cast<CppEditor::Internal::CPPEditorWidget *>(editor->editorWidget());
+ if (cppEditorWidget) {
+ SemanticInfo semanticInfo = cppEditorWidget->semanticInfo();
+ CPlusPlus::Snapshot snapshot;
+
+ // Add semantic info snapshot
+ snapshot = semanticInfo.snapshot;
+ m_snapshotInfos->append(SnapshotInfo(snapshot, SnapshotInfo::EditorSnapshot));
+ m_ui->snapshotSelector->addItem(
+ QString::fromLatin1("Current Editor's Semantic Info Snapshot (%1 Documents)")
+ .arg(snapshot.size()));
+
+ // Add a pseudo snapshot containing only the semantic info document since this document
+ // is not part of the semantic snapshot.
+ snapshot = CPlusPlus::Snapshot();
+ snapshot.insert(cppEditorWidget->semanticInfo().doc);
+ m_snapshotInfos->append(SnapshotInfo(snapshot, SnapshotInfo::EditorSnapshot));
+ const QString snapshotTitle
+ = QString::fromLatin1("Current Editor's Pseudo Snapshot with Semantic Info Document (%1 Documents)")
+ .arg(snapshot.size());
+ dumper.dumpSnapshot(snapshot, snapshotTitle);
+ m_ui->snapshotSelector->addItem(snapshotTitle);
+ }
+ }
+
+ int snapshotIndex = 0;
+ if (selectEditorRelevant) {
+ for (int i = 0, total = m_snapshotInfos->size(); i < total; ++i) {
+ const SnapshotInfo info = m_snapshotInfos->at(i);
+ if (info.type == SnapshotInfo::EditorSnapshot) {
+ snapshotIndex = i;
+ break;
+ }
+ }
+ } else if (oldSnapshotIndex < m_snapshotInfos->size()) {
+ snapshotIndex = oldSnapshotIndex;
+ }
+ m_ui->snapshotSelector->setCurrentIndex(snapshotIndex);
+ onSnapshotSelected(snapshotIndex);
+
+ // Project Parts
+ const ProjectPart::Ptr editorsProjectPart = editorSupport
+ ? editorSupport->snapshotUpdater()->currentProjectPart()
+ : ProjectPart::Ptr();
+
+ const QList<CppModelManagerInterface::ProjectInfo> projectInfos = cmm->projectInfos();
+ dumper.dumpProjectInfos(projectInfos);
+ m_projectPartsModel->configure(projectInfos, editorsProjectPart);
+ m_projectPartsView->resizeColumns(ProjectPartsModel::ColumnCount);
+ QModelIndex index = m_proxyProjectPartsModel->index(0, ProjectPartsModel::PartFilePathColumn);
+ if (index.isValid()) {
+ if (selectEditorRelevant && editorsProjectPart) {
+ QModelIndex editorPartIndex = m_projectPartsModel->indexForCurrentEditorsProjectPart();
+ editorPartIndex = m_proxyProjectPartsModel->mapFromSource(editorPartIndex);
+ if (editorPartIndex.isValid())
+ index = editorPartIndex;
+ }
+ m_projectPartsView->selectIndex(index);
+ }
+
+ // Working Copy
+ const CppModelManagerInterface::WorkingCopy workingCopy = cmm->workingCopy();
+ dumper.dumpWorkingCopy(workingCopy);
+ m_workingCopyModel->configure(workingCopy);
+ m_workingCopyView->resizeColumns(WorkingCopyModel::ColumnCount);
+ if (workingCopy.size() > 0) {
+ QModelIndex index = m_proxyWorkingCopyModel->index(0, WorkingCopyModel::FilePathColumn);
+ if (selectEditorRelevant) {
+ const QModelIndex eindex = m_workingCopyModel->indexForFile(fileInCurrentEditor());
+ if (eindex.isValid())
+ index = m_proxyWorkingCopyModel->mapFromSource(eindex);
+ }
+ m_workingCopyView->selectIndex(index);
+ }
+}
+
+enum DocumentTabs {
+ DocumentGeneralTab,
+ DocumentIncludesTab,
+ DocumentDiagnosticsTab,
+ DocumentDefinedMacrosTab,
+ DocumentPreprocessedSourceTab,
+ DocumentSymbolsTab,
+ DocumentTokensTab
+};
+
+static QString docTabName(int tabIndex, int numberOfEntries = -1)
+{
+ const char *names[] = {
+ "&General",
+ "&Includes",
+ "&Diagnostic Messages",
+ "(Un)Defined &Macros",
+ "P&reprocessed Source",
+ "&Symbols",
+ "&Tokens"
+ };
+ QString result = QLatin1String(names[tabIndex]);
+ if (numberOfEntries != -1)
+ result += QString::fromLatin1(" (%1)").arg(numberOfEntries);
+ return result;
+}
+
+void CppCodeModelInspectorDialog::clearDocumentData()
+{
+ m_docGenericInfoModel->clear();
+
+ m_ui->docTab->setTabText(DocumentIncludesTab, docTabName(DocumentIncludesTab));
+ m_docIncludesModel->clear();
+
+ m_ui->docTab->setTabText(DocumentDiagnosticsTab, docTabName(DocumentDiagnosticsTab));
+ m_docDiagnosticMessagesModel->clear();
+
+ m_ui->docTab->setTabText(DocumentDefinedMacrosTab, docTabName(DocumentDefinedMacrosTab));
+ m_docMacrosModel->clear();
+
+ m_ui->docPreprocessedSourceEdit->setPlainText(QString());
+
+ m_docSymbolsModel->clear();
+
+ m_ui->docTab->setTabText(DocumentTokensTab, docTabName(DocumentTokensTab));
+ m_docTokensModel->clear();
+}
+
+void CppCodeModelInspectorDialog::updateDocumentData(const CPlusPlus::Document::Ptr &document)
+{
+ QTC_ASSERT(document, return);
+
+ // General
+ KeyValueModel::Table table = KeyValueModel::Table()
+ << qMakePair(QString::fromLatin1("File Path"),
+ QDir::toNativeSeparators(document->fileName()))
+ << qMakePair(QString::fromLatin1("Last Modified"), toString(document->lastModified()))
+ << qMakePair(QString::fromLatin1("Revision"), toString(document->revision()))
+ << qMakePair(QString::fromLatin1("Editor Revision"), toString(document->editorRevision()))
+ << qMakePair(QString::fromLatin1("Check Mode"), toString(document->checkMode()))
+ << qMakePair(QString::fromLatin1("Tokenized"), toString(document->isTokenized()))
+ << qMakePair(QString::fromLatin1("Parsed"), toString(document->isParsed()))
+ << qMakePair(QString::fromLatin1("Project Parts"), partsForFile(document->fileName()))
+ ;
+ m_docGenericInfoModel->configure(table);
+ resizeColumns<KeyValueModel>(m_ui->docGeneralView);
+
+ // Includes
+ m_docIncludesModel->configure(document->resolvedIncludes() + document->unresolvedIncludes());
+ resizeColumns<IncludesModel>(m_ui->docIncludesView);
+ m_ui->docTab->setTabText(DocumentIncludesTab,
+ docTabName(DocumentIncludesTab, m_docIncludesModel->rowCount()));
+
+ // Diagnostic Messages
+ m_docDiagnosticMessagesModel->configure(document->diagnosticMessages());
+ resizeColumns<DiagnosticMessagesModel>(m_ui->docDiagnosticMessagesView);
+ m_ui->docTab->setTabText(DocumentDiagnosticsTab,
+ docTabName(DocumentDiagnosticsTab, m_docDiagnosticMessagesModel->rowCount()));
+
+ // Macros
+ m_docMacrosModel->configure(document->definedMacros());
+ resizeColumns<MacrosModel>(m_ui->docDefinedMacrosView);
+ m_ui->docTab->setTabText(DocumentDefinedMacrosTab,
+ docTabName(DocumentDefinedMacrosTab, m_docMacrosModel->rowCount()));
+
+ // Source
+ m_ui->docPreprocessedSourceEdit->setPlainText(QString::fromUtf8(document->utf8Source()));
+
+ // Symbols
+ m_docSymbolsModel->configure(document);
+ resizeColumns<SymbolsModel>(m_ui->docSymbolsView);
+
+ // Tokens
+ m_docTokensModel->configure(document->translationUnit());
+ resizeColumns<TokensModel>(m_ui->docTokensView);
+ m_ui->docTab->setTabText(DocumentTokensTab,
+ docTabName(DocumentTokensTab, m_docTokensModel->rowCount()));
+}
+
+enum ProjectPartTabs {
+ ProjectPartGeneralTab,
+ ProjectPartFilesTab,
+ ProjectPartDefinesTab,
+ ProjectPartIncludePathsTab,
+ ProjectPartFrameworkPathsTab,
+ ProjectPartPrecompiledHeadersTab
+};
+
+static QString partTabName(int tabIndex, int numberOfEntries = -1)
+{
+ const char *names[] = {
+ "&General",
+ "Project &Files",
+ "&Defines",
+ "&Include Paths",
+ "F&ramework Paths",
+ "Pre&compiled Headers"
+ };
+ QString result = QLatin1String(names[tabIndex]);
+ if (numberOfEntries != -1)
+ result += QString::fromLatin1(" (%1)").arg(numberOfEntries);
+ return result;
+}
+
+void CppCodeModelInspectorDialog::clearProjectPartData()
+{
+ m_partGenericInfoModel->clear();
+
+ m_ui->partProjectFilesEdit->setPlainText(QString());
+ m_ui->projectPartTab->setTabText(ProjectPartFilesTab, partTabName(ProjectPartFilesTab));
+
+ m_ui->partToolchainDefinesEdit->setPlainText(QString());
+ m_ui->partProjectDefinesEdit->setPlainText(QString());
+ m_ui->projectPartTab->setTabText(ProjectPartDefinesTab, partTabName(ProjectPartDefinesTab));
+
+ m_ui->partIncludePathsEdit->setPlainText(QString());
+ m_ui->projectPartTab->setTabText(ProjectPartIncludePathsTab,
+ partTabName(ProjectPartIncludePathsTab));
+
+ m_ui->partFrameworkPathsEdit->setPlainText(QString());
+ m_ui->projectPartTab->setTabText(ProjectPartFrameworkPathsTab,
+ partTabName(ProjectPartFrameworkPathsTab));
+
+ m_ui->partPrecompiledHeadersEdit->setPlainText(QString());
+ m_ui->projectPartTab->setTabText(ProjectPartPrecompiledHeadersTab,
+ partTabName(ProjectPartPrecompiledHeadersTab));
+}
+
+void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::Ptr &part)
+{
+ QTC_ASSERT(part, return);
+
+ // General
+ QString projectName = QLatin1String("<None>");
+ QString projectFilePath = QLatin1String("<None>");
+ if (ProjectExplorer::Project *project = part->project) {
+ projectName = project->displayName();
+ projectFilePath = project->projectFilePath();
+ }
+ KeyValueModel::Table table = KeyValueModel::Table()
+ << qMakePair(QString::fromLatin1("Project Part Name"), part->displayName)
+ << qMakePair(QString::fromLatin1("Project Part File"),
+ QDir::toNativeSeparators(part->projectFile))
+ << qMakePair(QString::fromLatin1("Project Name"), projectName)
+ << qMakePair(QString::fromLatin1("Project File"),
+ QDir::toNativeSeparators(projectFilePath))
+ << qMakePair(QString::fromLatin1("C Version"), toString(part->cVersion))
+ << qMakePair(QString::fromLatin1("CXX Version"), toString(part->cxxVersion))
+ << qMakePair(QString::fromLatin1("CXX Extensions"), toString(part->cxxExtensions))
+ << qMakePair(QString::fromLatin1("Qt Version"), toString(part->qtVersion))
+ ;
+ m_partGenericInfoModel->configure(table);
+ resizeColumns<KeyValueModel>(m_ui->partGeneralView);
+
+ // Project Files
+ m_ui->partProjectFilesEdit->setPlainText(toString(part->files));
+ m_ui->projectPartTab->setTabText(ProjectPartFilesTab,
+ partTabName(ProjectPartFilesTab, part->files.size()));
+
+ // Defines
+ const QList<QByteArray> defineLines = part->toolchainDefines.split('\n')
+ + part->projectDefines.split('\n');
+ int numberOfDefines = 0;
+ foreach (const QByteArray &line, defineLines) {
+ if (line.startsWith("#define "))
+ ++numberOfDefines;
+ }
+ m_ui->partToolchainDefinesEdit->setPlainText(QString::fromUtf8(part->toolchainDefines));
+ m_ui->partProjectDefinesEdit->setPlainText(QString::fromUtf8(part->projectDefines));
+ m_ui->projectPartTab->setTabText(ProjectPartDefinesTab,
+ partTabName(ProjectPartDefinesTab, numberOfDefines));
+
+ // Include Paths
+ m_ui->partIncludePathsEdit->setPlainText(pathListToString(part->includePaths));
+ m_ui->projectPartTab->setTabText(ProjectPartIncludePathsTab,
+ partTabName(ProjectPartIncludePathsTab, part->includePaths.size()));
+
+ // Framework Paths
+ m_ui->partFrameworkPathsEdit->setPlainText(pathListToString(part->frameworkPaths));
+ m_ui->projectPartTab->setTabText(ProjectPartFrameworkPathsTab,
+ partTabName(ProjectPartFrameworkPathsTab, part->frameworkPaths.size()));
+
+ // Precompiled Headers
+ m_ui->partPrecompiledHeadersEdit->setPlainText(pathListToString(part->precompiledHeaders));
+ m_ui->projectPartTab->setTabText(ProjectPartPrecompiledHeadersTab,
+ partTabName(ProjectPartPrecompiledHeadersTab, part->precompiledHeaders.size()));
+}
+
+bool CppCodeModelInspectorDialog::event(QEvent *e)
+{
+ if (e->type() == QEvent::ShortcutOverride) {
+ QKeyEvent *ke = static_cast<QKeyEvent *>(e);
+ if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
+ ke->accept();
+ close();
+ return false;
+ }
+ }
+ return QDialog::event(e);
+}
+
+} // namespace Internal
+} // namespace CppEditor
+
+#include "cppcodemodelinspectordialog.moc"
diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.h b/src/plugins/cppeditor/cppcodemodelinspectordialog.h
new file mode 100644
index 0000000000..569453c001
--- /dev/null
+++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CPPCODEMODELINSPECTORDIALOG_H
+#define CPPCODEMODELINSPECTORDIALOG_H
+
+#include <cpptools/cppmodelmanagerinterface.h>
+
+#include <cplusplus/CppDocument.h>
+
+#include <QDialog>
+#include <QList>
+
+QT_BEGIN_NAMESPACE
+class QSortFilterProxyModel;
+class QModelIndex;
+namespace Ui { class CppCodeModelInspectorDialog; }
+QT_END_NAMESPACE
+
+namespace CppEditor {
+namespace Internal {
+
+class FilterableView;
+class SnapshotInfo;
+
+class DiagnosticMessagesModel;
+class IncludesModel;
+class KeyValueModel;
+class MacrosModel;
+class ProjectPartsModel;
+class SnapshotModel;
+class SymbolsModel;
+class TokensModel;
+class WorkingCopyModel;
+
+//
+// This dialog is for DEBUGGING PURPOSES and thus NOT TRANSLATED.
+//
+
+class CppCodeModelInspectorDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit CppCodeModelInspectorDialog(QWidget *parent = 0);
+ ~CppCodeModelInspectorDialog();
+
+private slots:
+ void onRefreshRequested();
+
+ void onSnapshotFilterChanged(const QString &pattern);
+ void onSnapshotSelected(int row);
+ void onDocumentSelected(const QModelIndex &current, const QModelIndex &);
+ void onSymbolsViewExpandedOrCollapsed(const QModelIndex &);
+
+ void onProjectPartFilterChanged(const QString &pattern);
+ void onProjectPartSelected(const QModelIndex &current, const QModelIndex &);
+
+ void onWorkingCopyFilterChanged(const QString &pattern);
+ void onWorkingCopyDocumentSelected(const QModelIndex &current, const QModelIndex &);
+
+private:
+ void refresh();
+
+ void clearDocumentData();
+ void updateDocumentData(const CPlusPlus::Document::Ptr &document);
+
+ void clearProjectPartData();
+ void updateProjectPartData(const CppTools::ProjectPart::Ptr &part);
+
+ bool event(QEvent *e);
+
+private:
+ Ui::CppCodeModelInspectorDialog *m_ui;
+
+ // Snapshots and Documents
+ QList<SnapshotInfo> *m_snapshotInfos;
+ FilterableView *m_snapshotView;
+ SnapshotModel *m_snapshotModel;
+ QSortFilterProxyModel *m_proxySnapshotModel;
+ KeyValueModel *m_docGenericInfoModel;
+ IncludesModel *m_docIncludesModel;
+ DiagnosticMessagesModel *m_docDiagnosticMessagesModel;
+ MacrosModel *m_docMacrosModel;
+ SymbolsModel *m_docSymbolsModel;
+ TokensModel *m_docTokensModel;
+
+ // Project Parts
+ FilterableView *m_projectPartsView;
+ ProjectPartsModel *m_projectPartsModel;
+ QSortFilterProxyModel *m_proxyProjectPartsModel;
+ KeyValueModel *m_partGenericInfoModel;
+
+ // Working Copy
+ FilterableView *m_workingCopyView;
+ WorkingCopyModel *m_workingCopyModel;
+ QSortFilterProxyModel *m_proxyWorkingCopyModel;
+};
+
+} // namespace Internal
+} // namespace CppEditor
+
+#endif // CPPCODEMODELINSPECTORDIALOG_H
diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.ui b/src/plugins/cppeditor/cppcodemodelinspectordialog.ui
new file mode 100644
index 0000000000..fbe95c08a7
--- /dev/null
+++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.ui
@@ -0,0 +1,381 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CppCodeModelInspectorDialog</class>
+ <widget class="QDialog" name="CppCodeModelInspectorDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>818</width>
+ <height>756</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string notr="true">C++ Code Model Inspector</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string notr="true">&amp;Snapshots and Documents</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="QSplitter" name="splitter">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="QWidget" name="layoutWidget">
+ <layout class="QVBoxLayout" name="snapshotSelectorAndViewLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="snapshotSelectorLabel">
+ <property name="text">
+ <string notr="true">Sn&amp;apshot:</string>
+ </property>
+ <property name="buddy">
+ <cstring>snapshotSelector</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="snapshotSelector">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>100</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QTabWidget" name="docTab">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab_8">
+ <attribute name="title">
+ <string notr="true">&amp;General</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QTreeView" name="docGeneralView">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="textElideMode">
+ <enum>Qt::ElideMiddle</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_7">
+ <attribute name="title">
+ <string notr="true">&amp;Includes</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QTreeView" name="docIncludesView">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="textElideMode">
+ <enum>Qt::ElideMiddle</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_6">
+ <attribute name="title">
+ <string notr="true">&amp;Diagnostic Messages</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_6">
+ <item>
+ <widget class="QTreeView" name="docDiagnosticMessagesView">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="textElideMode">
+ <enum>Qt::ElideMiddle</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_4">
+ <attribute name="title">
+ <string notr="true">(Un)Defined &amp;Macros</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_7">
+ <item>
+ <widget class="QTreeView" name="docDefinedMacrosView">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="textElideMode">
+ <enum>Qt::ElideMiddle</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_5">
+ <attribute name="title">
+ <string notr="true">P&amp;reprocessed Source</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <widget class="QPlainTextEdit" name="docPreprocessedSourceEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_9">
+ <attribute name="title">
+ <string notr="true">&amp;Symbols</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_8">
+ <item>
+ <widget class="QTreeView" name="docSymbolsView">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="textElideMode">
+ <enum>Qt::ElideMiddle</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_10">
+ <attribute name="title">
+ <string notr="true">&amp;Tokens</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_10">
+ <item>
+ <widget class="QTreeView" name="docTokensView">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="textElideMode">
+ <enum>Qt::ElideMiddle</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string notr="true">&amp;Project Parts</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_12">
+ <item>
+ <widget class="QSplitter" name="projectPartsSplitter">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="QTabWidget" name="projectPartTab">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab_17">
+ <attribute name="title">
+ <string notr="true">&amp;General</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_9">
+ <item>
+ <widget class="QTreeView" name="partGeneralView"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_13">
+ <attribute name="title">
+ <string notr="true">Project &amp;Files</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_14">
+ <item>
+ <widget class="QPlainTextEdit" name="partProjectFilesEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_14">
+ <attribute name="title">
+ <string notr="true">&amp;Defines</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_19">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string notr="true">Toolchain Defines</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_13">
+ <item>
+ <widget class="QPlainTextEdit" name="partToolchainDefinesEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string notr="true">Project Defines</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_15">
+ <item>
+ <widget class="QPlainTextEdit" name="partProjectDefinesEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_15">
+ <attribute name="title">
+ <string notr="true">&amp;Include Paths</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_16">
+ <item>
+ <widget class="QPlainTextEdit" name="partIncludePathsEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="definesTab_2">
+ <attribute name="title">
+ <string notr="true">F&amp;ramework Paths</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_17">
+ <item>
+ <widget class="QPlainTextEdit" name="partFrameworkPathsEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_16">
+ <attribute name="title">
+ <string notr="true">Pre&amp;compiled Headers</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_18">
+ <item>
+ <widget class="QPlainTextEdit" name="partPrecompiledHeadersEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_3">
+ <attribute name="title">
+ <string notr="true">&amp;Working Copy</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_11">
+ <item>
+ <widget class="QSplitter" name="workingCopySplitter">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="childrenCollapsible">
+ <bool>true</bool>
+ </property>
+ <widget class="QPlainTextEdit" name="workingCopySourceEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QPushButton" name="refreshButton">
+ <property name="text">
+ <string notr="true">&amp;Refresh</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="selectEditorRelevantEntriesAfterRefreshCheckBox">
+ <property name="text">
+ <string notr="true">Select &amp;editor relevant entries after refresh</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="closeButton">
+ <property name="text">
+ <string notr="true">Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/plugins/cppeditor/cppdoxygen_test.cpp b/src/plugins/cppeditor/cppdoxygen_test.cpp
index 94749370e5..d4a2ab9a94 100644
--- a/src/plugins/cppeditor/cppdoxygen_test.cpp
+++ b/src/plugins/cppeditor/cppdoxygen_test.cpp
@@ -28,12 +28,13 @@
****************************************************************************/
#include "cppeditor.h"
+#include "cppeditorplugin.h"
+#include "cppeditortestcase.h"
#include <coreplugin/editormanager/editormanager.h>
-#include <cplusplus/CppDocument.h>
-#include <cppeditor/cppeditor.h>
-#include <cppeditor/cppeditorplugin.h>
#include <cpptools/cppmodelmanagerinterface.h>
+
+#include <cplusplus/CppDocument.h>
#include <utils/fileutils.h>
#include <QCoreApplication>
@@ -58,89 +59,52 @@ typedef QByteArray _;
* Encapsulates the whole process of setting up an editor,
* pressing ENTER and checking the result.
*/
-struct TestCase
-{
- QByteArray originalText;
- int pos;
- CPPEditor *editor;
- CPPEditorWidget *editorWidget;
-
- TestCase(const QByteArray &input);
- ~TestCase();
-
- void run(const QByteArray &expected, int undoCount = 1);
-
-private:
- TestCase(const TestCase &);
- TestCase &operator=(const TestCase &);
-};
-
-/// The '|' in the input denotes the cursor position.
-TestCase::TestCase(const QByteArray &input)
- : originalText(input)
+class DoxygenTestCase : public CppEditor::Internal::Tests::TestCase
{
- pos = originalText.indexOf('|');
- QVERIFY(pos != -1);
- originalText.remove(pos, 1);
- QString fileName(QDir::tempPath() + QLatin1String("/file.cpp"));
- Utils::FileSaver srcSaver(fileName);
- srcSaver.write(originalText);
- srcSaver.finalize();
- CppTools::CppModelManagerInterface::instance()->updateSourceFiles(QStringList()<<fileName);
-
- // Wait for the parser in the future to give us the document
- while (true) {
- Snapshot s = CppTools::CppModelManagerInterface::instance()->snapshot();
- if (s.contains(fileName))
- break;
- QCoreApplication::processEvents();
+public:
+ /// The '|' in the input denotes the cursor position.
+ DoxygenTestCase(const QByteArray &original, const QByteArray &expected)
+ {
+ QVERIFY(succeededSoFar());
+
+ CppEditor::Internal::Tests::TestDocument testDocument("file.cpp", original, '|');
+ QVERIFY(testDocument.hasCursorMarker());
+ testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
+ QVERIFY(testDocument.writeToDisk());
+
+ // Update Code Model
+ QVERIFY(parseFiles(testDocument.filePath()));
+
+ // Open Editor
+ QVERIFY(openCppEditor(testDocument.filePath(), &testDocument.m_editor,
+ &testDocument.m_editorWidget));
+ closeEditorAtEndOfTestCase(testDocument.m_editor);
+
+ // We want to test documents that start with a comment. By default, the
+ // editor will fold the very first comment it encounters, assuming
+ // it is a license header. Currently unfoldAll() does not work as
+ // expected (some blocks are still hidden in some test cases, so the
+ // cursor movements are not as expected). For the time being, we just
+ // prepend a declaration before the initial test comment.
+ // testDocument.m_editorWidget->unfoldAll();
+ testDocument.m_editor->setCursorPosition(testDocument.m_cursorPosition);
+
+ waitForRehighlightedSemanticDocument(testDocument.m_editorWidget);
+
+ // Send 'ENTER' key press
+ QKeyEvent event(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
+ QCoreApplication::sendEvent(testDocument.m_editorWidget, &event);
+ const QByteArray result = testDocument.m_editorWidget->document()->toPlainText().toUtf8();
+
+ QCOMPARE(QLatin1String(result), QLatin1String(expected));
+
+ testDocument.m_editorWidget->undo();
+ const QByteArray contentsAfterUndo
+ = testDocument.m_editorWidget->document()->toPlainText().toUtf8();
+ QCOMPARE(contentsAfterUndo, testDocument.m_source);
}
+};
- editor = dynamic_cast<CPPEditor *>(EditorManager::openEditor(fileName));
- QVERIFY(editor);
- editorWidget = dynamic_cast<CPPEditorWidget *>(editor->editorWidget());
- QVERIFY(editorWidget);
-
- // We want to test documents that start with a comment. By default, the
- // editor will fold the very first comment it encounters, assuming
- // it is a license header. Currently unfoldAll() does not work as
- // expected (some blocks are still hidden in some test cases, so the
- // cursor movements are not as expected). For the time being, we just
- // prepend a declaration before the initial test comment.
-// editorWidget->unfoldAll();
- editor->setCursorPosition(pos);
-
- editorWidget->semanticRehighlight(true);
- // Wait for the semantic info from the future:
- while (editorWidget->semanticInfo().doc.isNull())
- QCoreApplication::processEvents();
-}
-
-TestCase::~TestCase()
-{
- EditorManager::closeEditor(editor, false);
- QCoreApplication::processEvents(); // process any pending events
-
- // Remove the test file from the code-model
- CppTools::CppModelManagerInterface *mmi = CppTools::CppModelManagerInterface::instance();
- mmi->GC();
- QCOMPARE(mmi->snapshot().size(), 0);
-}
-
-void TestCase::run(const QByteArray &expected, int undoCount)
-{
- // Send 'ENTER' key press
- QKeyEvent event(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
- QCoreApplication::sendEvent(editorWidget, &event);
- const QByteArray result = editorWidget->document()->toPlainText().toUtf8();
-
- QCOMPARE(QLatin1String(result), QLatin1String(expected));
-
- for (int i = 0; i < undoCount; ++i)
- editorWidget->undo();
- const QByteArray contentsAfterUndo = editorWidget->document()->toPlainText().toUtf8();
- QCOMPARE(contentsAfterUndo, originalText);
-}
} // anonymous namespace
void CppEditorPlugin::test_doxygen_comments_data()
@@ -286,6 +250,5 @@ void CppEditorPlugin::test_doxygen_comments()
{
QFETCH(QByteArray, given);
QFETCH(QByteArray, expected);
- TestCase data(given);
- data.run(expected);
+ DoxygenTestCase(given, expected);
}
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index f8264260ec..6dc61e9349 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -513,15 +513,27 @@ Q_GLOBAL_STATIC(CppTools::SymbolFinder, symbolFinder)
CPPEditorWidget::CPPEditorWidget(QWidget *parent)
: TextEditor::BaseTextEditorWidget(parent)
- , m_currentRenameSelection(NoCurrentRenameSelection)
- , m_inRename(false)
- , m_inRenameChanged(false)
- , m_firstRenameChange(false)
- , m_objcEnabled(false)
- , m_commentsSettings(CppTools::CppToolsSettings::instance()->commentsSettings())
- , m_followSymbolUnderCursor(new FollowSymbolUnderCursor(this))
- , m_preprocessorButton(0)
{
+ ctor();
+}
+
+CPPEditorWidget::CPPEditorWidget(CPPEditorWidget *other)
+ : TextEditor::BaseTextEditorWidget(other)
+{
+ ctor();
+}
+
+void CPPEditorWidget::ctor()
+{
+ m_currentRenameSelection = NoCurrentRenameSelection;
+ m_inRename = false;
+ m_inRenameChanged = false;
+ m_firstRenameChange = false;
+ m_objcEnabled = false;
+ m_commentsSettings = CppTools::CppToolsSettings::instance()->commentsSettings();
+ m_followSymbolUnderCursor.reset(new FollowSymbolUnderCursor(this));
+ m_preprocessorButton = 0;
+
qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo");
setParenthesesMatchingEnabled(true);
@@ -564,6 +576,13 @@ CPPEditorWidget::CPPEditorWidget(QWidget *parent)
SIGNAL(commentsSettingsChanged(CppTools::CommentsSettings)),
this,
SLOT(onCommentsSettingsChanged(CppTools::CommentsSettings)));
+
+ connect(baseTextDocument(), SIGNAL(filePathChanged(QString,QString)),
+ this, SLOT(onFilePathChanged()));
+ connect(baseTextDocument(), SIGNAL(mimeTypeChanged()),
+ this, SLOT(onMimeTypeChanged()));
+ onFilePathChanged();
+ onMimeTypeChanged();
}
CPPEditorWidget::~CPPEditorWidget()
@@ -640,7 +659,8 @@ void CPPEditorWidget::createToolBar(CPPEditor *editor)
connect(m_outlineCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateOutlineToolTip()));
// set up slots to document changes
- updateContentsChangedSignal();
+ connect(document(), SIGNAL(contentsChange(int,int,int)),
+ this, SLOT(onContentsChanged(int,int,int)));
// set up function declaration - definition link
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateFunctionDeclDefLink()));
@@ -705,27 +725,6 @@ void CPPEditorWidget::selectAll()
BaseTextEditorWidget::selectAll();
}
-void CPPEditorWidget::setMimeType(const QString &mt)
-{
- const QString &filePath = editor()->document()->filePath();
- const QString &projectFile = ProjectExplorer::SessionManager::value(
- QLatin1String(Constants::CPP_PREPROCESSOR_PROJECT_PREFIX) + filePath).toString();
- const QByteArray &additionalDirectives = ProjectExplorer::SessionManager::value(
- projectFile + QLatin1Char(',') + filePath).toString().toUtf8();
-
- QSharedPointer<SnapshotUpdater> updater
- = m_modelManager->cppEditorSupport(editor())->snapshotUpdater();
- updater->setProjectPart(m_modelManager->projectPartForProjectFile(projectFile));
- updater->setEditorDefines(additionalDirectives);
-
- m_preprocessorButton->setProperty("highlightWidget", !additionalDirectives.trimmed().isEmpty());
- m_preprocessorButton->update();
-
- BaseTextEditorWidget::setMimeType(mt);
- setObjCEnabled(mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)
- || mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
-}
-
void CPPEditorWidget::setObjCEnabled(bool onoff)
{
m_objcEnabled = onoff;
@@ -1077,7 +1076,7 @@ void CPPEditorWidget::updateOutlineNow()
return;
const Snapshot snapshot = m_modelManager->snapshot();
- Document::Ptr document = snapshot.document(editorDocument()->filePath());
+ Document::Ptr document = snapshot.document(baseTextDocument()->filePath());
if (!document)
return;
@@ -1203,6 +1202,9 @@ void CPPEditorWidget::finishHighlightSymbolUsages()
if (m_highlighter.isCanceled())
return; // aborted
+ else if (m_lastSemanticInfo.doc.isNull())
+ return;
+
TextEditor::SyntaxHighlighter *highlighter = baseTextDocument()->syntaxHighlighter();
QTC_ASSERT(highlighter, return);
@@ -1496,12 +1498,10 @@ void CPPEditorWidget::keyPressEvent(QKeyEvent *e)
finishRename();
}
-Core::IEditor *CPPEditor::duplicate(QWidget *parent)
+Core::IEditor *CPPEditor::duplicate()
{
- CPPEditorWidget *newEditor = new CPPEditorWidget(parent);
- newEditor->duplicateFrom(editorWidget());
- // A new QTextDocument was set, so update our signal/slot connection to the new document
- newEditor->updateContentsChangedSignal();
+ CPPEditorWidget *newEditor = new CPPEditorWidget(
+ qobject_cast<CPPEditorWidget *>(editorWidget()));
CppEditorPlugin::instance()->initializeEditor(newEditor);
return newEditor->editor();
}
@@ -1515,7 +1515,7 @@ bool CPPEditor::open(QString *errorString, const QString &fileName, const QStrin
{
if (!TextEditor::BaseTextEditor::open(errorString, fileName, realFileName))
return false;
- editorWidget()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
+ baseTextDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
return true;
}
@@ -1562,6 +1562,8 @@ void CPPEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
fs.toTextCharFormat(TextEditor::C_FUNCTION);
m_semanticHighlightFormatMap[CppHighlightingSupport::PseudoKeywordUse] =
fs.toTextCharFormat(TextEditor::C_KEYWORD);
+ m_semanticHighlightFormatMap[CppHighlightingSupport::StringUse] =
+ fs.toTextCharFormat(TextEditor::C_STRING);
m_keywordFormat = fs.toTextCharFormat(TextEditor::C_KEYWORD);
// only set the background, we do not want to modify foreground properties
@@ -1669,7 +1671,7 @@ void CPPEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo)
// We can use the semanticInfo's snapshot (and avoid locking), but not its
// document, since it doesn't contain expanded macros.
- LookupContext context(semanticInfo.snapshot.document(editorDocument()->filePath()),
+ LookupContext context(semanticInfo.snapshot.document(baseTextDocument()->filePath()),
semanticInfo.snapshot);
SemanticInfo::LocalUseIterator it(semanticInfo.localUses);
@@ -1838,14 +1840,41 @@ void CPPEditorWidget::onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefL
m_declDefLink = link;
Core::IDocument *targetDocument = Core::EditorManager::documentModel()->documentForFilePath(
m_declDefLink->targetFile->fileName());
- if (editorDocument() != targetDocument) {
- if (TextEditor::BaseTextDocument *baseTextDocument = qobject_cast<TextEditor::BaseTextDocument *>(targetDocument))
- connect(baseTextDocument->document(), SIGNAL(contentsChanged()),
+ if (baseTextDocument() != targetDocument) {
+ if (TextEditor::ITextEditorDocument *textEditorDocument = qobject_cast<TextEditor::ITextEditorDocument *>(targetDocument))
+ connect(textEditorDocument, SIGNAL(contentsChanged()),
this, SLOT(abortDeclDefLink()));
}
}
+void CPPEditorWidget::onFilePathChanged()
+{
+ QTC_ASSERT(m_modelManager, return);
+ QByteArray additionalDirectives;
+ const QString &filePath = baseTextDocument()->filePath();
+ if (!filePath.isEmpty()) {
+ const QString &projectFile = ProjectExplorer::SessionManager::value(
+ QLatin1String(Constants::CPP_PREPROCESSOR_PROJECT_PREFIX) + filePath).toString();
+ additionalDirectives = ProjectExplorer::SessionManager::value(
+ projectFile + QLatin1Char(',') + filePath).toString().toUtf8();
+
+ QSharedPointer<SnapshotUpdater> updater
+ = m_modelManager->cppEditorSupport(editor())->snapshotUpdater();
+ updater->setProjectPart(m_modelManager->projectPartForProjectFile(projectFile));
+ updater->setEditorDefines(additionalDirectives);
+ }
+ m_preprocessorButton->setProperty("highlightWidget", !additionalDirectives.trimmed().isEmpty());
+ m_preprocessorButton->update();
+}
+
+void CPPEditorWidget::onMimeTypeChanged()
+{
+ const QString &mt = baseTextDocument()->mimeType();
+ setObjCEnabled(mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)
+ || mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
+}
+
void CPPEditorWidget::applyDeclDefLinkChanges(bool jumpToMatch)
{
if (!m_declDefLink)
@@ -1855,12 +1884,6 @@ void CPPEditorWidget::applyDeclDefLinkChanges(bool jumpToMatch)
updateFunctionDeclDefLink();
}
-void CPPEditorWidget::updateContentsChangedSignal()
-{
- connect(document(), SIGNAL(contentsChange(int,int,int)),
- this, SLOT(onContentsChanged(int,int,int)));
-}
-
FollowSymbolUnderCursor *CPPEditorWidget::followSymbolUnderCursorDelegate()
{
return m_followSymbolUnderCursor.data();
@@ -1873,9 +1896,9 @@ void CPPEditorWidget::abortDeclDefLink()
Core::IDocument *targetDocument = Core::EditorManager::documentModel()->documentForFilePath(
m_declDefLink->targetFile->fileName());
- if (editorDocument() != targetDocument) {
- if (TextEditor::BaseTextDocument *baseTextDocument = qobject_cast<TextEditor::BaseTextDocument *>(targetDocument))
- disconnect(baseTextDocument->document(), SIGNAL(contentsChanged()),
+ if (baseTextDocument() != targetDocument) {
+ if (TextEditor::ITextEditorDocument *textEditorDocument = qobject_cast<TextEditor::ITextEditorDocument *>(targetDocument))
+ disconnect(textEditorDocument, SIGNAL(contentsChanged()),
this, SLOT(abortDeclDefLink()));
}
@@ -1990,7 +2013,7 @@ void CPPEditorWidget::showPreProcessorWidget()
if (projectParts.isEmpty())
projectParts << m_modelManager->fallbackProjectPart();
- CppPreProcessorDialog preProcessorDialog(this, projectParts);
+ CppPreProcessorDialog preProcessorDialog(this, baseTextDocument()->filePath(), projectParts);
if (preProcessorDialog.exec() == QDialog::Accepted) {
QSharedPointer<SnapshotUpdater> updater
= m_modelManager->cppEditorSupport(editor())->snapshotUpdater();
diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h
index 4a838ade7d..5e8fc642d6 100644
--- a/src/plugins/cppeditor/cppeditor.h
+++ b/src/plugins/cppeditor/cppeditor.h
@@ -78,7 +78,7 @@ public:
CPPEditor(CPPEditorWidget *);
bool duplicateSupported() const { return true; }
- Core::IEditor *duplicate(QWidget *parent);
+ Core::IEditor *duplicate();
Core::Id id() const;
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
@@ -97,7 +97,8 @@ class CPPEditorWidget : public TextEditor::BaseTextEditorWidget
public:
typedef TextEditor::TabSettings TabSettings;
- CPPEditorWidget(QWidget *parent);
+ CPPEditorWidget(QWidget *parent = 0);
+ CPPEditorWidget(CPPEditorWidget *other);
~CPPEditorWidget();
void unCommentSelection();
@@ -112,8 +113,6 @@ public:
virtual void cut(); // reimplemented from BaseTextEditorWidget
virtual void selectAll(); // reimplemented from BaseTextEditorWidget
- virtual void setMimeType(const QString &mt);
-
void setObjCEnabled(bool onoff);
bool isObjCEnabled() const;
@@ -130,8 +129,6 @@ public:
QSharedPointer<FunctionDeclDefLink> declDefLink() const;
void applyDeclDefLinkChanges(bool jumpToMatch);
- void updateContentsChangedSignal();
-
FollowSymbolUnderCursor *followSymbolUnderCursorDelegate(); // exposed for tests
Q_SIGNALS:
@@ -174,6 +171,8 @@ private Q_SLOTS:
void updateFunctionDeclDefLink();
void updateFunctionDeclDefLinkNow();
void onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefLink> link);
+ void onFilePathChanged();
+ void onMimeTypeChanged();
void onDocumentUpdated();
void onContentsChanged(int position, int charsRemoved, int charsAdded);
void updatePreprocessorButtonTooltip();
@@ -191,6 +190,8 @@ private Q_SLOTS:
void onCommentsSettingsChanged(const CppTools::CommentsSettings &settings);
private:
+ CPPEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
+ void ctor();
void markSymbols(const QTextCursor &tc, const CppTools::SemanticInfo &info);
bool sortedOutline() const;
diff --git a/src/plugins/cppeditor/cppeditor.pro b/src/plugins/cppeditor/cppeditor.pro
index 6257e2c165..3ab35cdf4c 100644
--- a/src/plugins/cppeditor/cppeditor.pro
+++ b/src/plugins/cppeditor/cppeditor.pro
@@ -1,37 +1,42 @@
DEFINES += CPPEDITOR_LIBRARY
include(../../qtcreatorplugin.pri)
-HEADERS += cppeditorplugin.h \
+
+HEADERS += \
cppautocompleter.h \
cppclasswizard.h \
+ cppcodemodelinspectordialog.h \
+ cppeditor.h \
+ cppeditor_global.h \
cppeditorconstants.h \
cppeditorenums.h \
- cppeditor_global.h \
- cppeditor.h \
+ cppeditorplugin.h \
cppelementevaluator.h \
cppfilewizard.h \
cppfollowsymbolundercursor.h \
cppfunctiondecldeflink.h \
- cpphighlighterfactory.h \
cpphighlighter.h \
+ cpphighlighterfactory.h \
cpphoverhandler.h \
+ cppincludehierarchy.h \
+ cppincludehierarchyitem.h \
+ cppincludehierarchymodel.h \
+ cppincludehierarchytreeview.h \
cppoutline.h \
+ cpppreprocessordialog.h \
+ cppquickfix.h \
cppquickfixassistant.h \
cppquickfixes.h \
- cppquickfix.h \
cppsnippetprovider.h \
cpptypehierarchy.h \
- cppincludehierarchy.h \
- cppincludehierarchymodel.h \
- cppincludehierarchyitem.h \
- cppincludehierarchytreeview.h \
cppvirtualfunctionassistprovider.h \
- cppvirtualfunctionproposalitem.h \
- cpppreprocessordialog.h
+ cppvirtualfunctionproposalitem.h
-SOURCES += cppeditorplugin.cpp \
+SOURCES += \
cppautocompleter.cpp \
cppclasswizard.cpp \
+ cppcodemodelinspectordialog.cpp \
cppeditor.cpp \
+ cppeditorplugin.cpp \
cppelementevaluator.cpp \
cppfilewizard.cpp \
cppfollowsymbolundercursor.cpp \
@@ -39,35 +44,38 @@ SOURCES += cppeditorplugin.cpp \
cpphighlighter.cpp \
cpphighlighterfactory.cpp \
cpphoverhandler.cpp \
+ cppincludehierarchy.cpp \
+ cppincludehierarchyitem.cpp \
+ cppincludehierarchymodel.cpp \
+ cppincludehierarchytreeview.cpp \
cppoutline.cpp \
- cppquickfixassistant.cpp \
+ cpppreprocessordialog.cpp \
cppquickfix.cpp \
+ cppquickfixassistant.cpp \
cppquickfixes.cpp \
cppsnippetprovider.cpp \
cpptypehierarchy.cpp \
- cppincludehierarchy.cpp \
- cppincludehierarchymodel.cpp \
- cppincludehierarchyitem.cpp \
- cppincludehierarchytreeview.cpp \
cppvirtualfunctionassistprovider.cpp \
- cppvirtualfunctionproposalitem.cpp \
- cpppreprocessordialog.cpp
+ cppvirtualfunctionproposalitem.cpp
-RESOURCES += cppeditor.qrc
+FORMS += \
+ cpppreprocessordialog.ui \
+ cppcodemodelinspectordialog.ui
-equals(TEST, 1) {
- HEADERS += cppquickfix_test_utils.h
+RESOURCES += \
+ cppeditor.qrc
+equals(TEST, 1) {
+ HEADERS += \
+ cppeditortestcase.h \
+ cppquickfix_test_utils.h
SOURCES += \
+ cppdoxygen_test.cpp \
+ cppeditortestcase.cpp \
+ cppincludehierarchy_test.cpp \
cppquickfix_test.cpp \
cppquickfix_test_utils.cpp \
- cppdoxygen_test.cpp \
fileandtokenactions_test.cpp \
- followsymbol_switchmethoddecldef_test.cpp \
- cppincludehierarchy_test.cpp
-
+ followsymbol_switchmethoddecldef_test.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
}
-
-FORMS += \
- cpppreprocessordialog.ui
diff --git a/src/plugins/cppeditor/cppeditor.qbs b/src/plugins/cppeditor/cppeditor.qbs
index a92808d279..8a2f724306 100644
--- a/src/plugins/cppeditor/cppeditor.qbs
+++ b/src/plugins/cppeditor/cppeditor.qbs
@@ -12,61 +12,38 @@ QtcPlugin {
Depends { name: "CPlusPlus" }
Depends { name: "TextEditor" }
Depends { name: "ProjectExplorer" }
+ Depends { name: "app_version_header" }
files: [
- "cppautocompleter.cpp",
- "cppautocompleter.h",
- "cppclasswizard.cpp",
- "cppclasswizard.h",
+ "cppautocompleter.cpp", "cppautocompleter.h",
+ "cppclasswizard.cpp", "cppclasswizard.h",
+ "cppcodemodelinspectordialog.cpp", "cppcodemodelinspectordialog.h", "cppcodemodelinspectordialog.ui",
+ "cppeditor.cpp", "cppeditor.h",
+ "cppeditor.qrc",
+ "cppeditor_global.h",
"cppeditorconstants.h",
- "cppeditor.cpp",
"cppeditorenums.h",
- "cppeditor_global.h",
- "cppeditor.h",
- "cppeditorplugin.cpp",
- "cppeditorplugin.h",
- "cppeditor.qrc",
- "cppelementevaluator.cpp",
- "cppelementevaluator.h",
- "cppfilewizard.cpp",
- "cppfilewizard.h",
- "cppfollowsymbolundercursor.cpp",
- "cppfollowsymbolundercursor.h",
- "cppfunctiondecldeflink.cpp",
- "cppfunctiondecldeflink.h",
- "cpphighlighter.cpp",
- "cpphighlighterfactory.cpp",
- "cpphighlighterfactory.h",
- "cpphighlighter.h",
- "cpphoverhandler.cpp",
- "cpphoverhandler.h",
- "cppincludehierarchy.cpp",
- "cppincludehierarchy.h",
- "cppincludehierarchyitem.cpp",
- "cppincludehierarchyitem.h",
- "cppincludehierarchymodel.cpp",
- "cppincludehierarchymodel.h",
- "cppincludehierarchytreeview.cpp",
- "cppincludehierarchytreeview.h",
- "cppoutline.cpp",
- "cppoutline.h",
- "cpppreprocessordialog.cpp",
- "cpppreprocessordialog.h",
- "cpppreprocessordialog.ui",
- "cppquickfixassistant.cpp",
- "cppquickfixassistant.h",
- "cppquickfix.cpp",
- "cppquickfixes.cpp",
- "cppquickfixes.h",
- "cppquickfix.h",
- "cppsnippetprovider.cpp",
- "cppsnippetprovider.h",
- "cpptypehierarchy.cpp",
- "cpptypehierarchy.h",
- "cppvirtualfunctionassistprovider.cpp",
- "cppvirtualfunctionassistprovider.h",
- "cppvirtualfunctionproposalitem.cpp",
- "cppvirtualfunctionproposalitem.h",
+ "cppeditorplugin.cpp", "cppeditorplugin.h",
+ "cppelementevaluator.cpp", "cppelementevaluator.h",
+ "cppfilewizard.cpp", "cppfilewizard.h",
+ "cppfollowsymbolundercursor.cpp", "cppfollowsymbolundercursor.h",
+ "cppfunctiondecldeflink.cpp", "cppfunctiondecldeflink.h",
+ "cpphighlighter.cpp", "cpphighlighter.h",
+ "cpphighlighterfactory.cpp", "cpphighlighterfactory.h",
+ "cpphoverhandler.cpp", "cpphoverhandler.h",
+ "cppincludehierarchy.cpp", "cppincludehierarchy.h",
+ "cppincludehierarchyitem.cpp", "cppincludehierarchyitem.h",
+ "cppincludehierarchymodel.cpp", "cppincludehierarchymodel.h",
+ "cppincludehierarchytreeview.cpp", "cppincludehierarchytreeview.h",
+ "cppoutline.cpp", "cppoutline.h",
+ "cpppreprocessordialog.cpp", "cpppreprocessordialog.h", "cpppreprocessordialog.ui",
+ "cppquickfix.cpp", "cppquickfix.h",
+ "cppquickfixassistant.cpp", "cppquickfixassistant.h",
+ "cppquickfixes.cpp", "cppquickfixes.h",
+ "cppsnippetprovider.cpp", "cppsnippetprovider.h",
+ "cpptypehierarchy.cpp", "cpptypehierarchy.h",
+ "cppvirtualfunctionassistprovider.cpp", "cppvirtualfunctionassistprovider.h",
+ "cppvirtualfunctionproposalitem.cpp", "cppvirtualfunctionproposalitem.h",
]
Group {
@@ -74,12 +51,13 @@ QtcPlugin {
condition: project.testsEnabled
files: [
"cppdoxygen_test.cpp",
+ "cppeditortestcase.cpp", "cppeditortestcase.h",
+ "cppincludehierarchy_test.cpp",
"cppquickfix_test.cpp",
"cppquickfix_test_utils.cpp",
"cppquickfix_test_utils.h",
"fileandtokenactions_test.cpp",
"followsymbol_switchmethoddecldef_test.cpp",
- "cppincludehierarchy_test.cpp",
]
cpp.defines: outer.concat(['SRCDIR="' + FileInfo.path(filePath) + '"'])
diff --git a/src/plugins/cppeditor/cppeditorconstants.h b/src/plugins/cppeditor/cppeditorconstants.h
index 18b10ec10d..324d614456 100644
--- a/src/plugins/cppeditor/cppeditorconstants.h
+++ b/src/plugins/cppeditor/cppeditorconstants.h
@@ -44,6 +44,7 @@ const char FIND_USAGES[] = "CppEditor.FindUsages";
const char OPEN_PREPROCESSOR_DIALOG[] = "CppEditor.OpenPreprocessorDialog";
const char M_REFACTORING_MENU_INSERTION_POINT[] = "CppEditor.RefactorGroup";
const char UPDATE_CODEMODEL[] = "CppEditor.UpdateCodeModel";
+const char INSPECT_CPP_CODEMODEL[] = "CppEditor.InspectCppCodeModel";
const int TYPE_HIERARCHY_PRIORITY = 700;
const char TYPE_HIERARCHY_ID[] = "CppEditor.TypeHierarchy";
diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp
index 2cfcaccf8b..505ffe9d17 100644
--- a/src/plugins/cppeditor/cppeditorplugin.cpp
+++ b/src/plugins/cppeditor/cppeditorplugin.cpp
@@ -42,6 +42,8 @@
#include "cppquickfixes.h"
#include "cpphighlighterfactory.h"
+#include "cppcodemodelinspectordialog.h"
+
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/coreconstants.h>
@@ -78,6 +80,12 @@ CppEditorFactory::CppEditorFactory(CppEditorPlugin *owner) :
addMimeType(CppEditor::Constants::CPP_SOURCE_MIMETYPE);
addMimeType(CppEditor::Constants::CPP_HEADER_MIMETYPE);
+ new TextEditor::TextEditorActionHandler(this, CppEditor::Constants::C_CPPEDITOR,
+ TextEditor::TextEditorActionHandler::Format
+ | TextEditor::TextEditorActionHandler::UnCommentSelection
+ | TextEditor::TextEditorActionHandler::UnCollapseAll
+ | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
+
if (!Utils::HostOsInfo::isMacHost() && !Utils::HostOsInfo::isWindowsHost()) {
FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_cpp.png", CppEditor::Constants::CPP_SOURCE_MIMETYPE);
FileIconProvider::registerIconOverlayForMimeType(":/cppeditor/images/qt_c.png", CppEditor::Constants::C_SOURCE_MIMETYPE);
@@ -85,9 +93,9 @@ CppEditorFactory::CppEditorFactory(CppEditorPlugin *owner) :
}
}
-IEditor *CppEditorFactory::createEditor(QWidget *parent)
+IEditor *CppEditorFactory::createEditor()
{
- CPPEditorWidget *editor = new CPPEditorWidget(parent);
+ CPPEditorWidget *editor = new CPPEditorWidget();
editor->setRevisionsVisible(true);
m_owner->initializeEditor(editor);
return editor->editor();
@@ -98,8 +106,7 @@ IEditor *CppEditorFactory::createEditor(QWidget *parent)
CppEditorPlugin *CppEditorPlugin::m_instance = 0;
CppEditorPlugin::CppEditorPlugin() :
- m_actionHandler(0),
- m_sortedOutline(false),
+ m_sortedOutline(true),
m_renameSymbolUnderCursorAction(0),
m_findUsagesAction(0),
m_reparseExternallyChangedFiles(0),
@@ -112,7 +119,6 @@ CppEditorPlugin::CppEditorPlugin() :
CppEditorPlugin::~CppEditorPlugin()
{
- delete m_actionHandler;
m_instance = 0;
}
@@ -123,8 +129,6 @@ CppEditorPlugin *CppEditorPlugin::instance()
void CppEditorPlugin::initializeEditor(CPPEditorWidget *editor)
{
- m_actionHandler->setupActions(editor);
-
editor->setLanguageSettingsId(CppTools::Constants::CPP_SETTINGS_ID);
TextEditor::TextEditorSettings::initializeEditor(editor);
@@ -285,13 +289,10 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
connect(m_reparseExternallyChangedFiles, SIGNAL(triggered()), cppModelManager, SLOT(updateModifiedSourceFiles()));
cppToolsMenu->addAction(cmd);
- m_actionHandler = new TextEditor::TextEditorActionHandler(CppEditor::Constants::C_CPPEDITOR,
- TextEditor::TextEditorActionHandler::Format
- | TextEditor::TextEditorActionHandler::UnCommentSelection
- | TextEditor::TextEditorActionHandler::UnCollapseAll
- | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
-
- m_actionHandler->initializeActions();
+ QAction *inspectCppCodeModel = new QAction(tr("Debug: Inspect C++ Code Model"), this);
+ cmd = ActionManager::registerAction(inspectCppCodeModel, Constants::INSPECT_CPP_CODEMODEL, globalContext);
+ cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Shift+F12") : tr("Ctrl+Shift+F12")));
+ connect(inspectCppCodeModel, SIGNAL(triggered()), this, SLOT(inspectCppCodeModel()));
contextMenu->addSeparator(context);
@@ -306,16 +307,13 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
connect(ProgressManager::instance(), SIGNAL(allTasksFinished(Core::Id)),
this, SLOT(onAllTasksFinished(Core::Id)));
- connect(EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
- SLOT(currentEditorChanged(Core::IEditor*)));
-
readSettings();
return true;
}
void CppEditorPlugin::readSettings()
{
- m_sortedOutline = ICore::settings()->value(QLatin1String("CppTools/SortedMethodOverview"), false).toBool();
+ m_sortedOutline = ICore::settings()->value(QLatin1String("CppTools/SortedMethodOverview"), true).toBool();
}
void CppEditorPlugin::writeSettings()
@@ -390,13 +388,14 @@ void CppEditorPlugin::onAllTasksFinished(Core::Id type)
}
}
-void CppEditorPlugin::currentEditorChanged(IEditor *editor)
+void CppEditorPlugin::inspectCppCodeModel()
{
- if (!editor)
- return;
-
- if (CPPEditorWidget *editorWidget = currentCppEditorWidget())
- editorWidget->semanticRehighlight(/*force = */ true);
+ if (m_cppCodeModelInspectorDialog) {
+ ICore::raiseWindow(m_cppCodeModelInspectorDialog);
+ } else {
+ m_cppCodeModelInspectorDialog = new CppCodeModelInspectorDialog(ICore::mainWindow());
+ m_cppCodeModelInspectorDialog->show();
+ }
}
void CppEditorPlugin::openTypeHierarchy()
diff --git a/src/plugins/cppeditor/cppeditorplugin.h b/src/plugins/cppeditor/cppeditorplugin.h
index b460436955..998c6ca952 100644
--- a/src/plugins/cppeditor/cppeditorplugin.h
+++ b/src/plugins/cppeditor/cppeditorplugin.h
@@ -38,7 +38,6 @@
#include <QAction>
namespace TextEditor {
-class TextEditorActionHandler;
class ITextEditor;
} // namespace TextEditor
@@ -46,6 +45,7 @@ namespace CppEditor {
namespace Internal {
class CPPEditorWidget;
+class CppCodeModelInspectorDialog;
class CppQuickFixCollector;
class CppQuickFixAssistProvider;
@@ -90,7 +90,7 @@ public slots:
private slots:
void onTaskStarted(Core::Id type);
void onAllTasksFinished(Core::Id type);
- void currentEditorChanged(Core::IEditor *editor);
+ void inspectCppCodeModel();
#ifdef WITH_TESTS
private slots:
@@ -143,6 +143,7 @@ private slots:
void test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile1();
void test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile2();
void test_quickfix_InsertDefFromDecl_erroneousStatementAtEndOfFile();
+ void test_quickfix_InsertDefFromDecl_rvalueReference();
void test_quickfix_InsertDeclFromDef();
@@ -207,9 +208,6 @@ private slots:
void test_quickfix_InsertVirtualMethods_implementationFile();
void test_quickfix_InsertVirtualMethods_BaseClassInNamespace();
- void test_functionhelper_virtualFunctions();
- void test_functionhelper_virtualFunctions_data();
-
// tests for "Include Hiererchy"
void test_includeHierarchyModel_simpleIncludes();
void test_includeHierarchyModel_simpleIncludedBy();
@@ -236,7 +234,6 @@ private:
static CppEditorPlugin *m_instance;
- TextEditor::TextEditorActionHandler *m_actionHandler;
bool m_sortedOutline;
QAction *m_renameSymbolUnderCursorAction;
QAction *m_findUsagesAction;
@@ -246,6 +243,8 @@ private:
CppQuickFixAssistProvider *m_quickFixProvider;
+ QPointer<CppCodeModelInspectorDialog> m_cppCodeModelInspectorDialog;
+
QPointer<TextEditor::ITextEditor> m_currentEditor;
};
@@ -256,7 +255,7 @@ class CppEditorFactory : public Core::IEditorFactory
public:
CppEditorFactory(CppEditorPlugin *owner);
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
private:
CppEditorPlugin *m_owner;
diff --git a/src/plugins/cppeditor/cppeditortestcase.cpp b/src/plugins/cppeditor/cppeditortestcase.cpp
new file mode 100644
index 0000000000..ea24125488
--- /dev/null
+++ b/src/plugins/cppeditor/cppeditortestcase.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+
+#include "cppeditortestcase.h"
+
+#include "cppeditor.h"
+
+#include <coreplugin/editormanager/editormanager.h>
+#include <cplusplus/CppDocument.h>
+
+#include <QDir>
+
+namespace CppEditor {
+namespace Internal {
+namespace Tests {
+
+TestDocument::TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker)
+ : CppTools::Tests::TestDocument(fileName, source, cursorMarker)
+ , m_cursorPosition(source.indexOf(m_cursorMarker))
+ , m_editor(0)
+ , m_editorWidget(0)
+{
+}
+
+bool TestDocument::hasCursorMarker() const { return m_cursorPosition != -1; }
+
+TestCase::TestCase(bool runGarbageCollector)
+ : CppTools::Tests::TestCase(runGarbageCollector)
+{
+}
+
+TestCase::~TestCase()
+{
+}
+
+bool TestCase::openCppEditor(const QString &fileName,
+ Internal::CPPEditor **editor,
+ Internal::CPPEditorWidget **editorWidget)
+{
+ using namespace CppEditor::Internal;
+ if (CPPEditor *e = dynamic_cast<CPPEditor *>(Core::EditorManager::openEditor(fileName))) {
+ if (editor)
+ *editor = e;
+ if (editorWidget) {
+ if (CPPEditorWidget *w = dynamic_cast<CPPEditorWidget *>(e->editorWidget())) {
+ *editorWidget = w;
+ return true;
+ } else {
+ return false; // no or wrong widget
+ }
+ } else {
+ return true; // ok since no widget requested
+ }
+ } else {
+ return false; // no or wrong editor
+ }
+}
+
+CPlusPlus::Document::Ptr TestCase::waitForRehighlightedSemanticDocument(
+ Internal::CPPEditorWidget *editorWidget)
+{
+ editorWidget->semanticRehighlight(true);
+ while (editorWidget->semanticInfo().doc.isNull())
+ QCoreApplication::processEvents();
+ return editorWidget->semanticInfo().doc;
+}
+
+} // namespace Tests
+} // namespace Internal
+} // namespace CppEditor
diff --git a/src/plugins/cppeditor/cppeditortestcase.h b/src/plugins/cppeditor/cppeditortestcase.h
new file mode 100644
index 0000000000..76f3e49239
--- /dev/null
+++ b/src/plugins/cppeditor/cppeditortestcase.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+
+#ifndef CPPEDITORTESTCASE_H
+#define CPPEDITORTESTCASE_H
+
+#include <cpptools/cpptoolstestcase.h>
+
+namespace CppEditor {
+
+namespace Internal {
+class CPPEditor;
+class CPPEditorWidget;
+
+namespace Tests {
+
+class TestDocument : public CppTools::Tests::TestDocument
+{
+public:
+ TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker = '@');
+
+ bool hasCursorMarker() const;
+
+public:
+ int m_cursorPosition;
+ Internal::CPPEditor *m_editor;
+ Internal::CPPEditorWidget *m_editorWidget;
+};
+
+class TestCase : public CppTools::Tests::TestCase
+{
+public:
+ TestCase(bool runGarbageCollector = true);
+ ~TestCase();
+
+ static bool openCppEditor(const QString &fileName,
+ Internal::CPPEditor **editor,
+ Internal::CPPEditorWidget **editorWidget = 0);
+
+ static CPlusPlus::Document::Ptr waitForRehighlightedSemanticDocument(
+ Internal::CPPEditorWidget *editorWidget);
+};
+
+} // namespace Tests
+} // namespace Internal
+} // namespace CppEditor
+
+#endif // CPPEDITORTESTCASE_H
diff --git a/src/plugins/cppeditor/cppelementevaluator.cpp b/src/plugins/cppeditor/cppelementevaluator.cpp
index 50bc7cc7d5..0da38d6958 100644
--- a/src/plugins/cppeditor/cppelementevaluator.cpp
+++ b/src/plugins/cppeditor/cppelementevaluator.cpp
@@ -85,7 +85,7 @@ void CppElementEvaluator::execute()
return;
const Snapshot &snapshot = m_modelManager->snapshot();
- Document::Ptr doc = snapshot.document(m_editor->editorDocument()->filePath());
+ Document::Ptr doc = snapshot.document(m_editor->baseTextDocument()->filePath());
if (!doc)
return;
diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
index d16e7917b2..f1ad1f8bf4 100644
--- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
+++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
@@ -39,6 +39,7 @@
#include <cplusplus/SimpleLexer.h>
#include <cplusplus/TypeOfExpression.h>
#include <cpptools/cppmodelmanagerinterface.h>
+#include <cpptools/functionutils.h>
#include <cpptools/symbolfinder.h>
#include <texteditor/basetextdocumentlayout.h>
#include <utils/qtcassert.h>
@@ -78,7 +79,6 @@ private:
private:
// Provided
- const QSharedPointer<TypeOfExpression> m_typeOfExpression;
const Document::Ptr m_expressionDocument;
Scope *m_scope;
const Document::Ptr &m_document;
@@ -128,11 +128,13 @@ bool VirtualFunctionHelper::canLookupVirtualFunctionOverrides(Function *function
if (IdExpressionAST *idExpressionAST = m_baseExpressionAST->asIdExpression()) {
NameAST *name = idExpressionAST->name;
const bool nameIsQualified = name && name->asQualifiedName();
- result = !nameIsQualified && FunctionHelper::isVirtualFunction(function, m_snapshot);
+ result = !nameIsQualified && FunctionUtils::isVirtualFunction(
+ function, LookupContext(m_document, m_snapshot));
} else if (MemberAccessAST *memberAccessAST = m_baseExpressionAST->asMemberAccess()) {
NameAST *name = memberAccessAST->member_name;
const bool nameIsQualified = name && name->asQualifiedName();
- if (!nameIsQualified && FunctionHelper::isVirtualFunction(function, m_snapshot)) {
+ if (!nameIsQualified && FunctionUtils::isVirtualFunction(
+ function, LookupContext(m_document, m_snapshot))) {
TranslationUnit *unit = m_expressionDocument->translationUnit();
QTC_ASSERT(unit, return false);
m_accessTokenKind = unit->tokenKind(memberAccessAST->access_token);
@@ -541,7 +543,7 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &
}
// Now we prefer the doc from the snapshot with macros expanded.
- Document::Ptr doc = snapshot.document(m_widget->editorDocument()->filePath());
+ Document::Ptr doc = snapshot.document(m_widget->baseTextDocument()->filePath());
if (!doc) {
doc = documentFromSemanticInfo;
if (!doc)
@@ -636,7 +638,7 @@ BaseTextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &
if (Symbol *d = r.declaration()) {
if (d->isDeclaration() || d->isFunction()) {
const QString fileName = QString::fromUtf8(d->fileName(), d->fileNameLength());
- if (m_widget->editorDocument()->filePath() == fileName) {
+ if (m_widget->baseTextDocument()->filePath() == fileName) {
if (unsigned(lineNumber) == d->line()
&& unsigned(positionInBlock) >= d->column()) { // TODO: check the end
result = r; // take the symbol under cursor.
diff --git a/src/plugins/cppeditor/cppincludehierarchy.cpp b/src/plugins/cppeditor/cppincludehierarchy.cpp
index ba755a157d..2806b0c011 100644
--- a/src/plugins/cppeditor/cppincludehierarchy.cpp
+++ b/src/plugins/cppeditor/cppincludehierarchy.cpp
@@ -142,12 +142,12 @@ void CppIncludeHierarchyWidget::perform()
return;
m_model->clear();
- m_model->buildHierarchy(m_editor, widget->editorDocument()->filePath());
+ m_model->buildHierarchy(m_editor, widget->baseTextDocument()->filePath());
if (m_model->isEmpty())
return;
- m_inspectedFile->setup(widget->editorDocument()->displayName(),
- widget->editorDocument()->filePath());
+ m_inspectedFile->setup(widget->baseTextDocument()->displayName(),
+ widget->baseTextDocument()->filePath());
//expand "Includes"
m_treeView->expand(m_model->index(0, 0));
diff --git a/src/plugins/cppeditor/cppincludehierarchy_test.cpp b/src/plugins/cppeditor/cppincludehierarchy_test.cpp
index f10cd3ba5d..bd95012692 100644
--- a/src/plugins/cppeditor/cppincludehierarchy_test.cpp
+++ b/src/plugins/cppeditor/cppincludehierarchy_test.cpp
@@ -28,6 +28,7 @@
****************************************************************************/
#include "cppeditorplugin.h"
+#include "cppeditortestcase.h"
#include "cppincludehierarchymodel.h"
#include <coreplugin/editormanager/editormanager.h>
@@ -44,13 +45,16 @@ using namespace CppEditor::Internal;
using namespace CppTools;
namespace {
-class TestCase
+
+class IncludeHierarchyTestCase: public CppEditor::Internal::Tests::TestCase
{
public:
- TestCase(const QList<QByteArray> &sourceList)
- : m_cmm(CppModelManagerInterface::instance())
- , m_editor(0)
+ IncludeHierarchyTestCase(const QList<QByteArray> &sourceList,
+ int includesCount,
+ int includedByCount)
{
+ QVERIFY(succeededSoFar());
+
QStringList filePaths;
const int sourceListSize = sourceList.size();
for (int i = 0; i < sourceListSize; ++i) {
@@ -59,58 +63,29 @@ public:
// Write source to file
const QString fileName = QString::fromLatin1("%1/file%2.h").arg(QDir::tempPath())
.arg(i+1);
- Utils::FileSaver srcSaver(fileName);
- srcSaver.write(source);
- srcSaver.finalize();
+ QVERIFY(writeFile(fileName, source));
filePaths << fileName;
}
// Update Code Model
- m_cmm->updateSourceFiles(filePaths);
-
- // Wait for the parser in the future to give us the document
- QStringList filePathsNotYetInSnapshot(filePaths);
- forever {
- const Snapshot snapshot = m_cmm->snapshot();
- foreach (const QString &filePath, filePathsNotYetInSnapshot) {
- if (snapshot.contains(filePath))
- filePathsNotYetInSnapshot.removeOne(filePath);
- }
- if (filePathsNotYetInSnapshot.isEmpty())
- break;
- QCoreApplication::processEvents();
- }
- }
+ QVERIFY(parseFiles(filePaths));
- ~TestCase()
- {
- // Close editor
- if (m_editor)
- Core::EditorManager::closeEditor(m_editor, false);
-
- m_cmm->GC();
- QVERIFY(m_cmm->snapshot().isEmpty());
- }
-
- void run(int includesCount, int includedByCount)
- {
+ // Open Editor
const QString fileName = QDir::tempPath() + QLatin1String("/file1.h");
+ CPPEditor *editor;
+ QVERIFY(openCppEditor(fileName, &editor));
+ closeEditorAtEndOfTestCase(editor);
- m_editor = qobject_cast<CPPEditor *>(Core::EditorManager::openEditor(fileName));
- QVERIFY(m_editor);
-
+ // Test model
CppIncludeHierarchyModel model(0);
- model.buildHierarchy(m_editor, fileName);
+ model.buildHierarchy(editor, fileName);
QCOMPARE(model.rowCount(model.index(0, 0)), includesCount);
QCOMPARE(model.rowCount(model.index(1, 0)), includedByCount);
}
-
-private:
- CppModelManagerInterface *m_cmm;
- CPPEditor *m_editor;
};
-}
+
+} // anonymous namespace
void CppEditorPlugin::test_includeHierarchyModel_simpleIncludes()
{
@@ -118,8 +93,7 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludes()
sourceList.append(QByteArray("#include \"file2.h\"\n"));
sourceList.append(QByteArray());
- TestCase testCase(sourceList);
- testCase.run(1, 0);
+ IncludeHierarchyTestCase(sourceList, 1, 0);
}
void CppEditorPlugin::test_includeHierarchyModel_simpleIncludedBy()
@@ -128,18 +102,15 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludedBy()
sourceList.append(QByteArray());
sourceList.append(QByteArray("#include \"file1.h\"\n"));
- TestCase testCase(sourceList);
- testCase.run(0, 1);
+ IncludeHierarchyTestCase(sourceList, 0, 1);
}
void CppEditorPlugin::test_includeHierarchyModel_simpleIncludesAndIncludedBy()
{
QList<QByteArray> sourceList;
- QByteArray source;
sourceList.append(QByteArray("#include \"file2.h\"\n"));
sourceList.append(QByteArray());
sourceList.append(QByteArray("#include \"file1.h\"\n"));
- TestCase testCase(sourceList);
- testCase.run(1, 1);
+ IncludeHierarchyTestCase(sourceList, 1, 1);
}
diff --git a/src/plugins/cppeditor/cpppreprocessordialog.cpp b/src/plugins/cppeditor/cpppreprocessordialog.cpp
index 3a53f30231..0366069ae6 100644
--- a/src/plugins/cppeditor/cpppreprocessordialog.cpp
+++ b/src/plugins/cppeditor/cpppreprocessordialog.cpp
@@ -30,7 +30,6 @@
#include "cpppreprocessordialog.h"
#include "ui_cpppreprocessordialog.h"
-#include "cppeditor.h"
#include "cppeditorconstants.h"
#include "cppsnippetprovider.h"
@@ -44,11 +43,11 @@ static bool projectPartLessThan(const CppTools::ProjectPart::Ptr &projectPart1,
return projectPart1->displayName < projectPart2->displayName;
}
-CppPreProcessorDialog::CppPreProcessorDialog(CPPEditorWidget *editorWidget,
+CppPreProcessorDialog::CppPreProcessorDialog(QWidget *parent, const QString &filePath,
const QList<CppTools::ProjectPart::Ptr> &projectParts)
- : QDialog(editorWidget)
+ : QDialog(parent)
, m_ui(new Ui::CppPreProcessorDialog())
- , m_filePath(editorWidget->editor()->document()->filePath())
+ , m_filePath(filePath)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
diff --git a/src/plugins/cppeditor/cpppreprocessordialog.h b/src/plugins/cppeditor/cpppreprocessordialog.h
index 25c701fe62..07fd30281b 100644
--- a/src/plugins/cppeditor/cpppreprocessordialog.h
+++ b/src/plugins/cppeditor/cpppreprocessordialog.h
@@ -38,14 +38,12 @@ namespace CppEditor {
namespace Internal {
namespace Ui { class CppPreProcessorDialog; }
-class CPPEditorWidget;
-
class CppPreProcessorDialog : public QDialog
{
Q_OBJECT
public:
- explicit CppPreProcessorDialog(CPPEditorWidget *editorWidget,
+ explicit CppPreProcessorDialog(QWidget *parent, const QString &filePath,
const QList<CppTools::ProjectPart::Ptr> &projectParts);
~CppPreProcessorDialog();
diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp
index 7b6bb4e0e7..1a87985f17 100644
--- a/src/plugins/cppeditor/cppquickfix_test.cpp
+++ b/src/plugins/cppeditor/cppquickfix_test.cpp
@@ -31,13 +31,14 @@
#include "cppeditor.h"
#include "cppeditorplugin.h"
+#include "cppeditortestcase.h"
#include "cppquickfixassistant.h"
#include "cppquickfixes.h"
#include <cpptools/cppcodestylepreferences.h>
#include <cpptools/cppmodelmanager.h>
-#include <cpptools/cpppreprocessor.h>
#include <cpptools/cpppreprocessertesthelper.h>
+#include <cpptools/cpppreprocessor.h>
#include <cpptools/cpptoolssettings.h>
#include <cpptools/includeutils.h>
@@ -58,6 +59,8 @@ using namespace CppTools;
using namespace IncludeUtils;
using namespace TextEditor;
+using CppTools::Tests::TestIncludePaths;
+
namespace {
typedef QByteArray _;
@@ -68,97 +71,68 @@ typedef QSharedPointer<TestDocument> TestDocumentPtr;
/**
* Represents a test document before and after applying the quick fix.
*
- * A TestDocument's originalSource may contain an '@' character to denote
+ * A TestDocument's source may contain an '@' character to denote
* the cursor position. This marker is removed before the Editor reads
* the document.
*/
-class TestDocument
+class TestDocument : public CppEditor::Internal::Tests::TestDocument
{
public:
- TestDocument(const QByteArray &theOriginalSource, const QByteArray &theExpectedSource,
- const QString &fileName)
- : originalSource(theOriginalSource)
- , expectedSource(theExpectedSource)
- , fileName(fileName)
- , cursorMarkerPosition(theOriginalSource.indexOf('@'))
- , editor(0)
- , editorWidget(0)
+ TestDocument(const QByteArray &fileName, const QByteArray &source,
+ const QByteArray &expectedSource)
+ : CppEditor::Internal::Tests::TestDocument(fileName, source)
+ , m_expectedSource(expectedSource)
{
- originalSource.remove(cursorMarkerPosition, 1);
- expectedSource.remove(theExpectedSource.indexOf('@'), 1);
+ m_source.remove(m_cursorPosition, 1);
+ m_expectedSource.remove(expectedSource.indexOf(m_cursorMarker), 1);
}
- static TestDocumentPtr create(const QByteArray &theOriginalSource,
- const QByteArray &theExpectedSource,const QString &fileName)
+ static TestDocumentPtr create(const QByteArray &fileName, const QByteArray &source,
+ const QByteArray &expectedSource)
{
- return TestDocumentPtr(new TestDocument(theOriginalSource, theExpectedSource, fileName));
+ return TestDocumentPtr(new TestDocument(fileName, source, expectedSource));
}
- bool hasCursorMarkerPosition() const { return cursorMarkerPosition != -1; }
- bool changesExpected() const { return originalSource != expectedSource; }
-
- QString filePath() const
- {
- if (!QFileInfo(fileName).isAbsolute())
- return QDir::tempPath() + QLatin1Char('/') + fileName;
- return fileName;
- }
-
- void writeToDisk() const
- {
- Utils::FileSaver srcSaver(filePath());
- srcSaver.write(originalSource);
- srcSaver.finalize();
- }
-
- QByteArray originalSource;
- QByteArray expectedSource;
-
- const QString fileName;
- const int cursorMarkerPosition;
-
- CPPEditor *editor;
- CPPEditorWidget *editorWidget;
+public:
+ QByteArray m_expectedSource;
};
+QList<TestDocumentPtr> singleDocument(const QByteArray &original, const QByteArray &expected)
+{
+ return QList<TestDocumentPtr>() << TestDocument::create("file.cpp", original, expected);
+}
+
/**
* Encapsulates the whole process of setting up an editor, getting the
* quick-fix, applying it, and checking the result.
*/
-class TestCase
+class QuickFixTestCase : public CppEditor::Internal::Tests::TestCase
{
public:
- TestCase(const QByteArray &originalSource, const QByteArray &expectedSource,
- const QStringList &includePaths = QStringList());
- TestCase(const QList<TestDocumentPtr> theTestFiles,
- const QStringList &includePaths = QStringList());
- ~TestCase();
+ QuickFixTestCase(const QList<TestDocumentPtr> theTestFiles,
+ CppQuickFixFactory *factory,
+ const QStringList &includePaths = QStringList(),
+ int resultIndex = 0);
+ ~QuickFixTestCase();
+private:
QuickFixOperation::Ptr getFix(CppQuickFixFactory *factory, CPPEditorWidget *editorWidget,
int resultIndex = 0);
- TestDocumentPtr testFileWithCursorMarker() const;
-
- void run(CppQuickFixFactory *factory, int resultIndex = 0);
-
-private:
- TestCase(const TestCase &);
- TestCase &operator=(const TestCase &);
-
- void init(const QStringList &includePaths);
private:
- QList<TestDocumentPtr> testFiles;
+ QList<TestDocumentPtr> m_testFiles;
- CppCodeStylePreferences *cppCodeStylePreferences;
- QByteArray cppCodeStylePreferencesOriginalDelegateId;
+ CppCodeStylePreferences *m_cppCodeStylePreferences;
+ QByteArray m_cppCodeStylePreferencesOriginalDelegateId;
- QStringList includePathsToRestore;
- bool restoreIncludePaths;
+ QStringList m_includePathsToRestore;
+ bool m_restoreIncludePaths;
};
/// Apply the factory on the source and get back the resultIndex'th result or a null pointer.
-QuickFixOperation::Ptr TestCase::getFix(CppQuickFixFactory *factory, CPPEditorWidget *editorWidget,
- int resultIndex)
+QuickFixOperation::Ptr QuickFixTestCase::getFix(CppQuickFixFactory *factory,
+ CPPEditorWidget *editorWidget,
+ int resultIndex)
{
CppQuickFixInterface qfi(new CppQuickFixAssistInterface(editorWidget, ExplicitlyInvoked));
TextEditor::QuickFixOperations results;
@@ -166,172 +140,128 @@ QuickFixOperation::Ptr TestCase::getFix(CppQuickFixFactory *factory, CPPEditorWi
return results.isEmpty() ? QuickFixOperation::Ptr() : results.at(resultIndex);
}
-/// The '@' in the originalSource is the position from where the quick-fix discovery is triggered.
-TestCase::TestCase(const QByteArray &originalSource, const QByteArray &expectedSource,
- const QStringList &includePaths)
- : cppCodeStylePreferences(0), restoreIncludePaths(false)
+/// Leading whitespace is not removed, so we can check if the indetation ranges
+/// have been set correctly by the quick-fix.
+QByteArray &removeTrailingWhitespace(QByteArray &input)
{
- testFiles << TestDocument::create(originalSource, expectedSource, QLatin1String("file.cpp"));
- init(includePaths);
+ QList<QByteArray> lines = input.split('\n');
+ input.resize(0);
+ foreach (QByteArray line, lines) {
+ while (line.length() > 0) {
+ char lastChar = line[line.length() - 1];
+ if (lastChar == ' ' || lastChar == '\t')
+ line = line.left(line.length() - 1);
+ else
+ break;
+ }
+ input.append(line);
+ input.append('\n');
+ }
+ return input;
}
+/// The '@' in the originalSource is the position from where the quick-fix discovery is triggered.
/// Exactly one TestFile must contain the cursor position marker '@' in the originalSource.
-TestCase::TestCase(const QList<TestDocumentPtr> theTestFiles, const QStringList &includePaths)
- : testFiles(theTestFiles), cppCodeStylePreferences(0), restoreIncludePaths(false)
+QuickFixTestCase::QuickFixTestCase(const QList<TestDocumentPtr> theTestFiles,
+ CppQuickFixFactory *factory,
+ const QStringList &includePaths,
+ int resultIndex)
+ : m_testFiles(theTestFiles)
+ , m_cppCodeStylePreferences(0)
+ , m_restoreIncludePaths(false)
{
- init(includePaths);
-}
+ QVERIFY(succeededSoFar());
-void TestCase::init(const QStringList &includePaths)
-{
// Check if there is exactly one cursor marker
unsigned cursorMarkersCount = 0;
- foreach (const TestDocumentPtr testFile, testFiles) {
- if (testFile->hasCursorMarkerPosition())
+ foreach (const TestDocumentPtr testFile, m_testFiles) {
+ if (testFile->hasCursorMarker())
++cursorMarkersCount;
}
QVERIFY2(cursorMarkersCount == 1, "Exactly one cursor marker is allowed.");
// Write files to disk
- foreach (TestDocumentPtr testFile, testFiles)
+ foreach (TestDocumentPtr testFile, m_testFiles)
testFile->writeToDisk();
- CppTools::Internal::CppModelManager *cmm = CppTools::Internal::CppModelManager::instance();
-
// Set appropriate include paths
if (!includePaths.isEmpty()) {
- restoreIncludePaths = true;
- includePathsToRestore = cmm->includePaths();
- cmm->setIncludePaths(includePaths);
+ m_restoreIncludePaths = true;
+ m_includePathsToRestore = m_modelManager->includePaths();
+ m_modelManager->setIncludePaths(includePaths);
}
// Update Code Model
QStringList filePaths;
- foreach (const TestDocumentPtr &testFile, testFiles)
+ foreach (const TestDocumentPtr &testFile, m_testFiles)
filePaths << testFile->filePath();
- cmm->updateSourceFiles(filePaths);
-
- // Wait for the parser in the future to give us the document
- QStringList filePathsNotYetInSnapshot(filePaths);
- forever {
- Snapshot snapshot = cmm->snapshot();
- foreach (const QString &filePath, filePathsNotYetInSnapshot) {
- if (snapshot.contains(filePath))
- filePathsNotYetInSnapshot.removeOne(filePath);
- }
- if (filePathsNotYetInSnapshot.isEmpty())
- break;
- QCoreApplication::processEvents();
- }
+ QVERIFY(parseFiles(filePaths));
// Open Files
- foreach (TestDocumentPtr testFile, testFiles) {
- testFile->editor
- = dynamic_cast<CPPEditor *>(EditorManager::openEditor(testFile->filePath()));
- QVERIFY(testFile->editor);
+ foreach (TestDocumentPtr testFile, m_testFiles) {
+ QVERIFY(openCppEditor(testFile->filePath(), &testFile->m_editor,
+ &testFile->m_editorWidget));
+ closeEditorAtEndOfTestCase(testFile->m_editor);
// Set cursor position
- const int cursorPosition = testFile->hasCursorMarkerPosition()
- ? testFile->cursorMarkerPosition : 0;
- testFile->editor->setCursorPosition(cursorPosition);
-
- testFile->editorWidget = dynamic_cast<CPPEditorWidget *>(testFile->editor->editorWidget());
- QVERIFY(testFile->editorWidget);
+ const int cursorPosition = testFile->hasCursorMarker()
+ ? testFile->m_cursorPosition : 0;
+ testFile->m_editor->setCursorPosition(cursorPosition);
// Rehighlight
- testFile->editorWidget->semanticRehighlight(true);
- // Wait for the semantic info from the future
- while (testFile->editorWidget->semanticInfo().doc.isNull())
- QCoreApplication::processEvents();
+ waitForRehighlightedSemanticDocument(testFile->m_editorWidget);
}
// Enforce the default cpp code style, so we are independent of config file settings.
// This is needed by e.g. the GenerateGetterSetter quick fix.
- cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStyle();
- QVERIFY(cppCodeStylePreferences);
- cppCodeStylePreferencesOriginalDelegateId = cppCodeStylePreferences->currentDelegateId();
- cppCodeStylePreferences->setCurrentDelegate("qt");
-}
-
-TestCase::~TestCase()
-{
- // Restore default cpp code style
- if (cppCodeStylePreferences)
- cppCodeStylePreferences->setCurrentDelegate(cppCodeStylePreferencesOriginalDelegateId);
-
- // Close editors
- QList<Core::IEditor *> editorsToClose;
- foreach (const TestDocumentPtr testFile, testFiles) {
- if (testFile->editor)
- editorsToClose << testFile->editor;
- }
- EditorManager::closeEditors(editorsToClose, false);
- QCoreApplication::processEvents(); // process any pending events
-
- // Remove the test files from the code-model
- CppModelManagerInterface *mmi = CppModelManagerInterface::instance();
- mmi->GC();
- QCOMPARE(mmi->snapshot().size(), 0);
-
- // Restore include paths
- if (restoreIncludePaths)
- CppTools::Internal::CppModelManager::instance()->setIncludePaths(includePathsToRestore);
-
- // Remove created files from file system
- foreach (const TestDocumentPtr &testDocument, testFiles)
- QVERIFY(QFile::remove(testDocument->filePath()));
-}
-
-/// Leading whitespace is not removed, so we can check if the indetation ranges
-/// have been set correctly by the quick-fix.
-QByteArray &removeTrailingWhitespace(QByteArray &input)
-{
- QList<QByteArray> lines = input.split('\n');
- input.resize(0);
- foreach (QByteArray line, lines) {
- while (line.length() > 0) {
- char lastChar = line[line.length() - 1];
- if (lastChar == ' ' || lastChar == '\t')
- line = line.left(line.length() - 1);
- else
- break;
- }
- input.append(line);
- input.append('\n');
- }
- return input;
-}
+ m_cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStyle();
+ QVERIFY(m_cppCodeStylePreferences);
+ m_cppCodeStylePreferencesOriginalDelegateId = m_cppCodeStylePreferences->currentDelegateId();
+ m_cppCodeStylePreferences->setCurrentDelegate("qt");
-void TestCase::run(CppQuickFixFactory *factory, int resultIndex)
-{
// Run the fix in the file having the cursor marker
TestDocumentPtr testFile;
- foreach (const TestDocumentPtr file, testFiles) {
- if (file->hasCursorMarkerPosition())
+ foreach (const TestDocumentPtr file, m_testFiles) {
+ if (file->hasCursorMarker())
testFile = file;
}
QVERIFY2(testFile, "No test file with cursor marker found");
- if (QuickFixOperation::Ptr fix = getFix(factory, testFile->editorWidget, resultIndex))
+ if (QuickFixOperation::Ptr fix = getFix(factory, testFile->m_editorWidget, resultIndex))
fix->perform();
else
qDebug() << "Quickfix was not triggered";
// Compare all files
- foreach (const TestDocumentPtr testFile, testFiles) {
+ foreach (const TestDocumentPtr testFile, m_testFiles) {
// Check
- QByteArray result = testFile->editorWidget->document()->toPlainText().toUtf8();
+ QByteArray result = testFile->m_editorWidget->document()->toPlainText().toUtf8();
removeTrailingWhitespace(result);
- QCOMPARE(QLatin1String(result), QLatin1String(testFile->expectedSource));
+ QCOMPARE(QLatin1String(result), QLatin1String(testFile->m_expectedSource));
// Undo the change
for (int i = 0; i < 100; ++i)
- testFile->editorWidget->undo();
- result = testFile->editorWidget->document()->toPlainText().toUtf8();
- QCOMPARE(result, testFile->originalSource);
+ testFile->m_editorWidget->undo();
+ result = testFile->m_editorWidget->document()->toPlainText().toUtf8();
+ QCOMPARE(result, testFile->m_source);
}
}
+QuickFixTestCase::~QuickFixTestCase()
+{
+ // Restore default cpp code style
+ if (m_cppCodeStylePreferences)
+ m_cppCodeStylePreferences->setCurrentDelegate(m_cppCodeStylePreferencesOriginalDelegateId);
+
+ // Restore include paths
+ if (m_restoreIncludePaths)
+ m_modelManager->setIncludePaths(m_includePathsToRestore);
+
+ // Remove created files from file system
+ foreach (const TestDocumentPtr &testDocument, m_testFiles)
+ QVERIFY(QFile::remove(testDocument->filePath()));
+}
+
/// Delegates directly to AddIncludeForUndefinedIdentifierOp for easier testing.
class AddIncludeForUndefinedIdentifierTestFactory : public CppQuickFixFactory
{
@@ -1257,8 +1187,7 @@ void CppEditorPlugin::test_quickfix()
if (expected.isEmpty())
expected = original + '\n';
- TestCase data(original, expected);
- data.run(factory.data());
+ QuickFixTestCase(singleDocument(original, expected), factory.data());
}
/// Checks: In addition to test_quickfix_GenerateGetterSetter_basicGetterWithPrefix
@@ -1288,7 +1217,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_basicGetterWithPrefixAn
" void setIt(int value);\n"
"};\n"
"}\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -1308,11 +1237,10 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_basicGetterWithPrefixAn
" it = value;\n"
"}\n\n"
"}\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
GenerateGetterSetter factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check if definition is inserted right after class for insert definition outside
@@ -1342,7 +1270,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass()
"{\n\n}\n"
"\n"
"class Bar {};\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -1352,11 +1280,10 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass()
"{\n\n"
"}\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
- TestCase data(testFiles);
- data.run(&factory, 1);
+ QuickFixTestCase(testFiles, &factory, QStringList(), 1);
}
/// Check from header file: If there is a source file, insert the definition in the source file.
@@ -1375,7 +1302,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic1()
" Foo()@;\n"
"};\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original.resize(0);
@@ -1386,11 +1313,10 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic1()
"}\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check from header file: If there is a source file, insert the definition in the source file.
@@ -1405,7 +1331,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic2()
// Header File
original = "void f()@;\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -1425,11 +1351,10 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic2()
"}\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check from source file: Insert in source file, not header file.
@@ -1441,7 +1366,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic3()
QByteArray expected;
// Empty Header File
- testFiles << TestDocument::create("", "\n", QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", "", "\n");
// Source File
original =
@@ -1457,11 +1382,10 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic3()
"}\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check from header file: If the class is in a namespace, the added function definition
@@ -1482,7 +1406,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace1()
"};\n"
"}\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original.resize(0);
@@ -1493,11 +1417,10 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace1()
"}\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check from header file: If the class is in namespace N and the source file has a
@@ -1518,7 +1441,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace2()
"};\n"
"}\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -1533,11 +1456,10 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace2()
"}\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check definition insert inside class
@@ -1555,8 +1477,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_insideClass()
"};\n";
InsertDefFromDecl factory;
- TestCase data(original, expected);
- data.run(&factory, 1);
+ QuickFixTestCase(singleDocument(original, expected), &factory, QStringList(), 1);
}
/// Check not triggering when definition exists
@@ -1570,8 +1491,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitio
const QByteArray expected = original + "\n";
InsertDefFromDecl factory;
- TestCase data(original, expected);
- data.run(&factory, 1);
+ QuickFixTestCase test(singleDocument(original, expected), &factory, QStringList(), 1);
}
/// Find right implementation file.
@@ -1592,7 +1512,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findRightImplementationFil
"};\n"
"}\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File #1
original =
@@ -1603,7 +1523,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findRightImplementationFil
"}\n"
"\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
// Source File #2
@@ -1619,11 +1539,10 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findRightImplementationFil
"{\n\n"
"}\n"
"\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file2.cpp"));
+ testFiles << TestDocument::create("file2.cpp", original, expected);
InsertDefFromDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Ignore generated functions declarations when looking at the surrounding
@@ -1646,7 +1565,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_ignoreSurroundingGenerated
"};\n"
"}\n";
expected = original + '\n';
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File #1
original =
@@ -1666,7 +1585,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_ignoreSurroundingGenerated
"{\n\n"
"}\n"
"\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
// Source File #2
original =
@@ -1676,11 +1595,10 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_ignoreSurroundingGenerated
"{\n\n"
"}\n";
expected = original + '\n';
- testFiles << TestDocument::create(original, expected, QLatin1String("file2.cpp"));
+ testFiles << TestDocument::create("file2.cpp", original, expected);
InsertDefFromDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check if whitespace is respected for operator functions
@@ -1705,8 +1623,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames1(
"\n";
InsertDefFromDecl factory;
- TestCase data(original, expected);
- data.run(&factory);
+ QuickFixTestCase(singleDocument(original, expected), &factory);
}
/// Check if whitespace is respected for operator functions
@@ -1731,8 +1648,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames2(
"\n";
InsertDefFromDecl factory;
- TestCase data(original, expected);
- data.run(&factory);
+ QuickFixTestCase(singleDocument(original, expected), &factory);
}
/// Check if a function like macro use is not separated by the function to insert
@@ -1747,7 +1663,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile1()
// Header File
original = "void f()@;\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -1772,11 +1688,10 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile1()
"MACRO(int)\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check if a function like macro use is not separated by the function to insert
@@ -1791,7 +1706,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile2()
// Header File
original = "void f()@;\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -1814,11 +1729,10 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile2()
"MACRO(int)\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check if insertion happens before syntactically erroneous statements at end of file.
@@ -1832,7 +1746,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_erroneousStatementAtEndOfF
// Header File
original = "void f()@;\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -1853,11 +1767,39 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_erroneousStatementAtEndOfF
"MissingSemicolon(int)\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
+}
+
+/// Check: Respect rvalue references
+void CppEditorPlugin::test_quickfix_InsertDefFromDecl_rvalueReference()
+{
+ QList<TestDocumentPtr> testFiles;
+
+ QByteArray original;
+ QByteArray expected;
+
+ // Header File
+ original = "void f(Foo &&)@;\n";
+ expected = original + "\n";
+ testFiles << TestDocument::create("file.h", original, expected);
+
+ // Source File
+ original = "";
+ expected =
+ "\n"
+ "void f(Foo &&)\n"
+ "{\n"
+ "\n"
+ "}\n"
+ "\n"
+ ;
+ testFiles << TestDocument::create("file.cpp", original, expected);
+
+ InsertDefFromDecl factory;
+ QuickFixTestCase(testFiles, &factory);
}
// Function for one of InsertDeclDef section cases
@@ -1879,7 +1821,7 @@ void insertToSectionDeclFromDef(const QByteArray &section, int sectionIndex)
+ section + ":\n" +
" Foo();\n"
"@};\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -1891,11 +1833,10 @@ void insertToSectionDeclFromDef(const QByteArray &section, int sectionIndex)
"\n"
;
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertDeclFromDef factory;
- TestCase data(testFiles);
- data.run(&factory, sectionIndex);
+ QuickFixTestCase(testFiles, &factory, QStringList(), sectionIndex);
}
/// Check from source file: Insert in header file.
@@ -1911,10 +1852,8 @@ void CppEditorPlugin::test_quickfix_InsertDeclFromDef()
QList<Include> includesForSource(const QByteArray &source)
{
- const QString fileName = TestIncludePaths::directoryOfTestFile() + QLatin1String("/file.cpp");
- Utils::FileSaver srcSaver(fileName);
- srcSaver.write(source);
- srcSaver.finalize();
+ const QString fileName = TestIncludePaths::testFilePath();
+ CppTools::Tests::TestCase::writeFile(fileName, source);
using namespace CppTools::Internal;
@@ -2078,8 +2017,8 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_normal()
// Header File
original = "class Foo {};\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("afile.h"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8() + "/afile.h",
+ original, expected);
// Source File
original =
@@ -2100,13 +2039,12 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_normal()
"}\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("afile.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/afile.cpp", original, expected);
// Do not use the test factory, at least once we want to go through the "full stack".
AddIncludeForUndefinedIdentifier factory;
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Ignore *.moc includes
@@ -2128,12 +2066,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_ignoremoc()
"#include \"file.moc\";\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Insert include at top for a sorted group
@@ -2155,12 +2092,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_sortingTop(
"#include \"z.h\"\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Insert include in the middle for a sorted group
@@ -2182,12 +2118,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_sortingMidd
"#include \"z.h\"\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Insert include at bottom for a sorted group
@@ -2209,12 +2144,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_sortingBott
"#include \"file.h\"\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: For an unsorted group the new include is appended
@@ -2236,12 +2170,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_appendToUns
"#include \"file.h\"\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8() +
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Insert a local include at front if there are only global includes
@@ -2264,12 +2197,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_firstLocalI
"#include <b.h>\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Insert a global include at back if there are only local includes
@@ -2295,12 +2227,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_firstGlobal
"void f();\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<file.h>"));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Prefer group with longest matching prefix
@@ -2326,12 +2257,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_preferGroup
"#include \"foo.h\"\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"prefixc.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Create a new include group if there are only include groups with a different include dir
@@ -2354,12 +2284,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_newGroupIfO
"#include \"file.h\"\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Include group with mixed include dirs, sorted --> insert properly
@@ -2383,12 +2312,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedDirsSo
"#include <utils/file.h>\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<firstlib/file.h>"));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Include group with mixed include dirs, unsorted --> append
@@ -2412,12 +2340,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedDirsUn
"#include <lastlib/file.h>\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lastlib/file.h>"));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Include group with mixed include types
@@ -2439,12 +2366,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
"#include <global.h>\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"z.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Include group with mixed include types
@@ -2466,12 +2392,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
"#include <global.h>\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"a.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Include group with mixed include types
@@ -2493,12 +2418,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
"#include <global.h>\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"lib/file.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Include group with mixed include types
@@ -2520,12 +2444,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
"#include <lib/file.h>\n"
"\n\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lib/file.h>"));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Insert very first include
@@ -2545,12 +2468,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_noinclude()
"void f();\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Insert very first include if there is a c++ style comment on top
@@ -2576,12 +2498,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_veryFirstIn
"void @f();\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: Insert very first include if there is a c style comment on top
@@ -2611,12 +2532,11 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_veryFirstIn
"void @f();\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- TestCase data(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
}
/// Check: If a "Qt Class" was not found by the locator, check the header files in the Qt
@@ -2637,12 +2557,12 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_checkQSomet
"QDir dir;\n"
"\n"
;
- testFiles << TestDocument::create(original, expected, TestIncludePaths::directoryOfTestFile() + QLatin1Char('/')
- + QLatin1String("file.cpp"));
+ testFiles << TestDocument::create(TestIncludePaths::directoryOfTestFile().toUtf8()
+ + "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifier factory;
- TestCase data(testFiles, QStringList(TestIncludePaths::globalQtCoreIncludePath()));
- data.run(&factory);
+ QuickFixTestCase(testFiles,&factory,
+ QStringList(CppTools::Tests::TestIncludePaths::globalQtCoreIncludePath()));
}
/// Check: Move definition from header to cpp.
@@ -2668,7 +2588,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
"\n"
" void bar();\n"
"};\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -2682,11 +2602,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
" return 5;\n"
"}\n"
"\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppInsideNS()
@@ -2711,7 +2630,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppInsideNS()
" int ba@r();\n"
"};\n"
"}\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -2729,11 +2648,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppInsideNS()
"}\n"
"\n"
"}\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: Move definition outside class
@@ -2767,8 +2685,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutside1()
"void Foo::f4() {}\n\n";
MoveFuncDefOutside factory;
- TestCase data(original, expected);
- data.run(&factory);
+ QuickFixTestCase(singleDocument(original, expected), &factory);
}
/// Check: Move definition outside class
@@ -2799,7 +2716,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutside2()
"{\n"
" return 1;\n"
"}\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -2807,11 +2724,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutside2()
"void Foo::f1() {}\n"
"void Foo::f3() {}\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- TestCase data(testFiles);
- data.run(&factory, 1);
+ QuickFixTestCase(testFiles, &factory, QStringList(), 1);
}
/// Check: Move definition from header to cpp (with namespace).
@@ -2837,7 +2753,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppNS()
" inline int number() const;\n"
"};\n"
"}\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -2851,11 +2767,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppNS()
" return 5;\n"
"}\n"
"\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: Move definition from header to cpp (with namespace + using).
@@ -2881,7 +2796,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppNSUsing()
" inline int number() const;\n"
"};\n"
"}\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -2897,11 +2812,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppNSUsing()
" return 5;\n"
"}\n"
"\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: Move definition outside class with Namespace
@@ -2928,8 +2842,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutsideWithNs()
"\n}\n";
MoveFuncDefOutside factory;
- TestCase data(original, expected);
- data.run(&factory);
+ QuickFixTestCase(singleDocument(original, expected), &factory);
}
/// Check: Move free function from header to cpp.
@@ -2948,7 +2861,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_FreeFuncToCpp()
expected =
"int number() const;\n"
"\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -2962,11 +2875,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_FreeFuncToCpp()
" return 5;\n"
"}\n"
"\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: Move free function from header to cpp (with namespace).
@@ -2989,7 +2901,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_FreeFuncToCppNS()
"int number() const;\n"
"}\n"
"\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -3003,11 +2915,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_FreeFuncToCppNS()
" return 5;\n"
"}\n"
"\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: Move Ctor with member initialization list (QTCREATORBUG-9157).
@@ -3034,7 +2945,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_CtorWithInitialization1()
" int a;\n"
" float b;\n"
"};\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original ="#include \"file.h\"\n";
@@ -3044,11 +2955,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_CtorWithInitialization1()
"\n"
"Foo::Foo() : a(42), b(3.141) {}\n"
"\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: Move Ctor with member initialization list (QTCREATORBUG-9462).
@@ -3078,7 +2988,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_CtorWithInitialization2()
"\n"
" int member;\n"
"};\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original ="#include \"file.h\"\n";
@@ -3090,11 +3000,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_CtorWithInitialization2()
"{\n"
"}\n"
"\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check if definition is inserted right after class for move definition outside
@@ -3123,7 +3032,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_afterClass()
"void Foo::a() {}\n"
"\n"
"class Bar {};\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -3133,11 +3042,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_afterClass()
"{\n\n"
"}\n";
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- TestCase data(testFiles);
- data.run(&factory, 1);
+ QuickFixTestCase(testFiles, &factory, QStringList(), 1);
}
/// Check if whitespace is respected for operator functions
@@ -3159,8 +3067,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames1
"\n";
MoveFuncDefOutside factory;
- TestCase data(original, expected);
- data.run(&factory);
+ QuickFixTestCase(singleDocument(original, expected), &factory);
}
/// Check if whitespace is respected for operator functions
@@ -3182,8 +3089,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames2
"\n";
MoveFuncDefOutside factory;
- TestCase data(original, expected);
- data.run(&factory);
+ QuickFixTestCase(singleDocument(original, expected), &factory);
}
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
@@ -3202,7 +3108,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFunc()
"class Foo {\n"
" inline int number() const {return 5;}\n"
"};\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -3212,11 +3118,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFunc()
expected =
"#include \"file.h\"\n"
"\n\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefToDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncOutside()
@@ -3242,8 +3147,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncOutside()
"\n\n\n";
MoveFuncDefToDecl factory;
- TestCase data(original, expected);
- data.run(&factory);
+ QuickFixTestCase(singleDocument(original, expected), &factory);
}
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCppNS()
@@ -3269,7 +3173,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncToCppNS()
" }\n"
"};\n"
"}\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -3280,11 +3184,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncToCppNS()
" return 5;\n"
"}\n";
expected = "#include \"file.h\"\n\n\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefToDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCppNSUsing()
@@ -3310,7 +3213,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncToCppNSUsing()
" }\n"
"};\n"
"}\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -3325,11 +3228,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncToCppNSUsing()
"#include \"file.h\"\n"
"using namespace MyNs;\n"
"\n\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefToDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncOutsideWithNs()
@@ -3356,8 +3258,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncOutsideWithNs()
"};\n\n\n}\n\n";
MoveFuncDefToDecl factory;
- TestCase data(original, expected);
- data.run(&factory);
+ QuickFixTestCase(singleDocument(original, expected), &factory);
}
/// Check: revert test_quickfix_MoveFuncDefOutside_FreeFuncToCpp()
@@ -3374,7 +3275,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_FreeFuncToCpp()
"{\n"
" return 5;\n"
"}\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -3386,11 +3287,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_FreeFuncToCpp()
" return 5;\n"
"}\n";
expected = "#include \"file.h\"\n\n\n\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefToDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: revert test_quickfix_MoveFuncDefOutside_FreeFuncToCppNS()
@@ -3412,7 +3312,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_FreeFuncToCppNS()
" return 5;\n"
"}\n"
"}\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -3425,11 +3325,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_FreeFuncToCppNS()
expected =
"#include \"file.h\"\n"
"\n\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefToDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: revert test_quickfix_MoveFuncDefOutside_CtorWithInitialization()
@@ -3456,7 +3355,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_CtorWithInitialization()
" int a;\n"
" float b;\n"
"};\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -3465,11 +3364,10 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_CtorWithInitialization()
"Foo::F@oo() : a(42), b(3.141) {}"
;
expected ="#include \"file.h\"\n\n\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
MoveFuncDefToDecl factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: Definition should not be placed behind the variable. QTCREATORBUG-10303
@@ -3495,8 +3393,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_structWithAssignedVariable
"} bar;\n\n\n";
MoveFuncDefToDecl factory;
- TestCase data(original, expected);
- data.run(&factory);
+ QuickFixTestCase(singleDocument(original, expected), &factory);
}
void CppEditorPlugin::test_quickfix_AssignToLocalVariable_templates()
@@ -3515,7 +3412,7 @@ void CppEditorPlugin::test_quickfix_AssignToLocalVariable_templates()
"};\n"
;
expected = original + "\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -3530,11 +3427,10 @@ void CppEditorPlugin::test_quickfix_AssignToLocalVariable_templates()
" List<int> list;\n"
" int localFirst = list.first();\n"
"}\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
AssignToLocalVariable factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_typeDeduction_data()
@@ -3598,8 +3494,7 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_typeDeduction()
}
ExtractLiteralAsParameter factory;
- TestCase data(original, expected);
- data.run(&factory);
+ QuickFixTestCase(singleDocument(original, expected), &factory);
}
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_freeFunction_separateFiles()
@@ -3613,7 +3508,7 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_freeFunction_separ
"void foo(const char *a, long b = 1);";
expected =
"void foo(const char *a, long b = 1, int newParameter = 156);\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -3622,11 +3517,10 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_freeFunction_separ
expected =
"void foo(const char *a, long b, int newParameter)\n"
"{return newParameter + 123 + newParameter;}\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
ExtractLiteralAsParameter factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_memberFunction_separateFiles()
@@ -3646,7 +3540,7 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_memberFunction_sep
"public:\n"
" int zort(int newParameter = 155);\n"
"};\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
@@ -3657,11 +3551,10 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_memberFunction_sep
"#include \"file.h\"\n\n"
"int Narf::zort(int newParameter)\n"
"{ return newParameter + 1; }\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
ExtractLiteralAsParameter factory;
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
Q_DECLARE_METATYPE(InsertVirtualMethodsDialog::ImplementationMode)
@@ -3678,14 +3571,14 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
<< InsertVirtualMethodsDialog::ModeOnlyDeclarations << true << _(
"class BaseA {\n"
"public:\n"
- " virtual int virtualFuncA();\n"
+ " virtual int virtualFuncA() = 0;\n"
"};\n\n"
"class Derived : public Bas@eA {\n"
"};"
) << _(
"class BaseA {\n"
"public:\n"
- " virtual int virtualFuncA();\n"
+ " virtual int virtualFuncA() = 0;\n"
"};\n\n"
"class Derived : public BaseA {\n"
"\n"
@@ -3700,14 +3593,14 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
<< InsertVirtualMethodsDialog::ModeOnlyDeclarations << false << _(
"class BaseA {\n"
"public:\n"
- " virtual int virtualFuncA();\n"
+ " virtual int virtualFuncA() = 0;\n"
"};\n\n"
"class Derived : public Bas@eA {\n"
"};"
) << _(
"class BaseA {\n"
"public:\n"
- " virtual int virtualFuncA();\n"
+ " virtual int virtualFuncA() = 0;\n"
"};\n\n"
"class Derived : public BaseA {\n"
"\n"
@@ -3722,38 +3615,38 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
<< InsertVirtualMethodsDialog::ModeOnlyDeclarations << true << _(
"class BaseA {\n"
"public:\n"
- " virtual int a();\n"
+ " virtual int a() = 0;\n"
"protected:\n"
- " virtual int b();\n"
+ " virtual int b() = 0;\n"
"private:\n"
- " virtual int c();\n"
+ " virtual int c() = 0;\n"
"public slots:\n"
- " virtual int d();\n"
+ " virtual int d() = 0;\n"
"protected slots:\n"
- " virtual int e();\n"
+ " virtual int e() = 0;\n"
"private slots:\n"
- " virtual int f();\n"
+ " virtual int f() = 0;\n"
"signals:\n"
- " virtual int g();\n"
+ " virtual int g() = 0;\n"
"};\n\n"
"class Der@ived : public BaseA {\n"
"};"
) << _(
"class BaseA {\n"
"public:\n"
- " virtual int a();\n"
+ " virtual int a() = 0;\n"
"protected:\n"
- " virtual int b();\n"
+ " virtual int b() = 0;\n"
"private:\n"
- " virtual int c();\n"
+ " virtual int c() = 0;\n"
"public slots:\n"
- " virtual int d();\n"
+ " virtual int d() = 0;\n"
"protected slots:\n"
- " virtual int e();\n"
+ " virtual int e() = 0;\n"
"private slots:\n"
- " virtual int f();\n"
+ " virtual int f() = 0;\n"
"signals:\n"
- " virtual int g();\n"
+ " virtual int g() = 0;\n"
"};\n\n"
"class Derived : public BaseA {\n"
"\n"
@@ -3780,56 +3673,57 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
<< InsertVirtualMethodsDialog::ModeOnlyDeclarations << true << _(
"class BaseA {\n"
"public:\n"
- " virtual int a();\n"
+ " virtual int a() = 0;\n"
"};\n\n"
"class BaseB : public BaseA {\n"
"public:\n"
- " virtual int b();\n"
+ " virtual int b() = 0;\n"
"};\n\n"
"class Der@ived : public BaseB {\n"
"};"
) << _(
"class BaseA {\n"
"public:\n"
- " virtual int a();\n"
+ " virtual int a() = 0;\n"
"};\n\n"
"class BaseB : public BaseA {\n"
"public:\n"
- " virtual int b();\n"
+ " virtual int b() = 0;\n"
"};\n\n"
"class Der@ived : public BaseB {\n"
"\n"
- " // BaseB interface\n"
- "public:\n"
- " virtual int b();\n"
- "\n"
" // BaseA interface\n"
"public:\n"
" virtual int a();\n"
+ "\n"
+ " // BaseB interface\n"
+ "public:\n"
+ " virtual int b();\n"
"};\n"
);
+
// Check: Do not insert reimplemented functions twice.
QTest::newRow("SuperclassOverride")
<< InsertVirtualMethodsDialog::ModeOnlyDeclarations << true << _(
"class BaseA {\n"
"public:\n"
- " virtual int a();\n"
+ " virtual int a() = 0;\n"
"};\n\n"
"class BaseB : public BaseA {\n"
"public:\n"
- " virtual int a();\n"
+ " virtual int a() = 0;\n"
"};\n\n"
"class Der@ived : public BaseB {\n"
"};"
) << _(
"class BaseA {\n"
"public:\n"
- " virtual int a();\n"
+ " virtual int a() = 0;\n"
"};\n\n"
"class BaseB : public BaseA {\n"
"public:\n"
- " virtual int a();\n"
+ " virtual int a() = 0;\n"
"};\n\n"
"class Der@ived : public BaseB {\n"
"\n"
@@ -3890,14 +3784,14 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
<< InsertVirtualMethodsDialog::ModeInsideClass << true << _(
"class BaseA {\n"
"public:\n"
- " virtual int virtualFuncA();\n"
+ " virtual int virtualFuncA() = 0;\n"
"};\n\n"
"class Derived : public Bas@eA {\n"
"};"
) << _(
"class BaseA {\n"
"public:\n"
- " virtual int virtualFuncA();\n"
+ " virtual int virtualFuncA() = 0;\n"
"};\n\n"
"class Derived : public BaseA {\n"
"\n"
@@ -3914,14 +3808,14 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
<< InsertVirtualMethodsDialog::ModeOutsideClass << true << _(
"class BaseA {\n"
"public:\n"
- " virtual int virtualFuncA();\n"
+ " virtual int virtualFuncA() = 0;\n"
"};\n\n"
"class Derived : public Bas@eA {\n"
"};"
) << _(
"class BaseA {\n"
"public:\n"
- " virtual int virtualFuncA();\n"
+ " virtual int virtualFuncA() = 0;\n"
"};\n\n"
"class Derived : public BaseA {\n"
"\n"
@@ -3943,7 +3837,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
"};\n\n"
"class Derived : public Bas@eA {\n"
"public:\n"
- " virtual int virtualFuncA();\n"
+ " virtual int virtualFuncA() = 0;\n"
"};"
) << _(
"class BaseA {\n"
@@ -3952,9 +3846,135 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
"};\n\n"
"class Derived : public Bas@eA {\n"
"public:\n"
+ " virtual int virtualFuncA() = 0;\n"
+ "};\n"
+ );
+
+ // Check: One pure, one not
+ QTest::newRow("Some_Pure")
+ << InsertVirtualMethodsDialog::ModeOnlyDeclarations << true << _(
+ "class BaseA {\n"
+ "public:\n"
+ " virtual int virtualFuncA() = 0;\n"
+ " virtual int virtualFuncB();\n"
+ "};\n\n"
+ "class Derived : public Bas@eA {\n"
+ "};"
+ ) << _(
+ "class BaseA {\n"
+ "public:\n"
+ " virtual int virtualFuncA() = 0;\n"
+ " virtual int virtualFuncB();\n"
+ "};\n\n"
+ "class Derived : public BaseA {\n"
+ "\n"
+ " // BaseA interface\n"
+ "public:\n"
" virtual int virtualFuncA();\n"
"};\n"
);
+
+ // Check: Pure function in derived class
+ QTest::newRow("Pure_in_Derived")
+ << InsertVirtualMethodsDialog::ModeOnlyDeclarations << true << _(
+ "class BaseA {\n"
+ "public:\n"
+ " virtual int a();\n"
+ "};\n\n"
+ "class BaseB : public BaseA {\n"
+ "public:\n"
+ " virtual int a() = 0;\n"
+ "};\n\n"
+ "class Der@ived : public BaseB {\n"
+ "};"
+ ) << _(
+ "class BaseA {\n"
+ "public:\n"
+ " virtual int a();\n"
+ "};\n\n"
+ "class BaseB : public BaseA {\n"
+ "public:\n"
+ " virtual int a() = 0;\n"
+ "};\n\n"
+ "class Der@ived : public BaseB {\n"
+ "\n"
+ " // BaseA interface\n"
+ "public:\n"
+ " virtual int a();\n"
+ "};\n"
+ );
+
+ // Check: One pure function in base class, one in derived
+ QTest::newRow("Pure_in_Base_And_Derived")
+ << InsertVirtualMethodsDialog::ModeOnlyDeclarations << true << _(
+ "class BaseA {\n"
+ "public:\n"
+ " virtual int a() = 0;\n"
+ " virtual int b();\n"
+ "};\n\n"
+ "class BaseB : public BaseA {\n"
+ "public:\n"
+ " virtual int b() = 0;\n"
+ "};\n\n"
+ "class Der@ived : public BaseB {\n"
+ "};"
+ ) << _(
+ "class BaseA {\n"
+ "public:\n"
+ " virtual int a() = 0;\n"
+ " virtual int b();\n"
+ "};\n\n"
+ "class BaseB : public BaseA {\n"
+ "public:\n"
+ " virtual int b() = 0;\n"
+ "};\n\n"
+ "class Der@ived : public BaseB {\n"
+ "\n"
+ " // BaseA interface\n"
+ "public:\n"
+ " virtual int a();\n"
+ " virtual int b();\n"
+ "};\n"
+ );
+
+ // Check: One pure function in base class, two in derived
+ QTest::newRow("Pure_in_Base_And_Derived_2")
+ << InsertVirtualMethodsDialog::ModeOnlyDeclarations << true << _(
+ "class BaseA {\n"
+ "public:\n"
+ " virtual int a() = 0;\n"
+ " virtual int b();\n"
+ "};\n\n"
+ "class BaseB : public BaseA {\n"
+ "public:\n"
+ " virtual int b() = 0;\n"
+ " virtual int c() = 0;\n"
+ "};\n\n"
+ "class Der@ived : public BaseB {\n"
+ "};"
+ ) << _(
+ "class BaseA {\n"
+ "public:\n"
+ " virtual int a() = 0;\n"
+ " virtual int b();\n"
+ "};\n\n"
+ "class BaseB : public BaseA {\n"
+ "public:\n"
+ " virtual int b() = 0;\n"
+ " virtual int c() = 0;\n"
+ "};\n\n"
+ "class Der@ived : public BaseB {\n"
+ "\n"
+ " // BaseA interface\n"
+ "public:\n"
+ " virtual int a();\n"
+ " virtual int b();\n"
+ "\n"
+ " // BaseB interface\n"
+ "public:\n"
+ " virtual int c();\n"
+ "};\n"
+ );
}
void CppEditorPlugin::test_quickfix_InsertVirtualMethods()
@@ -3966,8 +3986,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods()
InsertVirtualMethods factory(
new InsertVirtualMethodsDialogTest(implementationMode, insertVirtualKeyword));
- TestCase data(original, expected);
- data.run(&factory);
+ QuickFixTestCase(singleDocument(original, expected), &factory);
}
/// Check: Insert in implementation file
@@ -3981,7 +4000,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile()
original =
"class BaseA {\n"
"public:\n"
- " virtual int a();\n"
+ " virtual int a() = 0;\n"
"};\n\n"
"class Derived : public Bas@eA {\n"
"public:\n"
@@ -3990,7 +4009,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile()
expected =
"class BaseA {\n"
"public:\n"
- " virtual int a();\n"
+ " virtual int a() = 0;\n"
"};\n\n"
"class Derived : public BaseA {\n"
"public:\n"
@@ -4000,7 +4019,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile()
"public:\n"
" virtual int a();\n"
"};\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original = "#include \"file.h\"\n";
@@ -4009,12 +4028,11 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile()
"\n\n"
"int Derived::a()\n"
"{\n}\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertVirtualMethods factory(new InsertVirtualMethodsDialogTest(
InsertVirtualMethodsDialog::ModeImplementationFile, true));
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
/// Check: Qualified names.
@@ -4030,7 +4048,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
"namespace BaseNS {\n"
"class Base {\n"
"public:\n"
- " virtual BaseEnum a(BaseEnum e);\n"
+ " virtual BaseEnum a(BaseEnum e) = 0;\n"
"};\n"
"}\n"
"class Deri@ved : public BaseNS::Base {\n"
@@ -4042,7 +4060,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
"namespace BaseNS {\n"
"class Base {\n"
"public:\n"
- " virtual BaseEnum a(BaseEnum e);\n"
+ " virtual BaseEnum a(BaseEnum e) = 0;\n"
"};\n"
"}\n"
"class Deri@ved : public BaseNS::Base {\n"
@@ -4053,7 +4071,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
"public:\n"
" virtual BaseNS::BaseEnum a(BaseNS::BaseEnum e);\n"
"};\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
+ testFiles << TestDocument::create("file.h", original, expected);
// Source File
original = "#include \"file.h\"\n";
@@ -4062,10 +4080,9 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
"\n\n"
"BaseNS::BaseEnum Derived::a(BaseNS::BaseEnum e)\n"
"{\n}\n";
- testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
+ testFiles << TestDocument::create("file.cpp", original, expected);
InsertVirtualMethods factory(new InsertVirtualMethodsDialogTest(
InsertVirtualMethodsDialog::ModeImplementationFile, true));
- TestCase data(testFiles);
- data.run(&factory);
+ QuickFixTestCase(testFiles, &factory);
}
diff --git a/src/plugins/cppeditor/cppquickfixassistant.cpp b/src/plugins/cppeditor/cppquickfixassistant.cpp
index 2f84cf80d0..6e0c253f62 100644
--- a/src/plugins/cppeditor/cppquickfixassistant.cpp
+++ b/src/plugins/cppeditor/cppquickfixassistant.cpp
@@ -87,7 +87,7 @@ const IAssistProvider *CppQuickFixAssistProcessor::provider() const
CppQuickFixAssistInterface::CppQuickFixAssistInterface(CPPEditorWidget *editor,
TextEditor::AssistReason reason)
: DefaultAssistInterface(editor->document(), editor->position(),
- editor->editorDocument()->filePath(), reason)
+ editor->baseTextDocument()->filePath(), reason)
, m_editor(editor)
, m_semanticInfo(editor->semanticInfo())
, m_snapshot(CppTools::CppModelManagerInterface::instance()->snapshot())
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index be06973d6e..e61d14b30d 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -32,6 +32,7 @@
#include "cppeditor.h"
#include "cppfunctiondecldeflink.h"
#include "cppquickfixassistant.h"
+#include "cppvirtualfunctionassistprovider.h"
#include <coreplugin/icore.h>
@@ -40,6 +41,7 @@
#include <cpptools/cpppointerdeclarationformatter.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cpptoolsreuse.h>
+#include <cpptools/functionutils.h>
#include <cpptools/includeutils.h>
#include <cpptools/insertionpointlocator.h>
#include <cpptools/symbolfinder.h>
@@ -158,10 +160,8 @@ InsertionLocation insertLocationForMethodDefinition(Symbol *symbol, const bool u
= locator.methodDefinition(symbol, useSymbolFinder, fileName);
for (int i = 0; i < list.count(); ++i) {
InsertionLocation location = list.at(i);
- if (location.isValid() && location.fileName() == fileName) {
+ if (location.isValid() && location.fileName() == fileName)
return location;
- break;
- }
}
// ...failed,
@@ -1934,10 +1934,10 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
}
// find a include file through the locator
- QFutureInterface<Locator::FilterEntry> dummyInterface;
- QList<Locator::FilterEntry> matches = classesFilter->matchesFor(dummyInterface, className);
+ QFutureInterface<Core::LocatorFilterEntry> dummyInterface;
+ QList<Core::LocatorFilterEntry> matches = classesFilter->matchesFor(dummyInterface, className);
bool classExists = false;
- foreach (const Locator::FilterEntry &entry, matches) {
+ foreach (const Core::LocatorFilterEntry &entry, matches) {
const ModelItemInfo info = entry.internalData.value<ModelItemInfo>();
if (info.symbolName != className)
continue;
@@ -4692,7 +4692,6 @@ public:
, m_insertPosDecl(0)
, m_insertPosOutside(0)
, m_functionCount(0)
- , m_implementedFunctionCount(0)
{
setDescription(QCoreApplication::translate(
"CppEditor::QuickFix", "Insert Virtual Functions of Base Classes"));
@@ -4744,7 +4743,7 @@ public:
&& (clazz = interface->context().lookupType(symbol))
&& !visitedBaseClasses.contains(clazz)
&& !baseClasses.contains(base)) {
- baseClasses << base;
+ baseClasses.prepend(base);
baseClassQueue.enqueue(clazz);
}
}
@@ -4757,36 +4756,36 @@ public:
printer.showFunctionSignatures = true;
const TextEditor::FontSettings &fs = TextEditor::TextEditorSettings::fontSettings();
const Format formatReimpFunc = fs.formatFor(C_DISABLED_CODE);
+ QHash<const Function *, QStandardItem *> virtualFunctions;
foreach (const Class *clazz, baseClasses) {
QStandardItem *itemBase = new QStandardItem(printer.prettyName(clazz->name()));
- itemBase->setData(false, InsertVirtualMethodsDialog::Implemented);
+ itemBase->setData(false, InsertVirtualMethodsDialog::Reimplemented);
itemBase->setData(qVariantFromValue((void *) clazz),
InsertVirtualMethodsDialog::ClassOrFunction);
- const QString baseClassName = printer.prettyName(clazz->name());
- const Qt::CheckState funcItemsCheckState = (baseClassName != QLatin1String("QObject")
- && baseClassName != QLatin1String("QWidget")
- && baseClassName != QLatin1String("QPaintDevice"))
- ? Qt::Checked : Qt::Unchecked;
for (Scope::iterator it = clazz->firstMember(); it != clazz->lastMember(); ++it) {
if (const Function *func = (*it)->type()->asFunctionType()) {
- if (!func->isVirtual())
+ // Filter virtual destructors
+ if (func->name()->asDestructorNameId())
continue;
- // Filter virtual destructors
- if (printer.prettyName(func->name()).startsWith(QLatin1Char('~')))
+ const Function *firstVirtual = 0;
+ const bool isVirtual = FunctionUtils::isVirtualFunction(
+ func, interface->context(), &firstVirtual);
+ if (!isVirtual)
continue;
// Filter OQbject's
// - virtual const QMetaObject *metaObject() const;
// - virtual void *qt_metacast(const char *);
// - virtual int qt_metacall(QMetaObject::Call, int, void **);
- if (baseClassName == QLatin1String("QObject")) {
- if (printer.prettyName(func->name()) == QLatin1String("metaObject"))
- continue;
- if (printer.prettyName(func->name()) == QLatin1String("qt_metacast"))
- continue;
- if (printer.prettyName(func->name()) == QLatin1String("qt_metacall"))
+ if (printer.prettyName(firstVirtual->enclosingClass()->name())
+ == QLatin1String("QObject")) {
+ const QString funcName = printer.prettyName(func->name());
+ if (funcName == QLatin1String("metaObject")
+ || funcName == QLatin1String("qt_metacast")
+ || funcName == QLatin1String("qt_metacall")) {
continue;
+ }
}
// Do not implement existing functions inside target class
@@ -4804,76 +4803,83 @@ public:
}
}
- // Do not show when reimplemented from an other class
- bool funcReimplemented = false;
- for (int i = baseClasses.count() - 1; i >= 0; --i) {
- const Class *prevClass = baseClasses.at(i);
- if (clazz == prevClass)
- break; // reached current class
-
- for (const Symbol *symbol = prevClass->find(funcName->identifier());
- symbol; symbol = symbol->next()) {
- if (!symbol->name()
- || !funcName->identifier()->isEqualTo(symbol->identifier())) {
- continue;
- }
- if (symbol->type().isEqualTo(func->type())) {
- funcReimplemented = true;
- break;
- }
- }
- }
- if (funcReimplemented)
- continue;
-
// Construct function item
+ const bool isReimplemented = (func != firstVirtual);
const bool isPureVirtual = func->isPureVirtual();
QString itemName = printer.prettyType(func->type(), func->name());
if (isPureVirtual)
itemName += QLatin1String(" = 0");
const QString itemReturnTypeString = printer.prettyType(func->returnType());
- QStandardItem *funcItem = new QStandardItem(
- itemName + QLatin1String(" : ") + itemReturnTypeString);
- if (!funcExistsInClass) {
- funcItem->setCheckable(true);
- funcItem->setCheckState(Qt::Checked);
- } else {
+ itemName += QLatin1String(" : ") + itemReturnTypeString;
+ if (isReimplemented)
+ itemName += QLatin1String(" (redeclared)");
+ QStandardItem *funcItem = new QStandardItem(itemName);
+ funcItem->setCheckable(true);
+ if (isReimplemented) {
+ factory->setHasReimplementedFunctions(true);
funcItem->setEnabled(false);
- funcItem->setData(formatReimpFunc.foreground(), Qt::ForegroundRole);
- if (formatReimpFunc.background().isValid())
- funcItem->setData(formatReimpFunc.background(), Qt::BackgroundRole);
+ funcItem->setCheckState(Qt::Unchecked);
+ if (QStandardItem *first = virtualFunctions[firstVirtual]) {
+ if (!first->data(InsertVirtualMethodsDialog::Reimplemented).toBool()) {
+ first->setCheckState(isPureVirtual ? Qt::Checked : Qt::Unchecked);
+ factory->updateCheckBoxes(first);
+ }
+ }
+ } else {
+ if (!funcExistsInClass) {
+ funcItem->setCheckState(isPureVirtual ? Qt::Checked : Qt::Unchecked);
+ } else {
+ funcItem->setEnabled(false);
+ funcItem->setCheckState(Qt::Checked);
+ funcItem->setData(formatReimpFunc.foreground(), Qt::ForegroundRole);
+ if (formatReimpFunc.background().isValid())
+ funcItem->setData(formatReimpFunc.background(), Qt::BackgroundRole);
+ }
}
funcItem->setData(qVariantFromValue((void *) func),
InsertVirtualMethodsDialog::ClassOrFunction);
funcItem->setData(isPureVirtual, InsertVirtualMethodsDialog::PureVirtual);
funcItem->setData(acessSpec(*it), InsertVirtualMethodsDialog::AccessSpec);
- funcItem->setData(funcExistsInClass, InsertVirtualMethodsDialog::Implemented);
- funcItem->setCheckState(funcItemsCheckState);
+ funcItem->setData(funcExistsInClass || isReimplemented,
+ InsertVirtualMethodsDialog::Reimplemented);
itemBase->appendRow(funcItem);
+ virtualFunctions[func] = funcItem;
// update internal counters
- if (funcExistsInClass)
- ++m_implementedFunctionCount;
- else
+ if (!funcExistsInClass)
++m_functionCount;
}
}
if (itemBase->hasChildren()) {
+ itemBase->setData(false, InsertVirtualMethodsDialog::Reimplemented);
+ bool enabledFound = false;
+ Qt::CheckState state = Qt::Unchecked;
for (int i = 0; i < itemBase->rowCount(); ++i) {
- if (itemBase->child(i, 0)->isCheckable()) {
+ QStandardItem *childItem = itemBase->child(i, 0);
+ if (!childItem->isEnabled())
+ continue;
+ if (!enabledFound) {
+ state = childItem->checkState();
+ enabledFound = true;
+ }
+ if (childItem->isCheckable()) {
if (!itemBase->isCheckable()) {
itemBase->setCheckable(true);
itemBase->setTristate(true);
- itemBase->setData(false, InsertVirtualMethodsDialog::Implemented);
+ itemBase->setCheckState(state);
}
- if (itemBase->child(i, 0)->checkState() == Qt::Checked) {
- itemBase->setCheckState(Qt::Checked);
+ if (state != childItem->checkState()) {
+ itemBase->setCheckState(Qt::PartiallyChecked);
break;
}
}
}
+ if (!enabledFound) {
+ itemBase->setCheckable(true);
+ itemBase->setEnabled(false);
+ }
m_factory->classFunctionModel->invisibleRootItem()->appendRow(itemBase);
}
}
@@ -4885,7 +4891,6 @@ public:
bool isHeaderFile = false;
m_cppFileName = correspondingHeaderOrSource(interface->fileName(), &isHeaderFile);
m_factory->setHasImplementationFile(isHeaderFile && !m_cppFileName.isEmpty());
- m_factory->setHasReimplementedFunctions(m_implementedFunctionCount != 0);
m_valid = true;
}
@@ -4917,16 +4922,12 @@ public:
switch (spec) {
case InsertionPointLocator::Private:
return InsertionPointLocator::PrivateSlot;
- break;
case InsertionPointLocator::Protected:
return InsertionPointLocator::ProtectedSlot;
- break;
case InsertionPointLocator::Public:
return InsertionPointLocator::PublicSlot;
- break;
default:
return spec;
- break;
}
}
return spec;
@@ -5093,7 +5094,6 @@ private:
int m_insertPosDecl;
int m_insertPosOutside;
unsigned m_functionCount;
- unsigned m_implementedFunctionCount;
};
class InsertVirtualMethodsFilterModel : public QSortFilterProxyModel
@@ -5119,14 +5119,14 @@ public:
for (int i = 0; i < sourceModel()->rowCount(index); ++i) {
const QModelIndex child = sourceModel()->index(i, 0, index);
- if (!child.data(InsertVirtualMethodsDialog::Implemented).toBool())
+ if (!child.data(InsertVirtualMethodsDialog::Reimplemented).toBool())
return true;
}
return false;
}
if (m_hideReimplemented)
- return !index.data(InsertVirtualMethodsDialog::Implemented).toBool();
+ return !index.data(InsertVirtualMethodsDialog::Reimplemented).toBool();
return true;
}
@@ -5180,7 +5180,7 @@ void InsertVirtualMethodsDialog::initGui()
m_view->setHeaderHidden(true);
groupBoxViewLayout->addWidget(m_view);
m_hideReimplementedFunctions =
- new QCheckBox(tr("&Hide already implemented functions of current class"), this);
+ new QCheckBox(tr("&Hide reimplemented functions"), this);
groupBoxViewLayout->addWidget(m_hideReimplementedFunctions);
// Insertion options
@@ -5229,7 +5229,7 @@ void InsertVirtualMethodsDialog::initData()
m_view->setModel(classFunctionFilterModel);
m_expansionStateNormal.clear();
m_expansionStateReimp.clear();
- m_hideReimplementedFunctions->setVisible(m_hasReimplementedFunctions);
+ m_hideReimplementedFunctions->setEnabled(m_hasReimplementedFunctions);
m_virtualKeyword->setChecked(m_insertKeywordVirtual);
m_insertMode->setCurrentIndex(m_insertMode->findData(m_implementationMode));
@@ -5310,8 +5310,9 @@ void InsertVirtualMethodsDialog::updateCheckBoxes(QStandardItem *item)
if (!item->isCheckable() || state == Qt::PartiallyChecked)
return;
for (int i = 0; i < item->rowCount(); ++i) {
- if (item->child(i, 0)->isCheckable())
- item->child(i, 0)->setCheckState(state);
+ QStandardItem *childItem = item->child(i, 0);
+ if (childItem->isCheckable() && childItem->isEnabled())
+ childItem->setCheckState(state);
}
} else {
QStandardItem *parent = item->parent();
@@ -5319,7 +5320,8 @@ void InsertVirtualMethodsDialog::updateCheckBoxes(QStandardItem *item)
return;
const Qt::CheckState state = item->checkState();
for (int i = 0; i < parent->rowCount(); ++i) {
- if (state != parent->child(i, 0)->checkState()) {
+ QStandardItem *childItem = parent->child(i, 0);
+ if (childItem->isEnabled() && state != childItem->checkState()) {
parent->setCheckState(Qt::PartiallyChecked);
return;
}
diff --git a/src/plugins/cppeditor/cppquickfixes.h b/src/plugins/cppeditor/cppquickfixes.h
index 3e60341ce7..1ae1f20053 100644
--- a/src/plugins/cppeditor/cppquickfixes.h
+++ b/src/plugins/cppeditor/cppquickfixes.h
@@ -532,7 +532,7 @@ class InsertVirtualMethodsDialog : public QDialog
public:
enum CustomItemRoles {
ClassOrFunction = Qt::UserRole + 1,
- Implemented = Qt::UserRole + 2,
+ Reimplemented = Qt::UserRole + 2,
PureVirtual = Qt::UserRole + 3,
AccessSpec = Qt::UserRole + 4
};
@@ -556,8 +556,10 @@ public:
bool hideReimplementedFunctions() const;
virtual bool gather();
-private slots:
+public slots:
void updateCheckBoxes(QStandardItem *item);
+
+private slots:
void setHideReimplementedFunctions(bool hide);
private:
diff --git a/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp b/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp
index 132f999397..c014aee126 100644
--- a/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp
+++ b/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp
@@ -30,8 +30,8 @@
#include "cppvirtualfunctionassistprovider.h"
+#include "cppeditor.h"
#include "cppeditorconstants.h"
-#include "cppelementevaluator.h"
#include "cppvirtualfunctionproposalitem.h"
#include <cplusplus/Icons.h>
@@ -40,7 +40,9 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
+#include <cpptools/functionutils.h>
#include <cpptools/symbolfinder.h>
+#include <cpptools/typehierarchybuilder.h>
#include <texteditor/codeassist/basicproposalitemlistmodel.h>
#include <texteditor/codeassist/genericproposal.h>
@@ -48,11 +50,13 @@
#include <texteditor/codeassist/iassistinterface.h>
#include <texteditor/codeassist/iassistprocessor.h>
#include <texteditor/codeassist/iassistproposal.h>
+#include <texteditor/texteditorconstants.h>
#include <utils/qtcassert.h>
using namespace CPlusPlus;
using namespace CppEditor::Internal;
+using namespace CppTools;
using namespace TextEditor;
/// Activate current item with the same shortcut that is configured for Follow Symbol Under Cursor.
@@ -141,7 +145,7 @@ public:
if (!functionsClass)
return 0;
- const QList<Symbol *> overrides = FunctionHelper::overrides(
+ const QList<Symbol *> overrides = FunctionUtils::overrides(
m_params.function, functionsClass, m_params.staticClass, m_params.snapshot);
if (overrides.isEmpty())
return 0;
@@ -206,219 +210,3 @@ IAssistProcessor *VirtualFunctionAssistProvider::createProcessor() const
{
return new VirtualFunctionsAssistProcessor(m_params);
}
-
-enum VirtualType { Virtual, PureVirtual };
-
-static bool isVirtualFunction_helper(const Function *function,
- const Snapshot &snapshot,
- VirtualType virtualType)
-{
- if (!function)
- return false;
-
- if (virtualType == PureVirtual)
- return function->isPureVirtual();
-
- if (function->isVirtual())
- return true;
-
- const QString filePath = QString::fromUtf8(function->fileName(), function->fileNameLength());
- if (Document::Ptr document = snapshot.document(filePath)) {
- LookupContext context(document, snapshot);
- QList<LookupItem> results = context.lookup(function->name(), function->enclosingScope());
- if (!results.isEmpty()) {
- const bool isDestructor = function->name()->isDestructorNameId();
- foreach (const LookupItem &item, results) {
- if (Symbol *symbol = item.declaration()) {
- if (Function *functionType = symbol->type()->asFunctionType()) {
- if (functionType->name()->isDestructorNameId() != isDestructor)
- continue;
- if (functionType == function) // already tested
- continue;
- if (functionType->isFinal())
- return false;
- if (functionType->isVirtual())
- return true;
- }
- }
- }
- }
- }
-
- return false;
-}
-
-bool FunctionHelper::isVirtualFunction(const Function *function, const Snapshot &snapshot)
-{
- return isVirtualFunction_helper(function, snapshot, Virtual);
-}
-
-bool FunctionHelper::isPureVirtualFunction(const Function *function, const Snapshot &snapshot)
-{
- return isVirtualFunction_helper(function, snapshot, PureVirtual);
-}
-
-QList<Symbol *> FunctionHelper::overrides(Function *function, Class *functionsClass,
- Class *staticClass, const Snapshot &snapshot)
-{
- QList<Symbol *> result;
- QTC_ASSERT(function && functionsClass && staticClass, return result);
-
- FullySpecifiedType referenceType = function->type();
- const Name *referenceName = function->name();
- QTC_ASSERT(referenceName && referenceType.isValid(), return result);
-
- // Find overrides
- CppEditor::Internal::CppClass cppClass = CppClass(functionsClass);
- cppClass.lookupDerived(staticClass, snapshot);
-
- QList<CppClass> l;
- l << cppClass;
-
- while (!l.isEmpty()) {
- // Add derived
- CppClass clazz = l.takeFirst();
-
- QTC_ASSERT(clazz.declaration, continue);
- Class *c = clazz.declaration->asClass();
- QTC_ASSERT(c, continue);
-
- foreach (const CppClass &d, clazz.derived) {
- if (!l.contains(d))
- l << d;
- }
-
- // Check member functions
- for (int i = 0, total = c->memberCount(); i < total; ++i) {
- Symbol *candidate = c->memberAt(i);
- const Name *candidateName = candidate->name();
- const FullySpecifiedType candidateType = candidate->type();
- if (!candidateName || !candidateType.isValid())
- continue;
- if (candidateName->isEqualTo(referenceName) && candidateType.isEqualTo(referenceType))
- result << candidate;
- }
- }
-
- return result;
-}
-
-#ifdef WITH_TESTS
-#include "cppeditorplugin.h"
-
-#include <QList>
-#include <QTest>
-
-namespace CppEditor {
-namespace Internal {
-
-enum Virtuality
-{
- NotVirtual,
- Virtual,
- PureVirtual
-};
-typedef QList<Virtuality> VirtualityList;
-} // Internal namespace
-} // CppEditor namespace
-
-Q_DECLARE_METATYPE(CppEditor::Internal::Virtuality)
-Q_DECLARE_METATYPE(CppEditor::Internal::VirtualityList)
-
-namespace CppEditor {
-namespace Internal {
-
-void CppEditorPlugin::test_functionhelper_virtualFunctions()
-{
- // Create and parse document
- QFETCH(QByteArray, source);
- QFETCH(VirtualityList, virtualityList);
- Document::Ptr document = Document::create(QLatin1String("virtuals"));
- document->setUtf8Source(source);
- document->check(); // calls parse();
- QCOMPARE(document->diagnosticMessages().size(), 0);
- QVERIFY(document->translationUnit()->ast());
-
- // Iterate through Function symbols
- Snapshot snapshot;
- snapshot.insert(document);
- Control *control = document->translationUnit()->control();
- Symbol **end = control->lastSymbol();
- for (Symbol **it = control->firstSymbol(); it != end; ++it) {
- const CPlusPlus::Symbol *symbol = *it;
- if (const Function *function = symbol->asFunction()) {
- QTC_ASSERT(!virtualityList.isEmpty(), return);
- Virtuality virtuality = virtualityList.takeFirst();
- if (FunctionHelper::isVirtualFunction(function, snapshot)) {
- if (FunctionHelper::isPureVirtualFunction(function, snapshot))
- QCOMPARE(virtuality, PureVirtual);
- else
- QCOMPARE(virtuality, Virtual);
- } else {
- QCOMPARE(virtuality, NotVirtual);
- }
- }
- }
- QVERIFY(virtualityList.isEmpty());
-}
-
-void CppEditorPlugin::test_functionhelper_virtualFunctions_data()
-{
- typedef QByteArray _;
- QTest::addColumn<QByteArray>("source");
- QTest::addColumn<VirtualityList>("virtualityList");
-
- QTest::newRow("none")
- << _("struct None { void foo() {} };\n")
- << (VirtualityList() << NotVirtual);
-
- QTest::newRow("single-virtual")
- << _("struct V { virtual void foo() {} };\n")
- << (VirtualityList() << Virtual);
-
- QTest::newRow("single-pure-virtual")
- << _("struct PV { virtual void foo() = 0; };\n")
- << (VirtualityList() << PureVirtual);
-
- QTest::newRow("virtual-derived-with-specifier")
- << _("struct Base { virtual void foo() {} };\n"
- "struct Derived : Base { virtual void foo() {} };\n")
- << (VirtualityList() << Virtual << Virtual);
-
- QTest::newRow("virtual-derived-implicit")
- << _("struct Base { virtual void foo() {} };\n"
- "struct Derived : Base { void foo() {} };\n")
- << (VirtualityList() << Virtual << Virtual);
-
- QTest::newRow("not-virtual-then-virtual")
- << _("struct Base { void foo() {} };\n"
- "struct Derived : Base { virtual void foo() {} };\n")
- << (VirtualityList() << NotVirtual << Virtual);
-
- QTest::newRow("virtual-final-not-virtual")
- << _("struct Base { virtual void foo() {} };\n"
- "struct Derived : Base { void foo() final {} };\n"
- "struct Derived2 : Derived { void foo() {} };")
- << (VirtualityList() << Virtual << Virtual << NotVirtual);
-
- QTest::newRow("virtual-then-pure")
- << _("struct Base { virtual void foo() {} };\n"
- "struct Derived : Base { virtual void foo() = 0; };\n"
- "struct Derived2 : Derived { void foo() {} };")
- << (VirtualityList() << Virtual << PureVirtual << Virtual);
-
- QTest::newRow("virtual-virtual-final-not-virtual")
- << _("struct Base { virtual void foo() {} };\n"
- "struct Derived : Base { virtual void foo() final {} };\n"
- "struct Derived2 : Derived { void foo() {} };")
- << (VirtualityList() << Virtual << Virtual << NotVirtual);
-
- QTest::newRow("ctor-virtual-dtor")
- << _("struct Base { Base() {} virtual ~Base() {} };\n")
- << (VirtualityList() << NotVirtual << Virtual);
-}
-
-} // namespace Internal
-} // namespace CppEditor
-
-#endif
diff --git a/src/plugins/cppeditor/cppvirtualfunctionassistprovider.h b/src/plugins/cppeditor/cppvirtualfunctionassistprovider.h
index f0a3a6c013..45d6245ca7 100644
--- a/src/plugins/cppeditor/cppvirtualfunctionassistprovider.h
+++ b/src/plugins/cppeditor/cppvirtualfunctionassistprovider.h
@@ -70,21 +70,6 @@ private:
Parameters m_params;
};
-class FunctionHelper
-{
-public:
- static bool isVirtualFunction(const CPlusPlus::Function *function,
- const CPlusPlus::Snapshot &snapshot);
-
- static bool isPureVirtualFunction(const CPlusPlus::Function *function,
- const CPlusPlus::Snapshot &snapshot);
-
- static QList<CPlusPlus::Symbol *> overrides(CPlusPlus::Function *function,
- CPlusPlus::Class *functionsClass,
- CPlusPlus::Class *staticClass,
- const CPlusPlus::Snapshot &snapshot);
-};
-
} // namespace Internal
} // namespace CppEditor
diff --git a/src/plugins/cppeditor/fileandtokenactions_test.cpp b/src/plugins/cppeditor/fileandtokenactions_test.cpp
index 51c56fef06..156a4d0676 100644
--- a/src/plugins/cppeditor/fileandtokenactions_test.cpp
+++ b/src/plugins/cppeditor/fileandtokenactions_test.cpp
@@ -27,26 +27,28 @@
**
****************************************************************************/
-#include <cplusplus/CppDocument.h>
-#include <cplusplus/TranslationUnit.h>
+#include "cppeditor.h"
+#include "cppeditorplugin.h"
+#include "cppeditortestcase.h"
+#include "cppquickfix.h"
+#include "cppquickfix_test_utils.h"
+#include "cppquickfixassistant.h"
+#include "cppquickfixes.h"
#include <coreplugin/editormanager/editormanager.h>
-#include <cppeditor/cppeditor.h>
-#include <cppeditor/cppeditorplugin.h>
-#include <cppeditor/cppquickfixassistant.h>
-#include <cppeditor/cppquickfixes.h>
-#include <cppeditor/cppquickfix.h>
-#include <cppeditor/cppquickfix_test_utils.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <cpptools/cpptoolsplugin.h>
#include <extensionsystem/pluginmanager.h>
-#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
+#include <projectexplorer/projectexplorer.h>
#include <texteditor/basetextdocument.h>
+#include <cplusplus/CppDocument.h>
+#include <cplusplus/TranslationUnit.h>
+
#include <QDebug>
-#include <QtAlgorithms>
#include <QTextDocument>
+#include <QtAlgorithms>
#include <QtTest>
#if QT_VERSION >= 0x050000
@@ -81,7 +83,7 @@ using namespace TextEditor;
namespace {
-class TestActionsTestCase
+class TestActionsTestCase : public CppEditor::Internal::Tests::TestCase
{
public:
class AbstractAction
@@ -97,8 +99,8 @@ public:
public:
/// Run the given fileActions for each file and the given tokenActions for each token.
/// The cursor is positioned on the very first character of each token.
- void run(const Actions &tokenActions = Actions(),
- const Actions &fileActions = Actions());
+ TestActionsTestCase(const Actions &tokenActions = Actions(),
+ const Actions &fileActions = Actions());
/// Simulate pressing ESC, which will close popups, search results pane, etc...
/// This works only if the Qt Creator window is active.
@@ -132,14 +134,21 @@ bool TestActionsTestCase::allProjectsConfigured = false;
typedef TestActionsTestCase::Actions Actions;
typedef TestActionsTestCase::ActionPointer ActionPointer;
-void TestActionsTestCase::run(const Actions &tokenActions, const Actions &fileActions)
+Actions singleAction(const ActionPointer &action)
+{
+ return Actions() << action;
+}
+
+TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Actions &fileActions)
+ : CppEditor::Internal::Tests::TestCase(/*runGarbageCollector=*/false)
{
- CppModelManagerInterface *mm = CppModelManagerInterface::instance();
+ QVERIFY(succeededSoFar());
// Collect files to process
QStringList filesToOpen;
QList<QPointer<ProjectExplorer::Project> > projects;
- const QList<CppModelManagerInterface::ProjectInfo> projectInfos = mm->projectInfos();
+ const QList<CppModelManagerInterface::ProjectInfo> projectInfos
+ = m_modelManager->projectInfos();
if (projectInfos.isEmpty())
MSKIP_SINGLE("No project(s) loaded. Test operates only on loaded projects.");
@@ -175,18 +184,16 @@ void TestActionsTestCase::run(const Actions &tokenActions, const Actions &fileAc
// Open editor
QCOMPARE(EditorManager::documentModel()->openedDocuments().size(), 0);
- CPPEditor *editor = dynamic_cast<CPPEditor *>(EditorManager::openEditor(filePath));
- QVERIFY(editor);
+ CPPEditor *editor;
+ CPPEditorWidget *editorWidget;
+ QVERIFY(openCppEditor(filePath, &editor, &editorWidget));
+
QCOMPARE(EditorManager::documentModel()->openedDocuments().size(), 1);
- QVERIFY(mm->isCppEditor(editor));
- QVERIFY(mm->workingCopy().contains(filePath));
+ QVERIFY(m_modelManager->isCppEditor(editor));
+ QVERIFY(m_modelManager->workingCopy().contains(filePath));
// Rehighlight
- CPPEditorWidget *editorWidget = dynamic_cast<CPPEditorWidget *>(editor->editorWidget());
- QVERIFY(editorWidget);
- editorWidget->semanticRehighlight(true);
- while (editorWidget->semanticInfo().doc.isNull())
- QApplication::processEvents();
+ waitForRehighlightedSemanticDocument(editorWidget);
// Run all file actions
executeActionsOnEditorWidget(editorWidget, fileActions);
@@ -194,7 +201,7 @@ void TestActionsTestCase::run(const Actions &tokenActions, const Actions &fileAc
if (tokenActions.empty())
continue;
- Snapshot snapshot = mm->snapshot();
+ const Snapshot snapshot = globalSnapshot();
Document::Ptr document = snapshot.preprocessedDocument(
editorWidget->document()->toPlainText().toUtf8(), filePath);
QVERIFY(document);
@@ -436,8 +443,7 @@ void InvokeCompletionTokenAction::run(CPPEditorWidget *editorWidget)
// editorWidget->setFocus();
QApplication::processEvents();
- BaseTextDocument *doc = qobject_cast<BaseTextDocument *>(editorWidget->editorDocument());
- TestActionsTestCase::undoChangesInDocument(doc);
+ TestActionsTestCase::undoChangesInDocument(editorWidget->baseTextDocument());
}
class RunAllQuickFixesTokenAction : public TestActionsTestCase::AbstractAction
@@ -511,88 +517,51 @@ void SwitchHeaderSourceFileAction::run(CPPEditorWidget *)
void CppEditorPlugin::test_openEachFile()
{
- TestActionsTestCase test;
- test.run();
+ TestActionsTestCase();
}
void CppEditorPlugin::test_switchHeaderSourceOnEachFile()
{
- Actions fileActions;
- fileActions << ActionPointer(new SwitchHeaderSourceFileAction);
-
- TestActionsTestCase test;
- test.run(Actions(), fileActions);
+ TestActionsTestCase(Actions(), singleAction(ActionPointer(new SwitchHeaderSourceFileAction)));
}
void CppEditorPlugin::test_moveTokenWiseThroughEveryFile()
{
- Actions tokenActions;
- tokenActions << ActionPointer(new NoOpTokenAction());
-
- TestActionsTestCase test;
- test.run(tokenActions);
+ TestActionsTestCase(singleAction(ActionPointer(new NoOpTokenAction)));
}
/// May block if file does not exists (e.g. a not generated ui_* file).
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndFollowSymbol()
{
- Actions tokenActions;
- tokenActions << ActionPointer(new FollowSymbolUnderCursorTokenAction());
-
- TestActionsTestCase test;
- test.run(tokenActions);
+ TestActionsTestCase(singleAction(ActionPointer(new FollowSymbolUnderCursorTokenAction)));
}
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndSwitchDeclarationDefinition()
{
- Actions tokenActions;
- tokenActions << ActionPointer(new SwitchDeclarationDefinitionTokenAction());
-
- TestActionsTestCase test;
- test.run(tokenActions);
+ TestActionsTestCase(singleAction(ActionPointer(new SwitchDeclarationDefinitionTokenAction)));
}
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndFindUsages()
{
- Actions tokenActions;
- tokenActions << ActionPointer(new FindUsagesTokenAction());
-
- TestActionsTestCase test;
- test.run(tokenActions);
+ TestActionsTestCase(singleAction(ActionPointer(new FindUsagesTokenAction)));
}
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndRenameUsages()
{
- Actions tokenActions;
- tokenActions << ActionPointer(new RenameSymbolUnderCursorTokenAction());
-
- TestActionsTestCase test;
- test.run(tokenActions);
+ TestActionsTestCase(singleAction(ActionPointer(new RenameSymbolUnderCursorTokenAction)));
}
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndOpenTypeHierarchy()
{
- Actions tokenActions;
- tokenActions << ActionPointer(new OpenTypeHierarchyTokenAction());
-
- TestActionsTestCase test;
- test.run(tokenActions);
+ TestActionsTestCase(singleAction(ActionPointer(new OpenTypeHierarchyTokenAction)));
}
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndInvokeCompletion()
{
- Actions tokenActions;
- tokenActions << ActionPointer(new InvokeCompletionTokenAction());
-
- TestActionsTestCase test;
- test.run(tokenActions);
+ TestActionsTestCase(singleAction(ActionPointer(new InvokeCompletionTokenAction)));
}
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndTriggerQuickFixes()
{
- Actions tokenActions;
- tokenActions << ActionPointer(new RunAllQuickFixesTokenAction());
-
- TestActionsTestCase test;
- test.run(tokenActions);
+ TestActionsTestCase(singleAction(ActionPointer(new RunAllQuickFixesTokenAction)));
}
diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
index e41974f8ad..c9e763cb3a 100644
--- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
+++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
@@ -29,20 +29,21 @@
#include "cppeditor.h"
#include "cppeditorplugin.h"
+#include "cppeditortestcase.h"
#include "cppelementevaluator.h"
#include "cppvirtualfunctionassistprovider.h"
#include "cppvirtualfunctionproposalitem.h"
-#include <texteditor/codeassist/iassistproposal.h>
-#include <texteditor/codeassist/iassistprocessor.h>
#include <texteditor/codeassist/basicproposalitemlistmodel.h>
+#include <texteditor/codeassist/iassistprocessor.h>
+#include <texteditor/codeassist/iassistproposal.h>
+
#include <utils/fileutils.h>
#include <QDebug>
#include <QDir>
#include <QtTest>
-
/*!
Tests for Follow Symbol Under Cursor and Switch Between Function Declaration/Definition
@@ -53,6 +54,7 @@
You can find potential test code for Follow Symbol Under Cursor on the bottom of this file.
*/
+
using namespace CPlusPlus;
using namespace CppEditor;
using namespace CppEditor::Internal;
@@ -168,74 +170,53 @@ typedef QSharedPointer<TestDocument> TestDocumentPtr;
* - a '@' character denotes the initial text cursor position
* - a '$' character denotes the target text cursor position
*/
-class TestDocument
+class TestDocument : public CppEditor::Internal::Tests::TestDocument
{
public:
- TestDocument(const QByteArray &theSource, const QString &fileName)
- : source(theSource)
- , fileName(fileName)
- , initialCursorPosition(source.indexOf('@'))
- , targetCursorPosition(source.indexOf('$'))
- , editor(0)
- , editorWidget(0)
+ TestDocument(const QByteArray &source, const QByteArray &fileName)
+ : CppEditor::Internal::Tests::TestDocument(fileName, source)
+ , m_targetCursorPosition(source.indexOf('$'))
{
- if (initialCursorPosition != -1 || targetCursorPosition != -1)
- QVERIFY(initialCursorPosition != targetCursorPosition);
-
- if (initialCursorPosition > targetCursorPosition) {
- source.remove(initialCursorPosition, 1);
- if (targetCursorPosition != -1) {
- source.remove(targetCursorPosition, 1);
- --initialCursorPosition;
+ if (m_cursorPosition != -1 || m_targetCursorPosition != -1)
+ QVERIFY(m_cursorPosition != m_targetCursorPosition);
+
+ if (m_cursorPosition > m_targetCursorPosition) {
+ m_source.remove(m_cursorPosition, 1);
+ if (m_targetCursorPosition != -1) {
+ m_source.remove(m_targetCursorPosition, 1);
+ --m_cursorPosition;
}
} else {
- source.remove(targetCursorPosition, 1);
- if (initialCursorPosition != -1) {
- source.remove(initialCursorPosition, 1);
- --targetCursorPosition;
+ m_source.remove(m_targetCursorPosition, 1);
+ if (m_cursorPosition != -1) {
+ m_source.remove(m_cursorPosition, 1);
+ --m_targetCursorPosition;
}
}
}
- static TestDocumentPtr create(const QByteArray &theOriginalSource, const QString &fileName)
- {
- return TestDocumentPtr(new TestDocument(theOriginalSource, fileName));
- }
-
- bool hasInitialCursorMarker() const { return initialCursorPosition != -1; }
- bool hasTargetCursorMarker() const { return targetCursorPosition != -1; }
-
- QString filePath() const
- {
- if (directoryPath.isEmpty())
- qDebug() << "directoryPath not set!";
- return directoryPath + QLatin1Char('/') + fileName;
- }
-
- void writeToDisk() const
+ static TestDocumentPtr create(const QByteArray &source, const QByteArray &fileName)
{
- Utils::FileSaver srcSaver(filePath());
- srcSaver.write(source);
- srcSaver.finalize();
+ return TestDocumentPtr(new TestDocument(source, fileName));
}
- QByteArray source;
+ bool hasTargetCursorMarker() const { return m_targetCursorPosition != -1; }
- const QString fileName;
- QString directoryPath;
- int initialCursorPosition;
- int targetCursorPosition;
-
- CPPEditor *editor;
- CPPEditorWidget *editorWidget;
+public:
+ int m_targetCursorPosition;
};
+QList<TestDocumentPtr> singleDocument(const QByteArray &source)
+{
+ return QList<TestDocumentPtr>() << TestDocument::create(source, "file.cpp");
+}
+
/**
* Encapsulates the whole process of setting up several editors, positioning the cursor,
* executing Follow Symbol Under Cursor or Switch Between Function Declaration/Definition
* and checking the result.
*/
-class TestCase
+class F2TestCase : public CppEditor::Internal::Tests::TestCase
{
public:
enum CppEditorAction {
@@ -243,163 +224,66 @@ public:
SwitchBetweenMethodDeclarationDefinitionAction
};
- TestCase(CppEditorAction action, const QByteArray &source,
- const OverrideItemList &expectedVirtualFunctionProposal = OverrideItemList());
- TestCase(CppEditorAction action, const QList<TestDocumentPtr> theTestFiles,
- const OverrideItemList &expectedVirtualFunctionProposal = OverrideItemList());
- ~TestCase();
-
- void run();
+ F2TestCase(CppEditorAction action,
+ const QList<TestDocumentPtr> testFiles,
+ const OverrideItemList &expectedVirtualFunctionProposal = OverrideItemList());
private:
- TestCase(const TestCase &);
- TestCase &operator=(const TestCase &);
-
- void init();
-
- TestDocumentPtr testFileWithInitialCursorMarker();
- TestDocumentPtr testFileWithTargetCursorMarker();
-
-private:
- CppEditorAction m_action;
- QList<TestDocumentPtr> m_testFiles;
- OverrideItemList m_expectedVirtualFunctionProposal;
+ static TestDocumentPtr testFileWithInitialCursorMarker(const QList<TestDocumentPtr> &testFiles);
+ static TestDocumentPtr testFileWithTargetCursorMarker(const QList<TestDocumentPtr> &testFiles);
};
-/// Convenience function for creating a TestDocument.
-/// See TestDocument.
-TestCase::TestCase(CppEditorAction action, const QByteArray &source,
- const OverrideItemList &expectedVirtualFunctionProposal)
- : m_action(action)
- , m_expectedVirtualFunctionProposal(expectedVirtualFunctionProposal)
-{
- m_testFiles << TestDocument::create(source, QLatin1String("file.cpp"));
- init();
-}
-
/// Creates a test case with multiple test files.
/// Exactly one test document must be provided that contains '@', the initial position marker.
/// Exactly one test document must be provided that contains '$', the target position marker.
/// It can be the same document.
-TestCase::TestCase(CppEditorAction action, const QList<TestDocumentPtr> theTestFiles,
- const OverrideItemList &expectedVirtualFunctionProposal)
- : m_action(action)
- , m_testFiles(theTestFiles)
- , m_expectedVirtualFunctionProposal(expectedVirtualFunctionProposal)
+F2TestCase::F2TestCase(CppEditorAction action,
+ const QList<TestDocumentPtr> testFiles,
+ const OverrideItemList &expectedVirtualFunctionProposal)
{
- init();
-}
+ QVERIFY(succeededSoFar());
-void TestCase::init()
-{
// Check if there are initial and target position markers
- QVERIFY2(testFileWithInitialCursorMarker(),
+ TestDocumentPtr initialTestFile = testFileWithInitialCursorMarker(testFiles);
+ QVERIFY2(initialTestFile,
"No test file with initial cursor marker is provided.");
- QVERIFY2(testFileWithTargetCursorMarker(),
+ TestDocumentPtr targetTestFile = testFileWithTargetCursorMarker(testFiles);
+ QVERIFY2(targetTestFile,
"No test file with target cursor marker is provided.");
// Write files to disk
- const QString directoryPath = QDir::tempPath();
- foreach (TestDocumentPtr testFile, m_testFiles) {
- testFile->directoryPath = directoryPath;
- testFile->writeToDisk();
- }
+ foreach (TestDocumentPtr testFile, testFiles)
+ QVERIFY(testFile->writeToDisk());
// Update Code Model
QStringList filePaths;
- foreach (const TestDocumentPtr &testFile, m_testFiles)
+ foreach (const TestDocumentPtr &testFile, testFiles)
filePaths << testFile->filePath();
- CppTools::CppModelManagerInterface::instance()->updateSourceFiles(filePaths);
-
- // Wait for the indexer to process all files.
- // All these files are "Fast Checked", that is the function bodies are not processed.
- QStringList filePathsNotYetInSnapshot(filePaths);
- forever {
- Snapshot snapshot = CppTools::CppModelManagerInterface::instance()->snapshot();
- foreach (const QString &filePath, filePathsNotYetInSnapshot) {
- if (snapshot.contains(filePath))
- filePathsNotYetInSnapshot.removeOne(filePath);
- }
- if (filePathsNotYetInSnapshot.isEmpty())
- break;
- QCoreApplication::processEvents();
- }
+ QVERIFY(parseFiles(filePaths));
// Open Files
- foreach (TestDocumentPtr testFile, m_testFiles) {
- testFile->editor
- = dynamic_cast<CPPEditor *>(EditorManager::openEditor(testFile->filePath()));
- QVERIFY(testFile->editor);
-
- testFile->editorWidget = dynamic_cast<CPPEditorWidget *>(testFile->editor->editorWidget());
- QVERIFY(testFile->editorWidget);
+ foreach (TestDocumentPtr testFile, testFiles) {
+ QVERIFY(openCppEditor(testFile->filePath(), &testFile->m_editor,
+ &testFile->m_editorWidget));
+ closeEditorAtEndOfTestCase(testFile->m_editor);
// Wait until the indexer processed the just opened file.
// The file is "Full Checked" since it is in the working copy now,
// that is the function bodies are processed.
forever {
- Snapshot snapshot = CppTools::CppModelManagerInterface::instance()->snapshot();
- if (Document::Ptr document = snapshot.document(testFile->filePath())) {
- if (document->checkMode() == Document::FullCheck)
- break;
- QCoreApplication::processEvents();
- }
+ const Document::Ptr document = waitForFileInGlobalSnapshot(testFile->filePath());
+ if (document->checkMode() == Document::FullCheck)
+ break;
}
// Rehighlight
- testFile->editorWidget->semanticRehighlight(true);
- // Wait for the semantic info from the future
- while (testFile->editorWidget->semanticInfo().doc.isNull())
- QCoreApplication::processEvents();
- }
-}
-
-TestCase::~TestCase()
-{
- // Close editors
- QList<Core::IEditor *> editorsToClose;
- foreach (const TestDocumentPtr testFile, m_testFiles) {
- if (testFile->editor)
- editorsToClose << testFile->editor;
- }
- EditorManager::closeEditors(editorsToClose, false);
- QCoreApplication::processEvents(); // process any pending events
-
- // Remove the test files from the code-model
- CppModelManagerInterface *mmi = CppTools::CppModelManagerInterface::instance();
- mmi->GC();
- QCOMPARE(mmi->snapshot().size(), 0);
-}
-
-TestDocumentPtr TestCase::testFileWithInitialCursorMarker()
-{
- foreach (const TestDocumentPtr testFile, m_testFiles) {
- if (testFile->hasInitialCursorMarker())
- return testFile;
- }
- return TestDocumentPtr();
-}
-
-TestDocumentPtr TestCase::testFileWithTargetCursorMarker()
-{
- foreach (const TestDocumentPtr testFile, m_testFiles) {
- if (testFile->hasTargetCursorMarker())
- return testFile;
+ waitForRehighlightedSemanticDocument(testFile->m_editorWidget);
}
- return TestDocumentPtr();
-}
-
-void TestCase::run()
-{
- TestDocumentPtr initialTestFile = testFileWithInitialCursorMarker();
- QVERIFY(initialTestFile);
- TestDocumentPtr targetTestFile = testFileWithTargetCursorMarker();
- QVERIFY(targetTestFile);
// Activate editor of initial test file
- EditorManager::activateEditor(initialTestFile->editor);
+ EditorManager::activateEditor(initialTestFile->m_editor);
- initialTestFile->editor->setCursorPosition(initialTestFile->initialCursorPosition);
+ initialTestFile->m_editor->setCursorPosition(initialTestFile->m_cursorPosition);
// qDebug() << "Initial line:" << initialTestFile->editor->currentLine();
// qDebug() << "Initial column:" << initialTestFile->editor->currentColumn() - 1;
@@ -407,9 +291,9 @@ void TestCase::run()
OverrideItemList finalVirtualSymbolResults;
// Trigger the action
- switch (m_action) {
+ switch (action) {
case FollowSymbolUnderCursorAction: {
- CPPEditorWidget *widget = initialTestFile->editorWidget;
+ CPPEditorWidget *widget = initialTestFile->m_editorWidget;
FollowSymbolUnderCursor *delegate = widget->followSymbolUnderCursorDelegate();
VirtualFunctionAssistProvider *original = delegate->virtualFunctionAssistProvider();
@@ -417,7 +301,7 @@ void TestCase::run()
QScopedPointer<VirtualFunctionTestAssistProvider> testProvider(
new VirtualFunctionTestAssistProvider(widget));
delegate->setVirtualFunctionAssistProvider(testProvider.data());
- initialTestFile->editorWidget->openLinkUnderCursor();
+ initialTestFile->m_editorWidget->openLinkUnderCursor();
immediateVirtualSymbolResults = testProvider->m_immediateItems;
finalVirtualSymbolResults = testProvider->m_finalItems;
@@ -442,7 +326,7 @@ void TestCase::run()
QCOMPARE(currentTextEditor->document()->filePath(), targetTestFile->filePath());
int expectedLine, expectedColumn;
- currentTextEditor->convertPosition(targetTestFile->targetCursorPosition,
+ currentTextEditor->convertPosition(targetTestFile->m_targetCursorPosition,
&expectedLine, &expectedColumn);
// qDebug() << "Expected line:" << expectedLine;
// qDebug() << "Expected column:" << expectedColumn;
@@ -454,13 +338,30 @@ void TestCase::run()
// qDebug() << immediateVirtualSymbolResults;
// qDebug() << finalVirtualSymbolResults;
OverrideItemList expectedImmediate;
- if (!m_expectedVirtualFunctionProposal.isEmpty()) {
- expectedImmediate << m_expectedVirtualFunctionProposal.first();
+ if (!expectedVirtualFunctionProposal.isEmpty()) {
+ expectedImmediate << expectedVirtualFunctionProposal.first();
expectedImmediate << OverrideItem(QLatin1String("...searching overrides"));
}
QCOMPARE(immediateVirtualSymbolResults, expectedImmediate);
- QEXPECT_FAIL("differentReturnTypes", "Doesn't work", Abort);
- QCOMPARE(finalVirtualSymbolResults, m_expectedVirtualFunctionProposal);
+ QCOMPARE(finalVirtualSymbolResults, expectedVirtualFunctionProposal);
+}
+
+TestDocumentPtr F2TestCase::testFileWithInitialCursorMarker(const QList<TestDocumentPtr> &testFiles)
+{
+ foreach (const TestDocumentPtr testFile, testFiles) {
+ if (testFile->hasCursorMarker())
+ return testFile;
+ }
+ return TestDocumentPtr();
+}
+
+TestDocumentPtr F2TestCase::testFileWithTargetCursorMarker(const QList<TestDocumentPtr> &testFiles)
+{
+ foreach (const TestDocumentPtr testFile, testFiles) {
+ if (testFile->hasTargetCursorMarker())
+ return testFile;
+ }
+ return TestDocumentPtr();
}
} // anonymous namespace
@@ -558,12 +459,11 @@ void CppEditorPlugin::test_SwitchMethodDeclarationDefinition()
QFETCH(QByteArray, header);
QFETCH(QByteArray, source);
- QList<TestDocumentPtr> testFiles;
- testFiles << TestDocument::create(header, QLatin1String("file.h"));
- testFiles << TestDocument::create(source, QLatin1String("file.cpp"));
+ const QList<TestDocumentPtr> testFiles = QList<TestDocumentPtr>()
+ << TestDocument::create(header, "file.h")
+ << TestDocument::create(source, "file.cpp");
- TestCase test(TestCase::SwitchBetweenMethodDeclarationDefinitionAction, testFiles);
- test.run();
+ F2TestCase(F2TestCase::SwitchBetweenMethodDeclarationDefinitionAction, testFiles);
}
void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
@@ -834,8 +734,8 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
);
// 3.3.10 Name hiding (par 2.), from text
- // A class name (9.1) or enumeration name (7.2) can be hidden by the name of a variable, data member,
- // function, or enumerator declared in the same scope.
+ // A class name (9.1) or enumeration name (7.2) can be hidden by the name of a variable,
+ // data member, function, or enumerator declared in the same scope.
QTest::newRow("funLocalVarHidesOuterClass") << _(
"struct C {};\n"
"\n"
@@ -923,8 +823,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
void CppEditorPlugin::test_FollowSymbolUnderCursor()
{
QFETCH(QByteArray, source);
- TestCase test(TestCase::FollowSymbolUnderCursorAction, source);
- test.run();
+ F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
}
void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments_data()
@@ -933,27 +832,25 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments_data()
QTest::newRow("skipForwardDeclarationBasic") << (QList<TestDocumentPtr>()
<< TestDocument::create("class $Foo {};\n",
- QLatin1String("defined.h"))
+ "defined.h")
<< TestDocument::create("class Foo;\n"
"@Foo foo;\n",
- QLatin1String("forwardDeclaredAndUsed.h"))
+ "forwardDeclaredAndUsed.h")
);
QTest::newRow("skipForwardDeclarationTemplates") << (QList<TestDocumentPtr>()
<< TestDocument::create("template <class E> class $Container {};\n",
- QLatin1String("defined.h"))
+ "defined.h")
<< TestDocument::create("template <class E> class Container;\n"
"@Container<int> container;\n",
- QLatin1String("forwardDeclaredAndUsed.h"))
+ "forwardDeclaredAndUsed.h")
);
}
void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments()
{
QFETCH(QList<TestDocumentPtr>, documents);
-
- TestCase test(TestCase::FollowSymbolUnderCursorAction, documents);
- test.run();
+ F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, documents);
}
void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_connect_data()
@@ -1042,8 +939,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_connect()
return;
}
- TestCase test(TestCase::FollowSymbolUnderCursorAction, source);
- test.run();
+ F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
}
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_onOperatorToken_data()
@@ -1066,8 +962,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_onOperatorToken
"}\n";
if (toDeclaration)
source.replace('@', '#').replace('$', '@').replace('#', '$');
- TestCase test(TestCase::FollowSymbolUnderCursorAction, source);
- test.run();
+ F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
}
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_data()
@@ -1092,8 +987,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator()
else
source.replace("@2", QByteArray()).replace("$2", QByteArray())
.replace("@1", "@").replace("$1", "$");
- TestCase test(TestCase::FollowSymbolUnderCursorAction, source);
- test.run();
+ F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
}
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_inOp_data()
@@ -1118,8 +1012,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_inOp()
else
source.replace("@2", QByteArray()).replace("$2", QByteArray())
.replace("@1", "@").replace("$1", "$");
- TestCase test(TestCase::FollowSymbolUnderCursorAction, source);
- test.run();
+ F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
}
void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
@@ -1178,7 +1071,8 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
<< OverrideItem(QLatin1String("CD1::virt"), 11)
<< OverrideItem(QLatin1String("CD2::virt"), 14));
- /// Check: Virtual function call in member of class hierarchy, only possible overrides are presented.
+ /// Check: Virtual function call in member of class hierarchy,
+ /// only possible overrides are presented.
QTest::newRow("possibleOverrides2") << _(
"struct A { virtual void virt(); };\n"
"void A::virt() {}\n"
@@ -1400,8 +1294,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall()
QFETCH(QByteArray, source);
QFETCH(OverrideItemList, results);
- TestCase test(TestCase::FollowSymbolUnderCursorAction, source, results);
- test.run();
+ F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source), results);
}
/// Check: Base classes can be found although these might be defined in distinct documents.
@@ -1409,21 +1302,20 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_multipleD
{
QList<TestDocumentPtr> testFiles = QList<TestDocumentPtr>()
<< TestDocument::create("struct A { virtual void virt(int) = 0; };\n",
- QLatin1String("a.h"))
+ "a.h")
<< TestDocument::create("#include \"a.h\"\n"
"struct B : A { void virt(int) {} };\n",
- QLatin1String("b.h"))
+ "b.h")
<< TestDocument::create("#include \"a.h\"\n"
"void f(A *o) { o->$@virt(42); }\n",
- QLatin1String("u.cpp"))
+ "u.cpp")
;
const OverrideItemList finalResults = OverrideItemList()
<< OverrideItem(QLatin1String("A::virt"), 1)
<< OverrideItem(QLatin1String("B::virt"), 2);
- TestCase test(TestCase::FollowSymbolUnderCursorAction, testFiles, finalResults);
- test.run();
+ F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, testFiles, finalResults);
}
/*
diff --git a/src/plugins/cpptools/builtinindexingsupport.cpp b/src/plugins/cpptools/builtinindexingsupport.cpp
index faec76d150..0e7542a2d7 100644
--- a/src/plugins/cpptools/builtinindexingsupport.cpp
+++ b/src/plugins/cpptools/builtinindexingsupport.cpp
@@ -92,7 +92,7 @@ public:
~BuiltinSymbolSearcher()
{}
- void runSearch(QFutureInterface<Find::SearchResultItem> &future)
+ void runSearch(QFutureInterface<Core::SearchResultItem> &future)
{
future.setProgressRange(0, m_snapshot.size());
future.setProgressValue(0);
@@ -102,11 +102,11 @@ public:
search.setSymbolsToSearchFor(m_parameters.types);
CPlusPlus::Snapshot::const_iterator it = m_snapshot.begin();
- QString findString = (m_parameters.flags & Find::FindRegularExpression
+ QString findString = (m_parameters.flags & Core::FindRegularExpression
? m_parameters.text : QRegExp::escape(m_parameters.text));
- if (m_parameters.flags & Find::FindWholeWords)
+ if (m_parameters.flags & Core::FindWholeWords)
findString = QString::fromLatin1("\\b%1\\b").arg(findString);
- QRegExp matcher(findString, (m_parameters.flags & Find::FindCaseSensitively
+ QRegExp matcher(findString, (m_parameters.flags & Core::FindCaseSensitively
? Qt::CaseSensitive : Qt::CaseInsensitive));
while (it != m_snapshot.end()) {
if (future.isPaused())
@@ -114,7 +114,7 @@ public:
if (future.isCanceled())
break;
if (m_fileNames.isEmpty() || m_fileNames.contains(it.value()->fileName())) {
- QVector<Find::SearchResultItem> resultItems;
+ QVector<Core::SearchResultItem> resultItems;
QList<ModelItemInfo> modelInfos = search(it.value());
foreach (const ModelItemInfo &info, modelInfos) {
int index = matcher.indexIn(info.symbolName);
@@ -130,7 +130,7 @@ public:
info.symbolType);
}
- Find::SearchResultItem item;
+ Core::SearchResultItem item;
item.path = scope.split(QLatin1String("::"), QString::SkipEmptyParts);
item.text = text;
item.textMarkPos = -1;
diff --git a/src/plugins/cpptools/completionsettingspage.cpp b/src/plugins/cpptools/completionsettingspage.cpp
index 111183b2d7..cdf58d94ff 100644
--- a/src/plugins/cpptools/completionsettingspage.cpp
+++ b/src/plugins/cpptools/completionsettingspage.cpp
@@ -56,67 +56,54 @@ CompletionSettingsPage::~CompletionSettingsPage()
delete m_page;
}
-QWidget *CompletionSettingsPage::createPage(QWidget *parent)
+QWidget *CompletionSettingsPage::widget()
{
- QWidget *w = new QWidget(parent);
- m_page = new Ui::CompletionSettingsPage;
- m_page->setupUi(w);
-
- const TextEditor::CompletionSettings &settings =
- TextEditor::TextEditorSettings::completionSettings();
-
- int caseSensitivityIndex = 0;
- switch (settings.m_caseSensitivity) {
- case TextEditor::CaseSensitive:
- caseSensitivityIndex = 0;
- break;
- case TextEditor::CaseInsensitive:
- caseSensitivityIndex = 1;
- break;
- case TextEditor::FirstLetterCaseSensitive:
- caseSensitivityIndex = 2;
- break;
+ if (!m_widget) {
+ m_widget = new QWidget;
+ m_page = new Ui::CompletionSettingsPage;
+ m_page->setupUi(m_widget);
+
+ const TextEditor::CompletionSettings &settings =
+ TextEditor::TextEditorSettings::completionSettings();
+
+ int caseSensitivityIndex = 0;
+ switch (settings.m_caseSensitivity) {
+ case TextEditor::CaseSensitive:
+ caseSensitivityIndex = 0;
+ break;
+ case TextEditor::CaseInsensitive:
+ caseSensitivityIndex = 1;
+ break;
+ case TextEditor::FirstLetterCaseSensitive:
+ caseSensitivityIndex = 2;
+ break;
+ }
+
+ int completionTriggerIndex = 0;
+ switch (settings.m_completionTrigger) {
+ case TextEditor::ManualCompletion:
+ completionTriggerIndex = 0;
+ break;
+ case TextEditor::TriggeredCompletion:
+ completionTriggerIndex = 1;
+ break;
+ case TextEditor::AutomaticCompletion:
+ completionTriggerIndex = 2;
+ break;
+ }
+
+ m_page->caseSensitivity->setCurrentIndex(caseSensitivityIndex);
+ m_page->completionTrigger->setCurrentIndex(completionTriggerIndex);
+ m_page->autoInsertBrackets->setChecked(settings.m_autoInsertBrackets);
+ m_page->surroundSelectedText->setChecked(settings.m_surroundingAutoBrackets);
+ m_page->partiallyComplete->setChecked(settings.m_partiallyComplete);
+ m_page->spaceAfterFunctionName->setChecked(settings.m_spaceAfterFunctionName);
+ m_page->enableDoxygenCheckBox->setChecked(m_commentsSettings.m_enableDoxygen);
+ m_page->generateBriefCheckBox->setChecked(m_commentsSettings.m_generateBrief);
+ m_page->leadingAsterisksCheckBox->setChecked(m_commentsSettings.m_leadingAsterisks);
+ m_page->generateBriefCheckBox->setEnabled(m_page->enableDoxygenCheckBox->isChecked());
}
-
- int completionTriggerIndex = 0;
- switch (settings.m_completionTrigger) {
- case TextEditor::ManualCompletion:
- completionTriggerIndex = 0;
- break;
- case TextEditor::TriggeredCompletion:
- completionTriggerIndex = 1;
- break;
- case TextEditor::AutomaticCompletion:
- completionTriggerIndex = 2;
- break;
- }
-
- m_page->caseSensitivity->setCurrentIndex(caseSensitivityIndex);
- m_page->completionTrigger->setCurrentIndex(completionTriggerIndex);
- m_page->autoInsertBrackets->setChecked(settings.m_autoInsertBrackets);
- m_page->surroundSelectedText->setChecked(settings.m_surroundingAutoBrackets);
- m_page->partiallyComplete->setChecked(settings.m_partiallyComplete);
- m_page->spaceAfterFunctionName->setChecked(settings.m_spaceAfterFunctionName);
- m_page->enableDoxygenCheckBox->setChecked(m_commentsSettings.m_enableDoxygen);
- m_page->generateBriefCheckBox->setChecked(m_commentsSettings.m_generateBrief);
- m_page->leadingAsterisksCheckBox->setChecked(m_commentsSettings.m_leadingAsterisks);
-
- if (m_searchKeywords.isEmpty()) {
- QTextStream(&m_searchKeywords) << m_page->caseSensitivityLabel->text()
- << ' ' << m_page->autoInsertBrackets->text()
- << ' ' << m_page->surroundSelectedText->text()
- << ' ' << m_page->completionTriggerLabel->text()
- << ' ' << m_page->partiallyComplete->text()
- << ' ' << m_page->spaceAfterFunctionName->text()
- << ' ' << m_page->enableDoxygenCheckBox->text()
- << ' ' << m_page->generateBriefCheckBox->text()
- << ' ' << m_page->leadingAsterisksCheckBox->text();
- m_searchKeywords.remove(QLatin1Char('&'));
- }
-
- m_page->generateBriefCheckBox->setEnabled(m_page->enableDoxygenCheckBox->isChecked());
-
- return w;
+ return m_widget;
}
void CompletionSettingsPage::apply()
@@ -144,11 +131,6 @@ void CompletionSettingsPage::apply()
emit commentsSettingsChanged(m_commentsSettings);
}
-bool CompletionSettingsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
TextEditor::CaseSensitivity CompletionSettingsPage::caseSensitivity() const
{
switch (m_page->caseSensitivity->currentIndex()) {
@@ -175,6 +157,7 @@ TextEditor::CompletionTrigger CompletionSettingsPage::completionTrigger() const
void CompletionSettingsPage::finish()
{
+ delete m_widget;
if (!m_page) // page was never shown
return;
delete m_page;
diff --git a/src/plugins/cpptools/completionsettingspage.h b/src/plugins/cpptools/completionsettingspage.h
index 592117fb69..83fa49cec8 100644
--- a/src/plugins/cpptools/completionsettingspage.h
+++ b/src/plugins/cpptools/completionsettingspage.h
@@ -35,6 +35,8 @@
#include <texteditor/completionsettings.h>
#include <texteditor/texteditoroptionspage.h>
+#include <QPointer>
+
namespace CppTools {
namespace Internal {
@@ -52,10 +54,9 @@ public:
CompletionSettingsPage(QObject *parent);
~CompletionSettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &) const;
const CommentsSettings &commentsSettings() const;
@@ -69,7 +70,7 @@ private:
bool requireCommentsSettingsUpdate() const;
Ui::CompletionSettingsPage *m_page;
- QString m_searchKeywords;
+ QPointer<QWidget> m_widget;
CommentsSettings m_commentsSettings;
};
diff --git a/src/plugins/cpptools/completionsettingspage.ui b/src/plugins/cpptools/completionsettingspage.ui
index b500f9095e..3ff7358375 100644
--- a/src/plugins/cpptools/completionsettingspage.ui
+++ b/src/plugins/cpptools/completionsettingspage.ui
@@ -107,7 +107,7 @@
<item row="2" column="0">
<widget class="QCheckBox" name="partiallyComplete">
<property name="toolTip">
- <string>Insert the common prefix of available completion items.</string>
+ <string>Inserts the common prefix of available completion items.</string>
</property>
<property name="text">
<string>Autocomplete common &amp;prefix</string>
@@ -120,7 +120,7 @@
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="autoInsertBrackets">
<property name="toolTip">
- <string>Automatically insert semicolons and closing brackets, parentheses, curly braces, and quotes when appropriate.</string>
+ <string>Automatically inserts semicolons and closing brackets, parentheses, curly braces, and quotes when appropriate.</string>
</property>
<property name="text">
<string>&amp;Automatically insert matching characters</string>
@@ -151,7 +151,7 @@
<item>
<widget class="QCheckBox" name="surroundSelectedText">
<property name="toolTip">
- <string>When typing a matching character and there is a text selection, instead of removing the selection, surround it with the corresponding characters.</string>
+ <string>When typing a matching character and there is a text selection, instead of removing the selection, surrounds it with the corresponding characters.</string>
</property>
<property name="text">
<string>Surround &amp;text selections</string>
@@ -205,7 +205,7 @@
<item>
<widget class="QCheckBox" name="enableDoxygenCheckBox">
<property name="toolTip">
- <string>Automatically create a Doxygen comment upon pressing enter after a /** or /*!</string>
+ <string>Automatically creates a Doxygen comment upon pressing enter after a /**, /*!, //! or ///</string>
</property>
<property name="text">
<string>Enable Doxygen blocks</string>
@@ -233,7 +233,7 @@
<item>
<widget class="QCheckBox" name="generateBriefCheckBox">
<property name="toolTip">
- <string>Generate a &lt;i&gt;brief&lt;/i&gt; command with an initial description for the corresponding declaration</string>
+ <string>Generates a &lt;i&gt;brief&lt;/i&gt; command with an initial description for the corresponding declaration</string>
</property>
<property name="text">
<string>Generate brief description</string>
@@ -245,7 +245,7 @@
<item>
<widget class="QCheckBox" name="leadingAsterisksCheckBox">
<property name="toolTip">
- <string>Add leading asterisks when continuing Qt (/*!) and Java (/**) style comments on new lines</string>
+ <string>Adds leading asterisks when continuing Qt (/*!) and Java (/**) style comments on new lines</string>
</property>
<property name="text">
<string>Add leading asterisks</string>
diff --git a/src/plugins/cpptools/cppclassesfilter.cpp b/src/plugins/cpptools/cppclassesfilter.cpp
index 5809e01520..a32ec4a562 100644
--- a/src/plugins/cpptools/cppclassesfilter.cpp
+++ b/src/plugins/cpptools/cppclassesfilter.cpp
@@ -50,10 +50,10 @@ QList<QList<CppTools::ModelItemInfo> > CppClassesFilter::itemsToMatchUserInputAg
return QList<QList<CppTools::ModelItemInfo> >() << m_data->classes();
}
-Locator::FilterEntry CppClassesFilter::filterEntryFromModelItemInfo(const ModelItemInfo &info)
+Core::LocatorFilterEntry CppClassesFilter::filterEntryFromModelItemInfo(const ModelItemInfo &info)
{
const QVariant id = qVariantFromValue(info);
- Locator::FilterEntry filterEntry(this, info.symbolName, id, info.icon);
+ Core::LocatorFilterEntry filterEntry(this, info.symbolName, id, info.icon);
filterEntry.extraInfo = info.symbolScope.isEmpty()
? info.shortNativeFilePath()
: info.symbolScope;
diff --git a/src/plugins/cpptools/cppclassesfilter.h b/src/plugins/cpptools/cppclassesfilter.h
index ceb02b8e7d..40888d6c33 100644
--- a/src/plugins/cpptools/cppclassesfilter.h
+++ b/src/plugins/cpptools/cppclassesfilter.h
@@ -46,7 +46,7 @@ public:
private:
QList<QList<CppTools::ModelItemInfo> > itemsToMatchUserInputAgainst() const;
- Locator::FilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
+ Core::LocatorFilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
};
} // namespace CppTools
diff --git a/src/plugins/cpptools/cppcodegen_test.cpp b/src/plugins/cpptools/cppcodegen_test.cpp
index 43da0763f0..9b708e5419 100644
--- a/src/plugins/cpptools/cppcodegen_test.cpp
+++ b/src/plugins/cpptools/cppcodegen_test.cpp
@@ -27,8 +27,9 @@
**
****************************************************************************/
-#include "insertionpointlocator.h"
#include "cpptoolsplugin.h"
+#include "cpptoolstestcase.h"
+#include "insertionpointlocator.h"
#include <utils/fileutils.h>
@@ -361,9 +362,7 @@ void CppToolsPlugin::test_codegen_definition_empty_class()
"\n";
Document::Ptr src = Document::create(QDir::tempPath() + QLatin1String("/file.h"));
- Utils::FileSaver srcSaver(src->fileName());
- srcSaver.write(srcText);
- srcSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(src->fileName(), srcText));
src->setUtf8Source(srcText);
src->parse();
src->check();
@@ -371,9 +370,7 @@ void CppToolsPlugin::test_codegen_definition_empty_class()
QCOMPARE(src->globalSymbolCount(), 1U);
Document::Ptr dst = Document::create(QDir::tempPath() + QLatin1String("/file.cpp"));
- Utils::FileSaver dstSaver(dst->fileName());
- dstSaver.write(dstText);
- dstSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(dst->fileName(), dstText));
dst->setUtf8Source(dstText);
dst->parse();
dst->check();
@@ -429,9 +426,7 @@ void CppToolsPlugin::test_codegen_definition_first_member()
"int y;\n").arg(QDir::tempPath()).toLatin1();
Document::Ptr src = Document::create(QDir::tempPath() + QLatin1String("/file.h"));
- Utils::FileSaver srcSaver(src->fileName());
- srcSaver.write(srcText);
- srcSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(src->fileName(), srcText));
src->setUtf8Source(srcText);
src->parse();
src->check();
@@ -441,9 +436,7 @@ void CppToolsPlugin::test_codegen_definition_first_member()
Document::Ptr dst = Document::create(QDir::tempPath() + QLatin1String("/file.cpp"));
dst->addIncludeFile(Document::Include(QLatin1String("file.h"), src->fileName(), 1,
Client::IncludeLocal));
- Utils::FileSaver dstSaver(dst->fileName());
- dstSaver.write(dstText);
- dstSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(dst->fileName(), dstText));
dst->setUtf8Source(dstText);
dst->parse();
dst->check();
@@ -499,9 +492,7 @@ void CppToolsPlugin::test_codegen_definition_last_member()
"int y;\n").arg(QDir::tempPath()).toLatin1();
Document::Ptr src = Document::create(QDir::tempPath() + QLatin1String("/file.h"));
- Utils::FileSaver srcSaver(src->fileName());
- srcSaver.write(srcText);
- srcSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(src->fileName(), srcText));
src->setUtf8Source(srcText);
src->parse();
src->check();
@@ -511,9 +502,7 @@ void CppToolsPlugin::test_codegen_definition_last_member()
Document::Ptr dst = Document::create(QDir::tempPath() + QLatin1String("/file.cpp"));
dst->addIncludeFile(Document::Include(QLatin1String("file.h"), src->fileName(), 1,
Client::IncludeLocal));
- Utils::FileSaver dstSaver(dst->fileName());
- dstSaver.write(dstText);
- dstSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(dst->fileName(), dstText));
dst->setUtf8Source(dstText);
dst->parse();
dst->check();
@@ -575,9 +564,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member()
"int y;\n").arg(QDir::tempPath()).toLatin1();
Document::Ptr src = Document::create(QDir::tempPath() + QLatin1String("/file.h"));
- Utils::FileSaver srcSaver(src->fileName());
- srcSaver.write(srcText);
- srcSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(src->fileName(), srcText));
src->setUtf8Source(srcText);
src->parse();
src->check();
@@ -587,9 +574,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member()
Document::Ptr dst = Document::create(QDir::tempPath() + QLatin1String("/file.cpp"));
dst->addIncludeFile(Document::Include(QLatin1String("file.h"), src->fileName(), 1,
Client::IncludeLocal));
- Utils::FileSaver dstSaver(dst->fileName());
- dstSaver.write(dstText);
- dstSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(dst->fileName(), dstText));
dst->setUtf8Source(dstText);
dst->parse();
dst->check();
@@ -647,9 +632,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member_surrounded_by_undefin
"int y;\n").arg(QDir::tempPath()).toLatin1();
Document::Ptr src = Document::create(QDir::tempPath() + QLatin1String("/file.h"));
- Utils::FileSaver srcSaver(src->fileName());
- srcSaver.write(srcText);
- srcSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(src->fileName(), srcText));
src->setUtf8Source(srcText);
src->parse();
src->check();
@@ -659,9 +642,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member_surrounded_by_undefin
Document::Ptr dst = Document::create(QDir::tempPath() + QLatin1String("/file.cpp"));
dst->addIncludeFile(Document::Include(QLatin1String("file.h"), src->fileName(), 1,
Client::IncludeLocal));
- Utils::FileSaver dstSaver(dst->fileName());
- dstSaver.write(dstText);
- dstSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(dst->fileName(), dstText));
dst->setUtf8Source(dstText);
dst->parse();
dst->check();
@@ -722,9 +703,7 @@ void CppToolsPlugin::test_codegen_definition_member_specific_file()
"int y;\n").arg(QDir::tempPath()).toLatin1();
Document::Ptr src = Document::create(QDir::tempPath() + QLatin1String("/file.h"));
- Utils::FileSaver srcSaver(src->fileName());
- srcSaver.write(srcText);
- srcSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(src->fileName(), srcText));
src->setUtf8Source(srcText);
src->parse();
src->check();
@@ -734,9 +713,7 @@ void CppToolsPlugin::test_codegen_definition_member_specific_file()
Document::Ptr dst = Document::create(QDir::tempPath() + QLatin1String("/file.cpp"));
dst->addIncludeFile(Document::Include(QLatin1String("file.h"), src->fileName(), 1,
Client::IncludeLocal));
- Utils::FileSaver dstSaver(dst->fileName());
- dstSaver.write(dstText);
- dstSaver.finalize();
+ QVERIFY(CppTools::Tests::TestCase::writeFile(dst->fileName(), dstText));
dst->setUtf8Source(dstText);
dst->parse();
dst->check();
diff --git a/src/plugins/cpptools/cppcodemodelsettings.cpp b/src/plugins/cpptools/cppcodemodelsettings.cpp
index 207cc5141f..074ee34fe2 100644
--- a/src/plugins/cpptools/cppcodemodelsettings.cpp
+++ b/src/plugins/cpptools/cppcodemodelsettings.cpp
@@ -34,6 +34,9 @@
using namespace CppTools;
using namespace CppTools::Internal;
+static QLatin1String cppHeaderMimeType(Constants::CPP_HEADER_MIMETYPE);
+static QLatin1String cHeaderMimeType(Constants::C_HEADER_MIMETYPE);
+
void CppCodeModelSettings::fromSettings(QSettings *s)
{
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
@@ -42,6 +45,7 @@ void CppCodeModelSettings::fromSettings(QSettings *s)
setIdForMimeType(supporters, QLatin1String(Constants::CPP_SOURCE_MIMETYPE));
setIdForMimeType(supporters, QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE));
setIdForMimeType(supporters, QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
+ setIdForMimeType(supporters, QLatin1String(Constants::CPP_HEADER_MIMETYPE));
QVariant v = s->value(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_PCH_USAGE), PchUse_None);
setPCHUsage(static_cast<PCHUsage>(v.toInt()));
s->endGroup();
@@ -65,6 +69,23 @@ void CppCodeModelSettings::setModelManagerSupports(const QList<ModelManagerSuppo
m_availableModelManagerSupportersByName[supporter->displayName()] = supporter->id();
}
+QString CppCodeModelSettings::modelManagerSupportId(const QString &mimeType) const
+{
+ if (mimeType == cHeaderMimeType)
+ return m_modelManagerSupportByMimeType.value(cppHeaderMimeType);
+ else
+ return m_modelManagerSupportByMimeType.value(mimeType);
+}
+
+void CppCodeModelSettings::setModelManagerSupportId(const QString &mimeType,
+ const QString &supporter)
+{
+ if (mimeType == cHeaderMimeType)
+ m_modelManagerSupportByMimeType.insert(cppHeaderMimeType, supporter);
+ else
+ m_modelManagerSupportByMimeType.insert(mimeType, supporter);
+}
+
void CppCodeModelSettings::setIdForMimeType(const QVariant &var, const QString &mimeType)
{
QHash<QString, QVariant> mimeToId = var.toHash();
diff --git a/src/plugins/cpptools/cppcodemodelsettings.h b/src/plugins/cpptools/cppcodemodelsettings.h
index 21039593f6..5836b4d6d7 100644
--- a/src/plugins/cpptools/cppcodemodelsettings.h
+++ b/src/plugins/cpptools/cppcodemodelsettings.h
@@ -46,7 +46,7 @@ class CppCodeModelSettings
public:
enum PCHUsage {
PchUse_None = 1,
- PchUse_BuildSystem = 2,
+ PchUse_BuildSystem = 2
};
public:
@@ -57,8 +57,8 @@ public:
void setModelManagerSupports(const QList<ModelManagerSupport *> &supporters);
- QString &modelManagerSupportId(const QString &mimeType)
- { return m_modelManagerSupportByMimeType[mimeType]; }
+ QString modelManagerSupportId(const QString &mimeType) const;
+ void setModelManagerSupportId(const QString &mimeType, const QString &supporter);
const QHash<QString, QString> &availableModelManagerSupportersByName() const
{ return m_availableModelManagerSupportersByName; }
diff --git a/src/plugins/cpptools/cppcodemodelsettingspage.cpp b/src/plugins/cpptools/cppcodemodelsettingspage.cpp
index 2b9e8653b5..5b975217da 100644
--- a/src/plugins/cpptools/cppcodemodelsettingspage.cpp
+++ b/src/plugins/cpptools/cppcodemodelsettingspage.cpp
@@ -44,7 +44,7 @@ CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(QWidget *parent)
{
m_ui->setupUi(this);
- m_ui->theGroupBox->setVisible(false);
+ m_ui->theGroupBox->setVisible(true);
}
CppCodeModelSettingsWidget::~CppCodeModelSettingsWidget()
@@ -60,6 +60,7 @@ void CppCodeModelSettingsWidget::setSettings(const QSharedPointer<CppCodeModelSe
applyToWidget(m_ui->cppChooser, QLatin1String(Constants::CPP_SOURCE_MIMETYPE));
applyToWidget(m_ui->objcChooser, QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE));
applyToWidget(m_ui->objcppChooser, QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
+ applyToWidget(m_ui->hChooser, QLatin1String(Constants::C_HEADER_MIMETYPE));
m_ui->ignorePCHCheckBox->setChecked(s->pchUsage() == CppCodeModelSettings::PchUse_None);
}
@@ -88,6 +89,8 @@ void CppCodeModelSettingsWidget::applyToSettings() const
QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE));
changed |= applyToSettings(m_ui->objcppChooser,
QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
+ changed |= applyToSettings(m_ui->hChooser,
+ QLatin1String(Constants::C_HEADER_MIMETYPE));
if (m_ui->ignorePCHCheckBox->isChecked() !=
(m_settings->pchUsage() == CppCodeModelSettings::PchUse_None)) {
@@ -101,31 +104,14 @@ void CppCodeModelSettingsWidget::applyToSettings() const
m_settings->toSettings(Core::ICore::settings());
}
-QString CppCodeModelSettingsWidget::searchKeywords() const
-{
- QString rc;
- QTextStream ts(&rc);
- ts << m_ui->theGroupBox->title()
- << ' ' << m_ui->cLabel->text()
- << ' ' << m_ui->cppLabel->text()
- << ' ' << m_ui->objcLabel->text()
- << ' ' << m_ui->objcppLabel->text()
- << ' ' << m_ui->anotherGroupBox->title()
- << ' ' << m_ui->ignorePCHCheckBox->text();
- foreach (const QString &mmsNames, m_settings->availableModelManagerSupportersByName().keys())
- ts << ' ' << mmsNames;
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
bool CppCodeModelSettingsWidget::applyToSettings(QComboBox *chooser, const QString &mimeType) const
{
QString newId = chooser->itemData(chooser->currentIndex()).toString();
- QString &currentId = m_settings->modelManagerSupportId(mimeType);
+ QString currentId = m_settings->modelManagerSupportId(mimeType);
if (newId == currentId)
return false;
- currentId = newId;
+ m_settings->setModelManagerSupportId(mimeType, newId);
return true;
}
@@ -141,12 +127,12 @@ CppCodeModelSettingsPage::CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSe
setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_CPP_ICON));
}
-QWidget *CppCodeModelSettingsPage::createPage(QWidget *parent)
+QWidget *CppCodeModelSettingsPage::widget()
{
- m_widget = new CppCodeModelSettingsWidget(parent);
- m_widget->setSettings(m_settings);
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new CppCodeModelSettingsWidget;
+ m_widget->setSettings(m_settings);
+ }
return m_widget;
}
@@ -156,7 +142,7 @@ void CppCodeModelSettingsPage::apply()
m_widget->applyToSettings();
}
-bool CppCodeModelSettingsPage::matches(const QString &s) const
+void CppCodeModelSettingsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
diff --git a/src/plugins/cpptools/cppcodemodelsettingspage.h b/src/plugins/cpptools/cppcodemodelsettingspage.h
index 343d81e6af..3989be4bab 100644
--- a/src/plugins/cpptools/cppcodemodelsettingspage.h
+++ b/src/plugins/cpptools/cppcodemodelsettingspage.h
@@ -56,8 +56,6 @@ public:
void setSettings(const QSharedPointer<CppCodeModelSettings> &s);
void applyToSettings() const;
- QString searchKeywords() const;
-
private:
bool applyToSettings(QComboBox *chooser, const QString &mimeType) const;
void applyToWidget(QComboBox *chooser, const QString &mimeType) const;
@@ -73,15 +71,13 @@ public:
explicit CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSettings> &settings,
QObject *parent = 0);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &s) const;
+ void finish();
private:
const QSharedPointer<CppCodeModelSettings> m_settings;
QPointer<CppCodeModelSettingsWidget> m_widget;
- QString m_searchKeywords;
};
} // Internal namespace
diff --git a/src/plugins/cpptools/cppcodemodelsettingspage.ui b/src/plugins/cpptools/cppcodemodelsettingspage.ui
index 310c01d966..1109649ceb 100644
--- a/src/plugins/cpptools/cppcodemodelsettingspage.ui
+++ b/src/plugins/cpptools/cppcodemodelsettingspage.ui
@@ -74,6 +74,16 @@
<item row="3" column="1">
<widget class="QComboBox" name="objcppChooser"/>
</item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="hLabel">
+ <property name="text">
+ <string>Headers</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QComboBox" name="hChooser"/>
+ </item>
</layout>
</widget>
</item>
diff --git a/src/plugins/cpptools/cppcodestylesettingspage.cpp b/src/plugins/cpptools/cppcodestylesettingspage.cpp
index eba4b33974..2a5d889583 100644
--- a/src/plugins/cpptools/cppcodestylesettingspage.cpp
+++ b/src/plugins/cpptools/cppcodestylesettingspage.cpp
@@ -428,44 +428,6 @@ void CppCodeStylePreferencesWidget::slotCurrentPreferencesChanged(TextEditor::IC
updatePreview();
}
-QString CppCodeStylePreferencesWidget::searchKeywords() const
-{
- QString rc;
- QLatin1Char sep(' ');
- QTextStream(&rc)
- << sep << m_ui->tabSettingsWidget->searchKeywords()
- << sep << m_ui->indentBlockBraces->text()
- << sep << m_ui->indentBlockBody->text()
- << sep << m_ui->indentClassBraces->text()
- << sep << m_ui->indentEnumBraces->text()
- << sep << m_ui->indentNamespaceBraces->text()
- << sep << m_ui->indentNamespaceBody->text()
- << sep << m_ui->indentAccessSpecifiers->text()
- << sep << m_ui->indentDeclarationsRelativeToAccessSpecifiers->text()
- << sep << m_ui->indentFunctionBody->text()
- << sep << m_ui->indentFunctionBraces->text()
- << sep << m_ui->indentSwitchLabels->text()
- << sep << m_ui->indentCaseStatements->text()
- << sep << m_ui->indentCaseBlocks->text()
- << sep << m_ui->indentCaseBreak->text()
- << sep << m_ui->bindStarToIdentifier->text()
- << sep << m_ui->bindStarToTypeName->text()
- << sep << m_ui->bindStarToLeftSpecifier->text()
- << sep << m_ui->bindStarToRightSpecifier->text()
- << sep << m_ui->contentGroupBox->title()
- << sep << m_ui->bracesGroupBox->title()
- << sep << m_ui->switchGroupBox->title()
- << sep << m_ui->alignmentGroupBox->title()
- << sep << m_ui->pointerReferencesGroupBox->title()
- << sep << m_ui->extraPaddingConditions->text()
- << sep << m_ui->alignAssignments->text()
- ;
- for (int i = 0; i < m_ui->categoryTab->count(); i++)
- QTextStream(&rc) << sep << m_ui->categoryTab->tabText(i);
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
void CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged()
{
if (m_blockUpdates)
@@ -564,19 +526,20 @@ CppCodeStyleSettingsPage::CppCodeStyleSettingsPage(QWidget *parent) :
setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_CPP_ICON));
}
-QWidget *CppCodeStyleSettingsPage::createPage(QWidget *parent)
+QWidget *CppCodeStyleSettingsPage::widget()
{
- CppCodeStylePreferences *originalCodeStylePreferences
- = CppToolsSettings::instance()->cppCodeStyle();
- m_pageCppCodeStylePreferences = new CppCodeStylePreferences(m_widget);
- m_pageCppCodeStylePreferences->setDelegatingPool(originalCodeStylePreferences->delegatingPool());
- m_pageCppCodeStylePreferences->setCodeStyleSettings(originalCodeStylePreferences->codeStyleSettings());
- m_pageCppCodeStylePreferences->setCurrentDelegate(originalCodeStylePreferences->currentDelegate());
- // we set id so that it won't be possible to set delegate to the original prefs
- m_pageCppCodeStylePreferences->setId(originalCodeStylePreferences->id());
- m_widget = new CodeStyleEditor(TextEditorSettings::codeStyleFactory(CppTools::Constants::CPP_SETTINGS_ID),
- m_pageCppCodeStylePreferences, parent);
-
+ if (!m_widget) {
+ CppCodeStylePreferences *originalCodeStylePreferences
+ = CppToolsSettings::instance()->cppCodeStyle();
+ m_pageCppCodeStylePreferences = new CppCodeStylePreferences(m_widget);
+ m_pageCppCodeStylePreferences->setDelegatingPool(originalCodeStylePreferences->delegatingPool());
+ m_pageCppCodeStylePreferences->setCodeStyleSettings(originalCodeStylePreferences->codeStyleSettings());
+ m_pageCppCodeStylePreferences->setCurrentDelegate(originalCodeStylePreferences->currentDelegate());
+ // we set id so that it won't be possible to set delegate to the original prefs
+ m_pageCppCodeStylePreferences->setId(originalCodeStylePreferences->id());
+ m_widget = new CodeStyleEditor(TextEditorSettings::codeStyleFactory(CppTools::Constants::CPP_SETTINGS_ID),
+ m_pageCppCodeStylePreferences);
+ }
return m_widget;
}
@@ -601,9 +564,9 @@ void CppCodeStyleSettingsPage::apply()
}
}
-bool CppCodeStyleSettingsPage::matches(const QString &s) const
+void CppCodeStyleSettingsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/cpptools/cppcodestylesettingspage.h b/src/plugins/cpptools/cppcodestylesettingspage.h
index 4328e1faac..c9719bed48 100644
--- a/src/plugins/cpptools/cppcodestylesettingspage.h
+++ b/src/plugins/cpptools/cppcodestylesettingspage.h
@@ -66,8 +66,6 @@ public:
void setCodeStyle(CppTools::CppCodeStylePreferences *codeStylePreferences);
- QString searchKeywords() const;
-
private slots:
void decorateEditors(const TextEditor::FontSettings &fontSettings);
void setVisualizeWhitespace(bool on);
@@ -95,13 +93,11 @@ class CppCodeStyleSettingsPage : public Core::IOptionsPage
public:
explicit CppCodeStyleSettingsPage(QWidget *parent = 0);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &) const;
+ void finish();
private:
- QString m_searchKeywords;
CppCodeStylePreferences *m_pageCppCodeStylePreferences;
QPointer<TextEditor::CodeStyleEditor> m_widget;
};
diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp
index ff3f5c38b1..da0ef9fa3e 100644
--- a/src/plugins/cpptools/cppcompletion_test.cpp
+++ b/src/plugins/cpptools/cppcompletion_test.cpp
@@ -27,21 +27,22 @@
**
****************************************************************************/
-#include "cpptoolsplugin.h"
#include "cppcompletionassist.h"
#include "cppmodelmanager.h"
+#include "cpptoolsplugin.h"
+#include "cpptoolstestcase.h"
-#include <texteditor/plaintexteditor.h>
#include <texteditor/codeassist/iassistproposal.h>
#include <texteditor/convenience.h>
+#include <texteditor/plaintexteditor.h>
#include <utils/changeset.h>
#include <utils/fileutils.h>
-#include <QtTest>
#include <QDebug>
-#include <QTextDocument>
#include <QDir>
+#include <QTextDocument>
+#include <QtTest>
/*!
Tests for code completion.
@@ -52,57 +53,56 @@ using namespace CppTools::Internal;
using namespace TextEditor;
using namespace Core;
-class CompletionTestCase
+namespace {
+
+typedef QByteArray _;
+
+class CompletionTestCase : public CppTools::Tests::TestCase
{
public:
CompletionTestCase(const QByteArray &sourceText, const QByteArray &textToInsert = QByteArray())
- : position(-1), editorWidget(0), textDocument(0), editor(0),
- cmm(CppModelManager::instance())
+ : m_position(-1), m_editorWidget(0), m_textDocument(0), m_editor(0)
{
- source = sourceText;
- position = source.indexOf('@');
- QVERIFY(position != -1);
- source[position] = ' ';
+ QVERIFY(succeededSoFar());
+ m_succeededSoFar = false;
+
+ m_source = sourceText;
+ m_position = m_source.indexOf('@');
+ QVERIFY(m_position != -1);
+ m_source[m_position] = ' ';
// Write source to file
const QString fileName = QDir::tempPath() + QLatin1String("/file.h");
- Utils::FileSaver srcSaver(fileName);
- srcSaver.write(source);
- srcSaver.finalize();
+ QVERIFY(writeFile(fileName, m_source));
// Open in editor
- editor = EditorManager::openEditor(fileName);
- QVERIFY(editor);
- editorWidget = qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget());
- QVERIFY(editorWidget);
+ m_editor = EditorManager::openEditor(fileName);
+ QVERIFY(m_editor);
+ closeEditorAtEndOfTestCase(m_editor);
+ m_editorWidget = qobject_cast<TextEditor::BaseTextEditorWidget *>(m_editor->widget());
+ QVERIFY(m_editorWidget);
- textDocument = editorWidget->document();
+ m_textDocument = m_editorWidget->document();
// Get Document
- while (!cmm->snapshot().contains(fileName))
- QCoreApplication::processEvents();
- Document::Ptr document = cmm->snapshot().document(fileName);
+ waitForFileInGlobalSnapshot(fileName);
+ const Document::Ptr document = globalSnapshot().document(fileName);
- snapshot.insert(document);
+ m_snapshot.insert(document);
if (!textToInsert.isEmpty())
insertText(textToInsert);
- }
- ~CompletionTestCase()
- {
- EditorManager::closeEditor(editor, /*askAboutModifiedEditors=*/ false);
- cmm->GC();
- QVERIFY(cmm->snapshot().isEmpty());
+ m_succeededSoFar = true;
}
QStringList getCompletions(bool *replaceAccessOperator = 0) const
{
QStringList completions;
CppCompletionAssistInterface *ai
- = new CppCompletionAssistInterface(editorWidget->document(), position,
- editorWidget->editorDocument()->filePath(),
- ExplicitlyInvoked, snapshot,
+ = new CppCompletionAssistInterface(m_editorWidget->document(), m_position,
+ m_editorWidget->baseTextDocument()->filePath(),
+ ExplicitlyInvoked, m_snapshot,
QStringList(), QStringList());
CppCompletionAssistProcessor processor;
IAssistProposal *proposal = processor.perform(ai);
@@ -116,8 +116,9 @@ public:
return completions;
const int pos = proposal->basePosition();
- const int length = position - pos;
- const QString prefix = Convenience::textAt(QTextCursor(editorWidget->document()), pos, length);
+ const int length = m_position - pos;
+ const QString prefix = Convenience::textAt(QTextCursor(m_editorWidget->document()), pos,
+ length);
if (!prefix.isEmpty())
listmodel->filter(prefix);
if (listmodel->isSortable(prefix))
@@ -135,52 +136,199 @@ public:
void insertText(const QByteArray &text)
{
Utils::ChangeSet change;
- change.insert(position, QLatin1String(text));
- QTextCursor cursor(textDocument);
+ change.insert(m_position, QLatin1String(text));
+ QTextCursor cursor(m_textDocument);
change.apply(&cursor);
- position += text.length();
+ m_position += text.length();
}
private:
- QByteArray source;
- int position;
- Snapshot snapshot;
- BaseTextEditorWidget *editorWidget;
- QTextDocument *textDocument;
- IEditor *editor;
-
- CppModelManager *cmm;
+ QByteArray m_source;
+ int m_position;
+ Snapshot m_snapshot;
+ BaseTextEditorWidget *m_editorWidget;
+ QTextDocument *m_textDocument;
+ IEditor *m_editor;
};
-void CppToolsPlugin::test_completion_forward_declarations_present()
+} // anonymous namespace
+
+void CppToolsPlugin::test_completion_basic_1()
+{
+ const QByteArray source =
+ "class Foo\n"
+ "{\n"
+ " void foo();\n"
+ " int m;\n"
+ "};\n"
+ "\n"
+ "void func() {\n"
+ " Foo f;\n"
+ " @\n"
+ "}";
+ CompletionTestCase test(source);
+ QVERIFY(test.succeededSoFar());
+
+ QStringList basicCompletions = test.getCompletions();
+ QVERIFY(!basicCompletions.contains(QLatin1String("foo")));
+ QVERIFY(!basicCompletions.contains(QLatin1String("m")));
+ QVERIFY(basicCompletions.contains(QLatin1String("Foo")));
+ QVERIFY(basicCompletions.contains(QLatin1String("func")));
+ QVERIFY(basicCompletions.contains(QLatin1String("f")));
+
+ test.insertText("f.");
+
+ QStringList memberCompletions = test.getCompletions();
+ QVERIFY(memberCompletions.contains(QLatin1String("foo")));
+ QVERIFY(memberCompletions.contains(QLatin1String("m")));
+ QVERIFY(!memberCompletions.contains(QLatin1String("func")));
+ QVERIFY(!memberCompletions.contains(QLatin1String("f")));
+}
+
+void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_8737()
+{
+ const QByteArray source =
+ "void f()\n"
+ "{\n"
+ " int a_b_c, a_c, a_c_a;\n"
+ " @;\n"
+ "}\n"
+ ;
+ CompletionTestCase test(source, "a_c");
+ QVERIFY(test.succeededSoFar());
+
+ QStringList completions = test.getCompletions();
+
+ QVERIFY(completions.size() >= 2);
+ QCOMPARE(completions.at(0), QLatin1String("a_c"));
+ QCOMPARE(completions.at(1), QLatin1String("a_c_a"));
+ QVERIFY(completions.contains(QLatin1String("a_b_c")));
+}
+
+void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_9236()
{
const QByteArray source =
- "\n"
- "class Foo\n"
- "{\n"
- " struct Bar;\n"
- " int i;\n"
- "};\n"
- "\n"
- "struct Foo::Bar \n"
- "{\n"
- " Bar() {}\n"
- "};\n"
- "\n"
- "@\n"
- "// padding so we get the scope right\n";
- CompletionTestCase test(source, "Foo::Bar::");
-
- QStringList expected;
- expected.append(QLatin1String("Bar"));
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions, expected);
+ "class r_etclass\n"
+ "{\n"
+ "public:\n"
+ " int raEmTmber;\n"
+ " void r_e_t(int re_t)\n"
+ " {\n"
+ " int r_et;\n"
+ " int rETUCASE;\n"
+ " @\n"
+ " }\n"
+ "};\n"
+ ;
+ CompletionTestCase test(source, "ret");
+ QVERIFY(test.succeededSoFar());
+
+ QStringList completions = test.getCompletions();
+ QVERIFY(completions.size() >= 2);
+ QCOMPARE(completions.at(0), QLatin1String("return"));
+ QCOMPARE(completions.at(1), QLatin1String("rETUCASE"));
+ QVERIFY(completions.contains(QLatin1String("r_etclass")));
+ QVERIFY(completions.contains(QLatin1String("raEmTmber")));
+ QVERIFY(completions.contains(QLatin1String("r_e_t")));
+ QVERIFY(completions.contains(QLatin1String("re_t")));
+ QVERIFY(completions.contains(QLatin1String("r_et")));
}
-void CppToolsPlugin::test_completion_inside_parentheses_c_style_conversion()
+void CppToolsPlugin::test_completion_template_function()
{
- const QByteArray source = "\n"
+ QFETCH(QByteArray, code);
+ QFETCH(QStringList, expectedCompletions);
+
+ CompletionTestCase test(code);
+ QVERIFY(test.succeededSoFar());
+
+ QStringList actualCompletions = test.getCompletions();
+ QString errorPattern(QLatin1String("Completion not found: %1"));
+ foreach (const QString &completion, expectedCompletions) {
+ QByteArray errorMessage = errorPattern.arg(completion).toUtf8();
+ QVERIFY2(actualCompletions.contains(completion), errorMessage.data());
+ }
+}
+
+void CppToolsPlugin::test_completion_template_function_data()
+{
+ QTest::addColumn<QByteArray>("code");
+ QTest::addColumn<QStringList>("expectedCompletions");
+
+ QByteArray code;
+ QStringList completions;
+
+ code =
+ "template <class tclass, typename tname, int tint>\n"
+ "tname Hello(const tclass &e)\n"
+ "{\n"
+ " tname e2 = e;\n"
+ " @\n"
+ "}";
+
+ completions.append(QLatin1String("tclass"));
+ completions.append(QLatin1String("tname"));
+ completions.append(QLatin1String("tint"));
+
+ QTest::newRow("case: template parameters in template function body")
+ << code << completions;
+
+ completions.clear();
+
+ code =
+ "template <class tclass, typename tname, int tint>\n"
+ "tname Hello(const tclass &e, @)\n"
+ "{\n"
+ " tname e2 = e;\n"
+ "}";
+
+ completions.append(QLatin1String("tclass"));
+ completions.append(QLatin1String("tname"));
+ completions.append(QLatin1String("tint"));
+
+ QTest::newRow("case: template parameters in template function parameters list")
+ << code << completions;
+}
+
+void CppToolsPlugin::test_completion()
+{
+ QFETCH(QByteArray, code);
+ QFETCH(QByteArray, prefix);
+ QFETCH(QStringList, expectedCompletions);
+
+ CompletionTestCase test(code, prefix);
+ QVERIFY(test.succeededSoFar());
+
+ QStringList actualCompletions = test.getCompletions();
+ actualCompletions.sort();
+ expectedCompletions.sort();
+
+ QCOMPARE(actualCompletions, expectedCompletions);
+}
+
+void CppToolsPlugin::test_completion_data()
+{
+ QTest::addColumn<QByteArray>("code");
+ QTest::addColumn<QByteArray>("prefix");
+ QTest::addColumn<QStringList>("expectedCompletions");
+
+ QTest::newRow("forward_declarations_present") << _(
+ "class Foo\n"
+ "{\n"
+ " struct Bar;\n"
+ " int i;\n"
+ "};\n"
+ "\n"
+ "struct Foo::Bar \n"
+ "{\n"
+ " Bar() {}\n"
+ "};\n"
+ "\n"
+ "@\n"
+ ) << _("Foo::Bar::") << (QStringList()
+ << QLatin1String("Bar"));
+
+ QTest::newRow("inside_parentheses_c_style_conversion") << _(
"class Base\n"
"{\n"
" int i_base;\n"
@@ -197,20 +345,13 @@ void CppToolsPlugin::test_completion_inside_parentheses_c_style_conversion()
" if (1)\n"
" @\n"
"}\n"
- ;
- CompletionTestCase test(source, "((Derived *)b)->");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 4);
- QVERIFY(completions.contains(QLatin1String("Derived")));
- QVERIFY(completions.contains(QLatin1String("Base")));
- QVERIFY(completions.contains(QLatin1String("i_derived")));
- QVERIFY(completions.contains(QLatin1String("i_base")));
-}
+ ) << _("((Derived *)b)->") << (QStringList()
+ << QLatin1String("Derived")
+ << QLatin1String("Base")
+ << QLatin1String("i_derived")
+ << QLatin1String("i_base"));
-void CppToolsPlugin::test_completion_inside_parentheses_cast_operator_conversion()
-{
- const QByteArray source = "\n"
+ QTest::newRow("inside_parentheses_cast_operator_conversion") << _(
"class Base\n"
"{\n"
" int i_base;\n"
@@ -227,52 +368,13 @@ void CppToolsPlugin::test_completion_inside_parentheses_cast_operator_conversion
" if (1)\n"
" @\n"
"}\n"
- ;
- CompletionTestCase test(source, "(static_cast<Derived *>(b))->");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 4);
- QVERIFY(completions.contains(QLatin1String("Derived")));
- QVERIFY(completions.contains(QLatin1String("Base")));
- QVERIFY(completions.contains(QLatin1String("i_derived")));
- QVERIFY(completions.contains(QLatin1String("i_base")));
-}
-
-void CppToolsPlugin::test_completion_basic_1()
-{
- const QByteArray source = "\n"
- "class Foo\n"
- "{\n"
- " void foo();\n"
- " int m;\n"
- "};\n"
- "\n"
- "void func() {\n"
- " Foo f;\n"
- " @\n"
- " // padding so we get the scope right\n"
- "}";
- CompletionTestCase test(source);
-
- QStringList basicCompletions = test.getCompletions();
- QVERIFY(!basicCompletions.contains(QLatin1String("foo")));
- QVERIFY(!basicCompletions.contains(QLatin1String("m")));
- QVERIFY(basicCompletions.contains(QLatin1String("Foo")));
- QVERIFY(basicCompletions.contains(QLatin1String("func")));
- QVERIFY(basicCompletions.contains(QLatin1String("f")));
-
- test.insertText("f.");
+ ) << _("(static_cast<Derived *>(b))->") << (QStringList()
+ << QLatin1String("Derived")
+ << QLatin1String("Base")
+ << QLatin1String("i_derived")
+ << QLatin1String("i_base"));
- QStringList memberCompletions = test.getCompletions();
- QVERIFY(memberCompletions.contains(QLatin1String("foo")));
- QVERIFY(memberCompletions.contains(QLatin1String("m")));
- QVERIFY(!memberCompletions.contains(QLatin1String("func")));
- QVERIFY(!memberCompletions.contains(QLatin1String("f")));
-}
-
-void CppToolsPlugin::test_completion_template_1()
-{
- const QByteArray source = "\n"
+ QTest::newRow("template_1") << _(
"template <class T>\n"
"class Foo\n"
"{\n"
@@ -284,22 +386,14 @@ void CppToolsPlugin::test_completion_template_1()
"void func() {\n"
" Foo f;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- CompletionTestCase test(source, "Foo::");
-
- const QStringList completions = test.getCompletions();
- QVERIFY(completions.contains(QLatin1String("Type")));
- QVERIFY(completions.contains(QLatin1String("foo")));
- QVERIFY(completions.contains(QLatin1String("m")));
- QVERIFY(!completions.contains(QLatin1String("T")));
- QVERIFY(!completions.contains(QLatin1String("f")));
- QVERIFY(!completions.contains(QLatin1String("func")));
-}
+ "}"
+ ) << _("Foo::") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("Type")
+ << QLatin1String("foo")
+ << QLatin1String("m"));
-void CppToolsPlugin::test_completion_template_2()
-{
- const QByteArray source = "\n"
+ QTest::newRow("template_2") << _(
"template <class T>\n"
"struct List\n"
"{\n"
@@ -311,20 +405,13 @@ void CppToolsPlugin::test_completion_template_2()
"void func() {\n"
" List<Tupple> l;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- CompletionTestCase test(source, "l.at(0).");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 3);
- QVERIFY(completions.contains(QLatin1String("Tupple")));
- QVERIFY(completions.contains(QLatin1String("a")));
- QVERIFY(completions.contains(QLatin1String("b")));
-}
+ "}"
+ ) << _("l.at(0).") << (QStringList()
+ << QLatin1String("Tupple")
+ << QLatin1String("a")
+ << QLatin1String("b"));
-void CppToolsPlugin::test_completion_template_3()
-{
- const QByteArray source = "\n"
+ QTest::newRow("template_3") << _(
"template <class T>\n"
"struct List\n"
"{\n"
@@ -336,20 +423,13 @@ void CppToolsPlugin::test_completion_template_3()
"void func() {\n"
" List<Tupple> l;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- CompletionTestCase test(source, "l.t.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 3);
- QVERIFY(completions.contains(QLatin1String("Tupple")));
- QVERIFY(completions.contains(QLatin1String("a")));
- QVERIFY(completions.contains(QLatin1String("b")));
-}
+ "}"
+ ) << _("l.t.") << (QStringList()
+ << QLatin1String("Tupple")
+ << QLatin1String("a")
+ << QLatin1String("b"));
-void CppToolsPlugin::test_completion_template_4()
-{
- const QByteArray source = "\n"
+ QTest::newRow("template_4") << _(
"template <class T>\n"
"struct List\n"
"{\n"
@@ -362,20 +442,13 @@ void CppToolsPlugin::test_completion_template_4()
"void func() {\n"
" List<Tupple> l;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- CompletionTestCase test(source, "l.u.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 3);
- QVERIFY(completions.contains(QLatin1String("Tupple")));
- QVERIFY(completions.contains(QLatin1String("a")));
- QVERIFY(completions.contains(QLatin1String("b")));
-}
+ "}"
+ ) << _("l.u.") << (QStringList()
+ << QLatin1String("Tupple")
+ << QLatin1String("a")
+ << QLatin1String("b"));
-void CppToolsPlugin::test_completion_template_5()
-{
- const QByteArray source = "\n"
+ QTest::newRow("template_5") << _(
"template <class T>\n"
"struct List\n"
"{\n"
@@ -388,20 +461,13 @@ void CppToolsPlugin::test_completion_template_5()
" typedef List<Tupple> LT;\n"
" LT l;"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- CompletionTestCase test(source, "l.u.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 3);
- QVERIFY(completions.contains(QLatin1String("Tupple")));
- QVERIFY(completions.contains(QLatin1String("a")));
- QVERIFY(completions.contains(QLatin1String("b")));
-}
+ "}"
+ ) << _("l.u.") << (QStringList()
+ << QLatin1String("Tupple")
+ << QLatin1String("a")
+ << QLatin1String("b"));
-void CppToolsPlugin::test_completion_template_6()
-{
- const QByteArray source = "\n"
+ QTest::newRow("template_6") << _(
"class Item\n"
"{\n"
" int i;\n"
@@ -419,18 +485,11 @@ void CppToolsPlugin::test_completion_template_6()
"{};\n"
"ItemContainer container;\n"
"@\n"
- ;
- CompletionTestCase test(source, "container.get().");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Item")));
- QVERIFY(completions.contains(QLatin1String("i")));
-}
+ ) << _("container.get().") << (QStringList()
+ << QLatin1String("Item")
+ << QLatin1String("i"));
-void CppToolsPlugin::test_completion_template_7()
-{
- const QByteArray source = "\n"
+ QTest::newRow("template_7") << _(
"struct Test\n"
"{\n"
" int i;\n"
@@ -451,36 +510,22 @@ void CppToolsPlugin::test_completion_template_7()
"\n"
"TemplateClass<Test> p(new Test);\n"
"@\n"
- ;
- CompletionTestCase test(source, "p->");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Test")));
- QVERIFY(completions.contains(QLatin1String("i")));
-}
+ ) << _("p->") << (QStringList()
+ << QLatin1String("Test")
+ << QLatin1String("i"));
-void CppToolsPlugin::test_completion_type_of_pointer_is_typedef()
-{
- const QByteArray source = "\n"
+ QTest::newRow("type_of_pointer_is_typedef") << _(
"typedef struct Foo\n"
"{\n"
" int foo;\n"
"} Foo;\n"
"Foo *bar;\n"
"@\n"
- ;
- CompletionTestCase test(source, "bar->");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("foo")));
-}
+ ) << _("bar->") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("foo"));
-void CppToolsPlugin::test_completion_instantiate_full_specialization()
-{
- const QByteArray source = "\n"
+ QTest::newRow("instantiate_full_specialization") << _(
"template<typename T>\n"
"struct Template\n"
"{\n"
@@ -495,59 +540,25 @@ void CppToolsPlugin::test_completion_instantiate_full_specialization()
"\n"
"Template<char> templateChar;\n"
"@\n"
- ;
- CompletionTestCase test(source, "templateChar.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Template")));
- QVERIFY(completions.contains(QLatin1String("templateChar_i")));
-}
-
-void CppToolsPlugin::test_completion()
-{
- QFETCH(QByteArray, code);
- QFETCH(QStringList, expectedCompletions);
-
- CompletionTestCase test(code, "c.");
-
- QStringList actualCompletions = test.getCompletions();
- actualCompletions.sort();
- expectedCompletions.sort();
-
- QCOMPARE(actualCompletions, expectedCompletions);
-}
+ ) << _("templateChar.") << (QStringList()
+ << QLatin1String("Template")
+ << QLatin1String("templateChar_i"));
-void CppToolsPlugin::test_completion_template_as_base()
-{
- test_completion();
-}
-
-void CppToolsPlugin::test_completion_template_as_base_data()
-{
- QTest::addColumn<QByteArray>("code");
- QTest::addColumn<QStringList>("expectedCompletions");
-
- QByteArray code;
- QStringList completions;
-
- code = "\n"
+ QTest::newRow("template_as_base: base as template directly") << _(
"class Data { int dataMember; };\n"
"template <class T> class Other : public T { int otherMember; };\n"
"\n"
"void func() {\n"
" Other<Data> c;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- completions.append(QLatin1String("Data"));
- completions.append(QLatin1String("dataMember"));
- completions.append(QLatin1String("Other"));
- completions.append(QLatin1String("otherMember"));
- QTest::newRow("case: base as template directly") << code << completions;
+ "}"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("Data")
+ << QLatin1String("dataMember")
+ << QLatin1String("Other")
+ << QLatin1String("otherMember"));
- completions.clear();
- code = "\n"
+ QTest::newRow("template_as_base: base as class template") << _(
"class Data { int dataMember; };\n"
"template <class T> class Other : public T { int otherMember; };\n"
"template <class T> class More : public Other<T> { int moreMember; };\n"
@@ -555,18 +566,16 @@ void CppToolsPlugin::test_completion_template_as_base_data()
"void func() {\n"
" More<Data> c;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- completions.append(QLatin1String("Data"));
- completions.append(QLatin1String("dataMember"));
- completions.append(QLatin1String("Other"));
- completions.append(QLatin1String("otherMember"));
- completions.append(QLatin1String("More"));
- completions.append(QLatin1String("moreMember"));
- QTest::newRow("case: base as class template") << code << completions;
-
- completions.clear();
- code = "\n"
+ "}"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("Data")
+ << QLatin1String("dataMember")
+ << QLatin1String("Other")
+ << QLatin1String("otherMember")
+ << QLatin1String("More")
+ << QLatin1String("moreMember"));
+
+ QTest::newRow("template_as_base: base as globally qualified class template") << _(
"class Data { int dataMember; };\n"
"template <class T> class Other : public T { int otherMember; };\n"
"template <class T> class More : public ::Other<T> { int moreMember; };\n"
@@ -574,18 +583,16 @@ void CppToolsPlugin::test_completion_template_as_base_data()
"void func() {\n"
" More<Data> c;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- completions.append(QLatin1String("Data"));
- completions.append(QLatin1String("dataMember"));
- completions.append(QLatin1String("Other"));
- completions.append(QLatin1String("otherMember"));
- completions.append(QLatin1String("More"));
- completions.append(QLatin1String("moreMember"));
- QTest::newRow("case: base as globally qualified class template") << code << completions;
-
- completions.clear();
- code = "\n"
+ "}"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("Data")
+ << QLatin1String("dataMember")
+ << QLatin1String("Other")
+ << QLatin1String("otherMember")
+ << QLatin1String("More")
+ << QLatin1String("moreMember"));
+
+ QTest::newRow("template_as_base: base as namespace qualified class template") << _(
"class Data { int dataMember; };\n"
"namespace NS {\n"
"template <class T> class Other : public T { int otherMember; };\n"
@@ -595,18 +602,16 @@ void CppToolsPlugin::test_completion_template_as_base_data()
"void func() {\n"
" More<Data> c;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- completions.append(QLatin1String("Data"));
- completions.append(QLatin1String("dataMember"));
- completions.append(QLatin1String("Other"));
- completions.append(QLatin1String("otherMember"));
- completions.append(QLatin1String("More"));
- completions.append(QLatin1String("moreMember"));
- QTest::newRow("case: base as namespace qualified class template") << code << completions;
-
- completions.clear();
- code = "\n"
+ "}"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("Data")
+ << QLatin1String("dataMember")
+ << QLatin1String("Other")
+ << QLatin1String("otherMember")
+ << QLatin1String("More")
+ << QLatin1String("moreMember"));
+
+ QTest::newRow("template_as_base: base as nested template name") << _(
"class Data { int dataMember; };\n"
"namespace NS {\n"
"template <class T> class Delegate { typedef Data<T> Type; };\n"
@@ -616,16 +621,14 @@ void CppToolsPlugin::test_completion_template_as_base_data()
"void func() {\n"
" Final<Data> c;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- completions.append(QLatin1String("Data"));
- completions.append(QLatin1String("dataMember"));
- completions.append(QLatin1String("Final"));
- completions.append(QLatin1String("finalMember"));
- QTest::newRow("case: base as nested template name") << code << completions;
+ "}"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("Data")
+ << QLatin1String("dataMember")
+ << QLatin1String("Final")
+ << QLatin1String("finalMember"));
- completions.clear();
- code = "\n"
+ QTest::newRow("template_as_base: base as nested template name in non-template") << _(
"class Data { int dataMember; };\n"
"namespace NS {\n"
"template <class T> class Delegate { typedef Data<T> Type; };\n"
@@ -635,16 +638,14 @@ void CppToolsPlugin::test_completion_template_as_base_data()
"void func() {\n"
" Final c;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- completions.append(QLatin1String("Data"));
- completions.append(QLatin1String("dataMember"));
- completions.append(QLatin1String("Final"));
- completions.append(QLatin1String("finalMember"));
- QTest::newRow("case: base as nested template name in non-template") << code << completions;
+ "}"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("Data")
+ << QLatin1String("dataMember")
+ << QLatin1String("Final")
+ << QLatin1String("finalMember"));
- completions.clear();
- code = "\n"
+ QTest::newRow("template_as_base: base as template name in non-template") << _(
"class Data { int dataMember; };\n"
"namespace NS {\n"
"template <class T> class Other : public T { int otherMember; };\n"
@@ -654,31 +655,16 @@ void CppToolsPlugin::test_completion_template_as_base_data()
"void func() {\n"
" Final c;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- completions.append(QLatin1String("Data"));
- completions.append(QLatin1String("dataMember"));
- completions.append(QLatin1String("Final"));
- completions.append(QLatin1String("finalMember"));
- completions.append(QLatin1String("Other"));
- completions.append(QLatin1String("otherMember"));
- QTest::newRow("case: base as template name in non-template") << code << completions;
-}
-
-void CppToolsPlugin::test_completion_use_global_identifier_as_base_class()
-{
- test_completion();
-}
-
-void CppToolsPlugin::test_completion_use_global_identifier_as_base_class_data()
-{
- QTest::addColumn<QByteArray>("code");
- QTest::addColumn<QStringList>("expectedCompletions");
-
- QByteArray code;
- QStringList completions;
-
- code = "\n"
+ "}"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("Data")
+ << QLatin1String("dataMember")
+ << QLatin1String("Final")
+ << QLatin1String("finalMember")
+ << QLatin1String("Other")
+ << QLatin1String("otherMember"));
+
+ QTest::newRow("use_global_identifier_as_base_class: derived as global and base as global") << _(
"struct Global\n"
"{\n"
" int int_global;\n"
@@ -691,17 +677,14 @@ void CppToolsPlugin::test_completion_use_global_identifier_as_base_class_data()
"\n"
"Final c;\n"
"@\n"
- "// padding so we get the scope right\n";
-
- completions.append(QLatin1String("int_global"));
- completions.append(QLatin1String("int_final"));
- completions.append(QLatin1String("Final"));
- completions.append(QLatin1String("Global"));
- QTest::newRow("case: derived as global and base as global") << code << completions;
-
- completions.clear();
-
- code = "\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("int_global")
+ << QLatin1String("int_final")
+ << QLatin1String("Final")
+ << QLatin1String("Global"));
+
+ QTest::newRow("use_global_identifier_as_base_class: derived is inside namespace. "
+ "base as global") << _(
"struct Global\n"
"{\n"
" int int_global;\n"
@@ -717,61 +700,37 @@ void CppToolsPlugin::test_completion_use_global_identifier_as_base_class_data()
"\n"
"NS::Final c;\n"
"@\n"
- "// padding so we get the scope right\n";
-
- completions.append(QLatin1String("int_global"));
- completions.append(QLatin1String("int_final"));
- completions.append(QLatin1String("Final"));
- completions.append(QLatin1String("Global"));
- QTest::newRow("case: derived is inside namespace, base as global")
- << code << completions;
-
- completions.clear();
-
- // This test does not work due to the bug QTCREATORBUG-7912
-// code = "\n"
-// "struct Global\n"
-// "{\n"
-// " int int_global;\n"
-// "};\n"
-// "\n"
-// "template <typename T>\n"
-// "struct Enclosing\n"
-// "{\n"
-// "struct Final : ::Global\n"
-// "{\n"
-// " int int_final;\n"
-// "};\n"
-// "}\n"
-// "\n"
-// "Enclosing<int>::Final c;\n"
-// "@\n"
-// "// padding so we get the scope right\n";
-
-// completions.append(QLatin1String("int_global"));
-// completions.append(QLatin1String("int_final"));
-// completions.append(QLatin1String("Final"));
-// completions.append(QLatin1String("Global"));
-// QTest::newRow("case: derived is enclosed by template, base as global")
-// << code << completions;
-
-// completions.clear();
-}
-
-void CppToolsPlugin::test_completion_base_class_has_name_the_same_as_derived()
-{
- test_completion();
-}
-
-void CppToolsPlugin::test_completion_base_class_has_name_the_same_as_derived_data()
-{
- QTest::addColumn<QByteArray>("code");
- QTest::addColumn<QStringList>("expectedCompletions");
-
- QByteArray code;
- QStringList completions;
+ ) << _("c.") << (QStringList()
+ << QLatin1String("int_global")
+ << QLatin1String("int_final")
+ << QLatin1String("Final")
+ << QLatin1String("Global"));
+
+ QTest::newRow("use_global_identifier_as_base_class: derived is enclosed by template. "
+ "base as global") << _(
+ "struct Global\n"
+ "{\n"
+ " int int_global;\n"
+ "};\n"
+ "\n"
+ "template <typename T>\n"
+ "struct Enclosing\n"
+ "{\n"
+ "struct Final : ::Global\n"
+ "{\n"
+ " int int_final;\n"
+ "};\n"
+ "};\n"
+ "\n"
+ "Enclosing<int>::Final c;\n"
+ "@\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("int_global")
+ << QLatin1String("int_final")
+ << QLatin1String("Final")
+ << QLatin1String("Global"));
- code = "\n"
+ QTest::newRow("base_class_has_name_the_same_as_derived: base class is derived class") << _(
"struct A : A\n"
"{\n"
" int int_a;\n"
@@ -779,15 +738,12 @@ void CppToolsPlugin::test_completion_base_class_has_name_the_same_as_derived_dat
"\n"
"A c;\n"
"@\n"
- "// padding so we get the scope right\n";
-
- completions.append(QLatin1String("int_a"));
- completions.append(QLatin1String("A"));
- QTest::newRow("case: base class is derived class") << code << completions;
+ ) << _("c.") << (QStringList()
+ << QLatin1String("int_a")
+ << QLatin1String("A"));
- completions.clear();
-
- code = "\n"
+ QTest::newRow("base_class_has_name_the_same_as_derived: base class is derived class. "
+ "class is in namespace") << _(
"namespace NS\n"
"{\n"
"struct A : A\n"
@@ -798,16 +754,12 @@ void CppToolsPlugin::test_completion_base_class_has_name_the_same_as_derived_dat
"\n"
"NS::A c;\n"
"@\n"
- "// padding so we get the scope right\n";
-
- completions.append(QLatin1String("int_a"));
- completions.append(QLatin1String("A"));
- QTest::newRow("case: base class is derived class. class is in namespace")
- << code << completions;
+ ) << _("c.") << (QStringList()
+ << QLatin1String("int_a")
+ << QLatin1String("A"));
- completions.clear();
-
- code = "\n"
+ QTest::newRow("base_class_has_name_the_same_as_derived: base class is derived class. "
+ "class is in namespace. use scope operator for base class") << _(
"namespace NS\n"
"{\n"
"struct A : NS::A\n"
@@ -818,16 +770,12 @@ void CppToolsPlugin::test_completion_base_class_has_name_the_same_as_derived_dat
"\n"
"NS::A c;\n"
"@\n"
- "// padding so we get the scope right\n";
-
- completions.append(QLatin1String("int_a"));
- completions.append(QLatin1String("A"));
- QTest::newRow("case: base class is derived class. class is in namespace. "
- "use scope operator for base class") << code << completions;
-
- completions.clear();
+ ) << _("c.") << (QStringList()
+ << QLatin1String("int_a")
+ << QLatin1String("A"));
- code = "\n"
+ QTest::newRow("base_class_has_name_the_same_as_derived: base class has the same name as "
+ "derived but in different namespace") << _(
"namespace NS1\n"
"{\n"
"struct A\n"
@@ -845,17 +793,13 @@ void CppToolsPlugin::test_completion_base_class_has_name_the_same_as_derived_dat
"\n"
"NS2::A c;\n"
"@\n"
- "// padding so we get the scope right\n";
-
- completions.append(QLatin1String("int_ns1_a"));
- completions.append(QLatin1String("int_ns2_a"));
- completions.append(QLatin1String("A"));
- QTest::newRow("case: base class has the same name as derived but in different namespace")
- << code << completions;
-
- completions.clear();
+ ) << _("c.") << (QStringList()
+ << QLatin1String("int_ns1_a")
+ << QLatin1String("int_ns2_a")
+ << QLatin1String("A"));
- code = "\n"
+ QTest::newRow("base_class_has_name_the_same_as_derived: base class has the same name as "
+ "derived (in namespace) but is nested by different class") << _(
"struct Enclosing\n"
"{\n"
"struct A\n"
@@ -873,17 +817,13 @@ void CppToolsPlugin::test_completion_base_class_has_name_the_same_as_derived_dat
"\n"
"NS2::A c;\n"
"@\n"
- "// padding so we get the scope right\n";
-
- completions.append(QLatin1String("int_enclosing_a"));
- completions.append(QLatin1String("int_ns2_a"));
- completions.append(QLatin1String("A"));
- QTest::newRow("case: base class has the same name as derived(in namespace) "
- "but is nested by different class") << code << completions;
-
- completions.clear();
+ ) << _("c.") << (QStringList()
+ << QLatin1String("int_enclosing_a")
+ << QLatin1String("int_ns2_a")
+ << QLatin1String("A"));
- code = "\n"
+ QTest::newRow("base_class_has_name_the_same_as_derived: base class has the same name as "
+ "derived (nested) but is nested by different class") << _(
"struct EnclosingBase\n"
"{\n"
"struct A\n"
@@ -901,17 +841,13 @@ void CppToolsPlugin::test_completion_base_class_has_name_the_same_as_derived_dat
"\n"
"EnclosingDerived::A c;\n"
"@\n"
- "// padding so we get the scope right\n";
+ ) << _("c.") << (QStringList()
+ << QLatin1String("int_enclosing_base_a")
+ << QLatin1String("int_enclosing_derived_a")
+ << QLatin1String("A"));
- completions.append(QLatin1String("int_enclosing_base_a"));
- completions.append(QLatin1String("int_enclosing_derived_a"));
- completions.append(QLatin1String("A"));
- QTest::newRow("case: base class has the same name as derived(nested) "
- "but is nested by different class") << code << completions;
-
- completions.clear();
-
- code = "\n"
+ QTest::newRow("base_class_has_name_the_same_as_derived: base class is derived class. "
+ "class is a template") << _(
"template <typename T>\n"
"struct A : A\n"
"{\n"
@@ -920,45 +856,24 @@ void CppToolsPlugin::test_completion_base_class_has_name_the_same_as_derived_dat
"\n"
"A<int> c;\n"
"@\n"
- "// padding so we get the scope right\n";
-
- completions.append(QLatin1String("int_a"));
- completions.append(QLatin1String("A"));
- QTest::newRow("case: base class is derived class. class is a template")
- << code << completions;
-
- completions.clear();
-}
-
-void CppToolsPlugin::test_completion_cyclic_inheritance()
-{
- test_completion();
-}
-
-void CppToolsPlugin::test_completion_cyclic_inheritance_data()
-{
- QTest::addColumn<QByteArray>("code");
- QTest::addColumn<QStringList>("expectedCompletions");
-
- QByteArray code;
- QStringList completions;
+ ) << _("c.") << (QStringList()
+ << QLatin1String("int_a")
+ << QLatin1String("A"));
- code = "\n"
+ QTest::newRow("cyclic_inheritance: direct cyclic inheritance") << _(
"struct B;\n"
"struct A : B { int _a; };\n"
"struct B : A { int _b; };\n"
"\n"
"A c;\n"
"@\n"
- ;
- completions.append(QLatin1String("A"));
- completions.append(QLatin1String("_a"));
- completions.append(QLatin1String("B"));
- completions.append(QLatin1String("_b"));
- QTest::newRow("case: direct cyclic inheritance") << code << completions;
+ ) << _("c.") << (QStringList()
+ << QLatin1String("A")
+ << QLatin1String("_a")
+ << QLatin1String("B")
+ << QLatin1String("_b"));
- completions.clear();
- code = "\n"
+ QTest::newRow("cyclic_inheritance: indirect cyclic inheritance") << _(
"struct C;\n"
"struct A : C { int _a; };\n"
"struct B : A { int _b; };\n"
@@ -966,17 +881,15 @@ void CppToolsPlugin::test_completion_cyclic_inheritance_data()
"\n"
"A c;\n"
"@\n"
- ;
- completions.append(QLatin1String("A"));
- completions.append(QLatin1String("_a"));
- completions.append(QLatin1String("B"));
- completions.append(QLatin1String("_b"));
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("_c"));
- QTest::newRow("case: indirect cyclic inheritance") << code << completions;
-
- completions.clear();
- code = "\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("A")
+ << QLatin1String("_a")
+ << QLatin1String("B")
+ << QLatin1String("_b")
+ << QLatin1String("C")
+ << QLatin1String("_c"));
+
+ QTest::newRow("cyclic_inheritance: indirect cyclic inheritance") << _(
"struct B;\n"
"struct A : B { int _a; };\n"
"struct C { int _c; };\n"
@@ -984,17 +897,15 @@ void CppToolsPlugin::test_completion_cyclic_inheritance_data()
"\n"
"A c;\n"
"@\n"
- ;
- completions.append(QLatin1String("A"));
- completions.append(QLatin1String("_a"));
- completions.append(QLatin1String("B"));
- completions.append(QLatin1String("_b"));
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("_c"));
- QTest::newRow("case: indirect cyclic inheritance") << code << completions;
-
- completions.clear();
- code = "\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("A")
+ << QLatin1String("_a")
+ << QLatin1String("B")
+ << QLatin1String("_b")
+ << QLatin1String("C")
+ << QLatin1String("_c"));
+
+ QTest::newRow("cyclic_inheritance: direct cyclic inheritance with templates") << _(
"template< typename T > struct C;\n"
"template< typename T, typename S > struct D : C< S >\n"
"{\n"
@@ -1008,17 +919,14 @@ void CppToolsPlugin::test_completion_cyclic_inheritance_data()
"\n"
"D<int, float> c;\n"
"@\n"
- ;
- completions.append(QLatin1String("D"));
- completions.append(QLatin1String("_d_t"));
- completions.append(QLatin1String("_d_s"));
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("_c_t"));
- QTest::newRow("case: direct cyclic inheritance with templates")
- << code << completions;
-
- completions.clear();
- code = "\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("D")
+ << QLatin1String("_d_t")
+ << QLatin1String("_d_s")
+ << QLatin1String("C")
+ << QLatin1String("_c_t"));
+
+ QTest::newRow("cyclic_inheritance: indirect cyclic inheritance with templates") << _(
"template< typename T > struct C;\n"
"template< typename T, typename S > struct D : C< S >\n"
"{\n"
@@ -1036,19 +944,17 @@ void CppToolsPlugin::test_completion_cyclic_inheritance_data()
"\n"
"D<int, float> c;\n"
"@\n"
- ;
- completions.append(QLatin1String("D"));
- completions.append(QLatin1String("_d_t"));
- completions.append(QLatin1String("_d_s"));
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("_c_t"));
- completions.append(QLatin1String("B"));
- completions.append(QLatin1String("_b_t"));
- QTest::newRow("case: indirect cyclic inheritance with templates")
- << code << completions;
-
- completions.clear();
- code = "\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("D")
+ << QLatin1String("_d_t")
+ << QLatin1String("_d_s")
+ << QLatin1String("C")
+ << QLatin1String("_c_t")
+ << QLatin1String("B")
+ << QLatin1String("_b_t"));
+
+ QTest::newRow("cyclic_inheritance: direct cyclic inheritance with templates. "
+ "more complex situation") << _(
"namespace NS\n"
"{\n"
"template <typename T> struct SuperClass\n"
@@ -1076,86 +982,14 @@ void CppToolsPlugin::test_completion_cyclic_inheritance_data()
"\n"
"Class<int> c;\n"
"@\n"
- ;
- completions.append(QLatin1String("Class"));
- completions.append(QLatin1String("ClassRecurse"));
- completions.append(QLatin1String("class_t"));
- completions.append(QLatin1String("class_recurse_s"));
- completions.append(QLatin1String("class_recurse_t"));
- QTest::newRow("case: direct cyclic inheritance with templates, more complex situation")
- << code << completions;
-}
-
-void CppToolsPlugin::test_completion_template_function()
-{
- QFETCH(QByteArray, code);
- QFETCH(QStringList, expectedCompletions);
-
- CompletionTestCase test(code);
-
- QStringList actualCompletions = test.getCompletions();
- actualCompletions.sort();
- expectedCompletions.sort();
-
- QString errorPattern(QLatin1String("Completion not found: %1"));
- foreach (const QString &completion, expectedCompletions) {
- QByteArray errorMessage = errorPattern.arg(completion).toUtf8();
- QVERIFY2(actualCompletions.contains(completion), errorMessage.data());
- }
-}
-
-void CppToolsPlugin::test_completion_template_function_data()
-{
- QTest::addColumn<QByteArray>("code");
- QTest::addColumn<QStringList>("expectedCompletions");
-
- QByteArray code;
- QStringList completions;
-
- code = "\n"
- "template <class tclass, typename tname, int tint>\n"
- "tname Hello(const tclass &e)\n"
- "{\n"
- " tname e2 = e;\n"
- " @\n"
- "}";
-
- completions.append(QLatin1String("tclass"));
- completions.append(QLatin1String("tname"));
- completions.append(QLatin1String("tint"));
- QTest::newRow("case: template parameters in template function body")
- << code << completions;
-
- completions.clear();
-
- code = "\n"
- "template <class tclass, typename tname, int tint>\n"
- "tname Hello(const tclass &e, @)\n"
- "{\n"
- " tname e2 = e;\n"
- "}";
-
- completions.append(QLatin1String("tclass"));
- completions.append(QLatin1String("tname"));
- completions.append(QLatin1String("tint"));
- QTest::newRow("case: template parameters in template function parameters list")
- << code << completions;
-}
-
-void CppToolsPlugin::test_completion_enclosing_template_class()
-{
- test_completion();
-}
-
-void CppToolsPlugin::test_completion_enclosing_template_class_data()
-{
- QTest::addColumn<QByteArray>("code");
- QTest::addColumn<QStringList>("expectedCompletions");
-
- QByteArray code;
- QStringList completions;
-
- code = "\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("Class")
+ << QLatin1String("ClassRecurse")
+ << QLatin1String("class_t")
+ << QLatin1String("class_recurse_s")
+ << QLatin1String("class_recurse_t"));
+
+ QTest::newRow("enclosing_template_class: nested class with enclosing template class") << _(
"template<typename T>\n"
"struct Enclosing\n"
"{\n"
@@ -1164,15 +998,13 @@ void CppToolsPlugin::test_completion_enclosing_template_class_data()
"};\n"
"\n"
"Enclosing<int>::Nested c;"
- "@\n";
- completions.append(QLatin1String("Nested"));
- completions.append(QLatin1String("int_nested"));
- QTest::newRow("case: nested class with enclosing template class")
- << code << completions;
-
- completions.clear();
+ "@\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("Nested")
+ << QLatin1String("int_nested"));
- code = "\n"
+ QTest::newRow("enclosing_template_class: nested template class with enclosing template "
+ "class") << _(
"template<typename T>\n"
"struct Enclosing\n"
"{\n"
@@ -1181,16 +1013,12 @@ void CppToolsPlugin::test_completion_enclosing_template_class_data()
"};\n"
"\n"
"Enclosing<int>::Nested<int> c;"
- "@\n";
- completions.append(QLatin1String("Nested"));
- completions.append(QLatin1String("int_nested"));
- QTest::newRow("case: nested template class with enclosing template class")
- << code << completions;
-}
+ "@\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("Nested")
+ << QLatin1String("int_nested"));
-void CppToolsPlugin::test_completion_instantiate_nested_class_when_enclosing_is_template()
-{
- const QByteArray source = "\n"
+ QTest::newRow("instantiate_nested_class_when_enclosing_is_template") << _(
"struct Foo \n"
"{\n"
" int foo_i;\n"
@@ -1209,18 +1037,11 @@ void CppToolsPlugin::test_completion_instantiate_nested_class_when_enclosing_is_
"\n"
"Enclosing<Foo> enclosing;\n"
"@\n"
- ;
- CompletionTestCase test(source, "enclosing.nested.nested_t.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("foo_i")));
-}
+ ) << _("enclosing.nested.nested_t.") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("foo_i"));
-void CppToolsPlugin::test_completion_instantiate_nested_of_nested_class_when_enclosing_is_template()
-{
- const QByteArray source = "\n"
+ QTest::newRow("instantiate_nested_of_nested_class_when_enclosing_is_template") << _(
"struct Foo \n"
"{\n"
" int foo_i;\n"
@@ -1243,18 +1064,11 @@ void CppToolsPlugin::test_completion_instantiate_nested_of_nested_class_when_enc
"\n"
"Enclosing<Foo> enclosing;\n"
"@\n"
- ;
- CompletionTestCase test(source, "enclosing.nested.nestedNested.nestedNested_t.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("foo_i")));
-}
+ ) << _("enclosing.nested.nestedNested.nestedNested_t.") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("foo_i"));
-void CppToolsPlugin::test_completion_instantiate_template_with_default_argument_type()
-{
- const QByteArray source = "\n"
+ QTest::newRow("instantiate_template_with_default_argument_type") << _(
"struct Foo\n"
"{\n"
" int bar;\n"
@@ -1268,18 +1082,11 @@ void CppToolsPlugin::test_completion_instantiate_template_with_default_argument_
"\n"
"Template<> templateWithDefaultTypeOfArgument;\n"
"@\n"
- ;
- CompletionTestCase test(source, "templateWithDefaultTypeOfArgument.t.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
+ ) << _("templateWithDefaultTypeOfArgument.t.") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar"));
-void CppToolsPlugin::test_completion_instantiate_template_with_default_argument_type_as_template()
-{
- const QByteArray source = "\n"
+ QTest::newRow("instantiate_template_with_default_argument_type_as_template") << _(
"struct Foo\n"
"{\n"
" int bar;\n"
@@ -1298,222 +1105,35 @@ void CppToolsPlugin::test_completion_instantiate_template_with_default_argument_
"\n"
"Template<Foo> templateWithDefaultTypeOfArgument;\n"
"@\n"
- ;
- CompletionTestCase test(source, "templateWithDefaultTypeOfArgument.s.t.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
-
-void CppToolsPlugin::test_completion_member_access_operator_1()
-{
- const QByteArray source = "\n"
- "struct S { void t(); };\n"
- "void f() { S *s;\n"
- "@\n"
- "}\n"
- ;
- CompletionTestCase test(source, "s.");
-
- bool replaceAccessOperator = false;
- const QStringList completions = test.getCompletions(&replaceAccessOperator);
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("t")));
- QVERIFY(replaceAccessOperator);
-}
-
-void CppToolsPlugin::test_completion_typedef_of_type_and_decl_of_type_no_replace_access_operator()
-{
- const QByteArray source = "\n"
- "struct S { int m; };\n"
- "typedef S SType;\n"
- "SType p;\n"
- "@\n"
- "}\n"
- ;
- CompletionTestCase test(source, "p.");
-
- bool replaceAccessOperator = false;
- const QStringList completions = test.getCompletions(&replaceAccessOperator);
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("m")));
- QVERIFY(!replaceAccessOperator);
-}
-
-void CppToolsPlugin::test_completion_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator()
-{
- const QByteArray source = "\n"
- "struct S { int m; };\n"
- "typedef S *SType;\n"
- "SType *p;\n"
- "@\n"
- "}\n"
- ;
- CompletionTestCase test(source, "p.");
-
- bool replaceAccessOperator = false;
- const QStringList completions = test.getCompletions(&replaceAccessOperator);
- QCOMPARE(completions.size(), 0);
- QVERIFY(!replaceAccessOperator);
-}
-
-void CppToolsPlugin::test_completion_typedef_of_type_and_decl_of_pointer_replace_access_operator()
-{
- const QByteArray source = "\n"
- "struct S { int m; };\n"
- "typedef S SType;\n"
- "SType *p;\n"
- "@\n"
- "}\n"
- ;
- CompletionTestCase test(source, "p.");
+ ) << _("templateWithDefaultTypeOfArgument.s.t.") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar"));
- bool replaceAccessOperator = false;
- const QStringList completions = test.getCompletions(&replaceAccessOperator);
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("m")));
- QVERIFY(replaceAccessOperator);
-}
-
-void CppToolsPlugin::test_completion_typedef_of_pointer_and_decl_of_type_replace_access_operator()
-{
- const QByteArray source = "\n"
- "struct S { int m; };\n"
- "typedef S* SPtr;\n"
- "SPtr p;\n"
- "@\n"
- "}\n"
- ;
- CompletionTestCase test(source, "p.");
-
- bool replaceAccessOperator = false;
- const QStringList completions = test.getCompletions(&replaceAccessOperator);
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("m")));
- QVERIFY(replaceAccessOperator);
-}
-
-void CppToolsPlugin::test_completion_predecl_typedef_of_type_and_decl_of_pointer_replace_access_operator()
-{
- const QByteArray source = "\n"
- "typedef struct S SType;\n"
- "struct S { int m; };\n"
- "SType *p;\n"
- "@\n"
- "}\n"
- ;
- CompletionTestCase test(source, "p.");
-
- bool replaceAccessOperator = false;
- const QStringList completions = test.getCompletions(&replaceAccessOperator);
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("m")));
- QVERIFY(replaceAccessOperator);
-}
-
-void CppToolsPlugin::test_completion_predecl_typedef_of_type_and_decl_type_no_replace_access_operator()
-{
- const QByteArray source = "\n"
- "typedef struct S SType;\n"
- "struct S { int m; };\n"
- "SType p;\n"
- "@\n"
- "}\n"
- ;
- CompletionTestCase test(source, "p.");
-
- bool replaceAccessOperator = false;
- const QStringList completions = test.getCompletions(&replaceAccessOperator);
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("m")));
- QVERIFY(!replaceAccessOperator);
-}
-
-void CppToolsPlugin::test_completion_predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator()
-{
- const QByteArray source = "\n"
- "typedef struct S *SType;\n"
- "struct S { int m; };\n"
- "SType *p;\n"
- "@\n"
- "}\n"
- ;
- CompletionTestCase test(source, "p.");
-
- bool replaceAccessOperator = false;
- const QStringList completions = test.getCompletions(&replaceAccessOperator);
- QCOMPARE(completions.size(), 0);
- QVERIFY(!replaceAccessOperator);
-}
-
-void CppToolsPlugin::test_completion_predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator()
-{
- const QByteArray source = "\n"
- "typedef struct S *SType;\n"
- "struct S { int m; };\n"
- "SType p;\n"
- "@\n"
- "}\n"
- ;
- CompletionTestCase test(source, "p.");
-
- bool replaceAccessOperator = false;
- const QStringList completions = test.getCompletions(&replaceAccessOperator);
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("m")));
- QVERIFY(replaceAccessOperator);
-}
-
-void CppToolsPlugin::test_completion_typedef_of_pointer()
-{
- const QByteArray source = "\n"
+ QTest::newRow("typedef_of_pointer") << _(
"struct Foo { int bar; };\n"
"typedef Foo *FooPtr;\n"
"void main()\n"
"{\n"
" FooPtr ptr;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- CompletionTestCase test(source, "ptr->");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
+ "}"
+ ) << _("ptr->") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar"));
-void CppToolsPlugin::test_completion_typedef_of_pointer_inside_function()
-{
- const QByteArray source = "\n"
+ QTest::newRow("typedef_of_pointer_inside_function") << _(
"struct Foo { int bar; };\n"
"void f()\n"
"{\n"
" typedef Foo *FooPtr;\n"
" FooPtr ptr;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}";
- CompletionTestCase test(source, "ptr->");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
+ "}"
+ ) << _("ptr->") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar"));
-void CppToolsPlugin::test_completion_typedef_is_inside_function_before_declaration_block()
-{
- const QByteArray source = "\n"
+ QTest::newRow("typedef_is_inside_function_before_declaration_block") << _(
"struct Foo { int bar; };\n"
"void f()\n"
"{\n"
@@ -1521,21 +1141,13 @@ void CppToolsPlugin::test_completion_typedef_is_inside_function_before_declarati
" if (true) {\n"
" FooPtr ptr;\n"
" @\n"
- " // padding so we get the scope right\n"
" }"
"}"
- ;
- CompletionTestCase test(source, "ptr->");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
+ ) << _("ptr->") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar"));
-void CppToolsPlugin::test_completion_resolve_complex_typedef_with_template()
-{
- const QByteArray source = "\n"
+ QTest::newRow("resolve_complex_typedef_with_template") << _(
"template <typename T>\n"
"struct Template2\n"
"{\n"
@@ -1555,21 +1167,13 @@ void CppToolsPlugin::test_completion_resolve_complex_typedef_with_template()
"{\n"
" Template2<Foo> template2;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "template2.templateTypedef.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 3);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("bar")));
- QVERIFY(completions.contains(QLatin1String("Template1")));
-}
+ ) << _("template2.templateTypedef.") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar")
+ << QLatin1String("Template1"));
-void CppToolsPlugin::test_completion_template_specialization_with_pointer()
-{
- const QByteArray source = "\n"
+ QTest::newRow("template_specialization_with_pointer") << _(
"template <typename T>\n"
"struct Template\n"
"{\n"
@@ -1582,18 +1186,11 @@ void CppToolsPlugin::test_completion_template_specialization_with_pointer()
"};\n"
"Template<int*> templ;\n"
"@\n"
- ;
- CompletionTestCase test(source, "templ.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Template")));
- QVERIFY(completions.contains(QLatin1String("pointer")));
-}
+ ) << _("templ.") << (QStringList()
+ << QLatin1String("Template")
+ << QLatin1String("pointer"));
-void CppToolsPlugin::test_completion_typedef_using_templates1()
-{
- const QByteArray source = "\n"
+ QTest::newRow("typedef_using_templates1") << _(
"namespace NS1\n"
"{\n"
"template<typename T>\n"
@@ -1623,20 +1220,12 @@ void CppToolsPlugin::test_completion_typedef_using_templates1()
"{\n"
" NS2::NS2Struct<Foo> s;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "s.p->");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
+ ) << _("s.p->") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar"));
-void CppToolsPlugin::test_completion_typedef_using_templates2()
-{
- const QByteArray source = "\n"
+ QTest::newRow("typedef_using_templates2") << _(
"namespace NS1\n"
"{\n"
"template<typename T>\n"
@@ -1666,20 +1255,12 @@ void CppToolsPlugin::test_completion_typedef_using_templates2()
"{\n"
" NS2::NS2Struct<Foo>::pointer p;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "p->");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
+ ) << _("p->") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar"));
-void CppToolsPlugin::test_completion_namespace_alias_with_many_namespace_declarations()
-{
- const QByteArray source =
+ QTest::newRow("namespace_alias_with_many_namespace_declarations") << _(
"namespace NS1\n"
"{\n"
"namespace NS2\n"
@@ -1704,20 +1285,12 @@ void CppToolsPlugin::test_completion_namespace_alias_with_many_namespace_declara
"int main()\n"
"{\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "NS::");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo1")));
- QVERIFY(completions.contains(QLatin1String("Foo2")));
-}
+ ) << _("NS::") << (QStringList()
+ << QLatin1String("Foo1")
+ << QLatin1String("Foo2"));
-void CppToolsPlugin::test_completion_QTCREATORBUG9098()
-{
- const QByteArray source =
+ QTest::newRow("QTCREATORBUG9098") << _(
"template <typename T>\n"
"class B\n"
"{\n"
@@ -1732,32 +1305,13 @@ void CppToolsPlugin::test_completion_QTCREATORBUG9098()
" void fun()\n"
" {\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
"};\n"
- ;
- CompletionTestCase test(source, "b.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("c")));
- QVERIFY(completions.contains(QLatin1String("B")));
-}
-
-void CppToolsPlugin::test_completion_type_and_using_declaration()
-{
- test_completion();
-}
-
-void CppToolsPlugin::test_completion_type_and_using_declaration_data()
-{
- QTest::addColumn<QByteArray>("code");
- QTest::addColumn<QStringList>("expectedCompletions");
+ ) << _("b.") << (QStringList()
+ << QLatin1String("c")
+ << QLatin1String("B"));
- QByteArray code;
- QStringList completions;
-
- code = "\n"
+ QTest::newRow("type_and_using_declaration: type and using declaration inside function") << _(
"namespace NS\n"
"{\n"
"struct C { int m; };\n"
@@ -1767,16 +1321,13 @@ void CppToolsPlugin::test_completion_type_and_using_declaration_data()
" using NS::C;\n"
" C c;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}\n";
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("m"));
- QTest::newRow("case: type and using declaration inside function")
- << code << completions;
-
- completions.clear();
+ "}\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("m"));
- code = "\n"
+ QTest::newRow("type_and_using_declaration: type and using declaration in global "
+ "namespace") << _(
"namespace NS\n"
"{\n"
"struct C { int m; };\n"
@@ -1786,16 +1337,13 @@ void CppToolsPlugin::test_completion_type_and_using_declaration_data()
"{\n"
" C c;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}\n";
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("m"));
- QTest::newRow("case: type and using declaration in global namespace")
- << code << completions;
-
- completions.clear();
+ "}\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("m"));
- code = "\n"
+ QTest::newRow("type_and_using_declaration: type in global namespace and using declaration in "
+ "NS namespace") << _(
"struct C { int m; };\n"
"namespace NS\n"
"{\n"
@@ -1804,17 +1352,14 @@ void CppToolsPlugin::test_completion_type_and_using_declaration_data()
" {\n"
" C c;\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
- "}\n";
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("m"));
- QTest::newRow("case: type in global namespace and using declaration in NS namespace")
- << code << completions;
-
- completions.clear();
+ "}\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("m"));
- code = "\n"
+ QTest::newRow("type_and_using_declaration: type in global namespace and using declaration "
+ "inside function in NS namespace") << _(
"struct C { int m; };\n"
"namespace NS\n"
"{\n"
@@ -1823,17 +1368,14 @@ void CppToolsPlugin::test_completion_type_and_using_declaration_data()
" using ::C;\n"
" C c;\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
- "}\n";
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("m"));
- QTest::newRow("case: type in global namespace and using declaration inside function in NS namespace")
- << code << completions;
-
- completions.clear();
+ "}\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("m"));
- code = "\n"
+ QTest::newRow("type_and_using_declaration: type inside namespace NS1 and using declaration in "
+ "function inside NS2 namespace") << _(
"namespace NS1\n"
"{\n"
"struct C { int m; };\n"
@@ -1845,17 +1387,14 @@ void CppToolsPlugin::test_completion_type_and_using_declaration_data()
" using NS1::C;\n"
" C c;\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
- "}\n";
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("m"));
- QTest::newRow("case: type inside namespace NS1 and using declaration in function inside NS2 namespace")
- << code << completions;
-
- completions.clear();
+ "}\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("m"));
- code = "\n"
+ QTest::newRow("type_and_using_declaration: type inside namespace NS1 and using declaration "
+ "inside NS2 namespace") << _(
"namespace NS1\n"
"{\n"
"struct C { int m; };\n"
@@ -1867,18 +1406,13 @@ void CppToolsPlugin::test_completion_type_and_using_declaration_data()
" {\n"
" C c;\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
- "}\n";
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("m"));
- QTest::newRow("case: type inside namespace NS1 and using declaration inside NS2 namespace")
- << code << completions;
-}
+ "}\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("m"));
-void CppToolsPlugin::test_completion_instantiate_template_with_anonymous_class()
-{
- const QByteArray source =
+ QTest::newRow("instantiate_template_with_anonymous_class") << _(
"template <typename T>\n"
"struct S\n"
"{\n"
@@ -1888,39 +1422,23 @@ void CppToolsPlugin::test_completion_instantiate_template_with_anonymous_class()
"{\n"
" S<int> s;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "s.");
+ ) << _("s.") << (QStringList()
+ << QLatin1String("S"));
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 1);
- QVERIFY(completions.contains(QLatin1String("S")));
-}
-
-void CppToolsPlugin::test_completion_instantiate_template_function()
-{
- const QByteArray source =
+ QTest::newRow("instantiate_template_function") << _(
"template <typename T>\n"
"T* templateFunction() { return 0; }\n"
"struct A { int a; };\n"
"void foo()\n"
"{\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "templateFunction<A>()->");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("A")));
- QVERIFY(completions.contains(QLatin1String("a")));
-}
+ ) << _("templateFunction<A>()->") << (QStringList()
+ << QLatin1String("A")
+ << QLatin1String("a"));
-void CppToolsPlugin::test_completion_crash_cloning_template_class_QTCREATORBUG9329()
-{
- const QByteArray source =
+ QTest::newRow("crash_cloning_template_class_QTCREATORBUG9329") << _(
"struct A {};\n"
"template <typename T>\n"
"struct Templ {};\n"
@@ -1929,76 +1447,44 @@ void CppToolsPlugin::test_completion_crash_cloning_template_class_QTCREATORBUG93
" int f()\n"
" {\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
"};\n"
- ;
- CompletionTestCase test(source, "this->");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 4);
- QVERIFY(completions.contains(QLatin1String("A")));
- QVERIFY(completions.contains(QLatin1String("B")));
- QVERIFY(completions.contains(QLatin1String("Templ")));
- QVERIFY(completions.contains(QLatin1String("f")));
-}
+ ) << _("this->") << (QStringList()
+ << QLatin1String("A")
+ << QLatin1String("B")
+ << QLatin1String("Templ")
+ << QLatin1String("f"));
-void CppToolsPlugin::test_completion_recursive_auto_declarations1_QTCREATORBUG9503()
-{
- const QByteArray source =
+ QTest::newRow("recursive_auto_declarations1_QTCREATORBUG9503") << _(
"void f()\n"
"{\n"
" auto object2 = object1;\n"
" auto object1 = object2;\n"
" @;\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "object1.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 0);
-}
+ ) << _("object1.") << (QStringList());
-void CppToolsPlugin::test_completion_recursive_auto_declarations2_QTCREATORBUG9503()
-{
- const QByteArray source =
+ QTest::newRow("recursive_auto_declarations2_QTCREATORBUG9503") << _(
"void f()\n"
"{\n"
" auto object3 = object1;\n"
" auto object2 = object3;\n"
" auto object1 = object2;\n"
" @;\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "object1.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 0);
-}
+ ) << _("object1.") << (QStringList());
-void CppToolsPlugin::test_completion_recursive_typedefs_declarations1()
-{
- const QByteArray source =
+ QTest::newRow("recursive_typedefs_declarations1") << _(
"void f()\n"
"{\n"
" typedef A B;\n"
" typedef B A;\n"
" A a;\n"
" @;\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "a.");
+ ) << _("a.") << (QStringList());
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 0);
-}
-
-void CppToolsPlugin::test_completion_recursive_typedefs_declarations2()
-{
- const QByteArray source =
+ QTest::newRow("recursive_typedefs_declarations2") << _(
"void f()\n"
"{\n"
" typedef A C;\n"
@@ -2006,36 +1492,20 @@ void CppToolsPlugin::test_completion_recursive_typedefs_declarations2()
" typedef B A;\n"
" A a;\n"
" @;\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "a.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 0);
-}
+ ) << _("a.") << (QStringList());
-void CppToolsPlugin::test_completion_recursive_using_declarations1()
-{
- const QByteArray source =
+ QTest::newRow("recursive_using_declarations1") << _(
"void f()\n"
"{\n"
" using B = A;\n"
" using A = B;\n"
" A a;\n"
" @;\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "a.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 0);
-}
+ ) << _("a.") << (QStringList());
-void CppToolsPlugin::test_completion_recursive_using_declarations2()
-{
- const QByteArray source =
+ QTest::newRow("recursive_using_declarations2") << _(
"void f()\n"
"{\n"
" using C = A;\n"
@@ -2043,36 +1513,20 @@ void CppToolsPlugin::test_completion_recursive_using_declarations2()
" using A = B;\n"
" A a;\n"
" @;\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "a.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 0);
-}
+ ) << _("a.") << (QStringList());
-void CppToolsPlugin::test_completion_recursive_using_typedef_declarations()
-{
- const QByteArray source =
+ QTest::newRow("recursive_using_typedef_declarations") << _(
"void f()\n"
"{\n"
" using B = A;\n"
" typedef B A;\n"
" A a;\n"
" @;\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "a.");
+ ) << _("a.") << (QStringList());
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 0);
-}
-
-void CppToolsPlugin::test_completion_recursive_typedefs_in_templates1()
-{
- const QByteArray source =
+ QTest::newRow("recursive_typedefs_in_templates1") << _(
"template<typename From>\n"
"struct simplify_type {\n"
" typedef From SimpleType;\n"
@@ -2093,16 +1547,9 @@ void CppToolsPlugin::test_completion_recursive_typedefs_in_templates1()
"{\n"
" @;\n"
"}\n"
- ;
- CompletionTestCase test(source, "cast_retty<T1, T2>::ret_type.");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 0);
-}
+ ) << _("cast_retty<T1, T2>::ret_type.") << (QStringList());
-void CppToolsPlugin::test_completion_recursive_typedefs_in_templates2()
-{
- const QByteArray source =
+ QTest::newRow("recursive_typedefs_in_templates2") << _(
"template<class T>\n"
"struct recursive {\n"
" typedef typename recursive<T>::ret_type ret_type;\n"
@@ -2112,110 +1559,36 @@ void CppToolsPlugin::test_completion_recursive_typedefs_in_templates2()
"{\n"
" @;\n"
"}\n"
- ;
- CompletionTestCase test(source, "recursive<T1>::ret_type.foo");
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 0);
-}
+ ) << _("recursive<T1>::ret_type.foo") << (QStringList());
-void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_8737()
-{
- const QByteArray source =
- "void f()\n"
- "{\n"
- " int a_b_c, a_c, a_c_a;\n"
- " @;\n"
- " // padding so we get the scope right\n"
- "}\n"
- ;
- CompletionTestCase test(source, "a_c");
-
- QStringList completions = test.getCompletions();
-
- QVERIFY(completions.size() >= 2);
- QCOMPARE(completions.at(0), QLatin1String("a_c"));
- QCOMPARE(completions.at(1), QLatin1String("a_c_a"));
- QVERIFY(completions.contains(QLatin1String("a_b_c")));
-}
-
-void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_9236()
-{
- const QByteArray source =
- "class r_etclass\n"
- "{\n"
- "public:\n"
- " int raEmTmber;\n"
- " void r_e_t(int re_t)\n"
- " {\n"
- " int r_et;\n"
- " int rETUCASE;\n"
- " @\n"
- " // padding so we get the scope right\n"
- " }\n"
- "};\n"
- ;
- CompletionTestCase test(source, "ret");
-
- QStringList completions = test.getCompletions();
-
- QVERIFY(completions.size() >= 2);
- QCOMPARE(completions.at(0), QLatin1String("return"));
- QCOMPARE(completions.at(1), QLatin1String("rETUCASE"));
- QVERIFY(completions.contains(QLatin1String("r_etclass")));
- QVERIFY(completions.contains(QLatin1String("raEmTmber")));
- QVERIFY(completions.contains(QLatin1String("r_e_t")));
- QVERIFY(completions.contains(QLatin1String("re_t")));
- QVERIFY(completions.contains(QLatin1String("r_et")));
-}
-
-void CppToolsPlugin::test_completion_class_declaration_inside_function_or_block_QTCREATORBUG3620()
-{
- test_completion();
-}
-
-void CppToolsPlugin::test_completion_class_declaration_inside_function_or_block_QTCREATORBUG3620_data()
-{
- QTest::addColumn<QByteArray>("code");
- QTest::addColumn<QStringList>("expectedCompletions");
-
- QByteArray code;
- QStringList completions;
-
- code = "\n"
+ QTest::newRow("class_declaration_inside_function_or_block_QTCREATORBUG3620: "
+ "class definition inside function") << _(
"void foo()\n"
"{\n"
" struct C { int m; };\n"
" C c;\n"
" @\n"
- " // padding so we get the scope right\n"
- "}\n";
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("m"));
- QTest::newRow("case: class definition inside function")
- << code << completions;
-
- completions.clear();
+ "}\n"
+ ) << _("c.") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("m"));
- code = "\n"
+ QTest::newRow("class_declaration_inside_function_or_block_QTCREATORBUG3620: "
+ "class definition inside block inside function") << _(
"void foo()\n"
"{\n"
" {\n"
" struct C { int m; };\n"
" C c;\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
"}\n"
- ;
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("m"));
- QTest::newRow("case: class definition inside block inside function")
- << code << completions;
+ ) << _("c.") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("m"));
- completions.clear();
-
- code = "\n"
+ QTest::newRow("class_declaration_inside_function_or_block_QTCREATORBUG3620: "
+ "class definition with the same name inside different block inside function") << _(
"void foo()\n"
"{\n"
" {\n"
@@ -2225,32 +1598,14 @@ void CppToolsPlugin::test_completion_class_declaration_inside_function_or_block_
" struct C { int m2; };\n"
" C c;\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
"}\n"
- ;
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("m2"));
- QTest::newRow("case: class definition with the same name inside different block inside function")
- << code << completions;
+ ) << _("c.") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("m2"));
- completions.clear();
-}
-
-void CppToolsPlugin::test_completion_namespace_alias_inside_function_or_block_QTCREATORBUG166()
-{
- test_completion();
-}
-
-void CppToolsPlugin::test_completion_namespace_alias_inside_function_or_block_QTCREATORBUG166_data()
-{
- QTest::addColumn<QByteArray>("code");
- QTest::addColumn<QStringList>("expectedCompletions");
-
- QByteArray code;
- QStringList completions;
-
- code = "\n"
+ QTest::newRow("namespace_alias_inside_function_or_block_QTCREATORBUG166: "
+ "namespace alias inside function") << _(
"namespace NS1\n"
"{\n"
"namespace NS2\n"
@@ -2265,17 +1620,13 @@ void CppToolsPlugin::test_completion_namespace_alias_inside_function_or_block_QT
" namespace NS = NS1::NS2;\n"
" NS::C c;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("m"));
- QTest::newRow("case: namespace alias inside function")
- << code << completions;
-
- completions.clear();
+ ) << _("c.") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("m"));
- code = "\n"
+ QTest::newRow("namespace_alias_inside_function_or_block_QTCREATORBUG166: "
+ "namespace alias inside block inside function") << _(
"namespace NS1\n"
"{\n"
"namespace NS2\n"
@@ -2291,21 +1642,13 @@ void CppToolsPlugin::test_completion_namespace_alias_inside_function_or_block_QT
" namespace NS = NS1::NS2;\n"
" NS::C c;\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
"}\n"
- ;
- completions.append(QLatin1String("C"));
- completions.append(QLatin1String("m"));
- QTest::newRow("case: namespace alias inside block inside function")
- << code << completions;
-
- completions.clear();
-}
+ ) << _("c.") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("m"));
-void CppToolsPlugin::test_completion_class_declaration_inside_function_or_block_QTCREATORBUG3620_static_member()
-{
- const QByteArray source =
+ QTest::newRow("class_declaration_inside_function_or_block_QTCREATORBUG3620_static_member") << _(
"void foo()\n"
"{\n"
" {\n"
@@ -2314,162 +1657,164 @@ void CppToolsPlugin::test_completion_class_declaration_inside_function_or_block_
" {\n"
" struct C { static void staticFun2(); int m2; };\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
"}\n"
- ;
- CompletionTestCase test(source, "C::");
+ ) << _("C::") << (QStringList()
+ << QLatin1String("C")
+ << QLatin1String("staticFun2")
+ << QLatin1String("m2"));
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 3);
- QVERIFY(completions.contains(QLatin1String("C")));
- QVERIFY(completions.contains(QLatin1String("staticFun2")));
- QVERIFY(completions.contains(QLatin1String("m2")));
-}
-
-void CppToolsPlugin::test_completion_enum_inside_block_inside_function_QTCREATORBUG5456()
-{
- const QByteArray source =
+ QTest::newRow("enum_inside_block_inside_function_cxx11_QTCREATORBUG5456") << _(
"void foo()\n"
"{\n"
" {\n"
" enum E { e1, e2, e3 };\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
"}\n"
- ;
- CompletionTestCase test(source, "E::");
+ ) << _("E::") << (QStringList()
+ << QLatin1String("E")
+ << QLatin1String("e1")
+ << QLatin1String("e2")
+ << QLatin1String("e3"));
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 4);
- QVERIFY(completions.contains(QLatin1String("E")));
- QVERIFY(completions.contains(QLatin1String("e1")));
- QVERIFY(completions.contains(QLatin1String("e2")));
- QVERIFY(completions.contains(QLatin1String("e3")));
-}
-
-void CppToolsPlugin::test_completion_enum_inside_function_QTCREATORBUG5456()
-{
- const QByteArray source =
+ QTest::newRow("enum_inside_function_cxx11_QTCREATORBUG5456") << _(
"void foo()\n"
"{\n"
" enum E { e1, e2, e3 };\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "E::");
+ ) << _("E::") << (QStringList()
+ << QLatin1String("E")
+ << QLatin1String("e1")
+ << QLatin1String("e2")
+ << QLatin1String("e3"));
- const QStringList completions = test.getCompletions();
+ QTest::newRow("enum_inside_class") << _(
+ "struct Foo\n"
+ "{\n"
+ " enum E { val1, val2, val3 };\n"
+ " @\n"
+ "};\n"
+ "@\n"
+ ) << _("Foo::v") << (QStringList()
+ << QLatin1String("val1")
+ << QLatin1String("val2")
+ << QLatin1String("val3"));
- QCOMPARE(completions.size(), 4);
- QVERIFY(completions.contains(QLatin1String("E")));
- QVERIFY(completions.contains(QLatin1String("e1")));
- QVERIFY(completions.contains(QLatin1String("e2")));
- QVERIFY(completions.contains(QLatin1String("e3")));
-}
+ QTest::newRow("enum_inside_class_cxx11") << _(
+ "struct Foo\n"
+ "{\n"
+ " enum E { val1, val2, val3 };\n"
+ " @\n"
+ "};\n"
+ "@\n"
+ ) << _("Foo::E::") << (QStringList()
+ << QLatin1String("E")
+ << QLatin1String("val1")
+ << QLatin1String("val2")
+ << QLatin1String("val3"));
-void CppToolsPlugin::test_completion_lambdaCalls_1()
-{
- const QByteArray source =
- "struct S { int bar; };\n"
- "void foo()\n"
+ QTest::newRow("anon_enum_inside_class") << _(
+ "struct Foo\n"
"{\n"
+ " enum { val1, val2, val3 };\n"
" @\n"
- " // padding so we get the scope right\n"
- "}\n"
- ;
- CompletionTestCase test(source, "[](){ return new S; } ()->");
+ "};\n"
+ "@\n"
+ ) << _("Foo::v") << (QStringList()
+ << QLatin1String("val1")
+ << QLatin1String("val2")
+ << QLatin1String("val3"));
- const QStringList completions = test.getCompletions();
+ QTest::newRow("enum_inside_namespace") << _(
+ "namespace Ns\n"
+ "{\n"
+ " enum E { val1, val2, val3 };\n"
+ " @\n"
+ "};\n"
+ "@\n"
+ ) << _("Ns::v") << (QStringList()
+ << QLatin1String("val1")
+ << QLatin1String("val2")
+ << QLatin1String("val3"));
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
+ QTest::newRow("enum_inside_namespace_cxx11") << _(
+ "namespace Ns\n"
+ "{\n"
+ " enum E { val1, val2, val3 };\n"
+ " @\n"
+ "};\n"
+ "@\n"
+ ) << _("Ns::E::") << (QStringList()
+ << QLatin1String("E")
+ << QLatin1String("val1")
+ << QLatin1String("val2")
+ << QLatin1String("val3"));
-void CppToolsPlugin::test_completion_lambdaCalls_2()
-{
- const QByteArray source =
+ QTest::newRow("anon_enum_inside_namespace") << _(
+ "namespace Ns\n"
+ "{\n"
+ " enum { val1, val2, val3 };\n"
+ " @\n"
+ "};\n"
+ "@\n"
+ ) << _("Ns::v") << (QStringList()
+ << QLatin1String("val1")
+ << QLatin1String("val2")
+ << QLatin1String("val3"));
+
+ QTest::newRow("lambdaCalls_1") << _(
"struct S { int bar; };\n"
"void foo()\n"
"{\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "[] { return new S; } ()->");
-
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
+ ) << _("[](){ return new S; } ()->") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("bar"));
-void CppToolsPlugin::test_completion_lambdaCalls_3()
-{
- const QByteArray source =
+ QTest::newRow("lambdaCalls_2") << _(
"struct S { int bar; };\n"
"void foo()\n"
"{\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "[]() ->S* { return new S; } ()->");
-
- const QStringList completions = test.getCompletions();
+ ) << _("[] { return new S; } ()->") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("bar"));
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
-
-void CppToolsPlugin::test_completion_lambdaCalls_4()
-{
- const QByteArray source =
+ QTest::newRow("lambdaCalls_3") << _(
"struct S { int bar; };\n"
"void foo()\n"
"{\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "[]() throw() { return new S; } ()->");
-
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
+ ) << _("[]() ->S* { return new S; } ()->") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("bar"));
-void CppToolsPlugin::test_completion_lambdaCalls_5()
-{
- const QByteArray source =
+ QTest::newRow("lambdaCalls_4") << _(
"struct S { int bar; };\n"
"void foo()\n"
"{\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "[]() throw()->S* { return new S; } ()->");
-
- const QStringList completions = test.getCompletions();
+ ) << _("[]() throw() { return new S; } ()->") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("bar"));
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("S")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
+ QTest::newRow("lambdaCalls_5") << _(
+ "struct S { int bar; };\n"
+ "void foo()\n"
+ "{\n"
+ " @\n"
+ "}\n"
+ ) << _("[]() throw()->S* { return new S; } ()->") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("bar"));
-void CppToolsPlugin::test_completion_local_type_and_member_1()
-{
- const QByteArray source =
+ QTest::newRow("local_type_and_member_1") << _(
"struct OtherType { int otherTypeMember; };\n"
"void foo()\n"
"{\n"
@@ -2480,21 +1825,12 @@ void CppToolsPlugin::test_completion_local_type_and_member_1()
" };\n"
" LocalType lt;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "lt.ot.");
-
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("OtherType")));
- QVERIFY(completions.contains(QLatin1String("otherTypeMember")));
-}
+ ) << _("lt.ot.") << (QStringList()
+ << QLatin1String("OtherType")
+ << QLatin1String("otherTypeMember"));
-void CppToolsPlugin::test_completion_local_type_and_member_2()
-{
- const QByteArray source =
+ QTest::newRow("local_type_and_member_2") << _(
"void foo()\n"
"{\n"
" struct OtherType { int otherTypeMember; };\n"
@@ -2505,21 +1841,12 @@ void CppToolsPlugin::test_completion_local_type_and_member_2()
" };\n"
" LocalType lt;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "lt.ot.");
-
- const QStringList completions = test.getCompletions();
+ ) << _("lt.ot.") << (QStringList()
+ << QLatin1String("OtherType")
+ << QLatin1String("otherTypeMember"));
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("OtherType")));
- QVERIFY(completions.contains(QLatin1String("otherTypeMember")));
-}
-
-void CppToolsPlugin::test_completion_local_type_and_member_3()
-{
- const QByteArray source =
+ QTest::newRow("local_type_and_member_3") << _(
"void foo()\n"
"{\n"
" struct OtherType { int otherTypeMember; };\n"
@@ -2531,22 +1858,13 @@ void CppToolsPlugin::test_completion_local_type_and_member_3()
" };\n"
" LocalType lt;\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
"}\n"
- ;
- CompletionTestCase test(source, "lt.ot.");
-
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("OtherType")));
- QVERIFY(completions.contains(QLatin1String("otherTypeMember")));
-}
+ ) << _("lt.ot.") << (QStringList()
+ << QLatin1String("OtherType")
+ << QLatin1String("otherTypeMember"));
-void CppToolsPlugin::test_completion_local_type_and_member_4()
-{
- const QByteArray source =
+ QTest::newRow("local_type_and_member_4") << _(
"namespace NS {struct OtherType { int otherTypeMember; };}\n"
"void foo()\n"
"{\n"
@@ -2557,21 +1875,12 @@ void CppToolsPlugin::test_completion_local_type_and_member_4()
" };\n"
" LocalType lt;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "lt.ot.");
-
- const QStringList completions = test.getCompletions();
+ ) << _("lt.ot.") << (QStringList()
+ << QLatin1String("OtherType")
+ << QLatin1String("otherTypeMember"));
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("OtherType")));
- QVERIFY(completions.contains(QLatin1String("otherTypeMember")));
-}
-
-void CppToolsPlugin::test_completion_local_type_and_member_5()
-{
- const QByteArray source =
+ QTest::newRow("local_type_and_member_5") << _(
"namespace NS {struct OtherType { int otherTypeMember; };}\n"
"void foo()\n"
"{\n"
@@ -2583,21 +1892,12 @@ void CppToolsPlugin::test_completion_local_type_and_member_5()
" };\n"
" LocalType lt;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "lt.ot.");
-
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("OtherType")));
- QVERIFY(completions.contains(QLatin1String("otherTypeMember")));
-}
+ ) << _("lt.ot.") << (QStringList()
+ << QLatin1String("OtherType")
+ << QLatin1String("otherTypeMember"));
-void CppToolsPlugin::test_completion_local_type_and_member_6()
-{
- const QByteArray source =
+ QTest::newRow("local_type_and_member_6") << _(
"namespace NS {struct OtherType { int otherTypeMember; };}\n"
"void foo()\n"
"{\n"
@@ -2609,21 +1909,12 @@ void CppToolsPlugin::test_completion_local_type_and_member_6()
" };\n"
" LocalType lt;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "lt.ot.");
+ ) << _("lt.ot.") << (QStringList()
+ << QLatin1String("OtherType")
+ << QLatin1String("otherTypeMember"));
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("OtherType")));
- QVERIFY(completions.contains(QLatin1String("otherTypeMember")));
-}
-
-void CppToolsPlugin::test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG9169_1()
-{
- const QByteArray source =
+ QTest::newRow("template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG9169_1") << _(
"struct A\n"
"{\n"
" void foo();\n"
@@ -2649,21 +1940,12 @@ void CppToolsPlugin::test_completion_template_parameter_defined_inside_scope_of_
"{\n"
" Template<B> templ;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "templ.get()->");
+ ) << _("templ.get()->") << (QStringList()
+ << QLatin1String("B")
+ << QLatin1String("b"));
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("B")));
- QVERIFY(completions.contains(QLatin1String("b")));
-}
-
-void CppToolsPlugin::test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG9169_2()
-{
- const QByteArray source =
+ QTest::newRow("template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG9169_2") << _(
"struct A\n"
"{\n"
" void foo();\n"
@@ -2689,21 +1971,12 @@ void CppToolsPlugin::test_completion_template_parameter_defined_inside_scope_of_
"{\n"
" Template<B> templ;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "templ.t.");
+ ) << _("templ.t.") << (QStringList()
+ << QLatin1String("B")
+ << QLatin1String("b"));
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("B")));
- QVERIFY(completions.contains(QLatin1String("b")));
-}
-
-void CppToolsPlugin::test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_1()
-{
- const QByteArray source =
+ QTest::newRow("template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_1") << _(
"template <typename T>\n"
"struct QList\n"
"{\n"
@@ -2716,22 +1989,13 @@ void CppToolsPlugin::test_completion_template_parameter_defined_inside_scope_of_
" {\n"
" QList<Foo> list;\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
"}\n"
- ;
- CompletionTestCase test(source, "list.at(0).");
+ ) << _("list.at(0).") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar"));
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
-
-void CppToolsPlugin::test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_2()
-{
- const QByteArray source =
+ QTest::newRow("template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_2") << _(
"template <typename T>\n"
"struct QList\n"
"{\n"
@@ -2746,23 +2010,14 @@ void CppToolsPlugin::test_completion_template_parameter_defined_inside_scope_of_
" {\n"
" QList<Foo> list;\n"
" @\n"
- " // padding so we get the scope right\n"
" }\n"
" }\n"
"}\n"
- ;
- CompletionTestCase test(source, "list.at(0).");
-
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
+ ) << _("list.at(0).") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar"));
-void CppToolsPlugin::test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_3()
-{
- const QByteArray source =
+ QTest::newRow("template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_3") << _(
"template <typename T>\n"
"struct QList\n"
"{\n"
@@ -2777,72 +2032,49 @@ void CppToolsPlugin::test_completion_template_parameter_defined_inside_scope_of_
" using namespace ns;\n"
" QList<Foo> list;\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "list.at(0).");
+ ) << _("list.at(0).") << (QStringList()
+ << QLatin1String("Foo")
+ << QLatin1String("bar"));
- const QStringList completions = test.getCompletions();
-
- QCOMPARE(completions.size(), 2);
- QVERIFY(completions.contains(QLatin1String("Foo")));
- QVERIFY(completions.contains(QLatin1String("bar")));
-}
-
-void CppToolsPlugin::test_completion_signals_hide_QPrivateSignal()
-{
- const QByteArray source =
- "#define SIGNAL(a) #a\n"
- "#define SLOT(a) #a\n"
- "#define signals public\n"
- "#define Q_OBJECT struct QPrivateSignal {};\n"
- "\n"
- "class QObject\n"
- "{\n"
- "public:\n"
- " void connect(QObject *, char *, QObject *, char *);\n"
- "};\n"
- "\n"
- "class Timer : public QObject\n"
- "{\n"
- " Q_OBJECT\n"
- "signals:\n"
- " void timeout(QPrivateSignal);\n"
- "};\n"
- "\n"
- "void client()\n"
- "{\n"
- " Timer *timer = new Timer;\n"
- " connect(timer, SIGNAL(@\n"
- "}\n";
- CompletionTestCase test(source);
-
- const QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 1);
- QVERIFY(completions.contains(QLatin1String("timeout()")));
-}
+ QTest::newRow("signals_hide_QPrivateSignal") << _(
+ "#define SIGNAL(a) #a\n"
+ "#define SLOT(a) #a\n"
+ "#define signals public\n"
+ "#define Q_OBJECT struct QPrivateSignal {};\n"
+ "\n"
+ "class QObject\n"
+ "{\n"
+ "public:\n"
+ " void connect(QObject *, char *, QObject *, char *);\n"
+ "};\n"
+ "\n"
+ "class Timer : public QObject\n"
+ "{\n"
+ " Q_OBJECT\n"
+ "signals:\n"
+ " void timeout(QPrivateSignal);\n"
+ "};\n"
+ "\n"
+ "void client()\n"
+ "{\n"
+ " Timer *timer = new Timer;\n"
+ " connect(timer, SIGNAL(@\n"
+ "}\n"
+ ) << _() << (QStringList()
+ << QLatin1String("timeout()"));
-void CppToolsPlugin::test_completion_member_of_class_accessed_by_using_QTCREATORBUG9037_1()
-{
- const QByteArray source =
+ QTest::newRow("member_of_class_accessed_by_using_QTCREATORBUG9037_1") << _(
"namespace NS { struct S { int member; void fun(); }; }\n"
"using NS::S;\n"
"void S::fun()\n"
"{\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "mem");
-
- QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 1);
- QVERIFY(completions.contains(QLatin1String("member")));
-}
+ ) << _("mem") << (QStringList()
+ << QLatin1String("member"));
-void CppToolsPlugin::test_completion_member_of_class_accessed_by_using_QTCREATORBUG9037_2()
-{
- const QByteArray source =
+ QTest::newRow("member_of_class_accessed_by_using_QTCREATORBUG9037_2") << _(
"namespace NS \n"
"{\n"
" namespace Internal\n"
@@ -2855,12 +2087,129 @@ void CppToolsPlugin::test_completion_member_of_class_accessed_by_using_QTCREATOR
"void S::fun()\n"
"{\n"
" @\n"
- " // padding so we get the scope right\n"
"}\n"
- ;
- CompletionTestCase test(source, "mem");
+ ) << _("mem") << (QStringList()
+ << QLatin1String("member"));
+}
- QStringList completions = test.getCompletions();
- QCOMPARE(completions.size(), 1);
- QVERIFY(completions.contains(QLatin1String("member")));
+void CppToolsPlugin::test_completion_member_access_operator()
+{
+ QFETCH(QByteArray, code);
+ QFETCH(QByteArray, prefix);
+ QFETCH(QStringList, expectedCompletions);
+ QFETCH(bool, expectedReplaceAccessOperator);
+
+ CompletionTestCase test(code, prefix);
+ QVERIFY(test.succeededSoFar());
+
+ bool replaceAccessOperator = false;
+ QStringList completions = test.getCompletions(&replaceAccessOperator);
+
+ completions.sort();
+ expectedCompletions.sort();
+
+ QCOMPARE(completions, expectedCompletions);
+ QCOMPARE(replaceAccessOperator, expectedReplaceAccessOperator);
+}
+
+void CppToolsPlugin::test_completion_member_access_operator_data()
+{
+ QTest::addColumn<QByteArray>("code");
+ QTest::addColumn<QByteArray>("prefix");
+ QTest::addColumn<QStringList>("expectedCompletions");
+ QTest::addColumn<bool>("expectedReplaceAccessOperator");
+
+ QTest::newRow("member_access_operator") << _(
+ "struct S { void t(); };\n"
+ "void f() { S *s;\n"
+ "@\n"
+ "}\n"
+ ) << _("s.") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("t"))
+ << true;
+
+ QTest::newRow("typedef_of_type_and_decl_of_type_no_replace_access_operator") << _(
+ "struct S { int m; };\n"
+ "typedef S SType;\n"
+ "SType p;\n"
+ "@\n"
+ "}\n"
+ ) << _("p.") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("m"))
+ << false;
+
+ QTest::newRow("typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator") << _(
+ "struct S { int m; };\n"
+ "typedef S *SType;\n"
+ "SType *p;\n"
+ "@\n"
+ "}\n"
+ ) << _("p.") << (QStringList())
+ << false;
+
+ QTest::newRow("typedef_of_type_and_decl_of_pointer_replace_access_operator") << _(
+ "struct S { int m; };\n"
+ "typedef S SType;\n"
+ "SType *p;\n"
+ "@\n"
+ "}\n"
+ ) << _("p.") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("m"))
+ << true;
+
+ QTest::newRow("typedef_of_pointer_and_decl_of_type_replace_access_operator") << _(
+ "struct S { int m; };\n"
+ "typedef S* SPtr;\n"
+ "SPtr p;\n"
+ "@\n"
+ "}\n"
+ ) << _("p.") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("m"))
+ << true;
+
+ QTest::newRow("predecl_typedef_of_type_and_decl_of_pointer_replace_access_operator") << _(
+ "typedef struct S SType;\n"
+ "struct S { int m; };\n"
+ "SType *p;\n"
+ "@\n"
+ "}\n"
+ ) << _("p.") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("m"))
+ << true;
+
+ QTest::newRow("predecl_typedef_of_type_and_decl_type_no_replace_access_operator") << _(
+ "typedef struct S SType;\n"
+ "struct S { int m; };\n"
+ "SType p;\n"
+ "@\n"
+ "}\n"
+ ) << _("p.") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("m"))
+ << false;
+
+ QTest::newRow("predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator") << _(
+ "typedef struct S *SType;\n"
+ "struct S { int m; };\n"
+ "SType *p;\n"
+ "@\n"
+ "}\n"
+ ) << _("p.") << (QStringList())
+ << false;
+
+ QTest::newRow("predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator") << _(
+ "typedef struct S *SType;\n"
+ "struct S { int m; };\n"
+ "SType p;\n"
+ "@\n"
+ "}\n"
+ ) << _("p.") << (QStringList()
+ << QLatin1String("S")
+ << QLatin1String("m"))
+ << true;
}
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index 2c8878a24a..f5c58bee34 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -1362,19 +1362,14 @@ void CppCompletionAssistProcessor::globalCompletion(CPlusPlus::Scope *currentSco
for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) {
if (scope->isBlock()) {
- for (unsigned i = 0; i < scope->memberCount(); ++i) {
+ for (unsigned i = 0; i < scope->memberCount(); ++i)
addCompletionItem(scope->memberAt(i), FunctionLocalsOrder);
- }
- } else if (scope->isFunction()) {
- Function *fun = scope->asFunction();
- for (unsigned i = 0, argc = fun->argumentCount(); i < argc; ++i) {
+ } else if (Function *fun = scope->asFunction()) {
+ for (unsigned i = 0, argc = fun->argumentCount(); i < argc; ++i)
addCompletionItem(fun->argumentAt(i), FunctionArgumentsOrder);
- }
- } else if (scope->isTemplate()) {
- Template *templ = scope->asTemplate();
- for (unsigned i = 0, argc = templ->templateParameterCount(); i < argc; ++i) {
+ } else if (Template *templ = scope->asTemplate()) {
+ for (unsigned i = 0, argc = templ->templateParameterCount(); i < argc; ++i)
addCompletionItem(templ->templateParameterAt(i), FunctionArgumentsOrder);
- }
break;
}
}
@@ -1513,9 +1508,8 @@ void CppCompletionAssistProcessor::completeNamespace(CPlusPlus::ClassOrNamespace
scopesToVisit.append(scope);
}
- foreach (Enum *e, binding->unscopedEnums()) {
+ foreach (Enum *e, binding->unscopedEnums())
scopesToVisit.append(e);
- }
while (!scopesToVisit.isEmpty()) {
Scope *scope = scopesToVisit.takeFirst();
@@ -1729,9 +1723,8 @@ void CppCompletionAssistProcessor::addMacros_helper(const CPlusPlus::Snapshot &s
processed->insert(doc->fileName());
- foreach (const Document::Include &i, doc->resolvedIncludes()) {
+ foreach (const Document::Include &i, doc->resolvedIncludes())
addMacros_helper(snapshot, i.resolvedFileName(), processed, definedMacros);
- }
foreach (const Macro &macro, doc->definedMacros()) {
const QString macroName = QString::fromUtf8(macro.name().constData(), macro.name().length());
diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
index 2febb844c6..fb5567d47c 100644
--- a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
+++ b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
@@ -57,11 +57,11 @@ CppCurrentDocumentFilter::CppCurrentDocumentFilter(CppModelManager *manager)
this, SLOT(onEditorAboutToClose(Core::IEditor*)));
}
-QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString & origEntry)
+QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString & origEntry)
{
QString entry = trimWildcards(origEntry);
- QList<Locator::FilterEntry> goodEntries;
- QList<Locator::FilterEntry> betterEntries;
+ QList<Core::LocatorFilterEntry> goodEntries;
+ QList<Core::LocatorFilterEntry> betterEntries;
QStringMatcher matcher(entry, Qt::CaseInsensitive);
const QChar asterisk = QLatin1Char('*');
QRegExp regexp(asterisk + entry + asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
@@ -102,7 +102,7 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterfac
if (info.unqualifiedNameAndScope(matchString, &name, &extraInfo))
name += info.symbolType;
}
- Locator::FilterEntry filterEntry(this, name, id, info.icon);
+ Core::LocatorFilterEntry filterEntry(this, name, id, info.icon);
filterEntry.extraInfo = extraInfo;
if (matchString.startsWith(entry, caseSensitivityForPrefix))
@@ -118,7 +118,7 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterfac
return betterEntries;
}
-void CppCurrentDocumentFilter::accept(Locator::FilterEntry selection) const
+void CppCurrentDocumentFilter::accept(Core::LocatorFilterEntry selection) const
{
ModelItemInfo info = qvariant_cast<CppTools::ModelItemInfo>(selection.internalData);
Core::EditorManager::openEditorAt(info.fileName, info.line, info.column);
diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.h b/src/plugins/cpptools/cppcurrentdocumentfilter.h
index 5e2bb390d6..b181bc40bf 100644
--- a/src/plugins/cpptools/cppcurrentdocumentfilter.h
+++ b/src/plugins/cpptools/cppcurrentdocumentfilter.h
@@ -31,7 +31,7 @@
#include "searchsymbols.h"
-#include <locator/ilocatorfilter.h>
+#include <coreplugin/locator/ilocatorfilter.h>
namespace Core { class IEditor; }
@@ -40,7 +40,7 @@ namespace Internal {
class CppModelManager;
-class CppCurrentDocumentFilter : public Locator::ILocatorFilter
+class CppCurrentDocumentFilter : public Core::ILocatorFilter
{
Q_OBJECT
@@ -48,8 +48,8 @@ public:
explicit CppCurrentDocumentFilter(CppModelManager *manager);
~CppCurrentDocumentFilter() {}
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
private slots:
diff --git a/src/plugins/cpptools/cppfilesettingspage.cpp b/src/plugins/cpptools/cppfilesettingspage.cpp
index c5cac630ef..cb2a39949d 100644
--- a/src/plugins/cpptools/cppfilesettingspage.cpp
+++ b/src/plugins/cpptools/cppfilesettingspage.cpp
@@ -254,6 +254,7 @@ CppFileSettingsWidget::CppFileSettingsWidget(QWidget *parent) :
foreach (const QString &suffix, headerMt.suffixes())
m_ui->headerSuffixComboBox->addItem(suffix);
m_ui->licenseTemplatePathChooser->setExpectedKind(Utils::PathChooser::File);
+ m_ui->licenseTemplatePathChooser->setHistoryCompleter(QLatin1String("Cpp.LicenseTemplate.History"));
m_ui->licenseTemplatePathChooser->addButton(tr("Edit..."), this, SLOT(slotEdit()));
}
@@ -292,21 +293,6 @@ CppFileSettings CppFileSettingsWidget::settings() const
return rc;
}
-QString CppFileSettingsWidget::searchKeywords() const
-{
- QString rc;
- QTextStream(&rc) << m_ui->headersGroupBox->title()
- << ' ' << m_ui->headerSuffixLabel->text()
- << ' ' << m_ui->headerSearchPathsLabel->text()
- << ' ' << m_ui->sourcesGroupBox->title()
- << ' ' << m_ui->sourceSuffixLabel->text()
- << ' ' << m_ui->sourceSearchPathsLabel->text()
- << ' ' << m_ui->lowerCaseFileNamesCheckBox->text()
- << ' ' << m_ui->licenseTemplateLabel->text();
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
static inline void setComboText(QComboBox *cb, const QString &text, int defaultIndex = 0)
{
const int index = cb->findText(text);
@@ -354,13 +340,13 @@ CppFileSettingsPage::CppFileSettingsPage(QSharedPointer<CppFileSettings> &settin
setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_CPP_ICON));
}
-QWidget *CppFileSettingsPage::createPage(QWidget *parent)
+QWidget *CppFileSettingsPage::widget()
{
- m_widget = new CppFileSettingsWidget(parent);
- m_widget->setSettings(*m_settings);
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new CppFileSettingsWidget;
+ m_widget->setSettings(*m_settings);
+ }
return m_widget;
}
@@ -377,9 +363,9 @@ void CppFileSettingsPage::apply()
}
}
-bool CppFileSettingsPage::matches(const QString &s) const
+void CppFileSettingsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/cpptools/cppfilesettingspage.h b/src/plugins/cpptools/cppfilesettingspage.h
index df66260303..0ca3284246 100644
--- a/src/plugins/cpptools/cppfilesettingspage.h
+++ b/src/plugins/cpptools/cppfilesettingspage.h
@@ -80,8 +80,6 @@ public:
CppFileSettings settings() const;
void setSettings(const CppFileSettings &s);
- QString searchKeywords() const;
-
private slots:
void slotEdit();
@@ -98,15 +96,13 @@ public:
explicit CppFileSettingsPage(QSharedPointer<CppFileSettings> &settings,
QObject *parent = 0);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &) const;
+ void finish();
private:
const QSharedPointer<CppFileSettings> m_settings;
QPointer<CppFileSettingsWidget> m_widget;
- QString m_searchKeywords;
};
} // namespace Internal
diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp
index 0cce94007c..8f846a90c2 100644
--- a/src/plugins/cpptools/cppfindreferences.cpp
+++ b/src/plugins/cpptools/cppfindreferences.cpp
@@ -325,15 +325,15 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
bool replace)
{
Overview overview;
- Find::SearchResult *search = Find::SearchResultWindow::instance()->startNewSearch(tr("C++ Usages:"),
+ Core::SearchResult *search = Core::SearchResultWindow::instance()->startNewSearch(tr("C++ Usages:"),
QString(),
overview.prettyName(context.fullyQualifiedName(symbol)),
- replace ? Find::SearchResultWindow::SearchAndReplace
- : Find::SearchResultWindow::SearchOnly,
+ replace ? Core::SearchResultWindow::SearchAndReplace
+ : Core::SearchResultWindow::SearchOnly,
QLatin1String("CppEditor"));
search->setTextToReplace(replacement);
- connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)),
- SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)));
+ connect(search, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)),
+ SLOT(onReplaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)));
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
search->setSearchAgainSupported(true);
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
@@ -354,7 +354,7 @@ void CppFindReferences::renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus:
}
}
-void CppFindReferences::findAll_helper(Find::SearchResult *search, CPlusPlus::Symbol *symbol,
+void CppFindReferences::findAll_helper(Core::SearchResult *search, CPlusPlus::Symbol *symbol,
const CPlusPlus::LookupContext &context)
{
if (!(symbol && symbol->identifier())) {
@@ -362,10 +362,10 @@ void CppFindReferences::findAll_helper(Find::SearchResult *search, CPlusPlus::Sy
return;
}
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
- connect(search, SIGNAL(activated(Find::SearchResultItem)),
- this, SLOT(openEditor(Find::SearchResultItem)));
+ connect(search, SIGNAL(activated(Core::SearchResultItem)),
+ this, SLOT(openEditor(Core::SearchResultItem)));
- Find::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
+ Core::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
const CppModelManagerInterface::WorkingCopy workingCopy = m_modelManager->workingCopy();
QFuture<Usage> result;
result = QtConcurrent::run(&find_helper, workingCopy, context, this, symbol);
@@ -378,19 +378,19 @@ void CppFindReferences::findAll_helper(Find::SearchResult *search, CPlusPlus::Sy
}
void CppFindReferences::onReplaceButtonClicked(const QString &text,
- const QList<Find::SearchResultItem> &items,
+ const QList<Core::SearchResultItem> &items,
bool preserveCase)
{
const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items, preserveCase);
if (!fileNames.isEmpty()) {
m_modelManager->updateSourceFiles(fileNames);
- Find::SearchResultWindow::instance()->hide();
+ Core::SearchResultWindow::instance()->hide();
}
}
void CppFindReferences::searchAgain()
{
- Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
+ Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
CppFindReferencesParameters parameters = search->userData().value<CppFindReferencesParameters>();
Snapshot snapshot = CppModelManagerInterface::instance()->snapshot();
search->restart();
@@ -470,7 +470,7 @@ CPlusPlus::Symbol *CppFindReferences::findSymbol(const CppFindReferencesParamete
void CppFindReferences::displayResults(int first, int last)
{
QFutureWatcher<Usage> *watcher = static_cast<QFutureWatcher<Usage> *>(sender());
- Find::SearchResult *search = m_watchers.value(watcher);
+ Core::SearchResult *search = m_watchers.value(watcher);
if (!search) {
// search was deleted while it was running
watcher->cancel();
@@ -489,7 +489,7 @@ void CppFindReferences::displayResults(int first, int last)
void CppFindReferences::searchFinished()
{
QFutureWatcher<Usage> *watcher = static_cast<QFutureWatcher<Usage> *>(sender());
- Find::SearchResult *search = m_watchers.value(watcher);
+ Core::SearchResult *search = m_watchers.value(watcher);
if (search)
search->finishSearch(watcher->isCanceled());
m_watchers.remove(watcher);
@@ -498,7 +498,7 @@ void CppFindReferences::searchFinished()
void CppFindReferences::cancel()
{
- Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
+ Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
QTC_ASSERT(search, return);
QFutureWatcher<Usage> *watcher = m_watchers.key(search);
QTC_ASSERT(watcher, return);
@@ -507,7 +507,7 @@ void CppFindReferences::cancel()
void CppFindReferences::setPaused(bool paused)
{
- Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
+ Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
QTC_ASSERT(search, return);
QFutureWatcher<Usage> *watcher = m_watchers.key(search);
QTC_ASSERT(watcher, return);
@@ -515,7 +515,7 @@ void CppFindReferences::setPaused(bool paused)
watcher->setPaused(paused);
}
-void CppFindReferences::openEditor(const Find::SearchResultItem &item)
+void CppFindReferences::openEditor(const Core::SearchResultItem &item)
{
if (item.path.size() > 0) {
EditorManager::openEditorAt(QDir::fromNativeSeparators(item.path.first()),
@@ -634,22 +634,22 @@ void CppFindReferences::findMacroUses(const Macro &macro)
void CppFindReferences::findMacroUses(const Macro &macro, const QString &replacement, bool replace)
{
- Find::SearchResult *search = Find::SearchResultWindow::instance()->startNewSearch(
+ Core::SearchResult *search = Core::SearchResultWindow::instance()->startNewSearch(
tr("C++ Macro Usages:"),
QString(),
QString::fromUtf8(macro.name()),
- replace ? Find::SearchResultWindow::SearchAndReplace
- : Find::SearchResultWindow::SearchOnly,
+ replace ? Core::SearchResultWindow::SearchAndReplace
+ : Core::SearchResultWindow::SearchOnly,
QLatin1String("CppEditor"));
search->setTextToReplace(replacement);
- connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)),
- SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)));
+ connect(search, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)),
+ SLOT(onReplaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)));
- Find::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
+ Core::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
- connect(search, SIGNAL(activated(Find::SearchResultItem)),
- this, SLOT(openEditor(Find::SearchResultItem)));
+ connect(search, SIGNAL(activated(Core::SearchResultItem)),
+ this, SLOT(openEditor(Core::SearchResultItem)));
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
@@ -714,7 +714,7 @@ void CppFindReferences::setDependencyTable(const CPlusPlus::DependencyTable &new
m_deps = newTable;
}
-void CppFindReferences::createWatcher(const QFuture<Usage> &future, Find::SearchResult *search)
+void CppFindReferences::createWatcher(const QFuture<Usage> &future, Core::SearchResult *search)
{
QFutureWatcher<Usage> *watcher = new QFutureWatcher<Usage>();
watcher->setPendingResultsLimit(1);
diff --git a/src/plugins/cpptools/cppfindreferences.h b/src/plugins/cpptools/cppfindreferences.h
index 3b8863d0b0..200907ed11 100644
--- a/src/plugins/cpptools/cppfindreferences.h
+++ b/src/plugins/cpptools/cppfindreferences.h
@@ -41,10 +41,10 @@
QT_FORWARD_DECLARE_CLASS(QTimer)
-namespace Find {
+namespace Core {
class SearchResultItem;
class SearchResult;
-} // namespace Find
+} // namespace Core
namespace CppTools {
class CppModelManagerInterface;
@@ -86,8 +86,8 @@ private slots:
void searchFinished();
void cancel();
void setPaused(bool paused);
- void openEditor(const Find::SearchResultItem &item);
- void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items, bool preserveCase);
+ void openEditor(const Core::SearchResultItem &item);
+ void onReplaceButtonClicked(const QString &text, const QList<Core::SearchResultItem> &items, bool preserveCase);
void searchAgain();
private:
@@ -95,17 +95,17 @@ private:
const QString &replacement, bool replace);
void findMacroUses(const CPlusPlus::Macro &macro, const QString &replacement,
bool replace);
- void findAll_helper(Find::SearchResult *search, CPlusPlus::Symbol *symbol,
+ void findAll_helper(Core::SearchResult *search, CPlusPlus::Symbol *symbol,
const CPlusPlus::LookupContext &context);
CPlusPlus::DependencyTable dependencyTable() const;
void setDependencyTable(const CPlusPlus::DependencyTable &newTable);
- void createWatcher(const QFuture<CPlusPlus::Usage> &future, Find::SearchResult *search);
+ void createWatcher(const QFuture<CPlusPlus::Usage> &future, Core::SearchResult *search);
CPlusPlus::Symbol *findSymbol(const CppFindReferencesParameters &parameters,
const CPlusPlus::Snapshot &snapshot, CPlusPlus::LookupContext *context);
private:
QPointer<CppModelManagerInterface> m_modelManager;
- QMap<QFutureWatcher<CPlusPlus::Usage> *, QPointer<Find::SearchResult> > m_watchers;
+ QMap<QFutureWatcher<CPlusPlus::Usage> *, QPointer<Core::SearchResult> > m_watchers;
mutable QMutex m_depsLock;
CPlusPlus::DependencyTable m_deps;
diff --git a/src/plugins/cpptools/cppfunctionsfilter.cpp b/src/plugins/cpptools/cppfunctionsfilter.cpp
index 400d19c1e6..1f17402763 100644
--- a/src/plugins/cpptools/cppfunctionsfilter.cpp
+++ b/src/plugins/cpptools/cppfunctionsfilter.cpp
@@ -49,7 +49,7 @@ QList<QList<CppTools::ModelItemInfo> > CppFunctionsFilter::itemsToMatchUserInput
return QList<QList<CppTools::ModelItemInfo> >() << m_data->functions();
}
-Locator::FilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info)
+Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info)
{
const QVariant id = qVariantFromValue(info);
@@ -59,7 +59,7 @@ Locator::FilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(const CppT
if (extraInfo.isEmpty())
extraInfo = info.shortNativeFilePath();
- Locator::FilterEntry filterEntry(this, name + info.symbolType, id, info.icon);
+ Core::LocatorFilterEntry filterEntry(this, name + info.symbolType, id, info.icon);
filterEntry.extraInfo = extraInfo;
return filterEntry;
diff --git a/src/plugins/cpptools/cppfunctionsfilter.h b/src/plugins/cpptools/cppfunctionsfilter.h
index a3aa7d3c09..5926f645cd 100644
--- a/src/plugins/cpptools/cppfunctionsfilter.h
+++ b/src/plugins/cpptools/cppfunctionsfilter.h
@@ -46,7 +46,7 @@ public:
private:
QList<QList<ModelItemInfo> > itemsToMatchUserInputAgainst() const;
- Locator::FilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
+ Core::LocatorFilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
};
} // namespace Internal
diff --git a/src/plugins/cpptools/cppheadersource_test.cpp b/src/plugins/cpptools/cppheadersource_test.cpp
index 95cb2cf1c6..bbc4efa24f 100644
--- a/src/plugins/cpptools/cppheadersource_test.cpp
+++ b/src/plugins/cpptools/cppheadersource_test.cpp
@@ -46,8 +46,8 @@ void CppToolsPlugin::test_headersource()
QFETCH(QString, headerFileName);
bool wasHeader;
- Core::Internal::Tests::TestDataDir dataDir(
- _(SRCDIR "/../../../tests/cppheadersource/") + _(QTest::currentDataTag()));
+ Core::Tests::TestDataDir dataDir(_(SRCDIR "/../../../tests/cppheadersource/")
+ + _(QTest::currentDataTag()));
const QString sourcePath = dataDir.file(sourceFileName);
const QString headerPath = dataDir.file(headerFileName);
diff --git a/src/plugins/cpptools/cpphighlightingsupport.h b/src/plugins/cpptools/cpphighlightingsupport.h
index 97f2e9d475..757c3b04df 100644
--- a/src/plugins/cpptools/cpphighlightingsupport.h
+++ b/src/plugins/cpptools/cpphighlightingsupport.h
@@ -57,7 +57,8 @@ public:
LabelUse,
MacroUse,
FunctionUse,
- PseudoKeywordUse
+ PseudoKeywordUse,
+ StringUse
};
public:
diff --git a/src/plugins/cpptools/cppindexingsupport.h b/src/plugins/cpptools/cppindexingsupport.h
index 00cb80f5d4..bd50dfc636 100644
--- a/src/plugins/cpptools/cppindexingsupport.h
+++ b/src/plugins/cpptools/cppindexingsupport.h
@@ -34,8 +34,8 @@
#include "cppmodelmanagerinterface.h"
-#include <find/searchresultwindow.h>
-#include <find/textfindconstants.h>
+#include <coreplugin/find/searchresultwindow.h>
+#include <coreplugin/find/textfindconstants.h>
#include <QFuture>
#include <QStringList>
@@ -64,7 +64,7 @@ public:
struct Parameters
{
QString text;
- Find::FindFlags flags;
+ Core::FindFlags flags;
SymbolTypes types;
SearchScope scope;
};
@@ -73,7 +73,7 @@ public:
public:
SymbolSearcher(QObject *parent = 0);
virtual ~SymbolSearcher() = 0;
- virtual void runSearch(QFutureInterface<Find::SearchResultItem> &future) = 0;
+ virtual void runSearch(QFutureInterface<Core::SearchResultItem> &future) = 0;
};
diff --git a/src/plugins/cpptools/cpplocatorfilter.cpp b/src/plugins/cpptools/cpplocatorfilter.cpp
index 5680d36dc0..e4286e13ee 100644
--- a/src/plugins/cpptools/cpplocatorfilter.cpp
+++ b/src/plugins/cpptools/cpplocatorfilter.cpp
@@ -47,10 +47,10 @@ CppLocatorFilter::~CppLocatorFilter()
{
}
-Locator::FilterEntry CppLocatorFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info)
+Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info)
{
const QVariant id = qVariantFromValue(info);
- Locator::FilterEntry filterEntry(this, info.scopedSymbolName(), id, info.icon);
+ Core::LocatorFilterEntry filterEntry(this, info.scopedSymbolName(), id, info.icon);
filterEntry.extraInfo = info.type == ModelItemInfo::Class || info.type == ModelItemInfo::Enum
? info.shortNativeFilePath()
: info.symbolType;
@@ -71,17 +71,17 @@ QList<QList<CppTools::ModelItemInfo> > CppLocatorFilter::itemsToMatchUserInputAg
<< m_data->enums();
}
-static bool compareLexigraphically(const Locator::FilterEntry &a,
- const Locator::FilterEntry &b)
+static bool compareLexigraphically(const Core::LocatorFilterEntry &a,
+ const Core::LocatorFilterEntry &b)
{
return a.displayName < b.displayName;
}
-QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &origEntry)
+QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &origEntry)
{
QString entry = trimWildcards(origEntry);
- QList<Locator::FilterEntry> goodEntries;
- QList<Locator::FilterEntry> betterEntries;
+ QList<Core::LocatorFilterEntry> goodEntries;
+ QList<Core::LocatorFilterEntry> betterEntries;
const QChar asterisk = QLatin1Char('*');
QStringMatcher matcher(entry, Qt::CaseInsensitive);
QRegExp regexp(asterisk + entry+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
@@ -99,7 +99,7 @@ QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locato
const QString matchString = hasColonColon ? info.scopedSymbolName() : info.symbolName;
if ((hasWildcard && regexp.exactMatch(matchString))
|| (!hasWildcard && matcher.indexIn(matchString) != -1)) {
- const Locator::FilterEntry filterEntry = filterEntryFromModelItemInfo(info);
+ const Core::LocatorFilterEntry filterEntry = filterEntryFromModelItemInfo(info);
if (matchString.startsWith(entry, caseSensitivityForPrefix))
betterEntries.append(filterEntry);
else
@@ -117,7 +117,7 @@ QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locato
return betterEntries;
}
-void CppLocatorFilter::accept(Locator::FilterEntry selection) const
+void CppLocatorFilter::accept(Core::LocatorFilterEntry selection) const
{
ModelItemInfo info = qvariant_cast<CppTools::ModelItemInfo>(selection.internalData);
Core::EditorManager::openEditorAt(info.fileName, info.line, info.column);
diff --git a/src/plugins/cpptools/cpplocatorfilter.h b/src/plugins/cpptools/cpplocatorfilter.h
index c170241037..aba6fe4a27 100644
--- a/src/plugins/cpptools/cpplocatorfilter.h
+++ b/src/plugins/cpptools/cpplocatorfilter.h
@@ -33,14 +33,14 @@
#include "cpplocatordata.h"
#include "searchsymbols.h"
-#include <locator/ilocatorfilter.h>
+#include <coreplugin/locator/ilocatorfilter.h>
namespace CppTools {
namespace Internal {
class CppModelManager;
-class CppLocatorFilter : public Locator::ILocatorFilter
+class CppLocatorFilter : public Core::ILocatorFilter
{
Q_OBJECT
@@ -48,13 +48,13 @@ public:
CppLocatorFilter(CppLocatorData *locatorData);
~CppLocatorFilter();
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
private:
virtual QList<QList<ModelItemInfo> > itemsToMatchUserInputAgainst() const;
- virtual Locator::FilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
+ virtual Core::LocatorFilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
protected:
CppLocatorData *m_data;
diff --git a/src/plugins/cpptools/cpplocatorfilter_test.cpp b/src/plugins/cpptools/cpplocatorfilter_test.cpp
index bc3b9341fd..175ba94ea8 100644
--- a/src/plugins/cpptools/cpplocatorfilter_test.cpp
+++ b/src/plugins/cpptools/cpplocatorfilter_test.cpp
@@ -34,11 +34,12 @@
#include "cppfunctionsfilter.h"
#include "cpplocatorfilter.h"
#include "cppmodelmanager.h"
+#include "cpptoolstestcase.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/testdatadir.h>
#include <extensionsystem/pluginmanager.h>
-#include <locator/locatorfiltertest.h>
+#include <coreplugin/locator/locatorfiltertest.h>
#include <utils/fileutils.h>
#include <QDebug>
@@ -46,99 +47,94 @@
#include <QtTest>
using namespace Core;
-using namespace Core::Internal::Tests;
+using namespace Core::Tests;
using namespace CppTools::Internal;
using namespace ExtensionSystem;
-using namespace Locator;
-using namespace Locator::Internal;
-using namespace Locator::Internal::Tests;
using namespace Utils;
Q_DECLARE_METATYPE(ILocatorFilter *)
namespace {
-class MyTestDataDir : public Core::Internal::Tests::TestDataDir
-{
-public:
- MyTestDataDir(const QString &testDataDirectory)
- : TestDataDir(QLatin1String(SRCDIR "/../../../tests/cpplocators/") + testDataDirectory) {}
-};
+QTC_DECLARE_MYTESTDATADIR("../../../tests/cpplocators/")
+
+inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
-class CppLocatorFilterTest : public BasicLocatorFilterTest
+class CppLocatorFilterTestCase
+ : public BasicLocatorFilterTest
+ , public CppTools::Tests::TestCase
{
public:
- CppLocatorFilterTest(ILocatorFilter *filter, const QString &fileName)
+ CppLocatorFilterTestCase(ILocatorFilter *filter,
+ const QString &fileName,
+ const QString &searchText,
+ const ResultDataList &expectedResults)
: BasicLocatorFilterTest(filter)
- , m_modelManager(CppModelManager::instance())
, m_fileName(fileName)
{
+ QVERIFY(succeededSoFar());
QVERIFY(!m_fileName.isEmpty());
- m_modelManager->GC();
- QVERIFY(m_modelManager->snapshot().isEmpty());
- }
+ QVERIFY(garbageCollectGlobalSnapshot());
-private:
- virtual void doBeforeLocatorRun()
- {
- m_modelManager->updateSourceFiles(QStringList() << m_fileName).waitForFinished();
- QVERIFY(m_modelManager->snapshot().contains(m_fileName));
- QCoreApplication::processEvents();
+ ResultDataList results = ResultData::fromFilterEntryList(matchesFor(searchText));
+// ResultData::printFilterEntries(results);
+ QVERIFY(!results.isEmpty());
+ QCOMPARE(results, expectedResults);
}
- virtual void doAfterLocatorRun()
- {
- m_modelManager->GC();
- QVERIFY(m_modelManager->snapshot().isEmpty());
- }
+private:
+ void doBeforeLocatorRun() { QVERIFY(parseFiles(m_fileName)); }
+ void doAfterLocatorRun() { QVERIFY(garbageCollectGlobalSnapshot()); }
- CppModelManager *m_modelManager;
+private:
const QString m_fileName;
};
-class CppCurrentDocumentFilterTest : public BasicLocatorFilterTest
+class CppCurrentDocumentFilterTestCase
+ : public BasicLocatorFilterTest
+ , public CppTools::Tests::TestCase
{
public:
- CppCurrentDocumentFilterTest(const QString &fileName)
+ CppCurrentDocumentFilterTestCase(const QString &fileName,
+ const ResultDataList &expectedResults)
: BasicLocatorFilterTest(PluginManager::getObject<CppCurrentDocumentFilter>())
- , m_modelManager(CppModelManager::instance())
, m_editor(0)
, m_fileName(fileName)
{
+ QVERIFY(succeededSoFar());
QVERIFY(!m_fileName.isEmpty());
- m_modelManager->GC();
- QVERIFY(m_modelManager->snapshot().isEmpty());
+
+ ResultDataList results = ResultData::fromFilterEntryList(matchesFor());
+// ResultData::printFilterEntries(results);
+ QVERIFY(!results.isEmpty());
+ QCOMPARE(results, expectedResults);
}
private:
- virtual void doBeforeLocatorRun()
+ void doBeforeLocatorRun()
{
QVERIFY(EditorManager::documentModel()->openedDocuments().isEmpty());
- m_modelManager->GC();
- QVERIFY(m_modelManager->snapshot().isEmpty());
+ QVERIFY(garbageCollectGlobalSnapshot());
m_editor = EditorManager::openEditor(m_fileName);
QVERIFY(m_editor);
- while (!m_modelManager->snapshot().contains(m_fileName))
- QCoreApplication::processEvents();
+
+ waitForFileInGlobalSnapshot(m_fileName);
}
- virtual void doAfterLocatorRun()
+ void doAfterLocatorRun()
{
- EditorManager::closeEditor(m_editor, /*askAboutModifiedEditors=*/ false);
+ QVERIFY(closeEditorWithoutGarbageCollectorInvocation(m_editor));
QCoreApplication::processEvents();
QVERIFY(EditorManager::documentModel()->openedDocuments().isEmpty());
- m_modelManager->GC();
- QVERIFY(m_modelManager->snapshot().isEmpty());
+ QVERIFY(garbageCollectGlobalSnapshot());
}
- CppModelManager *m_modelManager;
+private:
IEditor *m_editor;
const QString m_fileName;
};
-inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
-
} // anonymous namespace
void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter()
@@ -148,11 +144,7 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter()
QFETCH(QString, searchText);
QFETCH(ResultDataList, expectedResults);
- CppLocatorFilterTest test(filter, testFile);
- ResultDataList results = ResultData::fromFilterEntryList(test.matchesFor(searchText));
-// ResultData::printFilterEntries(results);
- QVERIFY(!results.isEmpty());
- QCOMPARE(results, expectedResults);
+ CppLocatorFilterTestCase(filter, testFile, searchText, expectedResults);
}
void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
@@ -173,15 +165,18 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
QTest::newRow("CppFunctionsFilter")
<< testFile
<< cppFunctionsFilter
- << QString::fromLatin1("function")
+ << _("function")
<< (QList<ResultData>()
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
- << ResultData(_("functionDefinedInClass(bool, int)"), _("<anonymous namespace>::MyClass"))
+ << ResultData(_("functionDefinedInClass(bool, int)"),
+ _("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
- << ResultData(_("functionDefinedOutSideClass(char)"), _("<anonymous namespace>::MyClass"))
- << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
+ << ResultData(_("functionDefinedOutSideClass(char)"),
+ _("<anonymous namespace>::MyClass"))
+ << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
+ _("MyNamespace::MyClass"))
<< ResultData(_("myFunction(bool, int)"), testFileShort)
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
@@ -195,7 +190,8 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
<< ResultData(_("MyClass()"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
- << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
+ << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
+ _("MyNamespace::MyClass"))
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
);
@@ -225,7 +221,8 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
<< (QList<ResultData>()
<< ResultData(_("<anonymous namespace>::MyClass"), testFileShort)
<< ResultData(_("<anonymous namespace>::MyClass::MyClass"), _("()"))
- << ResultData(_("<anonymous namespace>::MyClass::functionDefinedOutSideClass"), _("(char)"))
+ << ResultData(_("<anonymous namespace>::MyClass::functionDefinedOutSideClass"),
+ _("(char)"))
<< ResultData(_("<anonymous namespace>::MyEnum"), testFileShort)
<< ResultData(_("<anonymous namespace>::myFunction"), _("(bool, int)"))
<< ResultData(_("MyClass"), testFileShort)
@@ -234,8 +231,10 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
<< ResultData(_("MyEnum"), testFileShort)
<< ResultData(_("MyNamespace::MyClass"), testFileShort)
<< ResultData(_("MyNamespace::MyClass::MyClass"), _("()"))
- << ResultData(_("MyNamespace::MyClass::functionDefinedOutSideClass"), _("(char)"))
- << ResultData(_("MyNamespace::MyClass::functionDefinedOutSideClassAndNamespace"), _("(float)"))
+ << ResultData(_("MyNamespace::MyClass::functionDefinedOutSideClass"),
+ _("(char)"))
+ << ResultData(_("MyNamespace::MyClass::functionDefinedOutSideClassAndNamespace"),
+ _("(float)"))
<< ResultData(_("MyNamespace::MyEnum"), testFileShort)
<< ResultData(_("MyNamespace::myFunction"), _("(bool, int)"))
<< ResultData(_("myFunction"), _("(bool, int)"))
@@ -269,9 +268,11 @@ void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter()
<< ResultData(_("functionDeclaredOnly()"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
- << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
+ << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
+ _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
- << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
+ << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
+ _("MyNamespace::MyClass"))
<< ResultData(_("int myVariable"), _("<anonymous namespace>"))
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
<< ResultData(_("MyEnum"), _("<anonymous namespace>"))
@@ -286,9 +287,5 @@ void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter()
<< ResultData(_("main()"), _(""))
;
- CppCurrentDocumentFilterTest test(testFile);
- ResultDataList results = ResultData::fromFilterEntryList(test.matchesFor());
-// ResultData::printFilterEntries(results);
- QVERIFY(!results.isEmpty());
- QCOMPARE(expectedResults, results);
+ CppCurrentDocumentFilterTestCase(testFile, expectedResults);
}
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index 1ea0c77de4..f4a5329b33 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -64,7 +64,8 @@ namespace CppTools {
uint qHash(const ProjectPart &p)
{
- uint h = qHash(p.defines) ^ p.cVersion ^ p.cxxVersion ^ p.cxxExtensions ^ p.qtVersion;
+ uint h = qHash(p.toolchainDefines) ^ qHash(p.projectDefines) ^ p.cVersion ^ p.cxxVersion
+ ^ p.cxxExtensions ^ p.qtVersion;
foreach (const QString &i, p.includePaths)
h ^= qHash(i);
@@ -78,7 +79,9 @@ uint qHash(const ProjectPart &p)
bool operator==(const ProjectPart &p1,
const ProjectPart &p2)
{
- if (p1.defines != p2.defines)
+ if (p1.toolchainDefines != p2.toolchainDefines)
+ return false;
+ if (p1.projectDefines != p2.projectDefines)
return false;
if (p1.cVersion != p2.cVersion)
return false;
@@ -363,6 +366,22 @@ QStringList CppModelManager::internalFrameworkPaths() const
return frameworkPaths;
}
+static void addUnique(const QList<QByteArray> &defs, QByteArray *macros, QSet<QByteArray> *alreadyIn)
+{
+ Q_ASSERT(macros);
+ Q_ASSERT(alreadyIn);
+
+ foreach (const QByteArray &def, defs) {
+ if (def.trimmed().isEmpty())
+ continue;
+ if (!alreadyIn->contains(def)) {
+ macros->append(def);
+ macros->append('\n');
+ alreadyIn->insert(def);
+ }
+ }
+}
+
QByteArray CppModelManager::internalDefinedMacros() const
{
QByteArray macros;
@@ -372,14 +391,8 @@ QByteArray CppModelManager::internalDefinedMacros() const
it.next();
const ProjectInfo pinfo = it.value();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
- const QList<QByteArray> defs = part->defines.split('\n');
- foreach (const QByteArray &def, defs) {
- if (!alreadyIn.contains(def)) {
- macros += def;
- macros.append('\n');
- alreadyIn.insert(def);
- }
- }
+ addUnique(part->toolchainDefines.split('\n'), &macros, &alreadyIn);
+ addUnique(part->projectDefines.split('\n'), &macros, &alreadyIn);
}
}
return macros;
@@ -422,7 +435,8 @@ void CppModelManager::dumpModelManagerConfiguration()
qDebug() << "cxxExtensions:" << cxxExtensions;
qDebug() << "Qt version:" << part->qtVersion;
qDebug() << "precompiled header:" << part->precompiledHeaders;
- qDebug() << "defines:" << part->defines;
+ qDebug() << "toolchain defines:" << part->toolchainDefines;
+ qDebug() << "project defines:" << part->projectDefines;
qDebug() << "includes:" << part->includePaths;
qDebug() << "frameworkPaths:" << part->frameworkPaths;
qDebug() << "files:" << part->files;
@@ -802,7 +816,7 @@ ProjectPart::Ptr CppModelManager::fallbackProjectPart() const
{
ProjectPart::Ptr part(new ProjectPart);
- part->defines = m_definedMacros;
+ part->projectDefines = m_definedMacros;
part->includePaths = m_includePaths;
part->frameworkPaths = m_frameworkPaths;
part->cVersion = ProjectPart::C11;
@@ -832,7 +846,8 @@ void CppModelManager::onProjectAdded(ProjectExplorer::Project *)
void CppModelManager::delayedGC()
{
- m_delayedGcTimer->start(500);
+ if (m_enableGC)
+ m_delayedGcTimer->start(500);
}
void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
@@ -978,6 +993,12 @@ CppIndexingSupport *CppModelManager::indexingSupport()
return m_indexingSupporter ? m_indexingSupporter : m_internalIndexingSupport;
}
+void CppModelManager::enableGarbageCollector(bool enable)
+{
+ m_delayedGcTimer->stop();
+ m_enableGC = enable;
+}
+
void CppModelManager::setExtraDiagnostics(const QString &fileName,
const QString &kind,
const QList<Document::DiagnosticMessage> &diagnostics)
diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h
index e8e922b604..96a5796a2d 100644
--- a/src/plugins/cpptools/cppmodelmanager.h
+++ b/src/plugins/cpptools/cppmodelmanager.h
@@ -47,7 +47,6 @@ namespace TextEditor { class BaseTextEditorWidget; }
namespace CppTools {
class CppEditorSupport;
-class CppHighlightingSupportFactory;
namespace Internal {
@@ -153,6 +152,8 @@ public:
return m_definedMacros;
}
+ void enableGarbageCollector(bool enable);
+
static QStringList timeStampModifiedFiles(const QList<Document::Ptr> documentsToCheck);
signals:
diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp
index 91e89fced7..7f2b7765c8 100644
--- a/src/plugins/cpptools/cppmodelmanager_test.cpp
+++ b/src/plugins/cpptools/cppmodelmanager_test.cpp
@@ -27,9 +27,10 @@
**
****************************************************************************/
-#include "cpptoolsplugin.h"
#include "cpppreprocessor.h"
#include "cpptoolseditorsupport.h"
+#include "cpptoolsplugin.h"
+#include "cpptoolstestcase.h"
#include "modelmanagertesthelper.h"
#include <coreplugin/editormanager/editormanager.h>
@@ -62,7 +63,7 @@ namespace {
inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
-class MyTestDataDir : public Core::Internal::Tests::TestDataDir
+class MyTestDataDir : public Core::Tests::TestDataDir
{
public:
MyTestDataDir(const QString &dir)
@@ -181,25 +182,30 @@ public:
return isFetchOk;
}
- void writeContents(const QByteArray &contents) const
+ bool writeContents(const QByteArray &contents) const
{
- Utils::FileSaver fileSaver(m_filePath);
- fileSaver.write(contents);
- fileSaver.finalize();
+ return CppTools::Tests::TestCase::writeFile(m_filePath, contents);
}
private:
void restoreContents() const
{
- Utils::FileSaver fileSaver(m_filePath);
- fileSaver.write(m_originalFileContents);
- fileSaver.finalize();
+ CppTools::Tests::TestCase::writeFile(m_filePath, m_originalFileContents);
}
QByteArray m_originalFileContents;
const QString &m_filePath;
};
+static QStringList updateProjectInfo(CppModelManager *modelManager, ModelManagerTestHelper *helper,
+ const ProjectInfo &projectInfo)
+{
+ helper->resetRefreshedSourceFiles();
+ modelManager->updateProjectInfo(projectInfo).waitForFinished();
+ QCoreApplication::processEvents();
+ return helper->waitForRefreshedSourceFiles();
+}
+
} // anonymous namespace
/// Check: The preprocessor cleans include and framework paths.
@@ -217,7 +223,7 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean()
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5;
- part->defines = QByteArray("#define OH_BEHAVE -1\n");
+ part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
part->includePaths = QStringList() << testDataDir.includeDir(false);
part->frameworkPaths = QStringList() << testDataDir.frameworksDir(false);
pi.appendProjectPart(part);
@@ -251,7 +257,7 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5;
- part->defines = QByteArray("#define OH_BEHAVE -1\n");
+ part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
part->includePaths << testDataDir.includeDir();
part->frameworkPaths << testDataDir.frameworksDir();
const QString &source = testDataDir.fileFromSourcesDir(
@@ -300,14 +306,12 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5;
- part->defines = QByteArray("#define OH_BEHAVE -1\n");
+ part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
part->includePaths = QStringList() << testDataDir.includeDir(false);
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
- mm->updateProjectInfo(pi);
-
- QStringList refreshedFiles = helper.waitForRefreshedSourceFiles();
+ QStringList refreshedFiles = updateProjectInfo(mm, &helper, pi);
QCOMPARE(refreshedFiles.size(), 1);
QVERIFY(refreshedFiles.contains(testCpp));
CPlusPlus::Snapshot snapshot = mm->snapshot();
@@ -320,12 +324,11 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
QVERIFY(macrosInHeaderBefore.first().name() == "test_modelmanager_refresh_h");
// Introduce a define that will enable another define once the document is reparsed.
- part->defines = QByteArray("#define TEST_DEFINE 1\n");
+ part->projectDefines = QByteArray("#define TEST_DEFINE 1\n");
pi.clearProjectParts();
pi.appendProjectPart(part);
- mm->updateProjectInfo(pi);
- refreshedFiles = helper.waitForRefreshedSourceFiles();
+ refreshedFiles = updateProjectInfo(mm, &helper, pi);
QCOMPARE(refreshedFiles.size(), 1);
QVERIFY(refreshedFiles.contains(testCpp));
@@ -377,7 +380,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
ProjectPart::Ptr part(new ProjectPart);
// Simulate project configuration change by having different defines each time.
defines += "\n#define ANOTHER_DEFINE";
- part->defines = defines;
+ part->projectDefines = defines;
part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testHeader1, ProjectFile::CXXHeader));
@@ -385,11 +388,9 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
- mm->updateProjectInfo(pi);
-
- refreshedFiles = helper.waitForRefreshedSourceFiles();
-
+ refreshedFiles = updateProjectInfo(mm, &helper, pi);
QCOMPARE(refreshedFiles.size(), 3);
+
QVERIFY(refreshedFiles.contains(testHeader1));
QVERIFY(refreshedFiles.contains(testHeader2));
QVERIFY(refreshedFiles.contains(testCpp));
@@ -432,8 +433,10 @@ void CppToolsPlugin::test_modelmanager_refresh_test_for_changes()
pi.appendProjectPart(part);
// Reindexing triggers a reparsing thread
+ helper.resetRefreshedSourceFiles();
QFuture<void> firstFuture = mm->updateProjectInfo(pi);
QVERIFY(firstFuture.isStarted() || firstFuture.isRunning());
+ firstFuture.waitForFinished();
const QStringList refreshedFiles = helper.waitForRefreshedSourceFiles();
QCOMPARE(refreshedFiles.size(), 1);
QVERIFY(refreshedFiles.contains(testCpp));
@@ -470,8 +473,7 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
CPlusPlus::Snapshot snapshot;
QStringList refreshedFiles;
- mm->updateProjectInfo(pi);
- refreshedFiles = helper.waitForRefreshedSourceFiles();
+ refreshedFiles = updateProjectInfo(mm, &helper, pi);
QCOMPARE(refreshedFiles.size(), 2);
QVERIFY(refreshedFiles.contains(testHeader1));
@@ -490,8 +492,7 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
newPart->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
pi.appendProjectPart(newPart);
- mm->updateProjectInfo(pi);
- refreshedFiles = helper.waitForRefreshedSourceFiles();
+ refreshedFiles = updateProjectInfo(mm, &helper, pi);
// Only the added project file was reparsed
QCOMPARE(refreshedFiles.size(), 1);
@@ -530,8 +531,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
CPlusPlus::Snapshot snapshot;
QStringList refreshedFiles;
- mm->updateProjectInfo(pi);
- refreshedFiles = helper.waitForRefreshedSourceFiles();
+ refreshedFiles = updateProjectInfo(mm, &helper, pi);
QCOMPARE(refreshedFiles.size(), initialProjectFiles.size());
snapshot = mm->snapshot();
@@ -551,7 +551,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
QByteArray originalContents;
QVERIFY(fileChangerAndRestorer.readContents(&originalContents));
const QByteArray newFileContentes = originalContents + "\nint addedOtherGlobal;";
- fileChangerAndRestorer.writeContents(newFileContentes);
+ QVERIFY(fileChangerAndRestorer.writeContents(newFileContentes));
// Add or remove source file. The configuration stays the same.
part->files.clear();
@@ -560,8 +560,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
pi.clearProjectParts();
pi.appendProjectPart(part);
- mm->updateProjectInfo(pi);
- refreshedFiles = helper.waitForRefreshedSourceFiles();
+ refreshedFiles = updateProjectInfo(mm, &helper, pi);
QCOMPARE(refreshedFiles.size(), finalProjectFiles.size());
snapshot = mm->snapshot();
@@ -618,8 +617,7 @@ void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects()
<< _("foo.cpp")
<< _("main.cpp"));
- mm->updateProjectInfo(project1.projectInfo);
- refreshedFiles = helper.waitForRefreshedSourceFiles();
+ refreshedFiles = updateProjectInfo(mm, &helper, project1.projectInfo);
QCOMPARE(refreshedFiles.toSet(), project1.projectFiles.toSet());
const int snapshotSizeAfterProject1 = mm->snapshot().size();
@@ -633,8 +631,7 @@ void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects()
<< _("bar.cpp")
<< _("main.cpp"));
- mm->updateProjectInfo(project2.projectInfo);
- refreshedFiles = helper.waitForRefreshedSourceFiles();
+ refreshedFiles = updateProjectInfo(mm, &helper, project2.projectInfo);
QCOMPARE(refreshedFiles.toSet(), project2.projectFiles.toSet());
const int snapshotSizeAfterProject2 = mm->snapshot().size();
@@ -710,6 +707,7 @@ void CppToolsPlugin::test_modelmanager_gc_if_last_cppeditor_closed()
const QString file = testDataDirectory.file(_("main.cpp"));
CppModelManager *mm = CppModelManager::instance();
+ helper.resetRefreshedSourceFiles();
// Open a file in the editor
QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 0);
@@ -740,6 +738,7 @@ void CppToolsPlugin::test_modelmanager_dont_gc_opened_files()
const QString file = testDataDirectory.file(_("main.cpp"));
CppModelManager *mm = CppModelManager::instance();
+ helper.resetRefreshedSourceFiles();
// Open a file in the editor
QCOMPARE(Core::EditorManager::documentModel()->openedDocuments().size(), 0);
@@ -750,6 +749,7 @@ void CppToolsPlugin::test_modelmanager_dont_gc_opened_files()
// Wait until the file is refreshed and check whether it is in the working copy
helper.waitForRefreshedSourceFiles();
+
QVERIFY(mm->workingCopy().contains(file));
// Run the garbage collector
@@ -771,8 +771,9 @@ struct EditorCloser {
EditorCloser(Core::IEditor *editor): editor(editor) {}
~EditorCloser()
{
+ using namespace CppTools;
if (editor)
- Core::EditorManager::closeEditor(editor);
+ QVERIFY(Tests::TestCase::closeEditorWithoutGarbageCollectorInvocation(editor));
}
};
@@ -811,7 +812,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part1->cxxVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
- part1->defines = QByteArray("#define SUB1\n");
+ part1->projectDefines = QByteArray("#define SUB1\n");
part1->includePaths = QStringList() << testDataDirectory.includeDir(false);
ProjectPart::Ptr part2(new ProjectPart);
@@ -820,17 +821,14 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part2->cxxVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
- part2->defines = QByteArray("#define SUB2\n");
+ part2->projectDefines = QByteArray("#define SUB2\n");
part2->includePaths = QStringList() << testDataDirectory.includeDir(false);
ProjectInfo pi = mm->projectInfo(project);
pi.appendProjectPart(part1);
pi.appendProjectPart(part2);
- mm->updateProjectInfo(pi);
-
- helper.waitForRefreshedSourceFiles();
-
+ updateProjectInfo(mm, &helper, pi);
QCOMPARE(mm->snapshot().size(), 4);
// Open a file in the editor
@@ -901,10 +899,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project_pch()
pi.appendProjectPart(part1);
pi.appendProjectPart(part2);
- mm->updateProjectInfo(pi);
-
- helper.waitForRefreshedSourceFiles();
-
+ updateProjectInfo(mm, &helper, pi);
QCOMPARE(mm->snapshot().size(), 4);
// Open a file in the editor
@@ -972,9 +967,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
pi.appendProjectPart(part1);
pi.appendProjectPart(part2);
- mm->updateProjectInfo(pi);
-
- helper.waitForRefreshedSourceFiles();
+ updateProjectInfo(mm, &helper, pi);
QCOMPARE(mm->snapshot().size(), 4);
diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.cpp b/src/plugins/cpptools/cppmodelmanagerinterface.cpp
index d3fb0fda86..e755783bef 100644
--- a/src/plugins/cpptools/cppmodelmanagerinterface.cpp
+++ b/src/plugins/cpptools/cppmodelmanagerinterface.cpp
@@ -161,13 +161,7 @@ void ProjectPart::evaluateToolchain(const ToolChain *tc,
else
includePaths << header.path();
- const QByteArray macros = tc->predefinedMacros(cxxflags);
- if (!macros.isEmpty()) {
- if (!defines.isEmpty())
- defines += '\n';
- defines += macros;
- defines += '\n';
- }
+ toolchainDefines = tc->predefinedMacros(cxxflags);
}
static CppModelManagerInterface *g_instance = 0;
@@ -235,5 +229,6 @@ void CppModelManagerInterface::ProjectInfo::appendProjectPart(const ProjectPart:
// Update defines
if (!m_defines.isEmpty())
m_defines.append('\n');
- m_defines.append(part->defines);
+ m_defines.append(part->toolchainDefines);
+ m_defines.append(part->projectDefines);
}
diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.h b/src/plugins/cpptools/cppmodelmanagerinterface.h
index 000b921113..84cca908b7 100644
--- a/src/plugins/cpptools/cppmodelmanagerinterface.h
+++ b/src/plugins/cpptools/cppmodelmanagerinterface.h
@@ -56,7 +56,6 @@ class ModelManagerSupport;
class CppCompletionAssistProvider;
class CppEditorSupport;
class CppHighlightingSupport;
-class CppHighlightingSupportFactory;
class CppIndexingSupport;
class CPPTOOLS_EXPORT ProjectPart
@@ -106,7 +105,8 @@ public:
QString projectFile;
ProjectExplorer::Project *project;
QList<ProjectFile> files;
- QByteArray defines;
+ QByteArray projectDefines;
+ QByteArray toolchainDefines;
QStringList includePaths;
QStringList frameworkPaths;
QStringList precompiledHeaders;
@@ -268,6 +268,9 @@ public:
virtual void setIndexingSupport(CppTools::CppIndexingSupport *indexingSupport) = 0;
virtual CppIndexingSupport *indexingSupport() = 0;
+ virtual void setIncludePaths(const QStringList &includePaths) = 0;
+ virtual void enableGarbageCollector(bool enable) = 0;
+
signals:
/// Project data might be locked while this is emitted.
void aboutToRemoveFiles(const QStringList &files);
diff --git a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
index 14d6fef5a4..1212ea0060 100644
--- a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
+++ b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
@@ -27,9 +27,10 @@
**
****************************************************************************/
-#include "cpptoolsplugin.h"
#include "cpppointerdeclarationformatter.h"
#include "cpptoolsplugin.h"
+#include "cpptoolsplugin.h"
+#include "cpptoolstestcase.h"
#include <texteditor/plaintexteditor.h>
@@ -48,11 +49,14 @@ using namespace CppTools;
using namespace CppTools::Internal;
using Utils::ChangeSet;
-typedef Utils::ChangeSet::Range Range;
Q_DECLARE_METATYPE(Overview)
-static QString stripCursor(const QString &source)
+namespace {
+
+typedef Utils::ChangeSet::Range Range;
+
+QString stripCursor(const QString &source)
{
QString copy(source);
const int pos = copy.indexOf(QLatin1Char('@'));
@@ -63,19 +67,16 @@ static QString stripCursor(const QString &source)
return copy;
}
-struct TestEnvironment
+class PointerDeclarationFormatterTestCase : public CppTools::Tests::TestCase
{
- QByteArray source;
- Snapshot snapshot;
- CppRefactoringFilePtr cppRefactoringFile;
- TextEditor::BaseTextEditorWidget *editor;
- Document::Ptr document;
- QTextDocument *textDocument;
- TranslationUnit *translationUnit;
- Environment env;
-
- TestEnvironment(const QByteArray &source, Document::ParseMode parseMode)
+public:
+ PointerDeclarationFormatterTestCase(const QByteArray &source,
+ const QString &expectedSource,
+ Document::ParseMode parseMode,
+ PointerDeclarationFormatter::CursorHandling cursorHandling)
{
+ QVERIFY(succeededSoFar());
+
// Find cursor position and remove cursor marker '@'
int cursorPosition = 0;
QString sourceWithoutCursorMarker = QLatin1String(source);
@@ -87,35 +88,37 @@ struct TestEnvironment
// Write source to temprorary file
const QString filePath = QDir::tempPath() + QLatin1String("/file.h");
- document = Document::create(filePath);
- Utils::FileSaver documentSaver(document->fileName());
- documentSaver.write(sourceWithoutCursorMarker.toLatin1());
- documentSaver.finalize();
+ Document::Ptr document = Document::create(filePath);
+ QVERIFY(writeFile(document->fileName(), sourceWithoutCursorMarker.toLatin1()));
// Preprocess source
+ Environment env;
Preprocessor preprocess(0, &env);
const QByteArray preprocessedSource = preprocess.run(filePath, sourceWithoutCursorMarker);
document->setUtf8Source(preprocessedSource);
document->parse(parseMode);
document->check();
- translationUnit = document->translationUnit();
- snapshot.insert(document);
- editor = new TextEditor::PlainTextEditorWidget(0);
+ AST *ast = document->translationUnit()->ast();
+ QVERIFY(ast);
+
+ // Open file
+ QScopedPointer<TextEditor::BaseTextEditorWidget> editorWidget(
+ new TextEditor::PlainTextEditorWidget);
QString error;
- editor->open(&error, document->fileName(), document->fileName());
+ editorWidget->open(&error, document->fileName(), document->fileName());
+ QVERIFY(error.isEmpty());
// Set cursor position
- QTextCursor cursor = editor->textCursor();
+ QTextCursor cursor = editorWidget->textCursor();
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, cursorPosition);
- editor->setTextCursor(cursor);
+ editorWidget->setTextCursor(cursor);
- textDocument = editor->document();
- cppRefactoringFile = CppRefactoringChanges::file(editor, document);
- }
+ QTextDocument *textDocument = editorWidget->document();
+ CppRefactoringFilePtr cppRefactoringFile
+ = CppRefactoringChanges::file(editorWidget.data(), document);
- void applyFormatting(AST *ast, PointerDeclarationFormatter::CursorHandling cursorHandling)
- {
+ // Prepare for formatting
Overview overview;
overview.showReturnTypes = true;
overview.showArgumentNames = true;
@@ -126,23 +129,25 @@ struct TestEnvironment
ChangeSet change = formatter.format(ast); // ChangeSet may be empty.
// Apply change
- QTextCursor cursor(textDocument);
- change.apply(&cursor);
+ QTextCursor changeCursor(textDocument);
+ change.apply(&changeCursor);
+
+ // Compare
+ QCOMPARE(textDocument->toPlainText(), expectedSource);
}
};
+} // anonymous namespace
+
void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations()
{
QFETCH(QString, source);
QFETCH(QString, reformattedSource);
- TestEnvironment env(source.toLatin1(), Document::ParseDeclaration);
- AST *ast = env.translationUnit->ast();
- QVERIFY(ast);
-
- env.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
-
- QCOMPARE(env.textDocument->toPlainText(), reformattedSource);
+ PointerDeclarationFormatterTestCase(source.toLatin1(),
+ reformattedSource,
+ Document::ParseDeclaration,
+ PointerDeclarationFormatter::RespectCursor);
}
void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations_data()
@@ -363,13 +368,10 @@ void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements()
QFETCH(QString, source);
QFETCH(QString, reformattedSource);
- TestEnvironment env(source.toLatin1(), Document::ParseStatement);
- AST *ast = env.translationUnit->ast();
- QVERIFY(ast);
-
- env.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
-
- QCOMPARE(env.textDocument->toPlainText(), reformattedSource);
+ PointerDeclarationFormatterTestCase(source.toLatin1(),
+ reformattedSource,
+ Document::ParseStatement,
+ PointerDeclarationFormatter::RespectCursor);
}
void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements_data()
@@ -441,13 +443,10 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators()
QFETCH(QString, source);
QFETCH(QString, reformattedSource);
- TestEnvironment env(source.toLatin1(), Document::ParseDeclaration);
- AST *ast = env.translationUnit->ast();
- QVERIFY(ast);
-
- env.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
-
- QCOMPARE(env.textDocument->toPlainText(), reformattedSource);
+ PointerDeclarationFormatterTestCase(source.toLatin1(),
+ reformattedSource,
+ Document::ParseDeclaration,
+ PointerDeclarationFormatter::RespectCursor);
}
void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators_data()
@@ -499,13 +498,10 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches()
QFETCH(QString, source);
QFETCH(QString, reformattedSource);
- TestEnvironment env(source.toLatin1(), Document::ParseTranlationUnit);
- AST *ast = env.translationUnit->ast();
- QVERIFY(ast);
-
- env.applyFormatting(ast, PointerDeclarationFormatter::IgnoreCursor);
-
- QCOMPARE(env.textDocument->toPlainText(), reformattedSource);
+ PointerDeclarationFormatterTestCase(source.toLatin1(),
+ reformattedSource,
+ Document::ParseTranlationUnit,
+ PointerDeclarationFormatter::IgnoreCursor);
}
void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches_data()
@@ -585,13 +581,10 @@ void CppToolsPlugin::test_format_pointerdeclaration_macros()
QFETCH(QString, source);
QFETCH(QString, reformattedSource);
- TestEnvironment env(source.toLatin1(), Document::ParseTranlationUnit);
- AST *ast = env.translationUnit->ast();
- QVERIFY(ast);
-
- env.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
-
- QCOMPARE(env.textDocument->toPlainText(), reformattedSource);
+ PointerDeclarationFormatterTestCase(source.toLatin1(),
+ reformattedSource,
+ Document::ParseTranlationUnit,
+ PointerDeclarationFormatter::RespectCursor);
}
void CppToolsPlugin::test_format_pointerdeclaration_macros_data()
diff --git a/src/plugins/cpptools/cpppreprocessertesthelper.cpp b/src/plugins/cpptools/cpppreprocessertesthelper.cpp
index 88dd073bda..7f27f6d140 100644
--- a/src/plugins/cpptools/cpppreprocessertesthelper.cpp
+++ b/src/plugins/cpptools/cpppreprocessertesthelper.cpp
@@ -32,7 +32,8 @@
#include <QDir>
-using namespace CppTools;
+namespace CppTools {
+namespace Tests {
QString TestIncludePaths::includeBaseDirectory()
{
@@ -54,3 +55,11 @@ QString TestIncludePaths::directoryOfTestFile()
{
return QDir::cleanPath(includeBaseDirectory() + QLatin1String("/local"));
}
+
+QString TestIncludePaths::testFilePath(const QString &fileName)
+{
+ return Tests::TestIncludePaths::directoryOfTestFile() + QLatin1Char('/') + fileName;
+}
+
+} // namespace Tests
+} // namespace CppTools
diff --git a/src/plugins/cpptools/cpppreprocessertesthelper.h b/src/plugins/cpptools/cpppreprocessertesthelper.h
index cd6084dddf..de830aca42 100644
--- a/src/plugins/cpptools/cpppreprocessertesthelper.h
+++ b/src/plugins/cpptools/cpppreprocessertesthelper.h
@@ -34,20 +34,26 @@
#include "cpptools_global.h"
#include <QtGlobal>
+#include <QString>
QT_FORWARD_DECLARE_CLASS(QString)
namespace CppTools {
+namespace Tests {
class CPPTOOLS_EXPORT TestIncludePaths
{
+ Q_DISABLE_COPY(TestIncludePaths)
+
public:
static QString includeBaseDirectory();
static QString globalQtCoreIncludePath();
static QString globalIncludePath();
static QString directoryOfTestFile();
+ static QString testFilePath(const QString &fileName = QLatin1String("file.cpp"));
};
+} // namespace Tests
} // namespace CppTools
#endif // CPPPREPROCESSERTESTHELPER_H
diff --git a/src/plugins/cpptools/cpppreprocessor_test.cpp b/src/plugins/cpptools/cpppreprocessor_test.cpp
index 000f19b997..d2557e81e2 100644
--- a/src/plugins/cpptools/cpppreprocessor_test.cpp
+++ b/src/plugins/cpptools/cpppreprocessor_test.cpp
@@ -32,6 +32,7 @@
#include "cppmodelmanager.h"
#include "cpppreprocessertesthelper.h"
#include "cpppreprocessor.h"
+#include "cpptoolstestcase.h"
#include <cplusplus/CppDocument.h>
#include <utils/fileutils.h>
@@ -42,6 +43,7 @@
using namespace CPlusPlus;
using namespace CppTools;
+using namespace CppTools::Tests;
using namespace CppTools::Internal;
typedef Document::Include Include;
@@ -57,14 +59,11 @@ public:
Document::Ptr run(const QByteArray &source)
{
- const QString fileName = TestIncludePaths::directoryOfTestFile()
- + QLatin1String("/file.cpp");
+ const QString fileName = TestIncludePaths::testFilePath();
if (QFileInfo(fileName).exists())
return Document::Ptr(); // Test file was not removed.
- Utils::FileSaver srcSaver(fileName);
- srcSaver.write(source);
- srcSaver.finalize();
+ TestCase::writeFile(fileName, source);
CppPreprocessor pp((QPointer<CppModelManager>(m_cmm)));
pp.setIncludePaths(QStringList(TestIncludePaths::directoryOfTestFile()));
@@ -108,7 +107,7 @@ void CppToolsPlugin::test_cpppreprocessor_includes()
QVERIFY(resolvedIncludes.at(0).type() == Client::IncludeLocal);
QCOMPARE(resolvedIncludes.at(0).unresolvedFileName(), QLatin1String("header.h"));
const QString expectedResolvedFileName
- = TestIncludePaths::directoryOfTestFile() + QLatin1String("/header.h");
+ = TestIncludePaths::testFilePath(QLatin1String("header.h"));
QCOMPARE(resolvedIncludes.at(0).resolvedFileName(), expectedResolvedFileName);
const QList<Document::Include> unresolvedIncludes = document->unresolvedIncludes();
diff --git a/src/plugins/cpptools/cppsnapshotupdater.cpp b/src/plugins/cpptools/cppsnapshotupdater.cpp
index ae8e4e325a..85a282ae34 100644
--- a/src/plugins/cpptools/cppsnapshotupdater.cpp
+++ b/src/plugins/cpptools/cppsnapshotupdater.cpp
@@ -69,7 +69,8 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
}
if (m_projectPart) {
- configFile += m_projectPart->defines;
+ configFile += m_projectPart->toolchainDefines;
+ configFile += m_projectPart->projectDefines;
includePaths = m_projectPart->includePaths;
frameworkPaths = m_projectPart->frameworkPaths;
if (m_usePrecompiledHeaders)
diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro
index 9700ea853a..059cc06342 100644
--- a/src/plugins/cpptools/cpptools.pro
+++ b/src/plugins/cpptools/cpptools.pro
@@ -1,129 +1,136 @@
-include(../../qtcreatorplugin.pri)
-
DEFINES += CPPTOOLS_LIBRARY
win32-msvc*:DEFINES += _SCL_SECURE_NO_WARNINGS
-HEADERS += completionsettingspage.h \
+include(../../qtcreatorplugin.pri)
+
+HEADERS += \
+ abstracteditorsupport.h \
+ builtinindexingsupport.h \
+ commentssettings.h \
+ completionsettingspage.h \
+ cppchecksymbols.h \
cppclassesfilter.h \
+ cppcodeformatter.h \
+ cppcodemodelsettings.h \
+ cppcodemodelsettingspage.h \
+ cppcodestylepreferences.h \
+ cppcodestylepreferencesfactory.h \
+ cppcodestylesettings.h \
+ cppcodestylesettingspage.h \
+ cppcompletionassist.h \
+ cppcompletionassistprovider.h \
cppcurrentdocumentfilter.h \
+ cppdoxygen.h \
+ cppfilesettingspage.h \
+ cppfindreferences.h \
cppfunctionsfilter.h \
+ cpphighlightingsupport.h \
+ cpphighlightingsupportinternal.h \
+ cppindexingsupport.h \
+ cpplocalsymbols.h \
+ cpplocatordata.h \
+ cpplocatorfilter.h \
cppmodelmanager.h \
cppmodelmanagerinterface.h \
- cpplocatorfilter.h \
+ cppmodelmanagersupport.h \
+ cppmodelmanagersupportinternal.h \
+ cpppointerdeclarationformatter.h \
+ cpppreprocessor.h \
+ cppprojectfile.h \
+ cppqtstyleindenter.h \
+ cpprefactoringchanges.h \
+ cppsemanticinfo.h \
+ cppsnapshotupdater.h \
cpptools_global.h \
cpptoolsconstants.h \
cpptoolseditorsupport.h \
- cppsnapshotupdater.h \
cpptoolsplugin.h \
- cppqtstyleindenter.h \
- searchsymbols.h \
- cppdoxygen.h \
- cppfilesettingspage.h \
- cppfindreferences.h \
- cppcodeformatter.h \
- symbolsfindfilter.h \
- insertionpointlocator.h \
- cpprefactoringchanges.h \
- abstracteditorsupport.h \
- cppcompletionassist.h \
- cppcodestylesettingspage.h \
- cpptoolssettings.h \
- cppcodestylesettings.h \
- cppcodestylepreferencesfactory.h \
- cppcodestylepreferences.h \
cpptoolsreuse.h \
+ cpptoolssettings.h \
doxygengenerator.h \
- commentssettings.h \
- symbolfinder.h \
- cppmodelmanagersupport.h \
- cpphighlightingsupport.h \
- cpphighlightingsupportinternal.h \
- cppchecksymbols.h \
- cpplocalsymbols.h \
- cppsemanticinfo.h \
- cppcompletionassistprovider.h \
- typehierarchybuilder.h \
- cppindexingsupport.h \
- builtinindexingsupport.h \
- cpppointerdeclarationformatter.h \
- cppprojectfile.h \
- cpppreprocessor.h \
+ functionutils.h \
includeutils.h \
- cpplocatordata.h \
- cppmodelmanagersupportinternal.h \
- cppcodemodelsettings.h \
- cppcodemodelsettingspage.h
+ insertionpointlocator.h \
+ searchsymbols.h \
+ symbolfinder.h \
+ symbolsfindfilter.h \
+ typehierarchybuilder.h
-SOURCES += completionsettingspage.cpp \
+SOURCES += \
+ abstracteditorsupport.cpp \
+ builtinindexingsupport.cpp \
+ commentssettings.cpp \
+ completionsettingspage.cpp \
+ cppchecksymbols.cpp \
cppclassesfilter.cpp \
+ cppcodeformatter.cpp \
+ cppcodemodelsettings.cpp \
+ cppcodemodelsettingspage.cpp \
+ cppcodestylepreferences.cpp \
+ cppcodestylepreferencesfactory.cpp \
+ cppcodestylesettings.cpp \
+ cppcodestylesettingspage.cpp \
+ cppcompletionassist.cpp \
+ cppcompletionassistprovider.cpp \
cppcurrentdocumentfilter.cpp \
- cppfunctionsfilter.cpp \
- cppmodelmanager.cpp \
- cppmodelmanagerinterface.cpp \
- cpplocatorfilter.cpp \
- cpptoolseditorsupport.cpp \
- cppsnapshotupdater.cpp \
- cpptoolsplugin.cpp \
- cppqtstyleindenter.cpp \
- searchsymbols.cpp \
cppdoxygen.cpp \
cppfilesettingspage.cpp \
- abstracteditorsupport.cpp \
cppfindreferences.cpp \
- cppcodeformatter.cpp \
- symbolsfindfilter.cpp \
- insertionpointlocator.cpp \
- cpprefactoringchanges.cpp \
- cppcompletionassist.cpp \
- cppcodestylesettingspage.cpp \
- cpptoolssettings.cpp \
- cppcodestylesettings.cpp \
- cppcodestylepreferencesfactory.cpp \
- cppcodestylepreferences.cpp \
- cpptoolsreuse.cpp \
- doxygengenerator.cpp \
- commentssettings.cpp \
- symbolfinder.cpp \
- cppmodelmanagersupport.cpp \
+ cppfunctionsfilter.cpp \
cpphighlightingsupport.cpp \
cpphighlightingsupportinternal.cpp \
- cppchecksymbols.cpp \
- cpplocalsymbols.cpp \
- cppsemanticinfo.cpp \
- cppcompletionassistprovider.cpp \
- typehierarchybuilder.cpp \
cppindexingsupport.cpp \
- builtinindexingsupport.cpp \
+ cpplocalsymbols.cpp \
+ cpplocatordata.cpp \
+ cpplocatorfilter.cpp \
+ cppmodelmanager.cpp \
+ cppmodelmanagerinterface.cpp \
+ cppmodelmanagersupport.cpp \
+ cppmodelmanagersupportinternal.cpp \
cpppointerdeclarationformatter.cpp \
- cppprojectfile.cpp \
cpppreprocessor.cpp \
+ cppprojectfile.cpp \
+ cppqtstyleindenter.cpp \
+ cpprefactoringchanges.cpp \
+ cppsemanticinfo.cpp \
+ cppsnapshotupdater.cpp \
+ cpptoolseditorsupport.cpp \
+ cpptoolsplugin.cpp \
+ cpptoolsreuse.cpp \
+ cpptoolssettings.cpp \
+ doxygengenerator.cpp \
+ functionutils.cpp \
includeutils.cpp \
- cpplocatordata.cpp \
- cppmodelmanagersupportinternal.cpp \
- cppcodemodelsettings.cpp \
- cppcodemodelsettingspage.cpp
+ insertionpointlocator.cpp \
+ searchsymbols.cpp \
+ symbolfinder.cpp \
+ symbolsfindfilter.cpp \
+ typehierarchybuilder.cpp
-FORMS += completionsettingspage.ui \
- cppfilesettingspage.ui \
+FORMS += \
+ completionsettingspage.ui \
+ cppcodemodelsettingspage.ui \
cppcodestylesettingspage.ui \
- cppcodemodelsettingspage.ui
+ cppfilesettingspage.ui
equals(TEST, 1) {
+ HEADERS += \
+ cpppreprocessertesthelper.h \
+ cpptoolstestcase.h \
+ modelmanagertesthelper.h
+
SOURCES += \
cppcodegen_test.cpp \
cppcompletion_test.cpp \
+ cppheadersource_test.cpp \
+ cpplocatorfilter_test.cpp \
cppmodelmanager_test.cpp \
- modelmanagertesthelper.cpp \
cpppointerdeclarationformatter_test.cpp \
- cpplocatorfilter_test.cpp \
- symbolsearcher_test.cpp \
- cpppreprocessor_test.cpp \
cpppreprocessertesthelper.cpp \
- cppheadersource_test.cpp \
+ cpppreprocessor_test.cpp \
+ cpptoolstestcase.cpp \
+ modelmanagertesthelper.cpp \
+ symbolsearcher_test.cpp \
typehierarchybuilder_test.cpp
- HEADERS += \
- cpppreprocessertesthelper.h \
- modelmanagertesthelper.h
-
DEFINES += SRCDIR=\\\"$$PWD\\\"
}
diff --git a/src/plugins/cpptools/cpptools.qbs b/src/plugins/cpptools/cpptools.qbs
index e955c80e3a..ddbc4feace 100644
--- a/src/plugins/cpptools/cpptools.qbs
+++ b/src/plugins/cpptools/cpptools.qbs
@@ -8,10 +8,8 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
- Depends { name: "Find" }
Depends { name: "TextEditor" }
Depends { name: "ProjectExplorer" }
- Depends { name: "Locator" }
Depends { name: "CPlusPlus" }
Depends { name: "LanguageUtils" }
@@ -22,108 +20,57 @@ QtcPlugin {
}
files: [
- "abstracteditorsupport.cpp",
- "abstracteditorsupport.h",
- "commentssettings.cpp",
- "commentssettings.h",
- "completionsettingspage.cpp",
- "completionsettingspage.h",
- "completionsettingspage.ui",
- "cppchecksymbols.cpp",
- "cppchecksymbols.h",
- "cppclassesfilter.cpp",
- "cppclassesfilter.h",
- "cppcodeformatter.cpp",
- "cppcodeformatter.h",
- "cppcodestylepreferences.cpp",
- "cppcodestylepreferences.h",
- "cppcodestylepreferencesfactory.cpp",
- "cppcodestylepreferencesfactory.h",
- "cppcodestylesettings.cpp",
- "cppcodestylesettings.h",
- "cppcodestylesettingspage.cpp",
- "cppcodestylesettingspage.h",
- "cppcodestylesettingspage.ui",
- "cppcompletionassist.cpp",
- "cppcompletionassist.h",
- "cppcompletionassistprovider.cpp",
- "cppcompletionassistprovider.h",
- "cppcurrentdocumentfilter.cpp",
- "cppcurrentdocumentfilter.h",
- "cppdoxygen.cpp",
- "cppdoxygen.h",
- "cppfilesettingspage.cpp",
- "cppfilesettingspage.h",
- "cppfilesettingspage.ui",
- "cppfindreferences.cpp",
- "cppfindreferences.h",
- "cppfunctionsfilter.cpp",
- "cppfunctionsfilter.h",
- "cpphighlightingsupport.cpp",
- "cpphighlightingsupport.h",
- "cpphighlightingsupportinternal.cpp",
- "cpphighlightingsupportinternal.h",
- "cppindexingsupport.cpp",
- "cppindexingsupport.h",
- "cpplocalsymbols.cpp",
- "cpplocalsymbols.h",
- "cpplocatordata.cpp",
- "cpplocatordata.h",
- "cpplocatorfilter.cpp",
- "cpplocatorfilter.h",
- "cppmodelmanager.cpp",
- "cppmodelmanager.h",
- "cppmodelmanagersupport.h",
- "cppmodelmanagersupport.cpp",
- "cppmodelmanagersupportinternal.h",
- "cppmodelmanagersupportinternal.cpp",
- "cppmodelmanagerinterface.cpp",
- "cppmodelmanagerinterface.h",
- "cppqtstyleindenter.cpp",
- "cppqtstyleindenter.h",
- "cpppointerdeclarationformatter.cpp",
- "cpppointerdeclarationformatter.h",
- "cppprojectfile.cpp",
- "cppprojectfile.h",
- "cpprefactoringchanges.cpp",
- "cpprefactoringchanges.h",
- "cppsemanticinfo.cpp",
- "cppsemanticinfo.h",
+ "abstracteditorsupport.cpp", "abstracteditorsupport.h",
+ "builtinindexingsupport.cpp", "builtinindexingsupport.h",
+ "commentssettings.cpp", "commentssettings.h",
+ "completionsettingspage.cpp", "completionsettingspage.h", "completionsettingspage.ui",
+ "cppchecksymbols.cpp", "cppchecksymbols.h",
+ "cppclassesfilter.cpp", "cppclassesfilter.h",
+ "cppcodeformatter.cpp", "cppcodeformatter.h",
+ "cppcodemodelsettings.cpp", "cppcodemodelsettings.h",
+ "cppcodemodelsettingspage.cpp", "cppcodemodelsettingspage.h", "cppcodemodelsettingspage.ui",
+ "cppcodestylepreferences.cpp", "cppcodestylepreferences.h",
+ "cppcodestylepreferencesfactory.cpp", "cppcodestylepreferencesfactory.h",
+ "cppcodestylesettings.cpp", "cppcodestylesettings.h",
+ "cppcodestylesettingspage.cpp", "cppcodestylesettingspage.h", "cppcodestylesettingspage.ui",
+ "cppcompletionassist.cpp", "cppcompletionassist.h",
+ "cppcompletionassistprovider.cpp", "cppcompletionassistprovider.h",
+ "cppcurrentdocumentfilter.cpp", "cppcurrentdocumentfilter.h",
+ "cppdoxygen.cpp", "cppdoxygen.h",
+ "cppfilesettingspage.cpp", "cppfilesettingspage.h", "cppfilesettingspage.ui",
+ "cppfindreferences.cpp", "cppfindreferences.h",
+ "cppfunctionsfilter.cpp", "cppfunctionsfilter.h",
+ "cpphighlightingsupport.cpp", "cpphighlightingsupport.h",
+ "cpphighlightingsupportinternal.cpp", "cpphighlightingsupportinternal.h",
+ "cppindexingsupport.cpp", "cppindexingsupport.h",
+ "cpplocalsymbols.cpp", "cpplocalsymbols.h",
+ "cpplocatordata.cpp", "cpplocatordata.h",
+ "cpplocatorfilter.cpp", "cpplocatorfilter.h",
+ "cppmodelmanager.cpp", "cppmodelmanager.h",
+ "cppmodelmanagerinterface.cpp", "cppmodelmanagerinterface.h",
+ "cppmodelmanagersupport.cpp", "cppmodelmanagersupport.h",
+ "cppmodelmanagersupportinternal.cpp", "cppmodelmanagersupportinternal.h",
+ "cpppointerdeclarationformatter.cpp", "cpppointerdeclarationformatter.h",
+ "cpppreprocessor.cpp", "cpppreprocessor.h",
+ "cppprojectfile.cpp", "cppprojectfile.h",
+ "cppqtstyleindenter.cpp", "cppqtstyleindenter.h",
+ "cpprefactoringchanges.cpp", "cpprefactoringchanges.h",
+ "cppsemanticinfo.cpp", "cppsemanticinfo.h",
+ "cppsnapshotupdater.cpp", "cppsnapshotupdater.h",
"cpptools_global.h",
"cpptoolsconstants.h",
- "cpptoolseditorsupport.cpp",
- "cpptoolseditorsupport.h",
- "cpptoolsplugin.cpp",
- "cpptoolsplugin.h",
- "cpptoolsreuse.cpp",
- "cpptoolsreuse.h",
- "cpptoolssettings.cpp",
- "cpptoolssettings.h",
- "doxygengenerator.cpp",
- "doxygengenerator.h",
- "insertionpointlocator.cpp",
- "insertionpointlocator.h",
- "searchsymbols.cpp",
- "searchsymbols.h",
- "symbolfinder.cpp",
- "symbolfinder.h",
- "symbolsfindfilter.cpp",
- "symbolsfindfilter.h",
- "typehierarchybuilder.cpp",
- "typehierarchybuilder.h",
- "builtinindexingsupport.cpp",
- "builtinindexingsupport.h",
- "cpppreprocessor.cpp",
- "cpppreprocessor.h",
- "includeutils.cpp",
- "includeutils.h",
- "cppcodemodelsettings.cpp",
- "cppcodemodelsettings.h",
- "cppcodemodelsettingspage.cpp",
- "cppcodemodelsettingspage.h",
- "cppcodemodelsettingspage.ui",
- "cppsnapshotupdater.cpp",
- "cppsnapshotupdater.h",
+ "cpptoolseditorsupport.cpp", "cpptoolseditorsupport.h",
+ "cpptoolsplugin.cpp", "cpptoolsplugin.h",
+ "cpptoolsreuse.cpp", "cpptoolsreuse.h",
+ "cpptoolssettings.cpp", "cpptoolssettings.h",
+ "doxygengenerator.cpp", "doxygengenerator.h",
+ "functionutils.cpp", "functionutils.h",
+ "includeutils.cpp", "includeutils.h",
+ "insertionpointlocator.cpp", "insertionpointlocator.h",
+ "searchsymbols.cpp", "searchsymbols.h",
+ "symbolfinder.cpp", "symbolfinder.h",
+ "symbolsfindfilter.cpp", "symbolsfindfilter.h",
+ "typehierarchybuilder.cpp", "typehierarchybuilder.h",
]
Group {
@@ -133,14 +80,15 @@ QtcPlugin {
"cppcodegen_test.cpp",
"cppcompletion_test.cpp",
"cppheadersource_test.cpp",
+ "cpplocatorfilter_test.cpp",
"cppmodelmanager_test.cpp",
- "modelmanagertesthelper.cpp", "modelmanagertesthelper.h",
"cpppointerdeclarationformatter_test.cpp",
- "cpplocatorfilter_test.cpp",
- "symbolsearcher_test.cpp",
- "cpppreprocessor_test.cpp",
"cpppreprocessertesthelper.cpp", "cpppreprocessertesthelper.h",
- "typehierarchybuilder_test.cpp"
+ "cpppreprocessor_test.cpp",
+ "cpptoolstestcase.cpp", "cpptoolstestcase.h",
+ "modelmanagertesthelper.cpp", "modelmanagertesthelper.h",
+ "symbolsearcher_test.cpp",
+ "typehierarchybuilder_test.cpp",
]
cpp.defines: outer.concat(['SRCDIR="' + FileInfo.path(filePath) + '"'])
diff --git a/src/plugins/cpptools/cpptools_dependencies.pri b/src/plugins/cpptools/cpptools_dependencies.pri
index 15f93ba837..82a3b3fdf7 100644
--- a/src/plugins/cpptools/cpptools_dependencies.pri
+++ b/src/plugins/cpptools/cpptools_dependencies.pri
@@ -5,6 +5,4 @@ QTC_LIB_DEPENDS += \
QTC_PLUGIN_DEPENDS += \
coreplugin \
projectexplorer \
- texteditor \
- locator \
- find
+ texteditor
diff --git a/src/plugins/cpptools/cpptoolseditorsupport.cpp b/src/plugins/cpptools/cpptoolseditorsupport.cpp
index a07c686cb5..66d2f8adce 100644
--- a/src/plugins/cpptools/cpptoolseditorsupport.cpp
+++ b/src/plugins/cpptools/cpptoolseditorsupport.cpp
@@ -142,7 +142,7 @@ CppEditorSupport::CppEditorSupport(CppModelManager *modelManager, BaseTextEditor
connect(m_updateEditorTimer, SIGNAL(timeout()),
this, SLOT(updateEditorNow()));
- connect(m_textEditor, SIGNAL(contentsChanged()), this, SLOT(updateDocument()));
+ connect(m_textEditor->document(), SIGNAL(contentsChanged()), this, SLOT(updateDocument()));
connect(this, SIGNAL(diagnosticsChanged()), this, SLOT(onDiagnosticsChanged()));
connect(m_textEditor->document(), SIGNAL(mimeTypeChanged()),
@@ -186,7 +186,7 @@ QByteArray CppEditorSupport::contents() const
const int editorRev = editorRevision();
if (m_cachedContentsEditorRevision != editorRev && !m_fileIsBeingReloaded) {
m_cachedContentsEditorRevision = editorRev;
- m_cachedContents = m_textEditor->textDocument()->contents().toUtf8();
+ m_cachedContents = m_textEditor->textDocument()->plainText().toUtf8();
}
return m_cachedContents;
@@ -260,7 +260,7 @@ CppCompletionAssistProvider *CppEditorSupport::completionAssistProvider() const
QSharedPointer<SnapshotUpdater> CppEditorSupport::snapshotUpdater()
{
QSharedPointer<SnapshotUpdater> updater = m_snapshotUpdater;
- if (!updater) {
+ if (!updater || updater->fileInEditor() != fileName()) {
updater = QSharedPointer<SnapshotUpdater>(new SnapshotUpdater(fileName()));
m_snapshotUpdater = updater;
@@ -392,10 +392,14 @@ void CppEditorSupport::startHighlighting()
m_lastHighlightRevision = revision;
emit highlighterStarted(&m_highlighter, m_lastHighlightRevision);
} else {
+ const unsigned revision = currentSource(false).revision;
+ if (m_lastHighlightRevision == revision)
+ return;
+
+ m_lastHighlightRevision = revision;
static const Document::Ptr dummyDoc;
static const Snapshot dummySnapshot;
m_highlighter = m_highlightingSupport->highlightingFuture(dummyDoc, dummySnapshot);
- m_lastHighlightRevision = editorRevision();
emit highlighterStarted(&m_highlighter, m_lastHighlightRevision);
}
}
@@ -407,7 +411,7 @@ void CppEditorSupport::onDiagnosticsChanged()
QList<Document::DiagnosticMessage> allDiagnostics;
{
QMutexLocker locker(&m_diagnosticsMutex);
- foreach (const QList<Document::DiagnosticMessage> &msgs, m_allDiagnostics.values())
+ foreach (const QList<Document::DiagnosticMessage> &msgs, m_allDiagnostics)
allDiagnostics.append(msgs);
}
@@ -506,7 +510,7 @@ SemanticInfo::Source CppEditorSupport::currentSource(bool force)
int line = 0, column = 0;
m_textEditor->convertPosition(m_textEditor->editorWidget()->position(), &line, &column);
- const Snapshot snapshot = m_snapshotUpdater->snapshot();
+ const Snapshot snapshot = snapshotUpdater()->snapshot();
QByteArray code;
if (force || m_lastSemanticInfo.revision != editorRevision())
diff --git a/src/plugins/cpptools/cpptoolseditorsupport.h b/src/plugins/cpptools/cpptoolseditorsupport.h
index ab7dc8e4a2..f9ba876256 100644
--- a/src/plugins/cpptools/cpptoolseditorsupport.h
+++ b/src/plugins/cpptools/cpptoolseditorsupport.h
@@ -59,7 +59,7 @@ class CppCompletionAssistProvider;
* its document.
*
* The following steps are taken:
- * 1. the text editor fires a contentsChanged() signal that triggers updateDocument
+ * 1. the text editor document fires a contentsChanged() signal that triggers updateDocument
* 2. update document will start a timer, or reset the timer if it was already running. This way
* subsequent updates (e.g. keypresses) get bunched together instead of running the subsequent
* actions for every key press
diff --git a/src/plugins/cpptools/cpptoolsplugin.h b/src/plugins/cpptools/cpptoolsplugin.h
index 067c484bb5..c5d573e1cb 100644
--- a/src/plugins/cpptools/cpptoolsplugin.h
+++ b/src/plugins/cpptools/cpptoolsplugin.h
@@ -91,106 +91,20 @@ private slots:
void test_codegen_definition_middle_member_surrounded_by_undefined();
void test_codegen_definition_member_specific_file();
- void test_completion_forward_declarations_present();
- void test_completion_inside_parentheses_c_style_conversion();
- void test_completion_inside_parentheses_cast_operator_conversion();
void test_completion_basic_1();
- void test_completion_template_1();
- void test_completion_template_2();
- void test_completion_template_3();
- void test_completion_template_4();
- void test_completion_template_5();
- void test_completion_template_6();
- void test_completion_template_7();
- void test_completion_type_of_pointer_is_typedef();
- void test_completion_instantiate_full_specialization();
- void test_completion_template_as_base();
- void test_completion_template_as_base_data();
- void test_completion_use_global_identifier_as_base_class();
- void test_completion_use_global_identifier_as_base_class_data();
- void test_completion_base_class_has_name_the_same_as_derived();
- void test_completion_base_class_has_name_the_same_as_derived_data();
- void test_completion_cyclic_inheritance();
- void test_completion_cyclic_inheritance_data();
- void test_completion_template_function();
+
void test_completion_template_function_data();
- void test_completion_enclosing_template_class();
- void test_completion_enclosing_template_class_data();
- void test_completion_instantiate_nested_class_when_enclosing_is_template();
- void test_completion_instantiate_nested_of_nested_class_when_enclosing_is_template();
- void test_completion_instantiate_template_with_default_argument_type();
- void test_completion_instantiate_template_with_default_argument_type_as_template();
- void test_completion_member_access_operator_1();
-
- void test_completion_typedef_of_type_and_decl_of_type_no_replace_access_operator();
- void test_completion_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator();
- void test_completion_typedef_of_type_and_decl_of_pointer_replace_access_operator();
- void test_completion_typedef_of_pointer_and_decl_of_type_replace_access_operator();
-
- void test_completion_predecl_typedef_of_type_and_decl_of_pointer_replace_access_operator();
- void test_completion_predecl_typedef_of_type_and_decl_type_no_replace_access_operator();
- void test_completion_predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator();
- void test_completion_predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator();
-
- void test_completion_typedef_of_pointer();
- void test_completion_typedef_of_pointer_inside_function();
- void test_completion_typedef_is_inside_function_before_declaration_block();
- void test_completion_resolve_complex_typedef_with_template();
- void test_completion_template_specialization_with_pointer();
- void test_completion_typedef_using_templates1();
- void test_completion_typedef_using_templates2();
- void test_completion_namespace_alias_with_many_namespace_declarations();
- void test_completion_QTCREATORBUG9098();
- void test_completion_type_and_using_declaration();
- void test_completion_type_and_using_declaration_data();
- void test_completion_instantiate_template_with_anonymous_class();
- void test_completion_instantiate_template_function();
- void test_completion_crash_cloning_template_class_QTCREATORBUG9329();
- void test_completion_recursive_auto_declarations1_QTCREATORBUG9503();
- void test_completion_recursive_auto_declarations2_QTCREATORBUG9503();
- void test_completion_recursive_typedefs_declarations1();
- void test_completion_recursive_typedefs_declarations2();
- void test_completion_recursive_using_declarations1();
- void test_completion_recursive_using_declarations2();
- void test_completion_recursive_using_typedef_declarations();
- void test_completion_recursive_typedefs_in_templates1();
- void test_completion_recursive_typedefs_in_templates2();
+ void test_completion_template_function();
+
+ void test_completion_data();
+ void test_completion();
+
+ void test_completion_member_access_operator_data();
+ void test_completion_member_access_operator();
+
void test_completion_prefix_first_QTCREATORBUG_8737();
void test_completion_prefix_first_QTCREATORBUG_9236();
- void test_completion_class_declaration_inside_function_or_block_QTCREATORBUG3620();
- void test_completion_class_declaration_inside_function_or_block_QTCREATORBUG3620_data();
- void test_completion_namespace_alias_inside_function_or_block_QTCREATORBUG166();
- void test_completion_namespace_alias_inside_function_or_block_QTCREATORBUG166_data();
- void test_completion_class_declaration_inside_function_or_block_QTCREATORBUG3620_static_member();
- void test_completion_enum_inside_block_inside_function_QTCREATORBUG5456();
- void test_completion_enum_inside_function_QTCREATORBUG5456();
-
- void test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG9169_1();
- void test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG9169_2();
- void test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_1();
- void test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_2();
- void test_completion_template_parameter_defined_inside_scope_of_declaration_QTCREATORBUG8852_3();
-
- //lambda
- void test_completion_lambdaCalls_1();
- void test_completion_lambdaCalls_2();
- void test_completion_lambdaCalls_3();
- void test_completion_lambdaCalls_4();
- void test_completion_lambdaCalls_5();
-
- void test_completion_member_of_class_accessed_by_using_QTCREATORBUG9037_1();
- void test_completion_member_of_class_accessed_by_using_QTCREATORBUG9037_2();
-
- void test_completion_local_type_and_member_1();
- void test_completion_local_type_and_member_2();
- void test_completion_local_type_and_member_3();
- void test_completion_local_type_and_member_4();
- void test_completion_local_type_and_member_5();
- void test_completion_local_type_and_member_6();
-
- void test_completion_signals_hide_QPrivateSignal();
-
void test_format_pointerdeclaration_in_simpledeclarations();
void test_format_pointerdeclaration_in_simpledeclarations_data();
void test_format_pointerdeclaration_in_controlflowstatements();
@@ -204,6 +118,9 @@ private slots:
void test_cpppreprocessor_includes();
+ void test_functionutils_virtualFunctions();
+ void test_functionutils_virtualFunctions_data();
+
void test_modelmanager_paths_are_clean();
void test_modelmanager_framework_headers();
void test_modelmanager_refresh_also_includes_of_project_files();
@@ -232,9 +149,6 @@ private slots:
void test_typehierarchy_data();
void test_typehierarchy();
-
-private:
- void test_completion();
#endif
private:
diff --git a/src/plugins/cpptools/cpptoolstestcase.cpp b/src/plugins/cpptools/cpptoolstestcase.cpp
new file mode 100644
index 0000000000..7c46ec84b0
--- /dev/null
+++ b/src/plugins/cpptools/cpptoolstestcase.cpp
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "cpptoolstestcase.h"
+
+#include <coreplugin/editormanager/editormanager.h>
+
+#include <cplusplus/CppDocument.h>
+#include <utils/fileutils.h>
+
+#include <QtTest>
+
+static bool closeEditorsWithoutGarbageCollectorInvocation(const QList<Core::IEditor *> &editors)
+{
+ CppTools::CppModelManagerInterface::instance()->enableGarbageCollector(false);
+ const bool closeEditorsSucceeded = Core::EditorManager::closeEditors(editors, false);
+ CppTools::CppModelManagerInterface::instance()->enableGarbageCollector(true);
+ return closeEditorsSucceeded;
+}
+
+static bool snapshotContains(const CPlusPlus::Snapshot &snapshot, const QStringList &filePaths)
+{
+ foreach (const QString &filePath, filePaths) {
+ if (!snapshot.contains(filePath)) {
+ const QString warning = QLatin1String("Missing file in snapshot: ") + filePath;
+ QWARN(qPrintable(warning));
+ return false;
+ }
+ }
+ return true;
+}
+
+namespace CppTools {
+namespace Tests {
+
+TestDocument::TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker)
+ : m_fileName(fileName), m_source(source), m_cursorMarker(cursorMarker)
+{}
+
+QString TestDocument::filePath() const
+{
+ const QString fileNameAsString = QString::fromUtf8(m_fileName);
+ if (!QFileInfo(fileNameAsString).isAbsolute())
+ return QDir::tempPath() + QLatin1Char('/') + fileNameAsString;
+ return fileNameAsString;
+}
+
+bool TestDocument::writeToDisk() const
+{
+ return TestCase::writeFile(filePath(), m_source);
+}
+
+TestCase::TestCase(bool runGarbageCollector)
+ : m_modelManager(CppModelManagerInterface::instance())
+ , m_succeededSoFar(false)
+ , m_runGarbageCollector(runGarbageCollector)
+{
+ if (m_runGarbageCollector)
+ QVERIFY(garbageCollectGlobalSnapshot());
+ m_succeededSoFar = true;
+}
+
+TestCase::~TestCase()
+{
+ QVERIFY(closeEditorsWithoutGarbageCollectorInvocation(m_editorsToClose));
+ QCoreApplication::processEvents();
+
+ if (m_runGarbageCollector)
+ QVERIFY(garbageCollectGlobalSnapshot());
+}
+
+bool TestCase::succeededSoFar() const
+{
+ return m_succeededSoFar;
+}
+
+CPlusPlus::Snapshot TestCase::globalSnapshot()
+{
+ return CppModelManagerInterface::instance()->snapshot();
+}
+
+bool TestCase::garbageCollectGlobalSnapshot()
+{
+ CppModelManagerInterface::instance()->GC();
+ return globalSnapshot().isEmpty();
+}
+
+bool TestCase::parseFiles(const QStringList &filePaths)
+{
+ CppModelManagerInterface::instance()->updateSourceFiles(filePaths).waitForFinished();
+ QCoreApplication::processEvents();
+ const CPlusPlus::Snapshot snapshot = globalSnapshot();
+ if (snapshot.isEmpty()) {
+ QWARN("After parsing: snapshot is empty.");
+ return false;
+ }
+ if (!snapshotContains(snapshot, filePaths)) {
+ QWARN("After parsing: snapshot does not contain all expected files.");
+ return false;
+ }
+ return true;
+}
+
+bool TestCase::parseFiles(const QString &filePath)
+{
+ return parseFiles(QStringList(filePath));
+}
+
+void TestCase::closeEditorAtEndOfTestCase(Core::IEditor *editor)
+{
+ if (editor && !m_editorsToClose.contains(editor))
+ m_editorsToClose.append(editor);
+}
+
+bool TestCase::closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *editor)
+{
+ return closeEditorsWithoutGarbageCollectorInvocation(QList<Core::IEditor *>() << editor);
+}
+
+CPlusPlus::Document::Ptr TestCase::waitForFileInGlobalSnapshot(const QString &filePath)
+{
+ return waitForFilesInGlobalSnapshot(QStringList(filePath)).first();
+}
+
+QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(
+ const QStringList &filePaths)
+{
+ QList<CPlusPlus::Document::Ptr> result;
+ foreach (const QString &filePath, filePaths) {
+ forever {
+ if (CPlusPlus::Document::Ptr document = globalSnapshot().document(filePath)) {
+ result.append(document);
+ break;
+ }
+ QCoreApplication::processEvents();
+ }
+ }
+ return result;
+}
+
+bool TestCase::writeFile(const QString &filePath, const QByteArray &contents)
+{
+ Utils::FileSaver saver(filePath);
+ if (!saver.write(contents) || !saver.finalize()) {
+ const QString warning = QLatin1String("Failed to write file to disk: ") + filePath;
+ QWARN(qPrintable(warning));
+ return false;
+ }
+ return true;
+}
+
+} // namespace Tests
+} // namespace CppTools
diff --git a/src/plugins/cpptools/cpptoolstestcase.h b/src/plugins/cpptools/cpptoolstestcase.h
new file mode 100644
index 0000000000..b8d3f4d5ee
--- /dev/null
+++ b/src/plugins/cpptools/cpptoolstestcase.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CPPTOOLSTESTCASE_H
+#define CPPTOOLSTESTCASE_H
+
+#include "cppmodelmanagerinterface.h"
+#include "cpptools_global.h"
+
+#include <coreplugin/editormanager/ieditor.h>
+
+#include <QStringList>
+
+namespace CPlusPlus {
+class Document;
+class Snapshot;
+}
+namespace Core {
+class IEditor;
+}
+
+namespace CppTools {
+namespace Tests {
+
+class CPPTOOLS_EXPORT TestDocument
+{
+public:
+ TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker = '@');
+
+ QString filePath() const;
+ bool writeToDisk() const;
+
+public:
+ QByteArray m_fileName;
+ QByteArray m_source;
+ char m_cursorMarker;
+};
+
+class CPPTOOLS_EXPORT TestCase
+{
+ Q_DISABLE_COPY(TestCase)
+
+public:
+ TestCase(bool runGarbageCollector = true);
+ ~TestCase();
+
+ bool succeededSoFar() const;
+ void closeEditorAtEndOfTestCase(Core::IEditor *editor);
+
+ static bool closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *editor);
+
+ static bool parseFiles(const QString &filePath);
+ static bool parseFiles(const QStringList &filePaths);
+
+ static CPlusPlus::Snapshot globalSnapshot();
+ static bool garbageCollectGlobalSnapshot();
+
+ static CPlusPlus::Document::Ptr waitForFileInGlobalSnapshot(const QString &filePath);
+ static QList<CPlusPlus::Document::Ptr> waitForFilesInGlobalSnapshot(
+ const QStringList &filePaths);
+
+ static bool writeFile(const QString &filePath, const QByteArray &contents);
+
+protected:
+ CppModelManagerInterface *m_modelManager;
+ bool m_succeededSoFar;
+
+private:
+ QList<Core::IEditor *> m_editorsToClose;
+ bool m_runGarbageCollector;
+};
+
+} // namespace Tests
+} // namespace CppTools
+
+#endif // CPPTOOLSTESTCASE_H
diff --git a/src/plugins/cpptools/functionutils.cpp b/src/plugins/cpptools/functionutils.cpp
new file mode 100644
index 0000000000..7aa369c74e
--- /dev/null
+++ b/src/plugins/cpptools/functionutils.cpp
@@ -0,0 +1,323 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "functionutils.h"
+
+#include "typehierarchybuilder.h"
+
+#include <cplusplus/CppDocument.h>
+#include <cplusplus/LookupContext.h>
+#include <cplusplus/Symbols.h>
+#include <utils/qtcassert.h>
+
+#include <QList>
+
+using namespace CPlusPlus;
+using namespace CppTools;
+
+enum VirtualType { Virtual, PureVirtual };
+
+static bool isVirtualFunction_helper(const Function *function,
+ const LookupContext &context,
+ VirtualType virtualType,
+ const Function **firstVirtual)
+{
+ enum { Unknown, False, True } res = Unknown;
+
+ if (firstVirtual)
+ *firstVirtual = 0;
+
+ if (!function)
+ return false;
+
+ if (virtualType == PureVirtual)
+ res = function->isPureVirtual() ? True : False;
+
+ if (function->isVirtual()) {
+ if (firstVirtual)
+ *firstVirtual = function;
+ if (res == Unknown)
+ res = True;
+ }
+
+ if (!firstVirtual && res != Unknown)
+ return res == True;
+
+ QList<LookupItem> results = context.lookup(function->name(), function->enclosingScope());
+ if (!results.isEmpty()) {
+ const bool isDestructor = function->name()->isDestructorNameId();
+ foreach (const LookupItem &item, results) {
+ if (Symbol *symbol = item.declaration()) {
+ if (Function *functionType = symbol->type()->asFunctionType()) {
+ if (functionType->name()->isDestructorNameId() != isDestructor)
+ continue;
+ if (functionType == function) // already tested
+ continue;
+ if (functionType->isFinal())
+ return res == True;
+ if (functionType->isVirtual()) {
+ if (!firstVirtual)
+ return true;
+ if (res == Unknown)
+ res = True;
+ *firstVirtual = functionType;
+ }
+ }
+ }
+ }
+ }
+
+ return res == True;
+}
+
+bool FunctionUtils::isVirtualFunction(const Function *function,
+ const LookupContext &context,
+ const Function **firstVirtual)
+{
+ return isVirtualFunction_helper(function, context, Virtual, firstVirtual);
+}
+
+bool FunctionUtils::isPureVirtualFunction(const Function *function,
+ const LookupContext &context,
+ const Function **firstVirtual)
+{
+ return isVirtualFunction_helper(function, context, PureVirtual, firstVirtual);
+}
+
+QList<Symbol *> FunctionUtils::overrides(Function *function, Class *functionsClass,
+ Class *staticClass, const Snapshot &snapshot)
+{
+ QList<Symbol *> result;
+ QTC_ASSERT(function && functionsClass && staticClass, return result);
+
+ FullySpecifiedType referenceType = function->type();
+ const Name *referenceName = function->name();
+ QTC_ASSERT(referenceName && referenceType.isValid(), return result);
+
+ // Find overrides
+ TypeHierarchyBuilder builder(staticClass, snapshot);
+ const TypeHierarchy &staticClassHierarchy = builder.buildDerivedTypeHierarchy();
+
+ QList<TypeHierarchy> l;
+ l.append(TypeHierarchy(functionsClass));
+ l.append(staticClassHierarchy);
+
+ while (!l.isEmpty()) {
+ // Add derived
+ const TypeHierarchy hierarchy = l.takeFirst();
+ QTC_ASSERT(hierarchy.symbol(), continue);
+ Class *c = hierarchy.symbol()->asClass();
+ QTC_ASSERT(c, continue);
+
+ foreach (const TypeHierarchy &t, hierarchy.hierarchy()) {
+ if (!l.contains(t))
+ l << t;
+ }
+
+ // Check member functions
+ for (int i = 0, total = c->memberCount(); i < total; ++i) {
+ Symbol *candidate = c->memberAt(i);
+ const Name *candidateName = candidate->name();
+ const Function *candidateFunc = candidate->type()->asFunctionType();
+ if (!candidateName || !candidateFunc)
+ continue;
+ if (candidateName->isEqualTo(referenceName)
+ && candidateFunc->isSignatureEqualTo(function)) {
+ result << candidate;
+ }
+ }
+ }
+
+ return result;
+}
+
+#ifdef WITH_TESTS
+#include "cpptoolsplugin.h"
+
+#include <QTest>
+
+namespace CppTools {
+namespace Internal {
+
+enum Virtuality
+{
+ NotVirtual,
+ Virtual,
+ PureVirtual
+};
+typedef QList<Virtuality> VirtualityList;
+} // Internal namespace
+} // CppTools namespace
+
+Q_DECLARE_METATYPE(CppTools::Internal::Virtuality)
+Q_DECLARE_METATYPE(CppTools::Internal::VirtualityList)
+Q_DECLARE_METATYPE(QList<int>)
+
+namespace CppTools {
+namespace Internal {
+
+void CppToolsPlugin::test_functionutils_virtualFunctions()
+{
+ // Create and parse document
+ QFETCH(QByteArray, source);
+ QFETCH(VirtualityList, virtualityList);
+ QFETCH(QList<int>, firstVirtualList);
+ Document::Ptr document = Document::create(QLatin1String("virtuals"));
+ document->setUtf8Source(source);
+ document->check(); // calls parse();
+ QCOMPARE(document->diagnosticMessages().size(), 0);
+ QVERIFY(document->translationUnit()->ast());
+ QList<const Function *> allFunctions;
+ const Function *firstVirtual = 0;
+
+ // Iterate through Function symbols
+ Snapshot snapshot;
+ snapshot.insert(document);
+ const LookupContext context(document, snapshot);
+ Control *control = document->translationUnit()->control();
+ Symbol **end = control->lastSymbol();
+ for (Symbol **it = control->firstSymbol(); it != end; ++it) {
+ if (const Function *function = (*it)->asFunction()) {
+ allFunctions.append(function);
+ QTC_ASSERT(!virtualityList.isEmpty(), return);
+ Virtuality virtuality = virtualityList.takeFirst();
+ QTC_ASSERT(!firstVirtualList.isEmpty(), return);
+ int firstVirtualIndex = firstVirtualList.takeFirst();
+ bool isVirtual = FunctionUtils::isVirtualFunction(function, context, &firstVirtual);
+ bool isPureVirtual = FunctionUtils::isPureVirtualFunction(function, context,
+ &firstVirtual);
+
+ // Test for regressions introduced by firstVirtual
+ QCOMPARE(FunctionUtils::isVirtualFunction(function, context), isVirtual);
+ QCOMPARE(FunctionUtils::isPureVirtualFunction(function, context), isPureVirtual);
+ if (isVirtual) {
+ if (isPureVirtual)
+ QCOMPARE(virtuality, PureVirtual);
+ else
+ QCOMPARE(virtuality, Virtual);
+ } else {
+ QEXPECT_FAIL("virtual-dtor-dtor", "Not implemented", Abort);
+ if (allFunctions.size() == 3)
+ QEXPECT_FAIL("dtor-virtual-dtor-dtor", "Not implemented", Abort);
+ QCOMPARE(virtuality, NotVirtual);
+ }
+ if (firstVirtualIndex == -1)
+ QVERIFY(!firstVirtual);
+ else
+ QCOMPARE(firstVirtual, allFunctions.at(firstVirtualIndex));
+ }
+ }
+ QVERIFY(virtualityList.isEmpty());
+ QVERIFY(firstVirtualList.isEmpty());
+}
+
+void CppToolsPlugin::test_functionutils_virtualFunctions_data()
+{
+ typedef QByteArray _;
+ QTest::addColumn<QByteArray>("source");
+ QTest::addColumn<VirtualityList>("virtualityList");
+ QTest::addColumn<QList<int> >("firstVirtualList");
+
+ QTest::newRow("none")
+ << _("struct None { void foo() {} };\n")
+ << (VirtualityList() << NotVirtual)
+ << (QList<int>() << -1);
+
+ QTest::newRow("single-virtual")
+ << _("struct V { virtual void foo() {} };\n")
+ << (VirtualityList() << Virtual)
+ << (QList<int>() << 0);
+
+ QTest::newRow("single-pure-virtual")
+ << _("struct PV { virtual void foo() = 0; };\n")
+ << (VirtualityList() << PureVirtual)
+ << (QList<int>() << 0);
+
+ QTest::newRow("virtual-derived-with-specifier")
+ << _("struct Base { virtual void foo() {} };\n"
+ "struct Derived : Base { virtual void foo() {} };\n")
+ << (VirtualityList() << Virtual << Virtual)
+ << (QList<int>() << 0 << 0);
+
+ QTest::newRow("virtual-derived-implicit")
+ << _("struct Base { virtual void foo() {} };\n"
+ "struct Derived : Base { void foo() {} };\n")
+ << (VirtualityList() << Virtual << Virtual)
+ << (QList<int>() << 0 << 0);
+
+ QTest::newRow("not-virtual-then-virtual")
+ << _("struct Base { void foo() {} };\n"
+ "struct Derived : Base { virtual void foo() {} };\n")
+ << (VirtualityList() << NotVirtual << Virtual)
+ << (QList<int>() << -1 << 1);
+
+ QTest::newRow("virtual-final-not-virtual")
+ << _("struct Base { virtual void foo() {} };\n"
+ "struct Derived : Base { void foo() final {} };\n"
+ "struct Derived2 : Derived { void foo() {} };")
+ << (VirtualityList() << Virtual << Virtual << NotVirtual)
+ << (QList<int>() << 0 << 0 << -1);
+
+ QTest::newRow("virtual-then-pure")
+ << _("struct Base { virtual void foo() {} };\n"
+ "struct Derived : Base { virtual void foo() = 0; };\n"
+ "struct Derived2 : Derived { void foo() {} };")
+ << (VirtualityList() << Virtual << PureVirtual << Virtual)
+ << (QList<int>() << 0 << 0 << 0);
+
+ QTest::newRow("virtual-virtual-final-not-virtual")
+ << _("struct Base { virtual void foo() {} };\n"
+ "struct Derived : Base { virtual void foo() final {} };\n"
+ "struct Derived2 : Derived { void foo() {} };")
+ << (VirtualityList() << Virtual << Virtual << NotVirtual)
+ << (QList<int>() << 0 << 0 << -1);
+
+ QTest::newRow("ctor-virtual-dtor")
+ << _("struct Base { Base() {} virtual ~Base() {} };\n")
+ << (VirtualityList() << NotVirtual << Virtual)
+ << (QList<int>() << -1 << 1);
+
+ QTest::newRow("virtual-dtor-dtor")
+ << _("struct Base { virtual ~Base() {} };\n"
+ "struct Derived : Base { ~Derived() {} };\n")
+ << (VirtualityList() << Virtual << Virtual)
+ << (QList<int>() << 0 << 0);
+
+ QTest::newRow("dtor-virtual-dtor-dtor")
+ << _("struct Base { ~Base() {} };\n"
+ "struct Derived : Base { virtual ~Derived() {} };\n"
+ "struct Derived2 : Derived { ~Derived2() {} };\n")
+ << (VirtualityList() << NotVirtual << Virtual << Virtual)
+ << (QList<int>() << -1 << 1 << 1);
+}
+
+} // namespace Internal
+} // namespace CppTools
+
+#endif
diff --git a/src/plugins/cpptools/functionutils.h b/src/plugins/cpptools/functionutils.h
new file mode 100644
index 0000000000..0ca362a89d
--- /dev/null
+++ b/src/plugins/cpptools/functionutils.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef FUNCTIONUTILS_H
+#define FUNCTIONUTILS_H
+
+#include "cpptools_global.h"
+
+QT_BEGIN_NAMESPACE
+template <class> class QList;
+QT_END_NAMESPACE
+
+namespace CPlusPlus {
+class Class;
+class Function;
+class LookupContext;
+class Snapshot;
+class Symbol;
+} // namespace CPlusPlus
+
+namespace CppTools {
+
+class CPPTOOLS_EXPORT FunctionUtils
+{
+public:
+ static bool isVirtualFunction(const CPlusPlus::Function *function,
+ const CPlusPlus::LookupContext &context,
+ const CPlusPlus::Function **firstVirtual = 0);
+
+ static bool isPureVirtualFunction(const CPlusPlus::Function *function,
+ const CPlusPlus::LookupContext &context,
+ const CPlusPlus::Function **firstVirtual = 0);
+
+ static QList<CPlusPlus::Symbol *> overrides(CPlusPlus::Function *function,
+ CPlusPlus::Class *functionsClass,
+ CPlusPlus::Class *staticClass,
+ const CPlusPlus::Snapshot &snapshot);
+};
+
+} // namespace CppTools
+
+#endif // FUNCTIONUTILS_H
diff --git a/src/plugins/cpptools/modelmanagertesthelper.cpp b/src/plugins/cpptools/modelmanagertesthelper.cpp
index 98de70ddff..b53cd40506 100644
--- a/src/plugins/cpptools/modelmanagertesthelper.cpp
+++ b/src/plugins/cpptools/modelmanagertesthelper.cpp
@@ -39,6 +39,7 @@ TestProject::TestProject(const QString &name, QObject *parent)
: m_name (name)
{
setParent(parent);
+ setId(Core::Id::fromString(name));
}
TestProject::~TestProject()
@@ -102,10 +103,14 @@ ModelManagerTestHelper::Project *ModelManagerTestHelper::createProject(const QSt
return tp;
}
-QStringList ModelManagerTestHelper::waitForRefreshedSourceFiles()
+void ModelManagerTestHelper::resetRefreshedSourceFiles()
{
+ m_lastRefreshedSourceFiles.clear();
m_refreshHappened = false;
+}
+QStringList ModelManagerTestHelper::waitForRefreshedSourceFiles()
+{
while (!m_refreshHappened)
QCoreApplication::processEvents();
diff --git a/src/plugins/cpptools/modelmanagertesthelper.h b/src/plugins/cpptools/modelmanagertesthelper.h
index 3923c96cbe..3292e1950e 100644
--- a/src/plugins/cpptools/modelmanagertesthelper.h
+++ b/src/plugins/cpptools/modelmanagertesthelper.h
@@ -48,9 +48,6 @@ public:
virtual QString displayName() const
{ return m_name; }
- virtual Core::Id id() const
- { return Core::Id::fromString(m_name); }
-
virtual Core::IDocument *document() const
{ return 0; }
@@ -83,6 +80,7 @@ public:
Project *createProject(const QString &name);
+ void resetRefreshedSourceFiles();
QStringList waitForRefreshedSourceFiles();
void waitForFinishedGc();
diff --git a/src/plugins/cpptools/symbolsearcher_test.cpp b/src/plugins/cpptools/symbolsearcher_test.cpp
index 0426435029..9c128b2630 100644
--- a/src/plugins/cpptools/symbolsearcher_test.cpp
+++ b/src/plugins/cpptools/symbolsearcher_test.cpp
@@ -31,6 +31,7 @@
#include "builtinindexingsupport.h"
#include "cppmodelmanager.h"
+#include "cpptoolstestcase.h"
#include "searchsymbols.h"
#include <coreplugin/testdatadir.h>
@@ -43,14 +44,9 @@ using namespace CppTools::Internal;
namespace {
-class MyTestDataDir : public Core::Internal::Tests::TestDataDir
-{
-public:
- MyTestDataDir(const QString &testDataDirectory)
- : TestDataDir(QLatin1String(SRCDIR "/../../../tests/cppsymbolsearcher/")
- + testDataDirectory)
- {}
-};
+QTC_DECLARE_MYTESTDATADIR("../../../tests/cppsymbolsearcher/")
+
+inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
class ResultData
{
@@ -66,10 +62,10 @@ public:
return m_symbolName == other.m_symbolName && m_scope == other.m_scope;
}
- static ResultDataList fromSearchResultList(const QList<Find::SearchResultItem> &entries)
+ static ResultDataList fromSearchResultList(const QList<Core::SearchResultItem> &entries)
{
ResultDataList result;
- foreach (const Find::SearchResultItem &entry, entries)
+ foreach (const Core::SearchResultItem &entry, entries)
result << ResultData(entry.text, entry.path.join(QLatin1String("::")));
return result;
}
@@ -84,59 +80,52 @@ public:
}
}
+public:
QString m_symbolName;
QString m_scope;
};
typedef ResultData::ResultDataList ResultDataList;
-class SymbolSearcherTest
+class SymbolSearcherTestCase : public CppTools::Tests::TestCase
{
public:
/// Takes no ownership of indexingSupportToUse
- SymbolSearcherTest(const QString &testFile, CppIndexingSupport *indexingSupportToUse)
- : m_modelManager(CppModelManager::instance())
+ SymbolSearcherTestCase(const QString &testFile,
+ CppIndexingSupport *indexingSupportToUse,
+ const SymbolSearcher::Parameters &searchParameters,
+ const ResultDataList &expectedResults)
+ : m_indexingSupportToRestore(0)
, m_indexingSupportToUse(indexingSupportToUse)
- , m_testFile(testFile)
{
- QVERIFY(m_indexingSupportToUse);
- QVERIFY(m_modelManager->snapshot().isEmpty());
- m_modelManager->updateSourceFiles(QStringList() << m_testFile).waitForFinished();
- QVERIFY(m_modelManager->snapshot().contains(m_testFile));
+ QVERIFY(succeededSoFar());
+ QVERIFY(m_indexingSupportToUse);
+ QVERIFY(parseFiles(testFile));
m_indexingSupportToRestore = m_modelManager->indexingSupport();
m_modelManager->setIndexingSupport(m_indexingSupportToUse);
- QCoreApplication::processEvents();
- }
- ResultDataList run(const SymbolSearcher::Parameters &searchParameters) const
- {
CppIndexingSupport *indexingSupport = m_modelManager->indexingSupport();
- SymbolSearcher *symbolSearcher
- = indexingSupport->createSymbolSearcher(searchParameters, QSet<QString>() << m_testFile);
- QFuture<Find::SearchResultItem> search
+ SymbolSearcher *symbolSearcher = indexingSupport->createSymbolSearcher(searchParameters,
+ QSet<QString>() << testFile);
+ QFuture<Core::SearchResultItem> search
= QtConcurrent::run(&SymbolSearcher::runSearch, symbolSearcher);
search.waitForFinished();
ResultDataList results = ResultData::fromSearchResultList(search.results());
- return results;
+ QCOMPARE(results, expectedResults);
}
- ~SymbolSearcherTest()
+ ~SymbolSearcherTestCase()
{
- m_modelManager->setIndexingSupport(m_indexingSupportToRestore);
- m_modelManager->GC();
- QVERIFY(m_modelManager->snapshot().isEmpty());
+ if (m_indexingSupportToRestore)
+ m_modelManager->setIndexingSupport(m_indexingSupportToRestore);
}
private:
- CppModelManager *m_modelManager;
CppIndexingSupport *m_indexingSupportToRestore;
CppIndexingSupport *m_indexingSupportToUse;
- const QString m_testFile;
};
-inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
-
} // anonymous namespace
Q_DECLARE_METATYPE(ResultData)
@@ -161,10 +150,10 @@ void CppToolsPlugin::test_builtinsymbolsearcher()
QFETCH(ResultDataList, expectedResults);
QScopedPointer<CppIndexingSupport> builtinIndexingSupport(new BuiltinIndexingSupport);
-
- SymbolSearcherTest test(testFile, builtinIndexingSupport.data());
- const ResultDataList results = test.run(searchParameters);
- QCOMPARE(results, expectedResults);
+ SymbolSearcherTestCase(testFile,
+ builtinIndexingSupport.data(),
+ searchParameters,
+ expectedResults);
}
void CppToolsPlugin::test_builtinsymbolsearcher_data()
@@ -211,9 +200,11 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< ResultData(_("functionDeclaredOnly()"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
- << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
+ << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
+ _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
- << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
+ << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
+ _("MyNamespace::MyClass"))
<< ResultData(_("int myVariable"), _("<anonymous namespace>"))
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
<< ResultData(_("MyEnum"), _("<anonymous namespace>"))
@@ -222,9 +213,12 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< ResultData(_("MyClass"), _("<anonymous namespace>"))
<< ResultData(_("MyClass()"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDeclaredOnly()"), _("<anonymous namespace>::MyClass"))
- << ResultData(_("functionDefinedInClass(bool, int)"), _("<anonymous namespace>::MyClass"))
- << ResultData(_("functionDefinedOutSideClass(char)"), _("<anonymous namespace>::MyClass"))
- << ResultData(_("functionDefinedOutSideClass(char)"), _("<anonymous namespace>::MyClass"))
+ << ResultData(_("functionDefinedInClass(bool, int)"),
+ _("<anonymous namespace>::MyClass"))
+ << ResultData(_("functionDefinedOutSideClass(char)"),
+ _("<anonymous namespace>::MyClass"))
+ << ResultData(_("functionDefinedOutSideClass(char)"),
+ _("<anonymous namespace>::MyClass"))
<< ResultData(_("main()"), _(""))
);
@@ -260,10 +254,13 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
- << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
+ << ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
+ _("MyNamespace::MyClass"))
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
- << ResultData(_("functionDefinedInClass(bool, int)"), _("<anonymous namespace>::MyClass"))
- << ResultData(_("functionDefinedOutSideClass(char)"), _("<anonymous namespace>::MyClass"))
+ << ResultData(_("functionDefinedInClass(bool, int)"),
+ _("<anonymous namespace>::MyClass"))
+ << ResultData(_("functionDefinedOutSideClass(char)"),
+ _("<anonymous namespace>::MyClass"))
);
// Check Enums
diff --git a/src/plugins/cpptools/symbolsfindfilter.cpp b/src/plugins/cpptools/symbolsfindfilter.cpp
index adfdbc2191..6150c01bec 100644
--- a/src/plugins/cpptools/symbolsfindfilter.cpp
+++ b/src/plugins/cpptools/symbolsfindfilter.cpp
@@ -84,35 +84,35 @@ bool SymbolsFindFilter::isEnabled() const
void SymbolsFindFilter::cancel()
{
- Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
+ Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
QTC_ASSERT(search, return);
- QFutureWatcher<Find::SearchResultItem> *watcher = m_watchers.key(search);
+ QFutureWatcher<Core::SearchResultItem> *watcher = m_watchers.key(search);
QTC_ASSERT(watcher, return);
watcher->cancel();
}
void SymbolsFindFilter::setPaused(bool paused)
{
- Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
+ Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
QTC_ASSERT(search, return);
- QFutureWatcher<Find::SearchResultItem> *watcher = m_watchers.key(search);
+ QFutureWatcher<Core::SearchResultItem> *watcher = m_watchers.key(search);
QTC_ASSERT(watcher, return);
if (!paused || watcher->isRunning()) // guard against pausing when the search is finished
watcher->setPaused(paused);
}
-Find::FindFlags SymbolsFindFilter::supportedFindFlags() const
+Core::FindFlags SymbolsFindFilter::supportedFindFlags() const
{
- return Find::FindCaseSensitively | Find::FindRegularExpression | Find::FindWholeWords;
+ return Core::FindCaseSensitively | Core::FindRegularExpression | Core::FindWholeWords;
}
-void SymbolsFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
+void SymbolsFindFilter::findAll(const QString &txt, Core::FindFlags findFlags)
{
- Find::SearchResultWindow *window = Find::SearchResultWindow::instance();
- Find::SearchResult *search = window->startNewSearch(label(), toolTip(findFlags), txt);
+ Core::SearchResultWindow *window = Core::SearchResultWindow::instance();
+ Core::SearchResult *search = window->startNewSearch(label(), toolTip(findFlags), txt);
search->setSearchAgainSupported(true);
- connect(search, SIGNAL(activated(Find::SearchResultItem)),
- this, SLOT(openEditor(Find::SearchResultItem)));
+ connect(search, SIGNAL(activated(Core::SearchResultItem)),
+ this, SLOT(openEditor(Core::SearchResultItem)));
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
@@ -128,7 +128,7 @@ void SymbolsFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
startSearch(search);
}
-void SymbolsFindFilter::startSearch(Find::SearchResult *search)
+void SymbolsFindFilter::startSearch(Core::SearchResult *search)
{
SymbolSearcher::Parameters parameters = search->userData().value<SymbolSearcher::Parameters>();
QSet<QString> projectFileNames;
@@ -137,7 +137,7 @@ void SymbolsFindFilter::startSearch(Find::SearchResult *search)
projectFileNames += project->files(ProjectExplorer::Project::AllFiles).toSet();
}
- QFutureWatcher<Find::SearchResultItem> *watcher = new QFutureWatcher<Find::SearchResultItem>();
+ QFutureWatcher<Core::SearchResultItem> *watcher = new QFutureWatcher<Core::SearchResultItem>();
m_watchers.insert(watcher, search);
connect(watcher, SIGNAL(finished()),
this, SLOT(finish()));
@@ -148,38 +148,38 @@ void SymbolsFindFilter::startSearch(Find::SearchResult *search)
symbolSearcher, SLOT(deleteLater()));
watcher->setFuture(QtConcurrent::run(&SymbolSearcher::runSearch, symbolSearcher));
FutureProgress *progress = ProgressManager::addTask(watcher->future(), tr("Searching"),
- Find::Constants::TASK_SEARCH);
+ Core::Constants::TASK_SEARCH);
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
}
void SymbolsFindFilter::addResults(int begin, int end)
{
- QFutureWatcher<Find::SearchResultItem> *watcher =
- static_cast<QFutureWatcher<Find::SearchResultItem> *>(sender());
- Find::SearchResult *search = m_watchers.value(watcher);
+ QFutureWatcher<Core::SearchResultItem> *watcher =
+ static_cast<QFutureWatcher<Core::SearchResultItem> *>(sender());
+ Core::SearchResult *search = m_watchers.value(watcher);
if (!search) {
// search was removed from search history while the search is running
watcher->cancel();
return;
}
- QList<Find::SearchResultItem> items;
+ QList<Core::SearchResultItem> items;
for (int i = begin; i < end; ++i)
items << watcher->resultAt(i);
- search->addResults(items, Find::SearchResult::AddSorted);
+ search->addResults(items, Core::SearchResult::AddSorted);
}
void SymbolsFindFilter::finish()
{
- QFutureWatcher<Find::SearchResultItem> *watcher =
- static_cast<QFutureWatcher<Find::SearchResultItem> *>(sender());
- Find::SearchResult *search = m_watchers.value(watcher);
+ QFutureWatcher<Core::SearchResultItem> *watcher =
+ static_cast<QFutureWatcher<Core::SearchResultItem> *>(sender());
+ Core::SearchResult *search = m_watchers.value(watcher);
if (search)
search->finishSearch(watcher->isCanceled());
m_watchers.remove(watcher);
watcher->deleteLater();
}
-void SymbolsFindFilter::openEditor(const Find::SearchResultItem &item)
+void SymbolsFindFilter::openEditor(const Core::SearchResultItem &item)
{
if (!item.userData.canConvert<ModelItemInfo>())
return;
@@ -229,7 +229,7 @@ void SymbolsFindFilter::onAllTasksFinished(Core::Id type)
void SymbolsFindFilter::searchAgain()
{
- Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
+ Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
QTC_ASSERT(search, return);
search->restart();
startSearch(search);
@@ -240,7 +240,7 @@ QString SymbolsFindFilter::label() const
return tr("C++ Symbols:");
}
-QString SymbolsFindFilter::toolTip(Find::FindFlags findFlags) const
+QString SymbolsFindFilter::toolTip(Core::FindFlags findFlags) const
{
QStringList types;
if (m_symbolsToSearch & SymbolSearcher::Classes)
@@ -254,7 +254,7 @@ QString SymbolsFindFilter::toolTip(Find::FindFlags findFlags) const
return tr("Scope: %1\nTypes: %2\nFlags: %3")
.arg(searchScope() == SymbolSearcher::SearchGlobal ? tr("All") : tr("Projects"))
.arg(types.join(tr(", ")))
- .arg(Find::IFindFilter::descriptionForFindFlags(findFlags));
+ .arg(Core::IFindFilter::descriptionForFindFlags(findFlags));
}
// #pragma mark -- SymbolsFindFilterConfigWidget
diff --git a/src/plugins/cpptools/symbolsfindfilter.h b/src/plugins/cpptools/symbolsfindfilter.h
index 998b58dba3..6dc550763e 100644
--- a/src/plugins/cpptools/symbolsfindfilter.h
+++ b/src/plugins/cpptools/symbolsfindfilter.h
@@ -32,7 +32,7 @@
#include "searchsymbols.h"
-#include <find/ifindfilter.h>
+#include <coreplugin/find/ifindfilter.h>
#include <QFutureWatcher>
#include <QPointer>
@@ -45,7 +45,7 @@ namespace Internal {
class CppModelManager;
-class SymbolsFindFilter : public Find::IFindFilter
+class SymbolsFindFilter : public Core::IFindFilter
{
Q_OBJECT
@@ -58,9 +58,9 @@ public:
QString id() const;
QString displayName() const;
bool isEnabled() const;
- Find::FindFlags supportedFindFlags() const;
+ Core::FindFlags supportedFindFlags() const;
- void findAll(const QString &txt, Find::FindFlags findFlags);
+ void findAll(const QString &txt, Core::FindFlags findFlags);
QWidget *createConfigWidget();
void writeSettings(QSettings *settings);
@@ -76,7 +76,7 @@ signals:
void symbolsToSearchChanged();
private slots:
- void openEditor(const Find::SearchResultItem &item);
+ void openEditor(const Core::SearchResultItem &item);
void addResults(int begin, int end);
void finish();
@@ -88,13 +88,13 @@ private slots:
private:
QString label() const;
- QString toolTip(Find::FindFlags findFlags) const;
- void startSearch(Find::SearchResult *search);
+ QString toolTip(Core::FindFlags findFlags) const;
+ void startSearch(Core::SearchResult *search);
CppModelManager *m_manager;
bool m_enabled;
- QMap<QFutureWatcher<Find::SearchResultItem> *, QPointer<Find::SearchResult> > m_watchers;
- QPointer<Find::SearchResult> m_currentSearch;
+ QMap<QFutureWatcher<Core::SearchResultItem> *, QPointer<Core::SearchResult> > m_watchers;
+ QPointer<Core::SearchResult> m_currentSearch;
SearchSymbols::SymbolTypes m_symbolsToSearch;
SearchScope m_scope;
};
diff --git a/src/plugins/cpptools/typehierarchybuilder.h b/src/plugins/cpptools/typehierarchybuilder.h
index 0a4153ea9f..99241d0099 100644
--- a/src/plugins/cpptools/typehierarchybuilder.h
+++ b/src/plugins/cpptools/typehierarchybuilder.h
@@ -53,6 +53,9 @@ public:
CPlusPlus::Symbol *symbol() const;
const QList<TypeHierarchy> &hierarchy() const;
+ bool operator==(const TypeHierarchy &other) const
+ { return _symbol == other._symbol; }
+
private:
CPlusPlus::Symbol *_symbol;
QList<TypeHierarchy> _hierarchy;
diff --git a/src/plugins/cpptools/typehierarchybuilder_test.cpp b/src/plugins/cpptools/typehierarchybuilder_test.cpp
index 34b78326d1..e417383532 100644
--- a/src/plugins/cpptools/typehierarchybuilder_test.cpp
+++ b/src/plugins/cpptools/typehierarchybuilder_test.cpp
@@ -30,10 +30,11 @@
#include "cpptoolsplugin.h"
#include "cppmodelmanagerinterface.h"
+#include "cpptoolstestcase.h"
#include "typehierarchybuilder.h"
-#include <cplusplus/SymbolVisitor.h>
#include <cplusplus/Overview.h>
+#include <cplusplus/SymbolVisitor.h>
#include <utils/fileutils.h>
#include <QDir>
@@ -43,6 +44,8 @@ using namespace CPlusPlus;
using namespace CppTools;
using namespace CppTools::Internal;
+Q_DECLARE_METATYPE(QList<Tests::TestDocument>)
+
namespace {
bool hierarchySorter(const TypeHierarchy &h1, const TypeHierarchy &h2)
@@ -89,48 +92,30 @@ private:
return true;
}
+private:
Class *m_clazz;
};
-struct TestDocument
-{
-public:
- TestDocument(const QString &fileName, const QString &contents)
- : fileName(fileName), contents(contents) {}
-
- QString fileName;
- QString contents;
-};
-
-class TestCase
+class TypeHierarchyBuilderTestCase : public CppTools::Tests::TestCase
{
public:
- TestCase(const QList<TestDocument> &documents, const QString &expectedHierarchy)
- : m_modelManager(CppModelManagerInterface::instance())
- , m_documents(documents)
- , m_expectedHierarchy(expectedHierarchy)
+ TypeHierarchyBuilderTestCase(const QList<Tests::TestDocument> &documents,
+ const QString &expectedHierarchy)
{
- QVERIFY(m_modelManager->snapshot().isEmpty());
- }
+ QVERIFY(succeededSoFar());
- void run()
- {
// Write files
QStringList filePaths;
- foreach (const TestDocument &document, m_documents) {
- const QString filePath = QDir::tempPath() + QLatin1Char('/') + document.fileName;
- Utils::FileSaver documentSaver(filePath);
- documentSaver.write(document.contents.toUtf8());
- documentSaver.finalize();
- filePaths << filePath;
+ foreach (const Tests::TestDocument &document, documents) {
+ QVERIFY(document.writeToDisk());
+ filePaths << document.filePath();
}
// Parse files
- m_modelManager->updateSourceFiles(filePaths).waitForFinished();
+ QVERIFY(parseFiles(filePaths));
+ const Snapshot snapshot = globalSnapshot();
// Get class for which to generate the hierarchy
- const Snapshot snapshot = m_modelManager->snapshot();
- QVERIFY(!snapshot.isEmpty());
const Document::Ptr firstDocument = snapshot.document(filePaths.first());
Class *clazz = FindFirstClassInDocument()(firstDocument);
QVERIFY(clazz);
@@ -142,40 +127,27 @@ public:
const QString actualHierarchy = toString(hierarchy);
// Uncomment for updating/generating reference data:
// qDebug() << actualHierarchy;
- QCOMPARE(actualHierarchy, m_expectedHierarchy);
- }
-
- ~TestCase()
- {
- m_modelManager->GC();
- QVERIFY(m_modelManager->snapshot().isEmpty());
+ QCOMPARE(actualHierarchy, expectedHierarchy);
}
-
-private:
- CppModelManagerInterface *m_modelManager;
- QList<TestDocument> m_documents;
- QString m_expectedHierarchy;
};
} // anonymous namespace
-Q_DECLARE_METATYPE(QList<TestDocument>)
-
void CppToolsPlugin::test_typehierarchy_data()
{
- QTest::addColumn<QList<TestDocument> >("documents");
+ QTest::addColumn<QList<Tests::TestDocument> >("documents");
QTest::addColumn<QString>("expectedHierarchy");
- typedef QLatin1String _;
+ typedef Tests::TestDocument TestDocument;
QTest::newRow("basic-single-document")
<< (QList<TestDocument>()
- << TestDocument(_("a.h"),
- _("class A {};\n"
- "class B : public A {};\n"
- "class C1 : public B {};\n"
- "class C2 : public B {};\n"
- "class D : public C1 {};\n")))
+ << TestDocument("a.h",
+ "class A {};\n"
+ "class B : public A {};\n"
+ "class C1 : public B {};\n"
+ "class C2 : public B {};\n"
+ "class D : public C1 {};\n"))
<< QString::fromLatin1(
"A\n"
" B\n"
@@ -185,20 +157,20 @@ void CppToolsPlugin::test_typehierarchy_data()
QTest::newRow("basic-multiple-documents")
<< (QList<TestDocument>()
- << TestDocument(_("a.h"),
- _("class A {};"))
- << TestDocument(_("b.h"),
- _("#include \"a.h\"\n"
- "class B : public A {};"))
- << TestDocument(_("c1.h"),
- _("#include \"b.h\"\n"
- "class C1 : public B {};"))
- << TestDocument(_("c2.h"),
- _("#include \"b.h\"\n"
- "class C2 : public B {};"))
- << TestDocument(_("d.h"),
- _("#include \"c1.h\"\n"
- "class D : public C1 {};")))
+ << TestDocument("a.h",
+ "class A {};")
+ << TestDocument("b.h",
+ "#include \"a.h\"\n"
+ "class B : public A {};")
+ << TestDocument("c1.h",
+ "#include \"b.h\"\n"
+ "class C1 : public B {};")
+ << TestDocument("c2.h",
+ "#include \"b.h\"\n"
+ "class C2 : public B {};")
+ << TestDocument("d.h",
+ "#include \"c1.h\"\n"
+ "class D : public C1 {};"))
<< QString::fromLatin1(
"A\n"
" B\n"
@@ -210,9 +182,8 @@ void CppToolsPlugin::test_typehierarchy_data()
void CppToolsPlugin::test_typehierarchy()
{
- QFETCH(QList<TestDocument>, documents);
+ QFETCH(QList<Tests::TestDocument>, documents);
QFETCH(QString, expectedHierarchy);
- TestCase testCase(documents, expectedHierarchy);
- testCase.run();
+ TypeHierarchyBuilderTestCase(documents, expectedHierarchy);
}
diff --git a/src/plugins/cvs/checkoutwizard.cpp b/src/plugins/cvs/checkoutwizard.cpp
index 99dbf3a938..b9660f3d8a 100644
--- a/src/plugins/cvs/checkoutwizard.cpp
+++ b/src/plugins/cvs/checkoutwizard.cpp
@@ -68,7 +68,7 @@ VcsBase::Command *CheckoutWizard::createCommand(const QList<QWizardPage*> &param
const CheckoutWizardPage *cwp = qobject_cast<const CheckoutWizardPage *>(parameterPages.front());
QTC_ASSERT(cwp, return 0);
const CvsSettings settings = CvsPlugin::instance()->settings();
- const QString binary = settings.cvsBinaryPath;
+ const QString binary = settings.binaryPath();
QStringList args;
const QString repository = cwp->repository();
args << QLatin1String("checkout") << repository;
diff --git a/src/plugins/cvs/cvs.pro b/src/plugins/cvs/cvs.pro
index 9ecb32b06e..be1d4af402 100644
--- a/src/plugins/cvs/cvs.pro
+++ b/src/plugins/cvs/cvs.pro
@@ -2,6 +2,7 @@ include(../../qtcreatorplugin.pri)
HEADERS += annotationhighlighter.h \
cvsplugin.h \
+ cvsclient.h \
cvscontrol.h \
settingspage.h \
cvseditor.h \
@@ -14,6 +15,7 @@ HEADERS += annotationhighlighter.h \
SOURCES += annotationhighlighter.cpp \
cvsplugin.cpp \
+ cvsclient.cpp \
cvscontrol.cpp \
settingspage.cpp \
cvseditor.cpp \
diff --git a/src/plugins/cvs/cvs.qbs b/src/plugins/cvs/cvs.qbs
index 8d858a7b24..810ae1211b 100644
--- a/src/plugins/cvs/cvs.qbs
+++ b/src/plugins/cvs/cvs.qbs
@@ -8,9 +8,7 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
Depends { name: "TextEditor" }
- Depends { name: "Find" }
Depends { name: "VcsBase" }
- Depends { name: "Locator" }
files: [
"annotationhighlighter.cpp",
@@ -20,6 +18,8 @@ QtcPlugin {
"checkoutwizardpage.cpp",
"checkoutwizardpage.h",
"cvs.qrc",
+ "cvsclient.cpp",
+ "cvsclient.h",
"cvsconstants.h",
"cvscontrol.cpp",
"cvscontrol.h",
diff --git a/src/plugins/cvs/cvs_dependencies.pri b/src/plugins/cvs/cvs_dependencies.pri
index a10e575988..8761cf6570 100644
--- a/src/plugins/cvs/cvs_dependencies.pri
+++ b/src/plugins/cvs/cvs_dependencies.pri
@@ -2,7 +2,6 @@ QTC_PLUGIN_NAME = CVS
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
- locator \
texteditor \
coreplugin \
vcsbase
diff --git a/src/plugins/cvs/cvsclient.cpp b/src/plugins/cvs/cvsclient.cpp
new file mode 100644
index 0000000000..1a7f0603d0
--- /dev/null
+++ b/src/plugins/cvs/cvsclient.cpp
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "cvsclient.h"
+#include "cvssettings.h"
+#include "cvsconstants.h"
+
+#include <vcsbase/vcsbaseplugin.h>
+#include <vcsbase/vcsbaseeditor.h>
+#include <vcsbase/vcsbaseconstants.h>
+#include <vcsbase/vcsbaseeditorparameterwidget.h>
+#include <utils/synchronousprocess.h>
+
+#include <QDir>
+#include <QFileInfo>
+#include <QTextStream>
+#include <QDebug>
+
+namespace Cvs {
+namespace Internal {
+
+class CvsDiffExitCodeInterpreter : public Utils::ExitCodeInterpreter
+{
+ Q_OBJECT
+public:
+ CvsDiffExitCodeInterpreter(QObject *parent) : Utils::ExitCodeInterpreter(parent) {}
+ Utils::SynchronousProcessResponse::Result interpretExitCode(int code) const;
+
+};
+
+Utils::SynchronousProcessResponse::Result CvsDiffExitCodeInterpreter::interpretExitCode(int code) const
+{
+ if (code < 0 || code > 2)
+ return Utils::SynchronousProcessResponse::FinishedError;
+ return Utils::SynchronousProcessResponse::Finished;
+}
+
+// Collect all parameters required for a diff to be able to associate them
+// with a diff editor and re-run the diff with parameters.
+struct CvsDiffParameters
+{
+ QString workingDir;
+ QStringList extraOptions;
+ QStringList files;
+};
+
+// Parameter widget controlling whitespace diff mode, associated with a parameter
+class CvsDiffParameterWidget : public VcsBase::VcsBaseEditorParameterWidget
+{
+ Q_OBJECT
+public:
+ explicit CvsDiffParameterWidget(CvsClient *client,
+ const CvsDiffParameters &p,
+ QWidget *parent = 0);
+ QStringList arguments() const;
+ void executeCommand();
+
+private:
+
+ CvsClient *m_client;
+ const CvsDiffParameters m_params;
+};
+
+CvsDiffParameterWidget::CvsDiffParameterWidget(CvsClient *client,
+ const CvsDiffParameters &p,
+ QWidget *parent)
+ : VcsBase::VcsBaseEditorParameterWidget(parent), m_client(client), m_params(p)
+{
+ mapSetting(addToggleButton(QLatin1String("-w"), tr("Ignore Whitespace")),
+ client->settings()->boolPointer(CvsSettings::diffIgnoreWhiteSpaceKey));
+ mapSetting(addToggleButton(QLatin1String("-B"), tr("Ignore Blank Lines")),
+ client->settings()->boolPointer(CvsSettings::diffIgnoreBlankLinesKey));
+}
+
+QStringList CvsDiffParameterWidget::arguments() const
+{
+ QStringList args;
+ args = m_client->settings()->stringValue(CvsSettings::diffOptionsKey).split(QLatin1Char(' '), QString::SkipEmptyParts);
+ args += VcsBaseEditorParameterWidget::arguments();
+ return args;
+}
+
+void CvsDiffParameterWidget::executeCommand()
+{
+ m_client->diff(m_params.workingDir, m_params.files, m_params.extraOptions);
+}
+
+CvsClient::CvsClient(CvsSettings *settings) :
+ VcsBase::VcsBaseClient(settings)
+{
+}
+
+CvsSettings *CvsClient::settings() const
+{
+ return dynamic_cast<CvsSettings *>(VcsBase::VcsBaseClient::settings());
+}
+
+Core::Id CvsClient::vcsEditorKind(VcsCommand cmd) const
+{
+ switch (cmd) {
+ case DiffCommand:
+ return "CVS Diff Editor"; // TODO: replace by string from cvsconstants.h
+ default:
+ return Core::Id();
+ }
+}
+
+Utils::ExitCodeInterpreter *CvsClient::exitCodeInterpreter(VcsCommand cmd, QObject *parent) const
+{
+ switch (cmd) {
+ case DiffCommand:
+ return new CvsDiffExitCodeInterpreter(parent);
+ default:
+ return 0;
+ }
+}
+
+void CvsClient::diff(const QString &workingDir, const QStringList &files,
+ const QStringList &extraOptions)
+{
+ VcsBaseClient::diff(workingDir, files, extraOptions);
+}
+
+QString CvsClient::findTopLevelForFile(const QFileInfo &file) const
+{
+ Q_UNUSED(file)
+ return QString();
+}
+
+QStringList CvsClient::revisionSpec(const QString &revision) const
+{
+ Q_UNUSED(revision)
+ return QStringList();
+}
+
+VcsBase::VcsBaseClient::StatusItem CvsClient::parseStatusLine(const QString &line) const
+{
+ Q_UNUSED(line)
+ return VcsBase::VcsBaseClient::StatusItem();
+}
+
+VcsBase::VcsBaseEditorParameterWidget *CvsClient::createDiffEditor(
+ const QString &workingDir, const QStringList &files, const QStringList &extraOptions)
+{
+ Q_UNUSED(extraOptions)
+ CvsDiffParameters p;
+ p.workingDir = workingDir;
+ p.files = files;
+ p.extraOptions = extraOptions;
+ return new CvsDiffParameterWidget(this, p);
+}
+
+} // namespace Internal
+} // namespace Cvs
+
+#include "cvsclient.moc"
diff --git a/src/plugins/cvs/cvsclient.h b/src/plugins/cvs/cvsclient.h
new file mode 100644
index 0000000000..3f3c1ab84a
--- /dev/null
+++ b/src/plugins/cvs/cvsclient.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CVSCLIENT_H
+#define CVSCLIENT_H
+
+#include "cvssettings.h"
+#include <vcsbase/vcsbaseclient.h>
+
+namespace Cvs {
+namespace Internal {
+
+class CvsSettings;
+
+class CvsClient : public VcsBase::VcsBaseClient
+{
+ Q_OBJECT
+
+public:
+ CvsClient(CvsSettings *settings);
+
+ CvsSettings *settings() const;
+ void diff(const QString &workingDir, const QStringList &files,
+ const QStringList &extraOptions = QStringList());
+ QString findTopLevelForFile(const QFileInfo &file) const;
+ QStringList revisionSpec(const QString &revision) const;
+ StatusItem parseStatusLine(const QString &line) const;
+
+
+protected:
+ Utils::ExitCodeInterpreter *exitCodeInterpreter(VcsCommand cmd, QObject *parent) const;
+ Core::Id vcsEditorKind(VcsCommand cmd) const;
+ VcsBase::VcsBaseEditorParameterWidget *createDiffEditor(const QString &workingDir,
+ const QStringList &files,
+ const QStringList &extraOptions);
+private:
+};
+
+} // namespace Internal
+} // namespace Cvs
+
+#endif // CVSCLIENT_H
diff --git a/src/plugins/cvs/cvscontrol.cpp b/src/plugins/cvs/cvscontrol.cpp
index 6627779327..af1b9c0b9d 100644
--- a/src/plugins/cvs/cvscontrol.cpp
+++ b/src/plugins/cvs/cvscontrol.cpp
@@ -55,7 +55,7 @@ Core::Id CvsControl::id() const
bool CvsControl::isConfigured() const
{
- const QString binary = m_plugin->settings().cvsBinaryPath;
+ const QString binary = m_plugin->settings().binaryPath();
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
@@ -81,8 +81,9 @@ bool CvsControl::supportsOperation(Operation operation) const
return rc;
}
-Core::IVersionControl::OpenSupportMode CvsControl::openSupportMode() const
+Core::IVersionControl::OpenSupportMode CvsControl::openSupportMode(const QString &fileName) const
{
+ Q_UNUSED(fileName);
return OpenOptional;
}
diff --git a/src/plugins/cvs/cvscontrol.h b/src/plugins/cvs/cvscontrol.h
index 7c07517637..9efb2831dd 100644
--- a/src/plugins/cvs/cvscontrol.h
+++ b/src/plugins/cvs/cvscontrol.h
@@ -52,7 +52,7 @@ public:
bool isConfigured() const;
bool supportsOperation(Operation operation) const;
- OpenSupportMode openSupportMode() const;
+ OpenSupportMode openSupportMode(const QString &fileName) const;
bool vcsOpen(const QString &fileName);
bool vcsAdd(const QString &fileName);
bool vcsDelete(const QString &filename);
diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp
index a431190ccc..fcca910b39 100644
--- a/src/plugins/cvs/cvsplugin.cpp
+++ b/src/plugins/cvs/cvsplugin.cpp
@@ -31,6 +31,7 @@
#include "settingspage.h"
#include "cvseditor.h"
#include "cvssubmiteditor.h"
+#include "cvsclient.h"
#include "cvsconstants.h"
#include "cvscontrol.h"
#include "checkoutwizard.h"
@@ -40,7 +41,6 @@
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <vcsbase/vcsbaseeditorparameterwidget.h>
-#include <locator/commandlocator.h>
#include <utils/synchronousprocess.h>
#include <utils/parameteraction.h>
#include <utils/qtcassert.h>
@@ -55,6 +55,7 @@
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/id.h>
#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/locator/commandlocator.h>
#include <coreplugin/vcsmanager.h>
#include <utils/stringutils.h>
#include <utils/fileutils.h>
@@ -192,6 +193,7 @@ CvsPlugin::CvsPlugin() :
CvsPlugin::~CvsPlugin()
{
+ delete m_client;
cleanCommitMessageFile();
}
@@ -234,7 +236,8 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
if (!MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.cvs/CVS.mimetypes.xml"), errorMessage))
return false;
- m_settings.fromSettings(ICore::settings());
+ m_settings.readSettings(ICore::settings());
+ m_client = new CvsClient(&m_settings);
addAutoReleasedObject(new SettingsPage);
@@ -248,7 +251,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
addAutoReleasedObject(new CheckoutWizard);
const QString prefix = QLatin1String("cvs");
- m_commandLocator = new Locator::CommandLocator("CVS", prefix, prefix);
+ m_commandLocator = new Core::CommandLocator("CVS", prefix, prefix);
addAutoReleasedObject(m_commandLocator);
// Register actions
@@ -470,7 +473,8 @@ bool CvsPlugin::submitEditorAboutToClose()
editor->promptSubmit(tr("Closing CVS Editor"),
tr("Do you want to commit the change?"),
tr("The commit message check failed. Do you want to commit the change?"),
- &newSettings.promptToSubmit, !m_submitActionTriggered);
+ newSettings.boolPointer(CvsSettings::promptOnSubmitKey),
+ !m_submitActionTriggered);
m_submitActionTriggered = false;
switch (answer) {
case VcsBaseSubmitEditor::SubmitCanceled:
@@ -497,7 +501,7 @@ bool CvsPlugin::submitEditorAboutToClose()
void CvsPlugin::diffCommitFiles(const QStringList &files)
{
- cvsDiff(m_commitRepository, files);
+ m_client->diff(m_commitRepository, files);
}
static void setDiffBaseDirectory(IEditor *editor, const QString &db)
@@ -506,114 +510,6 @@ static void setDiffBaseDirectory(IEditor *editor, const QString &db)
ve->setWorkingDirectory(db);
}
-// Collect all parameters required for a diff to be able to associate them
-// with a diff editor and re-run the diff with parameters.
-struct CvsDiffParameters
-{
- QString workingDir;
- QStringList arguments;
- QStringList files;
-};
-
-// Parameter widget controlling whitespace diff mode, associated with a parameter
-// struct.
-class CvsDiffParameterWidget : public VcsBaseEditorParameterWidget
-{
- Q_OBJECT
-
-public:
- explicit CvsDiffParameterWidget(const CvsDiffParameters &p, QWidget *parent = 0);
-
-signals:
- void reRunDiff(const Cvs::Internal::CvsDiffParameters &);
-
-public slots:
- void triggerReRun();
-
-private:
- const CvsDiffParameters m_parameters;
-};
-
-CvsDiffParameterWidget::CvsDiffParameterWidget(const CvsDiffParameters &p, QWidget *parent) :
- VcsBaseEditorParameterWidget(parent), m_parameters(p)
-{
- setBaseArguments(p.arguments);
- addToggleButton(QLatin1String("-w"), tr("Ignore Whitespace"));
- addToggleButton(QLatin1String("-B"), tr("Ignore Blank Lines"));
- connect(this, SIGNAL(argumentsChanged()),
- this, SLOT(triggerReRun()));
-}
-
-void CvsDiffParameterWidget::triggerReRun()
-{
- CvsDiffParameters effectiveParameters = m_parameters;
- effectiveParameters.arguments = arguments();
- emit reRunDiff(effectiveParameters);
-}
-
-void CvsPlugin::cvsDiff(const QString &workingDir, const QStringList &files)
-{
- CvsDiffParameters p;
- p.workingDir = workingDir;
- p.files = files;
- p.arguments = m_settings.cvsDiffOptions.split(QLatin1Char(' '), QString::SkipEmptyParts);
- cvsDiff(p);
-}
-
-void CvsPlugin::cvsDiff(const Cvs::Internal::CvsDiffParameters &p)
-{
- if (Constants::debug)
- qDebug() << Q_FUNC_INFO << p.files;
- const QString source = VcsBaseEditorWidget::getSource(p.workingDir, p.files);
- QTextCodec *codec = VcsBaseEditorWidget::getCodec(p.workingDir, p.files);
- const QString id = VcsBaseEditorWidget::getTitleId(p.workingDir, p.files);
-
- QStringList args(QLatin1String("diff"));
- args.append(p.arguments);
- args.append(p.files);
-
- // CVS returns the diff exit code (1 if files differ), which is
- // undistinguishable from a "file not found" error, unfortunately.
- const CvsResponse response =
- runCvs(p.workingDir, args, m_settings.timeOutMS(), 0, codec);
- switch (response.result) {
- case CvsResponse::NonNullExitCode:
- case CvsResponse::Ok:
- break;
- case CvsResponse::OtherError:
- return;
- }
-
- QString output = fixDiffOutput(response.stdOut);
- if (output.isEmpty())
- output = tr("The files do not differ.");
- // diff of a single file? re-use an existing view if possible to support
- // the common usage pattern of continuously changing and diffing a file
- // Show in the same editor if diff has been executed before
- const QString tag = VcsBaseEditorWidget::editorTag(DiffOutput, p.workingDir, p.files);
- if (IEditor *existingEditor = VcsBaseEditorWidget::locateEditorByTag(tag)) {
- existingEditor->document()->setContents(output.toUtf8());
- EditorManager::activateEditor(existingEditor);
- setDiffBaseDirectory(existingEditor, p.workingDir);
- return;
- }
- const QString title = QString::fromLatin1("cvs diff %1").arg(id);
- IEditor *editor = showOutputInEditor(title, output, DiffOutput, source, codec);
- VcsBaseEditorWidget::tagEditor(editor, tag);
- setDiffBaseDirectory(editor, p.workingDir);
- CvsEditor *diffEditorWidget = qobject_cast<CvsEditor*>(editor->widget());
- QTC_ASSERT(diffEditorWidget, return);
-
- // Wire up the parameter widget to trigger a re-run on
- // parameter change and 'revert' from inside the diff editor.
- CvsDiffParameterWidget *pw = new CvsDiffParameterWidget(p);
- connect(pw, SIGNAL(reRunDiff(Cvs::Internal::CvsDiffParameters)),
- this, SLOT(cvsDiff(Cvs::Internal::CvsDiffParameters)));
- connect(diffEditorWidget, SIGNAL(diffChunkReverted(VcsBase::DiffChunk)),
- pw, SLOT(triggerReRun()));
- diffEditorWidget->setConfigurationWidget(pw);
-}
-
CvsSubmitEditor *CvsPlugin::openCVSSubmitEditor(const QString &fileName)
{
IEditor *editor = EditorManager::openEditor(fileName, Constants::CVSCOMMITEDITOR_ID);
@@ -678,7 +574,7 @@ void CvsPlugin::revertAll()
QStringList args;
args << QLatin1String("update") << QLatin1String("-C") << state.topLevel();
const CvsResponse revertResponse =
- runCvs(state.topLevel(), args, m_settings.timeOutMS(),
+ runCvs(state.topLevel(), args, m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
if (revertResponse.result == CvsResponse::Ok)
cvsVersionControl()->emitRepositoryChanged(state.topLevel());
@@ -693,7 +589,7 @@ void CvsPlugin::revertCurrentFile()
QStringList args;
args << QLatin1String("diff") << state.relativeCurrentFile();
const CvsResponse diffResponse =
- runCvs(state.currentFileTopLevel(), args, m_settings.timeOutMS(), 0);
+ runCvs(state.currentFileTopLevel(), args, m_settings.timeOutMs(), 0);
switch (diffResponse.result) {
case CvsResponse::Ok:
return; // Not modified, diff exit code 0
@@ -715,7 +611,7 @@ void CvsPlugin::revertCurrentFile()
args.clear();
args << QLatin1String("update") << QLatin1String("-C") << state.relativeCurrentFile();
const CvsResponse revertResponse =
- runCvs(state.currentFileTopLevel(), args, m_settings.timeOutMS(),
+ runCvs(state.currentFileTopLevel(), args, m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
if (revertResponse.result == CvsResponse::Ok)
cvsVersionControl()->emitFilesChanged(QStringList(state.currentFile()));
@@ -726,7 +622,7 @@ void CvsPlugin::diffProject()
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return);
const QString relativeProject = state.relativeCurrentProject();
- cvsDiff(state.currentProjectTopLevel(),
+ m_client->diff(state.currentProjectTopLevel(),
relativeProject.isEmpty() ? QStringList() : QStringList(relativeProject));
}
@@ -734,7 +630,7 @@ void CvsPlugin::diffCurrentFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
- cvsDiff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
+ m_client->diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
}
void CvsPlugin::startCommitCurrentFile()
@@ -767,7 +663,7 @@ void CvsPlugin::startCommit(const QString &workingDir, const QString &file)
// where we are, so, have stdout/stderr channels merged.
QStringList args = QStringList(QLatin1String("status"));
const CvsResponse response =
- runCvs(workingDir, args, m_settings.timeOutMS(), MergeOutputChannels);
+ runCvs(workingDir, args, m_settings.timeOutMs(), MergeOutputChannels);
if (response.result != CvsResponse::Ok)
return;
// Get list of added/modified/deleted files and purge out undesired ones
@@ -815,7 +711,7 @@ bool CvsPlugin::commit(const QString &messageFile,
args << QLatin1String("-F") << messageFile;
args.append(fileList);
const CvsResponse response =
- runCvs(m_commitRepository, args, m_settings.longTimeOutMS(),
+ runCvs(m_commitRepository, args, 10 * m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
return response.result == CvsResponse::Ok ;
}
@@ -853,7 +749,7 @@ void CvsPlugin::filelog(const QString &workingDir,
args << QLatin1String("log");
args.append(file);
const CvsResponse response =
- runCvs(workingDir, args, m_settings.timeOutMS(),
+ runCvs(workingDir, args, m_settings.timeOutMs(),
SshPasswordPrompt, codec);
if (response.result != CvsResponse::Ok)
return;
@@ -887,7 +783,7 @@ bool CvsPlugin::update(const QString &topLevel, const QString &file)
if (!file.isEmpty())
args.append(file);
const CvsResponse response =
- runCvs(topLevel, args, m_settings.longTimeOutMS(),
+ runCvs(topLevel, args, 10 * m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
const bool ok = response.result == CvsResponse::Ok;
if (ok)
@@ -934,7 +830,7 @@ bool CvsPlugin::edit(const QString &topLevel, const QStringList &files)
QStringList args(QLatin1String("edit"));
args.append(files);
const CvsResponse response =
- runCvs(topLevel, args, m_settings.timeOutMS(),
+ runCvs(topLevel, args, m_settings.timeOutMs(),
ShowStdOutInLogWindow|SshPasswordPrompt);
return response.result == CvsResponse::Ok;
}
@@ -946,7 +842,7 @@ bool CvsPlugin::diffCheckModified(const QString &topLevel, const QStringList &fi
QStringList args(QLatin1String("-q"));
args << QLatin1String("diff");
args.append(files);
- const CvsResponse response = runCvs(topLevel, args, m_settings.timeOutMS(), 0);
+ const CvsResponse response = runCvs(topLevel, args, m_settings.timeOutMs(), 0);
if (response.result == CvsResponse::OtherError)
return false;
*modified = response.result == CvsResponse::NonNullExitCode;
@@ -974,7 +870,7 @@ bool CvsPlugin::unedit(const QString &topLevel, const QStringList &files)
args.append(QLatin1String("-y"));
args.append(files);
const CvsResponse response =
- runCvs(topLevel, args, m_settings.timeOutMS(),
+ runCvs(topLevel, args, m_settings.timeOutMs(),
ShowStdOutInLogWindow|SshPasswordPrompt);
return response.result == CvsResponse::Ok;
}
@@ -993,7 +889,7 @@ void CvsPlugin::annotate(const QString &workingDir, const QString &file,
args << QLatin1String("-r") << revision;
args << file;
const CvsResponse response =
- runCvs(workingDir, args, m_settings.timeOutMS(),
+ runCvs(workingDir, args, m_settings.timeOutMs(),
SshPasswordPrompt, codec);
if (response.result != CvsResponse::Ok)
return;
@@ -1022,7 +918,7 @@ bool CvsPlugin::status(const QString &topLevel, const QString &file, const QStri
if (!file.isEmpty())
args.append(file);
const CvsResponse response =
- runCvs(topLevel, args, m_settings.timeOutMS(), 0);
+ runCvs(topLevel, args, m_settings.timeOutMs(), 0);
const bool ok = response.result == CvsResponse::Ok;
if (ok)
showOutputInEditor(title, response.stdOut, OtherContent, topLevel, 0);
@@ -1047,7 +943,7 @@ void CvsPlugin::diffRepository()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
- cvsDiff(state.topLevel(), QStringList());
+ m_client->diff(state.topLevel(), QStringList());
}
void CvsPlugin::statusRepository()
@@ -1105,7 +1001,7 @@ bool CvsPlugin::describe(const QString &toplevel, const QString &file, const
QStringList args;
args << QLatin1String("log") << (QLatin1String("-r") + changeNr) << file;
const CvsResponse logResponse =
- runCvs(toplevel, args, m_settings.timeOutMS(), SshPasswordPrompt);
+ runCvs(toplevel, args, m_settings.timeOutMs(), SshPasswordPrompt);
if (logResponse.result != CvsResponse::Ok) {
*errorMessage = logResponse.message;
return false;
@@ -1115,7 +1011,7 @@ bool CvsPlugin::describe(const QString &toplevel, const QString &file, const
*errorMessage = msgLogParsingFailed();
return false;
}
- if (m_settings.describeByCommitId) {
+ if (m_settings.boolValue(CvsSettings::describeByCommitIdKey)) {
// Run a log command over the repo, filtering by the commit date
// and commit id, collecting all files touched by the commit.
const QString commitId = fileLog.front().revisions.front().commitId;
@@ -1127,7 +1023,7 @@ bool CvsPlugin::describe(const QString &toplevel, const QString &file, const
args << QLatin1String("log") << QLatin1String("-d") << (dateS + QLatin1Char('<') + nextDayS);
const CvsResponse repoLogResponse =
- runCvs(toplevel, args, m_settings.longTimeOutMS(), SshPasswordPrompt);
+ runCvs(toplevel, args, 10 * m_settings.timeOutMs(), SshPasswordPrompt);
if (repoLogResponse.result != CvsResponse::Ok) {
*errorMessage = repoLogResponse.message;
return false;
@@ -1164,7 +1060,7 @@ bool CvsPlugin::describe(const QString &repositoryPath,
QStringList args(QLatin1String("log"));
args << (QLatin1String("-r") + it->revisions.front().revision) << it->file;
const CvsResponse logResponse =
- runCvs(repositoryPath, args, m_settings.timeOutMS(), SshPasswordPrompt);
+ runCvs(repositoryPath, args, m_settings.timeOutMs(), SshPasswordPrompt);
if (logResponse.result != CvsResponse::Ok) {
*errorMessage = logResponse.message;
return false;
@@ -1177,11 +1073,11 @@ bool CvsPlugin::describe(const QString &repositoryPath,
if (!isFirstRevision(revision)) {
const QString previousRev = previousRevision(revision);
QStringList args(QLatin1String("diff"));
- args << m_settings.cvsDiffOptions << QLatin1String("-r") << previousRev
+ args << m_settings.stringValue(CvsSettings::diffOptionsKey) << QLatin1String("-r") << previousRev
<< QLatin1String("-r") << it->revisions.front().revision
<< it->file;
const CvsResponse diffResponse =
- runCvs(repositoryPath, args, m_settings.timeOutMS(), 0, codec);
+ runCvs(repositoryPath, args, m_settings.timeOutMs(), 0, codec);
switch (diffResponse.result) {
case CvsResponse::Ok:
case CvsResponse::NonNullExitCode: // Diff exit code != 0
@@ -1228,7 +1124,7 @@ CvsResponse CvsPlugin::runCvs(const QString &workingDirectory,
unsigned flags,
QTextCodec *outputCodec) const
{
- const QString executable = m_settings.cvsBinaryPath;
+ const QString executable = m_settings.binaryPath();
CvsResponse response;
if (executable.isEmpty()) {
response.result = CvsResponse::OtherError;
@@ -1280,15 +1176,14 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp
if (!e)
return 0;
s.replace(QLatin1Char(' '), QLatin1Char('_'));
- e->setSuggestedFileName(s);
+ e->baseTextDocument()->setSuggestedFileName(s);
e->setForceReadOnly(true);
if (!source.isEmpty())
e->setSource(source);
if (codec)
e->setCodec(codec);
- IEditor *ie = e->editor();
- EditorManager::activateEditor(ie);
- return ie;
+ EditorManager::activateEditor(editor);
+ return editor;
}
CvsSettings CvsPlugin::settings() const
@@ -1300,7 +1195,7 @@ void CvsPlugin::setSettings(const CvsSettings &s)
{
if (s != m_settings) {
m_settings = s;
- m_settings.toSettings(ICore::settings());
+ m_settings.writeSettings(ICore::settings());
cvsVersionControl()->emitConfigurationChanged();
}
}
@@ -1316,7 +1211,7 @@ bool CvsPlugin::vcsAdd(const QString &workingDir, const QString &rawFileName)
QStringList args;
args << QLatin1String("add") << rawFileName;
const CvsResponse response =
- runCvs(workingDir, args, m_settings.timeOutMS(),
+ runCvs(workingDir, args, m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
return response.result == CvsResponse::Ok;
}
@@ -1326,7 +1221,7 @@ bool CvsPlugin::vcsDelete(const QString &workingDir, const QString &rawFileName)
QStringList args;
args << QLatin1String("remove") << QLatin1String("-f") << rawFileName;
const CvsResponse response =
- runCvs(workingDir, args, m_settings.timeOutMS(),
+ runCvs(workingDir, args, m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
return response.result == CvsResponse::Ok;
}
@@ -1372,7 +1267,7 @@ bool CvsPlugin::managesFile(const QString &workingDirectory, const QString &file
QStringList args;
args << QLatin1String("status") << fileName;
const CvsResponse response =
- runCvs(workingDirectory, args, m_settings.timeOutMS(), SshPasswordPrompt);
+ runCvs(workingDirectory, args, m_settings.timeOutMs(), SshPasswordPrompt);
if (response.result != CvsResponse::Ok)
return false;
return !response.stdOut.contains(QLatin1String("Status: Unknown"));
@@ -1442,5 +1337,3 @@ void CvsPlugin::testLogResolving()
} // namespace Cvs
Q_EXPORT_PLUGIN(Cvs::Internal::CvsPlugin)
-
-#include "cvsplugin.moc"
diff --git a/src/plugins/cvs/cvsplugin.h b/src/plugins/cvs/cvsplugin.h
index 521e33d361..bc725da768 100644
--- a/src/plugins/cvs/cvsplugin.h
+++ b/src/plugins/cvs/cvsplugin.h
@@ -42,13 +42,13 @@ class QTextCodec;
QT_END_NAMESPACE
namespace Core {
+class CommandLocator;
class IEditorFactory;
class IVersionControl;
}
namespace Utils { class ParameterAction; }
namespace VcsBase { class VcsBaseSubmitEditor; }
-namespace Locator { class CommandLocator; }
namespace Cvs {
namespace Internal {
@@ -56,6 +56,7 @@ namespace Internal {
struct CvsDiffParameters;
class CvsSubmitEditor;
class CvsControl;
+class CvsClient;
struct CvsResponse
{
@@ -79,8 +80,6 @@ public:
bool initialize(const QStringList &arguments, QString *errorMessage);
- void cvsDiff(const QString &workingDir, const QStringList &files);
-
CvsSubmitEditor *openCVSSubmitEditor(const QString &fileName);
CvsSettings settings() const;
@@ -124,7 +123,6 @@ private slots:
void editCurrentFile();
void uneditCurrentFile();
void uneditCurrentRepository();
- void cvsDiff(const Cvs::Internal::CvsDiffParameters &p);
#ifdef WITH_TESTS
void testDiffFileResolving_data();
void testDiffFileResolving();
@@ -168,10 +166,12 @@ private:
inline CvsControl *cvsVersionControl() const;
CvsSettings m_settings;
+ CvsClient *m_client;
+
QString m_commitMessageFileName;
QString m_commitRepository;
- Locator::CommandLocator *m_commandLocator;
+ Core::CommandLocator *m_commandLocator;
Utils::ParameterAction *m_addAction;
Utils::ParameterAction *m_deleteAction;
Utils::ParameterAction *m_revertAction;
diff --git a/src/plugins/cvs/cvssettings.cpp b/src/plugins/cvs/cvssettings.cpp
index 9d2629d062..a340d9c32e 100644
--- a/src/plugins/cvs/cvssettings.cpp
+++ b/src/plugins/cvs/cvssettings.cpp
@@ -35,71 +35,34 @@
#include <QSettings>
#include <QTextStream>
-static const char groupC[] = "CVS";
-static const char commandKeyC[] = "Command";
-static const char rootC[] = "Root";
-static const char promptToSubmitKeyC[] = "PromptForSubmit";
-static const char diffOptionsKeyC[] = "DiffOptions";
-static const char describeByCommitIdKeyC[] = "DescribeByCommitId";
-static const char defaultDiffOptions[] = "-du";
-static const char timeOutKeyC[] = "TimeOut";
-
-enum { defaultTimeOutS = 30 };
-
-static QString defaultCommand()
-{
- return QLatin1String("cvs" QTC_HOST_EXE_SUFFIX);
-}
-
namespace Cvs {
namespace Internal {
-CvsSettings::CvsSettings() :
- cvsCommand(defaultCommand()),
- cvsDiffOptions(QLatin1String(defaultDiffOptions)),
- timeOutS(defaultTimeOutS),
- promptToSubmit(true),
- describeByCommitId(true)
-{
-}
+const QLatin1String CvsSettings::cvsRootKey("Root");
+const QLatin1String CvsSettings::diffOptionsKey("DiffOptions");
+const QLatin1String CvsSettings::describeByCommitIdKey("DescribeByCommitId");
+const QLatin1String CvsSettings::diffIgnoreWhiteSpaceKey("DiffIgnoreWhiteSpace");
+const QLatin1String CvsSettings::diffIgnoreBlankLinesKey("DiffIgnoreBlankLines");
-void CvsSettings::fromSettings(QSettings *settings)
+CvsSettings::CvsSettings()
{
- settings->beginGroup(QLatin1String(groupC));
- cvsCommand = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString();
- cvsBinaryPath = Utils::Environment::systemEnvironment().searchInPath(cvsCommand);
- promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
- cvsRoot = settings->value(QLatin1String(rootC), QString()).toString();
- cvsDiffOptions = settings->value(QLatin1String(diffOptionsKeyC), QLatin1String(defaultDiffOptions)).toString();
- describeByCommitId = settings->value(QLatin1String(describeByCommitIdKeyC), true).toBool();
- timeOutS = settings->value(QLatin1String(timeOutKeyC), defaultTimeOutS).toInt();
- settings->endGroup();
+ setSettingsGroup(QLatin1String("CVS"));
+ declareKey(binaryPathKey, QLatin1String("cvs" QTC_HOST_EXE_SUFFIX));
+ declareKey(cvsRootKey, QLatin1String(""));
+ declareKey(diffOptionsKey, QLatin1String("-du"));
+ declareKey(describeByCommitIdKey, true);
+ declareKey(diffIgnoreWhiteSpaceKey, false);
+ declareKey(diffIgnoreBlankLinesKey, false);
}
-void CvsSettings::toSettings(QSettings *settings) const
+int CvsSettings::timeOutMs() const
{
- settings->beginGroup(QLatin1String(groupC));
- settings->setValue(QLatin1String(commandKeyC), cvsCommand);
- settings->setValue(QLatin1String(promptToSubmitKeyC), promptToSubmit);
- settings->setValue(QLatin1String(rootC), cvsRoot);
- settings->setValue(QLatin1String(diffOptionsKeyC), cvsDiffOptions);
- settings->setValue(QLatin1String(timeOutKeyC), timeOutS);
- settings->setValue(QLatin1String(describeByCommitIdKeyC), describeByCommitId);
- settings->endGroup();
-}
-
-bool CvsSettings::equals(const CvsSettings &s) const
-{
- return promptToSubmit == s.promptToSubmit
- && describeByCommitId == s.describeByCommitId
- && cvsCommand == s.cvsCommand
- && cvsRoot == s.cvsRoot
- && timeOutS == s.timeOutS
- && cvsDiffOptions == s.cvsDiffOptions;
+ return 1000 * intValue(timeoutKey);
}
QStringList CvsSettings::addOptions(const QStringList &args) const
{
+ const QString cvsRoot = stringValue(cvsRootKey);
if (cvsRoot.isEmpty())
return args;
@@ -110,5 +73,19 @@ QStringList CvsSettings::addOptions(const QStringList &args) const
return rc;
}
+void CvsSettings::readLegacySettings(const QSettings *settings)
+{
+ const QString keyRoot = settingsGroup() + QLatin1Char('/');
+ const QString oldBinaryPathKey = keyRoot + QLatin1String("Command");
+ const QString oldPromptOnSubmitKey = keyRoot + QLatin1String("PromptForSubmit");
+ const QString oldTimeoutKey = keyRoot + QLatin1String("TimeOut");
+ if (settings->contains(oldBinaryPathKey))
+ this->setValue(binaryPathKey, settings->value(oldBinaryPathKey).toString());
+ if (settings->contains(oldPromptOnSubmitKey))
+ this->setValue(promptOnSubmitKey, settings->value(oldPromptOnSubmitKey).toBool());
+ if (settings->contains(oldTimeoutKey))
+ this->setValue(timeoutKey, settings->value(oldTimeoutKey).toInt());
+}
+
} // namespace Internal
} // namespace Cvs
diff --git a/src/plugins/cvs/cvssettings.h b/src/plugins/cvs/cvssettings.h
index b0f4ebc665..1b58ba2c68 100644
--- a/src/plugins/cvs/cvssettings.h
+++ b/src/plugins/cvs/cvssettings.h
@@ -30,44 +30,30 @@
#ifndef CVSSETTINGS_H
#define CVSSETTINGS_H
-#include <QStringList>
-
-QT_BEGIN_NAMESPACE
-class QSettings;
-QT_END_NAMESPACE
+#include <vcsbase/vcsbaseclientsettings.h>
namespace Cvs {
namespace Internal {
-struct CvsSettings
+class CvsSettings : public VcsBase::VcsBaseClientSettings
{
- CvsSettings();
+public:
+ static const QLatin1String cvsRootKey;
+ static const QLatin1String diffOptionsKey;
+ static const QLatin1String describeByCommitIdKey;
+ static const QLatin1String diffIgnoreWhiteSpaceKey;
+ static const QLatin1String diffIgnoreBlankLinesKey;
- void fromSettings(QSettings *);
- void toSettings(QSettings *) const;
+ CvsSettings();
- int timeOutMS() const { return timeOutS * 1000; }
- int longTimeOutMS() const { return timeOutS * 10000; }
+ int timeOutMs() const;
- // Add common options to the command line
QStringList addOptions(const QStringList &args) const;
- bool equals(const CvsSettings &s) const;
-
- QString cvsCommand;
- QString cvsBinaryPath;
- QString cvsRoot;
- QString cvsDiffOptions;
- int timeOutS;
- bool promptToSubmit;
- bool describeByCommitId;
+protected:
+ void readLegacySettings(const QSettings *settings);
};
-inline bool operator==(const CvsSettings &p1, const CvsSettings &p2)
- { return p1.equals(p2); }
-inline bool operator!=(const CvsSettings &p1, const CvsSettings &p2)
- { return !p1.equals(p2); }
-
} // namespace Internal
} // namespace Cvs
diff --git a/src/plugins/cvs/settingspage.cpp b/src/plugins/cvs/settingspage.cpp
index 60c41f4d1d..e6d1a16499 100644
--- a/src/plugins/cvs/settingspage.cpp
+++ b/src/plugins/cvs/settingspage.cpp
@@ -48,48 +48,30 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
{
m_ui.setupUi(this);
m_ui.commandPathChooser->setExpectedKind(PathChooser::ExistingCommand);
+ m_ui.commandPathChooser->setHistoryCompleter(QLatin1String("Cvs.Command.History"));
m_ui.commandPathChooser->setPromptDialogTitle(tr("CVS Command"));
}
CvsSettings SettingsPageWidget::settings() const
{
CvsSettings rc;
- rc.cvsCommand = m_ui.commandPathChooser->rawPath();
- rc.cvsBinaryPath = m_ui.commandPathChooser->path();
- rc.cvsRoot = m_ui.rootLineEdit->text();
- rc.cvsDiffOptions = m_ui.diffOptionsLineEdit->text();
- rc.timeOutS = m_ui.timeOutSpinBox->value();
- rc.promptToSubmit = m_ui.promptToSubmitCheckBox->isChecked();
- rc.describeByCommitId = m_ui.describeByCommitIdCheckBox->isChecked();
+ rc.setValue(CvsSettings::binaryPathKey, m_ui.commandPathChooser->rawPath());
+ rc.setValue(CvsSettings::cvsRootKey, m_ui.rootLineEdit->text());
+ rc.setValue(CvsSettings::diffOptionsKey, m_ui.diffOptionsLineEdit->text());
+ rc.setValue(CvsSettings::timeoutKey, m_ui.timeOutSpinBox->value());
+ rc.setValue(CvsSettings::promptOnSubmitKey, m_ui.promptToSubmitCheckBox->isChecked());
+ rc.setValue(CvsSettings::describeByCommitIdKey, m_ui.describeByCommitIdCheckBox->isChecked());
return rc;
}
void SettingsPageWidget::setSettings(const CvsSettings &s)
{
- m_ui.commandPathChooser->setPath(s.cvsCommand);
- m_ui.rootLineEdit->setText(s.cvsRoot);
- m_ui.diffOptionsLineEdit->setText(s.cvsDiffOptions);
- m_ui.timeOutSpinBox->setValue(s.timeOutS);
- m_ui.promptToSubmitCheckBox->setChecked(s.promptToSubmit);
- m_ui.describeByCommitIdCheckBox->setChecked(s.describeByCommitId);
-}
-
-QString SettingsPageWidget::searchKeywords() const
-{
- QString rc;
- QLatin1Char sep(' ');
- QTextStream(&rc)
- << sep << m_ui.configGroupBox->title()
- << sep << m_ui.commandLabel->text()
- << sep << m_ui.rootLabel->text()
- << sep << m_ui.miscGroupBox->title()
- << sep << m_ui.timeOutLabel->text()
- << sep << m_ui.diffOptionsLabel->text()
- << sep << m_ui.promptToSubmitCheckBox->text()
- << sep << m_ui.describeByCommitIdCheckBox->text()
- ;
- rc.remove(QLatin1Char('&'));
- return rc;
+ m_ui.commandPathChooser->setPath(s.binaryPath());
+ m_ui.rootLineEdit->setText(s.stringValue(CvsSettings::cvsRootKey));
+ m_ui.diffOptionsLineEdit->setText(s.stringValue(CvsSettings::diffOptionsKey));
+ m_ui.timeOutSpinBox->setValue(s.intValue(CvsSettings::timeoutKey));
+ m_ui.promptToSubmitCheckBox->setChecked(s.boolValue(CvsSettings::promptOnSubmitKey));
+ m_ui.describeByCommitIdCheckBox->setChecked(s.boolValue(CvsSettings::describeByCommitIdKey));
}
SettingsPage::SettingsPage()
@@ -98,12 +80,12 @@ SettingsPage::SettingsPage()
setDisplayName(tr("CVS"));
}
-QWidget *SettingsPage::createPage(QWidget *parent)
+QWidget *SettingsPage::widget()
{
- m_widget = new SettingsPageWidget(parent);
- m_widget->setSettings(CvsPlugin::instance()->settings());
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new SettingsPageWidget;
+ m_widget->setSettings(CvsPlugin::instance()->settings());
+ }
return m_widget;
}
@@ -112,7 +94,7 @@ void SettingsPage::apply()
CvsPlugin::instance()->setSettings(m_widget->settings());
}
-bool SettingsPage::matches(const QString &s) const
+void SettingsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
diff --git a/src/plugins/cvs/settingspage.h b/src/plugins/cvs/settingspage.h
index 729fa33f64..6f3c270775 100644
--- a/src/plugins/cvs/settingspage.h
+++ b/src/plugins/cvs/settingspage.h
@@ -45,7 +45,7 @@ QT_END_NAMESPACE
namespace Cvs {
namespace Internal {
-struct CvsSettings;
+class CvsSettings;
class SettingsPageWidget : public QWidget
{
@@ -57,8 +57,6 @@ public:
CvsSettings settings() const;
void setSettings(const CvsSettings &);
- QString searchKeywords() const;
-
private:
Ui::SettingsPage m_ui;
};
@@ -71,14 +69,12 @@ class SettingsPage : public VcsBase::VcsBaseOptionsPage
public:
SettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() {}
- bool matches(const QString &) const;
+ void finish();
private:
- QString m_searchKeywords;
- SettingsPageWidget *m_widget;
+ QPointer<SettingsPageWidget> m_widget;
};
} // namespace Cvs
diff --git a/src/plugins/debugger/basewindow.cpp b/src/plugins/debugger/basewindow.cpp
index b2757de790..3da6a8aa7f 100644
--- a/src/plugins/debugger/basewindow.cpp
+++ b/src/plugins/debugger/basewindow.cpp
@@ -34,7 +34,7 @@
#include <aggregation/aggregate.h>
#include <coreplugin/findplaceholder.h>
-#include <find/treeviewfind.h>
+#include <coreplugin/find/treeviewfind.h>
#include <utils/savedaction.h>
#include <QMenu>
@@ -69,7 +69,7 @@ BaseWindow::BaseWindow(QTreeView *treeView, QWidget *parent)
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(m_treeView);
- agg->add(new Find::TreeViewFind(m_treeView));
+ agg->add(new Core::TreeViewFind(m_treeView));
}
} // namespace Internal
diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp
index ec4be8cc61..cf76805536 100644
--- a/src/plugins/debugger/breakwindow.cpp
+++ b/src/plugins/debugger/breakwindow.cpp
@@ -170,6 +170,7 @@ BreakpointDialog::BreakpointDialog(BreakpointModelId id, QWidget *parent)
m_labelType->setBuddy(m_comboBoxType);
m_pathChooserFileName = new Utils::PathChooser(groupBoxBasic);
+ m_pathChooserFileName->setHistoryCompleter(QLatin1String("Debugger.Breakpoint.File.History"));
m_pathChooserFileName->setExpectedKind(Utils::PathChooser::File);
m_labelFileName = new QLabel(tr("&File name:"), groupBoxBasic);
m_labelFileName->setBuddy(m_pathChooserFileName);
diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp
index c19ad017d6..388535eba5 100644
--- a/src/plugins/debugger/cdb/cdbengine.cpp
+++ b/src/plugins/debugger/cdb/cdbengine.cpp
@@ -339,7 +339,6 @@ void addCdbOptionPages(QList<Core::IOptionsPage *> *opts)
CdbEngine::CdbEngine(const DebuggerStartParameters &sp) :
DebuggerEngine(sp),
- m_creatorExtPrefix("<qtcreatorcdbext>|"),
m_tokenPrefix("<token>"),
m_effectiveStartMode(NoStartMode),
m_accessible(false),
@@ -2554,11 +2553,12 @@ void CdbEngine::parseOutputLine(QByteArray line)
while (isCdbPrompt(line))
line.remove(0, CdbPromptLength);
// An extension notification (potentially consisting of several chunks)
- if (line.startsWith(m_creatorExtPrefix)) {
+ static const QByteArray creatorExtPrefix = "<qtcreatorcdbext>|";
+ if (line.startsWith(creatorExtPrefix)) {
// "<qtcreatorcdbext>|type_char|token|remainingChunks|serviceName|message"
- const char type = line.at(m_creatorExtPrefix.size());
+ const char type = line.at(creatorExtPrefix.size());
// integer token
- const int tokenPos = m_creatorExtPrefix.size() + 2;
+ const int tokenPos = creatorExtPrefix.size() + 2;
const int tokenEndPos = line.indexOf('|', tokenPos);
QTC_ASSERT(tokenEndPos != -1, return);
const int token = line.mid(tokenPos, tokenEndPos - tokenPos).toInt();
diff --git a/src/plugins/debugger/cdb/cdbengine.h b/src/plugins/debugger/cdb/cdbengine.h
index 3296344f9f..0030334385 100644
--- a/src/plugins/debugger/cdb/cdbengine.h
+++ b/src/plugins/debugger/cdb/cdbengine.h
@@ -251,7 +251,6 @@ private:
unsigned parseStackTrace(const GdbMi &data, bool sourceStepInto);
void mergeStartParametersSourcePathMap();
- const QByteArray m_creatorExtPrefix;
const QByteArray m_tokenPrefix;
QProcess m_process;
diff --git a/src/plugins/debugger/cdb/cdboptionspage.cpp b/src/plugins/debugger/cdb/cdboptionspage.cpp
index 5060a8ce15..e709191ecc 100644
--- a/src/plugins/debugger/cdb/cdboptionspage.cpp
+++ b/src/plugins/debugger/cdb/cdboptionspage.cpp
@@ -198,22 +198,6 @@ QStringList CdbOptionsPageWidget::breakEvents() const
return m_breakEventWidget->breakEvents();
}
-static QString stripColon(QString s)
-{
- const int lastColon = s.lastIndexOf(QLatin1Char(':'));
- if (lastColon != -1)
- s.truncate(lastColon);
- return s;
-}
-
-QString CdbOptionsPageWidget::searchKeywords() const
-{
- QString rc;
- QTextStream(&rc) << stripColon(m_ui.additionalArgumentsLabel->text());
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
// ---------- CdbOptionsPage
CdbOptionsPage::CdbOptionsPage()
@@ -230,11 +214,10 @@ CdbOptionsPage::~CdbOptionsPage()
{
}
-QWidget *CdbOptionsPage::createPage(QWidget *parent)
+QWidget *CdbOptionsPage::widget()
{
- m_widget = new CdbOptionsPageWidget(parent);
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget)
+ m_widget = new CdbOptionsPageWidget;
return m_widget;
}
@@ -248,13 +231,10 @@ void CdbOptionsPage::apply()
void CdbOptionsPage::finish()
{
- if (m_widget)
+ if (m_widget) {
m_widget->group.finish();
-}
-
-bool CdbOptionsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
+ }
}
// ---------- CdbPathsPage
@@ -266,8 +246,6 @@ public:
Utils::SavedActionSet group;
// CdbPaths m_paths;
- QString m_searchKeywords;
-
CdbSymbolPathListEditor *m_symbolPathListEditor;
Utils::PathListEditor *m_sourcePathListEditor;
@@ -280,7 +258,6 @@ CdbPathsPageWidget::CdbPathsPageWidget(QWidget *parent) :
QVBoxLayout *layout = new QVBoxLayout(this);
QString title = tr("Symbol Paths");
- m_searchKeywords.append(title);
QGroupBox* gbSymbolPath = new QGroupBox(this);
gbSymbolPath->setTitle(title);
QVBoxLayout *gbSymbolPathLayout = new QVBoxLayout(gbSymbolPath);
@@ -288,7 +265,6 @@ CdbPathsPageWidget::CdbPathsPageWidget(QWidget *parent) :
gbSymbolPathLayout->addWidget(m_symbolPathListEditor);
title = tr("Source Paths");
- m_searchKeywords.append(title);
QGroupBox* gbSourcePath = new QGroupBox(this);
gbSourcePath->setTitle(title);
QVBoxLayout *gbSourcePathLayout = new QVBoxLayout(gbSourcePath);
@@ -318,12 +294,10 @@ CdbPathsPage::~CdbPathsPage()
{
}
-QWidget *CdbPathsPage::createPage(QWidget *parent)
+QWidget *CdbPathsPage::widget()
{
if (!m_widget)
- m_widget = new CdbPathsPageWidget(parent);
- else
- m_widget->setParent(parent);
+ m_widget = new CdbPathsPageWidget;
return m_widget;
}
@@ -335,14 +309,10 @@ void CdbPathsPage::apply()
void CdbPathsPage::finish()
{
- if (m_widget)
+ if (m_widget) {
m_widget->group.finish();
-}
-
-bool CdbPathsPage::matches(const QString &searchKeyWord) const
-{
- return m_widget &&
- m_widget->m_searchKeywords.contains(searchKeyWord, Qt::CaseInsensitive);
+ delete m_widget;
+ }
}
} // namespace Internal
diff --git a/src/plugins/debugger/cdb/cdboptionspage.h b/src/plugins/debugger/cdb/cdboptionspage.h
index f26ab7cc3e..f8fd0bcc35 100644
--- a/src/plugins/debugger/cdb/cdboptionspage.h
+++ b/src/plugins/debugger/cdb/cdboptionspage.h
@@ -78,9 +78,8 @@ class CdbOptionsPageWidget : public QWidget
Q_OBJECT
public:
- explicit CdbOptionsPageWidget(QWidget *parent);
+ explicit CdbOptionsPageWidget(QWidget *parent = 0);
QStringList breakEvents() const;
- QString searchKeywords() const;
Utils::SavedActionSet group;
@@ -103,17 +102,15 @@ public:
virtual ~CdbOptionsPage();
// IOptionsPage
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &) const;
static const char *crtDbgReport;
private:
Utils::SavedActionSet group;
QPointer<CdbOptionsPageWidget> m_widget;
- QString m_searchKeywords;
};
class CdbPathsPage : public Core::IOptionsPage
@@ -127,10 +124,9 @@ public:
static CdbPathsPage *instance();
// IOptionsPage
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &searchKeyWord) const;
private:
QPointer<CdbPathsPageWidget> m_widget;
diff --git a/src/plugins/debugger/commonoptionspage.cpp b/src/plugins/debugger/commonoptionspage.cpp
index 5493450d5e..bd4fe189e3 100644
--- a/src/plugins/debugger/commonoptionspage.cpp
+++ b/src/plugins/debugger/commonoptionspage.cpp
@@ -202,29 +202,6 @@ CommonOptionsPageWidget::CommonOptionsPageWidget
}
}
-QString CommonOptionsPageWidget::searchKeyWords() const
-{
- QString rc;
- const QLatin1Char sep(' ');
- QTextStream stream(&rc);
- stream << sep << checkBoxUseAlternatingRowColors->text()
- << sep << checkBoxFontSizeFollowsEditor->text()
- << sep << checkBoxUseToolTipsInMainEditor->text()
- << sep << checkBoxListSourceFiles->text()
- << sep << checkBoxBreakpointsFullPath->text()
- << sep << checkBoxCloseBuffersOnExit->text()
- << sep << checkBoxSwitchModeOnExit->text()
- << sep << labelMaximalStackDepth->text()
- << sep << checkBoxBringToForegroundOnInterrrupt->text()
- << sep << checkBoxShowQmlObjectTree->text()
- << sep << checkBoxWarnOnReleaseBuilds->text();
- if (Utils::HostOsInfo::isWindowsHost())
- stream << sep << checkBoxRegisterForPostMortem->text();
-
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
GlobalDebuggerOptions CommonOptionsPageWidget::globalOptions() const
{
GlobalDebuggerOptions o;
@@ -274,22 +251,19 @@ void CommonOptionsPage::finish()
{
if (!m_group.isNull())
m_group->finish();
+ delete m_widget;
}
-QWidget *CommonOptionsPage::createPage(QWidget *parent)
+QWidget *CommonOptionsPage::widget()
{
if (m_group.isNull())
m_group = QSharedPointer<Utils::SavedActionSet>(new Utils::SavedActionSet);
- m_widget = new CommonOptionsPageWidget(m_group, parent);
- m_widget->setGlobalOptions(*m_options);
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeyWords();
- return m_widget;
-}
-bool CommonOptionsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ if (!m_widget) {
+ m_widget = new CommonOptionsPageWidget(m_group);
+ m_widget->setGlobalOptions(*m_options);
+ }
+ return m_widget;
}
QString CommonOptionsPage::msgSetBreakpointAtFunction(const char *function)
@@ -301,7 +275,7 @@ QString CommonOptionsPage::msgSetBreakpointAtFunctionToolTip(const char *functio
const QString &hint)
{
QString result = QLatin1String("<html><head/><body>");
- result += tr("Always add a breakpoint on the <i>%1()</i> function.").arg(QLatin1String(function));
+ result += tr("Always adds a breakpoint on the <i>%1()</i> function.").arg(QLatin1String(function));
if (!hint.isEmpty()) {
result += QLatin1String("<br>");
result += hint;
@@ -334,57 +308,43 @@ void LocalsAndExpressionsOptionsPage::apply()
void LocalsAndExpressionsOptionsPage::finish()
{
m_group.finish();
+ delete m_widget;
}
-QWidget *LocalsAndExpressionsOptionsPage::createPage(QWidget *parent)
+QWidget *LocalsAndExpressionsOptionsPage::widget()
{
- QWidget *w = new QWidget(parent);
- m_ui.setupUi(w);
+ if (!m_widget) {
+ m_widget = new QWidget;
+ m_ui.setupUi(m_widget);
- m_group.clear();
- DebuggerCore *dc = debuggerCore();
+ m_group.clear();
+ DebuggerCore *dc = debuggerCore();
- m_group.insert(dc->action(UseDebuggingHelpers),
- m_ui.debuggingHelperGroupBox);
+ m_group.insert(dc->action(UseDebuggingHelpers),
+ m_ui.debuggingHelperGroupBox);
- m_group.insert(dc->action(UseCodeModel),
- m_ui.checkBoxUseCodeModel);
- m_ui.checkBoxUseCodeModel->setToolTip(dc->action(UseCodeModel)->toolTip());
+ m_group.insert(dc->action(UseCodeModel),
+ m_ui.checkBoxUseCodeModel);
+ m_ui.checkBoxUseCodeModel->setToolTip(dc->action(UseCodeModel)->toolTip());
- m_group.insert(dc->action(ShowThreadNames),
- m_ui.checkBoxShowThreadNames);
- m_group.insert(dc->action(ShowStdNamespace), m_ui.checkBoxShowStdNamespace);
- m_group.insert(dc->action(ShowQtNamespace), m_ui.checkBoxShowQtNamespace);
+ m_group.insert(dc->action(ShowThreadNames),
+ m_ui.checkBoxShowThreadNames);
+ m_group.insert(dc->action(ShowStdNamespace), m_ui.checkBoxShowStdNamespace);
+ m_group.insert(dc->action(ShowQtNamespace), m_ui.checkBoxShowQtNamespace);
#ifndef QT_DEBUG
#if 0
- cmd = am->registerAction(m_dumpLogAction,
- DUMP_LOG, globalcontext);
- //cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+L")));
- cmd->setDefaultKeySequence(QKeySequence(QCoreApplication::translate("Debugger", "Ctrl+Shift+F11")));
- mdebug->addAction(cmd);
+ cmd = am->registerAction(m_dumpLogAction,
+ DUMP_LOG, globalcontext);
+ //cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+L")));
+ cmd->setDefaultKeySequence(QKeySequence(QCoreApplication::translate("Debugger", "Ctrl+Shift+F11")));
+ mdebug->addAction(cmd);
#endif
#endif
-
- if (m_searchKeywords.isEmpty()) {
- QTextStream(&m_searchKeywords)
- << ' ' << m_ui.debuggingHelperGroupBox->title()
- << ' ' << m_ui.checkBoxUseCodeModel->text()
- << ' ' << m_ui.checkBoxShowThreadNames->text()
- << ' ' << m_ui.checkBoxShowStdNamespace->text()
- << ' ' << m_ui.checkBoxShowQtNamespace->text();
-
- m_searchKeywords.remove(QLatin1Char('&'));
}
- return w;
-}
-
-bool LocalsAndExpressionsOptionsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ return m_widget;
}
-
} // namespace Internal
} // namespace Debugger
diff --git a/src/plugins/debugger/commonoptionspage.h b/src/plugins/debugger/commonoptionspage.h
index 508fb20240..a35bb66654 100644
--- a/src/plugins/debugger/commonoptionspage.h
+++ b/src/plugins/debugger/commonoptionspage.h
@@ -60,7 +60,6 @@ class CommonOptionsPageWidget : public QWidget
public:
explicit CommonOptionsPageWidget(const QSharedPointer<Utils::SavedActionSet> &group, QWidget *parent = 0);
- QString searchKeyWords() const;
GlobalDebuggerOptions globalOptions() const;
void setGlobalOptions(const GlobalDebuggerOptions &go);
@@ -94,10 +93,9 @@ public:
~CommonOptionsPage();
// IOptionsPage
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &s) const;
static QString msgSetBreakpointAtFunction(const char *function);
static QString msgSetBreakpointAtFunctionToolTip(const char *function,
@@ -106,7 +104,6 @@ public:
private:
const QSharedPointer<GlobalDebuggerOptions> m_options;
QSharedPointer<Utils::SavedActionSet> m_group;
- QString m_searchKeywords;
QPointer<CommonOptionsPageWidget> m_widget;
};
@@ -123,15 +120,14 @@ public:
LocalsAndExpressionsOptionsPage();
// IOptionsPage
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &s) const;
private:
+ QPointer<QWidget> m_widget;
Ui::DebuggingHelperOptionPage m_ui;
Utils::SavedActionSet m_group;
- QString m_searchKeywords;
};
} // namespace Internal
diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro
index 7798cf0bfe..03b260c6bc 100644
--- a/src/plugins/debugger/debugger.pro
+++ b/src/plugins/debugger/debugger.pro
@@ -72,7 +72,8 @@ HEADERS += \
debuggersourcepathmappingwidget.h \
memoryview.h \
localsandexpressionswindow.h \
- imageviewer.h
+ imageviewer.h \
+ simplifytype.h
SOURCES += \
basewindow.cpp \
@@ -127,7 +128,8 @@ SOURCES += \
debuggersourcepathmappingwidget.cpp \
memoryview.cpp \
localsandexpressionswindow.cpp \
- imageviewer.cpp
+ imageviewer.cpp \
+ simplifytype.cpp
FORMS += \
localsandexpressionsoptionspage.ui
@@ -151,7 +153,6 @@ include(cdb/cdb.pri)
include(gdb/gdb.pri)
include(pdb/pdb.pri)
include(lldb/lldb.pri)
-include(lldblib/lldbhost.pri)
include(qml/qml.pri)
include(namedemangler/namedemangler.pri)
diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs
index 709dc128c3..c120336821 100644
--- a/src/plugins/debugger/debugger.qbs
+++ b/src/plugins/debugger/debugger.qbs
@@ -8,7 +8,6 @@ QtcPlugin {
Depends { name: "Qt"; submodules: ["widgets", "network", "script"] }
Depends { name: "Core" }
Depends { name: "CppTools" }
- Depends { name: "Find" }
Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" }
Depends { name: "CPlusPlus" }
@@ -89,6 +88,7 @@ QtcPlugin {
"watchhandler.cpp", "watchhandler.h",
"watchutils.cpp", "watchutils.h",
"watchwindow.cpp", "watchwindow.h",
+ "simplifytype.cpp", "simplifytype.h",
]
}
@@ -109,14 +109,12 @@ QtcPlugin {
prefix: "gdb/"
files: [
"attachgdbadapter.cpp", "attachgdbadapter.h",
- "classicgdbengine.cpp",
"coregdbadapter.cpp", "coregdbadapter.h",
"gdb.qrc",
"gdbengine.cpp", "gdbengine.h",
"gdboptionspage.cpp", "gdboptionspage.h",
"gdbprocess.cpp", "gdbprocess.h",
"gdbplainengine.cpp", "gdbplainengine.h",
- "pythongdbengine.cpp",
"remotegdbserveradapter.cpp", "remotegdbserveradapter.h",
"startgdbserverdialog.cpp", "startgdbserverdialog.h",
"termgdbadapter.cpp", "termgdbadapter.h"
@@ -132,16 +130,6 @@ QtcPlugin {
}
Group {
- name: "lldblib"
- id: lldblib
- prefix: "lldblib/"
- files: [
- "ipcenginehost.cpp", "ipcenginehost.h",
- "lldbenginehost.cpp", "lldbenginehost.h"
- ]
- }
-
- Group {
name: "pdb"
prefix: "pdb/"
files: ["pdbengine.cpp", "pdbengine.h"]
@@ -247,16 +235,6 @@ QtcPlugin {
]
}
- Group {
- name: "LLDBOptions"
- condition: qbs.targetOS.contains("osx")
- files: [
- "lldblib/lldboptionspage.cpp",
- "lldblib/lldboptionspage.h",
- "lldblib/lldboptionspagewidget.ui",
- ]
- }
-
Properties {
condition: qbs.targetOS.contains("windows")
cpp.dynamicLibraries: [
diff --git a/src/plugins/debugger/debugger_dependencies.pri b/src/plugins/debugger/debugger_dependencies.pri
index 369a4fc252..d537fa70d5 100644
--- a/src/plugins/debugger/debugger_dependencies.pri
+++ b/src/plugins/debugger/debugger_dependencies.pri
@@ -8,7 +8,6 @@ QTC_LIB_DEPENDS += \
QTC_PLUGIN_DEPENDS += \
coreplugin \
cpptools \
- find \
projectexplorer \
texteditor
QTC_PLUGIN_RECOMMENDS += \
diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h
index 941e9c2431..8a8e9d3d25 100644
--- a/src/plugins/debugger/debuggerconstants.h
+++ b/src/plugins/debugger/debuggerconstants.h
@@ -190,14 +190,12 @@ enum DebuggerEngineType
PdbEngineType = 0x008,
QmlEngineType = 0x020,
QmlCppEngineType = 0x040,
- LldbLibEngineType = 0x080,
LldbEngineType = 0x100,
AllEngineTypes = GdbEngineType
| CdbEngineType
| PdbEngineType
| QmlEngineType
| QmlCppEngineType
- | LldbLibEngineType
| LldbEngineType
};
diff --git a/src/plugins/debugger/debuggercore.h b/src/plugins/debugger/debuggercore.h
index 7b056ca44e..304d317323 100644
--- a/src/plugins/debugger/debuggercore.h
+++ b/src/plugins/debugger/debuggercore.h
@@ -118,7 +118,6 @@ public:
const QVector<Section> &sections) = 0;
virtual void openMemoryEditor() = 0;
virtual void languagesChanged() = 0;
- virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages) = 0;
virtual Utils::SavedAction *action(int code) const = 0;
virtual bool boolSetting(int code) const = 0;
diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp
index 3be9af3872..afcea28a58 100644
--- a/src/plugins/debugger/debuggerdialogs.cpp
+++ b/src/plugins/debugger/debuggerdialogs.cpp
@@ -279,6 +279,7 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent)
d->debuginfoPathChooser->setToolTip(tr(
"Base path for external debug information and debug sources. "
"If empty, $SYSROOT/usr/lib/debug will be chosen."));
+ d->debuginfoPathChooser->setHistoryCompleter(QLatin1String("Debugger.DebugLocation.History"));
QFrame *line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index b6b69ff4e4..7d060f4c73 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -1045,7 +1045,7 @@ void DebuggerEnginePrivate::doFinishDebugger()
void DebuggerEnginePrivate::setRemoteSetupState(RemoteSetupState state)
{
- bool allowedTransition = true;
+ bool allowedTransition = false;
if (m_remoteSetupState == RemoteSetupNone) {
if (state == RemoteSetupRequested)
allowedTransition = true;
diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h
index 2dbb083960..539d85a8d2 100644
--- a/src/plugins/debugger/debuggerengine.h
+++ b/src/plugins/debugger/debuggerengine.h
@@ -189,6 +189,7 @@ public:
virtual void setRegisterValue(int regnr, const QString &value);
virtual void addOptionPages(QList<Core::IOptionsPage*> *) const;
virtual bool hasCapability(unsigned cap) const = 0;
+ virtual void debugLastCommand() {}
virtual bool isSynchronous() const;
virtual QByteArray qtNamespace() const;
@@ -205,6 +206,8 @@ public:
virtual void changeBreakpoint(BreakpointModelId id); // FIXME: make pure
virtual bool acceptsDebuggerCommands() const { return true; }
+ virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
+
virtual void assignValueInDebugger(const Internal::WatchData *data,
const QString &expr, const QVariant &value);
virtual void selectThread(Internal::ThreadId threadId) = 0;
@@ -347,7 +350,6 @@ protected:
virtual void executeRunToLine(const Internal::ContextData &data);
virtual void executeRunToFunction(const QString &functionName);
virtual void executeJumpToLine(const Internal::ContextData &data);
- virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
virtual void frameUp();
virtual void frameDown();
diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp
index 0f22707df8..967dd01057 100644
--- a/src/plugins/debugger/debuggeritem.cpp
+++ b/src/plugins/debugger/debuggeritem.cpp
@@ -47,6 +47,7 @@ static const char DEBUGGER_INFORMATION_DISPLAYNAME[] = "DisplayName";
static const char DEBUGGER_INFORMATION_ID[] = "Id";
static const char DEBUGGER_INFORMATION_ENGINETYPE[] = "EngineType";
static const char DEBUGGER_INFORMATION_AUTODETECTED[] = "AutoDetected";
+static const char DEBUGGER_INFORMATION_AUTODETECTION_SOURCE[] = "AutoDetectionSource";
static const char DEBUGGER_INFORMATION_ABIS[] = "Abis";
namespace Debugger {
@@ -74,6 +75,7 @@ DebuggerItem::DebuggerItem(const QVariantMap &data)
m_id = data.value(QLatin1String(DEBUGGER_INFORMATION_ID)).toString();
m_displayName = data.value(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME)).toString();
m_isAutoDetected = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), false).toBool();
+ m_autoDetectionSource = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE)).toString();
m_engineType = DebuggerEngineType(data.value(QLatin1String(DEBUGGER_INFORMATION_ENGINETYPE),
static_cast<int>(NoEngineType)).toInt());
@@ -185,6 +187,7 @@ QVariantMap DebuggerItem::toMap() const
data.insert(QLatin1String(DEBUGGER_INFORMATION_COMMAND), m_command.toUserOutput());
data.insert(QLatin1String(DEBUGGER_INFORMATION_ENGINETYPE), int(m_engineType));
data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), m_isAutoDetected);
+ data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE), m_autoDetectionSource);
data.insert(QLatin1String(DEBUGGER_INFORMATION_ABIS), abiNames());
return data;
}
@@ -209,6 +212,11 @@ void DebuggerItem::setAutoDetected(bool isAutoDetected)
m_isAutoDetected = isAutoDetected;
}
+void DebuggerItem::setAutoDetectionSource(const QString &autoDetectionSource)
+{
+ m_autoDetectionSource = autoDetectionSource;
+}
+
void DebuggerItem::setAbis(const QList<ProjectExplorer::Abi> &abis)
{
m_abis = abis;
diff --git a/src/plugins/debugger/debuggeritem.h b/src/plugins/debugger/debuggeritem.h
index 9d3a36d341..a9910b0ad5 100644
--- a/src/plugins/debugger/debuggeritem.h
+++ b/src/plugins/debugger/debuggeritem.h
@@ -79,6 +79,9 @@ public:
bool isAutoDetected() const { return m_isAutoDetected; }
void setAutoDetected(bool isAutoDetected);
+ QString autoDetectionSource() const { return m_autoDetectionSource; }
+ void setAutoDetectionSource(const QString &autoDetectionSource);
+
QList<ProjectExplorer::Abi> abis() const { return m_abis; }
void setAbis(const QList<ProjectExplorer::Abi> &abis);
void setAbi(const ProjectExplorer::Abi &abi);
@@ -99,6 +102,7 @@ private:
DebuggerEngineType m_engineType;
Utils::FileName m_command;
bool m_isAutoDetected;
+ QString m_autoDetectionSource;
QList<ProjectExplorer::Abi> m_abis;
friend class Internal::DebuggerItemConfigWidget;
diff --git a/src/plugins/debugger/debuggeroptionspage.cpp b/src/plugins/debugger/debuggeroptionspage.cpp
index 75dbaf5aee..6fe0a19135 100644
--- a/src/plugins/debugger/debuggeroptionspage.cpp
+++ b/src/plugins/debugger/debuggeroptionspage.cpp
@@ -217,63 +217,61 @@ DebuggerOptionsPage::DebuggerOptionsPage()
setCategoryIcon(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON));
}
-QWidget *DebuggerOptionsPage::createPage(QWidget *parent)
+QWidget *DebuggerOptionsPage::widget()
{
- m_configWidget = new QWidget(parent);
-
- m_addButton = new QPushButton(tr("Add"), m_configWidget);
- m_cloneButton = new QPushButton(tr("Clone"), m_configWidget);
- m_delButton = new QPushButton(tr("Remove"), m_configWidget);
-
- m_container = new DetailsWidget(m_configWidget);
- m_container->setState(DetailsWidget::NoSummary);
- m_container->setVisible(false);
-
- m_model = new DebuggerItemModel(parent);
-
- m_debuggerView = new QTreeView(m_configWidget);
- m_debuggerView->setModel(m_model);
- m_debuggerView->setUniformRowHeights(true);
- m_debuggerView->setSelectionMode(QAbstractItemView::SingleSelection);
- m_debuggerView->setSelectionBehavior(QAbstractItemView::SelectRows);
- m_debuggerView->expandAll();
-
- QHeaderView *header = m_debuggerView->header();
- header->setStretchLastSection(false);
- header->setResizeMode(0, QHeaderView::ResizeToContents);
- header->setResizeMode(1, QHeaderView::ResizeToContents);
- header->setResizeMode(2, QHeaderView::Stretch);
-
- QVBoxLayout *buttonLayout = new QVBoxLayout();
- buttonLayout->setSpacing(6);
- buttonLayout->setContentsMargins(0, 0, 0, 0);
- buttonLayout->addWidget(m_addButton);
- buttonLayout->addWidget(m_cloneButton);
- buttonLayout->addWidget(m_delButton);
- buttonLayout->addItem(new QSpacerItem(10, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
-
- QVBoxLayout *verticalLayout = new QVBoxLayout();
- verticalLayout->addWidget(m_debuggerView);
- verticalLayout->addWidget(m_container);
-
- QHBoxLayout *horizontalLayout = new QHBoxLayout(m_configWidget);
- horizontalLayout->addLayout(verticalLayout);
- horizontalLayout->addLayout(buttonLayout);
-
- connect(m_debuggerView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
- this, SLOT(debuggerSelectionChanged()));
-
- connect(m_addButton, SIGNAL(clicked()), this, SLOT(addDebugger()), Qt::QueuedConnection);
- connect(m_cloneButton, SIGNAL(clicked()), this, SLOT(cloneDebugger()), Qt::QueuedConnection);
- connect(m_delButton, SIGNAL(clicked()), this, SLOT(removeDebugger()), Qt::QueuedConnection);
-
- m_searchKeywords = tr("Debuggers");
-
- m_itemConfigWidget = new DebuggerItemConfigWidget(m_model);
- m_container->setWidget(m_itemConfigWidget);
-
- updateState();
-
+ if (!m_configWidget) {
+ m_configWidget = new QWidget;
+
+ m_addButton = new QPushButton(tr("Add"), m_configWidget);
+ m_cloneButton = new QPushButton(tr("Clone"), m_configWidget);
+ m_delButton = new QPushButton(tr("Remove"), m_configWidget);
+
+ m_container = new DetailsWidget(m_configWidget);
+ m_container->setState(DetailsWidget::NoSummary);
+ m_container->setVisible(false);
+
+ m_debuggerView = new QTreeView(m_configWidget);
+ m_model = new DebuggerItemModel(m_debuggerView);
+ m_debuggerView->setModel(m_model);
+ m_debuggerView->setUniformRowHeights(true);
+ m_debuggerView->setSelectionMode(QAbstractItemView::SingleSelection);
+ m_debuggerView->setSelectionBehavior(QAbstractItemView::SelectRows);
+ m_debuggerView->expandAll();
+
+ QHeaderView *header = m_debuggerView->header();
+ header->setStretchLastSection(false);
+ header->setResizeMode(0, QHeaderView::ResizeToContents);
+ header->setResizeMode(1, QHeaderView::ResizeToContents);
+ header->setResizeMode(2, QHeaderView::Stretch);
+
+ QVBoxLayout *buttonLayout = new QVBoxLayout();
+ buttonLayout->setSpacing(6);
+ buttonLayout->setContentsMargins(0, 0, 0, 0);
+ buttonLayout->addWidget(m_addButton);
+ buttonLayout->addWidget(m_cloneButton);
+ buttonLayout->addWidget(m_delButton);
+ buttonLayout->addItem(new QSpacerItem(10, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
+
+ QVBoxLayout *verticalLayout = new QVBoxLayout();
+ verticalLayout->addWidget(m_debuggerView);
+ verticalLayout->addWidget(m_container);
+
+ QHBoxLayout *horizontalLayout = new QHBoxLayout(m_configWidget);
+ horizontalLayout->addLayout(verticalLayout);
+ horizontalLayout->addLayout(buttonLayout);
+
+ connect(m_debuggerView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+ this, SLOT(debuggerSelectionChanged()));
+
+ connect(m_addButton, SIGNAL(clicked()), this, SLOT(addDebugger()), Qt::QueuedConnection);
+ connect(m_cloneButton, SIGNAL(clicked()), this, SLOT(cloneDebugger()), Qt::QueuedConnection);
+ connect(m_delButton, SIGNAL(clicked()), this, SLOT(removeDebugger()), Qt::QueuedConnection);
+
+ m_itemConfigWidget = new DebuggerItemConfigWidget(m_model);
+ m_container->setWidget(m_itemConfigWidget);
+
+ updateState();
+ }
return m_configWidget;
}
@@ -322,10 +320,10 @@ void DebuggerOptionsPage::removeDebugger()
void DebuggerOptionsPage::finish()
{
- // Deleted by settingsdialog.
- m_configWidget = 0;
+ delete m_configWidget;
// Children of m_configWidget.
+ m_model = 0;
m_container = 0;
m_debuggerView = 0;
m_addButton = 0;
@@ -333,11 +331,6 @@ void DebuggerOptionsPage::finish()
m_delButton = 0;
}
-bool DebuggerOptionsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
void DebuggerOptionsPage::debuggerSelectionChanged()
{
QTC_ASSERT(m_container, return);
diff --git a/src/plugins/debugger/debuggeroptionspage.h b/src/plugins/debugger/debuggeroptionspage.h
index f214bf99bf..158362d9ed 100644
--- a/src/plugins/debugger/debuggeroptionspage.h
+++ b/src/plugins/debugger/debuggeroptionspage.h
@@ -34,6 +34,7 @@
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
#include <QWidget>
QT_BEGIN_NAMESPACE
@@ -97,10 +98,9 @@ class DebuggerOptionsPage : public Core::IOptionsPage
public:
DebuggerOptionsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &) const;
private slots:
void debuggerSelectionChanged();
@@ -111,8 +111,7 @@ private slots:
void removeDebugger();
private:
- QWidget *m_configWidget;
- QString m_searchKeywords;
+ QPointer<QWidget> m_configWidget;
DebuggerItemModel *m_model;
DebuggerItemConfigWidget *m_itemConfigWidget;
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 21a3e206cf..64349b68bf 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -684,7 +684,7 @@ static bool currentTextEditorPosition(ContextData *data)
data->fileName = document->filePath();
if (document->property(Constants::OPENED_WITH_DISASSEMBLY).toBool()) {
int lineNumber = textEditor->currentLine();
- QString line = textEditor->textDocument()->contents()
+ QString line = textEditor->textDocument()->plainText()
.section(QLatin1Char('\n'), lineNumber - 1, lineNumber - 1);
data->address = DisassemblerLine::addressFromDisassemblyLine(line);
} else {
@@ -847,14 +847,6 @@ public slots:
}
}
- void synchronizeWatchers()
- {
- for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
- if (DebuggerEngine *engine = m_snapshotHandler->at(i))
- engine->watchHandler()->updateWatchers();
- }
- }
-
void editorOpened(Core::IEditor *editor);
void updateBreakMenuItem(Core::IEditor *editor);
void setBusyCursor(bool busy);
@@ -931,7 +923,6 @@ public slots:
void aboutToUnloadSession();
void aboutToSaveSession();
- void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
void coreShutdown();
#ifdef WITH_TESTS
@@ -1026,7 +1017,6 @@ public slots:
void handleExecJumpToLine()
{
- //removeTooltip();
currentEngine()->resetLocation();
ContextData data;
if (currentTextEditorPosition(&data))
@@ -1035,7 +1025,6 @@ public slots:
void handleExecRunToLine()
{
- //removeTooltip();
currentEngine()->resetLocation();
ContextData data;
if (currentTextEditorPosition(&data))
@@ -1843,7 +1832,7 @@ void DebuggerPluginPrivate::requestContextMenu(ITextEditor *editor,
ITextEditorDocument *document = editor->textDocument();
args.fileName = document->filePath();
if (document->property(Constants::OPENED_WITH_DISASSEMBLY).toBool()) {
- QString line = document->contents()
+ QString line = document->plainText()
.section(QLatin1Char('\n'), lineNumber - 1, lineNumber - 1);
BreakpointResponse needle;
needle.type = BreakpointByAddress;
@@ -1956,7 +1945,7 @@ void DebuggerPluginPrivate::toggleBreakpoint()
QTC_ASSERT(textEditor, return);
const int lineNumber = textEditor->currentLine();
if (textEditor->property(Constants::OPENED_WITH_DISASSEMBLY).toBool()) {
- QString line = textEditor->textDocument()->contents()
+ QString line = textEditor->textDocument()->plainText()
.section(QLatin1Char('\n'), lineNumber - 1, lineNumber - 1);
quint64 address = DisassemblerLine::addressFromDisassemblyLine(line);
toggleBreakpointByAddress(address);
@@ -2013,7 +2002,7 @@ void DebuggerPluginPrivate::requestMark(ITextEditor *editor,
return;
if (editor->property("DisassemblerView").toBool()) {
- QString line = editor->textDocument()->contents()
+ QString line = editor->textDocument()->plainText()
.section(QLatin1Char('\n'), lineNumber - 1, lineNumber - 1);
quint64 address = DisassemblerLine::addressFromDisassemblyLine(line);
toggleBreakpointByAddress(address);
@@ -2449,14 +2438,6 @@ void DebuggerPluginPrivate::aboutToSaveSession()
m_breakHandler->saveSessionData();
}
-void DebuggerPluginPrivate::executeDebuggerCommand(const QString &command, DebuggerLanguages languages)
-{
- if (currentEngine()->acceptsDebuggerCommands())
- currentEngine()->executeDebuggerCommand(command, languages);
- else
- showStatusMessage(tr("User commands are not accepted in the current state."));
-}
-
void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout)
{
showMessage(msg0, LogStatus);
@@ -2594,10 +2575,6 @@ static QString formatStartParameters(DebuggerStartParameters &sp)
}
str << "Sysroot: " << sp.sysRoot << '\n';
str << "Debug Source Location: " << sp.debugSourceLocation.join(QLatin1String(":")) << '\n';
- str << "Dumper libraries: " << QDir::toNativeSeparators(sp.dumperLibrary);
- foreach (const QString &dl, sp.dumperLibraryLocations)
- str << ' ' << QDir::toNativeSeparators(dl);
- str << '\n';
return rc;
}
diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp
index 086e47fae5..1897527e49 100644
--- a/src/plugins/debugger/debuggerprotocol.cpp
+++ b/src/plugins/debugger/debuggerprotocol.cpp
@@ -33,12 +33,18 @@
#include <QDateTime>
#include <QDebug>
#include <QHostAddress>
+#include <QRegExp>
#if QT_VERSION >= 0x050200
#include <QTimeZone>
#endif
#include <ctype.h>
+#define QTC_ASSERT_STRINGIFY_HELPER(x) #x
+#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x)
+#define QTC_ASSERT_STRING(cond) qDebug("SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__))
+#define QTC_ASSERT(cond, action) if (cond) {} else { QTC_ASSERT_STRING(#cond); action; } do {} while (0)
+
namespace Debugger {
namespace Internal {
diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp
index 9ccb36c5b8..224bff04a5 100644
--- a/src/plugins/debugger/debuggerrunner.cpp
+++ b/src/plugins/debugger/debuggerrunner.cpp
@@ -75,7 +75,6 @@ DebuggerEngine *createGdbEngine(const DebuggerStartParameters &sp);
DebuggerEngine *createPdbEngine(const DebuggerStartParameters &sp);
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp);
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp, QString *error);
-DebuggerEngine *createLldbLibEngine(const DebuggerStartParameters &sp);
DebuggerEngine *createLldbEngine(const DebuggerStartParameters &sp);
static const char *engineTypeName(DebuggerEngineType et)
@@ -93,8 +92,6 @@ static const char *engineTypeName(DebuggerEngineType et)
return "QML engine";
case Debugger::QmlCppEngineType:
return "QML C++ engine";
- case Debugger::LldbLibEngineType:
- return "LLDB binary engine";
case Debugger::LldbEngineType:
return "LLDB command line engine";
case Debugger::AllEngineTypes:
@@ -354,8 +351,6 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
sp.processArgs = rc->commandLineArguments();
sp.useTerminal = rc->runMode() == LocalApplicationRunConfiguration::Console;
- sp.dumperLibrary = rc->dumperLibrary();
- sp.dumperLibraryLocations = rc->dumperLibraryLocations();
if (target) {
if (const Project *project = target->project()) {
@@ -399,11 +394,6 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
}
sp.startMode = StartInternal;
-
- // FIXME: If it's not yet build this will be empty and not filled
- // when rebuild as the runConfiguration is not stored and therefore
- // cannot be used to retrieve the dumper location.
- //qDebug() << "DUMPER: " << sp.dumperLibrary << sp.dumperLibraryLocations;
sp.displayName = rc->displayName();
return sp;
@@ -518,8 +508,6 @@ DebuggerEngine *DebuggerRunControlFactory::createEngine(DebuggerEngineType et,
return createQmlEngine(sp);
case LldbEngineType:
return createLldbEngine(sp);
- case LldbLibEngineType:
- return createLldbLibEngine(sp);
case QmlCppEngineType:
return createQmlCppEngine(sp, errorMessage);
default:
diff --git a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp
index ddd2c272b6..dd5ed64d51 100644
--- a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp
+++ b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp
@@ -243,6 +243,7 @@ DebuggerSourcePathMappingWidget::DebuggerSourcePathMappingWidget(QWidget *parent
// Edit part
m_targetChooser->setExpectedKind(PathChooser::ExistingDirectory);
+ m_targetChooser->setHistoryCompleter(QLatin1String("Debugger.MappingTarget.History"));
connect(m_sourceLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(slotEditSourceFieldChanged()));
connect(m_targetChooser, SIGNAL(changed(QString)),
diff --git a/src/plugins/debugger/debuggerstartparameters.h b/src/plugins/debugger/debuggerstartparameters.h
index 935fe9153f..17dc02a7b6 100644
--- a/src/plugins/debugger/debuggerstartparameters.h
+++ b/src/plugins/debugger/debuggerstartparameters.h
@@ -134,9 +134,7 @@ public:
bool useContinueInsteadOfRun; // if connected to a hw debugger run is not possible but continue is used
QByteArray commandsAfterConnect; // additional commands to post after connection to debug target
- QString dumperLibrary;
QStringList solibSearchPath;
- QStringList dumperLibraryLocations;
DebuggerStartMode startMode;
DebuggerCloseMode closeMode;
diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp
index 6748ff9fe1..2fec392687 100644
--- a/src/plugins/debugger/disassembleragent.cpp
+++ b/src/plugins/debugger/disassembleragent.cpp
@@ -192,7 +192,7 @@ void DisassemblerAgent::resetLocation()
if (d->resetLocationScheduled) {
d->resetLocationScheduled = false;
if (d->locationMark)
- d->editor->markableInterface()->removeMark(d->locationMark);
+ d->editor->textDocument()->markableInterface()->removeMark(d->locationMark);
}
}
@@ -346,14 +346,14 @@ void DisassemblerAgent::updateLocationMarker()
int lineNumber = contents.lineForAddress(d->location.address());
if (d->location.needsMarker()) {
if (d->locationMark)
- d->editor->markableInterface()->removeMark(d->locationMark);
+ d->editor->textDocument()->markableInterface()->removeMark(d->locationMark);
delete d->locationMark;
d->locationMark = 0;
if (lineNumber) {
d->locationMark = new ITextMark(lineNumber);
d->locationMark->setIcon(debuggerCore()->locationMarkIcon());
d->locationMark->setPriority(TextEditor::ITextMark::HighPriority);
- d->editor->markableInterface()->addMark(d->locationMark);
+ d->editor->textDocument()->markableInterface()->addMark(d->locationMark);
}
}
@@ -379,7 +379,7 @@ void DisassemblerAgent::updateBreakpointMarkers()
const DisassemblerLines contents = d->contentsAtCurrentLocation();
foreach (TextEditor::ITextMark *marker, d->breakpointMarks)
- d->editor->markableInterface()->removeMark(marker);
+ d->editor->textDocument()->markableInterface()->removeMark(marker);
qDeleteAll(d->breakpointMarks);
d->breakpointMarks.clear();
foreach (BreakpointModelId id, ids) {
@@ -393,7 +393,7 @@ void DisassemblerAgent::updateBreakpointMarkers()
marker->setIcon(handler->icon(id));
marker->setPriority(ITextMark::NormalPriority);
d->breakpointMarks.append(marker);
- d->editor->markableInterface()->addMark(marker);
+ d->editor->textDocument()->markableInterface()->addMark(marker);
}
}
diff --git a/src/plugins/debugger/dumper.pro b/src/plugins/debugger/dumper.pro
deleted file mode 100644
index 80898b06b5..0000000000
--- a/src/plugins/debugger/dumper.pro
+++ /dev/null
@@ -1,24 +0,0 @@
-# This is a compile check for the dumpers only. Don't install the library!
-
-include(../../../qtcreator.pri)
-
-TEMPLATE = lib
-TARGET = DebuggingHelper
-DESTDIR = $$IDE_LIBRARY_PATH # /tmp would be better in some respect ...
-
-linux-* {
-CONFIG -= release
-CONFIG += debug
-# The following line works around a linker issue with gcc 4.1.2
-QMAKE_CXXFLAGS *= -O2
-}
-
-true {
- QT = core
-} else {
- DEFINES += USE_QT_GUI=1
- QT = core gui
-}
-
-SOURCES += ../../../share/qtcreator/debugger/dumper.cpp
-
diff --git a/src/plugins/debugger/gdb/attachgdbadapter.cpp b/src/plugins/debugger/gdb/attachgdbadapter.cpp
index 038aa5618c..1291689219 100644
--- a/src/plugins/debugger/gdb/attachgdbadapter.cpp
+++ b/src/plugins/debugger/gdb/attachgdbadapter.cpp
@@ -97,7 +97,7 @@ void GdbAttachEngine::handleAttach(const GdbResponse &response)
break;
case GdbResultError:
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
- notifyInferiorSetupFailed(DumperHelper::msgPtraceError(startParameters().startMode));
+ notifyInferiorSetupFailed(msgPtraceError(startParameters().startMode));
break;
}
// if msg != "ptrace: ..." fall through
diff --git a/src/plugins/debugger/gdb/attachgdbadapter.h b/src/plugins/debugger/gdb/attachgdbadapter.h
index ca900b0650..9a5db0dff3 100644
--- a/src/plugins/debugger/gdb/attachgdbadapter.h
+++ b/src/plugins/debugger/gdb/attachgdbadapter.h
@@ -50,8 +50,6 @@ public:
explicit GdbAttachEngine(const DebuggerStartParameters &startParameters);
private:
- DumperHandling dumperHandling() const { return DumperLoadedByGdb; }
-
void setupEngine();
void setupInferior();
void runEngine();
diff --git a/src/plugins/debugger/gdb/classicgdbengine.cpp b/src/plugins/debugger/gdb/classicgdbengine.cpp
deleted file mode 100644
index 518faf29fc..0000000000
--- a/src/plugins/debugger/gdb/classicgdbengine.cpp
+++ /dev/null
@@ -1,1535 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "gdbengine.h"
-
-#include <debugger/debuggeractions.h>
-#include <debugger/debuggercore.h>
-#include <debugger/debuggerprotocol.h>
-#include <debugger/debuggerstartparameters.h>
-#include <debugger/debuggerstringutils.h>
-#include <debugger/sourceutils.h>
-#include <debugger/stackhandler.h>
-
-#include <coreplugin/icore.h>
-#include <projectexplorer/projectexplorerconstants.h>
-#include <qtsupport/qtsupportconstants.h>
-#include <utils/qtcassert.h>
-#include <utils/savedaction.h>
-#include <QFileInfo>
-#include <QMessageBox>
-#include <QPushButton>
-
-#if !defined(Q_OS_WIN)
-#include <dlfcn.h>
-#endif
-
-#include <cctype>
-
-#define PRECONDITION QTC_CHECK(!hasPython())
-
-#define CB(callback) &GdbEngine::callback, STRINGIFY(callback)
-
-enum {
- debugPending = 0,
- debugSubItem = 0,
- debug = 0
-};
-
-namespace Debugger {
-namespace Internal {
-
-// ----------------- QtDumperHelper::TypeData
-DumperHelper::TypeData::TypeData() :
- type(UnknownType),
- isTemplate(false)
-{
-}
-
-void DumperHelper::TypeData::clear()
-{
- isTemplate = false;
- type = UnknownType;
- tmplate.clear();
- inner.clear();
-}
-
-// ----------------- QtDumperHelper
-DumperHelper::DumperHelper() :
- m_qtVersion(0),
- m_dumperVersion(1.0)
-{
- qFill(m_specialSizes, m_specialSizes + SpecialSizeCount, 0);
- setQClassPrefixes(QByteArray());
-}
-
-void DumperHelper::clear()
-{
- m_nameTypeMap.clear();
- m_qtVersion = 0;
- m_dumperVersion = 1.0;
- m_qtNamespace.clear();
- m_sizeCache.clear();
- qFill(m_specialSizes, m_specialSizes + SpecialSizeCount, 0);
- m_expressionCache.clear();
- setQClassPrefixes(QByteArray());
-}
-
-QString DumperHelper::msgDumperOutdated(double requiredVersion, double currentVersion)
-{
- return QCoreApplication::translate("QtDumperHelper",
- "Found an outdated version of the debugging helper library (%1); "
- "version %2 is required.").
- arg(currentVersion).arg(requiredVersion);
-}
-
-QString DumperHelper::msgPtraceError(DebuggerStartMode sm)
-{
- if (sm == StartInternal) {
- return QCoreApplication::translate("QtDumperHelper",
- "ptrace: Operation not permitted.\n\n"
- "Could not attach to the process. "
- "Make sure no other debugger traces this process.\n"
- "Check the settings of\n"
- "/proc/sys/kernel/yama/ptrace_scope\n"
- "For more details, see /etc/sysctl.d/10-ptrace.conf\n");
- }
- return QCoreApplication::translate("QtDumperHelper",
- "ptrace: Operation not permitted.\n\n"
- "Could not attach to the process. "
- "Make sure no other debugger traces this process.\n"
- "If your uid matches the uid\n"
- "of the target process, check the settings of\n"
- "/proc/sys/kernel/yama/ptrace_scope\n"
- "For more details, see /etc/sysctl.d/10-ptrace.conf\n");
-}
-
-static inline void formatQtVersion(int v, QTextStream &str)
-{
- str << ((v >> 16) & 0xFF) << '.' << ((v >> 8) & 0xFF) << '.' << (v & 0xFF);
-}
-
-QString DumperHelper::toString(bool debug) const
-{
- if (debug) {
- QString rc;
- QTextStream str(&rc);
- str << "version=";
- formatQtVersion(m_qtVersion, str);
- str << "dumperversion='" << m_dumperVersion << "' namespace='" << m_qtNamespace << "'," << m_nameTypeMap.size() << " known types <type enum>: ";
- const NameTypeMap::const_iterator cend = m_nameTypeMap.constEnd();
- for (NameTypeMap::const_iterator it = m_nameTypeMap.constBegin(); it != cend; ++it) {
- str <<",[" << it.key() << ',' << it.value() << ']';
- }
- str << "\nSpecial size: ";
- for (int i = 0; i < SpecialSizeCount; i++)
- str << ' ' << m_specialSizes[i];
- str << "\nSize cache: ";
- const SizeCache::const_iterator scend = m_sizeCache.constEnd();
- for (SizeCache::const_iterator it = m_sizeCache.constBegin(); it != scend; ++it) {
- str << ' ' << it.key() << '=' << it.value() << '\n';
- }
- str << "\nExpression cache: (" << m_expressionCache.size() << ")\n";
- const ExpressionCache::const_iterator excend = m_expressionCache.constEnd();
- for (ExpressionCache::const_iterator it = m_expressionCache.constBegin(); it != excend; ++it)
- str << " " << it.key() << ' ' << it.value() << '\n';
- return rc;
- }
- const QString nameSpace = m_qtNamespace.isEmpty()
- ? QCoreApplication::translate("QtDumperHelper", "<none>") : QLatin1String(m_qtNamespace);
- return QCoreApplication::translate("QtDumperHelper",
- "%n known types, Qt version: %1, Qt namespace: %2 Dumper version: %3",
- 0, QCoreApplication::CodecForTr,
- m_nameTypeMap.size()).arg(QLatin1String(qtVersionString()), nameSpace).arg(m_dumperVersion);
-}
-
-DumperHelper::Type DumperHelper::simpleType(const QByteArray &simpleType) const
-{
- return m_nameTypeMap.value(simpleType, UnknownType);
-}
-
-int DumperHelper::qtVersion() const
-{
- return m_qtVersion;
-}
-
-QByteArray DumperHelper::qtNamespace() const
-{
- return m_qtNamespace;
-}
-
-int DumperHelper::typeCount() const
-{
- return m_nameTypeMap.size();
-}
-
-// Look up unnamespaced 'std' types.
-static DumperHelper::Type stdType(const QByteArray &type)
-{
- if (type == "vector")
- return DumperHelper::StdVectorType;
- if (type == "deque")
- return DumperHelper::StdDequeType;
- if (type == "set")
- return DumperHelper::StdSetType;
- if (type == "stack")
- return DumperHelper::StdStackType;
- if (type == "map")
- return DumperHelper::StdMapType;
- if (type == "basic_string")
- return DumperHelper::StdStringType;
- return DumperHelper::UnknownType;
-}
-
-static DumperHelper::Type specialType(QByteArray type)
-{
- // Std classes.
- if (type.startsWith("std::"))
- return stdType(type.mid(5));
-
- // Strip namespace
- // FIXME: that's not a good idea as it makes all namespaces equal.
- const int namespaceIndex = type.lastIndexOf("::");
- if (namespaceIndex == -1) {
- // None ... check for std..
- const DumperHelper::Type sType = stdType(type);
- if (sType != DumperHelper::UnknownType)
- return sType;
- } else {
- type = type.mid(namespaceIndex + 2);
- }
-
- if (type == "QAbstractItem")
- return DumperHelper::QAbstractItemType;
- if (type == "QMap")
- return DumperHelper::QMapType;
- if (type == "QMapNode")
- return DumperHelper::QMapNodeType;
- if (type == "QMultiMap")
- return DumperHelper::QMultiMapType;
- if (type == "QObject")
- return DumperHelper::QObjectType;
- if (type == "QObjectSignal")
- return DumperHelper::QObjectSignalType;
- if (type == "QObjectSlot")
- return DumperHelper::QObjectSlotType;
- if (type == "QStack")
- return DumperHelper::QStackType;
- if (type == "QVector")
- return DumperHelper::QVectorType;
- if (type == "QWidget")
- return DumperHelper::QWidgetType;
- return DumperHelper::UnknownType;
-}
-
-QByteArray DumperHelper::qtVersionString() const
-{
- QString rc;
- QTextStream str(&rc);
- formatQtVersion(m_qtVersion, str);
- return rc.toLatin1();
-}
-
-// Parse a list of types.
-typedef QList<QByteArray> QByteArrayList;
-
-static QByteArray qClassName(const QByteArray &qtNamespace, const char *className)
-{
- if (qtNamespace.isEmpty())
- return className;
- QByteArray rc = qtNamespace;
- rc += "::";
- rc += className;
- return rc;
-}
-
-static double getDumperVersion(const GdbMi &contents)
-{
- const GdbMi dumperVersionG = contents["dumperversion"];
- if (dumperVersionG.type() != GdbMi::Invalid) {
- bool ok;
- const double v = QString::fromLatin1(dumperVersionG.data()).toDouble(&ok);
- if (ok)
- return v;
- }
- return 1.0;
-}
-
-
-void DumperHelper::setQClassPrefixes(const QByteArray &qNamespace)
-{
- // Prefixes with namespaces
- m_qPointerPrefix = qClassName(qNamespace, "QPointer");
- m_qSharedPointerPrefix = qClassName(qNamespace, "QSharedPointer");
- m_qSharedDataPointerPrefix = qClassName(qNamespace, "QSharedDataPointer");
- m_qWeakPointerPrefix = qClassName(qNamespace, "QWeakPointer");
- m_qListPrefix = qClassName(qNamespace, "QList");
- m_qLinkedListPrefix = qClassName(qNamespace, "QLinkedList");
- m_qVectorPrefix = qClassName(qNamespace, "QVector");
- m_qQueuePrefix = qClassName(qNamespace, "QQueue");
-}
-
-bool DumperHelper::parseQuery(const GdbMi &contents)
-{
- clear();
- if (debug > 1)
- qDebug() << "parseQuery" << contents.toString(true, 2);
-
- // Common info, dumper version, etc
- QByteArray ns = contents["namespace"].data();
- setQtNamespace(ns);
- int qtv = 0;
- const GdbMi qtversion = contents["qtversion"];
- if (qtversion.children().size() == 3) {
- qtv = (qtversion.childAt(0).toInt() << 16)
- + (qtversion.childAt(1).toInt() << 8)
- + qtversion.childAt(2).toInt();
- }
- m_qtVersion = qtv;
- // Get list of helpers
- QByteArrayList availableSimpleDebuggingHelpers;
- foreach (const GdbMi &item, contents["dumpers"].children())
- availableSimpleDebuggingHelpers.append(item.data());
-
- // Parse types
- m_nameTypeMap.clear();
- foreach (const QByteArray &type, availableSimpleDebuggingHelpers) {
- const Type t = specialType(type);
- m_nameTypeMap.insert(type, t != UnknownType ? t : SupportedType);
- }
-
- m_dumperVersion = getDumperVersion(contents);
- // Parse sizes
- foreach (const GdbMi &sizesList, contents["sizes"].children()) {
- const int childCount = sizesList.childCount();
- if (childCount > 1) {
- const int size = sizesList.childAt(0).toInt();
- for (int c = 1; c < childCount; c++)
- addSize(sizesList.childAt(c).data(), size);
- }
- }
- // Parse expressions
- foreach (const GdbMi &exprList, contents["expressions"].children())
- if (exprList.childCount() == 2)
- m_expressionCache.insert(exprList.childAt(0).data(),
- exprList.childAt(1).data());
- return true;
-}
-
-void DumperHelper::addSize(const QByteArray &name, int size)
-{
- // Special interest cases
- if (name == "char*") {
- m_specialSizes[PointerSize] = size;
- return;
- }
- const SpecialSizeType st = specialSizeType(name);
- if (st != SpecialSizeCount) {
- m_specialSizes[st] = size;
- return;
- }
- do {
- // CDB helpers
- if (name == "std::string") {
- m_sizeCache.insert("std::basic_string<char,std::char_traits<char>,std::allocator<char> >", size);
- m_sizeCache.insert("basic_string<char,char_traits<char>,allocator<char> >", size);
- break;
- }
- if (name == "std::wstring") {
- m_sizeCache.insert("basic_string<unsigned short,char_traits<unsignedshort>,allocator<unsignedshort> >", size);
- m_sizeCache.insert("std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >", size);
- break;
- }
- } while (false);
- m_sizeCache.insert(name, size);
-}
-
-DumperHelper::Type DumperHelper::type(const QByteArray &typeName) const
-{
- const DumperHelper::TypeData td = typeData(typeName);
- return td.type;
-}
-
-static bool extractTemplate(const QByteArray &type, QByteArray *tmplate, QByteArray *inner)
-{
- // Input "Template<Inner1,Inner2,...>::Foo" will return "Template::Foo" in
- // 'tmplate' and "Inner1@Inner2@..." etc in 'inner'. Result indicates
- // whether parsing was successful
- // Gdb inserts a blank after each comma which we would like to avoid
- tmplate->clear();
- inner->clear();
- if (!type.contains('<'))
- return false;
- int level = 0;
- bool skipSpace = false;
- const int size = type.size();
-
- for (int i = 0; i != size; ++i) {
- const char c = type.at(i);
- switch (c) {
- case '<':
- *(level == 0 ? tmplate : inner) += c;
- ++level;
- break;
- case '>':
- --level;
- *(level == 0 ? tmplate : inner) += c;
- break;
- case ',':
- *inner += (level == 1) ? '@' : ',';
- skipSpace = true;
- break;
- default:
- if (!skipSpace || c != ' ') {
- *(level == 0 ? tmplate : inner) += c;
- skipSpace = false;
- }
- break;
- }
- }
- *tmplate = tmplate->trimmed();
- tmplate->replace("<>", "");
- tmplate->replace("'", ""); // Sometimes 'std::vector' is reported, with quotes.
- *inner = inner->trimmed();
- // qDebug() << "EXTRACT TEMPLATE: " << *tmplate << *inner << " FROM " << type;
- return !inner->isEmpty();
-}
-
-DumperHelper::TypeData DumperHelper::typeData(const QByteArray &typeName) const
-{
- TypeData td;
- td.type = UnknownType;
- const Type st = simpleType(typeName);
- if (st != UnknownType) {
- td.isTemplate = false;
- td.type = st;
- return td;
- }
- // Try template
- td.isTemplate = extractTemplate(typeName, &td.tmplate, &td.inner);
- if (!td.isTemplate)
- return td;
- // Check the template type QMap<X,Y> -> 'QMap'
- td.type = simpleType(td.tmplate);
- return td;
-}
-
-static QByteArray sizeofTypeExpression(const QByteArray &type)
-{
- if (type.endsWith('*'))
- return "sizeof(void*)";
- if (type.endsWith('>'))
- return "sizeof(" + type + ')';
- return "sizeof(" + gdbQuoteTypes(type) + ')';
-}
-
-// Format an expression to have the debugger query the
-// size. Use size cache if possible
-QByteArray DumperHelper::evaluationSizeofTypeExpression(const QByteArray &typeName) const
-{
- // Look up special size types
- const SpecialSizeType st = specialSizeType(typeName);
- if (st != SpecialSizeCount) {
- if (const int size = m_specialSizes[st])
- return QByteArray::number(size);
- }
- // Look up size cache
- const SizeCache::const_iterator sit = m_sizeCache.constFind(typeName);
- if (sit != m_sizeCache.constEnd())
- return QByteArray::number(sit.value());
- // Finally have the debugger evaluate
- return sizeofTypeExpression(typeName);
-}
-
-DumperHelper::SpecialSizeType DumperHelper::specialSizeType(const QByteArray &typeName) const
-{
- if (isPointerType(typeName))
- return PointerSize;
- if (typeName == "int")
- return IntSize;
- if (typeName.startsWith("std::allocator"))
- return StdAllocatorSize;
- if (typeName.startsWith(m_qPointerPrefix))
- return QPointerSize;
- if (typeName.startsWith(m_qSharedPointerPrefix))
- return QSharedPointerSize;
- if (typeName.startsWith(m_qSharedDataPointerPrefix))
- return QSharedDataPointerSize;
- if (typeName.startsWith(m_qWeakPointerPrefix))
- return QWeakPointerSize;
- if (typeName.startsWith(m_qListPrefix))
- return QListSize;
- if (typeName.startsWith(m_qLinkedListPrefix))
- return QLinkedListSize;
- if (typeName.startsWith(m_qVectorPrefix))
- return QVectorSize;
- if (typeName.startsWith(m_qQueuePrefix))
- return QQueueSize;
- return SpecialSizeCount;
-}
-
-static inline bool isInteger(const QByteArray &n)
-{
- const int size = n.size();
- if (!size)
- return false;
- for (int i = 0; i < size; i++)
- if (!std::isdigit(n.at(i)))
- return false;
- return true;
-}
-
-// Return debugger expression to get the offset of a map node.
-static inline QByteArray qMapNodeValueOffsetExpression(const QByteArray &type)
-{
- return "(size_t)&(('" + type + "'*)0)->value";
-}
-
-void DumperHelper::evaluationParameters(const WatchData &data,
- const TypeData &td, QByteArray *inBuffer, QByteArrayList *extraArgsIn) const
-{
- enum { maxExtraArgCount = 4 };
-
- QByteArrayList &extraArgs = *extraArgsIn;
-
- // See extractTemplate for parameters
- QByteArrayList inners = td.inner.split('@');
- if (inners.at(0).isEmpty())
- inners.clear();
- for (int i = 0; i != inners.size(); ++i)
- inners[i] = inners[i].simplified();
-
- QByteArray outertype = td.isTemplate ? td.tmplate : data.type;
- // adjust the data extract
- if (outertype == m_qtNamespace + "QWidget")
- outertype = m_qtNamespace + "QObject";
-
- QByteArray inner = td.inner;
- const QByteArray zero = "0";
-
- extraArgs.clear();
-
- if (!inners.empty()) {
- // "generic" template dumpers: passing sizeof(argument)
- // gives already most information the dumpers need
- const int count = qMin(int(maxExtraArgCount), inners.size());
- for (int i = 0; i < count; i++)
- extraArgs.push_back(evaluationSizeofTypeExpression(inners.at(i)));
- }
-
- // Pad with zeros
- while (extraArgs.size() < maxExtraArgCount)
- extraArgs.push_back("0");
-
- // in rare cases we need more or less:
- switch (td.type) {
- case QAbstractItemType:
- if (data.dumperFlags.isEmpty())
- qWarning("Internal error: empty dumper state '%s'.", data.iname.constData());
- else
- inner = data.dumperFlags.mid(1);
- break;
- case QObjectSlotType:
- case QObjectSignalType: {
- // we need the number out of something like
- // iname="local.ob.slots.2" // ".deleteLater()"?
- const int pos = data.iname.lastIndexOf('.');
- const QByteArray slotNumber = data.iname.mid(pos + 1);
- QTC_CHECK(slotNumber.toInt() != -1);
- extraArgs[0] = slotNumber;
- }
- break;
- case QMapType:
- case QMultiMapType: {
- QByteArray nodetype;
- if (m_qtVersion >= 0x040500) {
- nodetype = m_qtNamespace + "QMapNode";
- nodetype += data.type.mid(outertype.size());
- } else {
- // FIXME: doesn't work for QMultiMap
- nodetype = data.type + "::Node";
- }
- //qDebug() << "OUTERTYPE: " << outertype << " NODETYPE: " << nodetype
- // << "QT VERSION" << m_qtVersion << ((4 << 16) + (5 << 8) + 0);
- extraArgs[2] = evaluationSizeofTypeExpression(nodetype);
- extraArgs[3] = qMapNodeValueOffsetExpression(nodetype);
- }
- break;
- case QMapNodeType:
- extraArgs[2] = evaluationSizeofTypeExpression(data.type);
- extraArgs[3] = qMapNodeValueOffsetExpression(data.type);
- break;
- case StdVectorType:
- //qDebug() << "EXTRACT TEMPLATE: " << outertype << inners;
- if (inners.at(0) == "bool")
- outertype = "std::vector::bool";
- break;
- case StdDequeType:
- extraArgs[1] = "0";
- break;
- case StdStackType:
- // remove 'std::allocator<...>':
- extraArgs[1] = "0";
- break;
- case StdSetType:
- // remove 'std::less<...>':
- extraArgs[1] = "0";
- // remove 'std::allocator<...>':
- extraArgs[2] = "0";
- break;
- case StdMapType: {
- // We need the offset of the second item in the value pair.
- // We read the type of the pair from the allocator argument because
- // that gets the constness "right" (in the sense that gdb/cdb can
- // read it back: "std::allocator<std::pair<Key,Value> >"
- // -> "std::pair<Key,Value>". Different debuggers have varying
- // amounts of terminating blanks...
- extraArgs[2].clear();
- extraArgs[3] = "0";
- QByteArray pairType = inners.at(3);
- int bracketPos = pairType.indexOf('<');
- if (bracketPos != -1)
- pairType.remove(0, bracketPos + 1);
- // We don't want the comparator and the allocator confuse gdb.
- const char closingBracket = '>';
- bracketPos = pairType.lastIndexOf(closingBracket);
- if (bracketPos != -1)
- bracketPos = pairType.lastIndexOf(closingBracket, bracketPos - pairType.size() - 1);
- if (bracketPos != -1)
- pairType.truncate(bracketPos + 1);
- extraArgs[2] = "(size_t)&(('";
- extraArgs[2] += pairType;
- extraArgs[2] += "'*)0)->second";
- }
- break;
- case StdStringType:
- //qDebug() << "EXTRACT TEMPLATE: " << outertype << inners;
- if (inners.at(0) == "char")
- outertype = "std::string";
- else if (inners.at(0) == "wchar_t")
- outertype = "std::wstring";
- qFill(extraArgs, zero);
- break;
- case UnknownType:
- qWarning("Unknown type encountered in %s.\n", Q_FUNC_INFO);
- break;
- case SupportedType:
- case QVectorType:
- case QStackType:
- case QObjectType:
- case QWidgetType:
- break;
- }
-
- // Look up expressions in the cache
- if (!m_expressionCache.empty()) {
- const ExpressionCache::const_iterator excCend = m_expressionCache.constEnd();
- const QByteArrayList::iterator eend = extraArgs.end();
- for (QByteArrayList::iterator it = extraArgs.begin(); it != eend; ++it) {
- QByteArray &e = *it;
- if (!e.isEmpty() && e != zero && !isInteger(e)) {
- const ExpressionCache::const_iterator eit = m_expressionCache.constFind(e);
- if (eit != excCend)
- e = eit.value();
- }
- }
- }
-
- inBuffer->clear();
- inBuffer->append(outertype);
- inBuffer->append('\0');
- inBuffer->append(data.iname);
- inBuffer->append('\0');
- inBuffer->append(data.exp);
- inBuffer->append('\0');
- inBuffer->append(inner);
- inBuffer->append('\0');
- inBuffer->append(data.iname);
- inBuffer->append('\0');
-
- if (debug)
- qDebug() << '\n' << Q_FUNC_INFO << '\n' << data.toString() << "\n-->" << outertype << td.type << extraArgs;
-}
-
-QDebug operator<<(QDebug in, const DumperHelper::TypeData &d)
-{
- QDebug nsp = in.nospace();
- nsp << " type=" << d.type << " tpl=" << d.isTemplate;
- if (d.isTemplate)
- nsp << d.tmplate << '<' << d.inner << '>';
- return in;
-}
-
-static bool isAccessSpecifier(const QByteArray &ba)
-{
- return ba == "private" || ba == "protected" || ba == "public";
-}
-
-// reads a MI-encoded item frome the consolestream
-static bool parseConsoleStream(const GdbResponse &response, GdbMi *contents)
-{
- QByteArray out = response.consoleStreamOutput;
-
- int markerPos = out.indexOf('"') + 1; // position of 'success marker'
- if (markerPos == 0 || out.at(markerPos) == 'f') { // 't' or 'f'
- // custom dumper produced no output
- return false;
- }
-
- out = out.mid(markerPos + 1);
- out = out.left(out.lastIndexOf('"'));
- // optimization: dumper output never needs real C unquoting
- out.replace('\\', "");
-
- contents->fromStringMultiple(out);
- //qDebug() << "CONTENTS" << contents->toString(true);
- return contents->isValid();
-}
-
-void GdbEngine::updateLocalsClassic()
-{
- PRECONDITION;
- //m_pendingWatchRequests = 0;
- m_pendingBreakpointRequests = 0;
- m_processedNames.clear();
-
- QByteArray level = QByteArray::number(currentFrame());
- // '2' is 'list with type and value'
- QByteArray cmd = "-stack-list-arguments 2 " + level + ' ' + level;
- postCommand(cmd, Discardable,
- CB(handleStackListArgumentsClassic));
- // '2' is 'list with type and value'
- postCommand("-stack-list-locals 2", Discardable,
- CB(handleStackListLocalsClassic)); // stage 2/2
-}
-
-static inline QString msgRetrievingWatchData(int pending)
-{
- return GdbEngine::tr("Retrieving data for watch view (%n requests pending)...", 0, pending);
-}
-
-void GdbEngine::runDirectDebuggingHelperClassic(const WatchData &data, bool dumpChildren)
-{
- Q_UNUSED(dumpChildren)
- QByteArray type = data.type;
- QByteArray cmd;
-
- if (type == "QString" || type.endsWith("::QString"))
- cmd = "qdumpqstring (&(" + data.exp + "))";
- else if (type == "QStringList" || type.endsWith("::QStringList"))
- cmd = "qdumpqstringlist (&(" + data.exp + "))";
-
- QVariant var;
- var.setValue(data);
- postCommand(cmd, Discardable, CB(handleDebuggingHelperValue3Classic), var);
-
- showStatusMessage(msgRetrievingWatchData(m_uncompleted.size()), 10000);
-}
-
-void GdbEngine::runDebuggingHelperClassic(const WatchData &data0, bool dumpChildren)
-{
- PRECONDITION;
- if (m_debuggingHelperState != DebuggingHelperAvailable) {
- runDirectDebuggingHelperClassic(data0, dumpChildren);
- return;
- }
- WatchData data = data0;
-
- // Avoid endless loops created by faulty dumpers.
- QByteArray processedName = QByteArray::number(dumpChildren) + '-' + data.iname;
- if (m_processedNames.contains(processedName)) {
- showMessage(
- _("<Breaking endless loop for " + data.iname + '>'), LogMiscInput);
- data.setAllUnneeded();
- data.setValue(_("<unavailable>"));
- data.setHasChildren(false);
- insertData(data);
- return;
- }
- m_processedNames.insert(processedName);
-
- QByteArray params;
- QList<QByteArray> extraArgs;
- const DumperHelper::TypeData td = m_dumperHelper.typeData(data0.type);
- m_dumperHelper.evaluationParameters(data, td, &params, &extraArgs);
-
- //int protocol = (data.iname.startsWith("watch") && data.type == "QImage") ? 3 : 2;
- //int protocol = data.iname.startsWith("watch") ? 3 : 2;
- const int protocol = 2;
- //int protocol = isDisplayedIName(data.iname) ? 3 : 2;
-
- QByteArray addr;
- if (data.address)
- addr = "(void*)" + data.hexAddress();
- else if (data.exp.isEmpty()) // happens e.g. for QAbstractItem
- addr = QByteArray(1, '0');
- else
- addr = "&(" + data.exp + ')';
-
- sendWatchParameters(params);
-
- QByteArray cmd = "call (void*)qDumpObjectData440("
- + QByteArray::number(protocol)
- + ",0,"
- + addr
- + ','
- + (dumpChildren ? '1' : '0');
- foreach (const QByteArray &ex, extraArgs)
- cmd += ',' + ex;
- cmd += ')';
-
- postCommand(cmd, Discardable | NonCriticalResponse);
-
- showStatusMessage(msgRetrievingWatchData(m_uncompleted.size()), 10000);
-
- // retrieve response
- postCommand("p (char*)&qDumpOutBuffer", Discardable,
- CB(handleDebuggingHelperValue2Classic), qVariantFromValue(data));
-}
-
-void GdbEngine::createGdbVariableClassic(const WatchData &data)
-{
- PRECONDITION;
- postCommand("-var-delete \"" + data.iname + '"', Discardable);
- QByteArray exp = data.exp;
- if (exp.isEmpty() && data.address)
- exp = "*(" + gdbQuoteTypes(data.type) + "*)" + data.hexAddress();
- QVariant val = QVariant::fromValue<WatchData>(data);
- postCommand("-var-create \"" + data.iname + "\" * \"" + exp + '"',
- Discardable, CB(handleVarCreate), val);
-}
-
-void GdbEngine::updateSubItemClassic(const WatchData &data0)
-{
- PRECONDITION;
- WatchData data = data0;
- if (debugSubItem)
- qDebug() << "UPDATE SUBITEM:" << data.toString();
- QTC_ASSERT(data.isValid(), return);
-
- // in any case we need the type first
- if (data.isTypeNeeded()) {
- // This should only happen if we don't have a variable yet.
- // Let's play safe, though.
- if (!data.variable.isEmpty()) {
- // Update: It does so for out-of-scope watchers.
-# if 1
- qDebug() << "FIXME: GdbEngine::updateSubItem:"
- << data.toString() << "should not happen";
-# else
- data.setType(WatchData::msgNotInScope());
- data.setValue(WatchData::msgNotInScope());
- data.setHasChildren(false);
- insertData(data);
- return;
-# endif
- }
- // The WatchVarCreate handler will receive type information
- // and re-insert a WatchData item with correct type, so
- // we will not re-enter this bit.
- // FIXME: Concurrency issues?
- createGdbVariableClassic(data);
- return;
- }
-
- // We should have a type now. This is relied upon further below.
- QTC_ASSERT(!data.type.isEmpty(), return);
-
- // A common case that can be easily solved.
- if (data.isChildrenNeeded() && isPointerType(data.type)
- && !hasDebuggingHelperForType(data.type)) {
- // We sometimes know what kind of children pointers have.
- if (debugSubItem)
- qDebug() << "IT'S A POINTER";
-
- if (debuggerCore()->boolSetting(AutoDerefPointers)) {
- // Try automatic dereferentiation
- data.exp = "(*(" + data.exp + "))";
- data.type = data.type + '.'; // FIXME: fragile HACK to avoid recursion
- if (data.value.startsWith(QLatin1String("0x")))
- data.value.insert(0, QLatin1Char('@'));
- insertData(data);
- } else {
- data.setChildrenUnneeded();
- insertData(data);
- WatchData data1;
- data1.iname = data.iname + ".*";
- data1.name = QLatin1Char('*') + data.name;
- data1.exp = "(*(" + data.exp + "))";
- data1.type = stripPointerType(data.type);
- data1.setValueNeeded();
- data1.setChildrenUnneeded();
- insertData(data1);
- }
- return;
- }
-
- if (data.isValueNeeded() && hasDebuggingHelperForType(data.type)) {
- if (debugSubItem)
- qDebug() << "UPDATE SUBITEM: CUSTOMVALUE";
- runDebuggingHelperClassic(data,
- watchHandler()->isExpandedIName(data.iname));
- return;
- }
-
-/*
- if (data.isValueNeeded() && data.exp.isEmpty()) {
- if (debugSubItem)
- qDebug() << "UPDATE SUBITEM: NO EXPRESSION?";
- data.setError("<no expression given>");
- insertData(data);
- return;
- }
-*/
-
- if (data.isValueNeeded() && data.variable.isEmpty()) {
- if (debugSubItem)
- qDebug() << "UPDATE SUBITEM: VARIABLE NEEDED FOR VALUE";
- createGdbVariableClassic(data);
- // the WatchVarCreate handler will re-insert a WatchData
- // item, with valueNeeded() set.
- return;
- }
-
- if (data.isValueNeeded()) {
- QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
- if (debugSubItem)
- qDebug() << "UPDATE SUBITEM: VALUE";
- QByteArray cmd = "-var-evaluate-expression \"" + data.iname + '"';
- postCommand(cmd, Discardable,
- CB(handleEvaluateExpressionClassic), QVariant::fromValue(data));
- return;
- }
-
- if (data.isChildrenNeeded() && hasDebuggingHelperForType(data.type)) {
- if (debugSubItem)
- qDebug() << "UPDATE SUBITEM: CUSTOMVALUE WITH CHILDREN";
- runDebuggingHelperClassic(data, true);
- return;
- }
-
- if (data.isChildrenNeeded() && data.variable.isEmpty()) {
- if (debugSubItem)
- qDebug() << "UPDATE SUBITEM: VARIABLE NEEDED FOR CHILDREN";
- createGdbVariableClassic(data);
- // the WatchVarCreate handler will re-insert a WatchData
- // item, with childrenNeeded() set.
- return;
- }
-
- if (data.isChildrenNeeded()) {
- QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
- QByteArray cmd = "-var-list-children --all-values \"" + data.variable + '"';
- postCommand(cmd, Discardable,
- CB(handleVarListChildrenClassic), QVariant::fromValue(data));
- return;
- }
-
- if (data.isHasChildrenNeeded() && hasDebuggingHelperForType(data.type)) {
- if (debugSubItem)
- qDebug() << "UPDATE SUBITEM: CUSTOMVALUE WITH CHILDREN";
- runDebuggingHelperClassic(data, watchHandler()->isExpandedIName(data.iname));
- return;
- }
-
-//#if !X
- if (data.isHasChildrenNeeded() && data.variable.isEmpty()) {
- if (debugSubItem)
- qDebug() << "UPDATE SUBITEM: VARIABLE NEEDED FOR CHILDCOUNT";
- createGdbVariableClassic(data);
- // the WatchVarCreate handler will re-insert a WatchData
- // item, with childrenNeeded() set.
- return;
- }
-//#endif
-
- if (data.isHasChildrenNeeded()) {
- QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
- QByteArray cmd = "-var-list-children --all-values \"" + data.variable + '"';
- postCommand(cmd, Discardable,
- CB(handleVarListChildrenClassic), QVariant::fromValue(data));
- return;
- }
-
- qDebug() << "FIXME: UPDATE SUBITEM:" << data.toString();
- QTC_ASSERT(false, return);
-}
-
-void GdbEngine::handleDebuggingHelperValue2Classic(const GdbResponse &response)
-{
- PRECONDITION;
- WatchData data = response.cookie.value<WatchData>();
- QTC_ASSERT(data.isValid(), return);
-
- // The real dumper might have aborted without giving any answers.
- // Remove traces of the question, too.
- if (m_cookieForToken.contains(response.token - 1)) {
- m_cookieForToken.remove(response.token - 1);
- showMessage(_("DETECTING LOST COMMAND %1").arg(response.token - 1));
- // --m_pendingWatchRequests;
- data.setError(WatchData::msgNotInScope());
- insertData(data);
- return;
- }
-
- //qDebug() << "CUSTOM VALUE RESULT:" << response.toString();
- //qDebug() << "FOR DATA:" << data.toString() << response.resultClass;
- if (response.resultClass != GdbResultDone) {
- qDebug() << "STRANGE CUSTOM DUMPER RESULT DATA:" << data.toString();
- return;
- }
-
- GdbMi contents;
- if (!parseConsoleStream(response, &contents)) {
- data.setError(WatchData::msgNotInScope());
- insertData(data);
- return;
- }
-
- data.updateType(response.data["type"]);
- data.updateDisplayedType(response.data["displaytype"]);
- QList<WatchData> list;
- parseWatchData(watchHandler()->expandedINames(), data, contents, &list);
- //for (int i = 0; i != list.size(); ++i)
- // qDebug() << "READ: " << list.at(i).toString();
- foreach (const WatchData &data, list)
- insertData(data);
-}
-
-void GdbEngine::handleDebuggingHelperValue3Classic(const GdbResponse &response)
-{
- if (response.resultClass == GdbResultDone) {
- WatchData data = response.cookie.value<WatchData>();
- QByteArray out = response.consoleStreamOutput;
- while (out.endsWith(' ') || out.endsWith('\n'))
- out.chop(1);
- QList<QByteArray> list = out.split(' ');
- if (list.isEmpty()) {
- data.setError(WatchData::msgNotInScope());
- data.setAllUnneeded();
- insertData(data);
- } else if (data.type == "QString"
- || data.type.endsWith("::QString")) {
- QList<QByteArray> list = out.split(' ');
- QString str;
- int l = out.isEmpty() ? 0 : list.size();
- for (int i = 0; i < l; ++i)
- str.append(list.at(i).toInt());
- data.setValue(QLatin1Char('"') + str + QLatin1Char('"'));
- data.setHasChildren(false);
- data.setAllUnneeded();
- insertData(data);
- } else if (data.type == "QStringList"
- || data.type.endsWith("::QStringList")) {
- if (out.isEmpty()) {
- data.setValue(tr("<0 items>"));
- data.setHasChildren(false);
- data.setAllUnneeded();
- insertData(data);
- } else {
- int l = list.size();
- //: In string list
- data.setValue(tr("<%n items>", 0, l));
- data.setHasChildren(!list.empty());
- data.setAllUnneeded();
- insertData(data);
- for (int i = 0; i < l; ++i) {
- WatchData data1;
- data1.name = _("[%1]").arg(i);
- data1.type = data.type.left(data.type.size() - 4);
- data1.iname = data.iname + '.' + QByteArray::number(i);
- const QByteArray &addressSpec = list.at(i);
- if (addressSpec.startsWith("0x"))
- data.setHexAddress(addressSpec);
- else
- data.dumperFlags = addressSpec; // Item model dumpers pull tricks
- data1.exp = "((" + gdbQuoteTypes(data1.type) + "*)" + addressSpec + ')';
- data1.setHasChildren(false);
- data1.setValueNeeded();
- QByteArray cmd = "qdumpqstring (" + data1.exp + ')';
- QVariant var;
- var.setValue(data1);
- postCommand(cmd, Discardable,
- CB(handleDebuggingHelperValue3Classic), var);
- }
- }
- } else {
- data.setError(WatchData::msgNotInScope());
- data.setAllUnneeded();
- insertData(data);
- }
- } else {
- WatchData data = response.cookie.value<WatchData>();
- data.setError(WatchData::msgNotInScope());
- data.setAllUnneeded();
- insertData(data);
- }
-}
-
-void GdbEngine::tryLoadDebuggingHelpersClassic()
-{
- if (m_forceAsyncModel)
- return;
-
- PRECONDITION;
- if (dumperHandling() == GdbEngine::DumperNotAvailable) {
- // Load at least gdb macro based dumpers.
- m_debuggingHelperState = DebuggingHelperLoadTried;
- postCommand(Utils::FileReader::fetchQrc(_(":/gdb/gdbmacros.txt")));
- return;
- }
-
- if (debugPending)
- qDebug() << "TRY LOAD CUSTOM DUMPERS";
- m_debuggingHelperState = DebuggingHelperUnavailable;
- if (!checkDebuggingHelpersClassic())
- return;
-
- m_debuggingHelperState = DebuggingHelperLoadTried;
-
- // Do not use STRINGIFY for RTLD_NOW as we really want to expand that to a number.
-#if defined(Q_OS_WIN)
- // We are using Python on Windows.
- QTC_CHECK(false);
-#elif defined(Q_OS_MAC)
- QByteArray dlopenLib = startParameters().dumperLibrary.toLocal8Bit();
- //postCommand("sharedlibrary libc"); // for malloc
- //postCommand("sharedlibrary libdl"); // for dlopen
- const QByteArray flag = QByteArray::number(RTLD_NOW);
- postCommand("call (void)dlopen(\"" + GdbMi::escapeCString(dlopenLib)
- + "\", " + flag + ")",
- CB(handleDebuggingHelperSetup));
- //postCommand("sharedlibrary " + dotEscape(dlopenLib));
-#else
- QByteArray dlopenLib = startParameters().dumperLibrary.toLocal8Bit();
- //postCommand("p dlopen");
- const QByteArray flag = QByteArray::number(RTLD_NOW);
- postCommand("sharedlibrary libc"); // for malloc
- postCommand("sharedlibrary libdl"); // for dlopen
- postCommand("call (void*)dlopen(\"" + GdbMi::escapeCString(dlopenLib)
- + "\", " + flag + ")",
- CB(handleDebuggingHelperSetup));
- // Some older systems like CentOS 4.6 prefer this:
- postCommand("call (void*)__dlopen(\"" + GdbMi::escapeCString(dlopenLib)
- + "\", " + flag + ")",
- CB(handleDebuggingHelperSetup));
- postCommand("sharedlibrary " + dotEscape(dlopenLib));
-#endif
-
- // Retrieve list of dumpable classes.
- postCommand("call (void*)qDumpObjectData440(1,0,0,0,0,0,0,0)");
- postCommand("p (char*)&qDumpOutBuffer", CB(handleQueryDebuggingHelperClassic));
-}
-
-// Called from CoreAdapter and AttachAdapter
-void GdbEngine::updateAllClassic()
-{
- PRECONDITION;
- if (debugPending)
- qDebug() << "UPDATING ALL\n";
- QTC_ASSERT(state() == InferiorUnrunnable || state() == InferiorStopOk,
- qDebug() << state());
- tryLoadDebuggingHelpersClassic();
- reloadModulesInternal();
- postCommand("-stack-list-frames", Discardable,
- CB(handleStackListFrames),
- QVariant::fromValue<StackCookie>(StackCookie(false, true)));
- stackHandler()->setCurrentIndex(0);
- if (supportsThreads())
- postCommand("-thread-list-ids", Discardable, CB(handleThreadListIds), 0);
- reloadRegisters();
- updateLocals();
-}
-
-void GdbEngine::setDebuggingHelperStateClassic(DebuggingHelperState s)
-{
- PRECONDITION;
- m_debuggingHelperState = s;
-}
-
-void GdbEngine::handleStackListArgumentsClassic(const GdbResponse &response)
-{
- PRECONDITION;
- // stage 1/2
-
- // Linux:
- // 12^done,stack-args=
- // [frame={level="0",args=[
- // {name="argc",type="int",value="1"},
- // {name="argv",type="char **",value="(char **) 0x7..."}]}]
- // Mac:
- // 78^done,stack-args=
- // {frame={level="0",args={
- // varobj=
- // {exp="this",value="0x38a2fab0",name="var21",numchild="3",
- // type="CurrentDocumentFind * const",typecode="PTR",
- // dynamic_type="",in_scope="true",block_start_addr="0x3938e946",
- // block_end_addr="0x3938eb2d"},
- // varobj=
- // {exp="before",value="@0xbfffb9f8: {d = 0x3a7f2a70}",
- // name="var22",numchild="1",type="const QString ...} }}}
- //
- // In both cases, iterating over the children of stack-args/frame/args
- // is ok.
- m_currentFunctionArgs.clear();
- if (response.resultClass == GdbResultDone) {
- const GdbMi list = response.data["stack-args"];
- const GdbMi frame = list["frame"];
- const GdbMi args = frame["args"];
- m_currentFunctionArgs = args.children();
- } else {
- // Seems to occur on "RedHat 4 based Linux" gdb 7.0.1:
- // ^error,msg="Cannot access memory at address 0x0"
- showMessage(_("UNEXPECTED RESPONSE: ") + QLatin1String(response.toString()));
- }
-}
-
-void GdbEngine::handleStackListLocalsClassic(const GdbResponse &response)
-{
- PRECONDITION;
- // stage 2/2
-
- // There could be shadowed variables
- QList<GdbMi> locals = response.data["locals"].children();
- locals += m_currentFunctionArgs;
- QMap<QByteArray, int> seen;
- // If desired, retrieve list of uninitialized variables looking at
- // the current frame. This is invoked first time after a stop from
- // handleStop1, which passes on the frame as cookie. The whole stack
- // is not known at this point.
- QStringList uninitializedVariables;
- if (debuggerCore()->action(UseCodeModel)->isChecked()) {
- const StackFrame frame =
- response.cookie.canConvert<Debugger::Internal::StackFrame>()
- ? qvariant_cast<Debugger::Internal::StackFrame>(response.cookie)
- : stackHandler()->currentFrame();
- if (frame.isUsable())
- getUninitializedVariables(debuggerCore()->cppCodeModelSnapshot(),
- frame.function, frame.file, frame.line,
- &uninitializedVariables);
- }
- WatchHandler *handler = watchHandler();
- insertData(*handler->findData("local"));
-
- foreach (const GdbMi &item, locals) {
- const WatchData data = localVariable(item, uninitializedVariables, &seen);
- if (data.isValid())
- insertData(data);
- }
-
- if (!m_resultVarName.isEmpty()) {
- WatchData rd;
- rd.iname = "return.0";
- rd.name = QLatin1String("return");
- rd.exp = m_resultVarName;
- insertData(rd);
- }
-
- handler->updateWatchers();
-}
-
-static void showQtDumperLibraryWarning(const QString &details)
-{
- QMessageBox dialog(Core::ICore::mainWindow());
- QPushButton *qtPref = dialog.addButton(DebuggerCore::tr("Open Qt Options"),
- QMessageBox::ActionRole);
- QPushButton *helperOff = dialog.addButton(DebuggerCore::tr("Turn off Helper Usage"),
- QMessageBox::ActionRole);
- QPushButton *justContinue = dialog.addButton(DebuggerCore::tr("Continue Anyway"),
- QMessageBox::AcceptRole);
- dialog.setDefaultButton(justContinue);
- dialog.setWindowTitle(DebuggerCore::tr("Debugging Helper Missing"));
- dialog.setText(DebuggerCore::tr("The debugger could not load the debugging helper library."));
- dialog.setInformativeText(DebuggerCore::tr(
- "The debugging helper is used to nicely format the values of some Qt "
- "and Standard Library data types. "
- "It must be compiled for each used Qt version separately. "
- "In the Qt Creator Build and Run preferences page, select a Qt version, "
- "expand the Details section and click Build All."));
- if (!details.isEmpty())
- dialog.setDetailedText(details);
-#if defined(Q_OS_MAC) && QT_VERSION >= 0x050000
- dialog.setWindowModality(Qt::WindowModal);
-#endif
- dialog.exec();
- if (dialog.clickedButton() == qtPref) {
- Core::ICore::showOptionsDialog(
- ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY,
- QtSupport::Constants::QTVERSION_SETTINGS_PAGE_ID);
- } else if (dialog.clickedButton() == helperOff) {
- debuggerCore()->action(UseDebuggingHelpers)->setValue(qVariantFromValue(false), false);
- }
-}
-
-bool GdbEngine::checkDebuggingHelpersClassic()
-{
- PRECONDITION;
- if (!debuggerCore()->boolSetting(UseDebuggingHelpers))
- return false;
- const QString lib = startParameters().dumperLibrary;
- if (QFileInfo(lib).exists())
- return true;
- const QStringList &locations = startParameters().dumperLibraryLocations;
- const QString loc = locations.join(QLatin1String(", "));
- const QString msg = tr("The debugging helper library was not found at %1.")
- .arg(loc);
- showMessage(msg);
- // This can happen for remote debugging.
- if (!locations.isEmpty())
- showQtDumperLibraryWarning(msg); // This might build the library.
- return QFileInfo(lib).exists();
-}
-
-void GdbEngine::handleQueryDebuggingHelperClassic(const GdbResponse &response)
-{
- const double dumperVersionRequired = 1.0;
- //qDebug() << "DATA DUMPER TRIAL:" << response.toString();
-
- GdbMi contents;
- QTC_ASSERT(parseConsoleStream(response, &contents), qDebug() << response.toString());
- const bool ok = m_dumperHelper.parseQuery(contents)
- && m_dumperHelper.typeCount();
- if (ok) {
- // Get version and sizes from dumpers. Expression cache
- // currently causes errors.
- const double dumperVersion = getDumperVersion(contents);
- if (dumperVersion < dumperVersionRequired) {
- showQtDumperLibraryWarning(
- DumperHelper::msgDumperOutdated(dumperVersionRequired, dumperVersion));
- m_debuggingHelperState = DebuggingHelperUnavailable;
- return;
- }
- m_debuggingHelperState = DebuggingHelperAvailable;
- const QString successMsg = tr("Dumper version %1, %n custom dumpers found.",
- 0, m_dumperHelper.typeCount()).arg(dumperVersion);
- showStatusMessage(successMsg);
-
- // Sanity check for Qt version of dumpers and debuggee.
- QByteArray ns = m_dumperHelper.qtNamespace();
- postCommand("-var-create A@ * '" + ns + "qVersion'()",
- CB(handleDebuggingHelperVersionCheckClassic));
- postCommand("-var-delete A@");
- } else {
- // Retry if thread has not terminated yet.
- m_debuggingHelperState = DebuggingHelperUnavailable;
- showStatusMessage(tr("Debugging helpers not found."));
- }
- //qDebug() << m_dumperHelper.toString(true);
- //qDebug() << m_availableSimpleDebuggingHelpers << "DATA DUMPERS AVAILABLE";
-}
-
-void GdbEngine::handleDebuggingHelperVersionCheckClassic(const GdbResponse &response)
-{
- if (response.resultClass == GdbResultDone) {
- QString value = _(response.data["value"].data());
- QString debuggeeQtVersion = value.section(QLatin1Char('"'), 1, 1);
- QString dumperQtVersion = QLatin1String(m_dumperHelper.qtVersionString());
- if (debuggeeQtVersion.isEmpty()) {
- showMessage(_("DUMPER VERSION CHECK SKIPPED, NO qVersion() OUTPUT IN")
- + QLatin1String(response.toString()));
- } else if (dumperQtVersion.isEmpty()) {
- showMessage(_("DUMPER VERSION CHECK SKIPPED, NO VERSION STRING"));
- } else if (dumperQtVersion != debuggeeQtVersion) {
- showMessageBox(QMessageBox::Warning,
- tr("Debugging helpers: Qt version mismatch"),
- tr("The Qt version used to build the debugging helpers (%1) "
- "does not match the Qt version used to build the debugged "
- "application (%2).\nThis might yield incorrect results.")
- .arg(dumperQtVersion).arg(debuggeeQtVersion));
- } else {
- showMessage(_("DUMPER VERSION CHECK SUCCESSFUL: ")
- + dumperQtVersion);
- }
- } else {
- showMessage(QLatin1String("DUMPER VERSION CHECK NOT COMPLETED"));
- }
-}
-
-void GdbEngine::handleVarListChildrenHelperClassic(const GdbMi &item,
- const WatchData &parent, int sortId)
-{
- //qDebug() << "VAR_LIST_CHILDREN: PARENT" << parent.toString();
- //qDebug() << "VAR_LIST_CHILDREN: ITEM" << item.toString();
- QByteArray exp = item["exp"].data();
- QByteArray name = item["name"].data();
- if (isAccessSpecifier(exp)) {
- // Suppress 'private'/'protected'/'public' level.
- WatchData data;
- data.variable = name;
- data.iname = parent.iname;
- //data.iname = data.variable;
- data.exp = parent.exp;
- data.setTypeUnneeded();
- data.setValueUnneeded();
- data.setHasChildrenUnneeded();
- data.setChildrenUnneeded();
- QByteArray cmd = "-var-list-children --all-values \"" + data.variable + '"';
- //iname += '.' + exp;
- postCommand(cmd, Discardable,
- CB(handleVarListChildrenClassic), QVariant::fromValue(data));
- } else if (!startsWithDigit(QLatin1String(exp))
- && item["numchild"].data() == "0") {
- // Happens for structs without data, e.g. interfaces.
- WatchData data;
- data.name = _(exp);
- data.iname = parent.iname + '.' + data.name.toLatin1();
- data.variable = name;
- data.updateType(item["type"]);
- data.updateValue(item);
- data.updateAddress(item["addr"]);
- data.setHasChildren(false);
- insertData(data);
- } else if (parent.iname.endsWith('.')) {
- // Happens with anonymous unions.
- WatchData data;
- data.iname = name;
- QByteArray cmd = "-var-list-children --all-values \"" + data.variable + '"';
- postCommand(cmd, Discardable,
- CB(handleVarListChildrenClassic), QVariant::fromValue(data));
- } else if (exp == "staticMetaObject") {
- // && item.findChild("type").data() == "const QMetaObject")
- // FIXME: Namespaces?
- // { do nothing } FIXME: make configurable?
- // special "clever" hack to avoid clutter in the GUI.
- // I am not sure this is a good idea...
- } else {
- // Suppress 'private'/'protected'/'public' level.
- WatchData data;
- data.iname = parent.iname + '.' + exp;
- data.variable = name;
- data.sortId = sortId;
- data.updateType(item["type"]);
- data.updateValue(item);
- data.updateAddress(item["addr"]);
- data.updateChildCount(item["numchild"]);
- if (!watchHandler()->isExpandedIName(data.iname))
- data.setChildrenUnneeded();
-
- data.name = _(exp);
- if (data.name == QLatin1String(data.type)) {
- if (isPointerType(parent.type)) {
- data.exp = "*(" + parent.exp + ')';
- data.name = _("*") + parent.name;
- } else {
- // A type we derive from? gdb crashes when creating variables here
- data.exp = parent.exp;
- }
- } else if (exp.startsWith('*')) {
- // A pointer
- data.exp = "*(" + parent.exp + ')';
- } else if (startsWithDigit(data.name)) {
- // An array. No variables needed?
- data.name = QLatin1Char('[') + data.name + QLatin1Char(']');
- data.exp = parent.exp + '[' + exp + ']';
- } else if (0 && parent.name.endsWith(QLatin1Char('.'))) {
- // Happens with anonymous unions
- data.exp = parent.exp + data.name.toLatin1();
- //data.name = "<anonymous union>";
- } else if (exp.isEmpty()) {
- // Happens with anonymous unions
- data.exp = parent.exp;
- data.name = tr("<n/a>");
- data.iname = parent.iname + ".@";
- data.type = tr("<anonymous union>").toUtf8();
- } else {
- // A structure. Hope there's nothing else...
- data.exp = '(' + parent.exp + ")." + data.name.toLatin1();
- }
-
- if (hasDebuggingHelperForType(data.type)) {
- // we do not trust gdb if we have a custom dumper
- data.setValueNeeded();
- data.setHasChildrenNeeded();
- }
-
- //qDebug() << "VAR_LIST_CHILDREN: PARENT 3" << parent.toString();
- //qDebug() << "VAR_LIST_CHILDREN: APPENDEE" << data.toString();
- insertData(data);
- }
-}
-
-void GdbEngine::handleVarListChildrenClassic(const GdbResponse &response)
-{
- //WatchResultCounter dummy(this, WatchVarListChildren);
- WatchData data = response.cookie.value<WatchData>();
- if (!data.isValid())
- return;
- if (response.resultClass == GdbResultDone) {
- //qDebug() << "VAR_LIST_CHILDREN: PARENT" << data.toString();
- QList<GdbMi> children = response.data["children"].children();
-
- if (children.isEmpty()) {
- // happens e.g. if no debug information is present or
- // if the class really has no children
- WatchData data1;
- data1.iname = data.iname + ".child";
- //: About variable's value
- data1.value = tr("<no information>");
- data1.hasChildren = false;
- data1.setAllUnneeded();
- insertData(data1);
- data.setAllUnneeded();
- insertData(data);
- } else {
- if (data.variable.endsWith("private")
- || data.variable.endsWith("protected")
- || data.variable.endsWith("public")) {
- // this skips the spurious "public", "private" etc levels
- // gdb produces
- } else {
- data.setChildrenUnneeded();
- insertData(data);
- }
- for (int i = 0; i != children.size(); ++i)
- handleVarListChildrenHelperClassic(children.at(i), data, i);
- }
- } else {
- data.setError(QString::fromLocal8Bit(response.data["msg"].data()));
- }
-}
-
-void GdbEngine::handleEvaluateExpressionClassic(const GdbResponse &response)
-{
- WatchData data = response.cookie.value<WatchData>();
- QTC_ASSERT(data.isValid(), qDebug() << "HUH?");
- if (response.resultClass == GdbResultDone) {
- //if (col == 0)
- // data.name = response.data.findChild("value").data();
- //else
- data.updateValue(response.data);
- } else {
- data.setError(QString::fromLocal8Bit(response.data["msg"].data()));
- }
- //qDebug() << "HANDLE EVALUATE EXPRESSION:" << data.toString();
- insertData(data);
- //updateWatchModel2();
-}
-
-} // namespace Internal
-} // namespace Debugger
diff --git a/src/plugins/debugger/gdb/coregdbadapter.h b/src/plugins/debugger/gdb/coregdbadapter.h
index 4f274fb26a..af1a45c309 100644
--- a/src/plugins/debugger/gdb/coregdbadapter.h
+++ b/src/plugins/debugger/gdb/coregdbadapter.h
@@ -52,8 +52,6 @@ public:
~GdbCoreEngine();
private:
- DumperHandling dumperHandling() const { return DumperNotAvailable; }
-
void setupEngine();
void setupInferior();
void runEngine();
diff --git a/src/plugins/debugger/gdb/gdb.pri b/src/plugins/debugger/gdb/gdb.pri
index 64607124f8..8fc016a19a 100644
--- a/src/plugins/debugger/gdb/gdb.pri
+++ b/src/plugins/debugger/gdb/gdb.pri
@@ -11,8 +11,6 @@ HEADERS += \
SOURCES += \
$$PWD/gdbengine.cpp \
- $$PWD/classicgdbengine.cpp \
- $$PWD/pythongdbengine.cpp \
$$PWD/gdboptionspage.cpp \
$$PWD/attachgdbadapter.cpp \
$$PWD/coregdbadapter.cpp \
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 0ff3993168..2fdb7f336d 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -34,7 +34,6 @@
#include "gdbplainengine.h"
#include "termgdbadapter.h"
#include "remotegdbserveradapter.h"
-
#include "gdboptionspage.h"
#include <debugger/debuggerstartparameters.h>
@@ -92,6 +91,7 @@ enum { debugPending = 0 };
#define CB(callback) &GdbEngine::callback, STRINGIFY(callback)
+
QByteArray GdbEngine::tooltipIName(const QString &exp)
{
return "tooltip." + exp.toLatin1().toHex();
@@ -206,13 +206,8 @@ GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters)
setObjectName(_("GdbEngine"));
m_busy = false;
- m_debuggingHelperState = DebuggingHelperUninitialized;
m_gdbVersion = 100;
- m_gdbBuildVersion = -1;
- m_isMacGdb = false;
m_isQnxGdb = false;
- m_hasBreakpointNotifications = false;
- m_hasPython = false;
m_registerNamesListed = false;
m_sourcesListUpdating = false;
m_oldestAcceptableToken = -1;
@@ -222,16 +217,11 @@ GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters)
m_commandsDoneCallback = 0;
m_stackNeeded = false;
m_preparedForQmlBreak = false;
- m_disassembleUsesComma = false;
m_terminalTrap = startParameters.useTerminal;
m_fullStartDone = false;
m_systemDumpersLoaded = false;
- m_forceAsyncModel = false;
- m_pythonAttemptedToLoad = false;
m_gdbProc = new GdbProcess(this);
- invalidateSourcesList();
-
m_debugInfoTaskHandler = new DebugInfoTaskHandler(this);
//ExtensionSystem::PluginManager::addObject(m_debugInfoTaskHandler);
@@ -463,7 +453,6 @@ void GdbEngine::handleResponse(const QByteArray &buff)
if (!id.isEmpty())
showStatusMessage(tr("Library %1 loaded").arg(_(id)), 1000);
progressPing();
- invalidateSourcesList();
Module module;
module.startAddress = 0;
module.endAddress = 0;
@@ -478,7 +467,6 @@ void GdbEngine::handleResponse(const QByteArray &buff)
QByteArray id = result["id"].data();
progressPing();
showStatusMessage(tr("Library %1 unloaded").arg(_(id)), 1000);
- invalidateSourcesList();
} else if (asyncClass == "thread-group-added") {
// 7.1-symbianelf has "{id="i1"}"
} else if (asyncClass == "thread-group-created"
@@ -522,33 +510,6 @@ void GdbEngine::handleResponse(const QByteArray &buff)
QByteArray id = result["id"].data();
showStatusMessage(tr("Thread %1 selected").arg(_(id)), 1000);
//"{id="2"}"
- } else if (m_isMacGdb && asyncClass == "shlibs-updated") {
- // Apple's gdb announces updated libs.
- invalidateSourcesList();
- } else if (m_isMacGdb && asyncClass == "shlibs-added") {
- // Apple's gdb announces added libs.
- // {shlib-info={num="2", name="libmathCommon.A_debug.dylib",
- // kind="-", dyld-addr="0x7f000", reason="dyld", requested-state="Y",
- // state="Y", path="/usr/lib/system/libmathCommon.A_debug.dylib",
- // description="/usr/lib/system/libmathCommon.A_debug.dylib",
- // loaded_addr="0x7f000", slide="0x7f000", prefix=""}}
- invalidateSourcesList();
- } else if (m_isMacGdb && asyncClass == "resolve-pending-breakpoint") {
- // Apple's gdb announces resolved breakpoints.
- // new_bp="1",pended_bp="1",new_expr="\"gdbengine.cpp\":1584",
- // bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
- // addr="0x0000000115cc3ddf",func="foo()",file="../foo.cpp",
- // line="1584",shlib="/../libFoo_debug.dylib",times="0"}
- const GdbMi bkpt = result["bkpt"];
- const BreakpointResponseId rid(bkpt["number"].data());
- if (!isQmlStepBreakpoint(rid)) {
- BreakHandler *handler = breakHandler();
- BreakpointModelId id = handler->findBreakpointByResponseId(rid);
- BreakpointResponse br = handler->response(id);
- updateResponse(br, bkpt);
- handler->setResponse(id, br);
- attemptAdjustBreakpointLocation(id);
- }
} else if (asyncClass == "breakpoint-modified") {
// New in FSF gdb since 2011-04-27.
// "{bkpt={number="3",type="breakpoint",disp="keep",
@@ -557,7 +518,7 @@ void GdbEngine::handleResponse(const QByteArray &buff)
// {number="3.1",enabled="y",addr="0x0805ff68",
// func="Vector<int>::Vector(int)",
// file="simple_gdbtest_app.cpp",
- // fullname="/data/...line="135"},{number="3.2"...}}"
+ // fullname="/data/...line="135"},{number="3.2"...}}.."
// Note the leading comma in original-location. Filter it out.
// We don't need the field anyway.
@@ -596,13 +557,12 @@ void GdbEngine::handleResponse(const QByteArray &buff)
}
}
}
- m_hasBreakpointNotifications = true;
} else if (asyncClass == "breakpoint-created") {
// "{bkpt={number="1",type="breakpoint",disp="del",enabled="y",
// addr="<PENDING>",pending="main",times="0",
// original-location="main"}}" -- or --
// {bkpt={number="2",type="hw watchpoint",disp="keep",enabled="y",
- // what="*0xbfffed48",times="0",original-location="*0xbfffed48"
+ // what="*0xbfffed48",times="0",original-location="*0xbfffed48"}}
BreakHandler *handler = breakHandler();
foreach (const GdbMi &bkpt, result.children()) {
BreakpointResponse br;
@@ -663,7 +623,6 @@ void GdbEngine::handleResponse(const QByteArray &buff)
if (data.startsWith("Reading symbols from ")) {
showStatusMessage(tr("Reading %1...").arg(_(data.mid(21))), 1000);
progressPing();
- invalidateSourcesList();
} else if (data.startsWith("[New ") || data.startsWith("[Thread ")) {
if (data.endsWith('\n'))
data.chop(1);
@@ -1283,10 +1242,15 @@ void GdbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages
// This is called from CoreAdapter and AttachAdapter.
void GdbEngine::updateAll()
{
- if (hasPython())
- updateAllPython();
- else
- updateAllClassic();
+ //PENDING_DEBUG("UPDATING ALL\n");
+ QTC_CHECK(state() == InferiorUnrunnable || state() == InferiorStopOk);
+ reloadModulesInternal();
+ postCommand("-stack-list-frames", CB(handleStackListFrames),
+ QVariant::fromValue<StackCookie>(StackCookie(false, true)));
+ stackHandler()->setCurrentIndex(0);
+ postCommand("-thread-info", CB(handleThreadInfo), 0);
+ reloadRegisters();
+ updateLocals();
}
void GdbEngine::handleQuerySources(const GdbResponse &response)
@@ -1578,29 +1542,7 @@ void GdbEngine::handleStop1(const GdbMi &data)
postCommand("importPlainDumpers");
}
- bool initHelpers = m_debuggingHelperState == DebuggingHelperUninitialized
- || m_debuggingHelperState == DebuggingHelperLoadTried;
- // Don't load helpers on stops triggered by signals unless it's
- // an intentional trap.
- if (initHelpers
- && dumperHandling() != DumperLoadedByGdbPreload
- && reason == "signal-received") {
- const QByteArray name = data["signal-name"].data();
- const DebuggerStartParameters &sp = startParameters();
- if (name != stopSignal(sp.toolChainAbi))
- initHelpers = false;
- }
- if (isSynchronous())
- initHelpers = false;
- if (initHelpers) {
- tryLoadDebuggingHelpersClassic();
- QVariant var = QVariant::fromValue<GdbMi>(data);
- postCommand("p 4", CB(handleStop2), var); // dummy
- } else {
- handleStop2(data);
- }
- // Dumper loading is sequenced, as otherwise the display functions
- // will start requesting data without knowing that dumpers are available.
+ handleStop2(data);
}
void GdbEngine::handleStop2(const GdbResponse &response)
@@ -1667,15 +1609,6 @@ void GdbEngine::handleStop2(const GdbMi &data)
isStopperThread = true;
}
- if (m_breakListOutdated) {
- reloadBreakListInternal();
- } else {
- // Older gdb versions do not produce "library loaded" messages
- // so the breakpoint update is not triggered.
- if (m_gdbVersion < 70000 && !m_isMacGdb && breakHandler()->size() > 0)
- reloadBreakListInternal();
- }
-
if (reason == "watchpoint-trigger") {
// *stopped,reason="watchpoint-trigger",wpt={number="2",exp="*0xbfffed40"},
// value={old="1",new="0"},frame={addr="0x00451e1b",
@@ -1745,14 +1678,8 @@ void GdbEngine::handleStop2()
if (!m_stackNeeded)
return;
- if (supportsThreads()) {
- if (m_isMacGdb || m_gdbVersion < 70100) {
- postCommand("-thread-list-ids", Discardable, CB(handleThreadListIds));
- } else {
- // This is only available in gdb 7.1+.
- postCommand("-thread-info", Discardable, CB(handleThreadInfo));
- }
- }
+ // This is only available in gdb 7.1+.
+ postCommand("-thread-info", Discardable, CB(handleThreadInfo));
}
void GdbEngine::handleInfoProc(const GdbResponse &response)
@@ -1769,40 +1696,31 @@ void GdbEngine::handleShowVersion(const GdbResponse &response)
{
showMessage(_("PARSING VERSION: " + response.toString()));
if (response.resultClass == GdbResultDone) {
+ bool isMacGdb = false;
+ int gdbBuildVersion = -1;
m_gdbVersion = 100;
- m_gdbBuildVersion = -1;
- m_isMacGdb = false;
m_isQnxGdb = false;
QString msg = QString::fromLocal8Bit(response.consoleStreamOutput);
extractGdbVersion(msg,
- &m_gdbVersion, &m_gdbBuildVersion, &m_isMacGdb, &m_isQnxGdb);
+ &m_gdbVersion, &gdbBuildVersion, &isMacGdb, &m_isQnxGdb);
// On Mac, fsf gdb does not work sufficiently well,
// and on Linux and Windows we require at least 7.2.
// Older versions with python still work, but can
// be significantly slower.
- bool isSupported = m_isMacGdb ? m_gdbVersion < 70000
- : (m_gdbVersion > 70200 && m_gdbVersion < 200000);
+ bool isSupported = m_gdbVersion >= 70500;
if (isSupported)
showMessage(_("SUPPORTED GDB VERSION ") + msg);
else
showMessage(_("UNSUPPORTED GDB VERSION ") + msg);
showMessage(_("USING GDB VERSION: %1, BUILD: %2%3").arg(m_gdbVersion)
- .arg(m_gdbBuildVersion).arg(_(m_isMacGdb ? " (APPLE)" : "")));
-
- if (m_gdbVersion > 70300)
- m_hasBreakpointNotifications = true;
+ .arg(gdbBuildVersion).arg(_(isMacGdb ? " (APPLE)" : "")));
- if (m_gdbVersion > 70100)
- m_disassembleUsesComma = true;
-
- if (m_gdbVersion > 70100) {
- if (usesExecInterrupt())
- postCommand("set target-async on", ConsoleCommand);
- else
- postCommand("set target-async off", ConsoleCommand);
- }
+ if (usesExecInterrupt())
+ postCommand("set target-async on", ConsoleCommand);
+ else
+ postCommand("set target-async off", ConsoleCommand);
if (startParameters().multiProcess)
postCommand("set detach-on-fork off", ConsoleCommand);
@@ -1819,10 +1737,7 @@ void GdbEngine::handleListFeatures(const GdbResponse &response)
void GdbEngine::handleHasPython(const GdbResponse &response)
{
- if (response.resultClass == GdbResultDone)
- m_hasPython = true;
- else
- pythonDumpersFailed();
+ Q_UNUSED(response);
}
void GdbEngine::handlePythonSetup(const GdbResponse &response)
@@ -1834,7 +1749,6 @@ void GdbEngine::handlePythonSetup(const GdbResponse &response)
postCommand("bbsetup");
}
- m_hasPython = true;
GdbMi data;
data.fromStringMultiple(response.consoleStreamOutput);
const GdbMi dumpers = data["dumpers"];
@@ -1855,24 +1769,6 @@ void GdbEngine::handlePythonSetup(const GdbResponse &response)
}
}
-void GdbEngine::pythonDumpersFailed()
-{
- m_hasPython = false;
- const DebuggerStartParameters &sp = startParameters();
- if (dumperHandling() == DumperLoadedByGdbPreload && checkDebuggingHelpersClassic()) {
- QByteArray cmd = "set environment ";
- if (sp.toolChainAbi.os() == Abi::MacOS)
- cmd += "DYLD_INSERT_LIBRARIES";
- else
- cmd += "LD_PRELOAD";
- cmd += ' ';
- if (sp.startMode != StartRemoteGdb)
- cmd += sp.dumperLibrary.toLocal8Bit();
- postCommand(cmd);
- m_debuggingHelperState = DebuggingHelperLoadTried;
- }
-}
-
void GdbEngine::showExecutionError(const QString &message)
{
showMessageBox(QMessageBox::Critical, tr("Execution Error"),
@@ -2310,24 +2206,13 @@ void GdbEngine::executeRunToLine(const ContextData &data)
showStatusMessage(tr("Run to line %1 requested...").arg(data.lineNumber), 5000);
#if 1
QByteArray loc;
- if (m_isMacGdb) {
- if (data.address)
- loc = addressSpec(data.address);
- else
- loc = "\"\\\"" + breakLocation(data.fileName).toLocal8Bit() + "\\\":"
- + QByteArray::number(data.lineNumber) + '"';
- // "tbreak/continue" does _not_ work on Mac. See #4619
- postCommand("-break-insert -t -l -1 -f " + loc);
- postCommand("-exec-continue", RunRequest, CB(handleExecuteRunToLine));
- } else {
- if (data.address)
- loc = addressSpec(data.address);
- else
- loc = '"' + breakLocation(data.fileName).toLocal8Bit() + '"' + ':'
- + QByteArray::number(data.lineNumber);
- postCommand("tbreak " + loc);
- postCommand("continue", RunRequest, CB(handleExecuteRunToLine));
- }
+ if (data.address)
+ loc = addressSpec(data.address);
+ else
+ loc = '"' + breakLocation(data.fileName).toLocal8Bit() + '"' + ':'
+ + QByteArray::number(data.lineNumber);
+ postCommand("tbreak " + loc);
+ postCommand("continue", RunRequest, CB(handleExecuteRunToLine));
#else
// Seems to jump to unpredicatable places. Observed in the manual
// tests in the Foo::Foo() constructor with both gdb 6.8 and 7.1.
@@ -2482,7 +2367,7 @@ void GdbEngine::updateResponse(BreakpointResponse &response, const GdbMi &bkpt)
} else if (child.hasName("type")) {
// "breakpoint", "hw breakpoint", "tracepoint", "hw watchpoint"
// {bkpt={number="2",type="hw watchpoint",disp="keep",enabled="y",
- // what="*0xbfffed48",times="0",original-location="*0xbfffed48"
+ // what="*0xbfffed48",times="0",original-location="*0xbfffed48"}}
if (child.data().contains("tracepoint")) {
response.tracepoint = true;
} else if (child.data() == "hw watchpoint" || child.data() == "watchpoint") {
@@ -2536,7 +2421,6 @@ void GdbEngine::updateResponse(BreakpointResponse &response, const GdbMi &bkpt)
QString GdbEngine::breakLocation(const QString &file) const
{
- //QTC_CHECK(!m_breakListOutdated);
QString where = m_fullToShortName.value(file);
if (where.isEmpty())
return QFileInfo(file).fileName();
@@ -2627,31 +2511,12 @@ void GdbEngine::handleWatchInsert(const GdbResponse &response)
}
}
-void GdbEngine::attemptAdjustBreakpointLocation(BreakpointModelId id)
-{
- if (m_hasBreakpointNotifications)
- return;
- if (!debuggerCore()->boolSetting(AdjustBreakpointLocations))
- return;
- BreakpointResponse response = breakHandler()->response(id);
- if (response.address == 0 || response.correctedLineNumber != 0)
- return;
- // Prevent endless loop.
- response.correctedLineNumber = -1;
- breakHandler()->setResponse(id, response);
- postCommand("info line *0x" + QByteArray::number(response.address, 16),
- NeedsStop | RebuildBreakpointModel,
- CB(handleInfoLine), QVariant::fromValue(id));
-}
-
void GdbEngine::handleCatchInsert(const GdbResponse &response)
{
BreakHandler *handler = breakHandler();
BreakpointModelId id = response.cookie.value<BreakpointModelId>();
- if (response.resultClass == GdbResultDone) {
+ if (response.resultClass == GdbResultDone)
handler->notifyBreakpointInsertOk(id);
- attemptAdjustBreakpointLocation(id);
- }
}
void GdbEngine::handleBkpt(const GdbMi &bkpt, const BreakpointModelId &id)
@@ -2727,13 +2592,6 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response)
} else {
handler->notifyBreakpointInsertOk(id);
}
- BreakpointResponse br = handler->response(id);
- attemptAdjustBreakpointLocation(id);
- // Remove if we only support 7.4 or later.
- if (br.multiple && !m_hasBreakpointNotifications)
- postCommand("info break " + QByteArray::number(br.id.majorPart()),
- NeedsStop, CB(handleBreakListMultiple),
- QVariant::fromValue(id));
}
} else if (response.data["msg"].data().contains("Unknown option")) {
// Older version of gdb don't know the -a option to set tracepoints
@@ -2743,9 +2601,7 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response)
QByteArray cmd = "trace "
"\"" + GdbMi::escapeCString(fileName.toLocal8Bit()) + "\":"
+ QByteArray::number(lineNumber);
- QVariant vid = QVariant::fromValue(id);
- postCommand(cmd, NeedsStop | RebuildBreakpointModel,
- CB(handleTraceInsert2), vid);
+ postCommand(cmd, NeedsStop | RebuildBreakpointModel);
} else {
// Some versions of gdb like "GNU gdb (GDB) SUSE (6.8.91.20090930-2.4)"
// know how to do pending breakpoints using CLI but not MI. So try
@@ -2761,7 +2617,6 @@ void GdbEngine::handleBreakInsert2(const GdbResponse &response)
{
if (response.resultClass == GdbResultDone) {
BreakpointModelId id = response.cookie.value<BreakpointModelId>();
- attemptAdjustBreakpointLocation(id);
breakHandler()->notifyBreakpointInsertOk(id);
} else {
// Note: gdb < 60800 doesn't "do" pending breakpoints.
@@ -2771,94 +2626,6 @@ void GdbEngine::handleBreakInsert2(const GdbResponse &response)
}
}
-void GdbEngine::handleTraceInsert2(const GdbResponse &response)
-{
- if (response.resultClass == GdbResultDone)
- reloadBreakListInternal();
-}
-
-void GdbEngine::reloadBreakListInternal()
-{
- if (m_hasBreakpointNotifications) {
- // Assume this properly handles breakpoint notifications.
- return;
- }
- postCommand("-break-list", NeedsStop | RebuildBreakpointModel,
- CB(handleBreakList));
-}
-
-void GdbEngine::handleBreakList(const GdbResponse &response)
-{
- // 45^done,BreakpointTable={nr_rows="2",nr_cols="6",hdr=[
- // {width="3",alignment="-1",col_name="number",colhdr="Num"}, ...
- // body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
- // addr="0x000000000040109e",func="main",file="app.cpp",
- // fullname="/home/apoenitz/dev/work/plugintest/app/app.cpp",
- // line="11",times="1"},
- // bkpt={number="2",type="breakpoint",disp="keep",enabled="y",
- // addr="<PENDING>",pending="plugin.cpp:7",times="0"}] ... }
-
- if (response.resultClass == GdbResultDone) {
- GdbMi table = response.data["BreakpointTable"];
- if (table.isValid())
- handleBreakList(table);
- }
-}
-
-void GdbEngine::handleBreakList(const GdbMi &table)
-{
- const GdbMi body = table["body"];
- QList<GdbMi> bkpts;
- if (body.isValid()) {
- // Non-Mac
- bkpts = body.children();
- } else {
- // Mac
- bkpts = table.children();
- // Remove the 'hdr' and artificial items.
- for (int i = bkpts.size(); --i >= 0; ) {
- int num = bkpts.at(i)["number"].toInt();
- if (num <= 0)
- bkpts.removeAt(i);
- }
- }
-
- BreakHandler *handler = breakHandler();
- foreach (const GdbMi &bkpt, bkpts) {
- BreakpointResponse needle;
- needle.id = BreakpointResponseId(bkpt["number"].data());
- if (isQmlStepBreakpoint2(needle.id))
- continue;
- if (isQFatalBreakpoint(needle.id))
- continue;
- BreakpointModelId id = handler->findSimilarBreakpoint(needle);
- if (id.isValid()) {
- BreakpointResponse response = handler->response(id);
- updateResponse(response, bkpt);
- handler->setResponse(id, response);
- attemptAdjustBreakpointLocation(id);
- response = handler->response(id);
- if (response.multiple)
- postCommand("info break " + response.id.toString().toLatin1(),
- NeedsStop, CB(handleBreakListMultiple),
- QVariant::fromValue(id));
- } else {
- qDebug() << " NOTHING SUITABLE FOUND";
- showMessage(_("CANNOT FIND BP: " + bkpt.toString()));
- }
- }
-
- m_breakListOutdated = false;
-}
-
-void GdbEngine::handleBreakListMultiple(const GdbResponse &response)
-{
- QTC_CHECK(response.resultClass == GdbResultDone);
- const BreakpointModelId id = response.cookie.value<BreakpointModelId>();
- const QString str = QString::fromLocal8Bit(response.consoleStreamOutput);
- extractDataFromInfoBreak(str, id);
-}
-
void GdbEngine::handleBreakDisable(const GdbResponse &response)
{
QTC_CHECK(response.resultClass == GdbResultDone);
@@ -2948,164 +2715,14 @@ void GdbEngine::handleBreakCondition(const GdbResponse &response)
// the output stream data.
// The following happens on Mac:
// QByteArray msg = response.data.findChild("msg").data();
- // if (1 || msg.startsWith("Error parsing breakpoint condition. "
- // " Will try again when we hit the breakpoint.")) {
+ // if (msg.startsWith("Error parsing breakpoint condition. "
+ // " Will try again when we hit the breakpoint."))
BreakpointResponse br = handler->response(id);
br.condition = handler->condition(id);
handler->setResponse(id, br);
changeBreakpoint(id); // Maybe there's more to do.
}
-void GdbEngine::extractDataFromInfoBreak(const QString &output, BreakpointModelId id)
-{
- //qDebug() << output;
- if (output.isEmpty())
- return;
- // "Num Type Disp Enb Address What
- // 4 breakpoint keep y <MULTIPLE> 0x00000000004066ad
- // 4.1 y 0x00000000004066ad in CTorTester
- // at /data5/dev/ide/main/tests/manual/gdbdebugger/simple/app.cpp:124
- // - or -
- // everything on a single line on Windows for constructors of classes
- // within namespaces.
- // Sometimes the path is relative too.
-
- // 2 breakpoint keep y <MULTIPLE> 0x0040168e
- // 2.1 y 0x0040168e in MainWindow::MainWindow(QWidget*) at mainwindow.cpp:7
- // 2.2 y 0x00401792 in MainWindow::MainWindow(QWidget*) at mainwindow.cpp:7
-
- // "Num Type Disp Enb Address What
- // 3 breakpoint keep y <MULTIPLE> \n"
- // 3.1 y 0x0806094e in Vector<int>::Vector(int) at simple.cpp:141
- // 3.2 y 0x08060994 in Vector<float>::Vector(int) at simple.cpp:141
- // 3.3 y 0x080609da in Vector<double>::Vector(int) at simple.cpp:141
- // 3.4 y 0x08060a1d in Vector<char>::Vector(int) at simple.cpp:141
-
- BreakHandler *handler = breakHandler();
- BreakpointResponse response = handler->response(id);
- int posMultiple = output.indexOf(_("<MULTIPLE>"));
- if (posMultiple != -1) {
- QByteArray data = output.toUtf8();
- data.replace('\n', ' ');
- data.replace(" ", " ");
- data.replace(" ", " ");
- data.replace(" ", " ");
- int majorPart = 0;
- int minorPart = 0;
- int hitCount = 0;
- bool hitCountComing = false;
- bool functionComing = false;
- bool locationComing = false;
- QByteArray location;
- QByteArray function;
- qulonglong address = 0;
- foreach (const QByteArray &part, data.split(' ')) {
- if (part.isEmpty())
- continue;
- //qDebug() << "PART: " << part;
- if (majorPart == 0) {
- majorPart = part.toInt();
- if (majorPart > 0)
- continue;
- }
- if (part == "hit") {
- hitCountComing = true;
- continue;
- }
- if (hitCountComing) {
- hitCountComing = false;
- hitCount = part.toInt();
- continue;
- }
- if (part == "at") {
- locationComing = true;
- continue;
- }
- if (locationComing) {
- locationComing = false;
- location = part;
- continue;
- }
- if (part == "in") {
- functionComing = true;
- continue;
- }
- if (functionComing) {
- functionComing = false;
- function = part;
- continue;
- }
- if (part.startsWith("0x")) {
- address = part.toInt(0, 0);
- continue;
- }
- if (part.size() >= 3 && part.count('.') == 1) {
- BreakpointResponseId subId(part);
- int tmpMajor = subId.majorPart();
- int tmpMinor = subId.minorPart();
- if (tmpMajor == majorPart) {
- if (minorPart) {
- // Commit what we had before.
- BreakpointResponse sub;
- sub.address = address;
- sub.functionName = QString::fromUtf8(function);
- sub.updateLocation(location);
- sub.id = BreakpointResponseId(majorPart, minorPart);
- sub.type = response.type;
- sub.address = address;
- sub.hitCount = hitCount;
- handler->insertSubBreakpoint(id, sub);
- location.clear();
- function.clear();
- address = 0;
- }
-
- // Now start new.
- minorPart = tmpMinor;
- continue;
- }
- }
- }
- if (minorPart) {
- // Commit last chunk.
- BreakpointResponse sub;
- sub.address = address;
- sub.functionName = QString::fromUtf8(function);
- sub.updateLocation(location);
- sub.id = BreakpointResponseId(majorPart, minorPart);
- sub.type = response.type;
- sub.hitCount = hitCount;
- handler->insertSubBreakpoint(id, sub);
- location.clear();
- function.clear();
- address = 0;
- }
- } else {
- qDebug() << "COULD NOT MATCH" << output;
- response.id = BreakpointResponseId(); // Unavailable.
- }
- //handler->setResponse(id, response);
-}
-
-void GdbEngine::handleInfoLine(const GdbResponse &response)
-{
- if (response.resultClass == GdbResultDone) {
- // Old-style output: "Line 1102 of \"simple/app.cpp\" starts
- // at address 0x80526aa <_Z10...+131> and ends at 0x80526b5
- // <_Z10testQStackv+142>.\n"
- QByteArray ba = response.consoleStreamOutput;
- const BreakpointModelId id = response.cookie.value<BreakpointModelId>();
- const int pos = ba.indexOf(' ', 5);
- if (ba.startsWith("Line ") && pos != -1) {
- const int line = ba.mid(5, pos - 5).toInt();
- BreakpointResponse br = breakHandler()->response(id);
- br.lineNumber = line;
- br.correctedLineNumber = line;
- breakHandler()->setResponse(id, br);
- }
- }
-}
-
bool GdbEngine::stateAcceptsBreakpointChanges() const
{
switch (state()) {
@@ -3177,26 +2794,18 @@ void GdbEngine::insertBreakpoint(BreakpointModelId id)
QByteArray cmd;
if (handler->isTracepoint(id)) {
cmd = "-break-insert -a -f ";
- } else if (m_isMacGdb) {
- cmd = "-break-insert -l -1 -f ";
- } else if (m_gdbVersion >= 70000) {
+ } else {
int spec = handler->threadSpec(id);
cmd = "-break-insert ";
if (spec >= 0)
cmd += "-p " + QByteArray::number(spec);
cmd += " -f ";
- } else if (m_gdbVersion >= 60800) {
- // Probably some earlier version would work as well.
- cmd = "-break-insert -f ";
- } else {
- cmd = "-break-insert ";
}
if (handler->isOneShot(id))
cmd += "-t ";
- // FIXME: -d does not work on Mac gdb.
- if (!handler->isEnabled(id) && !m_isMacGdb)
+ if (!handler->isEnabled(id))
cmd += "-d ";
if (int ignoreCount = handler->ignoreCount(id))
@@ -3278,7 +2887,6 @@ void GdbEngine::changeBreakpoint(BreakpointModelId id)
return;
}
handler->notifyBreakpointChangeOk(id);
- attemptAdjustBreakpointLocation(id);
}
void GdbEngine::removeBreakpoint(BreakpointModelId id)
@@ -3314,7 +2922,6 @@ void GdbEngine::loadSymbols(const QString &modulePath)
// FIXME: gdb does not understand quoted names here (tested with 6.8)
postCommand("sharedlibrary " + dotEscape(modulePath.toLocal8Bit()));
reloadModulesInternal();
- reloadBreakListInternal();
reloadStack(true);
updateLocals();
}
@@ -3323,7 +2930,6 @@ void GdbEngine::loadAllSymbols()
{
postCommand("sharedlibrary .*");
reloadModulesInternal();
- reloadBreakListInternal();
reloadStack(true);
updateLocals();
}
@@ -3347,7 +2953,6 @@ void GdbEngine::loadSymbolsForStack()
}
if (needUpdate) {
//reloadModulesInternal();
- reloadBreakListInternal();
reloadStack(true);
updateLocals();
}
@@ -3558,11 +3163,6 @@ void GdbEngine::examineModules()
//
//////////////////////////////////////////////////////////////////////
-void GdbEngine::invalidateSourcesList()
-{
- m_breakListOutdated = true;
-}
-
void GdbEngine::reloadSourceFiles()
{
if ((state() == InferiorRunOk || state() == InferiorStopOk)
@@ -3575,10 +3175,6 @@ void GdbEngine::reloadSourceFilesInternal()
QTC_CHECK(!m_sourcesListUpdating);
m_sourcesListUpdating = true;
postCommand("-file-list-exec-source-files", NeedsStop, CB(handleQuerySources));
-#if 0
- if (m_gdbVersion < 70000 && !m_isMacGdb)
- postCommand("set stop-on-solib-events 1");
-#endif
}
@@ -3644,8 +3240,7 @@ StackFrame GdbEngine::parseStackFrame(const GdbMi &frameMi, int level)
void GdbEngine::handleStackListFrames(const GdbResponse &response)
{
- bool handleIt = (m_isMacGdb || response.resultClass == GdbResultDone);
- if (!handleIt) {
+ if (response.resultClass != GdbResultDone) {
// That always happens on symbian gdb with
// ^error,data={msg="Previous frame identical to this frame (corrupt stack?)"
// logStreamOutput: "Previous frame identical to this frame (corrupt stack?)\n"
@@ -3747,7 +3342,7 @@ void GdbEngine::handleThreadInfo(const GdbResponse &response)
selectThread(other);
}
updateViews(); // Adjust Threads combobox.
- if (m_hasPython && debuggerCore()->boolSetting(ShowThreadNames)) {
+ if (debuggerCore()->boolSetting(ShowThreadNames)) {
postCommand("threadnames " +
debuggerCore()->action(MaximalStackDepth)->value().toByteArray(),
Discardable, CB(handleThreadNames));
@@ -3918,20 +3513,6 @@ void GdbEngine::handleRegisterListValues(const GdbResponse &response)
//////////////////////////////////////////////////////////////////////
//
-// Thread specific stuff
-//
-//////////////////////////////////////////////////////////////////////
-
-bool GdbEngine::supportsThreads() const
-{
- // FSF gdb 6.3 crashes happily on -thread-list-ids. So don't use it.
- // The test below is a semi-random pick, 6.8 works fine
- return m_isMacGdb || m_gdbVersion > 60500;
-}
-
-
-//////////////////////////////////////////////////////////////////////
-//
// Tooltip specific stuff
//
//////////////////////////////////////////////////////////////////////
@@ -4015,19 +3596,11 @@ bool GdbEngine::setToolTipExpression(const QPoint &mousePos,
if (DebuggerToolTipManager::debug())
qDebug() << "GdbEngine::setToolTipExpression2 " << exp << (*m_toolTipContext);
- if (isSynchronous()) {
- UpdateParameters params;
- params.tryPartial = true;
- params.tooltipOnly = true;
- params.varList = iname;
- updateLocalsPython(params);
- } else {
- WatchData toolTip;
- toolTip.exp = exp.toLatin1();
- toolTip.name = exp;
- toolTip.iname = iname;
- watchHandler()->insertData(toolTip);
- }
+ UpdateParameters params;
+ params.tryPartial = true;
+ params.tooltipOnly = true;
+ params.varList = iname;
+ updateLocalsPython(params);
return true;
}
@@ -4044,66 +3617,41 @@ void GdbEngine::reloadLocals()
updateLocals();
}
-bool GdbEngine::hasDebuggingHelperForType(const QByteArray &type) const
+void GdbEngine::updateWatchData(const WatchData &data, const WatchUpdateFlags &flags)
{
- if (!debuggerCore()->boolSetting(UseDebuggingHelpers))
- return false;
+ // This should only be called for fresh expanded items, not for
+ // items that had their children retrieved earlier.
+ //qDebug() << "\nUPDATE WATCH DATA: " << data.toString() << "\n";
+ if (data.iname.endsWith("."))
+ return;
- if (dumperHandling() == DumperNotAvailable) {
- // Inferior calls are not possible in gdb when looking at core files.
- return type == "QString" || type.endsWith("::QString")
- || type == "QStringList" || type.endsWith("::QStringList");
+ // Avoid endless loops created by faulty dumpers.
+ QByteArray processedName = "1-" + data.iname;
+ //qDebug() << "PROCESSED NAMES: " << processedName << m_processedNames;
+ if (m_processedNames.contains(processedName)) {
+ WatchData data1 = data;
+ showMessage(_("<Breaking endless loop for " + data.iname + '>'),
+ LogMiscInput);
+ data1.setAllUnneeded();
+ data1.setValue(_("<unavailable>"));
+ data1.setHasChildren(false);
+ insertData(data1);
+ return;
}
+ m_processedNames.insert(processedName);
- if (m_debuggingHelperState != DebuggingHelperAvailable)
- return false;
+ // FIXME: Is this sufficient when "external" changes are
+ // triggered e.g. by manually entered command in the gdb console?
+ //qDebug() << "TRY PARTIAL: " << flags.tryIncremental
+ // << (m_pendingBreakpointRequests == 0);
- // Simple types.
- return m_dumperHelper.type(type) != DumperHelper::UnknownType;
-}
-
-void GdbEngine::updateWatchData(const WatchData &data, const WatchUpdateFlags &flags)
-{
- if (isSynchronous()) {
- // This should only be called for fresh expanded items, not for
- // items that had their children retrieved earlier.
- //qDebug() << "\nUPDATE WATCH DATA: " << data.toString() << "\n";
- if (data.iname.endsWith("."))
- return;
+ UpdateParameters params;
+ params.tooltipOnly = data.iname.startsWith("tooltip");
+ params.tryPartial = flags.tryIncremental
+ && m_pendingBreakpointRequests == 0;
+ params.varList = data.iname;
- // Avoid endless loops created by faulty dumpers.
- QByteArray processedName = "1-" + data.iname;
- //qDebug() << "PROCESSED NAMES: " << processedName << m_processedNames;
- if (m_processedNames.contains(processedName)) {
- WatchData data1 = data;
- showMessage(_("<Breaking endless loop for " + data.iname + '>'),
- LogMiscInput);
- data1.setAllUnneeded();
- data1.setValue(_("<unavailable>"));
- data1.setHasChildren(false);
- insertData(data1);
- return;
- }
- m_processedNames.insert(processedName);
-
- // FIXME: Is this sufficient when "external" changes are
- // triggered e.g. by manually entered command in the gdb console?
- //qDebug() << "TRY PARTIAL: " << flags.tryIncremental
- // << hasPython()
- // << (m_pendingBreakpointRequests == 0);
-
- UpdateParameters params;
- params.tooltipOnly = data.iname.startsWith("tooltip");
- params.tryPartial = flags.tryIncremental
- && hasPython()
- && m_pendingBreakpointRequests == 0;
- params.varList = data.iname;
-
- updateLocalsPython(params);
- } else {
- PENDING_DEBUG("UPDATE WATCH BUMPS PENDING UP TO " << m_uncompleted.size());
- updateSubItemClassic(data);
- }
+ updateLocalsPython(params);
}
void GdbEngine::rebuildWatchModel()
@@ -4112,8 +3660,6 @@ void GdbEngine::rebuildWatchModel()
QTC_CHECK(m_uncompleted.isEmpty());
static int count = 0;
++count;
- if (!isSynchronous())
- m_processedNames.clear();
PENDING_DEBUG("REBUILDING MODEL" << count);
if (debuggerCore()->boolSetting(LogTimeStamps))
showMessage(LogWindow::logTimeStamp(), LogMiscInput);
@@ -4122,38 +3668,6 @@ void GdbEngine::rebuildWatchModel()
showToolTip();
}
-static QByteArray arrayFillCommand(const char *array, const QByteArray &params)
-{
- QString buf;
- buf.sprintf("set {char[%d]} &%s = {", params.size(), array);
- QByteArray encoded;
- encoded.append(buf.toLocal8Bit());
- const int size = params.size();
- for (int i = 0; i != size; ++i) {
- buf.sprintf("%d,", int(params[i]));
- encoded.append(buf.toLocal8Bit());
- }
- encoded[encoded.size() - 1] = '}';
- return encoded;
-}
-
-void GdbEngine::sendWatchParameters(const QByteArray &params0)
-{
- QByteArray params = params0;
- params.append('\0');
- const QByteArray inBufferCmd = arrayFillCommand("qDumpInBuffer", params);
-
- params.replace('\0','!');
- showMessage(QString::fromUtf8(params), LogMiscInput);
-
- params.clear();
- params.append('\0');
- const QByteArray outBufferCmd = arrayFillCommand("qDumpOutBuffer", params);
-
- postCommand(inBufferCmd);
- postCommand(outBufferCmd);
-}
-
void GdbEngine::handleVarAssign(const GdbResponse &)
{
// Everything might have changed, force re-evaluation.
@@ -4161,127 +3675,10 @@ void GdbEngine::handleVarAssign(const GdbResponse &)
updateLocals();
}
-void GdbEngine::handleVarCreate(const GdbResponse &response)
-{
- WatchData data = response.cookie.value<WatchData>();
- // Happens e.g. when we already issued a var-evaluate command.
- if (!data.isValid())
- return;
- //qDebug() << "HANDLE VARIABLE CREATION:" << data.toString();
- if (response.resultClass == GdbResultDone) {
- data.variable = data.iname;
- data.updateType(response.data["type"]);
- if (watchHandler()->isExpandedIName(data.iname)
- && !response.data["children"].isValid())
- data.setChildrenNeeded();
- else
- data.setChildrenUnneeded();
- data.updateChildCount(response.data["numchild"]);
- insertData(data);
- } else {
- data.setError(QString::fromLocal8Bit(response.data["msg"].data()));
- if (data.isWatcher()) {
- data.value = WatchData::msgNotInScope();
- data.type = " ";
- data.setAllUnneeded();
- data.setHasChildren(false);
- data.valueEnabled = false;
- data.valueEditable = false;
- insertData(data);
- }
- }
-}
-
-void GdbEngine::handleDebuggingHelperSetup(const GdbResponse &response)
-{
- if (response.resultClass == GdbResultDone) {
- } else {
- QString msg = QString::fromLocal8Bit(response.data["msg"].data());
- showStatusMessage(tr("Custom dumper setup: %1").arg(msg), 10000);
- }
-}
-
void GdbEngine::updateLocals()
{
watchHandler()->resetValueCache();
- if (hasPython())
- updateLocalsPython(UpdateParameters());
- else
- updateLocalsClassic();
-}
-
-// Parse a local variable from GdbMi.
-WatchData GdbEngine::localVariable(const GdbMi &item,
- const QStringList &uninitializedVariables,
- QMap<QByteArray, int> *seen)
-{
- // Local variables of inlined code are reported as
- // 26^done,locals={varobj={exp="this",value="",name="var4",exp="this",
- // numchild="1",type="const QtSharedPointer::Basic<CPlusPlus::..."}}
- // We do not want these at all. Current hypotheses is that those
- // "spurious" locals have _two_ "exp" field. Try to filter them:
- QByteArray name;
- if (m_isMacGdb) {
- int numExps = 0;
- foreach (const GdbMi &child, item.children())
- numExps += int(child.name() == "exp");
- if (numExps > 1)
- return WatchData();
- name = item["exp"].data();
- } else {
- name = item["name"].data();
- }
- const QMap<QByteArray, int>::iterator it = seen->find(name);
- if (it != seen->end()) {
- const int n = it.value();
- ++(it.value());
- WatchData data;
- QString nam = _(name);
- data.iname = "local." + name + QByteArray::number(n + 1);
- data.name = WatchData::shadowedName(nam, n);
- if (uninitializedVariables.contains(data.name)) {
- data.setError(WatchData::msgNotInScope());
- return data;
- }
- data.updateValue(item);
- //: Type of local variable or parameter shadowed by another
- //: variable of the same name in a nested block.
- data.setType(GdbEngine::tr("<shadowed>").toUtf8());
- data.setHasChildren(false);
- return data;
- }
- seen->insert(name, 1);
- WatchData data;
- QString nam = _(name);
- data.iname = "local." + name;
- data.name = nam;
- data.exp = name;
- data.updateType(item["type"]);
- if (uninitializedVariables.contains(data.name)) {
- data.setError(WatchData::msgNotInScope());
- return data;
- }
- if (isSynchronous()) {
- data.updateValue(item);
- // We know that the complete list of children is
- // somewhere in the response.
- data.setChildrenUnneeded();
- } else {
- // Set value only directly if it is simple enough, otherwise
- // pass through the insertData() machinery.
- if (isIntOrFloatType(data.type) || isPointerType(data.type))
- data.updateValue(item);
- }
-
- if (!watchHandler()->isExpandedIName(data.iname))
- data.setChildrenUnneeded();
-
- GdbMi t = item["numchild"];
- if (t.isValid())
- data.setHasChildren(t.toInt() > 0);
- else if (isPointerType(data.type) || data.name == QLatin1String("this"))
- data.setHasChildren(true);
- return data;
+ updateLocalsPython(UpdateParameters());
}
void GdbEngine::insertData(const WatchData &data)
@@ -4306,7 +3703,7 @@ void GdbEngine::insertData(const WatchData &data)
void GdbEngine::assignValueInDebugger(const WatchData *data,
const QString &expression, const QVariant &value)
{
- if (hasPython() && !isIntOrFloatType(data->type)) {
+ if (!isIntOrFloatType(data->type)) {
QByteArray cmd = "bbedit "
+ data->type.toHex() + ','
+ expression.toUtf8().toHex() + ','
@@ -4582,8 +3979,7 @@ void GdbEngine::fetchDisassemblerByCliRangeMixed(const DisassemblerAgentCookie &
const quint64 address = ac.agent->address();
QByteArray start = QByteArray::number(address - 20, 16);
QByteArray end = QByteArray::number(address + 100, 16);
- const char sep = m_disassembleUsesComma ? ',' : ' ';
- QByteArray cmd = "disassemble /m 0x" + start + sep + "0x" + end;
+ QByteArray cmd = "disassemble /m 0x" + start + ",0x" + end;
postCommand(cmd, Discardable|ConsoleCommand,
CB(handleFetchDisassemblerByCliRangeMixed), QVariant::fromValue(ac));
}
@@ -4595,8 +3991,7 @@ void GdbEngine::fetchDisassemblerByCliRangePlain(const DisassemblerAgentCookie &
const quint64 address = ac.agent->address();
QByteArray start = QByteArray::number(address - 20, 16);
QByteArray end = QByteArray::number(address + 100, 16);
- const char sep = m_disassembleUsesComma ? ',' : ' ';
- QByteArray cmd = "disassemble 0x" + start + sep + "0x" + end;
+ QByteArray cmd = "disassemble 0x" + start + ",0x" + end;
postCommand(cmd, Discardable,
CB(handleFetchDisassemblerByCliRangePlain), QVariant::fromValue(ac));
}
@@ -4987,14 +4382,6 @@ void GdbEngine::loadInitScript()
void GdbEngine::tryLoadPythonDumpers()
{
- if (m_forceAsyncModel)
- return;
- if (!m_hasPython)
- return;
- if (m_pythonAttemptedToLoad)
- return;
- m_pythonAttemptedToLoad = true;
-
const QByteArray dumperSourcePath =
Core::ICore::resourcePath().toLocal8Bit() + "/debugger/";
@@ -5010,11 +4397,7 @@ void GdbEngine::tryLoadPythonDumpers()
void GdbEngine::reloadDebuggingHelpers()
{
- // Only supported for python.
- if (m_hasPython) {
- m_pythonAttemptedToLoad = false;
- tryLoadPythonDumpers();
- }
+ tryLoadPythonDumpers();
}
void GdbEngine::handleGdbError(QProcess::ProcessError error)
@@ -5270,11 +4653,6 @@ void GdbEngine::handleAdapterCrashed(const QString &msg)
showMessageBox(QMessageBox::Critical, tr("Adapter crashed"), msg);
}
-bool GdbEngine::hasPython() const
-{
- return m_hasPython;
-}
-
void GdbEngine::createFullBacktrace()
{
postCommand("thread apply all bt full",
@@ -5363,9 +4741,6 @@ bool GdbEngine::isHiddenBreakpoint(const BreakpointResponseId &id) const
bool GdbEngine::usesExecInterrupt() const
{
- if (m_gdbVersion < 70000)
- return false;
-
// debuggerCore()->boolSetting(TargetAsync)
DebuggerStartMode mode = startParameters().startMode;
return (mode == AttachToRemoteServer || mode == AttachToRemoteProcess)
@@ -5390,9 +4765,6 @@ void GdbEngine::requestDebugInformation(const DebugInfoTask &task)
bool GdbEngine::attemptQuickStart() const
{
- if (m_forceAsyncModel)
- return false;
-
// Don't try if the user does not ask for it.
if (!debuggerCore()->boolSetting(AttemptQuickStart))
return false;
@@ -5484,6 +4856,11 @@ QByteArray GdbEngine::dotEscape(QByteArray str)
return str;
}
+void GdbEngine::debugLastCommand()
+{
+ postCommand(m_lastDebuggableCommand, Discardable);
+}
+
//
// Factory
//
@@ -5511,6 +4888,192 @@ void addGdbOptionPages(QList<Core::IOptionsPage *> *opts)
opts->push_back(new GdbOptionsPage2());
}
+
+void GdbEngine::updateLocalsPython(const UpdateParameters &params)
+{
+ //m_pendingWatchRequests = 0;
+ m_pendingBreakpointRequests = 0;
+ m_processedNames.clear();
+
+ WatchHandler *handler = watchHandler();
+ QByteArray expanded = "expanded:" + handler->expansionRequests() + ' ';
+ expanded += "typeformats:" + handler->typeFormatRequests() + ' ';
+ expanded += "formats:" + handler->individualFormatRequests();
+
+ QByteArray cutOff = " stringcutoff:"
+ + debuggerCore()->action(MaximalStringLength)->value().toByteArray();
+
+ QByteArray watchers;
+ const QString fileName = stackHandler()->currentFrame().file;
+ const QString function = stackHandler()->currentFrame().function;
+ if (!fileName.isEmpty()) {
+ // Re-create tooltip items that are not filters on existing local variables in
+ // the tooltip model.
+ DebuggerToolTipContexts toolTips =
+ DebuggerToolTipManager::treeWidgetExpressions(fileName, objectName(), function);
+
+ const QString currentExpression = tooltipExpression();
+ if (!currentExpression.isEmpty()) {
+ int currentIndex = -1;
+ for (int i = 0; i < toolTips.size(); ++i) {
+ if (toolTips.at(i).expression == currentExpression) {
+ currentIndex = i;
+ break;
+ }
+ }
+ if (currentIndex < 0) {
+ DebuggerToolTipContext context;
+ context.expression = currentExpression;
+ context.iname = tooltipIName(currentExpression);
+ toolTips.push_back(context);
+ }
+ }
+
+ foreach (const DebuggerToolTipContext &p, toolTips) {
+ if (p.iname.startsWith("tooltip")) {
+ if (!watchers.isEmpty())
+ watchers += "##";
+ watchers += p.expression.toLatin1();
+ watchers += '#';
+ watchers += p.iname;
+ }
+ }
+ }
+
+ QHash<QByteArray, int> watcherNames = handler->watcherNames();
+ QHashIterator<QByteArray, int> it(watcherNames);
+ while (it.hasNext()) {
+ it.next();
+ if (!watchers.isEmpty())
+ watchers += "##";
+ watchers += it.key() + "#watch." + QByteArray::number(it.value());
+ }
+
+ const static bool alwaysVerbose = !qgetenv("QTC_DEBUGGER_PYTHON_VERBOSE").isEmpty();
+ QByteArray options;
+ if (alwaysVerbose)
+ options += "pe,";
+ if (debuggerCore()->boolSetting(UseDebuggingHelpers))
+ options += "fancy,";
+ if (debuggerCore()->boolSetting(AutoDerefPointers))
+ options += "autoderef,";
+ if (debuggerCore()->boolSetting(UseDynamicType))
+ options += "dyntype,";
+ if (options.isEmpty())
+ options += "defaults,";
+ if (params.tryPartial)
+ options += "partial,";
+ if (params.tooltipOnly)
+ options += "tooltiponly,";
+ options.chop(1);
+
+ QByteArray resultVar;
+ if (!m_resultVarName.isEmpty())
+ resultVar = "resultvarname:" + m_resultVarName + ' ';
+
+ m_lastDebuggableCommand =
+ "bb options:pe," + options + " vars:" + params.varList + ' '
+ + expanded + " watchers:" + watchers.toHex() + cutOff;
+
+ postCommand("bb options:" + options + " vars:" + params.varList + ' '
+ + resultVar + expanded + " watchers:" + watchers.toHex() + cutOff,
+ Discardable, CB(handleStackFramePython), QVariant(params.tryPartial));
+}
+
+void GdbEngine::handleStackFramePython(const GdbResponse &response)
+{
+ if (response.resultClass == GdbResultDone) {
+ const bool partial = response.cookie.toBool();
+ QByteArray out = response.consoleStreamOutput;
+ while (out.endsWith(' ') || out.endsWith('\n'))
+ out.chop(1);
+ int pos = out.indexOf("data=");
+ if (pos != 0) {
+ showMessage(_("DISCARDING JUNK AT BEGIN OF RESPONSE: "
+ + out.left(pos)));
+ out = out.mid(pos);
+ }
+ GdbMi all;
+ all.fromStringMultiple(out);
+ GdbMi data = all["data"];
+
+ WatchHandler *handler = watchHandler();
+ QList<WatchData> list;
+
+ if (!partial) {
+ list.append(*handler->findData("local"));
+ list.append(*handler->findData("watch"));
+ list.append(*handler->findData("return"));
+ }
+
+ foreach (const GdbMi &child, data.children()) {
+ WatchData dummy;
+ dummy.iname = child["iname"].data();
+ GdbMi wname = child["wname"];
+ if (wname.isValid()) {
+ // Happens (only) for watched expressions. They are encoded as
+ // base64 encoded 8 bit data, without quotes
+ dummy.name = decodeData(wname.data(), Base64Encoded8Bit);
+ dummy.exp = dummy.name.toUtf8();
+ } else {
+ dummy.name = _(child["name"].data());
+ }
+ parseWatchData(handler->expandedINames(), dummy, child, &list);
+ }
+ const GdbMi typeInfo = all["typeinfo"];
+ if (typeInfo.type() == GdbMi::List) {
+ foreach (const GdbMi &s, typeInfo.children()) {
+ const GdbMi name = s["name"];
+ const GdbMi size = s["size"];
+ if (name.isValid() && size.isValid())
+ m_typeInfoCache.insert(QByteArray::fromBase64(name.data()),
+ TypeInfo(size.data().toUInt()));
+ }
+ }
+ for (int i = 0; i != list.size(); ++i) {
+ const TypeInfo ti = m_typeInfoCache.value(list.at(i).type);
+ if (ti.size)
+ list[i].size = ti.size;
+ }
+
+ handler->insertData(list);
+
+ //PENDING_DEBUG("AFTER handleStackFrame()");
+ // FIXME: This should only be used when updateLocals() was
+ // triggered by expanding an item in the view.
+ //if (m_pendingWatchRequests <= 0) {
+ //PENDING_DEBUG("\n\n .... AND TRIGGERS MODEL UPDATE\n");
+ rebuildWatchModel();
+ //}
+ if (!partial)
+ emit stackFrameCompleted();
+ } else {
+ showMessage(_("DUMPER FAILED: " + response.toString()));
+ }
+}
+
+QString GdbEngine::msgPtraceError(DebuggerStartMode sm)
+{
+ if (sm == StartInternal) {
+ return QCoreApplication::translate("QtDumperHelper",
+ "ptrace: Operation not permitted.\n\n"
+ "Could not attach to the process. "
+ "Make sure no other debugger traces this process.\n"
+ "Check the settings of\n"
+ "/proc/sys/kernel/yama/ptrace_scope\n"
+ "For more details, see /etc/sysctl.d/10-ptrace.conf\n");
+ }
+ return QCoreApplication::translate("QtDumperHelper",
+ "ptrace: Operation not permitted.\n\n"
+ "Could not attach to the process. "
+ "Make sure no other debugger traces this process.\n"
+ "If your uid matches the uid\n"
+ "of the target process, check the settings of\n"
+ "/proc/sys/kernel/yama/ptrace_scope\n"
+ "For more details, see /etc/sysctl.d/10-ptrace.conf\n");
+}
+
+
} // namespace Internal
} // namespace Debugger
diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h
index 7146a6c10f..c4f3a78fa1 100644
--- a/src/plugins/debugger/gdb/gdbengine.h
+++ b/src/plugins/debugger/gdb/gdbengine.h
@@ -58,131 +58,6 @@ class WatchData;
class DisassemblerAgentCookie;
class DisassemblerLines;
-enum DebuggingHelperState
-{
- DebuggingHelperUninitialized,
- DebuggingHelperLoadTried,
- DebuggingHelperAvailable,
- DebuggingHelperUnavailable
-};
-
-/* This is only used with Mac gdb since 2.2
- *
- * "Custom dumper" is a library compiled against the current
- * Qt containing functions to evaluate values of Qt classes
- * (such as QString, taking pointers to their addresses).
- * The library must be loaded into the debuggee.
- * It provides a function that takes input from an input buffer
- * and some parameters and writes output into an output buffer.
- * Parameter 1 is the protocol:
- * 1) Query. Fills output buffer with known types, Qt version and namespace.
- * This information is parsed and stored by this class (special type
- * enumeration).
- * 2) Evaluate symbol, taking address and some additional parameters
- * depending on type. */
-
-class DumperHelper
-{
-public:
- enum Type {
- UnknownType,
- SupportedType, // A type that requires no special handling by the dumper
- // Below types require special handling
- QAbstractItemType,
- QObjectType, QWidgetType, QObjectSlotType, QObjectSignalType,
- QVectorType, QMapType, QMultiMapType, QMapNodeType, QStackType,
- StdVectorType, StdDequeType, StdSetType, StdMapType, StdStackType,
- StdStringType
- };
-
- // Type/Parameter struct required for building a value query
- struct TypeData {
- TypeData();
- void clear();
-
- Type type;
- bool isTemplate;
- QByteArray tmplate;
- QByteArray inner;
- };
-
- DumperHelper();
- void clear();
-
- double dumperVersion() const { return m_dumperVersion; }
-
- int typeCount() const;
- // Look up a simple, non-template type
- Type simpleType(const QByteArray &simpleType) const;
- // Look up a (potentially) template type and fill parameter struct
- TypeData typeData(const QByteArray &typeName) const;
- Type type(const QByteArray &typeName) const;
-
- int qtVersion() const;
- QByteArray qtVersionString() const;
- QByteArray qtNamespace() const;
- void setQtNamespace(const QByteArray &ba)
- { if (!ba.isEmpty()) m_qtNamespace = ba; }
-
- // Complete parse of "query" (protocol 1) response from debuggee buffer.
- // 'data' excludes the leading indicator character.
- bool parseQuery(const GdbMi &data);
- // Sizes can be added as the debugger determines them
- void addSize(const QByteArray &type, int size);
-
- // Determine the parameters required for an "evaluate" (protocol 2) call
- void evaluationParameters(const WatchData &data,
- const TypeData &td,
- QByteArray *inBuffer,
- QList<QByteArray> *extraParameters) const;
-
- QString toString(bool debug = false) const;
-
- static QString msgDumperOutdated(double requiredVersion, double currentVersion);
- static QString msgPtraceError(DebuggerStartMode sm);
-
-private:
- typedef QMap<QByteArray, Type> NameTypeMap;
- typedef QMap<QByteArray, int> SizeCache;
-
- // Look up a simple (namespace) type
- QByteArray evaluationSizeofTypeExpression(const QByteArray &typeName) const;
-
- NameTypeMap m_nameTypeMap;
- SizeCache m_sizeCache;
-
- // The initial dumper query function returns sizes of some special
- // types to aid CDB since it cannot determine the size of classes.
- // They are not complete (std::allocator<X>).
- enum SpecialSizeType { IntSize, PointerSize, StdAllocatorSize,
- QSharedPointerSize, QSharedDataPointerSize,
- QWeakPointerSize, QPointerSize,
- QListSize, QLinkedListSize, QVectorSize, QQueueSize,
- SpecialSizeCount };
-
- // Resolve name to enumeration or SpecialSizeCount (invalid)
- SpecialSizeType specialSizeType(const QByteArray &type) const;
-
- int m_specialSizes[SpecialSizeCount];
-
- typedef QMap<QByteArray, QByteArray> ExpressionCache;
- ExpressionCache m_expressionCache;
- int m_qtVersion;
- double m_dumperVersion;
- QByteArray m_qtNamespace;
-
- void setQClassPrefixes(const QByteArray &qNamespace);
-
- QByteArray m_qPointerPrefix;
- QByteArray m_qSharedPointerPrefix;
- QByteArray m_qSharedDataPointerPrefix;
- QByteArray m_qWeakPointerPrefix;
- QByteArray m_qListPrefix;
- QByteArray m_qLinkedListPrefix;
- QByteArray m_qVectorPrefix;
- QByteArray m_qQueuePrefix;
-};
-
class GdbEngine : public Debugger::DebuggerEngine
{
Q_OBJECT
@@ -206,9 +81,8 @@ private: ////////// General Interface //////////
virtual bool acceptsDebuggerCommands() const;
virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
- virtual QByteArray qtNamespace() const { return m_dumperHelper.qtNamespace(); }
- virtual void setQtNamespace(const QByteArray &ns)
- { return m_dumperHelper.setQtNamespace(ns); }
+ virtual QByteArray qtNamespace() const { return m_qtNamespace; }
+ virtual void setQtNamespace(const QByteArray &ns) { m_qtNamespace = ns; }
private: ////////// General State //////////
@@ -228,7 +102,6 @@ protected: ////////// Gdb Process Management //////////
void loadInitScript();
void tryLoadPythonDumpers();
- void pythonDumpersFailed();
// Something went wrong with the adapter *before* adapterStarted() was emitted.
// Make sure to clean up everything before emitting this signal.
@@ -359,7 +232,6 @@ private:
CommandsDoneCallback m_commandsDoneCallback;
QList<GdbCommand> m_commandsToRunOnTemporaryBreak;
- int gdbVersion() const { return m_gdbVersion; }
private: ////////// Gdb Output, State & Capability Handling //////////
protected:
@@ -374,9 +246,7 @@ protected:
StackFrame parseStackFrame(const GdbMi &mi, int level);
void resetCommandQueue();
- bool isSynchronous() const { return hasPython(); }
- virtual bool hasPython() const;
- bool supportsThreads() const;
+ bool isSynchronous() const { return true; }
// Gdb initialization sequence
void handleShowVersion(const GdbResponse &response);
@@ -384,12 +254,8 @@ protected:
void handleHasPython(const GdbResponse &response);
void handlePythonSetup(const GdbResponse &response);
- int m_gdbVersion; // 6.8.0 is 60800
- int m_gdbBuildVersion; // MAC only?
- bool m_isMacGdb;
+ int m_gdbVersion; // 7.6.1 is 70601
bool m_isQnxGdb;
- bool m_hasBreakpointNotifications;
- bool m_hasPython;
private: ////////// Inferior Management //////////
@@ -428,9 +294,9 @@ private: ////////// Inferior Management //////////
void maybeHandleInferiorPidChanged(const QString &pid);
void handleInfoProc(const GdbResponse &response);
+ QString msgPtraceError(DebuggerStartMode sm);
private: ////////// View & Data Stuff //////////
- protected:
void selectThread(ThreadId threadId);
void activateFrame(int index);
@@ -439,10 +305,7 @@ private: ////////// View & Data Stuff //////////
//
// Breakpoint specific stuff
//
- void handleBreakList(const GdbResponse &response);
- void handleBreakList(const GdbMi &table);
void handleBreakModifications(const GdbMi &bkpts);
- void handleBreakListMultiple(const GdbResponse &response);
void handleBreakIgnore(const GdbResponse &response);
void handleBreakDisable(const GdbResponse &response);
void handleBreakEnable(const GdbResponse &response);
@@ -455,18 +318,15 @@ private: ////////// View & Data Stuff //////////
void handleWatchInsert(const GdbResponse &response);
void handleCatchInsert(const GdbResponse &response);
void handleBkpt(const GdbMi &bkpt, const BreakpointModelId &id);
- void handleInfoLine(const GdbResponse &response);
- void extractDataFromInfoBreak(const QString &output, BreakpointModelId);
void updateResponse(BreakpointResponse &response, const GdbMi &bkpt);
QByteArray breakpointLocation(BreakpointModelId id); // For gdb/MI.
QByteArray breakpointLocation2(BreakpointModelId id); // For gdb/CLI fallback.
QString breakLocation(const QString &file) const;
- void reloadBreakListInternal();
- void attemptAdjustBreakpointLocation(BreakpointModelId id);
//
// Modules specific stuff
//
+ protected:
void loadSymbols(const QString &moduleName);
Q_SLOT void loadAllSymbols();
void loadSymbolsForStack();
@@ -474,6 +334,7 @@ private: ////////// View & Data Stuff //////////
void requestModuleSections(const QString &moduleName);
void reloadModules();
void examineModules();
+
void reloadModulesInternal();
void handleModulesList(const GdbResponse &response);
void handleShowModuleSymbols(const GdbResponse &response);
@@ -522,8 +383,6 @@ private: ////////// View & Data Stuff //////////
DisassemblerLines parseMiDisassembler(const GdbMi &response);
Q_SLOT void reloadDisassembly();
- bool m_disassembleUsesComma;
-
//
// Source file specific stuff
//
@@ -539,17 +398,13 @@ private: ////////// View & Data Stuff //////////
QMap<QString, QString> m_fullToShortName;
QMultiMap<QString, QString> m_baseNameToFullName;
- void invalidateSourcesList();
bool m_sourcesListUpdating;
- bool m_breakListOutdated;
//
// Stack specific stuff
//
protected:
void updateAll();
- void updateAllClassic();
- void updateAllPython();
void handleStackListFrames(const GdbResponse &response);
void handleStackSelectThread(const GdbResponse &response);
void handleStackSelectFrame(const GdbResponse &response);
@@ -581,34 +436,14 @@ protected:
virtual void watchPoint(const QPoint &);
void handleWatchPoint(const GdbResponse &response);
- void updateSubItemClassic(const WatchData &data);
-
void updateWatchData(const WatchData &data, const WatchUpdateFlags &flags);
void rebuildWatchModel();
void showToolTip();
void insertData(const WatchData &data);
- void sendWatchParameters(const QByteArray &params0);
- void createGdbVariableClassic(const WatchData &data);
-
- void runDebuggingHelperClassic(const WatchData &data, bool dumpChildren);
- void runDirectDebuggingHelperClassic(const WatchData &data, bool dumpChildren);
- bool hasDebuggingHelperForType(const QByteArray &type) const;
- void handleVarListChildrenClassic(const GdbResponse &response);
- void handleVarListChildrenHelperClassic(const GdbMi &child,
- const WatchData &parent, int sortId);
- void handleVarCreate(const GdbResponse &response);
void handleVarAssign(const GdbResponse &response);
- void handleEvaluateExpressionClassic(const GdbResponse &response);
- void handleQueryDebuggingHelperClassic(const GdbResponse &response);
- void handleDebuggingHelperValue2Classic(const GdbResponse &response);
- void handleDebuggingHelperValue3Classic(const GdbResponse &response);
- void handleDebuggingHelperEditValue(const GdbResponse &response);
- void handleDebuggingHelperSetup(const GdbResponse &response);
- void handleDebuggingHelperVersionCheckClassic(const GdbResponse &response);
void handleDetach(const GdbResponse &response);
-
void handleThreadGroupCreated(const GdbMi &result);
void handleThreadGroupExited(const GdbMi &result);
@@ -616,17 +451,10 @@ protected:
void handleCreateFullBacktrace(const GdbResponse &response);
void updateLocals();
- void updateLocalsClassic();
void updateLocalsPython(const UpdateParameters &parameters);
void handleStackFramePython(const GdbResponse &response);
- void handleStackListLocalsClassic(const GdbResponse &response);
-
- WatchData localVariable(const GdbMi &item,
- const QStringList &uninitializedVariables,
- QMap<QByteArray, int> *seen);
void setLocals(const QList<GdbMi> &locals);
- void handleStackListArgumentsClassic(const GdbResponse &response);
QSet<QByteArray> m_processedNames;
struct TypeInfo
@@ -641,13 +469,9 @@ protected:
//
// Dumper Management
//
- bool checkDebuggingHelpersClassic();
- void setDebuggingHelperStateClassic(DebuggingHelperState);
- void tryLoadDebuggingHelpersClassic();
void reloadDebuggingHelpers();
- DebuggingHelperState m_debuggingHelperState;
- DumperHelper m_dumperHelper;
+ QByteArray m_qtNamespace;
QString m_gdb;
//
@@ -699,10 +523,8 @@ protected:
bool attemptQuickStart() const;
bool m_fullStartDone;
bool m_systemDumpersLoaded;
- bool m_pythonAttemptedToLoad;
// Test
- bool m_forceAsyncModel;
QList<WatchData> m_completed;
QSet<QByteArray> m_uncompleted;
@@ -714,19 +536,12 @@ protected:
static QString msgConnectRemoteServerFailed(const QString &why);
static QByteArray dotEscape(QByteArray str);
-protected:
- enum DumperHandling
- {
- DumperNotAvailable,
- DumperLoadedByAdapter,
- DumperLoadedByGdbPreload,
- DumperLoadedByGdb
- };
+ void debugLastCommand();
+ QByteArray m_lastDebuggableCommand;
+protected:
virtual void write(const QByteArray &data);
- virtual DumperHandling dumperHandling() const = 0;
-
protected:
bool prepareCommand();
void interruptLocalInferior(qint64 pid);
@@ -735,7 +550,6 @@ protected:
ProjectExplorer::DeviceProcessSignalOperation::Ptr m_signalOperation;
};
-
} // namespace Internal
} // namespace Debugger
diff --git a/src/plugins/debugger/gdb/gdboptionspage.cpp b/src/plugins/debugger/gdb/gdboptionspage.cpp
index 518a3f2841..719778a743 100644
--- a/src/plugins/debugger/gdb/gdboptionspage.cpp
+++ b/src/plugins/debugger/gdb/gdboptionspage.cpp
@@ -54,7 +54,7 @@ namespace Internal {
class GdbOptionsPageWidget : public QWidget
{
public:
- explicit GdbOptionsPageWidget(QWidget *parent);
+ explicit GdbOptionsPageWidget(QWidget *parent = 0);
QGroupBox *groupBoxGeneral;
QLabel *labelGdbWatchdogTimeout;
@@ -83,7 +83,6 @@ public:
//QLineEdit *lineEditSelectedPluginBreakpointsPattern;
Utils::SavedActionSet group;
- QString searchKeywords;
};
GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
@@ -297,19 +296,6 @@ GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
// setEnabled(dc->action(SelectedPluginBreakpoints)->value().toBool());
//connect(radioButtonSelectedPluginBreakpoints, SIGNAL(toggled(bool)),
// lineEditSelectedPluginBreakpointsPattern, SLOT(setEnabled(bool)));
-
- const QLatin1Char sep(' ');
- QTextStream(&searchKeywords)
- << sep << groupBoxGeneral->title()
- << sep << checkBoxLoadGdbInit->text()
- << sep << checkBoxLoadGdbDumpers->text()
- << sep << checkBoxUseDynamicType->text()
- << sep << labelGdbWatchdogTimeout->text()
- << sep << checkBoxSkipKnownFrames->text()
- << sep << checkBoxUseMessageBoxForSignals->text()
- << sep << checkBoxAdjustBreakpointLocations->text();
- ;
- searchKeywords.remove(QLatin1Char('&'));
}
GdbOptionsPage::GdbOptionsPage()
@@ -325,9 +311,10 @@ GdbOptionsPage::~GdbOptionsPage()
{
}
-QWidget *GdbOptionsPage::createPage(QWidget *parent)
+QWidget *GdbOptionsPage::widget()
{
- m_widget = new GdbOptionsPageWidget(parent);
+ if (!m_widget)
+ m_widget = new GdbOptionsPageWidget;
return m_widget;
}
@@ -339,13 +326,10 @@ void GdbOptionsPage::apply()
void GdbOptionsPage::finish()
{
- if (m_widget)
+ if (m_widget) {
m_widget->group.finish();
-}
-
-bool GdbOptionsPage::matches(const QString &s) const
-{
- return m_widget && m_widget->searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
+ }
}
/////////////////////////////////////////////////////////////////////////
@@ -357,7 +341,7 @@ bool GdbOptionsPage::matches(const QString &s) const
class GdbOptionsPageWidget2 : public QWidget
{
public:
- explicit GdbOptionsPageWidget2(QWidget *parent);
+ explicit GdbOptionsPageWidget2(QWidget *parent = 0);
QGroupBox *groupBoxDangerous;
QLabel *labelDangerous;
@@ -371,7 +355,6 @@ public:
QCheckBox *checkBoxMultiInferior;
Utils::SavedActionSet group;
- QString searchKeywords;
};
GdbOptionsPageWidget2::GdbOptionsPageWidget2(QWidget *parent)
@@ -398,7 +381,7 @@ GdbOptionsPageWidget2::GdbOptionsPageWidget2(QWidget *parent)
checkBoxAutoEnrichParameters->setText(GdbOptionsPage::tr(
"Use common locations for debug information"));
checkBoxAutoEnrichParameters->setToolTip(GdbOptionsPage::tr(
- "<html><head/><body>Add common paths to locations "
+ "<html><head/><body>Adds common paths to locations "
"of debug information such as <i>/usr/src/debug</i> "
"when starting GDB.</body></html>"));
@@ -418,7 +401,7 @@ GdbOptionsPageWidget2::GdbOptionsPageWidget2(QWidget *parent)
checkBoxEnableReverseDebugging = new QCheckBox(groupBoxDangerous);
checkBoxEnableReverseDebugging->setText(GdbOptionsPage::tr("Enable reverse debugging"));
checkBoxEnableReverseDebugging->setToolTip(GdbOptionsPage::tr(
- "<html><head/><body><p>Enable stepping backwards.</p><p>"
+ "<html><head/><body><p>Enables stepping backwards.</p><p>"
"<b>Note:</b> This feature is very slow and unstable on the GDB side. "
"It exhibits unpredictable behavior when going backwards over system "
"calls and is very likely to destroy your debugging session.</p></body></html>"));
@@ -426,14 +409,14 @@ GdbOptionsPageWidget2::GdbOptionsPageWidget2(QWidget *parent)
checkBoxAttemptQuickStart = new QCheckBox(groupBoxDangerous);
checkBoxAttemptQuickStart->setText(GdbOptionsPage::tr("Attempt quick start"));
checkBoxAttemptQuickStart->setToolTip(GdbOptionsPage::tr(
- "<html><head/><body>Postpone reading debug information as long as possible. "
+ "<html><head/><body>Postpones reading debug information as long as possible. "
"This can result in faster startup times at the price of not being able to "
"set breakpoints by file and number.</body></html>"));
checkBoxMultiInferior = new QCheckBox(groupBoxDangerous);
checkBoxMultiInferior->setText(GdbOptionsPage::tr("Debug all children"));
checkBoxMultiInferior->setToolTip(GdbOptionsPage::tr(
- "<html><head/><body>Keep debugging all children after a fork."
+ "<html><head/><body>Keeps debugging all children after a fork."
"</body></html>"));
@@ -460,16 +443,6 @@ GdbOptionsPageWidget2::GdbOptionsPageWidget2(QWidget *parent)
group.insert(dc->action(AttemptQuickStart), checkBoxAttemptQuickStart);
group.insert(dc->action(MultiInferior), checkBoxMultiInferior);
group.insert(dc->action(EnableReverseDebugging), checkBoxEnableReverseDebugging);
-
- const QLatin1Char sep(' ');
- QTextStream(&searchKeywords)
- << sep << groupBoxDangerous->title()
- << sep << checkBoxTargetAsync->text()
- << sep << checkBoxEnableReverseDebugging->text()
- << sep << checkBoxAttemptQuickStart->text()
- << sep << checkBoxMultiInferior->text()
- ;
- searchKeywords.remove(QLatin1Char('&'));
}
GdbOptionsPage2::GdbOptionsPage2()
@@ -485,9 +458,10 @@ GdbOptionsPage2::~GdbOptionsPage2()
{
}
-QWidget *GdbOptionsPage2::createPage(QWidget *parent)
+QWidget *GdbOptionsPage2::widget()
{
- m_widget = new GdbOptionsPageWidget2(parent);
+ if (!m_widget)
+ m_widget = new GdbOptionsPageWidget2;
return m_widget;
}
@@ -499,13 +473,10 @@ void GdbOptionsPage2::apply()
void GdbOptionsPage2::finish()
{
- if (m_widget)
+ if (m_widget) {
m_widget->group.finish();
-}
-
-bool GdbOptionsPage2::matches(const QString &s) const
-{
- return m_widget && m_widget->searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
+ }
}
} // namespace Internal
diff --git a/src/plugins/debugger/gdb/gdboptionspage.h b/src/plugins/debugger/gdb/gdboptionspage.h
index 8dacb9bb2d..beda3989dc 100644
--- a/src/plugins/debugger/gdb/gdboptionspage.h
+++ b/src/plugins/debugger/gdb/gdboptionspage.h
@@ -46,10 +46,9 @@ class GdbOptionsPage : public Core::IOptionsPage
public:
GdbOptionsPage();
~GdbOptionsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &) const;
private:
QPointer<GdbOptionsPageWidget> m_widget;
@@ -63,10 +62,9 @@ class GdbOptionsPage2 : public Core::IOptionsPage
public:
GdbOptionsPage2();
~GdbOptionsPage2();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &) const;
private:
QPointer<GdbOptionsPageWidget2> m_widget;
diff --git a/src/plugins/debugger/gdb/gdbplainengine.cpp b/src/plugins/debugger/gdb/gdbplainengine.cpp
index c9651c9ee0..366395db64 100644
--- a/src/plugins/debugger/gdb/gdbplainengine.cpp
+++ b/src/plugins/debugger/gdb/gdbplainengine.cpp
@@ -112,13 +112,6 @@ void GdbPlainEngine::handleExecRun(const GdbResponse &response)
}
}
-GdbEngine::DumperHandling GdbPlainEngine::dumperHandling() const
-{
- // LD_PRELOAD fails for System-Qt on Mac.
- return Utils::HostOsInfo::isWindowsHost() || Utils::HostOsInfo::isMacHost()
- ? DumperLoadedByGdb : DumperLoadedByGdbPreload;
-}
-
void GdbPlainEngine::setupEngine()
{
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
diff --git a/src/plugins/debugger/gdb/gdbplainengine.h b/src/plugins/debugger/gdb/gdbplainengine.h
index 0b9f79d278..df2894ecc4 100644
--- a/src/plugins/debugger/gdb/gdbplainengine.h
+++ b/src/plugins/debugger/gdb/gdbplainengine.h
@@ -55,8 +55,6 @@ private:
void interruptInferior2();
void shutdownEngine();
- DumperHandling dumperHandling() const;
-
QByteArray execFilePath() const;
QByteArray toLocalEncoding(const QString &s) const;
QString fromLocalEncoding(const QByteArray &b) const;
diff --git a/src/plugins/debugger/gdb/pythongdbengine.cpp b/src/plugins/debugger/gdb/pythongdbengine.cpp
deleted file mode 100644
index fa560cdca0..0000000000
--- a/src/plugins/debugger/gdb/pythongdbengine.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "gdbengine.h"
-
-#include <debugger/debuggerprotocol.h>
-#include <debugger/debuggeractions.h>
-#include <debugger/debuggercore.h>
-#include <debugger/debuggerstringutils.h>
-#include <debugger/debuggertooltipmanager.h>
-
-#include <debugger/stackhandler.h>
-
-#include <utils/savedaction.h>
-#include <utils/qtcassert.h>
-
-#define PRECONDITION QTC_CHECK(hasPython())
-#define CB(callback) &GdbEngine::callback, STRINGIFY(callback)
-
-
-namespace Debugger {
-namespace Internal {
-
-void GdbEngine::updateLocalsPython(const UpdateParameters &params)
-{
- PRECONDITION;
- //m_pendingWatchRequests = 0;
- m_pendingBreakpointRequests = 0;
- m_processedNames.clear();
-
- WatchHandler *handler = watchHandler();
- QByteArray expanded = "expanded:" + handler->expansionRequests() + ' ';
- expanded += "typeformats:" + handler->typeFormatRequests() + ' ';
- expanded += "formats:" + handler->individualFormatRequests();
-
- QByteArray cutOff = " stringcutoff:"
- + debuggerCore()->action(MaximalStringLength)->value().toByteArray();
-
- QByteArray watchers;
- const QString fileName = stackHandler()->currentFrame().file;
- const QString function = stackHandler()->currentFrame().function;
- if (!fileName.isEmpty()) {
- // Re-create tooltip items that are not filters on existing local variables in
- // the tooltip model.
- DebuggerToolTipContexts toolTips =
- DebuggerToolTipManager::treeWidgetExpressions(fileName, objectName(), function);
-
- const QString currentExpression = tooltipExpression();
- if (!currentExpression.isEmpty()) {
- int currentIndex = -1;
- for (int i = 0; i < toolTips.size(); ++i) {
- if (toolTips.at(i).expression == currentExpression) {
- currentIndex = i;
- break;
- }
- }
- if (currentIndex < 0) {
- DebuggerToolTipContext context;
- context.expression = currentExpression;
- context.iname = tooltipIName(currentExpression);
- toolTips.push_back(context);
- }
- }
-
- foreach (const DebuggerToolTipContext &p, toolTips) {
- if (p.iname.startsWith("tooltip")) {
- if (!watchers.isEmpty())
- watchers += "##";
- watchers += p.expression.toLatin1();
- watchers += '#';
- watchers += p.iname;
- }
- }
- }
-
- QHash<QByteArray, int> watcherNames = handler->watcherNames();
- QHashIterator<QByteArray, int> it(watcherNames);
- while (it.hasNext()) {
- it.next();
- if (!watchers.isEmpty())
- watchers += "##";
- watchers += it.key() + "#watch." + QByteArray::number(it.value());
- }
-
- const static bool alwaysVerbose = !qgetenv("QTC_DEBUGGER_PYTHON_VERBOSE").isEmpty();
- QByteArray options;
- if (alwaysVerbose)
- options += "pe,";
- if (debuggerCore()->boolSetting(UseDebuggingHelpers))
- options += "fancy,";
- if (debuggerCore()->boolSetting(AutoDerefPointers))
- options += "autoderef,";
- if (debuggerCore()->boolSetting(UseDynamicType))
- options += "dyntype,";
- if (options.isEmpty())
- options += "defaults,";
- if (params.tryPartial)
- options += "partial,";
- if (params.tooltipOnly)
- options += "tooltiponly,";
- options.chop(1);
-
- QByteArray resultVar;
- if (!m_resultVarName.isEmpty())
- resultVar = "resultvarname:" + m_resultVarName + ' ';
-
- postCommand("bb options:" + options + " vars:" + params.varList + ' '
- + resultVar + expanded + " watchers:" + watchers.toHex() + cutOff,
- Discardable, CB(handleStackFramePython), QVariant(params.tryPartial));
-}
-
-void GdbEngine::handleStackFramePython(const GdbResponse &response)
-{
- PRECONDITION;
- if (response.resultClass == GdbResultDone) {
- const bool partial = response.cookie.toBool();
- QByteArray out = response.consoleStreamOutput;
- while (out.endsWith(' ') || out.endsWith('\n'))
- out.chop(1);
- int pos = out.indexOf("data=");
- if (pos != 0) {
- showMessage(_("DISCARDING JUNK AT BEGIN OF RESPONSE: "
- + out.left(pos)));
- out = out.mid(pos);
- }
- GdbMi all;
- all.fromStringMultiple(out);
- GdbMi data = all["data"];
-
- WatchHandler *handler = watchHandler();
- QList<WatchData> list;
-
- if (!partial) {
- list.append(*handler->findData("local"));
- list.append(*handler->findData("watch"));
- list.append(*handler->findData("return"));
- }
-
- foreach (const GdbMi &child, data.children()) {
- WatchData dummy;
- dummy.iname = child["iname"].data();
- GdbMi wname = child["wname"];
- if (wname.isValid()) {
- // Happens (only) for watched expressions. They are encoded as
- // base64 encoded 8 bit data, without quotes
- dummy.name = decodeData(wname.data(), Base64Encoded8Bit);
- dummy.exp = dummy.name.toUtf8();
- } else {
- dummy.name = _(child["name"].data());
- }
- parseWatchData(handler->expandedINames(), dummy, child, &list);
- }
- const GdbMi typeInfo = all["typeinfo"];
- if (typeInfo.type() == GdbMi::List) {
- foreach (const GdbMi &s, typeInfo.children()) {
- const GdbMi name = s["name"];
- const GdbMi size = s["size"];
- if (name.isValid() && size.isValid())
- m_typeInfoCache.insert(QByteArray::fromBase64(name.data()),
- TypeInfo(size.data().toUInt()));
- }
- }
- for (int i = 0; i != list.size(); ++i) {
- const TypeInfo ti = m_typeInfoCache.value(list.at(i).type);
- if (ti.size)
- list[i].size = ti.size;
- }
-
- handler->insertData(list);
-
- //PENDING_DEBUG("AFTER handleStackFrame()");
- // FIXME: This should only be used when updateLocals() was
- // triggered by expanding an item in the view.
- //if (m_pendingWatchRequests <= 0) {
- //PENDING_DEBUG("\n\n .... AND TRIGGERS MODEL UPDATE\n");
- rebuildWatchModel();
- //}
- if (!partial)
- emit stackFrameCompleted();
- } else {
- showMessage(_("DUMPER FAILED: " + response.toString()));
- }
-}
-
-// Called from CoreAdapter and AttachAdapter
-void GdbEngine::updateAllPython()
-{
- PRECONDITION;
- //PENDING_DEBUG("UPDATING ALL\n");
- QTC_CHECK(state() == InferiorUnrunnable || state() == InferiorStopOk);
- reloadModulesInternal();
- postCommand("-stack-list-frames", CB(handleStackListFrames),
- QVariant::fromValue<StackCookie>(StackCookie(false, true)));
- stackHandler()->setCurrentIndex(0);
- postCommand("-thread-info", CB(handleThreadInfo), 0);
- reloadRegisters();
- updateLocals();
-}
-
-} // namespace Internal
-} // namespace Debugger
diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp
index 9b62f422f6..3554ade37f 100644
--- a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp
+++ b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp
@@ -75,16 +75,6 @@ GdbRemoteServerEngine::GdbRemoteServerEngine(const DebuggerStartParameters &star
SLOT(uploadProcFinished()));
}
-GdbEngine::DumperHandling GdbRemoteServerEngine::dumperHandling() const
-{
- using namespace ProjectExplorer;
- const Abi abi = startParameters().toolChainAbi;
- if (abi.os() == Abi::WindowsOS
- || abi.binaryFormat() == Abi::ElfFormat)
- return DumperLoadedByGdb;
- return DumperLoadedByGdbPreload;
-}
-
void GdbRemoteServerEngine::setupEngine()
{
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
@@ -378,7 +368,7 @@ void GdbRemoteServerEngine::handleAttach(const GdbResponse &response)
}
case GdbResultError:
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
- notifyInferiorSetupFailed(DumperHelper::msgPtraceError(startParameters().startMode));
+ notifyInferiorSetupFailed(msgPtraceError(startParameters().startMode));
break;
}
// if msg != "ptrace: ..." fall through
diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.h b/src/plugins/debugger/gdb/remotegdbserveradapter.h
index 38daa7dbc9..b6548a98b6 100644
--- a/src/plugins/debugger/gdb/remotegdbserveradapter.h
+++ b/src/plugins/debugger/gdb/remotegdbserveradapter.h
@@ -49,8 +49,6 @@ public:
explicit GdbRemoteServerEngine(const DebuggerStartParameters &startParameters);
private:
- DumperHandling dumperHandling() const;
-
void setupEngine();
void setupInferior();
void runEngine();
diff --git a/src/plugins/debugger/gdb/termgdbadapter.cpp b/src/plugins/debugger/gdb/termgdbadapter.cpp
index 5f372e8386..9251be8f7c 100644
--- a/src/plugins/debugger/gdb/termgdbadapter.cpp
+++ b/src/plugins/debugger/gdb/termgdbadapter.cpp
@@ -74,14 +74,6 @@ GdbTermEngine::~GdbTermEngine()
m_stubProc.disconnect(); // Avoid spurious state transitions from late exiting stub
}
-GdbEngine::DumperHandling GdbTermEngine::dumperHandling() const
-{
- // LD_PRELOAD fails for System-Qt on Mac.
- return Utils::HostOsInfo::isWindowsHost() || Utils::HostOsInfo::isMacHost()
- ? DumperLoadedByGdb
- : DumperLoadedByAdapter; // Handles loading itself via LD_PRELOAD
-}
-
void GdbTermEngine::setupEngine()
{
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
@@ -169,7 +161,7 @@ void GdbTermEngine::handleStubAttached(const GdbResponse &response)
break;
case GdbResultError:
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
- notifyInferiorSetupFailed(DumperHelper::msgPtraceError(startParameters().startMode));
+ notifyInferiorSetupFailed(msgPtraceError(startParameters().startMode));
break;
}
notifyInferiorSetupFailed(QString::fromLocal8Bit(response.data["msg"].data()));
diff --git a/src/plugins/debugger/gdb/termgdbadapter.h b/src/plugins/debugger/gdb/termgdbadapter.h
index ac84271d39..f91602f973 100644
--- a/src/plugins/debugger/gdb/termgdbadapter.h
+++ b/src/plugins/debugger/gdb/termgdbadapter.h
@@ -52,8 +52,6 @@ public:
~GdbTermEngine();
private:
- DumperHandling dumperHandling() const;
-
void setupEngine();
void handleGdbStartFailed();
void setupInferior();
diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp
index e640c87257..624200d840 100644
--- a/src/plugins/debugger/lldb/lldbengine.cpp
+++ b/src/plugins/debugger/lldb/lldbengine.cpp
@@ -120,6 +120,11 @@ void LldbEngine::runCommand(const Command &command)
m_lldbProc.write(cmd);
}
+void LldbEngine::debugLastCommand()
+{
+ runCommand(m_lastDebuggableCommand);
+}
+
void LldbEngine::shutdownInferior()
{
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
@@ -829,6 +834,9 @@ void LldbEngine::doUpdateLocals(UpdateParameters params)
//cmd.arg("resultvarname", m_resultVarName);
+ m_lastDebuggableCommand = cmd;
+ m_lastDebuggableCommand.args.replace("\"passexceptions\":0", "\"passexceptions\":1");
+
runCommand(cmd);
reloadRegisters();
diff --git a/src/plugins/debugger/lldb/lldbengine.h b/src/plugins/debugger/lldb/lldbengine.h
index b5e0a2c4ea..d1974b3867 100644
--- a/src/plugins/debugger/lldb/lldbengine.h
+++ b/src/plugins/debugger/lldb/lldbengine.h
@@ -192,6 +192,8 @@ private:
QList<WatchData> *list);
void runCommand(const Command &cmd);
+ void debugLastCommand();
+ Command m_lastDebuggableCommand;
QByteArray m_inbuffer;
QString m_scriptFileName;
diff --git a/src/plugins/debugger/lldblib/guest/README b/src/plugins/debugger/lldblib/guest/README
deleted file mode 100644
index be9d4fbee7..0000000000
--- a/src/plugins/debugger/lldblib/guest/README
+++ /dev/null
@@ -1,31 +0,0 @@
-LLDB Guest Engine
-
-You can use the LLDB debugger from the LLVM project with the Qt Creator debugger
-plugin on Mac OS.
-
-For the Qt Creator build to pick up the LLDB Guest Engine,
-you must download the LLDB debugger and configure it
-to be included in the Qt Creator build.
-
-To debug an application, Qt Creator must access the memory of the application.
-On Mac OS X, this requires code signing.
-
-To enable LLDB debugger support in Qt Creator:
-
-1. To download the LLDB debugger, enter the following command:
- svn co http://llvm.org/svn/llvm-project/lldb/trunk lldb
-
-2. To sign the code, follow the instructions in lldb/docs/code-signing.txt.
-
-3. To open LLDB in Xcode for building, enter the following command:
- open lldb.xcodeproj
- then select the Release target and press the build button.
-
-4. In Xcode, press the build button.
-
-5. type the following to have the qt creator build system find your lldb build:
- export WITH_LLDB=/path/to/lldb
-
-6. To rebuild Qt Creator, change back to the top level directory of
- the Qt Creator source, and enter the following command:
- qmake -r && make
diff --git a/src/plugins/debugger/lldblib/guest/lldbengineguest.cpp b/src/plugins/debugger/lldblib/guest/lldbengineguest.cpp
deleted file mode 100644
index 15b82c8503..0000000000
--- a/src/plugins/debugger/lldblib/guest/lldbengineguest.cpp
+++ /dev/null
@@ -1,761 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#define QT_NO_CAST_FROM_ASCII
-
-#include "lldbengineguest.h"
-
-#include "debuggeractions.h"
-#include "debuggerconstants.h"
-#include "debuggerdialogs.h"
-#include "debuggerplugin.h"
-#include "debuggerstringutils.h"
-
-#include "breakhandler.h"
-#include "breakpoint.h"
-#include "moduleshandler.h"
-#include "registerhandler.h"
-#include "stackhandler.h"
-#include "watchhandler.h"
-#include "watchutils.h"
-#include "threadshandler.h"
-
-#include <utils/qtcassert.h>
-#include <QDebug>
-#include <QProcess>
-#include <QFileInfo>
-#include <QThread>
-#include <QMutexLocker>
-
-#include <lldb/API/LLDB.h>
-
-#define DEBUG_FUNC_ENTER \
- showMessage(QString(QLatin1String("LLDB guest engine: %1 ")) \
- .arg(QLatin1String(Q_FUNC_INFO))); \
- qDebug("%s", Q_FUNC_INFO)
-
-#define SYNC_INFERIOR_OR(x) if (m_running) { x; }
-
-
-namespace Debugger {
-namespace Internal {
-
-void LldbEventListener::listen(lldb::SBListener *listener)
-{
- while (true) {
- lldb::SBEvent event;
- if (listener->WaitForEvent(1000, event))
- emit lldbEvent(&event);
- }
-}
-
-LldbEngineGuest::LldbEngineGuest()
- : IPCEngineGuest()
- , m_running (false)
- , m_worker (new LldbEventListener)
- , m_lldb (new lldb::SBDebugger)
- , m_target (new lldb::SBTarget)
- , m_process (new lldb::SBProcess)
- , m_listener(new lldb::SBListener("bla"))
- , m_relistFrames (false)
-#if defined(HAVE_LLDB_PRIVATE)
- , py (new PythonLLDBToGdbMiHack)
-#endif
-{
- qRegisterMetaType<lldb::SBListener *>("lldb::SBListener *");
- qRegisterMetaType<lldb::SBEvent *>("lldb::SBEvent *");
-
- m_worker->moveToThread(&m_wThread);
- connect(m_worker, SIGNAL(lldbEvent(lldb::SBEvent*)), this,
- SLOT(lldbEvent(lldb::SBEvent*)), Qt::BlockingQueuedConnection);
- m_wThread.start();
- setObjectName(QLatin1String("LLDBEngineGuest"));
-}
-
-LldbEngineGuest::~LldbEngineGuest()
-{
- delete m_lldb;
- delete m_target;
- delete m_process;
- delete m_listener;
-}
-
-
-void LldbEngineGuest::nuke()
-{
- ::exit(4);
-}
-
-void LldbEngineGuest::setupEngine()
-{
- DEBUG_FUNC_ENTER;
-
- lldb::SBDebugger::Initialize();
-
- *m_lldb = lldb::SBDebugger::Create();
- m_lldb->Initialize();
- if (m_lldb->IsValid())
- notifyEngineSetupOk();
- else
- notifyEngineSetupFailed();
-
-}
-
-void LldbEngineGuest::setupInferior(const QString &executable,
- const QStringList &args, const QStringList &env)
-{
- DEBUG_FUNC_ENTER;
-
- foreach (const QString &s, args) {
- m_arguments.append(s.toLocal8Bit());
- }
- foreach (const QString &s, env) {
- m_environment.append(s.toLocal8Bit());
- }
-
- qDebug("creating target for %s", executable.toLocal8Bit().data());
- showStatusMessage(QLatin1String("starting ") + executable);
- *m_target = m_lldb->CreateTarget(executable.toLocal8Bit().data());
- if (!m_target->IsValid()) {
- notifyInferiorSetupFailed();
- return;
- }
- DEBUG_FUNC_ENTER;
-
- const char **argp = new const char *[m_arguments.count() + 1];
- argp[m_arguments.count()] = 0;
- for (int i = 0; i < m_arguments.count(); i++) {
- argp[i] = m_arguments[i].data();
- }
-
- const char **envp = new const char *[m_environment.count() + 1];
- envp[m_environment.count()] = 0;
- for (int i = 0; i < m_environment.count(); i++) {
- envp[i] = m_environment[i].data();
- }
- lldb::SBError err;
- *m_process = m_target->Launch(argp, envp, NULL, NULL, true, err);
-
- if (!err.Success()) {
- showMessage(QString::fromLocal8Bit(err.GetCString()));
- qDebug() << err.GetCString();
- notifyInferiorSetupFailed();
- }
-
- /*
- * note, the actual string ptrs are still valid. They are in m_environment.
- * They probably leak. Considered the marvelous API, there is not much we can do
- */
- delete [] envp;
-
- if (!m_process->IsValid())
- notifyEngineRunFailed();
- QTC_ASSERT(m_listener->IsValid(), qDebug() << false);
- m_listener->StartListeningForEvents(m_process->GetBroadcaster(), UINT32_MAX);
- QMetaObject::invokeMethod(m_worker, "listen", Qt::QueuedConnection,
- Q_ARG(lldb::SBListener *, m_listener));
- notifyInferiorSetupOk();
-}
-
-void LldbEngineGuest::runEngine()
-{
- DEBUG_FUNC_ENTER;
- m_process->Continue();
-}
-
-void LldbEngineGuest::shutdownInferior()
-{
- DEBUG_FUNC_ENTER;
- m_process->Kill();
-}
-
-void LldbEngineGuest::shutdownEngine()
-{
- DEBUG_FUNC_ENTER;
- m_currentFrame = lldb::SBFrame();
- m_currentThread = lldb::SBThread();
- m_breakpoints.clear();
- m_localesCache.clear();
-
- /*
- * this leaks. However, Terminate is broken and lldb leaks anyway
- * We should kill the engine guest process
- */
-
- *m_lldb = lldb::SBDebugger();
- // leakd.Terminate();
- notifyEngineShutdownOk();
-}
-
-void LldbEngineGuest::detachDebugger()
-{
- DEBUG_FUNC_ENTER;
-}
-
-void LldbEngineGuest::executeStep()
-{
- DEBUG_FUNC_ENTER;
-
- if (!m_currentThread.IsValid())
- return;
- m_currentThread.StepInto();
-}
-
-void LldbEngineGuest::executeStepOut()
-{
- DEBUG_FUNC_ENTER;
-
- if (!m_currentThread.IsValid())
- return;
- m_currentThread.StepOut();
-}
-
-void LldbEngineGuest::executeNext()
-{
- DEBUG_FUNC_ENTER;
-
- if (!m_currentThread.IsValid())
- return;
- m_currentThread.StepOver();
-}
-
-void LldbEngineGuest::executeStepI()
-{
- DEBUG_FUNC_ENTER;
-
- if (!m_currentThread.IsValid())
- return;
- m_currentThread.StepInstruction(false);
-}
-
-void LldbEngineGuest::executeNextI()
-{
- DEBUG_FUNC_ENTER;
-
- if (!m_currentThread.IsValid())
- return;
- m_currentThread.StepInstruction(true);
-}
-
-void LldbEngineGuest::continueInferior()
-{
- DEBUG_FUNC_ENTER;
-
- notifyInferiorRunRequested();
- m_process->Continue();
- showStatusMessage(QLatin1String("resuming inferior"));
-}
-void LldbEngineGuest::interruptInferior()
-{
- DEBUG_FUNC_ENTER;
-
- m_process->Stop();
- notifyInferiorStopOk();
- m_relistFrames = true;
- updateThreads();
-}
-
-void LldbEngineGuest::executeRunToLine(const ContextData &data);
-{
- DEBUG_FUNC_ENTER;
-
- // TODO
- Q_UNUSED(data);
-}
-
-void LldbEngineGuest::executeRunToFunction(const QString &functionName)
-{
- DEBUG_FUNC_ENTER;
-
- // TODO
- Q_UNUSED(functionName);
-}
-void LldbEngineGuest::executeJumpToLine(const ContextData &data);
-{
- DEBUG_FUNC_ENTER;
-
- // TODO
- Q_UNUSED(data);
-}
-
-void LldbEngineGuest::activateFrame(qint64 token)
-{
- DEBUG_FUNC_ENTER;
- SYNC_INFERIOR_OR(showMessage(QLatin1String(
- "activateFrame called while inferior running")); return);
-
- currentFrameChanged(token);
- m_localesCache.clear();
-
- lldb::SBFrame fr = m_currentThread.GetFrameAtIndex(token);
- m_currentFrame = fr;
- lldb::SBSymbolContext context = fr.GetSymbolContext(lldb::eSymbolContextEverything);
- lldb::SBValueList values = fr.GetVariables(true, true, false, true);
- QList<WatchData> wd;
- QByteArray iname = "local";
- for (uint i = 0; i < values.GetSize(); i++) {
- lldb::SBValue v = values.GetValueAtIndex(i);
- if (!v.IsInScope(fr))
- continue;
- getWatchDataR(v, 1, iname, wd);
- }
- updateWatchData(true, wd);
-}
-
-void LldbEngineGuest::requestUpdateWatchData(const Internal::WatchData &data,
- const Internal::WatchUpdateFlags &)
-{
- DEBUG_FUNC_ENTER;
- SYNC_INFERIOR_OR(return);
-
- lldb::SBValue v = m_localesCache.value(QString::fromUtf8(data.iname));
- QList<WatchData> wd;
- for (uint j = 0; j < v.GetNumChildren(); j++) {
- lldb::SBValue vv = v.GetChildAtIndex(j);
- getWatchDataR(vv, 1, data.iname, wd);
- }
- updateWatchData(false, wd);
-}
-
-void LldbEngineGuest::getWatchDataR(lldb::SBValue v, int level,
- const QByteArray &p_iname, QList<WatchData> &wd)
-{
- QByteArray iname = p_iname + '.' + QByteArray(v.GetName());
- m_localesCache.insert(QString::fromLocal8Bit(iname), v);
-
-#if defined(HAVE_LLDB_PRIVATE)
- wd += py->expand(p_iname, v, m_currentFrame, *m_process);
-#else
- WatchData d;
- d.name = QString::fromLocal8Bit(v.GetName());
- d.iname = iname;
- d.type = QByteArray(v.GetTypeName()).trimmed();
- d.value = (QString::fromLocal8Bit(v.GetValue(m_currentFrame)));
- d.hasChildren = v.GetNumChildren();
- d.state = WatchData::State(0);
- wd.append(d);
-#endif
-
- if (--level > 0) {
- for (uint j = 0; j < v.GetNumChildren(); j++) {
- lldb::SBValue vv = v.GetChildAtIndex(j);
- getWatchDataR(vv, level, iname, wd);
- }
- }
-}
-
-void LldbEngineGuest::disassemble(quint64 pc)
-{
- DEBUG_FUNC_ENTER;
- SYNC_INFERIOR_OR(return);
-
- if (!m_currentThread.IsValid())
- return;
- for (uint j = 0; j < m_currentThread.GetNumFrames(); j++) {
- lldb::SBFrame fr = m_currentThread.GetFrameAtIndex(j);
- if (pc == fr.GetPCAddress().GetLoadAddress(*m_target)) {
- QString linesStr = QString::fromLocal8Bit(fr.Disassemble());
- DisassemblerLines lines;
- foreach (const QString &lineStr, linesStr.split(QLatin1Char('\n'))) {
- lines.appendLine(DisassemblerLine(lineStr));
- }
- disassembled(pc, lines);
- }
- }
-}
-void LldbEngineGuest::fetchFrameSource(qint64 frame)
-{
- QFile f(m_frame_to_file.value(frame));
- f.open(QFile::ReadOnly);
- frameSourceFetched(frame, QFileInfo(m_frame_to_file.value(frame)).fileName()
- , QString::fromLocal8Bit(f.readAll()));
-}
-
-void LldbEngineGuest::addBreakpoint(BreakpointId id,
- const Internal::BreakpointParameters &bp_)
-{
- DEBUG_FUNC_ENTER;
- SYNC_INFERIOR_OR(notifyAddBreakpointFailed(id); return);
-
- Internal::BreakpointParameters bp(bp_);
-
- lldb::SBBreakpoint llbp = m_target->BreakpointCreateByLocation(
- bp.fileName.toLocal8Bit().constData(), bp.lineNumber);
- if (llbp.IsValid()) {
- m_breakpoints.insert(id, llbp);
-
- llbp.SetIgnoreCount(bp.ignoreCount);
- bp.ignoreCount = llbp.GetIgnoreCount();
- bp.enabled = llbp.IsEnabled();
-
- lldb::SBBreakpointLocation location = llbp.GetLocationAtIndex(0);
- if (location.IsValid()) {
- bp.address = location.GetLoadAddress();
-
- // FIXME get those from lldb
- bp.lineNumber = bp.lineNumber;
- bp.fileName = bp.fileName;
- notifyAddBreakpointOk(id);
- showMessage(QLatin1String("[BB] ok."));
- notifyBreakpointAdjusted(id, bp);
- } else {
- m_breakpoints.take(id);
- showMessage(QLatin1String("[BB] failed. cant resolve yet"));
-// notifyAddBreakpointFailed(id);
-// notifyAddBreakpointOk(id);
- }
- } else {
- showMessage(QLatin1String("[BB] failed. dunno."));
- notifyAddBreakpointFailed(id);
- }
-}
-
-void LldbEngineGuest::removeBreakpoint(BreakpointId id)
-{
- DEBUG_FUNC_ENTER;
- SYNC_INFERIOR_OR(notifyRemoveBreakpointFailed(id); return);
-
- lldb::SBBreakpoint llbp = m_breakpoints.take(id);
- llbp.SetEnabled(false);
- notifyRemoveBreakpointOk(id);
-}
-
-void LldbEngineGuest::changeBreakpoint(BreakpointId id,
- const Internal::BreakpointParameters &bp)
-{
- DEBUG_FUNC_ENTER;
-
- // TODO
- Q_UNUSED(id);
- Q_UNUSED(bp);
-}
-
-void LldbEngineGuest::selectThread(qint64 token)
-{
- DEBUG_FUNC_ENTER;
- SYNC_INFERIOR_OR(return);
-
- m_frame_to_file.clear();
- for (uint i = 0; i < m_process->GetNumThreads(); i++) {
- lldb::SBThread t = m_process->GetThreadAtIndex(i);
- if (t.GetThreadID() == token) {
- m_currentThread = t;
- StackFrames frames;
- int firstResolvableFrame = -1;
- for (uint j = 0; j < t.GetNumFrames(); j++) {
- lldb::SBFrame fr = t.GetFrameAtIndex(j);
- if (!fr.IsValid()) {
- qDebug("warning: frame %i is garbage", j);
- continue;
- }
- lldb::SBSymbolContext context =
- fr.GetSymbolContext(lldb::eSymbolContextEverything);
- lldb::SBSymbol sym = fr.GetSymbol();
- lldb::SBFunction func = fr.GetFunction();
- lldb::SBCompileUnit tu = fr.GetCompileUnit();
- lldb::SBModule module = fr.GetModule();
- lldb::SBBlock block = fr.GetBlock();
- lldb::SBBlock fblock = fr.GetFrameBlock();
- lldb::SBLineEntry le = fr.GetLineEntry();
- lldb::SBValueList values = fr.GetVariables(true, true, true, false);
-#if 0
- qDebug()<<"\tframe "<<fr.GetFrameID();
- qDebug() << "\t\tPC: " << ("0x" + QByteArray::number(
- fr.GetPCAddress().GetLoadAddress(*m_target), 16)).data();
- qDebug() << "\t\tFP: " << ("0x" + QByteArray::number(fr.GetFP(), 16)).data();
- qDebug() << "\t\tSP: " << ("0x" + QByteArray::number(fr.GetSP(), 16)).data();
- qDebug() << "\t\tsymbol: " << sym.IsValid() << sym.GetName() << sym.GetMangledName();
- qDebug() << "\t\tfunction:" << func.IsValid();
- qDebug() << "\t\ttu: " << tu.IsValid();
- if (tu.IsValid())
-
- qDebug() << "\t\tmodule: " << module.IsValid() << module.GetFileSpec().IsValid()
- << module.GetFileSpec().GetFilename();
- qDebug() << "\t\tblock: " << block.IsValid() << block.GetInlinedName();
- qDebug() << "\t\tfblock: " << block.IsValid() << block.GetInlinedName();
- qDebug() << "\t\tle: " << le.IsValid() << le.GetLine()<<le.GetColumn();
- qDebug() << "\t\tvalues: "<<values.IsValid() << values.GetSize();
- qDebug() << "\t\tcontext: " << context.IsValid();
- qDebug() << "\t\t\tmodule: " << context.GetModule().IsValid();
- qDebug() << "\t\t\tfunction: " << context.GetFunction().IsValid();
- qDebug() << "\t\t\tblock: " << context.GetBlock().IsValid();
- qDebug() << "\t\t\tle: " << context.GetLineEntry().IsValid();
- qDebug() << "\t\t\tsymbol: " << context.GetSymbol().IsValid();
-// qDebug() << "\t\tdisassemly -->\n" << fr.Disassemble() << "<--";
-#endif
-
- QString sourceFile;
- QString sourceFilePath;
- int lineNumber = 0;
- if (le.IsValid()) {
- lineNumber = le.GetLine();
- if (le.GetFileSpec().IsValid()) {
- sourceFile = QString::fromLocal8Bit(le.GetFileSpec().GetFilename());
- sourceFilePath = QString::fromLocal8Bit(le.GetFileSpec().GetDirectory())
- + QLatin1String("/") + sourceFile;
- if (firstResolvableFrame < 0)
- firstResolvableFrame = j;
- }
- }
- sourceFilePath = QFileInfo(sourceFilePath).canonicalFilePath();
-
- QString functionName;
- if (func.IsValid())
- functionName = QString::fromLocal8Bit(func.GetName());
- else
- functionName = QString::fromLocal8Bit(sym.GetName());
-
- StackFrame frame;
- frame.level = fr.GetFrameID();
- if (func.IsValid())
- frame.function = QString::fromLocal8Bit(func.GetName());
- else
- frame.function = QString::fromLocal8Bit(sym.GetName());
- frame.from = QString::fromLocal8Bit(module.GetFileSpec().GetFilename());
- frame.address = fr.GetPCAddress().GetLoadAddress(*m_target);
- frame.line = lineNumber;
- frame.file = sourceFilePath;
- frame.usable = QFileInfo(frame.file).isReadable();
- frames.append(frame);
- m_frame_to_file.insert(j, frame.file);
- }
- currentThreadChanged(token);
- listFrames(frames);
- activateFrame(firstResolvableFrame > -1 ? firstResolvableFrame : 0);
- return;
- }
- }
-}
-
-void LldbEngineGuest::updateThreads()
-{
- DEBUG_FUNC_ENTER;
- SYNC_INFERIOR_OR(return);
-
- /* There is no way to find the StopReason of a _process_
- * We try to emulate gdb here, by assuming there must be exactly one 'guilty' thread.
- * However, if there are no threads at all, it must be that the process
- * no longer exists. Let's tear down the whole session.
- */
- if (m_process->GetNumThreads() < 1) {
- notifyEngineSpontaneousShutdown();
- m_process->Kill();
- m_process->Destroy();
- }
-
- Threads threads;
- for (uint i = 0; i < m_process->GetNumThreads(); i++) {
- lldb::SBThread t = m_process->GetThreadAtIndex(i);
- if (!t.IsValid()) {
- qDebug("warning: thread %i is garbage", i);
- continue;
- }
- ThreadData thread;
- thread.id = t.GetThreadID();
- thread.targetId = QString::number(t.GetThreadID());
- thread.core.clear();
- thread.state = QString::number(t.GetStopReason());
-
- switch (t.GetStopReason()) {
- case lldb::eStopReasonInvalid:
- case lldb::eStopReasonNone:
- case lldb::eStopReasonTrace:
- thread.state = QLatin1String("running");
- break;
- case lldb::eStopReasonBreakpoint:
- case lldb::eStopReasonWatchpoint:
- showStatusMessage(QLatin1String("hit breakpoint"));
- thread.state = QLatin1String("hit breakpoint");
- if (m_currentThread.GetThreadID() != t.GetThreadID()) {
- m_currentThread = t;
- currentThreadChanged(t.GetThreadID());
- m_relistFrames = true;
- }
- break;
- case lldb::eStopReasonSignal:
- showStatusMessage(QLatin1String("stopped"));
- thread.state = QLatin1String("stopped");
- if (m_currentThread.GetThreadID() != t.GetThreadID()) {
- m_currentThread = t;
- currentThreadChanged(t.GetThreadID());
- m_relistFrames = true;
- }
- break;
- case lldb::eStopReasonException:
- showStatusMessage(QLatin1String("application crashed."));
- thread.state = QLatin1String("crashed");
- if (m_currentThread.GetThreadID() != t.GetThreadID()) {
- m_currentThread = t;
- currentThreadChanged(t.GetThreadID());
- m_relistFrames = true;
- }
- break;
- case lldb::eStopReasonPlanComplete:
- thread.state = QLatin1String("crazy things happened");
- break;
- };
-
- thread.lineNumber = 0;
- thread.name = QString::fromLocal8Bit(t.GetName());
-
- lldb::SBFrame fr = t.GetFrameAtIndex(0);
- if (!fr.IsValid()) {
- qDebug("warning: frame 0 is garbage");
- continue;
- }
- lldb::SBSymbolContext context = fr.GetSymbolContext(lldb::eSymbolContextEverything);
- lldb::SBSymbol sym = fr.GetSymbol();
- lldb::SBFunction func = fr.GetFunction();
- lldb::SBLineEntry le = fr.GetLineEntry();
- QString sourceFile;
- QString sourceFilePath;
- int lineNumber = 0;
- if (le.IsValid()) {
- lineNumber = le.GetLine();
- if (le.GetFileSpec().IsValid()) {
- sourceFile = QString::fromLocal8Bit(le.GetFileSpec().GetFilename());
- sourceFilePath = QString::fromLocal8Bit(le.GetFileSpec().GetDirectory())
- + QLatin1String("/") + sourceFile;
- }
- }
- QString functionName;
- if (func.IsValid())
- functionName = QString::fromLocal8Bit(func.GetName());
- else
- functionName = QString::fromLocal8Bit(sym.GetName());
-
- lldb::SBValueList values = fr.GetVariables(true, true, false, false);
- thread.fileName = sourceFile;
- thread.function = functionName;
- thread.address = fr.GetPCAddress().GetLoadAddress(*m_target);
- thread.lineNumber = lineNumber;
- threads.append(thread);
- }
- listThreads(threads);
- if (m_relistFrames) {
- selectThread(m_currentThread.GetThreadID());
- m_relistFrames = false;
- }
-}
-
-void LldbEngineGuest::lldbEvent(lldb::SBEvent *ev)
-{
- qDebug() << "lldbevent" << ev->GetType() <<
- m_process->GetState() << (int)state();
-
- uint32_t etype = ev->GetType();
- switch (etype) {
- // ProcessEvent
- case 1:
- switch (m_process->GetState()) {
- case lldb::eStateRunning: // 5
- if (!m_running)
- m_running = true;
- notifyInferiorPid(m_process->GetProcessID());
- switch (state()) {
- case EngineRunRequested:
- notifyEngineRunAndInferiorRunOk();
- break;
- case InferiorRunRequested:
- notifyInferiorRunOk();
- break;
- case InferiorStopOk:
- notifyInferiorRunRequested();
- notifyInferiorRunOk();
- break;
- default:
- break;
- }
- break;
- case lldb::eStateExited: // 9
- if (m_running)
- m_running = false;
- switch (state()) {
- case InferiorShutdownRequested:
- notifyInferiorShutdownOk();
- break;
- case InferiorRunOk:
- m_relistFrames = true;
- updateThreads();
- notifyEngineSpontaneousShutdown();
- m_process->Kill();
- m_process->Destroy();
- break;
- default:
- updateThreads();
- break;
- }
- break;
- case lldb::eStateStopped: // 4
- if (m_running)
- m_running = false;
- switch (state()) {
- case InferiorShutdownRequested:
- notifyInferiorShutdownOk();
- break;
- case InferiorRunOk:
- m_relistFrames = true;
- updateThreads();
- notifyInferiorSpontaneousStop();
- // fall
- default:
- m_relistFrames = true;
- updateThreads();
- break;
- }
- break;
- case lldb::eStateCrashed: // 7
- if (m_running)
- m_running = false;
- switch (state()) {
- case InferiorShutdownRequested:
- notifyInferiorShutdownOk();
- break;
- case InferiorRunOk:
- m_relistFrames = true;
- updateThreads();
- notifyInferiorSpontaneousStop();
- break;
- default:
- break;
- }
- break;
- default:
- qDebug("unexpected ProcessEvent");
- break;
- }
- break;
- default:
- break;
- };
-}
-
-
-} // namespace Internal
-} // namespace Debugger
diff --git a/src/plugins/debugger/lldblib/guest/lldbengineguest.h b/src/plugins/debugger/lldblib/guest/lldbengineguest.h
deleted file mode 100644
index b2af9842b0..0000000000
--- a/src/plugins/debugger/lldblib/guest/lldbengineguest.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef DEBUGGER_LLDBENGINE_GUEST_H
-#define DEBUGGER_LLDBENGINE_GUEST_H
-
-#include "ipcengineguest.h"
-
-#include <QQueue>
-#include <QVariant>
-#include <QThread>
-#include <QStringList>
-
-#include <lldb/API/LLDB.h>
-
-#if defined(HAVE_LLDB_PRIVATE)
-#include "pygdbmiemu.h"
-#endif
-
-Q_DECLARE_METATYPE (lldb::SBListener *)
-Q_DECLARE_METATYPE (lldb::SBEvent *)
-
-namespace Debugger {
-namespace Internal {
-
-class LldbEventListener : public QObject
-{
-Q_OBJECT
-public slots:
- void listen(lldb::SBListener *listener);
-signals:
- // lldb API uses non thread safe implicit sharing with no explicit copy feature
- // additionally the scope is undefined, hence this signal needs to be connected BlockingQueued
- // whutever, works for now.
- void lldbEvent(lldb::SBEvent *ev);
-};
-
-
-class LldbEngineGuest : public IPCEngineGuest
-{
- Q_OBJECT
-
-public:
- explicit LldbEngineGuest();
- ~LldbEngineGuest();
-
- void nuke();
- void setupEngine();
- void setupInferior(const QString &executable, const QStringList &arguments,
- const QStringList &environment);
- void runEngine();
- void shutdownInferior();
- void shutdownEngine();
- void detachDebugger();
- void executeStep();
- void executeStepOut() ;
- void executeNext();
- void executeStepI();
- void executeNextI();
- void continueInferior();
- void interruptInferior();
- void executeRunToLine(const ContextData &data);
- void executeRunToFunction(const QString &functionName);
- void executeJumpToLine(const ContextData &data);
- void activateFrame(qint64);
- void selectThread(qint64);
- void disassemble(quint64 pc);
- void addBreakpoint(BreakpointModelId id, const BreakpointParameters &bp);
- void removeBreakpoint(BreakpointModelId id);
- void changeBreakpoint(BreakpointModelId id, const BreakpointParameters &bp);
- void requestUpdateWatchData(const WatchData &data,
- const WatchUpdateFlags &flags);
- void fetchFrameSource(qint64 frame);
-
-private:
- bool m_running;
-
- QList<QByteArray> m_arguments;
- QList<QByteArray> m_environment;
- QThread m_wThread;
- LldbEventListener *m_worker;
- lldb::SBDebugger *m_lldb;
- lldb::SBTarget *m_target;
- lldb::SBProcess *m_process;
- lldb::SBListener *m_listener;
-
- lldb::SBFrame m_currentFrame;
- lldb::SBThread m_currentThread;
- bool m_relistFrames;
- QHash<QString, lldb::SBValue> m_localesCache;
- QHash<BreakpointModelId, lldb::SBBreakpoint> m_breakpoints;
- QHash<qint64, QString> m_frame_to_file;
-
- void updateThreads();
- void getWatchDataR(lldb::SBValue v, int level,
- const QByteArray &p_iname, QList<WatchData> &wd);
-
-#if defined(HAVE_LLDB_PRIVATE)
- PythonLLDBToGdbMiHack * py;
-#endif
-
-private slots:
- void lldbEvent(lldb::SBEvent *ev);
-};
-
-} // namespace Internal
-} // namespace Debugger
-
-#endif // DEBUGGER_LLDBENGINE_H
-#define SYNC_INFERIOR
diff --git a/src/plugins/debugger/lldblib/guest/main.cpp b/src/plugins/debugger/lldblib/guest/main.cpp
deleted file mode 100644
index dfb382d38d..0000000000
--- a/src/plugins/debugger/lldblib/guest/main.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "lldbengineguest.h"
-
-#include <QLocalSocket>
-#include <QCoreApplication>
-#include <QSocketNotifier>
-#include <QQueue>
-
-#include <cstdio>
-
-// #define DO_STDIO_DEBUG 1
-#ifdef DO_STDIO_DEBUG
-#define D_STDIO0(x) qDebug(x)
-#define D_STDIO1(x,a1) qDebug(x,a1)
-#define D_STDIO2(x,a1,a2) qDebug(x,a1,a2)
-#define D_STDIO3(x,a1,a2,a3) qDebug(x,a1,a2,a3)
-#else
-#define D_STDIO0(x)
-#define D_STDIO1(x,a1)
-#define D_STDIO2(x,a1,a2)
-#define D_STDIO3(x,a1,a2,a3)
-#endif
-
-class Stdio : public QIODevice
-{
- Q_OBJECT
-public:
- QSocketNotifier notify;
- Stdio()
- : QIODevice()
- , notify(fileno(stdin), QSocketNotifier::Read)
- , buckethead(0)
- {
- setvbuf(stdin , NULL , _IONBF , 0);
- setvbuf(stdout , NULL , _IONBF , 0);
- setOpenMode(QIODevice::ReadWrite | QIODevice::Unbuffered);
- connect(&notify, SIGNAL(activated(int)), this, SLOT(activated()));
- }
- virtual qint64 bytesAvailable () const
- {
- qint64 r = QIODevice::bytesAvailable();
- foreach (const QByteArray &bucket, buckets)
- r += bucket.size();
- r-= buckethead;
- return r;
- }
-
- virtual qint64 readData (char * data, qint64 maxSize)
- {
- D_STDIO1("readData %lli",maxSize);
- qint64 size = maxSize;
- while (size > 0) {
- if (!buckets.size()) {
- D_STDIO1("done prematurely with %lli", maxSize - size);
- return maxSize - size;
- }
- QByteArray &bucket = buckets.head();
- if ((size + buckethead) >= bucket.size()) {
- int d = bucket.size() - buckethead;
- D_STDIO3("read (over bucket) d: %i buckethead: %i bucket.size(): %i",
- d, buckethead, bucket.size());
- memcpy(data, bucket.data() + buckethead, d);
- data += d;
- size -= d;
- buckets.dequeue();
- buckethead = 0;
- } else {
- D_STDIO1("read (in bucket) size: %lli", size);
- memcpy(data, bucket.data() + buckethead, size);
- data += size;
- buckethead += size;
- size = 0;
- }
- }
- D_STDIO1("done with %lli",(maxSize - size));
- return maxSize - size;
- }
-
- virtual qint64 writeData (const char * data, qint64 maxSize)
- {
- return ::write(fileno(stdout), data, maxSize);
- }
-
- QQueue<QByteArray> buckets;
- int buckethead;
-
-private slots:
- void activated()
- {
- QByteArray a;
- a.resize(1000);
- int ret = ::read(fileno(stdin), a.data(), 1000);
- if (ret == 0)
- ::exit(0);
- assert(ret <= 1000);
- D_STDIO1("activated %i", ret);
- a.resize(ret);
- buckets.enqueue(a);
- emit readyRead();
- }
-};
-
-int main(int argc, char **argv)
-{
- QCoreApplication app(argc, argv);
- qDebug() << "guest engine operational";
-
- Debugger::Internal::LldbEngineGuest lldb;
-
-
- Stdio stdio;
- lldb.setHostDevice(&stdio);
-
- return app.exec();
-}
-
-extern "C" {
-extern const unsigned char lldbVersionString[] __attribute__ ((used)) = "@(#)PROGRAM:lldb PROJECT:lldb-26" "\n";
-extern const double lldbVersionNumber __attribute__ ((used)) = (double)26.;
-extern const double LLDBVersionNumber __attribute__ ((used)) = (double)26.;
-}
-
-#include "main.moc"
diff --git a/src/plugins/debugger/lldblib/guest/qtcreator-lldb.plist b/src/plugins/debugger/lldblib/guest/qtcreator-lldb.plist
deleted file mode 100644
index c0a3b2beaf..0000000000
--- a/src/plugins/debugger/lldblib/guest/qtcreator-lldb.plist
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleIdentifier</key>
- <string>org.qt-project.qtcreator-lldb</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleName</key>
- <string>Qt Creator LLDB Guest</string>
- <key>CFBundleVersion</key>
- <string>1.0</string>
- <key>SecTaskAccess</key>
- <array>
- <string>allowed</string>
- <string>safe</string>
- </array>
-</dict>
-</plist>
diff --git a/src/plugins/debugger/lldblib/guest/qtcreator-lldb.pri b/src/plugins/debugger/lldblib/guest/qtcreator-lldb.pri
deleted file mode 100644
index f44c3e9c84..0000000000
--- a/src/plugins/debugger/lldblib/guest/qtcreator-lldb.pri
+++ /dev/null
@@ -1,2 +0,0 @@
-WITH_LLDB = $$(WITH_LLDB)
-macx: !isEmpty(WITH_LLDB) : SUBDIRS += $$PWD/qtcreator-lldb.pro
diff --git a/src/plugins/debugger/lldblib/guest/qtcreator-lldb.pro b/src/plugins/debugger/lldblib/guest/qtcreator-lldb.pro
deleted file mode 100644
index b6f5437284..0000000000
--- a/src/plugins/debugger/lldblib/guest/qtcreator-lldb.pro
+++ /dev/null
@@ -1,61 +0,0 @@
-WITH_LLDB = $$(WITH_LLDB)
-
-!macx: error (This can only be built on mac)
-!exists($${WITH_LLDB}/include/lldb/lldb-enumerations.h): error(please see the README for build instructions)
-
-QT = core network
-
-include(../../../../../qtcreator.pri)
-TEMPLATE = app
-CONFIG -= app_bundle
-CONFIG += debug
-TARGET = qtcreator-lldb
-DEPENDPATH += . .. ../.. ../../..
-INCLUDEPATH += . .. ../.. ../../..
-DESTDIR = $$IDE_LIBEXEC_PATH
-
-MOC_DIR=.tmp
-OBJECTS_DIR=.tmp
-
-HEADERS += ../ipcengineguest.h \
- ../debuggerstreamops.h \
- ../breakpoint.h \
- ../watchdata.h \
- ../stackframe.h \
- ../disassemblerlines.h \
- lldbengineguest.h
-
-SOURCES += ../ipcengineguest.cpp \
- ../debuggerstreamops.cpp \
- ../breakpoint.cpp \
- ../watchdata.cpp \
- ../stackframe.cpp \
- ../disassemblerlines.cpp \
- lldbengineguest.cpp \
- main.cpp
-
-
-LIBS += -sectcreate __TEXT __info_plist $$PWD/qtcreator-lldb.plist
-
-POSTL = rm -rf \'$${IDE_LIBEXEC_PATH}/LLDB.framework\' $$escape_expand(\\n\\t) \
- $$QMAKE_COPY_DIR $${WITH_LLDB}/build/Release/* \'$$IDE_LIBEXEC_PATH\' $$escape_expand(\\n\\t) \
- install_name_tool -change '@rpath/LLDB.framework/Versions/A/LLDB' '@executable_path/LLDB.framework/Versions/A/LLDB' $(TARGET) $$escape_expand(\\n\\t) \
- codesign -s lldb_codesign $(TARGET)
-
-!isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK = $$escape_expand(\\n\\t)$$QMAKE_POST_LINK
-QMAKE_POST_LINK = $$POSTL $$QMAKE_POST_LINK
-silent:QMAKE_POST_LINK = @echo signing $@ && $$QMAKE_POST_LINK
-
-LIBS += -framework Security -framework Python
-
-DEFINES += __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS
-
-INCLUDEPATH += $${WITH_LLDB}/include $${WITH_LLDB}/llvm/include/
-LIBS += -F$${WITH_LLDB}/build/Release -framework LLDB
-
-# include (lldb.pri)
-# DEFINES += HAVE_LLDB_PRIVATE
-# HEADERS += pygdbmiemu.h
-# SOURCES += pygdbmiemu.cpp
-
-
diff --git a/src/plugins/debugger/lldblib/ipcengineguest.cpp b/src/plugins/debugger/lldblib/ipcengineguest.cpp
deleted file mode 100644
index 4c5d9c814e..0000000000
--- a/src/plugins/debugger/lldblib/ipcengineguest.cpp
+++ /dev/null
@@ -1,637 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "ipcengineguest.h"
-#include "ipcenginehost.h"
-#include "breakpoint.h"
-#include "stackframe.h"
-#include "threaddata.h"
-#include "debuggerstreamops.h"
-
-#include <utils/qtcassert.h>
-
-#include <QLocalSocket>
-
-#include <QSysInfo>
-#include <QDebug>
-#include <QFileInfo>
-#include <QTimer>
-
-#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
-#define SET_NATIVE_BYTE_ORDER(x) x.setByteOrder(QDataStream::LittleEndian)
-#else
-#define SET_NATIVE_BYTE_ORDER(x) x.setByteOrder(QDataStream::BigEndian)
-#endif
-
-namespace Debugger {
-namespace Internal {
-
-IPCEngineGuest::IPCEngineGuest()
- : QObject()
- , m_local_host(0)
- , m_nextMessagePayloadSize(0)
- , m_cookie(1)
- , m_device(0)
-{
-}
-
-IPCEngineGuest::~IPCEngineGuest()
-{
-}
-
-void IPCEngineGuest::setLocalHost(IPCEngineHost *host)
-{
- m_local_host = host;
-}
-
-void IPCEngineGuest::setHostDevice(QIODevice *device)
-{
- if (m_device) {
- disconnect(m_device, SIGNAL(readyRead()), this, SLOT(readyRead()));
- delete m_device;
- }
- m_device = device;
- if (m_device)
- connect(m_device, SIGNAL(readyRead()), SLOT(readyRead()));
-}
-
-void IPCEngineGuest::rpcCall(Function f, QByteArray payload)
-{
-#if 0
- if (m_local_host) {
- QMetaObject::invokeMethod(m_local_host,
- "rpcCallback",
- Qt::QueuedConnection,
- Q_ARG(quint64, f),
- Q_ARG(QByteArray, payload));
- } else
-#endif
- if (m_device) {
- {
- QDataStream s(m_device);
- SET_NATIVE_BYTE_ORDER(s);
- s << m_cookie++;
- s << quint64(f);
- s << quint64(payload.size());
- }
- m_device->write(payload);
- m_device->putChar('T');
- QLocalSocket *sock = qobject_cast<QLocalSocket *>(m_device);
- if (sock)
- sock->flush();
- }
-}
-
-void IPCEngineGuest::readyRead()
-{
- if (!m_nextMessagePayloadSize) {
- if (quint64(m_device->bytesAvailable()) < 3 * sizeof(quint64))
- return;
- QDataStream s(m_device);
- SET_NATIVE_BYTE_ORDER(s);
- s >> m_nextMessageCookie;
- s >> m_nextMessageFunction;
- s >> m_nextMessagePayloadSize;
- m_nextMessagePayloadSize += 1; // terminator and "got header" marker
- }
-
- quint64 ba = m_device->bytesAvailable();
- if (ba < m_nextMessagePayloadSize)
- return;
-
- qint64 rrr = m_nextMessagePayloadSize;
- QByteArray payload = m_device->read(rrr);
- if (quint64(payload.size()) != m_nextMessagePayloadSize || !payload.endsWith('T')) {
- qDebug("IPC Error: corrupted frame");
- showMessage(QLatin1String("[guest] IPC Error: corrupted frame"), LogError);
- nuke();
- return;
- }
- payload.chop(1);
- rpcCallback(m_nextMessageFunction, payload);
- m_nextMessagePayloadSize = 0;
-
- if (quint64(m_device->bytesAvailable ()) >= 3 * sizeof(quint64))
- QTimer::singleShot(0, this, SLOT(readyRead()));
-}
-
-void IPCEngineGuest::rpcCallback(quint64 f, QByteArray payload)
-{
- switch (f) {
- default:
- qDebug("IPC Error: unhandled id in host to guest call");
- showMessage(QLatin1String("IPC Error: unhandled id in host to guest call"), LogError);
- nuke();
- break;
- case IPCEngineHost::SetupIPC:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- int version;
- s >> version;
- Q_ASSERT(version == 1);
- }
- break;
- case IPCEngineHost::StateChanged:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 st;
- s >> st;
- m_state = (DebuggerState)st;
- }
- break;
- case IPCEngineHost::SetupEngine:
- setupEngine();
- break;
- case IPCEngineHost::SetupInferior:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- QString executable;
- QStringList arguments;
- QStringList environment;
- s >> executable;
- s >> arguments;
- s >> environment;
- setupInferior(executable, arguments, environment);
- }
- break;
- case IPCEngineHost::RunEngine:
- runEngine();
- break;
- case IPCEngineHost::ShutdownInferior:
- shutdownInferior();
- break;
- case IPCEngineHost::ShutdownEngine:
- shutdownEngine();
- break;
- case IPCEngineHost::DetachDebugger:
- detachDebugger();
- break;
- case IPCEngineHost::ExecuteStep:
- executeStep();
- break;
- case IPCEngineHost::ExecuteStepOut:
- executeStepOut();
- break;
- case IPCEngineHost::ExecuteNext:
- executeNext();
- break;
- case IPCEngineHost::ExecuteStepI:
- executeStepI();
- break;
- case IPCEngineHost::ExecuteNextI:
- executeNextI();
- break;
- case IPCEngineHost::ContinueInferior:
- continueInferior();
- break;
- case IPCEngineHost::InterruptInferior:
- interruptInferior();
- break;
- case IPCEngineHost::ExecuteRunToLine:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- ContextData data;
- s >> data.fileName;
- s >> data.lineNumber;
- executeRunToLine(data);
- }
- break;
- case IPCEngineHost::ExecuteRunToFunction:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- QString functionName;
- s >> functionName;
- executeRunToFunction(functionName);
- }
- break;
- case IPCEngineHost::ExecuteJumpToLine:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- ContextData data;
- s >> data.fileName;
- s >> data.lineNumber;
- executeJumpToLine(data);
- }
- break;
- case IPCEngineHost::ActivateFrame:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 id;
- s >> id;
- activateFrame(id);
- }
- break;
- case IPCEngineHost::SelectThread:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 id;
- s >> id;
- selectThread(id);
- }
- break;
- case IPCEngineHost::Disassemble:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 pc;
- s >> pc;
- disassemble(pc);
- }
- break;
- case IPCEngineHost::AddBreakpoint:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- BreakpointModelId id;
- BreakpointParameters d;
- s >> id;
- s >> d;
- addBreakpoint(id, d);
- }
- break;
- case IPCEngineHost::RemoveBreakpoint:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- BreakpointModelId id;
- s >> id;
- removeBreakpoint(id);
- }
- break;
- case IPCEngineHost::ChangeBreakpoint:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- BreakpointModelId id;
- BreakpointParameters d;
- s >> id;
- s >> d;
- changeBreakpoint(id, d);
- }
- break;
- case IPCEngineHost::RequestUpdateWatchData:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- WatchData data;
- s >> data;
- requestUpdateWatchData(data);
- }
- break;
- case IPCEngineHost::FetchFrameSource:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- qint64 id;
- s >> id;
- fetchFrameSource(id);
- }
- break;
- };
-}
-
-DebuggerState IPCEngineGuest::state() const
-{
- return m_state;
-}
-
-void IPCEngineGuest::notifyEngineSetupOk()
-{
- rpcCall(NotifyEngineSetupOk);
-}
-
-void IPCEngineGuest::notifyEngineSetupFailed()
-{
- rpcCall(NotifyEngineSetupFailed);
-}
-
-void IPCEngineGuest::notifyEngineRunFailed()
-{
- rpcCall(NotifyEngineRunFailed);
-}
-
-void IPCEngineGuest::notifyInferiorSetupOk()
-{
- rpcCall(NotifyInferiorSetupOk);
-}
-
-void IPCEngineGuest::notifyInferiorSetupFailed()
-{
- rpcCall(NotifyInferiorSetupFailed);
-}
-
-void IPCEngineGuest::notifyEngineRunAndInferiorRunOk()
-{
- rpcCall(NotifyEngineRunAndInferiorRunOk);
-}
-
-void IPCEngineGuest::notifyEngineRunAndInferiorStopOk()
-{
- rpcCall(NotifyEngineRunAndInferiorStopOk);
-}
-
-void IPCEngineGuest::notifyInferiorRunRequested()
-{
- rpcCall(NotifyInferiorRunRequested);
-}
-
-void IPCEngineGuest::notifyInferiorRunOk()
-{
- rpcCall(NotifyInferiorRunOk);
-}
-
-void IPCEngineGuest::notifyInferiorRunFailed()
-{
- rpcCall(NotifyInferiorRunFailed);
-}
-
-void IPCEngineGuest::notifyInferiorStopOk()
-{
- rpcCall(NotifyInferiorStopOk);
-}
-
-void IPCEngineGuest::notifyInferiorSpontaneousStop()
-{
- rpcCall(NotifyInferiorSpontaneousStop);
-}
-
-void IPCEngineGuest::notifyInferiorStopFailed()
-{
- rpcCall(NotifyInferiorStopFailed);
-}
-
-void IPCEngineGuest::notifyInferiorExited()
-{
- rpcCall(NotifyInferiorExited);
-}
-
-void IPCEngineGuest::notifyInferiorShutdownOk()
-{
- rpcCall(NotifyInferiorShutdownOk);
-}
-
-void IPCEngineGuest::notifyInferiorShutdownFailed()
-{
- rpcCall(NotifyInferiorShutdownFailed);
-}
-
-void IPCEngineGuest::notifyEngineSpontaneousShutdown()
-{
- rpcCall(NotifyEngineSpontaneousShutdown);
-}
-
-void IPCEngineGuest::notifyEngineShutdownOk()
-{
- rpcCall(NotifyEngineShutdownOk);
-}
-
-void IPCEngineGuest::notifyEngineShutdownFailed()
-{
- rpcCall(NotifyEngineShutdownFailed);
-}
-
-void IPCEngineGuest::notifyInferiorIll()
-{
- rpcCall(NotifyInferiorIll);
-}
-
-void IPCEngineGuest::notifyEngineIll()
-{
- rpcCall(NotifyEngineIll);
-}
-
-void IPCEngineGuest::notifyInferiorPid(qint64 pid)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << pid;
- }
- rpcCall(NotifyInferiorPid, p);
-}
-
-void IPCEngineGuest::showStatusMessage(const QString &msg, quint64 timeout)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << msg;
- s << (qint64)timeout;
- }
- rpcCall(ShowStatusMessage, p);
-}
-
-void IPCEngineGuest::showMessage(const QString &msg, quint16 channel, quint64 timeout)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << msg;
- s << (qint64)channel;
- s << (qint64)timeout;
- }
- rpcCall(ShowMessage, p);
-}
-
-void IPCEngineGuest::currentFrameChanged(qint64 osid)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << osid;
- }
- rpcCall(CurrentFrameChanged, p);
-}
-
-void IPCEngineGuest::currentThreadChanged(qint64 osid)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << osid;
- }
- rpcCall(CurrentThreadChanged, p);
-}
-
-void IPCEngineGuest::listFrames(const StackFrames &frames)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << frames;
- }
- rpcCall(ListFrames, p);
-}
-
-void IPCEngineGuest::listThreads(const Threads &threads)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << threads;
- }
- rpcCall(ListThreads, p);
-}
-
-void IPCEngineGuest::disassembled(quint64 pc, const DisassemblerLines &da)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << pc;
- s << da;
- }
- rpcCall(Disassembled, p);
-}
-
-void IPCEngineGuest::notifyAddBreakpointOk(BreakpointModelId id)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id;
- }
- rpcCall(NotifyAddBreakpointOk, p);
-}
-
-void IPCEngineGuest::notifyAddBreakpointFailed(BreakpointModelId id)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id;
- }
- rpcCall(NotifyAddBreakpointFailed, p);
-}
-
-void IPCEngineGuest::notifyRemoveBreakpointOk(BreakpointModelId id)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id;
- }
- rpcCall(NotifyRemoveBreakpointOk, p);
-}
-
-void IPCEngineGuest::notifyRemoveBreakpointFailed(BreakpointModelId id)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id;
- }
- rpcCall(NotifyRemoveBreakpointFailed, p);
-}
-
-void IPCEngineGuest::notifyChangeBreakpointOk(BreakpointModelId id)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id;
- }
- rpcCall(NotifyChangeBreakpointOk, p);
-}
-
-void IPCEngineGuest::notifyChangeBreakpointFailed(BreakpointModelId id)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id;
- }
- rpcCall(NotifyChangeBreakpointFailed, p);
-}
-
-void IPCEngineGuest::notifyBreakpointAdjusted(BreakpointModelId id,
- const BreakpointParameters &bp)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id << bp;
- }
- rpcCall(NotifyBreakpointAdjusted, p);
-}
-
-void IPCEngineGuest::updateWatchData(bool fullCycle, const QList<WatchData> &wd)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << fullCycle;
- s << quint64(wd.count());
- for (int i = 0; i < wd.count(); ++i)
- s << wd.at(i);
- }
- rpcCall(UpdateWatchData, p);
-}
-
-void IPCEngineGuest::frameSourceFetched(qint64 id, const QString &name, const QString &source)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id;
- s << name;
- s << source;
- }
- rpcCall(FrameSourceFetched, p);
-}
-
-} // namespace Internal
-} // namespace Debugger
-
-
diff --git a/src/plugins/debugger/lldblib/ipcengineguest.h b/src/plugins/debugger/lldblib/ipcengineguest.h
deleted file mode 100644
index 75e278cfba..0000000000
--- a/src/plugins/debugger/lldblib/ipcengineguest.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef IPCENGINEGUEST_H
-#define IPCENGINEGUEST_H
-
-#include <debugger/breakhandler.h>
-#include <debugger/debuggerengine.h>
-#include <debugger/disassemblerlines.h>
-#include <debugger/stackhandler.h>
-#include <debugger/threadshandler.h>
-
-#include <QQueue>
-#include <QThread>
-#include <QVariant>
-
-namespace Debugger {
-namespace Internal {
-
-class IPCEngineHost;
-class IPCEngineGuest : public QObject
-{
- Q_OBJECT
-
-public:
- IPCEngineGuest();
- virtual ~IPCEngineGuest();
-
- void setLocalHost(IPCEngineHost *);
- void setHostDevice(QIODevice *);
-
- virtual void nuke() = 0;
- virtual void setupEngine() = 0;
- virtual void setupInferior(const QString &executeable,
- const QStringList &arguments, const QStringList &environment) = 0;
- virtual void runEngine() = 0;
- virtual void shutdownInferior() = 0;
- virtual void shutdownEngine() = 0;
- virtual void detachDebugger() = 0;
- virtual void executeStep() = 0;
- virtual void executeStepOut() = 0;
- virtual void executeNext() = 0;
- virtual void executeStepI() = 0;
- virtual void executeNextI() = 0;
- virtual void continueInferior() = 0;
- virtual void interruptInferior() = 0;
- virtual void executeRunToLine(const ContextData &data) = 0;
- virtual void executeRunToFunction(const QString &functionName) = 0;
- virtual void executeJumpToLine(const ContextData &data) = 0;
- virtual void activateFrame(qint64 token) = 0;
- virtual void selectThread(qint64 token) = 0;
- virtual void disassemble(quint64 pc) = 0;
- virtual void addBreakpoint(BreakpointModelId id, const BreakpointParameters &bp) = 0;
- virtual void removeBreakpoint(BreakpointModelId id) = 0;
- virtual void changeBreakpoint(BreakpointModelId id, const BreakpointParameters &bp) = 0;
- virtual void requestUpdateWatchData(const WatchData &data,
- const WatchUpdateFlags & flags = WatchUpdateFlags()) = 0;
- virtual void fetchFrameSource(qint64 frame) = 0;
-
- enum Function
- {
- NotifyEngineSetupOk = 1,
- NotifyEngineSetupFailed = 2,
- NotifyEngineRunFailed = 3,
- NotifyInferiorSetupOk = 4,
- NotifyInferiorSetupFailed = 5,
- NotifyEngineRunAndInferiorRunOk = 6,
- NotifyEngineRunAndInferiorStopOk = 7,
- NotifyInferiorRunRequested = 8,
- NotifyInferiorRunOk = 9,
- NotifyInferiorRunFailed = 10,
- NotifyInferiorStopOk = 11,
- NotifyInferiorSpontaneousStop = 12,
- NotifyInferiorStopFailed = 13,
- NotifyInferiorExited = 14,
- NotifyInferiorShutdownOk = 15,
- NotifyInferiorShutdownFailed = 16,
- NotifyEngineSpontaneousShutdown = 17,
- NotifyEngineShutdownOk = 18,
- NotifyEngineShutdownFailed = 19,
- NotifyInferiorIll = 20,
- NotifyEngineIll = 21,
- NotifyInferiorPid = 22,
- ShowStatusMessage = 23,
- ShowMessage = 24,
- CurrentFrameChanged = 25,
- CurrentThreadChanged = 26,
- ListFrames = 27,
- ListThreads = 28,
- Disassembled = 29,
- NotifyAddBreakpointOk = 30,
- NotifyAddBreakpointFailed = 31,
- NotifyRemoveBreakpointOk = 32,
- NotifyRemoveBreakpointFailed = 33,
- NotifyChangeBreakpointOk = 34,
- NotifyChangeBreakpointFailed = 35,
- NotifyBreakpointAdjusted = 36,
- UpdateWatchData = 47,
- FrameSourceFetched = 48
- };
- Q_ENUMS(Function)
-
- DebuggerState state() const;
- void notifyEngineSetupOk();
- void notifyEngineSetupFailed();
- void notifyEngineRunFailed();
- void notifyInferiorSetupOk();
- void notifyInferiorSetupFailed();
- void notifyEngineRunAndInferiorRunOk();
- void notifyEngineRunAndInferiorStopOk();
- void notifyInferiorRunRequested();
- void notifyInferiorRunOk();
- void notifyInferiorRunFailed();
- void notifyInferiorStopOk();
- void notifyInferiorSpontaneousStop();
- void notifyInferiorStopFailed();
- void notifyInferiorExited();
- void notifyInferiorShutdownOk();
- void notifyInferiorShutdownFailed();
- void notifyEngineSpontaneousShutdown();
- void notifyEngineShutdownOk();
- void notifyEngineShutdownFailed();
- void notifyInferiorIll();
- void notifyEngineIll();
- void notifyInferiorPid(qint64 pid);
- void showMessage(const QString &msg, quint16 channel = LogDebug, quint64 timeout = quint64(-1));
- void showStatusMessage(const QString &msg, quint64 timeout = quint64(-1));
-
- void currentFrameChanged(qint64 token);
- void currentThreadChanged(qint64 token);
- void listFrames(const StackFrames &);
- void listThreads(const Threads &);
- void disassembled(quint64 pc, const DisassemblerLines &da);
-
- void notifyAddBreakpointOk(BreakpointModelId id);
- void notifyAddBreakpointFailed(BreakpointModelId id);
- void notifyRemoveBreakpointOk(BreakpointModelId id);
- void notifyRemoveBreakpointFailed(BreakpointModelId id);
- void notifyChangeBreakpointOk(BreakpointModelId id);
- void notifyChangeBreakpointFailed(BreakpointModelId id);
- void notifyBreakpointAdjusted(BreakpointModelId id, const BreakpointParameters &bp);
-
- void updateWatchData(bool fullCycle, const QList<WatchData> &);
-
- void frameSourceFetched(qint64 frame, const QString &name, const QString &sourceCode);
-
- void rpcCall(Function f, QByteArray payload = QByteArray());
-public slots:
- void rpcCallback(quint64 f, QByteArray payload = QByteArray());
-private slots:
- void readyRead();
-private:
- IPCEngineHost *m_local_host;
- quint64 m_nextMessageCookie;
- quint64 m_nextMessageFunction;
- quint64 m_nextMessagePayloadSize;
- quint64 m_cookie;
- QIODevice *m_device;
- DebuggerState m_state;
-};
-
-} // namespace Internal
-} // namespace Debugger
-
-#endif // IPCENGINEGUEST_H
diff --git a/src/plugins/debugger/lldblib/ipcenginehost.cpp b/src/plugins/debugger/lldblib/ipcenginehost.cpp
deleted file mode 100644
index 3203231d16..0000000000
--- a/src/plugins/debugger/lldblib/ipcenginehost.cpp
+++ /dev/null
@@ -1,661 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "ipcenginehost.h"
-
-#include "ipcengineguest.h"
-#include <debugger/debuggerstartparameters.h>
-#include <debugger/breakhandler.h>
-#include <debugger/breakpoint.h>
-#include <debugger/disassemblerlines.h>
-#include <debugger/moduleshandler.h>
-#include <debugger/registerhandler.h>
-#include <debugger/stackhandler.h>
-#include <debugger/watchhandler.h>
-#include <debugger/watchutils.h>
-#include <debugger/threadshandler.h>
-#include <debugger/disassembleragent.h>
-#include <debugger/memoryagent.h>
-#include <debugger/debuggerstreamops.h>
-#include <debugger/debuggercore.h>
-
-#include <utils/qtcassert.h>
-
-#include <QSysInfo>
-#include <QDebug>
-#include <QFileInfo>
-#include <QTimer>
-#include <QLocalSocket>
-
-#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
-#define SET_NATIVE_BYTE_ORDER(x) x.setByteOrder(QDataStream::LittleEndian)
-#else
-#define SET_NATIVE_BYTE_ORDER(x) x.setByteOrder(QDataStream::BigEndian)
-#endif
-
-namespace Debugger {
-namespace Internal {
-
-IPCEngineHost::IPCEngineHost (const DebuggerStartParameters &startParameters)
- : DebuggerEngine(startParameters)
- , m_localGuest(0)
- , m_nextMessagePayloadSize(0)
- , m_cookie(1)
- , m_device(0)
-{
- connect(this, SIGNAL(stateChanged(Debugger::DebuggerState)), SLOT(m_stateChanged(Debugger::DebuggerState)));
-}
-
-IPCEngineHost::~IPCEngineHost()
-{
- delete m_device;
-}
-
-void IPCEngineHost::setLocalGuest(IPCEngineGuest *guest)
-{
- m_localGuest = guest;
-}
-
-void IPCEngineHost::setGuestDevice(QIODevice *device)
-{
- if (m_device) {
- disconnect(m_device, SIGNAL(readyRead()), this, SLOT(readyRead()));
- delete m_device;
- }
- m_device = device;
- if (m_device)
- connect(m_device, SIGNAL(readyRead()), this, SLOT(readyRead()));
-}
-
-void IPCEngineHost::setupEngine()
-{
- QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
- rpcCall(SetupEngine);
-}
-
-void IPCEngineHost::setupInferior()
-{
- QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << QFileInfo(startParameters().executable).absoluteFilePath();
- s << startParameters().processArgs;
- s << startParameters().environment.toStringList();
- }
- rpcCall(SetupInferior, p);
-}
-
-void IPCEngineHost::runEngine()
-{
- QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
- rpcCall(RunEngine);
-}
-
-void IPCEngineHost::shutdownInferior()
-{
- QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
- rpcCall(ShutdownInferior);
-}
-
-void IPCEngineHost::shutdownEngine()
-{
- rpcCall(ShutdownEngine);
-}
-
-void IPCEngineHost::detachDebugger()
-{
- rpcCall(DetachDebugger);
-}
-
-void IPCEngineHost::executeStep()
-{
- rpcCall(ExecuteStep);
-}
-
-void IPCEngineHost::executeStepOut()
-{
- rpcCall(ExecuteStepOut);
-}
-
-void IPCEngineHost::executeNext()
-{
- rpcCall(ExecuteNext);
-}
-
-void IPCEngineHost::executeStepI()
-{
- rpcCall(ExecuteStepI);
-}
-
-void IPCEngineHost::executeNextI()
-{
- rpcCall(ExecuteNextI);
-}
-
-void IPCEngineHost::continueInferior()
-{
- QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
- resetLocation();
- rpcCall(ContinueInferior);
-}
-
-void IPCEngineHost::interruptInferior()
-{
- QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state());
- rpcCall(InterruptInferior);
-}
-
-void IPCEngineHost::executeRunToLine(const ContextData &data)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << data.fileName;
- s << quint64(data.lineNumber);
- }
- rpcCall(ExecuteRunToLine, p);
-}
-
-void IPCEngineHost::executeRunToFunction(const QString &functionName)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << functionName;
- }
- rpcCall(ExecuteRunToFunction, p);
-}
-
-void IPCEngineHost::executeJumpToLine(const ContextData &data)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << data.fileName;
- s << quint64(data.lineNumber);
- }
- rpcCall(ExecuteJumpToLine, p);
-}
-
-void IPCEngineHost::activateFrame(int index)
-{
- resetLocation();
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << quint64(index);
- }
- rpcCall(ActivateFrame, p);
-}
-
-void IPCEngineHost::selectThread(ThreadId id)
-{
- resetLocation();
- QTC_ASSERT(id.isValid(), return);
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id.raw();
- }
- rpcCall(SelectThread, p);
-}
-
-void IPCEngineHost::fetchDisassembler(DisassemblerAgent *v)
-{
- quint64 address = v->location().address();
- m_frameToDisassemblerAgent.insert(address, v);
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << address;
- }
- rpcCall(Disassemble, p);
-}
-
-void IPCEngineHost::insertBreakpoint(BreakpointModelId id)
-{
- breakHandler()->notifyBreakpointInsertProceeding(id);
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id;
- s << breakHandler()->breakpointData(id);
- }
- rpcCall(AddBreakpoint, p);
-}
-
-void IPCEngineHost::removeBreakpoint(BreakpointModelId id)
-{
- breakHandler()->notifyBreakpointRemoveProceeding(id);
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id;
- }
- rpcCall(RemoveBreakpoint, p);
-}
-
-void IPCEngineHost::changeBreakpoint(BreakpointModelId id)
-{
- breakHandler()->notifyBreakpointChangeProceeding(id);
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id;
- s << breakHandler()->breakpointData(id);
- }
- rpcCall(RemoveBreakpoint, p);
-}
-
-void IPCEngineHost::updateWatchData(const WatchData &data,
- const WatchUpdateFlags &flags)
-{
- Q_UNUSED(flags);
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << data;
- }
- rpcCall(RequestUpdateWatchData, p);
-}
-
-void IPCEngineHost::fetchFrameSource(qint64 id)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << id;
- }
- rpcCall(FetchFrameSource, p);
-}
-
-void IPCEngineHost::rpcCallback(quint64 f, QByteArray payload)
-{
- switch (f) {
- default: {
- showMessage(QLatin1String("IPC Error: unhandled id in guest to host call"));
- const QString logMessage = tr("Fatal engine shutdown. Incompatible binary or IPC error.");
- showMessage(logMessage, LogError);
- showStatusMessage(logMessage);
- }
- nuke();
- break;
- case IPCEngineGuest::NotifyEngineSetupOk:
- notifyEngineSetupOk();
- break;
- case IPCEngineGuest::NotifyEngineSetupFailed:
- notifyEngineSetupFailed();
- break;
- case IPCEngineGuest::NotifyEngineRunFailed:
- notifyEngineRunFailed();
- break;
- case IPCEngineGuest::NotifyInferiorSetupOk:
- attemptBreakpointSynchronization();
- notifyInferiorSetupOk();
- break;
- case IPCEngineGuest::NotifyInferiorSetupFailed:
- notifyInferiorSetupFailed();
- break;
- case IPCEngineGuest::NotifyEngineRunAndInferiorRunOk:
- notifyEngineRunAndInferiorRunOk();
- break;
- case IPCEngineGuest::NotifyEngineRunAndInferiorStopOk:
- notifyEngineRunAndInferiorStopOk();
- break;
- case IPCEngineGuest::NotifyInferiorRunRequested:
- notifyInferiorRunRequested();
- break;
- case IPCEngineGuest::NotifyInferiorRunOk:
- notifyInferiorRunOk();
- break;
- case IPCEngineGuest::NotifyInferiorRunFailed:
- notifyInferiorRunFailed();
- break;
- case IPCEngineGuest::NotifyInferiorStopOk:
- notifyInferiorStopOk();
- break;
- case IPCEngineGuest::NotifyInferiorSpontaneousStop:
- notifyInferiorSpontaneousStop();
- break;
- case IPCEngineGuest::NotifyInferiorStopFailed:
- notifyInferiorStopFailed();
- break;
- case IPCEngineGuest::NotifyInferiorExited:
- notifyInferiorExited();
- break;
- case IPCEngineGuest::NotifyInferiorShutdownOk:
- notifyInferiorShutdownOk();
- break;
- case IPCEngineGuest::NotifyInferiorShutdownFailed:
- notifyInferiorShutdownFailed();
- break;
- case IPCEngineGuest::NotifyEngineSpontaneousShutdown:
- notifyEngineSpontaneousShutdown();
- break;
- case IPCEngineGuest::NotifyEngineShutdownOk:
- notifyEngineShutdownOk();
- break;
- case IPCEngineGuest::NotifyEngineShutdownFailed:
- notifyEngineShutdownFailed();
- break;
- case IPCEngineGuest::NotifyInferiorIll:
- notifyInferiorIll();
- break;
- case IPCEngineGuest::NotifyEngineIll:
- notifyEngineIll();
- break;
- case IPCEngineGuest::NotifyInferiorPid:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 pid;
- s >> pid;
- notifyInferiorPid(pid);
- }
- break;
- case IPCEngineGuest::ShowStatusMessage:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- QString msg;
- qint64 timeout;
- s >> msg;
- s >> timeout;
- showStatusMessage(msg, timeout);
- }
- break;
- case IPCEngineGuest::ShowMessage:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- QString msg;
- qint16 channel;
- qint64 timeout;
- s >> msg;
- s >> channel;
- s >> timeout;
- showMessage(msg, channel, timeout);
- }
- break;
- case IPCEngineGuest::CurrentFrameChanged:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 token;
- s >> token;
-
- resetLocation();
- StackHandler *sh = stackHandler();
- sh->setCurrentIndex(token);
- if (!sh->currentFrame().isUsable() || QFileInfo(sh->currentFrame().file).exists())
- gotoLocation(Location(sh->currentFrame(), true));
- else if (!m_sourceAgents.contains(sh->currentFrame().file))
- fetchFrameSource(token);
- foreach (SourceAgent *agent, m_sourceAgents.values())
- agent->updateLocationMarker();
- }
- break;
- case IPCEngineGuest::CurrentThreadChanged:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 token;
- s >> token;
- threadsHandler()->setCurrentThread(ThreadId(token));
- }
- break;
- case IPCEngineGuest::ListFrames:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- StackFrames frames;
- s >> frames;
- stackHandler()->setFrames(frames);
- }
- break;
- case IPCEngineGuest::ListThreads:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- Threads threads;
- s >> threads;
- threadsHandler()->setThreads(threads);
- }
- break;
- case IPCEngineGuest::Disassembled:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 pc;
- DisassemblerLines lines;
- s >> pc;
- s >> lines;
- DisassemblerAgent *view = m_frameToDisassemblerAgent.take(pc);
- if (view)
- view->setContents(lines);
- }
- break;
- case IPCEngineGuest::UpdateWatchData:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- bool fullCycle;
- qint64 count;
- QList<WatchData> wd;
- s >> fullCycle;
- s >> count;
- for (qint64 i = 0; i < count; ++i) {
- WatchData d;
- s >> d;
- wd.append(d);
- }
- WatchHandler *wh = watchHandler();
- if (!wh)
- break;
- wh->insertData(wd);
- }
- break;
- case IPCEngineGuest::NotifyAddBreakpointOk:
- {
- attemptBreakpointSynchronization();
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 d;
- s >> d;
- BreakpointModelId id = BreakpointModelId::fromInternalId(d);
- breakHandler()->notifyBreakpointInsertOk(id);
- }
- break;
- case IPCEngineGuest::NotifyAddBreakpointFailed:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 d;
- s >> d;
- BreakpointModelId id = BreakpointModelId::fromInternalId(d);
- breakHandler()->notifyBreakpointInsertFailed(id);
- }
- break;
- case IPCEngineGuest::NotifyRemoveBreakpointOk:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 d;
- s >> d;
- BreakpointModelId id = BreakpointModelId::fromInternalId(d);
- breakHandler()->notifyBreakpointRemoveOk(id);
- }
- break;
- case IPCEngineGuest::NotifyRemoveBreakpointFailed:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 d;
- s >> d;
- BreakpointModelId id = BreakpointModelId::fromInternalId(d);
- breakHandler()->notifyBreakpointRemoveFailed(id);
- }
- break;
- case IPCEngineGuest::NotifyChangeBreakpointOk:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 d;
- s >> d;
- BreakpointModelId id = BreakpointModelId::fromInternalId(d);
- breakHandler()->notifyBreakpointChangeOk(id);
- }
- break;
- case IPCEngineGuest::NotifyChangeBreakpointFailed:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 d;
- s >> d;
- BreakpointModelId id = BreakpointModelId::fromInternalId(d);
- breakHandler()->notifyBreakpointChangeFailed(id);
- }
- break;
- case IPCEngineGuest::NotifyBreakpointAdjusted:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- quint64 dd;
- BreakpointParameters d;
- s >> dd >> d;
- BreakpointModelId id = BreakpointModelId::fromInternalId(dd);
- breakHandler()->notifyBreakpointAdjusted(id, d);
- }
- break;
- case IPCEngineGuest::FrameSourceFetched:
- {
- QDataStream s(payload);
- SET_NATIVE_BYTE_ORDER(s);
- qint64 token;
- QString path;
- QString source;
- s >> token >> path >> source;
- SourceAgent *agent = new SourceAgent(this);
- agent->setSourceProducerName(startParameters().connParams.host);
- agent->setContent(path, source);
- m_sourceAgents.insert(path, agent);
- agent->updateLocationMarker();
- }
- break;
- }
-}
-
-void IPCEngineHost::m_stateChanged(Debugger::DebuggerState state)
-{
- QByteArray p;
- {
- QDataStream s(&p, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << (qint64)state;
- }
- rpcCall(StateChanged, p);
-
-}
-
-void IPCEngineHost::rpcCall(Function f, QByteArray payload)
-{
- if (m_localGuest) {
- QMetaObject::invokeMethod(m_localGuest,
- "rpcCallback",
- Qt::QueuedConnection,
- Q_ARG(quint64, f),
- Q_ARG(QByteArray, payload));
- } else if (m_device) {
- QByteArray header;
- {
- QDataStream s(&header, QIODevice::WriteOnly);
- SET_NATIVE_BYTE_ORDER(s);
- s << m_cookie++;
- s << (quint64) f;
- s << (quint64) payload.size();
- }
- m_device->write(header);
- m_device->write(payload);
- m_device->putChar('T');
- QLocalSocket *sock = qobject_cast<QLocalSocket *>(m_device);
- if (sock)
- sock->flush();
- }
-}
-
-void IPCEngineHost::readyRead()
-{
- QDataStream s(m_device);
- SET_NATIVE_BYTE_ORDER(s);
- if (!m_nextMessagePayloadSize) {
- if (quint64(m_device->bytesAvailable ()) < 3 * sizeof(quint64))
- return;
- s >> m_nextMessageCookie;
- s >> m_nextMessageFunction;
- s >> m_nextMessagePayloadSize;
- m_nextMessagePayloadSize += 1; // Terminator and "got header" marker.
- }
-
- quint64 ba = m_device->bytesAvailable();
- if (ba < m_nextMessagePayloadSize)
- return;
-
- QByteArray payload = m_device->read(m_nextMessagePayloadSize - 1);
-
- char terminator;
- m_device->getChar(&terminator);
- if (terminator != 'T') {
- showStatusMessage(tr("Fatal engine shutdown. Incompatible binary or IPC error."));
- showMessage(QLatin1String("IPC Error: terminator missing"));
- nuke();
- return;
- }
- rpcCallback(m_nextMessageFunction, payload);
- m_nextMessagePayloadSize = 0;
- if (quint64(m_device->bytesAvailable()) >= 3 * sizeof(quint64))
- QTimer::singleShot(0, this, SLOT(readyRead()));
-}
-
-} // namespace Internal
-} // namespace Debugger
-
-
diff --git a/src/plugins/debugger/lldblib/ipcenginehost.h b/src/plugins/debugger/lldblib/ipcenginehost.h
deleted file mode 100644
index 0175c78ec6..0000000000
--- a/src/plugins/debugger/lldblib/ipcenginehost.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef DEBUGGER_IPCENGINE_HOST_H
-#define DEBUGGER_IPCENGINE_HOST_H
-
-#include <debugger/debuggerengine.h>
-#include <debugger/threadshandler.h>
-#include <debugger/stackhandler.h>
-#include <debugger/breakhandler.h>
-#include <debugger/sourceagent.h>
-
-#include <QQueue>
-#include <QVariant>
-#include <QThread>
-
-namespace Debugger {
-namespace Internal {
-
-class IPCEngineGuest;
-class IPCEngineHost : public DebuggerEngine
-{
- Q_OBJECT
-
-public:
- explicit IPCEngineHost(const DebuggerStartParameters &startParameters);
- ~IPCEngineHost();
-
- // use either one
- void setLocalGuest(IPCEngineGuest *);
- void setGuestDevice(QIODevice *);
-
- enum Function
- {
- SetupIPC = 1,
- StateChanged = 2,
- SetupEngine = 3,
- SetupInferior = 4,
- RunEngine = 5,
- ShutdownInferior = 6,
- ShutdownEngine = 7,
- DetachDebugger = 8,
- ExecuteStep = 9,
- ExecuteStepOut = 10,
- ExecuteNext = 11,
- ExecuteStepI = 12,
- ExecuteNextI = 13,
- ContinueInferior = 14,
- InterruptInferior = 15,
- ExecuteRunToLine = 16,
- ExecuteRunToFunction = 17,
- ExecuteJumpToLine = 18,
- ActivateFrame = 19,
- SelectThread = 20,
- Disassemble = 21,
- AddBreakpoint = 22,
- RemoveBreakpoint = 23,
- ChangeBreakpoint = 24,
- RequestUpdateWatchData = 25,
- FetchFrameSource = 26
- };
- Q_ENUMS(Function)
-
- void setupEngine();
- void setupInferior();
- void runEngine();
- void shutdownInferior();
- void shutdownEngine();
- void detachDebugger();
- void executeStep();
- void executeStepOut() ;
- void executeNext();
- void executeStepI();
- void executeNextI();
- void continueInferior();
- void interruptInferior();
- void executeRunToLine(const ContextData &data);
- void executeRunToFunction(const QString &functionName);
- void executeJumpToLine(const ContextData &data);
- void activateFrame(int index);
- void selectThread(ThreadId index);
- void fetchDisassembler(DisassemblerAgent *);
- bool acceptsBreakpoint(BreakpointModelId) const { return true; } // FIXME
- void insertBreakpoint(BreakpointModelId id);
- void removeBreakpoint(BreakpointModelId id);
- void changeBreakpoint(BreakpointModelId id);
- void updateWatchData(const WatchData &data,
- const WatchUpdateFlags &flags = WatchUpdateFlags());
- void fetchFrameSource(qint64 id);
- bool hasCapability(unsigned) const { return false; }
-
- void rpcCall(Function f, QByteArray payload = QByteArray());
-protected:
- virtual void nuke() = 0;
-public slots:
- void rpcCallback(quint64 f, QByteArray payload = QByteArray());
-private slots:
- void m_stateChanged(Debugger::DebuggerState state);
- void readyRead();
-private:
- IPCEngineGuest *m_localGuest;
- quint64 m_nextMessageCookie;
- quint64 m_nextMessageFunction;
- quint64 m_nextMessagePayloadSize;
- quint64 m_cookie;
- QIODevice *m_device;
- QHash<quint64, DisassemblerAgent *> m_frameToDisassemblerAgent;
- QHash<QString, SourceAgent *> m_sourceAgents;
-};
-
-} // namespace Internal
-} // namespace Debugger
-
-#endif // DEBUGGER_LLDBENGINE_H
diff --git a/src/plugins/debugger/lldblib/lldbenginehost.cpp b/src/plugins/debugger/lldblib/lldbenginehost.cpp
deleted file mode 100644
index 2e484abe40..0000000000
--- a/src/plugins/debugger/lldblib/lldbenginehost.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "lldbenginehost.h"
-
-#include <debugger/debuggerstartparameters.h>
-#include <debugger/debuggeractions.h>
-#include <debugger/debuggerconstants.h>
-#include <debugger/debuggerdialogs.h>
-#include <debugger/debuggerplugin.h>
-#include <debugger/debuggerstringutils.h>
-
-#include <debugger/breakhandler.h>
-#include <debugger/breakpoint.h>
-#include <debugger/moduleshandler.h>
-#include <debugger/registerhandler.h>
-#include <debugger/stackhandler.h>
-#include <debugger/watchhandler.h>
-#include <debugger/watchutils.h>
-#include <debugger/threadshandler.h>
-#include <debugger/disassembleragent.h>
-#include <debugger/memoryagent.h>
-
-#include <coreplugin/icore.h>
-#include <utils/qtcassert.h>
-
-#include <QDebug>
-#include <QProcess>
-#include <QFileInfo>
-#include <QThread>
-#include <QCoreApplication>
-
-namespace Debugger {
-namespace Internal {
-
-SshIODevice::SshIODevice(QSsh::SshRemoteProcessRunner *r)
- : runner(r)
- , buckethead(0)
-{
- setOpenMode(QIODevice::ReadWrite | QIODevice::Unbuffered);
- connect (runner, SIGNAL(processStarted()), this, SLOT(processStarted()));
- connect(runner, SIGNAL(readyReadStandardOutput()), this, SLOT(outputAvailable()));
- connect(runner, SIGNAL(readyReadStandardError()), this, SLOT(errorOutputAvailable()));
-}
-
-SshIODevice::~SshIODevice()
-{
- delete runner;
-}
-
-qint64 SshIODevice::bytesAvailable () const
-{
- qint64 r = QIODevice::bytesAvailable();
- foreach (const QByteArray &bucket, buckets)
- r += bucket.size();
- r-= buckethead;
- return r;
-}
-qint64 SshIODevice::writeData (const char * data, qint64 maxSize)
-{
- if (proc == 0) {
- startupbuffer += QByteArray::fromRawData(data, maxSize);
- return maxSize;
- }
- proc->write(data, maxSize);
- return maxSize;
-}
-qint64 SshIODevice::readData (char * data, qint64 maxSize)
-{
- if (proc == 0)
- return 0;
- qint64 size = maxSize;
- while (size > 0) {
- if (!buckets.size())
- return maxSize - size;
- QByteArray &bucket = buckets.head();
- if ((size + buckethead) >= bucket.size()) {
- int d = bucket.size() - buckethead;
- memcpy(data, bucket.data() + buckethead, d);
- data += d;
- size -= d;
- buckets.dequeue();
- buckethead = 0;
- } else {
- memcpy(data, bucket.data() + buckethead, size);
- data += size;
- buckethead += size;
- size = 0;
- }
- }
- return maxSize - size;
-}
-
-void SshIODevice::processStarted()
-{
- runner->writeDataToProcess(startupbuffer);
-}
-
-void SshIODevice::outputAvailable()
-{
- buckets.enqueue(runner->readAllStandardOutput());
- emit readyRead();
-}
-
-void SshIODevice::errorOutputAvailable()
-{
- fprintf(stderr, "%s", runner->readAllStandardError().data());
-}
-
-
-LldbEngineHost::LldbEngineHost(const DebuggerStartParameters &startParameters)
- :IPCEngineHost(startParameters), m_ssh(0)
-{
- showMessage(QLatin1String("setting up coms"));
- setObjectName(QLatin1String("LLDBEngine"));
-
- if (startParameters.startMode == StartRemoteEngine)
- {
- m_guestProcess = 0;
- QSsh::SshRemoteProcessRunner * const runner = new QSsh::SshRemoteProcessRunner;
- connect (runner, SIGNAL(connectionError(QSsh::SshError)),
- this, SLOT(sshConnectionError(QSsh::SshError)));
- runner->run(startParameters.serverStartScript.toUtf8(), startParameters.connParams);
- setGuestDevice(new SshIODevice(runner));
- } else {
- m_guestProcess = new QProcess(this);
-
- connect(m_guestProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
- this, SLOT(finished(int,QProcess::ExitStatus)));
-
- connect(m_guestProcess, SIGNAL(readyReadStandardError()), this,
- SLOT(stderrReady()));
-
-
- QString a = Core::ICore::resourcePath() + QLatin1String("/qtcreator-lldb");
- if (getenv("QTC_LLDB_GUEST") != 0)
- a = QString::fromLocal8Bit(getenv("QTC_LLDB_GUEST"));
-
- showStatusMessage(QString(QLatin1String("starting %1")).arg(a));
-
- m_guestProcess->start(a, QStringList(), QIODevice::ReadWrite | QIODevice::Unbuffered);
- m_guestProcess->setReadChannel(QProcess::StandardOutput);
-
- if (!m_guestProcess->waitForStarted()) {
- showStatusMessage(tr("qtcreator-lldb failed to start: %1").arg(m_guestProcess->errorString()));
- notifyEngineSpontaneousShutdown();
- return;
- }
-
- setGuestDevice(m_guestProcess);
- }
-}
-
-LldbEngineHost::~LldbEngineHost()
-{
- showMessage(QLatin1String("tear down qtcreator-lldb"));
-
- if (m_guestProcess) {
- disconnect(m_guestProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
- this, SLOT(finished(int,QProcess::ExitStatus)));
-
-
- m_guestProcess->terminate();
- m_guestProcess->kill();
- }
- if (m_ssh && m_ssh->isProcessRunning()) {
- // TODO: openssh doesn't do that
-
- m_ssh->sendSignalToProcess(QSsh::SshRemoteProcess::KillSignal);
- }
-}
-
-void LldbEngineHost::nuke()
-{
- stderrReady();
- showMessage(QLatin1String("Nuke engaged. Bug in Engine/IPC or incompatible IPC versions. "), LogError);
- showStatusMessage(tr("Fatal engine shutdown. Consult debugger log for details."));
- m_guestProcess->terminate();
- m_guestProcess->kill();
- notifyEngineSpontaneousShutdown();
-}
-void LldbEngineHost::sshConnectionError(QSsh::SshError e)
-{
- showStatusMessage(tr("SSH connection error: %1").arg(e));
-}
-
-void LldbEngineHost::finished(int, QProcess::ExitStatus status)
-{
- showMessage(QString(QLatin1String("guest went bye bye. exit status: %1 and code: %2"))
- .arg(status).arg(m_guestProcess->exitCode()), LogError);
- nuke();
-}
-
-void LldbEngineHost::stderrReady()
-{
- fprintf(stderr,"%s", m_guestProcess->readAllStandardError().data());
-}
-
-DebuggerEngine *createLldbLibEngine(const DebuggerStartParameters &startParameters)
-{
- return new LldbEngineHost(startParameters);
-}
-
-} // namespace Internal
-} // namespace Debugger
-
diff --git a/src/plugins/debugger/lldblib/lldbhost.pri b/src/plugins/debugger/lldblib/lldbhost.pri
deleted file mode 100644
index 0e9297d7e3..0000000000
--- a/src/plugins/debugger/lldblib/lldbhost.pri
+++ /dev/null
@@ -1,20 +0,0 @@
-WITH_LLDB = $$(WITH_LLDB)
-
-HEADERS += $$PWD/ipcenginehost.h \
- $$PWD/lldbenginehost.h
-
-SOURCES += $$PWD/ipcenginehost.cpp \
- $$PWD/lldbenginehost.cpp
-
-INCLUDEPATH+=
-
-FORMS +=
-
-RESOURCES +=
-
-!isEmpty(WITH_LLDB) {
- DEFINES += WITH_LLDB
- HEADERS += $$PWD/lldboptionspage.h
- SOURCES += $$PWD/lldboptionspage.cpp
- FORMS += $$PWD/lldboptionspagewidget.ui
-}
diff --git a/src/plugins/debugger/lldblib/lldboptionspage.cpp b/src/plugins/debugger/lldblib/lldboptionspage.cpp
deleted file mode 100644
index 14d414d128..0000000000
--- a/src/plugins/debugger/lldblib/lldboptionspage.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "lldboptionspage.h"
-#include <debugger/debuggerconstants.h>
-#include <debugger/debuggerinternalconstants.h>
-
-#include <coreplugin/icore.h>
-
-#include <QCoreApplication>
-#include <QUrl>
-#include <QTextStream>
-#include <QMessageBox>
-#include <QDesktopServices>
-
-namespace Debugger {
-namespace Internal {
-
-LldbOptionsPageWidget::LldbOptionsPageWidget(QWidget *parent, QSettings *s_)
- : QWidget(parent)
- , s(s_)
-{
- m_ui.setupUi(this);
- load();
-}
-
-void LldbOptionsPageWidget::save()
-{
- s->beginGroup(QLatin1String("LLDB"));
- s->setValue(QLatin1String("enabled"), m_ui.enableLldb->isChecked ());
- s->setValue(QLatin1String("gdbEmu"), m_ui.gdbEmu->isChecked ());
- s->endGroup();
-}
-
-void LldbOptionsPageWidget::load()
-{
- s->beginGroup(QLatin1String("LLDB"));
- m_ui.enableLldb->setChecked(s->value(QLatin1String("enabled"), false).toBool());
- m_ui.gdbEmu->setChecked(s->value(QLatin1String("gdbEmu"), true).toBool());
- s->endGroup();
-}
-
-// ---------- LldbOptionsPage
-LldbOptionsPage::LldbOptionsPage()
-{
- // m_options->fromSettings(Core::ICore::settings());
- setId("F.Lldb");
- setDisplayName(tr("LLDB"));
- setCategory(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY);
- setDisplayCategory(QCoreApplication::translate("Debugger", Constants::DEBUGGER_SETTINGS_TR_CATEGORY));
- setCategoryIcon(QLatin1String(Constants::DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON));
-}
-
-QWidget *LldbOptionsPage::createPage(QWidget *parent)
-{
- m_widget = new LldbOptionsPageWidget(parent, Core::ICore::settings());
- return m_widget;
-}
-
-void LldbOptionsPage::apply()
-{
- if (!m_widget)
- return;
- m_widget->save();
-}
-
-void LldbOptionsPage::finish()
-{
-}
-
-bool LldbOptionsPage::matches(const QString &s) const
-{
- return QString(s.toLower()).contains(QLatin1String("lldb"));
-}
-
-void addLldbOptionPages(QList<Core::IOptionsPage *> *opts)
-{
- opts->push_back(new LldbOptionsPage);
-}
-
-
-} // namespace Internal
-} // namespace Debugger
diff --git a/src/plugins/debugger/lldblib/lldboptionspagewidget.ui b/src/plugins/debugger/lldblib/lldboptionspagewidget.ui
deleted file mode 100644
index 78e77699f0..0000000000
--- a/src/plugins/debugger/lldblib/lldboptionspagewidget.ui
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Debugger::Internal::LldbOptionsPageWidget</class>
- <widget class="QWidget" name="Debugger::Internal::LldbOptionsPageWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>522</width>
- <height>512</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout"/>
- </item>
- <item>
- <widget class="QGroupBox" name="enableLldb">
- <property name="title">
- <string>Enable LLDB</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QCheckBox" name="gdbEmu">
- <property name="text">
- <string>Use GDB Python dumpers</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>203</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/src/plugins/debugger/loadcoredialog.cpp b/src/plugins/debugger/loadcoredialog.cpp
index a8303c7006..63408b7505 100644
--- a/src/plugins/debugger/loadcoredialog.cpp
+++ b/src/plugins/debugger/loadcoredialog.cpp
@@ -236,14 +236,17 @@ AttachCoreDialog::AttachCoreDialog(QWidget *parent)
d->forceLocalLabel->setBuddy(d->forceLocalCheckBox);
d->localExecFileName = new PathChooser(this);
+ d->localExecFileName->setHistoryCompleter(QLatin1String("LocalExecutable"));
d->localExecFileName->setExpectedKind(PathChooser::File);
d->localExecFileName->setPromptDialogTitle(tr("Select Executable"));
d->localCoreFileName = new PathChooser(this);
+ d->localCoreFileName->setHistoryCompleter(QLatin1String("Debugger.CoreFile.History"));
d->localCoreFileName->setExpectedKind(PathChooser::File);
d->localCoreFileName->setPromptDialogTitle(tr("Select Core File"));
d->overrideStartScriptFileName = new PathChooser(this);
+ d->overrideStartScriptFileName->setHistoryCompleter(QLatin1String("Debugger.StartupScript.History"));
d->overrideStartScriptFileName->setExpectedKind(PathChooser::File);
d->overrideStartScriptFileName->setPromptDialogTitle(tr("Select Startup Script"));
diff --git a/src/plugins/debugger/localsandexpressionsoptionspage.ui b/src/plugins/debugger/localsandexpressionsoptionspage.ui
index ce60b3dfbd..d2b320ddaa 100644
--- a/src/plugins/debugger/localsandexpressionsoptionspage.ui
+++ b/src/plugins/debugger/localsandexpressionsoptionspage.ui
@@ -60,7 +60,7 @@
<item>
<widget class="QCheckBox" name="checkBoxShowStdNamespace">
<property name="toolTip">
- <string>Show 'std::' prefix for types from the standard library.</string>
+ <string>Shows 'std::' prefix for types from the standard library.</string>
</property>
<property name="text">
<string>Show &quot;std::&quot; namespace for types</string>
@@ -70,7 +70,7 @@
<item>
<widget class="QCheckBox" name="checkBoxShowQtNamespace">
<property name="toolTip">
- <string>Show Qt namespace prefix for Qt types. This is only relevant if Qt was configured with '-qtnamespace'.</string>
+ <string>Shows Qt namespace prefix for Qt types. This is only relevant if Qt was configured with '-qtnamespace'.</string>
</property>
<property name="text">
<string>Show Qt's namespace for types</string>
diff --git a/src/plugins/debugger/logwindow.cpp b/src/plugins/debugger/logwindow.cpp
index e9859924de..74a3f3f525 100644
--- a/src/plugins/debugger/logwindow.cpp
+++ b/src/plugins/debugger/logwindow.cpp
@@ -48,7 +48,7 @@
#include <aggregation/aggregate.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/minisplitter.h>
-#include <find/basetextfind.h>
+#include <coreplugin/find/basetextfind.h>
#include <utils/savedaction.h>
#include <utils/fancylineedit.h>
@@ -408,11 +408,11 @@ LogWindow::LogWindow(QWidget *parent)
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
aggregate->add(m_combinedText);
- aggregate->add(new Find::BaseTextFind(m_combinedText));
+ aggregate->add(new Core::BaseTextFind(m_combinedText));
aggregate = new Aggregation::Aggregate;
aggregate->add(m_inputText);
- aggregate->add(new Find::BaseTextFind(m_inputText));
+ aggregate->add(new Core::BaseTextFind(m_inputText));
connect(m_inputText, SIGNAL(statusMessageRequested(QString,int)),
SIGNAL(statusMessageRequested(QString,int)));
@@ -433,27 +433,22 @@ LogWindow::LogWindow(QWidget *parent)
void LogWindow::executeLine()
{
m_ignoreNextInputEcho = true;
- debuggerCore()->executeDebuggerCommand(m_inputText->textCursor().block().text(),
- CppLanguage);
+ debuggerCore()->currentEngine()->
+ executeDebuggerCommand(m_inputText->textCursor().block().text(), CppLanguage);
}
void LogWindow::repeatLastCommand()
{
- QTextCursor tc = m_inputText->textCursor();
- QRegExp re = QRegExp(QLatin1String("^\\d+(bb options:)(.*)$"));
- for (QTextBlock block = tc.block(); block.isValid(); block = block.previous()) {
- QString line = block.text();
- if (re.exactMatch(line)) {
- QString cmd = re.cap(1) + QLatin1String("pe,") + re.cap(2);
- debuggerCore()->executeDebuggerCommand(cmd, CppLanguage);
- return;
- }
- }
+ debuggerCore()->currentEngine()->debugLastCommand();
}
void LogWindow::sendCommand()
{
- debuggerCore()->executeDebuggerCommand(m_commandEdit->text(), CppLanguage);
+ DebuggerEngine *engine = debuggerCore()->currentEngine();
+ if (engine->acceptsDebuggerCommands())
+ engine->executeDebuggerCommand(m_commandEdit->text(), CppLanguage);
+ else
+ showOutput(LogError, tr("User commands are not accepted in the current state."));
}
void LogWindow::showOutput(int channel, const QString &output)
diff --git a/src/plugins/debugger/moduleshandler.cpp b/src/plugins/debugger/moduleshandler.cpp
index b92e991afd..3cb26edede 100644
--- a/src/plugins/debugger/moduleshandler.cpp
+++ b/src/plugins/debugger/moduleshandler.cpp
@@ -158,12 +158,12 @@ QVariant ModulesModel::data(const QModelIndex &index, int role) const
return ModulesHandler::tr(
"This module contains debug information.\nStepping "
"into the module or setting breakpoints by file and "
- "is expected to work.");
+ "line is expected to work.");
case FastSymbols:
return ModulesHandler::tr(
"This module contains debug information.\nStepping "
"into the module or setting breakpoints by file and "
- "is expected to work.");
+ "line is expected to work.");
case LinkedSymbols:
case BuildIdSymbols:
return ModulesHandler::tr(
diff --git a/src/plugins/debugger/qml/qmllivetextpreview.cpp b/src/plugins/debugger/qml/qmllivetextpreview.cpp
index 4379aca42b..ed9ee11245 100644
--- a/src/plugins/debugger/qml/qmllivetextpreview.cpp
+++ b/src/plugins/debugger/qml/qmllivetextpreview.cpp
@@ -713,7 +713,7 @@ void QmlLiveTextPreview::showSyncWarning(
foreach (TextEditor::BaseTextEditorWidget *editor, m_editors) {
if (editor) {
- Core::InfoBar *infoBar = editor->editorDocument()->infoBar();
+ Core::InfoBar *infoBar = editor->baseTextDocument()->infoBar();
Core::InfoBarEntry info(Core::Id(INFO_OUT_OF_SYNC), errorMessage);
BaseToolsClient *toolsClient = m_inspectorAdapter->toolsClient();
if (toolsClient && toolsClient->supportReload())
@@ -734,7 +734,7 @@ void QmlLiveTextPreview::removeOutofSyncInfo()
{
foreach (TextEditor::BaseTextEditorWidget *editor, m_editors) {
if (editor) {
- Core::InfoBar *infoBar = editor->editorDocument()->infoBar();
+ Core::InfoBar *infoBar = editor->baseTextDocument()->infoBar();
infoBar->removeInfo(Core::Id(INFO_OUT_OF_SYNC));
}
}
diff --git a/src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp b/src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp
index e687762358..29874ab35f 100644
--- a/src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp
+++ b/src/plugins/debugger/shared/cdbsymbolpathlisteditor.cpp
@@ -56,6 +56,7 @@ CacheDirectoryDialog::CacheDirectoryDialog(QWidget *parent) :
QFormLayout *formLayout = new QFormLayout;
m_chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
+ m_chooser->setHistoryCompleter(QLatin1String("Debugger.CdbCacheDir.History"));
m_chooser->setMinimumWidth(400);
formLayout->addRow(tr("Path:"), m_chooser);
diff --git a/src/plugins/debugger/shared/peutils.cpp b/src/plugins/debugger/shared/peutils.cpp
index de15df0f84..6ab7c8f983 100644
--- a/src/plugins/debugger/shared/peutils.cpp
+++ b/src/plugins/debugger/shared/peutils.cpp
@@ -32,6 +32,7 @@
#include <QStringList>
#ifdef Q_OS_WIN
# include <utils/winutils.h>
+# include <QDir>
# include <QDebug>
# include <climits>
# include <windows.h>
@@ -235,19 +236,25 @@ bool getPDBFiles(const QString &peExecutableFileName, QStringList *rc, QString *
hFile = CreateFile(reinterpret_cast<const WCHAR*>(peExecutableFileName.utf16()), GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL) {
- *errorMessage = QString::fromLatin1("Cannot open '%1': %2").arg(peExecutableFileName, winErrorMessage(GetLastError()));
+ *errorMessage = QString::fromLatin1("Cannot open '%1': %2")
+ .arg(QDir::toNativeSeparators(peExecutableFileName),
+ winErrorMessage(GetLastError()));
break;
}
hFileMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (hFileMap == NULL) {
- *errorMessage = QString::fromLatin1("Cannot create file mapping of '%1': %2").arg(peExecutableFileName, winErrorMessage(GetLastError()));
+ *errorMessage = QString::fromLatin1("Cannot create file mapping of '%1': %2")
+ .arg(QDir::toNativeSeparators(peExecutableFileName),
+ winErrorMessage(GetLastError()));
break;
}
fileMemory = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0);
if (!fileMemory) {
- *errorMessage = QString::fromLatin1("Cannot map '%1': %2").arg(peExecutableFileName, winErrorMessage(GetLastError()));
+ *errorMessage = QString::fromLatin1("Cannot map '%1': %2")
+ .arg(QDir::toNativeSeparators(peExecutableFileName),
+ winErrorMessage(GetLastError()));
break;
}
diff --git a/src/plugins/debugger/simplifytype.cpp b/src/plugins/debugger/simplifytype.cpp
new file mode 100644
index 0000000000..4e11afe741
--- /dev/null
+++ b/src/plugins/debugger/simplifytype.cpp
@@ -0,0 +1,301 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "simplifytype.h"
+
+#include <QRegExp>
+
+#include <ctype.h>
+
+#define QTC_ASSERT_STRINGIFY_HELPER(x) #x
+#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x)
+#define QTC_ASSERT_STRING(cond) qDebug("SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__))
+#define QTC_ASSERT(cond, action) if (cond) {} else { QTC_ASSERT_STRING(#cond); action; } do {} while (0)
+
+namespace Debugger {
+namespace Internal {
+
+// Simplify complicated STL template types,
+// such as 'std::basic_string<char,std::char_traits<char>,std::allocator<char> >'
+// -> 'std::string' and helpers.
+
+static QString chopConst(QString type)
+{
+ while (1) {
+ if (type.startsWith(QLatin1String("const")))
+ type = type.mid(5);
+ else if (type.startsWith(QLatin1Char(' ')))
+ type = type.mid(1);
+ else if (type.endsWith(QLatin1String("const")))
+ type.chop(5);
+ else if (type.endsWith(QLatin1Char(' ')))
+ type.chop(1);
+ else
+ break;
+ }
+ return type;
+}
+
+static inline QRegExp stdStringRegExp(const QString &charType)
+{
+ QString rc = QLatin1String("basic_string<");
+ rc += charType;
+ rc += QLatin1String(",[ ]?std::char_traits<");
+ rc += charType;
+ rc += QLatin1String(">,[ ]?std::allocator<");
+ rc += charType;
+ rc += QLatin1String("> >");
+ const QRegExp re(rc);
+ QTC_ASSERT(re.isValid(), /**/);
+ return re;
+}
+
+// Simplify string types in a type
+// 'std::set<std::basic_string<char... > >' -> std::set<std::string>'
+static inline void simplifyStdString(const QString &charType, const QString &replacement,
+ QString *type)
+{
+ QRegExp stringRegexp = stdStringRegExp(charType);
+ const int replacementSize = replacement.size();
+ for (int pos = 0; pos < type->size(); ) {
+ // Check next match
+ const int matchPos = stringRegexp.indexIn(*type, pos);
+ if (matchPos == -1)
+ break;
+ const int matchedLength = stringRegexp.matchedLength();
+ type->replace(matchPos, matchedLength, replacement);
+ pos = matchPos + replacementSize;
+ // If we were inside an 'allocator<std::basic_string..char > >'
+ // kill the following blank -> 'allocator<std::string>'
+ if (pos + 1 < type->size() && type->at(pos) == QLatin1Char(' ')
+ && type->at(pos + 1) == QLatin1Char('>'))
+ type->remove(pos, 1);
+ }
+}
+
+// Fix 'std::allocator<std::string >' -> 'std::allocator<std::string>',
+// which can happen when replacing/simplifying
+static inline QString fixNestedTemplates(QString s)
+{
+ const int size = s.size();
+ if (size > 3
+ && s.at(size - 1) == QLatin1Char('>')
+ && s.at(size - 2) == QLatin1Char(' ')
+ && s.at(size - 3) != QLatin1Char('>'))
+ s.remove(size - 2, 1);
+ return s;
+}
+
+QString simplifyType(const QString &typeIn)
+{
+ QString type = typeIn;
+ if (type.startsWith(QLatin1String("class "))) // MSVC prepends class,struct
+ type.remove(0, 6);
+ if (type.startsWith(QLatin1String("struct ")))
+ type.remove(0, 7);
+
+ const bool isLibCpp = type.contains(QLatin1String("std::__1"));
+ type.replace(QLatin1String("std::__1::"), QLatin1String("std::"));
+ type.replace(QLatin1String("std::__debug::"), QLatin1String("std::"));
+ type.replace(QLatin1Char('*'), QLatin1Char('@'));
+
+ for (int i = 0; i < 10; ++i) {
+ // boost::shared_ptr<...>::element_type
+ if (type.startsWith(QLatin1String("boost::shared_ptr<"))
+ && type.endsWith(QLatin1String(">::element_type")))
+ type = type.mid(18, type.size() - 33);
+
+ // std::shared_ptr<...>::element_type
+ if (type.startsWith(QLatin1String("std::shared_ptr<"))
+ && type.endsWith(QLatin1String(">::element_type")))
+ type = type.mid(16, type.size() - 31);
+
+ // std::ifstream
+ QRegExp ifstreamRE(QLatin1String("std::basic_ifstream<char,\\s*std::char_traits<char>\\s*>"));
+ ifstreamRE.setMinimal(true);
+ QTC_ASSERT(ifstreamRE.isValid(), return typeIn);
+ if (ifstreamRE.indexIn(type) != -1)
+ type.replace(ifstreamRE.cap(0), QLatin1String("std::ifstream"));
+
+
+ // std::__1::hash_node<int, void *>::value_type -> int
+ if (isLibCpp) {
+ //QRegExp hashNodeRE(QLatin1String("std::__hash_node<([^<>]*),\\s*void\\s*@>::value_type"));
+ QRegExp hashNodeRE(QLatin1String("std::__hash_node<([^<>]*),\\s*void\\s*@>::value_type"));
+ QTC_ASSERT(hashNodeRE.isValid(), return typeIn);
+ if (hashNodeRE.indexIn(type) != -1)
+ type.replace(hashNodeRE.cap(0), hashNodeRE.cap(1));
+ }
+
+ // Anything with a std::allocator
+ int start = type.indexOf(QLatin1String("std::allocator<"));
+ if (start != -1) {
+ // search for matching '>'
+ int pos;
+ int level = 0;
+ for (pos = start + 12; pos < type.size(); ++pos) {
+ int c = type.at(pos).unicode();
+ if (c == '<') {
+ ++level;
+ } else if (c == '>') {
+ --level;
+ if (level == 0)
+ break;
+ }
+ }
+ const QString alloc = fixNestedTemplates(type.mid(start, pos + 1 - start).trimmed());
+ const QString inner = fixNestedTemplates(alloc.mid(15, alloc.size() - 16).trimmed());
+
+ const QString allocEsc = QRegExp::escape(alloc);
+ const QString innerEsc = QRegExp::escape(inner);
+ if (inner == QLatin1String("char")) { // std::string
+ simplifyStdString(QLatin1String("char"), QLatin1String("string"), &type);
+ } else if (inner == QLatin1String("wchar_t")) { // std::wstring
+ simplifyStdString(QLatin1String("wchar_t"), QLatin1String("wstring"), &type);
+ } else if (inner == QLatin1String("unsigned short")) { // std::wstring/MSVC
+ simplifyStdString(QLatin1String("unsigned short"), QLatin1String("wstring"), &type);
+ }
+ // std::vector, std::deque, std::list
+ QRegExp re1(QString::fromLatin1("(vector|list|deque)<%1, ?%2\\s*>").arg(innerEsc, allocEsc));
+ QTC_ASSERT(re1.isValid(), return typeIn);
+ if (re1.indexIn(type) != -1)
+ type.replace(re1.cap(0), QString::fromLatin1("%1<%2>").arg(re1.cap(1), inner));
+
+ // std::stack
+ QRegExp stackRE(QString::fromLatin1("stack<%1, ?std::deque<%2> >").arg(innerEsc, innerEsc));
+ stackRE.setMinimal(true);
+ QTC_ASSERT(stackRE.isValid(), return typeIn);
+ if (stackRE.indexIn(type) != -1)
+ type.replace(stackRE.cap(0), QString::fromLatin1("stack<%1>").arg(inner));
+
+ // std::hash<char>
+ QRegExp hashCharRE(QString::fromLatin1("hash<char, std::char_traits<char>, ?%1\\s*>").arg(allocEsc));
+ hashCharRE.setMinimal(true);
+ QTC_ASSERT(hashCharRE.isValid(), return typeIn);
+ if (hashCharRE.indexIn(type) != -1)
+ type.replace(hashCharRE.cap(0), QString::fromLatin1("hash<char>"));
+
+ // std::set
+ QRegExp setRE(QString::fromLatin1("set<%1, ?std::less<%2>, ?%3\\s*>").arg(innerEsc, innerEsc, allocEsc));
+ setRE.setMinimal(true);
+ QTC_ASSERT(setRE.isValid(), return typeIn);
+ if (setRE.indexIn(type) != -1)
+ type.replace(setRE.cap(0), QString::fromLatin1("set<%1>").arg(inner));
+
+ // std::unordered_set
+ QRegExp unorderedSetRE(QString::fromLatin1("unordered_set<%1, ?std::hash<%2>, ?std::equal_to<%3>, ?%4\\s*>")
+ .arg(innerEsc, innerEsc, innerEsc, allocEsc));
+ unorderedSetRE.setMinimal(true);
+ QTC_ASSERT(unorderedSetRE.isValid(), return typeIn);
+ if (unorderedSetRE.indexIn(type) != -1)
+ type.replace(unorderedSetRE.cap(0), QString::fromLatin1("unordered_set<%1>").arg(inner));
+
+ // std::map
+ if (inner.startsWith(QLatin1String("std::pair<"))) {
+ // search for outermost ',', split key and value
+ int pos;
+ int level = 0;
+ for (pos = 10; pos < inner.size(); ++pos) {
+ int c = inner.at(pos).unicode();
+ if (c == '<')
+ ++level;
+ else if (c == '>')
+ --level;
+ else if (c == ',' && level == 0)
+ break;
+ }
+ const QString key = chopConst(inner.mid(10, pos - 10));
+ const QString keyEsc = QRegExp::escape(key);
+ // Get value: MSVC: 'pair<a const ,b>', gcc: 'pair<const a, b>'
+ if (inner.at(++pos) == QLatin1Char(' '))
+ pos++;
+ const QString value = inner.mid(pos, inner.size() - pos - 1).trimmed();
+ const QString valueEsc = QRegExp::escape(value);
+ QRegExp mapRE1(QString::fromLatin1("map<%1, ?%2, ?std::less<%3 ?>, ?%4\\s*>")
+ .arg(keyEsc, valueEsc, keyEsc, allocEsc));
+ mapRE1.setMinimal(true);
+ QTC_ASSERT(mapRE1.isValid(), return typeIn);
+ if (mapRE1.indexIn(type) != -1) {
+ type.replace(mapRE1.cap(0), QString::fromLatin1("map<%1, %2>").arg(key, value));
+ } else {
+ QRegExp mapRE2(QString::fromLatin1("map<const %1, ?%2, ?std::less<const %3>, ?%4\\s*>")
+ .arg(keyEsc, valueEsc, keyEsc, allocEsc));
+ mapRE2.setMinimal(true);
+ if (mapRE2.indexIn(type) != -1)
+ type.replace(mapRE2.cap(0), QString::fromLatin1("map<const %1, %2>").arg(key, value));
+ }
+ }
+
+ // std::unordered_map
+ if (inner.startsWith(QLatin1String("std::pair<"))) {
+ // search for outermost ',', split key and value
+ int pos;
+ int level = 0;
+ for (pos = 10; pos < inner.size(); ++pos) {
+ int c = inner.at(pos).unicode();
+ if (c == '<')
+ ++level;
+ else if (c == '>')
+ --level;
+ else if (c == ',' && level == 0)
+ break;
+ }
+ const QString key = chopConst(inner.mid(10, pos - 10));
+ const QString keyEsc = QRegExp::escape(key);
+ // Get value: MSVC: 'pair<a const ,b>', gcc: 'pair<const a, b>'
+ if (inner.at(++pos) == QLatin1Char(' '))
+ pos++;
+ const QString value = inner.mid(pos, inner.size() - pos - 1).trimmed();
+ const QString valueEsc = QRegExp::escape(value);
+ QRegExp mapRE1(QString::fromLatin1("unordered_map<%1, ?%2, ?std::hash<%3 ?>, ?std::equal_to<%4 ?>, ?%5\\s*>")
+ .arg(keyEsc, valueEsc, keyEsc, keyEsc, allocEsc));
+ mapRE1.setMinimal(true);
+ QTC_ASSERT(mapRE1.isValid(), return typeIn);
+ if (mapRE1.indexIn(type) != -1)
+ type.replace(mapRE1.cap(0), QString::fromLatin1("unordered_map<%1, %2>").arg(key, value));
+
+ if (isLibCpp) {
+ QRegExp mapRE2(QString::fromLatin1("unordered_map<std::string, ?%1, "
+ "?std::hash<char>, ?std::equal_to<std::string>, ?%2\\s*>")
+ .arg(valueEsc, allocEsc));
+ mapRE2.setMinimal(true);
+ QTC_ASSERT(mapRE2.isValid(), return typeIn);
+ if (mapRE2.indexIn(type) != -1)
+ type.replace(mapRE2.cap(0), QString::fromLatin1("unordered_map<std::string, %2>").arg(value));
+ }
+ }
+ } // with std::allocator
+ }
+ type.replace(QLatin1Char('@'), QLatin1Char('*'));
+ type.replace(QLatin1String(" >"), QLatin1String(">"));
+ return type;
+}
+
+} // namespace Internal
+} // namespace Debugger
diff --git a/src/plugins/debugger/simplifytype.h b/src/plugins/debugger/simplifytype.h
new file mode 100644
index 0000000000..34cabfc9bd
--- /dev/null
+++ b/src/plugins/debugger/simplifytype.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef DEBUGGER_SIMPLIFY_TYPE_H
+#define DEBUGGER_SIMPLIFY_TYPE_H
+
+#include <QString>
+
+namespace Debugger {
+namespace Internal {
+
+// Simplify complicated STL template types, such as
+// 'std::basic_string<char,std::char_traits<char>,std::allocator<char> > '->
+// 'std::string'.
+QString simplifyType(const QString &typeIn);
+
+} // namespace Internal
+} // namespace Debugger
+
+
+#endif // DEBUGGER_SIMPLIFY_TYPE_H
diff --git a/src/plugins/debugger/sourceagent.cpp b/src/plugins/debugger/sourceagent.cpp
index ce63960d37..ddcd76e132 100644
--- a/src/plugins/debugger/sourceagent.cpp
+++ b/src/plugins/debugger/sourceagent.cpp
@@ -137,7 +137,7 @@ void SourceAgent::updateLocationMarker()
QTC_ASSERT(d->editor, return);
if (d->locationMark)
- d->editor->markableInterface()->removeMark(d->locationMark);
+ d->editor->textDocument()->markableInterface()->removeMark(d->locationMark);
delete d->locationMark;
d->locationMark = 0;
if (d->engine->stackHandler()->currentFrame().file == d->path) {
@@ -145,7 +145,7 @@ void SourceAgent::updateLocationMarker()
d->locationMark = new TextEditor::ITextMark(lineNumber);
d->locationMark->setIcon(debuggerCore()->locationMarkIcon());
d->locationMark->setPriority(TextEditor::ITextMark::HighPriority);
- d->editor->markableInterface()->addMark(d->locationMark);
+ d->editor->textDocument()->markableInterface()->addMark(d->locationMark);
QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(d->editor->widget());
QTC_ASSERT(plainTextEdit, return);
QTextCursor tc = plainTextEdit->textCursor();
diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp
index 1ca9c46773..b86178b125 100644
--- a/src/plugins/debugger/stackwindow.cpp
+++ b/src/plugins/debugger/stackwindow.cpp
@@ -40,11 +40,16 @@
#include <utils/savedaction.h>
#include <QDebug>
+#include <QTextStream>
+#include <QFile>
+#include <QDir>
#include <QApplication>
#include <QClipboard>
#include <QContextMenuEvent>
#include <QInputDialog>
+#include <QFileDialog>
+#include <QMessageBox>
#include <QMenu>
namespace Debugger {
@@ -115,6 +120,31 @@ static inline StackFrame inputFunctionForDisassembly()
return frame;
}
+// Write stack frames as task file for displaying it in the build issues pane.
+void saveTaskFile(QWidget *parent, const StackHandler *sh)
+{
+ QFile file;
+ QFileDialog fileDialog(parent);
+ fileDialog.setAcceptMode(QFileDialog::AcceptSave);
+ fileDialog.selectFile(QDir::currentPath() + QLatin1String("/stack.tasks"));
+ while (!file.isOpen()) {
+ if (fileDialog.exec() != QDialog::Accepted)
+ return;
+ const QString fileName = fileDialog.selectedFiles().front();
+ file.setFileName(fileName);
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ QMessageBox::warning(parent, StackTreeView::tr("Cannot Open Task File"),
+ StackTreeView::tr("Cannot open \"%1\": %2").arg(QDir::toNativeSeparators(fileName), file.errorString()));
+ }
+ }
+
+ QTextStream str(&file);
+ foreach (const StackFrame &frame, sh->frames()) {
+ if (frame.isUsable())
+ str << frame.file << '\t' << frame.line << "\tstack\tFrame #" << frame.level << '\n';
+ }
+}
+
void StackTreeView::contextMenuEvent(QContextMenuEvent *ev)
{
DebuggerEngine *engine = currentEngine();
@@ -132,6 +162,9 @@ void StackTreeView::contextMenuEvent(QContextMenuEvent *ev)
QAction *actCopyContents = menu.addAction(tr("Copy Contents to Clipboard"));
actCopyContents->setEnabled(model() != 0);
+ QAction *actSaveTaskFile = menu.addAction(tr("Save as Task File..."));
+ actSaveTaskFile->setEnabled(model() != 0);
+
if (engine->hasCapability(CreateFullBacktraceCapability))
menu.addAction(debuggerCore()->action(CreateFullBacktrace));
@@ -207,6 +240,8 @@ void StackTreeView::contextMenuEvent(QContextMenuEvent *ev)
engine->openDisassemblerView(frame);
else if (act == actLoadSymbols)
engine->loadSymbolsForStack();
+ else if (act == actSaveTaskFile)
+ saveTaskFile(this, handler);
else
handleBaseContextAction(act);
}
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index 240933dc08..6fb1406d10 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -36,15 +36,15 @@
#include "debuggerengine.h"
#include "debuggerinternalconstants.h"
#include "debuggerprotocol.h"
+#include "simplifytype.h"
#include "imageviewer.h"
#include "watchutils.h"
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
-#include <cplusplus/CppRewriter.h>
-
#include <QDebug>
+#include <QFile>
#include <QProcess>
#include <QtAlgorithms>
#include <QTabWidget>
@@ -478,7 +478,7 @@ static QString niceTypeHelper(const QByteArray &typeIn)
const Cache::const_iterator it = cache.constFind(typeIn);
if (it != cache.constEnd())
return it.value();
- const QString simplified = CPlusPlus::simplifySTLType(QLatin1String(typeIn));
+ const QString simplified = simplifyType(QLatin1String(typeIn));
cache.insert(typeIn, simplified); // For simplicity, also cache unmodified types
return simplified;
}
@@ -982,14 +982,6 @@ QString WatchModel::displayType(const WatchData &data) const
return result;
}
-QString WatchModel::displayForAutoTest(const QByteArray &iname) const
-{
- WatchItem *item = findItem(iname);
- if (item)
- return displayValue(*item) + QLatin1Char(' ') + displayType(*item);
- return QString();
-}
-
QVariant WatchModel::data(const QModelIndex &idx, int role) const
{
if (!idx.isValid())
@@ -1230,8 +1222,10 @@ QStringList WatchModel::typeFormatList(const WatchData &data) const
<< tr("Local 8bit string")
<< tr("UTF16 string")
<< tr("UCS4 string")
- << tr("Array of 10 items")
- << tr("Array of 1000 items");
+ << tr("Array of %1 items").arg(10)
+ << tr("Array of %1 items").arg(100)
+ << tr("Array of %1 items").arg(1000)
+ << tr("Array of %1 items").arg(10000);
if (data.type.contains("char[") || data.type.contains("char ["))
return QStringList()
<< tr("Latin1 string")
@@ -1815,21 +1809,28 @@ void WatchHandler::saveWatchers()
DebuggerCore::setSessionValue("Watchers", watchedExpressions());
}
-void WatchHandler::loadTypeFormats()
+void WatchHandler::loadFormats()
{
QVariant value = DebuggerCore::sessionValue("DefaultFormats");
- QMap<QString, QVariant> typeFormats = value.toMap();
- QMapIterator<QString, QVariant> it(typeFormats);
+ QMapIterator<QString, QVariant> it(value.toMap());
while (it.hasNext()) {
it.next();
if (!it.key().isEmpty())
theTypeFormats.insert(it.key().toUtf8(), it.value().toInt());
}
+
+ value = DebuggerCore::sessionValue("IndividualFormats");
+ it = QMapIterator<QString, QVariant>(value.toMap());
+ while (it.hasNext()) {
+ it.next();
+ if (!it.key().isEmpty())
+ theIndividualFormats.insert(it.key().toUtf8(), it.value().toInt());
+ }
}
-void WatchHandler::saveTypeFormats()
+void WatchHandler::saveFormats()
{
- QMap<QString, QVariant> typeFormats;
+ QMap<QString, QVariant> formats;
QHashIterator<QByteArray, int> it(theTypeFormats);
while (it.hasNext()) {
it.next();
@@ -1837,21 +1838,32 @@ void WatchHandler::saveTypeFormats()
if (format != DecimalFormat) {
const QByteArray key = it.key().trimmed();
if (!key.isEmpty())
- typeFormats.insert(QLatin1String(key), format);
+ formats.insert(QString::fromLatin1(key), format);
}
}
- DebuggerCore::setSessionValue("DefaultFormats", typeFormats);
+ DebuggerCore::setSessionValue("DefaultFormats", formats);
+
+ formats.clear();
+ it = QHashIterator<QByteArray, int>(theIndividualFormats);
+ while (it.hasNext()) {
+ it.next();
+ const int format = it.value();
+ const QByteArray key = it.key().trimmed();
+ if (!key.isEmpty())
+ formats.insert(QString::fromLatin1(key), format);
+ }
+ DebuggerCore::setSessionValue("IndividualFormats", formats);
}
void WatchHandler::saveSessionData()
{
saveWatchers();
- saveTypeFormats();
+ saveFormats();
}
void WatchHandler::loadSessionData()
{
- loadTypeFormats();
+ loadFormats();
theWatcherNames.clear();
m_watcherCounter = 0;
QVariant value = DebuggerCore::sessionValue("Watchers");
@@ -1860,20 +1872,6 @@ void WatchHandler::loadSessionData()
watchExpression(exp);
}
-void WatchHandler::updateWatchers()
-{
- m_model->destroyChildren(m_model->m_watchRoot);
- // Copy over all watchers and mark all watchers as incomplete.
- foreach (const QByteArray &exp, theWatcherNames.keys()) {
- WatchData data;
- data.iname = watcherName(exp);
- data.setAllNeeded();
- data.name = QLatin1String(exp);
- data.exp = exp;
- insertIncompleteData(data);
- }
-}
-
QAbstractItemModel *WatchHandler::model() const
{
return m_model;
@@ -1908,11 +1906,6 @@ const WatchData *WatchHandler::findCppLocalVariable(const QString &name) const
return 0;
}
-QString WatchHandler::displayForAutoTest(const QByteArray &iname) const
-{
- return m_model->displayForAutoTest(iname);
-}
-
bool WatchHandler::hasItem(const QByteArray &iname) const
{
return m_model->findItem(iname);
@@ -1925,7 +1918,7 @@ void WatchHandler::setFormat(const QByteArray &type0, int format)
theTypeFormats.remove(type);
else
theTypeFormats[type] = format;
- saveTypeFormats();
+ saveFormats();
m_model->emitDataChanged(1);
}
@@ -2002,11 +1995,6 @@ QString WatchHandler::editorContents()
return contents;
}
-void WatchHandler::removeTooltip()
-{
- m_model->destroyChildren(m_model->m_tooltipRoot);
-}
-
void WatchHandler::setTypeFormats(const TypeFormats &typeFormats)
{
m_model->m_reportedTypeFormats = typeFormats;
diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h
index 73d8951415..0e610c40f3 100644
--- a/src/plugins/debugger/watchhandler.h
+++ b/src/plugins/debugger/watchhandler.h
@@ -80,20 +80,16 @@ public:
void watchVariable(const QString &exp);
Q_SLOT void clearWatches();
- void updateWatchers(); // Called after locals are fetched
-
void showEditValue(const WatchData &data);
const WatchData *watchData(const QModelIndex &) const;
const QModelIndex watchDataIndex(const QByteArray &iname) const;
const WatchData *findData(const QByteArray &iname) const;
const WatchData *findCppLocalVariable(const QString &name) const;
- QString displayForAutoTest(const QByteArray &iname) const;
bool hasItem(const QByteArray &iname) const;
void loadSessionData();
void saveSessionData();
- void removeTooltip();
bool isExpandedIName(const QByteArray &iname) const;
QSet<QByteArray> expandedINames() const;
@@ -115,7 +111,6 @@ public:
static int unprintableBase();
QByteArray watcherName(const QByteArray &exp);
- void synchronizeWatchers();
QString editorContents();
void editTypeFormats(bool includeLocals, const QByteArray &iname);
@@ -141,8 +136,8 @@ private:
friend class WatchModel;
void saveWatchers();
- static void loadTypeFormats();
- static void saveTypeFormats();
+ static void loadFormats();
+ static void saveFormats();
void setFormat(const QByteArray &type, int format);
diff --git a/src/plugins/designer/cpp/cppsettingspage.cpp b/src/plugins/designer/cpp/cppsettingspage.cpp
index 1355262f25..f3ddc32379 100644
--- a/src/plugins/designer/cpp/cppsettingspage.cpp
+++ b/src/plugins/designer/cpp/cppsettingspage.cpp
@@ -89,18 +89,6 @@ void CppSettingsPageWidget::setUiEmbedding(int v)
}
}
-QString CppSettingsPageWidget::searchKeywords() const
-{
- QString rc;
- QTextStream(&rc) << m_ui.ptrAggregationRadioButton->text()
- << ' ' << m_ui.aggregationButton->text()
- << ' ' << m_ui.multipleInheritanceButton->text()
- << ' ' << m_ui.retranslateCheckBox->text()
- << ' ' << m_ui.includeQtModuleCheckBox->text();
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
// ---------- CppSettingsPage
CppSettingsPage::CppSettingsPage(QObject *parent) : Core::IOptionsPage(parent)
{
@@ -112,12 +100,12 @@ CppSettingsPage::CppSettingsPage(QObject *parent) : Core::IOptionsPage(parent)
setCategoryIcon(QLatin1String(Designer::Constants::SETTINGS_CATEGORY_ICON));
}
-QWidget *CppSettingsPage::createPage(QWidget *parent)
+QWidget *CppSettingsPage::widget()
{
- m_widget = new CppSettingsPageWidget(parent);
- m_widget->setParameters(m_parameters);
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new CppSettingsPageWidget;
+ m_widget->setParameters(m_parameters);
+ }
return m_widget;
}
@@ -134,11 +122,7 @@ void CppSettingsPage::apply()
void CppSettingsPage::finish()
{
-}
-
-bool CppSettingsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/designer/cpp/cppsettingspage.h b/src/plugins/designer/cpp/cppsettingspage.h
index 0594ec1124..644c6da33c 100644
--- a/src/plugins/designer/cpp/cppsettingspage.h
+++ b/src/plugins/designer/cpp/cppsettingspage.h
@@ -49,8 +49,6 @@ public:
FormClassWizardGenerationParameters parameters() const;
void setParameters(const FormClassWizardGenerationParameters &p);
- QString searchKeywords() const;
-
private:
int uiEmbedding() const;
void setUiEmbedding(int);
@@ -63,15 +61,13 @@ class CppSettingsPage : public Core::IOptionsPage
public:
explicit CppSettingsPage(QObject *parent = 0);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &s) const;
private:
QPointer<CppSettingsPageWidget> m_widget;
FormClassWizardGenerationParameters m_parameters;
- QString m_searchKeywords;
};
} // namespace Internal
diff --git a/src/plugins/designer/designerxmleditorwidget.cpp b/src/plugins/designer/designerxmleditorwidget.cpp
index b7a5a70baa..62f8c8b144 100644
--- a/src/plugins/designer/designerxmleditorwidget.cpp
+++ b/src/plugins/designer/designerxmleditorwidget.cpp
@@ -39,13 +39,11 @@ namespace Internal {
DesignerXmlEditorWidget::DesignerXmlEditorWidget(QDesignerFormWindowInterface *form,
QWidget *parent) :
- TextEditor::PlainTextEditorWidget(parent),
- m_file(new FormWindowFile(form, this)),
+ TextEditor::PlainTextEditorWidget(new FormWindowFile(form), parent),
m_designerEditor(new FormWindowEditor(this))
{
- setBaseTextDocument(m_file);
setReadOnly(true);
- configure(m_file->mimeType());
+ configure(baseTextDocument()->mimeType());
}
TextEditor::BaseTextEditor *DesignerXmlEditorWidget::createEditor()
@@ -62,7 +60,7 @@ FormWindowEditor *DesignerXmlEditorWidget::designerEditor() const
Internal::FormWindowFile *DesignerXmlEditorWidget::formWindowFile() const
{
- return m_file.data();
+ return qobject_cast<FormWindowFile *>(baseTextDocument());
}
} // namespace Internal
diff --git a/src/plugins/designer/designerxmleditorwidget.h b/src/plugins/designer/designerxmleditorwidget.h
index e0c10552af..3471461006 100644
--- a/src/plugins/designer/designerxmleditorwidget.h
+++ b/src/plugins/designer/designerxmleditorwidget.h
@@ -67,7 +67,6 @@ protected:
virtual TextEditor::BaseTextEditor *createEditor();
private:
- QSharedPointer<Internal::FormWindowFile> m_file;
FormWindowEditor *m_designerEditor;
};
diff --git a/src/plugins/designer/formeditorfactory.cpp b/src/plugins/designer/formeditorfactory.cpp
index cbbd830c26..a005946fe3 100644
--- a/src/plugins/designer/formeditorfactory.cpp
+++ b/src/plugins/designer/formeditorfactory.cpp
@@ -57,9 +57,9 @@ FormEditorFactory::FormEditorFactory()
Core::FileIconProvider::registerIconOverlayForSuffix(":/formeditor/images/qt_ui.png", "ui");
}
-Core::IEditor *FormEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *FormEditorFactory::createEditor()
{
- const EditorData data = FormEditorW::instance()->createEditor(parent);
+ const EditorData data = FormEditorW::instance()->createEditor();
if (data.formWindowEditor) {
Core::InfoBarEntry info(Core::Id(Constants::INFO_READ_ONLY),
tr("This file can only be edited in <b>Design</b> mode."));
diff --git a/src/plugins/designer/formeditorfactory.h b/src/plugins/designer/formeditorfactory.h
index 45b96f80ba..0b0d662071 100644
--- a/src/plugins/designer/formeditorfactory.h
+++ b/src/plugins/designer/formeditorfactory.h
@@ -42,7 +42,7 @@ class FormEditorFactory : public Core::IEditorFactory
public:
FormEditorFactory();
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
private slots:
void designerModeClicked();
diff --git a/src/plugins/designer/formeditorw.h b/src/plugins/designer/formeditorw.h
index 7f20ee2eda..c476e1c7ce 100644
--- a/src/plugins/designer/formeditorw.h
+++ b/src/plugins/designer/formeditorw.h
@@ -113,7 +113,7 @@ public:
// Deletes an existing instance if there is one.
static void deleteInstance();
- EditorData createEditor(QWidget *parent);
+ EditorData createEditor(QWidget *parent = 0);
inline QDesignerFormEditorInterface *designerEditor() const { return m_formeditor; }
inline QWidget * const*designerSubWindows() const { return m_designerSubWindows; }
diff --git a/src/plugins/designer/formwindoweditor.h b/src/plugins/designer/formwindoweditor.h
index 2b71f08b94..7f84e71be0 100644
--- a/src/plugins/designer/formwindoweditor.h
+++ b/src/plugins/designer/formwindoweditor.h
@@ -39,7 +39,6 @@ class QDesignerFormWindowInterface;
QT_END_NAMESPACE
namespace TextEditor {
- class BaseTextDocument;
class PlainTextEditor;
}
diff --git a/src/plugins/designer/gotoslot_test.cpp b/src/plugins/designer/gotoslot_test.cpp
index b8b8f0a58b..1adafcd638 100644
--- a/src/plugins/designer/gotoslot_test.cpp
+++ b/src/plugins/designer/gotoslot_test.cpp
@@ -34,10 +34,11 @@
#else
#include "formeditorw.h"
-#include <coreplugin/testdatadir.h>
#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/testdatadir.h>
#include <cpptools/cppmodelmanager.h>
#include <cpptools/cpptoolseditorsupport.h>
+#include <cpptools/cpptoolstestcase.h>
#include <cplusplus/CppDocument.h>
#include <cplusplus/Overview.h>
@@ -49,7 +50,7 @@
#include <QtTest>
using namespace Core;
-using namespace Core::Internal::Tests;
+using namespace Core::Tests;
using namespace CppTools;
using namespace CPlusPlus;
using namespace Designer;
@@ -57,28 +58,7 @@ using namespace Designer::Internal;
namespace {
-class MyTestDataDir : public Core::Internal::Tests::TestDataDir {
-public:
- MyTestDataDir()
- : TestDataDir(QString())
- {}
- MyTestDataDir(const QString &dir)
- : TestDataDir(QLatin1String(SRCDIR "/../../../tests/designer/") + dir)
- {}
-};
-
-QString expectedContentsForFile(const QString &filePath)
-{
- QFileInfo fi(filePath);
- const QString referenceFileName = QLatin1String("reference_") + fi.fileName();
- const QString referenceFilePath = fi.dir().absoluteFilePath(referenceFileName);
-
- Utils::FileReader fileReader;
- const bool isFetchOk = fileReader.fetch(referenceFilePath);
- if (isFetchOk)
- return QString::fromUtf8(fileReader.data());
- return QString();
-}
+QTC_DECLARE_MYTESTDATADIR("../../../tests/designer/")
class DocumentContainsFunctionDefinition: protected SymbolVisitor
{
@@ -170,38 +150,30 @@ bool documentContainsMemberFunctionDeclaration(const Document::Ptr &document,
return DocumentContainsDeclaration()(document->globalNamespace(), declaration);
}
-class GoToSlotTest
+class GoToSlotTestCase : public CppTools::Tests::TestCase
{
public:
- GoToSlotTest(const QStringList &files)
- : m_files(files)
- , m_modelManager(CppModelManagerInterface::instance())
+ GoToSlotTestCase(const QStringList &files)
{
+ QVERIFY(succeededSoFar());
QCOMPARE(files.size(), 3);
- cleanup();
- }
- ~GoToSlotTest() { cleanup(); }
- void run() const
- {
QList<TextEditor::BaseTextEditor *> editors;
- foreach (const QString &file, m_files) {
+ foreach (const QString &file, files) {
IEditor *editor = EditorManager::openEditor(file);
TextEditor::BaseTextEditor *e = qobject_cast<TextEditor::BaseTextEditor *>(editor);
QVERIFY(e);
+ closeEditorAtEndOfTestCase(editor);
editors << e;
}
TextEditor::BaseTextEditor *cppFileEditor = editors.at(0);
TextEditor::BaseTextEditor *hFileEditor = editors.at(1);
- const QString cppFile = m_files.at(0);
- const QString hFile = m_files.at(1);
+ const QString cppFile = files.at(0);
+ const QString hFile = files.at(1);
- QCOMPARE(EditorManager::documentModel()->openedDocuments().size(), m_files.size());
- while (!m_modelManager->snapshot().contains(cppFile)
- || !m_modelManager->snapshot().contains(hFile)) {
- QApplication::processEvents();
- }
+ QCOMPARE(EditorManager::documentModel()->openedDocuments().size(), files.size());
+ waitForFilesInGlobalSnapshot(QStringList() << cppFile << hFile);
// Execute "Go To Slot"
FormEditorW *few = FormEditorW::instance();
@@ -231,20 +203,6 @@ public:
QVERIFY(documentContainsMemberFunctionDeclaration(hDocument,
QLatin1String("Form::on_pushButton_clicked")));
}
-
-private:
- void cleanup()
- {
- EditorManager::closeAllEditors(/*askAboutModifiedEditors =*/ false);
- QVERIFY(EditorManager::documentModel()->openedDocuments().isEmpty());
-
- m_modelManager->GC();
- QVERIFY(m_modelManager->snapshot().isEmpty());
- }
-
-private:
- QStringList m_files;
- CppModelManagerInterface *m_modelManager;
};
} // anonymous namespace
@@ -256,9 +214,7 @@ void Designer::Internal::FormEditorPlugin::test_gotoslot()
{
#if QT_VERSION >= 0x050000
QFETCH(QStringList, files);
-
- GoToSlotTest test(files);
- test.run();
+ (GoToSlotTestCase(files));
#else
QSKIP("Available only with >= Qt5", SkipSingle);
#endif
diff --git a/src/plugins/designer/qtcreatorintegration.cpp b/src/plugins/designer/qtcreatorintegration.cpp
index be0ad306d3..8385a77bd2 100644
--- a/src/plugins/designer/qtcreatorintegration.cpp
+++ b/src/plugins/designer/qtcreatorintegration.cpp
@@ -350,7 +350,7 @@ static Document::Ptr addDefinition(const Snapshot &docTable,
//! \todo use the InsertionPointLocator to insert at the correct place.
// (we'll have to extend that class first to do definition insertions)
- const QString contents = editable->textDocument()->contents();
+ const QString contents = editable->textDocument()->plainText();
int column;
editable->convertPosition(contents.length(), line, &column);
editable->gotoLine(*line, column);
diff --git a/src/plugins/designer/settingspage.cpp b/src/plugins/designer/settingspage.cpp
index 8892f8ada5..b513027a44 100644
--- a/src/plugins/designer/settingspage.cpp
+++ b/src/plugins/designer/settingspage.cpp
@@ -51,10 +51,13 @@ SettingsPage::SettingsPage(QDesignerOptionsPageInterface *designerPage) :
setCategoryIcon(QLatin1String(Designer::Constants::SETTINGS_CATEGORY_ICON));
}
-QWidget *SettingsPage::createPage(QWidget *parent)
+QWidget *SettingsPage::widget()
{
m_initialized = true;
- return m_designerPage->createPage(parent);
+ if (!m_widget)
+ m_widget = m_designerPage->createPage(0);
+ return m_widget;
+
}
void SettingsPage::apply()
@@ -67,6 +70,7 @@ void SettingsPage::finish()
{
if (m_initialized)
m_designerPage->finish();
+ delete m_widget;
}
SettingsPageProvider::SettingsPageProvider(QObject *parent)
@@ -87,3 +91,43 @@ QList<Core::IOptionsPage *> SettingsPageProvider::pages() const
}
return FormEditorW::instance()->optionsPages();
}
+
+bool SettingsPageProvider::matches(const QString &searchKeyWord) const
+{
+ // to avoid fully initializing designer when typing something in the options' filter edit
+ // we hardcode matching of UI text from the designer pages, which are taken if the designer pages
+ // were not yet loaded
+ // luckily linguist cannot resolve the translated texts, so we do not end up with duplicate
+ // translatable strings for Qt Creator
+ static const struct { const char *context; const char *value; } uitext[] = {
+ {"EmbeddedOptionsPage", "Embedded Design"},
+ {"EmbeddedOptionsPage", "Device Profiles"},
+ {"FormEditorOptionsPage", "Forms"},
+ {"FormEditorOptionsPage", "Preview Zoom"},
+ {"FormEditorOptionsPage", "Default Zoom"},
+ {"FormEditorOptionsPage", "Default Grid"},
+ {"qdesigner_internal::GridPanel", "Visible"},
+ {"qdesigner_internal::GridPanel", "Snap"},
+ {"qdesigner_internal::GridPanel", "Reset"},
+ {"qdesigner_internal::GridPanel", "Grid"},
+ {"qdesigner_internal::GridPanel", "Grid &X"},
+ {"qdesigner_internal::GridPanel", "Grid &Y"},
+ {"PreviewConfigurationWidget", "Print/Preview Configuration"},
+ {"PreviewConfigurationWidget", "Style"},
+ {"PreviewConfigurationWidget", "Style sheet"},
+ {"PreviewConfigurationWidget", "Device skin"},
+ {"TemplateOptionsPage", "Template Paths"},
+ {"qdesigner_internal::TemplateOptionsWidget", "Additional Template Paths"}
+ };
+ static const size_t itemCount = sizeof(uitext)/sizeof(uitext[0]);
+ if (m_keywords.isEmpty()) {
+ m_keywords.reserve(itemCount);
+ for (size_t i = 0; i < itemCount; ++i)
+ m_keywords << QCoreApplication::translate(uitext[i].context, uitext[i].value).remove(QLatin1Char('&'));
+ }
+ foreach (const QString &key, m_keywords) {
+ if (key.contains(searchKeyWord, Qt::CaseInsensitive))
+ return true;
+ }
+ return false;
+}
diff --git a/src/plugins/designer/settingspage.h b/src/plugins/designer/settingspage.h
index 0e6a9fcd3f..9aeac63426 100644
--- a/src/plugins/designer/settingspage.h
+++ b/src/plugins/designer/settingspage.h
@@ -32,6 +32,8 @@
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
QT_BEGIN_NAMESPACE
class QDesignerOptionsPageInterface;
QT_END_NAMESPACE
@@ -48,13 +50,14 @@ class SettingsPage : public Core::IOptionsPage
public:
explicit SettingsPage(QDesignerOptionsPageInterface *designerPage);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
private:
QDesignerOptionsPageInterface *m_designerPage;
bool m_initialized;
+ QPointer<QWidget> m_widget;
};
class SettingsPageProvider : public Core::IOptionsPageProvider
@@ -65,9 +68,11 @@ public:
SettingsPageProvider(QObject *parent = 0);
QList<Core::IOptionsPage *> pages() const;
+ bool matches(const QString &searchKeyWord) const;
private:
mutable bool m_initialized;
+ mutable QStringList m_keywords;
};
} // namespace Internal
diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp
index e99ce81284..d8a9113935 100644
--- a/src/plugins/diffeditor/diffeditor.cpp
+++ b/src/plugins/diffeditor/diffeditor.cpp
@@ -85,6 +85,11 @@ Core::Id DiffEditor::id() const
return Constants::DIFF_EDITOR_ID;
}
+QTextCodec *DiffEditor::codec() const
+{
+ return m_editorWidget->codec();
+}
+
static QToolBar *createToolBar(const QWidget *someWidget)
{
// Create
diff --git a/src/plugins/diffeditor/diffeditor.h b/src/plugins/diffeditor/diffeditor.h
index e557e2052e..daf0b07a67 100644
--- a/src/plugins/diffeditor/diffeditor.h
+++ b/src/plugins/diffeditor/diffeditor.h
@@ -63,7 +63,7 @@ public:
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document();
Core::Id id() const;
- DiffEditorWidget *editorWidget() const { return m_editorWidget; }
+ QTextCodec *codec() const;
QWidget *toolBar();
diff --git a/src/plugins/diffeditor/diffeditor.qbs b/src/plugins/diffeditor/diffeditor.qbs
index 69ef2c01dc..622267fbb5 100644
--- a/src/plugins/diffeditor/diffeditor.qbs
+++ b/src/plugins/diffeditor/diffeditor.qbs
@@ -8,7 +8,6 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
Depends { name: "TextEditor" }
- Depends { name: "Find" }
files: [
diff --git a/src/plugins/diffeditor/diffeditorfactory.cpp b/src/plugins/diffeditor/diffeditorfactory.cpp
index 46fbbf1e74..4cd2a1b11f 100644
--- a/src/plugins/diffeditor/diffeditorfactory.cpp
+++ b/src/plugins/diffeditor/diffeditorfactory.cpp
@@ -46,9 +46,9 @@ DiffEditorFactory::DiffEditorFactory(QObject *parent)
addMimeType(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE));
}
-Core::IEditor *DiffEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *DiffEditorFactory::createEditor()
{
- DiffEditorWidget *editorWidget = new DiffEditorWidget(parent);
+ DiffEditorWidget *editorWidget = new DiffEditorWidget();
DiffEditor *editor = new DiffEditor(editorWidget);
return editor;
}
diff --git a/src/plugins/diffeditor/diffeditorfactory.h b/src/plugins/diffeditor/diffeditorfactory.h
index 7abe41259a..d171cfe243 100644
--- a/src/plugins/diffeditor/diffeditorfactory.h
+++ b/src/plugins/diffeditor/diffeditorfactory.h
@@ -47,7 +47,7 @@ class DiffEditorFactory : public Core::IEditorFactory
public:
explicit DiffEditorFactory(QObject *parent);
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
};
} // namespace Internal
diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp
index c8eec21e65..647c197fe0 100644
--- a/src/plugins/diffeditor/diffeditorplugin.cpp
+++ b/src/plugins/diffeditor/diffeditorplugin.cpp
@@ -109,10 +109,10 @@ void DiffEditorPlugin::diff()
Core::EditorManager::activateEditor(editor);
- DiffEditorWidget *editorWidget = editor->editorWidget();
+ QTextCodec *codec = editor->codec();
- const QString text1 = getFileContents(fileName1, editorWidget->codec());
- const QString text2 = getFileContents(fileName2, editorWidget->codec());
+ const QString text1 = getFileContents(fileName1, codec);
+ const QString text2 = getFileContents(fileName2, codec);
DiffEditorWidget::DiffFilesContents dfc;
dfc.leftFileInfo = fileName1;
diff --git a/src/plugins/diffeditor/diffeditorwidget.cpp b/src/plugins/diffeditor/diffeditorwidget.cpp
index 9a4247d0f1..18284e8414 100644
--- a/src/plugins/diffeditor/diffeditorwidget.cpp
+++ b/src/plugins/diffeditor/diffeditorwidget.cpp
@@ -888,16 +888,6 @@ QTextCodec *DiffEditorWidget::codec() const
return const_cast<QTextCodec *>(m_leftEditor->codec());
}
-QString DiffEditorWidget::source() const
-{
- return m_source;
-}
-
-void DiffEditorWidget::setSource(const QString &source)
-{
- m_source = source;
-}
-
BaseTextEditorWidget *DiffEditorWidget::leftEditor() const
{
return m_leftEditor;
diff --git a/src/plugins/diffeditor/diffeditorwidget.h b/src/plugins/diffeditor/diffeditorwidget.h
index b819d4b978..97c131dccb 100644
--- a/src/plugins/diffeditor/diffeditorwidget.h
+++ b/src/plugins/diffeditor/diffeditorwidget.h
@@ -58,7 +58,6 @@ struct FileData;
class DIFFEDITOR_EXPORT DiffEditorWidget : public QWidget
{
- Q_PROPERTY(QString source READ source WRITE setSource)
Q_OBJECT
public:
struct DiffFileInfo {
@@ -84,9 +83,6 @@ public:
void setDiff(const QList<DiffFilesContents> &diffFileList, const QString &workingDirectory = QString());
QTextCodec *codec() const;
- QString source() const;
- void setSource(const QString &source);
-
#ifdef WITH_TESTS
void testAssemblyRows();
#endif // WITH_TESTS
diff --git a/src/plugins/diffeditor/diffshoweditorfactory.cpp b/src/plugins/diffeditor/diffshoweditorfactory.cpp
index b169a64898..a7e5e76bf8 100644
--- a/src/plugins/diffeditor/diffshoweditorfactory.cpp
+++ b/src/plugins/diffeditor/diffshoweditorfactory.cpp
@@ -46,9 +46,9 @@ DiffShowEditorFactory::DiffShowEditorFactory(QObject *parent)
setMimeTypes(QStringList() << QLatin1String(Constants::DIFF_EDITOR_MIMETYPE));
}
-Core::IEditor *DiffShowEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *DiffShowEditorFactory::createEditor()
{
- DiffEditorWidget *editorWidget = new DiffEditorWidget(parent);
+ DiffEditorWidget *editorWidget = new DiffEditorWidget();
DiffShowEditor *editor = new DiffShowEditor(editorWidget);
return editor;
}
diff --git a/src/plugins/diffeditor/diffshoweditorfactory.h b/src/plugins/diffeditor/diffshoweditorfactory.h
index 268ee01e59..b1823a27a9 100644
--- a/src/plugins/diffeditor/diffshoweditorfactory.h
+++ b/src/plugins/diffeditor/diffshoweditorfactory.h
@@ -47,7 +47,7 @@ class DiffShowEditorFactory : public Core::IEditorFactory
public:
explicit DiffShowEditorFactory(QObject *parent);
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
};
} // namespace Internal
diff --git a/src/plugins/fakevim/fakevim.qbs b/src/plugins/fakevim/fakevim.qbs
index 4864bc0b50..5ac7938928 100644
--- a/src/plugins/fakevim/fakevim.qbs
+++ b/src/plugins/fakevim/fakevim.qbs
@@ -7,7 +7,6 @@ QtcPlugin {
Depends { name: "Core" }
Depends { name: "TextEditor" }
- Depends { name: "Find" }
Depends { name: "Qt.widgets" }
files: [
diff --git a/src/plugins/fakevim/fakevim_dependencies.pri b/src/plugins/fakevim/fakevim_dependencies.pri
index abb8f31a74..51a82fc372 100644
--- a/src/plugins/fakevim/fakevim_dependencies.pri
+++ b/src/plugins/fakevim/fakevim_dependencies.pri
@@ -1,5 +1,4 @@
QTC_PLUGIN_NAME = FakeVim
QTC_PLUGIN_DEPENDS += \
coreplugin \
- texteditor \
- find
+ texteditor
diff --git a/src/plugins/fakevim/fakevim_test.cpp b/src/plugins/fakevim/fakevim_test.cpp
index eef9ab0874..037eb3ef27 100644
--- a/src/plugins/fakevim/fakevim_test.cpp
+++ b/src/plugins/fakevim/fakevim_test.cpp
@@ -1902,6 +1902,19 @@ void FakeVimPlugin::test_vim_letter_case()
KEYS("2gUU", " " X "ABC" N "DEF");
KEYS("u", " " X "abc" N "def");
KEYS("<c-r>", " " X "ABC" N "DEF");
+
+ // undo, redo and dot command
+ data.setText(" abcde" N " fgh" N " ijk");
+ KEYS("3l" "<C-V>2l2j" "U", " a" X "BCDe" N " fGH" N " iJK");
+ KEYS("u", " a" X "bcde" N " fgh" N " ijk");
+ KEYS("<C-R>", " a" X "BCDe" N " fGH" N " iJK");
+ KEYS("u", " a" X "bcde" N " fgh" N " ijk");
+ KEYS("h.", " " X "ABCde" N " FGH" N " IJK");
+ KEYS("u", " " X "abcde" N " fgh" N " ijk");
+ KEYS("h.", " " X " ABcde" N " FGh" N " IJk");
+ KEYS("u", " " X " abcde" N " fgh" N " ijk");
+ KEYS("j.", " abcde" N " " X " FGh" N " IJk");
+ KEYS("u", " abcde" N " " X " fgh" N " ijk");
}
void FakeVimPlugin::test_vim_code_autoindent()
@@ -2246,6 +2259,45 @@ void FakeVimPlugin::test_vim_ex_yank()
data.setText("abc" N "def");
KEYS("\"xy$", X "abc" N "def");
KEYS("\"xP", "ab" X "cabc" N "def");
+
+ data.setText(
+ "abc def" N
+ "ghi jkl" N
+ );
+ KEYS("yiwp",
+ "aab" X "cbc def" N
+ "ghi jkl" N
+ );
+ KEYS("u",
+ X "abc def" N
+ "ghi jkl" N
+ );
+ KEYS("\"0p",
+ "aab" X "cbc def" N
+ "ghi jkl" N
+ );
+ KEYS("\"xyiw",
+ X "aabcbc def" N
+ "ghi jkl" N
+ );
+ KEYS("\"0p",
+ "aab" X "cabcbc def" N
+ "ghi jkl" N
+ );
+ KEYS("\"xp",
+ "aabcaabcb" X "cabcbc def" N
+ "ghi jkl" N
+ );
+
+ // register " is last yank
+ data.setText(
+ "abc def" N
+ "ghi jkl" N
+ );
+ KEYS("yiwp\"xyiw\"\"p",
+ "aaabcb" X "cabcbc def" N
+ "ghi jkl" N
+ );
}
void FakeVimPlugin::test_vim_ex_delete()
@@ -2551,6 +2603,7 @@ void FakeVimPlugin::test_map()
data.setText("abc" N "def");
data.doCommand(QString::fromUtf8("no \xc3\xb8 l|no l k|no k j|no j h"));
KEYS(QString::fromUtf8("\xc3\xb8"), "a" X "bc" N "def");
+ data.doCommand(QString::fromUtf8("unmap \xc3\xb8|unmap l|unmap k|unmap j"));
// Don't handle mapping in sub-modes that are not followed by movement command.
data.setText("abc" N "def");
@@ -2575,6 +2628,16 @@ void FakeVimPlugin::test_map()
data.doCommand("onoremap iwwX 3iwX Y");
KEYS("ciwwX Z<esc>", "X Y " X "Z" N "ghi jkl");
data.doCommand("unmap <SPACE>X");
+
+ // use mapping for <ESC> in insert
+ data.setText("ab" X "c def" N "ghi jkl");
+ data.doCommand("inoremap jk <ESC>");
+ KEYS("<C-V>jll" "I__jk", "ab" X "__c def" N "gh__i jkl");
+ INTEGRITY(false);
+ data.doCommand("unmap jk"); // shouldn't unmap for insert mode
+ KEYS("ijk", "a" X "b__c def" N "gh__i jkl");
+ data.doCommand("iunmap jk");
+ KEYS("ijk<ESC>", "aj" X "kb__c def" N "gh__i jkl");
}
void FakeVimPlugin::test_vim_command_cc()
@@ -3012,6 +3075,90 @@ void FakeVimPlugin::test_vim_command_y_dollar()
KEYS("$y$P", l[0]+'\n'+ l[1]+">>|>>\n" + lmid(2));
}
+void FakeVimPlugin::test_vim_command_percent()
+{
+ TestData data;
+ setup(&data);
+
+ data.setText(
+ "bool f(int arg1) {" N
+ " Q_ASSERT(arg1 >= 0);" N
+ " if (arg1 > 0) return true; else if (arg1 <= 0) return false;" N
+ "}" N
+ );
+
+ KEYS("%",
+ "bool f(int arg1" X ") {" N
+ " Q_ASSERT(arg1 >= 0);" N
+ " if (arg1 > 0) return true; else if (arg1 <= 0) return false;" N
+ "}" N
+ );
+
+ KEYS("%",
+ "bool f" X "(int arg1) {" N
+ " Q_ASSERT(arg1 >= 0);" N
+ " if (arg1 > 0) return true; else if (arg1 <= 0) return false;" N
+ "}" N
+ );
+
+ KEYS("$h%",
+ "bool f(int arg1) {" N
+ " Q_ASSERT(arg1 >= 0);" N
+ " if (arg1 > 0) return true; else if (arg1 <= 0) return false;" N
+ X "}" N
+ );
+
+ KEYS("%",
+ "bool f(int arg1) " X "{" N
+ " Q_ASSERT(arg1 >= 0);" N
+ " if (arg1 > 0) return true; else if (arg1 <= 0) return false;" N
+ "}" N
+ );
+
+ KEYS("j%",
+ "bool f(int arg1) {" N
+ " Q_ASSERT" X "(arg1 >= 0);" N
+ " if (arg1 > 0) return true; else if (arg1 <= 0) return false;" N
+ "}" N
+ );
+
+ KEYS("%",
+ "bool f(int arg1) {" N
+ " Q_ASSERT(arg1 >= 0" X ");" N
+ " if (arg1 > 0) return true; else if (arg1 <= 0) return false;" N
+ "}" N
+ );
+
+ KEYS("j%",
+ "bool f(int arg1) {" N
+ " Q_ASSERT(arg1 >= 0);" N
+ " if (arg1 > 0) return true; else if (arg1 <= 0" X ") return false;" N
+ "}" N
+ );
+
+ KEYS("0%",
+ "bool f(int arg1) {" N
+ " Q_ASSERT(arg1 >= 0);" N
+ " if (arg1 > 0" X ") return true; else if (arg1 <= 0) return false;" N
+ "}" N
+ );
+
+ KEYS("%",
+ "bool f(int arg1) {" N
+ " Q_ASSERT(arg1 >= 0);" N
+ " if " X "(arg1 > 0) return true; else if (arg1 <= 0) return false;" N
+ "}" N
+ );
+
+ // jump to 50% of buffer
+ KEYS("50%",
+ "bool f(int arg1) {" N
+ " Q_ASSERT(arg1 >= 0);" N
+ " " X "if (arg1 > 0) return true; else if (arg1 <= 0) return false;" N
+ "}" N
+ );
+}
+
void FakeVimPlugin::test_vim_command_Yp()
{
TestData data;
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 6b9fc7129d..7d471b8c13 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -705,6 +705,33 @@ static void setClipboardData(const QString &content, RangeMode mode,
clipboard->setMimeData(data, clipboardMode);
}
+static QByteArray toLocalEncoding(const QString &text)
+{
+ return HostOsInfo::isWindowsHost() ? QString(text).replace(_("\n"), _("\r\n")).toLocal8Bit()
+ : text.toLocal8Bit();
+}
+
+static QString fromLocalEncoding(const QByteArray &data)
+{
+ return HostOsInfo::isWindowsHost() ? QString::fromLocal8Bit(data).replace(_("\n"), _("\r\n"))
+ : QString::fromLocal8Bit(data);
+}
+
+static QString getProcessOutput(const QString &command, const QString &input)
+{
+ QProcess proc;
+ proc.start(command);
+ proc.waitForStarted();
+ proc.write(toLocalEncoding(input));
+ proc.closeWriteChannel();
+
+ // FIXME: Process should be interruptable by user.
+ // Solution is to create a QObject for each process and emit finished state.
+ proc.waitForFinished();
+
+ return fromLocalEncoding(proc.readAllStandardOutput());
+}
+
static const QMap<QString, int> &vimKeyNames()
{
static QMap<QString, int> k;
@@ -816,6 +843,11 @@ QString Range::toString() const
.arg(rangemode);
}
+bool Range::isValid() const
+{
+ return beginPos >= 0 && endPos >= 0;
+}
+
QDebug operator<<(QDebug ts, const Range &range)
{
return ts << '[' << range.beginPos << ',' << range.endPos << ']';
@@ -1463,11 +1495,12 @@ private:
// state of current mapping
struct MappingState {
MappingState()
- : noremap(false), silent(false) {}
- MappingState(bool noremap, bool silent)
- : noremap(noremap), silent(silent) {}
+ : noremap(false), silent(false), editBlock(false) {}
+ MappingState(bool noremap, bool silent, bool editBlock)
+ : noremap(noremap), silent(silent), editBlock(editBlock) {}
bool noremap;
bool silent;
+ bool editBlock;
};
class FakeVimHandler::Private : public QObject
@@ -1631,12 +1664,10 @@ public:
void moveToFirstNonBlankOnLine();
void moveToFirstNonBlankOnLine(QTextCursor *tc);
+ void moveToFirstNonBlankOnLineVisually();
+ void moveToNonBlankOnLine(QTextCursor *tc);
void moveToTargetColumn();
- void setTargetColumn() {
- m_targetColumn = logicalCursorColumn();
- m_visualTargetColumn = m_targetColumn;
- //qDebug() << "TARGET: " << m_targetColumn;
- }
+ void setTargetColumn();
void moveToMatchingParanthesis();
void moveToBoundary(bool simple, bool forward = true);
void moveToNextBoundary(bool end, int count, bool simple, bool forward);
@@ -1652,10 +1683,15 @@ public:
// Convenience wrappers to reduce line noise.
void moveToStartOfLine();
+ void moveToStartOfLineVisually();
void moveToEndOfLine();
+ void moveToEndOfLineVisually();
+ void moveToEndOfLineVisually(QTextCursor *tc);
void moveBehindEndOfLine();
void moveUp(int n = 1) { moveDown(-n); }
void moveDown(int n = 1);
+ void moveUpVisually(int n = 1) { moveDownVisually(-n); }
+ void moveDownVisually(int n = 1);
void movePageDown(int count = 1);
void movePageUp(int count = 1) { movePageDown(-count); }
void dump(const char *msg) const {
@@ -1861,7 +1897,7 @@ public:
void setCurrentRange(const Range &range);
Range currentRange() const { return Range(position(), anchor(), g.rangemode); }
- void yankText(const Range &range, int toregister = '"');
+ void yankText(const Range &range, int toregister);
void pasteText(bool afterCursor);
@@ -1913,6 +1949,7 @@ public:
int m_targetColumn; // -1 if past end of line
int m_visualTargetColumn; // 'l' can move past eol in visual mode only
+ int m_targetColumnWrapped; // column in current part of wrapped line
// auto-indent
QString tabExpand(int len) const;
@@ -2099,6 +2136,7 @@ void FakeVimHandler::Private::init()
m_lastVisualModeInverted = false;
m_targetColumn = 0;
m_visualTargetColumn = 0;
+ m_targetColumnWrapped = 0;
m_ctrlVActive = false;
m_oldInternalAnchor = -1;
m_oldInternalPosition = -1;
@@ -2646,9 +2684,13 @@ void FakeVimHandler::Private::prependMapping(const Inputs &inputs)
++g.mapDepth;
g.pendingInput.prepend(Input());
prependInputs(inputs);
- g.mapStates << MappingState(inputs.noremap(), inputs.silent());
g.commandBuffer.setHistoryAutoSave(false);
- beginLargeEditBlock();
+
+ // start new edit block (undo/redo) only if necessary
+ bool editBlock = m_editBlockLevel == 0 && !(isInsertMode() && isInsertStateValid());
+ if (editBlock)
+ beginLargeEditBlock();
+ g.mapStates << MappingState(inputs.noremap(), inputs.silent(), editBlock);
}
bool FakeVimHandler::Private::expandCompleteMapping()
@@ -2678,8 +2720,9 @@ void FakeVimHandler::Private::endMapping()
--g.mapDepth;
if (g.mapStates.isEmpty())
return;
+ if (g.mapStates.last().editBlock)
+ endEditBlock();
g.mapStates.pop_back();
- endEditBlock();
if (g.mapStates.isEmpty())
g.commandBuffer.setHistoryAutoSave(true);
updateMiniBuffer();
@@ -2896,6 +2939,40 @@ void FakeVimHandler::Private::moveDown(int n)
updateScrollOffset();
}
+void FakeVimHandler::Private::moveDownVisually(int n)
+{
+ const QTextCursor::MoveOperation moveOperation = (n > 0) ? Down : Up;
+ int count = qAbs(n);
+ int oldPos = m_cursor.position();
+
+ while (count > 0) {
+ m_cursor.movePosition(moveOperation, KeepAnchor, 1);
+ if (oldPos == m_cursor.position())
+ break;
+ oldPos = m_cursor.position();
+ QTextBlock block = m_cursor.block();
+ if (block.isVisible())
+ --count;
+ }
+
+ QTextCursor tc = m_cursor;
+ tc.movePosition(StartOfLine);
+ const int minPos = tc.position();
+ moveToEndOfLineVisually(&tc);
+ const int maxPos = tc.position();
+
+ if (m_targetColumn == -1) {
+ setPosition(maxPos);
+ } else {
+ setPosition(qMin(maxPos, minPos + m_targetColumnWrapped));
+ const int targetColumn = m_targetColumnWrapped;
+ setTargetColumn();
+ m_targetColumnWrapped = targetColumn;
+ }
+
+ updateScrollOffset();
+}
+
void FakeVimHandler::Private::movePageDown(int count)
{
const int scrollOffset = windowScrollOffset();
@@ -2950,6 +3027,26 @@ void FakeVimHandler::Private::moveToEndOfLine()
bool onlyVisibleLines = isVisualMode() || g.submode != NoSubMode;
const int id = onlyVisibleLines ? lineNumber(block()) : block().blockNumber() + 1;
setPosition(lastPositionInLine(id, onlyVisibleLines));
+ setTargetColumn();
+}
+
+void FakeVimHandler::Private::moveToEndOfLineVisually()
+{
+ moveToEndOfLineVisually(&m_cursor);
+ setTargetColumn();
+}
+
+void FakeVimHandler::Private::moveToEndOfLineVisually(QTextCursor *tc)
+{
+ // Moving to end of line ends up on following line if the line is wrapped.
+ tc->movePosition(StartOfLine);
+ const int minPos = tc->position();
+ tc->movePosition(EndOfLine);
+ int maxPos = tc->position();
+ tc->movePosition(StartOfLine);
+ if (minPos != tc->position())
+ --maxPos;
+ tc->setPosition(maxPos);
}
void FakeVimHandler::Private::moveBehindEndOfLine()
@@ -2962,12 +3059,14 @@ void FakeVimHandler::Private::moveBehindEndOfLine()
void FakeVimHandler::Private::moveToStartOfLine()
{
-#if 0
- // does not work for "hidden" documents like in the autotests
- tc.movePosition(StartOfLine, MoveAnchor);
-#else
setPosition(block().position());
-#endif
+ setTargetColumn();
+}
+
+void FakeVimHandler::Private::moveToStartOfLineVisually()
+{
+ m_cursor.movePosition(StartOfLine, KeepAnchor);
+ setTargetColumn();
}
void FakeVimHandler::Private::fixSelection()
@@ -3482,15 +3581,19 @@ bool FakeVimHandler::Private::handleMovement(const Input &input)
return true;
} else if (input.is('0')) {
g.movetype = MoveExclusive;
- moveToStartOfLine();
- setTargetColumn();
+ if (g.gflag)
+ moveToStartOfLineVisually();
+ else
+ moveToStartOfLine();
count = 1;
} else if (input.is('a') || input.is('i')) {
g.subsubmode = TextObjectSubSubMode;
g.subsubdata = input;
} else if (input.is('^') || input.is('_')) {
- moveToFirstNonBlankOnLine();
- setTargetColumn();
+ if (g.gflag)
+ moveToFirstNonBlankOnLineVisually();
+ else
+ moveToFirstNonBlankOnLine();
g.movetype = MoveExclusive;
} else if (0 && input.is(',')) {
// FIXME: fakevim uses ',' by itself, so it is incompatible
@@ -3572,9 +3675,15 @@ bool FakeVimHandler::Private::handleMovement(const Input &input)
setTargetColumn();
movement = _("<HOME>");
} else if (input.is('$') || input.isKey(Key_End)) {
- if (count > 1)
- moveDown(count - 1);
- moveToEndOfLine();
+ if (g.gflag) {
+ if (count > 1)
+ moveDownVisually(count - 1);
+ moveToEndOfLineVisually();
+ } else {
+ if (count > 1)
+ moveDown(count - 1);
+ moveToEndOfLine();
+ }
g.movetype = atEmptyLine() ? MoveExclusive : MoveInclusive;
setTargetColumn();
if (g.submode == NoSubMode)
@@ -3670,13 +3779,25 @@ bool FakeVimHandler::Private::handleMovement(const Input &input)
handleStartOfLine();
} else if (input.is('j') || input.isKey(Key_Down)
|| input.isControl('j') || input.isControl('n')) {
- g.movetype = MoveLineWise;
- moveDown(count);
- movement = _("j");
+ if (g.gflag) {
+ g.movetype = MoveExclusive;
+ moveDownVisually(count);
+ movement = _("gj");
+ } else {
+ g.movetype = MoveLineWise;
+ moveDown(count);
+ movement = _("j");
+ }
} else if (input.is('k') || input.isKey(Key_Up) || input.isControl('p')) {
- g.movetype = MoveLineWise;
- moveUp(count);
- movement = _("k");
+ if (g.gflag) {
+ g.movetype = MoveExclusive;
+ moveUpVisually(count);
+ movement = _("gk");
+ } else {
+ g.movetype = MoveLineWise;
+ moveUp(count);
+ movement = _("k");
+ }
} else if (input.is('l') || input.isKey(Key_Right) || input.is(' ')) {
g.movetype = MoveExclusive;
bool pastEnd = count >= rightDist() - 1;
@@ -4239,7 +4360,9 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
g.submode = CapitalZSubMode;
} else if ((input.is('~') || input.is('u') || input.is('U'))) {
g.movetype = MoveExclusive;
+ pushUndoState();
if (isVisualMode()) {
+ setDotCommand(visualDotCommand() + QString::number(count()) + input.raw());
if (isVisualLineMode())
g.rangemode = RangeLineMode;
else if (isVisualBlockMode())
@@ -4253,7 +4376,6 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
g.submode = UpCaseSubMode;
finishMovement();
} else if (g.gflag || (input.is('~') && hasConfig(ConfigTildeOp))) {
- pushUndoState();
if (atEndOfLine())
moveLeft();
setAnchor();
@@ -5049,9 +5171,6 @@ bool FakeVimHandler::Private::parseExCommmand(QString *line, ExCommand *cmd)
if (line->isEmpty())
return false;
- // remove leading colons and spaces
- line->remove(QRegExp(_("^\\s*(:+\\s*)*")));
-
// parse range first
if (!parseLineRange(line, cmd))
return false;
@@ -5104,6 +5223,15 @@ bool FakeVimHandler::Private::parseExCommmand(QString *line, ExCommand *cmd)
bool FakeVimHandler::Private::parseLineRange(QString *line, ExCommand *cmd)
{
+ // remove leading colons and spaces
+ line->remove(QRegExp(_("^\\s*(:+\\s*)*")));
+
+ // special case ':!...' (use invalid range)
+ if (line->startsWith(QLatin1Char('!'))) {
+ cmd->range = Range();
+ return true;
+ }
+
// FIXME: that seems to be different for %w and %s
if (line->startsWith(QLatin1Char('%')))
line->replace(0, 1, _("1,$"));
@@ -5666,22 +5794,15 @@ bool FakeVimHandler::Private::handleExBangCommand(const ExCommand &cmd) // :!
if (!cmd.cmd.isEmpty() || !cmd.hasBang)
return false;
- setCurrentRange(cmd.range);
- int targetPosition = firstPositionInLine(lineForPosition(cmd.range.beginPos));
- QString command = QString(cmd.cmd.mid(1) + QLatin1Char(' ') + cmd.args).trimmed();
- QString text = selectText(cmd.range);
- QProcess proc;
- proc.start(command);
- proc.waitForStarted();
- if (HostOsInfo::isWindowsHost())
- text.replace(_("\n"), _("\r\n"));
- proc.write(text.toUtf8());
- proc.closeWriteChannel();
- proc.waitForFinished();
- QString result = QString::fromUtf8(proc.readAllStandardOutput());
- if (text.isEmpty()) {
- emit q->extraInformationChanged(result);
- } else {
+ bool replaceText = cmd.range.isValid();
+ const QString command = QString(cmd.cmd.mid(1) + QLatin1Char(' ') + cmd.args).trimmed();
+ const QString input = replaceText ? selectText(cmd.range) : QString();
+
+ const QString result = getProcessOutput(command, input);
+
+ if (replaceText) {
+ setCurrentRange(cmd.range);
+ int targetPosition = firstPositionInLine(lineForPosition(cmd.range.beginPos));
beginEditBlock();
removeText(currentRange());
insertText(result);
@@ -5690,8 +5811,11 @@ bool FakeVimHandler::Private::handleExBangCommand(const ExCommand &cmd) // :!
leaveVisualMode();
//qDebug() << "FILTER: " << command;
showMessage(MessageInfo, FakeVimHandler::tr("%n lines filtered.", 0,
- text.count(QLatin1Char('\n'))));
+ input.count(QLatin1Char('\n'))));
+ } else if (!result.isEmpty()) {
+ emit q->extraInformationChanged(result);
}
+
return true;
}
@@ -6042,19 +6166,31 @@ void FakeVimHandler::Private::highlightMatches(const QString &needle)
void FakeVimHandler::Private::moveToFirstNonBlankOnLine()
{
moveToFirstNonBlankOnLine(&m_cursor);
+ setTargetColumn();
}
void FakeVimHandler::Private::moveToFirstNonBlankOnLine(QTextCursor *tc)
{
+ tc->setPosition(tc->block().position(), KeepAnchor);
+ moveToNonBlankOnLine(tc);
+}
+
+void FakeVimHandler::Private::moveToFirstNonBlankOnLineVisually()
+{
+ moveToStartOfLineVisually();
+ moveToNonBlankOnLine(&m_cursor);
+ setTargetColumn();
+}
+
+void FakeVimHandler::Private::moveToNonBlankOnLine(QTextCursor *tc)
+{
QTextDocument *doc = tc->document();
- int firstPos = tc->block().position();
- for (int i = firstPos, n = firstPos + block().length(); i < n; ++i) {
- if (!doc->characterAt(i).isSpace() || i == n - 1) {
- tc->setPosition(i, KeepAnchor);
- return;
- }
- }
- tc->setPosition(block().position(), KeepAnchor);
+ const QTextBlock block = tc->block();
+ const int maxPos = block.position() + block.length() - 1;
+ int i = tc->position();
+ while (doc->characterAt(i).isSpace() && i < maxPos)
+ ++i;
+ tc->setPosition(i, KeepAnchor);
}
void FakeVimHandler::Private::indentSelectedText(QChar typedChar)
@@ -6157,6 +6293,16 @@ void FakeVimHandler::Private::moveToTargetColumn()
setPosition(qMin(pos, physical));
}
+void FakeVimHandler::Private::setTargetColumn()
+{
+ m_targetColumn = logicalCursorColumn();
+ m_visualTargetColumn = m_targetColumn;
+
+ QTextCursor tc = m_cursor;
+ tc.movePosition(StartOfLine);
+ m_targetColumnWrapped = m_cursor.position() - tc.position();
+}
+
/* if simple is given:
* class 0: spaces
* class 1: non-spaces
@@ -6377,11 +6523,22 @@ void FakeVimHandler::Private::moveToMatchingParanthesis()
const int anc = anchor();
QTextCursor tc = m_cursor;
+
+ // If no known parenthesis symbol is under cursor find one on the current line after cursor.
+ static const QString parenthesesChars(_("([{}])"));
+ while (!parenthesesChars.contains(document()->characterAt(tc.position())) && !tc.atBlockEnd())
+ tc.setPosition(tc.position() + 1);
+
+ if (tc.atBlockEnd())
+ tc = m_cursor;
+
emit q->moveToMatchingParenthesis(&moved, &forward, &tc);
- if (moved && forward)
- tc.movePosition(Left, KeepAnchor, 1);
- setAnchorAndPosition(anc, tc.position());
- setTargetColumn();
+ if (moved) {
+ if (forward)
+ tc.movePosition(Left, KeepAnchor, 1);
+ setAnchorAndPosition(anc, tc.position());
+ setTargetColumn();
+ }
}
int FakeVimHandler::Private::cursorLineOnScreen() const
@@ -6655,7 +6812,26 @@ QString FakeVimHandler::Private::selectText(const Range &range) const
void FakeVimHandler::Private::yankText(const Range &range, int reg)
{
- setRegister(reg, selectText(range), range.rangemode);
+ const QString text = selectText(range);
+ setRegister(reg, text, range.rangemode);
+
+ // If register is not specified or " ...
+ if (m_register == '"') {
+ // copy to yank register 0 too
+ setRegister('0', text, range.rangemode);
+
+ // with delete and change commands set register 1 (if text contains more lines) or
+ // small delete register -
+ if (g.submode == DeleteSubMode || g.submode == ChangeSubMode) {
+ if (text.contains(QLatin1Char('\n')))
+ setRegister('1', text, range.rangemode);
+ else
+ setRegister('-', text, range.rangemode);
+ }
+ } else {
+ // Always copy to " register too.
+ setRegister('"', text, range.rangemode);
+ }
const int lines = document()->findBlock(range.endPos).blockNumber()
- document()->findBlock(range.beginPos).blockNumber() + 1;
diff --git a/src/plugins/fakevim/fakevimhandler.h b/src/plugins/fakevim/fakevimhandler.h
index 30176cd689..408b1c3cc3 100644
--- a/src/plugins/fakevim/fakevimhandler.h
+++ b/src/plugins/fakevim/fakevimhandler.h
@@ -52,6 +52,7 @@ struct Range
Range();
Range(int b, int e, RangeMode m = RangeCharMode);
QString toString() const;
+ bool isValid() const;
int beginPos;
int endPos;
diff --git a/src/plugins/fakevim/fakevimoptions.ui b/src/plugins/fakevim/fakevimoptions.ui
index 8974f2ae0c..6f5d21d6b1 100644
--- a/src/plugins/fakevim/fakevimoptions.ui
+++ b/src/plugins/fakevim/fakevimoptions.ui
@@ -92,7 +92,7 @@
<item row="6" column="1">
<widget class="QCheckBox" name="checkBoxPassControlKey">
<property name="toolTip">
- <string>Pass key sequences like Ctrl-S to Qt Creator core instead of interpreting them in FakeVim. This gives easier access to Qt Creator core functionality at the price of losing some features of FakeVim.</string>
+ <string>Passes key sequences like Ctrl-S to Qt Creator core instead of interpreting them in FakeVim. This gives easier access to Qt Creator core functionality at the price of losing some features of FakeVim.</string>
</property>
<property name="text">
<string>Pass control key</string>
@@ -123,7 +123,7 @@
<item row="7" column="0">
<widget class="QCheckBox" name="checkBoxPassKeys">
<property name="toolTip">
- <string>Let Qt Creator handle some key presses in insert mode so that code can be properly completed and expanded.</string>
+ <string>Lets Qt Creator handle some key presses in insert mode so that code can be properly completed and expanded.</string>
</property>
<property name="text">
<string>Pass keys in insert mode</string>
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp
index 38d5456789..ed48448b38 100644
--- a/src/plugins/fakevim/fakevimplugin.cpp
+++ b/src/plugins/fakevim/fakevimplugin.cpp
@@ -42,6 +42,9 @@
#include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/documentmodel.h>
+#include <coreplugin/find/findplugin.h>
+#include <coreplugin/find/textfindconstants.h>
+#include <coreplugin/find/ifindsupport.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
@@ -68,10 +71,6 @@
#include <texteditor/codeassist/iassistinterface.h>
#include <texteditor/codeassist/genericproposal.h>
-#include <find/findplugin.h>
-#include <find/textfindconstants.h>
-#include <find/ifindsupport.h>
-
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/savedaction.h>
@@ -87,6 +86,7 @@
#include <QFileDialog>
#include <QtPlugin>
#include <QObject>
+#include <QPointer>
#include <QSettings>
#include <QStackedWidget>
#include <QTextStream>
@@ -254,10 +254,9 @@ public:
setCategoryIcon(_(SETTINGS_CATEGORY_FAKEVIM_ICON));
}
- QWidget *createPage(QWidget *parent);
- void apply() { m_group.apply(ICore::settings()); }
- void finish() { m_group.finish(); }
- virtual bool matches(const QString &) const;
+ QWidget *widget();
+ void apply();
+ void finish();
private slots:
void copyTextEditorSettings();
@@ -268,113 +267,98 @@ private slots:
private:
friend class DebuggerPlugin;
+ QPointer<QWidget> m_widget;
Ui::FakeVimOptionPage m_ui;
- QString m_searchKeywords;
Utils::SavedActionSet m_group;
};
-QWidget *FakeVimOptionPage::createPage(QWidget *parent)
-{
- QWidget *w = new QWidget(parent);
- m_ui.setupUi(w);
- const QString vimrcDefault = Utils::HostOsInfo::isAnyUnixHost() ?
- QLatin1String("$HOME/.vimrc") : QLatin1String("%USERPROFILE%\\_vimrc");
- m_ui.lineEditVimRcPath->setPlaceholderText(tr("Default: %1").arg(vimrcDefault));
-
- m_group.clear();
- m_group.insert(theFakeVimSetting(ConfigUseFakeVim),
- m_ui.checkBoxUseFakeVim);
- m_group.insert(theFakeVimSetting(ConfigReadVimRc),
- m_ui.checkBoxReadVimRc);
- m_group.insert(theFakeVimSetting(ConfigVimRcPath),
- m_ui.lineEditVimRcPath);
-
- m_group.insert(theFakeVimSetting(ConfigExpandTab),
- m_ui.checkBoxExpandTab);
- m_group.insert(theFakeVimSetting(ConfigHlSearch),
- m_ui.checkBoxHlSearch);
- m_group.insert(theFakeVimSetting(ConfigShiftWidth),
- m_ui.spinBoxShiftWidth);
- m_group.insert(theFakeVimSetting(ConfigShowMarks),
- m_ui.checkBoxShowMarks);
-
- m_group.insert(theFakeVimSetting(ConfigSmartTab),
- m_ui.checkBoxSmartTab);
- m_group.insert(theFakeVimSetting(ConfigStartOfLine),
- m_ui.checkBoxStartOfLine);
- m_group.insert(theFakeVimSetting(ConfigPassKeys),
- m_ui.checkBoxPassKeys);
- m_group.insert(theFakeVimSetting(ConfigTabStop),
- m_ui.spinBoxTabStop);
- m_group.insert(theFakeVimSetting(ConfigScrollOff),
- m_ui.spinBoxScrollOff);
- m_group.insert(theFakeVimSetting(ConfigBackspace),
- m_ui.lineEditBackspace);
- m_group.insert(theFakeVimSetting(ConfigIsKeyword),
- m_ui.lineEditIsKeyword);
-
- m_group.insert(theFakeVimSetting(ConfigPassControlKey),
- m_ui.checkBoxPassControlKey);
- m_group.insert(theFakeVimSetting(ConfigAutoIndent),
- m_ui.checkBoxAutoIndent);
- m_group.insert(theFakeVimSetting(ConfigSmartIndent),
- m_ui.checkBoxSmartIndent);
-
- m_group.insert(theFakeVimSetting(ConfigIncSearch),
- m_ui.checkBoxIncSearch);
- m_group.insert(theFakeVimSetting(ConfigUseCoreSearch),
- m_ui.checkBoxUseCoreSearch);
- m_group.insert(theFakeVimSetting(ConfigSmartCase),
- m_ui.checkBoxSmartCase);
- m_group.insert(theFakeVimSetting(ConfigIgnoreCase),
- m_ui.checkBoxIgnoreCase);
- m_group.insert(theFakeVimSetting(ConfigWrapScan),
- m_ui.checkBoxWrapScan);
-
- m_group.insert(theFakeVimSetting(ConfigShowCmd),
- m_ui.checkBoxShowCmd);
-
- connect(m_ui.pushButtonCopyTextEditorSettings, SIGNAL(clicked()),
- SLOT(copyTextEditorSettings()));
- connect(m_ui.pushButtonSetQtStyle, SIGNAL(clicked()),
- SLOT(setQtStyle()));
- connect(m_ui.pushButtonSetPlainStyle, SIGNAL(clicked()),
- SLOT(setPlainStyle()));
- connect(m_ui.pushButtonVimRcPath, SIGNAL(clicked()),
- SLOT(openVimRc()));
- connect(m_ui.checkBoxReadVimRc, SIGNAL(stateChanged(int)),
- SLOT(updateVimRcWidgets()));
- updateVimRcWidgets();
-
- if (m_searchKeywords.isEmpty()) {
- QLatin1Char sep(' ');
- QTextStream(&m_searchKeywords)
- << sep << m_ui.checkBoxUseFakeVim->text()
- << sep << m_ui.checkBoxReadVimRc->text()
- << sep << m_ui.checkBoxAutoIndent->text()
- << sep << m_ui.checkBoxSmartIndent->text()
- << sep << m_ui.checkBoxExpandTab->text()
- << sep << m_ui.checkBoxSmartTab->text()
- << sep << m_ui.checkBoxHlSearch->text()
- << sep << m_ui.checkBoxIncSearch->text()
- << sep << m_ui.checkBoxStartOfLine->text()
- << sep << m_ui.checkBoxUseCoreSearch->text()
- << sep << m_ui.checkBoxSmartCase->text()
- << sep << m_ui.checkBoxShowMarks->text()
- << sep << m_ui.checkBoxPassControlKey->text()
- << sep << m_ui.checkBoxPassKeys->text()
- << sep << m_ui.checkBoxIgnoreCase->text()
- << sep << m_ui.checkBoxWrapScan->text()
- << sep << m_ui.checkBoxShowCmd->text()
- << sep << m_ui.labelShiftWidth->text()
- << sep << m_ui.labelTabulator->text()
- << sep << m_ui.labelBackspace->text()
- << sep << m_ui.labelIsKeyword->text()
- << sep << m_ui.labelScrollOff->text()
- << sep << m_ui.lineEditVimRcPath->text();
- m_searchKeywords.remove(QLatin1Char('&'));
+QWidget *FakeVimOptionPage::widget()
+{
+ if (!m_widget) {
+ m_widget = new QWidget;
+ m_ui.setupUi(m_widget);
+ const QString vimrcDefault = Utils::HostOsInfo::isAnyUnixHost() ?
+ QLatin1String("$HOME/.vimrc") : QLatin1String("%USERPROFILE%\\_vimrc");
+ m_ui.lineEditVimRcPath->setPlaceholderText(tr("Default: %1").arg(vimrcDefault));
+
+ m_group.clear();
+ m_group.insert(theFakeVimSetting(ConfigUseFakeVim),
+ m_ui.checkBoxUseFakeVim);
+ m_group.insert(theFakeVimSetting(ConfigReadVimRc),
+ m_ui.checkBoxReadVimRc);
+ m_group.insert(theFakeVimSetting(ConfigVimRcPath),
+ m_ui.lineEditVimRcPath);
+
+ m_group.insert(theFakeVimSetting(ConfigExpandTab),
+ m_ui.checkBoxExpandTab);
+ m_group.insert(theFakeVimSetting(ConfigHlSearch),
+ m_ui.checkBoxHlSearch);
+ m_group.insert(theFakeVimSetting(ConfigShiftWidth),
+ m_ui.spinBoxShiftWidth);
+ m_group.insert(theFakeVimSetting(ConfigShowMarks),
+ m_ui.checkBoxShowMarks);
+
+ m_group.insert(theFakeVimSetting(ConfigSmartTab),
+ m_ui.checkBoxSmartTab);
+ m_group.insert(theFakeVimSetting(ConfigStartOfLine),
+ m_ui.checkBoxStartOfLine);
+ m_group.insert(theFakeVimSetting(ConfigPassKeys),
+ m_ui.checkBoxPassKeys);
+ m_group.insert(theFakeVimSetting(ConfigTabStop),
+ m_ui.spinBoxTabStop);
+ m_group.insert(theFakeVimSetting(ConfigScrollOff),
+ m_ui.spinBoxScrollOff);
+ m_group.insert(theFakeVimSetting(ConfigBackspace),
+ m_ui.lineEditBackspace);
+ m_group.insert(theFakeVimSetting(ConfigIsKeyword),
+ m_ui.lineEditIsKeyword);
+
+ m_group.insert(theFakeVimSetting(ConfigPassControlKey),
+ m_ui.checkBoxPassControlKey);
+ m_group.insert(theFakeVimSetting(ConfigAutoIndent),
+ m_ui.checkBoxAutoIndent);
+ m_group.insert(theFakeVimSetting(ConfigSmartIndent),
+ m_ui.checkBoxSmartIndent);
+
+ m_group.insert(theFakeVimSetting(ConfigIncSearch),
+ m_ui.checkBoxIncSearch);
+ m_group.insert(theFakeVimSetting(ConfigUseCoreSearch),
+ m_ui.checkBoxUseCoreSearch);
+ m_group.insert(theFakeVimSetting(ConfigSmartCase),
+ m_ui.checkBoxSmartCase);
+ m_group.insert(theFakeVimSetting(ConfigIgnoreCase),
+ m_ui.checkBoxIgnoreCase);
+ m_group.insert(theFakeVimSetting(ConfigWrapScan),
+ m_ui.checkBoxWrapScan);
+
+ m_group.insert(theFakeVimSetting(ConfigShowCmd),
+ m_ui.checkBoxShowCmd);
+
+ connect(m_ui.pushButtonCopyTextEditorSettings, SIGNAL(clicked()),
+ SLOT(copyTextEditorSettings()));
+ connect(m_ui.pushButtonSetQtStyle, SIGNAL(clicked()),
+ SLOT(setQtStyle()));
+ connect(m_ui.pushButtonSetPlainStyle, SIGNAL(clicked()),
+ SLOT(setPlainStyle()));
+ connect(m_ui.pushButtonVimRcPath, SIGNAL(clicked()),
+ SLOT(openVimRc()));
+ connect(m_ui.checkBoxReadVimRc, SIGNAL(stateChanged(int)),
+ SLOT(updateVimRcWidgets()));
+ updateVimRcWidgets();
+
}
- return w;
+ return m_widget;
+}
+
+void FakeVimOptionPage::apply()
+{
+ m_group.apply(ICore::settings());
+}
+
+void FakeVimOptionPage::finish()
+{
+ m_group.finish();
+ delete m_widget;
}
void FakeVimOptionPage::copyTextEditorSettings()
@@ -431,11 +415,6 @@ void FakeVimOptionPage::updateVimRcWidgets()
m_ui.pushButtonVimRcPath->setEnabled(enabled);
}
-bool FakeVimOptionPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
//const char *FAKEVIM_CONTEXT = "FakeVim";
///////////////////////////////////////////////////////////////////////
@@ -461,7 +440,7 @@ public:
setCategoryIcon(_(SETTINGS_CATEGORY_FAKEVIM_ICON));
}
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void initialize();
ExCommandMap &exCommandMap();
ExCommandMap &defaultExCommandMap();
@@ -477,9 +456,9 @@ private:
FakeVimPluginPrivate *m_q;
};
-QWidget *FakeVimExCommandsPage::createPage(QWidget *parent)
+QWidget *FakeVimExCommandsPage::widget()
{
- QWidget *w = CommandMappings::createPage(parent);
+ QWidget *w = CommandMappings::widget();
setPageTitle(tr("Ex Command Mapping"));
setTargetHeader(tr("Ex Trigger Expression"));
setTargetLabelText(tr("Regular expression:"));
@@ -686,37 +665,41 @@ public:
void apply();
void finish() {}
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void initialize() {}
UserCommandMap &userCommandMap();
UserCommandMap &defaultUserCommandMap();
private:
FakeVimPluginPrivate *m_q;
+ QPointer<QGroupBox> m_widget;
};
-QWidget *FakeVimUserCommandsPage::createPage(QWidget *parent)
+QWidget *FakeVimUserCommandsPage::widget()
{
- QGroupBox *box = new QGroupBox(parent);
-
- FakeVimUserCommandsModel *model = new FakeVimUserCommandsModel(m_q);
- QTreeView *widget = new QTreeView;
- widget->setModel(model);
- widget->resizeColumnToContents(0);
+ if (!m_widget) {
+ m_widget = new QGroupBox;
- FakeVimUserCommandsDelegate *delegate = new FakeVimUserCommandsDelegate(widget);
- widget->setItemDelegateForColumn(1, delegate);
+ FakeVimUserCommandsModel *model = new FakeVimUserCommandsModel(m_q);
+ QTreeView *widget = new QTreeView;
+ model->setParent(widget);
+ widget->setModel(model);
+ widget->resizeColumnToContents(0);
- QGridLayout *layout = new QGridLayout(box);
- layout->addWidget(widget, 0, 0);
- box->setLayout(layout);
+ FakeVimUserCommandsDelegate *delegate = new FakeVimUserCommandsDelegate(widget);
+ widget->setItemDelegateForColumn(1, delegate);
- return box;
+ QGridLayout *layout = new QGridLayout(m_widget);
+ layout->addWidget(widget, 0, 0);
+ m_widget->setLayout(layout);
+ }
+ return m_widget;
}
void FakeVimUserCommandsPage::apply()
{
//m_q->writeSettings();
+ delete m_widget;
}
@@ -1417,20 +1400,20 @@ void FakeVimPluginPrivate::keepOnlyWindow()
void FakeVimPluginPrivate::find(bool reverse)
{
- if (Find::FindPlugin *plugin = Find::FindPlugin::instance()) {
+ if (FindPlugin *plugin = FindPlugin::instance()) {
plugin->setUseFakeVim(true);
plugin->openFindToolBar(reverse
- ? Find::FindPlugin::FindBackwardDirection
- : Find::FindPlugin::FindForwardDirection);
+ ? FindPlugin::FindBackwardDirection
+ : FindPlugin::FindForwardDirection);
}
}
void FakeVimPluginPrivate::findNext(bool reverse)
{
if (reverse)
- triggerAction(Find::Constants::FIND_PREVIOUS);
+ triggerAction(Core::Constants::FIND_PREVIOUS);
else
- triggerAction(Find::Constants::FIND_NEXT);
+ triggerAction(Core::Constants::FIND_NEXT);
}
void FakeVimPluginPrivate::foldToggle(int depth)
@@ -1702,8 +1685,8 @@ void FakeVimPluginPrivate::setUseFakeVim(const QVariant &value)
{
//qDebug() << "SET USE FAKEVIM" << value;
bool on = value.toBool();
- if (Find::FindPlugin::instance())
- Find::FindPlugin::instance()->setUseFakeVim(on);
+ if (Core::FindPlugin::instance())
+ Core::FindPlugin::instance()->setUseFakeVim(on);
setUseFakeVimInternal(on);
}
@@ -1837,10 +1820,10 @@ void FakeVimPluginPrivate::handleExCommand(bool *handled, const ExCommand &cmd)
showSettingsDialog();
} else if (cmd.args == _("ic") || cmd.args == _("ignorecase")) {
// :set nc
- setActionChecked(Find::Constants::CASE_SENSITIVE, false);
+ setActionChecked(Core::Constants::CASE_SENSITIVE, false);
} else if (cmd.args == _("noic") || cmd.args == _("noignorecase")) {
// :set noic
- setActionChecked(Find::Constants::CASE_SENSITIVE, true);
+ setActionChecked(Core::Constants::CASE_SENSITIVE, true);
}
*handled = false; // Let the handler see it as well.
} else if (cmd.matches(_("n"), _("next"))) {
@@ -2006,9 +1989,9 @@ void FakeVimPluginPrivate::highlightMatches(const QString &needle)
{
foreach (IEditor *editor, EditorManager::visibleEditors()) {
QWidget *w = editor->widget();
- Find::IFindSupport *find = Aggregation::query<Find::IFindSupport>(w);
+ Core::IFindSupport *find = Aggregation::query<Core::IFindSupport>(w);
if (find != 0)
- find->highlightAll(needle, Find::FindRegularExpression | Find::FindCaseSensitively);
+ find->highlightAll(needle, FindRegularExpression | FindCaseSensitively);
}
}
diff --git a/src/plugins/fakevim/fakevimplugin.h b/src/plugins/fakevim/fakevimplugin.h
index 5adb0a6b30..db1ced99f0 100644
--- a/src/plugins/fakevim/fakevimplugin.h
+++ b/src/plugins/fakevim/fakevimplugin.h
@@ -136,6 +136,7 @@ private slots:
void test_vim_command_x();
void test_vim_command_yyp();
void test_vim_command_y_dollar();
+ void test_vim_command_percent();
void test_vim_visual_d();
void test_vim_Visual_d();
diff --git a/src/plugins/find/Find.pluginspec.in b/src/plugins/find/Find.pluginspec.in
index f670aa2f55..8af87eb2e5 100644
--- a/src/plugins/find/Find.pluginspec.in
+++ b/src/plugins/find/Find.pluginspec.in
@@ -1,4 +1,4 @@
-<plugin name=\"Find\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_COMPAT_VERSION\">
+<plugin name=\"Find\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_COMPAT_VERSION\" disabledByDefault=\"true\">
<vendor>Digia Plc</vendor>
<copyright>(C) 2014 Digia Plc</copyright>
<license>
@@ -13,5 +13,4 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General
<category>Qt Creator</category>
<description>Provides the find widget and the hooks for find implementations.</description>
<url>http://www.qt-project.org</url>
- $$dependencyList
</plugin>
diff --git a/src/plugins/find/find.pro b/src/plugins/find/find.pro
index 8666b26bde..a7d911be0d 100644
--- a/src/plugins/find/find.pro
+++ b/src/plugins/find/find.pro
@@ -1,38 +1,3 @@
include(../../qtcreatorplugin.pri)
DEFINES += FIND_LIBRARY
-HEADERS += findtoolwindow.h \
- textfindconstants.h \
- ifindsupport.h \
- ifindfilter.h \
- currentdocumentfind.h \
- basetextfind.h \
- find_global.h \
- findtoolbar.h \
- findplugin.h \
- searchresultcolor.h \
- searchresulttreeitemdelegate.h \
- searchresulttreeitemroles.h \
- searchresulttreeitems.h \
- searchresulttreemodel.h \
- searchresulttreeview.h \
- searchresultwindow.h \
- searchresultwidget.h \
- treeviewfind.h
-SOURCES += findtoolwindow.cpp \
- currentdocumentfind.cpp \
- basetextfind.cpp \
- findtoolbar.cpp \
- findplugin.cpp \
- searchresulttreeitemdelegate.cpp \
- searchresulttreeitems.cpp \
- searchresulttreemodel.cpp \
- searchresulttreeview.cpp \
- searchresultwindow.cpp \
- ifindfilter.cpp \
- ifindsupport.cpp \
- searchresultwidget.cpp \
- treeviewfind.cpp
-FORMS += findwidget.ui \
- finddialog.ui
-RESOURCES += find.qrc
-
+SOURCES += findplugin.cpp
diff --git a/src/plugins/find/find.qbs b/src/plugins/find/find.qbs
index 0b4a08986b..e0acdc006f 100644
--- a/src/plugins/find/find.qbs
+++ b/src/plugins/find/find.qbs
@@ -5,44 +5,7 @@ import QtcPlugin
QtcPlugin {
name: "Find"
- Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "script"] }
Depends { name: "Core" }
- files: [
- "basetextfind.cpp",
- "basetextfind.h",
- "currentdocumentfind.cpp",
- "currentdocumentfind.h",
- "find.qrc",
- "find_global.h",
- "finddialog.ui",
- "findplugin.cpp",
- "findplugin.h",
- "findtoolbar.cpp",
- "findtoolbar.h",
- "findtoolwindow.cpp",
- "findtoolwindow.h",
- "findwidget.ui",
- "ifindfilter.cpp",
- "ifindfilter.h",
- "ifindsupport.cpp",
- "ifindsupport.h",
- "searchresultcolor.h",
- "searchresulttreeitemdelegate.cpp",
- "searchresulttreeitemdelegate.h",
- "searchresulttreeitemroles.h",
- "searchresulttreeitems.cpp",
- "searchresulttreeitems.h",
- "searchresulttreemodel.cpp",
- "searchresulttreemodel.h",
- "searchresulttreeview.cpp",
- "searchresulttreeview.h",
- "searchresultwidget.cpp",
- "searchresultwidget.h",
- "searchresultwindow.cpp",
- "searchresultwindow.h",
- "textfindconstants.h",
- "treeviewfind.cpp",
- "treeviewfind.h",
- ]
+ files: [ "findplugin.cpp" ]
}
diff --git a/src/plugins/find/find_dependencies.pri b/src/plugins/find/find_dependencies.pri
index 52291a8aab..39a0b86f75 100644
--- a/src/plugins/find/find_dependencies.pri
+++ b/src/plugins/find/find_dependencies.pri
@@ -1,5 +1,3 @@
QTC_PLUGIN_NAME = Find
-QTC_LIB_DEPENDS += \
- utils
-QTC_PLUGIN_DEPENDS += \
- coreplugin
+QTC_LIB_DEPENDS +=
+QTC_PLUGIN_DEPENDS +=
diff --git a/src/plugins/find/findplugin.cpp b/src/plugins/find/findplugin.cpp
index be9196e209..a4428b657f 100644
--- a/src/plugins/find/findplugin.cpp
+++ b/src/plugins/find/findplugin.cpp
@@ -1,398 +1,2 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-#include "findplugin.h"
-
-#include "currentdocumentfind.h"
-#include "findtoolbar.h"
-#include "findtoolwindow.h"
-#include "searchresultwindow.h"
-#include "ifindfilter.h"
-
-#include <coreplugin/actionmanager/actionmanager.h>
-#include <coreplugin/actionmanager/actioncontainer.h>
-#include <coreplugin/coreconstants.h>
-#include <coreplugin/icore.h>
-#include <coreplugin/id.h>
-
-#include <extensionsystem/pluginmanager.h>
-
-#include <utils/qtcassert.h>
-
-#include <QMenu>
-#include <QStringListModel>
-#include <QAction>
-
-#include <QtPlugin>
-#include <QSettings>
-
-/*!
- \namespace Find
- The Find namespace provides everything that has to do with search term based searches.
-*/
-
-/*!
- \namespace Find::Internal
- \internal
-*/
-/*!
- \namespace Find::Internal::ItemDataRoles
- \internal
-*/
-
-Q_DECLARE_METATYPE(Find::IFindFilter*)
-
-namespace {
- const int MAX_COMPLETIONS = 50;
-}
-
-namespace Find {
-
-class FindPluginPrivate {
-public:
- explicit FindPluginPrivate(FindPlugin *q);
-
- //variables
- static FindPlugin *m_instance;
-
- QHash<IFindFilter *, QAction *> m_filterActions;
-
- Internal::CurrentDocumentFind *m_currentDocumentFind;
- Internal::FindToolBar *m_findToolBar;
- Internal::FindToolWindow *m_findDialog;
- FindFlags m_findFlags;
- QStringListModel *m_findCompletionModel;
- QStringListModel *m_replaceCompletionModel;
- QStringList m_findCompletions;
- QStringList m_replaceCompletions;
- QAction *m_openFindDialog;
-};
-
-FindPluginPrivate::FindPluginPrivate(FindPlugin *q) :
- m_currentDocumentFind(0), m_findToolBar(0), m_findDialog(0),
- m_findCompletionModel(new QStringListModel(q)),
- m_replaceCompletionModel(new QStringListModel(q))
-{
-}
-
-FindPlugin *FindPluginPrivate::m_instance = 0;
-
-FindPlugin::FindPlugin() : d(new FindPluginPrivate(this))
-{
- QTC_ASSERT(!FindPluginPrivate::m_instance, return);
- FindPluginPrivate::m_instance = this;
-}
-
-FindPlugin::~FindPlugin()
-{
- FindPluginPrivate::m_instance = 0;
- delete d->m_currentDocumentFind;
- delete d->m_findToolBar;
- delete d->m_findDialog;
- delete d;
-}
-
-FindPlugin *FindPlugin::instance()
-{
- return FindPluginPrivate::m_instance;
-}
-
-bool FindPlugin::initialize(const QStringList &, QString *)
-{
- setupMenu();
-
- d->m_currentDocumentFind = new Internal::CurrentDocumentFind;
-
- d->m_findToolBar = new Internal::FindToolBar(this, d->m_currentDocumentFind);
- d->m_findDialog = new Internal::FindToolWindow(this);
- SearchResultWindow *searchResultWindow = new SearchResultWindow(d->m_findDialog);
- addAutoReleasedObject(searchResultWindow);
- return true;
-}
-
-void FindPlugin::extensionsInitialized()
-{
- setupFilterMenuItems();
- readSettings();
-}
-
-ExtensionSystem::IPlugin::ShutdownFlag FindPlugin::aboutToShutdown()
-{
- d->m_findToolBar->setVisible(false);
- d->m_findToolBar->setParent(0);
- d->m_currentDocumentFind->removeConnections();
- writeSettings();
- return SynchronousShutdown;
-}
-
-void FindPlugin::filterChanged()
-{
- IFindFilter *changedFilter = qobject_cast<IFindFilter *>(sender());
- QAction *action = d->m_filterActions.value(changedFilter);
- QTC_ASSERT(changedFilter, return);
- QTC_ASSERT(action, return);
- action->setEnabled(changedFilter->isEnabled());
- bool haveEnabledFilters = false;
- foreach (const IFindFilter *filter, d->m_filterActions.keys()) {
- if (filter->isEnabled()) {
- haveEnabledFilters = true;
- break;
- }
- }
- d->m_openFindDialog->setEnabled(haveEnabledFilters);
-}
-
-void FindPlugin::openFindFilter()
-{
- QAction *action = qobject_cast<QAction*>(sender());
- QTC_ASSERT(action, return);
- IFindFilter *filter = action->data().value<IFindFilter *>();
- openFindDialog(filter);
-}
-
-void FindPlugin::openFindDialog(IFindFilter *filter)
-{
- if (d->m_currentDocumentFind->candidateIsEnabled())
- d->m_currentDocumentFind->acceptCandidate();
- const QString currentFindString =
- d->m_currentDocumentFind->isEnabled() ?
- d->m_currentDocumentFind->currentFindString() : QString();
- if (!currentFindString.isEmpty())
- d->m_findDialog->setFindText(currentFindString);
- d->m_findDialog->setCurrentFilter(filter);
- SearchResultWindow::instance()->openNewSearchPanel();
-}
-
-void FindPlugin::setupMenu()
-{
- Core::ActionContainer *medit = Core::ActionManager::actionContainer(Core::Constants::M_EDIT);
- Core::ActionContainer *mfind = Core::ActionManager::createMenu(Constants::M_FIND);
- medit->addMenu(mfind, Core::Constants::G_EDIT_FIND);
- mfind->menu()->setTitle(tr("&Find/Replace"));
- mfind->appendGroup(Constants::G_FIND_CURRENTDOCUMENT);
- mfind->appendGroup(Constants::G_FIND_FILTERS);
- mfind->appendGroup(Constants::G_FIND_FLAGS);
- mfind->appendGroup(Constants::G_FIND_ACTIONS);
- Core::Context globalcontext(Core::Constants::C_GLOBAL);
- Core::Command *cmd;
- mfind->addSeparator(globalcontext, Constants::G_FIND_FLAGS);
- mfind->addSeparator(globalcontext, Constants::G_FIND_ACTIONS);
-
- Core::ActionContainer *mfindadvanced = Core::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 = Core::ActionManager::registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND, globalcontext);
- cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F")));
- mfindadvanced->addAction(cmd);
- connect(d->m_openFindDialog, SIGNAL(triggered()), this, SLOT(openFindFilter()));
-}
-
-void FindPlugin::setupFilterMenuItems()
-{
- QList<IFindFilter*> findInterfaces =
- ExtensionSystem::PluginManager::getObjects<IFindFilter>();
- Core::Command *cmd;
- Core::Context globalcontext(Core::Constants::C_GLOBAL);
-
- Core::ActionContainer *mfindadvanced = Core::ActionManager::actionContainer(Constants::M_FIND_ADVANCED);
- d->m_filterActions.clear();
- bool haveEnabledFilters = false;
- const Core::Id base("FindFilter.");
- foreach (IFindFilter *filter, findInterfaces) {
- QAction *action = new QAction(QLatin1String(" ") + filter->displayName(), this);
- bool isEnabled = filter->isEnabled();
- if (isEnabled)
- haveEnabledFilters = true;
- action->setEnabled(isEnabled);
- action->setData(qVariantFromValue(filter));
- cmd = Core::ActionManager::registerAction(action,
- base.withSuffix(filter->id()), globalcontext);
- cmd->setDefaultKeySequence(filter->defaultShortcut());
- mfindadvanced->addAction(cmd);
- d->m_filterActions.insert(filter, action);
- connect(action, SIGNAL(triggered(bool)), this, SLOT(openFindFilter()));
- connect(filter, SIGNAL(enabledChanged(bool)), this, SLOT(filterChanged()));
- }
- d->m_findDialog->setFindFilters(findInterfaces);
- d->m_openFindDialog->setEnabled(haveEnabledFilters);
-}
-
-FindFlags FindPlugin::findFlags() const
-{
- return d->m_findFlags;
-}
-
-void FindPlugin::setCaseSensitive(bool sensitive)
-{
- setFindFlag(FindCaseSensitively, sensitive);
-}
-
-void FindPlugin::setWholeWord(bool wholeOnly)
-{
- setFindFlag(FindWholeWords, wholeOnly);
-}
-
-void FindPlugin::setBackward(bool backward)
-{
- setFindFlag(FindBackward, backward);
-}
-
-void FindPlugin::setRegularExpression(bool regExp)
-{
- setFindFlag(FindRegularExpression, regExp);
-}
-
-void FindPlugin::setPreserveCase(bool preserveCase)
-{
- setFindFlag(FindPreserveCase, preserveCase);
-}
-
-void FindPlugin::setFindFlag(FindFlag flag, bool enabled)
-{
- bool hasFlag = hasFindFlag(flag);
- if ((hasFlag && enabled) || (!hasFlag && !enabled))
- return;
- if (enabled)
- d->m_findFlags |= flag;
- else
- d->m_findFlags &= ~flag;
- if (flag != FindBackward)
- emit findFlagsChanged();
-}
-
-bool FindPlugin::hasFindFlag(FindFlag flag)
-{
- return d->m_findFlags & flag;
-}
-
-void FindPlugin::writeSettings()
-{
- QSettings *settings = Core::ICore::settings();
- settings->beginGroup(QLatin1String("Find"));
- settings->setValue(QLatin1String("Backward"), hasFindFlag(FindBackward));
- settings->setValue(QLatin1String("CaseSensitively"), hasFindFlag(FindCaseSensitively));
- settings->setValue(QLatin1String("WholeWords"), hasFindFlag(FindWholeWords));
- settings->setValue(QLatin1String("RegularExpression"), hasFindFlag(FindRegularExpression));
- settings->setValue(QLatin1String("PreserveCase"), hasFindFlag(FindPreserveCase));
- settings->setValue(QLatin1String("FindStrings"), d->m_findCompletions);
- settings->setValue(QLatin1String("ReplaceStrings"), d->m_replaceCompletions);
- settings->endGroup();
- d->m_findToolBar->writeSettings();
- d->m_findDialog->writeSettings();
-}
-
-void FindPlugin::readSettings()
-{
- QSettings *settings = Core::ICore::settings();
- settings->beginGroup(QLatin1String("Find"));
- bool block = blockSignals(true);
- setBackward(settings->value(QLatin1String("Backward"), false).toBool());
- setCaseSensitive(settings->value(QLatin1String("CaseSensitively"), false).toBool());
- setWholeWord(settings->value(QLatin1String("WholeWords"), false).toBool());
- setRegularExpression(settings->value(QLatin1String("RegularExpression"), false).toBool());
- setPreserveCase(settings->value(QLatin1String("PreserveCase"), false).toBool());
- blockSignals(block);
- d->m_findCompletions = settings->value(QLatin1String("FindStrings")).toStringList();
- d->m_replaceCompletions = settings->value(QLatin1String("ReplaceStrings")).toStringList();
- d->m_findCompletionModel->setStringList(d->m_findCompletions);
- d->m_replaceCompletionModel->setStringList(d->m_replaceCompletions);
- settings->endGroup();
- d->m_findToolBar->readSettings();
- d->m_findDialog->readSettings();
- emit findFlagsChanged(); // would have been done in the setXXX methods above
-}
-
-void FindPlugin::updateFindCompletion(const QString &text)
-{
- updateCompletion(text, d->m_findCompletions, d->m_findCompletionModel);
-}
-
-void FindPlugin::updateReplaceCompletion(const QString &text)
-{
- updateCompletion(text, d->m_replaceCompletions, d->m_replaceCompletionModel);
-}
-
-void FindPlugin::updateCompletion(const QString &text, QStringList &completions, QStringListModel *model)
-{
- if (text.isEmpty())
- return;
- completions.removeAll(text);
- completions.prepend(text);
- while (completions.size() > MAX_COMPLETIONS)
- completions.removeLast();
- model->setStringList(completions);
-}
-
-void FindPlugin::setUseFakeVim(bool on)
-{
- if (d->m_findToolBar)
- d->m_findToolBar->setUseFakeVim(on);
-}
-
-void FindPlugin::openFindToolBar(FindDirection direction)
-{
- if (d->m_findToolBar) {
- d->m_findToolBar->setBackward(direction == FindBackwardDirection);
- d->m_findToolBar->openFindToolBar();
- }
-}
-
-QStringListModel *FindPlugin::findCompletionModel() const
-{
- return d->m_findCompletionModel;
-}
-
-QStringListModel *FindPlugin::replaceCompletionModel() const
-{
- return d->m_replaceCompletionModel;
-}
-
-QKeySequence IFindFilter::defaultShortcut() const
-{
- return QKeySequence();
-}
-
-} // namespace Find
-
-// declared in textfindconstants.h
-QTextDocument::FindFlags Find::textDocumentFlagsForFindFlags(Find::FindFlags flags)
-{
- QTextDocument::FindFlags textDocFlags;
- if (flags & FindBackward)
- textDocFlags |= QTextDocument::FindBackward;
- if (flags & Find::FindCaseSensitively)
- textDocFlags |= QTextDocument::FindCaseSensitively;
- if (flags & Find::FindWholeWords)
- textDocFlags |= QTextDocument::FindWholeWords;
- return textDocFlags;
-}
-
-Q_EXPORT_PLUGIN(Find::FindPlugin)
+void dummyFindPlugin () {}
diff --git a/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp b/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp
index a577f0a6e6..e22ddd878b 100644
--- a/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp
+++ b/src/plugins/genericprojectmanager/filesselectionwizardpage.cpp
@@ -31,10 +31,10 @@
#include "genericprojectwizard.h"
#include "genericprojectconstants.h"
-#include "selectablefilesmodel.h"
#include <coreplugin/mimedatabase.h>
#include <coreplugin/icore.h>
+#include <projectexplorer/selectablefilesmodel.h>
#include <QVBoxLayout>
#include <QLineEdit>
@@ -117,12 +117,12 @@ void FilesSelectionWizardPage::initializePage()
{
m_view->setModel(0);
delete m_model;
- m_model = new SelectableFilesModel(m_genericProjectWizardDialog->path(), this);
+ m_model = new ProjectExplorer::SelectableFilesModel(this);
connect(m_model, SIGNAL(parsingProgress(QString)),
this, SLOT(parsingProgress(QString)));
connect(m_model, SIGNAL(parsingFinished()),
this, SLOT(parsingFinished()));
- m_model->startParsing();
+ m_model->startParsing(m_genericProjectWizardDialog->path());
m_hideFilesFilterLabel->setVisible(false);
m_hideFilesfilterLineEdit->setVisible(false);
@@ -139,7 +139,6 @@ void FilesSelectionWizardPage::initializePage()
void FilesSelectionWizardPage::cleanupPage()
{
m_model->cancel();
- m_model->waitForFinished();
}
void FilesSelectionWizardPage::parsingProgress(const QString &text)
diff --git a/src/plugins/genericprojectmanager/filesselectionwizardpage.h b/src/plugins/genericprojectmanager/filesselectionwizardpage.h
index 1758fdade4..142707875c 100644
--- a/src/plugins/genericprojectmanager/filesselectionwizardpage.h
+++ b/src/plugins/genericprojectmanager/filesselectionwizardpage.h
@@ -39,11 +39,14 @@ class QTreeView;
class QLineEdit;
QT_END_NAMESPACE
+namespace ProjectExplorer {
+ class SelectableFilesModel;
+}
+
namespace GenericProjectManager {
namespace Internal {
class GenericProjectWizardDialog;
-class SelectableFilesModel;
class FilesSelectionWizardPage : public QWizardPage
{
@@ -68,7 +71,7 @@ private:
void createApplyButton(QVBoxLayout *layout);
GenericProjectWizardDialog *m_genericProjectWizardDialog;
- SelectableFilesModel *m_model;
+ ProjectExplorer::SelectableFilesModel *m_model;
QLabel *m_hideFilesFilterLabel;
QLineEdit *m_hideFilesfilterLineEdit;
diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp
index d1102d6662..68d7714351 100644
--- a/src/plugins/genericprojectmanager/genericproject.cpp
+++ b/src/plugins/genericprojectmanager/genericproject.cpp
@@ -69,6 +69,7 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName)
: m_manager(manager),
m_fileName(fileName)
{
+ setId(Constants::GENERICPROJECT_ID);
setProjectContext(Context(GenericProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Context(ProjectExplorer::Constants::LANG_CXX));
@@ -264,7 +265,7 @@ void GenericProject::refresh(RefreshOptions options)
}
part->cxxVersion = CppTools::ProjectPart::CXX11; // assume C++11
- part->defines += m_defines;
+ part->projectDefines += m_defines;
// ### add _defines.
@@ -357,11 +358,6 @@ QString GenericProject::displayName() const
return m_projectName;
}
-Id GenericProject::id() const
-{
- return Id(Constants::GENERICPROJECT_ID);
-}
-
IDocument *GenericProject::document() const
{
return m_creatorIDocument;
diff --git a/src/plugins/genericprojectmanager/genericproject.h b/src/plugins/genericprojectmanager/genericproject.h
index ff8c8efe49..18ca8798c6 100644
--- a/src/plugins/genericprojectmanager/genericproject.h
+++ b/src/plugins/genericprojectmanager/genericproject.h
@@ -60,7 +60,6 @@ public:
QString configFileName() const;
QString displayName() const;
- Core::Id id() const;
Core::IDocument *document() const;
ProjectExplorer::IProjectManager *projectManager() const;
@@ -82,9 +81,6 @@ public:
void refresh(RefreshOptions options);
- QStringList includePaths() const;
- void setIncludePaths(const QStringList &includePaths);
-
QByteArray defines() const;
QStringList projectIncludePaths() const;
QStringList files() const;
diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
index 32837c6a88..958b6c4063 100644
--- a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
+++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp
@@ -50,20 +50,21 @@ namespace Internal {
//
////////////////////////////////////////////////////////////////////////////////////////
-ProjectFilesFactory::ProjectFilesFactory(Manager *manager, TextEditorActionHandler *handler)
- : Core::IEditorFactory(manager),
- m_actionHandler(handler)
+ProjectFilesFactory::ProjectFilesFactory(Manager *manager)
+ : Core::IEditorFactory(manager)
{
setId(Constants::FILES_EDITOR_ID);
setDisplayName(QCoreApplication::translate("OpenWith::Editors", ".files Editor"));
addMimeType(Constants::FILES_MIMETYPE);
addMimeType(Constants::INCLUDES_MIMETYPE);
addMimeType(Constants::CONFIG_MIMETYPE);
+ new TextEditor::TextEditorActionHandler(this, Constants::C_FILESEDITOR);
+
}
-Core::IEditor *ProjectFilesFactory::createEditor(QWidget *parent)
+Core::IEditor *ProjectFilesFactory::createEditor()
{
- ProjectFilesEditorWidget *ed = new ProjectFilesEditorWidget(parent, this, m_actionHandler);
+ ProjectFilesEditorWidget *ed = new ProjectFilesEditorWidget();
TextEditorSettings::initializeEditor(ed);
return ed->editor();
}
@@ -90,12 +91,10 @@ bool ProjectFilesEditor::duplicateSupported() const
return true;
}
-Core::IEditor *ProjectFilesEditor::duplicate(QWidget *parent)
+Core::IEditor *ProjectFilesEditor::duplicate()
{
- ProjectFilesEditorWidget *parentEditor = qobject_cast<ProjectFilesEditorWidget *>(editorWidget());
- ProjectFilesEditorWidget *editor = new ProjectFilesEditorWidget(parent,
- parentEditor->factory(),
- parentEditor->actionHandler());
+ ProjectFilesEditorWidget *editor = new ProjectFilesEditorWidget(
+ qobject_cast<ProjectFilesEditorWidget *>(editorWidget()));
TextEditorSettings::initializeEditor(editor);
return editor->editor();
}
@@ -106,26 +105,14 @@ Core::IEditor *ProjectFilesEditor::duplicate(QWidget *parent)
//
////////////////////////////////////////////////////////////////////////////////////////
-ProjectFilesEditorWidget::ProjectFilesEditorWidget(QWidget *parent, ProjectFilesFactory *factory,
- TextEditorActionHandler *handler)
- : BaseTextEditorWidget(parent),
- m_factory(factory),
- m_actionHandler(handler)
-{
- QSharedPointer<BaseTextDocument> doc(new BaseTextDocument());
- setBaseTextDocument(doc);
-
- handler->setupActions(this);
-}
-
-ProjectFilesFactory *ProjectFilesEditorWidget::factory() const
+ProjectFilesEditorWidget::ProjectFilesEditorWidget(QWidget *parent)
+ : BaseTextEditorWidget(parent)
{
- return m_factory;
}
-TextEditorActionHandler *ProjectFilesEditorWidget::actionHandler() const
+ProjectFilesEditorWidget::ProjectFilesEditorWidget(ProjectFilesEditorWidget *other)
+ : BaseTextEditorWidget(other)
{
- return m_actionHandler;
}
BaseTextEditor *ProjectFilesEditorWidget::createEditor()
diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.h b/src/plugins/genericprojectmanager/genericprojectfileseditor.h
index 4e1c7998fc..1236a8a924 100644
--- a/src/plugins/genericprojectmanager/genericprojectfileseditor.h
+++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.h
@@ -35,29 +35,21 @@
#include <coreplugin/editormanager/ieditorfactory.h>
-namespace TextEditor {
-class TextEditorActionHandler;
-}
-
namespace GenericProjectManager {
namespace Internal {
class Manager;
class ProjectFilesEditor;
class ProjectFilesEditorWidget;
-class ProjectFilesFactory;
class ProjectFilesFactory: public Core::IEditorFactory
{
Q_OBJECT
public:
- ProjectFilesFactory(Manager *manager, TextEditor::TextEditorActionHandler *handler);
-
- Core::IEditor *createEditor(QWidget *parent);
+ ProjectFilesFactory(Manager *manager);
-private:
- TextEditor::TextEditorActionHandler *m_actionHandler;
+ Core::IEditor *createEditor();
};
class ProjectFilesEditor : public TextEditor::BaseTextEditor
@@ -69,7 +61,7 @@ public:
Core::Id id() const;
bool duplicateSupported() const;
- Core::IEditor *duplicate(QWidget *parent);
+ Core::IEditor *duplicate();
};
class ProjectFilesEditorWidget : public TextEditor::BaseTextEditorWidget
@@ -77,16 +69,13 @@ class ProjectFilesEditorWidget : public TextEditor::BaseTextEditorWidget
Q_OBJECT
public:
- ProjectFilesEditorWidget(QWidget *parent, ProjectFilesFactory *factory,
- TextEditor::TextEditorActionHandler *handler);
+ ProjectFilesEditorWidget(QWidget *parent = 0);
+ ProjectFilesEditorWidget(ProjectFilesEditorWidget *other);
- ProjectFilesFactory *factory() const;
- TextEditor::TextEditorActionHandler *actionHandler() const;
TextEditor::BaseTextEditor *createEditor();
private:
- ProjectFilesFactory *m_factory;
- TextEditor::TextEditorActionHandler *m_actionHandler;
+ ProjectFilesEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
};
} // namespace Internal
diff --git a/src/plugins/genericprojectmanager/genericprojectmanager.pro b/src/plugins/genericprojectmanager/genericprojectmanager.pro
index 65528bcb6c..3ccecd9f86 100644
--- a/src/plugins/genericprojectmanager/genericprojectmanager.pro
+++ b/src/plugins/genericprojectmanager/genericprojectmanager.pro
@@ -10,7 +10,6 @@ HEADERS = genericproject.h \
pkgconfigtool.h \
genericmakestep.h \
genericbuildconfiguration.h \
- selectablefilesmodel.h \
filesselectionwizardpage.h
SOURCES = genericproject.cpp \
genericprojectplugin.cpp \
@@ -21,7 +20,6 @@ SOURCES = genericproject.cpp \
pkgconfigtool.cpp \
genericmakestep.cpp \
genericbuildconfiguration.cpp \
- selectablefilesmodel.cpp \
filesselectionwizardpage.cpp
RESOURCES += genericproject.qrc
FORMS += genericmakestep.ui
diff --git a/src/plugins/genericprojectmanager/genericprojectmanager.qbs b/src/plugins/genericprojectmanager/genericprojectmanager.qbs
index 70386b06ca..72729967a3 100644
--- a/src/plugins/genericprojectmanager/genericprojectmanager.qbs
+++ b/src/plugins/genericprojectmanager/genericprojectmanager.qbs
@@ -11,8 +11,6 @@ QtcPlugin {
Depends { name: "CppTools" }
Depends { name: "TextEditor" }
Depends { name: "ProjectExplorer" }
- Depends { name: "Find" }
- Depends { name: "Locator" }
Depends { name: "QtSupport" }
files: [
@@ -39,7 +37,5 @@ QtcPlugin {
"genericprojectwizard.h",
"pkgconfigtool.cpp",
"pkgconfigtool.h",
- "selectablefilesmodel.cpp",
- "selectablefilesmodel.h",
]
}
diff --git a/src/plugins/genericprojectmanager/genericprojectnodes.cpp b/src/plugins/genericprojectmanager/genericprojectnodes.cpp
index 4250e95b1a..6e7c1dde76 100644
--- a/src/plugins/genericprojectmanager/genericprojectnodes.cpp
+++ b/src/plugins/genericprojectmanager/genericprojectnodes.cpp
@@ -237,6 +237,7 @@ QList<ProjectNode::ProjectAction> GenericProjectNode::supportedActions(Node *nod
return QList<ProjectAction>()
<< AddNewFile
<< AddExistingFile
+ << AddExistingDirectory
<< RemoveFile
<< Rename;
}
diff --git a/src/plugins/genericprojectmanager/genericprojectplugin.cpp b/src/plugins/genericprojectmanager/genericprojectplugin.cpp
index c798a70a88..65557e026d 100644
--- a/src/plugins/genericprojectmanager/genericprojectplugin.cpp
+++ b/src/plugins/genericprojectmanager/genericprojectplugin.cpp
@@ -36,7 +36,6 @@
#include "genericprojectfileseditor.h"
#include "genericmakestep.h"
#include "genericproject.h"
-#include "selectablefilesmodel.h"
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
@@ -45,10 +44,9 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/selectablefilesmodel.h>
-#include <texteditor/texteditoractionhandler.h>
-
#include <QtPlugin>
#include <QDebug>
@@ -76,10 +74,7 @@ bool GenericProjectPlugin::initialize(const QStringList &, QString *errorMessage
Manager *manager = new Manager;
- TextEditor::TextEditorActionHandler *actionHandler =
- new TextEditor::TextEditorActionHandler(Constants::C_FILESEDITOR);
-
- m_projectFilesEditorFactory = new ProjectFilesFactory(manager, actionHandler);
+ m_projectFilesEditorFactory = new ProjectFilesFactory(manager);
addObject(m_projectFilesEditorFactory);
addAutoReleasedObject(manager);
@@ -115,7 +110,7 @@ void GenericProjectPlugin::updateContextMenu(ProjectExplorer::Project *project,
void GenericProjectPlugin::editFiles()
{
GenericProject *genericProject = static_cast<GenericProject *>(m_contextMenuProject);
- SelectableFilesDialog sfd(QFileInfo(genericProject->projectFilePath()).path(), genericProject->files(),
+ ProjectExplorer::SelectableFilesDialogEditFiles sfd(QFileInfo(genericProject->projectFilePath()).path(), genericProject->files(),
Core::ICore::mainWindow());
if (sfd.exec() == QDialog::Accepted)
genericProject->setFiles(sfd.selectedFiles());
diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp
index 1641f2e009..9409c56f98 100644
--- a/src/plugins/git/branchdialog.cpp
+++ b/src/plugins/git/branchdialog.cpp
@@ -38,11 +38,14 @@
#include "stashdialog.h" // Label helpers
#include <utils/qtcassert.h>
+#include <utils/execmenu.h>
#include <vcsbase/vcsbaseoutputwindow.h>
+#include <QAction>
#include <QItemSelectionModel>
#include <QMessageBox>
#include <QList>
+#include <QMenu>
#include <QDebug>
@@ -321,8 +324,18 @@ void BranchDialog::merge()
const QString branch = m_model->fullName(idx, true);
GitClient *client = GitPlugin::instance()->gitClient();
+ bool allowFastForward = true;
+ if (client->isFastForwardMerge(m_repository, branch)) {
+ QMenu popup;
+ QAction *fastForward = popup.addAction(tr("Fast-Forward"));
+ popup.addAction(tr("No Fast-Forward"));
+ QAction *chosen = Utils::execMenuAtWidget(&popup, m_ui->mergeButton);
+ if (!chosen)
+ return;
+ allowFastForward = (chosen == fastForward);
+ }
if (client->beginStashScope(m_repository, QLatin1String("merge"), AllowUnstashed))
- client->synchronousMerge(m_repository, branch);
+ client->synchronousMerge(m_repository, branch, allowFastForward);
}
void BranchDialog::rebase()
diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp
index d9552cd575..167d12ed03 100644
--- a/src/plugins/git/changeselectiondialog.cpp
+++ b/src/plugins/git/changeselectiondialog.cpp
@@ -42,6 +42,9 @@
#include <QPlainTextEdit>
#include <QDir>
#include <QFileDialog>
+#include <QCompleter>
+#include <QStringListModel>
+#include <QTimer>
namespace Git {
namespace Internal {
@@ -60,8 +63,9 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, Co
m_ui->changeNumberEdit->setFocus();
m_ui->changeNumberEdit->selectAll();
- connect(m_ui->changeNumberEdit, SIGNAL(textChanged(QString)), this, SLOT(recalculateDetails()));
+ connect(m_ui->changeNumberEdit, SIGNAL(textChanged(QString)), this, SLOT(changeTextChanged(QString)));
connect(m_ui->workingDirectoryEdit, SIGNAL(textChanged(QString)), this, SLOT(recalculateDetails()));
+ connect(m_ui->workingDirectoryEdit, SIGNAL(textChanged(QString)), this, SLOT(recalculateCompletion()));
connect(m_ui->selectDirectoryButton, SIGNAL(clicked()), this, SLOT(chooseWorkingDirectory()));
connect(m_ui->selectFromHistoryButton, SIGNAL(clicked()), this, SLOT(selectCommitFromRecentHistory()));
connect(m_ui->showButton, SIGNAL(clicked()), this, SLOT(acceptShow()));
@@ -77,7 +81,13 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, Co
m_ui->checkoutButton->setDefault(true);
else
m_ui->showButton->setDefault(true);
+ m_changeModel = new QStringListModel(this);
+ QCompleter *changeCompleter = new QCompleter(m_changeModel, this);
+ m_ui->changeNumberEdit->setCompleter(changeCompleter);
+ changeCompleter->setCaseSensitivity(Qt::CaseInsensitive);
+
recalculateDetails();
+ recalculateCompletion();
}
ChangeSelectionDialog::~ChangeSelectionDialog()
@@ -88,7 +98,7 @@ ChangeSelectionDialog::~ChangeSelectionDialog()
QString ChangeSelectionDialog::change() const
{
- return m_ui->changeNumberEdit->text();
+ return m_ui->changeNumberEdit->text().trimmed();
}
void ChangeSelectionDialog::selectCommitFromRecentHistory()
@@ -188,6 +198,26 @@ void ChangeSelectionDialog::enableButtons(bool b)
m_ui->checkoutButton->setEnabled(b);
}
+void ChangeSelectionDialog::recalculateCompletion()
+{
+ const QString workingDir = workingDirectory();
+ if (workingDir == m_oldWorkingDir)
+ return;
+ m_oldWorkingDir = workingDir;
+
+ if (!workingDir.isEmpty()) {
+ GitClient *client = GitPlugin::instance()->gitClient();
+ QStringList args;
+ args << QLatin1String("--format=%(refname:short)");
+ QString output;
+ if (client->synchronousForEachRefCmd(workingDir, args, &output)) {
+ m_changeModel->setStringList(output.split(QLatin1Char('\n')));
+ return;
+ }
+ }
+ m_changeModel->setStringList(QStringList());
+}
+
void ChangeSelectionDialog::recalculateDetails()
{
if (m_process) {
@@ -210,8 +240,14 @@ void ChangeSelectionDialog::recalculateDetails()
m_ui->workingDirectoryEdit->setPalette(palette);
}
+ const QString ref = change();
+ if (ref.isEmpty()) {
+ m_ui->detailsText->setPlainText(QString());
+ return;
+ }
+
QStringList args;
- args << QLatin1String("log") << QLatin1String("-n1") << m_ui->changeNumberEdit->text();
+ args << QLatin1String("log") << QLatin1String("-n1") << ref;
m_process = new QProcess(this);
m_process->setWorkingDirectory(workingDir);
@@ -227,5 +263,16 @@ void ChangeSelectionDialog::recalculateDetails()
m_ui->detailsText->setPlainText(tr("Fetching commit data..."));
}
+void ChangeSelectionDialog::changeTextChanged(const QString &text)
+{
+ if (QCompleter *comp = m_ui->changeNumberEdit->completer()) {
+ if (text.isEmpty() && !comp->popup()->isVisible()) {
+ comp->setCompletionPrefix(text);
+ QTimer::singleShot(0, comp, SLOT(complete()));
+ }
+ }
+ recalculateDetails();
+}
+
} // Internal
} // Git
diff --git a/src/plugins/git/changeselectiondialog.h b/src/plugins/git/changeselectiondialog.h
index fe441f2ec3..c1ab0b2b6a 100644
--- a/src/plugins/git/changeselectiondialog.h
+++ b/src/plugins/git/changeselectiondialog.h
@@ -41,6 +41,7 @@ class QLabel;
class QLineEdit;
class QPlainTextEdit;
class QProcess;
+class QStringListModel;
QT_END_NAMESPACE
namespace Git {
@@ -72,7 +73,9 @@ private slots:
void chooseWorkingDirectory();
void selectCommitFromRecentHistory();
void setDetails(int exitCode);
+ void recalculateCompletion();
void recalculateDetails();
+ void changeTextChanged(const QString &text);
void acceptCheckout();
void acceptCherryPick();
void acceptRevert();
@@ -87,6 +90,8 @@ private:
QString m_gitBinaryPath;
QProcessEnvironment m_gitEnvironment;
ChangeCommand m_command;
+ QStringListModel *m_changeModel;
+ QString m_oldWorkingDir;
};
} // namespace Internal
diff --git a/src/plugins/git/changeselectiondialog.ui b/src/plugins/git/changeselectiondialog.ui
index 5fd084858c..8fe291169f 100644
--- a/src/plugins/git/changeselectiondialog.ui
+++ b/src/plugins/git/changeselectiondialog.ui
@@ -39,7 +39,7 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="QLineEdit" name="changeNumberEdit">
+ <widget class="Utils::CompletingLineEdit" name="changeNumberEdit">
<property name="text">
<string>HEAD</string>
</property>
@@ -119,6 +119,13 @@
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>Utils::CompletingLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header location="global">utils/completinglineedit.h</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections>
<connection>
diff --git a/src/plugins/git/gerrit/gerritdialog.cpp b/src/plugins/git/gerrit/gerritdialog.cpp
index 881b3f736c..58e402bc5a 100644
--- a/src/plugins/git/gerrit/gerritdialog.cpp
+++ b/src/plugins/git/gerrit/gerritdialog.cpp
@@ -156,6 +156,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
detailsLayout->addWidget(m_detailsBrowser);
m_repositoryChooser->setExpectedKind(Utils::PathChooser::Directory);
+ m_repositoryChooser->setHistoryCompleter(QLatin1String("Git.RepoDir.History"));
QHBoxLayout *repoPathLayout = new QHBoxLayout;
repoPathLayout->addWidget(m_repositoryChooserLabel);
repoPathLayout->addWidget(m_repositoryChooser);
diff --git a/src/plugins/git/gerrit/gerritoptionspage.cpp b/src/plugins/git/gerrit/gerritoptionspage.cpp
index a63b64b97f..a6c09bbb56 100644
--- a/src/plugins/git/gerrit/gerritoptionspage.cpp
+++ b/src/plugins/git/gerrit/gerritoptionspage.cpp
@@ -55,12 +55,13 @@ GerritOptionsPage::~GerritOptionsPage()
delete m_widget;
}
-QWidget *GerritOptionsPage::createPage(QWidget *parent)
+QWidget *GerritOptionsPage::widget()
{
- GerritOptionsWidget *gow = new GerritOptionsWidget(parent);
- gow->setParameters(*m_parameters);
- m_widget = gow;
- return gow;
+ if (!m_widget) {
+ m_widget = new GerritOptionsWidget;
+ m_widget->setParameters(*m_parameters);
+ }
+ return m_widget;
}
void GerritOptionsPage::apply()
@@ -78,9 +79,9 @@ void GerritOptionsPage::apply()
}
}
-bool GerritOptionsPage::matches(const QString &s) const
+void GerritOptionsPage::finish()
{
- return s.contains(QLatin1String("gerrit"), Qt::CaseInsensitive);
+ delete m_widget;
}
GerritOptionsWidget::GerritOptionsWidget(QWidget *parent)
@@ -99,9 +100,11 @@ GerritOptionsWidget::GerritOptionsWidget(QWidget *parent)
formLayout->addRow(tr("&User:"), m_userLineEdit);
m_sshChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_sshChooser->setCommandVersionArguments(QStringList(QLatin1String("-V")));
+ m_sshChooser->setHistoryCompleter(QLatin1String("Git.SshCommand.History"));
formLayout->addRow(tr("&ssh:"), m_sshChooser);
formLayout->addRow(tr("&Repository:"), m_repositoryChooser);
m_repositoryChooser->setToolTip(tr("Default repository where patches will be applied."));
+ m_repositoryChooser->setHistoryCompleter(QLatin1String("Git.RepoDir.History"));
formLayout->addRow(tr("Pr&ompt:"), m_promptPathCheckBox);
m_promptPathCheckBox->setToolTip(tr("If checked, user will always be\n"
"asked to confirm the repository path."));
diff --git a/src/plugins/git/gerrit/gerritoptionspage.h b/src/plugins/git/gerrit/gerritoptionspage.h
index c027fd7a96..91eedde18b 100644
--- a/src/plugins/git/gerrit/gerritoptionspage.h
+++ b/src/plugins/git/gerrit/gerritoptionspage.h
@@ -78,10 +78,9 @@ public:
QObject *parent = 0);
~GerritOptionsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &) const;
+ void finish();
private:
const QSharedPointer<GerritParameters> &m_parameters;
diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp
index 2acbc32fce..27fe009d6a 100644
--- a/src/plugins/git/gerrit/gerritplugin.cpp
+++ b/src/plugins/git/gerrit/gerritplugin.cpp
@@ -51,7 +51,7 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/editormanager/editormanager.h>
-#include <locator/commandlocator.h>
+#include <coreplugin/locator/commandlocator.h>
#include <vcsbase/vcsbaseoutputwindow.h>
@@ -256,7 +256,7 @@ void FetchContext::cherryPick()
void FetchContext::checkout()
{
- Git::Internal::GitPlugin::instance()->gitClient()->synchronousCheckout(
+ Git::Internal::GitPlugin::instance()->gitClient()->stashAndCheckout(
m_repository, QLatin1String("FETCH_HEAD"));
}
@@ -302,7 +302,7 @@ void GerritPlugin::updateActions(bool hasTopLevel)
m_pushToGerritPair.first->setEnabled(hasTopLevel);
}
-void GerritPlugin::addToLocator(Locator::CommandLocator *locator)
+void GerritPlugin::addToLocator(Core::CommandLocator *locator)
{
locator->appendCommand(m_gerritCommand);
locator->appendCommand(m_pushToGerritPair.second);
diff --git a/src/plugins/git/gerrit/gerritplugin.h b/src/plugins/git/gerrit/gerritplugin.h
index cefa726d35..1d7217d9c4 100644
--- a/src/plugins/git/gerrit/gerritplugin.h
+++ b/src/plugins/git/gerrit/gerritplugin.h
@@ -42,10 +42,9 @@ QT_END_NAMESPACE
namespace Core {
class ActionContainer;
class Command;
+class CommandLocator;
}
-namespace Locator { class CommandLocator; }
-
namespace Gerrit {
namespace Internal {
@@ -66,7 +65,7 @@ public:
static QString gitBinary();
static QString branch(const QString &repository);
- void addToLocator(Locator::CommandLocator *locator);
+ void addToLocator(Core::CommandLocator *locator);
void push(const QString &topLevel);
public slots:
diff --git a/src/plugins/git/gerrit/gerritpushdialog.cpp b/src/plugins/git/gerrit/gerritpushdialog.cpp
index 83d182c12a..1c8d8a3df5 100644
--- a/src/plugins/git/gerrit/gerritpushdialog.cpp
+++ b/src/plugins/git/gerrit/gerritpushdialog.cpp
@@ -40,6 +40,23 @@
namespace Gerrit {
namespace Internal {
+class PushItemDelegate : public Git::Internal::IconItemDelegate
+{
+public:
+ PushItemDelegate(Git::Internal::LogChangeWidget *widget)
+ : IconItemDelegate(widget, QLatin1String(":/git/images/arrowup.png"))
+ {
+ }
+
+protected:
+ bool hasIcon(int row) const
+ {
+ return row >= currentRow();
+ }
+};
+
+
+
GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &reviewerList, QWidget *parent) :
QDialog(parent),
m_workingDir(workingDir),
@@ -55,6 +72,8 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
if (!m_ui->commitView->init(workingDir, QString(), false))
return;
+ PushItemDelegate *delegate = new PushItemDelegate(m_ui->commitView);
+ delegate->setParent(this);
QString earliestCommit = m_ui->commitView->earliestCommit();
if (earliestCommit.isEmpty())
return;
diff --git a/src/plugins/git/git.qbs b/src/plugins/git/git.qbs
index dd4e2e0205..bff95c4aca 100644
--- a/src/plugins/git/git.qbs
+++ b/src/plugins/git/git.qbs
@@ -8,10 +8,8 @@ QtcPlugin {
Depends { name: "Qt"; submodules: ["widgets", "network"] }
Depends { name: "Core" }
Depends { name: "TextEditor" }
- Depends { name: "Find" }
Depends { name: "VcsBase" }
Depends { name: "DiffEditor" }
- Depends { name: "Locator" }
files: [
"annotationhighlighter.cpp",
diff --git a/src/plugins/git/git.qrc b/src/plugins/git/git.qrc
index 3371b45cd8..15b93521a3 100644
--- a/src/plugins/git/git.qrc
+++ b/src/plugins/git/git.qrc
@@ -2,6 +2,7 @@
<qresource prefix="/git">
<file>images/git.png</file>
<file>images/gitorious.png</file>
+ <file>images/arrowup.png</file>
<file>Git.mimetypes.xml</file>
</qresource>
</RCC>
diff --git a/src/plugins/git/git_dependencies.pri b/src/plugins/git/git_dependencies.pri
index 6e7123f247..e78d2e2e5d 100644
--- a/src/plugins/git/git_dependencies.pri
+++ b/src/plugins/git/git_dependencies.pri
@@ -2,7 +2,6 @@ QTC_PLUGIN_NAME = Git
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
- locator \
texteditor \
coreplugin \
vcsbase \
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 614761e166..9bb2f86678 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -36,6 +36,8 @@
#include "gitsubmiteditor.h"
#include "gitversioncontrol.h"
#include "mergetool.h"
+#include "branchadddialog.h"
+#include "gerrit/gerritplugin.h"
#include <vcsbase/submitfilemodel.h>
@@ -360,7 +362,7 @@ void GitDiffHandler::collectShowDescription(const QString &id)
return;
m_editor->clear(m_waitMessage);
VcsBase::Command *command = new VcsBase::Command(m_gitPath, m_workingDirectory, m_processEnvironment);
- command->setCodec(m_editor->editorWidget()->codec());
+ command->setCodec(m_editor->codec());
connect(command, SIGNAL(output(QString)), this, SLOT(slotShowDescriptionReceived(QString)));
QStringList arguments;
arguments << QLatin1String("show") << QLatin1String("-s")
@@ -390,7 +392,7 @@ void GitDiffHandler::collectFilesList(const QStringList &additionalArguments)
return;
m_editor->clear(m_waitMessage);
VcsBase::Command *command = new VcsBase::Command(m_gitPath, m_workingDirectory, m_processEnvironment);
- command->setCodec(m_editor->editorWidget()->codec());
+ command->setCodec(m_editor->codec());
connect(command, SIGNAL(output(QString)), this, SLOT(slotFileListReceived(QString)));
QStringList arguments;
arguments << QLatin1String("diff") << QLatin1String("--name-only") << additionalArguments;
@@ -459,7 +461,7 @@ void GitDiffHandler::collectFilesContents()
VcsBase::Command *command = new VcsBase::Command(m_gitPath, m_workingDirectory, m_processEnvironment);
if (m_editor)
- command->setCodec(m_editor->editorWidget()->codec());
+ command->setCodec(m_editor->codec());
connect(command, SIGNAL(output(QString)), this, SLOT(slotFileContentsReceived(QString)));
QString revisionArgument = (revision.type == Other)
@@ -545,7 +547,7 @@ QString GitDiffHandler::workingTreeContents(const QString &fileName) const
QFile file(absoluteFileName);
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
- return m_editor->editorWidget()->codec()->toUnicode(file.readAll());
+ return m_editor->codec()->toUnicode(file.readAll());
return QString();
}
@@ -987,11 +989,9 @@ QString GitClient::findGitDirForRepository(const QString &repositoryDir) const
QString &res = repoDirCache[repositoryDir];
if (!res.isEmpty())
return res;
- QByteArray outputText;
- QStringList arguments;
- arguments << QLatin1String("rev-parse") << QLatin1String("--git-dir");
- fullySynchronousGit(repositoryDir, arguments, &outputText, 0, false);
- res = QString::fromLocal8Bit(outputText.trimmed());
+
+ synchronousRevParseCmd(repositoryDir, QLatin1String("--git-dir"), &res);
+
if (!QDir(res).isAbsolute())
res.prepend(repositoryDir + QLatin1Char('/'));
return res;
@@ -1045,7 +1045,7 @@ DiffEditor::DiffEditor *GitClient::createDiffEditor(const char *registerDynamicP
Core::EditorManager::openEditorWithContents(editorId, &title, m_msgWait.toUtf8()));
QTC_ASSERT(diffEditor, return 0);
diffEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue);
- diffEditor->editorWidget()->setSource(source);
+ VcsBasePlugin::setSource(diffEditor, source);
Core::EditorManager::activateEditor(diffEditor);
return diffEditor;
@@ -1554,12 +1554,10 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory,
{
QByteArray outputText;
QByteArray errorText;
- QStringList arguments;
- arguments << QLatin1String("checkout") << ref;
+ QStringList arguments = setupCheckoutArguments(workingDirectory, ref);
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText,
VcsBasePlugin::ExpectRepoChanges);
- const QString output = commandOutputFromLocal8Bit(outputText);
- outputWindow()->append(output);
+ outputWindow()->append(commandOutputFromLocal8Bit(outputText));
if (!rc) {
msgCannotRun(arguments, workingDirectory, errorText, errorMessage);
return false;
@@ -1568,6 +1566,67 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory,
return true;
}
+/* method used to setup arguments for checkout, in case user wants to create local branch */
+QStringList GitClient::setupCheckoutArguments(const QString &workingDirectory,
+ const QString &ref)
+{
+ QStringList arguments(QLatin1String("checkout"));
+ arguments << ref;
+
+ QStringList localBranches = synchronousRepositoryBranches(workingDirectory);
+
+ if (localBranches.contains(ref))
+ return arguments;
+
+ if (QMessageBox::question(Core::ICore::mainWindow(), tr("Create Local Branch"),
+ tr("Would you like to create local branch?"),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
+ return arguments;
+ }
+
+ if (synchronousCurrentLocalBranch(workingDirectory).isEmpty())
+ localBranches.removeFirst();
+
+ QString refSha;
+ if (!synchronousRevParseCmd(workingDirectory, ref, &refSha))
+ return arguments;
+
+ QString output;
+ QStringList forEachRefArgs(QLatin1String("refs/remotes/"));
+ forEachRefArgs << QLatin1String("--format=%(objectname) %(refname:short)");
+ if (!synchronousForEachRefCmd(workingDirectory, forEachRefArgs, &output))
+ return arguments;
+
+ QString remoteBranch;
+ const QString head(QLatin1String("/HEAD"));
+
+ foreach (const QString &singleRef, output.split(QLatin1Char('\n'))) {
+ if (singleRef.startsWith(refSha)) {
+ // branch name might be origin/foo/HEAD
+ if (!singleRef.endsWith(head) || singleRef.count(QLatin1Char('/')) > 1) {
+ remoteBranch = singleRef.mid(refSha.length() + 1);
+ if (remoteBranch == ref)
+ break;
+ }
+ }
+ }
+
+ BranchAddDialog branchAddDialog(localBranches, true, Core::ICore::mainWindow());
+ branchAddDialog.setTrackedBranchName(remoteBranch, true);
+
+ if (branchAddDialog.exec() != QDialog::Accepted)
+ return arguments;
+
+ arguments.removeLast();
+ arguments << QLatin1String("-b") << branchAddDialog.branchName();
+ if (branchAddDialog.track())
+ arguments << QLatin1String("--track") << remoteBranch;
+ else
+ arguments << QLatin1String("--no-track") << ref;
+
+ return arguments;
+}
+
void GitClient::reset(const QString &workingDirectory, const QString &argument, const QString &commit)
{
QStringList arguments;
@@ -1755,6 +1814,16 @@ bool GitClient::synchronousCheckoutFiles(const QString &workingDirectory,
return true;
}
+bool GitClient::stashAndCheckout(const QString &workingDirectory, const QString &ref)
+{
+ if (!beginStashScope(workingDirectory, QLatin1String("Checkout")))
+ return false;
+ if (!synchronousCheckout(workingDirectory, ref))
+ return false;
+ endStashScope(workingDirectory);
+ return true;
+}
+
static inline QString msgParentRevisionFailed(const QString &workingDirectory,
const QString &revision,
const QString &why)
@@ -1957,25 +2026,28 @@ QString GitClient::synchronousTopic(const QString &workingDirectory)
return data.topic = remoteBranch.isEmpty() ? tr("Detached HEAD") : remoteBranch;
}
+bool GitClient::synchronousRevParseCmd(const QString &workingDirectory, const QString &ref,
+ QString *output, QString *errorMessage) const
+{
+ QStringList arguments(QLatin1String("rev-parse"));
+ arguments << ref;
+ QByteArray outputText;
+ QByteArray errorText;
+ const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText,
+ VcsBasePlugin::SuppressCommandLogging);
+ *output = commandOutputFromLocal8Bit(outputText.trimmed());
+ if (!rc)
+ msgCannotRun(arguments, workingDirectory, errorText, errorMessage);
+
+ return rc;
+}
+
// Retrieve head revision
QString GitClient::synchronousTopRevision(const QString &workingDirectory, QString *errorMessageIn)
{
- QByteArray outputTextData;
- QByteArray errorText;
- QStringList arguments;
- QString errorMessage;
- // get revision
- arguments << QLatin1String("rev-parse") << QLatin1String(HEAD);
- if (!fullySynchronousGit(workingDirectory, arguments, &outputTextData, &errorText,
- VcsBasePlugin::SuppressCommandLogging)) {
- errorMessage = tr("Cannot retrieve top revision of \"%1\": %2")
- .arg(QDir::toNativeSeparators(workingDirectory), commandOutputFromLocal8Bit(errorText));
+ QString revision;
+ if (!synchronousRevParseCmd(workingDirectory, QLatin1String(HEAD), &revision, errorMessageIn))
return QString();
- }
- QString revision = commandOutputFromLocal8Bit(outputTextData);
- revision.remove(QLatin1Char('\n'));
- if (revision.isEmpty() && !errorMessage.isEmpty())
- msgCannotRun(errorMessage, errorMessageIn);
return revision;
}
@@ -2044,6 +2116,17 @@ bool GitClient::isRemoteCommit(const QString &workingDirectory, const QString &c
return !outputText.isEmpty();
}
+bool GitClient::isFastForwardMerge(const QString &workingDirectory, const QString &branch)
+{
+ QStringList arguments;
+ QByteArray outputText;
+ arguments << QLatin1String("merge-base") << QLatin1String(HEAD) << branch;
+ fullySynchronousGit(workingDirectory, arguments, &outputText, 0,
+ VcsBasePlugin::SuppressCommandLogging);
+ return commandOutputFromLocal8Bit(outputText).trimmed()
+ == synchronousTopRevision(workingDirectory);
+}
+
// Format an entry in a one-liner for selection list using git log.
QString GitClient::synchronousShortDescription(const QString &workingDirectory, const QString &revision,
const QString &format)
@@ -2468,12 +2551,13 @@ QProcessEnvironment GitClient::processEnvironment() const
return environment;
}
-bool GitClient::beginStashScope(const QString &workingDirectory, const QString &command, StashFlag flag)
+bool GitClient::beginStashScope(const QString &workingDirectory, const QString &command,
+ StashFlag flag, PushAction pushAction)
{
const QString repoDirectory = findRepositoryForDirectory(workingDirectory);
QTC_ASSERT(!repoDirectory.isEmpty(), return false);
StashInfo &stashInfo = m_stashInfo[repoDirectory];
- return stashInfo.init(repoDirectory, command, flag);
+ return stashInfo.init(repoDirectory, command, flag, pushAction);
}
GitClient::StashInfo &GitClient::stashInfo(const QString &workingDirectory)
@@ -2806,12 +2890,31 @@ void GitClient::launchGitK(const QString &workingDirectory, const QString &fileN
QDir foundBinDir(binaryInfo.dir());
const bool foundBinDirIsCmdDir = foundBinDir.dirName() == QLatin1String("cmd");
QProcessEnvironment env = processEnvironment();
- if (tryLauchingGitK(env, workingDirectory, fileName, foundBinDir.path(), foundBinDirIsCmdDir))
+ if (tryLauchingGitK(env, workingDirectory, fileName, foundBinDir.path()))
return;
- if (!foundBinDirIsCmdDir)
+
+ QString gitkPath = foundBinDir.path() + QLatin1String("/gitk");
+ VcsBase::VcsBaseOutputWindow::instance()->appendSilently(msgCannotLaunch(gitkPath));
+
+ if (foundBinDirIsCmdDir) {
+ foundBinDir.cdUp();
+ if (tryLauchingGitK(env, workingDirectory, fileName,
+ foundBinDir.path() + QLatin1String("/bin"))) {
+ return;
+ }
+ gitkPath = foundBinDir.path() + QLatin1String("/gitk");
+ VcsBase::VcsBaseOutputWindow::instance()->appendSilently(msgCannotLaunch(gitkPath));
+ }
+
+ Utils::Environment sysEnv = Utils::Environment::systemEnvironment();
+ const QString exec = sysEnv.searchInPath(QLatin1String("gitk"));
+
+ if (!exec.isEmpty() && tryLauchingGitK(env, workingDirectory, fileName,
+ QFileInfo(exec).absolutePath())) {
return;
- foundBinDir.cdUp();
- tryLauchingGitK(env, workingDirectory, fileName, foundBinDir.path() + QLatin1String("/bin"), false);
+ }
+
+ VcsBase::VcsBaseOutputWindow::instance()->appendError(msgCannotLaunch(QLatin1String("gitk")));
}
void GitClient::launchRepositoryBrowser(const QString &workingDirectory)
@@ -2824,8 +2927,7 @@ void GitClient::launchRepositoryBrowser(const QString &workingDirectory)
bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
const QString &workingDirectory,
const QString &fileName,
- const QString &gitBinDirectory,
- bool silent)
+ const QString &gitBinDirectory)
{
QString binary = gitBinDirectory + QLatin1String("/gitk");
QStringList arguments;
@@ -2860,12 +2962,7 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
} else {
success = QProcess::startDetached(binary, arguments, workingDirectory);
}
- if (!success) {
- if (silent)
- outwin->appendSilently(msgCannotLaunch(binary));
- else
- outwin->appendError(msgCannotLaunch(binary));
- }
+
return success;
}
@@ -2968,6 +3065,11 @@ bool GitClient::getCommitData(const QString &workingDirectory,
commitData.commitEncoding = readConfigValue(workingDirectory, QLatin1String("i18n.commitEncoding"));
+ // Set default commit encoding to 'UTF-8', when it's not set,
+ // to solve displaying error of commit log with non-latin characters.
+ if (commitData.commitEncoding.isEmpty())
+ commitData.commitEncoding = QLatin1String("UTF-8");
+
// Get the commit template or the last commit message
switch (commitData.commitType) {
case AmendCommit: {
@@ -3417,12 +3519,15 @@ void GitClient::push(const QString &workingDirectory, const QStringList &pushArg
executeGit(workingDirectory, arguments, 0, true);
}
-bool GitClient::synchronousMerge(const QString &workingDirectory, const QString &branch)
+bool GitClient::synchronousMerge(const QString &workingDirectory, const QString &branch,
+ bool allowFastForward)
{
QString command = QLatin1String("merge");
- QStringList arguments;
+ QStringList arguments(command);
- arguments << command << branch;
+ if (!allowFastForward)
+ arguments << QLatin1String("--no-ff");
+ arguments << branch;
return executeAndHandleConflicts(workingDirectory, arguments, command);
}
@@ -3439,21 +3544,39 @@ bool GitClient::canRebase(const QString &workingDirectory) const
return true;
}
-void GitClient::rebase(const QString &workingDirectory, const QString &baseBranch)
+void GitClient::rebase(const QString &workingDirectory, const QString &argument)
+{
+ asyncCommand(workingDirectory, QStringList() << QLatin1String("rebase") << argument, true);
+}
+
+void GitClient::cherryPick(const QString &workingDirectory, const QString &argument)
+{
+ asyncCommand(workingDirectory, QStringList() << QLatin1String("cherry-pick") << argument);
+}
+
+void GitClient::revert(const QString &workingDirectory, const QString &argument)
+{
+ asyncCommand(workingDirectory, QStringList() << QLatin1String("revert") << argument);
+}
+
+// Executes a command asynchronously. Work tree is expected to be clean.
+// Stashing is handled prior to this call.
+void GitClient::asyncCommand(const QString &workingDirectory, const QStringList &arguments,
+ bool hasProgress)
{
// Git might request an editor, so this must be done asynchronously
// and without timeout
- QString gitCommand = QLatin1String("rebase");
- QStringList arguments;
- arguments << gitCommand << baseBranch;
+ QString gitCommand = arguments.first();
outputWindow()->appendCommand(workingDirectory,
settings()->stringValue(GitSettings::binaryPathKey),
arguments);
VcsBase::Command *command = createCommand(workingDirectory, 0, true);
new ConflictHandler(command, workingDirectory, gitCommand);
- command->setProgressParser(new ProgressParser);
+ if (hasProgress)
+ command->setProgressParser(new ProgressParser);
command->addJob(arguments, -1);
command->execute();
+ command->setCookie(workingDirectory);
}
bool GitClient::synchronousRevert(const QString &workingDirectory, const QString &commit)
@@ -3495,12 +3618,7 @@ void GitClient::interactiveRebase(const QString &workingDirectory, const QString
outputWindow()->appendCommand(workingDirectory, settings()->stringValue(GitSettings::binaryPathKey), arguments);
if (fixup)
m_disableEditor = true;
- VcsBase::Command *command = createCommand(workingDirectory, 0, true);
- new ConflictHandler(command, workingDirectory, QLatin1String("rebase"));
- command->setProgressParser(new ProgressParser);
- command->addJob(arguments, -1);
- command->execute();
- command->setCookie(workingDirectory);
+ asyncCommand(workingDirectory, arguments, true);
if (fixup)
m_disableEditor = false;
}
@@ -3734,15 +3852,17 @@ unsigned GitClient::synchronousGitVersion(QString *errorMessage) const
}
GitClient::StashInfo::StashInfo() :
- m_client(GitPlugin::instance()->gitClient())
+ m_client(GitPlugin::instance()->gitClient()),
+ m_pushAction(NoPush)
{
}
bool GitClient::StashInfo::init(const QString &workingDirectory, const QString &command,
- StashFlag flag)
+ StashFlag flag, PushAction pushAction)
{
m_workingDir = workingDirectory;
m_flags = flag;
+ m_pushAction = pushAction;
QString errorMessage;
QString statusOutput;
switch (m_client->gitStatus(m_workingDir, StatusMode(NoUntracked | NoSubmodules),
@@ -3841,6 +3961,13 @@ void GitClient::StashInfo::end()
if (m_client->stashNameFromMessage(m_workingDir, m_message, &stashName))
m_client->stashPop(m_workingDir, stashName);
}
+
+ if (m_pushAction == NormalPush)
+ m_client->push(m_workingDir);
+ else if (m_pushAction == PushToGerrit)
+ GitPlugin::instance()->gerritPlugin()->push(m_workingDir);
+
+ m_pushAction = NoPush;
m_stashResult = NotStashed;
}
} // namespace Internal
diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h
index 382222680e..f1c9c00c41 100644
--- a/src/plugins/git/gitclient.h
+++ b/src/plugins/git/gitclient.h
@@ -31,6 +31,7 @@
#define GITCLIENT_H
#include "gitsettings.h"
+#include "commitdata.h"
#include <coreplugin/editormanager/ieditor.h>
@@ -110,7 +111,8 @@ public:
enum StashResult { StashUnchanged, StashCanceled, StashFailed,
Stashed, NotStashed /* User did not want it */ };
- bool init(const QString &workingDirectory, const QString &command, StashFlag flag = Default);
+ bool init(const QString &workingDirectory, const QString &command,
+ StashFlag flag = Default, PushAction pushAction = NoPush);
bool stashingFailed() const;
void end();
StashResult result() const { return m_stashResult; }
@@ -125,6 +127,7 @@ public:
QString m_workingDir;
GitClient *m_client;
StashFlag m_flags;
+ PushAction m_pushAction;
};
static const char *stashNamePrefix;
@@ -176,10 +179,12 @@ public:
QStringList files = QStringList(),
QString revision = QString(), QString *errorMessage = 0,
bool revertStaging = true);
- // Checkout branch
- bool synchronousCheckout(const QString &workingDirectory, const QString &ref, QString *errorMessage);
- bool synchronousCheckout(const QString &workingDirectory, const QString &ref)
- { return synchronousCheckout(workingDirectory, ref, 0); }
+ // Checkout ref
+ bool stashAndCheckout(const QString &workingDirectory, const QString &ref);
+ bool synchronousCheckout(const QString &workingDirectory, const QString &ref,
+ QString *errorMessage = 0);
+
+ QStringList setupCheckoutArguments(const QString &workingDirectory, const QString &ref);
void updateSubmodulesIfNeeded(const QString &workingDirectory, bool prompt);
// Do a stash and return identier.
@@ -232,21 +237,29 @@ public:
bool synchronousHeadRefs(const QString &workingDirectory, QStringList *output,
QString *errorMessage = 0);
QString synchronousTopic(const QString &workingDirectory);
+ bool synchronousRevParseCmd(const QString &workingDirectory, const QString &ref,
+ QString *output, QString *errorMessage = 0) const;
QString synchronousTopRevision(const QString &workingDirectory, QString *errorMessage = 0);
void synchronousTagsForCommit(const QString &workingDirectory, const QString &revision,
QString &precedes, QString &follows);
QStringList synchronousBranchesForCommit(const QString &workingDirectory,
const QString &revision);
bool isRemoteCommit(const QString &workingDirectory, const QString &commit);
+ bool isFastForwardMerge(const QString &workingDirectory, const QString &branch);
bool cloneRepository(const QString &directory, const QByteArray &url);
QString vcsGetRepositoryURL(const QString &directory);
void fetch(const QString &workingDirectory, const QString &remote);
bool synchronousPull(const QString &workingDirectory, bool rebase);
void push(const QString &workingDirectory, const QStringList &pushArgs = QStringList());
- bool synchronousMerge(const QString &workingDirectory, const QString &branch);
+ bool synchronousMerge(const QString &workingDirectory, const QString &branch,
+ bool allowFastForward = true);
bool canRebase(const QString &workingDirectory) const;
- void rebase(const QString &workingDirectory, const QString &baseBranch);
+ void rebase(const QString &workingDirectory, const QString &argument);
+ void cherryPick(const QString &workingDirectory, const QString &argument);
+ void revert(const QString &workingDirectory, const QString &argument);
+ void asyncCommand(const QString &workingDirectory, const QStringList &arguments,
+ bool hasProgress = false);
bool synchronousRevert(const QString &workingDirectory, const QString &commit);
bool synchronousCherryPick(const QString &workingDirectory, const QString &commit);
void interactiveRebase(const QString &workingDirectory, const QString &commit, bool fixup);
@@ -315,7 +328,8 @@ public:
QProcessEnvironment processEnvironment() const;
- bool beginStashScope(const QString &workingDirectory, const QString &command, StashFlag flag = Default);
+ bool beginStashScope(const QString &workingDirectory, const QString &command,
+ StashFlag flag = Default, PushAction pushAction = NoPush);
StashInfo &stashInfo(const QString &workingDirectory);
void endStashScope(const QString &workingDirectory);
bool isValidRevision(const QString &revision) const;
@@ -397,8 +411,7 @@ private:
bool tryLauchingGitK(const QProcessEnvironment &env,
const QString &workingDirectory,
const QString &fileName,
- const QString &gitBinDirectory,
- bool silent);
+ const QString &gitBinDirectory);
bool cleanList(const QString &workingDirectory, const QString &flag, QStringList *files, QString *errorMessage);
mutable QString m_gitVersionForBinary;
diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp
index c9b5552acb..c21b6166dd 100644
--- a/src/plugins/git/giteditor.cpp
+++ b/src/plugins/git/giteditor.cpp
@@ -278,9 +278,9 @@ void GitEditor::init()
VcsBase::VcsBaseEditorWidget::init();
Core::Id editorId = editor()->id();
if (editorId == Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID)
- new GitSubmitHighlighter(baseTextDocument().data());
+ new GitSubmitHighlighter(baseTextDocument());
else if (editorId == Git::Constants::GIT_REBASE_EDITOR_ID)
- new GitRebaseHighlighter(baseTextDocument().data());
+ new GitRebaseHighlighter(baseTextDocument());
}
void GitEditor::addDiffActions(QMenu *menu, const VcsBase::DiffChunk &chunk)
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index 1d148ec0ba..81d1816d75 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -60,6 +60,7 @@
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/vcsmanager.h>
+#include <coreplugin/coreconstants.h>
#include <utils/qtcassert.h>
#include <utils/parameteraction.h>
@@ -70,7 +71,7 @@
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <vcsbase/cleandialog.h>
-#include <locator/commandlocator.h>
+#include <coreplugin/locator/commandlocator.h>
#include <QDebug>
#include <QDir>
@@ -297,7 +298,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
addAutoReleasedObject(new Gitorious::Internal::GitoriousCloneWizard);
const QString prefix = QLatin1String("git");
- m_commandLocator = new Locator::CommandLocator("Git", prefix, prefix);
+ m_commandLocator = new Core::CommandLocator("Git", prefix, prefix);
addAutoReleasedObject(m_commandLocator);
//register actions
@@ -802,6 +803,33 @@ void GitPlugin::undoUnstagedFileChanges()
undoFileChanges(false);
}
+class ResetItemDelegate : public LogItemDelegate
+{
+public:
+ ResetItemDelegate(LogChangeWidget *widget) : LogItemDelegate(widget) {}
+ void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const
+ {
+ if (index.row() < currentRow())
+ option->font.setStrikeOut(true);
+ LogItemDelegate::initStyleOption(option, index);
+ }
+};
+
+class RebaseItemDelegate : public IconItemDelegate
+{
+public:
+ RebaseItemDelegate(LogChangeWidget *widget)
+ : IconItemDelegate(widget, QLatin1String(Core::Constants::ICON_UNDO))
+ {
+ }
+
+protected:
+ bool hasIcon(int row) const
+ {
+ return row <= currentRow();
+ }
+};
+
void GitPlugin::resetRepository()
{
if (!ensureAllDocumentsSaved())
@@ -811,6 +839,7 @@ void GitPlugin::resetRepository()
QString topLevel = state.topLevel();
LogChangeDialog dialog(true, Core::ICore::mainWindow());
+ ResetItemDelegate delegate(dialog.widget());
dialog.setWindowTitle(tr("Undo Changes to %1").arg(QDir::toNativeSeparators(topLevel)));
if (dialog.runDialog(topLevel))
m_gitClient->reset(topLevel, dialog.resetFlag(), dialog.commit());
@@ -825,14 +854,13 @@ void GitPlugin::startRebase()
const QString topLevel = state.topLevel();
if (topLevel.isEmpty() || !m_gitClient->canRebase(topLevel))
return;
- if (!m_gitClient->beginStashScope(topLevel, QLatin1String("Rebase-i")))
- return;
LogChangeDialog dialog(false, Core::ICore::mainWindow());
+ RebaseItemDelegate delegate(dialog.widget());
dialog.setWindowTitle(tr("Interactive Rebase"));
- if (dialog.runDialog(topLevel, QString(), false))
+ if (!dialog.runDialog(topLevel, QString(), false))
+ return;
+ if (m_gitClient->beginStashScope(topLevel, QLatin1String("Rebase-i")))
m_gitClient->interactiveRebase(topLevel, dialog.commit(), false);
- else
- m_gitClient->endStashScope(topLevel);
}
void GitPlugin::startChangeRelatedAction()
@@ -863,24 +891,20 @@ void GitPlugin::startChangeRelatedAction()
if (!ensureAllDocumentsSaved())
return;
- bool (GitClient::*commandFunction)(const QString&, const QString&);
+
switch (dialog.command()) {
case CherryPick:
- commandFunction = &GitClient::synchronousCherryPick;
+ m_gitClient->synchronousCherryPick(workingDirectory, change);
break;
case Revert:
- commandFunction = &GitClient::synchronousRevert;
+ m_gitClient->synchronousRevert(workingDirectory, change);
break;
case Checkout:
- if (!m_gitClient->beginStashScope(workingDirectory, QLatin1String("Checkout")))
- return;
- commandFunction = &GitClient::synchronousCheckout;
+ m_gitClient->stashAndCheckout(workingDirectory, QLatin1String("Checkout"));
break;
default:
return;
}
-
- (m_gitClient->*commandFunction)(workingDirectory, change);
}
void GitPlugin::stageFile()
@@ -1103,8 +1127,10 @@ bool GitPlugin::submitEditorAboutToClose()
return false;
cleanCommitMessageFile();
if (commitType == FixupCommit) {
- if (!m_gitClient->beginStashScope(m_submitRepository, QLatin1String("Rebase-fixup"), NoPrompt))
+ if (!m_gitClient->beginStashScope(m_submitRepository, QLatin1String("Rebase-fixup"),
+ NoPrompt, editor->panelData().pushAction)) {
return false;
+ }
m_gitClient->interactiveRebase(m_submitRepository, amendSHA1, true);
} else {
m_gitClient->continueCommandIfNeeded(m_submitRepository);
@@ -1178,9 +1204,9 @@ void GitPlugin::continueOrAbortCommand()
else if (action == m_continueRebaseAction)
m_gitClient->rebase(state.topLevel(), QLatin1String("--continue"));
else if (action == m_continueCherryPickAction)
- m_gitClient->synchronousCherryPick(state.topLevel(), QLatin1String("--continue"));
+ m_gitClient->cherryPick(state.topLevel(), QLatin1String("--continue"));
else if (action == m_continueRevertAction)
- m_gitClient->synchronousRevert(state.topLevel(), QLatin1String("--continue"));
+ m_gitClient->revert(state.topLevel(), QLatin1String("--continue"));
updateContinueAndAbortCommands();
}
@@ -1477,6 +1503,11 @@ GitClient *GitPlugin::gitClient() const
return m_gitClient;
}
+Gerrit::Internal::GerritPlugin *GitPlugin::gerritPlugin() const
+{
+ return m_gerritPlugin;
+}
+
#ifdef WITH_TESTS
#include <QTest>
diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h
index 5a0467717f..27e3292630 100644
--- a/src/plugins/git/gitplugin.h
+++ b/src/plugins/git/gitplugin.h
@@ -49,6 +49,7 @@ namespace Core {
class IEditor;
class IEditorFactory;
class Command;
+class CommandLocator;
class Context;
class ActionManager;
class ActionContainer;
@@ -56,9 +57,6 @@ class ActionContainer;
namespace Utils {
class ParameterAction;
}
-namespace Locator {
- class CommandLocator;
-}
namespace Gerrit {
namespace Internal {
class GerritPlugin;
@@ -99,6 +97,7 @@ public:
void setSettings(const GitSettings &s);
GitClient *gitClient() const;
+ Gerrit::Internal::GerritPlugin *gerritPlugin() const;
public slots:
void startCommit();
@@ -205,7 +204,7 @@ private:
void updateVersionWarning();
static GitPlugin *m_instance;
- Locator::CommandLocator *m_commandLocator;
+ Core::CommandLocator *m_commandLocator;
QAction *m_submitCurrentAction;
QAction *m_diffSelectedFilesAction;
diff --git a/src/plugins/git/gitsubmiteditorwidget.cpp b/src/plugins/git/gitsubmiteditorwidget.cpp
index a44e1ae578..3102bd270a 100644
--- a/src/plugins/git/gitsubmiteditorwidget.cpp
+++ b/src/plugins/git/gitsubmiteditorwidget.cpp
@@ -109,7 +109,7 @@ void GitSubmitEditorWidget::initialize(CommitType commitType,
setPanelData(data);
setPanelInfo(info);
- if (enablePush && commitType != FixupCommit) {
+ if (enablePush) {
QMenu *menu = new QMenu(this);
menu->addAction(tr("&Commit only"), this, SLOT(commitOnlySlot()));
menu->addAction(tr("Commit and &Push"), this, SLOT(commitAndPushSlot()));
diff --git a/src/plugins/git/images/arrowup.png b/src/plugins/git/images/arrowup.png
new file mode 100644
index 0000000000..5cdbc6ed9e
--- /dev/null
+++ b/src/plugins/git/images/arrowup.png
Binary files differ
diff --git a/src/plugins/git/logchangedialog.cpp b/src/plugins/git/logchangedialog.cpp
index cdc42a3863..30cf2bb080 100644
--- a/src/plugins/git/logchangedialog.cpp
+++ b/src/plugins/git/logchangedialog.cpp
@@ -33,6 +33,8 @@
#include <vcsbase/vcsbaseoutputwindow.h>
+#include <utils/qtcassert.h>
+
#include <QTreeView>
#include <QLabel>
#include <QPushButton>
@@ -41,6 +43,7 @@
#include <QItemSelectionModel>
#include <QVBoxLayout>
#include <QComboBox>
+#include <QPainter>
namespace Git {
namespace Internal {
@@ -55,6 +58,7 @@ enum Columns
LogChangeWidget::LogChangeWidget(QWidget *parent)
: QTreeView(parent)
, m_model(new QStandardItemModel(0, ColumnCount, this))
+ , m_hasCustomDelegate(false)
{
QStringList headers;
headers << tr("Sha1")<< tr("Subject");
@@ -104,6 +108,12 @@ QString LogChangeWidget::earliestCommit() const
return QString();
}
+void LogChangeWidget::setItemDelegate(QAbstractItemDelegate *delegate)
+{
+ QTreeView::setItemDelegate(delegate);
+ m_hasCustomDelegate = true;
+}
+
void LogChangeWidget::emitDoubleClicked(const QModelIndex &index)
{
if (index.isValid()) {
@@ -113,6 +123,26 @@ void LogChangeWidget::emitDoubleClicked(const QModelIndex &index)
}
}
+void LogChangeWidget::selectionChanged(const QItemSelection &selected,
+ const QItemSelection &deselected)
+{
+ QTreeView::selectionChanged(selected, deselected);
+ if (!m_hasCustomDelegate)
+ return;
+ const QModelIndexList previousIndexes = deselected.indexes();
+ if (previousIndexes.isEmpty())
+ return;
+ const QModelIndex current = currentIndex();
+ int row = current.row();
+ int previousRow = previousIndexes.first().row();
+ if (row < previousRow)
+ qSwap(row, previousRow);
+ for (int r = previousRow; r <= row; ++r) {
+ update(current.sibling(r, 0));
+ update(current.sibling(r, 1));
+ }
+}
+
bool LogChangeWidget::populateLog(const QString &repository, const QString &commit, bool includeRemote)
{
const QString currentCommit = this->commit();
@@ -234,5 +264,40 @@ QString LogChangeDialog::resetFlag() const
return m_resetTypeComboBox->itemData(m_resetTypeComboBox->currentIndex()).toString();
}
+LogChangeWidget *LogChangeDialog::widget() const
+{
+ return m_widget;
+}
+
+LogItemDelegate::LogItemDelegate(LogChangeWidget *widget) : m_widget(widget)
+{
+ m_widget->setItemDelegate(this);
+}
+
+int LogItemDelegate::currentRow() const
+{
+ return m_widget->commitIndex();
+}
+
+IconItemDelegate::IconItemDelegate(LogChangeWidget *widget, const QString &icon)
+ : LogItemDelegate(widget)
+ , m_icon(icon)
+{
+}
+
+void IconItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ QStyleOptionViewItem o = option;
+ if (index.column() == 0 && hasIcon(index.row())) {
+ const QSize size = option.decorationSize;
+ painter->save();
+ painter->drawPixmap(o.rect.x(), o.rect.y(), m_icon.pixmap(size.width(), size.height()));
+ painter->restore();
+ o.rect.translate(size.width(), 0);
+ }
+ QStyledItemDelegate::paint(painter, o, index);
+}
+
} // namespace Internal
} // namespace Git
diff --git a/src/plugins/git/logchangedialog.h b/src/plugins/git/logchangedialog.h
index 1c83cfce7a..603a7ff962 100644
--- a/src/plugins/git/logchangedialog.h
+++ b/src/plugins/git/logchangedialog.h
@@ -31,6 +31,8 @@
#define LOGCHANGEDDIALOG_H
#include <QDialog>
+#include <QIcon>
+#include <QStyledItemDelegate>
#include <QTreeView>
QT_BEGIN_NAMESPACE
@@ -57,6 +59,7 @@ public:
QString commit() const;
int commitIndex() const;
QString earliestCommit() const;
+ void setItemDelegate(QAbstractItemDelegate *delegate);
signals:
void doubleClicked(const QString &commit);
@@ -65,10 +68,12 @@ private slots:
void emitDoubleClicked(const QModelIndex &index);
private:
+ void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
bool populateLog(const QString &repository, const QString &commit, bool includeRemote);
const QStandardItem *currentItem(int column = 0) const;
QStandardItemModel *m_model;
+ bool m_hasCustomDelegate;
};
class LogChangeDialog : public QDialog
@@ -83,6 +88,7 @@ public:
QString commit() const;
int commitIndex() const;
QString resetFlag() const;
+ LogChangeWidget *widget() const;
private:
LogChangeWidget *m_widget;
@@ -90,6 +96,31 @@ private:
QComboBox *m_resetTypeComboBox;
};
+class LogItemDelegate : public QStyledItemDelegate
+{
+protected:
+ LogItemDelegate(LogChangeWidget *widget);
+
+ int currentRow() const;
+
+private:
+ LogChangeWidget *m_widget;
+};
+
+class IconItemDelegate : public LogItemDelegate
+{
+public:
+ IconItemDelegate(LogChangeWidget *widget, const QString &icon);
+
+ virtual bool hasIcon(int row) const = 0;
+
+ void paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+
+private:
+ QIcon m_icon;
+};
+
} // namespace Internal
} // namespace Git
diff --git a/src/plugins/git/settingspage.cpp b/src/plugins/git/settingspage.cpp
index 339d353ce8..2b7d187b3a 100644
--- a/src/plugins/git/settingspage.cpp
+++ b/src/plugins/git/settingspage.cpp
@@ -61,6 +61,7 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
m_ui.winHomeCheckBox->setVisible(false);
}
m_ui.repBrowserCommandPathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
+ m_ui.repBrowserCommandPathChooser->setHistoryCompleter(QLatin1String("Git.RepoCommand.History"));
m_ui.repBrowserCommandPathChooser->setPromptDialogTitle(tr("Git Repository Browser Command"));
}
@@ -90,25 +91,6 @@ void SettingsPageWidget::setSettings(const GitSettings &s)
m_ui.repBrowserCommandPathChooser->setPath(s.stringValue(GitSettings::repositoryBrowserCmd));
}
-QString SettingsPageWidget::searchKeywords() const
-{
- QString rc;
- QLatin1Char sep(' ');
- QTextStream(&rc)
- << sep << m_ui.pathlabel->text()
- << sep << m_ui.winHomeCheckBox->text()
- << sep << m_ui.groupBox->title()
- << sep << m_ui.logCountLabel->text()
- << sep << m_ui.timeoutLabel->text()
- << sep << m_ui.gitkGroupBox->title()
- << sep << m_ui.gitkOptionsLabel->text()
- << sep << m_ui.repBrowserGroupBox->title()
- << sep << m_ui.repBrowserCommandLabel->text()
- ;
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
// -------- SettingsPage
SettingsPage::SettingsPage() :
m_widget(0)
@@ -117,12 +99,12 @@ SettingsPage::SettingsPage() :
setDisplayName(tr("Git"));
}
-QWidget *SettingsPage::createPage(QWidget *parent)
+QWidget *SettingsPage::widget()
{
- m_widget = new SettingsPageWidget(parent);
- m_widget->setSettings(GitPlugin::instance()->settings());
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new SettingsPageWidget;
+ m_widget->setSettings(GitPlugin::instance()->settings());
+ }
return m_widget;
}
@@ -141,9 +123,9 @@ void SettingsPage::apply()
GitPlugin::instance()->setSettings(newSettings);
}
-bool SettingsPage::matches(const QString &s) const
+void SettingsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
}
diff --git a/src/plugins/git/settingspage.h b/src/plugins/git/settingspage.h
index 7386d85dda..f2ca8dc396 100644
--- a/src/plugins/git/settingspage.h
+++ b/src/plugins/git/settingspage.h
@@ -30,12 +30,13 @@
#ifndef SETTINGSPAGE_H
#define SETTINGSPAGE_H
-#include <QWidget>
-
#include <vcsbase/vcsbaseoptionspage.h>
#include "ui_settingspage.h"
+#include <QPointer>
+#include <QWidget>
+
QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE
@@ -53,8 +54,6 @@ public:
GitSettings settings() const;
void setSettings(const GitSettings &);
- QString searchKeywords() const;
-
private:
Ui::SettingsPage m_ui;
};
@@ -66,14 +65,13 @@ class SettingsPage : public VcsBase::VcsBaseOptionsPage
public:
SettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &) const;
+ void finish();
private:
QString m_searchKeywords;
- SettingsPageWidget* m_widget;
+ QPointer<SettingsPageWidget> m_widget;
};
} // namespace Internal
diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp
index 67ff3afd33..ad829c4780 100644
--- a/src/plugins/glsleditor/glsleditor.cpp
+++ b/src/plugins/glsleditor/glsleditor.cpp
@@ -140,10 +140,21 @@ void Document::addRange(const QTextCursor &cursor, GLSL::Scope *scope)
_cursors.append(c);
}
-GLSLTextEditorWidget::GLSLTextEditorWidget(QWidget *parent) :
- TextEditor::BaseTextEditorWidget(parent),
- m_outlineCombo(0)
+GLSLTextEditorWidget::GLSLTextEditorWidget(QWidget *parent)
+ : TextEditor::BaseTextEditorWidget(parent)
{
+ ctor();
+}
+
+GLSLTextEditorWidget::GLSLTextEditorWidget(GLSLTextEditorWidget *other)
+ : TextEditor::BaseTextEditorWidget(other)
+{
+ ctor();
+}
+
+void GLSLTextEditorWidget::ctor()
+{
+ m_outlineCombo = 0;
setParenthesesMatchingEnabled(true);
setMarksVisible(true);
setCodeFoldingSupported(true);
@@ -157,7 +168,7 @@ GLSLTextEditorWidget::GLSLTextEditorWidget(QWidget *parent) :
connect(this, SIGNAL(textChanged()), this, SLOT(updateDocument()));
- new Highlighter(baseTextDocument().data());
+ new Highlighter(baseTextDocument());
// if (m_modelManager) {
// m_semanticHighlighter->setModelManager(m_modelManager);
@@ -187,11 +198,11 @@ bool GLSLTextEditorWidget::isOutdated() const
return false;
}
-Core::IEditor *GLSLEditorEditable::duplicate(QWidget *parent)
+Core::IEditor *GLSLEditorEditable::duplicate()
{
- GLSLTextEditorWidget *newEditor = new GLSLTextEditorWidget(parent);
- newEditor->duplicateFrom(editorWidget());
- GLSLEditorPlugin::initializeEditor(newEditor);
+ GLSLTextEditorWidget *newEditor = new GLSLTextEditorWidget(
+ qobject_cast<GLSLTextEditorWidget *>(editorWidget()));
+ TextEditor::TextEditorSettings::initializeEditor(newEditor);
return newEditor->editor();
}
@@ -202,7 +213,7 @@ Core::Id GLSLEditorEditable::id() const
bool GLSLEditorEditable::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
- editorWidget()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
+ baseTextDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
bool b = TextEditor::BaseTextEditor::open(errorString, fileName, realFileName);
return b;
}
@@ -270,7 +281,7 @@ void GLSLTextEditorWidget::updateDocumentNow()
{
m_updateDocumentTimer->stop();
- int variant = languageVariant(mimeType());
+ int variant = languageVariant(baseTextDocument()->mimeType());
const QString contents = toPlainText(); // get the code from the editor
const QByteArray preprocessedCode = contents.toLatin1(); // ### use the QtCreator C++ preprocessor.
@@ -378,7 +389,7 @@ TextEditor::IAssistInterface *GLSLTextEditorWidget::createAssistInterface(
position(),
editor()->document()->filePath(),
reason,
- mimeType(),
+ baseTextDocument()->mimeType(),
m_glslDocument);
return BaseTextEditorWidget::createAssistInterface(kind, reason);
}
diff --git a/src/plugins/glsleditor/glsleditor.h b/src/plugins/glsleditor/glsleditor.h
index 5d1b9306a9..831b6e7d04 100644
--- a/src/plugins/glsleditor/glsleditor.h
+++ b/src/plugins/glsleditor/glsleditor.h
@@ -87,6 +87,7 @@ class GLSLTextEditorWidget : public TextEditor::BaseTextEditorWidget
public:
GLSLTextEditorWidget(QWidget *parent = 0);
+ GLSLTextEditorWidget(GLSLTextEditorWidget *other);
~GLSLTextEditorWidget();
virtual void unCommentSelection();
@@ -110,6 +111,8 @@ protected:
void createToolBar(Internal::GLSLEditorEditable *editable);
private:
+ GLSLTextEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
+ void ctor();
void setSelectedElements();
QString wordUnderCursor() const;
diff --git a/src/plugins/glsleditor/glsleditoreditable.h b/src/plugins/glsleditor/glsleditoreditable.h
index f4fec5744c..8632c64fa9 100644
--- a/src/plugins/glsleditor/glsleditoreditable.h
+++ b/src/plugins/glsleditor/glsleditoreditable.h
@@ -45,7 +45,7 @@ public:
explicit GLSLEditorEditable(GLSLTextEditorWidget *);
bool duplicateSupported() const { return true; }
- Core::IEditor *duplicate(QWidget *parent);
+ Core::IEditor *duplicate();
Core::Id id() const;
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
TextEditor::CompletionAssistProvider *completionAssistProvider();
diff --git a/src/plugins/glsleditor/glsleditorfactory.cpp b/src/plugins/glsleditor/glsleditorfactory.cpp
index 889db06caa..502d2dd3ef 100644
--- a/src/plugins/glsleditor/glsleditorfactory.cpp
+++ b/src/plugins/glsleditor/glsleditorfactory.cpp
@@ -37,6 +37,8 @@
#include <extensionsystem/pluginspec.h>
#include <coreplugin/icore.h>
+#include <texteditor/texteditoractionhandler.h>
+#include <texteditor/texteditorsettings.h>
#include <QCoreApplication>
#include <QSettings>
@@ -54,12 +56,17 @@ GLSLEditorFactory::GLSLEditorFactory(QObject *parent)
addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG);
addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_VERT_ES);
addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG_ES);
+ new TextEditor::TextEditorActionHandler(this, Constants::C_GLSLEDITOR_ID,
+ TextEditor::TextEditorActionHandler::Format
+ | TextEditor::TextEditorActionHandler::UnCommentSelection
+ | TextEditor::TextEditorActionHandler::UnCollapseAll);
+
}
-Core::IEditor *GLSLEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *GLSLEditorFactory::createEditor()
{
- GLSLTextEditorWidget *rc = new GLSLTextEditorWidget(parent);
- GLSLEditorPlugin::initializeEditor(rc);
+ GLSLTextEditorWidget *rc = new GLSLTextEditorWidget();
+ TextEditor::TextEditorSettings::initializeEditor(rc);
return rc->editor();
}
diff --git a/src/plugins/glsleditor/glsleditorfactory.h b/src/plugins/glsleditor/glsleditorfactory.h
index d36f8d459a..01a507b748 100644
--- a/src/plugins/glsleditor/glsleditorfactory.h
+++ b/src/plugins/glsleditor/glsleditorfactory.h
@@ -42,7 +42,7 @@ class GLSLEditorFactory : public Core::IEditorFactory
public:
GLSLEditorFactory(QObject *parent);
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
private slots:
void updateEditorInfoBar(Core::IEditor *editor);
diff --git a/src/plugins/glsleditor/glsleditorplugin.cpp b/src/plugins/glsleditor/glsleditorplugin.cpp
index a9544e9ef5..815689cb51 100644
--- a/src/plugins/glsleditor/glsleditorplugin.cpp
+++ b/src/plugins/glsleditor/glsleditorplugin.cpp
@@ -48,9 +48,7 @@
#include <projectexplorer/taskhub.h>
#include <extensionsystem/pluginmanager.h>
#include <texteditor/texteditorconstants.h>
-#include <texteditor/texteditorsettings.h>
#include <texteditor/textfilewizard.h>
-#include <texteditor/texteditoractionhandler.h>
#include <utils/qtcassert.h>
#include <glsl/glslengine.h>
@@ -77,7 +75,6 @@ class GLSLEditorPluginPrivate
public:
GLSLEditorPluginPrivate() :
m_editor(0),
- m_actionHandler(0),
m_glsl_120_frag(0),
m_glsl_120_vert(0),
m_glsl_120_common(0),
@@ -88,7 +85,6 @@ public:
~GLSLEditorPluginPrivate()
{
- delete m_actionHandler;
delete m_glsl_120_frag;
delete m_glsl_120_vert;
delete m_glsl_120_common;
@@ -98,7 +94,6 @@ public:
}
GLSLEditorFactory *m_editor;
- TextEditor::TextEditorActionHandler *m_actionHandler;
QPointer<TextEditor::ITextEditor> m_currentTextEditable;
GLSLEditorPlugin::InitFile *m_glsl_120_frag;
@@ -145,12 +140,6 @@ bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er
addAutoReleasedObject(new GLSLCompletionAssistProvider);
- dd->m_actionHandler = new TextEditorActionHandler(Constants::C_GLSLEDITOR_ID,
- TextEditorActionHandler::Format
- | TextEditorActionHandler::UnCommentSelection
- | TextEditorActionHandler::UnCollapseAll);
- dd->m_actionHandler->initializeActions();
-
ActionContainer *contextMenu = ActionManager::createMenu(GLSLEditor::Constants::M_CONTEXT);
ActionContainer *glslToolsMenu = ActionManager::createMenu(Id(Constants::M_TOOLS_GLSL));
glslToolsMenu->setOnAllDisabledBehavior(ActionContainer::Hide);
@@ -245,13 +234,6 @@ ExtensionSystem::IPlugin::ShutdownFlag GLSLEditorPlugin::aboutToShutdown()
return IPlugin::aboutToShutdown();
}
-void GLSLEditorPlugin::initializeEditor(GLSLTextEditorWidget *editor)
-{
- QTC_CHECK(m_instance);
- dd->m_actionHandler->setupActions(editor);
- TextEditorSettings::initializeEditor(editor);
-}
-
static QByteArray glslFile(const QString &fileName)
{
QFile file(ICore::resourcePath() + QLatin1String("/glsl/") + fileName);
diff --git a/src/plugins/glsleditor/glsleditorplugin.h b/src/plugins/glsleditor/glsleditorplugin.h
index c9627e8501..d4fae86c25 100644
--- a/src/plugins/glsleditor/glsleditorplugin.h
+++ b/src/plugins/glsleditor/glsleditorplugin.h
@@ -52,8 +52,6 @@ public:
void extensionsInitialized();
ShutdownFlag aboutToShutdown();
- static void initializeEditor(GLSLTextEditorWidget *editor);
-
struct InitFile
{
InitFile(GLSL::Engine *engine = 0, GLSL::TranslationUnitAST *ast = 0)
diff --git a/src/plugins/help/centralwidget.cpp b/src/plugins/help/centralwidget.cpp
index b99ba69487..7480831ed9 100644
--- a/src/plugins/help/centralwidget.cpp
+++ b/src/plugins/help/centralwidget.cpp
@@ -152,7 +152,7 @@ void CentralWidget::setCurrentPage(HelpViewer *page)
m_stackedWidget->setCurrentWidget(page);
}
-bool CentralWidget::find(const QString &txt, Find::FindFlags flags,
+bool CentralWidget::find(const QString &txt, Core::FindFlags flags,
bool incremental, bool *wrapped)
{
return currentHelpViewer()->findText(txt, flags, incremental, false, wrapped);
diff --git a/src/plugins/help/centralwidget.h b/src/plugins/help/centralwidget.h
index a260eb2326..be8d5abf01 100644
--- a/src/plugins/help/centralwidget.h
+++ b/src/plugins/help/centralwidget.h
@@ -30,7 +30,7 @@
#ifndef CENTRALWIDGET_H
#define CENTRALWIDGET_H
-#include <find/ifindsupport.h>
+#include <coreplugin/find/ifindsupport.h>
#include <QWidget>
@@ -68,7 +68,7 @@ public:
int currentIndex() const;
void setCurrentPage(HelpViewer *page);
- bool find(const QString &txt, Find::FindFlags findFlags,
+ bool find(const QString &txt, Core::FindFlags findFlags,
bool incremental, bool *wrapped = 0);
public slots:
diff --git a/src/plugins/help/docsettingspage.cpp b/src/plugins/help/docsettingspage.cpp
index 9c2bdcb83f..17cb777306 100644
--- a/src/plugins/help/docsettingspage.cpp
+++ b/src/plugins/help/docsettingspage.cpp
@@ -50,27 +50,26 @@ DocSettingsPage::DocSettingsPage()
setCategoryIcon(QLatin1String(Help::Constants::HELP_CATEGORY_ICON));
}
-QWidget *DocSettingsPage::createPage(QWidget *parent)
+QWidget *DocSettingsPage::widget()
{
- QWidget *widget = new QWidget(parent);
- m_ui.setupUi(widget);
+ if (!m_widget) {
+ m_widget = new QWidget;
+ m_ui.setupUi(m_widget);
- connect(m_ui.addButton, SIGNAL(clicked()), this, SLOT(addDocumentation()));
- connect(m_ui.removeButton, SIGNAL(clicked()), this, SLOT(removeDocumentation()));
+ connect(m_ui.addButton, SIGNAL(clicked()), this, SLOT(addDocumentation()));
+ connect(m_ui.removeButton, SIGNAL(clicked()), this, SLOT(removeDocumentation()));
- m_ui.docsListWidget->installEventFilter(this);
+ m_ui.docsListWidget->installEventFilter(this);
- const QStringList nameSpaces = HelpManager::registeredNamespaces();
- foreach (const QString &nameSpace, nameSpaces) {
- addItem(nameSpace, HelpManager::fileFromNamespace(nameSpace));
- m_filesToRegister.insert(nameSpace, HelpManager::fileFromNamespace(nameSpace));
- }
-
- m_filesToUnregister.clear();
+ const QStringList nameSpaces = HelpManager::registeredNamespaces();
+ foreach (const QString &nameSpace, nameSpaces) {
+ addItem(nameSpace, HelpManager::fileFromNamespace(nameSpace));
+ m_filesToRegister.insert(nameSpace, HelpManager::fileFromNamespace(nameSpace));
+ }
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_ui.groupBox->title();
- return widget;
+ m_filesToUnregister.clear();
+ }
+ return m_widget;
}
void DocSettingsPage::addDocumentation()
@@ -155,9 +154,9 @@ void DocSettingsPage::apply()
m_filesToUnregister.clear();
}
-bool DocSettingsPage::matches(const QString &s) const
+void DocSettingsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
bool DocSettingsPage::eventFilter(QObject *object, QEvent *event)
diff --git a/src/plugins/help/docsettingspage.h b/src/plugins/help/docsettingspage.h
index cb3db51ac4..64e884e1fc 100644
--- a/src/plugins/help/docsettingspage.h
+++ b/src/plugins/help/docsettingspage.h
@@ -33,6 +33,8 @@
#include "ui_docsettingspage.h"
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
namespace Help {
namespace Internal {
@@ -43,10 +45,9 @@ class DocSettingsPage : public Core::IOptionsPage
public:
DocSettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() {}
- bool matches(const QString &s) const;
+ void finish();
private slots:
void addDocumentation();
@@ -59,8 +60,8 @@ private:
private:
Ui::DocSettingsPage m_ui;
+ QPointer<QWidget> m_widget;
- QString m_searchKeywords;
QString m_recentDialogPath;
typedef QHash<QString, QString> NameSpaceToPathHash;
diff --git a/src/plugins/help/filtersettingspage.cpp b/src/plugins/help/filtersettingspage.cpp
index 7606f32c38..b653ea2558 100644
--- a/src/plugins/help/filtersettingspage.cpp
+++ b/src/plugins/help/filtersettingspage.cpp
@@ -51,29 +51,26 @@ FilterSettingsPage::FilterSettingsPage()
setCategoryIcon(QLatin1String(Help::Constants::HELP_CATEGORY_ICON));
}
-QWidget *FilterSettingsPage::createPage(QWidget *parent)
+QWidget *FilterSettingsPage::widget()
{
- QWidget *widget = new QWidget(parent);
- m_ui.setupUi(widget);
-
- updateFilterPage();
-
- connect(m_ui.attributeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
- this, SLOT(updateFilterMap()));
- connect(m_ui.filterWidget,
- SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this,
- SLOT(updateAttributes(QListWidgetItem*)));
- connect(m_ui.filterAddButton, SIGNAL(clicked()), this, SLOT(addFilter()));
- connect(m_ui.filterRemoveButton, SIGNAL(clicked()), this,
- SLOT(removeFilter()));
- connect(HelpManager::instance(), SIGNAL(documentationChanged()),
- this, SLOT(updateFilterPage()));
-
- if (m_searchKeywords.isEmpty()) {
- m_searchKeywords = m_ui.filterGroupBox->title() + QLatin1Char(' ')
- + m_ui.attributesGroupBox->title();
+ if (!m_widget) {
+ m_widget = new QWidget;
+ m_ui.setupUi(m_widget);
+
+ updateFilterPage();
+
+ connect(m_ui.attributeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
+ this, SLOT(updateFilterMap()));
+ connect(m_ui.filterWidget,
+ SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this,
+ SLOT(updateAttributes(QListWidgetItem*)));
+ connect(m_ui.filterAddButton, SIGNAL(clicked()), this, SLOT(addFilter()));
+ connect(m_ui.filterRemoveButton, SIGNAL(clicked()), this,
+ SLOT(removeFilter()));
+ connect(HelpManager::instance(), SIGNAL(documentationChanged()),
+ this, SLOT(updateFilterPage()));
}
- return widget;
+ return m_widget;
}
void FilterSettingsPage::updateFilterPage()
@@ -230,11 +227,7 @@ void FilterSettingsPage::finish()
{
disconnect(HelpManager::instance(), SIGNAL(documentationChanged()),
this, SLOT(updateFilterPage()));
-}
-
-bool FilterSettingsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
QString FilterSettingsPage::msgFilterLabel(const QString &filter) const
diff --git a/src/plugins/help/filtersettingspage.h b/src/plugins/help/filtersettingspage.h
index cc0ef99bc0..6574c4ac42 100644
--- a/src/plugins/help/filtersettingspage.h
+++ b/src/plugins/help/filtersettingspage.h
@@ -33,6 +33,8 @@
#include "ui_filtersettingspage.h"
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
namespace Help {
namespace Internal {
@@ -43,10 +45,9 @@ class FilterSettingsPage : public Core::IOptionsPage
public:
FilterSettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &s) const;
signals:
void filtersChanged();
@@ -64,12 +65,12 @@ private:
private:
QString msgFilterLabel(const QString &filter) const;
Ui::FilterSettingsPage m_ui;
+ QPointer<QWidget> m_widget;
typedef QMap<QString, QStringList> FilterMap;
FilterMap m_filterMap;
FilterMap m_filterMapBackup;
- QString m_searchKeywords;
QStringList m_removedFilters;
};
diff --git a/src/plugins/help/generalsettingspage.cpp b/src/plugins/help/generalsettingspage.cpp
index 39e495c96f..e687ed0cc0 100644
--- a/src/plugins/help/generalsettingspage.cpp
+++ b/src/plugins/help/generalsettingspage.cpp
@@ -72,59 +72,54 @@ GeneralSettingsPage::GeneralSettingsPage()
setCategoryIcon(QLatin1String(Help::Constants::HELP_CATEGORY_ICON));
}
-QWidget *GeneralSettingsPage::createPage(QWidget *parent)
+QWidget *GeneralSettingsPage::widget()
{
- QWidget *widget = new QWidget(parent);
- m_ui = new Ui::GeneralSettingsPage;
- m_ui->setupUi(widget);
- m_ui->sizeComboBox->setEditable(false);
- m_ui->styleComboBox->setEditable(false);
-
- m_font = qvariant_cast<QFont>(HelpManager::customValue(QLatin1String("font"), m_font));
-
- updateFontSize();
- updateFontStyle();
- updateFontFamily();
-
- m_homePage = HelpManager::customValue(QLatin1String("HomePage"), QString())
- .toString();
- if (m_homePage.isEmpty()) {
- m_homePage = HelpManager::customValue(QLatin1String("DefaultHomePage"),
- Help::Constants::AboutBlank).toString();
- }
- m_ui->homePageLineEdit->setText(m_homePage);
+ if (!m_widget) {
+ m_widget = new QWidget;
+ m_ui = new Ui::GeneralSettingsPage;
+ m_ui->setupUi(m_widget);
+ m_ui->sizeComboBox->setEditable(false);
+ m_ui->styleComboBox->setEditable(false);
+
+ m_font = qvariant_cast<QFont>(HelpManager::customValue(QLatin1String("font"), m_font));
+
+ updateFontSize();
+ updateFontStyle();
+ updateFontFamily();
+
+ m_homePage = HelpManager::customValue(QLatin1String("HomePage"), QString())
+ .toString();
+ if (m_homePage.isEmpty()) {
+ m_homePage = HelpManager::customValue(QLatin1String("DefaultHomePage"),
+ Help::Constants::AboutBlank).toString();
+ }
+ m_ui->homePageLineEdit->setText(m_homePage);
- m_startOption = HelpManager::customValue(QLatin1String("StartOption"),
- Help::Constants::ShowLastPages).toInt();
- m_ui->helpStartComboBox->setCurrentIndex(m_startOption);
+ m_startOption = HelpManager::customValue(QLatin1String("StartOption"),
+ Help::Constants::ShowLastPages).toInt();
+ m_ui->helpStartComboBox->setCurrentIndex(m_startOption);
- m_contextOption = HelpManager::customValue(QLatin1String("ContextHelpOption"),
- Help::Constants::SideBySideIfPossible).toInt();
- m_ui->contextHelpComboBox->setCurrentIndex(m_contextOption);
+ m_contextOption = HelpManager::customValue(QLatin1String("ContextHelpOption"),
+ Help::Constants::SideBySideIfPossible).toInt();
+ m_ui->contextHelpComboBox->setCurrentIndex(m_contextOption);
- connect(m_ui->currentPageButton, SIGNAL(clicked()), this, SLOT(setCurrentPage()));
- connect(m_ui->blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage()));
- connect(m_ui->defaultPageButton, SIGNAL(clicked()), this, SLOT(setDefaultPage()));
+ connect(m_ui->currentPageButton, SIGNAL(clicked()), this, SLOT(setCurrentPage()));
+ connect(m_ui->blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage()));
+ connect(m_ui->defaultPageButton, SIGNAL(clicked()), this, SLOT(setDefaultPage()));
- HelpViewer *viewer = CentralWidget::instance()->currentHelpViewer();
- if (!viewer)
- m_ui->currentPageButton->setEnabled(false);
+ HelpViewer *viewer = CentralWidget::instance()->currentHelpViewer();
+ if (!viewer)
+ m_ui->currentPageButton->setEnabled(false);
- m_ui->errorLabel->setVisible(false);
- connect(m_ui->importButton, SIGNAL(clicked()), this, SLOT(importBookmarks()));
- connect(m_ui->exportButton, SIGNAL(clicked()), this, SLOT(exportBookmarks()));
+ m_ui->errorLabel->setVisible(false);
+ connect(m_ui->importButton, SIGNAL(clicked()), this, SLOT(importBookmarks()));
+ connect(m_ui->exportButton, SIGNAL(clicked()), this, SLOT(exportBookmarks()));
- if (m_searchKeywords.isEmpty()) {
- QTextStream(&m_searchKeywords) << ' ' << m_ui->contextHelpLabel->text()
- << ' ' << m_ui->startPageLabel->text() << ' ' << m_ui->homePageLabel->text();
- m_searchKeywords.remove(QLatin1Char('&'));
+ m_returnOnClose = HelpManager::customValue(QLatin1String("ReturnOnClose"),
+ false).toBool();
+ m_ui->m_returnOnClose->setChecked(m_returnOnClose);
}
-
- m_returnOnClose = HelpManager::customValue(QLatin1String("ReturnOnClose"),
- false).toBool();
- m_ui->m_returnOnClose->setChecked(m_returnOnClose);
-
- return widget;
+ return m_widget;
}
void GeneralSettingsPage::apply()
@@ -342,13 +337,9 @@ int GeneralSettingsPage::closestPointSizeIndex(int desiredPointSize) const
return closestIndex;
}
-bool GeneralSettingsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
void GeneralSettingsPage::finish()
{
+ delete m_widget;
if (!m_ui) // page was never shown
return;
delete m_ui;
diff --git a/src/plugins/help/generalsettingspage.h b/src/plugins/help/generalsettingspage.h
index e243369e46..11524abce2 100644
--- a/src/plugins/help/generalsettingspage.h
+++ b/src/plugins/help/generalsettingspage.h
@@ -33,6 +33,8 @@
#include "ui_generalsettingspage.h"
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
namespace Help {
namespace Internal {
@@ -45,10 +47,9 @@ class GeneralSettingsPage : public Core::IOptionsPage
public:
GeneralSettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &s) const;
signals:
void fontChanged();
@@ -79,7 +80,7 @@ private:
int m_startOption;
bool m_returnOnClose;
- QString m_searchKeywords;
+ QPointer<QWidget> m_widget;
Ui::GeneralSettingsPage *m_ui;
};
diff --git a/src/plugins/help/help.qbs b/src/plugins/help/help.qbs
index b4c8b62f37..1761d5359c 100644
--- a/src/plugins/help/help.qbs
+++ b/src/plugins/help/help.qbs
@@ -12,8 +12,6 @@ QtcPlugin {
}
Depends { name: "Core" }
- Depends { name: "Find" }
- Depends { name: "Locator" }
Depends { name: "app_version_header" }
cpp.defines: base.concat(["QT_CLUCENE_SUPPORT"])
diff --git a/src/plugins/help/help_dependencies.pri b/src/plugins/help/help_dependencies.pri
index 058256c579..df04808074 100644
--- a/src/plugins/help/help_dependencies.pri
+++ b/src/plugins/help/help_dependencies.pri
@@ -1,5 +1,3 @@
QTC_PLUGIN_NAME = Help
QTC_PLUGIN_DEPENDS += \
- coreplugin \
- find \
- locator
+ coreplugin
diff --git a/src/plugins/help/helpfindsupport.cpp b/src/plugins/help/helpfindsupport.cpp
index 16efef0b00..b971fb1d9f 100644
--- a/src/plugins/help/helpfindsupport.cpp
+++ b/src/plugins/help/helpfindsupport.cpp
@@ -32,6 +32,7 @@
#include <utils/qtcassert.h>
+using namespace Core;
using namespace Help::Internal;
HelpFindSupport::HelpFindSupport(CentralWidget *centralWidget)
@@ -43,9 +44,9 @@ HelpFindSupport::~HelpFindSupport()
{
}
-Find::FindFlags HelpFindSupport::supportedFindFlags() const
+Core::FindFlags HelpFindSupport::supportedFindFlags() const
{
- return Find::FindBackward | Find::FindCaseSensitively;
+ return FindBackward | FindCaseSensitively;
}
QString HelpFindSupport::currentFindString() const
@@ -62,20 +63,20 @@ QString HelpFindSupport::completedFindString() const
return QString();
}
-Find::IFindSupport::Result HelpFindSupport::findIncremental(const QString &txt,
- Find::FindFlags findFlags)
+Core::IFindSupport::Result HelpFindSupport::findIncremental(const QString &txt,
+ Core::FindFlags findFlags)
{
- findFlags &= ~Find::FindBackward;
+ findFlags &= ~FindBackward;
return find(txt, findFlags, true) ? Found : NotFound;
}
-Find::IFindSupport::Result HelpFindSupport::findStep(const QString &txt,
- Find::FindFlags findFlags)
+Core::IFindSupport::Result HelpFindSupport::findStep(const QString &txt,
+ Core::FindFlags findFlags)
{
return find(txt, findFlags, false) ? Found : NotFound;
}
-bool HelpFindSupport::find(const QString &txt, Find::FindFlags findFlags, bool incremental)
+bool HelpFindSupport::find(const QString &txt, Core::FindFlags findFlags, bool incremental)
{
QTC_ASSERT(m_centralWidget, return false);
bool wrapped = false;
@@ -92,9 +93,9 @@ HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
{
}
-Find::FindFlags HelpViewerFindSupport::supportedFindFlags() const
+Core::FindFlags HelpViewerFindSupport::supportedFindFlags() const
{
- return Find::FindBackward | Find::FindCaseSensitively;
+ return FindBackward | FindCaseSensitively;
}
QString HelpViewerFindSupport::currentFindString() const
@@ -103,23 +104,23 @@ QString HelpViewerFindSupport::currentFindString() const
return m_viewer->selectedText();
}
-Find::IFindSupport::Result HelpViewerFindSupport::findIncremental(const QString &txt,
- Find::FindFlags findFlags)
+Core::IFindSupport::Result HelpViewerFindSupport::findIncremental(const QString &txt,
+ Core::FindFlags findFlags)
{
QTC_ASSERT(m_viewer, return NotFound);
- findFlags &= ~Find::FindBackward;
+ findFlags &= ~FindBackward;
return find(txt, findFlags, true) ? Found : NotFound;
}
-Find::IFindSupport::Result HelpViewerFindSupport::findStep(const QString &txt,
- Find::FindFlags findFlags)
+Core::IFindSupport::Result HelpViewerFindSupport::findStep(const QString &txt,
+ Core::FindFlags findFlags)
{
QTC_ASSERT(m_viewer, return NotFound);
return find(txt, findFlags, false) ? Found : NotFound;
}
bool HelpViewerFindSupport::find(const QString &txt,
- Find::FindFlags findFlags, bool incremental)
+ Core::FindFlags findFlags, bool incremental)
{
QTC_ASSERT(m_viewer, return false);
bool wrapped = false;
diff --git a/src/plugins/help/helpfindsupport.h b/src/plugins/help/helpfindsupport.h
index fce9eaf45e..c67a0a18d9 100644
--- a/src/plugins/help/helpfindsupport.h
+++ b/src/plugins/help/helpfindsupport.h
@@ -32,14 +32,14 @@
#include "centralwidget.h"
-#include <find/ifindsupport.h>
+#include <coreplugin/find/ifindsupport.h>
namespace Help {
namespace Internal {
class HelpViewer;
-class HelpFindSupport : public Find::IFindSupport
+class HelpFindSupport : public Core::IFindSupport
{
Q_OBJECT
@@ -48,40 +48,40 @@ public:
~HelpFindSupport();
bool supportsReplace() const { return false; }
- Find::FindFlags supportedFindFlags() const;
+ Core::FindFlags supportedFindFlags() const;
void resetIncrementalSearch() {}
void clearResults() {}
QString currentFindString() const;
QString completedFindString() const;
- Result findIncremental(const QString &txt, Find::FindFlags findFlags);
- Result findStep(const QString &txt, Find::FindFlags findFlags);
+ Result findIncremental(const QString &txt, Core::FindFlags findFlags);
+ Result findStep(const QString &txt, Core::FindFlags findFlags);
private:
- bool find(const QString &ttf, Find::FindFlags findFlags, bool incremental);
+ bool find(const QString &ttf, Core::FindFlags findFlags, bool incremental);
CentralWidget *m_centralWidget;
};
-class HelpViewerFindSupport : public Find::IFindSupport
+class HelpViewerFindSupport : public Core::IFindSupport
{
Q_OBJECT
public:
HelpViewerFindSupport(HelpViewer *viewer);
bool supportsReplace() const { return false; }
- Find::FindFlags supportedFindFlags() const;
+ Core::FindFlags supportedFindFlags() const;
void resetIncrementalSearch() {}
void clearResults() {}
QString currentFindString() const;
QString completedFindString() const { return QString(); }
- Result findIncremental(const QString &txt, Find::FindFlags findFlags);
- Result findStep(const QString &txt, Find::FindFlags findFlags);
+ Result findIncremental(const QString &txt, Core::FindFlags findFlags);
+ Result findStep(const QString &txt, Core::FindFlags findFlags);
private:
- bool find(const QString &ttf, Find::FindFlags findFlags, bool incremental);
+ bool find(const QString &ttf, Core::FindFlags findFlags, bool incremental);
HelpViewer *m_viewer;
};
diff --git a/src/plugins/help/helpindexfilter.cpp b/src/plugins/help/helpindexfilter.cpp
index e964e9c428..ebd04c3954 100644
--- a/src/plugins/help/helpindexfilter.cpp
+++ b/src/plugins/help/helpindexfilter.cpp
@@ -39,7 +39,7 @@
#include <QIcon>
-using namespace Locator;
+using namespace Core;
using namespace Help;
using namespace Help::Internal;
@@ -59,7 +59,7 @@ HelpIndexFilter::~HelpIndexFilter()
{
}
-QList<FilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
+QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future, const QString &entry)
{
QStringList keywords;
if (entry.length() < 2)
@@ -67,17 +67,17 @@ QList<FilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<Locator::FilterE
else
keywords = Core::HelpManager::findKeywords(entry, caseSensitivity(entry));
- QList<FilterEntry> entries;
+ QList<LocatorFilterEntry> entries;
foreach (const QString &keyword, keywords) {
if (future.isCanceled())
break;
- entries.append(FilterEntry(this, keyword, QVariant(), m_icon));
+ entries.append(LocatorFilterEntry(this, keyword, QVariant(), m_icon));
}
return entries;
}
-void HelpIndexFilter::accept(FilterEntry selection) const
+void HelpIndexFilter::accept(LocatorFilterEntry selection) const
{
const QString &key = selection.displayName;
const QMap<QString, QUrl> &links = Core::HelpManager::linksForKeyword(key);
diff --git a/src/plugins/help/helpindexfilter.h b/src/plugins/help/helpindexfilter.h
index bf26413dac..ae0e4bf7f4 100644
--- a/src/plugins/help/helpindexfilter.h
+++ b/src/plugins/help/helpindexfilter.h
@@ -30,14 +30,14 @@
#ifndef HELPINDEXFILTER_H
#define HELPINDEXFILTER_H
-#include <locator/ilocatorfilter.h>
+#include <coreplugin/locator/ilocatorfilter.h>
#include <QIcon>
namespace Help {
namespace Internal {
-class HelpIndexFilter : public Locator::ILocatorFilter
+class HelpIndexFilter : public Core::ILocatorFilter
{
Q_OBJECT
@@ -46,8 +46,8 @@ public:
~HelpIndexFilter();
// ILocatorFilter
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
signals:
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index 33ab67a5bd..1b48bad9e2 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -65,7 +65,7 @@
#include <coreplugin/rightpane.h>
#include <coreplugin/sidebar.h>
#include <extensionsystem/pluginmanager.h>
-#include <find/findplugin.h>
+#include <coreplugin/find/findplugin.h>
#include <texteditor/texteditorconstants.h>
#include <utils/hostosinfo.h>
#include <utils/styledbar.h>
@@ -342,7 +342,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
layout->setSpacing(0);
FindToolBarPlaceHolder *fth = new FindToolBarPlaceHolder(m_centralWidget);
fth->setObjectName(QLatin1String("HelpFindToolBarPlaceHolder"));
- layout->addWidget(fth);
+ mainWidgetLayout->addWidget(fth);
}
HelpIndexFilter *helpIndexFilter = new HelpIndexFilter();
@@ -1227,8 +1227,8 @@ void HelpPlugin::slotReportBug()
void HelpPlugin::openFindToolBar()
{
- if (Find::FindPlugin::instance())
- Find::FindPlugin::instance()->openFindToolBar(Find::FindPlugin::FindForwardDirection);
+ if (FindPlugin::instance())
+ FindPlugin::instance()->openFindToolBar(FindPlugin::FindForwardDirection);
}
void HelpPlugin::onSideBarVisibilityChanged()
diff --git a/src/plugins/help/helpviewer.h b/src/plugins/help/helpviewer.h
index 1355684b1d..8a877c317b 100644
--- a/src/plugins/help/helpviewer.h
+++ b/src/plugins/help/helpviewer.h
@@ -30,7 +30,7 @@
#ifndef HELPVIEWER_H
#define HELPVIEWER_H
-#include <find/ifindsupport.h>
+#include <coreplugin/find/ifindsupport.h>
#include <qglobal.h>
#include <QString>
@@ -82,7 +82,7 @@ public:
bool isForwardAvailable() const;
bool isBackwardAvailable() const;
- bool findText(const QString &text, Find::FindFlags flags,
+ bool findText(const QString &text, Core::FindFlags flags,
bool incremental, bool fromSearch, bool *wrapped = 0);
static bool isLocalUrl(const QUrl &url);
diff --git a/src/plugins/help/helpviewer_qtb.cpp b/src/plugins/help/helpviewer_qtb.cpp
index e643ccc158..b43a9c2fa9 100644
--- a/src/plugins/help/helpviewer_qtb.cpp
+++ b/src/plugins/help/helpviewer_qtb.cpp
@@ -45,7 +45,6 @@
#include <QHelpEngine>
-using namespace Find;
using namespace Help;
using namespace Help::Internal;
@@ -194,7 +193,7 @@ bool HelpViewer::isBackwardAvailable() const
return QTextBrowser::isBackwardAvailable();
}
-bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
+bool HelpViewer::findText(const QString &text, Core::FindFlags flags,
bool incremental, bool fromSearch, bool *wrapped)
{
if (wrapped)
@@ -208,10 +207,10 @@ bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
if (incremental)
cursor.setPosition(position);
- QTextDocument::FindFlags f = Find::textDocumentFlagsForFindFlags(flags);
+ QTextDocument::FindFlags f = Core::textDocumentFlagsForFindFlags(flags);
QTextCursor found = doc->find(text, cursor, f);
if (found.isNull()) {
- if ((flags & Find::FindBackward) == 0)
+ if ((flags & Core::FindBackward) == 0)
cursor.movePosition(QTextCursor::Start);
else
cursor.movePosition(QTextCursor::End);
diff --git a/src/plugins/help/helpviewer_qwv.cpp b/src/plugins/help/helpviewer_qwv.cpp
index f0f44bc66f..d8301084a8 100644
--- a/src/plugins/help/helpviewer_qwv.cpp
+++ b/src/plugins/help/helpviewer_qwv.cpp
@@ -58,7 +58,7 @@
#include <cstring>
-using namespace Find;
+using namespace Core;
using namespace Help;
using namespace Help::Internal;
@@ -412,7 +412,7 @@ bool HelpViewer::isBackwardAvailable() const
return pageAction(QWebPage::Back)->isEnabled();
}
-bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
+bool HelpViewer::findText(const QString &text, Core::FindFlags flags,
bool incremental, bool fromSearch, bool *wrapped)
{
Q_UNUSED(incremental);
@@ -420,9 +420,9 @@ bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
if (wrapped)
*wrapped = false;
QWebPage::FindFlags options;
- if (flags & Find::FindBackward)
+ if (flags & Core::FindBackward)
options |= QWebPage::FindBackward;
- if (flags & Find::FindCaseSensitively)
+ if (flags & Core::FindCaseSensitively)
options |= QWebPage::FindCaseSensitively;
bool found = QWebView::findText(text, options);
diff --git a/src/plugins/help/remotehelpfilter.cpp b/src/plugins/help/remotehelpfilter.cpp
index 130f196f1b..4d09abde98 100644
--- a/src/plugins/help/remotehelpfilter.cpp
+++ b/src/plugins/help/remotehelpfilter.cpp
@@ -96,20 +96,20 @@ RemoteHelpFilter::~RemoteHelpFilter()
{
}
-QList<Locator::FilterEntry> RemoteHelpFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &pattern)
+QList<Core::LocatorFilterEntry> RemoteHelpFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &pattern)
{
- QList<Locator::FilterEntry> entries;
+ QList<Core::LocatorFilterEntry> entries;
foreach (const QString &url, m_remoteUrls) {
if (future.isCanceled())
break;
- entries.append(Locator::FilterEntry(this, url.arg(pattern), QVariant(),
+ entries.append(Core::LocatorFilterEntry(this, url.arg(pattern), QVariant(),
m_icon));
}
return entries;
}
-void RemoteHelpFilter::accept(Locator::FilterEntry selection) const
+void RemoteHelpFilter::accept(Core::LocatorFilterEntry selection) const
{
const QString &url = selection.displayName;
if (!url.isEmpty())
diff --git a/src/plugins/help/remotehelpfilter.h b/src/plugins/help/remotehelpfilter.h
index a070a0f3fb..958deb1cbd 100644
--- a/src/plugins/help/remotehelpfilter.h
+++ b/src/plugins/help/remotehelpfilter.h
@@ -32,14 +32,14 @@
#include "ui_remotehelpfilter.h"
-#include <locator/ilocatorfilter.h>
+#include <coreplugin/locator/ilocatorfilter.h>
#include <QIcon>
namespace Help {
namespace Internal {
-class RemoteHelpFilter : public Locator::ILocatorFilter
+class RemoteHelpFilter : public Core::ILocatorFilter
{
Q_OBJECT
public:
@@ -47,8 +47,8 @@ public:
~RemoteHelpFilter();
// ILocatorFilter
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
diff --git a/src/plugins/imageviewer/imageviewerfactory.cpp b/src/plugins/imageviewer/imageviewerfactory.cpp
index faced86d9e..c972823e07 100644
--- a/src/plugins/imageviewer/imageviewerfactory.cpp
+++ b/src/plugins/imageviewer/imageviewerfactory.cpp
@@ -85,9 +85,9 @@ ImageViewerFactory::~ImageViewerFactory()
delete d;
}
-Core::IEditor *ImageViewerFactory::createEditor(QWidget *parent)
+Core::IEditor *ImageViewerFactory::createEditor()
{
- return new ImageViewer(parent);
+ return new ImageViewer();
}
void ImageViewerFactory::extensionsInitialized()
diff --git a/src/plugins/imageviewer/imageviewerfactory.h b/src/plugins/imageviewer/imageviewerfactory.h
index fa61e9ec1e..b788fdc6e3 100644
--- a/src/plugins/imageviewer/imageviewerfactory.h
+++ b/src/plugins/imageviewer/imageviewerfactory.h
@@ -45,7 +45,7 @@ public:
explicit ImageViewerFactory(QObject *parent = 0);
~ImageViewerFactory();
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
void extensionsInitialized();
diff --git a/src/plugins/ios/iosdeploystep.h b/src/plugins/ios/iosdeploystep.h
index ea09b7e000..86a7c7c199 100644
--- a/src/plugins/ios/iosdeploystep.h
+++ b/src/plugins/ios/iosdeploystep.h
@@ -51,26 +51,6 @@ namespace Internal {
class IosDeviceConfigListModel;
class IosPackageCreationStep;
-class DeployItem
-{
-public:
- DeployItem(const QString &_localFileName,
- unsigned int _localTimeStamp,
- const QString &_remoteFileName,
- bool _needsStrip)
- : localFileName(_localFileName),
- remoteFileName(_remoteFileName),
- localTimeStamp(_localTimeStamp),
- remoteTimeStamp(0),
- needsStrip(_needsStrip)
- {}
- QString localFileName;
- QString remoteFileName;
- unsigned int localTimeStamp;
- unsigned int remoteTimeStamp;
- bool needsStrip;
-};
-
class IosDeployStep : public ProjectExplorer::BuildStep
{
Q_OBJECT
diff --git a/src/plugins/ios/iossettingspage.cpp b/src/plugins/ios/iossettingspage.cpp
index 33cf2e2888..451afd89fd 100644
--- a/src/plugins/ios/iossettingspage.cpp
+++ b/src/plugins/ios/iossettingspage.cpp
@@ -48,16 +48,10 @@ IosSettingsPage::IosSettingsPage(QObject *parent)
setCategoryIcon(QLatin1String(Constants::IOS_SETTINGS_CATEGORY_ICON));
}
-bool IosSettingsPage::matches(const QString &searchKeyWord) const
+QWidget *IosSettingsPage::widget()
{
- return m_keywords.contains(searchKeyWord, Qt::CaseInsensitive);
-}
-
-QWidget *IosSettingsPage::createPage(QWidget *parent)
-{
- m_widget = new IosSettingsWidget(parent);
- if (m_keywords.isEmpty())
- m_keywords = m_widget->searchKeywords();
+ if (!m_widget)
+ m_widget = new IosSettingsWidget;
return m_widget;
}
@@ -69,6 +63,7 @@ void IosSettingsPage::apply()
void IosSettingsPage::finish()
{
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/ios/iossettingspage.h b/src/plugins/ios/iossettingspage.h
index 32711977b6..f9a26cb12e 100644
--- a/src/plugins/ios/iossettingspage.h
+++ b/src/plugins/ios/iossettingspage.h
@@ -31,6 +31,8 @@
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
namespace Ios {
namespace Internal {
@@ -43,14 +45,12 @@ class IosSettingsPage : public Core::IOptionsPage
public:
explicit IosSettingsPage(QObject *parent = 0);
- bool matches(const QString &searchKeyWord) const;
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
private:
- QString m_keywords;
- IosSettingsWidget *m_widget;
+ QPointer<IosSettingsWidget> m_widget;
};
} // namespace Internal
diff --git a/src/plugins/ios/iossettingswidget.cpp b/src/plugins/ios/iossettingswidget.cpp
index 16eea3846e..6edfeec775 100644
--- a/src/plugins/ios/iossettingswidget.cpp
+++ b/src/plugins/ios/iossettingswidget.cpp
@@ -65,14 +65,6 @@ IosSettingsWidget::~IosSettingsWidget()
delete m_ui;
}
-QString IosSettingsWidget::searchKeywords() const
-{
- QString rc;
- QTextStream(&rc) << m_ui->deviceAskCheckBox->text();
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
void IosSettingsWidget::initGui()
{
m_ui->setupUi(this);
diff --git a/src/plugins/ios/iossettingswidget.h b/src/plugins/ios/iossettingswidget.h
index 01e955c655..b7058af648 100644
--- a/src/plugins/ios/iossettingswidget.h
+++ b/src/plugins/ios/iossettingswidget.h
@@ -48,11 +48,10 @@ class IosSettingsWidget : public QWidget
Q_OBJECT
public:
// Todo: This would be so much simpler if it just used Utils::PathChooser!!!
- IosSettingsWidget(QWidget *parent);
+ IosSettingsWidget(QWidget *parent = 0);
~IosSettingsWidget();
void saveSettings();
- QString searchKeywords() const;
private slots:
diff --git a/src/plugins/locator/Locator.pluginspec.in b/src/plugins/locator/Locator.pluginspec.in
index ecd6d22c95..a67f7977e9 100644
--- a/src/plugins/locator/Locator.pluginspec.in
+++ b/src/plugins/locator/Locator.pluginspec.in
@@ -1,4 +1,4 @@
-<plugin name=\"Locator\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_COMPAT_VERSION\">
+<plugin name=\"Locator\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_COMPAT_VERSION\" disabledByDefault=\"true\">
<vendor>Digia Plc</vendor>
<copyright>(C) 2014 Digia Plc</copyright>
<license>
@@ -13,5 +13,4 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General
<category>Qt Creator</category>
<description>Provides the Locator widget and the hooks for Locator filter implementations.</description>
<url>http://www.qt-project.org</url>
- $$dependencyList
</plugin>
diff --git a/src/plugins/locator/locator.pro b/src/plugins/locator/locator.pro
index 69c237599b..a293b5ae63 100644
--- a/src/plugins/locator/locator.pro
+++ b/src/plugins/locator/locator.pro
@@ -1,43 +1,4 @@
DEFINES += LOCATOR_LIBRARY
include(../../qtcreatorplugin.pri)
-HEADERS += locatorplugin.h \
- commandlocator.h \
- locatorwidget.h \
- locatorfiltersfilter.h \
- settingspage.h \
- ilocatorfilter.h \
- opendocumentsfilter.h \
- filesystemfilter.h \
- locatorconstants.h \
- directoryfilter.h \
- locatormanager.h \
- basefilefilter.h \
- locator_global.h \
- executefilter.h \
- locatorsearchutils.h
-SOURCES += locatorplugin.cpp \
- commandlocator.cpp \
- locatorwidget.cpp \
- locatorfiltersfilter.cpp \
- opendocumentsfilter.cpp \
- filesystemfilter.cpp \
- settingspage.cpp \
- directoryfilter.cpp \
- locatormanager.cpp \
- basefilefilter.cpp \
- ilocatorfilter.cpp \
- executefilter.cpp \
- locatorsearchutils.cpp
-FORMS += settingspage.ui \
- filesystemfilter.ui \
- directoryfilter.ui
-RESOURCES += locator.qrc
-
-equals(TEST, 1) {
- HEADERS += locatorfiltertest.h
- SOURCES += \
- locatorfiltertest.cpp \
- locator_test.cpp
- DEFINES += SRCDIR=\\\"$$PWD\\\"
-}
+SOURCES += locatorplugin.cpp
diff --git a/src/plugins/locator/locator.qbs b/src/plugins/locator/locator.qbs
index 0e06a3b434..b32738a9f7 100644
--- a/src/plugins/locator/locator.qbs
+++ b/src/plugins/locator/locator.qbs
@@ -5,56 +5,7 @@ import QtcPlugin
QtcPlugin {
name: "Locator"
-
- Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "script"] }
Depends { name: "Core" }
- files: [
- "basefilefilter.cpp",
- "basefilefilter.h",
- "commandlocator.cpp",
- "commandlocator.h",
- "directoryfilter.cpp",
- "directoryfilter.h",
- "directoryfilter.ui",
- "executefilter.cpp",
- "executefilter.h",
- "filesystemfilter.cpp",
- "filesystemfilter.h",
- "filesystemfilter.ui",
- "ilocatorfilter.cpp",
- "ilocatorfilter.h",
- "locator.qrc",
- "locator_global.h",
- "locatorconstants.h",
- "locatorfiltersfilter.cpp",
- "locatorfiltersfilter.h",
- "locatormanager.cpp",
- "locatormanager.h",
- "locatorplugin.cpp",
- "locatorplugin.h",
- "locatorsearchutils.cpp",
- "locatorsearchutils.h",
- "locatorwidget.cpp",
- "locatorwidget.h",
- "opendocumentsfilter.cpp",
- "opendocumentsfilter.h",
- "settingspage.cpp",
- "settingspage.h",
- "settingspage.ui",
- "images/locator.png",
- "images/reload.png",
- ]
-
- Group {
- name: "Tests"
- condition: project.testsEnabled
- files: [
- "locatorfiltertest.cpp",
- "locatorfiltertest.h",
- "locator_test.cpp"
- ]
-
- cpp.defines: outer.concat(['SRCDIR="' + FileInfo.path(filePath) + '"'])
- }
+ files: [ "locatorplugin.cpp" ]
}
diff --git a/src/plugins/locator/locator_dependencies.pri b/src/plugins/locator/locator_dependencies.pri
index 899b5554a6..bb53d18702 100644
--- a/src/plugins/locator/locator_dependencies.pri
+++ b/src/plugins/locator/locator_dependencies.pri
@@ -1,3 +1,2 @@
QTC_PLUGIN_NAME = Locator
-QTC_PLUGIN_DEPENDS += \
- coreplugin
+QTC_PLUGIN_DEPENDS +=
diff --git a/src/plugins/locator/locatorplugin.cpp b/src/plugins/locator/locatorplugin.cpp
index 4348254135..802cedd7c5 100644
--- a/src/plugins/locator/locatorplugin.cpp
+++ b/src/plugins/locator/locatorplugin.cpp
@@ -1,268 +1,2 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-#include "locatorplugin.h"
-#include "locatorconstants.h"
-#include "locatorfiltersfilter.h"
-#include "locatormanager.h"
-#include "locatorwidget.h"
-#include "opendocumentsfilter.h"
-#include "filesystemfilter.h"
-#include "settingspage.h"
-
-#include <coreplugin/statusbarwidget.h>
-#include <coreplugin/coreconstants.h>
-#include <coreplugin/settingsdatabase.h>
-#include <coreplugin/icore.h>
-#include <coreplugin/actionmanager/actionmanager.h>
-#include <coreplugin/actionmanager/actioncontainer.h>
-#include <coreplugin/progressmanager/progressmanager.h>
-#include <coreplugin/progressmanager/futureprogress.h>
-#include <extensionsystem/pluginmanager.h>
-#include <utils/QtConcurrentTools>
-#include <utils/qtcassert.h>
-
-#include <QSettings>
-#include <QtPlugin>
-#include <QFuture>
-#include <QAction>
-
-/*!
- \namespace Locator
- The Locator namespace provides the hooks for Locator content.
-*/
-/*!
- \namespace Locator::Internal
- \internal
-*/
-
-using namespace Core;
-using namespace Locator;
-using namespace Locator::Internal;
-
-namespace {
- static bool filterLessThan(const ILocatorFilter *first, const ILocatorFilter *second)
- {
- if (first->priority() < second->priority())
- return true;
- if (first->priority() > second->priority())
- return false;
- return first->id().alphabeticallyBefore(second->id());
- }
-}
-
-LocatorPlugin::LocatorPlugin()
- : m_settingsInitialized(false)
-{
- m_refreshTimer.setSingleShot(false);
- connect(&m_refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
-}
-
-LocatorPlugin::~LocatorPlugin()
-{
- removeObject(m_openDocumentsFilter);
- removeObject(m_fileSystemFilter);
- removeObject(m_executeFilter);
- removeObject(m_settingsPage);
- delete m_openDocumentsFilter;
- delete m_fileSystemFilter;
- delete m_executeFilter;
- delete m_settingsPage;
- qDeleteAll(m_customFilters);
-}
-
-bool LocatorPlugin::initialize(const QStringList &, QString *)
-{
- m_settingsPage = new SettingsPage(this);
- addObject(m_settingsPage);
-
- m_locatorWidget = new LocatorWidget(this);
- m_locatorWidget->setEnabled(false);
- StatusBarWidget *view = new StatusBarWidget;
- view->setWidget(m_locatorWidget);
- view->setContext(Context("LocatorWidget"));
- view->setPosition(StatusBarWidget::First);
- addAutoReleasedObject(view);
-
- QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this);
- Command *cmd = ActionManager::registerAction(action, "QtCreator.Locate",
- Context(Core::Constants::C_GLOBAL));
- cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+K")));
- connect(action, SIGNAL(triggered()), this, SLOT(openLocator()));
- connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePlaceholderText()));
- updatePlaceholderText(cmd);
-
- ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
- mtools->addAction(cmd);
-
- addObject(new LocatorManager(m_locatorWidget));
-
- m_openDocumentsFilter = new OpenDocumentsFilter;
- addObject(m_openDocumentsFilter);
-
- m_fileSystemFilter = new FileSystemFilter(m_locatorWidget);
- addObject(m_fileSystemFilter);
-
- m_executeFilter = new ExecuteFilter();
- addObject(m_executeFilter);
-
- addAutoReleasedObject(new LocatorFiltersFilter(this, m_locatorWidget));
-
- return true;
-}
-
-void LocatorPlugin::updatePlaceholderText(Command *command)
-{
- if (!command)
- command = qobject_cast<Command *>(sender());
- QTC_ASSERT(command, return);
- if (command->keySequence().isEmpty())
- m_locatorWidget->setPlaceholderText(tr("Type to locate"));
- else
- m_locatorWidget->setPlaceholderText(tr("Type to locate (%1)").arg(
- command->keySequence().toString(QKeySequence::NativeText)));
-}
-
-void LocatorPlugin::openLocator()
-{
- m_locatorWidget->show(QString());
-}
-
-void LocatorPlugin::extensionsInitialized()
-{
- m_filters = ExtensionSystem::PluginManager::getObjects<ILocatorFilter>();
- qSort(m_filters.begin(), m_filters.end(), filterLessThan);
- setFilters(m_filters);
-}
-
-bool LocatorPlugin::delayedInitialize()
-{
- loadSettings();
- return true;
-}
-
-void LocatorPlugin::loadSettings()
-{
- QSettings *qs = ICore::settings();
-
- // Backwards compatibility to old settings location
- if (qs->contains(QLatin1String("QuickOpen/FiltersFilter"))) {
- loadSettingsHelper(qs);
- } else {
- SettingsDatabase *settings = ICore::settingsDatabase();
- loadSettingsHelper(settings);
- }
-
- qs->remove(QLatin1String("QuickOpen"));
-
- m_locatorWidget->updateFilterList();
- m_locatorWidget->setEnabled(true);
- if (m_refreshTimer.interval() > 0)
- m_refreshTimer.start();
- m_settingsInitialized = true;
-}
-
-void LocatorPlugin::saveSettings()
-{
- if (m_settingsInitialized) {
- SettingsDatabase *s = ICore::settingsDatabase();
- s->beginGroup(QLatin1String("QuickOpen"));
- s->remove(QString());
- s->setValue(QLatin1String("RefreshInterval"), refreshInterval());
- foreach (ILocatorFilter *filter, m_filters) {
- if (!m_customFilters.contains(filter))
- s->setValue(filter->id().toString(), filter->saveState());
- }
- s->beginGroup(QLatin1String("CustomFilters"));
- int i = 0;
- foreach (ILocatorFilter *filter, m_customFilters) {
- s->setValue(QLatin1String("directory") + QString::number(i),
- filter->saveState());
- ++i;
- }
- s->endGroup();
- s->endGroup();
- }
-}
-
-/*!
- Return all filters, including the ones created by the user.
-*/
-QList<ILocatorFilter *> LocatorPlugin::filters()
-{
- return m_filters;
-}
-
-/*!
- This returns a subset of all the filters, that contains only the filters that
- have been created by the user at some point (maybe in a previous session).
- */
-QList<ILocatorFilter *> LocatorPlugin::customFilters()
-{
- return m_customFilters;
-}
-
-void LocatorPlugin::setFilters(QList<ILocatorFilter *> f)
-{
- m_filters = f;
- m_locatorWidget->updateFilterList();
-}
-
-void LocatorPlugin::setCustomFilters(QList<ILocatorFilter *> filters)
-{
- m_customFilters = filters;
-}
-
-int LocatorPlugin::refreshInterval()
-{
- return m_refreshTimer.interval() / 60000;
-}
-
-void LocatorPlugin::setRefreshInterval(int interval)
-{
- if (interval < 1) {
- m_refreshTimer.stop();
- m_refreshTimer.setInterval(0);
- return;
- }
- m_refreshTimer.setInterval(interval * 60000);
- m_refreshTimer.start();
-}
-
-void LocatorPlugin::refresh(QList<ILocatorFilter *> filters)
-{
- if (filters.isEmpty())
- filters = m_filters;
- QFuture<void> task = QtConcurrent::run(&ILocatorFilter::refresh, filters);
- FutureProgress *progress =
- ProgressManager::addTask(task, tr("Indexing"), Locator::Constants::TASK_INDEX);
- connect(progress, SIGNAL(finished()), this, SLOT(saveSettings()));
-}
-
-Q_EXPORT_PLUGIN(LocatorPlugin)
+void dummyLocatorPlugin () {}
diff --git a/src/plugins/macros/findmacrohandler.cpp b/src/plugins/macros/findmacrohandler.cpp
index 4fe9508881..be7824019a 100644
--- a/src/plugins/macros/findmacrohandler.cpp
+++ b/src/plugins/macros/findmacrohandler.cpp
@@ -32,11 +32,10 @@
#include "macro.h"
#include "macrotextfind.h"
-#include <find/ifindsupport.h>
-
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
+#include <coreplugin/find/ifindsupport.h>
#include <aggregation/aggregate.h>
@@ -79,32 +78,32 @@ bool FindMacroHandler::executeEvent(const MacroEvent &macroEvent)
if (!aggregate)
return false;
- Find::IFindSupport *currentFind = aggregate->component<Find::IFindSupport>();
+ Core::IFindSupport *currentFind = aggregate->component<Core::IFindSupport>();
if (!currentFind)
return false;
switch (macroEvent.value(TYPE).toInt()) {
case FINDINCREMENTAL:
currentFind->findIncremental(macroEvent.value(BEFORE).toString(),
- (Find::FindFlags)macroEvent.value(FLAGS).toInt());
+ (Core::FindFlags)macroEvent.value(FLAGS).toInt());
break;
case FINDSTEP:
currentFind->findStep(macroEvent.value(BEFORE).toString(),
- (Find::FindFlags)macroEvent.value(FLAGS).toInt());
+ (Core::FindFlags)macroEvent.value(FLAGS).toInt());
break;
case REPLACE:
currentFind->replace(macroEvent.value(BEFORE).toString(),
macroEvent.value(AFTER).toString(),
- (Find::FindFlags)macroEvent.value(FLAGS).toInt());
+ (Core::FindFlags)macroEvent.value(FLAGS).toInt());
case REPLACESTEP:
currentFind->replaceStep(macroEvent.value(BEFORE).toString(),
macroEvent.value(AFTER).toString(),
- (Find::FindFlags)macroEvent.value(FLAGS).toInt());
+ (Core::FindFlags)macroEvent.value(FLAGS).toInt());
break;
case REPLACEALL:
currentFind->replaceAll(macroEvent.value(BEFORE).toString(),
macroEvent.value(AFTER).toString(),
- (Find::FindFlags)macroEvent.value(FLAGS).toInt());
+ (Core::FindFlags)macroEvent.value(FLAGS).toInt());
break;
case RESET:
currentFind->resetIncrementalSearch();
@@ -113,7 +112,7 @@ bool FindMacroHandler::executeEvent(const MacroEvent &macroEvent)
return true;
}
-void FindMacroHandler::findIncremental(const QString &txt, Find::FindFlags findFlags)
+void FindMacroHandler::findIncremental(const QString &txt, Core::FindFlags findFlags)
{
if (!isRecording())
return;
@@ -125,7 +124,7 @@ void FindMacroHandler::findIncremental(const QString &txt, Find::FindFlags findF
addMacroEvent(e);
}
-void FindMacroHandler::findStep(const QString &txt, Find::FindFlags findFlags)
+void FindMacroHandler::findStep(const QString &txt, Core::FindFlags findFlags)
{
if (!isRecording())
return;
@@ -137,7 +136,7 @@ void FindMacroHandler::findStep(const QString &txt, Find::FindFlags findFlags)
addMacroEvent(e);
}
-void FindMacroHandler::replace(const QString &before, const QString &after, Find::FindFlags findFlags)
+void FindMacroHandler::replace(const QString &before, const QString &after, Core::FindFlags findFlags)
{
if (!isRecording())
return;
@@ -150,7 +149,7 @@ void FindMacroHandler::replace(const QString &before, const QString &after, Find
addMacroEvent(e);
}
-void FindMacroHandler::replaceStep(const QString &before, const QString &after, Find::FindFlags findFlags)
+void FindMacroHandler::replaceStep(const QString &before, const QString &after, Core::FindFlags findFlags)
{
if (!isRecording())
return;
@@ -163,7 +162,7 @@ void FindMacroHandler::replaceStep(const QString &before, const QString &after,
addMacroEvent(e);
}
-void FindMacroHandler::replaceAll(const QString &before, const QString &after, Find::FindFlags findFlags)
+void FindMacroHandler::replaceAll(const QString &before, const QString &after, Core::FindFlags findFlags)
{
if (!isRecording())
return;
@@ -194,7 +193,7 @@ void FindMacroHandler::changeEditor(Core::IEditor *editor)
Aggregation::Aggregate *aggregate = Aggregation::Aggregate::parentAggregate(editor->widget());
if (aggregate) {
- Find::IFindSupport *currentFind = aggregate->component<Find::IFindSupport>();
+ Core::IFindSupport *currentFind = aggregate->component<Core::IFindSupport>();
if (currentFind) {
MacroTextFind *macroFind = qobject_cast<MacroTextFind *>(currentFind);
if (macroFind)
@@ -205,18 +204,18 @@ void FindMacroHandler::changeEditor(Core::IEditor *editor)
aggregate->add(macroFind);
// Connect all signals
- connect(macroFind, SIGNAL(allReplaced(QString,QString,Find::FindFlags)),
- this, SLOT(replaceAll(QString,QString,Find::FindFlags)));
- connect(macroFind, SIGNAL(incrementalFound(QString,Find::FindFlags)),
- this, SLOT(findIncremental(QString,Find::FindFlags)));
+ connect(macroFind, SIGNAL(allReplaced(QString,QString,Core::FindFlags)),
+ this, SLOT(replaceAll(QString,QString,Core::FindFlags)));
+ connect(macroFind, SIGNAL(incrementalFound(QString,Core::FindFlags)),
+ this, SLOT(findIncremental(QString,Core::FindFlags)));
connect(macroFind, SIGNAL(incrementalSearchReseted()),
this, SLOT(resetIncrementalSearch()));
- connect(macroFind, SIGNAL(replaced(QString,QString,Find::FindFlags)),
- this, SLOT(replace(QString,QString,Find::FindFlags)));
- connect(macroFind, SIGNAL(stepFound(QString,Find::FindFlags)),
- this, SLOT(findStep(QString,Find::FindFlags)));
- connect(macroFind, SIGNAL(stepReplaced(QString,QString,Find::FindFlags)),
- this, SLOT(replaceStep(QString,QString,Find::FindFlags)));
+ connect(macroFind, SIGNAL(replaced(QString,QString,Core::FindFlags)),
+ this, SLOT(replace(QString,QString,Core::FindFlags)));
+ connect(macroFind, SIGNAL(stepFound(QString,Core::FindFlags)),
+ this, SLOT(findStep(QString,Core::FindFlags)));
+ connect(macroFind, SIGNAL(stepReplaced(QString,QString,Core::FindFlags)),
+ this, SLOT(replaceStep(QString,QString,Core::FindFlags)));
}
}
}
diff --git a/src/plugins/macros/findmacrohandler.h b/src/plugins/macros/findmacrohandler.h
index 7f35f1adfd..33a68e5766 100644
--- a/src/plugins/macros/findmacrohandler.h
+++ b/src/plugins/macros/findmacrohandler.h
@@ -32,7 +32,7 @@
#include "imacrohandler.h"
-#include <find/textfindconstants.h>
+#include <coreplugin/find/textfindconstants.h>
namespace Core {
class IEditor;
@@ -54,11 +54,11 @@ public:
bool executeEvent(const MacroEvent &macroEvent);
public slots:
- void findIncremental(const QString &txt, Find::FindFlags findFlags);
- void findStep(const QString &txt, Find::FindFlags findFlags);
- void replace(const QString &before, const QString &after, Find::FindFlags findFlags);
- void replaceStep(const QString &before, const QString &after, Find::FindFlags findFlags);
- void replaceAll(const QString &before, const QString &after, Find::FindFlags findFlags);
+ void findIncremental(const QString &txt, Core::FindFlags findFlags);
+ void findStep(const QString &txt, Core::FindFlags findFlags);
+ void replace(const QString &before, const QString &after, Core::FindFlags findFlags);
+ void replaceStep(const QString &before, const QString &after, Core::FindFlags findFlags);
+ void replaceAll(const QString &before, const QString &after, Core::FindFlags findFlags);
void resetIncrementalSearch();
private slots:
diff --git a/src/plugins/macros/macrolocatorfilter.cpp b/src/plugins/macros/macrolocatorfilter.cpp
index e1cd889445..e63f1f090e 100644
--- a/src/plugins/macros/macrolocatorfilter.cpp
+++ b/src/plugins/macros/macrolocatorfilter.cpp
@@ -52,11 +52,11 @@ MacroLocatorFilter::~MacroLocatorFilter()
{
}
-QList<Locator::FilterEntry> MacroLocatorFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
+QList<Core::LocatorFilterEntry> MacroLocatorFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry)
{
Q_UNUSED(future)
- QList<Locator::FilterEntry> goodEntries;
- QList<Locator::FilterEntry> betterEntries;
+ QList<Core::LocatorFilterEntry> goodEntries;
+ QList<Core::LocatorFilterEntry> betterEntries;
const Qt::CaseSensitivity caseSensitivity_ = caseSensitivity(entry);
@@ -67,7 +67,7 @@ QList<Locator::FilterEntry> MacroLocatorFilter::matchesFor(QFutureInterface<Loca
it.next();
QString name = it.key();
- QList<Locator::FilterEntry> *category = 0;
+ QList<Core::LocatorFilterEntry> *category = 0;
if (name.startsWith(entry, caseSensitivity_))
category = &betterEntries;
else if (name.contains(entry, caseSensitivity_))
@@ -75,7 +75,7 @@ QList<Locator::FilterEntry> MacroLocatorFilter::matchesFor(QFutureInterface<Loca
if (category) {
QVariant id;
- Locator::FilterEntry entry(this, it.key(), id, m_icon);
+ Core::LocatorFilterEntry entry(this, it.key(), id, m_icon);
entry.extraInfo = it.value()->description();
category->append(entry);
}
@@ -84,7 +84,7 @@ QList<Locator::FilterEntry> MacroLocatorFilter::matchesFor(QFutureInterface<Loca
return betterEntries;
}
-void MacroLocatorFilter::accept(Locator::FilterEntry selection) const
+void MacroLocatorFilter::accept(Core::LocatorFilterEntry selection) const
{
// Give the focus back to the editor
Core::IEditor *editor = Core::EditorManager::currentEditor();
diff --git a/src/plugins/macros/macrolocatorfilter.h b/src/plugins/macros/macrolocatorfilter.h
index 40a685d746..700a597f09 100644
--- a/src/plugins/macros/macrolocatorfilter.h
+++ b/src/plugins/macros/macrolocatorfilter.h
@@ -30,7 +30,7 @@
#ifndef MACROSPLUGIN_MACROLOCATORFILTER_H
#define MACROSPLUGIN_MACROLOCATORFILTER_H
-#include <locator/ilocatorfilter.h>
+#include <coreplugin/locator/ilocatorfilter.h>
#include <QIcon>
@@ -40,7 +40,7 @@ class MacroManager;
namespace Internal {
-class MacroLocatorFilter : public Locator::ILocatorFilter
+class MacroLocatorFilter : public Core::ILocatorFilter
{
Q_OBJECT
@@ -48,8 +48,8 @@ public:
MacroLocatorFilter();
~MacroLocatorFilter();
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
private:
diff --git a/src/plugins/macros/macrooptionspage.cpp b/src/plugins/macros/macrooptionspage.cpp
index c3c259de99..c423b9c54d 100644
--- a/src/plugins/macros/macrooptionspage.cpp
+++ b/src/plugins/macros/macrooptionspage.cpp
@@ -53,9 +53,10 @@ MacroOptionsPage::MacroOptionsPage(QObject *parent)
TextEditor::Constants::TEXT_EDITOR_SETTINGS_TR_CATEGORY));
}
-QWidget *MacroOptionsPage::createPage(QWidget *parent)
+QWidget *MacroOptionsPage::widget()
{
- m_widget = new MacroOptionsWidget(parent);
+ if (!m_widget)
+ m_widget = new MacroOptionsWidget;
return m_widget;
}
@@ -67,5 +68,5 @@ void MacroOptionsPage::apply()
void MacroOptionsPage::finish()
{
- // Nothing to do
+ delete m_widget;
}
diff --git a/src/plugins/macros/macrooptionspage.h b/src/plugins/macros/macrooptionspage.h
index 767f6125c7..568d050baf 100644
--- a/src/plugins/macros/macrooptionspage.h
+++ b/src/plugins/macros/macrooptionspage.h
@@ -32,6 +32,8 @@
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
namespace Macros {
namespace Internal {
@@ -45,12 +47,12 @@ public:
MacroOptionsPage(QObject *parent = 0);
// IOptionsPage implementation
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
private:
- Internal::MacroOptionsWidget *m_widget;
+ QPointer<MacroOptionsWidget> m_widget;
};
} // namespace Internal
diff --git a/src/plugins/macros/macros.qbs b/src/plugins/macros/macros.qbs
index b9e90960a0..f6dac5cb8f 100644
--- a/src/plugins/macros/macros.qbs
+++ b/src/plugins/macros/macros.qbs
@@ -7,8 +7,6 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
- Depends { name: "Locator" }
- Depends { name: "Find" }
Depends { name: "TextEditor" }
Depends { name: "app_version_header" }
diff --git a/src/plugins/macros/macros_dependencies.pri b/src/plugins/macros/macros_dependencies.pri
index 3ae94328b3..e7850c9d52 100644
--- a/src/plugins/macros/macros_dependencies.pri
+++ b/src/plugins/macros/macros_dependencies.pri
@@ -1,6 +1,4 @@
QTC_PLUGIN_NAME = Macros
QTC_PLUGIN_DEPENDS += \
coreplugin \
- locator \
- find \
texteditor
diff --git a/src/plugins/macros/macrotextfind.cpp b/src/plugins/macros/macrotextfind.cpp
index b56a81cdd3..1aeef19113 100644
--- a/src/plugins/macros/macrotextfind.cpp
+++ b/src/plugins/macros/macrotextfind.cpp
@@ -34,8 +34,8 @@
using namespace Macros;
using namespace Macros::Internal;
-MacroTextFind::MacroTextFind(Find::IFindSupport *currentFind):
- Find::IFindSupport(),
+MacroTextFind::MacroTextFind(Core::IFindSupport *currentFind):
+ Core::IFindSupport(),
m_currentFind(currentFind)
{
}
@@ -46,7 +46,7 @@ bool MacroTextFind::supportsReplace() const
return m_currentFind->supportsReplace();
}
-Find::FindFlags MacroTextFind::supportedFindFlags() const
+Core::FindFlags MacroTextFind::supportedFindFlags() const
{
QTC_ASSERT(m_currentFind, return 0);
return m_currentFind->supportedFindFlags();
@@ -77,38 +77,38 @@ QString MacroTextFind::completedFindString() const
return m_currentFind->completedFindString();
}
-void MacroTextFind::highlightAll(const QString &txt, Find::FindFlags findFlags)
+void MacroTextFind::highlightAll(const QString &txt, Core::FindFlags findFlags)
{
QTC_ASSERT(m_currentFind, return);
m_currentFind->highlightAll(txt, findFlags);
}
-Find::IFindSupport::Result MacroTextFind::findIncremental(const QString &txt, Find::FindFlags findFlags)
+Core::IFindSupport::Result MacroTextFind::findIncremental(const QString &txt, Core::FindFlags findFlags)
{
QTC_ASSERT(m_currentFind, return IFindSupport::NotFound);
- Find::IFindSupport::Result result = m_currentFind->findIncremental(txt, findFlags);
+ Core::IFindSupport::Result result = m_currentFind->findIncremental(txt, findFlags);
if (result == Found)
emit incrementalFound(txt, findFlags);
return result;
}
-Find::IFindSupport::Result MacroTextFind::findStep(const QString &txt, Find::FindFlags findFlags)
+Core::IFindSupport::Result MacroTextFind::findStep(const QString &txt, Core::FindFlags findFlags)
{
QTC_ASSERT(m_currentFind, return IFindSupport::NotFound);
- Find::IFindSupport::Result result = m_currentFind->findStep(txt, findFlags);
+ Core::IFindSupport::Result result = m_currentFind->findStep(txt, findFlags);
if (result == Found)
emit stepFound(txt, findFlags);
return result;
}
-void MacroTextFind::replace(const QString &before, const QString &after, Find::FindFlags findFlags)
+void MacroTextFind::replace(const QString &before, const QString &after, Core::FindFlags findFlags)
{
QTC_ASSERT(m_currentFind, return);
m_currentFind->replace(before, after, findFlags);
emit replaced(before, after, findFlags);
}
-bool MacroTextFind::replaceStep(const QString &before, const QString &after, Find::FindFlags findFlags)
+bool MacroTextFind::replaceStep(const QString &before, const QString &after, Core::FindFlags findFlags)
{
QTC_ASSERT(m_currentFind, return false);
bool result = m_currentFind->replaceStep(before, after, findFlags);
@@ -116,7 +116,7 @@ bool MacroTextFind::replaceStep(const QString &before, const QString &after, Fin
return result;
}
-int MacroTextFind::replaceAll(const QString &before, const QString &after, Find::FindFlags findFlags)
+int MacroTextFind::replaceAll(const QString &before, const QString &after, Core::FindFlags findFlags)
{
QTC_ASSERT(m_currentFind, return 0);
int result = m_currentFind->replaceAll(before, after, findFlags);
diff --git a/src/plugins/macros/macrotextfind.h b/src/plugins/macros/macrotextfind.h
index f2e6fecb66..f703664dfd 100644
--- a/src/plugins/macros/macrotextfind.h
+++ b/src/plugins/macros/macrotextfind.h
@@ -30,50 +30,50 @@
#ifndef MACROSPLUGIN_MACROTEXTFIND_H
#define MACROSPLUGIN_MACROTEXTFIND_H
-#include <find/ifindsupport.h>
+#include <coreplugin/find/ifindsupport.h>
#include <QPointer>
namespace Macros {
namespace Internal {
-class MacroTextFind : public Find::IFindSupport
+class MacroTextFind : public Core::IFindSupport
{
Q_OBJECT
public:
- MacroTextFind(Find::IFindSupport *currentFind);
+ MacroTextFind(Core::IFindSupport *currentFind);
bool supportsReplace() const;
- Find::FindFlags supportedFindFlags() const;
+ Core::FindFlags supportedFindFlags() const;
void resetIncrementalSearch();
void clearResults();
QString currentFindString() const;
QString completedFindString() const;
- void highlightAll(const QString &txt, Find::FindFlags findFlags);
- Find::IFindSupport::Result findIncremental(const QString &txt, Find::FindFlags findFlags);
- Find::IFindSupport::Result findStep(const QString &txt, Find::FindFlags findFlags);
- void replace(const QString &before, const QString &after, Find::FindFlags findFlags);
- bool replaceStep(const QString &before, const QString &after, Find::FindFlags findFlags);
- int replaceAll(const QString &before, const QString &after, Find::FindFlags findFlags);
+ void highlightAll(const QString &txt, Core::FindFlags findFlags);
+ Core::IFindSupport::Result findIncremental(const QString &txt, Core::FindFlags findFlags);
+ Core::IFindSupport::Result findStep(const QString &txt, Core::FindFlags findFlags);
+ void replace(const QString &before, const QString &after, Core::FindFlags findFlags);
+ bool replaceStep(const QString &before, const QString &after, Core::FindFlags findFlags);
+ int replaceAll(const QString &before, const QString &after, Core::FindFlags findFlags);
void defineFindScope();
void clearFindScope();
signals:
void incrementalSearchReseted();
- void incrementalFound(const QString &txt, Find::FindFlags findFlags);
- void stepFound(const QString &txt, Find::FindFlags findFlags);
+ void incrementalFound(const QString &txt, Core::FindFlags findFlags);
+ void stepFound(const QString &txt, Core::FindFlags findFlags);
void replaced(const QString &before, const QString &after,
- Find::FindFlags findFlags);
+ Core::FindFlags findFlags);
void stepReplaced(const QString &before, const QString &after,
- Find::FindFlags findFlags);
+ Core::FindFlags findFlags);
void allReplaced(const QString &before, const QString &after,
- Find::FindFlags findFlags);
+ Core::FindFlags findFlags);
private:
- QPointer<Find::IFindSupport> m_currentFind;
+ QPointer<Core::IFindSupport> m_currentFind;
};
} // namespace Internal
diff --git a/src/plugins/mercurial/mercurial.qbs b/src/plugins/mercurial/mercurial.qbs
index 80611787e7..e6fec9fbed 100644
--- a/src/plugins/mercurial/mercurial.qbs
+++ b/src/plugins/mercurial/mercurial.qbs
@@ -8,9 +8,7 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
Depends { name: "TextEditor" }
- Depends { name: "Find" }
Depends { name: "VcsBase" }
- Depends { name: "Locator" }
files: [
"annotationhighlighter.cpp",
diff --git a/src/plugins/mercurial/mercurial_dependencies.pri b/src/plugins/mercurial/mercurial_dependencies.pri
index 8de4e4595d..de8a0df27a 100644
--- a/src/plugins/mercurial/mercurial_dependencies.pri
+++ b/src/plugins/mercurial/mercurial_dependencies.pri
@@ -2,7 +2,6 @@ QTC_PLUGIN_NAME = Mercurial
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
- locator \
texteditor \
coreplugin \
vcsbase
diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp
index 8814c4f0eb..eac981f3b3 100644
--- a/src/plugins/mercurial/mercurialplugin.cpp
+++ b/src/plugins/mercurial/mercurialplugin.cpp
@@ -49,7 +49,7 @@
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/editormanager.h>
-#include <locator/commandlocator.h>
+#include <coreplugin/locator/commandlocator.h>
#include <utils/parameteraction.h>
#include <utils/qtcassert.h>
@@ -152,7 +152,7 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString *
addAutoReleasedObject(new CloneWizard);
const QString prefix = QLatin1String("hg");
- m_commandLocator = new Locator::CommandLocator("Mercurial", prefix, prefix);
+ m_commandLocator = new Core::CommandLocator("Mercurial", prefix, prefix);
addAutoReleasedObject(m_commandLocator);
createMenu();
diff --git a/src/plugins/mercurial/mercurialplugin.h b/src/plugins/mercurial/mercurialplugin.h
index 7c5ab3d203..12676a9931 100644
--- a/src/plugins/mercurial/mercurialplugin.h
+++ b/src/plugins/mercurial/mercurialplugin.h
@@ -43,6 +43,7 @@ QT_END_NAMESPACE
namespace Core {
class ActionContainer;
class ActionManager;
+class CommandLocator;
class ICore;
class Id;
class IEditor;
@@ -50,7 +51,6 @@ class IEditor;
namespace Utils { class ParameterAction; }
namespace VcsBase { class VcsBaseSubmitEditor; }
-namespace Locator { class CommandLocator; }
namespace Mercurial {
namespace Internal {
@@ -143,7 +143,7 @@ private:
MercurialClient *m_client;
Core::ICore *core;
- Locator::CommandLocator *m_commandLocator;
+ Core::CommandLocator *m_commandLocator;
Core::ActionContainer *mercurialContainer;
QList<QAction *> m_repositoryActionList;
diff --git a/src/plugins/mercurial/optionspage.cpp b/src/plugins/mercurial/optionspage.cpp
index 3139cd61a4..390be856eb 100644
--- a/src/plugins/mercurial/optionspage.cpp
+++ b/src/plugins/mercurial/optionspage.cpp
@@ -68,37 +68,17 @@ void OptionsPageWidget::setSettings(const MercurialSettings &s)
m_ui.timeout->setValue(s.intValue(MercurialSettings::timeoutKey));
}
-QString OptionsPageWidget::searchKeywords() const
-{
- QString rc;
- QLatin1Char sep(' ');
- QTextStream(&rc)
- << sep << m_ui.configGroupBox->title()
- << sep << m_ui.mercurialCommandLabel->text()
- << sep << m_ui.userGroupBox->title()
- << sep << m_ui.defaultUsernameLabel->text()
- << sep << m_ui.defaultEmailLabel->text()
- << sep << m_ui.miscGroupBox->title()
- << sep << m_ui.showLogEntriesLabel->text()
- << sep << m_ui.timeoutSecondsLabel->text()
- ;
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
OptionsPage::OptionsPage()
{
setId(VcsBase::Constants::VCS_ID_MERCURIAL);
setDisplayName(tr("Mercurial"));
}
-QWidget *OptionsPage::createPage(QWidget *parent)
+QWidget *OptionsPage::widget()
{
if (!optionsPageWidget)
- optionsPageWidget = new OptionsPageWidget(parent);
+ optionsPageWidget = new OptionsPageWidget;
optionsPageWidget->setSettings(MercurialPlugin::settings());
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = optionsPageWidget->searchKeywords();
return optionsPageWidget;
}
@@ -115,7 +95,7 @@ void OptionsPage::apply()
}
}
-bool OptionsPage::matches(const QString &s) const
+void OptionsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete optionsPageWidget;
}
diff --git a/src/plugins/mercurial/optionspage.h b/src/plugins/mercurial/optionspage.h
index cb560c3d4b..828be3e396 100644
--- a/src/plugins/mercurial/optionspage.h
+++ b/src/plugins/mercurial/optionspage.h
@@ -51,7 +51,6 @@ public:
MercurialSettings settings() const;
void setSettings(const MercurialSettings &s);
- QString searchKeywords() const;
private:
Ui::OptionsPage m_ui;
@@ -65,16 +64,14 @@ class OptionsPage : public VcsBase::VcsBaseOptionsPage
public:
OptionsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &s) const;
+ void finish();
signals:
void settingsChanged();
private:
- QString m_searchKeywords;
QPointer<OptionsPageWidget> optionsPageWidget;
};
diff --git a/src/plugins/perforce/perforce.qbs b/src/plugins/perforce/perforce.qbs
index 9bc46fcee5..155da2891f 100644
--- a/src/plugins/perforce/perforce.qbs
+++ b/src/plugins/perforce/perforce.qbs
@@ -8,9 +8,7 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
Depends { name: "TextEditor" }
- Depends { name: "Find" }
Depends { name: "VcsBase" }
- Depends { name: "Locator" }
files: [
"annotationhighlighter.cpp",
diff --git a/src/plugins/perforce/perforce_dependencies.pri b/src/plugins/perforce/perforce_dependencies.pri
index 7e46fc7990..dca91be311 100644
--- a/src/plugins/perforce/perforce_dependencies.pri
+++ b/src/plugins/perforce/perforce_dependencies.pri
@@ -2,7 +2,6 @@ QTC_PLUGIN_NAME = Perforce
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
- locator \
texteditor \
coreplugin \
vcsbase
diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp
index 63872df622..fb6bfeb949 100644
--- a/src/plugins/perforce/perforceplugin.cpp
+++ b/src/plugins/perforce/perforceplugin.cpp
@@ -48,7 +48,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
#include <coreplugin/mimedatabase.h>
-#include <locator/commandlocator.h>
+#include <coreplugin/locator/commandlocator.h>
#include <utils/qtcassert.h>
#include <utils/synchronousprocess.h>
#include <utils/parameteraction.h>
@@ -226,7 +226,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er
addAutoReleasedObject(new PerforceEditorFactory(editorParameters + i, this, describeSlot));
const QString prefix = QLatin1String("p4");
- m_commandLocator = new Locator::CommandLocator("Perforce", prefix, prefix);
+ m_commandLocator = new Core::CommandLocator("Perforce", prefix, prefix);
addAutoReleasedObject(m_commandLocator);
Core::ActionContainer *mtools =
@@ -1182,12 +1182,11 @@ Core::IEditor *PerforcePlugin::showOutputInEditor(const QString &title, const QS
e->setForceReadOnly(true);
e->setSource(source);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
- e->setSuggestedFileName(s);
+ e->baseTextDocument()->setSuggestedFileName(s);
if (codec)
e->setCodec(codec);
- Core::IEditor *ie = e->editor();
- Core::EditorManager::activateEditor(ie);
- return ie;
+ Core::EditorManager::activateEditor(editor);
+ return editor;
}
void PerforcePlugin::slotSubmitDiff(const QStringList &files)
diff --git a/src/plugins/perforce/perforceplugin.h b/src/plugins/perforce/perforceplugin.h
index 7337181b22..9b6b48ca4d 100644
--- a/src/plugins/perforce/perforceplugin.h
+++ b/src/plugins/perforce/perforceplugin.h
@@ -53,7 +53,7 @@ namespace Utils {
class TempFileSaver;
}
-namespace Locator {
+namespace Core {
class CommandLocator;
}
@@ -203,7 +203,7 @@ private:
static PerforceVersionControl *perforceVersionControl();
- Locator::CommandLocator *m_commandLocator;
+ Core::CommandLocator *m_commandLocator;
Utils::ParameterAction *m_editAction;
Utils::ParameterAction *m_addAction;
Utils::ParameterAction *m_deleteAction;
diff --git a/src/plugins/perforce/perforceversioncontrol.cpp b/src/plugins/perforce/perforceversioncontrol.cpp
index 970f078cab..73cda711b8 100644
--- a/src/plugins/perforce/perforceversioncontrol.cpp
+++ b/src/plugins/perforce/perforceversioncontrol.cpp
@@ -82,8 +82,9 @@ bool PerforceVersionControl::supportsOperation(Operation operation) const
return false;
}
-Core::IVersionControl::OpenSupportMode PerforceVersionControl::openSupportMode() const
+Core::IVersionControl::OpenSupportMode PerforceVersionControl::openSupportMode(const QString &fileName) const
{
+ Q_UNUSED(fileName);
return OpenOptional;
}
diff --git a/src/plugins/perforce/perforceversioncontrol.h b/src/plugins/perforce/perforceversioncontrol.h
index 085eed0aab..7f9ab9d3cb 100644
--- a/src/plugins/perforce/perforceversioncontrol.h
+++ b/src/plugins/perforce/perforceversioncontrol.h
@@ -51,7 +51,7 @@ public:
bool isConfigured() const;
bool supportsOperation(Operation operation) const;
- OpenSupportMode openSupportMode() const;
+ OpenSupportMode openSupportMode(const QString &fileName) const;
bool vcsOpen(const QString &fileName);
SettingsFlags settingsFlags() const;
bool vcsAdd(const QString &fileName);
diff --git a/src/plugins/perforce/settingspage.cpp b/src/plugins/perforce/settingspage.cpp
index d2bae1dc2d..2391d5bd5d 100644
--- a/src/plugins/perforce/settingspage.cpp
+++ b/src/plugins/perforce/settingspage.cpp
@@ -48,6 +48,7 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
m_ui.setupUi(this);
m_ui.errorLabel->clear();
m_ui.pathChooser->setPromptDialogTitle(tr("Perforce Command"));
+ m_ui.pathChooser->setHistoryCompleter(QLatin1String("Perforce.Command.History"));
m_ui.pathChooser->setExpectedKind(PathChooser::Command);
connect(m_ui.testPushButton, SIGNAL(clicked()), this, SLOT(slotTest()));
}
@@ -142,12 +143,12 @@ SettingsPage::SettingsPage()
setDisplayName(tr("Perforce"));
}
-QWidget *SettingsPage::createPage(QWidget *parent)
+QWidget *SettingsPage::widget()
{
- m_widget = new SettingsPageWidget(parent);
- m_widget->setSettings(PerforcePlugin::settings());
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new SettingsPageWidget;
+ m_widget->setSettings(PerforcePlugin::settings());
+ }
return m_widget;
}
@@ -156,7 +157,7 @@ void SettingsPage::apply()
PerforcePlugin::setSettings(m_widget->settings());
}
-bool SettingsPage::matches(const QString &s) const
+void SettingsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
diff --git a/src/plugins/perforce/settingspage.h b/src/plugins/perforce/settingspage.h
index 84fba4f841..75e68e5642 100644
--- a/src/plugins/perforce/settingspage.h
+++ b/src/plugins/perforce/settingspage.h
@@ -49,7 +49,7 @@ class SettingsPageWidget : public QWidget
Q_OBJECT
public:
- explicit SettingsPageWidget(QWidget *parent);
+ explicit SettingsPageWidget(QWidget *parent = 0);
void setSettings(const PerforceSettings &);
Settings settings() const;
@@ -75,14 +75,12 @@ class SettingsPage : public VcsBase::VcsBaseOptionsPage
public:
SettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &) const;
+ void finish();
private:
- QString m_searchKeywords;
- SettingsPageWidget* m_widget;
+ QPointer<SettingsPageWidget> m_widget;
};
} // namespace Internal
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 31ea3da18a..4b4587e272 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -50,6 +50,12 @@ SUBDIRS = \
baremetal \
ios
+# prefer qmake variable set on command line over env var
+isEmpty(LLVM_INSTALL_DIR):LLVM_INSTALL_DIR=$$(LLVM_INSTALL_DIR)
+!isEmpty(LLVM_INSTALL_DIR) {
+ SUBDIRS += clangcodemodel
+}
+
isEmpty(QBS_INSTALL_DIR): QBS_INSTALL_DIR = $$(QBS_INSTALL_DIR)
exists(../shared/qbs/qbs.pro)|!isEmpty(QBS_INSTALL_DIR): \
SUBDIRS += \
@@ -83,9 +89,6 @@ for(p, SUBDIRS) {
$$pv = $$QTC_PLUGIN_DEPENDS
}
-SUBDIRS += debugger/dumper.pro
linux-* {
SUBDIRS += debugger/ptracepreload.pro
}
-
-include (debugger/lldblib/guest/qtcreator-lldb.pri)
diff --git a/src/plugins/plugins.qbs b/src/plugins/plugins.qbs
index cf301e0ade..757ec3200f 100644
--- a/src/plugins/plugins.qbs
+++ b/src/plugins/plugins.qbs
@@ -11,6 +11,7 @@ Project {
"bazaar/bazaar.qbs",
"bineditor/bineditor.qbs",
"bookmarks/bookmarks.qbs",
+ "clangcodemodel/clangcodemodel.qbs",
"classview/classview.qbs",
"clearcase/clearcase.qbs",
"cmakeprojectmanager/cmakeprojectmanager.qbs",
diff --git a/src/plugins/projectexplorer/abstractprocessstep.cpp b/src/plugins/projectexplorer/abstractprocessstep.cpp
index 01ce341880..bc2c499c23 100644
--- a/src/plugins/projectexplorer/abstractprocessstep.cpp
+++ b/src/plugins/projectexplorer/abstractprocessstep.cpp
@@ -188,6 +188,14 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi)
if (!wd.exists())
wd.mkpath(wd.absolutePath());
+ QString effectiveCommand = m_param.effectiveCommand();
+ if (!QFileInfo(effectiveCommand).exists()) {
+ processStartupFailed();
+ fi.reportResult(false);
+ emit finished();
+ return;
+ }
+
m_process = new Utils::QtcProcess();
#ifdef Q_OS_WIN
m_process->setUseCtrlCStub(true);
@@ -203,7 +211,7 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi)
connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)),
this, SLOT(slotProcessFinished(int,QProcess::ExitStatus)));
- m_process->setCommand(m_param.effectiveCommand(), m_param.effectiveArguments());
+ m_process->setCommand(effectiveCommand, m_param.effectiveArguments());
m_process->start();
if (!m_process->waitForStarted()) {
processStartupFailed();
diff --git a/src/plugins/projectexplorer/allprojectsfilter.cpp b/src/plugins/projectexplorer/allprojectsfilter.cpp
index 0c45806127..fe1e30b875 100644
--- a/src/plugins/projectexplorer/allprojectsfilter.cpp
+++ b/src/plugins/projectexplorer/allprojectsfilter.cpp
@@ -33,7 +33,6 @@
#include "project.h"
using namespace Core;
-using namespace Locator;
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
diff --git a/src/plugins/projectexplorer/allprojectsfilter.h b/src/plugins/projectexplorer/allprojectsfilter.h
index 38dae1ae14..0e5b79b561 100644
--- a/src/plugins/projectexplorer/allprojectsfilter.h
+++ b/src/plugins/projectexplorer/allprojectsfilter.h
@@ -30,14 +30,14 @@
#ifndef ALLPROJECTSFILTER_H
#define ALLPROJECTSFILTER_H
-#include <locator/basefilefilter.h>
+#include <coreplugin/locator/basefilefilter.h>
#include <QFutureInterface>
namespace ProjectExplorer {
namespace Internal {
-class AllProjectsFilter : public Locator::BaseFileFilter
+class AllProjectsFilter : public Core::BaseFileFilter
{
Q_OBJECT
diff --git a/src/plugins/projectexplorer/allprojectsfind.cpp b/src/plugins/projectexplorer/allprojectsfind.cpp
index cc93ff2af2..891480a651 100644
--- a/src/plugins/projectexplorer/allprojectsfind.cpp
+++ b/src/plugins/projectexplorer/allprojectsfind.cpp
@@ -43,7 +43,6 @@
#include <QGridLayout>
#include <QLabel>
-using namespace Find;
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
using namespace TextEditor;
@@ -83,7 +82,8 @@ Utils::FileIterator *AllProjectsFind::filesForProjects(const QStringList &nameFi
foreach (const QString &filter, nameFilters) {
filterRegs << QRegExp(filter, Qt::CaseInsensitive, QRegExp::Wildcard);
}
- QMap<QString, QTextCodec *> openEditorEncodings = TextEditor::ITextEditor::openedTextDocumentEncodings();
+ QMap<QString, QTextCodec *> openEditorEncodings
+ = TextEditor::ITextEditorDocument::openedTextDocumentEncodings();
QMap<QString, QTextCodec *> encodings;
foreach (const Project *project, projects) {
QStringList projectFiles = project->files(Project::AllFiles);
diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp
index 6606fd6127..38a0858fec 100644
--- a/src/plugins/projectexplorer/appoutputpane.cpp
+++ b/src/plugins/projectexplorer/appoutputpane.cpp
@@ -36,7 +36,7 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/outputwindow.h>
-#include <find/basetextfind.h>
+#include <coreplugin/find/basetextfind.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditorsettings.h>
#include <extensionsystem/pluginmanager.h>
@@ -101,7 +101,7 @@ void TabWidget::slotContextMenuRequested(const QPoint &pos)
}
AppOutputPane::RunControlTab::RunControlTab(RunControl *rc, Core::OutputWindow *w) :
- runControl(rc), window(w), asyncClosing(false), behavivorOnOutput(Flash)
+ runControl(rc), window(w), asyncClosing(false), behaviorOnOutput(Flash)
{
}
@@ -331,7 +331,7 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
ow->setMaxLineCount(ProjectExplorerPlugin::projectExplorerSettings().maxAppOutputLines);
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(ow);
- agg->add(new Find::BaseTextFind(ow));
+ agg->add(new Core::BaseTextFind(ow));
m_runControlTabs.push_back(RunControlTab(rc, ow));
m_tabWidget->addTab(ow, rc->displayName());
if (debug)
@@ -364,7 +364,7 @@ void AppOutputPane::appendMessage(RunControl *rc, const QString &out, Utils::Out
Core::OutputWindow *window = m_runControlTabs.at(index).window;
window->appendMessage(out, format);
if (format != Utils::NormalMessageFormat) {
- if (m_runControlTabs.at(index).behavivorOnOutput == Flash)
+ if (m_runControlTabs.at(index).behaviorOnOutput == Flash)
flash();
else
popup(NoModeSwitch);
@@ -377,11 +377,11 @@ void AppOutputPane::showTabFor(RunControl *rc)
m_tabWidget->setCurrentIndex(tabWidgetIndexOf(indexOf(rc)));
}
-void AppOutputPane::setBehaviorOnOutput(RunControl *rc, AppOutputPane::BehavivorOnOutput mode)
+void AppOutputPane::setBehaviorOnOutput(RunControl *rc, AppOutputPane::BehaviorOnOutput mode)
{
const int index = indexOf(rc);
if (index != -1)
- m_runControlTabs[index].behavivorOnOutput = mode;
+ m_runControlTabs[index].behaviorOnOutput = mode;
}
void AppOutputPane::reRunRunControl()
diff --git a/src/plugins/projectexplorer/appoutputpane.h b/src/plugins/projectexplorer/appoutputpane.h
index 7929ea8c05..01a70c84f3 100644
--- a/src/plugins/projectexplorer/appoutputpane.h
+++ b/src/plugins/projectexplorer/appoutputpane.h
@@ -60,7 +60,7 @@ public:
CloseTabWithPrompt
};
- enum BehavivorOnOutput {
+ enum BehaviorOnOutput {
Flash,
Popup
};
@@ -86,7 +86,7 @@ public:
void createNewOutputWindow(RunControl *rc);
void showTabFor(RunControl *rc);
- void setBehaviorOnOutput(RunControl *rc, BehavivorOnOutput mode);
+ void setBehaviorOnOutput(RunControl *rc, BehaviorOnOutput mode);
bool aboutToClose() const;
bool closeTabs(CloseTabMode mode);
@@ -130,7 +130,7 @@ private:
Core::OutputWindow *window;
// Is the run control stopping asynchronously, close the tab once it finishes
bool asyncClosing;
- BehavivorOnOutput behavivorOnOutput;
+ BehaviorOnOutput behaviorOnOutput;
};
bool isRunning() const;
diff --git a/src/plugins/projectexplorer/clangparser.cpp b/src/plugins/projectexplorer/clangparser.cpp
index 88747a054e..83bb2459bd 100644
--- a/src/plugins/projectexplorer/clangparser.cpp
+++ b/src/plugins/projectexplorer/clangparser.cpp
@@ -33,6 +33,15 @@
using namespace ProjectExplorer;
+static Task::TaskType taskType(const QString &capture)
+{
+ if (capture == QLatin1String("warning"))
+ return Task::Warning;
+ else if (capture == QLatin1String("note"))
+ return Task::Unknown;
+ return Task::Error;
+}
+
// opt. drive letter + filename: (2 brackets)
static const char * const FILE_PATTERN = "(<command line>|([A-Za-z]:)?[^:]+\\.[^:]+)";
@@ -60,15 +69,11 @@ void ClangParser::stdError(const QString &line)
if (m_commandRegExp.indexIn(lne) > -1) {
m_expectSnippet = true;
- Task task(Task::Error,
+ Task task(taskType(m_commandRegExp.cap(3)),
m_commandRegExp.cap(4),
Utils::FileName(), /* filename */
-1, /* line */
Constants::TASK_CATEGORY_COMPILE);
- if (m_commandRegExp.cap(3) == QLatin1String("warning"))
- task.type = Task::Warning;
- else if (m_commandRegExp.cap(3) == QLatin1String("note"))
- task.type = Task::Unknown;
newTask(task);
return;
}
@@ -89,15 +94,11 @@ void ClangParser::stdError(const QString &line)
int lineNo = m_messageRegExp.cap(4).toInt(&ok);
if (!ok)
lineNo = m_messageRegExp.cap(5).toInt(&ok);
- Task task(Task::Error,
+ Task task(taskType(m_messageRegExp.cap(7)),
m_messageRegExp.cap(8),
Utils::FileName::fromUserInput(m_messageRegExp.cap(1)), /* filename */
lineNo,
Core::Id(Constants::TASK_CATEGORY_COMPILE));
- if (m_messageRegExp.cap(7) == QLatin1String("warning"))
- task.type = Task::Warning;
- else if (m_messageRegExp.cap(7) == QLatin1String("note"))
- task.type = Task::Unknown;
newTask(task);
return;
}
diff --git a/src/plugins/projectexplorer/clangparser.h b/src/plugins/projectexplorer/clangparser.h
index af646e70ca..dc2f6ad962 100644
--- a/src/plugins/projectexplorer/clangparser.h
+++ b/src/plugins/projectexplorer/clangparser.h
@@ -37,7 +37,7 @@
namespace ProjectExplorer {
-class ClangParser : public ProjectExplorer::GccParser
+class PROJECTEXPLORER_EXPORT ClangParser : public ProjectExplorer::GccParser
{
Q_OBJECT
diff --git a/src/plugins/projectexplorer/compileoutputwindow.cpp b/src/plugins/projectexplorer/compileoutputwindow.cpp
index 539ad34f45..75df27230c 100644
--- a/src/plugins/projectexplorer/compileoutputwindow.cpp
+++ b/src/plugins/projectexplorer/compileoutputwindow.cpp
@@ -36,7 +36,7 @@
#include "taskhub.h"
#include <coreplugin/outputwindow.h>
-#include <find/basetextfind.h>
+#include <coreplugin/find/basetextfind.h>
#include <extensionsystem/pluginmanager.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h>
@@ -127,7 +127,7 @@ CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/, QAction *cancelB
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(m_outputWindow);
- agg->add(new Find::BaseTextFind(m_outputWindow));
+ agg->add(new Core::BaseTextFind(m_outputWindow));
qRegisterMetaType<QTextCharFormat>("QTextCharFormat");
diff --git a/src/plugins/projectexplorer/currentprojectfilter.cpp b/src/plugins/projectexplorer/currentprojectfilter.cpp
index 0d05f8ff91..dabee908b7 100644
--- a/src/plugins/projectexplorer/currentprojectfilter.cpp
+++ b/src/plugins/projectexplorer/currentprojectfilter.cpp
@@ -34,7 +34,6 @@
#include <QDebug>
using namespace Core;
-using namespace Locator;
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
diff --git a/src/plugins/projectexplorer/currentprojectfilter.h b/src/plugins/projectexplorer/currentprojectfilter.h
index f932b5aa20..25fe85a8ac 100644
--- a/src/plugins/projectexplorer/currentprojectfilter.h
+++ b/src/plugins/projectexplorer/currentprojectfilter.h
@@ -30,7 +30,7 @@
#ifndef CURRENTPROJECTFILTER_H
#define CURRENTPROJECTFILTER_H
-#include <locator/basefilefilter.h>
+#include <coreplugin/locator/basefilefilter.h>
#include <QFutureInterface>
@@ -40,7 +40,7 @@ class Project;
namespace Internal {
-class CurrentProjectFilter : public Locator::BaseFileFilter
+class CurrentProjectFilter : public Core::BaseFileFilter
{
Q_OBJECT
diff --git a/src/plugins/projectexplorer/currentprojectfind.cpp b/src/plugins/projectexplorer/currentprojectfind.cpp
index c0b89a8bfb..8b7fce4778 100644
--- a/src/plugins/projectexplorer/currentprojectfind.cpp
+++ b/src/plugins/projectexplorer/currentprojectfind.cpp
@@ -39,7 +39,6 @@
#include <QDebug>
#include <QSettings>
-using namespace Find;
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
using namespace TextEditor;
@@ -103,7 +102,7 @@ void CurrentProjectFind::handleProjectChanged()
void CurrentProjectFind::recheckEnabled()
{
- SearchResult *search = qobject_cast<SearchResult *>(sender());
+ Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
if (!search)
return;
QString projectFile = getAdditionalParameters(search).toString();
diff --git a/src/plugins/projectexplorer/customtoolchain.cpp b/src/plugins/projectexplorer/customtoolchain.cpp
index 490350bdc6..104da390d4 100644
--- a/src/plugins/projectexplorer/customtoolchain.cpp
+++ b/src/plugins/projectexplorer/customtoolchain.cpp
@@ -501,7 +501,9 @@ CustomToolChainConfigWidget::CustomToolChainConfigWidget(CustomToolChain *tc) :
m_cxx11Flags->setToolTip(tr("Comma-separated list of flags that turn on C++11 support."));
m_mkspecs->setToolTip(tr("Comma-separated list of mkspecs."));
m_compilerCommand->setExpectedKind(PathChooser::ExistingCommand);
+ m_compilerCommand->setHistoryCompleter(QLatin1String("PE.ToolChainCommand.History"));
m_makeCommand->setExpectedKind(PathChooser::ExistingCommand);
+ m_makeCommand->setHistoryCompleter(QLatin1String("PE.MakeCommand.History"));
m_mainLayout->addRow(tr("&Compiler path:"), m_compilerCommand);
m_mainLayout->addRow(tr("&Make path:"), m_makeCommand);
m_mainLayout->addRow(tr("&ABI:"), m_abiWidget);
diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp
index 8fba42afce..379819824f 100644
--- a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp
+++ b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp
@@ -336,6 +336,7 @@ QWidget *CustomWizardFieldPage::registerPathChooser(const QString &fieldName,
pathChooser->setExpectedKind(Utils::PathChooser::Command);
else if (expectedKind == QLatin1String("any"))
pathChooser->setExpectedKind(Utils::PathChooser::Any);
+ pathChooser->setHistoryCompleter(QString::fromLatin1("PE.Custom.") + m_parameters->id + QLatin1Char('.') + field.name);
registerField(fieldName, pathChooser, "path", SIGNAL(changed(QString)));
// Connect to completeChanged() for derived classes that reimplement isComplete()
@@ -523,6 +524,7 @@ CustomWizardPage::CustomWizardPage(const QSharedPointer<CustomWizardContext> &ct
CustomWizardFieldPage(ctx, parameters, parent),
m_pathChooser(new Utils::PathChooser)
{
+ m_pathChooser->setHistoryCompleter(QLatin1String("PE.ProjectDir.History"));
addRow(tr("Path:"), m_pathChooser);
connect(m_pathChooser, SIGNAL(validChanged()), this, SIGNAL(completeChanged()));
}
diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp
index 976cf733cb..f17cd3a843 100644
--- a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp
+++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp
@@ -587,6 +587,7 @@ CustomWizardParameters::ParseResult
if (!booleanAttributeValue(reader, wizardEnabledAttributeC, true))
return ParseDisabled;
bp->id = attributeValue(reader, idAttributeC);
+ id = bp->id;
bp->category = attributeValue(reader, categoryAttributeC);
bp->kind = kindAttribute(reader);
bp->requiredFeatures = requiredFeatures(reader);
diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.h b/src/plugins/projectexplorer/customwizard/customwizardparameters.h
index 3d92e6634a..c566e4979f 100644
--- a/src/plugins/projectexplorer/customwizard/customwizardparameters.h
+++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.h
@@ -111,6 +111,7 @@ public:
Core::IWizard::Data *bp, QString *errorMessage);
QString toString() const;
+ QString id;
QString directory;
QString klass;
QList<CustomWizardFile> files;
diff --git a/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.cpp b/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.cpp
index 04d0fc9b91..68c839ccc3 100644
--- a/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.cpp
+++ b/src/plugins/projectexplorer/devicesupport/deviceapplicationrunner.cpp
@@ -35,7 +35,6 @@
#include <utils/environment.h>
#include <utils/qtcassert.h>
-#include <QCoreApplication>
#include <QStringList>
#include <QTimer>
@@ -101,8 +100,7 @@ void DeviceApplicationRunner::start(const IDevice::ConstPtr &device,
}
if (command.isEmpty()) {
- emit reportError(QCoreApplication::translate("RemoteLinux::RemoteLinuxRunConfiguration",
- "Don't know what to run.")); // FIXME: Transitional message for 3.0.
+ emit reportError(tr("Cannot run: No command given."));
setFinished();
return;
}
diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingspage.cpp b/src/plugins/projectexplorer/devicesupport/devicesettingspage.cpp
index d31973b04f..833b02a083 100644
--- a/src/plugins/projectexplorer/devicesupport/devicesettingspage.cpp
+++ b/src/plugins/projectexplorer/devicesupport/devicesettingspage.cpp
@@ -48,16 +48,10 @@ DeviceSettingsPage::DeviceSettingsPage(QObject *parent)
setCategoryIcon(QLatin1String(":/projectexplorer/images/MaemoDevice.png"));
}
-bool DeviceSettingsPage::matches(const QString &searchKeyWord) const
+QWidget *DeviceSettingsPage::widget()
{
- return m_keywords.contains(searchKeyWord, Qt::CaseInsensitive);
-}
-
-QWidget *DeviceSettingsPage::createPage(QWidget *parent)
-{
- m_widget = new DeviceSettingsWidget(parent);
- if (m_keywords.isEmpty())
- m_keywords = m_widget->searchKeywords();
+ if (!m_widget)
+ m_widget = new DeviceSettingsWidget;
return m_widget;
}
@@ -68,6 +62,7 @@ void DeviceSettingsPage::apply()
void DeviceSettingsPage::finish()
{
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingspage.h b/src/plugins/projectexplorer/devicesupport/devicesettingspage.h
index 2719694797..97c85dca13 100644
--- a/src/plugins/projectexplorer/devicesupport/devicesettingspage.h
+++ b/src/plugins/projectexplorer/devicesupport/devicesettingspage.h
@@ -31,6 +31,8 @@
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
namespace ProjectExplorer {
namespace Internal {
@@ -43,14 +45,12 @@ class DeviceSettingsPage : public Core::IOptionsPage
public:
DeviceSettingsPage(QObject *parent = 0);
- bool matches(const QString &searchKeyWord) const;
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
private:
- QString m_keywords;
- DeviceSettingsWidget *m_widget;
+ QPointer<DeviceSettingsWidget> m_widget;
};
} // namespace Internal
diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.h b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.h
index e69baeed2c..1d25a6e4c0 100644
--- a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.h
+++ b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.h
@@ -55,7 +55,7 @@ class DeviceSettingsWidget : public QWidget
{
Q_OBJECT
public:
- DeviceSettingsWidget(QWidget *parent);
+ DeviceSettingsWidget(QWidget *parent = 0);
~DeviceSettingsWidget();
void saveSettings();
diff --git a/src/plugins/projectexplorer/editorconfiguration.cpp b/src/plugins/projectexplorer/editorconfiguration.cpp
index 10f27bbc38..4a61566ca7 100644
--- a/src/plugins/projectexplorer/editorconfiguration.cpp
+++ b/src/plugins/projectexplorer/editorconfiguration.cpp
@@ -42,6 +42,7 @@
#include <texteditor/behaviorsettings.h>
#include <texteditor/extraencodingsettings.h>
#include <texteditor/tabsettings.h>
+#include <texteditor/marginsettings.h>
#include <texteditor/icodestylepreferencesfactory.h>
#include <QLatin1String>
@@ -77,6 +78,7 @@ struct EditorConfigurationPrivate
StorageSettings m_storageSettings;
BehaviorSettings m_behaviorSettings;
ExtraEncodingSettings m_extraEncodingSettings;
+ MarginSettings m_marginSettings;
QTextCodec *m_textCodec;
QMap<Core::Id, ICodeStylePreferences *> m_languageCodeStylePreferences;
@@ -134,6 +136,7 @@ void EditorConfiguration::cloneGlobalSettings()
setStorageSettings(TextEditorSettings::storageSettings());
setBehaviorSettings(TextEditorSettings::behaviorSettings());
setExtraEncodingSettings(TextEditorSettings::extraEncodingSettings());
+ setMarginSettings(TextEditorSettings::marginSettings());
d->m_textCodec = Core::EditorManager::defaultTextCodec();
}
@@ -162,6 +165,11 @@ const ExtraEncodingSettings &EditorConfiguration::extraEncodingSettings() const
return d->m_extraEncodingSettings;
}
+const MarginSettings &EditorConfiguration::marginSettings() const
+{
+ return d->m_marginSettings;
+}
+
ICodeStylePreferences *EditorConfiguration::codeStyle() const
{
return d->m_defaultCodeStyle;
@@ -202,6 +210,7 @@ QVariantMap EditorConfiguration::toMap() const
d->m_storageSettings.toMap(kPrefix, &map);
d->m_behaviorSettings.toMap(kPrefix, &map);
d->m_extraEncodingSettings.toMap(kPrefix, &map);
+ d->m_marginSettings.toMap(kPrefix, &map);
return map;
}
@@ -234,6 +243,7 @@ void EditorConfiguration::fromMap(const QVariantMap &map)
d->m_storageSettings.fromMap(kPrefix, map);
d->m_behaviorSettings.fromMap(kPrefix, map);
d->m_extraEncodingSettings.fromMap(kPrefix, map);
+ d->m_marginSettings.fromMap(kPrefix, map);
}
void EditorConfiguration::configureEditor(ITextEditor *textEditor) const
@@ -276,6 +286,8 @@ void EditorConfiguration::setUseGlobalSettings(bool use)
static void switchSettings_helper(const QObject *newSender, const QObject *oldSender,
BaseTextEditorWidget *baseTextEditor)
{
+ QObject::disconnect(oldSender, SIGNAL(marginSettingsChanged(TextEditor::MarginSettings)),
+ baseTextEditor, SLOT(setMarginSettings(TextEditor::MarginSettings)));
QObject::disconnect(oldSender, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
baseTextEditor, SLOT(setTypingSettings(TextEditor::TypingSettings)));
QObject::disconnect(oldSender, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
@@ -285,6 +297,8 @@ static void switchSettings_helper(const QObject *newSender, const QObject *oldSe
QObject::disconnect(oldSender, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)),
baseTextEditor, SLOT(setExtraEncodingSettings(TextEditor::ExtraEncodingSettings)));
+ QObject::connect(newSender, SIGNAL(marginSettingsChanged(TextEditor::MarginSettings)),
+ baseTextEditor, SLOT(setMarginSettings(TextEditor::MarginSettings)));
QObject::connect(newSender, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
baseTextEditor, SLOT(setTypingSettings(TextEditor::TypingSettings)));
QObject::connect(newSender, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
@@ -298,12 +312,14 @@ static void switchSettings_helper(const QObject *newSender, const QObject *oldSe
void EditorConfiguration::switchSettings(BaseTextEditorWidget *baseTextEditor) const
{
if (d->m_useGlobal) {
+ baseTextEditor->setMarginSettings(TextEditorSettings::marginSettings());
baseTextEditor->setTypingSettings(TextEditorSettings::typingSettings());
baseTextEditor->setStorageSettings(TextEditorSettings::storageSettings());
baseTextEditor->setBehaviorSettings(TextEditorSettings::behaviorSettings());
baseTextEditor->setExtraEncodingSettings(TextEditorSettings::extraEncodingSettings());
switchSettings_helper(TextEditorSettings::instance(), this, baseTextEditor);
} else {
+ baseTextEditor->setMarginSettings(marginSettings());
baseTextEditor->setTypingSettings(typingSettings());
baseTextEditor->setStorageSettings(storageSettings());
baseTextEditor->setBehaviorSettings(behaviorSettings());
@@ -336,11 +352,35 @@ void EditorConfiguration::setExtraEncodingSettings(const TextEditor::ExtraEncodi
emit extraEncodingSettingsChanged(d->m_extraEncodingSettings);
}
+void EditorConfiguration::setMarginSettings(const MarginSettings &settings)
+{
+ if (d->m_marginSettings != settings) {
+ d->m_marginSettings = settings;
+ emit marginSettingsChanged(d->m_marginSettings);
+ }
+}
+
void EditorConfiguration::setTextCodec(QTextCodec *textCodec)
{
d->m_textCodec = textCodec;
}
+void EditorConfiguration::setShowWrapColumn(bool onoff)
+{
+ if (d->m_marginSettings.m_showMargin != onoff) {
+ d->m_marginSettings.m_showMargin = onoff;
+ emit marginSettingsChanged(d->m_marginSettings);
+ }
+}
+
+void EditorConfiguration::setWrapColumn(int column)
+{
+ if (d->m_marginSettings.m_marginColumn != column) {
+ d->m_marginSettings.m_marginColumn = column;
+ emit marginSettingsChanged(d->m_marginSettings);
+ }
+}
+
void EditorConfiguration::slotAboutToRemoveProject(ProjectExplorer::Project *project)
{
if (project->editorConfiguration() != this)
diff --git a/src/plugins/projectexplorer/editorconfiguration.h b/src/plugins/projectexplorer/editorconfiguration.h
index 8e64837e00..d4652cf7f2 100644
--- a/src/plugins/projectexplorer/editorconfiguration.h
+++ b/src/plugins/projectexplorer/editorconfiguration.h
@@ -46,6 +46,7 @@ class TypingSettings;
class StorageSettings;
class BehaviorSettings;
class ExtraEncodingSettings;
+class MarginSettings;
}
namespace ProjectExplorer {
@@ -72,6 +73,7 @@ public:
const TextEditor::StorageSettings &storageSettings() const;
const TextEditor::BehaviorSettings &behaviorSettings() const;
const TextEditor::ExtraEncodingSettings &extraEncodingSettings() const;
+ const TextEditor::MarginSettings &marginSettings() const;
TextEditor::ICodeStylePreferences *codeStyle() const;
TextEditor::ICodeStylePreferences *codeStyle(Core::Id languageId) const;
@@ -88,6 +90,7 @@ signals:
void storageSettingsChanged(const TextEditor::StorageSettings &);
void behaviorSettingsChanged(const TextEditor::BehaviorSettings &);
void extraEncodingSettingsChanged(const TextEditor::ExtraEncodingSettings &);
+ void marginSettingsChanged(const TextEditor::MarginSettings &);
private slots:
@@ -95,6 +98,10 @@ private slots:
void setStorageSettings(const TextEditor::StorageSettings &settings);
void setBehaviorSettings(const TextEditor::BehaviorSettings &settings);
void setExtraEncodingSettings(const TextEditor::ExtraEncodingSettings &settings);
+ void setMarginSettings(const TextEditor::MarginSettings &settings);
+
+ void setShowWrapColumn(bool onoff);
+ void setWrapColumn(int column);
void setTextCodec(QTextCodec *textCodec);
diff --git a/src/plugins/projectexplorer/editorsettingspropertiespage.cpp b/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
index e2e4526102..3382b83ab3 100644
--- a/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
+++ b/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
@@ -30,6 +30,7 @@
#include "editorsettingspropertiespage.h"
#include "editorconfiguration.h"
#include "project.h"
+#include <texteditor/marginsettings.h>
#include <QTextCodec>
@@ -78,6 +79,10 @@ EditorSettingsWidget::EditorSettingsWidget(Project *project) : QWidget(), m_proj
connect(m_ui.globalSelector, SIGNAL(activated(int)),
this, SLOT(globalSettingsActivated(int)));
connect(m_ui.restoreButton, SIGNAL(clicked()), this, SLOT(restoreDefaultValues()));
+
+ connect(m_ui.showWrapColumn, SIGNAL(toggled(bool)), config, SLOT(setShowWrapColumn(bool)));
+ connect(m_ui.wrapColumn, SIGNAL(valueChanged(int)), config, SLOT(setWrapColumn(int)));
+
connect(m_ui.behaviorSettingsWidget, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
config, SLOT(setTypingSettings(TextEditor::TypingSettings)));
connect(m_ui.behaviorSettingsWidget, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
@@ -92,6 +97,8 @@ EditorSettingsWidget::EditorSettingsWidget(Project *project) : QWidget(), m_proj
void EditorSettingsWidget::settingsToUi(const EditorConfiguration *config)
{
+ m_ui.showWrapColumn->setChecked(config->marginSettings().m_showMargin);
+ m_ui.wrapColumn->setValue(config->marginSettings().m_marginColumn);
m_ui.behaviorSettingsWidget->setCodeStyle(config->codeStyle());
m_ui.globalSelector->setCurrentIndex(config->useGlobalSettings() ? 0 : 1);
m_ui.behaviorSettingsWidget->setAssignedCodec(config->textCodec());
@@ -104,6 +111,7 @@ void EditorSettingsWidget::settingsToUi(const EditorConfiguration *config)
void EditorSettingsWidget::globalSettingsActivated(int index)
{
const bool useGlobal = !index;
+ m_ui.displaySettings->setEnabled(!useGlobal);
m_ui.behaviorSettingsWidget->setActive(!useGlobal);
m_ui.restoreButton->setEnabled(!useGlobal);
EditorConfiguration *config = m_project->editorConfiguration();
diff --git a/src/plugins/projectexplorer/editorsettingspropertiespage.ui b/src/plugins/projectexplorer/editorsettingspropertiespage.ui
index 785976a307..5a2ab33188 100644
--- a/src/plugins/projectexplorer/editorsettingspropertiespage.ui
+++ b/src/plugins/projectexplorer/editorsettingspropertiespage.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>401</width>
- <height>111</height>
+ <height>173</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
@@ -56,9 +56,51 @@
</spacer>
</item>
<item row="1" column="0" colspan="4">
+ <widget class="QGroupBox" name="displaySettings">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string>Display Settings</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QCheckBox" name="showWrapColumn">
+ <property name="text">
+ <string>Display right &amp;margin at column:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="wrapColumn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maximum">
+ <number>999</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>53</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="4">
<widget class="TextEditor::BehaviorSettingsWidget" name="behaviorSettingsWidget" native="true"/>
</item>
- <item row="2" column="0">
+ <item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -82,5 +124,22 @@
</customwidget>
</customwidgets>
<resources/>
- <connections/>
+ <connections>
+ <connection>
+ <sender>showWrapColumn</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>wrapColumn</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>211</x>
+ <y>75</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>283</x>
+ <y>82</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
</ui>
diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp
index 4e836e0cd4..1ca24358ed 100644
--- a/src/plugins/projectexplorer/foldernavigationwidget.cpp
+++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp
@@ -38,8 +38,8 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/fileutils.h>
+#include <coreplugin/find/findplugin.h>
-#include <find/findplugin.h>
#include <texteditor/findinfiles.h>
#include <utils/hostosinfo.h>
diff --git a/src/plugins/projectexplorer/gccparser.cpp b/src/plugins/projectexplorer/gccparser.cpp
index 2c318b5530..1df98096e4 100644
--- a/src/plugins/projectexplorer/gccparser.cpp
+++ b/src/plugins/projectexplorer/gccparser.cpp
@@ -87,38 +87,34 @@ void GccParser::stdError(const QString &line)
return;
} else if (m_regExpGccNames.indexIn(lne) > -1) {
QString description = lne.mid(m_regExpGccNames.matchedLength());
- Task task(Task::Error,
- description,
- Utils::FileName(), /* filename */
- -1, /* line */
- Constants::TASK_CATEGORY_COMPILE);
+ Task::TaskType type = Task::Error;
if (description.startsWith(QLatin1String("warning: "))) {
- task.type = Task::Warning;
- task.description = description.mid(9);
+ type = Task::Warning;
+ description = description.mid(9);
} else if (description.startsWith(QLatin1String("fatal: "))) {
- task.description = description.mid(7);
+ description = description.mid(7);
}
+ Task task(type, description, Utils::FileName(), /* filename */
+ -1, /* line */ Constants::TASK_CATEGORY_COMPILE);
newTask(task);
return;
} else if (m_regExp.indexIn(lne) > -1) {
Utils::FileName filename = Utils::FileName::fromUserInput(m_regExp.cap(1));
int lineno = m_regExp.cap(3).toInt();
- Task task(Task::Unknown,
- m_regExp.cap(8) /* description */,
- filename, lineno,
- Constants::TASK_CATEGORY_COMPILE);
+ Task::TaskType type = Task::Unknown;
+ QString description = m_regExp.cap(8);
if (m_regExp.cap(7) == QLatin1String("warning"))
- task.type = Task::Warning;
+ type = Task::Warning;
else if (m_regExp.cap(7) == QLatin1String("error") ||
- task.description.startsWith(QLatin1String("undefined reference to")) ||
- task.description.startsWith(QLatin1String("multiple definition of")))
- task.type = Task::Error;
-
+ description.startsWith(QLatin1String("undefined reference to")) ||
+ description.startsWith(QLatin1String("multiple definition of")))
+ type = Task::Error;
// Prepend "#warning" or "#error" if that triggered the match on (warning|error)
// We want those to show how the warning was triggered
if (m_regExp.cap(5).startsWith(QLatin1Char('#')))
- task.description = m_regExp.cap(5) + task.description;
+ description = m_regExp.cap(5) + description;
+ Task task(type, description, filename, lineno, Constants::TASK_CATEGORY_COMPILE);
newTask(task);
return;
} else if (m_regExpIncluded.indexIn(lne) > -1) {
diff --git a/src/plugins/projectexplorer/gccparser.h b/src/plugins/projectexplorer/gccparser.h
index e46cd91c23..b426a00fb4 100644
--- a/src/plugins/projectexplorer/gccparser.h
+++ b/src/plugins/projectexplorer/gccparser.h
@@ -38,7 +38,7 @@
namespace ProjectExplorer {
-class GccParser : public ProjectExplorer::IOutputParser
+class PROJECTEXPLORER_EXPORT GccParser : public ProjectExplorer::IOutputParser
{
Q_OBJECT
diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp
index ffef33ef95..11de8e27f2 100644
--- a/src/plugins/projectexplorer/gcctoolchain.cpp
+++ b/src/plugins/projectexplorer/gcctoolchain.cpp
@@ -403,7 +403,9 @@ QByteArray GccToolChain::predefinedMacros(const QStringList &cxxflags) const
|| a.startsWith(QLatin1String("-specs="))
|| a == QLatin1String("-ansi") || a == QLatin1String("-undef")
|| a.startsWith(QLatin1String("-D")) || a.startsWith(QLatin1String("-U"))
- || a == QLatin1String("-fopenmp") || a == QLatin1String("-Wno-deprecated"))
+ || a == QLatin1String("-fopenmp") || a == QLatin1String("-Wno-deprecated")
+ || a == QLatin1String("-fPIC") || a == QLatin1String("-fpic")
+ || a == QLatin1String("-fPIE") || a == QLatin1String("-fpie"))
arguments << a;
}
macros = gccPredefinedMacros(m_compilerCommand, reinterpretOptions(arguments),
@@ -852,6 +854,7 @@ GccToolChainConfigWidget::GccToolChainConfigWidget(GccToolChain *tc) :
const QStringList gnuVersionArgs = QStringList(QLatin1String("--version"));
m_compilerCommand->setExpectedKind(PathChooser::ExistingCommand);
m_compilerCommand->setCommandVersionArguments(gnuVersionArgs);
+ m_compilerCommand->setHistoryCompleter(QLatin1String("PE.Gcc.Command.History"));
m_mainLayout->addRow(tr("&Compiler path:"), m_compilerCommand);
m_platformCodeGenFlagsLineEdit = new QLineEdit(this);
m_platformCodeGenFlagsLineEdit->setText(QtcProcess::joinArgs(tc->platformCodeGenFlags()));
diff --git a/src/plugins/projectexplorer/importwidget.cpp b/src/plugins/projectexplorer/importwidget.cpp
index f39e6d11ea..eb7e34ee2e 100644
--- a/src/plugins/projectexplorer/importwidget.cpp
+++ b/src/plugins/projectexplorer/importwidget.cpp
@@ -59,6 +59,7 @@ ImportWidget::ImportWidget(QWidget *parent) :
layout->addWidget(m_pathChooser);
m_pathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
+ m_pathChooser->setHistoryCompleter(QLatin1String("SourceDir.History"));
QPushButton *importButton = new QPushButton(tr("Import"), widget);
layout->addWidget(importButton);
diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp
index 208fdeaac0..1e25cbdfee 100644
--- a/src/plugins/projectexplorer/kit.cpp
+++ b/src/plugins/projectexplorer/kit.cpp
@@ -49,6 +49,7 @@ namespace {
const char ID_KEY[] = "PE.Profile.Id";
const char DISPLAYNAME_KEY[] = "PE.Profile.Name";
const char AUTODETECTED_KEY[] = "PE.Profile.AutoDetected";
+const char AUTODETECTIONSOURCE_KEY[] = "PE.Profile.AutoDetectionSource";
const char SDK_PROVIDED_KEY[] = "PE.Profile.SDK";
const char DATA_KEY[] = "PE.Profile.Data";
const char ICON_KEY[] = "PE.Profile.Icon";
@@ -71,6 +72,7 @@ public:
m_id(id),
m_nestedBlockingLevel(0),
m_autodetected(false),
+ m_autoDetectionSource(QString()),
m_sdkProvided(false),
m_isValid(true),
m_hasWarning(false),
@@ -89,6 +91,7 @@ public:
Id m_id;
int m_nestedBlockingLevel;
bool m_autodetected;
+ QString m_autoDetectionSource;
bool m_sdkProvided;
bool m_isValid;
bool m_hasWarning;
@@ -124,6 +127,7 @@ Kit::Kit(const QVariantMap &data) :
d->m_id = Id::fromSetting(data.value(QLatin1String(ID_KEY)));
d->m_autodetected = data.value(QLatin1String(AUTODETECTED_KEY)).toBool();
+ d->m_autoDetectionSource = data.value(QLatin1String(AUTODETECTIONSOURCE_KEY)).toString();
// if we don't have that setting assume that autodetected implies sdk
QVariant value = data.value(QLatin1String(SDK_PROVIDED_KEY));
@@ -197,6 +201,7 @@ void Kit::copyFrom(const Kit *k)
d->m_iconPath = k->d->m_iconPath;
d->m_icon = k->d->m_icon;
d->m_autodetected = k->d->m_autodetected;
+ d->m_autoDetectionSource = k->d->m_autoDetectionSource;
d->m_displayName = k->d->m_displayName;
d->m_mustNotify = true;
d->m_mustNotifyAboutDisplayName = true;
@@ -321,6 +326,11 @@ bool Kit::isAutoDetected() const
return d->m_autodetected;
}
+QString Kit::autoDetectionSource() const
+{
+ return d->m_autoDetectionSource;
+}
+
bool Kit::isSdkProvided() const
{
return d->m_sdkProvided;
@@ -418,11 +428,12 @@ QVariantMap Kit::toMap() const
data.insert(QLatin1String(ID_KEY), QString::fromLatin1(d->m_id.name()));
data.insert(QLatin1String(DISPLAYNAME_KEY), d->m_displayName);
data.insert(QLatin1String(AUTODETECTED_KEY), d->m_autodetected);
+ data.insert(QLatin1String(AUTODETECTIONSOURCE_KEY), d->m_autoDetectionSource);
data.insert(QLatin1String(SDK_PROVIDED_KEY), d->m_sdkProvided);
data.insert(QLatin1String(ICON_KEY), d->m_iconPath.toString());
QStringList mutableInfo;
- foreach (const Core::Id &id, d->m_mutable.values())
+ foreach (const Core::Id &id, d->m_mutable)
mutableInfo << id.toString();
data.insert(QLatin1String(MUTABLE_INFO_KEY), mutableInfo);
@@ -496,6 +507,11 @@ void Kit::setAutoDetected(bool detected)
d->m_autodetected = detected;
}
+void Kit::setAutoDetectionSource(const QString &autoDetectionSource)
+{
+ d->m_autoDetectionSource = autoDetectionSource;
+}
+
void Kit::setSdkProvided(bool sdkProvided)
{
d->m_sdkProvided = sdkProvided;
diff --git a/src/plugins/projectexplorer/kit.h b/src/plugins/projectexplorer/kit.h
index 284babf3e1..d8e3adc27e 100644
--- a/src/plugins/projectexplorer/kit.h
+++ b/src/plugins/projectexplorer/kit.h
@@ -76,6 +76,7 @@ public:
QString fileSystemFriendlyName() const;
bool isAutoDetected() const;
+ QString autoDetectionSource() const;
bool isSdkProvided() const;
Core::Id id() const;
@@ -102,6 +103,7 @@ public:
// Note: Stickyness is *not* saved!
void setAutoDetected(bool detected);
+ void setAutoDetectionSource(const QString &autoDetectionSource);
void makeSticky();
void setSticky(Core::Id id, bool b);
void makeUnSticky();
diff --git a/src/plugins/projectexplorer/kitinformationconfigwidget.cpp b/src/plugins/projectexplorer/kitinformationconfigwidget.cpp
index 98bcc340c8..e93b8cb4f1 100644
--- a/src/plugins/projectexplorer/kitinformationconfigwidget.cpp
+++ b/src/plugins/projectexplorer/kitinformationconfigwidget.cpp
@@ -61,6 +61,7 @@ SysRootInformationConfigWidget::SysRootInformationConfigWidget(Kit *k, const Kit
{
m_chooser = new Utils::PathChooser;
m_chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
+ m_chooser->setHistoryCompleter(QLatin1String("PE.SysRoot.History"));
m_chooser->setFileName(SysRootKitInformation::sysRoot(k));
connect(m_chooser, SIGNAL(changed(QString)), this, SLOT(pathWasChanged()));
}
diff --git a/src/plugins/projectexplorer/kitoptionspage.cpp b/src/plugins/projectexplorer/kitoptionspage.cpp
index 7f81bdbb23..4e81d40ca8 100644
--- a/src/plugins/projectexplorer/kitoptionspage.cpp
+++ b/src/plugins/projectexplorer/kitoptionspage.cpp
@@ -59,76 +59,75 @@ KitOptionsPage::KitOptionsPage() :
setCategoryIcon(QLatin1String(Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON));
}
-QWidget *KitOptionsPage::createPage(QWidget *parent)
+QWidget *KitOptionsPage::widget()
{
- m_configWidget = new QWidget(parent);
+ if (!m_configWidget) {
+ m_configWidget = new QWidget;
- m_kitsView = new QTreeView(m_configWidget);
- m_kitsView->setUniformRowHeights(true);
- m_kitsView->header()->setStretchLastSection(true);
- m_kitsView->setSizePolicy(m_kitsView->sizePolicy().horizontalPolicy(),
+ m_kitsView = new QTreeView(m_configWidget);
+ m_kitsView->setUniformRowHeights(true);
+ m_kitsView->header()->setStretchLastSection(true);
+ m_kitsView->setSizePolicy(m_kitsView->sizePolicy().horizontalPolicy(),
QSizePolicy::Ignored);
- m_addButton = new QPushButton(tr("Add"), m_configWidget);
- m_cloneButton = new QPushButton(tr("Clone"), m_configWidget);
- m_delButton = new QPushButton(tr("Remove"), m_configWidget);
- m_makeDefaultButton = new QPushButton(tr("Make Default"), m_configWidget);
-
- QVBoxLayout *buttonLayout = new QVBoxLayout();
- buttonLayout->setSpacing(6);
- buttonLayout->setContentsMargins(0, 0, 0, 0);
- buttonLayout->addWidget(m_addButton);
- buttonLayout->addWidget(m_cloneButton);
- buttonLayout->addWidget(m_delButton);
- buttonLayout->addWidget(m_makeDefaultButton);
- buttonLayout->addStretch();
-
- QHBoxLayout *horizontalLayout = new QHBoxLayout();
- horizontalLayout->addWidget(m_kitsView);
- horizontalLayout->addLayout(buttonLayout);
-
- QVBoxLayout *verticalLayout = new QVBoxLayout(m_configWidget);
- verticalLayout->addLayout(horizontalLayout);
-
- m_model = new Internal::KitModel(verticalLayout);
- connect(m_model, SIGNAL(kitStateChanged()), this, SLOT(updateState()));
- verticalLayout->setStretch(0, 1);
- verticalLayout->setStretch(1, 0);
-
- m_kitsView->setModel(m_model);
- m_kitsView->header()->setResizeMode(0, QHeaderView::Stretch);
- m_kitsView->expandAll();
-
- m_selectionModel = m_kitsView->selectionModel();
- connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
- this, SLOT(kitSelectionChanged()));
- connect(KitManager::instance(), SIGNAL(kitAdded(ProjectExplorer::Kit*)),
- this, SLOT(kitSelectionChanged()));
- connect(KitManager::instance(), SIGNAL(kitRemoved(ProjectExplorer::Kit*)),
- this, SLOT(kitSelectionChanged()));
- connect(KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
- this, SLOT(kitSelectionChanged()));
-
- // Set up add menu:
- connect(m_addButton, SIGNAL(clicked()), this, SLOT(addNewKit()));
- connect(m_cloneButton, SIGNAL(clicked()), this, SLOT(cloneKit()));
- connect(m_delButton, SIGNAL(clicked()), this, SLOT(removeKit()));
- connect(m_makeDefaultButton, SIGNAL(clicked()), this, SLOT(makeDefaultKit()));
-
- m_searchKeywords = tr("Kits");
-
- updateState();
-
- if (m_toShow) {
- QModelIndex index = m_model->indexOf(m_toShow);
- m_selectionModel->select(index,
- QItemSelectionModel::Clear
- | QItemSelectionModel::SelectCurrent
- | QItemSelectionModel::Rows);
- m_kitsView->scrollTo(index);
+ m_addButton = new QPushButton(tr("Add"), m_configWidget);
+ m_cloneButton = new QPushButton(tr("Clone"), m_configWidget);
+ m_delButton = new QPushButton(tr("Remove"), m_configWidget);
+ m_makeDefaultButton = new QPushButton(tr("Make Default"), m_configWidget);
+
+ QVBoxLayout *buttonLayout = new QVBoxLayout();
+ buttonLayout->setSpacing(6);
+ buttonLayout->setContentsMargins(0, 0, 0, 0);
+ buttonLayout->addWidget(m_addButton);
+ buttonLayout->addWidget(m_cloneButton);
+ buttonLayout->addWidget(m_delButton);
+ buttonLayout->addWidget(m_makeDefaultButton);
+ buttonLayout->addStretch();
+
+ QHBoxLayout *horizontalLayout = new QHBoxLayout();
+ horizontalLayout->addWidget(m_kitsView);
+ horizontalLayout->addLayout(buttonLayout);
+
+ QVBoxLayout *verticalLayout = new QVBoxLayout(m_configWidget);
+ verticalLayout->addLayout(horizontalLayout);
+
+ m_model = new Internal::KitModel(verticalLayout);
+ connect(m_model, SIGNAL(kitStateChanged()), this, SLOT(updateState()));
+ verticalLayout->setStretch(0, 1);
+ verticalLayout->setStretch(1, 0);
+
+ m_kitsView->setModel(m_model);
+ m_kitsView->header()->setResizeMode(0, QHeaderView::Stretch);
+ m_kitsView->expandAll();
+
+ m_selectionModel = m_kitsView->selectionModel();
+ connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+ this, SLOT(kitSelectionChanged()));
+ connect(KitManager::instance(), SIGNAL(kitAdded(ProjectExplorer::Kit*)),
+ this, SLOT(kitSelectionChanged()));
+ connect(KitManager::instance(), SIGNAL(kitRemoved(ProjectExplorer::Kit*)),
+ this, SLOT(kitSelectionChanged()));
+ connect(KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
+ this, SLOT(kitSelectionChanged()));
+
+ // Set up add menu:
+ connect(m_addButton, SIGNAL(clicked()), this, SLOT(addNewKit()));
+ connect(m_cloneButton, SIGNAL(clicked()), this, SLOT(cloneKit()));
+ connect(m_delButton, SIGNAL(clicked()), this, SLOT(removeKit()));
+ connect(m_makeDefaultButton, SIGNAL(clicked()), this, SLOT(makeDefaultKit()));
+
+ updateState();
+
+ if (m_toShow) {
+ QModelIndex index = m_model->indexOf(m_toShow);
+ m_selectionModel->select(index,
+ QItemSelectionModel::Clear
+ | QItemSelectionModel::SelectCurrent
+ | QItemSelectionModel::Rows);
+ m_kitsView->scrollTo(index);
+ }
+ m_toShow = 0;
}
- m_toShow = 0;
-
return m_configWidget;
}
@@ -145,18 +144,13 @@ void KitOptionsPage::finish()
m_model = 0;
}
- m_configWidget = 0; // deleted by settingsdialog
+ delete m_configWidget;
m_selectionModel = 0; // child of m_configWidget
m_kitsView = 0; // child of m_configWidget
m_currentWidget = 0; // deleted by the model
m_toShow = 0;
}
-bool KitOptionsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
void KitOptionsPage::showKit(Kit *k)
{
m_toShow = k;
diff --git a/src/plugins/projectexplorer/kitoptionspage.h b/src/plugins/projectexplorer/kitoptionspage.h
index f08fe36b54..2f13b8bd41 100644
--- a/src/plugins/projectexplorer/kitoptionspage.h
+++ b/src/plugins/projectexplorer/kitoptionspage.h
@@ -35,6 +35,7 @@
#include <coreplugin/dialogs/ioptionspage.h>
#include <QModelIndex>
+#include <QPointer>
QT_BEGIN_NAMESPACE
class QItemSelectionModel;
@@ -59,10 +60,9 @@ class PROJECTEXPLORER_EXPORT KitOptionsPage : public Core::IOptionsPage
public:
KitOptionsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &) const;
void showKit(Kit *k);
@@ -83,8 +83,7 @@ private:
QPushButton *m_delButton;
QPushButton *m_makeDefaultButton;
- QWidget *m_configWidget;
- QString m_searchKeywords;
+ QPointer<QWidget> m_configWidget;
Internal::KitModel *m_model;
QItemSelectionModel *m_selectionModel;
diff --git a/src/plugins/projectexplorer/ldparser.cpp b/src/plugins/projectexplorer/ldparser.cpp
index 8ea71e96aa..70691e35f2 100644
--- a/src/plugins/projectexplorer/ldparser.cpp
+++ b/src/plugins/projectexplorer/ldparser.cpp
@@ -78,17 +78,15 @@ void LdParser::stdError(const QString &line)
return;
} else if (m_regExpGccNames.indexIn(lne) > -1) {
QString description = lne.mid(m_regExpGccNames.matchedLength());
- Task task(Task::Error,
- description,
- Utils::FileName(), /* filename */
- -1, /* line */
- Constants::TASK_CATEGORY_COMPILE);
+ Task::TaskType type = Task::Error;
if (description.startsWith(QLatin1String("warning: "))) {
- task.type = Task::Warning;
- task.description = description.mid(9);
+ type = Task::Warning;
+ description = description.mid(9);
} else if (description.startsWith(QLatin1String("fatal: "))) {
- task.description = description.mid(7);
+ description = description.mid(7);
}
+ Task task(type, description, Utils::FileName() /* filename */, -1 /* line */,
+ Constants::TASK_CATEGORY_COMPILE);
emit addTask(task);
return;
} else if (m_regExpLinker.indexIn(lne) > -1) {
@@ -104,20 +102,18 @@ void LdParser::stdError(const QString &line)
filename = Utils::FileName::fromUserInput(sourceFileName);
}
QString description = m_regExpLinker.cap(8).trimmed();
- Task task(Task::Error, description, filename, lineno,
- Constants::TASK_CATEGORY_COMPILE);
+ Task::TaskType type = Task::Error;
if (description.startsWith(QLatin1String("At global scope")) ||
description.startsWith(QLatin1String("At top level")) ||
description.startsWith(QLatin1String("instantiated from ")) ||
description.startsWith(QLatin1String("In ")) ||
description.startsWith(QLatin1String("first defined here"))) {
- task.type = Task::Unknown;
+ type = Task::Unknown;
+ } else if (description.startsWith(QLatin1String("warning: "), Qt::CaseInsensitive)) {
+ type = Task::Warning;
+ description = description.mid(9);
}
- if (description.startsWith(QLatin1String("warning: "), Qt::CaseInsensitive)) {
- task.type = Task::Warning;
- task.description = description.mid(9);
- }
-
+ Task task(type, description, filename, lineno, Constants::TASK_CATEGORY_COMPILE);
emit addTask(task);
return;
}
diff --git a/src/plugins/projectexplorer/linuxiccparser.cpp b/src/plugins/projectexplorer/linuxiccparser.cpp
index 713ee98d5e..d4ab5b72ee 100644
--- a/src/plugins/projectexplorer/linuxiccparser.cpp
+++ b/src/plugins/projectexplorer/linuxiccparser.cpp
@@ -67,15 +67,16 @@ void LinuxIccParser::stdError(const QString &line)
{
if (m_expectFirstLine && m_firstLine.indexIn(line) != -1) {
// Clear out old task
- m_temporary = ProjectExplorer::Task(Task::Unknown, m_firstLine.cap(6).trimmed(),
- Utils::FileName::fromUserInput(m_firstLine.cap(1)),
- m_firstLine.cap(2).toInt(),
- Constants::TASK_CATEGORY_COMPILE);
+ Task::TaskType type = Task::Unknown;
QString category = m_firstLine.cap(4);
if (category == QLatin1String("error"))
- m_temporary.type = Task::Error;
+ type = Task::Error;
else if (category == QLatin1String("warning"))
- m_temporary.type = Task::Warning;
+ type = Task::Warning;
+ m_temporary = ProjectExplorer::Task(type, m_firstLine.cap(6).trimmed(),
+ Utils::FileName::fromUserInput(m_firstLine.cap(1)),
+ m_firstLine.cap(2).toInt(),
+ Constants::TASK_CATEGORY_COMPILE);
m_expectFirstLine = false;
} else if (!m_expectFirstLine && m_caretLine.indexIn(line) != -1) {
diff --git a/src/plugins/projectexplorer/localapplicationrunconfiguration.h b/src/plugins/projectexplorer/localapplicationrunconfiguration.h
index 6b80726060..415a17c003 100644
--- a/src/plugins/projectexplorer/localapplicationrunconfiguration.h
+++ b/src/plugins/projectexplorer/localapplicationrunconfiguration.h
@@ -54,8 +54,6 @@ public:
virtual RunMode runMode() const = 0;
virtual QString workingDirectory() const = 0;
virtual QString commandLineArguments() const = 0;
- virtual QString dumperLibrary() const = 0;
- virtual QStringList dumperLibraryLocations() const = 0;
virtual void addToBaseEnvironment(Utils::Environment &env) const;
diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.cpp b/src/plugins/projectexplorer/localapplicationruncontrol.cpp
index c2678c5b3c..13c248e42d 100644
--- a/src/plugins/projectexplorer/localapplicationruncontrol.cpp
+++ b/src/plugins/projectexplorer/localapplicationruncontrol.cpp
@@ -101,7 +101,7 @@ void LocalApplicationRunControl::start()
appendMessage(tr("No executable specified.") + QLatin1Char('\n'), Utils::ErrorMessageFormat);
emit finished();
} else if (!QFileInfo(m_executable).exists()){
- appendMessage(tr("Executable %1 does not exist.").arg(m_executable) + QLatin1Char('\n'),
+ appendMessage(tr("Executable %1 does not exist.").arg(QDir::toNativeSeparators(m_executable)) + QLatin1Char('\n'),
Utils::ErrorMessageFormat);
emit finished();
} else {
diff --git a/src/plugins/projectexplorer/msvcparser.cpp b/src/plugins/projectexplorer/msvcparser.cpp
index 9ff6c36d4d..dc6dd1f020 100644
--- a/src/plugins/projectexplorer/msvcparser.cpp
+++ b/src/plugins/projectexplorer/msvcparser.cpp
@@ -157,15 +157,15 @@ bool MsvcParser::processCompileLine(const QString &line)
if (m_compileRegExp.indexIn(line) > -1) {
QPair<Utils::FileName, int> position = parseFileName( m_compileRegExp.cap(1));
- m_lastTask = Task(Task::Unknown,
- m_compileRegExp.cap(4).trimmed() /* description */,
+ Task::TaskType type = Task::Unknown;
+ const QString category = m_compileRegExp.cap(3);
+ if (category == QLatin1String("warning"))
+ type = Task::Warning;
+ else if (category == QLatin1String("error"))
+ type = Task::Error;
+ m_lastTask = Task(type, m_compileRegExp.cap(4).trimmed() /* description */,
position.first, position.second,
Constants::TASK_CATEGORY_COMPILE);
- if (m_compileRegExp.cap(3) == QLatin1String("warning"))
- m_lastTask.type = Task::Warning;
- else if (m_compileRegExp.cap(3) == QLatin1String("error"))
- m_lastTask.type = Task::Error;
-
return true;
}
return false;
diff --git a/src/plugins/projectexplorer/msvcparser.h b/src/plugins/projectexplorer/msvcparser.h
index 19f9aaf4cc..4576e86b00 100644
--- a/src/plugins/projectexplorer/msvcparser.h
+++ b/src/plugins/projectexplorer/msvcparser.h
@@ -38,7 +38,7 @@
namespace ProjectExplorer {
-class MsvcParser : public ProjectExplorer::IOutputParser
+class PROJECTEXPLORER_EXPORT MsvcParser : public ProjectExplorer::IOutputParser
{
Q_OBJECT
diff --git a/src/plugins/projectexplorer/osparser.h b/src/plugins/projectexplorer/osparser.h
index aa1261017b..cf8cf7d442 100644
--- a/src/plugins/projectexplorer/osparser.h
+++ b/src/plugins/projectexplorer/osparser.h
@@ -38,7 +38,7 @@
namespace ProjectExplorer {
-class OsParser : public ProjectExplorer::IOutputParser
+class PROJECTEXPLORER_EXPORT OsParser : public ProjectExplorer::IOutputParser
{
Q_OBJECT
diff --git a/src/plugins/projectexplorer/processstep.cpp b/src/plugins/projectexplorer/processstep.cpp
index 3f19933814..3d5376675b 100644
--- a/src/plugins/projectexplorer/processstep.cpp
+++ b/src/plugins/projectexplorer/processstep.cpp
@@ -236,6 +236,7 @@ ProcessStepConfigWidget::ProcessStepConfigWidget(ProcessStep *step)
{
m_ui.setupUi(this);
m_ui.command->setExpectedKind(Utils::PathChooser::Command);
+ m_ui.command->setHistoryCompleter(QLatin1String("PE.ProcessStepCommand.History"));
m_ui.workingDirectory->setExpectedKind(Utils::PathChooser::Directory);
BuildConfiguration *bc = m_step->buildConfiguration();
diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp
index 2e2247b286..e95d6b9878 100644
--- a/src/plugins/projectexplorer/project.cpp
+++ b/src/plugins/projectexplorer/project.cpp
@@ -84,6 +84,7 @@ public:
ProjectPrivate();
~ProjectPrivate();
+ Core::Id m_id;
QList<Target *> m_targets;
Target *m_activeTarget;
EditorConfiguration *m_editorConfiguration;
@@ -112,6 +113,12 @@ Project::~Project()
delete d;
}
+Core::Id Project::id() const
+{
+ QTC_CHECK(d->m_id.isValid());
+ return d->m_id;
+}
+
QString Project::projectFilePath() const
{
return document()->filePath();
@@ -262,6 +269,11 @@ bool Project::setupTarget(Target *t)
return true;
}
+void Project::setId(Core::Id id)
+{
+ d->m_id = id;
+}
+
Target *Project::restoreTarget(const QVariantMap &data)
{
Core::Id id = idFromMap(data);
diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h
index 09dd4c9a90..ba88092572 100644
--- a/src/plugins/projectexplorer/project.h
+++ b/src/plugins/projectexplorer/project.h
@@ -73,7 +73,7 @@ public:
virtual ~Project();
virtual QString displayName() const = 0;
- virtual Core::Id id() const = 0;
+ Core::Id id() const;
virtual Core::IDocument *document() const = 0;
virtual IProjectManager *projectManager() const = 0;
@@ -161,6 +161,7 @@ protected:
virtual bool fromMap(const QVariantMap &map);
virtual bool setupTarget(Target *t);
+ void setId(Core::Id id);
void setProjectContext(Core::Context context);
void setProjectLanguages(Core::Context language);
void addProjectLanguage(Core::Id id);
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index d6d7dd36af..7fe089e91f 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -76,6 +76,7 @@
#include "miniprojecttargetselector.h"
#include "taskhub.h"
#include "customtoolchain.h"
+#include "selectablefilesmodel.h"
#include <projectexplorer/customwizard/customwizard.h>
#include "devicesupport/desktopdevice.h"
#include "devicesupport/desktopdevicefactory.h"
@@ -199,6 +200,7 @@ struct ProjectExplorerPluginPrivate {
QAction *m_cancelBuildAction;
QAction *m_addNewFileAction;
QAction *m_addExistingFilesAction;
+ QAction *m_addExistingDirectoryAction;
QAction *m_addNewSubprojectAction;
QAction *m_removeFileAction;
QAction *m_removeProjectAction;
@@ -539,7 +541,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
d->m_openWithMenu->setTitle(tr("Open With"));
connect(d->m_openWithMenu, SIGNAL(triggered(QAction*)),
- DocumentManager::instance(), SLOT(slotExecuteOpenWithMenuAction(QAction*)));
+ DocumentManager::instance(), SLOT(executeOpenWithMenuAction(QAction*)));
//
// Separators
@@ -796,6 +798,15 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
+ // add existing directory action
+ d->m_addExistingDirectoryAction = new QAction(tr("Add Existing Directory..."), this);
+ cmd = Core::ActionManager::registerAction(d->m_addExistingDirectoryAction,
+ ProjectExplorer::Constants::ADDEXISTINGDIRECTORY,
+ projecTreeContext);
+ mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
+ msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
+ mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
+
// new subproject action
d->m_addNewSubprojectAction = new QAction(tr("New Subproject..."), this);
cmd = ActionManager::registerAction(d->m_addNewSubprojectAction, ProjectExplorer::Constants::ADDNEWSUBPROJECT,
@@ -963,6 +974,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(d->m_closeAllProjects, SIGNAL(triggered()), this, SLOT(closeAllProjects()));
connect(d->m_addNewFileAction, SIGNAL(triggered()), this, SLOT(addNewFile()));
connect(d->m_addExistingFilesAction, SIGNAL(triggered()), this, SLOT(addExistingFiles()));
+ connect(d->m_addExistingDirectoryAction, SIGNAL(triggered()), this, SLOT(addExistingDirectory()));
connect(d->m_addNewSubprojectAction, SIGNAL(triggered()), this, SLOT(addNewSubproject()));
connect(d->m_removeProjectAction, SIGNAL(triggered()), this, SLOT(removeProject()));
connect(d->m_openFileAction, SIGNAL(triggered()), this, SLOT(openFile()));
@@ -1373,8 +1385,10 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName
}
if (const MimeType mt = MimeDatabase::findByFile(QFileInfo(fileName))) {
+ bool foundProjectManager = false;
foreach (IProjectManager *manager, projectManagers) {
if (manager->mimeType() == mt.type()) {
+ foundProjectManager = true;
QString tmp;
if (Project *pro = manager->openProject(filePath, &tmp)) {
if (pro->restoreSettings()) {
@@ -1385,6 +1399,8 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName
setCurrentNode(pro->rootProjectNode());
openedPro += pro;
} else {
+ appendError(errorString, tr("Failed opening project '%1': Settings could not be restored")
+ .arg(QDir::toNativeSeparators(fileName)));
delete pro;
}
}
@@ -1393,6 +1409,14 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName
break;
}
}
+ if (!foundProjectManager) {
+ appendError(errorString, tr("Failed opening project '%1': No plugin can open project type '%2'.")
+ .arg(QDir::toNativeSeparators(fileName))
+ .arg((mt.type())));
+ }
+ } else {
+ appendError(errorString, tr("Failed opening project '%1': Unknown project type.")
+ .arg(QDir::toNativeSeparators(fileName)));
}
SessionManager::reportProjectLoadingProgress();
}
@@ -2632,6 +2656,7 @@ void ProjectExplorerPlugin::invalidateProject(Project *project)
void ProjectExplorerPlugin::updateContextMenuActions()
{
d->m_addExistingFilesAction->setEnabled(false);
+ d->m_addExistingDirectoryAction->setEnabled(false);
d->m_addNewFileAction->setEnabled(false);
d->m_addNewSubprojectAction->setEnabled(false);
d->m_removeFileAction->setEnabled(false);
@@ -2639,6 +2664,7 @@ void ProjectExplorerPlugin::updateContextMenuActions()
d->m_renameFileAction->setEnabled(false);
d->m_addExistingFilesAction->setVisible(true);
+ d->m_addExistingDirectoryAction->setVisible(true);
d->m_removeFileAction->setVisible(true);
d->m_deleteFileAction->setVisible(true);
d->m_runActionContextMenu->setVisible(false);
@@ -2676,6 +2702,7 @@ void ProjectExplorerPlugin::updateContextMenuActions()
d->m_addNewSubprojectAction->setEnabled(d->m_currentNode->nodeType() == ProjectNodeType
&& actions.contains(ProjectNode::AddSubProject));
d->m_addExistingFilesAction->setEnabled(actions.contains(ProjectNode::AddExistingFile));
+ d->m_addExistingDirectoryAction->setEnabled(actions.contains(ProjectNode::AddExistingDirectory));
d->m_renameFileAction->setEnabled(actions.contains(ProjectNode::Rename));
} else if (qobject_cast<FileNode*>(d->m_currentNode)) {
// Enable and show remove / delete in magic ways:
@@ -2785,6 +2812,17 @@ void ProjectExplorerPlugin::addExistingFiles()
addExistingFiles(fileNames);
}
+void ProjectExplorerPlugin::addExistingDirectory()
+{
+ QTC_ASSERT(d->m_currentNode, return);
+
+ const QString path = QFileInfo(d->m_currentNode->path()).absolutePath();
+ SelectableFilesDialogAddDirectory dialog(path, QStringList(), Core::ICore::mainWindow());
+
+ if (dialog.exec() == QDialog::Accepted)
+ addExistingFiles(dialog.selectedFiles());
+}
+
void ProjectExplorerPlugin::addExistingFiles(const QStringList &filePaths)
{
ProjectNode *projectNode = qobject_cast<ProjectNode*>(d->m_currentNode->projectNode());
diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h
index 1773b9c4e8..db03ae0045 100644
--- a/src/plugins/projectexplorer/projectexplorer.h
+++ b/src/plugins/projectexplorer/projectexplorer.h
@@ -186,6 +186,7 @@ private slots:
void addNewFile();
void addExistingFiles();
+ void addExistingDirectory();
void addNewSubproject();
void removeProject();
void openFile();
diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro
index 16eee949d3..03daf8b229 100644
--- a/src/plugins/projectexplorer/projectexplorer.pro
+++ b/src/plugins/projectexplorer/projectexplorer.pro
@@ -141,7 +141,8 @@ HEADERS += projectexplorer.h \
projectmacroexpander.h \
customparser.h \
customparserconfigdialog.h \
- ipotentialkit.h
+ ipotentialkit.h \
+ selectablefilesmodel.h
SOURCES += projectexplorer.cpp \
abi.cpp \
@@ -269,7 +270,8 @@ SOURCES += projectexplorer.cpp \
projectmacroexpander.cpp \
customparser.cpp \
customparserconfigdialog.cpp \
- ipotentialkit.cpp
+ ipotentialkit.cpp \
+ selectablefilesmodel.cpp
FORMS += processstep.ui \
editorsettingspropertiespage.ui \
diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs
index 357a4c5351..5f8abc5ae1 100644
--- a/src/plugins/projectexplorer/projectexplorer.qbs
+++ b/src/plugins/projectexplorer/projectexplorer.qbs
@@ -9,8 +9,6 @@ QtcPlugin {
Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "script"] }
Depends { name: "Qt.quick"; condition: QtcFunctions.versionIsAtLeast(Qt.core.version, "5.1"); }
Depends { name: "Core" }
- Depends { name: "Locator" }
- Depends { name: "Find" }
Depends { name: "TextEditor" }
Depends { name: "QtcSsh" }
@@ -121,6 +119,7 @@ QtcPlugin {
"runconfiguration.cpp", "runconfiguration.h",
"runconfigurationmodel.cpp", "runconfigurationmodel.h",
"runsettingspropertiespage.cpp", "runsettingspropertiespage.h",
+ "selectablefilesmodel.cpp", "selectablefilesmodel.h",
"session.cpp", "session.h",
"sessiondialog.cpp", "sessiondialog.h", "sessiondialog.ui",
"settingsaccessor.cpp", "settingsaccessor.h",
@@ -141,7 +140,7 @@ QtcPlugin {
"toolchainmanager.cpp", "toolchainmanager.h",
"toolchainoptionspage.cpp", "toolchainoptionspage.h",
"unconfiguredprojectpanel.cpp", "unconfiguredprojectpanel.h",
- "vcsannotatetaskhandler.cpp", "vcsannotatetaskhandler.h",
+ "vcsannotatetaskhandler.cpp", "vcsannotatetaskhandler.h"
]
}
diff --git a/src/plugins/projectexplorer/projectexplorer_dependencies.pri b/src/plugins/projectexplorer/projectexplorer_dependencies.pri
index f970e87607..ab0a5facc4 100644
--- a/src/plugins/projectexplorer/projectexplorer_dependencies.pri
+++ b/src/plugins/projectexplorer/projectexplorer_dependencies.pri
@@ -3,8 +3,6 @@ QTC_LIB_DEPENDS += \
ssh \
utils
QTC_PLUGIN_DEPENDS += \
- locator \
- find \
coreplugin \
texteditor
QT *= network
diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h
index 1f4c941552..0b1f8fc9f3 100644
--- a/src/plugins/projectexplorer/projectexplorerconstants.h
+++ b/src/plugins/projectexplorer/projectexplorerconstants.h
@@ -69,6 +69,7 @@ const char RUNCONTEXTMENU[] = "ProjectExplorer.RunContextMenu";
const char STOP[] = "ProjectExplorer.Stop";
const char ADDNEWFILE[] = "ProjectExplorer.AddNewFile";
const char ADDEXISTINGFILES[] = "ProjectExplorer.AddExistingFiles";
+const char ADDEXISTINGDIRECTORY[] = "ProjectExplorer.AddExistingDirectory";
const char ADDNEWSUBPROJECT[] = "ProjectExplorer.AddNewSubproject";
const char REMOVEPROJECT[] = "ProjectExplorer.RemoveProject";
const char OPENFILE[] = "ProjectExplorer.OpenFile";
@@ -245,6 +246,12 @@ const char VAR_CURRENTBUILD_TYPE[] = "CurrentBuild:Type";
const char VAR_CURRENTSESSION_PREFIX[] = "CurrentSession";
const char VAR_CURRENTSESSION_NAME[] = "CurrentSession:Name";
+const char HIDE_FILE_FILTER_SETTING[] = "GenericProject/FileFilter";
+const char HIDE_FILE_FILTER_DEFAULT[] = "Makefile*; *.o; *.obj; *~; *.files; *.config; *.creator; *.user; *.includes; *.autosave";
+
+const char SHOW_FILE_FILTER_SETTING[] = "GenericProject/ShowFileFilter";
+const char SHOW_FILE_FILTER_DEFAULT[] = "*.c; *.cc; *.cpp; *.cp; *.cxx; *.c++; *.h; *.hh; *.hpp; *.hxx;";
+
// Unconfigured Panel
const char UNCONFIGURED_PANEL_PAGE_ID[] = "UnconfiguredPanel";
diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.cpp b/src/plugins/projectexplorer/projectexplorersettingspage.cpp
index 7afd153495..b231e4fcb1 100644
--- a/src/plugins/projectexplorer/projectexplorersettingspage.cpp
+++ b/src/plugins/projectexplorer/projectexplorersettingspage.cpp
@@ -150,29 +150,6 @@ void ProjectExplorerSettingsWidget::updateResetButton()
m_ui.resetButton->setEnabled(buildDirectory() != QLatin1String(Core::Constants::DEFAULT_BUILD_DIRECTORY));
}
-QString ProjectExplorerSettingsWidget::searchKeywords() const
-{
- if (m_searchKeywords.isEmpty()) {
- QLatin1Char sep(' ');
- m_searchKeywords = m_ui.directoryGroupBox->title()
- + sep + m_ui.currentDirectoryRadioButton->text()
- + sep + m_ui.directoryRadioButton->text()
- + sep + m_ui.buildAndRunGroupBox->title()
- + sep + m_ui.saveAllFilesCheckBox->text()
- + sep + m_ui.buildProjectBeforeDeployCheckBox->text()
- + sep + m_ui.deployProjectBeforeRunCheckBox->text()
- + sep + m_ui.showCompileOutputCheckBox->text()
- + sep + m_ui.cleanOldAppOutputCheckBox->text()
- + sep + m_ui.mergeStdErrAndStdOutCheckBox->text()
- + sep + m_ui.mergeStdErrAndStdOutCheckBox->toolTip()
- + sep + m_ui.wrapAppOutputCheckBox->text()
- + sep + m_ui.jomLabel->text()
- ;
- m_searchKeywords.remove(QLatin1Char('&'));
- }
- return m_searchKeywords;
-}
-
// ------------------ ProjectExplorerSettingsPage
ProjectExplorerSettingsPage::ProjectExplorerSettingsPage()
{
@@ -188,15 +165,15 @@ ProjectExplorerSettingsPage::~ProjectExplorerSettingsPage()
{
}
-QWidget *ProjectExplorerSettingsPage::createPage(QWidget *parent)
+QWidget *ProjectExplorerSettingsPage::widget()
{
- m_widget = new ProjectExplorerSettingsWidget(parent);
- m_widget->setSettings(ProjectExplorerPlugin::projectExplorerSettings());
- m_widget->setProjectsDirectory(Core::DocumentManager::projectsDirectory());
- m_widget->setUseProjectsDirectory(Core::DocumentManager::useProjectsDirectory());
- m_widget->setBuildDirectory(Core::DocumentManager::buildDirectory());
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new ProjectExplorerSettingsWidget;
+ m_widget->setSettings(ProjectExplorerPlugin::projectExplorerSettings());
+ m_widget->setProjectsDirectory(Core::DocumentManager::projectsDirectory());
+ m_widget->setUseProjectsDirectory(Core::DocumentManager::useProjectsDirectory());
+ m_widget->setBuildDirectory(Core::DocumentManager::buildDirectory());
+ }
return m_widget;
}
@@ -212,12 +189,7 @@ void ProjectExplorerSettingsPage::apply()
void ProjectExplorerSettingsPage::finish()
{
- // Nothing to do
-}
-
-bool ProjectExplorerSettingsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.h b/src/plugins/projectexplorer/projectexplorersettingspage.h
index 5767ba6c73..c94fa16a52 100644
--- a/src/plugins/projectexplorer/projectexplorersettingspage.h
+++ b/src/plugins/projectexplorer/projectexplorersettingspage.h
@@ -59,8 +59,6 @@ public:
QString buildDirectory() const;
void setBuildDirectory(const QString &bd);
- QString searchKeywords() const;
-
private slots:
void slotDirectoryButtonGroupChanged();
void resetDefaultBuildDirectory();
@@ -70,7 +68,6 @@ private:
void setJomVisible(bool);
Ui::ProjectExplorerSettingsPageUi m_ui;
- mutable QString m_searchKeywords;
QUuid m_environmentId;
};
@@ -82,13 +79,11 @@ public:
ProjectExplorerSettingsPage();
~ProjectExplorerSettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &s) const;
private:
- QString m_searchKeywords;
QPointer<ProjectExplorerSettingsWidget> m_widget;
};
diff --git a/src/plugins/projectexplorer/projectnodes.h b/src/plugins/projectexplorer/projectnodes.h
index ce180cbb10..c351fdebf7 100644
--- a/src/plugins/projectexplorer/projectnodes.h
+++ b/src/plugins/projectexplorer/projectnodes.h
@@ -184,6 +184,9 @@ public:
// the file is added
AddNewFile,
AddExistingFile,
+ // Add files, which match user defined filters,
+ // from an existing directory and its subdirectories
+ AddExistingDirectory,
// Removes a file from the project, optionally also
// delete it on disc
RemoveFile,
diff --git a/src/plugins/genericprojectmanager/selectablefilesmodel.cpp b/src/plugins/projectexplorer/selectablefilesmodel.cpp
index 24e5f8ac34..64cf1d6918 100644
--- a/src/plugins/genericprojectmanager/selectablefilesmodel.cpp
+++ b/src/plugins/projectexplorer/selectablefilesmodel.cpp
@@ -28,7 +28,7 @@
****************************************************************************/
#include "selectablefilesmodel.h"
-#include "genericprojectconstants.h"
+#include "projectexplorerconstants.h"
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/icore.h>
@@ -41,19 +41,14 @@
#include <QPushButton>
#include <QTreeView>
#include <QDir>
+#include <utils/pathchooser.h>
-namespace GenericProjectManager {
-namespace Internal {
+namespace ProjectExplorer {
-SelectableFilesModel::SelectableFilesModel(const QString &baseDir, QObject *parent)
- : QAbstractItemModel(parent), m_root(0), m_baseDir(baseDir), m_allFiles(true)
+SelectableFilesModel::SelectableFilesModel(QObject *parent)
+ : QAbstractItemModel(parent), m_root(0), m_allFiles(true)
{
- // Dummy tree
- m_root = new Tree;
- m_root->name = QLatin1String("/");
- m_root->parent = 0;
- m_root->fullPath = m_baseDir;
- m_root->isDir = true;
+ connect(&m_watcher, SIGNAL(finished()), this, SLOT(buildTreeFinished()));
}
void SelectableFilesModel::setInitialMarkedFiles(const QStringList &files)
@@ -68,27 +63,26 @@ void SelectableFilesModel::setInitialMarkedFiles(const QStringList &files)
m_allFiles = false;
}
-void SelectableFilesModel::init()
+void SelectableFilesModel::startParsing(const QString &baseDir)
{
-}
+ m_watcher.cancel();
+ m_watcher.waitForFinished();
-void SelectableFilesModel::startParsing()
-{
+ m_baseDir = baseDir;
// Build a tree in a future
m_rootForFuture = new Tree;
m_rootForFuture->name = QLatin1String("/");
m_rootForFuture->parent = 0;
- m_rootForFuture->fullPath = m_baseDir;
+ m_rootForFuture->fullPath = baseDir;
m_rootForFuture->isDir = true;
- connect(&m_watcher, SIGNAL(finished()), this, SLOT(buildTreeFinished()));
m_watcher.setFuture(QtConcurrent::run(&SelectableFilesModel::run, this));
}
void SelectableFilesModel::run(QFutureInterface<void> &fi)
{
m_futureCount = 0;
- buildTree(m_baseDir, m_rootForFuture, fi);
+ buildTree(m_baseDir, m_rootForFuture, fi, 5);
}
void SelectableFilesModel::buildTreeFinished()
@@ -101,14 +95,10 @@ void SelectableFilesModel::buildTreeFinished()
emit parsingFinished();
}
-void SelectableFilesModel::waitForFinished()
-{
- m_watcher.waitForFinished();
-}
-
void SelectableFilesModel::cancel()
{
m_watcher.cancel();
+ m_watcher.waitForFinished();
}
bool SelectableFilesModel::filter(Tree *t)
@@ -141,8 +131,10 @@ bool SelectableFilesModel::filter(Tree *t)
return false;
}
-void SelectableFilesModel::buildTree(const QString &baseDir, Tree *tree, QFutureInterface<void> &fi)
+void SelectableFilesModel::buildTree(const QString &baseDir, Tree *tree, QFutureInterface<void> &fi, int symlinkDepth)
{
+ if (symlinkDepth == 0)
+ return;
const QFileInfoList fileInfoList = QDir(baseDir).entryInfoList(QDir::Files |
QDir::Dirs |
QDir::NoDotAndDotDot);
@@ -156,14 +148,12 @@ void SelectableFilesModel::buildTree(const QString &baseDir, Tree *tree, QFuture
}
++m_futureCount;
if (fileInfo.isDir()) {
- if (fileInfo.isSymLink())
- continue;
Tree *t = new Tree;
t->parent = tree;
t->name = fileInfo.fileName();
t->fullPath = fileInfo.filePath();
t->isDir = true;
- buildTree(fileInfo.filePath(), t, fi);
+ buildTree(fileInfo.filePath(), t, fi, symlinkDepth - fileInfo.isSymLink());
allChecked &= t->checked == Qt::Checked;
allUnchecked &= t->checked == Qt::Unchecked;
tree->childDirectories.append(t);
@@ -193,11 +183,15 @@ void SelectableFilesModel::buildTree(const QString &baseDir, Tree *tree, QFuture
SelectableFilesModel::~SelectableFilesModel()
{
+ m_watcher.cancel();
+ m_watcher.waitForFinished();
deleteTree(m_root);
}
void SelectableFilesModel::deleteTree(Tree *tree)
{
+ if (!tree)
+ return;
foreach (Tree *t, tree->childDirectories)
deleteTree(t);
foreach (Tree *t, tree->files)
@@ -234,6 +228,8 @@ QModelIndex SelectableFilesModel::parent(const QModelIndex &child) const
{
if (!child.isValid())
return QModelIndex();
+ if (!child.internalPointer())
+ return QModelIndex();
Tree *parent = static_cast<Tree *>(child.internalPointer())->parent;
if (!parent)
return QModelIndex();
@@ -398,6 +394,22 @@ void SelectableFilesModel::applyFilter(const QString &showFilesfilter, const QSt
applyFilter(createIndex(0, 0, m_root));
}
+void SelectableFilesModel::selectAllFiles()
+{
+ selectAllFiles(m_root);
+}
+
+void SelectableFilesModel::selectAllFiles(Tree *root)
+{
+ root->checked = Qt::Checked;
+
+ foreach (Tree *t, root->childDirectories)
+ selectAllFiles(t);
+
+ foreach (Tree *t, root->visibleFiles)
+ t->checked = Qt::Checked;
+}
+
Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index)
{
bool allChecked = true;
@@ -511,10 +523,10 @@ Qt::CheckState SelectableFilesModel::applyFilter(const QModelIndex &index)
}
//////////
-// SelectableFilesDialog
+// SelectableFilesDialogs
//////////
-SelectableFilesDialog::SelectableFilesDialog(const QString &path, const QStringList files, QWidget *parent)
+SelectableFilesDialogEditFiles::SelectableFilesDialogEditFiles(const QString &path, const QStringList files, QWidget *parent)
: QDialog(parent)
{
QVBoxLayout *layout = new QVBoxLayout();
@@ -527,7 +539,7 @@ SelectableFilesDialog::SelectableFilesDialog(const QString &path, const QStringL
createHideFileFilterControls(layout);
createApplyButton(layout);
- m_selectableFilesModel = new SelectableFilesModel(path, this);
+ m_selectableFilesModel = new SelectableFilesModel(this);
m_selectableFilesModel->setInitialMarkedFiles(files);
m_view->setModel(m_selectableFilesModel);
m_view->setMinimumSize(500, 400);
@@ -556,10 +568,10 @@ SelectableFilesDialog::SelectableFilesDialog(const QString &path, const QStringL
connect(m_selectableFilesModel, SIGNAL(parsingFinished()),
this, SLOT(parsingFinished()));
- m_selectableFilesModel->startParsing();
+ m_selectableFilesModel->startParsing(path);
}
-void SelectableFilesDialog::createHideFileFilterControls(QVBoxLayout *layout)
+void SelectableFilesDialogEditFiles::createHideFileFilterControls(QVBoxLayout *layout)
{
QHBoxLayout *hbox = new QHBoxLayout;
m_hideFilesFilterLabel = new QLabel;
@@ -576,7 +588,7 @@ void SelectableFilesDialog::createHideFileFilterControls(QVBoxLayout *layout)
layout->addLayout(hbox);
}
-void SelectableFilesDialog::createShowFileFilterControls(QVBoxLayout *layout)
+void SelectableFilesDialogEditFiles::createShowFileFilterControls(QVBoxLayout *layout)
{
QHBoxLayout *hbox = new QHBoxLayout;
m_showFilesFilterLabel = new QLabel;
@@ -593,7 +605,7 @@ void SelectableFilesDialog::createShowFileFilterControls(QVBoxLayout *layout)
layout->addLayout(hbox);
}
-void SelectableFilesDialog::createApplyButton(QVBoxLayout *layout)
+void SelectableFilesDialogEditFiles::createApplyButton(QVBoxLayout *layout)
{
QHBoxLayout *hbox = new QHBoxLayout;
@@ -608,18 +620,17 @@ void SelectableFilesDialog::createApplyButton(QVBoxLayout *layout)
connect(m_applyFilterButton, SIGNAL(clicked()), this, SLOT(applyFilter()));
}
-SelectableFilesDialog::~SelectableFilesDialog()
+SelectableFilesDialogEditFiles::~SelectableFilesDialogEditFiles()
{
m_selectableFilesModel->cancel();
- m_selectableFilesModel->waitForFinished();
}
-void SelectableFilesDialog::parsingProgress(const QString &fileName)
+void SelectableFilesDialogEditFiles::parsingProgress(const QString &fileName)
{
m_progressLabel->setText(tr("Generating file list...\n\n%1").arg(fileName));
}
-void SelectableFilesDialog::parsingFinished()
+void SelectableFilesDialogEditFiles::parsingFinished()
{
m_hideFilesFilterLabel->show();
m_hideFilesfilterLineEdit->show();
@@ -642,7 +653,7 @@ void SelectableFilesDialog::parsingFinished()
}
}
-void SelectableFilesDialog::smartExpand(const QModelIndex &index)
+void SelectableFilesDialogEditFiles::smartExpand(const QModelIndex &index)
{
if (m_view->model()->data(index, Qt::CheckStateRole) == Qt::PartiallyChecked) {
m_view->expand(index);
@@ -652,12 +663,12 @@ void SelectableFilesDialog::smartExpand(const QModelIndex &index)
}
}
-QStringList SelectableFilesDialog::selectedFiles() const
+QStringList SelectableFilesDialogEditFiles::selectedFiles() const
{
return m_selectableFilesModel->selectedFiles();
}
-void SelectableFilesDialog::applyFilter()
+void SelectableFilesDialogEditFiles::applyFilter()
{
const QString showFilesFilter = m_showFilesfilterLineEdit->text();
Core::ICore::settings()->setValue(QLatin1String(Constants::SHOW_FILE_FILTER_SETTING), showFilesFilter);
@@ -668,7 +679,70 @@ void SelectableFilesDialog::applyFilter()
m_selectableFilesModel->applyFilter(showFilesFilter, hideFilesFilter);
}
-} // namespace Internal
-} // namespace GenericProjectManager
+SelectableFilesDialogAddDirectory::SelectableFilesDialogAddDirectory(const QString &path,
+ const QStringList files, QWidget *parent) :
+ SelectableFilesDialogEditFiles(path, files, parent)
+{
+ setWindowTitle(tr("Add Existing Directory"));
+
+ connect(m_selectableFilesModel, SIGNAL(parsingFinished()), this, SLOT(parsingFinished()));
+
+ createPathChooser(static_cast<QVBoxLayout*>(layout()), path);
+}
+
+void SelectableFilesDialogAddDirectory::createPathChooser(QVBoxLayout *layout, const QString &path)
+{
+ QHBoxLayout *hbox = new QHBoxLayout;
+
+ m_pathChooser = new Utils::PathChooser;
+ m_pathChooser->setPath(path);
+ m_pathChooser->setHistoryCompleter(QLatin1String("PE.AddToProjectDir.History"));
+ m_sourceDirectoryLabel = new QLabel(tr("Source directory:"));
+ hbox->addWidget(m_sourceDirectoryLabel);
+
+ hbox->addWidget(m_pathChooser);
+ layout->insertLayout(0, hbox);
+
+ m_startParsingButton = new QPushButton(tr("Start Parsing"));
+ hbox->addWidget(m_startParsingButton);
+
+ connect(m_pathChooser, SIGNAL(validChanged(bool)), this, SLOT(validityOfDirectoryChanged(bool)));
+ connect(m_startParsingButton, SIGNAL(clicked()), this, SLOT(startParsing()));
+}
+
+void SelectableFilesDialogAddDirectory::validityOfDirectoryChanged(bool validState)
+{
+ m_startParsingButton->setEnabled(validState);
+}
+
+void SelectableFilesDialogAddDirectory::parsingFinished()
+{
+ m_selectableFilesModel->selectAllFiles();
+ m_selectableFilesModel->applyFilter(m_showFilesfilterLineEdit->text(),
+ m_hideFilesfilterLineEdit->text());
+
+ setWidgetsEnabled(true);
+}
+
+void SelectableFilesDialogAddDirectory::startParsing()
+{
+ setWidgetsEnabled(false);
+
+ m_selectableFilesModel->startParsing(m_pathChooser->path());
+}
+
+void SelectableFilesDialogAddDirectory::setWidgetsEnabled(bool enabled)
+{
+ m_hideFilesfilterLineEdit->setEnabled(enabled);
+ m_showFilesfilterLineEdit->setEnabled(enabled);
+ m_applyFilterButton->setEnabled(enabled);
+ m_view->setEnabled(enabled);
+ m_pathChooser->setEnabled(enabled);
+ m_startParsingButton->setVisible(enabled);
+
+ m_progressLabel->setVisible(!enabled);
+}
+
+} // namespace ProjectExplorer
diff --git a/src/plugins/genericprojectmanager/selectablefilesmodel.h b/src/plugins/projectexplorer/selectablefilesmodel.h
index adb98afaca..68561d9de9 100644
--- a/src/plugins/genericprojectmanager/selectablefilesmodel.h
+++ b/src/plugins/projectexplorer/selectablefilesmodel.h
@@ -37,13 +37,15 @@
#include <QDialog>
#include <QTreeView>
#include <QLabel>
+#include "projectexplorer_export.h"
+
+namespace Utils { class PathChooser; }
QT_BEGIN_NAMESPACE
class QVBoxLayout;
QT_END_NAMESPACE
-namespace GenericProjectManager {
-namespace Internal {
+namespace ProjectExplorer {
struct Tree
{
@@ -81,12 +83,12 @@ struct Glob
}
};
-class SelectableFilesModel : public QAbstractItemModel
+class PROJECTEXPLORER_EXPORT SelectableFilesModel : public QAbstractItemModel
{
Q_OBJECT
public:
- SelectableFilesModel(const QString &baseDir, QObject *parent);
+ SelectableFilesModel(QObject *parent);
~SelectableFilesModel();
void setInitialMarkedFiles(const QStringList &files);
@@ -104,12 +106,12 @@ public:
QStringList selectedPaths() const;
QStringList preservedFiles() const;
- // only call this once
- void startParsing();
- void waitForFinished();
+ void startParsing(const QString &baseDir);
void cancel();
void applyFilter(const QString &selectFilesfilter, const QString &hideFilesfilter);
+ void selectAllFiles();
+
signals:
void parsingFinished();
void parsingProgress(const QString &filename);
@@ -121,14 +123,14 @@ private:
QList<Glob> parseFilter(const QString &filter);
Qt::CheckState applyFilter(const QModelIndex &index);
bool filter(Tree *t);
- void init();
void run(QFutureInterface<void> &fi);
void collectFiles(Tree *root, QStringList *result) const;
void collectPaths(Tree *root, QStringList *result) const;
- void buildTree(const QString &baseDir, Tree *tree, QFutureInterface<void> &fi);
+ void buildTree(const QString &baseDir, Tree *tree, QFutureInterface<void> &fi, int symlinkDepth);
void deleteTree(Tree *tree);
void propagateUp(const QModelIndex &index);
void propagateDown(const QModelIndex &index);
+ void selectAllFiles(Tree *root);
Tree *m_root;
// Used in the future thread need to all not used after calling startParsing
QString m_baseDir;
@@ -143,13 +145,13 @@ private:
QList<Glob> m_showFilesFilter;
};
-class SelectableFilesDialog : public QDialog
+class PROJECTEXPLORER_EXPORT SelectableFilesDialogEditFiles : public QDialog
{
Q_OBJECT
public:
- SelectableFilesDialog(const QString &path, const QStringList files, QWidget *parent);
- ~SelectableFilesDialog();
+ SelectableFilesDialogEditFiles(const QString &path, const QStringList files, QWidget *parent);
+ ~SelectableFilesDialogEditFiles();
QStringList selectedFiles() const;
private slots:
@@ -157,11 +159,12 @@ private slots:
void parsingProgress(const QString &fileName);
void parsingFinished();
-private:
+protected:
void smartExpand(const QModelIndex &index);
void createShowFileFilterControls(QVBoxLayout *layout);
void createHideFileFilterControls(QVBoxLayout *layout);
void createApplyButton(QVBoxLayout *layout);
+
SelectableFilesModel *m_selectableFilesModel;
QLabel *m_hideFilesFilterLabel;
@@ -177,8 +180,28 @@ private:
QLabel *m_progressLabel;
};
-} // namespace Internal
-} // namespace GenericProjectManager
+class SelectableFilesDialogAddDirectory : public SelectableFilesDialogEditFiles
+{
+ Q_OBJECT
+
+public:
+ SelectableFilesDialogAddDirectory(const QString &path, const QStringList files, QWidget *parent);
+
+private slots:
+ void validityOfDirectoryChanged(bool validState);
+ void parsingFinished();
+ void startParsing();
+
+private:
+ Utils::PathChooser *m_pathChooser;
+ QLabel *m_sourceDirectoryLabel;
+ QPushButton *m_startParsingButton;
+
+ void setWidgetsEnabled(bool enabled);
+ void createPathChooser(QVBoxLayout *layout, const QString &path);
+};
+
+} // namespace ProjectExplorer
#endif // SELECTABLEFILESMODEL_H
diff --git a/src/plugins/projectexplorer/settingsaccessor.cpp b/src/plugins/projectexplorer/settingsaccessor.cpp
index 16558d1c29..4dd3e427d3 100644
--- a/src/plugins/projectexplorer/settingsaccessor.cpp
+++ b/src/plugins/projectexplorer/settingsaccessor.cpp
@@ -1233,8 +1233,6 @@ QVariantMap Version0Handler::convertRunConfigurations(Project *project, const QV
result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.DeviceId"), i.value());
else if (i.key() == QLatin1String("LastDeployed"))
result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.LastDeployed"), i.value());
- else if (i.key() == QLatin1String("DebuggingHelpersLastDeployed"))
- result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.DebuggingHelpersLastDeployed"), i.value());
else
qWarning() << "Unknown MaemoRunConfiguration key found:" << i.key() << i.value();
} else if (QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration") == id) {
diff --git a/src/plugins/projectexplorer/targetselector.cpp b/src/plugins/projectexplorer/targetselector.cpp
index 29d5129bb4..311516431a 100644
--- a/src/plugins/projectexplorer/targetselector.cpp
+++ b/src/plugins/projectexplorer/targetselector.cpp
@@ -116,13 +116,13 @@ void TargetSelector::menuAboutToHide()
updateButtons();
}
-void TargetSelector::insertTarget(int index, const QString &name)
+void TargetSelector::insertTarget(int index, int subIndex, const QString &name)
{
QTC_ASSERT(index >= 0 && index <= m_targets.count(), return);
Target target;
target.name = name;
- target.currentSubIndex = 0;
+ target.currentSubIndex = subIndex;
m_targets.insert(index, target);
diff --git a/src/plugins/projectexplorer/targetselector.h b/src/plugins/projectexplorer/targetselector.h
index 188bf3bef5..d2107d3191 100644
--- a/src/plugins/projectexplorer/targetselector.h
+++ b/src/plugins/projectexplorer/targetselector.h
@@ -70,7 +70,7 @@ public:
void setTargetMenu(QMenu *menu);
public:
- void insertTarget(int index, const QString &name);
+ void insertTarget(int index, int subIndex, const QString &name);
void renameTarget(int index, const QString &name);
void removeTarget(int index);
void setCurrentIndex(int index);
diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp
index f5b2d47feb..8a4128f1ef 100644
--- a/src/plugins/projectexplorer/targetsettingspanel.cpp
+++ b/src/plugins/projectexplorer/targetsettingspanel.cpp
@@ -181,9 +181,7 @@ void TargetSettingsPanelWidget::setupUi()
// Now set the correct target
int index = m_targets.indexOf(m_project->activeTarget());
m_selector->setCurrentIndex(index);
- m_selector->setCurrentSubIndex(0);
-
- currentTargetChanged(index, 0);
+ currentTargetChanged(index, m_selector->currentSubIndex());
connect(m_selector, SIGNAL(currentChanged(int,int)),
this, SLOT(currentTargetChanged(int,int)));
@@ -488,7 +486,9 @@ void TargetSettingsPanelWidget::targetAdded(ProjectExplorer::Target *target)
if (m_targets.count() == pos ||
m_targets.at(pos)->displayName() > target->displayName()) {
m_targets.insert(pos, target);
- m_selector->insertTarget(pos, target->displayName());
+ m_selector->insertTarget(pos, m_project->hasActiveBuildSettings() ? 0 : 1,
+ target->displayName());
+
break;
}
}
diff --git a/src/plugins/projectexplorer/targetsettingswidget.cpp b/src/plugins/projectexplorer/targetsettingswidget.cpp
index 3cc0cd4e72..e0cb60a886 100644
--- a/src/plugins/projectexplorer/targetsettingswidget.cpp
+++ b/src/plugins/projectexplorer/targetsettingswidget.cpp
@@ -83,9 +83,9 @@ TargetSettingsWidget::~TargetSettingsWidget()
delete ui;
}
-void TargetSettingsWidget::insertTarget(int index, const QString &name)
+void TargetSettingsWidget::insertTarget(int index, int subIndex, const QString &name)
{
- m_targetSelector->insertTarget(index, name);
+ m_targetSelector->insertTarget(index, subIndex, name);
}
void TargetSettingsWidget::renameTarget(int index, const QString &name)
diff --git a/src/plugins/projectexplorer/targetsettingswidget.h b/src/plugins/projectexplorer/targetsettingswidget.h
index 29b553360b..f22b537daf 100644
--- a/src/plugins/projectexplorer/targetsettingswidget.h
+++ b/src/plugins/projectexplorer/targetsettingswidget.h
@@ -62,7 +62,7 @@ public:
int currentSubIndex() const;
public:
- void insertTarget(int index, const QString &name);
+ void insertTarget(int index, int subIndex, const QString &name);
void renameTarget(int index, const QString &name);
void removeTarget(int index);
void setCurrentIndex(int index);
diff --git a/src/plugins/projectexplorer/targetsetuppage.cpp b/src/plugins/projectexplorer/targetsetuppage.cpp
index 2da697af1e..2d2db6873a 100644
--- a/src/plugins/projectexplorer/targetsetuppage.cpp
+++ b/src/plugins/projectexplorer/targetsetuppage.cpp
@@ -246,7 +246,7 @@ void TargetSetupPage::setKitSelected(Core::Id id, bool selected)
bool TargetSetupPage::isComplete() const
{
- foreach (TargetSetupWidget *widget, m_widgets.values())
+ foreach (TargetSetupWidget *widget, m_widgets)
if (widget->isKitSelected())
return true;
return false;
@@ -275,7 +275,7 @@ void TargetSetupPage::setupWidgets()
void TargetSetupPage::reset()
{
- foreach (TargetSetupWidget *widget, m_widgets.values()) {
+ foreach (TargetSetupWidget *widget, m_widgets) {
Kit *k = widget->kit();
if (!k)
continue;
@@ -386,7 +386,7 @@ void TargetSetupPage::handleKitUpdate(Kit *k)
void TargetSetupPage::selectAtLeastOneKit()
{
bool atLeastOneKitSelected = false;
- foreach (TargetSetupWidget *w, m_widgets.values()) {
+ foreach (TargetSetupWidget *w, m_widgets) {
if (w->isKitSelected()) {
atLeastOneKitSelected = true;
break;
@@ -514,7 +514,7 @@ TargetSetupWidget *TargetSetupPage::addWidget(Kit *k)
bool TargetSetupPage::setupProject(Project *project)
{
QList<const BuildInfo *> toSetUp; // Pointers are managed by the widgets!
- foreach (TargetSetupWidget *widget, m_widgets.values()) {
+ foreach (TargetSetupWidget *widget, m_widgets) {
if (!widget->isKitSelected())
continue;
diff --git a/src/plugins/projectexplorer/targetsetupwidget.cpp b/src/plugins/projectexplorer/targetsetupwidget.cpp
index 0c87247c4e..8e070965b3 100644
--- a/src/plugins/projectexplorer/targetsetupwidget.cpp
+++ b/src/plugins/projectexplorer/targetsetupwidget.cpp
@@ -180,6 +180,7 @@ void TargetSetupWidget::addBuildInfo(BuildInfo *info, bool isImport)
pathChooser->setExpectedKind(Utils::PathChooser::Directory);
pathChooser->setFileName(info->buildDirectory);
pathChooser->setEnabled(info->supportsShadowBuild);
+ pathChooser->setHistoryCompleter(QLatin1String("BuildDir.History"));
pathChooser->setReadOnly(!info->supportsShadowBuild || isImport);
m_newBuildsLayout->addWidget(pathChooser, pos * 2, 1);
diff --git a/src/plugins/projectexplorer/task.cpp b/src/plugins/projectexplorer/task.cpp
index 8e1edfad88..462e7e6d07 100644
--- a/src/plugins/projectexplorer/task.cpp
+++ b/src/plugins/projectexplorer/task.cpp
@@ -32,6 +32,19 @@
namespace ProjectExplorer
{
+static QString taskTypeIcon(Task::TaskType t)
+{
+ switch (t) {
+ case Task::Warning:
+ return QLatin1String(":/projectexplorer/images/compile_warning.png");
+ case Task::Error:
+ return QLatin1String(":/projectexplorer/images/compile_error.png");
+ case Task::Unknown:
+ break;
+ }
+ return QString();
+}
+
unsigned int Task::s_nextId = 1;
/*!
@@ -44,9 +57,11 @@ Task::Task() : taskId(0), type(Unknown), line(-1)
{ }
Task::Task(TaskType type_, const QString &description_,
- const Utils::FileName &file_, int line_, Core::Id category_) :
+ const Utils::FileName &file_, int line_, Core::Id category_,
+ const Utils::FileName &iconFile) :
taskId(s_nextId), type(type_), description(description_),
- file(file_), line(line_), movedLine(line_), category(category_)
+ file(file_), line(line_), movedLine(line_), category(category_),
+ icon(iconFile.isEmpty() ? taskTypeIcon(type_) : iconFile.toString())
{
++s_nextId;
}
@@ -70,6 +85,7 @@ void Task::clear()
movedLine = -1;
category = Core::Id();
type = Task::Unknown;
+ icon = QIcon();
}
//
diff --git a/src/plugins/projectexplorer/task.h b/src/plugins/projectexplorer/task.h
index 78640c9441..c6e0d6bc56 100644
--- a/src/plugins/projectexplorer/task.h
+++ b/src/plugins/projectexplorer/task.h
@@ -54,7 +54,8 @@ public:
Task();
Task(TaskType type, const QString &description,
- const Utils::FileName &file, int line, Core::Id category);
+ const Utils::FileName &file, int line, Core::Id category,
+ const Utils::FileName &iconName = Utils::FileName());
bool isNull() const;
void clear();
@@ -66,6 +67,7 @@ public:
int line;
int movedLine; // contains a line number if the line was moved in the editor
Core::Id category;
+ QIcon icon;
void addMark(TextEditor::BaseTextMark *mark);
// Having a QList<QTextLayout::FormatRange> in Task isn't that great
diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp
index 685e6ee6f2..990734c09c 100644
--- a/src/plugins/projectexplorer/taskhub.cpp
+++ b/src/plugins/projectexplorer/taskhub.cpp
@@ -115,9 +115,8 @@ void TaskHub::addTask(Task::TaskType type, const QString &description, Core::Id
void TaskHub::addTask(Task task)
{
if (task.line != -1 && !task.file.isEmpty()) {
- bool visible = (task.type == Task::Warning || task.type == Task::Error);
- TaskMark *mark = new TaskMark(task.taskId, task.file.toString(), task.line, visible);
- mark->setIcon(taskTypeIcon(task.type));
+ TaskMark *mark = new TaskMark(task.taskId, task.file.toString(), task.line, !task.icon.isNull());
+ mark->setIcon(task.icon);
mark->setPriority(TextEditor::ITextMark::LowPriority);
task.addMark(mark);
emit m_instance->taskAdded(task);
@@ -167,16 +166,3 @@ void TaskHub::requestPopup()
emit m_instance->popupRequested(Core::IOutputPane::NoModeSwitch);
}
-QIcon TaskHub::taskTypeIcon(Task::TaskType t)
-{
- switch (t) {
- case Task::Warning:
- return m_instance->m_warningIcon;
- case Task::Error:
- return m_instance->m_errorIcon;
- case Task::Unknown:
- break;
- }
- return QIcon();
-}
-
diff --git a/src/plugins/projectexplorer/taskhub.h b/src/plugins/projectexplorer/taskhub.h
index c34686f554..77cc75bf68 100644
--- a/src/plugins/projectexplorer/taskhub.h
+++ b/src/plugins/projectexplorer/taskhub.h
@@ -66,8 +66,6 @@ public:
static void requestPopup();
- static QIcon taskTypeIcon(ProjectExplorer::Task::TaskType t);
-
signals:
void categoryAdded(Core::Id categoryId, const QString &displayName, bool visible);
void taskAdded(const ProjectExplorer::Task &task);
diff --git a/src/plugins/projectexplorer/taskmodel.cpp b/src/plugins/projectexplorer/taskmodel.cpp
index 24495c41a8..6ceb5e8ffe 100644
--- a/src/plugins/projectexplorer/taskmodel.cpp
+++ b/src/plugins/projectexplorer/taskmodel.cpp
@@ -255,7 +255,7 @@ QVariant TaskModel::data(const QModelIndex &index, int role) const
else if (role == TaskModel::Category)
return m_tasks.at(index.row()).category.uniqueIdentifier();
else if (role == TaskModel::Icon)
- return TaskHub::taskTypeIcon(m_tasks.at(index.row()).type);
+ return m_tasks.at(index.row()).icon;
else if (role == TaskModel::Task_t)
return QVariant::fromValue(task(index));
return QVariant();
diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp
index 6835663ae2..8dc060e148 100644
--- a/src/plugins/projectexplorer/taskwindow.cpp
+++ b/src/plugins/projectexplorer/taskwindow.cpp
@@ -261,9 +261,9 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate)
d->m_listview->setContextMenuPolicy(Qt::ActionsContextMenu);
- d->m_filterWarningsButton = createFilterButton(TaskHub::taskTypeIcon(Task::Warning),
- tr("Show Warnings"),
- this, SLOT(setShowWarnings(bool)));
+ d->m_filterWarningsButton = createFilterButton(
+ QIcon(QLatin1String(":/projectexplorer/images/compile_warning.png")),
+ tr("Show Warnings"), this, SLOT(setShowWarnings(bool)));
d->m_categoriesButton = new QToolButton;
d->m_categoriesButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_FILTER)));
diff --git a/src/plugins/projectexplorer/toolchainoptionspage.cpp b/src/plugins/projectexplorer/toolchainoptionspage.cpp
index 222ea810b2..aa5a3fffbd 100644
--- a/src/plugins/projectexplorer/toolchainoptionspage.cpp
+++ b/src/plugins/projectexplorer/toolchainoptionspage.cpp
@@ -450,92 +450,81 @@ ToolChainOptionsPage::ToolChainOptionsPage() :
setCategoryIcon(QLatin1String(Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON));
}
-QWidget *ToolChainOptionsPage::createPage(QWidget *parent)
-{
- // Actual page setup:
- m_configWidget = new QWidget(parent);
-
- m_toolChainView = new QTreeView(m_configWidget);
- m_toolChainView->setUniformRowHeights(true);
- m_toolChainView->header()->setStretchLastSection(false);
-
- m_addButton = new QPushButton(tr("Add"), m_configWidget);
- m_cloneButton = new QPushButton(tr("Clone"), m_configWidget);
- m_delButton = new QPushButton(tr("Remove"), m_configWidget);
-
- m_container = new Utils::DetailsWidget(m_configWidget);
- m_container->setState(Utils::DetailsWidget::NoSummary);
- m_container->setVisible(false);
-
- QVBoxLayout *buttonLayout = new QVBoxLayout();
- buttonLayout->setSpacing(6);
- buttonLayout->setContentsMargins(0, 0, 0, 0);
- buttonLayout->addWidget(m_addButton);
- buttonLayout->addWidget(m_cloneButton);
- buttonLayout->addWidget(m_delButton);
- buttonLayout->addItem(new QSpacerItem(10, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
-
- QVBoxLayout *verticalLayout = new QVBoxLayout();
- verticalLayout->addWidget(m_toolChainView);
- verticalLayout->addWidget(m_container);
-
- QHBoxLayout *horizontalLayout = new QHBoxLayout(m_configWidget);
- horizontalLayout->addLayout(verticalLayout);
- horizontalLayout->addLayout(buttonLayout);
- Q_ASSERT(!m_model);
- m_model = new ToolChainModel(m_configWidget);
-
- connect(m_model, SIGNAL(toolChainStateChanged()), this, SLOT(updateState()));
-
- m_toolChainView->setModel(m_model);
- m_toolChainView->header()->setResizeMode(0, QHeaderView::ResizeToContents);
- m_toolChainView->header()->setResizeMode(1, QHeaderView::Stretch);
- m_toolChainView->expandAll();
-
- m_selectionModel = m_toolChainView->selectionModel();
- connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
- this, SLOT(toolChainSelectionChanged()));
- connect(ToolChainManager::instance(), SIGNAL(toolChainsChanged()),
- this, SLOT(toolChainSelectionChanged()));
-
- // Get toolchainfactories:
- m_factories = ExtensionSystem::PluginManager::getObjects<ToolChainFactory>();
-
- // Set up add menu:
- QMenu *addMenu = new QMenu(m_addButton);
- QSignalMapper *mapper = new QSignalMapper(addMenu);
- connect(mapper, SIGNAL(mapped(QObject*)), this, SLOT(createToolChain(QObject*)));
-
- foreach (ToolChainFactory *factory, m_factories) {
- if (factory->canCreate()) {
- QAction *action = new QAction(addMenu);
- action->setText(factory->displayName());
- connect(action, SIGNAL(triggered()), mapper, SLOT(map()));
- mapper->setMapping(action, static_cast<QObject *>(factory));
-
- addMenu->addAction(action);
+QWidget *ToolChainOptionsPage::widget()
+{
+ if (!m_configWidget) {
+ // Actual page setup:
+ m_configWidget = new QWidget;
+
+ m_toolChainView = new QTreeView(m_configWidget);
+ m_toolChainView->setUniformRowHeights(true);
+ m_toolChainView->header()->setStretchLastSection(false);
+
+ m_addButton = new QPushButton(tr("Add"), m_configWidget);
+ m_cloneButton = new QPushButton(tr("Clone"), m_configWidget);
+ m_delButton = new QPushButton(tr("Remove"), m_configWidget);
+
+ m_container = new Utils::DetailsWidget(m_configWidget);
+ m_container->setState(Utils::DetailsWidget::NoSummary);
+ m_container->setVisible(false);
+
+ QVBoxLayout *buttonLayout = new QVBoxLayout();
+ buttonLayout->setSpacing(6);
+ buttonLayout->setContentsMargins(0, 0, 0, 0);
+ buttonLayout->addWidget(m_addButton);
+ buttonLayout->addWidget(m_cloneButton);
+ buttonLayout->addWidget(m_delButton);
+ buttonLayout->addItem(new QSpacerItem(10, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
+
+ QVBoxLayout *verticalLayout = new QVBoxLayout();
+ verticalLayout->addWidget(m_toolChainView);
+ verticalLayout->addWidget(m_container);
+
+ QHBoxLayout *horizontalLayout = new QHBoxLayout(m_configWidget);
+ horizontalLayout->addLayout(verticalLayout);
+ horizontalLayout->addLayout(buttonLayout);
+ Q_ASSERT(!m_model);
+ m_model = new ToolChainModel(m_configWidget);
+
+ connect(m_model, SIGNAL(toolChainStateChanged()), this, SLOT(updateState()));
+
+ m_toolChainView->setModel(m_model);
+ m_toolChainView->header()->setResizeMode(0, QHeaderView::ResizeToContents);
+ m_toolChainView->header()->setResizeMode(1, QHeaderView::Stretch);
+ m_toolChainView->expandAll();
+
+ m_selectionModel = m_toolChainView->selectionModel();
+ connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+ this, SLOT(toolChainSelectionChanged()));
+ connect(ToolChainManager::instance(), SIGNAL(toolChainsChanged()),
+ this, SLOT(toolChainSelectionChanged()));
+
+ // Get toolchainfactories:
+ m_factories = ExtensionSystem::PluginManager::getObjects<ToolChainFactory>();
+
+ // Set up add menu:
+ QMenu *addMenu = new QMenu(m_addButton);
+ QSignalMapper *mapper = new QSignalMapper(addMenu);
+ connect(mapper, SIGNAL(mapped(QObject*)), this, SLOT(createToolChain(QObject*)));
+
+ foreach (ToolChainFactory *factory, m_factories) {
+ if (factory->canCreate()) {
+ QAction *action = new QAction(addMenu);
+ action->setText(factory->displayName());
+ connect(action, SIGNAL(triggered()), mapper, SLOT(map()));
+ mapper->setMapping(action, static_cast<QObject *>(factory));
+
+ addMenu->addAction(action);
+ }
}
- }
- connect(m_cloneButton, SIGNAL(clicked()), mapper, SLOT(map()));
- mapper->setMapping(m_cloneButton, static_cast<QObject *>(0));
-
- m_addButton->setMenu(addMenu);
-
- connect(m_delButton, SIGNAL(clicked()), this, SLOT(removeToolChain()));
+ connect(m_cloneButton, SIGNAL(clicked()), mapper, SLOT(map()));
+ mapper->setMapping(m_cloneButton, static_cast<QObject *>(0));
- // setup keywords:
- if (m_searchKeywords.isEmpty()) {
- QLatin1Char sep(' ');
- QTextStream stream(&m_searchKeywords);
- stream << tr("Compilers");
- foreach (ToolChainFactory *f, m_factories)
- stream << sep << f->displayName();
+ m_addButton->setMenu(addMenu);
- m_searchKeywords.remove(QLatin1Char('&'));
+ connect(m_delButton, SIGNAL(clicked()), this, SLOT(removeToolChain()));
+ updateState();
}
-
- updateState();
-
return m_configWidget;
}
@@ -550,8 +539,7 @@ void ToolChainOptionsPage::finish()
disconnect(ToolChainManager::instance(), SIGNAL(toolChainsChanged()),
this, SLOT(toolChainSelectionChanged()));
- // delete by settingsdialog;
- m_configWidget = 0;
+ delete m_configWidget;
// children of m_configWidget
m_model = 0;
@@ -563,11 +551,6 @@ void ToolChainOptionsPage::finish()
m_delButton = 0;
}
-bool ToolChainOptionsPage::matches(const QString &s) const
-{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
void ToolChainOptionsPage::toolChainSelectionChanged()
{
if (!m_container)
diff --git a/src/plugins/projectexplorer/toolchainoptionspage.h b/src/plugins/projectexplorer/toolchainoptionspage.h
index 3758edaacc..cccff782d7 100644
--- a/src/plugins/projectexplorer/toolchainoptionspage.h
+++ b/src/plugins/projectexplorer/toolchainoptionspage.h
@@ -33,6 +33,7 @@
#include <coreplugin/dialogs/ioptionspage.h>
#include <QAbstractItemModel>
+#include <QPointer>
QT_BEGIN_NAMESPACE
class QItemSelectionModel;
@@ -117,10 +118,9 @@ class ToolChainOptionsPage : public Core::IOptionsPage
public:
ToolChainOptionsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &) const;
private slots:
void toolChainSelectionChanged();
@@ -131,8 +131,7 @@ private slots:
private:
QModelIndex currentIndex() const;
- QWidget *m_configWidget;
- QString m_searchKeywords;
+ QPointer<QWidget> m_configWidget;
ToolChainModel *m_model;
QList<ToolChainFactory *> m_factories;
diff --git a/src/plugins/pythoneditor/pythoneditor.cpp b/src/plugins/pythoneditor/pythoneditor.cpp
index 1787f71d01..346c0f4019 100644
--- a/src/plugins/pythoneditor/pythoneditor.cpp
+++ b/src/plugins/pythoneditor/pythoneditor.cpp
@@ -58,12 +58,10 @@ PythonEditor::~PythonEditor()
{
}
-Core::IEditor *PythonEditor::duplicate(QWidget *parent)
+Core::IEditor *PythonEditor::duplicate()
{
- EditorWidget *widget = new EditorWidget(parent);
- widget->duplicateFrom(editorWidget());
- PythonEditorPlugin::initializeEditor(widget);
-
+ EditorWidget *widget = new EditorWidget(qobject_cast<EditorWidget *>(editorWidget()));
+ TextEditor::TextEditorSettings::initializeEditor(widget);
return widget->editor();
}
@@ -80,7 +78,7 @@ bool PythonEditor::open(QString *errorString,
const QString &realFileName)
{
Core::MimeType mimeType = Core::MimeDatabase::findByFile(QFileInfo(fileName));
- editorWidget()->setMimeType(mimeType.type());
+ baseTextDocument()->setMimeType(mimeType.type());
return TextEditor::BaseTextEditor::open(errorString, fileName, realFileName);
}
diff --git a/src/plugins/pythoneditor/pythoneditor.h b/src/plugins/pythoneditor/pythoneditor.h
index ed1eff5e8e..a53d031abe 100644
--- a/src/plugins/pythoneditor/pythoneditor.h
+++ b/src/plugins/pythoneditor/pythoneditor.h
@@ -46,7 +46,7 @@ public:
virtual ~PythonEditor();
bool duplicateSupported() const { return true; }
- Core::IEditor *duplicate(QWidget *parent);
+ Core::IEditor *duplicate();
Core::Id id() const;
diff --git a/src/plugins/pythoneditor/pythoneditorfactory.cpp b/src/plugins/pythoneditor/pythoneditorfactory.cpp
index eeb5f2cec4..c549646405 100644
--- a/src/plugins/pythoneditor/pythoneditorfactory.cpp
+++ b/src/plugins/pythoneditor/pythoneditorfactory.cpp
@@ -34,6 +34,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
+#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorsettings.h>
#include <QDebug>
@@ -47,12 +48,17 @@ EditorFactory::EditorFactory(QObject *parent)
setId(Constants::C_PYTHONEDITOR_ID);
setDisplayName(tr(Constants::C_EDITOR_DISPLAY_NAME));
addMimeType(QLatin1String(Constants::C_PY_MIMETYPE));
+ new TextEditor::TextEditorActionHandler(this,
+ Constants::C_PYTHONEDITOR_ID,
+ TextEditor::TextEditorActionHandler::Format
+ | TextEditor::TextEditorActionHandler::UnCommentSelection
+ | TextEditor::TextEditorActionHandler::UnCollapseAll);
}
-Core::IEditor *EditorFactory::createEditor(QWidget *parent)
+Core::IEditor *EditorFactory::createEditor()
{
- EditorWidget *widget = new EditorWidget(parent);
- PythonEditorPlugin::initializeEditor(widget);
+ EditorWidget *widget = new EditorWidget();
+ TextEditor::TextEditorSettings::initializeEditor(widget);
return widget->editor();
}
diff --git a/src/plugins/pythoneditor/pythoneditorfactory.h b/src/plugins/pythoneditor/pythoneditorfactory.h
index 0dcca8fbc2..50d8f925c1 100644
--- a/src/plugins/pythoneditor/pythoneditorfactory.h
+++ b/src/plugins/pythoneditor/pythoneditorfactory.h
@@ -45,7 +45,7 @@ public:
/**
Creates and initializes new editor widget
*/
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
};
} // namespace Internal
diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp
index 5ab39396ad..4be6691069 100644
--- a/src/plugins/pythoneditor/pythoneditorplugin.cpp
+++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp
@@ -43,7 +43,6 @@
#include <coreplugin/editormanager/editormanager.h>
#include <extensionsystem/pluginmanager.h>
#include <texteditor/texteditorconstants.h>
-#include <texteditor/texteditorsettings.h>
#include <QtPlugin>
#include <QCoreApplication>
@@ -198,7 +197,6 @@ static void copyIdentifiers(const char * const words[], size_t bytesCount, QSet<
PythonEditorPlugin::PythonEditorPlugin()
: m_factory(0)
- , m_actionHandler(0)
{
m_instance = this;
copyIdentifiers(LIST_OF_PYTHON_KEYWORDS, sizeof(LIST_OF_PYTHON_KEYWORDS), m_keywords);
@@ -223,13 +221,6 @@ bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *error
addObject(m_factory);
// Initialize editor actions handler
- m_actionHandler.reset(new TextEditor::TextEditorActionHandler(
- C_PYTHONEDITOR_ID,
- TextEditor::TextEditorActionHandler::Format
- | TextEditor::TextEditorActionHandler::UnCommentSelection
- | TextEditor::TextEditorActionHandler::UnCollapseAll));
- m_actionHandler->initializeActions();
-
// Add MIME overlay icons (these icons displayed at Project dock panel)
const QIcon icon = QIcon::fromTheme(QLatin1String(C_PY_MIME_ICON));
if (!icon.isNull())
@@ -247,12 +238,6 @@ void PythonEditorPlugin::extensionsInitialized()
{
}
-void PythonEditorPlugin::initializeEditor(EditorWidget *widget)
-{
- instance()->m_actionHandler->setupActions(widget);
- TextEditor::TextEditorSettings::initializeEditor(widget);
-}
-
QSet<QString> PythonEditorPlugin::keywords()
{
return instance()->m_keywords;
diff --git a/src/plugins/pythoneditor/pythoneditorplugin.h b/src/plugins/pythoneditor/pythoneditorplugin.h
index 4f54ea3874..2e8ac7d0fc 100644
--- a/src/plugins/pythoneditor/pythoneditorplugin.h
+++ b/src/plugins/pythoneditor/pythoneditorplugin.h
@@ -31,9 +31,7 @@
#define PYTHONEDITOR_PLUGIN_H
#include <extensionsystem/iplugin.h>
-#include <texteditor/texteditoractionhandler.h>
#include <QSet>
-#include <QScopedPointer>
namespace PythonEditor {
namespace Internal {
@@ -57,7 +55,6 @@ public:
virtual bool initialize(const QStringList &arguments, QString *errorMessage);
virtual void extensionsInitialized();
static PythonEditorPlugin *instance() { return m_instance; }
- static void initializeEditor(EditorWidget *widget);
static QSet<QString> keywords();
static QSet<QString> magics();
@@ -66,7 +63,6 @@ public:
private:
static PythonEditorPlugin *m_instance;
EditorFactory *m_factory;
- QScopedPointer<TextEditor::TextEditorActionHandler> m_actionHandler;
QSet<QString> m_keywords;
QSet<QString> m_magics;
QSet<QString> m_builtins;
diff --git a/src/plugins/pythoneditor/pythoneditorwidget.cpp b/src/plugins/pythoneditor/pythoneditorwidget.cpp
index 5e2f6b5ccf..4e5b119f3e 100644
--- a/src/plugins/pythoneditor/pythoneditorwidget.cpp
+++ b/src/plugins/pythoneditor/pythoneditorwidget.cpp
@@ -48,7 +48,18 @@ namespace PythonEditor {
namespace Internal {
EditorWidget::EditorWidget(QWidget *parent)
- :TextEditor::BaseTextEditorWidget(parent)
+ : TextEditor::BaseTextEditorWidget(parent)
+{
+ ctor();
+}
+
+EditorWidget::EditorWidget(EditorWidget *other)
+ : TextEditor::BaseTextEditorWidget(other)
+{
+ ctor();
+}
+
+void EditorWidget::ctor()
{
m_commentDefinition.multiLineStart.clear();
m_commentDefinition.multiLineEnd.clear();
@@ -59,7 +70,7 @@ EditorWidget::EditorWidget(QWidget *parent)
setCodeFoldingSupported(true);
setIndenter(new PythonIndenter());
- new PythonHighlighter(baseTextDocument().data());
+ new PythonHighlighter(baseTextDocument());
}
EditorWidget::~EditorWidget()
diff --git a/src/plugins/pythoneditor/pythoneditorwidget.h b/src/plugins/pythoneditor/pythoneditorwidget.h
index ebb76626cd..272eb3c8a4 100644
--- a/src/plugins/pythoneditor/pythoneditorwidget.h
+++ b/src/plugins/pythoneditor/pythoneditorwidget.h
@@ -42,6 +42,7 @@ class EditorWidget : public TextEditor::BaseTextEditorWidget
public:
EditorWidget(QWidget *parent = 0);
+ EditorWidget(EditorWidget *other);
virtual ~EditorWidget();
virtual void unCommentSelection();
@@ -53,6 +54,8 @@ protected:
TextEditor::BaseTextEditor *createEditor();
private:
+ EditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
+ void ctor();
Utils::CommentDefinition m_commentDefinition;
};
diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp
index 4cdbe41e9f..7bc8970c35 100644
--- a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp
+++ b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp
@@ -50,6 +50,7 @@
static const char QBS_CONFIG[] = "Qbs.Configuration";
static const char QBS_DRY_RUN[] = "Qbs.DryRun";
static const char QBS_KEEP_GOING[] = "Qbs.DryKeepGoing";
+static const char QBS_CHECK_TIMESTAMPS[] = "Qbs.CheckTimestamps";
static const char QBS_MAXJOBCOUNT[] = "Qbs.MaxJobs";
// --------------------------------------------------------------------
@@ -69,6 +70,7 @@ QbsBuildStep::QbsBuildStep(ProjectExplorer::BuildStepList *bsl) :
{
setDisplayName(tr("Qbs Build"));
setQbsConfiguration(QVariantMap());
+ m_qbsBuildOptions.setForceTimestampCheck(true);
}
QbsBuildStep::QbsBuildStep(ProjectExplorer::BuildStepList *bsl, const QbsBuildStep *other) :
@@ -194,6 +196,11 @@ bool QbsBuildStep::keepGoing() const
return m_qbsBuildOptions.keepGoing();
}
+bool QbsBuildStep::checkTimestamps() const
+{
+ return m_qbsBuildOptions.forceTimestampCheck();
+}
+
int QbsBuildStep::maxJobs() const
{
if (m_qbsBuildOptions.maxJobCount() > 0)
@@ -209,6 +216,7 @@ bool QbsBuildStep::fromMap(const QVariantMap &map)
setQbsConfiguration(map.value(QLatin1String(QBS_CONFIG)).toMap());
m_qbsBuildOptions.setDryRun(map.value(QLatin1String(QBS_DRY_RUN)).toBool());
m_qbsBuildOptions.setKeepGoing(map.value(QLatin1String(QBS_KEEP_GOING)).toBool());
+ m_qbsBuildOptions.setForceTimestampCheck(map.value(QLatin1String(QBS_CHECK_TIMESTAMPS), true).toBool());
m_qbsBuildOptions.setMaxJobCount(map.value(QLatin1String(QBS_MAXJOBCOUNT)).toInt());
return true;
}
@@ -219,6 +227,7 @@ QVariantMap QbsBuildStep::toMap() const
map.insert(QLatin1String(QBS_CONFIG), m_qbsConfiguration);
map.insert(QLatin1String(QBS_DRY_RUN), m_qbsBuildOptions.dryRun());
map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsBuildOptions.keepGoing());
+ map.insert(QLatin1String(QBS_CHECK_TIMESTAMPS), m_qbsBuildOptions.forceTimestampCheck());
map.insert(QLatin1String(QBS_MAXJOBCOUNT), m_qbsBuildOptions.maxJobCount());
return map;
}
@@ -333,6 +342,14 @@ void QbsBuildStep::setKeepGoing(bool kg)
emit qbsBuildOptionsChanged();
}
+void QbsBuildStep::setCheckTimestamps(bool ts)
+{
+ if (m_qbsBuildOptions.forceTimestampCheck() == ts)
+ return;
+ m_qbsBuildOptions.setForceTimestampCheck(ts);
+ emit qbsBuildOptionsChanged();
+}
+
void QbsBuildStep::setMaxJobs(int jobcount)
{
if (m_qbsBuildOptions.maxJobCount() == jobcount)
@@ -362,6 +379,8 @@ QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) :
this, SLOT(changeBuildVariant(int)));
connect(m_ui->dryRunCheckBox, SIGNAL(toggled(bool)), this, SLOT(changeDryRun(bool)));
connect(m_ui->keepGoingCheckBox, SIGNAL(toggled(bool)), this, SLOT(changeKeepGoing(bool)));
+ connect(m_ui->checkTimestampCheckBox, SIGNAL(toggled(bool)),
+ this, SLOT(changeCheckTimestamps(bool)));
connect(m_ui->jobSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeJobCount(int)));
connect(m_ui->propertyEdit, SIGNAL(propertiesChanged()), this, SLOT(changeProperties()));
connect(m_ui->qmlDebuggingLibraryCheckBox, SIGNAL(toggled(bool)),
@@ -386,6 +405,7 @@ void QbsBuildStepConfigWidget::updateState()
if (!m_ignoreChange) {
m_ui->dryRunCheckBox->setChecked(m_step->dryRun());
m_ui->keepGoingCheckBox->setChecked(m_step->keepGoing());
+ m_ui->checkTimestampCheckBox->setChecked(m_step->checkTimestamps());
m_ui->jobSpinBox->setValue(m_step->maxJobs());
updatePropertyEdit(m_step->qbsConfiguration());
m_ui->qmlDebuggingLibraryCheckBox->setChecked(m_step->isQmlDebuggingEnabled());
@@ -402,6 +422,8 @@ void QbsBuildStepConfigWidget::updateState()
command += QLatin1String("--dry-run ");
if (m_step->keepGoing())
command += QLatin1String("--keep-going ");
+ if (m_step->checkTimestamps())
+ command += QLatin1String("--check-timestamps ");
command += QString::fromLatin1("--jobs %1 ").arg(m_step->maxJobs());
command += QString::fromLatin1("%1 profile:%2").arg(buildVariant, m_step->profile());
@@ -480,6 +502,13 @@ void QbsBuildStepConfigWidget::changeKeepGoing(bool kg)
m_ignoreChange = false;
}
+void QbsBuildStepConfigWidget::changeCheckTimestamps(bool ts)
+{
+ m_ignoreChange = true;
+ m_step->setCheckTimestamps(ts);
+ m_ignoreChange = false;
+}
+
void QbsBuildStepConfigWidget::changeJobCount(int count)
{
m_ignoreChange = true;
diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.h b/src/plugins/qbsprojectmanager/qbsbuildstep.h
index 5227128afc..3b6ceb77c2 100644
--- a/src/plugins/qbsprojectmanager/qbsbuildstep.h
+++ b/src/plugins/qbsprojectmanager/qbsbuildstep.h
@@ -65,6 +65,7 @@ public:
bool dryRun() const;
bool keepGoing() const;
+ bool checkTimestamps() const;
int maxJobs() const;
QString buildVariant() const;
@@ -93,6 +94,7 @@ private:
void setDryRun(bool dr);
void setKeepGoing(bool kg);
+ void setCheckTimestamps(bool ts);
void setMaxJobs(int jobcount);
QVariantMap m_qbsConfiguration;
@@ -129,6 +131,7 @@ private slots:
void changeBuildVariant(int);
void changeDryRun(bool dr);
void changeKeepGoing(bool kg);
+ void changeCheckTimestamps(bool ts);
void changeJobCount(int count);
void changeProperties();
diff --git a/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui b/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui
index d527af4f96..52767a8103 100644
--- a/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui
+++ b/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui
@@ -168,6 +168,13 @@
</widget>
</item>
<item>
+ <widget class="QCheckBox" name="checkTimestampCheckBox">
+ <property name="text">
+ <string>Check timestamps</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="checkBoxSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
diff --git a/src/plugins/qbsprojectmanager/qbsinstallstep.cpp b/src/plugins/qbsprojectmanager/qbsinstallstep.cpp
index 1e7571e08f..738a2a6812 100644
--- a/src/plugins/qbsprojectmanager/qbsinstallstep.cpp
+++ b/src/plugins/qbsprojectmanager/qbsinstallstep.cpp
@@ -276,6 +276,7 @@ QbsInstallStepConfigWidget::QbsInstallStepConfigWidget(QbsInstallStep *step) :
m_ui->installRootChooser->setPromptDialogTitle(tr("Qbs Install Prefix"));
m_ui->installRootChooser->setExpectedKind(Utils::PathChooser::Directory);
+ m_ui->installRootChooser->setHistoryCompleter(QLatin1String("Qbs.InstallRoot.History"));
connect(m_ui->installRootChooser, SIGNAL(changed(QString)), this, SLOT(changeInstallRoot()));
connect(m_ui->removeFirstCheckBox, SIGNAL(toggled(bool)), this, SLOT(changeRemoveFirst(bool)));
diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp
index 50e277cb73..ff95a5d2fb 100644
--- a/src/plugins/qbsprojectmanager/qbsproject.cpp
+++ b/src/plugins/qbsprojectmanager/qbsproject.cpp
@@ -77,8 +77,8 @@ namespace Internal {
// --------------------------------------------------------------------
static const char CONFIG_CPP_MODULE[] = "cpp";
-static const char CONFIG_CXXFLAGS[] = "cxxflags";
-static const char CONFIG_CFLAGS[] = "cflags";
+static const char CONFIG_CXXFLAGS[] = "cxxFlags";
+static const char CONFIG_CFLAGS[] = "cFlags";
static const char CONFIG_DEFINES[] = "defines";
static const char CONFIG_INCLUDEPATHS[] = "includePaths";
static const char CONFIG_FRAMEWORKPATHS[] = "frameworkPaths";
@@ -102,6 +102,7 @@ QbsProject::QbsProject(QbsManager *manager, const QString &fileName) :
{
m_parsingDelay.setInterval(1000); // delay parsing by 1s.
+ setId(Constants::PROJECT_ID);
setProjectContext(Context(Constants::PROJECT_ID));
setProjectLanguages(Context(ProjectExplorer::Constants::LANG_CXX));
@@ -111,7 +112,7 @@ QbsProject::QbsProject(QbsManager *manager, const QString &fileName) :
this, SLOT(targetWasAdded(ProjectExplorer::Target*)));
connect(this, SIGNAL(environmentChanged()), this, SLOT(delayParsing()));
- connect(&m_parsingDelay, SIGNAL(timeout()), this, SLOT(parseCurrentBuildConfiguration()));
+ connect(&m_parsingDelay, SIGNAL(timeout()), this, SLOT(startParsing()));
updateDocuments(QSet<QString>() << fileName);
@@ -140,11 +141,6 @@ QString QbsProject::displayName() const
return m_projectName;
}
-Id QbsProject::id() const
-{
- return Constants::PROJECT_ID;
-}
-
IDocument *QbsProject::document() const
{
foreach (IDocument *doc, m_qbsDocuments) {
@@ -361,6 +357,11 @@ void QbsProject::buildConfigurationChanged(BuildConfiguration *bc)
}
}
+void QbsProject::startParsing()
+{
+ parseCurrentBuildConfiguration(false);
+}
+
void QbsProject::delayParsing()
{
m_parsingDelay.start();
@@ -372,10 +373,13 @@ void QbsProject::delayForcedParsing()
delayParsing();
}
-void QbsProject::parseCurrentBuildConfiguration()
+void QbsProject::parseCurrentBuildConfiguration(bool force)
{
m_parsingDelay.stop();
+ if (!m_forceParsing)
+ m_forceParsing = force;
+
if (!activeTarget())
return;
QbsBuildConfiguration *bc = qobject_cast<QbsBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
@@ -639,7 +643,7 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj)
part->includePaths += grpIncludePaths;
part->frameworkPaths += grpFrameworkPaths;
part->precompiledHeaders = QStringList(pch);
- part->defines += grpDefines;
+ part->projectDefines += grpDefines;
pinfo.appendProjectPart(part);
}
}
diff --git a/src/plugins/qbsprojectmanager/qbsproject.h b/src/plugins/qbsprojectmanager/qbsproject.h
index 2030ffe093..1ca9003717 100644
--- a/src/plugins/qbsprojectmanager/qbsproject.h
+++ b/src/plugins/qbsprojectmanager/qbsproject.h
@@ -74,7 +74,6 @@ public:
~QbsProject();
QString displayName() const;
- Core::Id id() const;
Core::IDocument *document() const;
QbsManager *projectManager() const;
@@ -91,6 +90,7 @@ public:
QString profileForTarget(const ProjectExplorer::Target *t) const;
bool isParsing() const;
bool hasParseResult() const;
+ void parseCurrentBuildConfiguration(bool force);
Utils::FileName defaultBuildDirectory() const;
static Utils::FileName defaultBuildDirectory(const QString &path);
@@ -102,7 +102,6 @@ public:
public slots:
void invalidate();
- void parseCurrentBuildConfiguration();
void delayParsing();
void delayForcedParsing();
@@ -118,6 +117,7 @@ private slots:
void targetWasAdded(ProjectExplorer::Target *t);
void changeActiveTarget(ProjectExplorer::Target *t);
void buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc);
+ void startParsing();
private:
bool fromMap(const QVariantMap &map);
diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro
index 47e40a1f22..3b8da1c508 100644
--- a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro
+++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro
@@ -36,7 +36,6 @@ HEADERS = \
qbsprojectmanagerplugin.h \
qbspropertylineedit.h \
qbsrunconfiguration.h \
- qbsstep.h \
qbsconstants.h
SOURCES = \
@@ -55,8 +54,7 @@ SOURCES = \
qbsprojectmanager.cpp \
qbsprojectmanagerplugin.cpp \
qbspropertylineedit.cpp \
- qbsrunconfiguration.cpp \
- qbsstep.cpp
+ qbsrunconfiguration.cpp
FORMS = \
qbsbuildstepconfigwidget.ui \
diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs
index af2759e317..b4e8ab2420 100644
--- a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs
+++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs
@@ -96,9 +96,7 @@ QtcPlugin {
"qbspropertylineedit.cpp",
"qbspropertylineedit.h",
"qbsrunconfiguration.cpp",
- "qbsrunconfiguration.h",
- "qbsstep.cpp",
- "qbsstep.h"
+ "qbsrunconfiguration.h"
]
}
diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp
index b518df7acc..ae39dbe47a 100644
--- a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp
+++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp
@@ -405,7 +405,7 @@ void QbsProjectManagerPlugin::buildProducts(QbsProject *project, const QStringLi
void QbsProjectManagerPlugin::reparseCurrentProject()
{
if (m_currentProject)
- m_currentProject->parseCurrentBuildConfiguration();
+ m_currentProject->parseCurrentBuildConfiguration(true);
}
} // namespace Internal
diff --git a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
index 4c5e76d6bd..522e375cf3 100644
--- a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
+++ b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
@@ -294,16 +294,6 @@ QString QbsRunConfiguration::qbsProduct() const
return m_qbsProduct;
}
-QString QbsRunConfiguration::dumperLibrary() const
-{
- return QtSupport::QtKitInformation::dumperLibrary(target()->kit());
-}
-
-QStringList QbsRunConfiguration::dumperLibraryLocations() const
-{
- return QtSupport::QtKitInformation::dumperLibraryLocations(target()->kit());
-}
-
QString QbsRunConfiguration::defaultDisplayName()
{
QString defaultName;
@@ -376,6 +366,7 @@ QbsRunConfigurationWidget::QbsRunConfigurationWidget(QbsRunConfiguration *rc, QW
toplayout->addRow(argumentsLabel, m_argumentsLineEdit);
m_workingDirectoryEdit = new Utils::PathChooser(this);
+ m_workingDirectoryEdit->setHistoryCompleter(QLatin1String("WorkingDir.History"));
m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory);
ProjectExplorer::EnvironmentAspect *aspect
= m_rc->extraAspect<ProjectExplorer::EnvironmentAspect>();
diff --git a/src/plugins/qbsprojectmanager/qbsrunconfiguration.h b/src/plugins/qbsprojectmanager/qbsrunconfiguration.h
index c01b1e5d8a..baa201144e 100644
--- a/src/plugins/qbsprojectmanager/qbsrunconfiguration.h
+++ b/src/plugins/qbsprojectmanager/qbsrunconfiguration.h
@@ -83,8 +83,6 @@ public:
bool forcedGuiMode() const;
QString workingDirectory() const;
QString commandLineArguments() const;
- QString dumperLibrary() const;
- QStringList dumperLibraryLocations() const;
QVariantMap toMap() const;
diff --git a/src/plugins/qbsprojectmanager/qbsstep.cpp b/src/plugins/qbsprojectmanager/qbsstep.cpp
deleted file mode 100644
index 7348398824..0000000000
--- a/src/plugins/qbsprojectmanager/qbsstep.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "qbsstep.h"
-
-#include "qbsbuildconfiguration.h"
-#include "qbsparser.h"
-#include "qbsproject.h"
-#include "qbsprojectmanagerconstants.h"
-
-#include <projectexplorer/buildsteplist.h>
-#include <projectexplorer/kit.h>
-#include <projectexplorer/projectexplorerconstants.h>
-#include <projectexplorer/target.h>
-#include <utils/qtcassert.h>
-
-#include <qbs.h>
-
-#include <QTimer>
-
-// --------------------------------------------------------------------
-// Constants:
-// --------------------------------------------------------------------
-
-static const char QBS_DRY_RUN[] = "Qbs.DryRun";
-static const char QBS_KEEP_GOING[] = "Qbs.DryKeepGoing";
-static const char QBS_MAXJOBCOUNT[] = "Qbs.MaxJobs";
-
-namespace QbsProjectManager {
-namespace Internal {
-
-// --------------------------------------------------------------------
-// QbsStep:
-// --------------------------------------------------------------------
-
-QbsStep::QbsStep(ProjectExplorer::BuildStepList *bsl, Core::Id id) :
- ProjectExplorer::BuildStep(bsl, id),
- m_job(0)
-{
- m_qbsBuildOptions.setMaxJobCount(QbsManager::preferences()->jobs());
-}
-
-QbsStep::QbsStep(ProjectExplorer::BuildStepList *bsl, const QbsStep *other) :
- ProjectExplorer::BuildStep(bsl, Core::Id(Constants::QBS_BUILDSTEP_ID)),
- m_qbsBuildOptions(other->m_qbsBuildOptions), m_job(0)
-{ }
-
-QbsBuildConfiguration *QbsStep::currentBuildConfiguration() const
-{
- QbsBuildConfiguration *bc = static_cast<QbsBuildConfiguration *>(buildConfiguration());
- if (!bc)
- bc = static_cast<QbsBuildConfiguration *>(target()->activeBuildConfiguration());
- return bc;
-}
-
-QbsStep::~QbsStep()
-{
- cancel();
- m_job->deleteLater();
- m_job = 0;
-}
-
-bool QbsStep::init()
-{
- if (static_cast<QbsProject *>(project())->isParsing() || m_job)
- return false;
-
- if (!currentBuildConfiguration())
- return false;
-
- return true;
-}
-
-void QbsStep::run(QFutureInterface<bool> &fi)
-{
- m_fi = &fi;
-
- m_job = createJob();
-
- if (!m_job) {
- jobDone(false);
- return;
- }
-
- m_progressBase = 0;
-
- connect(m_job, SIGNAL(finished(bool,qbs::AbstractJob*)), this, SLOT(jobDone(bool)));
- connect(m_job, SIGNAL(taskStarted(QString,int,qbs::AbstractJob*)),
- this, SLOT(handleTaskStarted(QString,int)));
- connect(m_job, SIGNAL(taskProgress(int,qbs::AbstractJob*)),
- this, SLOT(handleProgress(int)));
-}
-
-QFutureInterface<bool> *QbsStep::future() const
-{
- return m_fi;
-}
-
-bool QbsStep::runInGuiThread() const
-{
- return true;
-}
-
-void QbsStep::cancel()
-{
- if (m_job)
- m_job->cancel();
-}
-
-bool QbsStep::dryRun() const
-{
- return m_qbsBuildOptions.dryRun();
-}
-
-bool QbsStep::keepGoing() const
-{
- return m_qbsBuildOptions.keepGoing();
-}
-
-int QbsStep::maxJobs() const
-{
- return m_qbsBuildOptions.maxJobCount();
-}
-
-bool QbsStep::fromMap(const QVariantMap &map)
-{
- if (!ProjectExplorer::BuildStep::fromMap(map))
- return false;
-
- m_qbsBuildOptions.setDryRun(map.value(QLatin1String(QBS_DRY_RUN)).toBool());
- m_qbsBuildOptions.setKeepGoing(map.value(QLatin1String(QBS_KEEP_GOING)).toBool());
- m_qbsBuildOptions.setMaxJobCount(map.value(QLatin1String(QBS_MAXJOBCOUNT)).toInt());
-
- if (m_qbsBuildOptions.maxJobCount() <= 0)
- m_qbsBuildOptions.setMaxJobCount(QbsManager::preferences()->jobs());
-
- return true;
-}
-
-QVariantMap QbsStep::toMap() const
-{
- QVariantMap map = ProjectExplorer::BuildStep::toMap();
- map.insert(QLatin1String(QBS_DRY_RUN), m_qbsBuildOptions.dryRun());
- map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsBuildOptions.keepGoing());
- map.insert(QLatin1String(QBS_MAXJOBCOUNT), m_qbsBuildOptions.maxJobCount());
- return map;
-}
-
-void QbsStep::jobDone(bool success)
-{
- // Report errors:
- if (m_job) {
- foreach (const qbs::ErrorItem &item, m_job->error().items())
- createTaskAndOutput(ProjectExplorer::Task::Error, item.description(),
- item.codeLocation().fileName(), item.codeLocation().line());
- m_job->deleteLater();
- m_job = 0;
- }
-
- QTC_ASSERT(m_fi, return);
- m_fi->reportResult(success);
- m_fi = 0; // do not delete, it is not ours
-
- emit finished();
-}
-
-void QbsStep::handleTaskStarted(const QString &desciption, int max)
-{
- Q_UNUSED(desciption);
- QTC_ASSERT(m_fi, return);
-
- m_progressBase = m_fi->progressValue();
- m_fi->setProgressRange(0, m_progressBase + max);
-}
-
-void QbsStep::handleProgress(int value)
-{
- QTC_ASSERT(m_fi, return);
- m_fi->setProgressValue(m_progressBase + value);
-}
-
-void QbsStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message,
- const QString &file, int line)
-{
- emit addTask(ProjectExplorer::Task(type, message,
- Utils::FileName::fromString(file), line,
- ProjectExplorer::Constants::TASK_CATEGORY_COMPILE));
- emit addOutput(message, NormalOutput);
-}
-
-void QbsStep::setDryRun(bool dr)
-{
- if (m_qbsBuildOptions.dryRun() == dr)
- return;
- m_qbsBuildOptions.setDryRun(dr);
- emit qbsBuildOptionsChanged();
-}
-
-void QbsStep::setKeepGoing(bool kg)
-{
- if (m_qbsBuildOptions.keepGoing() == kg)
- return;
- m_qbsBuildOptions.setKeepGoing(kg);
- emit qbsBuildOptionsChanged();
-}
-
-void QbsStep::setMaxJobs(int jobcount)
-{
- if (m_qbsBuildOptions.maxJobCount() == jobcount)
- return;
- m_qbsBuildOptions.setMaxJobCount(jobcount);
- emit qbsBuildOptionsChanged();
-}
-
-} // namespace Internal
-} // namespace QbsProjectManager
diff --git a/src/plugins/qbsprojectmanager/qbsstep.h b/src/plugins/qbsprojectmanager/qbsstep.h
deleted file mode 100644
index 6ced81e85f..0000000000
--- a/src/plugins/qbsprojectmanager/qbsstep.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef QBSSTEP_H
-#define QBSSTEP_H
-
-#include "qbsbuildconfiguration.h"
-
-#include <projectexplorer/buildstep.h>
-#include <projectexplorer/task.h>
-
-#include <qbs.h>
-
-namespace QbsProjectManager {
-namespace Internal {
-
-class QbsStepConfigWidget;
-
-class QbsStep : public ProjectExplorer::BuildStep
-{
- Q_OBJECT
-
-public:
- ~QbsStep();
-
- bool init();
-
- void run(QFutureInterface<bool> &fi);
-
- QFutureInterface<bool> *future() const;
-
- bool runInGuiThread() const;
- void cancel();
-
- bool dryRun() const;
- bool keepGoing() const;
- int maxJobs() const;
- QString buildVariant() const;
-
- bool fromMap(const QVariantMap &map);
- QVariantMap toMap() const;
-
-signals:
- void qbsBuildOptionsChanged();
-
-private slots:
- virtual void jobDone(bool success);
- void handleTaskStarted(const QString &desciption, int max);
- void handleProgress(int value);
-
-protected:
- QbsStep(ProjectExplorer::BuildStepList *bsl, Core::Id id);
- QbsStep(ProjectExplorer::BuildStepList *bsl, const QbsStep *other);
-
- QbsBuildConfiguration *currentBuildConfiguration() const;
-
- virtual qbs::AbstractJob *createJob() = 0;
-
- void createTaskAndOutput(ProjectExplorer::Task::TaskType type,
- const QString &message, const QString &file, int line);
-
- qbs::AbstractJob *job() const { return m_job; }
- qbs::BuildOptions buildOptions() const { return m_qbsBuildOptions; }
-
-private:
- void setDryRun(bool dr);
- void setKeepGoing(bool kg);
- void setMaxJobs(int jobcount);
-
- qbs::BuildOptions m_qbsBuildOptions;
-
- QFutureInterface<bool> *m_fi;
- qbs::AbstractJob *m_job;
- int m_progressBase;
-
- friend class QbsStepConfigWidget;
-};
-
-} // namespace Internal
-} // namespace QbsProjectManager
-
-#endif // QBSSTEP_H
diff --git a/src/plugins/qmakeprojectmanager/customwidgetwizard/classdefinition.cpp b/src/plugins/qmakeprojectmanager/customwidgetwizard/classdefinition.cpp
index efe8d7c94a..e374d09c44 100644
--- a/src/plugins/qmakeprojectmanager/customwidgetwizard/classdefinition.cpp
+++ b/src/plugins/qmakeprojectmanager/customwidgetwizard/classdefinition.cpp
@@ -40,6 +40,7 @@ ClassDefinition::ClassDefinition(QWidget *parent) :
{
m_ui.setupUi(this);
m_ui.iconPathChooser->setExpectedKind(Utils::PathChooser::File);
+ m_ui.iconPathChooser->setHistoryCompleter(QLatin1String("Qmake.Icon.History"));
m_ui.iconPathChooser->setPromptDialogTitle(tr("Select Icon"));
m_ui.iconPathChooser->setPromptDialogFilter(tr("Icon files (*.png *.ico *.jpg *.xpm *.tif *.svg)"));
}
diff --git a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp
index b1dffee1b5..918546e484 100644
--- a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp
+++ b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp
@@ -217,6 +217,7 @@ DesktopQmakeRunConfigurationWidget::DesktopQmakeRunConfigurationWidget(DesktopQm
m_workingDirectoryEdit = new PathChooser(this);
m_workingDirectoryEdit->setExpectedKind(PathChooser::Directory);
+ m_workingDirectoryEdit->setHistoryCompleter(QLatin1String("WorkingDir.History"));
m_workingDirectoryEdit->setPath(m_qmakeRunConfiguration->baseWorkingDirectory());
m_workingDirectoryEdit->setBaseDirectory(m_qmakeRunConfiguration->target()->project()->projectDirectory());
EnvironmentAspect *aspect = qmakeRunConfiguration->extraAspect<EnvironmentAspect>();
@@ -552,16 +553,6 @@ QString DesktopQmakeRunConfiguration::proFilePath() const
return m_proFilePath;
}
-QString DesktopQmakeRunConfiguration::dumperLibrary() const
-{
- return QtSupport::QtKitInformation::dumperLibrary(target()->kit());
-}
-
-QStringList DesktopQmakeRunConfiguration::dumperLibraryLocations() const
-{
- return QtSupport::QtKitInformation::dumperLibraryLocations(target()->kit());
-}
-
QString DesktopQmakeRunConfiguration::defaultDisplayName()
{
QString defaultName;
diff --git a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h
index c89cef28e5..bbcc27a56b 100644
--- a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h
+++ b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h
@@ -81,8 +81,6 @@ public:
bool forcedGuiMode() const;
virtual QString workingDirectory() const;
virtual QString commandLineArguments() const;
- QString dumperLibrary() const;
- QStringList dumperLibraryLocations() const;
bool isUsingDyldImageSuffix() const;
void setUsingDyldImageSuffix(bool state);
diff --git a/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp b/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp
index a08539eae5..afe18ef262 100644
--- a/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp
+++ b/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp
@@ -620,6 +620,9 @@ NonInternalLibraryDetailsController::NonInternalLibraryDetailsController(
setLibraryComboBoxVisible(false);
setLibraryPathChooserVisible(true);
+ libraryDetailsWidget()->libraryPathChooser
+ ->setHistoryCompleter(QLatin1String("Qmake.LibDir.History"));
+
if (creatorPlatform() == CreatorWindows) {
libraryDetailsWidget()->libraryPathChooser->setPromptDialogFilter(
QLatin1String("Library file (*.lib lib*.a)"));
diff --git a/src/plugins/qmakeprojectmanager/makestep.cpp b/src/plugins/qmakeprojectmanager/makestep.cpp
index 2af7374072..d1b39bf2ed 100644
--- a/src/plugins/qmakeprojectmanager/makestep.cpp
+++ b/src/plugins/qmakeprojectmanager/makestep.cpp
@@ -326,7 +326,7 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
m_ui->makePathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_ui->makePathChooser->setBaseDirectory(Utils::PathChooser::homePath());
-
+ m_ui->makePathChooser->setHistoryCompleter(QLatin1String("PE.MakeCommand.History"));
const QString &makeCmd = m_makeStep->makeCommand();
m_ui->makePathChooser->setPath(makeCmd);
diff --git a/src/plugins/qmakeprojectmanager/profileeditor.cpp b/src/plugins/qmakeprojectmanager/profileeditor.cpp
index 68cac3bf6a..c9428cb4b9 100644
--- a/src/plugins/qmakeprojectmanager/profileeditor.cpp
+++ b/src/plugins/qmakeprojectmanager/profileeditor.cpp
@@ -59,11 +59,10 @@ ProFileEditor::ProFileEditor(ProFileEditorWidget *editor)
TextEditor::Constants::C_TEXTEDITOR));
}
-Core::IEditor *ProFileEditor::duplicate(QWidget *parent)
+Core::IEditor *ProFileEditor::duplicate()
{
- ProFileEditorWidget *ret = new ProFileEditorWidget(parent, qobject_cast<ProFileEditorWidget*>(editorWidget())->factory(),
- qobject_cast<ProFileEditorWidget*>(editorWidget())->actionHandler());
- ret->duplicateFrom(editorWidget());
+ ProFileEditorWidget *ret = new ProFileEditorWidget(
+ qobject_cast<ProFileEditorWidget*>(editorWidget()));
TextEditor::TextEditorSettings::initializeEditor(ret);
return ret->editor();
}
@@ -82,15 +81,20 @@ TextEditor::CompletionAssistProvider *ProFileEditor::completionAssistProvider()
// ProFileEditorWidget
//
-ProFileEditorWidget::ProFileEditorWidget(QWidget *parent, ProFileEditorFactory *factory, TextEditor::TextEditorActionHandler *ah)
- : BaseTextEditorWidget(parent), m_factory(factory), m_ah(ah)
+ProFileEditorWidget::ProFileEditorWidget(QWidget *parent)
+ : BaseTextEditorWidget(new ProFileDocument(), parent)
{
- QSharedPointer<ProFileDocument> doc(new ProFileDocument());
- doc->setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE));
- setBaseTextDocument(doc);
+ ctor();
+}
- ah->setupActions(this);
+ProFileEditorWidget::ProFileEditorWidget(ProFileEditorWidget *other)
+ : BaseTextEditorWidget(other)
+{
+ ctor();
+}
+void ProFileEditorWidget::ctor()
+{
baseTextDocument()->setSyntaxHighlighter(new ProFileHighlighter);
m_commentDefinition.clearCommentStyles();
m_commentDefinition.singleLine = QLatin1Char('#');
@@ -170,7 +174,7 @@ ProFileEditorWidget::Link ProFileEditorWidget::findLinkAt(const QTextCursor &cur
}
}
- QDir dir(QFileInfo(editorDocument()->filePath()).absolutePath());
+ QDir dir(QFileInfo(baseTextDocument()->filePath()).absolutePath());
QString fileName = dir.filePath(buffer);
QFileInfo fi(fileName);
if (fi.exists()) {
@@ -206,6 +210,7 @@ void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e)
ProFileDocument::ProFileDocument()
: TextEditor::BaseTextDocument()
{
+ setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE));
}
QString ProFileDocument::defaultPath() const
diff --git a/src/plugins/qmakeprojectmanager/profileeditor.h b/src/plugins/qmakeprojectmanager/profileeditor.h
index 31da55fbff..a45e83075b 100644
--- a/src/plugins/qmakeprojectmanager/profileeditor.h
+++ b/src/plugins/qmakeprojectmanager/profileeditor.h
@@ -34,11 +34,6 @@
#include <texteditor/basetexteditor.h>
#include <utils/uncommentselection.h>
-namespace TextEditor {
-class FontSettings;
-class TextEditorActionHandler;
-}
-
namespace QmakeProjectManager {
namespace Internal {
@@ -53,7 +48,7 @@ public:
ProFileEditor(ProFileEditorWidget *);
bool duplicateSupported() const { return true; }
- Core::IEditor *duplicate(QWidget *parent);
+ Core::IEditor *duplicate();
Core::Id id() const;
TextEditor::CompletionAssistProvider *completionAssistProvider();
};
@@ -63,11 +58,8 @@ class ProFileEditorWidget : public TextEditor::BaseTextEditorWidget
Q_OBJECT
public:
- ProFileEditorWidget(QWidget *parent, ProFileEditorFactory *factory,
- TextEditor::TextEditorActionHandler *ah);
-
- ProFileEditorFactory *factory() { return m_factory; }
- TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; }
+ ProFileEditorWidget(QWidget *parent = 0);
+ ProFileEditorWidget(ProFileEditorWidget *other);
void unCommentSelection();
@@ -78,8 +70,8 @@ protected:
void contextMenuEvent(QContextMenuEvent *);
private:
- ProFileEditorFactory *m_factory;
- TextEditor::TextEditorActionHandler *m_ah;
+ ProFileEditorWidget(BaseTextEditorWidget *); // avoid stupidity
+ void ctor();
Utils::CommentDefinition m_commentDefinition;
};
diff --git a/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp b/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp
index d549513d54..a5473d799c 100644
--- a/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp
+++ b/src/plugins/qmakeprojectmanager/profileeditorfactory.cpp
@@ -35,6 +35,7 @@
#include <qtsupport/qtsupportconstants.h>
#include <coreplugin/fileiconprovider.h>
+#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorsettings.h>
#include <QCoreApplication>
@@ -42,24 +43,26 @@
using namespace QmakeProjectManager;
using namespace QmakeProjectManager::Internal;
-ProFileEditorFactory::ProFileEditorFactory(QmakeManager *manager, TextEditor::TextEditorActionHandler *handler) :
- m_manager(manager),
- m_actionHandler(handler)
+ProFileEditorFactory::ProFileEditorFactory(QmakeManager *manager) :
+ m_manager(manager)
{
setId(QmakeProjectManager::Constants::PROFILE_EDITOR_ID);
setDisplayName(qApp->translate("OpenWith::Editors", QmakeProjectManager::Constants::PROFILE_EDITOR_DISPLAY_NAME));
addMimeType(QmakeProjectManager::Constants::PROFILE_MIMETYPE);
addMimeType(QmakeProjectManager::Constants::PROINCLUDEFILE_MIMETYPE);
addMimeType(QmakeProjectManager::Constants::PROFEATUREFILE_MIMETYPE);
+ new TextEditor::TextEditorActionHandler(this, Constants::C_PROFILEEDITOR,
+ TextEditor::TextEditorActionHandler::UnCommentSelection
+ | TextEditor::TextEditorActionHandler::JumpToFileUnderCursor);
Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "pro");
Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "pri");
Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "prf");
}
-Core::IEditor *ProFileEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *ProFileEditorFactory::createEditor()
{
- ProFileEditorWidget *editor = new ProFileEditorWidget(parent, this, m_actionHandler);
+ ProFileEditorWidget *editor = new ProFileEditorWidget;
TextEditor::TextEditorSettings::initializeEditor(editor);
return editor->editor();
}
diff --git a/src/plugins/qmakeprojectmanager/profileeditorfactory.h b/src/plugins/qmakeprojectmanager/profileeditorfactory.h
index 52bd50ae8c..d42deadfbc 100644
--- a/src/plugins/qmakeprojectmanager/profileeditorfactory.h
+++ b/src/plugins/qmakeprojectmanager/profileeditorfactory.h
@@ -32,8 +32,6 @@
#include <coreplugin/editormanager/ieditorfactory.h>
-namespace TextEditor { class TextEditorActionHandler; }
-
namespace QmakeProjectManager {
class QmakeManager;
@@ -45,15 +43,14 @@ class ProFileEditorFactory : public Core::IEditorFactory
Q_OBJECT
public:
- ProFileEditorFactory(QmakeManager *parent, TextEditor::TextEditorActionHandler *handler);
+ ProFileEditorFactory(QmakeManager *parent);
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
QmakeManager *qmakeProjectManager() const { return m_manager; }
private:
QmakeManager *m_manager;
- TextEditor::TextEditorActionHandler *m_actionHandler;
};
} // namespace Internal
diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
index 69a1bea7dd..32ad3e5adb 100644
--- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
@@ -865,7 +865,7 @@ QList<ProjectNode::ProjectAction> QmakePriFileNode::supportedActions(Node *node)
addExistingFiles = addExistingFiles && !deploysFolder(node->path());
if (addExistingFiles)
- actions << AddExistingFile;
+ actions << AddExistingFile << AddExistingDirectory;
break;
}
diff --git a/src/plugins/qmakeprojectmanager/qmakeparser.cpp b/src/plugins/qmakeprojectmanager/qmakeparser.cpp
index f4e8ac63a0..8f05dde81c 100644
--- a/src/plugins/qmakeprojectmanager/qmakeparser.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeparser.cpp
@@ -33,7 +33,6 @@
#include <projectexplorer/projectexplorerconstants.h>
using namespace QmakeProjectManager;
-using namespace QmakeProjectManager::Internal;
using ProjectExplorer::Task;
QMakeParser::QMakeParser() : m_error(QLatin1String("^(.+):(\\d+):\\s(.+)$"))
diff --git a/src/plugins/qmakeprojectmanager/qmakeparser.h b/src/plugins/qmakeprojectmanager/qmakeparser.h
index 38d1d63f0f..3d54e71ede 100644
--- a/src/plugins/qmakeprojectmanager/qmakeparser.h
+++ b/src/plugins/qmakeprojectmanager/qmakeparser.h
@@ -30,14 +30,15 @@
#ifndef QMAKEPARSER_H
#define QMAKEPARSER_H
+#include "qmakeprojectmanager_global.h"
+
#include <projectexplorer/ioutputparser.h>
#include <QRegExp>
namespace QmakeProjectManager {
-namespace Internal {
-class QMakeParser : public ProjectExplorer::IOutputParser
+class QMAKEPROJECTMANAGER_EXPORT QMakeParser : public ProjectExplorer::IOutputParser
{
Q_OBJECT
@@ -49,7 +50,6 @@ private:
QRegExp m_error;
};
-} // namesapce Internal
} // namespace QmakeProjectManager
#endif // QMAKEPARSER_H
diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
index 5951e7a58d..b3ab28aed1 100644
--- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
@@ -343,6 +343,7 @@ QmakeProject::QmakeProject(QmakeManager *manager, const QString &fileName) :
m_centralizedFolderWatcher(0),
m_activeTarget(0)
{
+ setId(Constants::QMAKEPROJECT_ID);
setProjectContext(Core::Context(QmakeProjectManager::Constants::PROJECT_ID));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX));
@@ -527,7 +528,7 @@ void QmakeProject::updateCppCodeModel()
SysRootKitInformation::sysRoot(k));
// part->defines
- part->defines += pro->cxxDefines();
+ part->projectDefines += pro->cxxDefines();
// part->includePaths, part->frameworkPaths
part->includePaths.append(pro->variableValue(IncludePathVar));
@@ -890,11 +891,6 @@ QString QmakeProject::displayName() const
return QFileInfo(projectFilePath()).completeBaseName();
}
-Core::Id QmakeProject::id() const
-{
- return Core::Id(Constants::QMAKEPROJECT_ID);
-}
-
Core::IDocument *QmakeProject::document() const
{
return m_fileInfo;
diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.h b/src/plugins/qmakeprojectmanager/qmakeproject.h
index acb95159e8..cc49b9ec9c 100644
--- a/src/plugins/qmakeprojectmanager/qmakeproject.h
+++ b/src/plugins/qmakeprojectmanager/qmakeproject.h
@@ -76,7 +76,6 @@ public:
virtual ~QmakeProject();
QString displayName() const;
- Core::Id id() const;
Core::IDocument *document() const;
ProjectExplorer::IProjectManager *projectManager() const;
QmakeManager *qmakeProjectManager() const;
diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectconfigwidget.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectconfigwidget.cpp
index 389f78deee..8f28bc8f55 100644
--- a/src/plugins/qmakeprojectmanager/qmakeprojectconfigwidget.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeprojectconfigwidget.cpp
@@ -67,6 +67,7 @@ QmakeProjectConfigWidget::QmakeProjectConfigWidget(QmakeBuildConfiguration *bc)
m_ui->shadowBuildDirEdit->setPromptDialogTitle(tr("Shadow Build Directory"));
m_ui->shadowBuildDirEdit->setExpectedKind(Utils::PathChooser::ExistingDirectory);
+ m_ui->shadowBuildDirEdit->setHistoryCompleter(QLatin1String("BuildDir.History"));
m_ui->shadowBuildDirEdit->setEnvironment(bc->environment());
m_ui->shadowBuildDirEdit->setBaseDirectory(bc->target()->project()->projectDirectory());
bool isShadowBuild = bc->isShadowBuild();
diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp
index 160924023d..699d80be0e 100644
--- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp
@@ -55,14 +55,6 @@ using namespace ProjectExplorer;
using namespace QmakeProjectManager;
using namespace QmakeProjectManager::Internal;
-// Known file types of a Qt 4 project
-static const char *qmakeFileTypes[] = {
- "CppHeaderFiles",
- "CppSourceFiles",
- "Qt4FormFiles",
- "Qt4ResourceFiles"
-};
-
QmakeManager::QmakeManager(QmakeProjectManagerPlugin *plugin)
: m_plugin(plugin),
m_contextNode(0),
@@ -140,10 +132,10 @@ void QmakeManager::setContextFile(ProjectExplorer::FileNode *file)
void QmakeManager::addLibrary()
{
- ProFileEditorWidget *editor =
- qobject_cast<ProFileEditorWidget*>(Core::EditorManager::currentEditor()->widget());
+ ProFileEditor *editor =
+ qobject_cast<ProFileEditor*>(Core::EditorManager::currentEditor());
if (editor)
- addLibrary(editor->editorDocument()->filePath(), editor);
+ addLibrary(editor->document()->filePath(), editor);
}
void QmakeManager::addLibraryContextMenu()
@@ -153,34 +145,29 @@ void QmakeManager::addLibraryContextMenu()
addLibrary(node->path());
}
-void QmakeManager::addLibrary(const QString &fileName, ProFileEditorWidget *editor)
+void QmakeManager::addLibrary(const QString &fileName, ProFileEditor *editor)
{
AddLibraryWizard wizard(fileName, Core::EditorManager::instance());
if (wizard.exec() != QDialog::Accepted)
return;
- TextEditor::BaseTextEditor *editable = 0;
- if (editor) {
- editable = editor->editor();
- } else {
- editable = qobject_cast<TextEditor::BaseTextEditor *>
- (Core::EditorManager::openEditor(fileName, QmakeProjectManager::Constants::PROFILE_EDITOR_ID,
- Core::EditorManager::DoNotMakeVisible));
- }
- if (!editable)
+ if (!editor)
+ editor = qobject_cast<ProFileEditor *> (Core::EditorManager::openEditor(fileName,
+ QmakeProjectManager::Constants::PROFILE_EDITOR_ID, Core::EditorManager::DoNotMakeVisible));
+ if (!editor)
return;
- const int endOfDoc = editable->position(TextEditor::ITextEditor::EndOfDoc);
- editable->setCursorPosition(endOfDoc);
+ const int endOfDoc = editor->position(TextEditor::ITextEditor::EndOfDoc);
+ editor->setCursorPosition(endOfDoc);
QString snippet = wizard.snippet();
// add extra \n in case the last line is not empty
int line, column;
- editable->convertPosition(endOfDoc, &line, &column);
- if (!editable->textDocument()->textAt(endOfDoc - column, column).simplified().isEmpty())
+ editor->convertPosition(endOfDoc, &line, &column);
+ if (!editor->textDocument()->textAt(endOfDoc - column, column).simplified().isEmpty())
snippet = QLatin1Char('\n') + snippet;
- editable->insert(snippet);
+ editor->insert(snippet);
}
@@ -310,22 +297,3 @@ void QmakeManager::handleSubDirContextMenu(QmakeManager::Action action, bool isF
bc->setSubNodeBuild(0);
bc->setFileNodeBuild(0);
}
-
-QString QmakeManager::fileTypeId(ProjectExplorer::FileType type)
-{
- switch (type) {
- case HeaderType:
- return QLatin1String(qmakeFileTypes[0]);
- case SourceType:
- return QLatin1String(qmakeFileTypes[1]);
- case FormType:
- return QLatin1String(qmakeFileTypes[2]);
- case ResourceType:
- return QLatin1String(qmakeFileTypes[3]);
- case UnknownFileType:
- default:
- break;
- }
- return QString();
-}
-
diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.h b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.h
index ca7314b6ec..a7fd326da4 100644
--- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.h
+++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.h
@@ -47,7 +47,7 @@ class ToolChain;
namespace QmakeProjectManager {
namespace Internal {
-class ProFileEditorWidget;
+class ProFileEditor;
class QmakeProjectManagerPlugin;
} // namespace Internal
@@ -76,9 +76,6 @@ public:
ProjectExplorer::FileNode *contextFile() const;
void setContextFile(ProjectExplorer::FileNode *file);
- // Return the id string of a file
- static QString fileTypeId(ProjectExplorer::FileType type);
-
enum Action { BUILD, REBUILD, CLEAN };
public slots:
@@ -99,7 +96,7 @@ private:
ProjectExplorer::Project *contextProject,
ProjectExplorer::Node *contextNode,
ProjectExplorer::FileNode *contextFile);
- void addLibrary(const QString &fileName, Internal::ProFileEditorWidget *editor = 0);
+ void addLibrary(const QString &fileName, Internal::ProFileEditor *editor = 0);
void runQMake(ProjectExplorer::Project *p, ProjectExplorer::Node *node);
Internal::QmakeProjectManagerPlugin *m_plugin;
diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp
index bd9aef8bd4..fd8886f653 100644
--- a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp
@@ -111,12 +111,7 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
m_qmakeProjectManager = new QmakeManager(this);
addObject(m_qmakeProjectManager);
- TextEditor::TextEditorActionHandler *editorHandler
- = new TextEditor::TextEditorActionHandler(Constants::C_PROFILEEDITOR,
- TextEditor::TextEditorActionHandler::UnCommentSelection
- | TextEditor::TextEditorActionHandler::JumpToFileUnderCursor);
-
- m_proFileEditorFactory = new ProFileEditorFactory(m_qmakeProjectManager, editorHandler);
+ m_proFileEditorFactory = new ProFileEditorFactory(m_qmakeProjectManager);
ProjectExplorer::KitManager::registerKitInformation(new QmakeKitInformation);
diff --git a/src/plugins/qmakeprojectmanager/wizards/abstractmobileapp.h b/src/plugins/qmakeprojectmanager/wizards/abstractmobileapp.h
index 86f1a19fb6..2dd2fcda85 100644
--- a/src/plugins/qmakeprojectmanager/wizards/abstractmobileapp.h
+++ b/src/plugins/qmakeprojectmanager/wizards/abstractmobileapp.h
@@ -121,6 +121,7 @@ public:
static const QString DeploymentPriFileName;
protected:
AbstractMobileApp();
+ virtual QByteArray generateProFile(QString *errorMessage) const;
static QString templatesRoot();
static void insertParameter(QString &line, const QString &parameter);
@@ -146,7 +147,6 @@ protected:
private:
QByteArray generateDesktopFile(QString *errorMessage, int fileType) const;
QByteArray generateMainCpp(QString *errorMessage) const;
- QByteArray generateProFile(QString *errorMessage) const;
virtual QByteArray generateFileExtended(int fileType,
bool *versionAndCheckSum, QString *comment, QString *errorMessage) const = 0;
diff --git a/src/plugins/qmakeprojectmanager/wizards/abstractmobileappwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/abstractmobileappwizard.cpp
index bbbd05beba..c4caa59454 100644
--- a/src/plugins/qmakeprojectmanager/wizards/abstractmobileappwizard.cpp
+++ b/src/plugins/qmakeprojectmanager/wizards/abstractmobileappwizard.cpp
@@ -71,7 +71,6 @@ void AbstractMobileAppWizardDialog::addKitsPage()
void AbstractMobileAppWizardDialog::updateKitsPage()
{
if (m_kitsPage) {
- m_kitsPage->setProjectImporter(new Internal::QmakeProjectImporter(path()));
QString platform = selectedPlatform();
if (platform.isEmpty()) {
m_kitsPage->setPreferredKitMatcher(
diff --git a/src/plugins/qmakeprojectmanager/wizards/consoleappwizarddialog.cpp b/src/plugins/qmakeprojectmanager/wizards/consoleappwizarddialog.cpp
index 125313ef6b..a3e1328cc8 100644
--- a/src/plugins/qmakeprojectmanager/wizards/consoleappwizarddialog.cpp
+++ b/src/plugins/qmakeprojectmanager/wizards/consoleappwizarddialog.cpp
@@ -46,7 +46,7 @@ ConsoleAppWizardDialog::ConsoleAppWizardDialog(const QString &templateName,
setSelectedModules(QLatin1String("core"));
setDeselectedModules(QLatin1String("gui"));
- setIntroDescription(tr("This wizard generates a Qt console application "
+ setIntroDescription(tr("This wizard generates a Qt Console Application "
"project. The application derives from QCoreApplication and does not "
"provide a GUI."));
diff --git a/src/plugins/qmakeprojectmanager/wizards/html5appwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/html5appwizard.cpp
index a058add510..bfe11dc188 100644
--- a/src/plugins/qmakeprojectmanager/wizards/html5appwizard.cpp
+++ b/src/plugins/qmakeprojectmanager/wizards/html5appwizard.cpp
@@ -63,7 +63,7 @@ Html5AppWizardDialog::Html5AppWizardDialog(QWidget *parent,
m_htmlOptionsPage(0)
{
setWindowTitle(tr("New HTML5 Application"));
- setIntroDescription(tr("This wizard generates a HTML5 application project."));
+ setIntroDescription(tr("This wizard generates a HTML5 Application project."));
m_htmlOptionsPage = new Html5AppWizardOptionsPage;
addPageWithTitle(m_htmlOptionsPage, tr("HTML Options"));
diff --git a/src/plugins/qmakeprojectmanager/wizards/html5appwizardpages.cpp b/src/plugins/qmakeprojectmanager/wizards/html5appwizardpages.cpp
index b4c41d845b..6fdaccd035 100644
--- a/src/plugins/qmakeprojectmanager/wizards/html5appwizardpages.cpp
+++ b/src/plugins/qmakeprojectmanager/wizards/html5appwizardpages.cpp
@@ -45,6 +45,7 @@ Html5AppWizardOptionsPage::Html5AppWizardOptionsPage(QWidget *parent)
{
d->ui.setupUi(this);
d->ui.importLineEdit->setExpectedKind(Utils::PathChooser::File);
+ d->ui.importLineEdit->setHistoryCompleter(QLatin1String("Qmake.Html.History"));
d->ui.importLineEdit->setPromptDialogFilter(QLatin1String("*.html"));
d->ui.importLineEdit->setPromptDialogTitle(tr("Select HTML File"));
connect(d->ui.importLineEdit, SIGNAL(changed(QString)), SIGNAL(completeChanged()));
diff --git a/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp b/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp
index c08b3b17d5..8fc7c6eaa8 100644
--- a/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp
+++ b/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp
@@ -144,7 +144,7 @@ LibraryWizardDialog::LibraryWizardDialog(const QString &templateName,
// Note that QWizard::currentIdChanged() is emitted at strange times.
// Use the intro page instead, set up initially
- setIntroDescription(tr("This wizard generates a C++ library project."));
+ setIntroDescription(tr("This wizard generates a C++ Library project."));
if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS)))
m_targetPageId = addTargetSetupPage();
diff --git a/src/plugins/qmakeprojectmanager/wizards/qtquickapp.cpp b/src/plugins/qmakeprojectmanager/wizards/qtquickapp.cpp
index 0509239e56..4138525808 100644
--- a/src/plugins/qmakeprojectmanager/wizards/qtquickapp.cpp
+++ b/src/plugins/qmakeprojectmanager/wizards/qtquickapp.cpp
@@ -44,6 +44,11 @@
namespace QmakeProjectManager {
namespace Internal {
+static QString qtQuickApplicationViewerDirectory()
+{
+ return Core::ICore::resourcePath() + QLatin1String("/templates/shared/qtquickapplicationviewer/");
+}
+
static QString templateRootDirectory()
{
return Core::ICore::resourcePath() + QLatin1String("/templates/qtquick/");
@@ -208,11 +213,11 @@ QString QtQuickApp::pathExtended(int fileType) const
case MainQmlDeployed: return qmlSubDir + mainQmlFile;
case MainQmlOrigin: return qmlOriginDir + mainQmlFile;
case AppViewerPri: return pathBase + appViewerTargetSubDir + fileName(AppViewerPri);
- case AppViewerPriOrigin: return originsRoot() + appViewerOriginSubDir() + fileName(AppViewerPri);
+ case AppViewerPriOrigin: return qtQuickApplicationViewerDirectory() + appViewerOriginSubDir() + fileName(AppViewerPri);
case AppViewerCpp: return pathBase + appViewerTargetSubDir + fileName(AppViewerCpp);
- case AppViewerCppOrigin: return originsRoot() + appViewerOriginSubDir() + fileName(AppViewerCpp);
+ case AppViewerCppOrigin: return qtQuickApplicationViewerDirectory() + appViewerOriginSubDir() + fileName(AppViewerCpp);
case AppViewerH: return pathBase + appViewerTargetSubDir + fileName(AppViewerH);
- case AppViewerHOrigin: return originsRoot() + appViewerOriginSubDir() + fileName(AppViewerH);
+ case AppViewerHOrigin: return qtQuickApplicationViewerDirectory() + appViewerOriginSubDir() + fileName(AppViewerH);
case QmlDirProFileRelative: return QString(qmlSubDir).remove(qmlSubDir.length() - 1, 1);
default: qFatal("QtQuickApp::pathExtended() needs more work");
}
@@ -294,6 +299,13 @@ QString QtQuickApp::appViewerOriginSubDir() const
return appViewerBaseName() + QLatin1Char('/');
}
+QByteArray QtQuickApp::generateProFile(QString *errorMessage) const
+{
+ QByteArray proFileContent = AbstractMobileApp::generateProFile(errorMessage);
+ proFileContent.replace("../../shared/qtquickapplicationviewer/", "");
+ return proFileContent;
+}
+
QByteArray QtQuickApp::generateFileExtended(int fileType,
bool *versionAndCheckSum, QString *comment, QString *errorMessage) const
{
diff --git a/src/plugins/qmakeprojectmanager/wizards/qtquickapp.h b/src/plugins/qmakeprojectmanager/wizards/qtquickapp.h
index 00234bbd2c..58d61fd0b8 100644
--- a/src/plugins/qmakeprojectmanager/wizards/qtquickapp.h
+++ b/src/plugins/qmakeprojectmanager/wizards/qtquickapp.h
@@ -95,7 +95,9 @@ public:
static const int StubVersion;
protected:
- virtual QString appViewerBaseName() const;
+ virtual QByteArray generateProFile(QString *errorMessage) const;
+
+ QString appViewerBaseName() const;
QString fileName(ExtendedFileType type) const;
QString appViewerOriginSubDir() const;
diff --git a/src/plugins/qmakeprojectmanager/wizards/qtquickappwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/qtquickappwizard.cpp
index 293805f92e..a38c910ff2 100644
--- a/src/plugins/qmakeprojectmanager/wizards/qtquickappwizard.cpp
+++ b/src/plugins/qmakeprojectmanager/wizards/qtquickappwizard.cpp
@@ -65,7 +65,7 @@ QtQuickAppWizardDialog::QtQuickAppWizardDialog(QWidget *parent,
QtSupport::QtVersionNumber(5, INT_MAX, INT_MAX), parameters)
{
setWindowTitle(tr("New Qt Quick Application"));
- setIntroDescription(tr("This wizard generates a Qt Quick application project."));
+ setIntroDescription(tr("This wizard generates a Qt Quick Application project."));
m_componentSetPage = new Internal::QtQuickComponentSetPage;
addPageWithTitle(m_componentSetPage, tr("Component Set"));
diff --git a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.cpp b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.cpp
index 37cc3b1746..8c3f8d7bc5 100644
--- a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.cpp
+++ b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizarddialog.cpp
@@ -42,7 +42,7 @@ SubdirsProjectWizardDialog::SubdirsProjectWizardDialog(const QString &templateNa
setWindowIcon(icon);
setWindowTitle(templateName);
- setIntroDescription(tr("This wizard generates a Qt subdirs project. "
+ setIntroDescription(tr("This wizard generates a Qt Subdirs project. "
"Add subprojects to it later on by using the other wizards."));
if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS)))
diff --git a/src/plugins/qmakeprojectmanager/wizards/testwizarddialog.cpp b/src/plugins/qmakeprojectmanager/wizards/testwizarddialog.cpp
index 4d1d271023..cff5c17cdc 100644
--- a/src/plugins/qmakeprojectmanager/wizards/testwizarddialog.cpp
+++ b/src/plugins/qmakeprojectmanager/wizards/testwizarddialog.cpp
@@ -56,7 +56,7 @@ TestWizardDialog::TestWizardDialog(const QString &templateName,
m_testPage(new TestWizardPage),
m_testPageId(-1), m_modulesPageId(-1)
{
- setIntroDescription(tr("This wizard generates a Qt unit test "
+ setIntroDescription(tr("This wizard generates a Qt Unit Test "
"consisting of a single source file with a test class."));
setWindowIcon(icon);
setWindowTitle(templateName);
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
index 405f4c6d17..c612ff41c2 100644
--- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
@@ -32,6 +32,7 @@
#include <cmath>
#include <QMessageBox>
+#include <QByteArray>
#include <nodeabstractproperty.h>
#include <nodemetainfo.h>
#include <modelnode.h>
@@ -211,7 +212,7 @@ void raise(const SelectionContext &selectionState)
return;
try {
- RewriterTransaction transaction(selectionState.view());
+ RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|raise"));
foreach (ModelNode modelNode, selectionState.selectedModelNodes()) {
QmlItemNode node = modelNode;
if (node.isValid()) {
@@ -232,7 +233,7 @@ void lower(const SelectionContext &selectionState)
return;
try {
- RewriterTransaction transaction(selectionState.view());
+ RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|lower"));
foreach (ModelNode modelNode, selectionState.selectedModelNodes()) {
QmlItemNode node = modelNode;
if (node.isValid()) {
@@ -302,7 +303,7 @@ void resetSize(const SelectionContext &selectionState)
return;
try {
- RewriterTransaction transaction(selectionState.view());
+ RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetSize"));
foreach (ModelNode node, selectionState.selectedModelNodes()) {
node.removeProperty("width");
node.removeProperty("height");
@@ -318,7 +319,7 @@ void resetPosition(const SelectionContext &selectionState)
return;
try {
- RewriterTransaction transaction(selectionState.view());
+ RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetPosition"));
foreach (ModelNode node, selectionState.selectedModelNodes()) {
node.removeProperty("x");
node.removeProperty("y");
@@ -342,7 +343,7 @@ void resetZ(const SelectionContext &selectionState)
if (!selectionState.view())
return;
- RewriterTransaction transaction(selectionState.view());
+ RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|resetZ"));
foreach (ModelNode node, selectionState.selectedModelNodes()) {
node.removeProperty("z");
}
@@ -373,7 +374,7 @@ void anchorsFill(const SelectionContext &selectionState)
if (!selectionState.view())
return;
- RewriterTransaction transaction(selectionState.view());
+ RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|anchorsFill"));
ModelNode modelNode = selectionState.currentSingleSelectedNode();
@@ -392,7 +393,7 @@ void anchorsReset(const SelectionContext &selectionState)
if (!selectionState.view())
return;
- RewriterTransaction transaction(selectionState.view());
+ RewriterTransaction transaction(selectionState.view(), QByteArrayLiteral("DesignerActionManager|anchorsReset"));
ModelNode modelNode = selectionState.currentSingleSelectedNode();
@@ -458,7 +459,7 @@ static void layoutHelperFunction(const SelectionContext &selectionContext,
ModelNode layoutNode;
{
- RewriterTransaction transaction(selectionContext.view());
+ RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|layoutHelperFunction1"));
QmlItemNode parentNode = qmlItemNode.instanceParentItem();
@@ -470,7 +471,7 @@ static void layoutHelperFunction(const SelectionContext &selectionContext,
}
{
- RewriterTransaction transaction(selectionContext.view());
+ RewriterTransaction transaction(selectionContext.view(), QByteArrayLiteral("DesignerActionManager|layoutHelperFunction2"));
QList<ModelNode> sortedSelectedNodes = selectionContext.selectedModelNodes();
qSort(sortedSelectedNodes.begin(), sortedSelectedNodes.end(), lessThan);
diff --git a/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.cpp b/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.cpp
index 38d8db1e4b..635c896a05 100644
--- a/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.cpp
@@ -211,7 +211,7 @@ static void updateAnchorLinePoints(QPointF *firstPoint, QPointF *secondPoint, co
void AnchorIndicatorGraphicsItem::updateAnchorIndicator(const AnchorLine &sourceAnchorLine, const AnchorLine targetAnchorLine)
{
- if (sourceAnchorLine.isValid() && targetAnchorLine.isValid()) {
+ if (sourceAnchorLine.qmlItemNode().isValid() && targetAnchorLine.qmlItemNode().isValid()) {
m_sourceAnchorLineType = sourceAnchorLine.type();
m_targetAnchorLineType = targetAnchorLine.type();
diff --git a/src/plugins/qmldesigner/components/formeditor/contentnoteditableindicator.cpp b/src/plugins/qmldesigner/components/formeditor/contentnoteditableindicator.cpp
index 098cae7a17..5cba0e3565 100644
--- a/src/plugins/qmldesigner/components/formeditor/contentnoteditableindicator.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/contentnoteditableindicator.cpp
@@ -30,6 +30,8 @@
#include "contentnoteditableindicator.h"
#include "nodemetainfo.h"
+#include <QSet>
+
namespace QmlDesigner {
ContentNotEditableIndicator::ContentNotEditableIndicator(LayerItem *layerItem)
@@ -68,6 +70,24 @@ void ContentNotEditableIndicator::setItems(const QList<FormEditorItem*> &itemLis
addAddiationEntries(itemList);
}
+void ContentNotEditableIndicator::updateItems(const QList<FormEditorItem *> &itemList)
+{
+ QSet<FormEditorItem*> affectedFormEditorItemItems;
+ affectedFormEditorItemItems.unite(itemList.toSet());
+ foreach (FormEditorItem *formEditorItem, itemList)
+ affectedFormEditorItemItems.unite(formEditorItem->offspringFormEditorItems().toSet());
+
+ foreach (const EntryPair &entryPair, m_entryList) {
+ foreach (FormEditorItem *formEditorItem, affectedFormEditorItemItems) {
+ if (formEditorItem == entryPair.first) {
+ QRectF boundingRectangleInSceneSpace = formEditorItem->qmlItemNode().instanceSceneTransform().mapRect(formEditorItem->qmlItemNode().instanceBoundingRect());
+ entryPair.second->setRect(boundingRectangleInSceneSpace);
+ entryPair.second->update();
+ }
+ }
+ }
+}
+
void ContentNotEditableIndicator::addAddiationEntries(const QList<FormEditorItem *> &itemList)
{
foreach (FormEditorItem *formEditorItem, itemList) {
diff --git a/src/plugins/qmldesigner/components/formeditor/contentnoteditableindicator.h b/src/plugins/qmldesigner/components/formeditor/contentnoteditableindicator.h
index a61340f9f1..9cd3ac8e1d 100644
--- a/src/plugins/qmldesigner/components/formeditor/contentnoteditableindicator.h
+++ b/src/plugins/qmldesigner/components/formeditor/contentnoteditableindicator.h
@@ -49,6 +49,7 @@ public:
void clear();
void setItems(const QList<FormEditorItem*> &itemList);
+ void updateItems(const QList<FormEditorItem*> &itemList);
protected:
void addAddiationEntries(const QList<FormEditorItem*> &itemList);
diff --git a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp
index d2c7e321df..393ab9a454 100644
--- a/src/plugins/qmldesigner/components/formeditor/dragtool.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/dragtool.cpp
@@ -324,7 +324,7 @@ void DragTool::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
if (!m_rewriterTransaction.isValid()) {
view()->clearSelectedModelNodes();
- m_rewriterTransaction = view()->beginRewriterTransaction();
+ m_rewriterTransaction = view()->beginRewriterTransaction(QByteArrayLiteral("DragTool::dragEnterEvent"));
}
}
}
diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp
index 14305590a2..805948f053 100644
--- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp
@@ -83,14 +83,28 @@ void FormEditorItem::setup()
QRectF FormEditorItem::boundingRect() const
{
- return m_paintedBoundingRect;
+ return m_boundingRect;
+}
+
+QPainterPath FormEditorItem::shape() const
+{
+ QPainterPath painterPath;
+ painterPath.addRect(m_selectionBoundingRect);
+
+ return painterPath;
+}
+
+bool FormEditorItem::contains(const QPointF &point) const
+{
+ return m_selectionBoundingRect.contains(point);
}
void FormEditorItem::updateGeometry()
{
prepareGeometryChange();
- m_boundingRect = qmlItemNode().instanceBoundingRect().adjusted(0, 0, 1., 1.);
- m_paintedBoundingRect = qmlItemNode().instancePaintedBoundingRect().united(m_boundingRect);
+ m_selectionBoundingRect = qmlItemNode().instanceBoundingRect().adjusted(0, 0, 1., 1.);
+ m_paintedBoundingRect = qmlItemNode().instancePaintedBoundingRect();
+ m_boundingRect = m_paintedBoundingRect.united(m_selectionBoundingRect);
setTransform(qmlItemNode().instanceTransformWithContentTransform());
//the property for zValue is called z in QGraphicsObject
if (qmlItemNode().instanceValue("z").isValid())
@@ -221,6 +235,8 @@ void FormEditorItem::paintBoundingRect(QPainter *painter) const
void FormEditorItem::paintPlaceHolderForInvisbleItem(QPainter *painter) const
{
+ painter->save();
+
qreal stripesWidth = 12;
QRegion innerRegion = QRegion(m_boundingRect.adjusted(stripesWidth, stripesWidth, -stripesWidth, -stripesWidth).toRect());
@@ -229,7 +245,6 @@ void FormEditorItem::paintPlaceHolderForInvisbleItem(QPainter *painter) const
painter->setClipRegion(outerRegion);
painter->setClipping(true);
painter->fillRect(m_boundingRect.adjusted(1, 1, -1, -1), Qt::BDiagPattern);
- painter->setClipping(false);
QString displayText = qmlItemNode().id();
@@ -241,8 +256,6 @@ void FormEditorItem::paintPlaceHolderForInvisbleItem(QPainter *painter) const
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
if (m_boundingRect.height() > 60) {
- painter->save();
-
QFont font;
font.setStyleHint(QFont::SansSerif);
font.setBold(true);
@@ -265,9 +278,9 @@ void FormEditorItem::paintPlaceHolderForInvisbleItem(QPainter *painter) const
painter->setFont(font);
painter->setPen(QColor(48, 48, 96, 255));
painter->drawText(rotatedBoundingBox, displayText, textOption);
-
- painter->restore();
}
+
+ painter->restore();
}
void FormEditorItem::paintComponentContentVisualisation(QPainter *painter, const QRectF &clippinRectangle) const
@@ -276,6 +289,20 @@ void FormEditorItem::paintComponentContentVisualisation(QPainter *painter, const
painter->fillRect(clippinRectangle, Qt::BDiagPattern);
}
+QList<FormEditorItem *> FormEditorItem::offspringFormEditorItemsRecursive(const FormEditorItem *formEditorItem) const
+{
+ QList<FormEditorItem*> formEditorItemList;
+
+ foreach (QGraphicsItem *item, formEditorItem->childItems()) {
+ FormEditorItem *formEditorItem = fromQGraphicsItem(item);
+ if (formEditorItem) {
+ formEditorItemList.append(formEditorItem);
+ }
+ }
+
+ return formEditorItemList;
+}
+
void FormEditorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
if (!painter->isActive())
@@ -291,9 +318,9 @@ void FormEditorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
paintPlaceHolderForInvisbleItem(painter);
} else {
if (m_blurContent)
- painter->drawPixmap(boundingRect().topLeft(), qmlItemNode().instanceBlurredRenderPixmap());
+ painter->drawPixmap(m_paintedBoundingRect.topLeft(), qmlItemNode().instanceBlurredRenderPixmap());
else
- painter->drawPixmap(boundingRect().topLeft(), qmlItemNode().instanceRenderPixmap());
+ painter->drawPixmap(m_paintedBoundingRect.topLeft(), qmlItemNode().instanceRenderPixmap());
}
if (!qmlItemNode().isRootModelNode())
@@ -381,6 +408,11 @@ QList<FormEditorItem*> FormEditorItem::childFormEditorItems() const
return formEditorItemList;
}
+QList<FormEditorItem *> FormEditorItem::offspringFormEditorItems() const
+{
+ return offspringFormEditorItemsRecursive(this);
+}
+
bool FormEditorItem::isContainer() const
{
NodeMetaInfo nodeMetaInfo = qmlItemNode().modelNode().metaInfo();
diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.h b/src/plugins/qmldesigner/components/formeditor/formeditoritem.h
index b6558eff7f..3370d0dce9 100644
--- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.h
+++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.h
@@ -86,10 +86,14 @@ public:
SnapLineMap rightSnappingOffsets() const;
QList<FormEditorItem*> childFormEditorItems() const;
+ QList<FormEditorItem*> offspringFormEditorItems() const;
+
FormEditorScene *scene() const;
FormEditorItem *parentItem() const;
QRectF boundingRect() const;
+ QPainterPath shape() const;
+ bool contains(const QPointF &point) const;
void updateGeometry();
void updateVisibilty();
@@ -112,6 +116,7 @@ protected:
void paintBoundingRect(QPainter *painter) const;
void paintPlaceHolderForInvisbleItem(QPainter *painter) const;
void paintComponentContentVisualisation(QPainter *painter, const QRectF &clippinRectangle) const;
+ QList<FormEditorItem*> offspringFormEditorItemsRecursive(const FormEditorItem *formEditorItem) const;
private: // functions
FormEditorItem(const QmlItemNode &qmlItemNode, FormEditorScene* scene);
@@ -124,6 +129,7 @@ private: // variables
QTransform m_inverseAttentionTransform;
QRectF m_boundingRect;
QRectF m_paintedBoundingRect;
+ QRectF m_selectionBoundingRect;
double m_borderWidth;
bool m_highlightBoundingRect;
bool m_blurContent;
diff --git a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp
index 0802bb166d..3cecfc4763 100644
--- a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp
@@ -159,7 +159,7 @@ void MoveManipulator::begin(const QPointF &beginPoint)
// setOpacityForAllElements(0.62);
- m_rewriterTransaction = m_view->beginRewriterTransaction();
+ m_rewriterTransaction = m_view->beginRewriterTransaction(QByteArrayLiteral("MoveManipulator::begin"));
}
@@ -421,7 +421,7 @@ void MoveManipulator::moveBy(double deltaX, double deltaY)
void MoveManipulator::beginRewriterTransaction()
{
- m_rewriterTransaction = m_view->beginRewriterTransaction();
+ m_rewriterTransaction = m_view->beginRewriterTransaction(QByteArrayLiteral("MoveManipulator::beginRewriterTransaction"));
}
void MoveManipulator::endRewriterTransaction()
diff --git a/src/plugins/qmldesigner/components/formeditor/movetool.cpp b/src/plugins/qmldesigner/components/formeditor/movetool.cpp
index e92fb8458d..6a05c2c1dd 100644
--- a/src/plugins/qmldesigner/components/formeditor/movetool.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/movetool.cpp
@@ -190,7 +190,6 @@ void MoveTool::keyReleaseEvent(QKeyEvent *keyEvent)
}
if (!keyEvent->isAutoRepeat()) {
- m_moveManipulator.beginRewriterTransaction();
m_moveManipulator.clear();
// m_selectionIndicator.show();
m_resizeIndicator.show();
@@ -401,6 +400,7 @@ void MoveTool::formEditorItemsChanged(const QList<FormEditorItem*> &itemList)
m_resizeIndicator.updateItems(selectedItemList);
m_anchorIndicator.updateItems(selectedItemList);
m_bindingIndicator.updateItems(selectedItemList);
+ m_contentNotEditableIndicator.updateItems(selectedItemList);
}
}
diff --git a/src/plugins/qmldesigner/components/formeditor/resizemanipulator.cpp b/src/plugins/qmldesigner/components/formeditor/resizemanipulator.cpp
index ccb2135068..82e54505ef 100644
--- a/src/plugins/qmldesigner/components/formeditor/resizemanipulator.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/resizemanipulator.cpp
@@ -81,7 +81,7 @@ void ResizeManipulator::begin(const QPointF &/*beginPoint*/)
m_beginFromSceneToContentItemTransform = m_beginFromContentItemToSceneTransform.inverted();
m_beginFromItemToSceneTransform = m_resizeController.formEditorItem()->qmlItemNode().instanceSceneTransform();
m_beginToParentTransform = m_resizeController.formEditorItem()->qmlItemNode().instanceTransform();
- m_rewriterTransaction = m_view->beginRewriterTransaction();
+ m_rewriterTransaction = m_view->beginRewriterTransaction(QByteArrayLiteral("ResizeManipulator::begin"));
m_snapper.updateSnappingLines(m_resizeController.formEditorItem());
m_beginBottomRightPoint = m_beginToParentTransform.map(m_resizeController.formEditorItem()->qmlItemNode().instanceBoundingRect().bottomRight());
diff --git a/src/plugins/qmldesigner/components/formeditor/selectionindicator.cpp b/src/plugins/qmldesigner/components/formeditor/selectionindicator.cpp
index f11bca4bff..473816a5e5 100644
--- a/src/plugins/qmldesigner/components/formeditor/selectionindicator.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/selectionindicator.cpp
@@ -46,20 +46,20 @@ SelectionIndicator::~SelectionIndicator()
void SelectionIndicator::show()
{
- foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash.values())
+ foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash)
item->show();
}
void SelectionIndicator::hide()
{
- foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash.values())
+ foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash)
item->hide();
}
void SelectionIndicator::clear()
{
if (m_layerItem) {
- foreach (QGraphicsItem *item, m_indicatorShapeHash.values()) {
+ foreach (QGraphicsItem *item, m_indicatorShapeHash) {
m_layerItem->scene()->removeItem(item);
delete item;
}
@@ -120,7 +120,7 @@ void SelectionIndicator::setCursor(const QCursor &cursor)
{
m_cursor = cursor;
- foreach (QGraphicsItem *item, m_indicatorShapeHash.values())
+ foreach (QGraphicsItem *item, m_indicatorShapeHash)
item->setCursor(cursor);
}
diff --git a/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp b/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp
index fc7defbb88..6eceed6307 100644
--- a/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp
@@ -271,6 +271,7 @@ void SelectionTool::formEditorItemsChanged(const QList<FormEditorItem*> &itemLis
m_resizeIndicator.updateItems(selectedItemList);
m_anchorIndicator.updateItems(selectedItemList);
m_bindingIndicator.updateItems(selectedItemList);
+ m_contentNotEditableIndicator.updateItems(selectedItemList);
}
void SelectionTool::instancesCompleted(const QList<FormEditorItem*> &/*itemList*/)
diff --git a/src/plugins/qmldesigner/components/integration/designdocument.cpp b/src/plugins/qmldesigner/components/integration/designdocument.cpp
index 1c0b6ecd99..d5a428e1a0 100644
--- a/src/plugins/qmldesigner/components/integration/designdocument.cpp
+++ b/src/plugins/qmldesigner/components/integration/designdocument.cpp
@@ -356,7 +356,7 @@ void DesignDocument::deleteSelected()
return;
try {
- RewriterTransaction transaction(rewriterView());
+ RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::deleteSelected"));
QList<ModelNode> toDelete = view()->selectedModelNodes();
foreach (ModelNode node, toDelete) {
if (node.isValid() && !node.isRootNode() && QmlObjectNode::isValidQmlObjectNode(node))
@@ -511,7 +511,7 @@ void DesignDocument::paste()
QList<ModelNode> pastedNodeList;
try {
- RewriterTransaction transaction(rewriterView());
+ RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste1"));
int offset = double(qrand()) / RAND_MAX * 20 - 10;
@@ -529,7 +529,7 @@ void DesignDocument::paste()
}
} else {
try {
- RewriterTransaction transaction(rewriterView());
+ RewriterTransaction transaction(rewriterView(), QByteArrayLiteral("DesignDocument::paste2"));
pasteModel->detachView(&view);
currentModel()->attachView(&view);
diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
index 9c7b567a06..f4f59b508b 100644
--- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
+++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
@@ -510,7 +510,7 @@ void NavigatorTreeModel::moveNodesInteractive(NodeAbstractProperty parentPropert
try {
TypeName propertyQmlType = qmlTypeInQtContainer(parentProperty.parentModelNode().metaInfo().propertyTypeName(parentProperty.name()));
- RewriterTransaction transaction = m_view->beginRewriterTransaction();
+ RewriterTransaction transaction = m_view->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel::moveNodesInteractive"));
foreach (const ModelNode &node, modelNodes) {
if (!node.isValid())
continue;
diff --git a/src/plugins/qmldesigner/components/propertyeditor/filewidget.cpp b/src/plugins/qmldesigner/components/propertyeditor/filewidget.cpp
deleted file mode 100644
index aa2ca684f0..0000000000
--- a/src/plugins/qmldesigner/components/propertyeditor/filewidget.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "filewidget.h"
-#include <QHBoxLayout>
-#include <QFileDialog>
-#include <QDirIterator>
-#include <QDebug>
-#include <model.h>
-
-
-QT_BEGIN_NAMESPACE
-
-static QString s_lastBrowserPath;
-
-FileWidget::FileWidget(QWidget *parent) : QWidget(parent), m_filter("(*.*)"), m_showComboBox(false), m_lock(false)
-{
- m_pushButton = new QToolButton(this);
- m_pushButton->setFixedWidth(32);
- m_lineEdit = new QLineEdit(this);
- m_comboBox = new QComboBox(this);
- m_comboBox->hide();
- QHBoxLayout *layout = new QHBoxLayout(this);
- setLayout(layout);
- layout->setContentsMargins(0, 0, 0, 0);
- layout->addWidget(m_lineEdit);
- layout->addWidget(m_comboBox);
- m_comboBox->setEditable(true);
- layout->addWidget(m_pushButton);
- m_pushButton->setText("...");
- connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(lineEditChanged()));
- connect(m_pushButton, SIGNAL(pressed()), this, SLOT(buttonPressed()));
- connect(m_comboBox, SIGNAL(editTextChanged(QString)), this, SLOT(comboBoxChanged()));
-}
-
-FileWidget::~FileWidget()
-{
-}
-
-void FileWidget::setItemNode(const QVariant &itemNode)
-{
-
- if (!itemNode.value<QmlDesigner::ModelNode>().isValid() || !QmlDesigner::QmlItemNode(itemNode.value<QmlDesigner::ModelNode>()).hasNodeParent())
- return;
- m_itemNode = itemNode.value<QmlDesigner::ModelNode>();
- setupComboBox();
- emit itemNodeChanged();
-}
-
-void FileWidget::setShowComboBox(bool show)
-{
- m_showComboBox = show;
- m_comboBox->setVisible(show);
- m_lineEdit->setVisible(!show);
-}
-
-void FileWidget::lineEditChanged()
-{
- if (m_lock)
- return;
- setFileNameStr(m_lineEdit->text());
-}
-
-void FileWidget::comboBoxChanged()
-{
- if (m_lock)
- return;
- setFileNameStr(m_comboBox->currentText());
-}
-
-void FileWidget::buttonPressed()
-{
- QString modelPath;
- if (m_itemNode.isValid())
- modelPath = QFileInfo(m_itemNode.modelNode().model()->fileUrl().toLocalFile()).absoluteDir().absolutePath();
-
- m_lastModelPath = modelPath;
-
- bool documentChanged = m_lastModelPath == modelPath;
-
- //First we try the last path this browser widget was opened with
- //if the document was not changed
- QString path = documentChanged ? QString() : m_currentPath;
-
-
- //If that one is not valid we try the path for the current file
- if (path.isEmpty() && !m_fileName.isEmpty())
- path = QFileInfo(modelPath + QLatin1String("/") + m_fileName.toString()).absoluteDir().absolutePath();
-
-
- //Next we try to fall back to the path any file browser was opened with
- if (!QFileInfo(path).exists()) {
- path = s_lastBrowserPath;
-
- //The last fallback is to try the path of the document
- if (!QFileInfo(path).exists()) {
- if (m_itemNode.isValid())
- path = modelPath;
- }
- }
-
- QString newFile = QFileDialog::getOpenFileName(0, tr("Open File"), path, m_filter);
-
- if (!newFile.isEmpty()) {
- setFileNameStr(newFile);
-
- m_currentPath = QFileInfo(newFile).absolutePath();
- s_lastBrowserPath = m_currentPath;
- }
-}
-
-void FileWidget::setFileNameStr(const QString &fileName)
-{
- setFileName(QUrl(fileName));
-}
-void FileWidget::setFileName(const QUrl &fileName)
-{
- if (fileName == m_fileName)
- return;
-
- m_fileName = fileName;
- if (m_lineEdit->text() != fileName.toString()) {
- m_lineEdit->setText(fileName.toString());
- m_lineEdit->setToolTip(m_fileName.toString());
- }
- if (m_comboBox->currentText() != fileName.toString()) {
- m_comboBox->setEditText(m_fileName.toString());
- m_comboBox->setToolTip(m_fileName.toString());
- }
- emit fileNameChanged(fileName);
-}
-
-void FileWidget::setupComboBox()
-{
- m_lock = true;
- m_comboBox->clear();
-
- QDir dir;
-
- if (m_itemNode.isValid())
- dir = QFileInfo(m_itemNode.modelNode().model()->fileUrl().toLocalFile()).dir();
- else if (m_path.isValid())
- dir = QDir(m_path.toLocalFile());
-
- QStringList filterList = m_filter.split(' ');
-
- QDirIterator it(dir.absolutePath(), filterList, QDir::Files, QDirIterator::Subdirectories);
- while (it.hasNext()) {
- QString absolutePath = it.next();
- m_comboBox->addItem(dir.relativeFilePath(absolutePath));
- }
- m_comboBox->setEditText(m_fileName.toString());
-
- m_lock = false;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/qmldesigner/components/propertyeditor/filewidget.h b/src/plugins/qmldesigner/components/propertyeditor/filewidget.h
deleted file mode 100644
index 57fbeee0f6..0000000000
--- a/src/plugins/qmldesigner/components/propertyeditor/filewidget.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-
-#ifndef FILEWIDGET_H
-#define FILEWIDGET_H
-
-#include <QWidget>
-#include <QToolButton>
-#include <QLineEdit>
-#include <QComboBox>
-#include <QUrl>
-#include <qmlitemnode.h>
-
-QT_BEGIN_NAMESPACE
-
-class FileWidget : public QWidget
-{
- Q_OBJECT
-
- Q_PROPERTY(QString text READ text WRITE setText)
- Q_PROPERTY(QString fileName READ fileName WRITE setFileNameStr NOTIFY fileNameChanged)
- Q_PROPERTY(QString filter READ filter WRITE setFilter)
- Q_PROPERTY(bool showComboBox READ showComboBox WRITE setShowComboBox)
- Q_PROPERTY(QVariant itemNode READ itemNode WRITE setItemNode NOTIFY itemNodeChanged)
- Q_PROPERTY(QUrl path READ path WRITE setPath)
-
-public:
-
- FileWidget(QWidget *parent = 0);
- ~FileWidget();
-
- QVariant itemNode() const { return QVariant::fromValue(m_itemNode.modelNode()); }
- void setItemNode(const QVariant &itemNode);
-
- QString fileName() const
- { return m_fileName.toString(); }
-
- void setText(const QString &/*text*/)
- {
-
- }
-
- void setPath(const QUrl &url) { m_path = url; setupComboBox(); }
-
- QUrl path() const { return m_path; }
-
- QString text() const
- {
- return QString();
- }
-
- void setFilter(const QString &filter)
- {
- m_filter = filter;
- }
-
- QString filter() const
- {
- return m_filter;
- }
-
- void setShowComboBox(bool show);
-
- bool showComboBox() const
- { return m_showComboBox; }
-
-public slots:
- void setFileName(const QUrl &fileName);
- void setFileNameStr(const QString &fileName);
- void buttonPressed();
- void lineEditChanged();
- void comboBoxChanged();
-
-signals:
- void fileNameChanged(const QUrl &fileName);
- void itemNodeChanged();
-
-protected:
-
-private:
-
- void setupComboBox();
-
- QToolButton *m_pushButton;
- QLineEdit *m_lineEdit;
- QComboBox *m_comboBox;
- QUrl m_fileName;
- QUrl m_path;
- QmlDesigner::QmlItemNode m_itemNode;
- QString m_filter;
- bool m_showComboBox;
- bool m_lock;
- QString m_currentPath;
- QString m_lastModelPath;
-
-};
-
-QT_END_NAMESPACE
-
-#endif
-
diff --git a/src/plugins/qmldesigner/components/propertyeditor/fontwidget.cpp b/src/plugins/qmldesigner/components/propertyeditor/fontwidget.cpp
deleted file mode 100644
index 845527c049..0000000000
--- a/src/plugins/qmldesigner/components/propertyeditor/fontwidget.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "fontwidget.h"
-#include <QPushButton>
-#include <QLabel>
-#include <QHBoxLayout>
-#include <QFontDialog>
-#include <QComboBox>
-
-namespace QmlDesigner {
-
-FontWidget::FontWidget(QWidget *parent)
- : QWidget(parent),
- m_label(new QLabel(this)),
- m_fontButton(new QPushButton("ABC..", this))
-{
- QHBoxLayout *horizonalBoxLayout = new QHBoxLayout(this);
-
- horizonalBoxLayout->addWidget(m_label);
- horizonalBoxLayout->addWidget(m_fontButton);
- m_fontButton->setMinimumHeight(20);
- m_fontButton->setCheckable(true);
- connect(m_fontButton, SIGNAL(toggled(bool)), SLOT(openFontEditor(bool)));
-}
-
-FontWidget::~FontWidget()
-{
-}
-
-void FontWidget::openFontEditor(bool show)
-{
- if (show && m_fontDialog.isNull()) {
- m_fontDialog = new QFontDialog();
- m_fontDialog->setAttribute(Qt::WA_DeleteOnClose);
- m_fontDialog->setCurrentFont(m_font);
- QComboBox *comboBox = m_fontDialog->findChild<QComboBox*>();
- QList<QLabel*> labels = m_fontDialog->findChildren<QLabel*>();
- foreach (QLabel *label, labels)
- if (label->buddy() == comboBox)
- label->hide();
- comboBox->hide();
- m_fontDialog->show();
- connect(m_fontDialog.data(), SIGNAL(accepted()), SLOT(updateFont()));
- connect(m_fontDialog.data(), SIGNAL(destroyed(QObject*)), SLOT(resetFontButton()));
- } else {
- delete m_fontDialog.data();
- }
-}
-
-void FontWidget::updateFont()
-{
- QFont font(m_fontDialog->currentFont());
- setFamily(font.family());
- setItalic(font.italic());
- setBold(font.bold());
- setFontSize(font.pointSizeF());
- emit dataFontChanged();
-}
-
-void FontWidget::resetFontButton()
-{
- m_fontButton->setChecked(false);
-}
-
-QString FontWidget::text() const
-{
- return m_label->text();
-}
-
-void FontWidget::setText(const QString &text)
-{
- m_label->setText(text);
-}
-
-QString FontWidget::family() const
-{
- return m_font.family();
-}
-
-void FontWidget::setFamily(const QString &fontFamily)
-{
- if (fontFamily != m_font.family()) {
- m_font.setFamily(fontFamily);
- emit familyChanged();
- }
-}
-
-bool FontWidget::isBold() const
-{
- return m_font.bold();
-}
-
-void FontWidget::setBold(bool isBold)
-{
- if (m_font.bold() != isBold) {
- m_font.setBold(isBold);
- emit boldChanged();
- }
-}
-
-bool FontWidget::isItalic() const
-{
- return m_font.italic();
-}
-
-void FontWidget::setItalic(bool isItalic)
-{
- if (m_font.italic() != isItalic) {
- m_font.setItalic(isItalic);
- emit italicChanged();
- }
-}
-
-
-QFont FontWidget::font() const
-{
- return m_font;
-}
-
-void FontWidget::setFont(QFont font)
-{
- if (m_font != font) {
- m_font = font;
- emit dataFontChanged();
- }
-}
-
-qreal FontWidget::fontSize() const
-{
- return m_font.pointSizeF();
-}
-
-void FontWidget::setFontSize(qreal size)
-{
- if (m_font.pointSizeF() != size) {
- m_font.setPointSizeF(size);
- emit fontSizeChanged();
- }
-}
-
-void FontWidget::registerDeclarativeTypes() {
- qmlRegisterType<QmlDesigner::FontWidget>("Bauhaus",1,0,"FontWidget");
-}
-
-} // namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/components/propertyeditor/fontwidget.h b/src/plugins/qmldesigner/components/propertyeditor/fontwidget.h
deleted file mode 100644
index 186e440685..0000000000
--- a/src/plugins/qmldesigner/components/propertyeditor/fontwidget.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef FONTWIDGET_H
-#define FONTWIDGET_H
-
-#include <QWeakPointer>
-#include <QWidget>
-#include <QtQml>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QPushButton;
-class QFontDialog;
-QT_END_NAMESPACE
-
-namespace QmlDesigner {
-
-class FontWidget : public QWidget
-{
- Q_OBJECT
- Q_PROPERTY(QString text READ text WRITE setText)
- Q_PROPERTY(QString family READ family WRITE setFamily NOTIFY familyChanged)
- Q_PROPERTY(bool bold READ isBold WRITE setBold NOTIFY boldChanged)
- Q_PROPERTY(bool italic READ isItalic WRITE setItalic NOTIFY italicChanged)
- Q_PROPERTY(qreal fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
- Q_PROPERTY(QFont dataFont READ font WRITE setFont NOTIFY dataFontChanged)
-
-public:
- FontWidget(QWidget *parent = 0);
- ~FontWidget();
-
- QString text() const;
- void setText(const QString &text);
-
- QString family() const;
- void setFamily(const QString &fontFamily);
-
- bool isBold() const;
- void setBold(bool isBold);
-
- bool isItalic() const;
- void setItalic(bool isItalic);
-
- qreal fontSize() const;
- void setFontSize(qreal size);
-
- QFont font() const;
- void setFont(QFont size);
-
- static void registerDeclarativeTypes();
-
-signals:
- void familyChanged();
- void boldChanged();
- void italicChanged();
- void fontSizeChanged();
- void dataFontChanged();
-
-private slots:
- void openFontEditor(bool show);
- void updateFont();
- void resetFontButton();
-
-private: //variables
- QFont m_font;
- QLabel *m_label;
- QPushButton *m_fontButton;
- QWeakPointer<QFontDialog> m_fontDialog;
-};
-
-} // namespace QmlDesigner
-
-QML_DECLARE_TYPE(QmlDesigner::FontWidget)
-
-#endif // FONTWIDGET_H
diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.cpp b/src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.cpp
deleted file mode 100644
index feafc14c86..0000000000
--- a/src/plugins/qmldesigner/components/propertyeditor/gradientlineqmladaptor.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "gradientlineqmladaptor.h"
-
-#include <QMessageBox>
-#include <QtQml>
-
-#include <nodeproperty.h>
-#include <nodelistproperty.h>
-#include <nodemetainfo.h>
-#include <abstractview.h>
-#include <rewritingexception.h>
-#include <variantproperty.h>
-
-namespace QmlDesigner {
-
-GradientLineQmlAdaptor::GradientLineQmlAdaptor(QWidget *parent) :
- QmlEditorWidgets::GradientLine(parent)
-{
- setActive(false);
- connect(this, SIGNAL(gradientChanged()), this, SLOT(writeGradient()));
-}
-
-void GradientLineQmlAdaptor::setItemNode(const QVariant &itemNode)
-{
-
- if (!itemNode.value<ModelNode>().isValid())
- return;
- m_itemNode = itemNode.value<ModelNode>();
- emit itemNodeChanged();
-}
-
-static inline QColor normalizeColor(const QColor &color)
-{
- QColor newColor = QColor(color.name());
- newColor.setAlpha(color.alpha());
- return newColor;
-}
-
-static inline qreal roundReal(qreal real)
-{
- int i = real * 100;
- return qreal(i) / 100;
-}
-
-void GradientLineQmlAdaptor::setupGradient()
-{
- if (!active())
- return;
-
- ModelNode modelNode = m_itemNode.modelNode();
- QLinearGradient newGradient;
- QVector<QGradientStop> stops;
-
- if (!modelNode.isValid())
- return;
-
- if (modelNode.hasBindingProperty(gradientName().toUtf8()))
- return;
-
- if (modelNode.hasProperty(gradientName().toUtf8())) { //gradient exists
-
- ModelNode gradientNode = modelNode.nodeProperty(gradientName().toUtf8()).modelNode();
- QList<ModelNode> stopList = gradientNode.nodeListProperty("stops").toModelNodeList();
-
- foreach (const ModelNode &stopNode, stopList) {
- QmlObjectNode stopObjectNode = stopNode;
- if (stopObjectNode.isValid()) {
- qreal position = stopObjectNode.modelValue("position").toReal();
- QColor color = stopObjectNode.modelValue("color").value<QColor>();
- stops.append( QPair<qreal, QColor>(position, color));
- }
- }
- } else {
- stops.append( QPair<qreal, QColor>(0, activeColor()));
- stops.append( QPair<qreal, QColor>(1, QColor(Qt::black)));
- }
-
- newGradient.setStops(stops);
- setGradient(newGradient);
-}
-
-void GradientLineQmlAdaptor::writeGradient()
-{
- if (!active())
- return;
-
- if (!m_itemNode.isValid())
- return;
-
- if (!m_itemNode.modelNode().metaInfo().hasProperty(gradientName().toUtf8()))
- return;
- try {
- ModelNode modelNode = m_itemNode.modelNode();
-
- QString oldId;
- QVector<QGradientStop> stops = gradient().stops();
- if (m_itemNode.isInBaseState()) {
- if (modelNode.hasProperty(gradientName().toUtf8())) {
- oldId = modelNode.nodeProperty(gradientName().toUtf8()).modelNode().id();
- modelNode.removeProperty(gradientName().toUtf8());
- }
-
- ModelNode gradientNode= modelNode.view()->createModelNode("QtQuick.Gradient", modelNode.view()->majorQtQuickVersion(), 0);
- modelNode.nodeProperty(gradientName().toUtf8()).reparentHere(gradientNode);
-
- RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
-
- if (!oldId.isNull())
- gradientNode.setId(oldId);
-
- for (int i = 0;i < stops.size(); i++) {
- ModelNode gradientStopNode = modelNode.view()->createModelNode("QtQuick.GradientStop", modelNode.view()->majorQtQuickVersion(), 0);
- gradientStopNode.variantProperty("position").setValue(roundReal(stops.at(i).first));
- gradientStopNode.variantProperty("color").setValue(normalizeColor(stops.at(i).second));
- gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode);
- }
- } else { //state
- if (!modelNode.hasProperty(gradientName().toUtf8())) {
- qWarning(" GradientLine::updateGradient: no gradient in state");
- return;
- }
- ModelNode gradientNode = modelNode.nodeProperty(gradientName().toUtf8()).modelNode();
- QList<ModelNode> stopList = gradientNode.nodeListProperty("stops").toModelNodeList();
- for (int i = 0;i < stops.size(); i++) {
- QmlObjectNode stopObjectNode = stopList.at(i);
- stopObjectNode.setVariantProperty("position", roundReal(stops.at(i).first));
- stopObjectNode.setVariantProperty("color", normalizeColor(stops.at(i).second));
- }
- }
- }
- catch (RewritingException &e) {
- QMessageBox::warning(0, "Error", e.description());
- }
-}
-
-void GradientLineQmlAdaptor::deleteGradient()
-{
- if (!m_itemNode.isValid())
- return;
-
- if (!m_itemNode.modelNode().metaInfo().hasProperty(gradientName().toUtf8()))
- return;
-
- ModelNode modelNode = m_itemNode.modelNode();
-
- if (m_itemNode.isInBaseState()) {
- if (modelNode.hasProperty(gradientName().toUtf8())) {
- RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
- ModelNode gradientNode = modelNode.nodeProperty(gradientName().toUtf8()).modelNode();
- if (QmlObjectNode(gradientNode).isValid())
- QmlObjectNode(gradientNode).destroy();
- }
- }
-}
-
-void GradientLineQmlAdaptor::registerDeclarativeType() {
- qmlRegisterType<QmlDesigner::GradientLineQmlAdaptor>("Bauhaus",1,0,"GradientLine");
-}
-
-} //QmlDesigner
diff --git a/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp
index d21c2fabec..855c475cfd 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/gradientmodel.cpp
@@ -143,7 +143,7 @@ void GradientModel::addGradient()
if (!color.isValid())
color = QColor(Qt::white);
- QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
+ QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::addGradient"));
QmlDesigner::ModelNode gradientNode =
m_itemNode.modelNode().view()->createModelNode("QtQuick.Gradient",
@@ -227,7 +227,7 @@ qreal GradientModel::getPosition(int index) const
void GradientModel::removeStop(int index)
{
if (index < rowCount() - 1 && index != 0) {
- QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
+ QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::removeStop"));
QmlDesigner::ModelNode gradientNode = m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();
QmlDesigner::QmlObjectNode stop = gradientNode.nodeListProperty("stops").toModelNodeList().at(index);
if (stop.isValid()) {
@@ -251,7 +251,7 @@ void GradientModel::deleteGradient()
if (m_itemNode.isInBaseState()) {
if (modelNode.hasProperty(gradientPropertyName().toUtf8())) {
- QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
+ QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("GradientModel::deleteGradient"));
QmlDesigner::ModelNode gradientNode = modelNode.nodeProperty(gradientPropertyName().toUtf8()).modelNode();
if (QmlDesigner::QmlObjectNode(gradientNode).isValid())
QmlDesigner::QmlObjectNode(gradientNode).destroy();
diff --git a/src/plugins/qmldesigner/components/propertyeditor/originwidget.cpp b/src/plugins/qmldesigner/components/propertyeditor/originwidget.cpp
deleted file mode 100644
index ca6588a23e..0000000000
--- a/src/plugins/qmldesigner/components/propertyeditor/originwidget.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "originwidget.h"
-#include <QList>
-#include <QPainter>
-#include <QMouseEvent>
-#include <QtQml>
-
-static QList<QPoint> positions;
-static QStringList originsStringList;
-
-namespace QmlDesigner {
-
-OriginWidget::OriginWidget(QWidget *parent) : QWidget(parent), m_pressed(false), m_marked(false)
-{
- if (positions.isEmpty())
- positions << QPoint(0, 0) << QPoint(18, 0) << QPoint(36, 0)
- << QPoint(0, 18) << QPoint(18, 18) << QPoint(36, 18)
- << QPoint(0, 36) << QPoint(18, 36) << QPoint(36, 36);
-
- if (originsStringList.isEmpty())
- originsStringList << "TopLeft" << "Top"
- << "TopRight" << "Left" << "Center" << "Right"
- << "BottomLeft" << "Bottom" << "BottomRight";
-
- m_originString = "Center";
- resize(50, 50);
- setMinimumHeight(50);
- m_index = 0;
- setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
-}
-
-void OriginWidget::setOrigin(const QString& newOrigin)
-{
- if (!originsStringList.contains(newOrigin))
- return;
- if (newOrigin == m_originString)
- return;
-
- m_originString = newOrigin;
- update();
- emit originChanged();
-}
-
-void OriginWidget::registerDeclarativeType()
-{
- qmlRegisterType<QmlDesigner::OriginWidget>("Bauhaus",1,0,"OriginWidget");
-
-}
-
-void OriginWidget::paintEvent(QPaintEvent *event)
-{
- QWidget::paintEvent(event);
-
- QPainter p(this);
-
- foreach (const QPoint& position, positions)
- p.fillRect(position.x(), position.y(), 14, 14, Qt::black);
-
- int origin = originsStringList.indexOf(m_originString);
-
- if (m_pressed)
- p.fillRect(positions.at(m_index).x() + 4, positions.at(m_index).y() + 4, 6, 6, "#868686");
-
- if (m_marked)
- p.fillRect(positions.at(origin).x(), positions.at(origin).y(), 14, 14, "#9999ff");
- else
- p.fillRect(positions.at(origin).x(), positions.at(origin).y(), 14, 14, "#e6e6e6");
- p.fillRect(positions.at(origin).x() + 2, positions.at(origin).y() + 2, 10, 10, "#666666");
-}
-
-void OriginWidget::mouseReleaseEvent(QMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton) {
- m_pressed = false;
- for (int i = 0; i < positions.size(); i++)
- if (QRect(positions.at(i), QSize(14, 14)).contains(event->pos()))
- setOrigin(originsStringList.at(i));
- }
- QWidget::mouseReleaseEvent(event);
-}
-
-void OriginWidget::mousePressEvent(QMouseEvent * event)
-{
- if (event->button() == Qt::LeftButton) {
- m_pressed = true;
- for (int i = 0; i < positions.size(); i++)
- if (QRect(positions.at(i), QSize(14, 14)).contains(event->pos())) {
- m_index = i;
- update();
- }
- }
- QWidget::mousePressEvent(event);
-}
-
-static inline QString getToolTip(const QPoint &pos)
-{
- for (int i = 0; i < positions.size(); i++)
- if (QRect(positions.at(i), QSize(14, 14)).contains(pos))
- return originsStringList.at(i);
-
- return QString();
-}
-
-bool OriginWidget::event(QEvent *event)
-{
- if (event->type() == QEvent::ToolTip)
- setToolTip(getToolTip(static_cast<QHelpEvent*>(event)->pos()));
-
- return QWidget::event(event);
-}
-
-} //QmlDesigner
-
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri
index 912e5e847a..218293f451 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.pri
@@ -2,15 +2,10 @@ VPATH += $$PWD
SOURCES += propertyeditorview.cpp \
qmlanchorbindingproxy.cpp \
- filewidget.cpp \
propertyeditorvalue.cpp \
- fontwidget.cpp \
- originwidget.cpp \
- siblingcombobox.cpp \
propertyeditortransaction.cpp \
propertyeditorcontextobject.cpp \
quick2propertyeditorview.cpp \
- gradientlineqmladaptor.cpp \
propertyeditorqmlbackend.cpp \
propertyeditorwidget.cpp \
fileresourcesmodel.cpp \
@@ -18,16 +13,11 @@ SOURCES += propertyeditorview.cpp \
HEADERS += propertyeditorview.h \
qmlanchorbindingproxy.h \
- filewidget.h \
propertyeditorvalue.h \
- fontwidget.h \
- originwidget.h \
- siblingcombobox.h \
propertyeditortransaction.h \
designerpropertymap.h \
propertyeditorcontextobject.h \
quick2propertyeditorview.h \
- gradientlineqmladaptor.h \
propertyeditorqmlbackend.h \
propertyeditorwidget.h \
fileresourcesmodel.h \
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditortransaction.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditortransaction.cpp
index d8a0c3d66a..e0014d2562 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditortransaction.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditortransaction.cpp
@@ -44,7 +44,7 @@ void PropertyEditorTransaction::start()
return;
if (m_rewriterTransaction.isValid())
m_rewriterTransaction.commit();
- m_rewriterTransaction = m_propertyEditor->beginRewriterTransaction();
+ m_rewriterTransaction = m_propertyEditor->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorTransaction::start"));
m_timerId = startTimer(4000);
}
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp
index 2ac59cb424..2177cf6522 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp
@@ -151,7 +151,11 @@ void PropertyEditorValue::setValue(const QVariant &value)
if (m_value.isValid())
emit valueChangedQml();
emit isBoundChanged();
+}
+QString PropertyEditorValue::enumeration() const
+{
+ return m_value.value<QmlDesigner::Enumeration>().nameToString();
}
QString PropertyEditorValue::expression() const
@@ -267,6 +271,13 @@ void PropertyEditorValue::resetValue()
}
}
+void PropertyEditorValue::setEnumeration(const QString &scope, const QString &name)
+{
+ QmlDesigner::Enumeration newEnumeration(scope, name);
+
+ setValueWithEmit(QVariant::fromValue(newEnumeration));
+}
+
void PropertyEditorValue::registerDeclarativeTypes()
{
qmlRegisterType<PropertyEditorValue>("HelperWidgets",2,0,"PropertyEditorValue");
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h
index 9ae815f44e..ff432abf01 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h
@@ -36,6 +36,7 @@
#include <QQmlPropertyMap>
#include <QtQml>
#include <modelnode.h>
+#include <enumeration.h>
class PropertyEditorValue;
@@ -78,6 +79,7 @@ class PropertyEditorValue : public QObject
{
Q_OBJECT
Q_PROPERTY(QVariant value READ value WRITE setValueWithEmit NOTIFY valueChangedQml)
+ Q_PROPERTY(QVariant enumeration READ enumeration NOTIFY valueChangedQml)
Q_PROPERTY(QString expression READ expression WRITE setExpressionWithEmit NOTIFY expressionChanged FINAL)
Q_PROPERTY(QString valueToString READ valueToString NOTIFY valueChangedQml FINAL)
Q_PROPERTY(bool isInModel READ isInModel NOTIFY valueChangedQml FINAL)
@@ -96,6 +98,8 @@ public:
void setValueWithEmit(const QVariant &value);
void setValue(const QVariant &value);
+ QString enumeration() const;
+
QString expression() const;
void setExpressionWithEmit(const QString &expression);
void setExpression(const QString &expression);
@@ -125,6 +129,7 @@ public:
public slots:
void resetValue();
+ void setEnumeration(const QString &scope, const QString &name);
signals:
void valueChanged(const QString &name, const QVariant&);
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp
index 27a1e84c61..126be7ad71 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp
@@ -243,7 +243,7 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
if (!m_selectedNode.isValid())
return;
- RewriterTransaction transaction = beginRewriterTransaction();
+ RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::changeExpression"));
try {
PropertyName underscoreName(name);
@@ -317,11 +317,13 @@ void PropertyEditorView::updateSize()
void PropertyEditorView::setupPanes()
{
- QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
- setupPane("QtQuick.Item");
- resetView();
- m_setupCompleted = true;
- QApplication::restoreOverrideCursor();
+ if (isAttached()) {
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ setupPane("QtQuick.Item");
+ resetView();
+ m_setupCompleted = true;
+ QApplication::restoreOverrideCursor();
+ }
}
void PropertyEditorView::setQmlDir(const QString &qmlDir)
diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
index 05e54f9063..e140692b57 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
@@ -268,7 +268,7 @@ void QmlAnchorBindingProxy::setTopTarget(const QString &target)
if (!newTarget.isValid())
return;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setTopTarget"));
m_topTarget = newTarget;
calcTopMargin();
@@ -293,7 +293,7 @@ void QmlAnchorBindingProxy::setBottomTarget(const QString &target)
if (!newTarget.isValid())
return;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setBottomTarget"));
m_bottomTarget = newTarget;
calcBottomMargin();
@@ -314,7 +314,7 @@ void QmlAnchorBindingProxy::setLeftTarget(const QString &target)
if (!newTarget.isValid())
return;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setLeftTarget"));
m_leftTarget = newTarget;
calcLeftMargin();
@@ -335,7 +335,7 @@ void QmlAnchorBindingProxy::setRightTarget(const QString &target)
if (!newTarget.isValid())
return;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setRightTarget"));
m_rightTarget = newTarget;
calcRightMargin();
@@ -356,7 +356,7 @@ void QmlAnchorBindingProxy::setVerticalTarget(const QString &target)
if (!newTarget.isValid())
return;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalTarget"));
m_verticalTarget = newTarget;
m_qmlItemNode.anchors().setAnchor(AnchorLine::VerticalCenter, m_verticalTarget, AnchorLine::VerticalCenter);
@@ -377,7 +377,7 @@ void QmlAnchorBindingProxy::setHorizontalTarget(const QString &target)
if (!newTarget.isValid())
return;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalTarget"));
m_horizontalTarget = newTarget;
m_qmlItemNode.anchors().setAnchor(AnchorLine::HorizontalCenter, m_horizontalTarget, AnchorLine::HorizontalCenter);
@@ -421,7 +421,7 @@ int QmlAnchorBindingProxy::indexOfPossibleTargetItem(const QString &targetName)
}
void QmlAnchorBindingProxy::resetLayout() {
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::resetLayout"));
m_qmlItemNode.anchors().removeAnchors();
m_qmlItemNode.anchors().removeMargins();
@@ -446,7 +446,7 @@ void QmlAnchorBindingProxy::setBottomAnchor(bool anchor)
if (bottomAnchored() == anchor)
return;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setBottomAnchor"));
if (!anchor) {
removeBottomAnchor();
@@ -469,7 +469,7 @@ void QmlAnchorBindingProxy::setLeftAnchor(bool anchor)
if (leftAnchored() == anchor)
return;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setLeftAnchor"));
if (!anchor) {
removeLeftAnchor();
@@ -493,7 +493,7 @@ void QmlAnchorBindingProxy::setRightAnchor(bool anchor)
if (rightAnchored() == anchor)
return;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setRightAnchor"));
if (!anchor) {
removeRightAnchor();
@@ -634,7 +634,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
if (topAnchored() == anchor)
return;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setTopAnchor"));
if (!anchor) {
removeTopAnchor();
@@ -650,7 +650,7 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
}
void QmlAnchorBindingProxy::removeTopAnchor() {
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeTopAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLine::Top);
m_qmlItemNode.anchors().removeMargin(AnchorLine::Top);
@@ -661,7 +661,7 @@ void QmlAnchorBindingProxy::removeTopAnchor() {
}
void QmlAnchorBindingProxy::removeBottomAnchor() {
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeBottomAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLine::Bottom);
m_qmlItemNode.anchors().removeMargin(AnchorLine::Bottom);
@@ -671,7 +671,7 @@ void QmlAnchorBindingProxy::removeBottomAnchor() {
}
void QmlAnchorBindingProxy::removeLeftAnchor() {
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeLeftAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLine::Left);
m_qmlItemNode.anchors().removeMargin(AnchorLine::Left);
@@ -681,7 +681,7 @@ void QmlAnchorBindingProxy::removeLeftAnchor() {
}
void QmlAnchorBindingProxy::removeRightAnchor() {
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeRightAnchor"));
m_qmlItemNode.anchors().removeAnchor(AnchorLine::Right);
m_qmlItemNode.anchors().removeMargin(AnchorLine::Right);
@@ -699,7 +699,7 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
m_locked = true;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalCentered"));
if (!centered) {
m_qmlItemNode.anchors().removeAnchor(AnchorLine::VerticalCenter);
@@ -723,7 +723,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
m_locked = true;
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalCentered"));
if (!centered) {
m_qmlItemNode.anchors().removeAnchor(AnchorLine::HorizontalCenter);
@@ -780,7 +780,7 @@ bool QmlAnchorBindingProxy::horizontalCentered()
void QmlAnchorBindingProxy::fill()
{
- RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::fill"));
backupPropertyAndRemove(modelNode(), "x");
diff --git a/src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.cpp b/src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.cpp
deleted file mode 100644
index 89fc6d9181..0000000000
--- a/src/plugins/qmldesigner/components/propertyeditor/siblingcombobox.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "siblingcombobox.h"
-
-#include <QtQml>
-
-namespace QmlDesigner {
-
-void SiblingComboBox::setItemNode(const QVariant &itemNode)
-{
-
- if (!itemNode.value<ModelNode>().isValid() || !QmlItemNode(itemNode.value<ModelNode>()).hasNodeParent())
- return;
- m_itemNode = itemNode.value<ModelNode>();
- setup();
- emit itemNodeChanged();
-}
-
-void SiblingComboBox::registerDeclarativeTypes()
-{
- qmlRegisterType<SiblingComboBox>("Bauhaus",1,0,"SiblingComboBox");
-}
-
-void SiblingComboBox::setSelectedItemNode(const QVariant &itemNode)
-{
- if (itemNode.value<ModelNode>() == m_selectedItemNode)
- return;
- if (!itemNode.value<ModelNode>().isValid())
- return;
- m_selectedItemNode = itemNode.value<ModelNode>();
- setup();
- emit selectedItemNodeChanged();
-}
-
-void SiblingComboBox::changeSelection(int i)
-{
- if (i < 0 || m_itemList.at(i) == m_selectedItemNode)
- return;
- setSelectedItemNode(QVariant::fromValue(m_itemList.at(i).modelNode()));
-}
-
-void SiblingComboBox::setup()
-{
- connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(changeSelection(int)));
- if (!m_itemNode.isValid())
- return;
-
- if (m_itemNode.instanceParent().modelNode().isValid())
- m_itemList = toQmlItemNodeList(m_itemNode.instanceParent().modelNode().allDirectSubModelNodes());
- m_itemList.removeOne(m_itemNode);
- //We currently have no instanceChildren().
- //So we double check here if the instanceParents are equal.
- foreach (const QmlItemNode &node, m_itemList)
- if (node.isValid() && (node.instanceParent().modelNode() != m_itemNode.instanceParent().modelNode()))
- m_itemList.removeAll(node);
-
- disconnect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(changeSelection(int)));
- clear();
-
- foreach (const QmlItemNode &itemNode, m_itemList) {
- if (itemNode.isValid()) {
- if (itemNode.id().isEmpty())
- addItem(itemNode.simplifiedTypeName());
- else
- addItem(itemNode.id());
- }
- }
-
- QmlItemNode parent(m_itemNode.instanceParent().toQmlItemNode());
-
- if (parent.isValid()) {
- m_itemList.prepend(parent);
- QString parentString("Parent (");
-
- if (parent.id().isEmpty())
- parentString += parent.simplifiedTypeName();
- else
- parentString += parent.id();
- parentString += ')';
- insertItem(0, parentString);
- }
- setCurrentIndex(m_itemList.indexOf(m_selectedItemNode));
- connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(changeSelection(int)));
-}
-
-
-} //QmlDesigner
diff --git a/src/plugins/qmldesigner/designercore/designercore-lib.pri b/src/plugins/qmldesigner/designercore/designercore-lib.pri
index 686867037e..32f2200bca 100644
--- a/src/plugins/qmldesigner/designercore/designercore-lib.pri
+++ b/src/plugins/qmldesigner/designercore/designercore-lib.pri
@@ -13,6 +13,7 @@ include (instances/instances.pri)
include (../../../../share/qtcreator/qml/qmlpuppet/interfaces/interfaces.pri)
include (../../../../share/qtcreator/qml/qmlpuppet/commands/commands.pri)
include (../../../../share/qtcreator/qml/qmlpuppet/container/container.pri)
+include (../../../../share/qtcreator/qml/qmlpuppet/types/types.pri)
SOURCES += $$PWD/model/abstractview.cpp \
$$PWD/model/rewriterview.cpp \
diff --git a/src/plugins/qmldesigner/designercore/include/abstractview.h b/src/plugins/qmldesigner/designercore/include/abstractview.h
index 41ad7406ae..653b0afccb 100644
--- a/src/plugins/qmldesigner/designercore/include/abstractview.h
+++ b/src/plugins/qmldesigner/designercore/include/abstractview.h
@@ -132,7 +132,7 @@ public:
Model* model() const;
bool isAttached() const;
- RewriterTransaction beginRewriterTransaction();
+ RewriterTransaction beginRewriterTransaction(const QByteArray &identifier);
ModelNode createModelNode(const TypeName &typeName,
int majorVersion,
diff --git a/src/plugins/qmldesigner/designercore/include/variantproperty.h b/src/plugins/qmldesigner/designercore/include/variantproperty.h
index eb548419fb..592556e0d3 100644
--- a/src/plugins/qmldesigner/designercore/include/variantproperty.h
+++ b/src/plugins/qmldesigner/designercore/include/variantproperty.h
@@ -32,6 +32,7 @@
#include "qmldesignercorelib_global.h"
#include "abstractproperty.h"
+#include "enumeration.h"
QT_BEGIN_NAMESPACE
class QTextStream;
@@ -55,7 +56,12 @@ public:
void setValue(const QVariant &value);
QVariant value() const;
+ void setEnumeration(const EnumerationName &enumerationName);
+ Enumeration enumeration() const;
+ bool holdsEnumeration() const;
+
void setDynamicTypeNameAndValue(const TypeName &type, const QVariant &value);
+ void setDynamicTypeNameAndEnumeration(const TypeName &type, const EnumerationName &enumerationName);
VariantProperty();
VariantProperty(const VariantProperty &property, AbstractView *view);
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
index a52cf475a8..b1262b21fe 100644
--- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
@@ -71,6 +71,8 @@
#include "import.h"
+#include "qmldesignerplugin.h"
+
#include <utils/hostosinfo.h>
#include <QMessageBox>
@@ -126,6 +128,20 @@ QString NodeInstanceServerProxy::creatorQmlPuppetPath()
return applicationPath;
}
+bool NodeInstanceServerProxy::checkPuppetVersion(const QString &qmlPuppetPath)
+{
+ QProcess qmlPuppetVersionProcess;
+ qmlPuppetVersionProcess.start(qmlPuppetPath, QStringList() << "--version");
+ qmlPuppetVersionProcess.waitForReadyRead(6000);
+
+ QByteArray versionString = qmlPuppetVersionProcess.readAll();
+
+ bool canConvert;
+ unsigned int versionNumber = versionString.toUInt(&canConvert);
+
+ return canConvert && versionNumber == 2;
+}
+
NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceView, RunModus runModus, const QString &pathToQt)
: NodeInstanceServerInterface(nodeInstanceView),
m_localServer(new QLocalServer(this)),
@@ -140,11 +156,6 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
m_runModus(runModus),
m_synchronizeId(-1)
{
- QString socketToken(QUuid::createUuid().toString());
-
- m_localServer->listen(socketToken);
- m_localServer->setMaxPendingConnections(3);
-
QString applicationPath = pathToQt + QLatin1String("/bin");
if (runModus == TestModus) {
applicationPath = QCoreApplication::applicationDirPath()
@@ -175,88 +186,100 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
#endif
if (QFileInfo(applicationPath).exists()) {
- m_qmlPuppetEditorProcess = new QProcess;
- m_qmlPuppetEditorProcess->setProcessEnvironment(environment);
- m_qmlPuppetEditorProcess->setObjectName("EditorProcess");
- connect(m_qmlPuppetEditorProcess.data(), SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
- connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), m_qmlPuppetEditorProcess.data(), SLOT(kill()));
- bool fowardQmlpuppetOutput = !qgetenv("FORWARD_QMLPUPPET_OUTPUT").isEmpty();
- if (fowardQmlpuppetOutput) {
- m_qmlPuppetEditorProcess->setProcessChannelMode(QProcess::MergedChannels);
- connect(m_qmlPuppetEditorProcess.data(), SIGNAL(readyRead()), this, SLOT(printEditorProcessOutput()));
- }
- m_qmlPuppetEditorProcess->start(applicationPath, QStringList() << socketToken << "editormode" << "-graphicssystem raster");
-
- if (runModus == NormalModus) {
- m_qmlPuppetPreviewProcess = new QProcess;
- m_qmlPuppetPreviewProcess->setProcessEnvironment(environment);
- m_qmlPuppetPreviewProcess->setObjectName("PreviewProcess");
- connect(m_qmlPuppetPreviewProcess.data(), SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
- connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), m_qmlPuppetPreviewProcess.data(), SLOT(kill()));
+ if (checkPuppetVersion(applicationPath)) {
+ QString socketToken(QUuid::createUuid().toString());
+ m_localServer->listen(socketToken);
+ m_localServer->setMaxPendingConnections(3);
+
+ m_qmlPuppetEditorProcess = new QProcess;
+ m_qmlPuppetEditorProcess->setProcessEnvironment(environment);
+ m_qmlPuppetEditorProcess->setObjectName("EditorProcess");
+ connect(m_qmlPuppetEditorProcess.data(), SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
+ connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), m_qmlPuppetEditorProcess.data(), SLOT(kill()));
+ bool fowardQmlpuppetOutput = !qgetenv("FORWARD_QMLPUPPET_OUTPUT").isEmpty();
if (fowardQmlpuppetOutput) {
- m_qmlPuppetPreviewProcess->setProcessChannelMode(QProcess::MergedChannels);
- connect(m_qmlPuppetPreviewProcess.data(), SIGNAL(readyRead()), this, SLOT(printPreviewProcessOutput()));
+ m_qmlPuppetEditorProcess->setProcessChannelMode(QProcess::MergedChannels);
+ connect(m_qmlPuppetEditorProcess.data(), SIGNAL(readyRead()), this, SLOT(printEditorProcessOutput()));
}
- m_qmlPuppetPreviewProcess->start(applicationPath, QStringList() << socketToken << "previewmode" << "-graphicssystem raster");
+ m_qmlPuppetEditorProcess->start(applicationPath, QStringList() << socketToken << "editormode" << "-graphicssystem raster");
+
+ if (runModus == NormalModus) {
+ m_qmlPuppetPreviewProcess = new QProcess;
+ m_qmlPuppetPreviewProcess->setProcessEnvironment(environment);
+ m_qmlPuppetPreviewProcess->setObjectName("PreviewProcess");
+ connect(m_qmlPuppetPreviewProcess.data(), SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
+ connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), m_qmlPuppetPreviewProcess.data(), SLOT(kill()));
+ if (fowardQmlpuppetOutput) {
+ m_qmlPuppetPreviewProcess->setProcessChannelMode(QProcess::MergedChannels);
+ connect(m_qmlPuppetPreviewProcess.data(), SIGNAL(readyRead()), this, SLOT(printPreviewProcessOutput()));
+ }
+ m_qmlPuppetPreviewProcess->start(applicationPath, QStringList() << socketToken << "previewmode" << "-graphicssystem raster");
+
+ m_qmlPuppetRenderProcess = new QProcess;
+ m_qmlPuppetRenderProcess->setProcessEnvironment(environment);
+ m_qmlPuppetRenderProcess->setObjectName("RenderProcess");
+ connect(m_qmlPuppetRenderProcess.data(), SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
+ connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), m_qmlPuppetRenderProcess.data(), SLOT(kill()));
+ if (fowardQmlpuppetOutput) {
+ m_qmlPuppetRenderProcess->setProcessChannelMode(QProcess::MergedChannels);
+ connect(m_qmlPuppetRenderProcess.data(), SIGNAL(readyRead()), this, SLOT(printRenderProcessOutput()));
+ }
+ m_qmlPuppetRenderProcess->start(applicationPath, QStringList() << socketToken << "rendermode" << "-graphicssystem raster");
- m_qmlPuppetRenderProcess = new QProcess;
- m_qmlPuppetRenderProcess->setProcessEnvironment(environment);
- m_qmlPuppetRenderProcess->setObjectName("RenderProcess");
- connect(m_qmlPuppetRenderProcess.data(), SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
- connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), m_qmlPuppetRenderProcess.data(), SLOT(kill()));
- if (fowardQmlpuppetOutput) {
- m_qmlPuppetRenderProcess->setProcessChannelMode(QProcess::MergedChannels);
- connect(m_qmlPuppetRenderProcess.data(), SIGNAL(readyRead()), this, SLOT(printRenderProcessOutput()));
}
- m_qmlPuppetRenderProcess->start(applicationPath, QStringList() << socketToken << "rendermode" << "-graphicssystem raster");
- }
+ connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(deleteLater()));
- connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(deleteLater()));
+ if (m_qmlPuppetEditorProcess->waitForStarted(10000)) {
+ connect(m_qmlPuppetEditorProcess.data(), SIGNAL(finished(int)), m_qmlPuppetEditorProcess.data(),SLOT(deleteLater()));
- if (m_qmlPuppetEditorProcess->waitForStarted(10000)) {
- connect(m_qmlPuppetEditorProcess.data(), SIGNAL(finished(int)), m_qmlPuppetEditorProcess.data(),SLOT(deleteLater()));
+ if (runModus == NormalModus) {
+ m_qmlPuppetPreviewProcess->waitForStarted();
+ connect(m_qmlPuppetPreviewProcess.data(), SIGNAL(finished(int)), m_qmlPuppetPreviewProcess.data(),SLOT(deleteLater()));
- if (runModus == NormalModus) {
- m_qmlPuppetPreviewProcess->waitForStarted();
- connect(m_qmlPuppetPreviewProcess.data(), SIGNAL(finished(int)), m_qmlPuppetPreviewProcess.data(),SLOT(deleteLater()));
+ m_qmlPuppetRenderProcess->waitForStarted();
+ connect(m_qmlPuppetRenderProcess.data(), SIGNAL(finished(int)), m_qmlPuppetRenderProcess.data(),SLOT(deleteLater()));
+ }
- m_qmlPuppetRenderProcess->waitForStarted();
- connect(m_qmlPuppetRenderProcess.data(), SIGNAL(finished(int)), m_qmlPuppetRenderProcess.data(),SLOT(deleteLater()));
- }
+ if (!m_localServer->hasPendingConnections())
+ m_localServer->waitForNewConnection(10000);
- if (!m_localServer->hasPendingConnections())
- m_localServer->waitForNewConnection(10000);
+ m_firstSocket = m_localServer->nextPendingConnection();
+ connect(m_firstSocket.data(), SIGNAL(readyRead()), this, SLOT(readFirstDataStream()));
- m_firstSocket = m_localServer->nextPendingConnection();
- connect(m_firstSocket.data(), SIGNAL(readyRead()), this, SLOT(readFirstDataStream()));
+ if (runModus == NormalModus) {
+ if (!m_localServer->hasPendingConnections())
+ m_localServer->waitForNewConnection(10000);
- if (runModus == NormalModus) {
- if (!m_localServer->hasPendingConnections())
- m_localServer->waitForNewConnection(10000);
+ m_secondSocket = m_localServer->nextPendingConnection();
+ connect(m_secondSocket.data(), SIGNAL(readyRead()), this, SLOT(readSecondDataStream()));
- m_secondSocket = m_localServer->nextPendingConnection();
- connect(m_secondSocket.data(), SIGNAL(readyRead()), this, SLOT(readSecondDataStream()));
+ if (!m_localServer->hasPendingConnections())
+ m_localServer->waitForNewConnection(10000);
- if (!m_localServer->hasPendingConnections())
- m_localServer->waitForNewConnection(10000);
+ m_thirdSocket = m_localServer->nextPendingConnection();
+ connect(m_thirdSocket.data(), SIGNAL(readyRead()), this, SLOT(readThirdDataStream()));
+ }
+
+ } else {
+ QMessageBox::warning(0, tr("Cannot Start QML Puppet Executable"),
+ tr("The executable of the QML Puppet process (%1) cannot be started. "
+ "Please check your installation. "
+ "QML Puppet is a process which runs in the background to render the items.").
+ arg(applicationPath));
- m_thirdSocket = m_localServer->nextPendingConnection();
- connect(m_thirdSocket.data(), SIGNAL(readyRead()), this, SLOT(readThirdDataStream()));
+ QmlDesignerPlugin::instance()->switchToTextModeDeferred();
}
+ m_localServer->close();
+
} else {
- QMessageBox::warning(0, tr("Cannot Start QML Puppet Executable"),
- tr("The executable of the QML Puppet process (%1) cannot be started. "
- "Please check your installation. "
- "QML Puppet is a process which runs in the background to render the items.").
- arg(applicationPath));
+ QMessageBox::warning(0, tr("Wrong QML Puppet Executable Version"), tr("The QML Puppet version is incompatible with the Qt Creator version."));
+ QmlDesignerPlugin::instance()->switchToTextModeDeferred();
}
-
- m_localServer->close();
-
} else {
QMessageBox::warning(0, tr("Cannot Find QML Puppet Executable"), missingQmlPuppetErrorMessage(applicationPath));
+ QmlDesignerPlugin::instance()->switchToTextModeDeferred();
}
int indexOfCapturePuppetStream = QCoreApplication::arguments().indexOf("-capture-puppet-stream");
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h
index 4c0593e519..00bef05957 100644
--- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h
+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h
@@ -79,6 +79,8 @@ protected:
QString qmlPuppetApplicationName() const;
QString macOSBundlePath(const QString &path) const;
QString creatorQmlPuppetPath();
+ static bool checkPuppetVersion(const QString &qmlPuppetPath);
+
signals:
void processCrashed();
diff --git a/src/plugins/qmldesigner/designercore/model/abstractview.cpp b/src/plugins/qmldesigner/designercore/model/abstractview.cpp
index 76b699f4aa..c59dab43b9 100644
--- a/src/plugins/qmldesigner/designercore/model/abstractview.cpp
+++ b/src/plugins/qmldesigner/designercore/model/abstractview.cpp
@@ -71,9 +71,9 @@ void AbstractView::setModel(Model *model)
m_model = model;
}
-RewriterTransaction AbstractView::beginRewriterTransaction()
+RewriterTransaction AbstractView::beginRewriterTransaction(const QByteArray &identifier)
{
- return RewriterTransaction(this);
+ return RewriterTransaction(this, identifier);
}
ModelNode AbstractView::createModelNode(const TypeName &typeName,
diff --git a/src/plugins/qmldesigner/designercore/model/import.cpp b/src/plugins/qmldesigner/designercore/model/import.cpp
index 0dd477049b..67e9510c1c 100644
--- a/src/plugins/qmldesigner/designercore/model/import.cpp
+++ b/src/plugins/qmldesigner/designercore/model/import.cpp
@@ -92,7 +92,7 @@ QString Import::toString(bool skipAlias) const
bool Import::operator==(const Import &other) const
{
- return url() == other.url() && file() == other.file() && version() == other.version() && alias() == other.alias();
+ return url() == other.url() && file() == other.file() && (version() == other.version() || version().isEmpty() || other.version().isEmpty());
}
bool Import::isSameModule(const Import &other) const
diff --git a/src/plugins/qmldesigner/designercore/model/modelmerger.cpp b/src/plugins/qmldesigner/designercore/model/modelmerger.cpp
index 0613b3d069..6fa0110b2b 100644
--- a/src/plugins/qmldesigner/designercore/model/modelmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/modelmerger.cpp
@@ -154,7 +154,7 @@ static ModelNode createNodeFromNode(const ModelNode &modelNode,const QHash<QStri
ModelNode ModelMerger::insertModel(const ModelNode &modelNode)
{
- RewriterTransaction transaction(view()->beginRewriterTransaction());
+ RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("ModelMerger::insertModel")));
QList<Import> newImports;
@@ -179,7 +179,7 @@ void ModelMerger::replaceModel(const ModelNode &modelNode)
view()->model()->setFileUrl(modelNode.model()->fileUrl());
try {
- RewriterTransaction transaction(view()->beginRewriterTransaction());
+ RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("ModelMerger::replaceModel")));
ModelNode rootNode(view()->rootModelNode());
diff --git a/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp b/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
index cbd295f87b..23ee802bf2 100644
--- a/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
+++ b/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
@@ -176,7 +176,7 @@ void QmlAnchors::setAnchor(AnchorLine::Type sourceAnchorLine,
const QmlItemNode &targetQmlItemNode,
AnchorLine::Type targetAnchorLine)
{
- RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::setAnchor"));
if (qmlItemNode().isInBaseState()) {
if ((qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLine::Fill))
|| ((qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLine::Center)))) {
@@ -330,7 +330,7 @@ AnchorLine QmlAnchors::instanceAnchor(AnchorLine::Type sourceAnchorLine) const
void QmlAnchors::removeAnchor(AnchorLine::Type sourceAnchorLine)
{
- RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeAnchor"));
if (qmlItemNode().isInBaseState()) {
const PropertyName propertyName = anchorPropertyName(sourceAnchorLine);
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLine::Fill)) {
@@ -352,7 +352,7 @@ void QmlAnchors::removeAnchor(AnchorLine::Type sourceAnchorLine)
void QmlAnchors::removeAnchors()
{
- RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeAnchors"));
if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill"))
qmlItemNode().modelNode().removeProperty("anchors.fill");
if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn"))
@@ -540,7 +540,7 @@ void QmlAnchors::removeMargin(AnchorLine::Type sourceAnchorLineType)
void QmlAnchors::removeMargins()
{
- RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction();
+ RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeMargins"));
removeMargin(AnchorLine::Left);
removeMargin(AnchorLine::Right);
removeMargin(AnchorLine::Top);
diff --git a/src/plugins/qmldesigner/designercore/model/qmlchangeset.cpp b/src/plugins/qmldesigner/designercore/model/qmlchangeset.cpp
index 14f00a5168..c34cfe2381 100644
--- a/src/plugins/qmldesigner/designercore/model/qmlchangeset.cpp
+++ b/src/plugins/qmldesigner/designercore/model/qmlchangeset.cpp
@@ -72,7 +72,7 @@ bool QmlModelStateOperation::isValidQmlModelStateOperation(const ModelNode &mode
void QmlPropertyChanges::removeProperty(const PropertyName &name)
{
- RewriterTransaction transaction(view()->beginRewriterTransaction());
+ RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("QmlPropertyChanges::removeProperty")));
if (name == "name")
return;
modelNode().removeProperty(name);
diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
index b557cafeca..96ca55157f 100644
--- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
+++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
@@ -100,7 +100,7 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary
QmlItemNode newQmlItemNode;
try {
- RewriterTransaction transaction = view->beginRewriterTransaction();
+ RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNode"));
NodeMetaInfo metaInfo = view->model()->metaInfo(itemLibraryEntry.typeName());
@@ -208,7 +208,7 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
parentQmlItemNode = QmlItemNode(view->rootModelNode());
if (parentQmlItemNode.isValid()) {
- RewriterTransaction transaction = view->beginRewriterTransaction();
+ RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNodeFromImage"));
checkImageImport(view);
diff --git a/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp b/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp
index 4be3d74103..5e505f8d58 100644
--- a/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp
+++ b/src/plugins/qmldesigner/designercore/model/qmltextgenerator.cpp
@@ -113,9 +113,8 @@ QString QmlTextGenerator::toQml(const AbstractProperty &property, int indentDept
if (false) {
}
- if (variantProperty.parentModelNode().metaInfo().isValid() &&
- variantProperty.parentModelNode().metaInfo().propertyIsEnumType(variantProperty.name())) {
- return variantProperty.parentModelNode().metaInfo().propertyEnumScope(variantProperty.name()) + '.' + stringValue;
+ if (variantProperty.holdsEnumeration()) {
+ return variantProperty.enumeration().toString();
} else {
switch (value.type()) {
diff --git a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp
index 6f3e4efca2..c59ef15c95 100644
--- a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp
+++ b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp
@@ -203,7 +203,7 @@ void RewriterView::propertiesAboutToBeRemoved(const QList<AbstractProperty> &pro
foreach (const AbstractProperty &property, propertyList) {
if (property.isDefaultProperty() && property.isNodeListProperty()) {
- m_removeDefaultPropertyTransaction = beginRewriterTransaction();
+ m_removeDefaultPropertyTransaction = beginRewriterTransaction(QByteArrayLiteral("RewriterView::propertiesAboutToBeRemoved"));
foreach (const ModelNode &node, property.toNodeListProperty().toModelNodeList()) {
modelToTextMerger()->nodeRemoved(node, property.toNodeAbstractProperty(), AbstractView::NoAdditionalChanges);
diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
index 3cedee0bdd..979defd1ab 100644
--- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
@@ -40,6 +40,7 @@
#include "variantproperty.h"
#include "signalhandlerproperty.h"
#include "nodemetainfo.h"
+#include "enumeration.h"
#include <qmljs/qmljsevaluate.h>
#include <qmljs/qmljslink.h>
@@ -565,7 +566,7 @@ public:
if (astValueList.count() == 2 //Check for global Qt enums
&& astValueList.first() == QLatin1String("Qt")
&& globalQtEnums().contains(astValueList.last()))
- return QVariant(astValueList.last());
+ return QVariant::fromValue(Enumeration(astValue));
ExpressionStatement *eStmt = cast<ExpressionStatement *>(rhs);
if (!eStmt || !eStmt->expression)
@@ -607,7 +608,7 @@ public:
return QVariant();
if (rhsCppComponentValue->getEnum(lhsPropertyTypeName).hasKey(rhsValueName))
- return QVariant(rhsValueName);
+ return QVariant::fromValue(Enumeration(astValue));
else
return QVariant();
}
diff --git a/src/plugins/qmldesigner/designercore/model/variantproperty.cpp b/src/plugins/qmldesigner/designercore/model/variantproperty.cpp
index bbbeb2bc5b..ab50777f24 100644
--- a/src/plugins/qmldesigner/designercore/model/variantproperty.cpp
+++ b/src/plugins/qmldesigner/designercore/model/variantproperty.cpp
@@ -89,6 +89,21 @@ QVariant VariantProperty::value() const
return QVariant();
}
+void VariantProperty::setEnumeration(const EnumerationName &enumerationName)
+{
+ setValue(QVariant::fromValue(Enumeration(enumerationName)));
+}
+
+Enumeration VariantProperty::enumeration() const
+{
+ return value().value<Enumeration>();
+}
+
+bool VariantProperty::holdsEnumeration() const
+{
+ return value().canConvert<Enumeration>();
+}
+
void VariantProperty::setDynamicTypeNameAndValue(const TypeName &type, const QVariant &value)
{
Internal::WriteLocker locker(model());
@@ -111,7 +126,12 @@ void VariantProperty::setDynamicTypeNameAndValue(const TypeName &type, const QVa
if (internalNode()->hasProperty(name()) && !internalNode()->property(name())->isVariantProperty())
model()->d->removeProperty(internalNode()->property(name()));
- model()->d->setDynamicVariantProperty(internalNode(), name(), type, value);
+ model()->d->setDynamicVariantProperty(internalNode(), name(), type, value);
+}
+
+void VariantProperty::setDynamicTypeNameAndEnumeration(const TypeName &type, const EnumerationName &enumerationName)
+{
+ setDynamicTypeNameAndValue(type, QVariant::fromValue(Enumeration(enumerationName)));
}
QDebug operator<<(QDebug debug, const VariantProperty &VariantProperty)
diff --git a/src/plugins/qmldesigner/designercore/rewritertransaction.cpp b/src/plugins/qmldesigner/designercore/rewritertransaction.cpp
index 8b00e96b17..3888bc3d98 100644
--- a/src/plugins/qmldesigner/designercore/rewritertransaction.cpp
+++ b/src/plugins/qmldesigner/designercore/rewritertransaction.cpp
@@ -35,13 +35,29 @@
namespace QmlDesigner {
+
+QList<QByteArray> RewriterTransaction::m_identifierList;
+bool RewriterTransaction::m_activeIdentifier = !qgetenv("QML_DESIGNER_TRACE_REWRITER_TRANSACTION").isEmpty();
+
RewriterTransaction::RewriterTransaction() : m_valid(false)
{
}
-RewriterTransaction::RewriterTransaction(AbstractView *_view) : m_view(_view), m_valid(true)
+RewriterTransaction::RewriterTransaction(AbstractView *_view, const QByteArray &identifier)
+ : m_view(_view),
+ m_identifier(identifier),
+ m_valid(true)
{
Q_ASSERT(view());
+
+ static int identifierNumber = 0;
+ m_identifierNumber = identifierNumber++;
+
+ if (m_activeIdentifier) {
+ qDebug() << "Begin RewriterTransaction:" << m_identifier << m_identifierNumber;
+ m_identifierList.append(m_identifier + QByteArrayLiteral("-") + QByteArray::number(m_identifierNumber));
+ }
+
view()->emitRewriterBeginTransaction();
}
@@ -60,6 +76,12 @@ void RewriterTransaction::commit()
if (m_valid) {
m_valid = false;
view()->emitRewriterEndTransaction();
+
+ if (m_activeIdentifier) {
+ qDebug() << "Commit RewriterTransaction:" << m_identifier << m_identifierNumber;
+ bool success = m_identifierList.removeOne(m_identifier + QByteArrayLiteral("-") + QByteArray::number(m_identifierNumber));
+ Q_ASSERT(success);
+ }
}
}
@@ -70,6 +92,11 @@ void RewriterTransaction::rollback()
m_valid = false;
view()->emitRewriterEndTransaction();
QmlDesignerPlugin::instance()->currentDesignDocument()->undo();
+
+ if (m_activeIdentifier) {
+ qDebug() << "Rollback RewriterTransaction:" << m_identifier << m_identifierNumber;
+ m_identifierList.removeOne(m_identifier + QByteArrayLiteral("-") + QByteArray::number(m_identifierNumber));
+ }
}
}
@@ -84,6 +111,8 @@ RewriterTransaction::RewriterTransaction(const RewriterTransaction &other)
if (&other != this) {
m_valid = other.m_valid;
m_view = other.m_view;
+ m_identifier = other.m_identifier;
+ m_identifierNumber = other.m_identifierNumber;
other.m_valid = false;
}
}
@@ -93,6 +122,8 @@ RewriterTransaction& RewriterTransaction::operator=(const RewriterTransaction &o
if (!m_valid && (&other != this)) {
m_valid = other.m_valid;
m_view = other.m_view;
+ m_identifier = other.m_identifier;
+ m_identifierNumber = other.m_identifierNumber;
other.m_valid = false;
}
diff --git a/src/plugins/qmldesigner/designercore/rewritertransaction.h b/src/plugins/qmldesigner/designercore/rewritertransaction.h
index ac58e5fb3a..815b0cb4bf 100644
--- a/src/plugins/qmldesigner/designercore/rewritertransaction.h
+++ b/src/plugins/qmldesigner/designercore/rewritertransaction.h
@@ -42,7 +42,7 @@ class QMLDESIGNERCORE_EXPORT RewriterTransaction
{
public:
RewriterTransaction();
- RewriterTransaction(AbstractView *view);
+ RewriterTransaction(AbstractView *view, const QByteArray &identifier);
~RewriterTransaction();
void commit();
void rollback();
@@ -55,7 +55,11 @@ protected:
AbstractView *view();
private:
QWeakPointer<AbstractView> m_view;
+ QByteArray m_identifier;
mutable bool m_valid;
+ int m_identifierNumber;
+ static QList<QByteArray> m_identifierList;
+ static bool m_activeIdentifier;
};
} //QmlDesigner
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp
index 5108cab37f..591f8e7b1e 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.cpp
+++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp
@@ -48,7 +48,7 @@
#include <utils/hostosinfo.h>
#include <QAction>
-
+#include <QTimer>
#include <QCoreApplication>
#include <qplugin.h>
#include <QDebug>
@@ -94,6 +94,7 @@ QmlDesignerPlugin::QmlDesignerPlugin() :
QmlDesignerPlugin::~QmlDesignerPlugin()
{
+ Core::DesignMode::instance()->unregisterDesignWidget(m_mainWidget);
Core::ICore::removeContextObject(m_context);
m_context = 0;
m_instance = 0;
@@ -372,6 +373,11 @@ Internal::DesignModeWidget *QmlDesignerPlugin::mainWidget() const
return m_mainWidget;
}
+void QmlDesignerPlugin::switchToTextModeDeferred()
+{
+ QTimer::singleShot(0, this, SLOT(switschToTextMode()));
+}
+
void QmlDesignerPlugin::onTextEditorsClosed(QList<Core::IEditor*> editors)
{
if (m_documentManager.hasCurrentDesignDocument()
@@ -439,6 +445,11 @@ void QmlDesignerPlugin::switchTextDesign()
}
}
+void QmlDesignerPlugin::switschToTextMode()
+{
+ Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
+}
+
DesignerSettings QmlDesignerPlugin::settings()
{
m_settings.fromSettings(Core::ICore::settings());
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.h b/src/plugins/qmldesigner/qmldesignerplugin.h
index e44fd1009d..6ce24e177b 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.h
+++ b/src/plugins/qmldesigner/qmldesignerplugin.h
@@ -92,8 +92,11 @@ public:
DesignDocument *currentDesignDocument() const;
Internal::DesignModeWidget *mainWidget() const;
+ void switchToTextModeDeferred();
+
private slots:
void switchTextDesign();
+ void switschToTextMode();
void onTextEditorsClosed(QList<Core::IEditor *> editors);
void onCurrentEditorChanged(Core::IEditor *editor);
void onCurrentModeChanged(Core::IMode *mode, Core::IMode *oldMode);
diff --git a/src/plugins/qmldesigner/settingspage.cpp b/src/plugins/qmldesigner/settingspage.cpp
index af513e158e..884ad140fa 100644
--- a/src/plugins/qmldesigner/settingspage.cpp
+++ b/src/plugins/qmldesigner/settingspage.cpp
@@ -73,18 +73,6 @@ void SettingsPageWidget::setSettings(const DesignerSettings &designerSettings)
m_ui.designerEnableDebuggerCheckBox->setChecked(designerSettings.enableDebugView);
}
-QString SettingsPageWidget::searchKeywords() const
-{
- QString rc;
- QTextStream(&rc)
- << ' ' << m_ui.snapMarginLabel->text()
- << ' ' << m_ui.itemSpacingLabel->text()
- << ' ' << m_ui.canvasWidthLabel->text()
- << ' ' << m_ui.canvasHeightLabel->text();
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
void SettingsPageWidget::debugViewEnabledToggled(bool b)
{
if (b && ! m_ui.designerShowDebuggerCheckBox->isChecked())
@@ -102,12 +90,12 @@ SettingsPage::SettingsPage() :
setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_QML_ICON));
}
-QWidget *SettingsPage::createPage(QWidget *parent)
+QWidget *SettingsPage::widget()
{
- m_widget = new SettingsPageWidget(parent);
- m_widget->setSettings(QmlDesignerPlugin::instance()->settings());
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new SettingsPageWidget;
+ m_widget->setSettings(QmlDesignerPlugin::instance()->settings());
+ }
return m_widget;
}
@@ -118,7 +106,7 @@ void SettingsPage::apply()
QmlDesignerPlugin::instance()->setSettings(m_widget->settings());
}
-bool SettingsPage::matches(const QString &s) const
+void SettingsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
diff --git a/src/plugins/qmldesigner/settingspage.h b/src/plugins/qmldesigner/settingspage.h
index 22aedc9f4f..538b1aeb95 100644
--- a/src/plugins/qmldesigner/settingspage.h
+++ b/src/plugins/qmldesigner/settingspage.h
@@ -35,6 +35,7 @@
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
#include <QWidget>
QT_BEGIN_NAMESPACE
@@ -57,8 +58,6 @@ public:
DesignerSettings settings() const;
void setSettings(const DesignerSettings &designerSettings);
- QString searchKeywords() const;
-
public slots:
void debugViewEnabledToggled(bool b);
@@ -74,14 +73,12 @@ class SettingsPage : public Core::IOptionsPage
public:
SettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &) const;
+ void finish();
private:
- QString m_searchKeywords;
- SettingsPageWidget* m_widget;
+ QPointer<SettingsPageWidget> m_widget;
};
} // namespace Internal
diff --git a/src/plugins/qmldesigner/settingspage.ui b/src/plugins/qmldesigner/settingspage.ui
index 124950c424..528f621d13 100644
--- a/src/plugins/qmldesigner/settingspage.ui
+++ b/src/plugins/qmldesigner/settingspage.ui
@@ -58,7 +58,7 @@
<item row="0" column="1">
<widget class="QCheckBox" name="designerWarningsCheckBox">
<property name="toolTip">
- <string>Warn about QML features which are not properly supported by the Qt Quick Designer</string>
+ <string>Warns about QML features which are not properly supported by the Qt Quick Designer</string>
</property>
<property name="text">
<string>Warn about unsupported features in the Qt Quick Designer</string>
@@ -68,7 +68,7 @@
<item row="1" column="1">
<widget class="QCheckBox" name="designerWarningsInEditorCheckBox">
<property name="toolTip">
- <string>Also warn in the code editor about QML features which are not properly supported by the Qt Quick Designer</string>
+ <string>Also warns in the code editor about QML features which are not properly supported by the Qt Quick Designer</string>
</property>
<property name="text">
<string>Warn about unsupported features of Qt Quick Designer in the code editor</string>
diff --git a/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp b/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp
index b65e7c99ea..cd0c0e10d1 100644
--- a/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp
+++ b/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp
@@ -66,6 +66,7 @@ void ComponentNameDialog::go(QString *proposedName,
d.ui->componentNameEdit->setForceFirstCapitalLetter(true);
d.ui->componentNameEdit->setText(*proposedName);
d.ui->pathEdit->setExpectedKind(Utils::PathChooser::ExistingDirectory);
+ d.ui->pathEdit->setHistoryCompleter(QLatin1String("QmlJs.Component.History"));
d.ui->pathEdit->setPath(*proposedPath);
if (QDialog::Accepted == d.exec()) {
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp
index 8878d6d54c..8e66676d85 100644
--- a/src/plugins/qmljseditor/qmljseditor.cpp
+++ b/src/plugins/qmljseditor/qmljseditor.cpp
@@ -46,6 +46,7 @@
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/qmljsutils.h>
+#include <qmljstools/qmljstoolsconstants.h>
#include <qmljstools/qmljsindenter.h>
#include <qmljstools/qmljsqtstylecodeformatter.h>
@@ -449,15 +450,26 @@ protected:
QmlJSTextEditorWidget::QmlJSTextEditorWidget(QWidget *parent) :
- TextEditor::BaseTextEditorWidget(parent),
- m_outlineCombo(0),
- m_outlineModel(new QmlOutlineModel(this)),
- m_modelManager(0),
- m_futureSemanticInfoRevision(0),
- m_contextPane(0),
- m_findReferences(new FindReferences(this)),
- m_semanticHighlighter(new SemanticHighlighter(this))
+ TextEditor::BaseTextEditorWidget(parent)
{
+ ctor();
+}
+
+QmlJSTextEditorWidget::QmlJSTextEditorWidget(QmlJSTextEditorWidget *other)
+ : TextEditor::BaseTextEditorWidget(other)
+{
+ ctor();
+}
+
+void QmlJSTextEditorWidget::ctor()
+{
+ m_outlineCombo = 0;
+ m_outlineModel = new QmlOutlineModel(this);
+ m_futureSemanticInfoRevision = 0;
+ m_contextPane = 0;
+ m_findReferences = new FindReferences(this);
+ m_semanticHighlighter = new SemanticHighlighter(this);
+
m_semanticInfoUpdater = new SemanticInfoUpdater(this);
m_semanticInfoUpdater->start();
@@ -466,6 +478,7 @@ QmlJSTextEditorWidget::QmlJSTextEditorWidget(QWidget *parent) :
setCodeFoldingSupported(true);
setIndenter(new Indenter);
setAutoCompleter(new AutoCompleter);
+ setLanguageSettingsId(QmlJSTools::Constants::QML_JS_SETTINGS_ID);
m_updateDocumentTimer = new QTimer(this);
m_updateDocumentTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
@@ -579,11 +592,11 @@ QModelIndex QmlJSTextEditorWidget::outlineModelIndex()
return m_outlineModelIndex;
}
-IEditor *QmlJSEditor::duplicate(QWidget *parent)
+IEditor *QmlJSEditor::duplicate()
{
- QmlJSTextEditorWidget *newEditor = new QmlJSTextEditorWidget(parent);
- newEditor->duplicateFrom(editorWidget());
- QmlJSEditorPlugin::instance()->initializeEditor(newEditor);
+ QmlJSTextEditorWidget *newEditor = new QmlJSTextEditorWidget(
+ qobject_cast<QmlJSTextEditorWidget *>(editorWidget()));
+ TextEditor::TextEditorSettings::initializeEditor(newEditor);
return newEditor->editor();
}
@@ -595,7 +608,7 @@ Id QmlJSEditor::id() const
bool QmlJSEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
bool b = TextEditor::BaseTextEditor::open(errorString, fileName, realFileName);
- editorWidget()->setMimeType(MimeDatabase::findByFile(QFileInfo(fileName)).type());
+ baseTextDocument()->setMimeType(MimeDatabase::findByFile(QFileInfo(fileName)).type());
return b;
}
@@ -608,7 +621,7 @@ void QmlJSTextEditorWidget::reparseDocumentNow()
{
m_updateDocumentTimer->stop();
- const QString fileName = editorDocument()->filePath();
+ const QString fileName = baseTextDocument()->filePath();
m_modelManager->updateSourceFiles(QStringList() << fileName, false);
}
@@ -650,7 +663,7 @@ static void appendExtraSelectionsForMessages(
void QmlJSTextEditorWidget::onDocumentUpdated(QmlJS::Document::Ptr doc)
{
- if (editorDocument()->filePath() != doc->fileName())
+ if (baseTextDocument()->filePath() != doc->fileName())
return;
if (doc->editorRevision() != editorRevision()) {
@@ -682,7 +695,7 @@ void QmlJSTextEditorWidget::onDocumentUpdated(QmlJS::Document::Ptr doc)
void QmlJSTextEditorWidget::modificationChanged(bool changed)
{
if (!changed && m_modelManager)
- m_modelManager->fileChangedOnDisk(editorDocument()->filePath());
+ m_modelManager->fileChangedOnDisk(baseTextDocument()->filePath());
}
void QmlJSTextEditorWidget::jumpToOutlineElement(int /*index*/)
@@ -973,10 +986,6 @@ void QmlJSTextEditorWidget::setSelectedElements()
emit selectedElementsChanged(offsets, wordAtCursor);
}
-void QmlJSTextEditorWidget::updateFileName()
-{
-}
-
void QmlJSTextEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
{
TextEditor::BaseTextEditorWidget::setFontSettings(fs);
@@ -1058,8 +1067,6 @@ void QmlJSTextEditorWidget::createToolBar(QmlJSEditor *editor)
connect(m_outlineCombo, SIGNAL(activated(int)), this, SLOT(jumpToOutlineElement(int)));
connect(this, SIGNAL(cursorPositionChanged()), m_updateOutlineIndexTimer, SLOT(start()));
- connect(editorDocument(), SIGNAL(changed()), this, SLOT(updateFileName()));
-
editor->insertExtraToolBarWidget(TextEditor::BaseTextEditor::Left, m_outlineCombo);
}
@@ -1148,12 +1155,12 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q
void QmlJSTextEditorWidget::findUsages()
{
- m_findReferences->findUsages(editorDocument()->filePath(), textCursor().position());
+ m_findReferences->findUsages(baseTextDocument()->filePath(), textCursor().position());
}
void QmlJSTextEditorWidget::renameUsages()
{
- m_findReferences->renameUsages(editorDocument()->filePath(), textCursor().position());
+ m_findReferences->renameUsages(baseTextDocument()->filePath(), textCursor().position());
}
void QmlJSTextEditorWidget::showContextPane()
diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h
index 21b5f00daf..4880ab0988 100644
--- a/src/plugins/qmljseditor/qmljseditor.h
+++ b/src/plugins/qmljseditor/qmljseditor.h
@@ -100,6 +100,7 @@ class QMLJSEDITOR_EXPORT QmlJSTextEditorWidget : public TextEditor::BaseTextEdit
public:
QmlJSTextEditorWidget(QWidget *parent = 0);
+ QmlJSTextEditorWidget(QmlJSTextEditorWidget *other);
~QmlJSTextEditorWidget();
virtual void unCommentSelection();
@@ -142,7 +143,6 @@ private slots:
void updateOutlineIndexNow();
void updateCursorPositionNow();
void showTextMarker();
- void updateFileName();
void updateUses();
void updateUsesNow();
@@ -167,6 +167,8 @@ protected:
QString foldReplacementText(const QTextBlock &block) const;
private:
+ QmlJSTextEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
+ void ctor();
bool isClosingBrace(const QList<QmlJS::Token> &tokens) const;
void setSelectedElements();
diff --git a/src/plugins/qmljseditor/qmljseditor.qbs b/src/plugins/qmljseditor/qmljseditor.qbs
index 7284d2a342..0ebd66d2a7 100644
--- a/src/plugins/qmljseditor/qmljseditor.qbs
+++ b/src/plugins/qmljseditor/qmljseditor.qbs
@@ -12,7 +12,6 @@ QtcPlugin {
Depends { name: "QmlJSTools" }
Depends { name: "QmlJS" }
Depends { name: "LanguageUtils" }
- Depends { name: "Find" }
Depends { name: "QmlEditorWidgets" }
Depends { name: "CPlusPlus" }
diff --git a/src/plugins/qmljseditor/qmljseditor_dependencies.pri b/src/plugins/qmljseditor/qmljseditor_dependencies.pri
index 481638aa2a..56134f0334 100644
--- a/src/plugins/qmljseditor/qmljseditor_dependencies.pri
+++ b/src/plugins/qmljseditor/qmljseditor_dependencies.pri
@@ -4,7 +4,6 @@ QTC_LIB_DEPENDS += \
qmleditorwidgets
QTC_PLUGIN_DEPENDS += \
coreplugin \
- find \
texteditor \
projectexplorer \
qmljstools
diff --git a/src/plugins/qmljseditor/qmljseditoreditable.h b/src/plugins/qmljseditor/qmljseditoreditable.h
index 98d05470f9..13cc7ff00a 100644
--- a/src/plugins/qmljseditor/qmljseditoreditable.h
+++ b/src/plugins/qmljseditor/qmljseditoreditable.h
@@ -45,7 +45,7 @@ public:
explicit QmlJSEditor(QmlJSTextEditorWidget *);
bool duplicateSupported() const { return true; }
- Core::IEditor *duplicate(QWidget *parent);
+ Core::IEditor *duplicate();
Core::Id id() const;
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
bool isDesignModePreferred() const;
diff --git a/src/plugins/qmljseditor/qmljseditorfactory.cpp b/src/plugins/qmljseditor/qmljseditorfactory.cpp
index 006fe79d5c..f0bbfb9757 100644
--- a/src/plugins/qmljseditor/qmljseditorfactory.cpp
+++ b/src/plugins/qmljseditor/qmljseditorfactory.cpp
@@ -34,6 +34,8 @@
#include "qmljseditorplugin.h"
#include <qmljstools/qmljstoolsconstants.h>
+#include <texteditor/texteditoractionhandler.h>
+#include <texteditor/texteditorsettings.h>
#include <QCoreApplication>
@@ -52,12 +54,18 @@ QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent)
addMimeType(QmlJSTools::Constants::QMLTYPES_MIMETYPE);
addMimeType(QmlJSTools::Constants::JS_MIMETYPE);
addMimeType(QmlJSTools::Constants::JSON_MIMETYPE);
+ new TextEditor::TextEditorActionHandler(this, Constants::C_QMLJSEDITOR_ID,
+ TextEditor::TextEditorActionHandler::Format
+ | TextEditor::TextEditorActionHandler::UnCommentSelection
+ | TextEditor::TextEditorActionHandler::UnCollapseAll
+ | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
+
}
-Core::IEditor *QmlJSEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *QmlJSEditorFactory::createEditor()
{
- QmlJSTextEditorWidget *rc = new QmlJSTextEditorWidget(parent);
- QmlJSEditorPlugin::instance()->initializeEditor(rc);
+ QmlJSTextEditorWidget *rc = new QmlJSTextEditorWidget();
+ TextEditor::TextEditorSettings::initializeEditor(rc);
return rc->editor();
}
diff --git a/src/plugins/qmljseditor/qmljseditorfactory.h b/src/plugins/qmljseditor/qmljseditorfactory.h
index 8370f68a53..e8e047cd9b 100644
--- a/src/plugins/qmljseditor/qmljseditorfactory.h
+++ b/src/plugins/qmljseditor/qmljseditorfactory.h
@@ -42,7 +42,7 @@ class QmlJSEditorFactory : public Core::IEditorFactory
public:
QmlJSEditorFactory(QObject *parent);
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
};
} // namespace Internal
diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp
index d63d612cb9..0820dd4b66 100644
--- a/src/plugins/qmljseditor/qmljseditorplugin.cpp
+++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp
@@ -62,9 +62,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <projectexplorer/taskhub.h>
#include <texteditor/texteditorconstants.h>
-#include <texteditor/texteditorsettings.h>
#include <texteditor/textfilewizard.h>
-#include <texteditor/texteditoractionhandler.h>
#include <utils/qtcassert.h>
#include <utils/json.h>
@@ -95,7 +93,6 @@ QmlJSEditorPlugin *QmlJSEditorPlugin::m_instance = 0;
QmlJSEditorPlugin::QmlJSEditorPlugin() :
m_modelManager(0),
m_editor(0),
- m_actionHandler(0),
m_quickFixAssistProvider(0),
m_reformatFileAction(0),
m_currentEditor(0),
@@ -109,7 +106,6 @@ QmlJSEditorPlugin::QmlJSEditorPlugin() :
QmlJSEditorPlugin::~QmlJSEditorPlugin()
{
removeObject(m_editor);
- delete m_actionHandler;
m_instance = 0;
}
@@ -165,13 +161,6 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
wizard->setId(QLatin1String("Z.Js"));
addAutoReleasedObject(wizard);
- m_actionHandler = new TextEditor::TextEditorActionHandler(Constants::C_QMLJSEDITOR_ID,
- TextEditor::TextEditorActionHandler::Format
- | TextEditor::TextEditorActionHandler::UnCommentSelection
- | TextEditor::TextEditorActionHandler::UnCollapseAll
- | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
- m_actionHandler->initializeActions();
-
Core::ActionContainer *contextMenu = Core::ActionManager::createMenu(Constants::M_CONTEXT);
Core::ActionContainer *qmlToolsMenu = Core::ActionManager::actionContainer(Core::Id(QmlJSTools::Constants::M_TOOLS_QMLJS));
@@ -262,16 +251,6 @@ ExtensionSystem::IPlugin::ShutdownFlag QmlJSEditorPlugin::aboutToShutdown()
return IPlugin::aboutToShutdown();
}
-void QmlJSEditorPlugin::initializeEditor(QmlJSTextEditorWidget *editor)
-{
- QTC_CHECK(m_instance);
-
- m_actionHandler->setupActions(editor);
-
- editor->setLanguageSettingsId(QmlJSTools::Constants::QML_JS_SETTINGS_ID);
- TextEditor::TextEditorSettings::initializeEditor(editor);
-}
-
Utils::JsonSchemaManager *QmlJSEditorPlugin::jsonManager() const
{
return m_jsonManager.data();
@@ -332,14 +311,12 @@ void QmlJSEditorPlugin::currentEditorChanged(Core::IEditor *editor)
newTextEditor = qobject_cast<QmlJSTextEditorWidget *>(editor->widget());
if (m_currentEditor) {
- disconnect(m_currentEditor.data(), SIGNAL(contentsChanged()),
- this, SLOT(checkCurrentEditorSemanticInfoUpToDate()));
- disconnect(m_currentEditor.data(), SIGNAL(semanticInfoUpdated()),
- this, SLOT(checkCurrentEditorSemanticInfoUpToDate()));
+ m_currentEditor->baseTextDocument()->disconnect(this);
+ m_currentEditor->disconnect(this);
}
m_currentEditor = newTextEditor;
if (newTextEditor) {
- connect(newTextEditor, SIGNAL(contentsChanged()),
+ connect(newTextEditor->baseTextDocument(), SIGNAL(contentsChanged()),
this, SLOT(checkCurrentEditorSemanticInfoUpToDate()));
connect(newTextEditor, SIGNAL(semanticInfoUpdated()),
this, SLOT(checkCurrentEditorSemanticInfoUpToDate()));
diff --git a/src/plugins/qmljseditor/qmljseditorplugin.h b/src/plugins/qmljseditor/qmljseditorplugin.h
index 2ee6e6ed76..791a653dfd 100644
--- a/src/plugins/qmljseditor/qmljseditorplugin.h
+++ b/src/plugins/qmljseditor/qmljseditorplugin.h
@@ -42,10 +42,6 @@ namespace Utils {
class JsonSchemaManager;
}
-namespace TextEditor {
-class TextEditorActionHandler;
-} // namespace TextEditor
-
namespace Core {
class Command;
class ActionContainer;
@@ -92,8 +88,6 @@ public:
QmlJSQuickFixAssistProvider *quickFixAssistProvider() const;
- void initializeEditor(QmlJSTextEditorWidget *editor);
-
Utils::JsonSchemaManager *jsonManager() const;
public Q_SLOTS:
@@ -115,7 +109,6 @@ private:
QmlJS::ModelManagerInterface *m_modelManager;
QmlJSEditorFactory *m_editor;
- TextEditor::TextEditorActionHandler *m_actionHandler;
QmlJSQuickFixAssistProvider *m_quickFixAssistProvider;
QmlTaskManager *m_qmlTaskManager;
diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp
index 7dc4179aa2..f4162da0c7 100644
--- a/src/plugins/qmljseditor/qmljsfindreferences.cpp
+++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp
@@ -30,7 +30,7 @@
#include "qmljsfindreferences.h"
#include <texteditor/basefilefind.h>
-#include <find/searchresultwindow.h>
+#include <coreplugin/find/searchresultwindow.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/filesearch.h>
#include <coreplugin/progressmanager/progressmanager.h>
@@ -925,20 +925,20 @@ void FindReferences::displayResults(int first, int last)
const QString label = tr("QML/JS Usages:");
if (replacement.isEmpty()) {
- m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(
- label, QString(), symbolName, Find::SearchResultWindow::SearchOnly);
+ m_currentSearch = Core::SearchResultWindow::instance()->startNewSearch(
+ label, QString(), symbolName, Core::SearchResultWindow::SearchOnly);
} else {
- m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(
- label, QString(), symbolName, Find::SearchResultWindow::SearchAndReplace);
+ m_currentSearch = Core::SearchResultWindow::instance()->startNewSearch(
+ label, QString(), symbolName, Core::SearchResultWindow::SearchAndReplace);
m_currentSearch->setTextToReplace(replacement);
- connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)),
- SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)));
+ connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)),
+ SLOT(onReplaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)));
}
- connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)),
- this, SLOT(openEditor(Find::SearchResultItem)));
+ connect(m_currentSearch, SIGNAL(activated(Core::SearchResultItem)),
+ this, SLOT(openEditor(Core::SearchResultItem)));
connect(m_currentSearch, SIGNAL(cancelled()), this, SLOT(cancel()));
connect(m_currentSearch, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
- Find::SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch | IOutputPane::WithFocus));
+ Core::SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch | IOutputPane::WithFocus));
FutureProgress *progress = ProgressManager::addTask(
m_watcher.future(), tr("Searching"),
@@ -981,7 +981,7 @@ void FindReferences::setPaused(bool paused)
m_watcher.setPaused(paused);
}
-void FindReferences::openEditor(const Find::SearchResultItem &item)
+void FindReferences::openEditor(const Core::SearchResultItem &item)
{
if (item.path.size() > 0) {
EditorManager::openEditorAt(QDir::fromNativeSeparators(item.path.first()),
@@ -991,7 +991,7 @@ void FindReferences::openEditor(const Find::SearchResultItem &item)
}
}
-void FindReferences::onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items, bool preserveCase)
+void FindReferences::onReplaceButtonClicked(const QString &text, const QList<Core::SearchResultItem> &items, bool preserveCase)
{
const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items, preserveCase);
@@ -1011,5 +1011,5 @@ void FindReferences::onReplaceButtonClicked(const QString &text, const QList<Fin
if (!changedUnsavedEditors.isEmpty())
QmlJS::ModelManagerInterface::instance()->updateSourceFiles(changedUnsavedEditors, false);
- Find::SearchResultWindow::instance()->hide();
+ Core::SearchResultWindow::instance()->hide();
}
diff --git a/src/plugins/qmljseditor/qmljsfindreferences.h b/src/plugins/qmljseditor/qmljsfindreferences.h
index f4d3dc6c55..a9fcd38de9 100644
--- a/src/plugins/qmljseditor/qmljsfindreferences.h
+++ b/src/plugins/qmljseditor/qmljsfindreferences.h
@@ -40,10 +40,10 @@
QT_FORWARD_DECLARE_CLASS(QTimer)
-namespace Find {
+namespace Core {
class SearchResultItem;
class SearchResult;
-} // namespace Find
+} // namespace Core
namespace QmlJSEditor {
@@ -85,11 +85,11 @@ private Q_SLOTS:
void searchFinished();
void cancel();
void setPaused(bool paused);
- void openEditor(const Find::SearchResultItem &item);
- void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items, bool preserveCase);
+ void openEditor(const Core::SearchResultItem &item);
+ void onReplaceButtonClicked(const QString &text, const QList<Core::SearchResultItem> &items, bool preserveCase);
private:
- QPointer<Find::SearchResult> m_currentSearch;
+ QPointer<Core::SearchResult> m_currentSearch;
QFutureWatcher<Usage> m_watcher;
};
diff --git a/src/plugins/qmljseditor/qmljsquickfixassist.cpp b/src/plugins/qmljseditor/qmljsquickfixassist.cpp
index af91ea8ce4..1bccc67923 100644
--- a/src/plugins/qmljseditor/qmljsquickfixassist.cpp
+++ b/src/plugins/qmljseditor/qmljsquickfixassist.cpp
@@ -48,7 +48,7 @@ using namespace Internal;
QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSTextEditorWidget *editor,
TextEditor::AssistReason reason)
: DefaultAssistInterface(editor->document(), editor->position(),
- editor->editorDocument()->filePath(), reason)
+ editor->baseTextDocument()->filePath(), reason)
, m_editor(editor)
, m_semanticInfo(editor->semanticInfo())
, m_currentFile(QmlJSRefactoringChanges::file(m_editor, m_semanticInfo.document))
diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
index 89a9e8d4a5..439f186629 100644
--- a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
+++ b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp
@@ -568,7 +568,7 @@ void SemanticHighlighter::applyResults(int from, int to)
if (m_startRevision != m_editor->editorRevision())
return;
- TextEditor::BaseTextDocument *baseTextDocument = m_editor->baseTextDocument().data();
+ TextEditor::BaseTextDocument *baseTextDocument = m_editor->baseTextDocument();
QTC_ASSERT(baseTextDocument, return);
TextEditor::SyntaxHighlighter *highlighter = qobject_cast<TextEditor::SyntaxHighlighter *>(baseTextDocument->syntaxHighlighter());
QTC_ASSERT(highlighter, return);
@@ -584,7 +584,7 @@ void SemanticHighlighter::finished()
if (m_startRevision != m_editor->editorRevision())
return;
- TextEditor::BaseTextDocument *baseTextDocument = m_editor->baseTextDocument().data();
+ TextEditor::BaseTextDocument *baseTextDocument = m_editor->baseTextDocument();
QTC_ASSERT(baseTextDocument, return);
TextEditor::SyntaxHighlighter *highlighter = qobject_cast<TextEditor::SyntaxHighlighter *>(baseTextDocument->syntaxHighlighter());
QTC_ASSERT(highlighter, return);
diff --git a/src/plugins/qmljseditor/quicktoolbarsettingspage.cpp b/src/plugins/qmljseditor/quicktoolbarsettingspage.cpp
index aca9d03dff..c7804178d2 100644
--- a/src/plugins/qmljseditor/quicktoolbarsettingspage.cpp
+++ b/src/plugins/qmljseditor/quicktoolbarsettingspage.cpp
@@ -101,16 +101,6 @@ void QuickToolBarSettingsPageWidget::setSettings(const QuickToolBarSettings &s)
m_ui.textEditHelperCheckBoxPin->setChecked(s.pinContextPane);
}
-QString QuickToolBarSettingsPageWidget::searchKeywords() const
-{
- QString rc;
- QTextStream(&rc)
- << ' ' << m_ui.textEditHelperCheckBox->text()
- << ' ' << m_ui.textEditHelperCheckBoxPin->text();
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
QuickToolBarSettings QuickToolBarSettings::get()
{
QuickToolBarSettings settings;
@@ -129,12 +119,12 @@ QuickToolBarSettingsPage::QuickToolBarSettingsPage() :
setCategoryIcon(QLatin1String(QmlDesigner::Constants::SETTINGS_CATEGORY_QML_ICON));
}
-QWidget *QuickToolBarSettingsPage::createPage(QWidget *parent)
+QWidget *QuickToolBarSettingsPage::widget()
{
- m_widget = new QuickToolBarSettingsPageWidget(parent);
- m_widget->setSettings(QuickToolBarSettings::get());
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new QuickToolBarSettingsPageWidget;
+ m_widget->setSettings(QuickToolBarSettings::get());
+ }
return m_widget;
}
@@ -145,7 +135,7 @@ void QuickToolBarSettingsPage::apply()
m_widget->settings().set();
}
-bool QuickToolBarSettingsPage::matches(const QString &s) const
+void QuickToolBarSettingsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
diff --git a/src/plugins/qmljseditor/quicktoolbarsettingspage.h b/src/plugins/qmljseditor/quicktoolbarsettingspage.h
index f9964629f4..896cda2e13 100644
--- a/src/plugins/qmljseditor/quicktoolbarsettingspage.h
+++ b/src/plugins/qmljseditor/quicktoolbarsettingspage.h
@@ -33,6 +33,7 @@
#include "ui_quicktoolbarsettingspage.h"
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
#include <QWidget>
QT_BEGIN_NAMESPACE
@@ -76,7 +77,6 @@ public:
QuickToolBarSettings settings() const;
void setSettings(const QuickToolBarSettings &);
- QString searchKeywords() const;
static QuickToolBarSettings get();
private:
@@ -91,14 +91,12 @@ class QuickToolBarSettingsPage : public Core::IOptionsPage
public:
QuickToolBarSettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &) const;
+ void finish();
private:
- QString m_searchKeywords;
- QuickToolBarSettingsPageWidget* m_widget;
+ QPointer<QuickToolBarSettingsPageWidget> m_widget;
};
} // namespace Internal
diff --git a/src/plugins/qmljstools/qmlconsolepane.cpp b/src/plugins/qmljstools/qmlconsolepane.cpp
index c55ecdfd31..6f5c0f26d2 100644
--- a/src/plugins/qmljstools/qmlconsolepane.cpp
+++ b/src/plugins/qmljstools/qmlconsolepane.cpp
@@ -36,7 +36,7 @@
#include <coreplugin/findplaceholder.h>
#include <utils/savedaction.h>
#include <aggregation/aggregate.h>
-#include <find/treeviewfind.h>
+#include <coreplugin/find/treeviewfind.h>
#include <QToolButton>
#include <QLabel>
@@ -95,7 +95,7 @@ QmlConsolePane::QmlConsolePane(QObject *parent)
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate();
aggregate->add(m_consoleView);
- aggregate->add(new Find::TreeViewFind(m_consoleView));
+ aggregate->add(new Core::TreeViewFind(m_consoleView));
vbox->addWidget(m_consoleView);
vbox->addWidget(new Core::FindToolBarPlaceHolder(m_consoleWidget));
diff --git a/src/plugins/qmljstools/qmljscodestylesettingspage.cpp b/src/plugins/qmljstools/qmljscodestylesettingspage.cpp
index 82d8664717..a6ff258beb 100644
--- a/src/plugins/qmljstools/qmljscodestylesettingspage.cpp
+++ b/src/plugins/qmljstools/qmljscodestylesettingspage.cpp
@@ -95,17 +95,6 @@ void QmlJSCodeStylePreferencesWidget::setPreferences(TextEditor::ICodeStylePrefe
}
-QString QmlJSCodeStylePreferencesWidget::searchKeywords() const
-{
- QString rc;
- QLatin1Char sep(' ');
- QTextStream(&rc)
- << sep << m_ui->tabPreferencesWidget->searchKeywords()
- ;
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
void QmlJSCodeStylePreferencesWidget::decorateEditor(const TextEditor::FontSettings &fontSettings)
{
const ISnippetProvider *provider = 0;
@@ -171,18 +160,19 @@ QmlJSCodeStyleSettingsPage::QmlJSCodeStyleSettingsPage(/*QSharedPointer<CppFileS
setCategoryIcon(QLatin1String(QmlDesigner::Constants::SETTINGS_CATEGORY_QML_ICON));
}
-QWidget *QmlJSCodeStyleSettingsPage::createPage(QWidget *parent)
+QWidget *QmlJSCodeStyleSettingsPage::widget()
{
- TextEditor::SimpleCodeStylePreferences *originalTabPreferences
- = QmlJSToolsSettings::globalCodeStyle();
- m_pageTabPreferences = new TextEditor::SimpleCodeStylePreferences(m_widget);
- m_pageTabPreferences->setDelegatingPool(originalTabPreferences->delegatingPool());
- m_pageTabPreferences->setTabSettings(originalTabPreferences->tabSettings());
- m_pageTabPreferences->setCurrentDelegate(originalTabPreferences->currentDelegate());
- m_pageTabPreferences->setId(originalTabPreferences->id());
- m_widget = new CodeStyleEditor(TextEditorSettings::codeStyleFactory(QmlJSTools::Constants::QML_JS_SETTINGS_ID),
- m_pageTabPreferences, parent);
-
+ if (!m_widget) {
+ TextEditor::SimpleCodeStylePreferences *originalTabPreferences
+ = QmlJSToolsSettings::globalCodeStyle();
+ m_pageTabPreferences = new TextEditor::SimpleCodeStylePreferences(m_widget);
+ m_pageTabPreferences->setDelegatingPool(originalTabPreferences->delegatingPool());
+ m_pageTabPreferences->setTabSettings(originalTabPreferences->tabSettings());
+ m_pageTabPreferences->setCurrentDelegate(originalTabPreferences->currentDelegate());
+ m_pageTabPreferences->setId(originalTabPreferences->id());
+ m_widget = new CodeStyleEditor(TextEditorSettings::codeStyleFactory(QmlJSTools::Constants::QML_JS_SETTINGS_ID),
+ m_pageTabPreferences);
+ }
return m_widget;
}
@@ -203,9 +193,9 @@ void QmlJSCodeStyleSettingsPage::apply()
}
}
-bool QmlJSCodeStyleSettingsPage::matches(const QString &s) const
+void QmlJSCodeStyleSettingsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/qmljstools/qmljscodestylesettingspage.h b/src/plugins/qmljstools/qmljscodestylesettingspage.h
index ddb05033d1..cf6782f50b 100644
--- a/src/plugins/qmljstools/qmljscodestylesettingspage.h
+++ b/src/plugins/qmljstools/qmljscodestylesettingspage.h
@@ -61,7 +61,6 @@ public:
~QmlJSCodeStylePreferencesWidget();
void setPreferences(TextEditor::ICodeStylePreferences *preferences);
- QString searchKeywords() const;
private slots:
void decorateEditor(const TextEditor::FontSettings &fontSettings);
@@ -82,13 +81,11 @@ class QmlJSCodeStyleSettingsPage : public Core::IOptionsPage
public:
explicit QmlJSCodeStyleSettingsPage(QWidget *parent = 0);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &) const;
+ void finish();
private:
- QString m_searchKeywords;
TextEditor::ICodeStylePreferences *m_pageTabPreferences;
QPointer<TextEditor::CodeStyleEditor> m_widget;
};
diff --git a/src/plugins/qmljstools/qmljsfunctionfilter.cpp b/src/plugins/qmljstools/qmljsfunctionfilter.cpp
index 9da8cc3c68..32e709b562 100644
--- a/src/plugins/qmljstools/qmljsfunctionfilter.cpp
+++ b/src/plugins/qmljstools/qmljsfunctionfilter.cpp
@@ -39,7 +39,7 @@ using namespace QmlJSTools::Internal;
Q_DECLARE_METATYPE(LocatorData::Entry)
FunctionFilter::FunctionFilter(LocatorData *data, QObject *parent)
- : Locator::ILocatorFilter(parent)
+ : Core::ILocatorFilter(parent)
, m_data(data)
{
setId("Functions");
@@ -55,17 +55,17 @@ void FunctionFilter::refresh(QFutureInterface<void> &)
{
}
-static bool compareLexigraphically(const Locator::FilterEntry &a,
- const Locator::FilterEntry &b)
+static bool compareLexigraphically(const Core::LocatorFilterEntry &a,
+ const Core::LocatorFilterEntry &b)
{
return a.displayName < b.displayName;
}
-QList<Locator::FilterEntry> FunctionFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &origEntry)
+QList<Core::LocatorFilterEntry> FunctionFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &origEntry)
{
QString entry = trimWildcards(origEntry);
- QList<Locator::FilterEntry> goodEntries;
- QList<Locator::FilterEntry> betterEntries;
+ QList<Core::LocatorFilterEntry> goodEntries;
+ QList<Core::LocatorFilterEntry> betterEntries;
const QChar asterisk = QLatin1Char('*');
QStringMatcher matcher(entry, Qt::CaseInsensitive);
QRegExp regexp(asterisk + entry+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
@@ -89,7 +89,7 @@ QList<Locator::FilterEntry> FunctionFilter::matchesFor(QFutureInterface<Locator:
|| (!hasWildcard && matcher.indexIn(info.symbolName) != -1)) {
QVariant id = qVariantFromValue(info);
- Locator::FilterEntry filterEntry(this, info.displayName, id/*, info.icon*/);
+ Core::LocatorFilterEntry filterEntry(this, info.displayName, id/*, info.icon*/);
filterEntry.extraInfo = info.extraInfo;
if (info.symbolName.startsWith(entry, caseSensitivityForPrefix))
@@ -109,7 +109,7 @@ QList<Locator::FilterEntry> FunctionFilter::matchesFor(QFutureInterface<Locator:
return betterEntries;
}
-void FunctionFilter::accept(Locator::FilterEntry selection) const
+void FunctionFilter::accept(Core::LocatorFilterEntry selection) const
{
const LocatorData::Entry entry = qvariant_cast<LocatorData::Entry>(selection.internalData);
Core::EditorManager::openEditorAt(entry.fileName, entry.line, entry.column);
diff --git a/src/plugins/qmljstools/qmljsfunctionfilter.h b/src/plugins/qmljstools/qmljsfunctionfilter.h
index ee7d468c1d..5728a46c6c 100644
--- a/src/plugins/qmljstools/qmljsfunctionfilter.h
+++ b/src/plugins/qmljstools/qmljsfunctionfilter.h
@@ -30,14 +30,14 @@
#ifndef QMLJSFUNCTIONFILTER_H
#define QMLJSFUNCTIONFILTER_H
-#include <locator/ilocatorfilter.h>
+#include <coreplugin/locator/ilocatorfilter.h>
namespace QmlJSTools {
namespace Internal {
class LocatorData;
-class FunctionFilter : public Locator::ILocatorFilter
+class FunctionFilter : public Core::ILocatorFilter
{
Q_OBJECT
@@ -45,8 +45,8 @@ public:
explicit FunctionFilter(LocatorData *data, QObject *parent = 0);
~FunctionFilter();
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
private:
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index 6c4a3a34a3..4342d9b126 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -329,7 +329,7 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopy() const
if (TextEditor::BaseTextDocument *textDocument = qobject_cast<TextEditor::BaseTextDocument *>(document)) {
// TODO the language should be a property on the document, not the editor
if (documentModel->editorsForDocument(document).first()->context().contains(ProjectExplorer::Constants::LANG_QMLJS))
- workingCopy.insert(key, textDocument->contents(), textDocument->document()->revision());
+ workingCopy.insert(key, textDocument->plainText(), textDocument->document()->revision());
}
}
diff --git a/src/plugins/qmljstools/qmljstools.qbs b/src/plugins/qmljstools/qmljstools.qbs
index 629cef4a15..ffbd062432 100644
--- a/src/plugins/qmljstools/qmljstools.qbs
+++ b/src/plugins/qmljstools/qmljstools.qbs
@@ -12,7 +12,6 @@ QtcPlugin {
Depends { name: "QmlJS" }
Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" }
- Depends { name: "Locator" }
Depends { name: "QmlDebug" }
Depends { name: "QtSupport" }
diff --git a/src/plugins/qmljstools/qmljstools_dependencies.pri b/src/plugins/qmljstools/qmljstools_dependencies.pri
index 2dd8e9b1c6..198ce543ed 100644
--- a/src/plugins/qmljstools/qmljstools_dependencies.pri
+++ b/src/plugins/qmljstools/qmljstools_dependencies.pri
@@ -5,8 +5,6 @@ QTC_LIB_DEPENDS += \
qmljs
QTC_PLUGIN_DEPENDS += \
coreplugin \
- find \
- locator \
projectexplorer \
qtsupport \
texteditor \
diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel.cpp b/src/plugins/qmlprofiler/abstracttimelinemodel.cpp
index 99d555efef..a4823b3582 100644
--- a/src/plugins/qmlprofiler/abstracttimelinemodel.cpp
+++ b/src/plugins/qmlprofiler/abstracttimelinemodel.cpp
@@ -41,7 +41,6 @@ void AbstractTimelineModel::setModelManager(QmlProfilerModelManager *modelManage
{
m_modelManager = modelManager;
connect(modelManager->simpleModel(),SIGNAL(changed()),this,SLOT(dataChanged()));
- connect(modelManager,SIGNAL(stateChanged()),this,SLOT(dataChanged()));
m_modelId = modelManager->registerModelProxy();
}
@@ -79,5 +78,24 @@ int AbstractTimelineModel::getBindingLoopDest(int index) const
return -1;
}
+void AbstractTimelineModel::dataChanged()
+{
+ switch (m_modelManager->state()) {
+ case QmlProfilerDataState::Done:
+ loadData();
+ break;
+ case QmlProfilerDataState::ClearingData:
+ clear();
+ break;
+ default:
+ break;
+ }
+
+ emit stateChanged();
+ emit dataAvailable();
+ emit emptyChanged();
+ emit expandedChanged();
+}
+
}
diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel.h b/src/plugins/qmlprofiler/abstracttimelinemodel.h
index a139669b12..a5bff2eefe 100644
--- a/src/plugins/qmlprofiler/abstracttimelinemodel.h
+++ b/src/plugins/qmlprofiler/abstracttimelinemodel.h
@@ -79,6 +79,10 @@ public:
virtual int getEventType(int index) const = 0;
virtual int getEventCategory(int index) const = 0;
virtual int getEventRow(int index) const = 0;
+
+ virtual void loadData() = 0;
+ virtual void clear() = 0;
+
Q_INVOKABLE virtual qint64 getDuration(int index) const = 0;
Q_INVOKABLE virtual qint64 getStartTime(int index) const = 0;
Q_INVOKABLE virtual qint64 getEndTime(int index) const = 0;
@@ -106,6 +110,9 @@ signals:
protected:
QmlProfilerModelManager *m_modelManager;
int m_modelId;
+
+protected slots:
+ void dataChanged();
};
}
diff --git a/src/plugins/qmlprofiler/canvas/canvas.pri b/src/plugins/qmlprofiler/canvas/canvas.pri
deleted file mode 100644
index 2960e94527..0000000000
--- a/src/plugins/qmlprofiler/canvas/canvas.pri
+++ /dev/null
@@ -1,9 +0,0 @@
-HEADERS += $$PWD/qdeclarativecontext2d_p.h \
- $$PWD/qdeclarativecanvas_p.h \
- $$PWD/qmlprofilercanvas.h \
- $$PWD/qdeclarativecanvastimer_p.h
-
-SOURCES += $$PWD/qdeclarativecontext2d.cpp \
- $$PWD/qdeclarativecanvas.cpp \
- $$PWD/qmlprofilercanvas.cpp \
- $$PWD/qdeclarativecanvastimer.cpp
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecanvas.cpp b/src/plugins/qmlprofiler/canvas/qdeclarativecanvas.cpp
deleted file mode 100644
index bb68bdeb4f..0000000000
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecanvas.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "qdeclarativecanvas_p.h"
-#include "qdeclarativecanvastimer_p.h"
-#include "qdeclarativecontext2d_p.h"
-
-#include <qpainter.h>
-
-QT_BEGIN_NAMESPACE
-
-Canvas::Canvas(QQuickPaintedItem *parent)
- : QQuickPaintedItem(parent),
- m_context(new Context2D(this)),
- m_canvasWidth(0),
- m_canvasHeight(0),
- m_fillMode(Canvas::Stretch),
- m_color(Qt::white)
-{
-}
-
-
-void Canvas::componentComplete()
-{
- if (m_canvasWidth == 0 && m_canvasHeight == 0)
- m_context->setSize(width(), height());
- else
- m_context->setSize(m_canvasWidth, m_canvasHeight);
-
- connect(m_context, SIGNAL(changed()), this, SLOT(requestPaint()));
- emit init();
- QQuickItem::componentComplete();
-}
-
-void Canvas::paint(QPainter *painter)
-{
- m_context->setInPaint(true);
- emit paint();
-
- bool oldAA = painter->testRenderHint(QPainter::Antialiasing);
- bool oldSmooth = painter->testRenderHint(QPainter::SmoothPixmapTransform);
- if (smooth())
- painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, smooth());
-
- if (m_context->pixmap().isNull()) {
- painter->fillRect(0, 0, width(), height(), m_color);
- } else if (width() != m_context->pixmap().width() || height() != m_context->pixmap().height()) {
- if (m_fillMode>= Tile) {
- if (m_fillMode== Tile) {
- painter->drawTiledPixmap(QRectF(0,0,width(),height()), m_context->pixmap());
- } else {
- qreal widthScale = width() / qreal(m_context->pixmap().width());
- qreal heightScale = height() / qreal(m_context->pixmap().height());
-
- QTransform scale;
- if (m_fillMode== TileVertically) {
- scale.scale(widthScale, 1.0);
- QTransform old = painter->transform();
- painter->setWorldTransform(scale * old);
- painter->drawTiledPixmap(QRectF(0,0,m_context->pixmap().width(),height()), m_context->pixmap());
- painter->setWorldTransform(old);
- } else {
- scale.scale(1.0, heightScale);
- QTransform old = painter->transform();
- painter->setWorldTransform(scale * old);
- painter->drawTiledPixmap(QRectF(0,0,width(),m_context->pixmap().height()), m_context->pixmap());
- painter->setWorldTransform(old);
- }
- }
- } else {
- qreal widthScale = width() / qreal(m_context->pixmap().width());
- qreal heightScale = height() / qreal(m_context->pixmap().height());
-
- QTransform scale;
-
- if (m_fillMode== PreserveAspectFit) {
- if (widthScale <= heightScale) {
- heightScale = widthScale;
- scale.translate(0, (height() - heightScale * m_context->pixmap().height()) / 2);
- } else if (heightScale < widthScale) {
- widthScale = heightScale;
- scale.translate((width() - widthScale * m_context->pixmap().width()) / 2, 0);
- }
- } else if (m_fillMode== PreserveAspectCrop) {
- if (widthScale < heightScale) {
- widthScale = heightScale;
- scale.translate((width() - widthScale * m_context->pixmap().width()) / 2, 0);
- } else if (heightScale < widthScale) {
- heightScale = widthScale;
- scale.translate(0, (height() - heightScale * m_context->pixmap().height()) / 2);
- }
- }
- if (clip()) {
- painter->save();
- painter->setClipRect(boundingRect(), Qt::IntersectClip);
- }
- scale.scale(widthScale, heightScale);
- QTransform old = painter->transform();
- painter->setWorldTransform(scale * old);
- painter->drawPixmap(0, 0, m_context->pixmap());
- painter->setWorldTransform(old);
- if (clip())
- painter->restore();
- }
- } else {
- painter->drawPixmap(0, 0, m_context->pixmap());
- }
-
- if (smooth()) {
- painter->setRenderHint(QPainter::Antialiasing, oldAA);
- painter->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
- }
- m_context->setInPaint(false);
-}
-
-Context2D *Canvas::getContext(const QString &contextId)
-{
- if (contextId == QLatin1String("2d"))
- return m_context;
- qDebug("Canvas:requesting unsupported context");
- return 0;
-}
-
-void Canvas::requestPaint()
-{
- update();
-}
-
-void Canvas::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- if (m_canvasWidth == 0 && m_canvasHeight == 0
- && newGeometry.width() > 0 && newGeometry.height() > 0) {
- m_context->setSize(width(), height());
- }
- QQuickItem::geometryChanged(newGeometry, oldGeometry);
-}
-
-void Canvas::setCanvasWidth(int newWidth)
-{
- if (m_canvasWidth != newWidth) {
- m_canvasWidth = newWidth;
- m_context->setSize(m_canvasWidth, m_canvasHeight);
- emit canvasWidthChanged();
- }
-}
-
-void Canvas::setCanvasHeight(int newHeight)
-{
- if (m_canvasHeight != newHeight) {
- m_canvasHeight = newHeight;
- m_context->setSize(m_canvasWidth, m_canvasHeight);
- emit canvasHeightChanged();
- }
-}
-
-void Canvas::setFillMode(FillMode mode)
-{
- if (m_fillMode == mode)
- return;
-
- m_fillMode = mode;
- update();
- emit fillModeChanged();
-}
-
-QColor Canvas::color()
-{
- return m_color;
-}
-
-void Canvas::setColor(const QColor &color)
-{
- if (m_color !=color) {
- m_color = color;
- colorChanged();
- }
-}
-
-Canvas::FillMode Canvas::fillMode() const
-{
- return m_fillMode;
-}
-
-bool Canvas::save(const QString &filename) const
-{
- return m_context->pixmap().save(filename);
-}
-
-CanvasImage *Canvas::toImage() const
-{
- return new CanvasImage(m_context->pixmap());
-}
-
-void Canvas::setTimeout(const QJSValue &handler, long timeout)
-{
- if (handler.isCallable())
- CanvasTimer::createTimer(this, handler, timeout, true);
-}
-
-void Canvas::setInterval(const QJSValue &handler, long interval)
-{
- if (handler.isCallable())
- CanvasTimer::createTimer(this, handler, interval, false);
-}
-
-void Canvas::clearTimeout(const QJSValue &handler)
-{
- CanvasTimer::removeTimer(handler);
-}
-
-void Canvas::clearInterval(const QJSValue &handler)
-{
- CanvasTimer::removeTimer(handler);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecanvas_p.h b/src/plugins/qmlprofiler/canvas/qdeclarativecanvas_p.h
deleted file mode 100644
index bf1af2431d..0000000000
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecanvas_p.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECANVAS_P_H
-#define QDECLARATIVECANVAS_P_H
-
-#include <QQuickPaintedItem>
-
-#include "qdeclarativecontext2d_p.h"
-#include "qdeclarativecanvastimer_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class Canvas : public QQuickPaintedItem
-{
- Q_OBJECT
-
- Q_ENUMS(FillMode)
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged);
- Q_PROPERTY(int canvasWidth READ canvasWidth WRITE setCanvasWidth NOTIFY canvasWidthChanged);
- Q_PROPERTY(int canvasHeight READ canvasHeight WRITE setCanvasHeight NOTIFY canvasHeightChanged);
- Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
-
-public:
- Canvas(QQuickPaintedItem *parent = 0);
- enum FillMode { Stretch, PreserveAspectFit, PreserveAspectCrop, Tile, TileVertically, TileHorizontally };
-
-
- void paint(QPainter *);
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
- void setCanvasWidth(int newWidth);
- int canvasWidth() {return m_canvasWidth;}
-
- void setCanvasHeight(int canvasHeight);
- int canvasHeight() {return m_canvasHeight;}
-
- void componentComplete();
-
-
-public Q_SLOTS:
- Context2D *getContext(const QString & = QLatin1String("2d"));
- void requestPaint();
-
- FillMode fillMode() const;
- void setFillMode(FillMode);
-
- QColor color();
- void setColor(const QColor &);
-
- // Save current canvas to disk
- bool save(const QString& filename) const;
-
- // Timers
- void setInterval(const QJSValue &handler, long timeout);
- void setTimeout(const QJSValue &handler, long timeout);
- void clearInterval(const QJSValue &handler);
- void clearTimeout(const QJSValue &handler);
-
-Q_SIGNALS:
- void fillModeChanged();
- void canvasWidthChanged();
- void canvasHeightChanged();
- void colorChanged();
- void init();
- void paint();
-
-private:
- // Return canvas contents as a drawable image
- CanvasImage *toImage() const;
- Context2D *m_context;
- int m_canvasWidth;
- int m_canvasHeight;
- FillMode m_fillMode;
- QColor m_color;
-
- friend class Context2D;
-};
-
-QT_END_NAMESPACE
-
-#endif //QDECLARATIVECANVAS_P_H
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer.cpp b/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer.cpp
deleted file mode 100644
index 33d94d8e54..0000000000
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "qdeclarativecanvastimer_p.h"
-
-#include <QJSEngine>
-#include <QJSValue>
-#include <qtimer.h>
-
-QT_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QList<CanvasTimer*> , activeTimers);
-
-CanvasTimer::CanvasTimer(QObject *parent, const QJSValue &data)
- : QTimer(parent), m_value(data)
-{
-}
-
-void CanvasTimer::handleTimeout()
-{
- Q_ASSERT(m_value.isCallable());
- m_value.call();
- if (isSingleShot())
- removeTimer(this);
-}
-
-void CanvasTimer::createTimer(QObject *parent, const QJSValue &val, long timeout, bool singleshot)
-{
-
- CanvasTimer *timer = new CanvasTimer(parent, val);
- timer->setInterval(timeout);
- timer->setSingleShot(singleshot);
- connect(timer, SIGNAL(timeout()), timer, SLOT(handleTimeout()));
- activeTimers()->append(timer);
- timer->start();
-}
-
-void CanvasTimer::removeTimer(CanvasTimer *timer)
-{
- activeTimers()->removeAll(timer);
- timer->deleteLater();
-}
-
-void CanvasTimer::removeTimer(const QJSValue &val)
-{
- if (!val.isCallable())
- return;
-
- for (int i = 0 ; i < activeTimers()->count() ; ++i) {
- CanvasTimer *timer = activeTimers()->at(i);
- if (timer->equals(val)) {
- removeTimer(timer);
- return;
- }
- }
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp b/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp
deleted file mode 100644
index b56037f7ac..0000000000
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp
+++ /dev/null
@@ -1,1134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "qdeclarativecontext2d_p.h"
-
-#include "qdeclarativecanvas_p.h"
-
-#include <qdebug.h>
-#include <math.h>
-
-#include <qgraphicsitem.h>
-#include <qapplication.h>
-#include <qgraphicseffect.h>
-
-#include <QImage>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-
-static const double Q_PI = 3.14159265358979323846; // pi
-
-class CustomDropShadowEffect : public QGraphicsDropShadowEffect
-{
-public:
- void draw(QPainter *painter) { QGraphicsDropShadowEffect::draw(painter);}
- void drawSource(QPainter *painter) { QGraphicsDropShadowEffect::drawSource(painter);}
-};
-
-// Note, this is exported but in a private header as qtopengl depends on it.
-// But it really should be considered private API
-void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
-void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0);
-
-#define DEGREES(t) ((t) * 180.0 / Q_PI)
-
-#define qClamp(val, min, max) qMin(qMax(val, min), max)
-static QList<qreal> parseNumbersList(QString::const_iterator &itr)
-{
- QList<qreal> points;
- QString temp;
- while ((*itr).isSpace())
- ++itr;
- while ((*itr).isNumber() ||
- (*itr) == QLatin1Char('-') || (*itr) == QLatin1Char('+') || (*itr) == QLatin1Char('.')) {
- temp.clear();
-
- if ((*itr) == QLatin1Char('-'))
- temp += *itr++;
- else if ((*itr) == QLatin1Char('+'))
- temp += *itr++;
- while ((*itr).isDigit())
- temp += *itr++;
- if ((*itr) == QLatin1Char('.'))
- temp += *itr++;
- while ((*itr).isDigit())
- temp += *itr++;
- while ((*itr).isSpace())
- ++itr;
- if ((*itr) == QLatin1Char(','))
- ++itr;
- points.append(temp.toDouble());
- //eat spaces
- while ((*itr).isSpace())
- ++itr;
- }
-
- return points;
-}
-
-QColor colorFromString(const QString &name)
-{
- QString::const_iterator itr = name.constBegin();
- QList<qreal> compo;
- if (name.startsWith(QLatin1String("rgba("))) {
- ++itr; ++itr; ++itr; ++itr; ++itr;
- compo = parseNumbersList(itr);
- if (compo.size() != 4)
- return QColor();
- //alpha seems to be always between 0-1
- compo[3] *= 255;
- return QColor((int)compo[0], (int)compo[1],
- (int)compo[2], (int)compo[3]);
- } else if (name.startsWith(QLatin1String("rgb("))) {
- ++itr; ++itr; ++itr; ++itr;
- compo = parseNumbersList(itr);
- if (compo.size() != 3)
- return QColor();
- return QColor((int)qClamp(compo[0], qreal(0), qreal(255)),
- (int)qClamp(compo[1], qreal(0), qreal(255)),
- (int)qClamp(compo[2], qreal(0), qreal(255)));
- } else if (name.startsWith(QLatin1String("hsla("))) {
- ++itr; ++itr; ++itr; ++itr; ++itr;
- compo = parseNumbersList(itr);
- if (compo.size() != 4)
- return QColor();
- return QColor::fromHslF(compo[0], compo[1],
- compo[2], compo[3]);
- } else if (name.startsWith(QLatin1String("hsl("))) {
- ++itr; ++itr; ++itr; ++itr; ++itr;
- compo = parseNumbersList(itr);
- if (compo.size() != 3)
- return QColor();
- return QColor::fromHslF(compo[0], compo[1],
- compo[2]);
- } else {
- //QRgb color;
- //CSSParser::parseColor(name, color);
- return QColor(name);
- }
-}
-
-
-static QPainter::CompositionMode compositeOperatorFromString(const QString &compositeOperator)
-{
- if (compositeOperator == QLatin1String("source-over"))
- return QPainter::CompositionMode_SourceOver;
- else if (compositeOperator == QLatin1String("source-out"))
- return QPainter::CompositionMode_SourceOut;
- else if (compositeOperator == QLatin1String("source-in"))
- return QPainter::CompositionMode_SourceIn;
- else if (compositeOperator == QLatin1String("source-atop"))
- return QPainter::CompositionMode_SourceAtop;
- else if (compositeOperator == QLatin1String("destination-atop"))
- return QPainter::CompositionMode_DestinationAtop;
- else if (compositeOperator == QLatin1String("destination-in"))
- return QPainter::CompositionMode_DestinationIn;
- else if (compositeOperator == QLatin1String("destination-out"))
- return QPainter::CompositionMode_DestinationOut;
- else if (compositeOperator == QLatin1String("destination-over"))
- return QPainter::CompositionMode_DestinationOver;
- else if (compositeOperator == QLatin1String("darker"))
- return QPainter::CompositionMode_SourceOver;
- else if (compositeOperator == QLatin1String("lighter"))
- return QPainter::CompositionMode_SourceOver;
- else if (compositeOperator == QLatin1String("copy"))
- return QPainter::CompositionMode_Source;
- else if (compositeOperator == QLatin1String("xor"))
- return QPainter::CompositionMode_Xor;
-
- return QPainter::CompositionMode_SourceOver;
-}
-
-static QString compositeOperatorToString(QPainter::CompositionMode op)
-{
- switch (op) {
- case QPainter::CompositionMode_SourceOver:
- return QLatin1String("source-over");
- case QPainter::CompositionMode_DestinationOver:
- return QLatin1String("destination-over");
- case QPainter::CompositionMode_Clear:
- return QLatin1String("clear");
- case QPainter::CompositionMode_Source:
- return QLatin1String("source");
- case QPainter::CompositionMode_Destination:
- return QLatin1String("destination");
- case QPainter::CompositionMode_SourceIn:
- return QLatin1String("source-in");
- case QPainter::CompositionMode_DestinationIn:
- return QLatin1String("destination-in");
- case QPainter::CompositionMode_SourceOut:
- return QLatin1String("source-out");
- case QPainter::CompositionMode_DestinationOut:
- return QLatin1String("destination-out");
- case QPainter::CompositionMode_SourceAtop:
- return QLatin1String("source-atop");
- case QPainter::CompositionMode_DestinationAtop:
- return QLatin1String("destination-atop");
- case QPainter::CompositionMode_Xor:
- return QLatin1String("xor");
- case QPainter::CompositionMode_Plus:
- return QLatin1String("plus");
- case QPainter::CompositionMode_Multiply:
- return QLatin1String("multiply");
- case QPainter::CompositionMode_Screen:
- return QLatin1String("screen");
- case QPainter::CompositionMode_Overlay:
- return QLatin1String("overlay");
- case QPainter::CompositionMode_Darken:
- return QLatin1String("darken");
- case QPainter::CompositionMode_Lighten:
- return QLatin1String("lighten");
- case QPainter::CompositionMode_ColorDodge:
- return QLatin1String("color-dodge");
- case QPainter::CompositionMode_ColorBurn:
- return QLatin1String("color-burn");
- case QPainter::CompositionMode_HardLight:
- return QLatin1String("hard-light");
- case QPainter::CompositionMode_SoftLight:
- return QLatin1String("soft-light");
- case QPainter::CompositionMode_Difference:
- return QLatin1String("difference");
- case QPainter::CompositionMode_Exclusion:
- return QLatin1String("exclusion");
- default:
- break;
- }
- return QString();
-}
-
-void Context2D::save()
-{
- m_stateStack.push(m_state);
-}
-
-
-void Context2D::restore()
-{
- if (!m_stateStack.isEmpty()) {
- m_state = m_stateStack.pop();
- m_state.flags = AllIsFullOfDirt;
- }
-}
-
-
-void Context2D::scale(qreal x, qreal y)
-{
- m_state.matrix.scale(x, y);
- m_state.flags |= DirtyTransformationMatrix;
-}
-
-
-void Context2D::rotate(qreal angle)
-{
- m_state.matrix.rotate(DEGREES(angle));
- m_state.flags |= DirtyTransformationMatrix;
-}
-
-
-void Context2D::translate(qreal x, qreal y)
-{
- m_state.matrix.translate(x, y);
- m_state.flags |= DirtyTransformationMatrix;
-}
-
-
-void Context2D::transform(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy)
-{
- QMatrix mat(m11, m12,
- m21, m22,
- dx, dy);
- m_state.matrix *= mat;
- m_state.flags |= DirtyTransformationMatrix;
-}
-
-
-void Context2D::setTransform(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy)
-{
- QMatrix mat(m11, m12,
- m21, m22,
- dx, dy);
- m_state.matrix = mat;
- m_state.flags |= DirtyTransformationMatrix;
-}
-
-
-QString Context2D::globalCompositeOperation() const
-{
- return compositeOperatorToString(m_state.globalCompositeOperation);
-}
-
-void Context2D::setGlobalCompositeOperation(const QString &op)
-{
- QPainter::CompositionMode mode =
- compositeOperatorFromString(op);
- m_state.globalCompositeOperation = mode;
- m_state.flags |= DirtyGlobalCompositeOperation;
-}
-
-QVariant Context2D::strokeStyle() const
-{
- return m_state.strokeStyle;
-}
-
-void Context2D::setStrokeStyle(const QVariant &style)
-{
- CanvasGradient * gradient= qobject_cast<CanvasGradient*>(style.value<QObject*>());
- if (gradient) {
- m_state.strokeStyle = gradient->value();
- } else {
- QColor color = colorFromString(style.toString());
- m_state.strokeStyle = color;
- }
- m_state.flags |= DirtyStrokeStyle;
-}
-
-QVariant Context2D::fillStyle() const
-{
- return m_state.fillStyle;
-}
-
-void Context2D::setFillStyle(const QVariant &style)
-{
- CanvasGradient * gradient= qobject_cast<CanvasGradient*>(style.value<QObject*>());
- if (gradient) {
- m_state.fillStyle = gradient->value();
- } else {
- QColor color = colorFromString(style.toString());
- m_state.fillStyle = color;
- }
- m_state.flags |= DirtyFillStyle;
-}
-
-qreal Context2D::globalAlpha() const
-{
- return m_state.globalAlpha;
-}
-
-void Context2D::setGlobalAlpha(qreal alpha)
-{
- m_state.globalAlpha = alpha;
- m_state.flags |= DirtyGlobalAlpha;
-}
-
-CanvasImage *Context2D::createImage(const QString &url)
-{
- return new CanvasImage(url);
-}
-
-CanvasGradient *Context2D::createLinearGradient(qreal x0, qreal y0,
- qreal x1, qreal y1)
-{
- QLinearGradient g(x0, y0, x1, y1);
- return new CanvasGradient(g);
-}
-
-
-CanvasGradient *Context2D::createRadialGradient(qreal x0, qreal y0,
- qreal r0, qreal x1,
- qreal y1, qreal r1)
-{
- QRadialGradient g(QPointF(x1, y1), r0+r1, QPointF(x0, y0));
- return new CanvasGradient(g);
-}
-
-qreal Context2D::lineWidth() const
-{
- return m_state.lineWidth;
-}
-
-void Context2D::setLineWidth(qreal w)
-{
- m_state.lineWidth = w;
- m_state.flags |= DirtyLineWidth;
-}
-
-QString Context2D::lineCap() const
-{
- switch (m_state.lineCap) {
- case Qt::FlatCap:
- return QLatin1String("butt");
- case Qt::SquareCap:
- return QLatin1String("square");
- case Qt::RoundCap:
- return QLatin1String("round");
- default: ;
- }
- return QString();
-}
-
-void Context2D::setLineCap(const QString &capString)
-{
- Qt::PenCapStyle style;
- if (capString == QLatin1String("round"))
- style = Qt::RoundCap;
- else if (capString == QLatin1String("square"))
- style = Qt::SquareCap;
- else //if (capString == QLatin1String("butt"))
- style = Qt::FlatCap;
- m_state.lineCap = style;
- m_state.flags |= DirtyLineCap;
-}
-
-QString Context2D::lineJoin() const
-{
- switch (m_state.lineJoin) {
- case Qt::RoundJoin:
- return QLatin1String("round");
- case Qt::BevelJoin:
- return QLatin1String("bevel");
- case Qt::MiterJoin:
- return QLatin1String("miter");
- default: ;
- }
- return QString();
-}
-
-void Context2D::setLineJoin(const QString &joinString)
-{
- Qt::PenJoinStyle style;
- if (joinString == QLatin1String("round"))
- style = Qt::RoundJoin;
- else if (joinString == QLatin1String("bevel"))
- style = Qt::BevelJoin;
- else //if (joinString == "miter")
- style = Qt::MiterJoin;
- m_state.lineJoin = style;
- m_state.flags |= DirtyLineJoin;
-}
-
-qreal Context2D::miterLimit() const
-{
- return m_state.miterLimit;
-}
-
-void Context2D::setMiterLimit(qreal m)
-{
- m_state.miterLimit = m;
- m_state.flags |= DirtyMiterLimit;
-}
-
-void Context2D::setShadowOffsetX(qreal x)
-{
- if (m_state.shadowOffsetX == x)
- return;
- m_state.shadowOffsetX = x;
- updateShadowBuffer();
- if (m_painter.device() == &m_shadowbuffer && m_state.shadowBlur>0)
- endPainting();
- m_state.flags |= DirtyShadowOffsetX;
-}
-
-const QList<Context2D::MouseArea> &Context2D::mouseAreas() const
-{
- return m_mouseAreas;
-}
-
-void Context2D::updateShadowBuffer() {
- if (m_shadowbuffer.isNull() || m_shadowbuffer.width() != m_width+m_state.shadowOffsetX ||
- m_shadowbuffer.height() != m_height+m_state.shadowOffsetY) {
- m_shadowbuffer = QImage(m_width+m_state.shadowOffsetX, m_height+m_state.shadowOffsetY, QImage::Format_ARGB32);
- m_shadowbuffer.fill(Qt::transparent);
- }
-}
-
-void Context2D::setShadowOffsetY(qreal y)
-{
- if (m_state.shadowOffsetY == y)
- return;
- m_state.shadowOffsetY = y;
- updateShadowBuffer();
- if (m_painter.device() == &m_shadowbuffer && m_state.shadowBlur>0)
- endPainting();
-
- m_state.flags |= DirtyShadowOffsetY;
-}
-
-void Context2D::setShadowBlur(qreal b)
-{
- if (m_state.shadowBlur == b)
- return;
- m_state.shadowBlur = b;
- updateShadowBuffer();
- if (m_painter.device() == &m_shadowbuffer && m_state.shadowBlur>0)
- endPainting();
- m_state.flags |= DirtyShadowBlur;
-}
-
-void Context2D::setShadowColor(const QString &str)
-{
- m_state.shadowColor = colorFromString(str);
- if (m_painter.device() == &m_shadowbuffer && m_state.shadowBlur>0)
- endPainting();
- m_state.flags |= DirtyShadowColor;
-}
-
-QString Context2D::textBaseline()
-{
- switch (m_state.textBaseline) {
- case Context2D::Alphabetic:
- return QLatin1String("alphabetic");
- case Context2D::Hanging:
- return QLatin1String("hanging");
- case Context2D::Bottom:
- return QLatin1String("bottom");
- case Context2D::Top:
- return QLatin1String("top");
- case Context2D::Middle:
- return QLatin1String("middle");
- default:
- Q_ASSERT("invalid value");
- return QLatin1String("start");
- }
-}
-
-void Context2D::setTextBaseline(const QString &baseline)
-{
- if (baseline==QLatin1String("alphabetic")) {
- m_state.textBaseline = Context2D::Alphabetic;
- } else if (baseline == QLatin1String("hanging")) {
- m_state.textBaseline = Context2D::Hanging;
- } else if (baseline == QLatin1String("top")) {
- m_state.textBaseline = Context2D::Top;
- } else if (baseline == QLatin1String("bottom")) {
- m_state.textBaseline = Context2D::Bottom;
- } else if (baseline == QLatin1String("middle")) {
- m_state.textBaseline = Context2D::Middle;
- } else {
- m_state.textBaseline = Context2D::Alphabetic;
- qWarning() << (QLatin1String("Context2D: invalid baseline:") + baseline);
- }
- m_state.flags |= DirtyTextBaseline;
-}
-
-QString Context2D::textAlign()
-{
- switch (m_state.textAlign) {
- case Context2D::Left:
- return QLatin1String("left");
- case Context2D::Right:
- return QLatin1String("right");
- case Context2D::Center:
- return QLatin1String("center");
- case Context2D::Start:
- return QLatin1String("start");
- case Context2D::End:
- return QLatin1String("end");
- default:
- Q_ASSERT("invalid value");
- qWarning() << ("Context2D::invalid textAlign");
- return QLatin1String("start");
- }
-}
-
-void Context2D::setTextAlign(const QString &baseline)
-{
- if (baseline==QLatin1String("start")) {
- m_state.textAlign = Context2D::Start;
- } else if (baseline == QLatin1String("end")) {
- m_state.textAlign = Context2D::End;
- } else if (baseline == QLatin1String("left")) {
- m_state.textAlign = Context2D::Left;
- } else if (baseline == QLatin1String("right")) {
- m_state.textAlign = Context2D::Right;
- } else if (baseline == QLatin1String("center")) {
- m_state.textAlign = Context2D::Center;
- } else {
- m_state.textAlign= Context2D::Start;
- qWarning("Context2D: invalid text align");
- }
- // ### alphabetic, ideographic, hanging
- m_state.flags |= DirtyTextBaseline;
-}
-
-void Context2D::setFont(const QString &fontString)
-{
- QFont font;
- // ### this is simplified and incomplete
- QStringList tokens = fontString.split(QLatin1Char(QLatin1Char(' ')));
- foreach (const QString &token, tokens) {
- if (token == QLatin1String("italic")) {
- font.setItalic(true);
- } else if (token == QLatin1String("bold")) {
- font.setBold(true);
- } else if (token.endsWith(QLatin1String("px"))) {
- QString number = token;
- number.remove(QLatin1String("px"));
-#ifdef Q_OS_MACX
- // compensating the extra antialias space with bigger fonts
- // this class is only used by the QML Profiler
- // not much harm can be inflicted by this dirty hack
- font.setPointSizeF(number.trimmed().toFloat()*4.0f/3.0f);
-#else
- font.setPointSizeF(number.trimmed().toFloat());
-#endif
- } else {
- font.setFamily(token);
- }
- }
- m_state.font = font;
- m_state.flags |= DirtyFont;
-}
-
-QString Context2D::font()
-{
- return m_state.font.toString();
-}
-
-qreal Context2D::shadowOffsetX() const
-{
- return m_state.shadowOffsetX;
-}
-
-qreal Context2D::shadowOffsetY() const
-{
- return m_state.shadowOffsetY;
-}
-
-
-qreal Context2D::shadowBlur() const
-{
- return m_state.shadowBlur;
-}
-
-
-QString Context2D::shadowColor() const
-{
- return m_state.shadowColor.name();
-}
-
-
-void Context2D::clearRect(qreal x, qreal y, qreal w, qreal h)
-{
- beginPainting();
- m_painter.save();
- m_painter.setMatrix(worldMatrix(), false);
- m_painter.setCompositionMode(QPainter::CompositionMode_Source);
- QColor fillColor = parent()->property("color").value<QColor>();
-
- m_painter.fillRect(QRectF(x, y, w, h), fillColor);
- m_painter.restore();
- scheduleChange();
-}
-
-void Context2D::fillRect(qreal x, qreal y, qreal w, qreal h)
-{
- beginPainting();
- m_painter.save();
- m_painter.setMatrix(worldMatrix(), false);
- m_painter.fillRect(QRectF(x, y, w, h), m_painter.brush());
- m_painter.restore();
- scheduleChange();
-}
-
-int Context2D::baseLineOffset(Context2D::TextBaseLine value, const QFontMetrics &metrics)
-{
- int offset = 0;
- switch (value) {
- case Context2D::Top:
- break;
- case Context2D::Alphabetic:
- case Context2D::Middle:
- case Context2D::Hanging:
- offset = metrics.ascent();
- break;
- case Context2D::Bottom:
- offset = metrics.height();
- break;
- }
- return offset;
-}
-
-int Context2D::textAlignOffset(Context2D::TextAlign value, const QFontMetrics &metrics, const QString &text)
-{
- int offset = 0;
- if (value == Context2D::Start)
- value = qApp->layoutDirection() == Qt::LeftToRight ? Context2D::Left : Context2D::Right;
- else if (value == Context2D::End)
- value = qApp->layoutDirection() == Qt::LeftToRight ? Context2D::Right: Context2D::Left;
- switch (value) {
- case Context2D::Center:
- offset = metrics.width(text)/2;
- break;
- case Context2D::Right:
- offset = metrics.width(text);
- case Context2D::Left:
- default:
- break;
- }
- return offset;
-}
-
-void Context2D::fillText(const QString &text, qreal x, qreal y)
-{
- beginPainting();
- m_painter.save();
- m_painter.setPen(QPen(m_state.fillStyle, m_state.lineWidth));
- m_painter.setMatrix(worldMatrix(), false);
- QFont font;
- font.setBold(true);
- m_painter.setFont(m_state.font);
- int yoffset = baseLineOffset(m_state.textBaseline, m_painter.fontMetrics());
- int xoffset = textAlignOffset(m_state.textAlign, m_painter.fontMetrics(), text);
- QTextOption opt; // Adjust baseLine etc
- m_painter.drawText(QRectF(x-xoffset, y-yoffset, QWIDGETSIZE_MAX, m_painter.fontMetrics().height()), text, opt);
- m_painter.restore();
- endPainting();
- scheduleChange();
-}
-
-void Context2D::strokeText(const QString &text, qreal x, qreal y)
-{
- beginPainting();
- m_painter.save();
- m_painter.setPen(QPen(m_state.fillStyle,0));
- m_painter.setMatrix(worldMatrix(), false);
-
- QPainterPath textPath;
- QFont font = m_state.font;
- font.setStyleStrategy(QFont::ForceOutline);
- m_painter.setFont(font);
- const QFontMetrics &metrics = m_painter.fontMetrics();
- int yoffset = baseLineOffset(m_state.textBaseline, metrics);
- int xoffset = textAlignOffset(m_state.textAlign, metrics, text);
- textPath.addText(x-xoffset, y-yoffset+metrics.ascent(), font, text);
- m_painter.strokePath(textPath, QPen(m_state.fillStyle, m_state.lineWidth));
- m_painter.restore();
- endPainting();
- scheduleChange();
-}
-
-void Context2D::strokeRect(qreal x, qreal y, qreal w, qreal h)
-{
- QPainterPath path;
- path.addRect(x, y, w, h);
- beginPainting();
- m_painter.save();
- m_painter.setMatrix(worldMatrix(), false);
- m_painter.strokePath(path, m_painter.pen());
- m_painter.restore();
- scheduleChange();
-}
-
-void Context2D::mouseArea(qreal x, qreal y, qreal w, qreal h, const QJSValue &callback,
- const QJSValue &data)
-{
- MouseArea a = { callback, data, QRectF(x, y, w, h), m_state.matrix };
- m_mouseAreas << a;
-}
-
-void Context2D::beginPath()
-{
- m_path = QPainterPath();
-}
-
-
-void Context2D::closePath()
-{
- m_path.closeSubpath();
-}
-
-
-void Context2D::moveTo(qreal x, qreal y)
-{
- QPointF pt = worldMatrix().map(QPointF(x, y));
- m_path.moveTo(pt);
-}
-
-
-void Context2D::lineTo(qreal x, qreal y)
-{
- QPointF pt = worldMatrix().map(QPointF(x, y));
- m_path.lineTo(pt);
-}
-
-
-void Context2D::quadraticCurveTo(qreal cpx, qreal cpy, qreal x, qreal y)
-{
- QPointF cp = worldMatrix().map(QPointF(cpx, cpy));
- QPointF xy = worldMatrix().map(QPointF(x, y));
- m_path.quadTo(cp, xy);
-}
-
-
-void Context2D::bezierCurveTo(qreal cp1x, qreal cp1y,
- qreal cp2x, qreal cp2y, qreal x, qreal y)
-{
- QPointF cp1 = worldMatrix().map(QPointF(cp1x, cp1y));
- QPointF cp2 = worldMatrix().map(QPointF(cp2x, cp2y));
- QPointF end = worldMatrix().map(QPointF(x, y));
- m_path.cubicTo(cp1, cp2, end);
-}
-
-
-void Context2D::arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius)
-{
- //FIXME: this is surely busted
- QPointF st = worldMatrix().map(QPointF(x1, y1));
- QPointF end = worldMatrix().map(QPointF(x2, y2));
- m_path.arcTo(st.x(), st.y(),
- end.x()-st.x(), end.y()-st.y(),
- radius, 90);
-}
-
-
-void Context2D::rect(qreal x, qreal y, qreal w, qreal h)
-{
- QPainterPath path; path.addRect(x, y, w, h);
- path = worldMatrix().map(path);
- m_path.addPath(path);
-}
-
-void Context2D::arc(qreal xc, qreal yc, qreal radius,
- qreal sar, qreal ear,
- bool anticlockwise)
-{
- //### HACK
- // In Qt we don't switch the coordinate system for degrees
- // and still use the 0,0 as bottom left for degrees so we need
- // to switch
- sar = -sar;
- ear = -ear;
- anticlockwise = !anticlockwise;
- //end hack
-
- float sa = DEGREES(sar);
- float ea = DEGREES(ear);
-
- double span = 0;
-
- double xs = xc - radius;
- double ys = yc - radius;
- double width = radius*2;
- double height = radius*2;
-
- if (!anticlockwise && (ea < sa))
- span += 360;
- else if (anticlockwise && (sa < ea))
- span -= 360;
-
- //### this is also due to switched coordinate system
- // we would end up with a 0 span instead of 360
- if (!(qFuzzyCompare(span + (ea - sa) + 1, 1) &&
- qFuzzyCompare(qAbs(span), 360))) {
- span += ea - sa;
- }
-
- QPainterPath path;
- path.moveTo(QPointF(xc + radius * cos(sar),
- yc - radius * sin(sar)));
-
- path.arcTo(xs, ys, width, height, sa, span);
- path = worldMatrix().map(path);
- m_path.addPath(path);
-}
-
-
-void Context2D::fill()
-{
- beginPainting();
- m_painter.fillPath(m_path, m_painter.brush());
- scheduleChange();
-}
-
-
-void Context2D::stroke()
-{
- beginPainting();
- m_painter.save();
- m_painter.setMatrix(worldMatrix(), false);
- QPainterPath tmp = worldMatrix().inverted().map(m_path);
- m_painter.strokePath(tmp, m_painter.pen());
- m_painter.restore();
- scheduleChange();
-}
-
-
-void Context2D::clip()
-{
- m_state.clipPath = m_path;
- m_state.flags |= DirtyClippingRegion;
-}
-
-
-bool Context2D::isPointInPath(qreal x, qreal y) const
-{
- return m_path.contains(QPointF(x, y));
-}
-
-
-ImageData Context2D::getImageData(qreal sx, qreal sy, qreal sw, qreal sh)
-{
- Q_UNUSED(sx);
- Q_UNUSED(sy);
- Q_UNUSED(sw);
- Q_UNUSED(sh);
- return ImageData();
-}
-
-
-void Context2D::putImageData(ImageData image, qreal dx, qreal dy)
-{
- Q_UNUSED(image);
- Q_UNUSED(dx);
- Q_UNUSED(dy);
-}
-
-Context2D::Context2D(QObject *parent)
- : QObject(parent), m_changeTimerId(-1), m_width(0), m_height(0), m_inPaint(false)
-{
- reset();
-}
-
-void Context2D::setupPainter()
-{
- m_painter.setRenderHint(QPainter::Antialiasing, true);
- if ((m_state.flags & DirtyClippingRegion) && !m_state.clipPath.isEmpty())
- m_painter.setClipPath(m_state.clipPath);
- if (m_state.flags & DirtyFillStyle)
- m_painter.setBrush(m_state.fillStyle);
- if (m_state.flags & DirtyGlobalAlpha)
- m_painter.setOpacity(m_state.globalAlpha);
- if (m_state.flags & DirtyGlobalCompositeOperation)
- m_painter.setCompositionMode(m_state.globalCompositeOperation);
- if (m_state.flags & MDirtyPen) {
- QPen pen = m_painter.pen();
- if (m_state.flags & DirtyStrokeStyle)
- pen.setBrush(m_state.strokeStyle);
- if (m_state.flags & DirtyLineWidth)
- pen.setWidthF(m_state.lineWidth);
- if (m_state.flags & DirtyLineCap)
- pen.setCapStyle(m_state.lineCap);
- if (m_state.flags & DirtyLineJoin)
- pen.setJoinStyle(m_state.lineJoin);
- if (m_state.flags & DirtyMiterLimit)
- pen.setMiterLimit(m_state.miterLimit);
- m_painter.setPen(pen);
- }
-}
-
-void Context2D::beginPainting()
-{
- if (m_pixmap.width() != m_width || m_pixmap.height() != m_height) {
- if (m_painter.isActive())
- m_painter.end();
- m_pixmap = QPixmap(m_width, m_height);
- m_pixmap.fill(parent()->property("color").value<QColor>());
- }
-
- if (m_state.shadowBlur > 0 && m_painter.device() != &m_shadowbuffer) {
- if (m_painter.isActive())
- m_painter.end();
- updateShadowBuffer();
- m_painter.begin(&m_shadowbuffer);
- m_painter.setViewport(m_state.shadowOffsetX,
- m_state.shadowOffsetY,
- m_shadowbuffer.width(),
- m_shadowbuffer.height());
- m_shadowbuffer.fill(Qt::transparent);
- }
-
- if (!m_painter.isActive()) {
- m_painter.begin(&m_pixmap);
- m_painter.setRenderHint(QPainter::Antialiasing);
- if (!m_state.clipPath.isEmpty())
- m_painter.setClipPath(m_state.clipPath);
- m_painter.setBrush(m_state.fillStyle);
- m_painter.setOpacity(m_state.globalAlpha);
- QPen pen;
- pen.setBrush(m_state.strokeStyle);
- if (pen.style() == Qt::NoPen)
- pen.setStyle(Qt::SolidLine);
- pen.setCapStyle(m_state.lineCap);
- pen.setJoinStyle(m_state.lineJoin);
- pen.setWidthF(m_state.lineWidth);
- pen.setMiterLimit(m_state.miterLimit);
- m_painter.setPen(pen);
- } else {
- setupPainter();
- m_state.flags = 0;
- }
-}
-
-void Context2D::endPainting()
-{
- if (m_state.shadowBlur > 0) {
- QImage alphaChannel = m_shadowbuffer.alphaChannel();
-
- qt_blurImage(alphaChannel, m_state.shadowBlur, false, 1);
-
- QRect imageRect = m_shadowbuffer.rect();
-
- if (m_shadowColorIndexBuffer.isEmpty() || m_shadowColorBuffer != m_state.shadowColor) {
- m_shadowColorIndexBuffer.clear();
- m_shadowColorBuffer = m_state.shadowColor;
-
- for (int i = 0; i < 256; ++i) {
- m_shadowColorIndexBuffer << qRgba(qRound(255 * m_state.shadowColor.redF()),
- qRound(255 * m_state.shadowColor.greenF()),
- qRound(255 * m_state.shadowColor.blueF()),
- i);
- }
- }
- alphaChannel.setColorTable(m_shadowColorIndexBuffer);
-
- if (m_painter.isActive())
- m_painter.end();
-
- m_painter.begin(&m_pixmap);
-
- // draw the blurred drop shadow...
- m_painter.save();
- QTransform tf = m_painter.transform();
- m_painter.translate(0, imageRect.height());
- m_painter.rotate(-90);
- m_painter.drawImage(0, 0, alphaChannel);
- m_painter.setTransform(tf);
- m_painter.restore();
-
- // draw source
- m_painter.drawImage(-m_state.shadowOffsetX, -m_state.shadowOffsetY, m_shadowbuffer.copy());
- m_painter.end();
- }
-}
-
-void Context2D::clear()
-{
- m_painter.fillRect(QRect(QPoint(0,0), size()), Qt::white);
-}
-
-void Context2D::reset()
-{
- m_stateStack.clear();
- m_state.matrix = QMatrix();
- m_state.clipPath = QPainterPath();
- m_state.strokeStyle = Qt::black;
- m_state.fillStyle = Qt::black;
- m_state.globalAlpha = 1.0;
- m_state.lineWidth = 1;
- m_state.lineCap = Qt::FlatCap;
- m_state.lineJoin = Qt::MiterJoin;
- m_state.miterLimit = 10;
- m_state.shadowOffsetX = 0;
- m_state.shadowOffsetY = 0;
- m_state.shadowBlur = 0;
- m_state.shadowColor = qRgba(0, 0, 0, 0);
- m_state.globalCompositeOperation = QPainter::CompositionMode_SourceOver;
- m_state.font = QFont();
- m_state.textAlign = Start;
- m_state.textBaseline = Alphabetic;
- m_state.flags = AllIsFullOfDirt;
- m_mouseAreas.clear();
- clear();
-}
-
-void Context2D::drawImage(const QVariant &var, qreal sx, qreal sy,
- qreal sw = 0, qreal sh = 0)
-{
- CanvasImage *image = qobject_cast<CanvasImage*>(var.value<QObject*>());
- if (!image) {
- Canvas *canvas = qobject_cast<Canvas*>(var.value<QObject*>());
- if (canvas)
- image = canvas->toImage();
- }
- if (image) {
- beginPainting();
- if (sw == sh && sh == 0)
- m_painter.drawPixmap(QPointF(sx, sy), image->value());
- else
- m_painter.drawPixmap(QRect(sx, sy, sw, sh), image->value());
-
- scheduleChange();
- }
-}
-
-void Context2D::setSize(int width, int height)
-{
- endPainting();
- m_width = width;
- m_height = height;
-
- scheduleChange();
-}
-
-void Context2D::setSize(const QSize &size)
-{
- setSize(size.width(), size.height());
-}
-
-QSize Context2D::size() const
-{
- return m_pixmap.size();
-}
-
-QPoint Context2D::painterTranslate() const
-{
- return m_painterTranslate;
-}
-
-void Context2D::setPainterTranslate(const QPoint &translate)
-{
- m_painterTranslate = translate;
- m_state.flags |= DirtyTransformationMatrix;
-}
-
-void Context2D::scheduleChange()
-{
- QMetaObject::invokeMethod(this, "onScheduleChange", Qt::QueuedConnection, Q_ARG(int, 0));
-}
-
-void Context2D::onScheduleChange(int interval)
-{
- if (m_changeTimerId == -1 && !m_inPaint)
- m_changeTimerId = startTimer(interval);
-}
-
-void Context2D::timerEvent(QTimerEvent *e)
-{
- if (e->timerId() == m_changeTimerId) {
- killTimer(m_changeTimerId);
- m_changeTimerId = -1;
- endPainting();
- emit changed();
- } else {
- QObject::timerEvent(e);
- }
-}
-
-QMatrix Context2D::worldMatrix() const
-{
- QMatrix mat;
- mat.translate(m_painterTranslate.x(), m_painterTranslate.y());
- mat *= m_state.matrix;
- return mat;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d_p.h b/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d_p.h
deleted file mode 100644
index c4add692cb..0000000000
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d_p.h
+++ /dev/null
@@ -1,326 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVECONTEXT2D_P_H
-#define QDECLARATIVECONTEXT2D_P_H
-
-#include <qpainter.h>
-#include <qpainterpath.h>
-#include <qpixmap.h>
-#include <qstring.h>
-#include <qstack.h>
-#include <qmetatype.h>
-#include <qcoreevent.h>
-#include <qvariant.h>
-
-#include <QJSValue>
-
-QT_BEGIN_NAMESPACE
-
-QColor colorFromString(const QString &name);
-
-class CanvasGradient : public QObject
-{
- Q_OBJECT
-public:
- CanvasGradient(const QGradient &gradient) : m_gradient(gradient) {}
-
-public slots:
- QGradient value() { return m_gradient; }
- void addColorStop(float pos, const QString &color) { m_gradient.setColorAt(pos, colorFromString(color));}
-
-public:
- QGradient m_gradient;
-};
-
-class CanvasImage: public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString src READ src WRITE setSrc NOTIFY sourceChanged)
- Q_PROPERTY(int width READ width)
- Q_PROPERTY(int height READ height)
-
-public:
- CanvasImage() {}
- CanvasImage(const QString &url) : m_image(url), m_src(url) {}
- CanvasImage(const QPixmap &pixmap) {m_image = pixmap;}
-
-public slots:
- int width() { return m_image.width(); }
- int height() { return m_image.height(); }
- QPixmap &value() { return m_image; }
- QString src() { return m_src; }
- void setSrc(const QString &src) { m_src = src; m_image.load(src); emit sourceChanged();}
-signals:
- void sourceChanged();
-
-private:
- QPixmap m_image;
- QString m_src;
-};
-
-
-class ImageData {
-};
-
-class Context2D : public QObject
-{
- Q_OBJECT
- // compositing
- Q_PROPERTY(qreal globalAlpha READ globalAlpha WRITE setGlobalAlpha)
- Q_PROPERTY(QString globalCompositeOperation READ globalCompositeOperation WRITE setGlobalCompositeOperation)
- Q_PROPERTY(QVariant strokeStyle READ strokeStyle WRITE setStrokeStyle)
- Q_PROPERTY(QVariant fillStyle READ fillStyle WRITE setFillStyle)
- // line caps/joins
- Q_PROPERTY(qreal lineWidth READ lineWidth WRITE setLineWidth)
- Q_PROPERTY(QString lineCap READ lineCap WRITE setLineCap)
- Q_PROPERTY(QString lineJoin READ lineJoin WRITE setLineJoin)
- Q_PROPERTY(qreal miterLimit READ miterLimit WRITE setMiterLimit)
- // shadows
- Q_PROPERTY(qreal shadowOffsetX READ shadowOffsetX WRITE setShadowOffsetX)
- Q_PROPERTY(qreal shadowOffsetY READ shadowOffsetY WRITE setShadowOffsetY)
- Q_PROPERTY(qreal shadowBlur READ shadowBlur WRITE setShadowBlur)
- Q_PROPERTY(QString shadowColor READ shadowColor WRITE setShadowColor)
- // fonts
- Q_PROPERTY(QString font READ font WRITE setFont)
- Q_PROPERTY(QString textBaseline READ textBaseline WRITE setTextBaseline)
- Q_PROPERTY(QString textAlign READ textAlign WRITE setTextAlign)
-
- enum TextBaseLine { Alphabetic=0, Top, Middle, Bottom, Hanging};
- enum TextAlign { Start=0, End, Left, Right, Center};
-
-public:
- Context2D(QObject *parent = 0);
- void setSize(int width, int height);
- void setSize(const QSize &size);
- QSize size() const;
-
- QPoint painterTranslate() const;
- void setPainterTranslate(const QPoint &);
-
- void scheduleChange();
- void timerEvent(QTimerEvent *e);
-
- void clear();
- void reset();
-
- QPixmap pixmap() { return m_pixmap; }
-
- // compositing
- qreal globalAlpha() const; // (default 1.0)
- QString globalCompositeOperation() const; // (default over)
- QVariant strokeStyle() const; // (default black)
- QVariant fillStyle() const; // (default black)
-
- void setGlobalAlpha(qreal alpha);
- void setGlobalCompositeOperation(const QString &op);
- void setStrokeStyle(const QVariant &style);
- void setFillStyle(const QVariant &style);
-
- // line caps/joins
- qreal lineWidth() const; // (default 1)
- QString lineCap() const; // "butt", "round", "square" (default "butt")
- QString lineJoin() const; // "round", "bevel", "miter" (default "miter")
- qreal miterLimit() const; // (default 10)
-
- void setLineWidth(qreal w);
- void setLineCap(const QString &s);
- void setLineJoin(const QString &s);
- void setMiterLimit(qreal m);
-
- void setFont(const QString &font);
- QString font();
- void setTextBaseline(const QString &font);
- QString textBaseline();
- void setTextAlign(const QString &font);
- QString textAlign();
-
- // shadows
- qreal shadowOffsetX() const; // (default 0)
- qreal shadowOffsetY() const; // (default 0)
- qreal shadowBlur() const; // (default 0)
- QString shadowColor() const; // (default black)
-
- void setShadowOffsetX(qreal x);
- void setShadowOffsetY(qreal y);
- void setShadowBlur(qreal b);
- void setShadowColor(const QString &str);
-
- struct MouseArea {
- QJSValue callback;
- QJSValue data;
- QRectF rect;
- QMatrix matrix;
- };
- const QList<MouseArea> &mouseAreas() const;
-
-public slots:
- void save(); // push state on state stack
- void restore(); // pop state stack and restore state
-
- void fillText(const QString &text, qreal x, qreal y);
- void strokeText(const QString &text, qreal x, qreal y);
-
- void setInPaint(bool val){m_inPaint = val;}
- void scale(qreal x, qreal y);
- void rotate(qreal angle);
- void translate(qreal x, qreal y);
- void transform(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy);
- void setTransform(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy);
-
- CanvasGradient *createLinearGradient(qreal x0, qreal y0,
- qreal x1, qreal y1);
- CanvasGradient *createRadialGradient(qreal x0, qreal y0,
- qreal r0, qreal x1,
- qreal y1, qreal r1);
-
- // rects
- void clearRect(qreal x, qreal y, qreal w, qreal h);
- void fillRect(qreal x, qreal y, qreal w, qreal h);
- void strokeRect(qreal x, qreal y, qreal w, qreal h);
-
- // mouse
- void mouseArea(qreal x, qreal y, qreal w, qreal h, const QJSValue &, const QJSValue & = QJSValue());
-
- // path API
- void beginPath();
- void closePath();
- void moveTo(qreal x, qreal y);
- void lineTo(qreal x, qreal y);
- void quadraticCurveTo(qreal cpx, qreal cpy, qreal x, qreal y);
- void bezierCurveTo(qreal cp1x, qreal cp1y,
- qreal cp2x, qreal cp2y, qreal x, qreal y);
- void arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius);
- void rect(qreal x, qreal y, qreal w, qreal h);
- void arc(qreal x, qreal y, qreal radius,
- qreal startAngle, qreal endAngle,
- bool anticlockwise);
- void fill();
- void stroke();
- void clip();
- bool isPointInPath(qreal x, qreal y) const;
-
- CanvasImage *createImage(const QString &url);
-
- // drawing images (no overloads due to QTBUG-11604)
- void drawImage(const QVariant &var, qreal dx, qreal dy, qreal dw, qreal dh);
-
- // pixel manipulation
- ImageData getImageData(qreal sx, qreal sy, qreal sw, qreal sh);
- void putImageData(ImageData image, qreal dx, qreal dy);
- void endPainting();
-
-private slots:
- void onScheduleChange(int interval);
-
-signals:
- void changed();
-
-private:
- void setupPainter();
- void beginPainting();
- void updateShadowBuffer();
-
- int m_changeTimerId;
- QPainterPath m_path;
-
- enum DirtyFlag {
- DirtyTransformationMatrix = 0x00001,
- DirtyClippingRegion = 0x00002,
- DirtyStrokeStyle = 0x00004,
- DirtyFillStyle = 0x00008,
- DirtyGlobalAlpha = 0x00010,
- DirtyLineWidth = 0x00020,
- DirtyLineCap = 0x00040,
- DirtyLineJoin = 0x00080,
- DirtyMiterLimit = 0x00100,
- MDirtyPen = DirtyStrokeStyle
- | DirtyLineWidth
- | DirtyLineCap
- | DirtyLineJoin
- | DirtyMiterLimit,
- DirtyShadowOffsetX = 0x00200,
- DirtyShadowOffsetY = 0x00400,
- DirtyShadowBlur = 0x00800,
- DirtyShadowColor = 0x01000,
- DirtyGlobalCompositeOperation = 0x2000,
- DirtyFont = 0x04000,
- DirtyTextAlign = 0x08000,
- DirtyTextBaseline = 0x10000,
- AllIsFullOfDirt = 0xfffff
- };
-
- struct State {
- State() : flags(0) {}
- QMatrix matrix;
- QPainterPath clipPath;
- QBrush strokeStyle;
- QBrush fillStyle;
- qreal globalAlpha;
- qreal lineWidth;
- Qt::PenCapStyle lineCap;
- Qt::PenJoinStyle lineJoin;
- qreal miterLimit;
- qreal shadowOffsetX;
- qreal shadowOffsetY;
- qreal shadowBlur;
- QColor shadowColor;
- QPainter::CompositionMode globalCompositeOperation;
- QFont font;
- Context2D::TextAlign textAlign;
- Context2D::TextBaseLine textBaseline;
- int flags;
- };
-
- int baseLineOffset(Context2D::TextBaseLine value, const QFontMetrics &metrics);
- int textAlignOffset(Context2D::TextAlign value, const QFontMetrics &metrics, const QString &string);
-
- QMatrix worldMatrix() const;
-
- QPoint m_painterTranslate;
- State m_state;
- QStack<State> m_stateStack;
- QPixmap m_pixmap;
- QList<MouseArea> m_mouseAreas;
- QImage m_shadowbuffer;
- QVector<QRgb> m_shadowColorIndexBuffer;
- QColor m_shadowColorBuffer;
- QPainter m_painter;
- int m_width, m_height;
- bool m_inPaint;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(CanvasImage*)
-Q_DECLARE_METATYPE(CanvasGradient*)
-
-#endif // QDECLARATIVECONTEXT2D_P_H
diff --git a/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.cpp b/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.cpp
deleted file mode 100644
index bfaa1185bc..0000000000
--- a/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "qmlprofilercanvas.h"
-
-#include "qdeclarativecontext2d_p.h"
-
-#include <qpixmap.h>
-#include <qpainter.h>
-
-namespace QmlProfiler {
-namespace Internal {
-
-QmlProfilerCanvas::QmlProfilerCanvas()
- : m_context2d(new Context2D(this))
-{
- setAcceptedMouseButtons(Qt::LeftButton);
- m_drawTimer.setSingleShot(true);
- connect(&m_drawTimer, SIGNAL(timeout()), this, SLOT(draw()));
-
- m_drawTimer.start();
-}
-
-void QmlProfilerCanvas::requestPaint()
-{
- if (m_context2d->size().width() != width()
- || m_context2d->size().height() != height()) {
- m_drawTimer.start();
- } else {
- update();
- }
-}
-
-void QmlProfilerCanvas::requestRedraw()
-{
- m_drawTimer.start();
-}
-
-// called from GUI thread. Draws into m_context2d.
-void QmlProfilerCanvas::draw()
-{
- QMutexLocker lock(&m_pixmapMutex);
- m_context2d->reset();
- m_context2d->setSize(width(), height());
-
- if (width() > 0 && height() > 0)
- emit drawRegion(m_context2d, QRect(0, 0, width(), height()));
- update();
-}
-
-// called from OpenGL thread. Renders m_context2d into OpenGL buffer.
-void QmlProfilerCanvas::paint(QPainter *p)
-{
- QMutexLocker lock(&m_pixmapMutex);
- p->drawPixmap(0, 0, m_context2d->pixmap());
-}
-
-void QmlProfilerCanvas::componentComplete()
-{
- const QMetaObject *metaObject = this->metaObject();
- int propertyCount = metaObject->propertyCount();
- int requestPaintMethod = metaObject->indexOfMethod("requestPaint()");
- for (int ii = QmlProfilerCanvas::staticMetaObject.propertyCount(); ii < propertyCount; ++ii) {
- QMetaProperty p = metaObject->property(ii);
- if (p.hasNotifySignal())
- QMetaObject::connect(this, p.notifySignalIndex(), this, requestPaintMethod, 0, 0);
- }
- QQuickItem::componentComplete();
- requestRedraw();
-}
-
-void QmlProfilerCanvas::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- QQuickItem::geometryChanged(newGeometry, oldGeometry);
- requestRedraw();
-}
-
-}
-}
diff --git a/src/plugins/qmlprofiler/qml/CategoryLabel.qml b/src/plugins/qmlprofiler/qml/CategoryLabel.qml
index 948a129534..0ea83dc7aa 100644
--- a/src/plugins/qmlprofiler/qml/CategoryLabel.qml
+++ b/src/plugins/qmlprofiler/qml/CategoryLabel.qml
@@ -47,7 +47,7 @@ Item {
onExpandedChanged: {
qmlProfilerModelProxy.setExpanded(modelIndex, categoryIndex, expanded);
- backgroundMarks.requestRedraw();
+ backgroundMarks.requestPaint();
getDescriptions();
updateHeight();
}
diff --git a/src/plugins/qmlprofiler/qml/Detail.qml b/src/plugins/qmlprofiler/qml/Detail.qml
index 1f6f22b8c0..5683735867 100644
--- a/src/plugins/qmlprofiler/qml/Detail.qml
+++ b/src/plugins/qmlprofiler/qml/Detail.qml
@@ -28,32 +28,9 @@
****************************************************************************/
import QtQuick 2.1
-import Monitor 1.0
-Item {
- id: detail
- property string label
- property string content
-
- height: childrenRect.height+2
- width: childrenRect.width
- Item {
- id: guideline
- x: 70
- width: 5
- }
- Text {
- y: 1
- id: lbl
- text: label
- font.pixelSize: 12
- font.bold: true
- }
- Text {
- text: content
- font.pixelSize: 12
- anchors.baseline: lbl.baseline
- anchors.left: guideline.right
- textFormat: Text.PlainText
- }
+Text {
+ font.pixelSize: 12
+ font.bold: index % 2 === 0
+ textFormat: Text.PlainText
}
diff --git a/src/plugins/qmlprofiler/qml/HorizontalGradientBorder.qml b/src/plugins/qmlprofiler/qml/HorizontalGradientBorder.qml
new file mode 100644
index 0000000000..16cf2b86e4
--- /dev/null
+++ b/src/plugins/qmlprofiler/qml/HorizontalGradientBorder.qml
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+import QtQuick 2.1
+
+Rectangle {
+ property color topColor
+ property color bottomColor
+ height: 6
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: bottomColor; }
+ GradientStop { position: 1.0; color: topColor; }
+ }
+}
diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml
index f34b003fd8..7bdadc0a29 100644
--- a/src/plugins/qmlprofiler/qml/MainView.qml
+++ b/src/plugins/qmlprofiler/qml/MainView.qml
@@ -169,28 +169,6 @@ Rectangle {
view.selectPrev();
}
- function updateZoomCentered(centerX, relativeFactor)
- {
- var min_length = 1e5; // 0.1 ms
- var windowLength = view.endTime - view.startTime;
- if (windowLength < min_length)
- windowLength = min_length;
- var newWindowLength = windowLength * relativeFactor;
-
- if (newWindowLength > qmlProfilerModelProxy.traceDuration()) {
- newWindowLength = qmlProfilerModelProxy.traceDuration();
- relativeFactor = newWindowLength / windowLength;
- }
- if (newWindowLength < min_length) {
- newWindowLength = min_length;
- relativeFactor = newWindowLength / windowLength;
- }
-
- var fixedPoint = (centerX - flick.x) * windowLength / flick.width + view.startTime;
- var startTime = fixedPoint - relativeFactor*(fixedPoint - view.startTime);
- zoomControl.setRange(startTime, startTime + newWindowLength);
- }
-
function recenter( centerPoint ) {
var windowLength = view.endTime - view.startTime;
var newStart = Math.floor(centerPoint - windowLength/2);
@@ -215,21 +193,10 @@ Rectangle {
}
- function wheelZoom(wheelCenter, wheelDelta) {
- if (qmlProfilerModelProxy.traceEndTime() > qmlProfilerModelProxy.traceStartTime() &&
- wheelDelta !== 0) {
- if (wheelDelta>0)
- updateZoomCentered(wheelCenter, 1/1.2);
- else
- updateZoomCentered(wheelCenter, 1.2);
- }
- }
-
function hideRangeDetails() {
rangeDetails.visible = false;
rangeDetails.duration = "";
rangeDetails.label = "";
- //rangeDetails.type = "";
rangeDetails.file = "";
rangeDetails.line = -1;
rangeDetails.column = 0;
@@ -468,22 +435,12 @@ Rectangle {
}
// Gradient borders
- Item {
+ VerticalGradientBorder {
anchors.left: labels.right
anchors.top: labels.top
anchors.bottom: labelsTail.bottom
- width: 6
- Rectangle {
- x: parent.width
- transformOrigin: Item.TopLeft
- rotation: 90
- width: parent.height
- height: parent.width
- gradient: Gradient {
- GradientStop { position: 0.0; color: "#00000000"; }
- GradientStop { position: 1.0; color: "#86000000"; }
- }
- }
+ leftColor: "#00000000"
+ rightColor: "#86000000"
}
}
@@ -559,32 +516,19 @@ Rectangle {
}
}
- Item {
+ VerticalGradientBorder {
anchors.right: root.right
- width: 6
anchors.top: root.top
anchors.bottom: root.bottom
- Rectangle {
- x: parent.width
- transformOrigin: Item.TopLeft
- rotation: 90
- width: parent.height
- height: parent.width
- gradient: Gradient {
- GradientStop { position: 0.0; color: "#86000000"; }
- GradientStop { position: 1.0; color: "#00000000"; }
- }
- }
+ rightColor: "#00000000"
+ leftColor: "#86000000"
}
- Rectangle {
- y: root.height - height
- height: 6
- width: root.width
- x: 0
- gradient: Gradient {
- GradientStop { position: 0.0; color: "#00000000"; }
- GradientStop { position: 1.0; color: "#86000000"; }
- }
+ HorizontalGradientBorder {
+ anchors.bottom: root.bottom
+ anchors.left: root.left
+ anchors.right: root.right
+ bottomColor: "#00000000"
+ topColor: "#86000000"
}
}
diff --git a/src/plugins/qmlprofiler/qml/Overview.js b/src/plugins/qmlprofiler/qml/Overview.js
index c6bb0300e7..7fe1084bdd 100644
--- a/src/plugins/qmlprofiler/qml/Overview.js
+++ b/src/plugins/qmlprofiler/qml/Overview.js
@@ -97,6 +97,7 @@ function drawData(canvas, ctxt, region)
var ycenter = Math.round(bump + (modelRowStart +
qmlProfilerModelProxy.getEventCategoryInModel(modelIndex, ii)) *
blockHeight + blockHeight/2);
+ ctxt.beginPath();
ctxt.arc(xcenter, ycenter, radius, 0, 2*Math.PI, true);
ctxt.stroke();
}
diff --git a/src/plugins/qmlprofiler/qml/Overview.qml b/src/plugins/qmlprofiler/qml/Overview.qml
index 9670fbb47f..9fed5a9c37 100644
--- a/src/plugins/qmlprofiler/qml/Overview.qml
+++ b/src/plugins/qmlprofiler/qml/Overview.qml
@@ -31,9 +31,10 @@ import QtQuick 2.1
import Monitor 1.0
import "Overview.js" as Plotter
-Canvas2D {
+Canvas {
id: canvas
objectName: "Overview"
+ contextType: "2d"
// ***** properties
height: 50
@@ -45,7 +46,7 @@ Canvas2D {
function clearDisplay()
{
dataReady = false;
- requestRedraw();
+ requestPaint();
}
function updateRange() {
@@ -84,18 +85,18 @@ Canvas2D {
target: qmlProfilerModelProxy
onDataAvailable: {
dataReady = true;
- requestRedraw();
+ requestPaint();
}
}
// ***** slots
- onDrawRegion: {
+ onPaint: {
Plotter.qmlProfilerModelProxy = qmlProfilerModelProxy;
if (dataReady) {
- Plotter.plot(canvas, ctxt, region);
+ Plotter.plot(canvas, context, region);
} else {
- Plotter.drawGraph(canvas, ctxt, region) //just draw the background
+ Plotter.drawGraph(canvas, context, region) //just draw the background
}
}
diff --git a/src/plugins/qmlprofiler/qml/RangeDetails.qml b/src/plugins/qmlprofiler/qml/RangeDetails.qml
index b7de8746d7..83988bfe54 100644
--- a/src/plugins/qmlprofiler/qml/RangeDetails.qml
+++ b/src/plugins/qmlprofiler/qml/RangeDetails.qml
@@ -43,7 +43,7 @@ Item {
property bool locked: view.selectionLocked
- width: col.width + 45
+ width: col.width + 25
height: col.height + 30
z: 1
visible: false
@@ -68,7 +68,8 @@ Item {
rangeDetails.dialogTitle = eventData[0]["title"];
for (var i = 1; i < eventData.length; i++) {
for (var k in eventData[i]) {
- eventInfo.append({"key": k, "value":eventData[i][k]});
+ eventInfo.append({"content" : k});
+ eventInfo.append({"content" : eventData[i][k]})
}
}
rangeDetails.visible = true;
@@ -163,24 +164,24 @@ Item {
border.color: "#a0a0a0"
//details
- Column {
+ Grid {
id: col
x: 10
y: 5
+ spacing: 5
+ columns: 2
Repeater {
model: eventInfo
Detail {
- label: key
- content: value
+ text: content
}
}
}
}
MouseArea {
- width: col.width + 45
- height: col.height + 30
+ anchors.fill: parent
drag.target: parent
drag.minimumX: 0
drag.maximumX: root.width - parent.width
@@ -211,7 +212,7 @@ Item {
Text {
id: closeIcon
- x: col.width + 30
+ x: col.width + 10
y: 4
text:"X"
color: "white"
diff --git a/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml b/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml
index eeef84550d..432fddb2cb 100644
--- a/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml
+++ b/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml
@@ -38,7 +38,7 @@ Item {
property string duration
property bool showDuration
- width: 170
+ width: Math.max(150, col.width + 25)
height: col.height + 30
z: 1
visible: false
@@ -126,30 +126,31 @@ Item {
y: 20
border.width: 1
border.color: "#a0a0a0"
- Column {
+ Grid {
id: col
x: 10
y: 5
- Detail {
- label: qsTr("Start")
- content: selectionRangeDetails.startTime
- }
- Detail {
- label: qsTr("End")
- visible: selectionRangeDetails.showDuration
- content: selectionRangeDetails.endTime
- }
- Detail {
- label: qsTr("Duration")
- visible: selectionRangeDetails.showDuration
- content: selectionRangeDetails.duration
+ spacing: 5
+ columns: 2
+
+ Repeater {
+ model: [
+ qsTr("Start"),
+ startTime,
+ showDuration ? qsTr("End") : "",
+ showDuration ? endTime : "",
+ showDuration ? qsTr("Duration") : "",
+ showDuration ? duration : ""
+ ]
+ Detail {
+ text: modelData
+ }
}
}
}
MouseArea {
- width: col.width + 45
- height: col.height + 30
+ anchors.fill: parent
drag.target: parent
drag.minimumX: 0
drag.maximumX: root.width - parent.width
diff --git a/src/plugins/qmlprofiler/qml/TimeDisplay.qml b/src/plugins/qmlprofiler/qml/TimeDisplay.qml
index 9c02665163..7ab1ab877d 100644
--- a/src/plugins/qmlprofiler/qml/TimeDisplay.qml
+++ b/src/plugins/qmlprofiler/qml/TimeDisplay.qml
@@ -30,9 +30,10 @@
import QtQuick 2.1
import Monitor 1.0
-Canvas2D {
+Canvas {
id: timeDisplay
objectName: "TimeDisplay"
+ contextType: "2d"
property real startTime : 0
property real endTime : 0
@@ -43,13 +44,13 @@ Canvas2D {
onRangeChanged: {
startTime = zoomControl.startTime();
endTime = zoomControl.endTime();
- requestRedraw();
+ requestPaint();
}
}
- onDrawRegion: {
- ctxt.fillStyle = "white";
- ctxt.fillRect(0, 0, width, height);
+ onPaint: {
+ context.fillStyle = "white";
+ context.fillRect(0, 0, width, height);
var totalTime = endTime - startTime;
var spacing = width / totalTime;
@@ -67,50 +68,50 @@ Canvas2D {
var initialColor = Math.floor(realStartTime/timePerBlock) % 2;
- ctxt.fillStyle = "#000000";
- ctxt.font = "8px sans-serif";
+ context.fillStyle = "#000000";
+ context.font = "8px sans-serif";
for (var ii = 0; ii < blockCount+1; ii++) {
var x = Math.floor(ii*pixelsPerBlock - realStartPos);
- ctxt.fillStyle = (ii+initialColor)%2 ? "#E6E6E6":"white";
- ctxt.fillRect(x, 0, pixelsPerBlock, height);
+ context.fillStyle = (ii+initialColor)%2 ? "#E6E6E6":"white";
+ context.fillRect(x, 0, pixelsPerBlock, height);
- ctxt.strokeStyle = "#B0B0B0";
- ctxt.beginPath();
- ctxt.moveTo(x, 0);
- ctxt.lineTo(x, height);
- ctxt.stroke();
+ context.strokeStyle = "#B0B0B0";
+ context.beginPath();
+ context.moveTo(x, 0);
+ context.lineTo(x, height);
+ context.stroke();
- ctxt.fillStyle = "#000000";
- ctxt.fillText(prettyPrintTime(ii*timePerBlock + realStartTime), x + 5, height/2 + 5);
+ context.fillStyle = "#000000";
+ context.fillText(prettyPrintTime(ii*timePerBlock + realStartTime), x + 5, height/2 + 5);
}
- ctxt.strokeStyle = "#525252";
- ctxt.beginPath();
- ctxt.moveTo(0, height-1);
- ctxt.lineTo(width, height-1);
- ctxt.stroke();
+ context.strokeStyle = "#525252";
+ context.beginPath();
+ context.moveTo(0, height-1);
+ context.lineTo(width, height-1);
+ context.stroke();
// gradient borders
var gradientDark = "rgba(0, 0, 0, 0.53125)";
var gradientClear = "rgba(0, 0, 0, 0)";
- var grad = ctxt.createLinearGradient(0, 0, 0, 6);
+ var grad = context.createLinearGradient(0, 0, 0, 6);
grad.addColorStop(0,gradientDark);
grad.addColorStop(1,gradientClear);
- ctxt.fillStyle = grad;
- ctxt.fillRect(0, 0, width, 6);
+ context.fillStyle = grad;
+ context.fillRect(0, 0, width, 6);
- grad = ctxt.createLinearGradient(0, 0, 6, 0);
+ grad = context.createLinearGradient(0, 0, 6, 0);
grad.addColorStop(0,gradientDark);
grad.addColorStop(1,gradientClear);
- ctxt.fillStyle = grad;
- ctxt.fillRect(0, 0, 6, height);
+ context.fillStyle = grad;
+ context.fillRect(0, 0, 6, height);
- grad = ctxt.createLinearGradient(width, 0, width-6, 0);
+ grad = context.createLinearGradient(width, 0, width-6, 0);
grad.addColorStop(0,gradientDark);
grad.addColorStop(1,gradientClear);
- ctxt.fillStyle = grad;
- ctxt.fillRect(width-6, 0, 6, height);
+ context.fillStyle = grad;
+ context.fillRect(width-6, 0, 6, height);
}
function prettyPrintTime( t )
diff --git a/src/plugins/qmlprofiler/qml/TimeMarks.qml b/src/plugins/qmlprofiler/qml/TimeMarks.qml
index 9f87e0319a..6bf6be330c 100644
--- a/src/plugins/qmlprofiler/qml/TimeMarks.qml
+++ b/src/plugins/qmlprofiler/qml/TimeMarks.qml
@@ -30,9 +30,10 @@
import QtQuick 2.1
import Monitor 1.0
-Canvas2D {
- id: timeDisplay
+Canvas {
+ id: timeMarks
objectName: "TimeMarks"
+ contextType: "2d"
property real startTime
property real endTime
@@ -40,11 +41,13 @@ Canvas2D {
Connections {
target: labels
- onHeightChanged: { requestRedraw(); }
+ onHeightChanged: requestPaint()
}
- onDrawRegion: {
- drawBackgroundBars( ctxt, region );
+ onYChanged: requestPaint()
+
+ onPaint: {
+ drawBackgroundBars( context, region );
var totalTime = endTime - startTime;
var spacing = width / totalTime;
@@ -63,23 +66,23 @@ Canvas2D {
var lineStart = y < 0 ? -y : 0;
var lineEnd = Math.min(height, labels.height - y);
- ctxt.fillStyle = "#000000";
- ctxt.font = "8px sans-serif";
+ context.fillStyle = "#000000";
+ context.font = "8px sans-serif";
for (var ii = 0; ii < blockCount+1; ii++) {
var x = Math.floor(ii*pixelsPerBlock - realStartPos);
- ctxt.strokeStyle = "#B0B0B0";
- ctxt.beginPath();
- ctxt.moveTo(x, lineStart);
- ctxt.lineTo(x, lineEnd);
- ctxt.stroke();
+ context.strokeStyle = "#B0B0B0";
+ context.beginPath();
+ context.moveTo(x, lineStart);
+ context.lineTo(x, lineEnd);
+ context.stroke();
- ctxt.strokeStyle = "#CCCCCC";
+ context.strokeStyle = "#CCCCCC";
for (var jj=1; jj < 5; jj++) {
var xx = Math.floor(ii*pixelsPerBlock + jj*pixelsPerSection - realStartPos);
- ctxt.beginPath();
- ctxt.moveTo(xx, lineStart);
- ctxt.lineTo(xx, lineEnd);
- ctxt.stroke();
+ context.beginPath();
+ context.moveTo(xx, lineStart);
+ context.lineTo(xx, lineEnd);
+ context.stroke();
}
}
}
@@ -88,19 +91,19 @@ Canvas2D {
if (startTime !== start || endTime !== end) {
startTime = start;
endTime = end;
- requestRedraw();
+ requestPaint();
}
}
- function drawBackgroundBars( ctxt, region ) {
+ function drawBackgroundBars( context, region ) {
var colorIndex = true;
// row background
var backgroundOffset = y < 0 ? -y : -(y % (2 * root.singleRowHeight));
for (var currentY= backgroundOffset; currentY < Math.min(height, labels.height - y); currentY += root.singleRowHeight) {
- ctxt.fillStyle = colorIndex ? "#f0f0f0" : "white";
- ctxt.strokeStyle = colorIndex ? "#f0f0f0" : "white";
- ctxt.fillRect(0, currentY, width, root.singleRowHeight);
+ context.fillStyle = colorIndex ? "#f0f0f0" : "white";
+ context.strokeStyle = colorIndex ? "#f0f0f0" : "white";
+ context.fillRect(0, currentY, width, root.singleRowHeight);
colorIndex = !colorIndex;
}
@@ -112,18 +115,18 @@ Canvas2D {
if (cumulatedHeight < y)
continue;
- ctxt.strokeStyle = "#B0B0B0";
- ctxt.beginPath();
- ctxt.moveTo(0, cumulatedHeight - y);
- ctxt.lineTo(width, cumulatedHeight - y);
- ctxt.stroke();
+ context.strokeStyle = "#B0B0B0";
+ context.beginPath();
+ context.moveTo(0, cumulatedHeight - y);
+ context.lineTo(width, cumulatedHeight - y);
+ context.stroke();
}
}
// bottom
if (height > labels.height - y) {
- ctxt.fillStyle = "#f5f5f5";
- ctxt.fillRect(0, labels.height - y, width, Math.min(height - labels.height + y, labelsTail.height));
+ context.fillStyle = "#f5f5f5";
+ context.fillRect(0, labels.height - y, width, Math.min(height - labels.height + y, labelsTail.height));
}
}
}
diff --git a/src/plugins/qmlprofiler/qml/VerticalGradientBorder.qml b/src/plugins/qmlprofiler/qml/VerticalGradientBorder.qml
new file mode 100644
index 0000000000..a143800ccb
--- /dev/null
+++ b/src/plugins/qmlprofiler/qml/VerticalGradientBorder.qml
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+import QtQuick 2.1
+
+Item {
+ property color leftColor
+ property color rightColor
+ width: 6
+ HorizontalGradientBorder {
+ anchors.left: parent.right
+ anchors.top: parent.top
+ transformOrigin: Item.TopLeft
+ rotation: 90
+ width: parent.height
+ topColor: rightColor
+ bottomColor: leftColor
+ }
+}
diff --git a/src/plugins/qmlprofiler/qml/qmlprofiler.qrc b/src/plugins/qmlprofiler/qml/qmlprofiler.qrc
index 1e45c14065..f503f72510 100644
--- a/src/plugins/qmlprofiler/qml/qmlprofiler.qrc
+++ b/src/plugins/qmlprofiler/qml/qmlprofiler.qrc
@@ -16,6 +16,8 @@
<file>Overview.js</file>
<file>SelectionRange.qml</file>
<file>SelectionRangeDetails.qml</file>
+ <file>HorizontalGradientBorder.qml</file>
+ <file>VerticalGradientBorder.qml</file>
<file>arrow_down.png</file>
<file>arrow_right.png</file>
<file>dialog_shadow.png</file>
diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro
index 8be8423533..8ca0e82f5a 100644
--- a/src/plugins/qmlprofiler/qmlprofiler.pro
+++ b/src/plugins/qmlprofiler/qmlprofiler.pro
@@ -3,7 +3,6 @@ DEFINES += QMLPROFILER_LIBRARY
QT += network qml quick
include(../../qtcreatorplugin.pri)
-include(canvas/canvas.pri)
SOURCES += \
qmlprofilerplugin.cpp \
@@ -31,7 +30,8 @@ SOURCES += \
qmlprofilertracefile.cpp \
abstracttimelinemodel.cpp \
timelinemodelaggregator.cpp \
- qmlprofilerpainteventsmodelproxy.cpp
+ qmlprofilerpainteventsmodelproxy.cpp \
+ sortedtimelinemodel.cpp
HEADERS += \
qmlprofilerconstants.h \
@@ -62,7 +62,8 @@ HEADERS += \
qmlprofilertracefile.h \
abstracttimelinemodel.h \
timelinemodelaggregator.h \
- qmlprofilerpainteventsmodelproxy.h
+ qmlprofilerpainteventsmodelproxy.h \
+ sortedtimelinemodel.h
RESOURCES += \
qml/qmlprofiler.qrc
@@ -77,4 +78,6 @@ OTHER_FILES += \
qml/TimeMarks.qml \
qml/SelectionRange.qml \
qml/SelectionRangeDetails.qml \
- qml/Overview.qml
+ qml/Overview.qml \
+ qml/VerticalGradientBorder.qml \
+ qml/HorizontalGradientBorder.qml
diff --git a/src/plugins/qmlprofiler/qmlprofiler.qbs b/src/plugins/qmlprofiler/qmlprofiler.qbs
index 507ce1093e..e102665d3f 100644
--- a/src/plugins/qmlprofiler/qmlprofiler.qbs
+++ b/src/plugins/qmlprofiler/qmlprofiler.qbs
@@ -50,23 +50,13 @@ QtcPlugin {
"qmlprofilerviewmanager.cpp", "qmlprofilerviewmanager.h",
"qv8profilerdatamodel.cpp", "qv8profilerdatamodel.h",
"qv8profilereventview.h", "qv8profilereventview.cpp",
+ "sortedtimelinemodel.h", "sortedtimelinemodel.cpp",
"timelinemodelaggregator.cpp", "timelinemodelaggregator.h",
"timelinerenderer.cpp", "timelinerenderer.h",
]
}
Group {
- name: "Canvas"
- prefix: "canvas/"
- files: [
- "qdeclarativecanvas.cpp", "qdeclarativecanvas_p.h",
- "qdeclarativecanvastimer.cpp", "qdeclarativecanvastimer_p.h",
- "qdeclarativecontext2d.cpp", "qdeclarativecontext2d_p.h",
- "qmlprofilercanvas.cpp", "qmlprofilercanvas.h"
- ]
- }
-
- Group {
name: "QML"
prefix: "qml/"
files: [
@@ -81,6 +71,8 @@ QtcPlugin {
"SelectionRangeDetails.qml",
"TimeDisplay.qml",
"TimeMarks.qml",
+ "HorizontalGradientBorder.qml",
+ "VerticalGradientBorder.qml",
"qmlprofiler.qrc",
]
}
diff --git a/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp
index a8b7ceb633..cdc672c8a6 100644
--- a/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp
@@ -96,10 +96,10 @@ void QmlProfilerEventsModelProxy::limitToRange(qint64 rangeStart, qint64 rangeEn
void QmlProfilerEventsModelProxy::dataChanged()
{
- if (d->modelManager->state() == QmlProfilerDataState::Empty)
- clear();
- else
+ if (d->modelManager->state() == QmlProfilerDataState::Done)
loadData();
+ else if (d->modelManager->state() == QmlProfilerDataState::ClearingData)
+ clear();
}
QSet<QString> QmlProfilerEventsModelProxy::eventsInBindingLoop() const
diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
index ab0e9aef8a..62751f3d22 100644
--- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
@@ -57,6 +57,9 @@ void QmlProfilerDataState::setState(QmlProfilerDataState::State state)
return;
switch (state) {
+ case ClearingData:
+ QTC_ASSERT(m_state == Done || m_state == Empty, /**/);
+ break;
case Empty:
// if it's not empty, complain but go on
QTC_ASSERT(m_modelManager->isEmpty(), /**/);
@@ -345,6 +348,7 @@ QmlProfilerDataState::State QmlProfilerModelManager::state() const
void QmlProfilerModelManager::clear()
{
+ setState(QmlProfilerDataState::ClearingData);
for (int i = 0; i < d->partialCounts.count(); i++)
d->partialCounts[i] = 0;
d->progress = 0;
diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.h b/src/plugins/qmlprofiler/qmlprofilermodelmanager.h
index 2954de4690..146c6acdfd 100644
--- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.h
+++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.h
@@ -52,6 +52,7 @@ public:
Empty,
AcquiringData,
ProcessingData,
+ ClearingData,
Done
};
diff --git a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp
index 630d25b38c..73d20cf7ad 100644
--- a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp
@@ -30,6 +30,7 @@
#include "qmlprofilerpainteventsmodelproxy.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilersimplemodel.h"
+#include "sortedtimelinemodel.h"
#include <QCoreApplication>
#include <QVector>
@@ -49,7 +50,7 @@ struct CategorySpan {
int contractedRows;
};
-class PaintEventsModelProxy::PaintEventsModelProxyPrivate
+class PaintEventsModelProxy::PaintEventsModelProxyPrivate : public SortedTimelineModel<QmlPaintEventData>
{
public:
PaintEventsModelProxyPrivate(PaintEventsModelProxy *qq) : q(qq) {}
@@ -58,10 +59,10 @@ public:
QString displayTime(double time);
void computeAnimationCountLimit();
- QVector <PaintEventsModelProxy::QmlPaintEventData> eventList;
int minAnimationCount;
int maxAnimationCount;
bool expanded;
+ bool seenForeignPaintEvent;
PaintEventsModelProxy *q;
};
@@ -94,49 +95,16 @@ QString PaintEventsModelProxy::name() const
return QLatin1String("PaintEventsModelProxy");
}
-const QVector<PaintEventsModelProxy::QmlPaintEventData> PaintEventsModelProxy::getData() const
-{
- return d->eventList;
-}
-
-const QVector<PaintEventsModelProxy::QmlPaintEventData> PaintEventsModelProxy::getData(qint64 fromTime, qint64 toTime) const
-{
- int fromIndex = findFirstIndex(fromTime);
- int toIndex = findLastIndex(toTime);
- if (fromIndex != -1 && toIndex > fromIndex)
- return d->eventList.mid(fromIndex, toIndex - fromIndex + 1);
- else
- return QVector<PaintEventsModelProxy::QmlPaintEventData>();
-}
-
void PaintEventsModelProxy::clear()
{
- d->eventList.clear();
+ d->SortedTimelineModel::clear();
d->minAnimationCount = 1;
d->maxAnimationCount = 1;
d->expanded = false;
+ d->seenForeignPaintEvent = false;
m_modelManager->modelProxyCountUpdated(m_modelId, 0, 1);
}
-void PaintEventsModelProxy::dataChanged()
-{
- if (m_modelManager->state() == QmlProfilerDataState::ProcessingData)
- loadData();
-
- if (m_modelManager->state() == QmlProfilerDataState::Empty)
- clear();
-
- emit stateChanged();
- emit dataAvailable();
- emit emptyChanged();
- emit expandedChanged();
-}
-
-bool compareStartTimes(const PaintEventsModelProxy::QmlPaintEventData &t1, const PaintEventsModelProxy::QmlPaintEventData &t2)
-{
- return t1.startTime < t2.startTime;
-}
-
bool PaintEventsModelProxy::eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const
{
return (event.eventType == QmlDebug::Painting && event.bindingType == QmlDebug::AnimationFrame);
@@ -151,44 +119,43 @@ void PaintEventsModelProxy::loadData()
// collect events
const QVector<QmlProfilerSimpleModel::QmlEventData> referenceList = simpleModel->getEvents();
+
+ QmlPaintEventData lastEvent;
+ qint64 minNextStartTime = 0;
+
foreach (const QmlProfilerSimpleModel::QmlEventData &event, referenceList) {
- if (!eventAccepted(event))
+ if (!eventAccepted(event)) {
+ if (event.eventType == QmlDebug::Painting)
+ d->seenForeignPaintEvent = true;
continue;
+ }
- qint64 estimatedDuration = 0;
// initial estimation of the event duration: 1/framerate
- if (event.numericData1 > 0)
- estimatedDuration = 1e9/event.numericData1;
+ qint64 estimatedDuration = event.numericData1 > 0 ? 1e9/event.numericData1 : 1;
// the profiler registers the animation events at the end of them
- qint64 realStartTime = event.startTime - estimatedDuration;
-
- // the duration of the events is estimated from the framerate
- // we need to correct it before appending a new event
- if (d->eventList.count() > 0) {
- QmlPaintEventData *lastEvent = &d->eventList[d->eventList.count()-1];
- if (lastEvent->startTime + lastEvent->duration >= realStartTime) {
- // 1 nanosecond less to prevent overlap
- lastEvent->duration = realStartTime - lastEvent->startTime - 1;
- lastEvent->framerate = 1e9/lastEvent->duration;
- }
- }
+ qint64 realEndTime = event.startTime;
+
+ // ranges should not overlap. If they do, our estimate wasn't accurate enough
+ qint64 realStartTime = qMax(event.startTime - estimatedDuration, minNextStartTime);
- QmlPaintEventData newEvent = {
- realStartTime,
- estimatedDuration,
- (int)event.numericData1,
- (int)event.numericData2
- };
+ // Sometimes our estimate is far off or the server has miscalculated the frame rate
+ if (realStartTime >= realEndTime)
+ realEndTime = realStartTime + 1;
- d->eventList.append(newEvent);
+ // Don't "fix" the framerate even if we've fixed the duration.
+ // The server should know better after all and if it doesn't we want to see that.
+ lastEvent.framerate = (int)event.numericData1;
+ lastEvent.animationcount = (int)event.numericData2;
+ d->insert(realStartTime, realEndTime - realStartTime, lastEvent);
- m_modelManager->modelProxyCountUpdated(m_modelId, d->eventList.count(), referenceList.count());
+ minNextStartTime = event.startTime + 1;
+
+ m_modelManager->modelProxyCountUpdated(m_modelId, d->count(), referenceList.count());
}
d->computeAnimationCountLimit();
-
- qSort(d->eventList.begin(), d->eventList.end(), compareStartTimes);
+ d->computeNesting();
m_modelManager->modelProxyCountUpdated(m_modelId, 1, 1);
@@ -204,12 +171,12 @@ bool PaintEventsModelProxy::isEmpty() const
int PaintEventsModelProxy::count() const
{
- return d->eventList.count();
+ return d->count();
}
qint64 PaintEventsModelProxy::lastTimeMark() const
{
- return d->eventList.last().startTime + d->eventList.last().duration;
+ return d->lastEndTime();
}
bool PaintEventsModelProxy::expanded(int ) const
@@ -228,7 +195,7 @@ int PaintEventsModelProxy::categoryDepth(int categoryIndex) const
{
Q_UNUSED(categoryIndex);
if (isEmpty())
- return 0;
+ return d->seenForeignPaintEvent ? 0 : 1;
else
return 2;
}
@@ -247,53 +214,17 @@ const QString PaintEventsModelProxy::categoryLabel(int categoryIndex) const
int PaintEventsModelProxy::findFirstIndex(qint64 startTime) const
{
- return findFirstIndexNoParents(startTime);
+ return d->findFirstIndex(startTime);
}
int PaintEventsModelProxy::findFirstIndexNoParents(qint64 startTime) const
{
- if (d->eventList.isEmpty())
- return -1;
- if (d->eventList.count() == 1 || d->eventList.first().startTime+d->eventList.first().duration >= startTime)
- return 0;
- else
- if (d->eventList.last().startTime+d->eventList.last().duration <= startTime)
- return -1;
-
- int fromIndex = 0;
- int toIndex = d->eventList.count()-1;
- while (toIndex - fromIndex > 1) {
- int midIndex = (fromIndex + toIndex)/2;
- if (d->eventList[midIndex].startTime + d->eventList[midIndex].duration < startTime)
- fromIndex = midIndex;
- else
- toIndex = midIndex;
- }
- return toIndex;
+ return d->findFirstIndexNoParents(startTime);
}
int PaintEventsModelProxy::findLastIndex(qint64 endTime) const
{
- if (d->eventList.isEmpty())
- return -1;
- if (d->eventList.first().startTime >= endTime)
- return -1;
- if (d->eventList.count() == 1)
- return 0;
- if (d->eventList.last().startTime <= endTime)
- return d->eventList.count()-1;
-
- int fromIndex = 0;
- int toIndex = d->eventList.count()-1;
- while (toIndex - fromIndex > 1) {
- int midIndex = (fromIndex + toIndex)/2;
- if (d->eventList[midIndex].startTime < endTime)
- fromIndex = midIndex;
- else
- toIndex = midIndex;
- }
-
- return fromIndex;
+ return d->findLastIndex(endTime);
}
int PaintEventsModelProxy::getEventType(int index) const
@@ -317,17 +248,17 @@ int PaintEventsModelProxy::getEventRow(int index) const
qint64 PaintEventsModelProxy::getDuration(int index) const
{
- return d->eventList[index].duration;
+ return d->range(index).duration;
}
qint64 PaintEventsModelProxy::getStartTime(int index) const
{
- return d->eventList[index].startTime;
+ return d->range(index).start;
}
qint64 PaintEventsModelProxy::getEndTime(int index) const
{
- return d->eventList[index].startTime + d->eventList[index].duration;
+ return d->range(index).start + d->range(index).duration;
}
int PaintEventsModelProxy::getEventId(int index) const
@@ -339,7 +270,7 @@ int PaintEventsModelProxy::getEventId(int index) const
QColor PaintEventsModelProxy::getColor(int index) const
{
- double fpsFraction = d->eventList[index].framerate / 60.0;
+ double fpsFraction = d->range(index).framerate / 60.0;
if (fpsFraction > 1.0)
fpsFraction = 1.0;
if (fpsFraction < 0.0)
@@ -352,7 +283,7 @@ float PaintEventsModelProxy::getHeight(int index) const
float scale = d->maxAnimationCount - d->minAnimationCount;
float fraction = 1.0f;
if (scale > 1)
- fraction = (float)(d->eventList[index].animationcount -
+ fraction = (float)(d->range(index).animationcount -
d->minAnimationCount) / scale;
return fraction * 0.85f + 0.15f;
@@ -388,14 +319,14 @@ void PaintEventsModelProxy::PaintEventsModelProxyPrivate::computeAnimationCountL
{
minAnimationCount = 1;
maxAnimationCount = 1;
- if (eventList.isEmpty())
+ if (count() == 0)
return;
- for (int i=0; i < eventList.count(); i++) {
- if (eventList[i].animationcount < minAnimationCount)
- minAnimationCount = eventList[i].animationcount;
- if (eventList[i].animationcount > maxAnimationCount)
- maxAnimationCount = eventList[i].animationcount;
+ for (int i=0; i < count(); i++) {
+ if (range(i).animationcount < minAnimationCount)
+ minAnimationCount = range(i).animationcount;
+ else if (range(i).animationcount > maxAnimationCount)
+ maxAnimationCount = range(i).animationcount;
}
}
@@ -414,21 +345,21 @@ const QVariantList PaintEventsModelProxy::getEventDetails(int index) const
// duration
{
QVariantMap valuePair;
- valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), QVariant(d->displayTime(d->eventList[index].duration)));
+ valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), QVariant(d->displayTime(d->range(index).duration)));
result << valuePair;
}
// duration
{
QVariantMap valuePair;
- valuePair.insert(QCoreApplication::translate(trContext, "Framerate:"), QVariant(QString::fromLatin1("%1 FPS").arg(d->eventList[index].framerate)));
+ valuePair.insert(QCoreApplication::translate(trContext, "Framerate:"), QVariant(QString::fromLatin1("%1 FPS").arg(d->range(index).framerate)));
result << valuePair;
}
// duration
{
QVariantMap valuePair;
- valuePair.insert(QCoreApplication::translate(trContext, "Animations:"), QVariant(QString::fromLatin1("%1").arg(d->eventList[index].animationcount)));
+ valuePair.insert(QCoreApplication::translate(trContext, "Animations:"), QVariant(QString::fromLatin1("%1").arg(d->range(index).animationcount)));
result << valuePair;
}
diff --git a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h
index d77921e61f..9d362fc79b 100644
--- a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h
+++ b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.h
@@ -56,8 +56,6 @@ class PaintEventsModelProxy : public AbstractTimelineModel
public:
struct QmlPaintEventData {
- qint64 startTime;
- qint64 duration;
int framerate;
int animationcount;
};
@@ -70,8 +68,6 @@ public:
QStringList categoryTitles() const;
QString name() const;
- const QVector<QmlPaintEventData> getData() const;
- const QVector<QmlPaintEventData> getData(qint64 fromTime, qint64 toTime) const;
void loadData();
Q_INVOKABLE int count() const;
void clear();
@@ -108,8 +104,6 @@ public:
private slots:
bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const;
-protected slots:
- void dataChanged();
private:
class PaintEventsModelProxyPrivate;
diff --git a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp
index ae9cc44684..deda2f0653 100644
--- a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp
@@ -30,6 +30,7 @@
#include "qmlprofilertimelinemodelproxy.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilersimplemodel.h"
+#include "sortedtimelinemodel.h"
#include <QCoreApplication>
#include <QVector>
@@ -48,10 +49,9 @@ struct CategorySpan {
int expandedRows;
int contractedRows;
int rowStart;
- bool empty;
};
-class BasicTimelineModel::BasicTimelineModelPrivate
+class BasicTimelineModel::BasicTimelineModelPrivate : public SortedTimelineModel<BasicTimelineModel::QmlRangeEventStartInstance>
{
public:
BasicTimelineModelPrivate(BasicTimelineModel *qq) : q(qq) {}
@@ -61,7 +61,6 @@ public:
void prepare();
void computeNestingContracted();
void computeExpandedLevels();
- void buildEndTimeList();
void findBindingLoops();
void computeRowStarts();
@@ -69,9 +68,8 @@ public:
QVector <BasicTimelineModel::QmlRangeEventData> eventDict;
QVector <QString> eventHashes;
- QVector <BasicTimelineModel::QmlRangeEventStartInstance> startTimeData;
- QVector <BasicTimelineModel::QmlRangeEventEndInstance> endTimeData;
QVector <CategorySpan> categorySpan;
+ bool seenPaintEvent;
BasicTimelineModel *q;
};
@@ -104,70 +102,31 @@ QString BasicTimelineModel::name() const
return QLatin1String("BasicTimelineModel");
}
-const QVector<BasicTimelineModel::QmlRangeEventStartInstance> BasicTimelineModel::getData() const
-{
- return d->startTimeData;
-}
-
-const QVector<BasicTimelineModel::QmlRangeEventStartInstance> BasicTimelineModel::getData(qint64 fromTime, qint64 toTime) const
-{
- int fromIndex = findFirstIndex(fromTime);
- int toIndex = findLastIndex(toTime);
- if (fromIndex != -1 && toIndex > fromIndex)
- return d->startTimeData.mid(fromIndex, toIndex - fromIndex + 1);
- else
- return QVector<BasicTimelineModel::QmlRangeEventStartInstance>();
-}
-
void BasicTimelineModel::clear()
{
+ d->SortedTimelineModel::clear();
d->eventDict.clear();
d->eventHashes.clear();
- d->startTimeData.clear();
- d->endTimeData.clear();
d->categorySpan.clear();
+ d->seenPaintEvent = false;
m_modelManager->modelProxyCountUpdated(m_modelId, 0, 1);
}
-void BasicTimelineModel::dataChanged()
-{
- if (m_modelManager->state() == QmlProfilerDataState::ProcessingData)
- loadData();
-
- if (m_modelManager->state() == QmlProfilerDataState::Empty)
- clear();
-
- emit stateChanged();
- emit dataAvailable();
- emit emptyChanged();
- emit expandedChanged();
-}
-
void BasicTimelineModel::BasicTimelineModelPrivate::prepare()
{
categorySpan.clear();
for (int i = 0; i < QmlDebug::MaximumQmlEventType; i++) {
- CategorySpan newCategory = {false, 1, 1, i, true};
+ CategorySpan newCategory = {false, 1, 1, i};
categorySpan << newCategory;
}
}
-bool compareStartTimes(const BasicTimelineModel::QmlRangeEventStartInstance&t1, const BasicTimelineModel::QmlRangeEventStartInstance &t2)
-{
- return t1.startTime < t2.startTime;
-}
-
-bool compareEndTimes(const BasicTimelineModel::QmlRangeEventEndInstance &t1, const BasicTimelineModel::QmlRangeEventEndInstance &t2)
-{
- return t1.endTime < t2.endTime;
-}
-
bool BasicTimelineModel::eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const
{
// only accept Qt4.x Painting events
if (event.eventType == QmlDebug::Painting)
- return event.bindingType == QmlDebug::QPainterEvent;
+ return (event.bindingType == QmlDebug::QPainterEvent);
return (event.eventType <= QmlDebug::HandlingSignal);
}
@@ -188,6 +147,8 @@ void BasicTimelineModel::loadData()
foreach (const QmlProfilerSimpleModel::QmlEventData &event, eventList) {
if (!eventAccepted(event))
continue;
+ if (event.eventType == QmlDebug::Painting)
+ d->seenPaintEvent = true;
QString eventHash = QmlProfilerSimpleModel::getHashString(event);
@@ -205,42 +166,30 @@ void BasicTimelineModel::loadData()
}
// store starttime-based instance
- QmlRangeEventStartInstance eventStartInstance = {
- event.startTime,
- event.duration,
- d->eventHashes.indexOf(eventHash), // event id
- QmlDebug::Constants::QML_MIN_LEVEL, // displayRowExpanded;
- QmlDebug::Constants::QML_MIN_LEVEL, // displayRowCollapsed;
- 1,
- -1 // bindingLoopHead
- };
- d->startTimeData.append(eventStartInstance);
-
- m_modelManager->modelProxyCountUpdated(m_modelId, d->startTimeData.count(), eventList.count() * 7);
+ d->insert(event.startTime, event.duration, QmlRangeEventStartInstance(d->eventHashes.indexOf(eventHash)));
+
+ m_modelManager->modelProxyCountUpdated(m_modelId, d->count(), eventList.count() * 6);
}
- qSort(d->startTimeData.begin(), d->startTimeData.end(), compareStartTimes);
+ m_modelManager->modelProxyCountUpdated(m_modelId, 2, 6);
- m_modelManager->modelProxyCountUpdated(m_modelId, 2, 7);
+ // compute range nesting
+ d->computeNesting();
// compute nestingLevel - nonexpanded
d->computeNestingContracted();
- m_modelManager->modelProxyCountUpdated(m_modelId, 3, 7);
+ m_modelManager->modelProxyCountUpdated(m_modelId, 3, 6);
// compute nestingLevel - expanded
d->computeExpandedLevels();
- m_modelManager->modelProxyCountUpdated(m_modelId, 4, 7);
-
- // populate endtimelist
- d->buildEndTimeList();
+ m_modelManager->modelProxyCountUpdated(m_modelId, 4, 6);
- m_modelManager->modelProxyCountUpdated(m_modelId, 5, 7);
d->findBindingLoops();
- m_modelManager->modelProxyCountUpdated(m_modelId, 6, 7);
+ m_modelManager->modelProxyCountUpdated(m_modelId, 5, 6);
d->computeRowStarts();
@@ -252,15 +201,10 @@ void BasicTimelineModel::loadData()
void BasicTimelineModel::BasicTimelineModelPrivate::computeNestingContracted()
{
int i;
- int eventCount = startTimeData.count();
+ int eventCount = count();
- QHash<int, qint64> endtimesPerLevel;
QList<int> nestingLevels;
QList< QHash<int, qint64> > endtimesPerNestingLevel;
- int level = QmlDebug::Constants::QML_MIN_LEVEL;
- endtimesPerLevel[QmlDebug::Constants::QML_MIN_LEVEL] = 0;
- int lastBaseEventIndex = 0;
- qint64 lastBaseEventEndTime = q->m_modelManager->traceTime()->startTime();
for (i = 0; i < QmlDebug::MaximumQmlEventType; i++) {
nestingLevels << QmlDebug::Constants::QML_MIN_LEVEL;
@@ -270,18 +214,9 @@ void BasicTimelineModel::BasicTimelineModelPrivate::computeNestingContracted()
}
for (i = 0; i < eventCount; i++) {
- qint64 st = startTimeData[i].startTime;
+ qint64 st = ranges[i].start;
int type = q->getEventType(i);
- // general level
- if (endtimesPerLevel[level] > st) {
- level++;
- } else {
- while (level > QmlDebug::Constants::QML_MIN_LEVEL && endtimesPerLevel[level-1] <= st)
- level--;
- }
- endtimesPerLevel[level] = st + startTimeData[i].duration;
-
// per type
if (endtimesPerNestingLevel[type][nestingLevels[type]] > st) {
nestingLevels[type]++;
@@ -291,67 +226,40 @@ void BasicTimelineModel::BasicTimelineModelPrivate::computeNestingContracted()
nestingLevels[type]--;
}
endtimesPerNestingLevel[type][nestingLevels[type]] =
- st + startTimeData[i].duration;
-
- startTimeData[i].displayRowCollapsed = nestingLevels[type];
+ st + ranges[i].duration;
- if (level == QmlDebug::Constants::QML_MIN_LEVEL) {
- if (lastBaseEventEndTime < startTimeData[i].startTime) {
- lastBaseEventIndex = i;
- lastBaseEventEndTime = startTimeData[i].startTime + startTimeData[i].duration;
- }
- }
- startTimeData[i].baseEventIndex = lastBaseEventIndex;
+ ranges[i].displayRowCollapsed = nestingLevels[type];
}
// nestingdepth
for (i = 0; i < eventCount; i++) {
int eventType = q->getEventType(i);
- categorySpan[eventType].empty = false;
- if (categorySpan[eventType].contractedRows <= startTimeData[i].displayRowCollapsed)
- categorySpan[eventType].contractedRows = startTimeData[i].displayRowCollapsed + 1;
+ if (categorySpan[eventType].contractedRows <= ranges[i].displayRowCollapsed)
+ categorySpan[eventType].contractedRows = ranges[i].displayRowCollapsed + 1;
}
}
void BasicTimelineModel::BasicTimelineModelPrivate::computeExpandedLevels()
{
QHash<int, int> eventRow;
- int eventCount = startTimeData.count();
+ int eventCount = count();
for (int i = 0; i < eventCount; i++) {
- int eventId = startTimeData[i].eventId;
+ int eventId = ranges[i].eventId;
int eventType = eventDict[eventId].eventType;
if (!eventRow.contains(eventId)) {
- categorySpan[eventType].empty = false;
eventRow[eventId] = categorySpan[eventType].expandedRows++;
}
- startTimeData[i].displayRowExpanded = eventRow[eventId];
+ ranges[i].displayRowExpanded = eventRow[eventId];
}
}
-void BasicTimelineModel::BasicTimelineModelPrivate::buildEndTimeList()
-{
- endTimeData.clear();
-
- int eventCount = startTimeData.count();
- for (int i = 0; i < eventCount; i++) {
- BasicTimelineModel::QmlRangeEventEndInstance endInstance = {
- i,
- startTimeData[i].startTime + startTimeData[i].duration
- };
-
- endTimeData << endInstance;
- }
-
- qSort(endTimeData.begin(), endTimeData.end(), compareEndTimes);
-}
-
void BasicTimelineModel::BasicTimelineModelPrivate::findBindingLoops()
{
typedef QPair<QString, int> CallStackEntry;
QStack<CallStackEntry> callStack;
- for (int i = 0; i < startTimeData.size(); ++i) {
- QmlRangeEventStartInstance *event = &startTimeData[i];
+ for (int i = 0; i < count(); ++i) {
+ Range *event = &ranges[i];
BasicTimelineModel::QmlRangeEventData data = eventDict.at(event->eventId);
@@ -363,14 +271,14 @@ void BasicTimelineModel::BasicTimelineModelPrivate::findBindingLoops()
continue;
const QString eventHash = eventHashes.at(event->eventId);
- const QmlRangeEventStartInstance *potentialParent = callStack.isEmpty()
- ? 0 : &startTimeData[callStack.top().second];
+ const Range *potentialParent = callStack.isEmpty()
+ ? 0 : &ranges[callStack.top().second];
while (potentialParent
- && !(potentialParent->startTime + potentialParent->duration > event->startTime)) {
+ && !(potentialParent->start + potentialParent->duration > event->start)) {
callStack.pop();
potentialParent = callStack.isEmpty() ? 0
- : &startTimeData[callStack.top().second];
+ : &ranges[callStack.top().second];
}
// check whether event is already in stack
@@ -406,12 +314,12 @@ bool BasicTimelineModel::isEmpty() const
int BasicTimelineModel::count() const
{
- return d->startTimeData.count();
+ return d->count();
}
qint64 BasicTimelineModel::lastTimeMark() const
{
- return d->startTimeData.last().startTime + d->startTimeData.last().duration;
+ return d->lastEndTime();
}
bool BasicTimelineModel::expanded(int category) const
@@ -433,11 +341,11 @@ void BasicTimelineModel::setExpanded(int category, bool expanded)
int BasicTimelineModel::categoryDepth(int categoryIndex) const
{
- if (d->categorySpan.count() <= categoryIndex)
- return 1;
// special for paint events: show only when empty model or there's actual events
- if (categoryIndex == QmlDebug::Painting && d->categorySpan[categoryIndex].empty && !isEmpty())
+ if (categoryIndex == QmlDebug::Painting && !d->seenPaintEvent)
return 0;
+ if (d->categorySpan.count() <= categoryIndex)
+ return 1;
if (d->categorySpan[categoryIndex].expanded)
return d->categorySpan[categoryIndex].expandedRows;
else
@@ -464,102 +372,29 @@ const QString BasicTimelineModel::categoryLabel(int categoryIndex) const
int BasicTimelineModel::findFirstIndex(qint64 startTime) const
{
- int candidate = -1;
- // in the "endtime" list, find the first event that ends after startTime
- if (d->endTimeData.isEmpty())
- return -1;
- if (d->endTimeData.count() == 1 || d->endTimeData.first().endTime >= startTime)
- candidate = 0;
- else
- if (d->endTimeData.last().endTime <= startTime)
- return -1;
-
- if (candidate == -1)
- {
- int fromIndex = 0;
- int toIndex = d->endTimeData.count()-1;
- while (toIndex - fromIndex > 1) {
- int midIndex = (fromIndex + toIndex)/2;
- if (d->endTimeData[midIndex].endTime < startTime)
- fromIndex = midIndex;
- else
- toIndex = midIndex;
- }
-
- candidate = toIndex;
- }
-
- int eventIndex = d->endTimeData[candidate].startTimeIndex;
- return d->startTimeData[eventIndex].baseEventIndex;
-
+ return d->findFirstIndex(startTime);
}
int BasicTimelineModel::findFirstIndexNoParents(qint64 startTime) const
{
- int candidate = -1;
- // in the "endtime" list, find the first event that ends after startTime
- if (d->endTimeData.isEmpty())
- return -1;
- if (d->endTimeData.count() == 1 || d->endTimeData.first().endTime >= startTime)
- candidate = 0;
- else
- if (d->endTimeData.last().endTime <= startTime)
- return -1;
-
- if (candidate == -1) {
- int fromIndex = 0;
- int toIndex = d->endTimeData.count()-1;
- while (toIndex - fromIndex > 1) {
- int midIndex = (fromIndex + toIndex)/2;
- if (d->endTimeData[midIndex].endTime < startTime)
- fromIndex = midIndex;
- else
- toIndex = midIndex;
- }
-
- candidate = toIndex;
- }
-
- int ndx = d->endTimeData[candidate].startTimeIndex;
-
- return ndx;
+ return d->findFirstIndexNoParents(startTime);
}
int BasicTimelineModel::findLastIndex(qint64 endTime) const
{
- // in the "starttime" list, find the last event that starts before endtime
- if (d->startTimeData.isEmpty())
- return -1;
- if (d->startTimeData.first().startTime >= endTime)
- return -1;
- if (d->startTimeData.count() == 1)
- return 0;
- if (d->startTimeData.last().startTime <= endTime)
- return d->startTimeData.count()-1;
-
- int fromIndex = 0;
- int toIndex = d->startTimeData.count()-1;
- while (toIndex - fromIndex > 1) {
- int midIndex = (fromIndex + toIndex)/2;
- if (d->startTimeData[midIndex].startTime < endTime)
- fromIndex = midIndex;
- else
- toIndex = midIndex;
- }
-
- return fromIndex;
+ return d->findLastIndex(endTime);
}
int BasicTimelineModel::getEventType(int index) const
{
- return d->eventDict[d->startTimeData[index].eventId].eventType;
+ return d->eventDict[d->range(index).eventId].eventType;
}
int BasicTimelineModel::getEventCategory(int index) const
{
int evTy = getEventType(index);
// special: paint events shown?
- if (d->categorySpan[0].empty && !isEmpty())
+ if (!d->seenPaintEvent)
return evTy - 1;
return evTy;
}
@@ -567,34 +402,34 @@ int BasicTimelineModel::getEventCategory(int index) const
int BasicTimelineModel::getEventRow(int index) const
{
if (d->categorySpan[getEventType(index)].expanded)
- return d->startTimeData[index].displayRowExpanded + d->categorySpan[getEventType(index)].rowStart;
+ return d->range(index).displayRowExpanded + d->categorySpan[getEventType(index)].rowStart;
else
- return d->startTimeData[index].displayRowCollapsed + d->categorySpan[getEventType(index)].rowStart;
+ return d->range(index).displayRowCollapsed + d->categorySpan[getEventType(index)].rowStart;
}
qint64 BasicTimelineModel::getDuration(int index) const
{
- return d->startTimeData[index].duration;
+ return d->range(index).duration;
}
qint64 BasicTimelineModel::getStartTime(int index) const
{
- return d->startTimeData[index].startTime;
+ return d->range(index).start;
}
qint64 BasicTimelineModel::getEndTime(int index) const
{
- return d->startTimeData[index].startTime + d->startTimeData[index].duration;
+ return d->range(index).start + d->range(index).duration;
}
int BasicTimelineModel::getEventId(int index) const
{
- return d->startTimeData[index].eventId;
+ return d->range(index).eventId;
}
int BasicTimelineModel::getBindingLoopDest(int index) const
{
- return d->startTimeData[index].bindingLoopHead;
+ return d->range(index).bindingLoopHead;
}
QColor BasicTimelineModel::getColor(int index) const
@@ -655,7 +490,7 @@ const QVariantList BasicTimelineModel::getEventDetails(int index) const
// duration
{
QVariantMap valuePair;
- valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), QVariant(d->displayTime(d->startTimeData[index].duration)));
+ valuePair.insert(QCoreApplication::translate(trContext, "Duration:"), QVariant(d->displayTime(d->range(index).duration)));
result << valuePair;
}
diff --git a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h
index 973376ce32..cf13b94959 100644
--- a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h
+++ b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.h
@@ -65,22 +65,20 @@ public:
};
struct QmlRangeEventStartInstance {
- qint64 startTime;
- qint64 duration;
+ QmlRangeEventStartInstance(int eventId = -1) :
+ eventId(eventId),
+ displayRowExpanded(QmlDebug::Constants::QML_MIN_LEVEL),
+ displayRowCollapsed(QmlDebug::Constants::QML_MIN_LEVEL),
+ bindingLoopHead(-1) {}
+
int eventId;
// not-expanded, per type
int displayRowExpanded;
int displayRowCollapsed;
- int baseEventIndex; // used by findfirstindex
int bindingLoopHead;
};
- struct QmlRangeEventEndInstance {
- int startTimeIndex;
- qint64 endTime;
- };
-
BasicTimelineModel(QObject *parent = 0);
~BasicTimelineModel();
@@ -89,8 +87,6 @@ public:
QStringList categoryTitles() const;
QString name() const;
- const QVector<QmlRangeEventStartInstance> getData() const;
- const QVector<QmlRangeEventStartInstance> getData(qint64 fromTime, qint64 toTime) const;
void loadData();
Q_INVOKABLE int count() const;
void clear();
@@ -131,8 +127,6 @@ public:
private slots:
bool eventAccepted(const QmlProfilerSimpleModel::QmlEventData &event) const;
-protected slots:
- void dataChanged();
private:
class BasicTimelineModelPrivate;
diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp
index 98b11a4244..5d0db79bb0 100644
--- a/src/plugins/qmlprofiler/qmlprofilertool.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp
@@ -41,9 +41,6 @@
#include <analyzerbase/analyzermanager.h>
#include <analyzerbase/analyzerruncontrol.h>
-#include "canvas/qdeclarativecontext2d_p.h"
-#include "canvas/qmlprofilercanvas.h"
-
#include <utils/fancymainwindow.h>
#include <utils/fileinprojectfinder.h>
#include <utils/qtcassert.h>
@@ -119,9 +116,6 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
d->m_profilerState = 0;
d->m_viewContainer = 0;
- qmlRegisterType<QmlProfilerCanvas>("Monitor", 1, 0, "Canvas2D");
- qmlRegisterType<Context2D>();
- qmlRegisterType<CanvasGradient>();
qmlRegisterType<TimelineRenderer>("Monitor", 1, 0,"TimelineRenderer");
d->m_profilerState = new QmlProfilerStateManager(this);
@@ -528,6 +522,8 @@ void QmlProfilerTool::profilerDataModelStateChanged()
{
switch (d->m_profilerModelManager->state()) {
case QmlProfilerDataState::Empty :
+ break;
+ case QmlProfilerDataState::ClearingData :
clearDisplay();
break;
case QmlProfilerDataState::AcquiringData :
diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp
index 9246910498..df9adf3238 100644
--- a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp
@@ -117,6 +117,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
d->m_mainView = new QQuickView();
d->m_mainView->setResizeMode(QQuickView::SizeRootObjectToView);
QWidget *mainViewContainer = QWidget::createWindowContainer(d->m_mainView);
+ mainViewContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QHBoxLayout *toolsLayout = new QHBoxLayout;
@@ -130,7 +131,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
d->m_overview->setResizeMode(QQuickView::SizeRootObjectToView);
QWidget *overviewContainer = QWidget::createWindowContainer(d->m_overview);
overviewContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- overviewContainer->setMaximumHeight(50);
+ overviewContainer->setFixedHeight(50);
toolsLayout->addWidget(createToolbar());
toolsLayout->addWidget(timeBarContainer);
@@ -400,12 +401,6 @@ void QmlProfilerTraceView::updateToolTip(const QString &text)
void QmlProfilerTraceView::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
- QQuickItem *rootObject = d->m_mainView->rootObject();
- if (rootObject) {
- rootObject->setProperty("width", QVariant(event->size().width()));
- int newHeight = event->size().height() - d->m_timebar->height() - d->m_overview->height();
- rootObject->setProperty("candidateHeight", QVariant(newHeight));
- }
emit resized();
}
@@ -474,7 +469,8 @@ void QmlProfilerTraceView::setAppKilled()
void QmlProfilerTraceView::profilerDataModelStateChanged()
{
switch (d->m_modelManager->state()) {
- case QmlProfilerDataState::Empty:
+ case QmlProfilerDataState::Empty: break;
+ case QmlProfilerDataState::ClearingData:
d->m_mainView->hide();
emit enableToolbar(false);
break;
diff --git a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp
index aadd11fce9..ffb9389711 100644
--- a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp
@@ -112,6 +112,8 @@ void QmlProfilerViewManager::createViews()
d->v8profilerView = new QV8ProfilerEventsWidget(mw, d->profilerTool, this,
d->profilerModelManager);
+ connect(d->v8profilerView, SIGNAL(gotoSourceLocation(QString,int,int)), this,
+ SIGNAL(gotoSourceLocation(QString,int,int)));
connect(d->traceView, SIGNAL(gotoSourceLocation(QString,int,int)),
d->v8profilerView, SLOT(selectBySourceLocation(QString,int,int)));
connect(d->v8profilerView, SIGNAL(gotoSourceLocation(QString,int,int)),
diff --git a/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp b/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp
index 68e05039db..d6899b65a5 100644
--- a/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp
+++ b/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp
@@ -138,7 +138,7 @@ bool QV8ProfilerDataModel::isEmpty() const
QV8EventData *QV8ProfilerDataModel::v8EventDescription(int eventId) const
{
- foreach (QV8EventData *event, d->v8EventHash.values()) {
+ foreach (QV8EventData *event, d->v8EventHash) {
if (event->eventId == eventId)
return event;
}
@@ -235,7 +235,7 @@ void QV8ProfilerDataModel::QV8ProfilerDataModelPrivate::collectV8Statistics()
if (!v8EventHash.isEmpty()) {
double totalTimes = v8MeasuredTime;
double selfTimes = 0;
- foreach (QV8EventData *v8event, v8EventHash.values()) {
+ foreach (const QV8EventData *v8event, v8EventHash) {
selfTimes += v8event->selfTime;
}
@@ -261,7 +261,7 @@ void QV8ProfilerDataModel::QV8ProfilerDataModelPrivate::collectV8Statistics()
*v8EventHash[rootEventHash] = v8RootEvent;
}
- foreach (QV8EventData *v8event, v8EventHash.values()) {
+ foreach (QV8EventData *v8event, v8EventHash) {
v8event->totalPercent = v8event->totalTime * 100.0 / totalTimes;
v8event->SelfTimeInPercent = v8event->selfTime * 100.0 / selfTimes;
}
@@ -300,7 +300,7 @@ void QV8ProfilerDataModel::save(QXmlStreamWriter &stream)
{
stream.writeStartElement(QLatin1String("v8profile")); // v8 profiler output
stream.writeAttribute(QLatin1String("totalTime"), QString::number(d->v8MeasuredTime));
- foreach (QV8EventData *v8event, d->v8EventHash.values()) {
+ foreach (const QV8EventData *v8event, d->v8EventHash) {
stream.writeStartElement(QLatin1String("event"));
stream.writeAttribute(QLatin1String("index"),
QString::number(
@@ -319,7 +319,7 @@ void QV8ProfilerDataModel::save(QXmlStreamWriter &stream)
QStringList childrenIndexes;
QStringList childrenTimes;
QStringList parentTimes;
- foreach (QV8EventSub *v8child, v8event->childrenHash.values()) {
+ foreach (const QV8EventSub *v8child, v8event->childrenHash) {
childrenIndexes << QString::number(v8child->reference->eventId);
childrenTimes << QString::number(v8child->totalTime);
parentTimes << QString::number(v8child->totalTime);
@@ -468,7 +468,7 @@ void QV8ProfilerDataModel::load(QXmlStreamReader &stream)
}
}
// store v8 events
- foreach (QV8EventData *storedV8Event, v8eventBuffer.values()) {
+ foreach (QV8EventData *storedV8Event, v8eventBuffer) {
storedV8Event->eventHashStr =
getHashStringForV8Event(
storedV8Event->displayName, storedV8Event->functionName);
diff --git a/src/plugins/qmlprofiler/sortedtimelinemodel.cpp b/src/plugins/qmlprofiler/sortedtimelinemodel.cpp
new file mode 100644
index 0000000000..ae8f8e7641
--- /dev/null
+++ b/src/plugins/qmlprofiler/sortedtimelinemodel.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+/*!
+ \class QmlProfiler::SortedTimelineModel
+ \brief Sorted model for timeline data
+
+ The SortedTimelineModel lets you keep any kind of range data sorted by
+ both start and end times, so that visible ranges can easily be computed.
+*/
+
+/*!
+ \fn SortedTimelineModel::clear()
+ Clears the ranges and their end times.
+*/
+
+/*!
+ \fn int SortedTimelineModel::count() const
+ Returns the number of ranges in the model.
+*/
+
+/*!
+ \fn qint64 SortedTimelineModel::firstStartTime() const
+ Returns the begin of the first range in the model.
+*/
+
+/*!
+ \fn qint64 SortedTimelineModel::lastEndTime() const
+ Returns the end of the last range in the model.
+*/
+
+/*!
+ \fn const SortedTimelineModel<Data>::Range &SortedTimelineModel::range(int index) const
+ Returns the range data at the specified index.
+*/
+
+/*!
+ \fn Data &SortedTimelineModel::data(int index)
+ Returns modifiable user data for the range at the specified index.
+*/
+
+/*!
+ \fn int SortedTimelineModel::insert(qint64 startTime, qint64 duration, const Data &item)
+ Inserts the given data at the given time position and returns its index.
+*/
+
+/*!
+ \fn int SortedTimelineModel::insertStart(qint64 startTime, const Data &item)
+ Inserts the given data as range start at the given time position and
+ returns its index. The range end isn't set.
+*/
+
+/*!
+ \fn int SortedTimelineModel::insertEnd(int index, qint64 duration)
+ Adds a range end for the given start index.
+*/
+
+/*!
+ \fn int SortedTimelineModel::findFirstIndexNoParents(qint64 startTime) const
+ Looks up the first range with an end time greater than the given time and
+ returns its index. If no such range is found it returns -1.
+*/
+
+/*!
+ \fn int SortedTimelineModel::findFirstIndex(qint64 startTime) const
+ Looks up the first range with an end time greater than the given time and
+ returns its parent's index. If no such range is found it returns -1. If there
+ is no parent it returns the found range's index. The parent of a range is the
+ range with the lowest start time that completely covers the child range.
+ "Completely covers" means:
+ parent.startTime <= child.startTime && parent.endTime >= child.endTime
+*/
+
+/*!
+ \fn int SortedTimelineModel::findLastIndex(qint64 endTime) const
+ Looks up the last range with a start time smaller than the given time and
+ returns its index. If no such range is found it returns -1.
+*/
+
+/*!
+ \fn void computeNesting()
+ Compute all ranges' parents.
+ \sa findFirstIndex
+*/
diff --git a/src/plugins/qmlprofiler/sortedtimelinemodel.h b/src/plugins/qmlprofiler/sortedtimelinemodel.h
new file mode 100644
index 0000000000..29a5697fd3
--- /dev/null
+++ b/src/plugins/qmlprofiler/sortedtimelinemodel.h
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef SORTEDTIMELINEMODEL_H
+#define SORTEDTIMELINEMODEL_H
+
+#include <QVector>
+#include <QLinkedList>
+
+namespace QmlProfiler {
+
+template<class Data>
+class SortedTimelineModel {
+public:
+ struct Range : public Data {
+ Range() : Data(), start(-1), duration(-1), parent(-1) {}
+ Range(qint64 start, qint64 duration, const Data &item) :
+ Data(item), start(start), duration(duration), parent(-1) {}
+ qint64 start;
+ qint64 duration;
+ int parent;
+ inline qint64 timestamp() const {return start;}
+ };
+
+ struct RangeEnd {
+ RangeEnd() : startIndex(-1), end(-1) {}
+ RangeEnd(int startIndex, qint64 end) :
+ startIndex(startIndex), end(end) {}
+ int startIndex;
+ qint64 end;
+ inline qint64 timestamp() const {return end;}
+ };
+
+ void clear()
+ {
+ ranges.clear();
+ endTimes.clear();
+ }
+
+ inline int count() const { return ranges.count(); }
+
+ inline qint64 lastEndTime() const { return endTimes.last().end; }
+ inline qint64 firstStartTime() const { return ranges.first().start; }
+
+ inline const Range &range(int index) { return ranges[index]; }
+ inline Data &data(int index) { return ranges[index]; }
+
+ inline int insert(qint64 startTime, qint64 duration, const Data &item)
+ {
+ /* Doing insert-sort here is preferable as most of the time the times will actually be
+ * presorted in the right way. So usually this will just result in appending. */
+ int index = insertSorted(ranges, Range(startTime, duration, item));
+ insertSorted(endTimes, RangeEnd(index, startTime + duration));
+ return index;
+ }
+
+ inline int insertStart(qint64 startTime, const Data &item)
+ {
+ return insertSorted(ranges, Range(startTime, 0, item));
+ }
+
+ inline void insertEnd(int index, qint64 duration)
+ {
+ ranges[index].duration = duration;
+ insertSorted(endTimes, RangeEnd(index, ranges[index].start + duration));
+ }
+
+ inline int findFirstIndex(qint64 startTime) const
+ {
+ int index = findFirstIndexNoParents(startTime);
+ if (index == -1)
+ return -1;
+ int parent = ranges[index].parent;
+ return parent == -1 ? index : parent;
+ }
+
+ inline int findFirstIndexNoParents(qint64 startTime) const
+ {
+ // in the "endtime" list, find the first event that ends after startTime
+ if (endTimes.isEmpty())
+ return -1;
+ if (endTimes.count() == 1 || endTimes.first().end >= startTime)
+ return endTimes.first().startIndex;
+ if (endTimes.last().end <= startTime)
+ return -1;
+
+ return endTimes[lowerBound(endTimes, startTime) + 1].startIndex;
+ }
+
+ inline int findLastIndex(qint64 endTime) const
+ {
+ // in the "starttime" list, find the last event that starts before endtime
+ if (ranges.isEmpty() || ranges.first().start >= endTime)
+ return -1;
+ if (ranges.count() == 1)
+ return 0;
+ if (ranges.last().start <= endTime)
+ return ranges.count() - 1;
+
+ return lowerBound(ranges, endTime);
+ }
+
+ inline void computeNesting()
+ {
+ QLinkedList<int> parents;
+ for (int range = 0; range != count(); ++range) {
+ Range &current = ranges[range];
+ for (QLinkedList<int>::iterator parent = parents.begin(); parent != parents.end();) {
+ qint64 parentEnd = ranges[*parent].start + ranges[*parent].duration;
+ if (parentEnd < current.start) {
+ parent = parents.erase(parent);
+ } else if (parentEnd >= current.start + current.duration) {
+ current.parent = *parent;
+ break;
+ } else {
+ ++parent;
+ }
+ }
+ parents.append(range);
+ }
+ }
+
+protected:
+ template<typename RangeDelimiter>
+ static inline int insertSorted(QVector<RangeDelimiter> &container, const RangeDelimiter &item)
+ {
+ for (int i = container.count();;) {
+ if (i == 0) {
+ container.prepend(item);
+ return 0;
+ }
+ if (container[--i].timestamp() <= item.timestamp()) {
+ container.insert(++i, item);
+ return i;
+ }
+ }
+ }
+
+ template<typename RangeDelimiter>
+ static inline int lowerBound(const QVector<RangeDelimiter> container, qint64 time)
+ {
+ int fromIndex = 0;
+ int toIndex = container.count() - 1;
+ while (toIndex - fromIndex > 1) {
+ int midIndex = (fromIndex + toIndex)/2;
+ if (container[midIndex].timestamp() < time)
+ fromIndex = midIndex;
+ else
+ toIndex = midIndex;
+ }
+
+ return fromIndex;
+ }
+
+ QVector<Range> ranges;
+ QVector<RangeEnd> endTimes;
+};
+
+}
+
+#endif
diff --git a/src/plugins/qmlprojectmanager/qmlapp.cpp b/src/plugins/qmlprojectmanager/qmlapp.cpp
index 442b3c2e29..57a58b6a7a 100644
--- a/src/plugins/qmlprojectmanager/qmlapp.cpp
+++ b/src/plugins/qmlprojectmanager/qmlapp.cpp
@@ -154,7 +154,6 @@ static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info)
static const QLatin1String tag_template("template");
static const QLatin1String tag_displayName("displayname");
static const QLatin1String tag_description("description");
- static const QLatin1String attribute_id("id");
static const QLatin1String attribute_featuresRequired("featuresRequired");
static const QLatin1String attribute_openEditor("openeditor");
static const QLatin1String attribute_priority("priority");
@@ -169,9 +168,6 @@ static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info)
if (reader.attributes().hasAttribute(attribute_priority))
info->priority = reader.attributes().value(attribute_priority).toString();
- if (reader.attributes().hasAttribute(attribute_id))
- info->wizardId = reader.attributes().value(attribute_id).toString();
-
if (reader.attributes().hasAttribute(attribute_featuresRequired))
info->featuresRequired = reader.attributes().value(attribute_featuresRequired).toString();
diff --git a/src/plugins/qmlprojectmanager/qmlapp.h b/src/plugins/qmlprojectmanager/qmlapp.h
index e19a6d4183..b023caeb48 100644
--- a/src/plugins/qmlprojectmanager/qmlapp.h
+++ b/src/plugins/qmlprojectmanager/qmlapp.h
@@ -47,7 +47,6 @@ public:
QString displayName;
QString description;
QString openFile;
- QString wizardId;
QString featuresRequired;
QString priority;
};
diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp
index b025fd55f0..76a07ce9de 100644
--- a/src/plugins/qmlprojectmanager/qmlproject.cpp
+++ b/src/plugins/qmlprojectmanager/qmlproject.cpp
@@ -111,6 +111,7 @@ QmlProject::QmlProject(Internal::Manager *manager, const QString &fileName)
m_modelManager(QmlJS::ModelManagerInterface::instance()),
m_activeTarget(0)
{
+ setId("QmlProjectManager.QmlProject");
setProjectContext(Context(QmlProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Context(ProjectExplorer::Constants::LANG_QMLJS));
@@ -324,11 +325,6 @@ QString QmlProject::displayName() const
return m_projectName;
}
-Id QmlProject::id() const
-{
- return "QmlProjectManager.QmlProject";
-}
-
IDocument *QmlProject::document() const
{
return m_file;
diff --git a/src/plugins/qmlprojectmanager/qmlproject.h b/src/plugins/qmlprojectmanager/qmlproject.h
index cc9563bc9f..87626091fa 100644
--- a/src/plugins/qmlprojectmanager/qmlproject.h
+++ b/src/plugins/qmlprojectmanager/qmlproject.h
@@ -61,7 +61,6 @@ public:
QString filesFileName() const;
QString displayName() const;
- Core::Id id() const;
Core::IDocument *document() const;
ProjectExplorer::IProjectManager *projectManager() const;
diff --git a/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp b/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp
index 493545ebb6..3e20f653e7 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp
@@ -176,7 +176,11 @@ QList<ProjectExplorer::ProjectNode::ProjectAction> QmlProjectNode::supportedActi
QList<ProjectAction> actions;
actions.append(AddNewFile);
actions.append(EraseFile);
- actions.append(Rename);
+ if (node->nodeType() == ProjectExplorer::FileNodeType) {
+ ProjectExplorer::FileNode *fileNode = static_cast<ProjectExplorer::FileNode *>(node);
+ if (fileNode->fileType() != ProjectExplorer::ProjectFileType)
+ actions.append(Rename);
+ }
return actions;
}
diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp
index 6f5b3b3e92..ec0f870ca3 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp
@@ -140,16 +140,6 @@ QString QmlProjectRunConfiguration::commandLineArguments() const
return args;
}
-QString QmlProjectRunConfiguration::dumperLibrary() const
-{
- return QString();
-}
-
-QStringList QmlProjectRunConfiguration::dumperLibraryLocations() const
-{
- return QStringList();
-}
-
QString QmlProjectRunConfiguration::workingDirectory() const
{
QFileInfo projectFile(target()->project()->projectFilePath());
diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h
index c83a1af18a..489d6c4ac2 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h
+++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h
@@ -65,8 +65,6 @@ public:
QString executable() const;
RunMode runMode() const;
QString commandLineArguments() const;
- QString dumperLibrary() const;
- QStringList dumperLibraryLocations() const;
QString workingDirectory() const;
QtSupport::BaseQtVersion *qtVersion() const;
diff --git a/src/plugins/qnx/bardescriptoreditor.cpp b/src/plugins/qnx/bardescriptoreditor.cpp
index fea8c591ab..671a34e677 100644
--- a/src/plugins/qnx/bardescriptoreditor.cpp
+++ b/src/plugins/qnx/bardescriptoreditor.cpp
@@ -38,11 +38,15 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/task.h>
#include <projectexplorer/taskhub.h>
-#include <utils/qtcassert.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/basetexteditor.h>
+#include <texteditor/tabsettings.h>
+#include <utils/linecolumnlabel.h>
+#include <utils/qtcassert.h>
#include <QAction>
+#include <QStyle>
+#include <QTextBlock>
#include <QToolBar>
using namespace ProjectExplorer;
@@ -50,11 +54,12 @@ using namespace ProjectExplorer;
namespace Qnx {
namespace Internal {
-BarDescriptorEditor::BarDescriptorEditor(BarDescriptorEditorWidget *editorWidget)
+BarDescriptorEditor::BarDescriptorEditor()
{
+ BarDescriptorEditorWidget *editorWidget = new BarDescriptorEditorWidget(this);
setWidget(editorWidget);
-
m_file = new BarDescriptorDocument(editorWidget);
+ connect(editorWidget, SIGNAL(changed()), m_file, SIGNAL(changed()));
m_toolBar = new QToolBar(editorWidget);
@@ -83,6 +88,17 @@ BarDescriptorEditor::BarDescriptorEditor(BarDescriptorEditorWidget *editorWidget
generalAction->setChecked(true);
+ m_cursorPositionLabel = new Utils::LineColumnLabel;
+ const int spacing = editorWidget->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2;
+ m_cursorPositionLabel->setContentsMargins(spacing, 0, spacing, 0);
+
+ QWidget *spacer = new QWidget;
+ spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ m_toolBar->addWidget(spacer);
+
+ m_cursorPositionAction = m_toolBar->addWidget(m_cursorPositionLabel);
+ connect(editorWidget->sourceWidget(), SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition()));
+
setContext(Core::Context(Constants::QNX_BAR_DESCRIPTOR_EDITOR_CONTEXT,
TextEditor::Constants::C_TEXTEDITOR));
}
@@ -133,6 +149,7 @@ void BarDescriptorEditor::setActivePage(BarDescriptorEditor::EditorPage page)
if (page == Source) {
editorWidget->setXmlSource(m_file->xmlSource());
+ updateCursorPosition();
} else if (prevPage == Source) {
TaskHub::clearTasks(Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR);
QString errorMsg;
@@ -150,8 +167,24 @@ void BarDescriptorEditor::setActivePage(BarDescriptorEditor::EditorPage page)
}
}
+ m_cursorPositionAction->setVisible(page == Source);
editorWidget->setCurrentIndex(page);
}
+void BarDescriptorEditor::updateCursorPosition()
+{
+ BarDescriptorEditorWidget *editorWidget = qobject_cast<BarDescriptorEditorWidget *>(widget());
+ QTC_ASSERT(editorWidget, return);
+
+ const QTextCursor cursor = editorWidget->sourceWidget()->textCursor();
+ const QTextBlock block = cursor.block();
+ const int line = block.blockNumber() + 1;
+ const int column = cursor.position() - block.position();
+ m_cursorPositionLabel->setText(tr("Line: %1, Col: %2").arg(line).arg(editorWidget->sourceWidget()->tabSettings().columnAt(block.text(), column)+1),
+ tr("Line: 9999, Col: 999"));
+ if (!block.isVisible())
+ editorWidget->sourceWidget()->ensureCursorVisible();
+}
+
} // namespace Internal
} // namespace Qnx
diff --git a/src/plugins/qnx/bardescriptoreditor.h b/src/plugins/qnx/bardescriptoreditor.h
index 3ecb63b3f0..ce235885e2 100644
--- a/src/plugins/qnx/bardescriptoreditor.h
+++ b/src/plugins/qnx/bardescriptoreditor.h
@@ -39,6 +39,10 @@ class QActionGroup;
class QToolBar;
QT_END_NAMESPACE
+namespace Utils {
+class LineColumnLabel;
+}
+
namespace Qnx {
namespace Internal {
@@ -56,7 +60,7 @@ public:
Source
};
- explicit BarDescriptorEditor(BarDescriptorEditorWidget *editorWidget);
+ BarDescriptorEditor();
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document();
@@ -67,6 +71,7 @@ public:
private slots:
void changeEditorPage(QAction *action);
+ void updateCursorPosition();
private:
void setActivePage(EditorPage page);
@@ -75,6 +80,8 @@ private:
QToolBar *m_toolBar;
QActionGroup *m_actionGroup;
+ Utils::LineColumnLabel *m_cursorPositionLabel;
+ QAction *m_cursorPositionAction;
};
} // namespace Internal
diff --git a/src/plugins/qnx/bardescriptoreditorfactory.cpp b/src/plugins/qnx/bardescriptoreditorfactory.cpp
index 1a8457b136..2bf90396f9 100644
--- a/src/plugins/qnx/bardescriptoreditorfactory.cpp
+++ b/src/plugins/qnx/bardescriptoreditorfactory.cpp
@@ -32,6 +32,7 @@
#include "bardescriptoreditorfactory.h"
#include "qnxconstants.h"
+#include "bardescriptoreditor.h"
#include "bardescriptoreditorwidget.h"
#include <coreplugin/editormanager/editormanager.h>
@@ -44,8 +45,8 @@ using namespace Qnx::Internal;
class BarDescriptorActionHandler : public TextEditor::TextEditorActionHandler
{
public:
- BarDescriptorActionHandler()
- : TextEditor::TextEditorActionHandler(Constants::QNX_BAR_DESCRIPTOR_EDITOR_CONTEXT)
+ BarDescriptorActionHandler(QObject *parent)
+ : TextEditor::TextEditorActionHandler(parent, Constants::QNX_BAR_DESCRIPTOR_EDITOR_CONTEXT)
{
}
protected:
@@ -58,20 +59,15 @@ protected:
BarDescriptorEditorFactory::BarDescriptorEditorFactory(QObject *parent)
: Core::IEditorFactory(parent)
- , m_actionHandler(new BarDescriptorActionHandler)
{
setId(Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID);
setDisplayName(tr("Bar descriptor editor"));
addMimeType(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE);
+ new BarDescriptorActionHandler(this);
}
-BarDescriptorEditorFactory::~BarDescriptorEditorFactory()
+Core::IEditor *BarDescriptorEditorFactory::createEditor()
{
- delete m_actionHandler;
-}
-
-Core::IEditor *BarDescriptorEditorFactory::createEditor(QWidget *parent)
-{
- BarDescriptorEditorWidget *editorWidget = new BarDescriptorEditorWidget(parent, m_actionHandler);
- return editorWidget->editor();
+ BarDescriptorEditor *editor = new BarDescriptorEditor();
+ return editor;
}
diff --git a/src/plugins/qnx/bardescriptoreditorfactory.h b/src/plugins/qnx/bardescriptoreditorfactory.h
index 97d8c80550..2edf3cf7c2 100644
--- a/src/plugins/qnx/bardescriptoreditorfactory.h
+++ b/src/plugins/qnx/bardescriptoreditorfactory.h
@@ -34,10 +34,6 @@
#include <coreplugin/editormanager/ieditorfactory.h>
-namespace TextEditor {
-class TextEditorActionHandler;
-}
-
namespace Qnx {
namespace Internal {
@@ -47,12 +43,8 @@ class BarDescriptorEditorFactory : public Core::IEditorFactory
public:
explicit BarDescriptorEditorFactory(QObject *parent = 0);
- ~BarDescriptorEditorFactory();
-
- Core::IEditor *createEditor(QWidget *parent);
-private:
- TextEditor::TextEditorActionHandler *m_actionHandler;
+ Core::IEditor *createEditor();
};
} // namespace Internal
diff --git a/src/plugins/qnx/bardescriptoreditorwidget.cpp b/src/plugins/qnx/bardescriptoreditorwidget.cpp
index 1ea571ac76..8a00efa22a 100644
--- a/src/plugins/qnx/bardescriptoreditorwidget.cpp
+++ b/src/plugins/qnx/bardescriptoreditorwidget.cpp
@@ -45,18 +45,15 @@
#include <projectexplorer/iprojectproperties.h>
#include <projectexplorer/projectwindow.h>
#include <texteditor/plaintexteditor.h>
-#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/texteditorconstants.h>
using namespace Qnx;
using namespace Qnx::Internal;
-BarDescriptorEditorWidget::BarDescriptorEditorWidget(
- QWidget *parent, TextEditor::TextEditorActionHandler *handler)
+BarDescriptorEditorWidget::BarDescriptorEditorWidget(BarDescriptorEditor *editor, QWidget *parent)
: QStackedWidget(parent)
- , m_editor(0)
- , m_handler(handler)
+ , m_editor(editor)
, m_dirty(false)
{
Core::IContext *myContext = new Core::IContext(this);
@@ -161,7 +158,6 @@ void BarDescriptorEditorWidget::initSourcePage()
addWidget(m_xmlSourceWidget);
TextEditor::TextEditorSettings::initializeEditor(m_xmlSourceWidget);
- m_handler->setupActions(m_xmlSourceWidget);
m_xmlSourceWidget->configure(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE));
connect(m_xmlSourceWidget, SIGNAL(textChanged()), this, SLOT(setDirty()));
}
@@ -174,11 +170,6 @@ void BarDescriptorEditorWidget::initPanelSize(ProjectExplorer::PanelsWidget *pan
Core::IEditor *BarDescriptorEditorWidget::editor() const
{
- if (!m_editor) {
- m_editor = const_cast<BarDescriptorEditorWidget *>(this)->createEditor();
- connect(this, SIGNAL(changed()), m_editor->document(), SIGNAL(changed()));
- }
-
return m_editor;
}
@@ -224,7 +215,7 @@ TextEditor::BaseTextEditorWidget *BarDescriptorEditorWidget::sourceWidget() cons
void BarDescriptorEditorWidget::setFilePath(const QString &filePath)
{
- Core::IDocument *doc = m_xmlSourceWidget->editorDocument();
+ Core::IDocument *doc = m_xmlSourceWidget->baseTextDocument();
if (doc) {
doc->setFilePath(filePath);
// setFilePath() call leads to a textChanged() signal emitted
@@ -273,8 +264,3 @@ void BarDescriptorEditorWidget::setDirty(bool dirty)
m_dirty = dirty;
emit changed();
}
-
-BarDescriptorEditor *BarDescriptorEditorWidget::createEditor()
-{
- return new BarDescriptorEditor(this);
-}
diff --git a/src/plugins/qnx/bardescriptoreditorwidget.h b/src/plugins/qnx/bardescriptoreditorwidget.h
index 00677c7332..256546de83 100644
--- a/src/plugins/qnx/bardescriptoreditorwidget.h
+++ b/src/plugins/qnx/bardescriptoreditorwidget.h
@@ -46,7 +46,6 @@ class PanelsWidget;
namespace TextEditor {
class PlainTextEditorWidget;
-class TextEditorActionHandler;
class BaseTextEditorWidget;
}
@@ -67,7 +66,7 @@ class BarDescriptorEditorWidget : public QStackedWidget
Q_OBJECT
public:
- explicit BarDescriptorEditorWidget(QWidget *parent, TextEditor::TextEditorActionHandler *handler);
+ explicit BarDescriptorEditorWidget(BarDescriptorEditor *editor, QWidget *parent = 0);
Core::IEditor *editor() const;
@@ -97,17 +96,14 @@ signals:
void changed();
private:
- BarDescriptorEditor *createEditor();
-
void initGeneralPage();
void initApplicationPage();
void initAssetsPage();
void initSourcePage();
void initPanelSize(ProjectExplorer::PanelsWidget *panelsWidget);
- mutable Core::IEditor *m_editor;
+ Core::IEditor *m_editor;
- TextEditor::TextEditorActionHandler *m_handler;
bool m_dirty;
// New UI
diff --git a/src/plugins/qnx/blackberrycertificate.cpp b/src/plugins/qnx/blackberrycertificate.cpp
index 036e0d5894..ce82928ed0 100644
--- a/src/plugins/qnx/blackberrycertificate.cpp
+++ b/src/plugins/qnx/blackberrycertificate.cpp
@@ -54,7 +54,7 @@ BlackBerryCertificate::BlackBerryCertificate(const QString &fileName,
{
m_process->setProcessChannelMode(QProcess::MergedChannels);
m_process->setEnvironment(Utils::EnvironmentItem::toStringList(
- BlackBerryConfigurationManager::instance().defaultQnxEnv()));
+ BlackBerryConfigurationManager::instance().defaultApiLevelEnv()));
}
void BlackBerryCertificate::load()
diff --git a/src/plugins/qnx/blackberrycheckdebugtokenstep.cpp b/src/plugins/qnx/blackberrycheckdebugtokenstep.cpp
new file mode 100644
index 0000000000..b707e6d1b6
--- /dev/null
+++ b/src/plugins/qnx/blackberrycheckdebugtokenstep.cpp
@@ -0,0 +1,156 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+**
+** Contact: BlackBerry (qt@blackberry.com)
+** Contact: KDAB (info@kdab.com)
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "blackberrycheckdebugtokenstep.h"
+
+#include "blackberrycheckdebugtokenstepconfigwidget.h"
+#include "blackberrydeviceinformation.h"
+#include "qnxconstants.h"
+
+#include <projectexplorer/buildconfiguration.h>
+#include <projectexplorer/projectexplorerconstants.h>
+#include <projectexplorer/target.h>
+#include <projectexplorer/task.h>
+#include <ssh/sshconnection.h>
+
+#include <qeventloop.h>
+
+using namespace Qnx;
+using namespace Qnx::Internal;
+
+BlackBerryCheckDebugTokenStep::BlackBerryCheckDebugTokenStep(ProjectExplorer::BuildStepList *bsl) :
+ ProjectExplorer::BuildStep(bsl, Core::Id(Constants::QNX_CHECK_DEBUG_TOKEN_BS_ID))
+ , m_deviceInfo(0)
+ , m_eventLoop(0)
+{
+ setDisplayName(tr("Check Debug Token"));
+}
+
+BlackBerryCheckDebugTokenStep::BlackBerryCheckDebugTokenStep(ProjectExplorer::BuildStepList *bsl, BlackBerryCheckDebugTokenStep *bs) :
+ ProjectExplorer::BuildStep(bsl, bs)
+ , m_deviceInfo(0)
+ , m_eventLoop(0)
+{
+ setDisplayName(tr("Check Debug Token"));
+}
+
+void BlackBerryCheckDebugTokenStep::checkDeviceInfo(int status)
+{
+ // Skip debug token check for internal non secure devices and simulators
+ if (m_deviceInfo->isProductionDevice() && !m_deviceInfo->isSimulator()) {
+ if (status != BlackBerryDeviceInformation::Success) {
+ switch (status) {
+ case BlackBerryDeviceInformation::AuthenticationFailed:
+ raiseError(tr("Authentication failed."));
+ break;
+ case BlackBerryDeviceInformation::NoRouteToHost:
+ raiseError(tr("Cannot connect to device."));
+ break;
+ case BlackBerryDeviceInformation::DevelopmentModeDisabled:
+ raiseError(tr("Device is not in the development mode."));
+ break;
+ case BlackBerryDeviceInformation::InferiorProcessTimedOut:
+ raiseError(tr("Timeout querying device information."));
+ break;
+ case BlackBerryDeviceInformation::FailedToStartInferiorProcess:
+ raiseError(tr("Failed to query device information."));
+ break;
+ case BlackBerryDeviceInformation::InferiorProcessCrashed:
+ raiseError(tr("Process to query device information has crashed."));
+ break;
+ default:
+ raiseError(tr("Cannot query device information."));
+ break;
+ }
+ m_eventLoop->exit(false);
+ return;
+ }
+
+ if (!m_deviceInfo->debugTokenValid()) {
+ raiseError(m_deviceInfo->debugTokenValidationError());
+ m_eventLoop->exit(false);
+ return;
+ }
+ }
+
+ m_eventLoop->exit(true);
+}
+
+void BlackBerryCheckDebugTokenStep::emitOutputInfo()
+{
+ emit addOutput(tr("Checking debug token..."), BuildStep::MessageOutput);
+}
+
+bool BlackBerryCheckDebugTokenStep::init()
+{
+ m_device = BlackBerryDeviceConfiguration::device(target()->kit());
+ if (!m_device)
+ return false;
+
+ if (m_device->sshParameters().host.isEmpty()) {
+ raiseError(tr("No hostname specified for the device"));
+ return false;
+ }
+
+ return true;
+}
+
+void BlackBerryCheckDebugTokenStep::run(QFutureInterface<bool> &fi)
+{
+ m_eventLoop = new QEventLoop;
+ m_deviceInfo = new BlackBerryDeviceInformation;
+
+ connect(m_deviceInfo, SIGNAL(started()), this, SLOT(emitOutputInfo()));
+ connect(m_deviceInfo, SIGNAL(finished(int)), this, SLOT(checkDeviceInfo(int)), Qt::DirectConnection);
+ m_deviceInfo->setDeviceTarget(m_device->sshParameters().host, m_device->sshParameters().password);
+
+ bool returnValue = m_eventLoop->exec();
+
+ delete m_eventLoop;
+ m_eventLoop = 0;
+
+ delete m_deviceInfo;
+ m_deviceInfo = 0;
+
+ return fi.reportResult(returnValue);
+}
+
+ProjectExplorer::BuildStepConfigWidget *BlackBerryCheckDebugTokenStep::createConfigWidget()
+{
+ return new BlackBerryCheckDebugTokenConfigWidget();
+}
+
+void BlackBerryCheckDebugTokenStep::raiseError(const QString &errorMessage)
+{
+ emit addOutput(errorMessage, BuildStep::ErrorMessageOutput);
+ emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error, errorMessage, Utils::FileName(), -1,
+ ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT));
+}
diff --git a/src/plugins/qnx/blackberrycheckdebugtokenstep.h b/src/plugins/qnx/blackberrycheckdebugtokenstep.h
new file mode 100644
index 0000000000..3a39777958
--- /dev/null
+++ b/src/plugins/qnx/blackberrycheckdebugtokenstep.h
@@ -0,0 +1,77 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+**
+** Contact: BlackBerry (qt@blackberry.com)
+** Contact: KDAB (info@kdab.com)
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QNX_INTERNAL_BLACKBERRYCHECKDEBUGTOKENSTEP_H
+#define QNX_INTERNAL_BLACKBERRYCHECKDEBUGTOKENSTEP_H
+
+#include "blackberrydeviceconfiguration.h"
+
+#include <projectexplorer/buildstep.h>
+
+QT_BEGIN_NAMESPACE
+class QEventLoop;
+QT_END_NAMESPACE
+
+namespace Qnx {
+namespace Internal {
+
+class BlackBerryDeviceInformation;
+class BlackBerryCheckDebugTokenStep : public ProjectExplorer::BuildStep
+{
+ Q_OBJECT
+ friend class BlackBerryCheckDebugTokenStepFactory;
+
+public:
+ explicit BlackBerryCheckDebugTokenStep(ProjectExplorer::BuildStepList *bsl);
+
+ bool init();
+ void run(QFutureInterface<bool> &fi);
+ ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
+
+ void raiseError(const QString& error);
+
+protected:
+ BlackBerryCheckDebugTokenStep(ProjectExplorer::BuildStepList *bsl, BlackBerryCheckDebugTokenStep *bs);
+
+protected slots:
+ void checkDeviceInfo(int status);
+ void emitOutputInfo();
+
+private:
+ BlackBerryDeviceInformation *m_deviceInfo;
+ BlackBerryDeviceConfiguration::ConstPtr m_device;
+ QEventLoop *m_eventLoop;
+};
+
+} // namespace Internal
+} // namespace Qnx
+
+#endif // QNX_INTERNAL_BLACKBERRYCHECKDEBUGTOKENSTEP_H
diff --git a/src/plugins/qnx/blackberrycheckdevmodestepconfigwidget.cpp b/src/plugins/qnx/blackberrycheckdebugtokenstepconfigwidget.cpp
index 45ef8c5361..3b19d5c32a 100644
--- a/src/plugins/qnx/blackberrycheckdevmodestepconfigwidget.cpp
+++ b/src/plugins/qnx/blackberrycheckdebugtokenstepconfigwidget.cpp
@@ -29,27 +29,27 @@
**
****************************************************************************/
-#include "blackberrycheckdevmodestepconfigwidget.h"
+#include "blackberrycheckdebugtokenstepconfigwidget.h"
using namespace Qnx;
using namespace Qnx::Internal;
-BlackBerryCheckDevModeStepConfigWidget::BlackBerryCheckDevModeStepConfigWidget() :
+BlackBerryCheckDebugTokenConfigWidget::BlackBerryCheckDebugTokenConfigWidget() :
ProjectExplorer::BuildStepConfigWidget()
{
}
-QString BlackBerryCheckDevModeStepConfigWidget::displayName() const
+QString BlackBerryCheckDebugTokenConfigWidget::displayName() const
{
- return tr("<b>Check development mode</b>");
+ return tr("<b>Check debug token</b>");
}
-QString BlackBerryCheckDevModeStepConfigWidget::summaryText() const
+QString BlackBerryCheckDebugTokenConfigWidget::summaryText() const
{
return displayName();
}
-bool BlackBerryCheckDevModeStepConfigWidget::showWidget() const
+bool BlackBerryCheckDebugTokenConfigWidget::showWidget() const
{
return false;
}
diff --git a/src/plugins/qnx/blackberrycheckdevmodestepconfigwidget.h b/src/plugins/qnx/blackberrycheckdebugtokenstepconfigwidget.h
index 02c555492d..e7d6a16df0 100644
--- a/src/plugins/qnx/blackberrycheckdevmodestepconfigwidget.h
+++ b/src/plugins/qnx/blackberrycheckdebugtokenstepconfigwidget.h
@@ -29,19 +29,19 @@
**
****************************************************************************/
-#ifndef QNX_INTERNAL_BLACKBERRYCHECKDEVMODESTEPCONFIGWIDGET_H
-#define QNX_INTERNAL_BLACKBERRYCHECKDEVMODESTEPCONFIGWIDGET_H
+#ifndef QNX_INTERNAL_BLACKBERRYCHECKDEBUGTOKENSTEPCONFIGWIDGET_H
+#define QNX_INTERNAL_BLACKBERRYCHECKDEBUGTOKENSTEPCONFIGWIDGET_H
#include <projectexplorer/buildstep.h>
namespace Qnx {
namespace Internal {
-class BlackBerryCheckDevModeStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
+class BlackBerryCheckDebugTokenConfigWidget : public ProjectExplorer::BuildStepConfigWidget
{
Q_OBJECT
public:
- explicit BlackBerryCheckDevModeStepConfigWidget();
+ explicit BlackBerryCheckDebugTokenConfigWidget();
QString displayName() const;
QString summaryText() const;
diff --git a/src/plugins/qnx/blackberrycheckdevmodestepfactory.cpp b/src/plugins/qnx/blackberrycheckdebugtokenstepfactory.cpp
index df1a378303..b20912bfde 100644
--- a/src/plugins/qnx/blackberrycheckdevmodestepfactory.cpp
+++ b/src/plugins/qnx/blackberrycheckdebugtokenstepfactory.cpp
@@ -29,9 +29,9 @@
**
****************************************************************************/
-#include "blackberrycheckdevmodestepfactory.h"
+#include "blackberrycheckdebugtokenstepfactory.h"
-#include "blackberrycheckdevmodestep.h"
+#include "blackberrycheckdebugtokenstep.h"
#include "blackberrydeviceconfigurationfactory.h"
#include "qnxconstants.h"
@@ -43,12 +43,12 @@
using namespace Qnx;
using namespace Qnx::Internal;
-BlackBerryCheckDevModeStepFactory::BlackBerryCheckDevModeStepFactory(QObject *parent) :
+BlackBerryCheckDebugTokenStepFactory::BlackBerryCheckDebugTokenStepFactory(QObject *parent) :
ProjectExplorer::IBuildStepFactory(parent)
{
}
-QList<Core::Id> BlackBerryCheckDevModeStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const
+QList<Core::Id> BlackBerryCheckDebugTokenStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const
{
if (parent->id() != ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)
return QList<Core::Id>();
@@ -57,52 +57,52 @@ QList<Core::Id> BlackBerryCheckDevModeStepFactory::availableCreationIds(ProjectE
if (deviceType != BlackBerryDeviceConfigurationFactory::deviceType())
return QList<Core::Id>();
- return QList<Core::Id>() << Core::Id(Constants::QNX_CHECK_DEVELOPMENT_MODE_BS_ID);
+ return QList<Core::Id>() << Core::Id(Constants::QNX_CHECK_DEBUG_TOKEN_BS_ID);
}
-QString BlackBerryCheckDevModeStepFactory::displayNameForId(const Core::Id id) const
+QString BlackBerryCheckDebugTokenStepFactory::displayNameForId(const Core::Id id) const
{
- if (id == Constants::QNX_CHECK_DEVELOPMENT_MODE_BS_ID)
- return tr("Check Development Mode");
+ if (id == Constants::QNX_CHECK_DEBUG_TOKEN_BS_ID)
+ return tr("Check Debug Token");
return QString();
}
-bool BlackBerryCheckDevModeStepFactory::canCreate(ProjectExplorer::BuildStepList *parent, const Core::Id id) const
+bool BlackBerryCheckDebugTokenStepFactory::canCreate(ProjectExplorer::BuildStepList *parent, const Core::Id id) const
{
return availableCreationIds(parent).contains(id);
}
-ProjectExplorer::BuildStep *BlackBerryCheckDevModeStepFactory::create(ProjectExplorer::BuildStepList *parent, const Core::Id id)
+ProjectExplorer::BuildStep *BlackBerryCheckDebugTokenStepFactory::create(ProjectExplorer::BuildStepList *parent, const Core::Id id)
{
if (!canCreate(parent, id))
return 0;
- return new BlackBerryCheckDevModeStep(parent);
+ return new BlackBerryCheckDebugTokenStep(parent);
}
-bool BlackBerryCheckDevModeStepFactory::canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const
+bool BlackBerryCheckDebugTokenStepFactory::canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const
{
return canCreate(parent, ProjectExplorer::idFromMap(map));
}
-ProjectExplorer::BuildStep *BlackBerryCheckDevModeStepFactory::restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map)
+ProjectExplorer::BuildStep *BlackBerryCheckDebugTokenStepFactory::restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map)
{
if (!canRestore(parent, map))
return 0;
- BlackBerryCheckDevModeStep *bs = new BlackBerryCheckDevModeStep(parent);
+ BlackBerryCheckDebugTokenStep *bs = new BlackBerryCheckDebugTokenStep(parent);
if (bs->fromMap(map))
return bs;
delete bs;
return 0;
}
-bool BlackBerryCheckDevModeStepFactory::canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const
+bool BlackBerryCheckDebugTokenStepFactory::canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const
{
return canCreate(parent, product->id());
}
-ProjectExplorer::BuildStep *BlackBerryCheckDevModeStepFactory::clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product)
+ProjectExplorer::BuildStep *BlackBerryCheckDebugTokenStepFactory::clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product)
{
if (!canClone(parent, product))
return 0;
- return new BlackBerryCheckDevModeStep(parent, static_cast<BlackBerryCheckDevModeStep *>(product));
+ return new BlackBerryCheckDebugTokenStep(parent, static_cast<BlackBerryCheckDebugTokenStep *>(product));
}
diff --git a/src/plugins/qnx/blackberrycheckdevmodestepfactory.h b/src/plugins/qnx/blackberrycheckdebugtokenstepfactory.h
index c06bdc0f0d..be3676f0ad 100644
--- a/src/plugins/qnx/blackberrycheckdevmodestepfactory.h
+++ b/src/plugins/qnx/blackberrycheckdebugtokenstepfactory.h
@@ -29,19 +29,19 @@
**
****************************************************************************/
-#ifndef QNX_INTERNAL_BLACKBERRYCHECKDEVMODESTEPFACTORY_H
-#define QNX_INTERNAL_BLACKBERRYCHECKDEVMODESTEPFACTORY_H
+#ifndef QNX_INTERNAL_BLACKBERRYCHECKDEBUGTOKENSTEPFACTORY_H
+#define QNX_INTERNAL_BLACKBERRYCHECKDEBUGTOKENSTEPFACTORY_H
#include <projectexplorer/buildstep.h>
namespace Qnx {
namespace Internal {
-class BlackBerryCheckDevModeStepFactory : public ProjectExplorer::IBuildStepFactory
+class BlackBerryCheckDebugTokenStepFactory : public ProjectExplorer::IBuildStepFactory
{
Q_OBJECT
public:
- explicit BlackBerryCheckDevModeStepFactory(QObject *parent = 0);
+ explicit BlackBerryCheckDebugTokenStepFactory(QObject *parent = 0);
QList<Core::Id> availableCreationIds(ProjectExplorer::BuildStepList *parent) const;
QString displayNameForId(const Core::Id id) const;
diff --git a/src/plugins/qnx/blackberrycheckdevmodestep.cpp b/src/plugins/qnx/blackberrycheckdevmodestep.cpp
deleted file mode 100644
index 5e5a956983..0000000000
--- a/src/plugins/qnx/blackberrycheckdevmodestep.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/**************************************************************************
-**
-** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-**
-** Contact: BlackBerry (qt@blackberry.com)
-** Contact: KDAB (info@kdab.com)
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "blackberrycheckdevmodestep.h"
-
-#include "blackberrycheckdevmodestepconfigwidget.h"
-#include "blackberrydeviceconfiguration.h"
-#include "qnxconstants.h"
-
-#include <projectexplorer/buildconfiguration.h>
-#include <projectexplorer/target.h>
-#include <ssh/sshconnection.h>
-
-using namespace Qnx;
-using namespace Qnx::Internal;
-
-BlackBerryCheckDevModeStep::BlackBerryCheckDevModeStep(ProjectExplorer::BuildStepList *bsl) :
- BlackBerryAbstractDeployStep(bsl, Core::Id(Constants::QNX_CHECK_DEVELOPMENT_MODE_BS_ID))
-{
- setDisplayName(tr("Check Development Mode"));
-}
-
-BlackBerryCheckDevModeStep::BlackBerryCheckDevModeStep(ProjectExplorer::BuildStepList *bsl, BlackBerryCheckDevModeStep *bs) :
- BlackBerryAbstractDeployStep(bsl, bs)
-{
- setDisplayName(tr("Check Development Mode"));
-}
-
-bool BlackBerryCheckDevModeStep::init()
-{
- if (!BlackBerryAbstractDeployStep::init())
- return false;
-
- QString deployCmd = target()->activeBuildConfiguration()->environment().searchInPath(QLatin1String(Constants::QNX_BLACKBERRY_DEPLOY_CMD));
- if (deployCmd.isEmpty()) {
- raiseError(tr("Could not find command '%1' in the build environment")
- .arg(QLatin1String(Constants::QNX_BLACKBERRY_DEPLOY_CMD)));
- return false;
- }
-
- BlackBerryDeviceConfiguration::ConstPtr device = BlackBerryDeviceConfiguration::device(target()->kit());
- QString deviceHost = device ? device->sshParameters().host : QString();
- if (deviceHost.isEmpty()) {
- raiseError(tr("No hostname specified for device"));
- return false;
- }
-
- QStringList args;
- args << QLatin1String("-listDeviceInfo");
- args << deviceHost;
- if (!device->sshParameters().password.isEmpty()) {
- args << QLatin1String("-password");
- args << device->sshParameters().password;
- }
-
- addCommand(deployCmd, args);
-
- return true;
-}
-
-ProjectExplorer::BuildStepConfigWidget *BlackBerryCheckDevModeStep::createConfigWidget()
-{
- return new BlackBerryCheckDevModeStepConfigWidget();
-}
-
-QString BlackBerryCheckDevModeStep::password() const
-{
- BlackBerryDeviceConfiguration::ConstPtr device = BlackBerryDeviceConfiguration::device(target()->kit());
- return device ? device->sshParameters().password : QString();
-}
-
-void BlackBerryCheckDevModeStep::processStarted(const ProjectExplorer::ProcessParameters &params)
-{
- QString arguments = params.prettyArguments();
- if (!password().isEmpty()) {
- const QString passwordLine = QLatin1String(" -password ") + password();
- const QString hiddenPasswordLine = QLatin1String(" -password <hidden>");
- arguments.replace(passwordLine, hiddenPasswordLine);
- }
-
- emitOutputInfo(params, arguments);
-}
diff --git a/src/plugins/qnx/blackberryconfiguration.cpp b/src/plugins/qnx/blackberryconfiguration.cpp
index 7c51ed196d..2213faca0b 100644
--- a/src/plugins/qnx/blackberryconfiguration.cpp
+++ b/src/plugins/qnx/blackberryconfiguration.cpp
@@ -33,7 +33,8 @@
#include "blackberryqtversion.h"
#include "qnxtoolchain.h"
-#include "qnxutils.h"
+
+#include <utils/qtcassert.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/kitmanager.h>
@@ -50,6 +51,8 @@
#include <debugger/debuggeritemmanager.h>
#include <debugger/debuggerkitinformation.h>
+#include <coreplugin/icore.h>
+
#include <QFileInfo>
#include <QDir>
#include <QMessageBox>
@@ -62,14 +65,39 @@ using namespace Debugger;
namespace Qnx {
namespace Internal {
-BlackBerryConfiguration::BlackBerryConfiguration(const FileName &ndkEnvFile, bool isAutoDetected,
- const QString &displayName)
+const QLatin1String NDKEnvFileKey("NDKEnvFile");
+const QLatin1String NDKPathKey("NDKPath");
+const QLatin1String NDKDisplayNameKey("NDKDisplayName");
+const QLatin1String NDKTargetKey("NDKTarget");
+const QLatin1String NDKHostKey("NDKHost");
+const QLatin1String NDKVersionKey("NDKVersion");
+const QLatin1String NDKAutoDetectionSourceKey("NDKAutoDetectionSource");
+const QLatin1String NDKAutoDetectedKey("NDKAutoDetectedKey");
+
+BlackBerryConfiguration::BlackBerryConfiguration(const NdkInstallInformation &ndkInstallInfo)
+{
+ QString envFilePath = QnxUtils::envFilePath(ndkInstallInfo.path, ndkInstallInfo.version);
+ QTC_ASSERT(!envFilePath.isEmpty(), return);
+ m_ndkEnvFile = Utils::FileName::fromString(envFilePath);
+ m_displayName = ndkInstallInfo.name;
+ m_qnxEnv = QnxUtils::qnxEnvironmentFromNdkFile(m_ndkEnvFile.toString());
+ QString sep = QString::fromLatin1("/qnx6");
+ // The QNX_TARGET value is using Unix-like separator on all platforms.
+ m_targetName = ndkInstallInfo.target.split(sep).first().split(QLatin1Char('/')).last();
+ m_qnxHost = ndkInstallInfo.host;
+ m_sysRoot = FileName::fromString(ndkInstallInfo.target);
+ m_version = BlackBerryVersionNumber(ndkInstallInfo.version);
+ m_autoDetectionSource = Utils::FileName::fromString(ndkInstallInfo.installationXmlFilePath);
+ ctor();
+}
+
+BlackBerryConfiguration::BlackBerryConfiguration(const FileName &ndkEnvFile)
+ : m_autoDetectionSource(Utils::FileName())
{
- Q_ASSERT(!QFileInfo(ndkEnvFile.toString()).isDir());
+ QTC_ASSERT(!QFileInfo(ndkEnvFile.toString()).isDir(), return);
m_ndkEnvFile = ndkEnvFile;
- m_isAutoDetected = isAutoDetected;
- QString ndkPath = ndkEnvFile.parentDir().toString();
- m_displayName = displayName.isEmpty() ? ndkPath.split(QDir::separator()).last() : displayName;
+ QString ndkPath = m_ndkEnvFile.parentDir().toString();
+ m_displayName = ndkPath.split(QDir::separator()).last();
m_qnxEnv = QnxUtils::qnxEnvironmentFromNdkFile(m_ndkEnvFile.toString());
QString ndkTarget;
@@ -89,6 +117,34 @@ BlackBerryConfiguration::BlackBerryConfiguration(const FileName &ndkEnvFile, boo
if (QDir(ndkTarget).exists())
m_sysRoot = FileName::fromString(ndkTarget);
+ m_version = BlackBerryVersionNumber::fromNdkEnvFileName(QFileInfo(m_ndkEnvFile.toString()).baseName());
+ if (m_version.isEmpty())
+ m_version = BlackBerryVersionNumber::fromTargetName(m_targetName);
+
+ ctor();
+}
+
+BlackBerryConfiguration::BlackBerryConfiguration(const QVariantMap &data)
+{
+ QString envFilePath = data.value(NDKEnvFileKey).toString();
+ QTC_ASSERT(!envFilePath.isEmpty(), return);
+ m_ndkEnvFile = Utils::FileName::fromString(envFilePath);
+ m_displayName = data.value(NDKDisplayNameKey).toString();
+ m_qnxEnv = QnxUtils::qnxEnvironmentFromNdkFile(m_ndkEnvFile.toString());
+ QString sep = QString::fromLatin1("/qnx6");
+ // The QNX_TARGET value is using Unix-like separator on all platforms.
+ m_targetName = data.value(NDKTargetKey).toString().split(sep).first().split(QLatin1Char('/')).last();
+ m_qnxHost = data.value(NDKHostKey).toString();
+ m_sysRoot = FileName::fromString(data.value(NDKTargetKey).toString());
+ m_version = BlackBerryVersionNumber(data.value(NDKVersionKey).toString());
+ if (data.value(QLatin1String(NDKAutoDetectedKey)).toBool())
+ m_autoDetectionSource = Utils::FileName::fromString(data.value(NDKAutoDetectionSourceKey).toString());
+
+ ctor();
+}
+
+void BlackBerryConfiguration::ctor()
+{
FileName qmake4Path = QnxUtils::executableWithExtension(FileName::fromString(m_qnxHost + QLatin1String("/usr/bin/qmake")));
FileName qmake5Path = QnxUtils::executableWithExtension(FileName::fromString(m_qnxHost + QLatin1String("/usr/bin/qt5/qmake")));
FileName gccPath = QnxUtils::executableWithExtension(FileName::fromString(m_qnxHost + QLatin1String("/usr/bin/qcc")));
@@ -131,20 +187,39 @@ QString BlackBerryConfiguration::qnxHost() const
return m_qnxHost;
}
+BlackBerryVersionNumber BlackBerryConfiguration::version() const
+{
+ return m_version;
+}
+
bool BlackBerryConfiguration::isAutoDetected() const
{
- return m_isAutoDetected;
+ return !m_autoDetectionSource.isEmpty();
+}
+
+Utils::FileName BlackBerryConfiguration::autoDetectionSource() const
+{
+ return m_autoDetectionSource;
}
bool BlackBerryConfiguration::isActive() const
{
- return !findRegisteredQtVersions().isEmpty();
+ foreach (Kit *kit, KitManager::kits()) {
+ if (kit->isAutoDetected() &&
+ kit->autoDetectionSource() == m_ndkEnvFile.toString())
+ return true;
+ }
+
+ return false;
}
bool BlackBerryConfiguration::isValid() const
{
- return !((m_qmake4BinaryFile.isEmpty() && m_qmake5BinaryFile.isEmpty()) || m_gccCompiler.isEmpty()
- || m_deviceDebugger.isEmpty() || m_simulatorDebugger.isEmpty());
+ return ((!m_qmake4BinaryFile.isEmpty() || !m_qmake5BinaryFile.isEmpty()) && !m_gccCompiler.isEmpty()
+ && !m_deviceDebugger.isEmpty() && !m_simulatorDebugger.isEmpty()
+ && m_ndkEnvFile.toFileInfo().exists() && (m_autoDetectionSource.isEmpty() ||
+ m_autoDetectionSource.toFileInfo().exists())
+ && m_sysRoot.toFileInfo().exists());
}
FileName BlackBerryConfiguration::ndkEnvFile() const
@@ -187,6 +262,20 @@ QList<Utils::EnvironmentItem> BlackBerryConfiguration::qnxEnv() const
return m_qnxEnv;
}
+QVariantMap BlackBerryConfiguration::toMap() const
+{
+ QVariantMap data;
+ data.insert(QLatin1String(NDKEnvFileKey), m_ndkEnvFile.toString());
+ data.insert(QLatin1String(NDKDisplayNameKey), m_displayName);
+ data.insert(QLatin1String(NDKPathKey), ndkPath());
+ data.insert(QLatin1String(NDKTargetKey), m_sysRoot.toString());
+ data.insert(QLatin1String(NDKHostKey), m_qnxHost);
+ data.insert(QLatin1String(NDKVersionKey), m_version.toString());
+ data.insert(QLatin1String(NDKAutoDetectionSourceKey), m_autoDetectionSource.toString());
+ data.insert(QLatin1String(NDKAutoDetectedKey), isAutoDetected());
+ return data;
+}
+
QnxAbstractQtVersion *BlackBerryConfiguration::createQtVersion(
const FileName &qmakePath, Qnx::QnxArchitecture arch, const QString &versionName)
{
@@ -246,6 +335,7 @@ Kit *BlackBerryConfiguration::createKit(
kit->setIconPath(FileName::fromString(QLatin1String(Constants::QNX_BB_CATEGORY_ICON)));
kit->setAutoDetected(true);
+ kit->setAutoDetectionSource(m_ndkEnvFile.toString());
kit->setMutable(DeviceKitInformation::id(), true);
kit->setSticky(QtKitInformation::id(), true);
@@ -262,7 +352,7 @@ Kit *BlackBerryConfiguration::createKit(
bool BlackBerryConfiguration::activate()
{
if (!isValid()) {
- if (m_isAutoDetected)
+ if (!m_autoDetectionSource.isEmpty())
return false;
QString errorMessage = tr("The following errors occurred while activating target: %1").arg(m_targetName);
@@ -278,7 +368,7 @@ bool BlackBerryConfiguration::activate()
if (!m_simulatorDebugger.isEmpty())
errorMessage += QLatin1Char('\n') + tr("- No GDB debugger found for BB10 Simulator.");
- QMessageBox::warning(0, tr("Cannot Set up BB10 Configuration"),
+ QMessageBox::warning(Core::ICore::mainWindow(), tr("Cannot Set up BB10 Configuration"),
errorMessage, QMessageBox::Ok);
return false;
}
@@ -339,50 +429,24 @@ bool BlackBerryConfiguration::activate()
return true;
}
-QList<BaseQtVersion *> BlackBerryConfiguration::findRegisteredQtVersions() const
-{
- QList<BaseQtVersion *> versions;
- foreach (BaseQtVersion *version, QtVersionManager::versions()) {
- if (version->type() == QLatin1String(Constants::QNX_BB_QT)) {
- QnxAbstractQtVersion *qnxVersion = dynamic_cast<QnxAbstractQtVersion *>(version);
- if (qnxVersion && qnxVersion->isAutodetected()
- && (qnxVersion->qmakeCommand() == qmake4BinaryFile()
- || qnxVersion->qmakeCommand() == qmake5BinaryFile()))
- versions << qnxVersion;
- }
- }
- return versions;
-}
-
void BlackBerryConfiguration::deactivate()
{
- QList<BaseQtVersion *> versions = findRegisteredQtVersions();
- QList<ToolChain *> toolChains;
foreach (Kit *kit, KitManager::kits()) {
- if (kit->isAutoDetected()) {
+ if (kit->isAutoDetected() &&
+ kit->autoDetectionSource() == ndkEnvFile().toString()) {
BaseQtVersion *version = QtKitInformation::qtVersion(kit);
- if (versions.contains(version)) {
- ToolChain *toolChain = ToolChainKitInformation::toolChain(kit);
- if (toolChain)
- toolChains << toolChain;
- KitManager::deregisterKit(kit);
- }
+ ToolChain *toolChain = ToolChainKitInformation::toolChain(kit);
+ const DebuggerItem *debugger = DebuggerKitInformation::debugger(kit);
+ if (version)
+ QtVersionManager::removeVersion(version);
+ if (toolChain)
+ ToolChainManager::deregisterToolChain(toolChain);
+ if (debugger)
+ DebuggerItemManager::deregisterDebugger(debugger->id());
+
+ KitManager::deregisterKit(kit);
}
}
-
- foreach (const DebuggerItem &item, DebuggerItemManager::debuggers())
- if (item.isAutoDetected() &&
- (item.command() == m_simulatorDebugger || item.command() == m_deviceDebugger))
- DebuggerItemManager::deregisterDebugger(item.id());
-
- foreach (ToolChain *toolChain, ToolChainManager::toolChains())
- if (toolChain->isAutoDetected()
- && (toolChains.contains(toolChain) || toolChain->compilerCommand() == m_gccCompiler))
- ToolChainManager::deregisterToolChain(toolChain);
-
- foreach (BaseQtVersion *version, versions)
- QtVersionManager::removeVersion(version);
-
}
} // namespace Internal
diff --git a/src/plugins/qnx/blackberryconfiguration.h b/src/plugins/qnx/blackberryconfiguration.h
index 573336d848..da5f50d3de 100644
--- a/src/plugins/qnx/blackberryconfiguration.h
+++ b/src/plugins/qnx/blackberryconfiguration.h
@@ -32,6 +32,8 @@
#ifndef BLACKBERRYCONFIGURATIONS_H
#define BLACKBERRYCONFIGURATIONS_H
+#include "qnxutils.h"
+#include "blackberryversionnumber.h"
#include "qnxconstants.h"
#include <utils/environment.h>
@@ -60,14 +62,18 @@ class BlackBerryConfiguration
{
Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::BlackBerryConfiguration)
public:
- BlackBerryConfiguration(const Utils::FileName &ndkEnvFile, bool isAutoDetected, const QString &displayName = QString());
+ BlackBerryConfiguration(const NdkInstallInformation &ndkInstallInfo);
+ BlackBerryConfiguration(const Utils::FileName &ndkEnvFile);
+ BlackBerryConfiguration(const QVariantMap &data);
bool activate();
void deactivate();
QString ndkPath() const;
QString displayName() const;
QString targetName() const;
QString qnxHost() const;
+ BlackBerryVersionNumber version() const;
bool isAutoDetected() const;
+ Utils::FileName autoDetectionSource() const;
bool isActive() const;
bool isValid() const;
Utils::FileName ndkEnvFile() const;
@@ -78,12 +84,14 @@ public:
Utils::FileName simulatorDebuger() const;
Utils::FileName sysRoot() const;
QList<Utils::EnvironmentItem> qnxEnv() const;
+ QVariantMap toMap() const;
private:
QString m_displayName;
QString m_targetName;
QString m_qnxHost;
- bool m_isAutoDetected;
+ BlackBerryVersionNumber m_version;
+ Utils::FileName m_autoDetectionSource;
Utils::FileName m_ndkEnvFile;
Utils::FileName m_qmake4BinaryFile;
Utils::FileName m_qmake5BinaryFile;
@@ -93,6 +101,8 @@ private:
Utils::FileName m_sysRoot;
QList<Utils::EnvironmentItem> m_qnxEnv;
+ void ctor();
+
QnxAbstractQtVersion* createQtVersion(
const Utils::FileName &qmakePath, Qnx::QnxArchitecture arch, const QString &versionName);
QnxToolChain* createToolChain(
@@ -102,7 +112,6 @@ private:
ProjectExplorer::Kit* createKit(
QnxAbstractQtVersion* version, QnxToolChain* toolChain,
const QVariant &debuggerItemId);
- QList<QtSupport::BaseQtVersion *> findRegisteredQtVersions() const;
};
} // namespace Internal
diff --git a/src/plugins/qnx/blackberryconfigurationmanager.cpp b/src/plugins/qnx/blackberryconfigurationmanager.cpp
index 8d1368c632..2f4fd3867e 100644
--- a/src/plugins/qnx/blackberryconfigurationmanager.cpp
+++ b/src/plugins/qnx/blackberryconfigurationmanager.cpp
@@ -49,8 +49,11 @@
#include <qtsupport/qtversionmanager.h>
#include <qtsupport/qtkitinformation.h>
+#include <debugger/debuggerkitinformation.h>
+
#include <QMessageBox>
#include <QFileInfo>
+#include <QDebug>
using namespace ProjectExplorer;
@@ -61,17 +64,73 @@ namespace {
const QLatin1String SettingsGroup("BlackBerryConfiguration");
const QLatin1String NDKLocationKey("NDKLocation"); // For 10.1 NDK support (< QTC 3.0)
const QLatin1String NDKEnvFileKey("NDKEnvFile");
-const QLatin1String CertificateGroup("Certificates");
const QLatin1String ManualNDKsGroup("ManualNDKs");
const QLatin1String ActiveNDKsGroup("ActiveNDKs");
+const QLatin1String DefaultApiLevelKey("DefaultApiLevel");
+const QLatin1String BBConfigsFileVersionKey("Version");
+const QLatin1String BBConfigDataKey("BBConfiguration.");
+const QLatin1String BBConfigCountKey("BBConfiguration.Count");
+}
+
+static Utils::FileName bbConfigSettingsFileName()
+{
+ return Utils::FileName::fromString(Core::ICore::userResourcePath() + QLatin1String("/qnx/")
+ + QLatin1String(Constants::QNX_BLACKBERRY_CONFIGS_FILENAME));
+}
+
+static bool sortConfigurationsByVersion(const BlackBerryConfiguration *a, const BlackBerryConfiguration *b)
+{
+ return a->version() > b->version();
}
BlackBerryConfigurationManager::BlackBerryConfigurationManager(QObject *parent)
- :QObject(parent)
+ : QObject(parent),
+ m_defaultApiLevel(0)
{
+ m_writer = new Utils::PersistentSettingsWriter(bbConfigSettingsFileName(),
+ QLatin1String("BlackBerryConfigurations"));
connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(saveSettings()));
}
+void BlackBerryConfigurationManager::saveConfigurations()
+{
+ QTC_ASSERT(m_writer, return);
+ QVariantMap data;
+ data.insert(QLatin1String(BBConfigsFileVersionKey), 1);
+ int count = 0;
+ foreach (BlackBerryConfiguration *config, m_configs) {
+ QVariantMap tmp = config->toMap();
+ if (tmp.isEmpty())
+ continue;
+
+ data.insert(BBConfigDataKey + QString::number(count), tmp);
+ ++count;
+ }
+
+ data.insert(QLatin1String(BBConfigCountKey), count);
+ m_writer->save(data, Core::ICore::mainWindow());
+}
+
+void BlackBerryConfigurationManager::restoreConfigurations()
+{
+ Utils::PersistentSettingsReader reader;
+ if (!reader.load(bbConfigSettingsFileName()))
+ return;
+
+ QVariantMap data = reader.restoreValues();
+ int count = data.value(BBConfigCountKey, 0).toInt();
+ for (int i = 0; i < count; ++i) {
+ const QString key = BBConfigDataKey + QString::number(i);
+ if (!data.contains(key))
+ continue;
+
+ const QVariantMap dMap = data.value(key).toMap();
+ insertByVersion(new BlackBerryConfiguration(dMap));
+ }
+}
+
+// Backward compatibility: Read existing entries in the ManualNDKsGroup
+// and then remove the group since not used.
void BlackBerryConfigurationManager::loadManualConfigurations()
{
QSettings *settings = Core::ICore::settings();
@@ -90,8 +149,7 @@ void BlackBerryConfigurationManager::loadManualConfigurations()
ndkEnvPath = QnxUtils::envFilePath(ndkPath);
}
- BlackBerryConfiguration *config = new BlackBerryConfiguration(Utils::FileName::fromString(ndkEnvPath),
- false);
+ BlackBerryConfiguration *config = new BlackBerryConfiguration(Utils::FileName::fromString(ndkEnvPath));
if (!addConfiguration(config))
delete config;
@@ -99,116 +157,96 @@ void BlackBerryConfigurationManager::loadManualConfigurations()
}
settings->endGroup();
+ settings->remove(ManualNDKsGroup);
settings->endGroup();
}
-void BlackBerryConfigurationManager::loadAutoDetectedConfigurations()
+void BlackBerryConfigurationManager::loadDefaultApiLevel()
{
- QStringList activePaths = activeConfigurationNdkEnvPaths();
- foreach (const NdkInstallInformation &ndkInfo, QnxUtils::installedNdks()) {
- QString envFilePath = QnxUtils::envFilePath(ndkInfo.path, ndkInfo.version);
- BlackBerryConfiguration *config = new BlackBerryConfiguration(Utils::FileName::fromString(envFilePath),
- true, ndkInfo.name);
- if (!addConfiguration(config)) {
- delete config;
- continue;
- }
-
- // Activate targets
- foreach (const QString activeNdkEnvPath, activePaths) {
- if (config->ndkEnvFile().toString() == activeNdkEnvPath)
- config->activate();
- }
- }
-
- // If no target was/is activated, activate one since it's needed by
- // device connection and CSK code.
- if (activeConfigurations().isEmpty() && !m_configs.isEmpty())
- m_configs.first()->activate();
-}
+ if (m_configs.isEmpty())
+ return;
-QStringList BlackBerryConfigurationManager::activeConfigurationNdkEnvPaths()
-{
- QStringList actives;
QSettings *settings = Core::ICore::settings();
settings->beginGroup(SettingsGroup);
- settings->beginGroup(ActiveNDKsGroup);
- foreach (const QString &activeNdkEnvPath, settings->childGroups()) {
- settings->beginGroup(activeNdkEnvPath);
- actives.append(settings->value(NDKEnvFileKey).toString());
- settings->endGroup();
+ const QString ndkEnvFile = settings->value(DefaultApiLevelKey).toString();
+
+ BlackBerryConfiguration *defaultApiLevel = 0;
+
+ // now check whether there is a cached value available to override it
+ foreach (BlackBerryConfiguration *config, m_configs) {
+ if (config->ndkEnvFile().toString() == ndkEnvFile) {
+ defaultApiLevel = config;
+ break;
+ }
}
+ if (defaultApiLevel)
+ setDefaultApiLevel(defaultApiLevel);
+ else
+ setDefaultApiLevel(m_configs.first());
+
+
settings->endGroup();
- settings->endGroup();
+}
- return actives;
+void BlackBerryConfigurationManager::loadAutoDetectedConfigurations()
+{
+ foreach (const NdkInstallInformation &ndkInfo, QnxUtils::installedNdks()) {
+ BlackBerryConfiguration *config = new BlackBerryConfiguration(ndkInfo);
+ if (!addConfiguration(config)) {
+ delete config;
+ continue;
+ }
+ }
}
-void BlackBerryConfigurationManager::saveManualConfigurations()
+void BlackBerryConfigurationManager::setDefaultApiLevel(BlackBerryConfiguration *config)
{
- if (manualConfigurations().isEmpty())
+ if (config && !m_configs.contains(config)) {
+ qWarning() << "BlackBerryConfigurationManager::setDefaultApiLevel -"
+ " configuration does not belong to this instance: "
+ << config->ndkEnvFile().toString();
return;
-
- QSettings *settings = Core::ICore::settings();
- settings->beginGroup(SettingsGroup);
- settings->beginGroup(ManualNDKsGroup);
-
- foreach (BlackBerryConfiguration *config, manualConfigurations()) {
- settings->beginGroup(config->displayName());
- settings->setValue(NDKEnvFileKey, config->ndkEnvFile().toString());
- settings->endGroup();
}
- settings->endGroup();
- settings->endGroup();
+ m_defaultApiLevel = config;
}
-void BlackBerryConfigurationManager::saveActiveConfigurationNdkEnvPath()
+void BlackBerryConfigurationManager::saveDefaultApiLevel()
{
- if (activeConfigurations().isEmpty())
+ if (!m_defaultApiLevel)
return;
QSettings *settings = Core::ICore::settings();
settings->beginGroup(SettingsGroup);
- settings->beginGroup(ActiveNDKsGroup);
-
- settings->remove(QString());
-
- foreach (BlackBerryConfiguration *config, activeConfigurations()) {
- settings->beginGroup(config->displayName());
- settings->setValue(NDKEnvFileKey, config->ndkEnvFile().toString());
- settings->endGroup();
- }
-
- settings->endGroup();
+ settings->setValue(DefaultApiLevelKey, m_defaultApiLevel->ndkEnvFile().toString());
settings->endGroup();
}
-// Remove no longer available/valid 'auto detected' BlackBerry kits and qt versions
-void BlackBerryConfigurationManager::clearInvalidConfigurations()
+void BlackBerryConfigurationManager::setKitsAutoDetectionSource()
{
- // Deregister invalid auto deteted BlackBerry Kits
foreach (Kit *kit, KitManager::kits()) {
- if (!kit->isAutoDetected())
- continue;
-
- if (DeviceTypeKitInformation::deviceTypeId(kit) == Constants::QNX_BB_OS_TYPE
- && !kit->isValid())
- KitManager::deregisterKit(kit);
+ if (kit->isAutoDetected() &&
+ (DeviceTypeKitInformation::deviceTypeId(kit) == Constants::QNX_BB_CATEGORY_ICON) &&
+ kit->autoDetectionSource().isEmpty()) {
+ QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
+ foreach (BlackBerryConfiguration *config, m_configs) {
+ if ((version &&
+ (version->qmakeCommand() == config->qmake4BinaryFile() || version->qmakeCommand() == config->qmake5BinaryFile()))
+ && (SysRootKitInformation::sysRoot(kit) == config->sysRoot()))
+ kit->setAutoDetectionSource(config->ndkEnvFile().toString());
+ }
+ }
}
+}
- // Remove invalid auto detected BlackBerry qtVerions
- foreach (QtSupport::BaseQtVersion *qtVersion, QtSupport::QtVersionManager::versions()) {
- if (!qtVersion->isAutodetected())
- continue;
-
- if (qtVersion->platformName() == QLatin1String(Constants::QNX_BB_PLATFORM_NAME)
- && !qtVersion->isValid())
- QtSupport::QtVersionManager::removeVersion(qtVersion);
- }
+void BlackBerryConfigurationManager::insertByVersion(BlackBerryConfiguration *config)
+{
+ QList<BlackBerryConfiguration *>::iterator it = qLowerBound(m_configs.begin(), m_configs.end(),
+ config, &sortConfigurationsByVersion);
+ m_configs.insert(it, config);
}
// Switch to QnxToolchain for exisintg configuration using GccToolChain
@@ -232,17 +270,16 @@ void BlackBerryConfigurationManager::checkToolChainConfiguration()
bool BlackBerryConfigurationManager::addConfiguration(BlackBerryConfiguration *config)
{
foreach (BlackBerryConfiguration *c, m_configs) {
- if (c->ndkPath() == config->ndkPath()
- && c->targetName() == config->targetName()) {
+ if (config->ndkEnvFile() == c->ndkEnvFile()) {
if (!config->isAutoDetected())
- QMessageBox::warning(0, tr("NDK Already Known"),
+ QMessageBox::warning(Core::ICore::mainWindow(), tr("NDK Already Known"),
tr("The NDK already has a configuration."), QMessageBox::Ok);
return false;
}
}
if (config->isValid()) {
- m_configs.append(config);
+ insertByVersion(config);
return true;
}
@@ -257,9 +294,17 @@ void BlackBerryConfigurationManager::removeConfiguration(BlackBerryConfiguration
if (config->isActive())
config->deactivate();
- clearConfigurationSettings(config);
-
m_configs.removeAt(m_configs.indexOf(config));
+
+ if (m_defaultApiLevel == config) {
+ if (m_configs.isEmpty())
+ setDefaultApiLevel(0);
+ else
+ setDefaultApiLevel(m_configs.first());
+
+ saveDefaultApiLevel();
+ }
+
delete config;
}
@@ -292,6 +337,9 @@ QList<BlackBerryConfiguration *> BlackBerryConfigurationManager::activeConfigura
BlackBerryConfiguration *BlackBerryConfigurationManager::configurationFromEnvFile(const Utils::FileName &envFile) const
{
+ if (envFile.isEmpty())
+ return 0;
+
foreach (BlackBerryConfiguration *config, m_configs) {
if (config->ndkEnvFile() == envFile)
return config;
@@ -300,65 +348,57 @@ BlackBerryConfiguration *BlackBerryConfigurationManager::configurationFromEnvFil
return 0;
}
-// Returns a valid qnxEnv from a valid configuration;
-// Needed by other classes to get blackberry process path (keys registration, debug token...)
-QList<Utils::EnvironmentItem> BlackBerryConfigurationManager::defaultQnxEnv()
+BlackBerryConfiguration *BlackBerryConfigurationManager::defaultApiLevel() const
{
- foreach (BlackBerryConfiguration *config, m_configs) {
- if (config->isActive() && config->qnxEnv().size())
- return config->qnxEnv();
- }
-
- return QList<Utils::EnvironmentItem>();
+ return m_defaultApiLevel;
}
-void BlackBerryConfigurationManager::loadSettings()
+QList<Utils::EnvironmentItem> BlackBerryConfigurationManager::defaultApiLevelEnv() const
{
- clearInvalidConfigurations();
- loadAutoDetectedConfigurations();
- loadManualConfigurations();
- checkToolChainConfiguration();
+ if (!m_defaultApiLevel)
+ return QList<Utils::EnvironmentItem>();
- emit settingsLoaded();
+ return m_defaultApiLevel->qnxEnv();
}
-void BlackBerryConfigurationManager::clearConfigurationSettings(BlackBerryConfiguration *config)
+void BlackBerryConfigurationManager::loadSettings()
{
- if (!config)
- return;
+ // Backward compatibility: Set kit's auto detection source
+ // for existing BlackBerry kits that do not have it set yet.
+ setKitsAutoDetectionSource();
- QSettings *settings = Core::ICore::settings();
- settings->beginGroup(SettingsGroup);
- settings->beginGroup(ManualNDKsGroup);
+ restoreConfigurations();
+ // For backward compatibility
+ loadManualConfigurations();
+ loadAutoDetectedConfigurations();
+ loadDefaultApiLevel();
+ checkToolChainConfiguration();
- foreach (const QString &manualNdk, settings->childGroups()) {
- if (manualNdk == config->displayName()) {
- settings->remove(manualNdk);
- break;
- }
- }
+ // If no target was/is activated, activate one since it's needed by
+ // device connection and CSK code.
+ if (activeConfigurations().isEmpty() && !m_configs.isEmpty())
+ m_configs.first()->activate();
- settings->endGroup();
- settings->endGroup();
+ emit settingsLoaded();
}
void BlackBerryConfigurationManager::saveSettings()
{
- saveActiveConfigurationNdkEnvPath();
- saveManualConfigurations();
+ saveConfigurations();
+ saveDefaultApiLevel();
}
BlackBerryConfigurationManager &BlackBerryConfigurationManager::instance()
{
- if (m_instance == 0)
- m_instance = new BlackBerryConfigurationManager();
+ static BlackBerryConfigurationManager instance;
- return *m_instance;
+ return instance;
}
BlackBerryConfigurationManager::~BlackBerryConfigurationManager()
{
qDeleteAll(m_configs);
+ delete m_writer;
}
QString BlackBerryConfigurationManager::barsignerCskPath() const
@@ -386,7 +426,5 @@ QString BlackBerryConfigurationManager::defaultDebugTokenPath() const
return QnxUtils::dataDirPath() + QLatin1String("/debugtoken.bar");
}
-BlackBerryConfigurationManager* BlackBerryConfigurationManager::m_instance = 0;
-
} // namespace Internal
} // namespace Qnx
diff --git a/src/plugins/qnx/blackberryconfigurationmanager.h b/src/plugins/qnx/blackberryconfigurationmanager.h
index 45290efe02..646b631b38 100644
--- a/src/plugins/qnx/blackberryconfigurationmanager.h
+++ b/src/plugins/qnx/blackberryconfigurationmanager.h
@@ -38,6 +38,8 @@
#include <QSettings>
#include <QObject>
+namespace Utils { class PersistentSettingsWriter; }
+
namespace Qnx {
namespace Internal {
@@ -55,6 +57,7 @@ public:
QList<BlackBerryConfiguration*> manualConfigurations() const;
QList<BlackBerryConfiguration *> activeConfigurations() const;
BlackBerryConfiguration *configurationFromEnvFile(const Utils::FileName &envFile) const;
+ BlackBerryConfiguration *defaultApiLevel() const;
QString barsignerCskPath() const;
QString idTokenPath() const;
@@ -63,9 +66,11 @@ public:
QString defaultDebugTokenPath() const;
void clearConfigurationSettings(BlackBerryConfiguration *config);
- QList<Utils::EnvironmentItem> defaultQnxEnv();
+ // returns the environment for the default API level
+ QList<Utils::EnvironmentItem> defaultApiLevelEnv() const;
void loadAutoDetectedConfigurations();
+ void setDefaultApiLevel(BlackBerryConfiguration *config);
public slots:
void loadSettings();
@@ -77,15 +82,22 @@ signals:
private:
BlackBerryConfigurationManager(QObject *parent = 0);
- static BlackBerryConfigurationManager *m_instance;
QList<BlackBerryConfiguration*> m_configs;
+ BlackBerryConfiguration *m_defaultApiLevel;
+
+ void loadDefaultApiLevel();
+ void saveDefaultApiLevel();
+
+ Utils::PersistentSettingsWriter *m_writer;
+
+ void saveConfigurations();
+ void restoreConfigurations();
+
void loadManualConfigurations();
- void saveManualConfigurations();
- void saveActiveConfigurationNdkEnvPath();
- void clearInvalidConfigurations();
+ void setKitsAutoDetectionSource();
- QStringList activeConfigurationNdkEnvPaths();
+ void insertByVersion(BlackBerryConfiguration* config);
};
} // namespace Internal
diff --git a/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp b/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp
index 5909927517..50ef16ba88 100644
--- a/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp
+++ b/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp
@@ -143,9 +143,24 @@ void BlackBerryDebugTokenRequestDialog::requestDebugToken()
BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance();
+ bool ok;
+ const QString cskPassword = m_utils.cskPassword(this, &ok);
+
+ if (!ok) {
+ setBusy(false);
+ return;
+ }
+
+ const QString certificatePassword = m_utils.certificatePassword(this, &ok);
+
+ if (!ok) {
+ setBusy(false);
+ return;
+ }
+
m_requester->requestDebugToken(m_ui->debugTokenPath->path(),
- m_utils.cskPassword(), configuration.defaultKeystorePath(),
- m_utils.certificatePassword(), m_ui->devicePin->text());
+ cskPassword, configuration.defaultKeystorePath(),
+ certificatePassword, m_ui->devicePin->text());
}
void BlackBerryDebugTokenRequestDialog::setDefaultPath()
@@ -235,6 +250,11 @@ void BlackBerryDebugTokenRequestDialog::debugTokenArrived(int status)
break;
}
+ QFile file(m_ui->debugTokenPath->path());
+
+ if (file.exists())
+ file.remove();
+
QMessageBox::critical(this, tr("Error"), errorString);
setBusy(false);
diff --git a/src/plugins/qnx/blackberrydeployconfigurationfactory.cpp b/src/plugins/qnx/blackberrydeployconfigurationfactory.cpp
index b968fc1b6f..04d4af8963 100644
--- a/src/plugins/qnx/blackberrydeployconfigurationfactory.cpp
+++ b/src/plugins/qnx/blackberrydeployconfigurationfactory.cpp
@@ -32,7 +32,7 @@
#include "blackberrydeployconfigurationfactory.h"
#include "qnxconstants.h"
-#include "blackberrycheckdevmodestep.h"
+#include "blackberrycheckdebugtokenstep.h"
#include "blackberrydeployconfiguration.h"
#include "blackberrycreatepackagestep.h"
#include "blackberrydeploystep.h"
@@ -93,7 +93,7 @@ ProjectExplorer::DeployConfiguration *BlackBerryDeployConfigurationFactory::crea
return 0;
BlackBerryDeployConfiguration *dc = new BlackBerryDeployConfiguration(parent);
- dc->stepList()->insertStep(0, new BlackBerryCheckDevModeStep(dc->stepList()));
+ dc->stepList()->insertStep(0, new BlackBerryCheckDebugTokenStep(dc->stepList()));
dc->stepList()->insertStep(1, new BlackBerryCreatePackageStep(dc->stepList()));
dc->stepList()->insertStep(2, new BlackBerryDeployStep(dc->stepList()));
return dc;
diff --git a/src/plugins/qnx/blackberrydeviceconnection.cpp b/src/plugins/qnx/blackberrydeviceconnection.cpp
index be613e0e72..c28bf87ddc 100644
--- a/src/plugins/qnx/blackberrydeviceconnection.cpp
+++ b/src/plugins/qnx/blackberrydeviceconnection.cpp
@@ -62,7 +62,7 @@ BlackBerryDeviceConnection::BlackBerryDeviceConnection() :
void BlackBerryDeviceConnection::connectDevice(const ProjectExplorer::IDevice::ConstPtr &device)
{
Utils::Environment env = Utils::Environment::systemEnvironment();
- env.modify(BlackBerryConfigurationManager::instance().defaultQnxEnv());
+ env.modify(BlackBerryConfigurationManager::instance().defaultApiLevelEnv());
m_process->setEnvironment(env.toStringList());
diff --git a/src/plugins/qnx/blackberrydeviceinformation.cpp b/src/plugins/qnx/blackberrydeviceinformation.cpp
index a21142bc2d..0c8d440589 100644
--- a/src/plugins/qnx/blackberrydeviceinformation.cpp
+++ b/src/plugins/qnx/blackberrydeviceinformation.cpp
@@ -68,6 +68,7 @@ void BlackBerryDeviceInformation::resetResults()
m_deviceOS.clear();
m_hardwareId.clear();
m_debugTokenAuthor.clear();
+ m_debugTokenValidationError.clear();
m_scmBundle.clear();
m_hostName.clear();
m_debugTokenValid = false;
@@ -95,6 +96,11 @@ QString BlackBerryDeviceInformation::debugTokenAuthor() const
return m_debugTokenAuthor;
}
+QString BlackBerryDeviceInformation::debugTokenValidationError() const
+{
+ return m_debugTokenValidationError;
+}
+
QString BlackBerryDeviceInformation::scmBundle() const
{
return m_scmBundle;
@@ -125,8 +131,9 @@ void BlackBerryDeviceInformation::processData(const QString &line)
static const QString devicepin = QLatin1String("devicepin::0x");
static const QString device_os = QLatin1String("device_os::");
static const QString hardwareid = QLatin1String("hardwareid::");
- static const QString debug_token_author = QLatin1String("debug_token_author::");
- static const QString debug_token_valid = QLatin1String("debug_token_valid:b:");
+ static const QString debug_token_author = QLatin1String("[n]debug_token_author::");
+ static const QString debug_token_validation_error = QLatin1String("[n]debug_token_validation_error::");
+ static const QString debug_token_valid = QLatin1String("[n]debug_token_valid:b:");
static const QString simulator = QLatin1String("simulator:b:");
static const QString scmbundle = QLatin1String("scmbundle::");
static const QString hostname = QLatin1String("hostname::");
@@ -140,6 +147,8 @@ void BlackBerryDeviceInformation::processData(const QString &line)
m_hardwareId = line.mid(hardwareid.size()).trimmed();
else if (line.startsWith(debug_token_author))
m_debugTokenAuthor = line.mid(debug_token_author.size()).trimmed();
+ else if (line.startsWith(debug_token_validation_error))
+ m_debugTokenValidationError = line.mid(debug_token_validation_error.size()).trimmed();
else if (line.startsWith(debug_token_valid))
m_debugTokenValid = line.mid(debug_token_valid.size()).trimmed() == QLatin1String("true");
else if (line.startsWith(simulator))
diff --git a/src/plugins/qnx/blackberrydeviceinformation.h b/src/plugins/qnx/blackberrydeviceinformation.h
index 0bfe156291..f9e8794299 100644
--- a/src/plugins/qnx/blackberrydeviceinformation.h
+++ b/src/plugins/qnx/blackberrydeviceinformation.h
@@ -62,6 +62,7 @@ public:
QString deviceOS() const;
QString hardwareId() const;
QString debugTokenAuthor() const;
+ QString debugTokenValidationError() const;
bool debugTokenValid() const;
QString scmBundle() const;
QString hostName() const;
@@ -75,6 +76,7 @@ private:
QString m_debugTokenAuthor;
QString m_scmBundle;
QString m_hostName;
+ QString m_debugTokenValidationError;
bool m_debugTokenValid;
bool m_isSimulator;
bool m_isProductionDevice;
diff --git a/src/plugins/qnx/blackberrydevicelistdetector.cpp b/src/plugins/qnx/blackberrydevicelistdetector.cpp
index 108f0607e1..59bd501f5d 100644
--- a/src/plugins/qnx/blackberrydevicelistdetector.cpp
+++ b/src/plugins/qnx/blackberrydevicelistdetector.cpp
@@ -57,7 +57,7 @@ void BlackBerryDeviceListDetector::detectDeviceList()
return;
m_process->setEnvironment(Utils::EnvironmentItem::toStringList(
- BlackBerryConfigurationManager::instance().defaultQnxEnv()));
+ BlackBerryConfigurationManager::instance().defaultApiLevelEnv()));
const QString command = BlackBerryNdkProcess::resolveNdkToolPath(QLatin1String("blackberry-deploy"));
QStringList arguments;
arguments << QLatin1String("-devices");
diff --git a/src/plugins/qnx/blackberryinstallwizardpages.cpp b/src/plugins/qnx/blackberryinstallwizardpages.cpp
index e0e8369048..207b8b29d7 100644
--- a/src/plugins/qnx/blackberryinstallwizardpages.cpp
+++ b/src/plugins/qnx/blackberryinstallwizardpages.cpp
@@ -479,7 +479,7 @@ void BlackBerryInstallWizardFinalPage::initializePage()
BlackBerryConfiguration *config = configManager.configurationFromEnvFile(Utils::FileName::fromString(m_data.ndkPath));
if (!config) {
- config = new BlackBerryConfiguration(Utils::FileName::fromString(m_data.ndkPath), false);
+ config = new BlackBerryConfiguration(Utils::FileName::fromString(m_data.ndkPath));
if (!configManager.addConfiguration(config)) {
delete config;
// TODO: more explicit error message!
diff --git a/src/plugins/qnx/blackberrykeyspage.cpp b/src/plugins/qnx/blackberrykeyspage.cpp
index e9c173c324..f0435a8ffb 100644
--- a/src/plugins/qnx/blackberrykeyspage.cpp
+++ b/src/plugins/qnx/blackberrykeyspage.cpp
@@ -51,9 +51,10 @@ BlackBerryKeysPage::BlackBerryKeysPage(QObject *parent) :
Constants::QNX_BB_CATEGORY_TR));
}
-QWidget *BlackBerryKeysPage::createPage(QWidget *parent)
+QWidget *BlackBerryKeysPage::widget()
{
- m_widget = new BlackBerryKeysWidget(parent);
+ if (!m_widget)
+ m_widget = new BlackBerryKeysWidget;
return m_widget;
}
@@ -63,6 +64,7 @@ void BlackBerryKeysPage::apply()
void BlackBerryKeysPage::finish()
{
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/qnx/blackberrykeyspage.h b/src/plugins/qnx/blackberrykeyspage.h
index 7c8c003a6e..dd2376e10c 100644
--- a/src/plugins/qnx/blackberrykeyspage.h
+++ b/src/plugins/qnx/blackberrykeyspage.h
@@ -34,6 +34,8 @@
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
namespace Qnx {
namespace Internal {
@@ -44,12 +46,12 @@ class BlackBerryKeysPage : public Core::IOptionsPage
Q_OBJECT
public:
explicit BlackBerryKeysPage(QObject *parent = 0);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
private:
- BlackBerryKeysWidget *m_widget;
+ QPointer<BlackBerryKeysWidget> m_widget;
};
} // namespace Internal
diff --git a/src/plugins/qnx/blackberrykeyswidget.cpp b/src/plugins/qnx/blackberrykeyswidget.cpp
index 905b95b667..8c5f6d22e2 100644
--- a/src/plugins/qnx/blackberrykeyswidget.cpp
+++ b/src/plugins/qnx/blackberrykeyswidget.cpp
@@ -68,6 +68,8 @@ void BlackBerryKeysWidget::certificateLoaded(int status)
switch (status) {
case BlackBerryCertificate::Success:
m_ui->certificateAuthor->setText(m_utils.defaultCertificate()->author());
+ m_ui->certificateAuthor->setVisible(true);
+ m_ui->authorLabel->setVisible(true);
m_ui->openCertificateButton->setVisible(false);
break;
case BlackBerryCertificate::WrongPassword:
@@ -130,9 +132,18 @@ void BlackBerryKeysWidget::updateCertificateSection()
BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance();
m_ui->certificatePath->setText(configManager.defaultKeystorePath());
- m_ui->certificateAuthor->setText(tr("Loading..."));
- loadDefaultCertificate();
+ const BlackBerryCertificate *certificate = m_utils.defaultCertificate();
+
+ if (certificate) {
+ m_ui->certificateAuthor->setText(certificate->author());
+ m_ui->openCertificateButton->setVisible(false);
+ return;
+ }
+
+ m_ui->openCertificateButton->setVisible(true);
+ m_ui->certificateAuthor->setVisible(false);
+ m_ui->authorLabel->setVisible(false);
} else {
setCreateCertificateVisible(true);
}
@@ -157,16 +168,8 @@ void BlackBerryKeysWidget::updateKeysSection()
void BlackBerryKeysWidget::loadDefaultCertificate()
{
- const BlackBerryCertificate *certificate = m_utils.defaultCertificate();
-
- if (certificate) {
- m_ui->certificateAuthor->setText(certificate->author());
- m_ui->openCertificateButton->setVisible(false);
- return;
- }
-
connect(&m_utils, SIGNAL(defaultCertificateLoaded(int)), this, SLOT(certificateLoaded(int)));
- m_utils.openDefaultCertificate();
+ m_utils.openDefaultCertificate(this);
}
void BlackBerryKeysWidget::setCertificateError(const QString &error)
diff --git a/src/plugins/qnx/blackberryndkprocess.cpp b/src/plugins/qnx/blackberryndkprocess.cpp
index 9f26718d88..2c1a182a43 100644
--- a/src/plugins/qnx/blackberryndkprocess.cpp
+++ b/src/plugins/qnx/blackberryndkprocess.cpp
@@ -47,8 +47,9 @@ BlackBerryNdkProcess::BlackBerryNdkProcess(const QString &command, QObject *pare
{
m_process->setProcessChannelMode(QProcess::MergedChannels);
m_process->setEnvironment(Utils::EnvironmentItem::toStringList(
- BlackBerryConfigurationManager::instance().defaultQnxEnv()));
+ BlackBerryConfigurationManager::instance().defaultApiLevelEnv()));
+ connect(m_process, SIGNAL(started()), this, SIGNAL(started()));
connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)),
this, SLOT(processFinished()));
connect(m_process, SIGNAL(error(QProcess::ProcessError)),
@@ -58,7 +59,8 @@ BlackBerryNdkProcess::BlackBerryNdkProcess(const QString &command, QObject *pare
const QString BlackBerryNdkProcess::resolveNdkToolPath(const QString &tool)
{
QString toolPath;
- QList<Utils::EnvironmentItem> qnxEnv = BlackBerryConfigurationManager::instance().defaultQnxEnv();
+ QList<Utils::EnvironmentItem> qnxEnv =
+ BlackBerryConfigurationManager::instance().defaultApiLevelEnv();
foreach (const Utils::EnvironmentItem &item, qnxEnv) {
if (item.name == QLatin1String("QNX_HOST") && !item.value.isEmpty()) {
toolPath = item.value
diff --git a/src/plugins/qnx/blackberryndkprocess.h b/src/plugins/qnx/blackberryndkprocess.h
index 13637de7e9..1532e1564e 100644
--- a/src/plugins/qnx/blackberryndkprocess.h
+++ b/src/plugins/qnx/blackberryndkprocess.h
@@ -65,6 +65,7 @@ public:
signals:
void finished(int status);
+ void started();
protected:
explicit BlackBerryNdkProcess(const QString &command, QObject *parent = 0);
diff --git a/src/plugins/qnx/blackberryndksettingspage.cpp b/src/plugins/qnx/blackberryndksettingspage.cpp
index ff77f7c1cd..0e28a4263c 100644
--- a/src/plugins/qnx/blackberryndksettingspage.cpp
+++ b/src/plugins/qnx/blackberryndksettingspage.cpp
@@ -31,6 +31,7 @@
#include "blackberryndksettingspage.h"
#include "blackberryndksettingswidget.h"
+#include "blackberryconfigurationmanager.h"
#include "blackberryconfiguration.h"
#include "qnxconstants.h"
@@ -45,16 +46,17 @@ BlackBerryNDKSettingsPage::BlackBerryNDKSettingsPage(QObject *parent) :
Core::IOptionsPage(parent)
{
setId(Core::Id(Constants::QNX_BB_NDK_SETTINGS_ID));
- setDisplayName(tr("NDK"));
+ setDisplayName(tr("API Level"));
setCategory(Constants::QNX_BB_CATEGORY);
setDisplayCategory(QCoreApplication::translate("BlackBerry",
Constants::QNX_BB_CATEGORY_TR));
setCategoryIcon(QLatin1String(Constants::QNX_BB_CATEGORY_ICON));
}
-QWidget *BlackBerryNDKSettingsPage::createPage(QWidget *parent)
+QWidget *BlackBerryNDKSettingsPage::widget()
{
- m_widget = new BlackBerryNDKSettingsWidget(parent);
+ if (!m_widget)
+ m_widget = new BlackBerryNDKSettingsWidget;
return m_widget;
}
@@ -69,10 +71,13 @@ void BlackBerryNDKSettingsPage::apply()
if (config->isActive())
config->deactivate();
}
+
+ BlackBerryConfigurationManager::instance().setDefaultApiLevel(m_widget->defaultApiLevel());
}
void BlackBerryNDKSettingsPage::finish()
{
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/qnx/blackberryndksettingspage.h b/src/plugins/qnx/blackberryndksettingspage.h
index 2992f80da0..825b95a4ae 100644
--- a/src/plugins/qnx/blackberryndksettingspage.h
+++ b/src/plugins/qnx/blackberryndksettingspage.h
@@ -34,6 +34,8 @@
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
namespace Qnx {
namespace Internal {
@@ -44,12 +46,12 @@ class BlackBerryNDKSettingsPage : public Core::IOptionsPage
Q_OBJECT
public:
explicit BlackBerryNDKSettingsPage(QObject *parent = 0);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
private:
- BlackBerryNDKSettingsWidget *m_widget;
+ QPointer<BlackBerryNDKSettingsWidget> m_widget;
};
} // namespace Internal
diff --git a/src/plugins/qnx/blackberryndksettingswidget.cpp b/src/plugins/qnx/blackberryndksettingswidget.cpp
index 0e7d89ab8f..a30a988bc9 100644
--- a/src/plugins/qnx/blackberryndksettingswidget.cpp
+++ b/src/plugins/qnx/blackberryndksettingswidget.cpp
@@ -51,23 +51,25 @@
namespace Qnx {
namespace Internal {
+static QIcon invalidConfigIcon(QLatin1String(":/projectexplorer/images/compile_error.png"));
+
BlackBerryNDKSettingsWidget::BlackBerryNDKSettingsWidget(QWidget *parent) :
QWidget(parent),
m_ui(new Ui_BlackBerryNDKSettingsWidget),
+ m_defaultApiLevel(0),
m_autoDetectedNdks(0),
m_manualNdks(0)
{
m_bbConfigManager = &BlackBerryConfigurationManager::instance();
m_ui->setupUi(this);
- m_ui->activateNdkTargetButton->setEnabled(false);
- m_ui->deactivateNdkTargetButton->setEnabled(false);
+ updateInfoTable(0);
m_activatedTargets << m_bbConfigManager->activeConfigurations();
m_ui->ndksTreeWidget->header()->setResizeMode(QHeaderView::Stretch);
m_ui->ndksTreeWidget->header()->setStretchLastSection(false);
- m_ui->ndksTreeWidget->setHeaderItem(new QTreeWidgetItem(QStringList() << tr("NDK") << tr("NDK Environment File")));
+ m_ui->ndksTreeWidget->setHeaderItem(new QTreeWidgetItem(QStringList() << tr("API Level") << tr("Environment File")));
m_ui->ndksTreeWidget->setTextElideMode(Qt::ElideNone);
m_ui->ndksTreeWidget->setColumnCount(2);
m_autoDetectedNdks = new QTreeWidgetItem(m_ui->ndksTreeWidget);
@@ -81,14 +83,17 @@ BlackBerryNDKSettingsWidget::BlackBerryNDKSettingsWidget(QWidget *parent) :
m_ui->ndksTreeWidget->expandAll();
- updateNdkList();
-
connect(m_ui->wizardButton, SIGNAL(clicked()), this, SLOT(launchBlackBerrySetupWizard()));
connect(m_ui->addNdkButton, SIGNAL(clicked()), this, SLOT(addNdkTarget()));
connect(m_ui->removeNdkButton, SIGNAL(clicked()), this, SLOT(removeNdkTarget()));
connect(m_ui->activateNdkTargetButton, SIGNAL(clicked()), this, SLOT(activateNdkTarget()));
connect(m_ui->deactivateNdkTargetButton, SIGNAL(clicked()), this, SLOT(deactivateNdkTarget()));
+ connect(m_ui->cleanUpButton, SIGNAL(clicked()), this, SLOT(cleanUp()));
connect(m_ui->ndksTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(updateInfoTable(QTreeWidgetItem*)));
+ connect(m_ui->apiLevelCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setDefaultApiLevel(int)));
+
+ updateNdkList();
+ updateDefaultApiLevel();
}
void BlackBerryNDKSettingsWidget::setWizardMessageVisible(bool visible)
@@ -112,13 +117,18 @@ QList<BlackBerryConfiguration *> BlackBerryNDKSettingsWidget::deactivatedTargets
return m_deactivatedTargets;
}
+BlackBerryConfiguration *BlackBerryNDKSettingsWidget::defaultApiLevel() const
+{
+ return m_defaultApiLevel;
+}
+
void BlackBerryNDKSettingsWidget::launchBlackBerrySetupWizard() const
{
BlackBerrySigningUtils &blackBerryUtils = BlackBerrySigningUtils::instance();
const bool alreadyConfigured = blackBerryUtils.hasRegisteredKeys() && blackBerryUtils.hasDefaultCertificate();
if (alreadyConfigured) {
- QMessageBox::information(0, tr("Qt Creator"),
+ QMessageBox::information(Core::ICore::mainWindow(), tr("Qt Creator"),
tr("It appears that your BlackBerry environment has already been configured."));
return;
}
@@ -130,37 +140,17 @@ void BlackBerryNDKSettingsWidget::launchBlackBerrySetupWizard() const
void BlackBerryNDKSettingsWidget::updateInfoTable(QTreeWidgetItem* currentItem)
{
- if (!currentItem)
- return;
-
- QString envFilePath = currentItem->text(1);
- if (envFilePath.isEmpty()) {
- m_ui->removeNdkButton->setEnabled(false);
- m_ui->activateNdkTargetButton->setEnabled(false);
- m_ui->deactivateNdkTargetButton->setEnabled(false);
- return;
- }
-
- BlackBerryConfiguration *config = m_bbConfigManager->configurationFromEnvFile(Utils::FileName::fromString(envFilePath));
- if (!config)
- return;
+ BlackBerryConfiguration *config = m_bbConfigManager->configurationFromEnvFile(
+ Utils::FileName::fromString(currentItem ? currentItem->text(1) : QString()));
+ updateUi(currentItem, config);
- m_ui->baseNameLabel->setText(config->displayName());
- m_ui->ndkPathLabel->setText(QDir::toNativeSeparators(config->ndkPath()));
- m_ui->hostLabel->setText(QDir::toNativeSeparators(config->qnxHost()));
- m_ui->targetLabel->setText(QDir::toNativeSeparators(config->sysRoot().toString()));
- m_ui->versionLabel->clear();
- // TODO: Add a versionNumber attribute for the BlackBerryConfiguration class
- if (config->isAutoDetected()) {
- foreach (const NdkInstallInformation &ndkInfo, QnxUtils::installedNdks()) {
- if (ndkInfo.name == config->displayName()) {
- m_ui->versionLabel->setText(ndkInfo.version);
- break;
- }
- }
+ m_ui->informationBox->setVisible(config);
+ if (config) {
+ m_ui->baseNameLabel->setText(config->displayName());
+ m_ui->hostLabel->setText(QDir::toNativeSeparators(config->qnxHost()));
+ m_ui->targetLabel->setText(QDir::toNativeSeparators(config->sysRoot().toString()));
+ m_ui->versionLabel->setText(config->version().toString());
}
-
- updateUi(currentItem, config);
}
void BlackBerryNDKSettingsWidget::updateNdkList()
@@ -168,6 +158,7 @@ void BlackBerryNDKSettingsWidget::updateNdkList()
qDeleteAll(m_autoDetectedNdks->takeChildren());
qDeleteAll(m_manualNdks->takeChildren());
+ bool enableCleanUp = false;
foreach (BlackBerryConfiguration *config, m_bbConfigManager->configurations()) {
QTreeWidgetItem *parent = config->isAutoDetected() ? m_autoDetectedNdks : m_manualNdks;
QTreeWidgetItem *item = new QTreeWidgetItem(parent);
@@ -177,12 +168,36 @@ void BlackBerryNDKSettingsWidget::updateNdkList()
font.setBold(config->isActive() || m_activatedTargets.contains(config));
item->setFont(0, font);
item->setFont(1, font);
- }
+ item->setIcon(0, config->isValid() ? QIcon() : invalidConfigIcon);
+ // TODO: Do the same if qmake, qcc, debugger are no longer detected...
+ if (!config->isValid()) {
+ QString toolTip = tr("Invalid target %1: ").arg(config->targetName());
+ if (config->isAutoDetected() && !config->autoDetectionSource().toFileInfo().exists())
+ toolTip += QLatin1Char('\n') + tr("- Target no longer installed.");
+
+ if (!config->ndkEnvFile().toFileInfo().exists())
+ toolTip += QLatin1Char('\n') + tr("- No NDK environment file found.");
- if (m_autoDetectedNdks->child(0)) {
- m_autoDetectedNdks->child(0)->setSelected(true);
- updateInfoTable(m_autoDetectedNdks->child(0));
+ if (config->qmake4BinaryFile().isEmpty()
+ && config->qmake5BinaryFile().isEmpty())
+ toolTip += QLatin1Char('\n') + tr("- No Qt version found.");
+
+ if (config->gccCompiler().isEmpty())
+ toolTip += QLatin1Char('\n') + tr("- No compiler found.");
+
+ if (config->deviceDebuger().isEmpty())
+ toolTip += QLatin1Char('\n') + tr("- No debugger found for device.");
+
+ if (config->simulatorDebuger().isEmpty())
+ toolTip += QLatin1Char('\n') + tr("- No debugger found for simulator.");
+
+ item->setToolTip(0, toolTip);
+ enableCleanUp = true;
+ }
}
+
+ m_ui->ndksTreeWidget->setCurrentItem(m_autoDetectedNdks->child(0));
+ m_ui->cleanUpButton->setEnabled(enableCleanUp);
}
void BlackBerryNDKSettingsWidget::addNdkTarget()
@@ -220,6 +235,7 @@ void BlackBerryNDKSettingsWidget::removeNdkTarget()
m_deactivatedTargets.removeOne(config);
m_bbConfigManager->removeConfiguration(config);
m_manualNdks->removeChild(m_ui->ndksTreeWidget->currentItem());
+ updateDefaultApiLevel();
emit targetsUpdated();
}
}
@@ -260,17 +276,21 @@ void BlackBerryNDKSettingsWidget::deactivateNdkTarget()
void BlackBerryNDKSettingsWidget::updateUi(QTreeWidgetItem *item, BlackBerryConfiguration *config)
{
- if (!item || !config)
+ if (!item || !config) {
+ m_ui->removeNdkButton->setEnabled(false);
+ m_ui->activateNdkTargetButton->setEnabled(false);
+ m_ui->deactivateNdkTargetButton->setEnabled(false);
return;
+ }
+ const bool contains = m_activatedTargets.contains(config);
QFont font;
- font.setBold(m_activatedTargets.contains(config));
+ font.setBold(contains);
item->setFont(0, font);
item->setFont(1, font);
- m_ui->activateNdkTargetButton->setEnabled(!m_activatedTargets.contains(config));
- m_ui->deactivateNdkTargetButton->setEnabled(m_activatedTargets.contains(config)
- && m_activatedTargets.size() > 1);
+ m_ui->activateNdkTargetButton->setEnabled(!contains);
+ m_ui->deactivateNdkTargetButton->setEnabled(contains && m_activatedTargets.size() > 1);
// Disable remove button for auto detected pre-10.2 NDKs (uninstall wizard doesn't handle them)
m_ui->removeNdkButton->setEnabled(!(config->isAutoDetected()
&& QnxUtils::sdkInstallerPath(config->ndkPath()).isEmpty()));
@@ -287,9 +307,23 @@ void BlackBerryNDKSettingsWidget::uninstallNdkTarget()
launchBlackBerryInstallerWizard(BlackBerryInstallerDataHandler::UninstallMode, m_ui->versionLabel->text());
}
+void BlackBerryNDKSettingsWidget::cleanUp()
+{
+ foreach (BlackBerryConfiguration *config, m_bbConfigManager->configurations()) {
+ if (!config->isValid()) {
+ m_activatedTargets.removeOne(config);
+ m_deactivatedTargets.removeOne(config);
+ m_bbConfigManager->removeConfiguration(config);
+ }
+ }
+
+ updateNdkList();
+}
+
void BlackBerryNDKSettingsWidget::handleInstallationFinished()
{
m_bbConfigManager->loadAutoDetectedConfigurations();
+ updateDefaultApiLevel();
updateNdkList();
}
@@ -314,9 +348,53 @@ void BlackBerryNDKSettingsWidget::handleUninstallationFinished()
m_bbConfigManager->removeConfiguration(config);
+ updateDefaultApiLevel();
updateNdkList();
}
+void BlackBerryNDKSettingsWidget::setDefaultApiLevel(int index)
+{
+ if (index < 0)
+ return;
+
+ const QString ndkEnvFile = m_ui->apiLevelCombo->itemData(index).toString();
+
+ foreach (BlackBerryConfiguration *config, m_bbConfigManager->configurations()) {
+ if (config->ndkEnvFile().toString() == ndkEnvFile) {
+ m_defaultApiLevel = config;
+ return;
+ }
+ }
+
+ m_defaultApiLevel = 0;
+
+ qWarning("Cannot set default API level");
+}
+
+void BlackBerryNDKSettingsWidget::updateDefaultApiLevel()
+{
+ m_ui->apiLevelCombo->clear();
+
+ if (m_bbConfigManager->configurations().isEmpty())
+ return;
+
+ foreach (BlackBerryConfiguration *config, m_bbConfigManager->configurations())
+ m_ui->apiLevelCombo->addItem(config->displayName(), config->ndkEnvFile().toString());
+
+ BlackBerryConfiguration *conf = m_bbConfigManager->defaultApiLevel();
+
+ if (!conf) {
+ m_ui->apiLevelCombo->setCurrentIndex(-1);
+ m_defaultApiLevel = 0;
+ return;
+ }
+
+ m_defaultApiLevel = conf;
+
+ const int currentIndex = m_ui->apiLevelCombo->findData(conf->ndkEnvFile().toString());
+ m_ui->apiLevelCombo->setCurrentIndex(currentIndex);
+}
+
void BlackBerryNDKSettingsWidget::launchBlackBerryInstallerWizard(BlackBerryInstallerDataHandler::Mode mode,
const QString& targetVersion)
{
diff --git a/src/plugins/qnx/blackberryndksettingswidget.h b/src/plugins/qnx/blackberryndksettingswidget.h
index 6d05dd6a19..494eb8aeed 100644
--- a/src/plugins/qnx/blackberryndksettingswidget.h
+++ b/src/plugins/qnx/blackberryndksettingswidget.h
@@ -61,6 +61,8 @@ public:
QList<BlackBerryConfiguration *> activatedTargets();
QList<BlackBerryConfiguration *> deactivatedTargets();
+ BlackBerryConfiguration *defaultApiLevel() const;
+
signals:
void targetsUpdated();
@@ -73,9 +75,12 @@ public slots:
void activateNdkTarget();
void deactivateNdkTarget();
void uninstallNdkTarget();
+ void cleanUp();
void handleInstallationFinished();
void handleUninstallationFinished();
void updateUi(QTreeWidgetItem* item, BlackBerryConfiguration* config);
+ void setDefaultApiLevel(int index);
+ void updateDefaultApiLevel();
private:
void launchBlackBerryInstallerWizard(BlackBerryInstallerDataHandler::Mode mode,
@@ -83,6 +88,7 @@ private:
Ui_BlackBerryNDKSettingsWidget *m_ui;
BlackBerryConfigurationManager *m_bbConfigManager;
+ BlackBerryConfiguration *m_defaultApiLevel;
QTreeWidgetItem *m_autoDetectedNdks;
QTreeWidgetItem *m_manualNdks;
diff --git a/src/plugins/qnx/blackberryndksettingswidget.ui b/src/plugins/qnx/blackberryndksettingswidget.ui
index 57d608b1a5..c142b58368 100644
--- a/src/plugins/qnx/blackberryndksettingswidget.ui
+++ b/src/plugins/qnx/blackberryndksettingswidget.ui
@@ -147,236 +147,192 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
+ <item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <widget class="QTreeWidget" name="ndksTreeWidget">
- <column>
- <property name="text">
- <string notr="true">1</string>
- </property>
- </column>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Default API level:</string>
+ </property>
</widget>
</item>
<item>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QPushButton" name="addNdkButton">
- <property name="text">
- <string>Add</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="removeNdkButton">
- <property name="text">
- <string>Remove</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="activateNdkTargetButton">
- <property name="text">
- <string>Activate</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="deactivateNdkTargetButton">
- <property name="text">
- <string>Deactivate</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <widget class="QComboBox" name="apiLevelCombo"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
</item>
</layout>
</item>
- </layout>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>BlackBerry NDK Information</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_7">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_7">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;NDK Base Name:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="baseNameLabel">
+ <item row="1" column="0">
+ <widget class="QTreeWidget" name="ndksTreeWidget">
+ <column>
+ <property name="text">
+ <string notr="true">1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="1" column="1" rowspan="2">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QPushButton" name="addNdkButton">
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="removeNdkButton">
+ <property name="text">
+ <string>Remove</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>13</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="activateNdkTargetButton">
+ <property name="text">
+ <string>Activate</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="deactivateNdkTargetButton">
+ <property name="text">
+ <string>Deactivate</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>13</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cleanUpButton">
+ <property name="text">
+ <string>Clean Up</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <widget class="QGroupBox" name="informationBox">
+ <property name="title">
+ <string>API Level Information</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="2" column="1">
+ <widget class="QLabel" name="versionLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_8">
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;NDK Path:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="ndkPathLabel">
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
<property name="text">
- <string/>
+ <string>Name:</string>
</property>
</widget>
</item>
- <item>
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_9">
- <item>
+ <item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Version:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>Version:</string>
</property>
</widget>
</item>
- <item>
- <widget class="QLabel" name="versionLabel">
+ <item row="3" column="1">
+ <widget class="QLabel" name="hostLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
- <item>
- <spacer name="horizontalSpacer_4">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_10">
- <item>
- <widget class="QLabel" name="label_4">
+ <item row="1" column="1">
+ <widget class="QLabel" name="baseNameLabel">
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Host:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string/>
</property>
</widget>
</item>
- <item>
- <widget class="QLabel" name="hostLabel">
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_4">
<property name="text">
- <string/>
+ <string>Host:</string>
</property>
</widget>
</item>
- <item>
- <spacer name="horizontalSpacer_5">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_11">
- <item>
+ <item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Target:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>Target:</string>
</property>
</widget>
</item>
- <item>
+ <item row="4" column="1">
<widget class="QLabel" name="targetLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
- <item>
- <spacer name="horizontalSpacer_6">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
- </item>
- </layout>
- </widget>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>
diff --git a/src/plugins/qnx/blackberrysetupwizard.cpp b/src/plugins/qnx/blackberrysetupwizard.cpp
index 183f31d903..d525c55808 100644
--- a/src/plugins/qnx/blackberrysetupwizard.cpp
+++ b/src/plugins/qnx/blackberrysetupwizard.cpp
@@ -217,6 +217,13 @@ void BlackBerrySetupWizard::debugTokenArrived(int status)
break;
}
+ BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance();
+
+ QFile dt(configuration.defaultKeystorePath());
+
+ if (dt.exists())
+ dt.remove();
+
QMessageBox::critical(this, tr("Error"), errorString);
reset();
@@ -407,8 +414,13 @@ void BlackBerrySetupWizard::requestDebugToken()
BlackBerryConfigurationManager &configuration = BlackBerryConfigurationManager::instance();
+ bool ok;
+ const QString cskPassword = m_utils.cskPassword(this, &ok);
+ if (!ok)
+ return;
+
m_requester->requestDebugToken(configuration.defaultDebugTokenPath(),
- m_utils.cskPassword(), configuration.defaultKeystorePath(), certificatePassword(), m_devicePin);
+ cskPassword, configuration.defaultKeystorePath(), certificatePassword(), m_devicePin);
}
void BlackBerrySetupWizard::uploadDebugToken()
diff --git a/src/plugins/qnx/blackberrysetupwizardkeyspage.ui b/src/plugins/qnx/blackberrysetupwizardkeyspage.ui
index c5cba65fa5..a71ed39883 100644
--- a/src/plugins/qnx/blackberrysetupwizardkeyspage.ui
+++ b/src/plugins/qnx/blackberrysetupwizardkeyspage.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>503</width>
+ <width>581</width>
<height>222</height>
</rect>
</property>
@@ -15,14 +15,14 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <spacer name="verticalSpacer">
+ <spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>63</height>
+ <height>40</height>
</size>
</property>
</spacer>
@@ -127,7 +127,7 @@
<enum>QFrame::StyledPanel</enum>
</property>
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Legacy keys detected&lt;/span&gt;&lt;/p&gt;&lt;p&gt;It appears you are using legacy key files. Please visit &lt;a href=&quot;https://developer.blackberry.com/native/documentation/core/com.qnx.doc.native_sdk.devguide/com.qnx.doc.native_sdk.devguide/topic/bbid_to_sa.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#004f69;&quot;&gt;this page&lt;/span&gt;&lt;/a&gt; to upgrade your keys.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Legacy keys detected&lt;/span&gt;&lt;/p&gt;&lt;p&gt;It appears you are using legacy key files. Please visit &lt;a href=&quot;https://developer.blackberry.com/native/documentation/core/com.qnx.doc.native_sdk.devguide/topic/bbid_to_sa.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#004f69;&quot;&gt;this page&lt;/span&gt;&lt;/a&gt; to upgrade your keys.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
@@ -266,6 +266,125 @@
</widget>
</item>
<item>
+ <widget class="QLabel" name="helpLabel">
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="Button">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="Button">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="Button">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Help&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Check &lt;a href=&quot;https://developer.blackberry.com/CodeSigningHelp/codesignhelp.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#004f69;&quot;&gt;this link&lt;/span&gt;&lt;/a&gt; if you need help with code signing.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="openExternalLinks">
+ <bool>false</bool>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextBrowserInteraction</set>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QLabel" name="statusLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -291,14 +410,14 @@
</widget>
</item>
<item>
- <spacer name="verticalSpacer_2">
+ <spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>62</height>
+ <height>40</height>
</size>
</property>
</spacer>
diff --git a/src/plugins/qnx/blackberrysetupwizardpages.cpp b/src/plugins/qnx/blackberrysetupwizardpages.cpp
index aee8907fc5..4a92c549c8 100644
--- a/src/plugins/qnx/blackberrysetupwizardpages.cpp
+++ b/src/plugins/qnx/blackberrysetupwizardpages.cpp
@@ -172,6 +172,8 @@ void BlackBerrySetupWizardKeysPage::initUi()
this, SLOT(showKeysMessage(QString)));
connect(m_ui->legacyLabel, SIGNAL(linkActivated(QString)),
this, SLOT(showKeysMessage(QString)));
+ connect(m_ui->helpLabel, SIGNAL(linkActivated(QString)),
+ this, SLOT(showKeysMessage(QString)));
}
void BlackBerrySetupWizardKeysPage::setComplete(bool complete)
@@ -321,7 +323,7 @@ BlackBerrySetupWizardFinishPage::BlackBerrySetupWizardFinishPage(QWidget *parent
: QWizardPage(parent),
m_ui(0)
{
- setSubTitle(tr("Your environment is ready to be configured."));
+ setTitle(tr("Your environment is ready to be configured."));
m_ui = new Ui::BlackBerrySetupWizardFinishPage;
m_ui->setupUi(this);
diff --git a/src/plugins/qnx/blackberrysigningutils.cpp b/src/plugins/qnx/blackberrysigningutils.cpp
index 9cfd77a0ca..eee1410def 100644
--- a/src/plugins/qnx/blackberrysigningutils.cpp
+++ b/src/plugins/qnx/blackberrysigningutils.cpp
@@ -82,18 +82,24 @@ bool BlackBerrySigningUtils::hasDefaultCertificate()
return keystore.exists();
}
-QString BlackBerrySigningUtils::cskPassword()
+QString BlackBerrySigningUtils::cskPassword(QWidget *passwordPromptParent, bool *ok)
{
if (m_cskPassword.isEmpty())
- m_cskPassword = promptPassword(tr("Please provide your bbidtoken.csk PIN."));
+ m_cskPassword = promptPassword(tr("Please provide your bbidtoken.csk PIN."), passwordPromptParent, ok);
+ else if (ok)
+ *ok = true;
return m_cskPassword;
}
-QString BlackBerrySigningUtils::certificatePassword()
+QString BlackBerrySigningUtils::certificatePassword(QWidget *passwordPromptParent, bool *ok)
{
- if (m_certificatePassword.isEmpty())
- m_certificatePassword = promptPassword(tr("Please enter your certificate password."));
+ if (m_certificatePassword.isEmpty()) {
+ m_certificatePassword =
+ promptPassword(tr("Please enter your certificate password."), passwordPromptParent, ok);
+ } else if (ok) {
+ *ok = true;
+ }
return m_certificatePassword;
}
@@ -103,14 +109,19 @@ const BlackBerryCertificate * BlackBerrySigningUtils::defaultCertificate() const
return m_defaultCertificate;
}
-void BlackBerrySigningUtils::openDefaultCertificate()
+void BlackBerrySigningUtils::openDefaultCertificate(QWidget *passwordPromptParent)
{
if (m_defaultCertificate) {
emit defaultCertificateLoaded(BlackBerryCertificate::Success);
return;
}
- const QString password = certificatePassword();
+ bool ok;
+ const QString password = certificatePassword(passwordPromptParent, &ok);
+
+ // action has been canceled
+ if (!ok)
+ return;
BlackBerryConfigurationManager &configManager = BlackBerryConfigurationManager::instance();
@@ -165,16 +176,24 @@ void BlackBerrySigningUtils::certificateLoaded(int status)
emit defaultCertificateLoaded(status);
}
-QString BlackBerrySigningUtils::promptPassword(const QString &message) const
+QString BlackBerrySigningUtils::promptPassword(const QString &message,
+ QWidget *dialogParent, bool *ok) const
{
- QInputDialog dialog;
+ QInputDialog dialog(dialogParent);
dialog.setWindowTitle(tr("Qt Creator"));
dialog.setInputMode(QInputDialog::TextInput);
dialog.setLabelText(message);
dialog.setTextEchoMode(QLineEdit::Password);
- if (dialog.exec() == QDialog::Rejected)
+ if (dialog.exec() == QDialog::Rejected) {
+ if (ok)
+ *ok = false;
+
return QString();
+ }
+
+ if (ok)
+ *ok = true;
return dialog.textValue();
}
diff --git a/src/plugins/qnx/blackberrysigningutils.h b/src/plugins/qnx/blackberrysigningutils.h
index c141ac069a..388604b4fc 100644
--- a/src/plugins/qnx/blackberrysigningutils.h
+++ b/src/plugins/qnx/blackberrysigningutils.h
@@ -55,12 +55,12 @@ public:
bool hasLegacyKeys();
bool hasDefaultCertificate();
- QString cskPassword();
- QString certificatePassword();
+ QString cskPassword(QWidget *passwordPromptParent = 0, bool *ok = 0);
+ QString certificatePassword(QWidget *passwordPromptParent = 0, bool *ok = 0);
const BlackBerryCertificate *defaultCertificate() const;
- void openDefaultCertificate();
+ void openDefaultCertificate(QWidget *passwordPromptParent = 0);
void setDefaultCertificate(BlackBerryCertificate *certificate);
void clearCskPassword();
void clearCertificatePassword();
@@ -77,7 +77,7 @@ private:
BlackBerrySigningUtils(QObject *parent = 0);
- QString promptPassword(const QString &message) const;
+ QString promptPassword(const QString &message, QWidget *dialogParent = 0, bool *ok = 0) const;
BlackBerryCertificate *m_defaultCertificate;
diff --git a/src/plugins/qnx/blackberryversionnumber.cpp b/src/plugins/qnx/blackberryversionnumber.cpp
new file mode 100644
index 0000000000..89f56a2886
--- /dev/null
+++ b/src/plugins/qnx/blackberryversionnumber.cpp
@@ -0,0 +1,125 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+**
+** Contact: BlackBerry (qt@blackberry.com)
+** Contact: KDAB (info@kdab.com)
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "blackberryversionnumber.h"
+
+#include <QDir>
+
+namespace Qnx {
+namespace Internal {
+
+static const char NONDIGIT_SEGMENT_REGEXP[] = "(?<=\\d)(?=\\D)|(?<=\\D)(?=\\d)";
+
+BlackBerryVersionNumber::BlackBerryVersionNumber(const QStringList &listNumber)
+ : m_segments(listNumber)
+{
+}
+
+BlackBerryVersionNumber::BlackBerryVersionNumber(const QString &version)
+{
+ m_segments = version.split(QLatin1Char('.'));
+}
+
+BlackBerryVersionNumber::BlackBerryVersionNumber()
+{
+}
+
+QString BlackBerryVersionNumber::toString() const
+{
+ return m_segments.join(QLatin1String("."));
+}
+
+bool BlackBerryVersionNumber::operator >(const BlackBerryVersionNumber &b) const
+{
+ int minSize = size() > b.size() ? b.size() : size();
+ for (int i = 0; i < minSize; i++) {
+ if (segment(i) != b.segment(i)) {
+ // Segment can contain digits and non digits expressions
+ QStringList aParts = segment(i).split(QLatin1String(NONDIGIT_SEGMENT_REGEXP));
+ QStringList bParts = b.segment(i).split(QLatin1String(NONDIGIT_SEGMENT_REGEXP));
+
+ int minPartSize = aParts.length() > bParts.length() ? bParts.length() : aParts.length();
+ for (int j = 0; j < minPartSize; j++) {
+ bool aOk = true;
+ bool bOk = true;
+ int aInt = aParts[j].toInt(&aOk);
+ int bInt = bParts[j].toInt(&bOk);
+
+ if (aOk && bOk)
+ return aInt > bInt;
+
+ return aParts[j].compare(bParts[j]) > 0;
+ }
+ }
+ }
+
+ return false;
+}
+
+QString BlackBerryVersionNumber::segment(int index) const
+{
+ if (index < m_segments.length())
+ return m_segments.at(index);
+
+ return QString();
+}
+
+BlackBerryVersionNumber BlackBerryVersionNumber::fromNdkEnvFileName(const QString &ndkEnvFileName)
+{
+ return fromFileName(ndkEnvFileName, QRegExp(QLatin1String("^bbndk-env_(.*)$")));
+}
+
+BlackBerryVersionNumber BlackBerryVersionNumber::fromTargetName(const QString &targetName)
+{
+ return fromFileName(targetName, QRegExp(QLatin1String("^target_(.*)$")));
+}
+
+BlackBerryVersionNumber BlackBerryVersionNumber::fromFileName(const QString &fileName, const QRegExp &regExp)
+{
+ QStringList segments;
+ if (regExp.exactMatch(fileName) && regExp.captureCount() == 1)
+ segments << regExp.cap(1).split(QLatin1Char('_'));
+
+ return BlackBerryVersionNumber(segments);
+}
+
+int BlackBerryVersionNumber::size() const
+{
+ return m_segments.length();
+}
+
+bool BlackBerryVersionNumber::isEmpty() const
+{
+ return m_segments.isEmpty();
+}
+
+} // namespace Internal
+} // namespace Qnx
diff --git a/src/plugins/qnx/blackberrycheckdevmodestep.h b/src/plugins/qnx/blackberryversionnumber.h
index 44b330f16c..86cf272b75 100644
--- a/src/plugins/qnx/blackberrycheckdevmodestep.h
+++ b/src/plugins/qnx/blackberryversionnumber.h
@@ -29,35 +29,36 @@
**
****************************************************************************/
-#ifndef QNX_INTERNAL_BLACKBERRYCHECKDEVMODESTEP_H
-#define QNX_INTERNAL_BLACKBERRYCHECKDEVMODESTEP_H
+#ifndef BLACKBERRY_VERSION_NUMBER_H
+#define BLACKBERRY_VERSION_NUMBER_H
-#include "blackberryabstractdeploystep.h"
+#include <QStringList>
namespace Qnx {
namespace Internal {
-
-class BlackBerryCheckDevModeStep : public BlackBerryAbstractDeployStep
+class BlackBerryVersionNumber
{
- Q_OBJECT
- friend class BlackBerryCheckDevModeStepFactory;
-
public:
- explicit BlackBerryCheckDevModeStep(ProjectExplorer::BuildStepList *bsl);
+ BlackBerryVersionNumber(const QStringList &segments);
+ BlackBerryVersionNumber(const QString &version);
+ BlackBerryVersionNumber();
- bool init();
- ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
+ int size() const;
+ bool isEmpty() const;
+ QString segment(int index) const;
+ QString toString() const;
-protected:
- BlackBerryCheckDevModeStep(ProjectExplorer::BuildStepList *bsl, BlackBerryCheckDevModeStep *bs);
+ static BlackBerryVersionNumber fromNdkEnvFileName(const QString &ndkEnvFileName);
+ static BlackBerryVersionNumber fromTargetName(const QString &targetName);
+ static BlackBerryVersionNumber fromFileName(const QString &fileName, const QRegExp &regExp);
- void processStarted(const ProjectExplorer::ProcessParameters &params);
+ bool operator >(const BlackBerryVersionNumber &b) const;
private:
- QString password() const;
+ QStringList m_segments;
};
} // namespace Internal
} // namespace Qnx
-#endif // QNX_INTERNAL_BLACKBERRYCHECKDEVMODESTEP_H
+#endif // VERSIONNUMBER_H
diff --git a/src/plugins/qnx/cascadesimport/cascadesimport.pri b/src/plugins/qnx/cascadesimport/cascadesimport.pri
index 82962717e3..d8a1093103 100644
--- a/src/plugins/qnx/cascadesimport/cascadesimport.pri
+++ b/src/plugins/qnx/cascadesimport/cascadesimport.pri
@@ -1,6 +1,7 @@
SOURCES += \
$$PWD/cascadesimportwizard.cpp \
$$PWD/srcprojectwizardpage.cpp \
+ $$PWD/srcprojectpathchooser.cpp \
$$PWD/fileconverter.cpp \
$$PWD/bardescriptorconverter.cpp \
$$PWD/projectfileconverter.cpp \
@@ -10,6 +11,7 @@ SOURCES += \
HEADERS += \
$$PWD/cascadesimportwizard.h \
$$PWD/srcprojectwizardpage.h \
+ $$PWD/srcprojectpathchooser.h \
$$PWD/fileconverter.h \
$$PWD/bardescriptorconverter.h \
$$PWD/projectfileconverter.h \
diff --git a/src/plugins/qnx/cascadesimport/cascadesimportwizard.h b/src/plugins/qnx/cascadesimport/cascadesimportwizard.h
index e7dd5ba41e..8e0facc8e0 100644
--- a/src/plugins/qnx/cascadesimport/cascadesimportwizard.h
+++ b/src/plugins/qnx/cascadesimport/cascadesimportwizard.h
@@ -76,7 +76,7 @@ protected:
bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
private:
bool collectFiles(ConvertedProjectContext &projectContext, QString &errorMessage) const;
- void collectFiles_helper(QStringList &file_paths, ConvertedProjectContext &projectContext,
+ void collectFiles_helper(QStringList &filePaths, ConvertedProjectContext &projectContext,
const QString &rootPath, const QList< QRegExp > &blackList) const;
bool convertFile(Core::GeneratedFile &file, ConvertedProjectContext &projectContext,
QString &errorMessage) const;
diff --git a/src/plugins/qnx/cascadesimport/srcprojectpathchooser.cpp b/src/plugins/qnx/cascadesimport/srcprojectpathchooser.cpp
new file mode 100644
index 0000000000..ce7db49f69
--- /dev/null
+++ b/src/plugins/qnx/cascadesimport/srcprojectpathchooser.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
+**
+** Contact: BlackBerry (qt@blackberry.com)
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "srcprojectpathchooser.h"
+
+#include <QDirIterator>
+
+namespace Qnx {
+namespace Internal {
+
+SrcProjectPathChooser::SrcProjectPathChooser(QWidget *parent) :
+ Utils::PathChooser(parent)
+{
+ setPromptDialogTitle(tr("Choose imported Cascades project directory"));
+ setExpectedKind(Utils::PathChooser::ExistingDirectory);
+}
+
+SrcProjectPathChooser::~SrcProjectPathChooser()
+{
+}
+
+bool SrcProjectPathChooser::validatePath(const QString &path, QString *errorMessage)
+{
+ if (!Utils::PathChooser::validatePath(path, errorMessage))
+ return false;
+
+ bool proFound = false;
+ bool barDescriptorFound = false;
+ QDirIterator di(path);
+ while (di.hasNext()) {
+ di.next();
+ QFileInfo fi = di.fileInfo();
+ if (fi.isFile()) {
+ if (fi.fileName() == QLatin1String("bar-descriptor.xml"))
+ barDescriptorFound = true;
+ else if (fi.fileName().endsWith(QLatin1String(".pro")))
+ proFound = true;
+ }
+ if (barDescriptorFound && proFound)
+ break;
+ }
+ const bool ret = barDescriptorFound && proFound;
+ if (!ret && errorMessage)
+ *errorMessage = tr("Directory does not seem to be a valid Cascades project.");
+ return ret;
+}
+
+
+} // namespace Internal
+} // namespace Qnx
diff --git a/src/plugins/qnx/cascadesimport/srcprojectpathchooser.h b/src/plugins/qnx/cascadesimport/srcprojectpathchooser.h
new file mode 100644
index 0000000000..2b7fae720f
--- /dev/null
+++ b/src/plugins/qnx/cascadesimport/srcprojectpathchooser.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
+**
+** Contact: BlackBerry (qt@blackberry.com)
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef SRCPROJECTPATHCHOOSER_H
+#define SRCPROJECTPATHCHOOSER_H
+
+#include <utils/pathchooser.h>
+
+namespace Qnx {
+namespace Internal {
+
+class SrcProjectPathChooser : public Utils::PathChooser
+{
+ Q_OBJECT
+public:
+ explicit SrcProjectPathChooser(QWidget *parent = 0);
+ virtual ~SrcProjectPathChooser();
+
+ virtual bool validatePath(const QString &path, QString *errorMessage = 0);
+};
+
+} // namespace Internal
+} // namespace Qnx
+
+
+#endif // SRCPROJECTPATHCHOOSER_H
diff --git a/src/plugins/qnx/cascadesimport/srcprojectwizardpage.ui b/src/plugins/qnx/cascadesimport/srcprojectwizardpage.ui
index 9348909441..e29f3d6fae 100644
--- a/src/plugins/qnx/cascadesimport/srcprojectwizardpage.ui
+++ b/src/plugins/qnx/cascadesimport/srcprojectwizardpage.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>Qnx::Internal::SrcProjectWizardPage</class>
- <widget class="QWizardPage" name="Qnx::Internal::SrcProjectWizardPage">
+ <class>Qnx::Internal::SrcProjectWizardPage</class>
+ <widget class="QWizardPage" name="Qnx::Internal::SrcProjectWizardPage">
<property name="geometry">
<rect>
<x>0</x>
@@ -25,15 +25,15 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="Utils::PathChooser" name="pathChooser" native="true"/>
+ <widget class="Qnx::Internal::SrcProjectPathChooser" name="pathChooser" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
- <class>Utils::PathChooser</class>
+ <class>Qnx::Internal::SrcProjectPathChooser</class>
<extends>QWidget</extends>
- <header location="global">utils/pathchooser.h</header>
+ <header location="global">qnx/cascadesimport/srcprojectpathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
diff --git a/src/plugins/qnx/qnx.pro b/src/plugins/qnx/qnx.pro
index 2f0b403b76..25df0bf0fa 100644
--- a/src/plugins/qnx/qnx.pro
+++ b/src/plugins/qnx/qnx.pro
@@ -69,9 +69,9 @@ SOURCES += qnxplugin.cpp \
blackberrydebugtokenuploader.cpp \
blackberrydebugtokenreader.cpp \
blackberryndkprocess.cpp \
- blackberrycheckdevmodestepfactory.cpp \
- blackberrycheckdevmodestep.cpp \
- blackberrycheckdevmodestepconfigwidget.cpp \
+ blackberrycheckdebugtokenstep.cpp \
+ blackberrycheckdebugtokenstepconfigwidget.cpp \
+ blackberrycheckdebugtokenstepfactory.cpp \
blackberrydeviceconnection.cpp \
blackberrydeviceconnectionmanager.cpp \
blackberrydeviceinformation.cpp \
@@ -98,7 +98,8 @@ SOURCES += qnxplugin.cpp \
qnxdeviceprocesssignaloperation.cpp \
qnxdeviceprocesslist.cpp \
qnxtoolchain.cpp \
- slog2inforunner.cpp
+ slog2inforunner.cpp \
+ blackberryversionnumber.cpp
HEADERS += qnxplugin.h\
qnxconstants.h \
@@ -167,9 +168,9 @@ HEADERS += qnxplugin.h\
blackberrydebugtokenuploader.h \
blackberrydebugtokenreader.h \
blackberryndkprocess.h \
- blackberrycheckdevmodestepfactory.h \
- blackberrycheckdevmodestep.h \
- blackberrycheckdevmodestepconfigwidget.h \
+ blackberrycheckdebugtokenstep.h \
+ blackberrycheckdebugtokenstepconfigwidget.h \
+ blackberrycheckdebugtokenstepfactory.h \
blackberrydeviceconnection.h \
blackberrydeviceconnectionmanager.h \
blackberrydeviceinformation.h \
@@ -196,7 +197,8 @@ HEADERS += qnxplugin.h\
qnxdeviceprocesssignaloperation.h \
qnxdeviceprocesslist.h \
qnxtoolchain.h \
- slog2inforunner.h
+ slog2inforunner.h \
+ blackberryversionnumber.h
FORMS += \
diff --git a/src/plugins/qnx/qnx.qbs b/src/plugins/qnx/qnx.qbs
index da95f3c55e..5cf317bab4 100644
--- a/src/plugins/qnx/qnx.qbs
+++ b/src/plugins/qnx/qnx.qbs
@@ -59,12 +59,12 @@ QtcPlugin {
"blackberryabstractdeploystep.h",
"blackberryapplicationrunner.cpp",
"blackberryapplicationrunner.h",
- "blackberrycheckdevmodestep.cpp",
- "blackberrycheckdevmodestep.h",
- "blackberrycheckdevmodestepconfigwidget.cpp",
- "blackberrycheckdevmodestepconfigwidget.h",
- "blackberrycheckdevmodestepfactory.cpp",
- "blackberrycheckdevmodestepfactory.h",
+ "blackberrycheckdebugtokenstep.cpp",
+ "blackberrycheckdebugtokenstep.h",
+ "blackberrycheckdebugtokenstepconfigwidget.cpp",
+ "blackberrycheckdebugtokenstepconfigwidget.h",
+ "blackberrycheckdebugtokenstepfactory.cpp",
+ "blackberrycheckdebugtokenstepfactory.h",
"blackberryconfigurationmanager.cpp",
"blackberryconfigurationmanager.h",
"blackberrycreatepackagestep.cpp",
@@ -185,6 +185,8 @@ QtcPlugin {
"blackberrysetupwizardfinishpage.ui",
"blackberrysigningutils.cpp",
"blackberrysigningutils.h",
+ "blackberryversionnumber.cpp",
+ "blackberryversionnumber.h",
"pathchooserdelegate.cpp",
"pathchooserdelegate.h",
"qnxtoolchain.cpp",
@@ -254,6 +256,7 @@ QtcPlugin {
"cascadesimportwizard.cpp",
"srcprojectwizardpage.cpp",
+ "srcprojectpathchooser.cpp",
"fileconverter.cpp",
"bardescriptorconverter.cpp",
"projectfileconverter.cpp",
@@ -262,6 +265,7 @@ QtcPlugin {
"cascadesimportwizard.h",
"srcprojectwizardpage.h",
+ "srcprojectpathchooser.h",
"fileconverter.h",
"bardescriptorconverter.h",
"projectfileconverter.h",
diff --git a/src/plugins/qnx/qnxconstants.h b/src/plugins/qnx/qnxconstants.h
index 2c530d4610..62366b99ab 100644
--- a/src/plugins/qnx/qnxconstants.h
+++ b/src/plugins/qnx/qnxconstants.h
@@ -69,7 +69,7 @@ const char QNX_QNX_RUNCONFIGURATION_PREFIX[] = "Qt4ProjectManager.QNX.QNXRunConf
const char QNX_CREATE_PACKAGE_BS_ID[] = "Qt4ProjectManager.QnxCreatePackageBuildStep";
const char QNX_DEPLOY_PACKAGE_BS_ID[] = "Qt4ProjectManager.QnxDeployPackageBuildStep";
-const char QNX_CHECK_DEVELOPMENT_MODE_BS_ID[] = "Qt4ProjectManager.QnxCheckDevelopmentModeBuildStep";
+const char QNX_CHECK_DEBUG_TOKEN_BS_ID[] = "Qt4ProjectManager.QnxCheckDebugTokenBuildStep";
const char QNX_PROFILEPATH_KEY[] = "Qt4ProjectManager.QnxRunConfiguration.ProFilePath";
@@ -113,6 +113,8 @@ const char QNX_BLACKBERRY_DEPLOY_CMD[] = "blackberry-deploy";
const char QNX_BLACKBERRY_CASCADESIMPORTER_VERSION[] = "0.0.1";
+const char QNX_BLACKBERRY_CONFIGS_FILENAME[] = "bbndkconfigurations.xml";
+
} // namespace Constants
} // namespace Qnx
diff --git a/src/plugins/qnx/qnxplugin.cpp b/src/plugins/qnx/qnxplugin.cpp
index 7d22da8f62..8d0297d011 100644
--- a/src/plugins/qnx/qnxplugin.cpp
+++ b/src/plugins/qnx/qnxplugin.cpp
@@ -49,7 +49,7 @@
#include "bardescriptoreditorfactory.h"
#include "bardescriptormagicmatcher.h"
#include "blackberrykeyspage.h"
-#include "blackberrycheckdevmodestepfactory.h"
+#include "blackberrycheckdebugtokenstepfactory.h"
#include "blackberrydeviceconnectionmanager.h"
#include "blackberryconfigurationmanager.h"
#include "cascadesimport/cascadesimportwizard.h"
@@ -73,7 +73,6 @@ QNXPlugin::QNXPlugin()
QNXPlugin::~QNXPlugin()
{
delete BlackBerryDeviceConnectionManager::instance();
- delete &BlackBerryConfigurationManager::instance();
}
bool QNXPlugin::initialize(const QStringList &arguments, QString *errorString)
@@ -91,7 +90,7 @@ bool QNXPlugin::initialize(const QStringList &arguments, QString *errorString)
addAutoReleasedObject(new BlackBerryRunControlFactory);
addAutoReleasedObject(new BlackBerryNDKSettingsPage);
addAutoReleasedObject(new BlackBerryKeysPage);
- addAutoReleasedObject(new BlackBerryCheckDevModeStepFactory);
+ addAutoReleasedObject(new BlackBerryCheckDebugTokenStepFactory);
addAutoReleasedObject(new CascadesImportWizard);
BlackBerryDeviceConnectionManager::instance()->initialize();
diff --git a/src/plugins/qnx/qnxutils.cpp b/src/plugins/qnx/qnxutils.cpp
index e87dd8dd8a..a56f909669 100644
--- a/src/plugins/qnx/qnxutils.cpp
+++ b/src/plugins/qnx/qnxutils.cpp
@@ -182,7 +182,7 @@ Utils::FileName QnxUtils::executableWithExtension(const Utils::FileName &fileNam
{
Utils::FileName result = fileName;
if (Utils::HostOsInfo::isWindowsHost())
- result.append(QLatin1String(".exe"));
+ result.appendString(QLatin1String(".exe"));
return result;
}
@@ -258,6 +258,7 @@ QList<NdkInstallInformation> QnxUtils::installedNdks()
ndkInfo.host = childElt.firstChildElement(QLatin1String("host")).text();
ndkInfo.target = childElt.firstChildElement(QLatin1String("target")).text();
ndkInfo.version = childElt.firstChildElement(QLatin1String("version")).text();
+ ndkInfo.installationXmlFilePath = ndkFile.absoluteFilePath();
ndkList.append(ndkInfo);
}
diff --git a/src/plugins/qnx/qnxutils.h b/src/plugins/qnx/qnxutils.h
index c57e0afb0d..9edae410a0 100644
--- a/src/plugins/qnx/qnxutils.h
+++ b/src/plugins/qnx/qnxutils.h
@@ -54,6 +54,10 @@ public:
QString host;
QString target;
QString version;
+ QString installationXmlFilePath;
+
+ bool isValid() { return !path.isEmpty() && !name.isEmpty() && !host.isEmpty()
+ && !target.isEmpty() && !version.isEmpty() && !installationXmlFilePath.isEmpty(); }
};
class QnxUtils
diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp
index 8289af639f..78d58d614b 100644
--- a/src/plugins/qtsupport/baseqtversion.cpp
+++ b/src/plugins/qtsupport/baseqtversion.cpp
@@ -41,7 +41,6 @@
#include <projectexplorer/toolchain.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/headerpath.h>
-#include <qtsupport/debugginghelper.h>
#include <qtsupport/debugginghelperbuildtask.h>
#include <qtsupport/qtsupportconstants.h>
@@ -137,7 +136,6 @@ int BaseQtVersion::getUniqueId()
BaseQtVersion::BaseQtVersion(const FileName &qmakeCommand, bool isAutodetected, const QString &autodetectionSource)
: m_id(getUniqueId()),
m_isAutodetected(isAutodetected),
- m_hasDebuggingHelper(false),
m_hasQmlDump(false),
m_mkspecUpToDate(false),
m_mkspecReadUpToDate(false),
@@ -158,7 +156,6 @@ BaseQtVersion::BaseQtVersion(const FileName &qmakeCommand, bool isAutodetected,
BaseQtVersion::BaseQtVersion()
: m_id(-1), m_isAutodetected(false),
- m_hasDebuggingHelper(false),
m_hasQmlDump(false),
m_mkspecUpToDate(false),
m_mkspecReadUpToDate(false),
@@ -911,7 +908,6 @@ void BaseQtVersion::updateVersionInfo() const
m_installed = true;
m_hasExamples = false;
m_hasDocumentation = false;
- m_hasDebuggingHelper = false;
m_hasQmlDump = false;
if (!queryQMakeVariables(qmakeCommand(), qmakeRunEnvironment(), &m_versionInfo)) {
@@ -927,7 +923,6 @@ void BaseQtVersion::updateVersionInfo() const
const QString qtHeaderData = qmakeProperty(m_versionInfo, "QT_INSTALL_HEADERS");
if (!qtInstallData.isNull()) {
if (!qtInstallData.isEmpty()) {
- m_hasDebuggingHelper = !DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData).isEmpty();
m_hasQmlDump
= !QmlDumpTool::toolForQtPaths(qtInstallData, qtInstallBins, qtHeaderData, false).isEmpty()
|| !QmlDumpTool::toolForQtPaths(qtInstallData, qtInstallBins, qtHeaderData, true).isEmpty();
@@ -1072,13 +1067,6 @@ Environment BaseQtVersion::qmakeRunEnvironment() const
return Environment::systemEnvironment();
}
-bool BaseQtVersion::hasGdbDebuggingHelper() const
-{
- updateVersionInfo();
- return m_hasDebuggingHelper;
-}
-
-
bool BaseQtVersion::hasQmlDump() const
{
updateVersionInfo();
@@ -1114,14 +1102,6 @@ Environment BaseQtVersion::qmlToolsEnvironment() const
return environment;
}
-QString BaseQtVersion::gdbDebuggingHelperLibrary() const
-{
- QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
- if (qtInstallData.isEmpty())
- return QString();
- return DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData);
-}
-
QString BaseQtVersion::qmlDumpTool(bool debugVersion) const
{
const QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
@@ -1132,21 +1112,6 @@ QString BaseQtVersion::qmlDumpTool(bool debugVersion) const
return QmlDumpTool::toolForQtPaths(qtInstallData, qtInstallBins, qtHeaderData, debugVersion);
}
-QStringList BaseQtVersion::debuggingHelperLibraryLocations() const
-{
- QString qtInstallData = qmakeProperty("QT_INSTALL_DATA");
- if (qtInstallData.isEmpty())
- return QStringList();
- return DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData);
-}
-
-bool BaseQtVersion::supportsBinaryDebuggingHelper() const
-{
- if (!isValid())
- return false;
- return true;
-}
-
void BaseQtVersion::recheckDumper()
{
m_versionInfoUpToDate = false;
diff --git a/src/plugins/qtsupport/baseqtversion.h b/src/plugins/qtsupport/baseqtversion.h
index 004d53068f..431ccef273 100644
--- a/src/plugins/qtsupport/baseqtversion.h
+++ b/src/plugins/qtsupport/baseqtversion.h
@@ -191,12 +191,8 @@ public:
static void buildDebuggingHelper(ProjectExplorer::Kit *k, int tools);
void buildDebuggingHelper(ProjectExplorer::ToolChain *tc, int tools);
- virtual bool supportsBinaryDebuggingHelper() const;
- virtual QString gdbDebuggingHelperLibrary() const;
virtual QString qmlDumpTool(bool debugVersion) const;
- virtual QStringList debuggingHelperLibraryLocations() const;
- virtual bool hasGdbDebuggingHelper() const;
virtual bool hasQmlDump() const;
virtual bool hasQmlDumpWithRelocatableFlag() const;
virtual bool needsQmlDump() const;
@@ -263,7 +259,6 @@ private:
int m_id;
bool m_isAutodetected;
- mutable bool m_hasDebuggingHelper; // controlled by m_versionInfoUpToDate
mutable bool m_hasQmlDump; // controlled by m_versionInfoUpToDate
mutable bool m_mkspecUpToDate;
mutable bool m_mkspecReadUpToDate;
diff --git a/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp b/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp
index 9efa791ce7..6437902e5f 100644
--- a/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp
+++ b/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp
@@ -55,6 +55,7 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
layout->setMargin(0);
m_executableChooser = new Utils::PathChooser(this);
+ m_executableChooser->setHistoryCompleter(QLatin1String("Qt.CustomExecutable.History"));
m_executableChooser->setExpectedKind(Utils::PathChooser::Command);
layout->addRow(tr("Executable:"), m_executableChooser);
@@ -63,6 +64,7 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
layout->addRow(tr("Arguments:"), m_commandLineArgumentsLineEdit);
m_workingDirectory = new Utils::PathChooser(this);
+ m_workingDirectory->setHistoryCompleter(QLatin1String("WorkingDir.History"));
m_workingDirectory->setExpectedKind(Utils::PathChooser::Directory);
m_workingDirectory->setBaseDirectory(rc->target()->project()->projectDirectory());
diff --git a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp
index f35a4dafdb..77d91c96c1 100644
--- a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp
+++ b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp
@@ -300,16 +300,6 @@ QWidget *CustomExecutableRunConfiguration::createConfigurationWidget()
return new CustomExecutableConfigurationWidget(this);
}
-QString CustomExecutableRunConfiguration::dumperLibrary() const
-{
- return QtKitInformation::dumperLibrary(target()->kit());
-}
-
-QStringList CustomExecutableRunConfiguration::dumperLibraryLocations() const
-{
- return QtKitInformation::dumperLibraryLocations(target()->kit());
-}
-
ProjectExplorer::Abi CustomExecutableRunConfiguration::abi() const
{
return ProjectExplorer::Abi(); // return an invalid ABI: We do not know what we will end up running!
diff --git a/src/plugins/qtsupport/customexecutablerunconfiguration.h b/src/plugins/qtsupport/customexecutablerunconfiguration.h
index 3d3883905a..631c35029f 100644
--- a/src/plugins/qtsupport/customexecutablerunconfiguration.h
+++ b/src/plugins/qtsupport/customexecutablerunconfiguration.h
@@ -69,8 +69,6 @@ public:
QString commandLineArguments() const;
QWidget *createConfigurationWidget();
- QString dumperLibrary() const;
- QStringList dumperLibraryLocations() const;
ProjectExplorer::Abi abi() const;
diff --git a/src/plugins/qtsupport/debugginghelper.cpp b/src/plugins/qtsupport/debugginghelper.cpp
deleted file mode 100644
index 34a3211c6e..0000000000
--- a/src/plugins/qtsupport/debugginghelper.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
-
-#include "debugginghelper.h"
-
-#include <coreplugin/icore.h>
-
-#include <QCoreApplication>
-#include <QDir>
-#include <QStringList>
-
-#include <QDesktopServices>
-
-using namespace QtSupport;
-
-static inline QStringList validBinaryFilenames()
-{
- return QStringList()
- << QLatin1String("debug/dumper.dll")
- << QLatin1String("libdumper.dylib")
- << QLatin1String("libdumper.so");
-}
-
-QStringList DebuggingHelperLibrary::debuggingHelperLibraryDirectories(const QString &qtInstallData)
-{
- const QChar slash = QLatin1Char('/');
- const uint hash = qHash(qtInstallData);
- QStringList directories;
- directories
- << (qtInstallData + QLatin1String("/qtc-debugging-helper/"))
- << QDir::cleanPath((QCoreApplication::applicationDirPath() + QLatin1String("/../qtc-debugging-helper/") + QString::number(hash))) + slash
- << (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/qtc-debugging-helper/") + QString::number(hash)) + slash;
- return directories;
-}
-
-static QString sourcePath()
-{
- return Core::ICore::resourcePath() + QLatin1String("/debugger/");
-}
-
-static QStringList sourceFileNames()
-{
- return QStringList()
- << QLatin1String("dumper.cpp") << QLatin1String("dumper_p.h")
- << QLatin1String("dumper.h") << QLatin1String("dumper.pro")
- << QLatin1String("LICENSE.LGPL") << QLatin1String("LGPL_EXCEPTION.TXT");
-}
-
-QString DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(const QString &qtInstallData)
-{
- if (!Core::ICore::instance())
- return QString();
-
- const QStringList directories = DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData);
- const QStringList binFilenames = validBinaryFilenames();
-
- return byInstallDataHelper(sourcePath(), sourceFileNames(), directories, binFilenames, false);
-}
-
-QString DebuggingHelperLibrary::copy(const QString &qtInstallData,
- QString *errorMessage)
-{
- // Locations to try:
- // $QTDIR/qtc-debugging-helper
- // $APPLICATION-DIR/qtc-debugging-helper/$hash
- // $USERDIR/qtc-debugging-helper/$hash
- const QStringList directories = DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData);
-
- // Try to find a writeable directory.
- foreach (const QString &directory, directories)
- if (copyFiles(sourcePath(), sourceFileNames(), directory, errorMessage)) {
- errorMessage->clear();
- return directory;
- }
- *errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
- "The debugger helpers could not be built in any of the directories:\n- %1\n\nReason: %2")
- .arg(directories.join(QLatin1String("\n- ")), *errorMessage);
- return QString();
-}
-
-bool DebuggingHelperLibrary::build(BuildHelperArguments arguments, QString *log, QString *errorMessage)
-{
- arguments.proFilename = QLatin1String("dumper.pro");
- arguments.helperName = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
- "GDB helper");
- return buildHelper(arguments, log, errorMessage);
-}
diff --git a/src/plugins/qtsupport/debugginghelper.ui b/src/plugins/qtsupport/debugginghelper.ui
index cd7dba4e4b..87f7a168c1 100644
--- a/src/plugins/qtsupport/debugginghelper.ui
+++ b/src/plugins/qtsupport/debugginghelper.ui
@@ -42,13 +42,6 @@
</property>
</widget>
</item>
- <item row="2" column="2">
- <widget class="QPushButton" name="gdbHelperBuildButton">
- <property name="text">
- <string>Build</string>
- </property>
- </widget>
- </item>
<item row="1" column="1">
<widget class="QLabel" name="qmlDumpStatus">
<property name="sizePolicy">
@@ -62,29 +55,6 @@
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="gdbHelperLabel">
- <property name="toolTip">
- <string>Helps showing content of Qt types. Only used in older versions of GDB.</string>
- </property>
- <property name="text">
- <string>GDB Helper:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="gdbHelperStatus">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>2</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string notr="true">TextLabel</string>
- </property>
- </widget>
- </item>
</layout>
</item>
<item>
diff --git a/src/plugins/qtsupport/debugginghelperbuildtask.cpp b/src/plugins/qtsupport/debugginghelperbuildtask.cpp
index 1f08154c7a..b5e95bfd21 100644
--- a/src/plugins/qtsupport/debugginghelperbuildtask.cpp
+++ b/src/plugins/qtsupport/debugginghelperbuildtask.cpp
@@ -28,7 +28,6 @@
****************************************************************************/
#include "debugginghelperbuildtask.h"
-#include "debugginghelper.h"
#include "qmldumptool.h"
#include "baseqtversion.h"
#include "qtversionmanager.h"
@@ -117,13 +116,6 @@ DebuggingHelperBuildTask::Tools DebuggingHelperBuildTask::availableTools(const B
QTC_ASSERT(version, return 0);
// Check the build requirements of the tools
DebuggingHelperBuildTask::Tools tools = 0;
- // Gdb helpers are needed on Mac/gdb only.
- foreach (const Abi &abi, version->qtAbis()) {
- if (abi.os() == Abi::MacOS) {
- tools |= DebuggingHelperBuildTask::GdbDebugging;
- break;
- }
- }
if (QmlDumpTool::canBuild(version))
tools |= QmlDump;
return tools;
@@ -169,18 +161,6 @@ bool DebuggingHelperBuildTask::buildDebuggingHelper(QFutureInterface<void> &futu
arguments.mkspec = m_mkspec;
arguments.environment = m_environment;
- if (m_tools & GdbDebugging) {
- QString output, error;
- bool success = true;
-
- arguments.directory = DebuggingHelperLibrary::copy(m_qtInstallData, &error);
- if (arguments.directory.isEmpty()
- || !DebuggingHelperLibrary::build(arguments, &output, &error))
- success = false;
- log(output, error);
- if (!success)
- return false;
- }
future.setProgressValue(2);
if (m_tools & QmlDump) {
diff --git a/src/plugins/qtsupport/debugginghelperbuildtask.h b/src/plugins/qtsupport/debugginghelperbuildtask.h
index f1c25ef531..a01553aea1 100644
--- a/src/plugins/qtsupport/debugginghelperbuildtask.h
+++ b/src/plugins/qtsupport/debugginghelperbuildtask.h
@@ -50,9 +50,8 @@ class QTSUPPORT_EXPORT DebuggingHelperBuildTask : public QObject
public:
enum DebuggingHelper {
- GdbDebugging = 0x01,
QmlDump = 0x02,
- AllTools = GdbDebugging | QmlDump
+ AllTools = QmlDump
};
Q_DECLARE_FLAGS(Tools, DebuggingHelper)
diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp
index c610935c00..bd8f045762 100644
--- a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp
+++ b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp
@@ -181,16 +181,19 @@ public:
// gets called by declarative in separate thread
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
- Q_UNUSED(size)
QMutexLocker lock(&m_mutex);
QUrl url = QUrl::fromEncoded(id.toLatin1());
- if (!m_fetcher.asynchronousFetchData(url))
- return QImage();
- if (m_fetcher.data().isEmpty())
+ if (!m_fetcher.asynchronousFetchData(url) || m_fetcher.data().isEmpty()) {
+ if (size) {
+ size->setWidth(0);
+ size->setHeight(0);
+ }
return QImage();
+ }
+
QByteArray data = m_fetcher.data();
QBuffer imgBuffer(&data);
imgBuffer.open(QIODevice::ReadOnly);
@@ -198,7 +201,11 @@ public:
QImage img = reader.read();
m_fetcher.clearData();
- return ScreenshotCropper::croppedImage(img, id, requestedSize);
+ img = ScreenshotCropper::croppedImage(img, id, requestedSize);
+ if (size)
+ *size = img.size();
+ return img;
+
}
private:
Fetcher m_fetcher;
@@ -321,6 +328,7 @@ QString ExamplesWelcomePage::copyToAlternativeLocation(const QFileInfo& proFileI
PathChooser *chooser = new PathChooser;
txt->setBuddy(chooser);
chooser->setExpectedKind(PathChooser::ExistingDirectory);
+ chooser->setHistoryCompleter(QLatin1String("Qt.WritableExamplesDir.History"));
QSettings *settings = Core::ICore::settings();
chooser->setPath(settings->value(QString::fromLatin1(C_FALLBACK_ROOT),
Core::DocumentManager::projectsDirectory()).toString());
diff --git a/src/plugins/qtsupport/qtkitinformation.cpp b/src/plugins/qtsupport/qtkitinformation.cpp
index 8b7000cf04..07f28a8971 100644
--- a/src/plugins/qtsupport/qtkitinformation.cpp
+++ b/src/plugins/qtsupport/qtkitinformation.cpp
@@ -172,22 +172,6 @@ void QtKitInformation::setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion
setQtVersionId(k, v->uniqueId());
}
-QString QtKitInformation::dumperLibrary(const ProjectExplorer::Kit *k)
-{
- BaseQtVersion *version = QtKitInformation::qtVersion(k);
- if (version)
- return version->gdbDebuggingHelperLibrary();
- return QString();
-}
-
-QStringList QtKitInformation::dumperLibraryLocations(const ProjectExplorer::Kit *k)
-{
- BaseQtVersion *version = QtKitInformation::qtVersion(k);
- if (version)
- return version->debuggingHelperLibraryLocations();
- return QStringList();
-}
-
void QtKitInformation::qtVersionsChanged(const QList<int> &addedIds,
const QList<int> &removedIds,
const QList<int> &changedIds)
diff --git a/src/plugins/qtsupport/qtkitinformation.h b/src/plugins/qtsupport/qtkitinformation.h
index e5dbcc15ed..ebd5700246 100644
--- a/src/plugins/qtsupport/qtkitinformation.h
+++ b/src/plugins/qtsupport/qtkitinformation.h
@@ -66,11 +66,6 @@ public:
static BaseQtVersion *qtVersion(const ProjectExplorer::Kit *k);
static void setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion *v);
- // Information derived from the Qt version:
- // FIXME: This should be part of an RunConfigurationAspect...
- static QString dumperLibrary(const ProjectExplorer::Kit *k);
- static QStringList dumperLibraryLocations(const ProjectExplorer::Kit *k);
-
private slots:
void qtVersionsChanged(const QList<int> &addedIds,
const QList<int> &removedIds,
diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp
index 6ab49361b4..6518442a26 100644
--- a/src/plugins/qtsupport/qtoptionspage.cpp
+++ b/src/plugins/qtsupport/qtoptionspage.cpp
@@ -75,11 +75,10 @@ QtOptionsPage::QtOptionsPage()
setCategoryIcon(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON));
}
-QWidget *QtOptionsPage::createPage(QWidget *parent)
+QWidget *QtOptionsPage::widget()
{
- m_widget = new QtOptionsPageWidget(parent);
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget)
+ m_widget = new QtOptionsPageWidget;
return m_widget;
}
@@ -92,9 +91,9 @@ void QtOptionsPage::apply()
m_widget->apply();
}
-bool QtOptionsPage::matches(const QString &s) const
+void QtOptionsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
//-----------------------------------------------------
@@ -173,8 +172,6 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent)
connect(m_debuggingHelperUi->rebuildButton, SIGNAL(clicked()),
this, SLOT(buildDebuggingHelper()));
- connect(m_debuggingHelperUi->gdbHelperBuildButton, SIGNAL(clicked()),
- this, SLOT(buildGdbHelper()));
connect(m_debuggingHelperUi->qmlDumpBuildButton, SIGNAL(clicked()),
this, SLOT(buildQmlDump()));
@@ -240,8 +237,6 @@ void QtOptionsPageWidget::debuggingHelperBuildFinished(int qtVersionId, const QS
item->setData(0, BuildLogRole, output);
bool success = true;
- if (tools & DebuggingHelperBuildTask::GdbDebugging)
- success &= version->hasGdbDebuggingHelper();
if (tools & DebuggingHelperBuildTask::QmlDump)
success &= version->hasQmlDump();
@@ -450,10 +445,6 @@ void QtOptionsPageWidget::buildDebuggingHelper(DebuggingHelperBuildTask::Tools t
Core::ProgressManager::addTask(task, taskName, "QmakeProjectManager::BuildHelpers");
}
-void QtOptionsPageWidget::buildGdbHelper()
-{
- buildDebuggingHelper(DebuggingHelperBuildTask::GdbDebugging);
-}
void QtOptionsPageWidget::buildQmlDump()
{
@@ -716,28 +707,22 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
m_ui->debuggingHelperWidget->setVisible(false);
} else {
const DebuggingHelperBuildTask::Tools availableTools = DebuggingHelperBuildTask::availableTools(version);
- const bool canBuildGdbHelper = availableTools & DebuggingHelperBuildTask::GdbDebugging;
const bool canBuildQmlDumper = availableTools & DebuggingHelperBuildTask::QmlDump;
- const bool hasGdbHelper = !version->gdbDebuggingHelperLibrary().isEmpty();
const bool hasQmlDumper = version->hasQmlDump();
const bool needsQmlDumper = version->needsQmlDump();
- bool isBuildingGdbHelper = false;
bool isBuildingQmlDumper = false;
if (currentItem) {
DebuggingHelperBuildTask::Tools buildingTools
= currentItem->data(0, BuildRunningRole).value<DebuggingHelperBuildTask::Tools>();
- isBuildingGdbHelper = buildingTools & DebuggingHelperBuildTask::GdbDebugging;
isBuildingQmlDumper = buildingTools & DebuggingHelperBuildTask::QmlDump;
}
// get names of tools from labels
QStringList helperNames;
const QChar colon = QLatin1Char(':');
- if (hasGdbHelper)
- helperNames << m_debuggingHelperUi->gdbHelperLabel->text().remove(colon);
if (hasQmlDumper)
helperNames << m_debuggingHelperUi->qmlDumpLabel->text().remove(colon);
@@ -751,21 +736,6 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
m_ui->debuggingHelperWidget->setSummaryText(status);
- QString gdbHelperText;
- Qt::TextInteractionFlags gdbHelperTextFlags = Qt::NoTextInteraction;
- if (hasGdbHelper) {
- gdbHelperText = QDir::toNativeSeparators(version->gdbDebuggingHelperLibrary());
- gdbHelperTextFlags = Qt::TextSelectableByMouse;
- } else {
- if (canBuildGdbHelper)
- gdbHelperText = tr("<i>Not yet built.</i>");
- else
- gdbHelperText = tr("<i>Not needed.</i>");
- }
- m_debuggingHelperUi->gdbHelperStatus->setText(gdbHelperText);
- m_debuggingHelperUi->gdbHelperStatus->setTextInteractionFlags(gdbHelperTextFlags);
- m_debuggingHelperUi->gdbHelperBuildButton->setEnabled(canBuildGdbHelper && !isBuildingGdbHelper);
-
QString qmlDumpStatusText, qmlDumpStatusToolTip;
Qt::TextInteractionFlags qmlDumpStatusTextFlags = Qt::NoTextInteraction;
if (hasQmlDumper) {
@@ -810,10 +780,8 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
const bool hasLog = currentItem && !currentItem->data(0, BuildLogRole).toString().isEmpty();
m_debuggingHelperUi->showLogButton->setEnabled(hasLog);
- const bool canBuild = canBuildGdbHelper
- || canBuildQmlDumper;
- const bool isBuilding = isBuildingGdbHelper
- || isBuildingQmlDumper;
+ const bool canBuild = canBuildQmlDumper;
+ const bool isBuilding = isBuildingQmlDumper;
m_debuggingHelperUi->rebuildButton->setEnabled(canBuild && !isBuilding);
m_debuggingHelperUi->toolChainComboBox->setEnabled(canBuild && !isBuilding);
@@ -1010,19 +978,5 @@ QList<BaseQtVersion *> QtOptionsPageWidget::versions() const
return result;
}
-QString QtOptionsPageWidget::searchKeywords() const
-{
- QString rc;
- QLatin1Char sep(' ');
- QTextStream ts(&rc);
- ts << sep << m_versionUi->versionNameLabel->text()
- << sep << m_versionUi->pathLabel->text()
- << sep << m_debuggingHelperUi->gdbHelperLabel->text()
- << sep << m_debuggingHelperUi->qmlDumpLabel->text();
-
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
} // namespace Internal
} // namespace QtSupport
diff --git a/src/plugins/qtsupport/qtoptionspage.h b/src/plugins/qtsupport/qtoptionspage.h
index 703c0747e8..9fc0454d61 100644
--- a/src/plugins/qtsupport/qtoptionspage.h
+++ b/src/plugins/qtsupport/qtoptionspage.h
@@ -33,8 +33,9 @@
#include "debugginghelperbuildtask.h"
#include <coreplugin/dialogs/ioptionspage.h>
-#include <QWidget>
#include <QIcon>
+#include <QPointer>
+#include <QWidget>
QT_BEGIN_NAMESPACE
class QTreeWidgetItem;
@@ -63,12 +64,11 @@ class QtOptionsPageWidget : public QWidget
Q_OBJECT
public:
- QtOptionsPageWidget(QWidget *parent);
+ QtOptionsPageWidget(QWidget *parent = 0);
~QtOptionsPageWidget();
QList<BaseQtVersion *> versions() const;
void finish();
void apply();
- QString searchKeywords() const;
private:
void updateDescriptionLabel();
@@ -106,7 +106,6 @@ private slots:
void updateCurrentQtName();
void buildDebuggingHelper(DebuggingHelperBuildTask::Tools tools
= DebuggingHelperBuildTask::AllTools);
- void buildGdbHelper();
void buildQmlDump();
void slotShowDebuggingBuildLog();
void debuggingHelperBuildFinished(int qtVersionId, const QString &output,
@@ -141,14 +140,12 @@ class QtOptionsPage : public Core::IOptionsPage
public:
QtOptionsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() {}
- bool matches(const QString &) const;
+ void finish();
private:
- QtOptionsPageWidget *m_widget;
- QString m_searchKeywords;
+ QPointer<QtOptionsPageWidget> m_widget;
};
} //namespace Internal
diff --git a/src/plugins/qtsupport/qtparser.cpp b/src/plugins/qtsupport/qtparser.cpp
index 131c978729..89a237b2a1 100644
--- a/src/plugins/qtsupport/qtparser.cpp
+++ b/src/plugins/qtsupport/qtparser.cpp
@@ -39,10 +39,12 @@ using ProjectExplorer::Task;
#define FILE_PATTERN "^(([A-Za-z]:)?[^:]+\\.[^:]+)"
QtParser::QtParser() :
- m_mocRegExp(QLatin1String(FILE_PATTERN"[:\\(](\\d+)\\)?:\\s([Ww]arning|[Ee]rror):\\s(.+)$"))
+ m_mocRegExp(QLatin1String(FILE_PATTERN"[:\\(](\\d+)\\)?:\\s([Ww]arning|[Ee]rror):\\s(.+)$")),
+ m_translationRegExp(QLatin1String("^([Ww]arning|[Ee]rror):\\s+(.*) in '(.*)'$"))
{
setObjectName(QLatin1String("QtParser"));
m_mocRegExp.setMinimal(true);
+ m_translationRegExp.setMinimal(true);
}
void QtParser::stdError(const QString &line)
@@ -53,13 +55,24 @@ void QtParser::stdError(const QString &line)
int lineno = m_mocRegExp.cap(3).toInt(&ok);
if (!ok)
lineno = -1;
- Task task(Task::Error,
- m_mocRegExp.cap(5).trimmed(),
+ Task::TaskType type = Task::Error;
+ if (m_mocRegExp.cap(4).compare(QLatin1String("Warning"), Qt::CaseInsensitive) == 0)
+ type = Task::Warning;
+ Task task(type, m_mocRegExp.cap(5).trimmed() /* description */,
Utils::FileName::fromUserInput(m_mocRegExp.cap(1)) /* filename */,
lineno,
ProjectExplorer::Constants::TASK_CATEGORY_COMPILE);
- if (m_mocRegExp.cap(4).compare(QLatin1String("Warning"), Qt::CaseInsensitive) == 0)
- task.type = Task::Warning;
+ emit addTask(task);
+ return;
+ }
+ if (m_translationRegExp.indexIn(lne) > -1) {
+ Task::TaskType type = Task::Warning;
+ if (m_translationRegExp.cap(1) == QLatin1String("Error"))
+ type = Task::Error;
+ Task task(type, m_translationRegExp.cap(2),
+ Utils::FileName::fromUserInput(m_translationRegExp.cap(3)) /* filename */,
+ -1,
+ ProjectExplorer::Constants::TASK_CATEGORY_COMPILE);
emit addTask(task);
return;
}
@@ -150,6 +163,15 @@ void QtSupportPlugin::testQtOutputParser_data()
Utils::FileName::fromUserInput(QLatin1String("E:/sandbox/creator/loaden/src/libs/utils/iwelcomepage.h")), 54,
ProjectExplorer::Constants::TASK_CATEGORY_COMPILE))
<< QString();
+ QTest::newRow("translation")
+ << QString::fromLatin1("Warning: dropping duplicate messages in '/some/place/qtcreator_fr.qm'")
+ << OutputParserTester::STDERR
+ << QString() << QString()
+ << (QList<ProjectExplorer::Task>() << Task(Task::Warning,
+ QLatin1String("dropping duplicate messages"),
+ Utils::FileName::fromUserInput(QLatin1String("/some/place/qtcreator_fr.qm")), -1,
+ ProjectExplorer::Constants::TASK_CATEGORY_COMPILE))
+ << QString();
}
void QtSupportPlugin::testQtOutputParser()
diff --git a/src/plugins/qtsupport/qtparser.h b/src/plugins/qtsupport/qtparser.h
index c58148265d..df1d121f3f 100644
--- a/src/plugins/qtsupport/qtparser.h
+++ b/src/plugins/qtsupport/qtparser.h
@@ -47,6 +47,7 @@ public:
private:
QRegExp m_mocRegExp;
+ QRegExp m_translationRegExp;
};
} // namespace ProjectExplorer
diff --git a/src/plugins/qtsupport/qtsupport.pro b/src/plugins/qtsupport/qtsupport.pro
index df7fe51a81..dcea5b3330 100644
--- a/src/plugins/qtsupport/qtsupport.pro
+++ b/src/plugins/qtsupport/qtsupport.pro
@@ -20,7 +20,6 @@ HEADERS += \
qtoptionspage.h \
customexecutablerunconfiguration.h \
customexecutableconfigurationwidget.h \
- debugginghelper.h \
debugginghelperbuildtask.h \
qtsupportconstants.h \
profilereader.h \
@@ -49,7 +48,6 @@ SOURCES += \
qtoptionspage.cpp \
customexecutablerunconfiguration.cpp \
customexecutableconfigurationwidget.cpp \
- debugginghelper.cpp \
debugginghelperbuildtask.cpp \
profilereader.cpp \
qtparser.cpp \
diff --git a/src/plugins/qtsupport/qtsupport.qbs b/src/plugins/qtsupport/qtsupport.qbs
index 72f0597a6a..dc9060481a 100644
--- a/src/plugins/qtsupport/qtsupport.qbs
+++ b/src/plugins/qtsupport/qtsupport.qbs
@@ -65,8 +65,6 @@ QtcPlugin {
"customexecutableconfigurationwidget.h",
"customexecutablerunconfiguration.cpp",
"customexecutablerunconfiguration.h",
- "debugginghelper.cpp",
- "debugginghelper.h",
"debugginghelper.ui",
"debugginghelperbuildtask.cpp",
"debugginghelperbuildtask.h",
diff --git a/src/plugins/qtsupport/qtversionmanager.cpp b/src/plugins/qtsupport/qtversionmanager.cpp
index 5966416121..dce5c211c9 100644
--- a/src/plugins/qtsupport/qtversionmanager.cpp
+++ b/src/plugins/qtsupport/qtversionmanager.cpp
@@ -35,13 +35,12 @@
#include "qtfeatureprovider.h"
#include "qtsupportconstants.h"
-#include <qtsupport/debugginghelper.h>
-
#include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <extensionsystem/pluginmanager.h>
+#include <utils/buildablehelperlibrary.h>
#include <utils/filesystemwatcher.h>
#include <utils/hostosinfo.h>
#include <utils/persistentsettings.h>
@@ -386,7 +385,7 @@ void QtVersionManager::saveQtVersions()
void QtVersionManager::findSystemQt()
{
- FileName systemQMakePath = QtSupport::DebuggingHelperLibrary::findSystemQt(Environment::systemEnvironment());
+ FileName systemQMakePath = BuildableHelperLibrary::findSystemQt(Environment::systemEnvironment());
if (systemQMakePath.isNull())
return;
diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp
index 91fddca290..29d68463fc 100644
--- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp
+++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp
@@ -183,6 +183,7 @@ void GenericLinuxDeviceConfigurationWidget::initGui()
m_ui->portsWarningLabel->setToolTip(QLatin1String("<font color=\"red\">")
+ tr("You will need at least one port.") + QLatin1String("</font>"));
m_ui->keyFileLineEdit->setExpectedKind(PathChooser::File);
+ m_ui->keyFileLineEdit->setHistoryCompleter(QLatin1String("Ssh.KeyFile.History"));
m_ui->keyFileLineEdit->lineEdit()->setMinimumWidth(0);
QRegExpValidator * const portsValidator
= new QRegExpValidator(QRegExp(PortList::regularExpression()), this);
diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp
index 5ef777d5ff..fa6144b593 100644
--- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp
+++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.cpp
@@ -59,6 +59,7 @@ GenericLinuxDeviceConfigurationWizardSetupPage::GenericLinuxDeviceConfigurationW
setTitle(tr("Connection"));
setSubTitle(QLatin1String(" ")); // For Qt bug (background color)
d->ui.privateKeyPathChooser->setExpectedKind(PathChooser::File);
+ d->ui.privateKeyPathChooser->setHistoryCompleter(QLatin1String("Ssh.KeyFile.History"));
d->ui.privateKeyPathChooser->setPromptDialogTitle(tr("Choose a Private Key File"));
connect(d->ui.nameLineEdit, SIGNAL(textChanged(QString)), SIGNAL(completeChanged()));
connect(d->ui.hostNameLineEdit, SIGNAL(textChanged(QString)), SIGNAL(completeChanged()));
diff --git a/src/plugins/resourceeditor/resourceeditor.qbs b/src/plugins/resourceeditor/resourceeditor.qbs
index bac0883400..193c9b7513 100644
--- a/src/plugins/resourceeditor/resourceeditor.qbs
+++ b/src/plugins/resourceeditor/resourceeditor.qbs
@@ -6,7 +6,6 @@ QtcPlugin {
name: "ResourceEditor"
Depends { name: "Core" }
- Depends { name: "Find" }
Depends { name: "Qt"; submodules: ["widgets", "xml"] }
Group {
diff --git a/src/plugins/resourceeditor/resourceeditor_dependencies.pri b/src/plugins/resourceeditor/resourceeditor_dependencies.pri
index 753971d6db..8a82e801cf 100644
--- a/src/plugins/resourceeditor/resourceeditor_dependencies.pri
+++ b/src/plugins/resourceeditor/resourceeditor_dependencies.pri
@@ -3,4 +3,3 @@ QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
coreplugin \
- find
diff --git a/src/plugins/resourceeditor/resourceeditorfactory.cpp b/src/plugins/resourceeditor/resourceeditorfactory.cpp
index 6999022d4f..824aed6c20 100644
--- a/src/plugins/resourceeditor/resourceeditorfactory.cpp
+++ b/src/plugins/resourceeditor/resourceeditorfactory.cpp
@@ -53,8 +53,8 @@ ResourceEditorFactory::ResourceEditorFactory(ResourceEditorPlugin *plugin) :
Core::FileIconProvider::registerIconOverlayForSuffix(":/resourceeditor/images/qt_qrc.png", "qrc");
}
-Core::IEditor *ResourceEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *ResourceEditorFactory::createEditor()
{
Core::Context context(ResourceEditor::Constants::C_RESOURCEEDITOR);
- return new ResourceEditorW(context, m_plugin, parent);
+ return new ResourceEditorW(context, m_plugin);
}
diff --git a/src/plugins/resourceeditor/resourceeditorfactory.h b/src/plugins/resourceeditor/resourceeditorfactory.h
index 26ae4ece1e..67cf83a840 100644
--- a/src/plugins/resourceeditor/resourceeditorfactory.h
+++ b/src/plugins/resourceeditor/resourceeditorfactory.h
@@ -47,7 +47,7 @@ class ResourceEditorFactory : public Core::IEditorFactory
public:
explicit ResourceEditorFactory(ResourceEditorPlugin *plugin);
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
private:
ResourceEditorPlugin *m_plugin;
diff --git a/src/plugins/resourceeditor/resourceeditorw.cpp b/src/plugins/resourceeditor/resourceeditorw.cpp
index a05ba174de..36ce8a14a1 100644
--- a/src/plugins/resourceeditor/resourceeditorw.cpp
+++ b/src/plugins/resourceeditor/resourceeditorw.cpp
@@ -39,7 +39,7 @@
#include <coreplugin/actionmanager/commandbutton.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/documentmanager.h>
-#include <find/treeviewfind.h>
+#include <coreplugin/find/treeviewfind.h>
#include <utils/reloadpromptutils.h>
#include <utils/fileutils.h>
@@ -97,7 +97,7 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context,
Aggregation::Aggregate * agg = new Aggregation::Aggregate;
agg->add(m_resourceEditor->treeView());
- agg->add(new Find::TreeViewFind(m_resourceEditor->treeView()));
+ agg->add(new Core::TreeViewFind(m_resourceEditor->treeView()));
m_resourceEditor->setResourceDragEnabled(true);
m_contextMenu->addAction(tr("Open File"), this, SLOT(openCurrentFile()));
@@ -110,7 +110,7 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context,
// (That is because this editor instance is deleted in executeOpenWithMenuAction
// in that case.)
connect(m_openWithMenu, SIGNAL(triggered(QAction*)),
- Core::DocumentManager::instance(), SLOT(slotExecuteOpenWithMenuAction(QAction*)),
+ Core::DocumentManager::instance(), SLOT(executeOpenWithMenuAction(QAction*)),
Qt::QueuedConnection);
connect(m_resourceEditor, SIGNAL(dirtyChanged(bool)), m_resourceDocument, SLOT(dirtyChanged(bool)));
diff --git a/src/plugins/subversion/checkoutwizard.cpp b/src/plugins/subversion/checkoutwizard.cpp
index 5495e29741..ed1f6b03f6 100644
--- a/src/plugins/subversion/checkoutwizard.cpp
+++ b/src/plugins/subversion/checkoutwizard.cpp
@@ -30,6 +30,7 @@
#include "checkoutwizard.h"
#include "checkoutwizardpage.h"
#include "subversionplugin.h"
+#include "subversionclient.h"
#include <coreplugin/iversioncontrol.h>
#include <vcsbase/command.h>
@@ -78,7 +79,7 @@ VcsBase::Command *CheckoutWizard::createCommand(const QList<QWizardPage*> &param
if (settings.hasAuthentication()) {
const QString user = settings.stringValue(SubversionSettings::userKey);
const QString pwd = settings.stringValue(SubversionSettings::passwordKey);
- args = SubversionPlugin::addAuthenticationOptions(args, user, pwd);
+ args = SubversionClient::addAuthenticationOptions(args, user, pwd);
}
VcsBase::Command *command = new VcsBase::Command(binary, workingDirectory,
QProcessEnvironment::systemEnvironment());
diff --git a/src/plugins/subversion/settingspage.cpp b/src/plugins/subversion/settingspage.cpp
index 7ae0998938..41dec9b870 100644
--- a/src/plugins/subversion/settingspage.cpp
+++ b/src/plugins/subversion/settingspage.cpp
@@ -48,6 +48,7 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
{
m_ui.setupUi(this);
m_ui.pathChooser->setExpectedKind(PathChooser::ExistingCommand);
+ m_ui.pathChooser->setHistoryCompleter(QLatin1String("Subversion.Command.History"));
m_ui.pathChooser->setPromptDialogTitle(tr("Subversion Command"));
}
@@ -81,26 +82,6 @@ void SettingsPageWidget::setSettings(const SubversionSettings &s)
m_ui.logCountSpinBox->setValue(s.intValue(SubversionSettings::logCountKey));
}
-QString SettingsPageWidget::searchKeywords() const
-{
- QString rc;
- QLatin1Char sep(' ');
- QTextStream(&rc)
- << sep << m_ui.generalGroupBox->title()
- << sep << m_ui.commandLabel->text()
- << sep << m_ui.userGroupBox->title()
- << sep << m_ui.usernameLabel->text()
- << sep << m_ui.passwordLabel->text()
- << sep << m_ui.miscGroupBox->title()
- << sep << m_ui.logCountLabel->text()
- << sep << m_ui.timeOutLabel->text()
- << sep << m_ui.promptToSubmitCheckBox->text()
- << sep << m_ui.spaceIgnorantAnnotationCheckBox->text()
- ;
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
SettingsPage::SettingsPage() :
m_widget(0)
{
@@ -108,12 +89,12 @@ SettingsPage::SettingsPage() :
setDisplayName(tr("Subversion"));
}
-QWidget *SettingsPage::createPage(QWidget *parent)
+QWidget *SettingsPage::widget()
{
- m_widget = new SettingsPageWidget(parent);
- m_widget->setSettings(SubversionPlugin::instance()->settings());
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_widget->searchKeywords();
+ if (!m_widget) {
+ m_widget = new SettingsPageWidget;
+ m_widget->setSettings(SubversionPlugin::instance()->settings());
+ }
return m_widget;
}
@@ -122,7 +103,7 @@ void SettingsPage::apply()
SubversionPlugin::instance()->setSettings(m_widget->settings());
}
-bool SettingsPage::matches(const QString &s) const
+void SettingsPage::finish()
{
- return m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ delete m_widget;
}
diff --git a/src/plugins/subversion/settingspage.h b/src/plugins/subversion/settingspage.h
index baa6134fa4..2bb5862dfc 100644
--- a/src/plugins/subversion/settingspage.h
+++ b/src/plugins/subversion/settingspage.h
@@ -57,8 +57,6 @@ public:
SubversionSettings settings() const;
void setSettings(const SubversionSettings &);
- QString searchKeywords() const;
-
private:
Ui::SettingsPage m_ui;
};
@@ -71,14 +69,12 @@ class SettingsPage : public VcsBase::VcsBaseOptionsPage
public:
SettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &) const;
+ void finish();
private:
- QString m_searchKeywords;
- SettingsPageWidget* m_widget;
+ QPointer<SettingsPageWidget> m_widget;
};
} // namespace Subversion
diff --git a/src/plugins/subversion/subversion.pro b/src/plugins/subversion/subversion.pro
index 6d2d9e21c0..ae8e211b62 100644
--- a/src/plugins/subversion/subversion.pro
+++ b/src/plugins/subversion/subversion.pro
@@ -2,6 +2,7 @@ include(../../qtcreatorplugin.pri)
HEADERS += annotationhighlighter.h \
subversionplugin.h \
+ subversionclient.h \
subversioncontrol.h \
settingspage.h \
subversioneditor.h \
@@ -13,6 +14,7 @@ HEADERS += annotationhighlighter.h \
SOURCES += annotationhighlighter.cpp \
subversionplugin.cpp \
+ subversionclient.cpp \
subversioncontrol.cpp \
settingspage.cpp \
subversioneditor.cpp \
diff --git a/src/plugins/subversion/subversion.qbs b/src/plugins/subversion/subversion.qbs
index d213ce0f77..b92fff54f3 100644
--- a/src/plugins/subversion/subversion.qbs
+++ b/src/plugins/subversion/subversion.qbs
@@ -8,9 +8,7 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
Depends { name: "TextEditor" }
- Depends { name: "Find" }
Depends { name: "VcsBase" }
- Depends { name: "Locator" }
files: [
"annotationhighlighter.cpp",
@@ -23,6 +21,8 @@ QtcPlugin {
"settingspage.h",
"settingspage.ui",
"subversion.qrc",
+ "subversionclient.cpp",
+ "subversionclient.h",
"subversionconstants.h",
"subversioncontrol.cpp",
"subversioncontrol.h",
diff --git a/src/plugins/subversion/subversion_dependencies.pri b/src/plugins/subversion/subversion_dependencies.pri
index 297af991b6..87e1a57ad5 100644
--- a/src/plugins/subversion/subversion_dependencies.pri
+++ b/src/plugins/subversion/subversion_dependencies.pri
@@ -2,7 +2,6 @@ QTC_PLUGIN_NAME = Subversion
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
- locator \
texteditor \
coreplugin \
vcsbase
diff --git a/src/plugins/subversion/subversionclient.cpp b/src/plugins/subversion/subversionclient.cpp
new file mode 100644
index 0000000000..3b3b193fe2
--- /dev/null
+++ b/src/plugins/subversion/subversionclient.cpp
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "subversionclient.h"
+#include "subversionsettings.h"
+
+#include <vcsbase/vcsbaseplugin.h>
+#include <vcsbase/vcsbaseconstants.h>
+#include <vcsbase/vcsbaseeditorparameterwidget.h>
+#include <utils/synchronousprocess.h>
+
+#include <QDir>
+#include <QFileInfo>
+#include <QTextStream>
+#include <QDebug>
+
+namespace Subversion {
+namespace Internal {
+
+// Collect all parameters required for a diff to be able to associate them
+// with a diff editor and re-run the diff with parameters.
+struct SubversionDiffParameters
+{
+ QString workingDir;
+ QStringList extraOptions;
+ QStringList files;
+};
+
+// Parameter widget controlling whitespace diff mode, associated with a parameter
+class SubversionDiffParameterWidget : public VcsBase::VcsBaseEditorParameterWidget
+{
+ Q_OBJECT
+public:
+ explicit SubversionDiffParameterWidget(SubversionClient *client,
+ const SubversionDiffParameters &p,
+ QWidget *parent = 0);
+ QStringList arguments() const;
+ void executeCommand();
+
+private:
+ SubversionClient *m_client;
+ const SubversionDiffParameters m_params;
+};
+
+SubversionDiffParameterWidget::SubversionDiffParameterWidget(SubversionClient *client,
+ const SubversionDiffParameters &p,
+ QWidget *parent)
+ : VcsBase::VcsBaseEditorParameterWidget(parent), m_client(client), m_params(p)
+{
+ mapSetting(addToggleButton(QLatin1String("w"), tr("Ignore Whitespace")),
+ client->settings()->boolPointer(SubversionSettings::diffIgnoreWhiteSpaceKey));
+}
+
+QStringList SubversionDiffParameterWidget::arguments() const
+{
+ QStringList args;
+ // Subversion wants" -x -<ext-args>", default being -u
+ const QStringList formatArguments = VcsBaseEditorParameterWidget::arguments();
+ if (!formatArguments.isEmpty()) {
+ args << QLatin1String("-x")
+ << (QLatin1String("-u") + formatArguments.join(QString()));
+ }
+ return args;
+}
+
+void SubversionDiffParameterWidget::executeCommand()
+{
+ m_client->diff(m_params.workingDir, m_params.files, m_params.extraOptions);
+}
+
+SubversionClient::SubversionClient(SubversionSettings *settings) :
+ VcsBase::VcsBaseClient(settings)
+{
+}
+
+SubversionSettings *SubversionClient::settings() const
+{
+ return dynamic_cast<SubversionSettings *>(VcsBase::VcsBaseClient::settings());
+}
+
+Core::Id SubversionClient::vcsEditorKind(VcsCommand cmd) const
+{
+ switch (cmd) {
+ case DiffCommand:
+ return "Subversion Diff Editor"; // TODO: create subversionconstants.h
+ default:
+ return Core::Id();
+ }
+}
+
+SubversionClient::Version SubversionClient::svnVersion()
+{
+ if (m_svnVersionBinary != settings()->binaryPath()) {
+ QStringList args;
+ args << QLatin1String("--version") << QLatin1String("-q");
+ const Utils::SynchronousProcessResponse response =
+ VcsBase::VcsBasePlugin::runVcs(QDir().absolutePath(), settings()->binaryPath(),
+ args, settings()->timeOutMs());
+ if (response.result == Utils::SynchronousProcessResponse::Finished &&
+ response.exitCode == 0) {
+ m_svnVersionBinary = settings()->binaryPath();
+ m_svnVersion = response.stdOut.trimmed();
+ } else {
+ m_svnVersionBinary.clear();
+ m_svnVersion.clear();
+ }
+ }
+
+ SubversionClient::Version v;
+ if (::sscanf(m_svnVersion.toLatin1().constData(), "%d.%d.%d",
+ &v.majorVersion, &v.minorVersion, &v.patchVersion) != 3) {
+ v.majorVersion = v.minorVersion = v.patchVersion = -1;
+ }
+
+ return v;
+}
+
+// Add authorization options to the command line arguments.
+// SVN pre 1.5 does not accept "--userName" for "add", which is most likely
+// an oversight. As no password is needed for the option, generally omit it.
+QStringList SubversionClient::addAuthenticationOptions(const QStringList &args,
+ const QString &userName,
+ const QString &password)
+{
+ if (userName.isEmpty())
+ return args;
+ if (!args.empty() && args.front() == QLatin1String("add"))
+ return args;
+ QStringList rc;
+ rc.push_back(QLatin1String("--username"));
+ rc.push_back(userName);
+ if (!password.isEmpty()) {
+ rc.push_back(QLatin1String("--password"));
+ rc.push_back(password);
+ }
+ rc.append(args);
+ return rc;
+}
+
+void SubversionClient::diff(const QString &workingDir, const QStringList &files,
+ const QStringList &extraOptions)
+{
+ QStringList args(extraOptions);
+ Version v = svnVersion();
+
+ // --internal-diff is new in v1.7.0
+ if (v.majorVersion > 1 || (v.majorVersion == 1 && v.minorVersion >= 7))
+ args.append(QLatin1String("--internal-diff"));
+
+ const bool hasAuth = settings()->hasAuthentication();
+ const QString userName = hasAuth ? settings()->stringValue(SubversionSettings::userKey) : QString();
+ const QString password = hasAuth ? settings()->stringValue(SubversionSettings::passwordKey) : QString();
+ args = addAuthenticationOptions(args, userName, password);
+
+ VcsBaseClient::diff(workingDir, files, args);
+}
+
+QString SubversionClient::findTopLevelForFile(const QFileInfo &file) const
+{
+ Q_UNUSED(file)
+ return QString();
+}
+
+QStringList SubversionClient::revisionSpec(const QString &revision) const
+{
+ Q_UNUSED(revision)
+ return QStringList();
+}
+
+VcsBase::VcsBaseClient::StatusItem SubversionClient::parseStatusLine(const QString &line) const
+{
+ Q_UNUSED(line)
+ return VcsBase::VcsBaseClient::StatusItem();
+}
+
+VcsBase::VcsBaseEditorParameterWidget *SubversionClient::createDiffEditor(
+ const QString &workingDir, const QStringList &files, const QStringList &extraOptions)
+{
+ Q_UNUSED(extraOptions)
+ SubversionDiffParameters p;
+ p.workingDir = workingDir;
+ p.files = files;
+ p.extraOptions = extraOptions;
+ return new SubversionDiffParameterWidget(this, p);
+}
+
+} // namespace Internal
+} // namespace Subversion
+
+#include "subversionclient.moc"
diff --git a/src/plugins/subversion/subversionclient.h b/src/plugins/subversion/subversionclient.h
new file mode 100644
index 0000000000..34e684f9e0
--- /dev/null
+++ b/src/plugins/subversion/subversionclient.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef SUBVERSIONCLIENT_H
+#define SUBVERSIONCLIENT_H
+
+#include "subversionsettings.h"
+#include <vcsbase/vcsbaseclient.h>
+
+namespace Subversion {
+namespace Internal {
+
+class SubversionSettings;
+
+class SubversionClient : public VcsBase::VcsBaseClient
+{
+ Q_OBJECT
+
+public:
+ SubversionClient(SubversionSettings *settings);
+
+ SubversionSettings *settings() const;
+ void diff(const QString &workingDir, const QStringList &files,
+ const QStringList &extraOptions = QStringList());
+ QString findTopLevelForFile(const QFileInfo &file) const;
+ QStringList revisionSpec(const QString &revision) const;
+ StatusItem parseStatusLine(const QString &line) const;
+
+ class Version {
+ public:
+ int majorVersion;
+ int minorVersion;
+ int patchVersion;
+ };
+
+ Version svnVersion();
+
+ // Add authorization options to the command line arguments.
+ static QStringList addAuthenticationOptions(const QStringList &args,
+ const QString &userName = QString(),
+ const QString &password = QString());
+
+protected:
+ Core::Id vcsEditorKind(VcsCommand cmd) const;
+ VcsBase::VcsBaseEditorParameterWidget *createDiffEditor(const QString &workingDir,
+ const QStringList &files,
+ const QStringList &extraOptions);
+private:
+ QString m_svnVersionBinary;
+ QString m_svnVersion;
+};
+
+} // namespace Internal
+} // namespace Subversion
+
+#endif // SUBVERSIONCLIENT_H
diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp
index 906afd31be..cd8de10eb4 100644
--- a/src/plugins/subversion/subversionplugin.cpp
+++ b/src/plugins/subversion/subversionplugin.cpp
@@ -33,6 +33,7 @@
#include "subversioneditor.h"
#include "subversionsubmiteditor.h"
+#include "subversionclient.h"
#include "subversionconstants.h"
#include "subversioncontrol.h"
#include "checkoutwizard.h"
@@ -58,7 +59,7 @@
#include <coreplugin/id.h>
#include <coreplugin/editormanager/editormanager.h>
-#include <locator/commandlocator.h>
+#include <coreplugin/locator/commandlocator.h>
#include <utils/qtcassert.h>
@@ -209,6 +210,7 @@ SubversionPlugin::SubversionPlugin() :
SubversionPlugin::~SubversionPlugin()
{
+ delete m_client;
cleanCommitMessageFile();
}
@@ -251,6 +253,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
return false;
m_settings.readSettings(Core::ICore::settings());
+ m_client = new SubversionClient(&m_settings);
addAutoReleasedObject(new SettingsPage);
@@ -264,7 +267,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
addAutoReleasedObject(new CheckoutWizard);
const QString prefix = QLatin1String("svn");
- m_commandLocator = new Locator::CommandLocator("Subversion", prefix, prefix);
+ m_commandLocator = new Core::CommandLocator("Subversion", prefix, prefix);
addAutoReleasedObject(m_commandLocator);
//register actions
@@ -497,117 +500,7 @@ bool SubversionPlugin::submitEditorAboutToClose()
void SubversionPlugin::diffCommitFiles(const QStringList &files)
{
- svnDiff(m_commitRepository, files);
-}
-
-// Collect all parameters required for a diff to be able to associate them
-// with a diff editor and re-run the diff with parameters.
-struct SubversionDiffParameters
-{
- QString workingDir;
- QStringList arguments;
- QStringList files;
- QString diffName;
-};
-
-// Parameter widget controlling whitespace diff mode, associated with a parameter
-class SubversionDiffParameterWidget : public VcsBase::VcsBaseEditorParameterWidget
-{
- Q_OBJECT
-public:
- explicit SubversionDiffParameterWidget(const SubversionDiffParameters &p, QWidget *parent = 0);
-
-signals:
- void reRunDiff(const Subversion::Internal::SubversionDiffParameters &);
-
-private slots:
- void triggerReRun();
-
-private:
- const SubversionDiffParameters m_parameters;
-};
-
-SubversionDiffParameterWidget::SubversionDiffParameterWidget(const SubversionDiffParameters &p, QWidget *parent) :
- VcsBase::VcsBaseEditorParameterWidget(parent), m_parameters(p)
-{
- setBaseArguments(p.arguments);
- addToggleButton(QLatin1String("w"), tr("Ignore Whitespace"));
- connect(this, SIGNAL(argumentsChanged()), this, SLOT(triggerReRun()));
-}
-
-void SubversionDiffParameterWidget::triggerReRun()
-{
- SubversionDiffParameters effectiveParameters = m_parameters;
- // Subversion wants" -x -<ext-args>", default being -u
- const QStringList a = arguments();
- if (!a.isEmpty())
- effectiveParameters.arguments << QLatin1String("-x") << (QLatin1String("-u") + a.join(QString()));
- emit reRunDiff(effectiveParameters);
-}
-
-static inline void setWorkingDirectory(Core::IEditor *editor, const QString &wd)
-{
- if (VcsBase::VcsBaseEditorWidget *ve = qobject_cast<VcsBase::VcsBaseEditorWidget*>(editor->widget()))
- ve->setWorkingDirectory(wd);
-}
-
-void SubversionPlugin::svnDiff(const QString &workingDir, const QStringList &files, QString diffname)
-{
- SubversionDiffParameters p;
- p.workingDir = workingDir;
- p.files = files;
- p.diffName = diffname;
- svnDiff(p);
-}
-
-void SubversionPlugin::svnDiff(const Subversion::Internal::SubversionDiffParameters &p)
-{
- if (Subversion::Constants::debug)
- qDebug() << Q_FUNC_INFO << p.files << p.diffName;
- const QString source = VcsBase::VcsBaseEditorWidget::getSource(p.workingDir, p.files);
- QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VcsBase::VcsBaseEditorWidget::getCodec(source);
-
- const QString diffName = p.files.count() == 1 && p.diffName.isEmpty() ?
- QFileInfo(p.files.front()).fileName() : p.diffName;
-
- QStringList args(QLatin1String("diff"));
- Version v = svnVersion();
- if (v.majorVersion > 1
- || (v.majorVersion == 1 && v.minorVersion >= 7)) // --internal-diff is new in v1.7.0
- args.append(QLatin1String("--internal-diff"));
- args.append(p.arguments);
- args << p.files;
-
- const SubversionResponse response =
- runSvn(p.workingDir, args, m_settings.timeOutMs(), 0, codec);
- if (response.error)
- return;
-
- // diff of a single file? re-use an existing view if possible to support
- // the common usage pattern of continuously changing and diffing a file
- const QString tag = VcsBase::VcsBaseEditorWidget::editorTag(VcsBase::DiffOutput, p.workingDir, p.files);
- // Show in the same editor if diff has been executed before
- if (Core::IEditor *existingEditor = VcsBase::VcsBaseEditorWidget::locateEditorByTag(tag)) {
- existingEditor->document()->setContents(response.stdOut.toUtf8());
- Core::EditorManager::activateEditor(existingEditor);
- setWorkingDirectory(existingEditor, p.workingDir);
- return;
- }
- const QString title = QString::fromLatin1("svn diff %1").arg(diffName);
- Core::IEditor *editor = showOutputInEditor(title, response.stdOut, VcsBase::DiffOutput, source, codec);
- setWorkingDirectory(editor, p.workingDir);
- VcsBase::VcsBaseEditorWidget::tagEditor(editor, tag);
- SubversionEditor *diffEditorWidget = qobject_cast<SubversionEditor *>(editor->widget());
- QTC_ASSERT(diffEditorWidget, return);
-
- // Wire up the parameter widget to trigger a re-run on
- // parameter change and 'revert' from inside the diff editor.
- SubversionDiffParameterWidget *pw = new SubversionDiffParameterWidget(p);
- connect(pw, SIGNAL(reRunDiff(Subversion::Internal::SubversionDiffParameters)),
- this, SLOT(svnDiff(Subversion::Internal::SubversionDiffParameters)));
- connect(diffEditorWidget, SIGNAL(diffChunkReverted(VcsBase::DiffChunk)),
- pw, SLOT(triggerReRun()));
- diffEditorWidget->setConfigurationWidget(pw);
+ m_client->diff(m_commitRepository, files);
}
SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QString &fileName)
@@ -724,15 +617,16 @@ void SubversionPlugin::diffProject()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return);
- svnDiff(state.currentProjectTopLevel(), QStringList(state.relativeCurrentProject()),
- state.currentProjectName());
+ const QString relativeProject = state.relativeCurrentProject();
+ m_client->diff(state.currentProjectTopLevel(),
+ relativeProject.isEmpty() ? QStringList() : QStringList(relativeProject));
}
void SubversionPlugin::diffCurrentFile()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
- svnDiff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
+ m_client->diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
}
void SubversionPlugin::startCommitCurrentFile()
@@ -842,7 +736,7 @@ void SubversionPlugin::diffRepository()
{
const VcsBase::VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
- svnDiff(state.topLevel(), QStringList());
+ m_client->diff(state.topLevel(), QStringList());
}
void SubversionPlugin::statusRepository()
@@ -1092,53 +986,6 @@ SubversionResponse
arguments, timeOut, flags, outputCodec);
}
-// Add authorization options to the command line arguments.
-// SVN pre 1.5 does not accept "--userName" for "add", which is most likely
-// an oversight. As no password is needed for the option, generally omit it.
-QStringList SubversionPlugin::addAuthenticationOptions(const QStringList &args,
- const QString &userName, const QString &password)
-{
- if (userName.isEmpty())
- return args;
- if (!args.empty() && args.front() == QLatin1String("add"))
- return args;
- QStringList rc;
- rc.push_back(QLatin1String("--username"));
- rc.push_back(userName);
- if (!password.isEmpty()) {
- rc.push_back(QLatin1String("--password"));
- rc.push_back(password);
- }
- rc.append(args);
- return rc;
-}
-
-SubversionPlugin::Version SubversionPlugin::svnVersion()
-{
- if (m_svnVersionBinary != m_settings.binaryPath()) {
- QStringList args;
- args << QLatin1String("--version") << QLatin1String("-q");
- const Utils::SynchronousProcessResponse response =
- VcsBase::VcsBasePlugin::runVcs(QDir().absolutePath(), m_settings.binaryPath(),
- args, m_settings.timeOutMs());
- if (response.result == Utils::SynchronousProcessResponse::Finished &&
- response.exitCode == 0) {
- m_svnVersionBinary = m_settings.binaryPath();
- m_svnVersion = response.stdOut.trimmed();
- } else {
- m_svnVersionBinary.clear();
- m_svnVersion.clear();
- }
- }
-
- SubversionPlugin::Version v;
- if (::sscanf(m_svnVersion.toLatin1().constData(), "%d.%d.%d",
- &v.majorVersion, &v.minorVersion, &v.patchVersion) != 3)
- v.majorVersion = v.minorVersion = v.patchVersion = -1;
-
- return v;
-}
-
SubversionResponse SubversionPlugin::runSvn(const QString &workingDir,
const QString &userName, const QString &password,
const QStringList &arguments, int timeOut,
@@ -1152,7 +999,7 @@ SubversionResponse SubversionPlugin::runSvn(const QString &workingDir,
return response;
}
- const QStringList completeArguments = SubversionPlugin::addAuthenticationOptions(arguments, userName, password);
+ const QStringList completeArguments = SubversionClient::addAuthenticationOptions(arguments, userName, password);
const Utils::SynchronousProcessResponse sp_resp =
VcsBase::VcsBasePlugin::runVcs(workingDir, executable, completeArguments, timeOut,
flags, outputCodec);
@@ -1184,14 +1031,13 @@ Core::IEditor *SubversionPlugin::showOutputInEditor(const QString &title, const
return 0;
e->setForceReadOnly(true);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
- e->setSuggestedFileName(s);
+ e->baseTextDocument()->setSuggestedFileName(s);
if (!source.isEmpty())
e->setSource(source);
if (codec)
e->setCodec(codec);
- Core::IEditor *ie = e->editor();
- Core::EditorManager::activateEditor(ie);
- return ie;
+ Core::EditorManager::activateEditor(editor);
+ return editor;
}
SubversionSettings SubversionPlugin::settings() const
@@ -1448,4 +1294,3 @@ void SubversionPlugin::testLogResolving()
Q_EXPORT_PLUGIN(Subversion::Internal::SubversionPlugin)
-#include "subversionplugin.moc"
diff --git a/src/plugins/subversion/subversionplugin.h b/src/plugins/subversion/subversionplugin.h
index e4f321a813..14e818156d 100644
--- a/src/plugins/subversion/subversionplugin.h
+++ b/src/plugins/subversion/subversionplugin.h
@@ -42,6 +42,7 @@ class QTextCodec;
QT_END_NAMESPACE
namespace Core {
+ class CommandLocator;
class IVersionControl;
class IEditor;
}
@@ -53,16 +54,12 @@ namespace VcsBase {
class VcsBaseSubmitEditor;
}
-namespace Locator {
- class CommandLocator;
-}
-
namespace Subversion {
namespace Internal {
class SubversionSubmitEditor;
class SubversionControl;
-struct SubversionDiffParameters;
+class SubversionClient;
struct SubversionResponse
{
@@ -84,8 +81,6 @@ public:
bool initialize(const QStringList &arguments, QString *errorMessage);
- void svnDiff(const QString &workingDir, const QStringList &files, QString diffname = QString());
-
SubversionSubmitEditor *openSubversionSubmitEditor(const QString &fileName);
SubversionSettings settings() const;
@@ -102,24 +97,9 @@ public:
static SubversionPlugin *instance();
- // Add authorization options to the command line arguments.
- static QStringList addAuthenticationOptions(const QStringList &args,
- const QString &userName = QString(),
- const QString &password = QString());
-
- class Version {
- public:
- int majorVersion;
- int minorVersion;
- int patchVersion;
- };
-
- Version svnVersion();
-
public slots:
void vcsAnnotate(const QString &workingDir, const QString &file,
const QString &revision = QString(), int lineNumber = -1);
- void svnDiff(const Subversion::Internal::SubversionDiffParameters &p);
private slots:
void addCurrentFile();
@@ -183,10 +163,11 @@ private:
const QStringList m_svnDirectories;
SubversionSettings m_settings;
+ SubversionClient *m_client;
QString m_commitMessageFileName;
QString m_commitRepository;
- Locator::CommandLocator *m_commandLocator;
+ Core::CommandLocator *m_commandLocator;
Utils::ParameterAction *m_addAction;
Utils::ParameterAction *m_deleteAction;
Utils::ParameterAction *m_revertAction;
@@ -214,9 +195,6 @@ private:
QAction *m_menuAction;
bool m_submitActionTriggered;
- QString m_svnVersionBinary;
- QString m_svnVersion;
-
static SubversionPlugin *m_subversionPluginInstance;
};
diff --git a/src/plugins/subversion/subversionsettings.cpp b/src/plugins/subversion/subversionsettings.cpp
index 3c568e4bec..d7109d302d 100644
--- a/src/plugins/subversion/subversionsettings.cpp
+++ b/src/plugins/subversion/subversionsettings.cpp
@@ -41,6 +41,7 @@ const QLatin1String SubversionSettings::useAuthenticationKey("Authentication");
const QLatin1String SubversionSettings::userKey("User");
const QLatin1String SubversionSettings::passwordKey("Password");
const QLatin1String SubversionSettings::spaceIgnorantAnnotationKey("SpaceIgnorantAnnotation");
+const QLatin1String SubversionSettings::diffIgnoreWhiteSpaceKey("DiffIgnoreWhiteSpace");
SubversionSettings::SubversionSettings()
{
@@ -51,6 +52,7 @@ SubversionSettings::SubversionSettings()
declareKey(userKey, QLatin1String(""));
declareKey(passwordKey, QLatin1String(""));
declareKey(spaceIgnorantAnnotationKey, true);
+ declareKey(diffIgnoreWhiteSpaceKey, false);
}
bool SubversionSettings::hasAuthentication() const
diff --git a/src/plugins/subversion/subversionsettings.h b/src/plugins/subversion/subversionsettings.h
index 2c80ce8d5d..6cfdc62f3a 100644
--- a/src/plugins/subversion/subversionsettings.h
+++ b/src/plugins/subversion/subversionsettings.h
@@ -42,6 +42,7 @@ public:
static const QLatin1String userKey;
static const QLatin1String passwordKey;
static const QLatin1String spaceIgnorantAnnotationKey;
+ static const QLatin1String diffIgnoreWhiteSpaceKey;
SubversionSettings();
bool hasAuthentication() const;
diff --git a/src/plugins/tasklist/tasklist.qbs b/src/plugins/tasklist/tasklist.qbs
index 8374262e75..ef105ea216 100644
--- a/src/plugins/tasklist/tasklist.qbs
+++ b/src/plugins/tasklist/tasklist.qbs
@@ -8,8 +8,6 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
Depends { name: "ProjectExplorer" }
- Depends { name: "Find" }
- Depends { name: "Locator" }
Depends { name: "TextEditor" }
files: [
diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp
index cb5d71fdd2..6772d9a64b 100644
--- a/src/plugins/texteditor/basefilefind.cpp
+++ b/src/plugins/texteditor/basefilefind.cpp
@@ -36,7 +36,7 @@
#include <coreplugin/progressmanager/futureprogress.h>
#include <coreplugin/dialogs/readonlyfilesdialog.h>
#include <coreplugin/documentmanager.h>
-#include <find/ifindsupport.h>
+#include <coreplugin/find/ifindsupport.h>
#include <texteditor/itexteditor.h>
#include <texteditor/refactoringchanges.h>
#include <utils/stylehelper.h>
@@ -56,27 +56,26 @@
namespace TextEditor {
namespace Internal {
-class BaseFileFindPrivate {
+
+class BaseFileFindPrivate
+{
public:
BaseFileFindPrivate() : m_resultLabel(0), m_filterCombo(0) {}
- QMap<QFutureWatcher<Utils::FileSearchResultList> *, QPointer<Find::SearchResult> > m_watchers;
- QPointer<Find::IFindSupport> m_currentFindSupport;
+ QMap<QFutureWatcher<Utils::FileSearchResultList> *, QPointer<Core::SearchResult> > m_watchers;
+ QPointer<Core::IFindSupport> m_currentFindSupport;
QLabel *m_resultLabel;
QStringListModel m_filterStrings;
QString m_filterSetting;
QPointer<QComboBox> m_filterCombo;
};
+
} // namespace Internal
-} // namespace TextEditor
-using namespace Core;
+using namespace Internal;
using namespace Utils;
-using namespace Find;
-using namespace TextEditor;
-using namespace TextEditor::Internal;
-
+using namespace Core;
BaseFileFind::BaseFileFind() : d(new BaseFileFindPrivate)
{
@@ -125,14 +124,14 @@ QStringList BaseFileFind::fileNameFilters() const
return filters;
}
-void BaseFileFind::runNewSearch(const QString &txt, Find::FindFlags findFlags,
+void BaseFileFind::runNewSearch(const QString &txt, Core::FindFlags findFlags,
SearchResultWindow::SearchMode searchMode)
{
d->m_currentFindSupport = 0;
if (d->m_filterCombo)
updateComboEntries(d->m_filterCombo, true);
- SearchResult *search = Find::SearchResultWindow::instance()->startNewSearch(label(),
- toolTip().arg(Find::IFindFilter::descriptionForFindFlags(findFlags)),
+ SearchResult *search = Core::SearchResultWindow::instance()->startNewSearch(label(),
+ toolTip().arg(Core::IFindFilter::descriptionForFindFlags(findFlags)),
txt, searchMode, QString::fromLatin1("TextEditor"));
search->setTextToReplace(txt);
search->setSearchAgainSupported(true);
@@ -142,10 +141,10 @@ void BaseFileFind::runNewSearch(const QString &txt, Find::FindFlags findFlags,
parameters.nameFilters = fileNameFilters();
parameters.additionalParameters = additionalParameters();
search->setUserData(qVariantFromValue(parameters));
- connect(search, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
+ connect(search, SIGNAL(activated(Core::SearchResultItem)), this, SLOT(openEditor(Core::SearchResultItem)));
if (searchMode == SearchResultWindow::SearchAndReplace) {
- connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)),
- this, SLOT(doReplace(QString,QList<Find::SearchResultItem>,bool)));
+ connect(search, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)),
+ this, SLOT(doReplace(QString,QList<Core::SearchResultItem>,bool)));
}
connect(search, SIGNAL(visibilityChanged(bool)), this, SLOT(hideHighlightAll(bool)));
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
@@ -157,29 +156,29 @@ void BaseFileFind::runNewSearch(const QString &txt, Find::FindFlags findFlags,
runSearch(search);
}
-void BaseFileFind::runSearch(Find::SearchResult *search)
+void BaseFileFind::runSearch(Core::SearchResult *search)
{
FileFindParameters parameters = search->userData().value<FileFindParameters>();
CountingLabel *label = new CountingLabel;
connect(search, SIGNAL(countChanged(int)), label, SLOT(updateCount(int)));
CountingLabel *statusLabel = new CountingLabel;
connect(search, SIGNAL(countChanged(int)), statusLabel, SLOT(updateCount(int)));
- Find::SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch|IOutputPane::WithFocus));
+ Core::SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch|IOutputPane::WithFocus));
QFutureWatcher<FileSearchResultList> *watcher = new QFutureWatcher<FileSearchResultList>();
d->m_watchers.insert(watcher, search);
watcher->setPendingResultsLimit(1);
connect(watcher, SIGNAL(resultReadyAt(int)), this, SLOT(displayResult(int)));
connect(watcher, SIGNAL(finished()), this, SLOT(searchFinished()));
- if (parameters.flags & Find::FindRegularExpression) {
+ if (parameters.flags & FindRegularExpression) {
watcher->setFuture(Utils::findInFilesRegExp(parameters.text,
files(parameters.nameFilters, parameters.additionalParameters),
textDocumentFlagsForFindFlags(parameters.flags),
- ITextEditor::openedTextDocumentContents()));
+ ITextEditorDocument::openedTextDocumentContents()));
} else {
watcher->setFuture(Utils::findInFiles(parameters.text,
files(parameters.nameFilters, parameters.additionalParameters),
textDocumentFlagsForFindFlags(parameters.flags),
- ITextEditor::openedTextDocumentContents()));
+ ITextEditorDocument::openedTextDocumentContents()));
}
FutureProgress *progress =
ProgressManager::addTask(watcher->future(), tr("Search"), Constants::TASK_SEARCH);
@@ -188,24 +187,24 @@ void BaseFileFind::runSearch(Find::SearchResult *search)
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
}
-void BaseFileFind::findAll(const QString &txt, Find::FindFlags findFlags)
+void BaseFileFind::findAll(const QString &txt, Core::FindFlags findFlags)
{
runNewSearch(txt, findFlags, SearchResultWindow::SearchOnly);
}
-void BaseFileFind::replaceAll(const QString &txt, Find::FindFlags findFlags)
+void BaseFileFind::replaceAll(const QString &txt, Core::FindFlags findFlags)
{
runNewSearch(txt, findFlags, SearchResultWindow::SearchAndReplace);
}
void BaseFileFind::doReplace(const QString &text,
- const QList<Find::SearchResultItem> &items,
+ const QList<Core::SearchResultItem> &items,
bool preserveCase)
{
QStringList files = replaceAll(text, items, preserveCase);
if (!files.isEmpty()) {
DocumentManager::notifyFilesChangedInternally(files);
- Find::SearchResultWindow::instance()->hide();
+ Core::SearchResultWindow::instance()->hide();
}
}
@@ -219,9 +218,9 @@ void BaseFileFind::displayResult(int index) {
return;
}
Utils::FileSearchResultList results = watcher->resultAt(index);
- QList<Find::SearchResultItem> items;
+ QList<Core::SearchResultItem> items;
foreach (const Utils::FileSearchResult &result, results) {
- Find::SearchResultItem item;
+ Core::SearchResultItem item;
item.path = QStringList() << QDir::toNativeSeparators(result.fileName);
item.lineNumber = result.lineNumber;
item.text = result.matchingLine;
@@ -231,7 +230,7 @@ void BaseFileFind::displayResult(int index) {
item.userData = result.regexpCapturedTexts;
items << item;
}
- search->addResults(items, Find::SearchResult::AddOrdered);
+ search->addResults(items, Core::SearchResult::AddOrdered);
}
void BaseFileFind::searchFinished()
@@ -304,7 +303,7 @@ void BaseFileFind::updateComboEntries(QComboBox *combo, bool onTop)
}
}
-void BaseFileFind::openEditor(const Find::SearchResultItem &item)
+void BaseFileFind::openEditor(const Core::SearchResultItem &item)
{
SearchResult *result = qobject_cast<SearchResult *>(sender());
IEditor *openedEditor = 0;
@@ -352,7 +351,7 @@ void BaseFileFind::recheckEnabled()
}
QStringList BaseFileFind::replaceAll(const QString &text,
- const QList<Find::SearchResultItem> &items,
+ const QList<Core::SearchResultItem> &items,
bool preserveCase)
{
if (items.isEmpty())
@@ -360,12 +359,12 @@ QStringList BaseFileFind::replaceAll(const QString &text,
RefactoringChanges refactoring;
- QHash<QString, QList<Find::SearchResultItem> > changes;
- foreach (const Find::SearchResultItem &item, items)
+ QHash<QString, QList<Core::SearchResultItem> > changes;
+ foreach (const Core::SearchResultItem &item, items)
changes[QDir::fromNativeSeparators(item.path.first())].append(item);
// Checking for files without write permissions
- QHashIterator<QString, QList<Find::SearchResultItem> > it(changes);
+ QHashIterator<QString, QList<Core::SearchResultItem> > it(changes);
QSet<QString> roFiles;
while (it.hasNext()) {
it.next();
@@ -386,12 +385,12 @@ QStringList BaseFileFind::replaceAll(const QString &text,
while (it.hasNext()) {
it.next();
const QString fileName = it.key();
- const QList<Find::SearchResultItem> changeItems = it.value();
+ const QList<Core::SearchResultItem> changeItems = it.value();
ChangeSet changeSet;
RefactoringFilePtr file = refactoring.file(fileName);
QSet<QPair<int, int> > processed;
- foreach (const Find::SearchResultItem &item, changeItems) {
+ foreach (const Core::SearchResultItem &item, changeItems) {
const QPair<int, int> &p = qMakePair(item.lineNumber, item.textMarkPos);
if (processed.contains(p))
continue;
@@ -441,3 +440,5 @@ void CountingLabel::updateCount(int count)
{
setText(tr("%1 found").arg(count));
}
+
+} // namespace TextEditor
diff --git a/src/plugins/texteditor/basefilefind.h b/src/plugins/texteditor/basefilefind.h
index e1d72b7324..f7f14662d5 100644
--- a/src/plugins/texteditor/basefilefind.h
+++ b/src/plugins/texteditor/basefilefind.h
@@ -32,8 +32,8 @@
#include "texteditor_global.h"
-#include <find/ifindfilter.h>
-#include <find/searchresultwindow.h>
+#include <coreplugin/find/ifindfilter.h>
+#include <coreplugin/find/searchresultwindow.h>
QT_BEGIN_NAMESPACE
class QLabel;
@@ -41,18 +41,18 @@ class QComboBox;
QT_END_NAMESPACE
namespace Utils { class FileIterator; }
-namespace Find {
+namespace Core {
class SearchResult;
class SearchResultItem;
class IFindSupport;
-} // namespace Find
+} // namespace Core
namespace TextEditor {
namespace Internal {
class BaseFileFindPrivate;
} // namespace Internal
-class TEXTEDITOR_EXPORT BaseFileFind : public Find::IFindFilter
+class TEXTEDITOR_EXPORT BaseFileFind : public Core::IFindFilter
{
Q_OBJECT
@@ -62,21 +62,21 @@ public:
bool isEnabled() const;
bool isReplaceSupported() const { return true; }
- void findAll(const QString &txt, Find::FindFlags findFlags);
- void replaceAll(const QString &txt, Find::FindFlags findFlags);
+ void findAll(const QString &txt, Core::FindFlags findFlags);
+ void replaceAll(const QString &txt, Core::FindFlags findFlags);
/* returns the list of unique files that were passed in items */
static QStringList replaceAll(const QString &txt,
- const QList<Find::SearchResultItem> &items,
+ const QList<Core::SearchResultItem> &items,
bool preserveCase = false);
protected:
virtual Utils::FileIterator *files(const QStringList &nameFilters,
const QVariant &additionalParameters) const = 0;
virtual QVariant additionalParameters() const = 0;
- QVariant getAdditionalParameters(Find::SearchResult *search);
- virtual QString label() const = 0; // see Find::SearchResultWindow::startNewSearch
- virtual QString toolTip() const = 0; // see Find::SearchResultWindow::startNewSearch,
+ QVariant getAdditionalParameters(Core::SearchResult *search);
+ virtual QString label() const = 0; // see Core::SearchResultWindow::startNewSearch
+ virtual QString toolTip() const = 0; // see Core::SearchResultWindow::startNewSearch,
// add %1 placeholder where the find flags should be put
void writeCommonSettings(QSettings *settings);
@@ -91,18 +91,18 @@ private slots:
void searchFinished();
void cancel();
void setPaused(bool paused);
- void openEditor(const Find::SearchResultItem &item);
+ void openEditor(const Core::SearchResultItem &item);
void doReplace(const QString &txt,
- const QList<Find::SearchResultItem> &items,
+ const QList<Core::SearchResultItem> &items,
bool preserveCase);
void hideHighlightAll(bool visible);
void searchAgain();
void recheckEnabled();
private:
- void runNewSearch(const QString &txt, Find::FindFlags findFlags,
- Find::SearchResultWindow::SearchMode searchMode);
- void runSearch(Find::SearchResult *search);
+ void runNewSearch(const QString &txt, Core::FindFlags findFlags,
+ Core::SearchResultWindow::SearchMode searchMode);
+ void runSearch(Core::SearchResult *search);
Internal::BaseFileFindPrivate *d;
};
diff --git a/src/plugins/texteditor/basefilefind_p.h b/src/plugins/texteditor/basefilefind_p.h
index 8234a924d6..8622771c29 100644
--- a/src/plugins/texteditor/basefilefind_p.h
+++ b/src/plugins/texteditor/basefilefind_p.h
@@ -30,7 +30,7 @@
#ifndef BASEFILEFIND_P_H
#define BASEFILEFIND_P_H
-#include <find/ifindfilter.h>
+#include <coreplugin/find/ifindfilter.h>
#include <QVariant>
#include <QLabel>
@@ -52,7 +52,7 @@ class FileFindParameters
{
public:
QString text;
- Find::FindFlags flags;
+ Core::FindFlags flags;
QStringList nameFilters;
QVariant additionalParameters;
};
diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp
index 3d651eca3a..adba636f4f 100644
--- a/src/plugins/texteditor/basetextdocument.cpp
+++ b/src/plugins/texteditor/basetextdocument.cpp
@@ -83,6 +83,18 @@ BaseTextDocumentPrivate::BaseTextDocumentPrivate(BaseTextDocument *q) :
BaseTextDocument::BaseTextDocument() : d(new BaseTextDocumentPrivate(this))
{
+ connect(d->m_document, SIGNAL(modificationChanged(bool)), this, SIGNAL(changed()));
+ connect(d->m_document, SIGNAL(contentsChanged()), this, SIGNAL(contentsChanged()));
+
+ // set new document layout
+ QTextOption opt = d->m_document->defaultTextOption();
+ opt.setTextDirection(Qt::LeftToRight);
+ opt.setFlags(opt.flags() | QTextOption::IncludeTrailingSpaces
+ | QTextOption::AddSpaceForLineAndParagraphSeparators
+ );
+ d->m_document->setDefaultTextOption(opt);
+ BaseTextDocumentLayout *documentLayout = new BaseTextDocumentLayout(d->m_document);
+ d->m_document->setDocumentLayout(documentLayout);
}
BaseTextDocument::~BaseTextDocument()
@@ -92,7 +104,7 @@ BaseTextDocument::~BaseTextDocument()
delete d;
}
-QString BaseTextDocument::contents() const
+QString BaseTextDocument::plainText() const
{
return document()->toPlainText();
}
@@ -195,7 +207,7 @@ SyntaxHighlighter *BaseTextDocument::syntaxHighlighter() const
return d->m_highlighter;
}
-ITextMarkable *BaseTextDocument::documentMarker() const
+ITextMarkable *BaseTextDocument::markableInterface() const
{
BaseTextDocumentLayout *documentLayout =
qobject_cast<BaseTextDocumentLayout *>(d->m_document->documentLayout());
@@ -319,7 +331,6 @@ void BaseTextDocument::setFilePath(const QString &newName)
return;
const QFileInfo fi(newName);
IDocument::setFilePath(QDir::cleanPath(fi.absoluteFilePath()));
- emit titleChanged(fi.fileName());
}
bool BaseTextDocument::isFileReadOnly() const
diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h
index ca3d896d57..af6bb25333 100644
--- a/src/plugins/texteditor/basetextdocument.h
+++ b/src/plugins/texteditor/basetextdocument.h
@@ -58,7 +58,7 @@ public:
virtual ~BaseTextDocument();
// ITextEditorDocument
- QString contents() const;
+ QString plainText() const;
QString textAt(int pos, int length) const;
QChar characterAt(int pos) const;
@@ -72,7 +72,7 @@ public:
const TabSettings &tabSettings() const;
const ExtraEncodingSettings &extraEncodingSettings() const;
- ITextMarkable *documentMarker() const;
+ ITextMarkable *markableInterface() const;
// IDocument implementation.
bool save(QString *errorString, const QString &fileName, bool autoSave);
@@ -104,7 +104,6 @@ public:
void cleanWhitespace(const QTextCursor &cursor);
signals:
- void titleChanged(QString title);
void mimeTypeChanged();
private:
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index d361997c22..b75ed7afe1 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -57,7 +57,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/infobar.h>
#include <coreplugin/manhattanstyle.h>
-#include <find/basetextfind.h>
+#include <coreplugin/find/basetextfind.h>
#include <utils/linecolumnlabel.h>
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
@@ -104,6 +104,7 @@
\internal
*/
+using namespace Core;
using namespace Utils;
namespace TextEditor {
@@ -188,10 +189,26 @@ QString BaseTextEditorWidget::convertToPlainText(const QString &txt)
static const char kTextBlockMimeType[] = "application/vnd.qtcreator.blocktext";
static const char kVerticalTextBlockMimeType[] = "application/vnd.qtcreator.vblocktext";
-
BaseTextEditorWidget::BaseTextEditorWidget(QWidget *parent)
: QPlainTextEdit(parent)
{
+ ctor(QSharedPointer<BaseTextDocument>(new BaseTextDocument));
+}
+
+BaseTextEditorWidget::BaseTextEditorWidget(BaseTextDocument *doc, QWidget *parent)
+ : QPlainTextEdit(parent)
+{
+ ctor(QSharedPointer<BaseTextDocument>(doc));
+}
+
+BaseTextEditorWidget::BaseTextEditorWidget(BaseTextEditorWidget *other)
+{
+ ctor(other->d->m_document);
+ d->m_revisionsVisible = other->d->m_revisionsVisible;
+}
+
+void BaseTextEditorWidget::ctor(const QSharedPointer<BaseTextDocument> &doc)
+{
d = new BaseTextEditorWidgetPrivate;
d->q = this;
d->m_extraArea = new TextEditExtraArea(this);
@@ -203,7 +220,8 @@ BaseTextEditorWidget::BaseTextEditorWidget(QWidget *parent)
d->m_searchResultOverlay = new TextEditorOverlay(this);
d->m_refactorOverlay = new RefactorOverlay(this);
- d->setupDocumentSignals(d->m_document);
+ d->m_document = doc;
+ d->setupDocumentSignals();
d->m_lastScrollPos = -1;
@@ -267,16 +285,6 @@ BaseTextEditorWidget::~BaseTextEditorWidget()
d = 0;
}
-QString BaseTextEditorWidget::mimeType() const
-{
- return d->m_document->mimeType();
-}
-
-void BaseTextEditorWidget::setMimeType(const QString &mt)
-{
- d->m_document->setMimeType(mt);
-}
-
void BaseTextEditorWidget::print(QPrinter *printer)
{
const bool oldFullPage = printer->fullPage();
@@ -486,20 +494,11 @@ int BaseTextEditorWidgetPrivate::visualIndent(const QTextBlock &block) const
return 0;
}
-ITextMarkable *BaseTextEditorWidget::markableInterface() const
-{
- return baseTextDocument()->documentMarker();
-}
-
BaseTextEditor *BaseTextEditorWidget::editor() const
{
if (!d->m_editor) {
d->m_editor = const_cast<BaseTextEditorWidget *>(this)->createEditor();
d->m_codeAssistant->configure(d->m_editor);
- connect(this, SIGNAL(textChanged()),
- d->m_editor, SIGNAL(contentsChanged()));
- connect(qobject_cast<BaseTextDocument *>(d->m_editor->document()),SIGNAL(mimeTypeChanged()),
- d->m_codeAssistant.data(), SLOT(reconfigure()));
}
return d->m_editor;
}
@@ -600,44 +599,7 @@ void BaseTextEditorWidgetPrivate::foldLicenseHeader()
}
}
-const Utils::ChangeSet &BaseTextEditorWidget::changeSet() const
-{
- return d->m_changeSet;
-}
-
-void BaseTextEditorWidget::setChangeSet(const Utils::ChangeSet &changeSet)
-{
- d->m_changeSet = changeSet;
-
- foreach (const ChangeSet::EditOp &op, changeSet.operationList()) {
- // ### TODO: process the edit operation
-
- switch (op.type) {
- case ChangeSet::EditOp::Replace:
- break;
-
- case ChangeSet::EditOp::Move:
- break;
-
- case ChangeSet::EditOp::Insert:
- break;
-
- case ChangeSet::EditOp::Remove:
- break;
-
- case ChangeSet::EditOp::Flip:
- break;
-
- case ChangeSet::EditOp::Copy:
- break;
-
- default:
- break;
- } // switch
- }
-}
-
-Core::IDocument *BaseTextEditorWidget::editorDocument() const
+BaseTextDocument *BaseTextEditorWidget::baseTextDocument() const
{
return d->m_document.data();
}
@@ -673,9 +635,6 @@ void BaseTextEditorWidget::editorContentsChange(int position, int charsRemoved,
d->snippetCheckCursor(cursor);
}
- if (doc->isRedoAvailable())
- emit editor()->contentsChangedBecauseOfUndo();
-
if (charsAdded != 0 && document()->characterAt(position + charsAdded - 1).isPrint())
d->m_assistRelevantContentAdded = true;
}
@@ -1846,7 +1805,8 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
return;
}
- if (ro || e->text().isEmpty() || !e->text().at(0).isPrint()) {
+ if (ro || e->text().isEmpty() || !e->text().at(0).isPrint()
+ || (e->modifiers() & (Qt::ControlModifier|Qt::AltModifier)) == Qt::ControlModifier) {
if (!cursorMoveKeyEvent(e)) {
QTextCursor cursor = textCursor();
bool cursorWithinSnippet = false;
@@ -1864,7 +1824,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
d->m_snippetOverlay->updateEquivalentSelections(textCursor());
}
}
- } else if ((e->modifiers() & (Qt::ControlModifier|Qt::AltModifier)) != Qt::ControlModifier){
+ } else {
QTextCursor cursor = textCursor();
QString text = e->text();
const QString &autoText = d->m_autoCompleter->autoComplete(cursor, text);
@@ -2078,31 +2038,6 @@ bool BaseTextEditorWidget::event(QEvent *e)
return QPlainTextEdit::event(e);
}
-void BaseTextEditorWidget::duplicateFrom(BaseTextEditorWidget *widget)
-{
- if (this == widget)
- return;
- d->m_revisionsVisible = widget->d->m_revisionsVisible;
- if (d->m_document == widget->d->m_document)
- return;
- d->setupDocumentSignals(widget->d->m_document);
- d->m_document = widget->d->m_document;
-}
-
-QSharedPointer<BaseTextDocument> BaseTextEditorWidget::baseTextDocument() const
-{
- return d->m_document;
-}
-
-
-void BaseTextEditorWidget::setBaseTextDocument(const QSharedPointer<BaseTextDocument> &doc)
-{
- if (!doc.isNull()) {
- d->setupDocumentSignals(doc);
- d->m_document = doc;
- }
-}
-
void BaseTextEditorWidget::documentAboutToBeReloaded()
{
//memorize cursor position
@@ -2209,16 +2144,6 @@ bool BaseTextEditorWidget::restoreState(const QByteArray &state)
return true;
}
-void BaseTextEditorWidget::setDefaultPath(const QString &defaultPath)
-{
- baseTextDocument()->setDefaultPath(defaultPath);
-}
-
-void BaseTextEditorWidget::setSuggestedFileName(const QString &suggestedFileName)
-{
- baseTextDocument()->setSuggestedFileName(suggestedFileName);
-}
-
void BaseTextEditorWidget::setParenthesesMatchingEnabled(bool b)
{
d->m_parenthesesMatchingEnabled = b;
@@ -2421,7 +2346,6 @@ BaseTextEditorWidgetPrivate::BaseTextEditorWidgetPrivate()
q(0),
m_contentsChanged(false),
m_lastCursorChangeWasInteresting(false),
- m_document(new BaseTextDocument),
m_parenthesesMatchingEnabled(false),
m_updateTimer(0),
m_formatRange(false),
@@ -2451,7 +2375,6 @@ BaseTextEditorWidgetPrivate::BaseTextEditorWidgetPrivate()
m_linkPressed(false),
m_delayedUpdateTimer(0),
m_editor(0),
- m_actionHack(0),
m_inBlockSelectionMode(false),
m_moveLineUndoHack(false),
m_findScopeVerticalBlockSelectionFirstColumn(-1),
@@ -2471,40 +2394,22 @@ BaseTextEditorWidgetPrivate::~BaseTextEditorWidgetPrivate()
{
}
-void BaseTextEditorWidgetPrivate::setupDocumentSignals(const QSharedPointer<BaseTextDocument> &document)
+void BaseTextEditorWidgetPrivate::setupDocumentSignals()
{
- QSharedPointer<BaseTextDocument> oldDocument = q->baseTextDocument();
- if (!oldDocument.isNull()) {
- q->disconnect(oldDocument->document(), 0, q, 0);
- q->disconnect(oldDocument.data(), 0, q, 0);
- q->disconnect(q, 0, oldDocument.data(), 0);
- }
-
- QTextDocument *doc = document->document();
- BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(doc->documentLayout());
- if (!documentLayout) {
- QTextOption opt = doc->defaultTextOption();
- opt.setTextDirection(Qt::LeftToRight);
- opt.setFlags(opt.flags() | QTextOption::IncludeTrailingSpaces
- | QTextOption::AddSpaceForLineAndParagraphSeparators
- );
- doc->setDefaultTextOption(opt);
- documentLayout = new BaseTextDocumentLayout(doc);
- doc->setDocumentLayout(documentLayout);
- }
-
+ QTextDocument *doc = m_document->document();
q->setDocument(doc);
q->setCursorWidth(2); // Applies to the document layout
+ BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(doc->documentLayout());
+ QTC_CHECK(documentLayout);
QObject::connect(documentLayout, SIGNAL(updateBlock(QTextBlock)), q, SLOT(slotUpdateBlockNotify(QTextBlock)));
QObject::connect(documentLayout, SIGNAL(updateExtraArea()), q, SLOT(slotUpdateExtraArea()));
QObject::connect(q, SIGNAL(requestBlockUpdate(QTextBlock)), documentLayout, SIGNAL(updateBlock(QTextBlock)));
QObject::connect(doc, SIGNAL(modificationChanged(bool)), q, SIGNAL(changed()));
- QObject::connect(q, SIGNAL(changed()), document.data(), SIGNAL(changed()));
QObject::connect(doc, SIGNAL(contentsChange(int,int,int)), q,
SLOT(editorContentsChange(int,int,int)), Qt::DirectConnection);
- QObject::connect(document.data(), SIGNAL(aboutToReload()), q, SLOT(documentAboutToBeReloaded()));
- QObject::connect(document.data(), SIGNAL(reloadFinished(bool)), q, SLOT(documentReloadFinished(bool)));
+ QObject::connect(m_document.data(), SIGNAL(aboutToReload()), q, SLOT(documentAboutToBeReloaded()));
+ QObject::connect(m_document.data(), SIGNAL(reloadFinished(bool)), q, SLOT(documentReloadFinished(bool)));
q->slotUpdateExtraAreaWidth();
}
@@ -2708,7 +2613,7 @@ void BaseTextEditorWidgetPrivate::highlightSearchResults(const QTextBlock &block
l = m_searchExpr.matchedLength();
if (l == 0)
break;
- if ((m_findFlags & Find::FindWholeWords)
+ if ((m_findFlags & Core::FindWholeWords)
&& ((idx && text.at(idx-1).isLetterOrNumber())
|| (idx + l < text.length() && text.at(idx + l).isLetterOrNumber())))
continue;
@@ -4286,6 +4191,15 @@ void BaseTextEditorWidget::dragEnterEvent(QDragEnterEvent *e)
QPlainTextEdit::dragEnterEvent(e);
}
+static void appendMenuActionsFromContext(QMenu *menu, const Core::Id menuContextId)
+{
+ Core::ActionContainer *mcontext = Core::ActionManager::actionContainer(menuContextId);
+ QMenu *contextMenu = mcontext->menu();
+
+ foreach (QAction *action, contextMenu->actions())
+ menu->addAction(action);
+}
+
void BaseTextEditorWidget::showDefaultContextMenu(QContextMenuEvent *e, const Core::Id menuContextId)
{
QMenu menu;
@@ -4560,6 +4474,10 @@ const DisplaySettings &BaseTextEditorWidget::displaySettings() const
return d->m_displaySettings;
}
+const MarginSettings &BaseTextEditorWidget::marginSettings() const
+{
+ return d->m_marginSettings;
+}
void BaseTextEditorWidget::indentOrUnindent(bool doIndent)
{
@@ -4881,19 +4799,19 @@ void BaseTextEditorWidget::markBlocksAsChanged(QList<int> blockNumbers)
}
-void BaseTextEditorWidget::highlightSearchResults(const QString &txt, Find::FindFlags findFlags)
+void BaseTextEditorWidget::highlightSearchResults(const QString &txt, Core::FindFlags findFlags)
{
QString pattern = txt;
// highlighting single characters only if you're searching for whole words
- if (pattern.size() < 2 && !(findFlags & Find::FindWholeWords))
+ if (pattern.size() < 2 && !(findFlags & FindWholeWords))
pattern.clear();
if (d->m_searchExpr.pattern() == pattern)
return;
d->m_searchExpr.setPattern(pattern);
- d->m_searchExpr.setPatternSyntax((findFlags & Find::FindRegularExpression) ?
+ d->m_searchExpr.setPatternSyntax((findFlags & FindRegularExpression) ?
QRegExp::RegExp : QRegExp::FixedString);
- d->m_searchExpr.setCaseSensitivity((findFlags & Find::FindCaseSensitively) ?
+ d->m_searchExpr.setCaseSensitivity((findFlags & FindCaseSensitively) ?
Qt::CaseSensitive : Qt::CaseInsensitive);
d->m_findFlags = findFlags;
@@ -5182,16 +5100,6 @@ void BaseTextEditorWidget::_q_highlightBlocks()
}
}
-void BaseTextEditorWidget::setActionHack(QObject *hack)
-{
- d->m_actionHack = hack;
-}
-
-QObject *BaseTextEditorWidget::actionHack() const
-{
- return d->m_actionHack;
-}
-
void BaseTextEditorWidget::changeEvent(QEvent *e)
{
QPlainTextEdit::changeEvent(e);
@@ -5427,7 +5335,7 @@ void BaseTextEditorWidget::format()
void BaseTextEditorWidget::rewrapParagraph()
{
- const int paragraphWidth = displaySettings().m_wrapColumn;
+ const int paragraphWidth = marginSettings().m_marginColumn;
const QRegExp anyLettersOrNumbers = QRegExp(QLatin1String("\\w"));
const int tabSize = tabSettings().m_tabSize;
@@ -5650,7 +5558,6 @@ void BaseTextEditorWidget::setDisplaySettings(const DisplaySettings &ds)
{
setLineWrapMode(ds.m_textWrapping ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap);
setLineNumbersVisible(ds.m_displayLineNumbers);
- setVisibleWrapColumn(ds.m_showWrapColumn ? ds.m_wrapColumn : 0);
setHighlightCurrentLine(ds.m_highlightCurrentLine);
setRevisionsVisible(ds.m_markTextChanges);
setCenterOnScroll(ds.m_centerCursorOnScroll);
@@ -5680,6 +5587,15 @@ void BaseTextEditorWidget::setDisplaySettings(const DisplaySettings &ds)
extraArea()->update();
}
+void BaseTextEditorWidget::setMarginSettings(const MarginSettings &ms)
+{
+ setVisibleWrapColumn(ms.m_showMargin ? ms.m_marginColumn : 0);
+ d->m_marginSettings = ms;
+
+ viewport()->update();
+ extraArea()->update();
+}
+
void BaseTextEditorWidget::setBehaviorSettings(const TextEditor::BehaviorSettings &bs)
{
d->m_behaviorSettings = bs;
@@ -5811,7 +5727,7 @@ void BaseTextEditorWidget::collectToCircularClipboard()
if (!mimeData)
return;
CircularClipboard *circularClipBoard = CircularClipboard::instance();
- circularClipBoard->collect(duplicateMimeData(mimeData));
+ circularClipBoard->collect(BaseTextEditorWidget::duplicateMimeData(mimeData));
// We want the latest copied content to be the first one to appear on circular paste.
circularClipBoard->toLastCollect();
}
@@ -5827,7 +5743,7 @@ void BaseTextEditorWidget::circularPaste()
{
CircularClipboard *circularClipBoard = CircularClipboard::instance();
if (const QMimeData *clipboardData = QApplication::clipboard()->mimeData()) {
- circularClipBoard->collect(duplicateMimeData(clipboardData));
+ circularClipBoard->collect(BaseTextEditorWidget::duplicateMimeData(clipboardData));
circularClipBoard->toLastCollect();
}
@@ -5835,7 +5751,7 @@ void BaseTextEditorWidget::circularPaste()
return invokeAssist(QuickFix, d->m_clipboardAssistProvider.data());
if (const QMimeData *mimeData = circularClipBoard->next().data()) {
- QApplication::clipboard()->setMimeData(duplicateMimeData(mimeData));
+ QApplication::clipboard()->setMimeData(BaseTextEditorWidget::duplicateMimeData(mimeData));
paste();
}
}
@@ -6069,7 +5985,7 @@ void BaseTextEditorWidget::insertFromMimeData(const QMimeData *source)
setTextCursor(cursor);
}
-QMimeData *BaseTextEditorWidget::duplicateMimeData(const QMimeData *source) const
+QMimeData *BaseTextEditorWidget::duplicateMimeData(const QMimeData *source)
{
Q_ASSERT(source);
@@ -6121,15 +6037,6 @@ QColor BaseTextEditorWidget::replacementPenColor(int blockNumber) const
return QColor();
}
-void BaseTextEditorWidget::appendMenuActionsFromContext(QMenu *menu, const Core::Id menuContextId)
-{
- Core::ActionContainer *mcontext = Core::ActionManager::actionContainer(menuContextId);
- QMenu *contextMenu = mcontext->menu();
-
- foreach (QAction *action, contextMenu->actions())
- menu->addAction(action);
-}
-
void BaseTextEditorWidget::appendStandardContextMenuActions(QMenu *menu)
{
menu->addSeparator();
@@ -6147,7 +6054,7 @@ void BaseTextEditorWidget::appendStandardContextMenuActions(QMenu *menu)
if (a && a->isEnabled())
menu->addAction(a);
- QSharedPointer<BaseTextDocument> doc = baseTextDocument();
+ BaseTextDocument *doc = baseTextDocument();
if (doc->codec()->name() == QByteArray("UTF-8") && doc->supportsUtf8Bom()) {
a = Core::ActionManager::command(Constants::SWITCH_UTF8BOM)->action();
if (a && a->isEnabled()) {
@@ -6164,11 +6071,10 @@ BaseTextEditor::BaseTextEditor(BaseTextEditorWidget *editor)
: m_editorWidget(editor)
{
setWidget(m_editorWidget);
- using namespace Find;
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
BaseTextFind *baseTextFind = new BaseTextFind(editor);
- connect(baseTextFind, SIGNAL(highlightAll(QString,Find::FindFlags)),
- editor, SLOT(highlightSearchResults(QString,Find::FindFlags)));
+ connect(baseTextFind, SIGNAL(highlightAll(QString,Core::FindFlags)),
+ editor, SLOT(highlightSearchResults(QString,Core::FindFlags)));
connect(baseTextFind, SIGNAL(findScopeChanged(QTextCursor,QTextCursor,int,int)),
editor, SLOT(setFindScope(QTextCursor,QTextCursor,int,int)));
aggregate->add(baseTextFind);
@@ -6340,7 +6246,7 @@ void BaseTextEditor::setFileEncodingLabelText(const QString &text)
QString BaseTextEditor::contextHelpId() const
{
if (m_contextHelpId.isEmpty())
- emit const_cast<BaseTextEditor*>(this)->contextHelpIdRequested(m_editorWidget->editor(),
+ emit const_cast<BaseTextEditor*>(this)->contextHelpIdRequested(const_cast<BaseTextEditor*>(this),
m_editorWidget->textCursor().position());
return m_contextHelpId;
}
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index d464d879b6..d1105b3658 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -30,11 +30,12 @@
#ifndef BASETEXTEDITOR_H
#define BASETEXTEDITOR_H
+#include "basetextdocument.h"
#include "itexteditor.h"
#include "codeassist/assistenums.h"
#include <coreplugin/editormanager/editormanager.h>
-#include <find/ifindsupport.h>
+#include <coreplugin/find/ifindsupport.h>
#include <QPlainTextEdit>
#include <QSharedPointer>
@@ -69,12 +70,12 @@ namespace Internal {
class ITextMarkable;
-class BaseTextDocument;
class BaseTextEditor;
class FontSettings;
class BehaviorSettings;
class CompletionSettings;
class DisplaySettings;
+class MarginSettings;
class TypingSettings;
class StorageSettings;
class Indenter;
@@ -129,34 +130,26 @@ class TEXTEDITOR_EXPORT BaseTextEditorWidget : public QPlainTextEdit
Q_PROPERTY(int verticalBlockSelectionLastColumn READ verticalBlockSelectionLastColumn)
public:
- BaseTextEditorWidget(QWidget *parent);
+ BaseTextEditorWidget(QWidget *parent = 0);
+ BaseTextEditorWidget(BaseTextDocument *doc, QWidget *parent = 0);
+ BaseTextEditorWidget(BaseTextEditorWidget *other);
~BaseTextEditorWidget();
- const Utils::ChangeSet &changeSet() const;
- void setChangeSet(const Utils::ChangeSet &changeSet);
+ BaseTextDocument *baseTextDocument() const;
- // EditorInterface
- Core::IDocument *editorDocument() const;
+ // IEditor
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName);
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
-
void gotoLine(int line, int column = 0);
-
int position(ITextEditor::PositionOperation posOp = ITextEditor::Current,
int at = -1) const;
void convertPosition(int pos, int *line, int *column) const;
BaseTextEditor *editor() const;
- ITextMarkable *markableInterface() const;
void print(QPrinter *);
- void setSuggestedFileName(const QString &suggestedFileName);
- QString mimeType() const;
- virtual void setMimeType(const QString &mt);
-
- void appendMenuActionsFromContext(QMenu *menu, Core::Id menuContextId);
void appendStandardContextMenuActions(QMenu *menu);
// Works only in conjunction with a syntax highlighter that puts
@@ -209,9 +202,6 @@ public:
int columnCount() const;
int rowCount() const;
- void setActionHack(QObject *hack);
- QObject *actionHack() const;
-
void setReadOnly(bool b);
void setTextCursor(const QTextCursor &cursor);
@@ -238,7 +228,7 @@ public:
virtual IAssistInterface *createAssistInterface(AssistKind assistKind,
AssistReason assistReason) const;
- QMimeData *duplicateMimeData(const QMimeData *source) const;
+ static QMimeData *duplicateMimeData(const QMimeData *source);
static QString msgTextTooLarge(quint64 size);
@@ -327,9 +317,6 @@ signals:
void assistFinished();
void readOnlyChanged();
- // ITextEditor
- void contentsChanged();
-
protected:
bool event(QEvent *e);
void keyPressEvent(QKeyEvent *e);
@@ -358,22 +345,14 @@ private:
void updateCannotDecodeInfo();
void collectToCircularClipboard();
-public:
- void duplicateFrom(BaseTextEditorWidget *editor);
-
protected:
- QSharedPointer<BaseTextDocument> baseTextDocument() const;
- void setBaseTextDocument(const QSharedPointer<BaseTextDocument> &doc);
-
- void setDefaultPath(const QString &defaultPath);
-
virtual BaseTextEditor *createEditor() = 0;
private slots:
void editorContentsChange(int position, int charsRemoved, int charsAdded);
void documentAboutToBeReloaded();
void documentReloadFinished(bool success);
- void highlightSearchResults(const QString &txt, Find::FindFlags findFlags);
+ void highlightSearchResults(const QString &txt, Core::FindFlags findFlags);
void setFindScope(const QTextCursor &start, const QTextCursor &end, int, int);
bool inFindScope(const QTextCursor &cursor);
bool inFindScope(int selectionStart, int selectionEnd);
@@ -401,6 +380,7 @@ public:
void setCodeStyle(ICodeStylePreferences *settings);
const DisplaySettings &displaySettings() const;
+ const MarginSettings &marginSettings() const;
void markBlocksAsChanged(QList<int> blockNumbers);
@@ -441,6 +421,7 @@ public slots:
void setFontSettingsIfVisible(const TextEditor::FontSettings &);
virtual void setTabSettings(const TextEditor::TabSettings &);
virtual void setDisplaySettings(const TextEditor::DisplaySettings &);
+ virtual void setMarginSettings(const TextEditor::MarginSettings &);
virtual void setBehaviorSettings(const TextEditor::BehaviorSettings &);
virtual void setTypingSettings(const TextEditor::TypingSettings &);
virtual void setStorageSettings(const TextEditor::StorageSettings &);
@@ -540,6 +521,7 @@ signals:
void requestBlockUpdate(const QTextBlock &);
private:
+ void ctor(const QSharedPointer<BaseTextDocument> &doc);
void indentOrUnindent(bool doIndent);
void handleHomeKey(bool anchor);
void handleBackspaceKey();
@@ -597,9 +579,10 @@ public:
friend class BaseTextEditorWidget;
BaseTextEditorWidget *editorWidget() const { return m_editorWidget; }
+ BaseTextDocument *baseTextDocument() { return m_editorWidget->baseTextDocument(); }
// IEditor
- Core::IDocument *document() { return m_editorWidget->editorDocument(); }
+ Core::IDocument *document() { return m_editorWidget->baseTextDocument(); }
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
QByteArray saveState() const { return m_editorWidget->saveState(); }
@@ -624,8 +607,6 @@ public:
QString selectedText() const;
- ITextMarkable *markableInterface() { return m_editorWidget->markableInterface(); }
-
QString contextHelpId() const; // from IContext
// ITextEditor
diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h
index c6d823b8ed..7af359af12 100644
--- a/src/plugins/texteditor/basetexteditor_p.h
+++ b/src/plugins/texteditor/basetexteditor_p.h
@@ -33,6 +33,7 @@
#include "basetexteditor.h"
#include "behaviorsettings.h"
#include "displaysettings.h"
+#include "marginsettings.h"
#include "fontsettings.h"
#include "refactoroverlay.h"
@@ -49,7 +50,6 @@
namespace TextEditor {
class BaseTextDocument;
-class TextEditorActionHandler;
class CodeAssistant;
namespace Internal {
@@ -102,8 +102,7 @@ public:
BaseTextEditorWidgetPrivate();
~BaseTextEditorWidgetPrivate();
- void setupBasicEditActions(TextEditorActionHandler *actionHandler);
- void setupDocumentSignals(const QSharedPointer<BaseTextDocument> &document);
+ void setupDocumentSignals();
void updateLineSelectionColor();
void print(QPrinter *printer);
@@ -126,8 +125,6 @@ public:
bool m_parenthesesMatchingEnabled;
QTimer *m_updateTimer;
- Utils::ChangeSet m_changeSet;
-
// parentheses matcher
bool m_formatRange;
QTextCharFormat m_matchFormat;
@@ -140,6 +137,7 @@ public:
Core::Id m_tabSettingsId;
ICodeStylePreferences *m_codeStylePreferences;
DisplaySettings m_displaySettings;
+ MarginSettings m_marginSettings;
FontSettings m_fontSettings;
BehaviorSettings m_behaviorSettings;
@@ -185,7 +183,7 @@ public:
QTextCharFormat m_ifdefedOutFormat;
QRegExp m_searchExpr;
- Find::FindFlags m_findFlags;
+ Core::FindFlags m_findFlags;
QTextCharFormat m_searchResultFormat;
QTextCharFormat m_searchScopeFormat;
QTextCharFormat m_currentLineFormat;
@@ -195,8 +193,6 @@ public:
BaseTextEditor *m_editor;
- QObject *m_actionHack;
-
QList<QTextEdit::ExtraSelection> m_extraSelections[BaseTextEditorWidget::NExtraSelectionKinds];
// block selection mode
diff --git a/src/plugins/texteditor/basetextmark.cpp b/src/plugins/texteditor/basetextmark.cpp
index f7ccdb7f4d..6d4e06d913 100644
--- a/src/plugins/texteditor/basetextmark.cpp
+++ b/src/plugins/texteditor/basetextmark.cpp
@@ -60,14 +60,11 @@ void BaseTextMarkRegistry::add(BaseTextMark *mark)
{
m_marks[FileName::fromString(mark->fileName())].insert(mark);
DocumentModel *documentModel = EditorManager::documentModel();
- IDocument *document = documentModel->documentForFilePath(mark->fileName());
+ ITextEditorDocument *document
+ = qobject_cast<ITextEditorDocument*>(documentModel->documentForFilePath(mark->fileName()));
if (!document)
return;
- // TODO: markableInterface should be moved to ITextEditorDocument
- if (ITextEditor *textEditor
- = qobject_cast<ITextEditor *>(documentModel->editorsForDocument(document).first())) {
- textEditor->markableInterface()->addMark(mark);
- }
+ document->markableInterface()->addMark(mark);
}
bool BaseTextMarkRegistry::remove(BaseTextMark *mark)
@@ -77,16 +74,14 @@ bool BaseTextMarkRegistry::remove(BaseTextMark *mark)
void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor)
{
- ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor);
- if (!textEditor)
+ ITextEditorDocument *document = qobject_cast<ITextEditorDocument *>(editor ? editor->document() : 0);
+ if (!document)
return;
- if (!m_marks.contains(FileName::fromString(editor->document()->filePath())))
+ if (!m_marks.contains(FileName::fromString(document->filePath())))
return;
- foreach (BaseTextMark *mark, m_marks.value(FileName::fromString(editor->document()->filePath()))) {
- ITextMarkable *markableInterface = textEditor->markableInterface();
- markableInterface->addMark(mark);
- }
+ foreach (BaseTextMark *mark, m_marks.value(FileName::fromString(document->filePath())))
+ document->markableInterface()->addMark(mark);
}
void BaseTextMarkRegistry::documentRenamed(IDocument *document, const
@@ -102,7 +97,7 @@ void BaseTextMarkRegistry::documentRenamed(IDocument *document, const
return;
QSet<BaseTextMark *> toBeMoved;
- foreach (ITextMark *mark, baseTextDocument->documentMarker()->marks())
+ foreach (ITextMark *mark, baseTextDocument->markableInterface()->marks())
if (BaseTextMark *baseTextMark = dynamic_cast<BaseTextMark *>(mark))
toBeMoved.insert(baseTextMark);
diff --git a/src/plugins/texteditor/behaviorsettingspage.cpp b/src/plugins/texteditor/behaviorsettingspage.cpp
index c232fc7485..2933e5fb99 100644
--- a/src/plugins/texteditor/behaviorsettingspage.cpp
+++ b/src/plugins/texteditor/behaviorsettingspage.cpp
@@ -49,6 +49,7 @@
#include <qmljseditor/qmljseditorconstants.h>
#include <qmljstools/qmljstoolsconstants.h>
+#include <QPointer>
#include <QSettings>
#include <QTextCodec>
@@ -59,6 +60,7 @@ struct BehaviorSettingsPage::BehaviorSettingsPagePrivate
explicit BehaviorSettingsPagePrivate(const BehaviorSettingsPageParameters &p);
const BehaviorSettingsPageParameters m_parameters;
+ QPointer<QWidget> m_widget;
Internal::Ui::BehaviorSettingsPage *m_page;
void init();
@@ -70,8 +72,6 @@ struct BehaviorSettingsPage::BehaviorSettingsPagePrivate
StorageSettings m_storageSettings;
BehaviorSettings m_behaviorSettings;
ExtraEncodingSettings m_extraEncodingSettings;
-
- QString m_searchKeywords;
};
BehaviorSettingsPage::BehaviorSettingsPagePrivate::BehaviorSettingsPagePrivate
@@ -114,30 +114,28 @@ BehaviorSettingsPage::~BehaviorSettingsPage()
delete d;
}
-QWidget *BehaviorSettingsPage::createPage(QWidget *parent)
+QWidget *BehaviorSettingsPage::widget()
{
- QWidget *w = new QWidget(parent);
- d->m_page = new Internal::Ui::BehaviorSettingsPage;
- d->m_page->setupUi(w);
- if (Utils::HostOsInfo::isMacHost())
- d->m_page->gridLayout->setContentsMargins(-1, 0, -1, 0); // don't ask.
- d->m_pageCodeStyle = new SimpleCodeStylePreferences(w);
- d->m_pageCodeStyle->setDelegatingPool(d->m_codeStyle->delegatingPool());
- d->m_pageCodeStyle->setTabSettings(d->m_codeStyle->tabSettings());
- d->m_pageCodeStyle->setCurrentDelegate(d->m_codeStyle->currentDelegate());
- d->m_page->behaviorWidget->setCodeStyle(d->m_pageCodeStyle);
-
- TabSettingsWidget *tabSettingsWidget = d->m_page->behaviorWidget->tabSettingsWidget();
- tabSettingsWidget->setCodingStyleWarningVisible(true);
- connect(tabSettingsWidget, SIGNAL(codingStyleLinkClicked(TextEditor::TabSettingsWidget::CodingStyleLink)),
- this, SLOT(openCodingStylePreferences(TextEditor::TabSettingsWidget::CodingStyleLink)));
-
- settingsToUI();
-
- if (d->m_searchKeywords.isEmpty())
- d->m_searchKeywords = d->m_page->behaviorWidget->collectUiKeywords();
-
- return w;
+ if (!d->m_widget) {
+ d->m_widget = new QWidget;
+ d->m_page = new Internal::Ui::BehaviorSettingsPage;
+ d->m_page->setupUi(d->m_widget);
+ if (Utils::HostOsInfo::isMacHost())
+ d->m_page->gridLayout->setContentsMargins(-1, 0, -1, 0); // don't ask.
+ d->m_pageCodeStyle = new SimpleCodeStylePreferences(d->m_widget);
+ d->m_pageCodeStyle->setDelegatingPool(d->m_codeStyle->delegatingPool());
+ d->m_pageCodeStyle->setTabSettings(d->m_codeStyle->tabSettings());
+ d->m_pageCodeStyle->setCurrentDelegate(d->m_codeStyle->currentDelegate());
+ d->m_page->behaviorWidget->setCodeStyle(d->m_pageCodeStyle);
+
+ TabSettingsWidget *tabSettingsWidget = d->m_page->behaviorWidget->tabSettingsWidget();
+ tabSettingsWidget->setCodingStyleWarningVisible(true);
+ connect(tabSettingsWidget, SIGNAL(codingStyleLinkClicked(TextEditor::TabSettingsWidget::CodingStyleLink)),
+ this, SLOT(openCodingStylePreferences(TextEditor::TabSettingsWidget::CodingStyleLink)));
+
+ settingsToUI();
+ }
+ return d->m_widget;
}
void BehaviorSettingsPage::apply()
@@ -227,6 +225,7 @@ void BehaviorSettingsPage::settingsToUI()
void BehaviorSettingsPage::finish()
{
+ delete d->m_widget;
if (!d->m_page) // page was never shown
return;
delete d->m_page;
@@ -263,11 +262,6 @@ const ExtraEncodingSettings &BehaviorSettingsPage::extraEncodingSettings() const
return d->m_extraEncodingSettings;
}
-bool BehaviorSettingsPage::matches(const QString &s) const
-{
- return d->m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
void BehaviorSettingsPage::openCodingStylePreferences(TabSettingsWidget::CodingStyleLink link)
{
diff --git a/src/plugins/texteditor/behaviorsettingspage.h b/src/plugins/texteditor/behaviorsettingspage.h
index d8126c4e0f..ba93f2aa51 100644
--- a/src/plugins/texteditor/behaviorsettingspage.h
+++ b/src/plugins/texteditor/behaviorsettingspage.h
@@ -62,10 +62,9 @@ public:
~BehaviorSettingsPage();
// IOptionsPage
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &s) const;
ICodeStylePreferences *codeStyle() const;
CodeStylePool *codeStylePool() const;
diff --git a/src/plugins/texteditor/behaviorsettingswidget.cpp b/src/plugins/texteditor/behaviorsettingswidget.cpp
index 218f0f8eb4..b7b9948e59 100644
--- a/src/plugins/texteditor/behaviorsettingswidget.cpp
+++ b/src/plugins/texteditor/behaviorsettingswidget.cpp
@@ -223,35 +223,6 @@ void BehaviorSettingsWidget::assignedExtraEncodingSettings(
(ExtraEncodingSettings::Utf8BomSetting)d->m_ui.utf8BomBox->currentIndex();
}
-QString BehaviorSettingsWidget::collectUiKeywords() const
-{
- static const QLatin1Char sep(' ');
- QString keywords;
- QTextStream(&keywords)
- << sep << d->m_ui.tabPreferencesWidget->searchKeywords()
- << sep << d->m_ui.autoIndent->text()
- << sep << d->m_ui.smartBackspaceLabel->text()
- << sep << d->m_ui.tabKeyBehaviorLabel->text()
- << sep << d->m_ui.cleanWhitespace->text()
- << sep << d->m_ui.inEntireDocument->text()
- << sep << d->m_ui.cleanIndentation->text()
- << sep << d->m_ui.addFinalNewLine->text()
- << sep << d->m_ui.encodingLabel->text()
- << sep << d->m_ui.utf8BomLabel->text()
- << sep << d->m_ui.mouseNavigation->text()
- << sep << d->m_ui.scrollWheelZooming->text()
- << sep << d->m_ui.helpTooltipsLabel->text()
- << sep << d->m_ui.constrainTooltipsBox->itemText(0)
- << sep << d->m_ui.constrainTooltipsBox->itemText(1)
- << sep << d->m_ui.camelCaseNavigation->text()
- << sep << d->m_ui.keyboardTooltips->text()
- << sep << d->m_ui.groupBoxStorageSettings->title()
- << sep << d->m_ui.groupBoxEncodings->title()
- << sep << d->m_ui.groupBoxMouse->title();
- keywords.remove(QLatin1Char('&'));
- return keywords;
-}
-
TabSettingsWidget *BehaviorSettingsWidget::tabSettingsWidget() const
{
return d->m_ui.tabPreferencesWidget->tabSettingsWidget();
diff --git a/src/plugins/texteditor/behaviorsettingswidget.h b/src/plugins/texteditor/behaviorsettingswidget.h
index 11aac48594..b840d67534 100644
--- a/src/plugins/texteditor/behaviorsettingswidget.h
+++ b/src/plugins/texteditor/behaviorsettingswidget.h
@@ -76,8 +76,6 @@ public:
void setAssignedExtraEncodingSettings(const ExtraEncodingSettings &encodingSettings);
void assignedExtraEncodingSettings(ExtraEncodingSettings *encodingSettings) const;
- QString collectUiKeywords() const;
-
TabSettingsWidget *tabSettingsWidget() const;
signals:
diff --git a/src/plugins/texteditor/behaviorsettingswidget.ui b/src/plugins/texteditor/behaviorsettingswidget.ui
index 324313b74a..5aeb0f37c5 100644
--- a/src/plugins/texteditor/behaviorsettingswidget.ui
+++ b/src/plugins/texteditor/behaviorsettingswidget.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>802</width>
- <height>416</height>
+ <height>441</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
@@ -207,7 +207,7 @@ Specifies how backspace interacts with indentation.
</sizepolicy>
</property>
<property name="toolTip">
- <string>Clean whitespace in entire document instead of only for changed parts.</string>
+ <string>Cleans whitespace in entire document instead of only for changed parts.</string>
</property>
<property name="text">
<string>In entire &amp;document</string>
@@ -220,7 +220,7 @@ Specifies how backspace interacts with indentation.
<bool>false</bool>
</property>
<property name="toolTip">
- <string>Correct leading whitespace according to tab settings.</string>
+ <string>Corrects leading whitespace according to tab settings.</string>
</property>
<property name="text">
<string>Clean indentation</string>
@@ -230,7 +230,7 @@ Specifies how backspace interacts with indentation.
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="addFinalNewLine">
<property name="toolTip">
- <string>Always write a newline character at the end of the file.</string>
+ <string>Always writes a newline character at the end of the file.</string>
</property>
<property name="text">
<string>&amp;Ensure newline at end of file</string>
diff --git a/src/plugins/texteditor/circularclipboardassist.cpp b/src/plugins/texteditor/circularclipboardassist.cpp
index 45a7e4d303..98db5f988d 100644
--- a/src/plugins/texteditor/circularclipboardassist.cpp
+++ b/src/plugins/texteditor/circularclipboardassist.cpp
@@ -73,7 +73,8 @@ public:
}
//Copy the selected item
- QApplication::clipboard()->setMimeData(editwidget->duplicateMimeData(m_mimeData.data()));
+ QApplication::clipboard()->setMimeData(
+ BaseTextEditorWidget::duplicateMimeData(m_mimeData.data()));
//Paste
editwidget->paste();
diff --git a/src/plugins/texteditor/codeassist/basicproposalitem.cpp b/src/plugins/texteditor/codeassist/basicproposalitem.cpp
index 6b815fe5fe..85010d1069 100644
--- a/src/plugins/texteditor/codeassist/basicproposalitem.cpp
+++ b/src/plugins/texteditor/codeassist/basicproposalitem.cpp
@@ -123,7 +123,7 @@ void BasicProposalItem::applyContextualContent(BaseTextEditor *editor, int baseP
void BasicProposalItem::applySnippet(BaseTextEditor *editor, int basePosition) const
{
- BaseTextEditorWidget *editorWidget = static_cast<BaseTextEditorWidget *>(editor->widget());
+ BaseTextEditorWidget *editorWidget = editor->editorWidget();
QTextCursor tc = editorWidget->textCursor();
tc.setPosition(basePosition, QTextCursor::KeepAnchor);
editorWidget->insertCodeSnippet(tc, data().toString());
diff --git a/src/plugins/texteditor/codeassist/codeassistant.cpp b/src/plugins/texteditor/codeassist/codeassistant.cpp
index d2618bc5ea..4d768a369e 100644
--- a/src/plugins/texteditor/codeassist/codeassistant.cpp
+++ b/src/plugins/texteditor/codeassist/codeassistant.cpp
@@ -44,11 +44,11 @@
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
-#include <QObject>
+#include <QKeyEvent>
#include <QList>
+#include <QObject>
+#include <QScopedPointer>
#include <QTimer>
-#include <QDebug>
-#include <QKeyEvent>
using namespace TextEditor;
using namespace Internal;
@@ -185,6 +185,8 @@ void CodeAssistantPrivate::configure(BaseTextEditor *textEditor)
filterEditorSpecificProviders(&m_quickFixProviders, m_textEditor->id());
m_textEditor->editorWidget()->installEventFilter(this);
+ connect(m_textEditor->baseTextDocument(),SIGNAL(mimeTypeChanged()),
+ m_q, SLOT(reconfigure()));
}
void CodeAssistantPrivate::reconfigure()
diff --git a/src/plugins/texteditor/displaysettings.cpp b/src/plugins/texteditor/displaysettings.cpp
index e54e1082bf..c90d0061b7 100644
--- a/src/plugins/texteditor/displaysettings.cpp
+++ b/src/plugins/texteditor/displaysettings.cpp
@@ -34,8 +34,6 @@
static const char displayLineNumbersKey[] = "DisplayLineNumbers";
static const char textWrappingKey[] = "TextWrapping";
-static const char showWrapColumnKey[] = "ShowWrapColumn";
-static const char wrapColumnKey[] = "WrapColumn";
static const char visualizeWhitespaceKey[] = "VisualizeWhitespace";
static const char displayFoldingMarkersKey[] = "DisplayFoldingMarkers";
static const char highlightCurrentLineKey[] = "HighlightCurrentLine2Key";
@@ -54,8 +52,6 @@ namespace TextEditor {
DisplaySettings::DisplaySettings() :
m_displayLineNumbers(true),
m_textWrapping(false),
- m_showWrapColumn(false),
- m_wrapColumn(80),
m_visualizeWhitespace(false),
m_displayFoldingMarkers(true),
m_highlightCurrentLine(false),
@@ -79,8 +75,6 @@ void DisplaySettings::toSettings(const QString &category, QSettings *s) const
s->beginGroup(group);
s->setValue(QLatin1String(displayLineNumbersKey), m_displayLineNumbers);
s->setValue(QLatin1String(textWrappingKey), m_textWrapping);
- s->setValue(QLatin1String(showWrapColumnKey), m_showWrapColumn);
- s->setValue(QLatin1String(wrapColumnKey), m_wrapColumn);
s->setValue(QLatin1String(visualizeWhitespaceKey), m_visualizeWhitespace);
s->setValue(QLatin1String(displayFoldingMarkersKey), m_displayFoldingMarkers);
s->setValue(QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine);
@@ -106,8 +100,6 @@ void DisplaySettings::fromSettings(const QString &category, const QSettings *s)
m_displayLineNumbers = s->value(group + QLatin1String(displayLineNumbersKey), m_displayLineNumbers).toBool();
m_textWrapping = s->value(group + QLatin1String(textWrappingKey), m_textWrapping).toBool();
- m_showWrapColumn = s->value(group + QLatin1String(showWrapColumnKey), m_showWrapColumn).toBool();
- m_wrapColumn = s->value(group + QLatin1String(wrapColumnKey), m_wrapColumn).toInt();
m_visualizeWhitespace = s->value(group + QLatin1String(visualizeWhitespaceKey), m_visualizeWhitespace).toBool();
m_displayFoldingMarkers = s->value(group + QLatin1String(displayFoldingMarkersKey), m_displayFoldingMarkers).toBool();
m_highlightCurrentLine = s->value(group + QLatin1String(highlightCurrentLineKey), m_highlightCurrentLine).toBool();
@@ -125,8 +117,6 @@ bool DisplaySettings::equals(const DisplaySettings &ds) const
{
return m_displayLineNumbers == ds.m_displayLineNumbers
&& m_textWrapping == ds.m_textWrapping
- && m_showWrapColumn == ds.m_showWrapColumn
- && m_wrapColumn == ds.m_wrapColumn
&& m_visualizeWhitespace == ds.m_visualizeWhitespace
&& m_displayFoldingMarkers == ds.m_displayFoldingMarkers
&& m_highlightCurrentLine == ds.m_highlightCurrentLine
diff --git a/src/plugins/texteditor/displaysettings.h b/src/plugins/texteditor/displaysettings.h
index 0ed9a0f031..4365e3d32c 100644
--- a/src/plugins/texteditor/displaysettings.h
+++ b/src/plugins/texteditor/displaysettings.h
@@ -48,8 +48,6 @@ public:
bool m_displayLineNumbers;
bool m_textWrapping;
- bool m_showWrapColumn;
- int m_wrapColumn;
bool m_visualizeWhitespace;
bool m_displayFoldingMarkers;
bool m_highlightCurrentLine;
diff --git a/src/plugins/texteditor/displaysettingspage.cpp b/src/plugins/texteditor/displaysettingspage.cpp
index 9f3adbef4e..60cbb976aa 100644
--- a/src/plugins/texteditor/displaysettingspage.cpp
+++ b/src/plugins/texteditor/displaysettingspage.cpp
@@ -29,10 +29,12 @@
#include "displaysettingspage.h"
#include "displaysettings.h"
+#include "marginsettings.h"
#include "ui_displaysettingspage.h"
#include <coreplugin/icore.h>
+#include <QPointer>
#include <QTextStream>
using namespace TextEditor;
@@ -42,9 +44,10 @@ struct DisplaySettingsPage::DisplaySettingsPagePrivate
explicit DisplaySettingsPagePrivate(const DisplaySettingsPageParameters &p);
const DisplaySettingsPageParameters m_parameters;
+ QPointer<QWidget> m_widget;
Internal::Ui::DisplaySettingsPage *m_page;
DisplaySettings m_displaySettings;
- QString m_searchKeywords;
+ MarginSettings m_marginSettings;
};
DisplaySettingsPage::DisplaySettingsPagePrivate::DisplaySettingsPagePrivate
@@ -52,6 +55,7 @@ DisplaySettingsPage::DisplaySettingsPagePrivate::DisplaySettingsPagePrivate
: m_parameters(p), m_page(0)
{
m_displaySettings.fromSettings(m_parameters.settingsPrefix, Core::ICore::settings());
+ m_marginSettings.fromSettings(m_parameters.settingsPrefix, Core::ICore::settings());
}
DisplaySettingsPage::DisplaySettingsPage(const DisplaySettingsPageParameters &p,
@@ -68,28 +72,15 @@ DisplaySettingsPage::~DisplaySettingsPage()
delete d;
}
-QWidget *DisplaySettingsPage::createPage(QWidget *parent)
+QWidget *DisplaySettingsPage::widget()
{
- QWidget *w = new QWidget(parent);
- d->m_page = new Internal::Ui::DisplaySettingsPage;
- d->m_page->setupUi(w);
- settingsToUI();
- if (d->m_searchKeywords.isEmpty()) {
- QTextStream(&d->m_searchKeywords) << d->m_page->displayLineNumbers->text()
- << ' ' << d->m_page->highlightCurrentLine->text()
- << ' ' << d->m_page->displayFoldingMarkers->text()
- << ' ' << d->m_page->highlightBlocks->text()
- << ' ' << d->m_page->visualizeWhitespace->text()
- << ' ' << d->m_page->animateMatchingParentheses->text()
- << ' ' << d->m_page->highlightMatchingParentheses->text()
- << ' ' << d->m_page->enableTextWrapping->text()
- << ' ' << d->m_page->autoFoldFirstComment->text()
- << ' ' << d->m_page->centerOnScroll->text()
- << ' ' << d->m_page->openLinksInNextSplit->text()
- << ' ' << d->m_page->displayFileEncoding->text();
- d->m_searchKeywords.remove(QLatin1Char('&'));
+ if (!d->m_widget) {
+ d->m_widget = new QWidget;
+ d->m_page = new Internal::Ui::DisplaySettingsPage;
+ d->m_page->setupUi(d->m_widget);
+ settingsToUI();
}
- return w;
+ return d->m_widget;
}
void DisplaySettingsPage::apply()
@@ -97,25 +88,28 @@ void DisplaySettingsPage::apply()
if (!d->m_page) // page was never shown
return;
DisplaySettings newDisplaySettings;
+ MarginSettings newMarginSettings;
- settingsFromUI(newDisplaySettings);
- setDisplaySettings(newDisplaySettings);
+ settingsFromUI(newDisplaySettings, newMarginSettings);
+ setDisplaySettings(newDisplaySettings, newMarginSettings);
}
void DisplaySettingsPage::finish()
{
+ delete d->m_widget;
if (!d->m_page) // page was never shown
return;
delete d->m_page;
d->m_page = 0;
}
-void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const
+void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings,
+ MarginSettings &marginSettings) const
{
displaySettings.m_displayLineNumbers = d->m_page->displayLineNumbers->isChecked();
displaySettings.m_textWrapping = d->m_page->enableTextWrapping->isChecked();
- displaySettings.m_showWrapColumn = d->m_page->showWrapColumn->isChecked();
- displaySettings.m_wrapColumn = d->m_page->wrapColumn->value();
+ marginSettings.m_showMargin = d->m_page->showWrapColumn->isChecked();
+ marginSettings.m_marginColumn = d->m_page->wrapColumn->value();
displaySettings.m_visualizeWhitespace = d->m_page->visualizeWhitespace->isChecked();
displaySettings.m_displayFoldingMarkers = d->m_page->displayFoldingMarkers->isChecked();
displaySettings.m_highlightCurrentLine = d->m_page->highlightCurrentLine->isChecked();
@@ -132,10 +126,11 @@ void DisplaySettingsPage::settingsFromUI(DisplaySettings &displaySettings) const
void DisplaySettingsPage::settingsToUI()
{
const DisplaySettings &displaySettings = d->m_displaySettings;
+ const MarginSettings &marginSettings = d->m_marginSettings;
d->m_page->displayLineNumbers->setChecked(displaySettings.m_displayLineNumbers);
d->m_page->enableTextWrapping->setChecked(displaySettings.m_textWrapping);
- d->m_page->showWrapColumn->setChecked(displaySettings.m_showWrapColumn);
- d->m_page->wrapColumn->setValue(displaySettings.m_wrapColumn);
+ d->m_page->showWrapColumn->setChecked(marginSettings.m_showMargin);
+ d->m_page->wrapColumn->setValue(marginSettings.m_marginColumn);
d->m_page->visualizeWhitespace->setChecked(displaySettings.m_visualizeWhitespace);
d->m_page->displayFoldingMarkers->setChecked(displaySettings.m_displayFoldingMarkers);
d->m_page->highlightCurrentLine->setChecked(displaySettings.m_highlightCurrentLine);
@@ -154,7 +149,13 @@ const DisplaySettings &DisplaySettingsPage::displaySettings() const
return d->m_displaySettings;
}
-void DisplaySettingsPage::setDisplaySettings(const DisplaySettings &newDisplaySettings)
+const MarginSettings &DisplaySettingsPage::marginSettings() const
+{
+ return d->m_marginSettings;
+}
+
+void DisplaySettingsPage::setDisplaySettings(const DisplaySettings &newDisplaySettings,
+ const MarginSettings &newMarginSettings)
{
if (newDisplaySettings != d->m_displaySettings) {
d->m_displaySettings = newDisplaySettings;
@@ -162,9 +163,11 @@ void DisplaySettingsPage::setDisplaySettings(const DisplaySettings &newDisplaySe
emit displaySettingsChanged(newDisplaySettings);
}
-}
-bool DisplaySettingsPage::matches(const QString &s) const
-{
- return d->m_searchKeywords.contains(s, Qt::CaseInsensitive);
+ if (newMarginSettings != d->m_marginSettings) {
+ d->m_marginSettings = newMarginSettings;
+ d->m_marginSettings.toSettings(d->m_parameters.settingsPrefix, Core::ICore::settings());
+
+ emit marginSettingsChanged(newMarginSettings);
+ }
}
diff --git a/src/plugins/texteditor/displaysettingspage.h b/src/plugins/texteditor/displaysettingspage.h
index 7c0483406e..fbe742ce3a 100644
--- a/src/plugins/texteditor/displaysettingspage.h
+++ b/src/plugins/texteditor/displaysettingspage.h
@@ -37,6 +37,7 @@
namespace TextEditor {
class DisplaySettings;
+class MarginSettings;
class DisplaySettingsPageParameters
{
@@ -55,20 +56,21 @@ public:
~DisplaySettingsPage();
// IOptionsPage
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &s) const;
const DisplaySettings &displaySettings() const;
+ const MarginSettings &marginSettings() const;
signals:
void displaySettingsChanged(const TextEditor::DisplaySettings &);
+ void marginSettingsChanged(const TextEditor::MarginSettings &);
private:
- void settingsFromUI(DisplaySettings &displaySettings) const;
+ void settingsFromUI(DisplaySettings &displaySettings, MarginSettings &marginSettings) const;
void settingsToUI();
- void setDisplaySettings(const DisplaySettings &);
+ void setDisplaySettings(const DisplaySettings &, const MarginSettings &newMarginSettings);
struct DisplaySettingsPagePrivate;
DisplaySettingsPagePrivate *d;
diff --git a/src/plugins/texteditor/findincurrentfile.cpp b/src/plugins/texteditor/findincurrentfile.cpp
index c8a93106da..a10c14a3ac 100644
--- a/src/plugins/texteditor/findincurrentfile.cpp
+++ b/src/plugins/texteditor/findincurrentfile.cpp
@@ -37,7 +37,6 @@
#include <QSettings>
-using namespace Find;
using namespace TextEditor;
using namespace TextEditor::Internal;
@@ -64,7 +63,8 @@ Utils::FileIterator *FindInCurrentFile::files(const QStringList &nameFilters,
{
Q_UNUSED(nameFilters)
QString fileName = additionalParameters.toString();
- QMap<QString, QTextCodec *> openEditorEncodings = ITextEditor::openedTextDocumentEncodings();
+ QMap<QString, QTextCodec *> openEditorEncodings
+ = ITextEditorDocument::openedTextDocumentEncodings();
QTextCodec *codec = openEditorEncodings.value(fileName);
if (!codec)
codec = Core::EditorManager::defaultTextCodec();
diff --git a/src/plugins/texteditor/findinfiles.cpp b/src/plugins/texteditor/findinfiles.cpp
index 9fc036e60a..bfc56b7f24 100644
--- a/src/plugins/texteditor/findinfiles.cpp
+++ b/src/plugins/texteditor/findinfiles.cpp
@@ -30,7 +30,7 @@
#include "findinfiles.h"
#include <coreplugin/editormanager/editormanager.h>
-#include <find/findplugin.h>
+#include <coreplugin/find/findplugin.h>
#include <utils/filesearch.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
@@ -44,7 +44,7 @@
#include <QComboBox>
#include <QHBoxLayout>
-using namespace Find;
+using namespace Core;
using namespace TextEditor;
static FindInFiles *m_instance = 0;
@@ -72,7 +72,7 @@ QString FindInFiles::displayName() const
return tr("Files on File System");
}
-void FindInFiles::findAll(const QString &txt, Find::FindFlags findFlags)
+void FindInFiles::findAll(const QString &txt, Core::FindFlags findFlags)
{
updateComboEntries(m_directory, true);
BaseFileFind::findAll(txt, findFlags);
@@ -195,5 +195,5 @@ void FindInFiles::findOnFileSystem(const QString &path)
const QFileInfo fi(path);
const QString folder = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath();
m_instance->setDirectory(folder);
- Find::FindPlugin::instance()->openFindDialog(m_instance);
+ FindPlugin::instance()->openFindDialog(m_instance);
}
diff --git a/src/plugins/texteditor/findinfiles.h b/src/plugins/texteditor/findinfiles.h
index 0038dd75bf..6f9cac5b5f 100644
--- a/src/plugins/texteditor/findinfiles.h
+++ b/src/plugins/texteditor/findinfiles.h
@@ -50,7 +50,7 @@ public:
QString id() const;
QString displayName() const;
- void findAll(const QString &txt, Find::FindFlags findFlags);
+ void findAll(const QString &txt, Core::FindFlags findFlags);
QWidget *createConfigWidget();
void writeSettings(QSettings *settings);
void readSettings(QSettings *settings);
diff --git a/src/plugins/texteditor/findinopenfiles.cpp b/src/plugins/texteditor/findinopenfiles.cpp
index dec1e278a8..84e76b35ca 100644
--- a/src/plugins/texteditor/findinopenfiles.cpp
+++ b/src/plugins/texteditor/findinopenfiles.cpp
@@ -37,7 +37,6 @@
#include <QSettings>
-using namespace Find;
using namespace TextEditor;
using namespace TextEditor::Internal;
@@ -64,7 +63,8 @@ Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters,
{
Q_UNUSED(nameFilters)
Q_UNUSED(additionalParameters)
- QMap<QString, QTextCodec *> openEditorEncodings = ITextEditor::openedTextDocumentEncodings();
+ QMap<QString, QTextCodec *> openEditorEncodings
+ = ITextEditorDocument::openedTextDocumentEncodings();
QStringList fileNames;
QList<QTextCodec *> codecs;
foreach (Core::DocumentModel::Entry *entry,
diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp
index 58ff3ed36c..1a224330d5 100644
--- a/src/plugins/texteditor/fontsettingspage.cpp
+++ b/src/plugins/texteditor/fontsettingspage.cpp
@@ -36,14 +36,15 @@
#include <utils/stringutils.h>
#include <utils/qtcassert.h>
-#include <QDebug>
-#include <QSettings>
-#include <QTimer>
#include <QFileDialog>
#include <QFontDatabase>
#include <QInputDialog>
#include <QMessageBox>
#include <QPalette>
+#include <QPointer>
+#include <QSettings>
+#include <QTimer>
+#include <QDebug>
namespace TextEditor {
namespace Internal {
@@ -122,10 +123,10 @@ public:
TextEditor::FormatDescriptions m_descriptions;
FontSettings m_value;
FontSettings m_lastValue;
+ QPointer<QWidget> m_widget;
Ui::FontSettingsPage *m_ui;
SchemeListModel *m_schemeListModel;
bool m_refreshingSchemeList;
- QString m_searchKeywords;
};
} // namespace Internal
@@ -326,49 +327,40 @@ FontSettingsPage::~FontSettingsPage()
delete d_ptr;
}
-QWidget *FontSettingsPage::createPage(QWidget *parent)
+QWidget *FontSettingsPage::widget()
{
- QWidget *w = new QWidget(parent);
- d_ptr->m_ui = new Ui::FontSettingsPage;
- d_ptr->m_ui->setupUi(w);
- d_ptr->m_ui->schemeComboBox->setModel(d_ptr->m_schemeListModel);
+ if (!d_ptr->m_widget){
+ d_ptr->m_widget = new QWidget;
+ d_ptr->m_ui = new Ui::FontSettingsPage;
+ d_ptr->m_ui->setupUi(d_ptr->m_widget);
+ d_ptr->m_ui->schemeComboBox->setModel(d_ptr->m_schemeListModel);
- QFontDatabase db;
- const QStringList families = db.families();
- d_ptr->m_ui->familyComboBox->addItems(families);
- const int idx = families.indexOf(d_ptr->m_value.family());
- d_ptr->m_ui->familyComboBox->setCurrentIndex(idx);
+ QFontDatabase db;
+ const QStringList families = db.families();
+ d_ptr->m_ui->familyComboBox->addItems(families);
+ const int idx = families.indexOf(d_ptr->m_value.family());
+ d_ptr->m_ui->familyComboBox->setCurrentIndex(idx);
- d_ptr->m_ui->antialias->setChecked(d_ptr->m_value.antialias());
- d_ptr->m_ui->zoomSpinBox->setValue(d_ptr->m_value.fontZoom());
+ d_ptr->m_ui->antialias->setChecked(d_ptr->m_value.antialias());
+ d_ptr->m_ui->zoomSpinBox->setValue(d_ptr->m_value.fontZoom());
- d_ptr->m_ui->schemeEdit->setFormatDescriptions(d_ptr->m_descriptions);
- d_ptr->m_ui->schemeEdit->setBaseFont(d_ptr->m_value.font());
- d_ptr->m_ui->schemeEdit->setColorScheme(d_ptr->m_value.colorScheme());
+ d_ptr->m_ui->schemeEdit->setFormatDescriptions(d_ptr->m_descriptions);
+ d_ptr->m_ui->schemeEdit->setBaseFont(d_ptr->m_value.font());
+ d_ptr->m_ui->schemeEdit->setColorScheme(d_ptr->m_value.colorScheme());
- connect(d_ptr->m_ui->familyComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontFamilySelected(QString)));
- connect(d_ptr->m_ui->sizeComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontSizeSelected(QString)));
- connect(d_ptr->m_ui->zoomSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fontZoomChanged()));
- connect(d_ptr->m_ui->schemeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(colorSchemeSelected(int)));
- connect(d_ptr->m_ui->copyButton, SIGNAL(clicked()), this, SLOT(copyColorScheme()));
- connect(d_ptr->m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(confirmDeleteColorScheme()));
+ connect(d_ptr->m_ui->familyComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontFamilySelected(QString)));
+ connect(d_ptr->m_ui->sizeComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontSizeSelected(QString)));
+ connect(d_ptr->m_ui->zoomSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fontZoomChanged()));
+ connect(d_ptr->m_ui->schemeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(colorSchemeSelected(int)));
+ connect(d_ptr->m_ui->copyButton, SIGNAL(clicked()), this, SLOT(copyColorScheme()));
+ connect(d_ptr->m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(confirmDeleteColorScheme()));
- updatePointSizes();
- refreshColorSchemeList();
- d_ptr->m_lastValue = d_ptr->m_value;
- if (d_ptr->m_searchKeywords.isEmpty()) {
- QLatin1Char sep(' ');
- d_ptr->m_searchKeywords =
- d_ptr->m_ui->fontGroupBox->title() + sep
- + d_ptr->m_ui->familyLabel->text() + sep
- + d_ptr->m_ui->sizeLabel->text() + sep
- + d_ptr->m_ui->zoomLabel->text() + sep
- + d_ptr->m_ui->antialias->text() + sep
- + d_ptr->m_ui->colorSchemeGroupBox->title();
- d_ptr->m_searchKeywords.remove(QLatin1Char('&'));
+ updatePointSizes();
+ refreshColorSchemeList();
+ d_ptr->m_lastValue = d_ptr->m_value;
}
- return w;
+ return d_ptr->m_widget;
}
void FontSettingsPage::fontFamilySelected(const QString &family)
@@ -630,6 +622,7 @@ void FontSettingsPage::saveSettings()
void FontSettingsPage::finish()
{
+ delete d_ptr->m_widget;
if (!d_ptr->m_ui) // page was never shown
return;
// If changes were applied, these are equal. Otherwise restores last value.
@@ -642,8 +635,3 @@ const FontSettings &FontSettingsPage::fontSettings() const
{
return d_ptr->m_value;
}
-
-bool FontSettingsPage::matches(const QString &s) const
-{
- return d_ptr->m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
diff --git a/src/plugins/texteditor/fontsettingspage.h b/src/plugins/texteditor/fontsettingspage.h
index f358652c09..82ff29ef72 100644
--- a/src/plugins/texteditor/fontsettingspage.h
+++ b/src/plugins/texteditor/fontsettingspage.h
@@ -92,10 +92,9 @@ public:
~FontSettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &) const;
void saveSettings();
diff --git a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp
index 4271d0f097..6ae35d4ede 100644
--- a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp
+++ b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp
@@ -36,6 +36,7 @@
#include <coreplugin/icore.h>
#include <QMessageBox>
+#include <QPointer>
using namespace TextEditor;
using namespace Internal;
@@ -50,10 +51,9 @@ struct HighlighterSettingsPage::HighlighterSettingsPagePrivate
const QString m_displayName;
const QString m_settingsPrefix;
- QString m_searchKeywords;
-
HighlighterSettings m_settings;
+ QPointer<QWidget> m_widget;
Ui::HighlighterSettingsPage *m_page;
};
@@ -88,34 +88,30 @@ HighlighterSettingsPage::~HighlighterSettingsPage()
delete m_d;
}
-QWidget *HighlighterSettingsPage::createPage(QWidget *parent)
-{
- QWidget *w = new QWidget(parent);
- m_d->m_page = new Ui::HighlighterSettingsPage;
- m_d->m_page->setupUi(w);
- m_d->m_page->definitionFilesPath->setExpectedKind(Utils::PathChooser::ExistingDirectory);
- m_d->m_page->definitionFilesPath->addButton(tr("Download Definitions..."), this,
- SLOT(requestAvailableDefinitionsMetaData()));
- m_d->m_page->fallbackDefinitionFilesPath->setExpectedKind(Utils::PathChooser::ExistingDirectory);
- m_d->m_page->fallbackDefinitionFilesPath->addButton(tr("Autodetect"), this,
- SLOT(resetDefinitionsLocation()));
-
- settingsToUI();
-
- if (m_d->m_searchKeywords.isEmpty()) {
- QTextStream(&m_d->m_searchKeywords) << m_d->m_page->definitionFilesGroupBox->title()
- << m_d->m_page->locationLabel->text()
- << m_d->m_page->useFallbackLocation->text()
- << m_d->m_page->ignoreLabel->text();
+QWidget *HighlighterSettingsPage::widget()
+{
+ if (!m_d->m_widget) {
+ m_d->m_widget = new QWidget;
+ m_d->m_page = new Ui::HighlighterSettingsPage;
+ m_d->m_page->setupUi(m_d->m_widget);
+ m_d->m_page->definitionFilesPath->setExpectedKind(Utils::PathChooser::ExistingDirectory);
+ m_d->m_page->definitionFilesPath->setHistoryCompleter(QLatin1String("TextEditor.Highlighter.History"));
+ m_d->m_page->definitionFilesPath->addButton(tr("Download Definitions..."), this,
+ SLOT(requestAvailableDefinitionsMetaData()));
+ m_d->m_page->fallbackDefinitionFilesPath->setExpectedKind(Utils::PathChooser::ExistingDirectory);
+ m_d->m_page->fallbackDefinitionFilesPath->setHistoryCompleter(QLatin1String("TextEditor.Highlighter.History"));
+ m_d->m_page->fallbackDefinitionFilesPath->addButton(tr("Autodetect"), this,
+ SLOT(resetDefinitionsLocation()));
+
+ settingsToUI();
+
+ connect(m_d->m_page->useFallbackLocation, SIGNAL(clicked(bool)),
+ this, SLOT(setFallbackLocationState(bool)));
+ connect(m_d->m_page->definitionFilesPath, SIGNAL(validChanged(bool)),
+ this, SLOT(setDownloadDefinitionsState(bool)));
+ connect(m_d->m_widget, SIGNAL(destroyed()), this, SLOT(ignoreDownloadReply()));
}
-
- connect(m_d->m_page->useFallbackLocation, SIGNAL(clicked(bool)),
- this, SLOT(setFallbackLocationState(bool)));
- connect(m_d->m_page->definitionFilesPath, SIGNAL(validChanged(bool)),
- this, SLOT(setDownloadDefinitionsState(bool)));
- connect(w, SIGNAL(destroyed()), this, SLOT(ignoreDownloadReply()));
-
- return w;
+ return m_d->m_widget;
}
void HighlighterSettingsPage::apply()
@@ -133,17 +129,13 @@ void HighlighterSettingsPage::apply()
void HighlighterSettingsPage::finish()
{
+ delete m_d->m_widget;
if (!m_d->m_page) // page was not shown
return;
delete m_d->m_page;
m_d->m_page = 0;
}
-bool HighlighterSettingsPage::matches(const QString &s) const
-{
- return m_d->m_searchKeywords.contains(s, Qt::CaseInsensitive);
-}
-
const HighlighterSettings &HighlighterSettingsPage::highlighterSettings() const
{
m_d->ensureInitialized();
diff --git a/src/plugins/texteditor/generichighlighter/highlightersettingspage.h b/src/plugins/texteditor/generichighlighter/highlightersettingspage.h
index 18c632ba14..69d1372f53 100644
--- a/src/plugins/texteditor/generichighlighter/highlightersettingspage.h
+++ b/src/plugins/texteditor/generichighlighter/highlightersettingspage.h
@@ -52,10 +52,9 @@ public:
HighlighterSettingsPage(Core::Id id, QObject *parent);
~HighlighterSettingsPage();
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &s) const;
const HighlighterSettings &highlighterSettings() const;
diff --git a/src/plugins/texteditor/itexteditor.cpp b/src/plugins/texteditor/itexteditor.cpp
index f325627c2b..52ab1b2053 100644
--- a/src/plugins/texteditor/itexteditor.cpp
+++ b/src/plugins/texteditor/itexteditor.cpp
@@ -38,7 +38,7 @@ ITextEditorDocument::ITextEditorDocument(QObject *parent)
{
}
-QMap<QString, QString> ITextEditor::openedTextDocumentContents()
+QMap<QString, QString> ITextEditorDocument::openedTextDocumentContents()
{
QMap<QString, QString> workingCopy;
foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) {
@@ -46,12 +46,12 @@ QMap<QString, QString> ITextEditor::openedTextDocumentContents()
if (!textEditorDocument)
continue;
QString fileName = textEditorDocument->filePath();
- workingCopy[fileName] = textEditorDocument->contents();
+ workingCopy[fileName] = textEditorDocument->plainText();
}
return workingCopy;
}
-QMap<QString, QTextCodec *> TextEditor::ITextEditor::openedTextDocumentEncodings()
+QMap<QString, QTextCodec *> ITextEditorDocument::openedTextDocumentEncodings()
{
QMap<QString, QTextCodec *> workingCopy;
foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) {
diff --git a/src/plugins/texteditor/itexteditor.h b/src/plugins/texteditor/itexteditor.h
index 69e724fe79..594efad15d 100644
--- a/src/plugins/texteditor/itexteditor.h
+++ b/src/plugins/texteditor/itexteditor.h
@@ -81,9 +81,17 @@ class TEXTEDITOR_EXPORT ITextEditorDocument : public Core::TextDocument
public:
explicit ITextEditorDocument(QObject *parent = 0);
- virtual QString contents() const = 0;
+ virtual QString plainText() const = 0;
virtual QString textAt(int pos, int length) const = 0;
virtual QChar characterAt(int pos) const = 0;
+
+ virtual ITextMarkable *markableInterface() const = 0;
+
+ static QMap<QString, QString> openedTextDocumentContents();
+ static QMap<QString, QTextCodec *> openedTextDocumentEncodings();
+
+signals:
+ void contentsChanged();
};
class TEXTEDITOR_EXPORT ITextEditor : public Core::IEditor
@@ -126,13 +134,8 @@ public:
/*! Selects text between current cursor position and \a toPos. */
virtual void select(int toPos) = 0;
- virtual ITextMarkable *markableInterface() = 0;
-
virtual const Utils::CommentDefinition* commentDefinition() const = 0;
- static QMap<QString, QString> openedTextDocumentContents();
- static QMap<QString, QTextCodec *> openedTextDocumentEncodings();
-
enum MarkRequestKind {
BreakpointRequest,
BookmarkRequest,
@@ -140,8 +143,6 @@ public:
};
signals:
- void contentsChanged();
- void contentsChangedBecauseOfUndo();
void markRequested(TextEditor::ITextEditor *editor, int line, TextEditor::ITextEditor::MarkRequestKind kind);
void markContextMenuRequested(TextEditor::ITextEditor *editor, int line, QMenu *menu);
void tooltipOverrideRequested(TextEditor::ITextEditor *editor, const QPoint &globalPos, int position, bool *handled);
diff --git a/src/plugins/texteditor/linenumberfilter.cpp b/src/plugins/texteditor/linenumberfilter.cpp
index 21e9576bfe..a97af5dbda 100644
--- a/src/plugins/texteditor/linenumberfilter.cpp
+++ b/src/plugins/texteditor/linenumberfilter.cpp
@@ -43,7 +43,6 @@ typedef QPair<int,int> LineColumn;
Q_DECLARE_METATYPE(LineColumn)
using namespace Core;
-using namespace Locator;
using namespace TextEditor;
using namespace TextEditor::Internal;
@@ -57,9 +56,9 @@ LineNumberFilter::LineNumberFilter(QObject *parent)
setIncludedByDefault(true);
}
-QList<FilterEntry> LineNumberFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &, const QString &entry)
+QList<LocatorFilterEntry> LineNumberFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &, const QString &entry)
{
- QList<FilterEntry> value;
+ QList<LocatorFilterEntry> value;
QStringList lineAndColumn = entry.split(QLatin1Char(':'));
int sectionCount = lineAndColumn.size();
int line = 0;
@@ -82,12 +81,12 @@ QList<FilterEntry> LineNumberFilter::matchesFor(QFutureInterface<Locator::Filter
text = tr("Line %1").arg(line);
else
text = tr("Column %1").arg(column);
- value.append(FilterEntry(this, text, QVariant::fromValue(data)));
+ value.append(LocatorFilterEntry(this, text, QVariant::fromValue(data)));
}
return value;
}
-void LineNumberFilter::accept(FilterEntry selection) const
+void LineNumberFilter::accept(LocatorFilterEntry selection) const
{
ITextEditor *editor = currentTextEditor();
if (editor) {
diff --git a/src/plugins/texteditor/linenumberfilter.h b/src/plugins/texteditor/linenumberfilter.h
index 304877812a..01617c2e5b 100644
--- a/src/plugins/texteditor/linenumberfilter.h
+++ b/src/plugins/texteditor/linenumberfilter.h
@@ -30,7 +30,7 @@
#ifndef LINENUMBERFILTER_H
#define LINENUMBERFILTER_H
-#include <locator/ilocatorfilter.h>
+#include <coreplugin/locator/ilocatorfilter.h>
#include <QString>
#include <QList>
@@ -42,15 +42,15 @@ class ITextEditor;
namespace Internal {
-class LineNumberFilter : public Locator::ILocatorFilter
+class LineNumberFilter : public Core::ILocatorFilter
{
Q_OBJECT
public:
explicit LineNumberFilter(QObject *parent = 0);
- QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
- void accept(Locator::FilterEntry selection) const;
+ QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
+ void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &) {}
private:
diff --git a/src/plugins/texteditor/marginsettings.cpp b/src/plugins/texteditor/marginsettings.cpp
new file mode 100644
index 0000000000..e05eeb783a
--- /dev/null
+++ b/src/plugins/texteditor/marginsettings.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "marginsettings.h"
+
+#include <QSettings>
+#include <QString>
+#include <QVariantMap>
+
+static const char showWrapColumnKey[] = "ShowMargin";
+static const char wrapColumnKey[] = "MarginColumn";
+static const char groupPostfix[] = "MarginSettings";
+
+using namespace TextEditor;
+
+MarginSettings::MarginSettings()
+ : m_showMargin(false)
+ , m_marginColumn(80)
+{
+}
+
+void MarginSettings::toSettings(const QString &category, QSettings *s) const
+{
+ QString group = QLatin1String(groupPostfix);
+ if (!category.isEmpty())
+ group.insert(0, category);
+ s->beginGroup(group);
+ s->setValue(QLatin1String(showWrapColumnKey), m_showMargin);
+ s->setValue(QLatin1String(wrapColumnKey), m_marginColumn);
+ s->endGroup();
+}
+
+void MarginSettings::fromSettings(const QString &category, const QSettings *s)
+{
+ QString group = QLatin1String(groupPostfix);
+ if (!category.isEmpty())
+ group.insert(0, category);
+ group += QLatin1Char('/');
+
+ *this = MarginSettings(); // Assign defaults
+
+ m_showMargin = s->value(group + QLatin1String(showWrapColumnKey), m_showMargin).toBool();
+ m_marginColumn = s->value(group + QLatin1String(wrapColumnKey), m_marginColumn).toInt();
+}
+
+void MarginSettings::toMap(const QString &prefix, QVariantMap *map) const
+{
+ map->insert(prefix + QLatin1String(showWrapColumnKey), m_showMargin);
+ map->insert(prefix + QLatin1String(wrapColumnKey), m_marginColumn);
+}
+
+void MarginSettings::fromMap(const QString &prefix, const QVariantMap &map)
+{
+ m_showMargin = map.value(prefix + QLatin1String(showWrapColumnKey), m_showMargin).toBool();
+ m_marginColumn = map.value(prefix + QLatin1String(wrapColumnKey), m_marginColumn).toInt();
+}
+
+bool MarginSettings::equals(const MarginSettings &other) const
+{
+ return m_showMargin == other.m_showMargin
+ && m_marginColumn == other.m_marginColumn
+ ;
+}
diff --git a/src/plugins/texteditor/marginsettings.h b/src/plugins/texteditor/marginsettings.h
new file mode 100644
index 0000000000..fdd8be555d
--- /dev/null
+++ b/src/plugins/texteditor/marginsettings.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef TEXTEDITOR_MARGINSETTINGS_H
+#define TEXTEDITOR_MARGINSETTINGS_H
+
+#include "texteditor_global.h"
+
+#include <QVariantMap>
+
+QT_BEGIN_NAMESPACE
+class QSettings;
+QT_END_NAMESPACE
+
+namespace TextEditor {
+
+class TEXTEDITOR_EXPORT MarginSettings
+{
+public:
+ MarginSettings();
+
+ void toSettings(const QString &category, QSettings *s) const;
+ void fromSettings(const QString &category, const QSettings *s);
+
+ void toMap(const QString &prefix, QVariantMap *map) const;
+ void fromMap(const QString &prefix, const QVariantMap &map);
+
+ bool equals(const MarginSettings &other) const;
+
+ bool m_showMargin;
+ int m_marginColumn;
+};
+
+inline bool operator==(const MarginSettings &one, const MarginSettings &two)
+{ return one.equals(two); }
+inline bool operator!=(const MarginSettings &one, const MarginSettings &two)
+{ return !one.equals(two); }
+
+} // namespace TextEditor
+
+#endif // TEXTEDITOR_MARGINSETTINGS_H
diff --git a/src/plugins/texteditor/plaintexteditor.cpp b/src/plugins/texteditor/plaintexteditor.cpp
index 27846929d6..4ffc4ec08d 100644
--- a/src/plugins/texteditor/plaintexteditor.cpp
+++ b/src/plugins/texteditor/plaintexteditor.cpp
@@ -58,28 +58,45 @@ PlainTextEditor::PlainTextEditor(PlainTextEditorWidget *editor)
}
PlainTextEditorWidget::PlainTextEditorWidget(QWidget *parent)
- : BaseTextEditorWidget(parent),
- m_isMissingSyntaxDefinition(false)
+ : BaseTextEditorWidget(parent)
{
+ ctor();
+}
+
+PlainTextEditorWidget::PlainTextEditorWidget(BaseTextDocument *doc, QWidget *parent)
+ : BaseTextEditorWidget(doc, parent)
+{
+ ctor();
+}
+
+PlainTextEditorWidget::PlainTextEditorWidget(PlainTextEditorWidget *other)
+ : BaseTextEditorWidget(other)
+{
+ ctor();
+}
+
+void PlainTextEditorWidget::ctor()
+{
+ m_isMissingSyntaxDefinition = false;
setRevisionsVisible(true);
setMarksVisible(true);
setLineSeparatorsAllowed(true);
setIndenter(new NormalIndenter); // Currently only "normal" indentation is supported.
- setMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
+ baseTextDocument()->setMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
m_commentDefinition.clearCommentStyles();
// If configure() is called immediately the whole document is considered modified
- connect(editorDocument(), SIGNAL(changed()), this, SLOT(configure()), Qt::QueuedConnection);
+ connect(baseTextDocument(), SIGNAL(changed()), this, SLOT(configure()), Qt::QueuedConnection);
connect(Manager::instance(), SIGNAL(mimeTypesRegistered()), this, SLOT(configure()));
}
-IEditor *PlainTextEditor::duplicate(QWidget *parent)
+IEditor *PlainTextEditor::duplicate()
{
- PlainTextEditorWidget *newWidget = new PlainTextEditorWidget(parent);
- newWidget->duplicateFrom(editorWidget());
- TextEditorPlugin::instance()->initializeEditor(newWidget);
+ PlainTextEditorWidget *newWidget = new PlainTextEditorWidget(
+ qobject_cast<PlainTextEditorWidget *>(editorWidget()));
+ TextEditorSettings::initializeEditor(newWidget);
return newWidget->editor();
}
@@ -107,8 +124,8 @@ void PlainTextEditorWidget::setTabSettings(const TextEditor::TabSettings &ts)
void PlainTextEditorWidget::configure()
{
MimeType mimeType;
- if (editorDocument())
- mimeType = MimeDatabase::findByFile(editorDocument()->filePath());
+ if (baseTextDocument())
+ mimeType = MimeDatabase::findByFile(baseTextDocument()->filePath());
configure(mimeType);
}
@@ -129,7 +146,7 @@ void PlainTextEditorWidget::configure(const MimeType &mimeType)
setMimeTypeForHighlighter(highlighter, mimeType);
const QString &type = mimeType.type();
- setMimeType(type);
+ baseTextDocument()->setMimeType(type);
QString definitionId = Manager::instance()->definitionIdByMimeType(type);
if (definitionId.isEmpty())
@@ -147,8 +164,8 @@ void PlainTextEditorWidget::configure(const MimeType &mimeType)
setCodeFoldingSupported(true);
}
- } else if (editorDocument()) {
- const QString &fileName = editorDocument()->filePath();
+ } else if (baseTextDocument()) {
+ const QString &fileName = baseTextDocument()->filePath();
if (TextEditorSettings::highlighterSettings().isIgnoredFilePattern(fileName))
m_isMissingSyntaxDefinition = false;
}
diff --git a/src/plugins/texteditor/plaintexteditor.h b/src/plugins/texteditor/plaintexteditor.h
index d9f1452ab9..e56b552bd6 100644
--- a/src/plugins/texteditor/plaintexteditor.h
+++ b/src/plugins/texteditor/plaintexteditor.h
@@ -50,7 +50,7 @@ public:
PlainTextEditor(PlainTextEditorWidget *);
bool duplicateSupported() const { return true; }
- Core::IEditor *duplicate(QWidget *parent);
+ Core::IEditor *duplicate();
Core::Id id() const;
};
@@ -59,7 +59,9 @@ class TEXTEDITOR_EXPORT PlainTextEditorWidget : public BaseTextEditorWidget
Q_OBJECT
public:
- PlainTextEditorWidget(QWidget *parent);
+ PlainTextEditorWidget(QWidget *parent = 0);
+ PlainTextEditorWidget(BaseTextDocument *doc, QWidget *parent = 0);
+ PlainTextEditorWidget(PlainTextEditorWidget *other);
void configure(const QString& mimeType);
void configure(const Core::MimeType &mimeType);
@@ -80,6 +82,9 @@ protected:
virtual BaseTextEditor *createEditor() { return new PlainTextEditor(this); }
private:
+ PlainTextEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
+ void ctor();
+
bool m_isMissingSyntaxDefinition;
Utils::CommentDefinition m_commentDefinition;
};
diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp
index 408b159a81..4323de80c7 100644
--- a/src/plugins/texteditor/plaintexteditorfactory.cpp
+++ b/src/plugins/texteditor/plaintexteditorfactory.cpp
@@ -30,9 +30,10 @@
#include "plaintexteditorfactory.h"
#include "plaintexteditor.h"
#include "basetextdocument.h"
+#include "texteditoractionhandler.h"
#include "texteditorconstants.h"
#include "texteditorplugin.h"
-#include "texteditoractionhandler.h"
+#include "texteditorsettings.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/infobar.h>
@@ -50,22 +51,17 @@ PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent)
setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
- m_actionHandler = new TextEditorActionHandler(
- TextEditor::Constants::C_TEXTEDITOR,
+ new TextEditorActionHandler(this,
+ Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
TextEditorActionHandler::Format |
TextEditorActionHandler::UnCommentSelection |
TextEditorActionHandler::UnCollapseAll);
}
-PlainTextEditorFactory::~PlainTextEditorFactory()
-{
- delete m_actionHandler;
-}
-
-Core::IEditor *PlainTextEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *PlainTextEditorFactory::createEditor()
{
- PlainTextEditorWidget *rc = new PlainTextEditorWidget(parent);
- TextEditorPlugin::instance()->initializeEditor(rc);
+ PlainTextEditorWidget *rc = new PlainTextEditorWidget();
+ TextEditorSettings::initializeEditor(rc);
connect(rc, SIGNAL(configured(Core::IEditor*)),
this, SLOT(updateEditorInfoBar(Core::IEditor*)));
updateEditorInfoBar(rc->editor());
diff --git a/src/plugins/texteditor/plaintexteditorfactory.h b/src/plugins/texteditor/plaintexteditorfactory.h
index 5c5393b425..8633fc8949 100644
--- a/src/plugins/texteditor/plaintexteditorfactory.h
+++ b/src/plugins/texteditor/plaintexteditorfactory.h
@@ -35,7 +35,6 @@
#include <QStringList>
namespace TextEditor {
-class TextEditorActionHandler;
namespace Internal {
class PlainTextEditorFactory : public Core::IEditorFactory
@@ -44,17 +43,12 @@ class PlainTextEditorFactory : public Core::IEditorFactory
public:
PlainTextEditorFactory(QObject *parent = 0);
- ~PlainTextEditorFactory();
using Core::IEditorFactory::addMimeType;
- Core::IEditor *createEditor(QWidget *parent);
- TextEditor::TextEditorActionHandler *actionHandler() const { return m_actionHandler; }
+ Core::IEditor *createEditor();
private slots:
void updateEditorInfoBar(Core::IEditor *editor);
-
-private:
- TextEditor::TextEditorActionHandler *m_actionHandler;
};
} // namespace Internal
diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp
index 482c3af017..605e6f4664 100644
--- a/src/plugins/texteditor/refactoringchanges.cpp
+++ b/src/plugins/texteditor/refactoringchanges.cpp
@@ -158,7 +158,7 @@ RefactoringFile::RefactoringFile(QTextDocument *document, const QString &fileNam
{ }
RefactoringFile::RefactoringFile(BaseTextEditorWidget *editor)
- : m_fileName(editor->editorDocument()->filePath())
+ : m_fileName(editor->baseTextDocument()->filePath())
, m_document(0)
, m_editor(editor)
, m_openEditor(false)
diff --git a/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp b/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp
index b0d6725403..8bb44291b4 100644
--- a/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp
+++ b/src/plugins/texteditor/simplecodestylepreferenceswidget.cpp
@@ -94,11 +94,6 @@ void SimpleCodeStylePreferencesWidget::slotTabSettingsChanged(const TextEditor::
current->setTabSettings(settings);
}
-QString SimpleCodeStylePreferencesWidget::searchKeywords() const
-{
- return m_tabSettingsWidget->searchKeywords();
-}
-
void SimpleCodeStylePreferencesWidget::setFlat(bool on)
{
m_tabSettingsWidget->setFlat(on);
diff --git a/src/plugins/texteditor/simplecodestylepreferenceswidget.h b/src/plugins/texteditor/simplecodestylepreferenceswidget.h
index 1f8dad7c4c..992b242b34 100644
--- a/src/plugins/texteditor/simplecodestylepreferenceswidget.h
+++ b/src/plugins/texteditor/simplecodestylepreferenceswidget.h
@@ -52,7 +52,6 @@ public:
explicit SimpleCodeStylePreferencesWidget(QWidget *parent = 0);
void setPreferences(ICodeStylePreferences *tabPreferences);
- QString searchKeywords() const;
void setFlat(bool on);
TabSettingsWidget *tabSettingsWidget() const;
diff --git a/src/plugins/texteditor/snippets/snippeteditor.h b/src/plugins/texteditor/snippets/snippeteditor.h
index 33229ef3d0..564eccaa78 100644
--- a/src/plugins/texteditor/snippets/snippeteditor.h
+++ b/src/plugins/texteditor/snippets/snippeteditor.h
@@ -49,7 +49,7 @@ public:
SnippetEditor(SnippetEditorWidget *editorWidget);
bool duplicateSupported() const { return false; }
- Core::IEditor *duplicate(QWidget * /* parent */ ) { return 0; }
+ Core::IEditor *duplicate() { return 0; }
Core::Id id() const;
};
diff --git a/src/plugins/texteditor/snippets/snippetssettingspage.cpp b/src/plugins/texteditor/snippets/snippetssettingspage.cpp
index 7062880ccf..e1db97ea96 100644
--- a/src/plugins/texteditor/snippets/snippetssettingspage.cpp
+++ b/src/plugins/texteditor/snippets/snippetssettingspage.cpp
@@ -39,11 +39,12 @@
#include <texteditor/texteditorsettings.h>
#include <extensionsystem/pluginmanager.h>
-#include <QModelIndex>
#include <QAbstractTableModel>
#include <QList>
-#include <QTextStream>
#include <QMessageBox>
+#include <QModelIndex>
+#include <QPointer>
+#include <QTextStream>
namespace TextEditor {
namespace Internal {
@@ -269,12 +270,13 @@ public:
Core::Id id() const { return m_id; }
const QString &displayName() const { return m_displayName; }
- bool isKeyword(const QString &s) const { return m_keywords.contains(s, Qt::CaseInsensitive); }
void configureUi(QWidget *parent);
void apply();
void finish();
+ QPointer<QWidget> m_widget;
+
private slots:
void loadSnippetGroup(int index);
void markSnippetsCollection();
@@ -302,7 +304,6 @@ private:
const QString m_settingsPrefix;
SnippetsTableModel *m_model;
bool m_snippetsCollectionChanged;
- QString m_keywords;
SnippetsSettings m_settings;
Ui::SnippetsSettingsPage m_ui;
};
@@ -350,8 +351,6 @@ void SnippetsSettingsPagePrivate::configureUi(QWidget *w)
m_ui.revertButton->setEnabled(false);
- QTextStream(&m_keywords) << m_displayName;
-
loadSettings();
loadSnippetGroup(m_ui.groupCombo->currentIndex());
@@ -566,16 +565,13 @@ SnippetsSettingsPage::~SnippetsSettingsPage()
delete d;
}
-bool SnippetsSettingsPage::matches(const QString &s) const
+QWidget *SnippetsSettingsPage::widget()
{
- return d->isKeyword(s);
-}
-
-QWidget *SnippetsSettingsPage::createPage(QWidget *parent)
-{
- QWidget *w = new QWidget(parent);
- d->configureUi(w);
- return w;
+ if (!d->m_widget) {
+ d->m_widget = new QWidget;
+ d->configureUi(d->m_widget);
+ }
+ return d->m_widget;
}
void SnippetsSettingsPage::apply()
@@ -586,6 +582,7 @@ void SnippetsSettingsPage::apply()
void SnippetsSettingsPage::finish()
{
d->finish();
+ delete d->m_widget;
}
} // Internal
diff --git a/src/plugins/texteditor/snippets/snippetssettingspage.h b/src/plugins/texteditor/snippets/snippetssettingspage.h
index 32e03e5cee..3ded2c558b 100644
--- a/src/plugins/texteditor/snippets/snippetssettingspage.h
+++ b/src/plugins/texteditor/snippets/snippetssettingspage.h
@@ -45,8 +45,7 @@ public:
SnippetsSettingsPage(Core::Id id, QObject *parent);
~SnippetsSettingsPage();
- bool matches(const QString &s) const;
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
diff --git a/src/plugins/texteditor/tabsettingswidget.cpp b/src/plugins/texteditor/tabsettingswidget.cpp
index 4b37a56a01..ed49a4aaea 100644
--- a/src/plugins/texteditor/tabsettingswidget.cpp
+++ b/src/plugins/texteditor/tabsettingswidget.cpp
@@ -101,21 +101,6 @@ void TabSettingsWidget::setFlat(bool on)
ui->tabsAndIndentationGroupBox->layout()->setContentsMargins(margin, -1, margin, margin);
}
-QString TabSettingsWidget::searchKeywords() const
-{
- QString rc;
- QLatin1Char sep(' ');
- QTextStream(&rc)
- << sep << ui->tabsAndIndentationGroupBox->title()
- << sep << ui->tabPolicyLabel->text()
- << sep << ui->tabSizeLabel->text()
- << sep << ui->indentSizeLabel->text()
- << sep << ui->continuationAlignBehaviorLabel->text()
- ;
- rc.remove(QLatin1Char('&'));
- return rc;
-}
-
void TabSettingsWidget::setCodingStyleWarningVisible(bool visible)
{
ui->codingStyleWarning->setVisible(visible);
diff --git a/src/plugins/texteditor/tabsettingswidget.h b/src/plugins/texteditor/tabsettingswidget.h
index b3ebf43255..e3bdb2e581 100644
--- a/src/plugins/texteditor/tabsettingswidget.h
+++ b/src/plugins/texteditor/tabsettingswidget.h
@@ -56,7 +56,6 @@ public:
TabSettings tabSettings() const;
void setFlat(bool on);
- QString searchKeywords() const;
void setCodingStyleWarningVisible(bool visible);
public slots:
diff --git a/src/plugins/texteditor/texteditor.pro b/src/plugins/texteditor/texteditor.pro
index 23acecbf02..7bc37d6d3f 100644
--- a/src/plugins/texteditor/texteditor.pro
+++ b/src/plugins/texteditor/texteditor.pro
@@ -107,7 +107,8 @@ SOURCES += texteditorplugin.cpp \
circularclipboard.cpp \
circularclipboardassist.cpp \
itextmark.cpp \
- codeassist/keywordscompletionassist.cpp
+ codeassist/keywordscompletionassist.cpp \
+ marginsettings.cpp
HEADERS += texteditorplugin.h \
textfilewizard.h \
@@ -224,7 +225,8 @@ HEADERS += texteditorplugin.h \
circularclipboardassist.h \
itextmark.h \
codeassist/keywordscompletionassist.h \
- basetextmarkregistry.h
+ basetextmarkregistry.h \
+ marginsettings.h
FORMS += \
displaysettingspage.ui \
diff --git a/src/plugins/texteditor/texteditor.qbs b/src/plugins/texteditor/texteditor.qbs
index 5f0505c6eb..f6472f7a18 100644
--- a/src/plugins/texteditor/texteditor.qbs
+++ b/src/plugins/texteditor/texteditor.qbs
@@ -7,8 +7,6 @@ QtcPlugin {
Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "script", "printsupport"] }
Depends { name: "Core" }
- Depends { name: "Find" }
- Depends { name: "Locator" }
cpp.includePaths: base.concat([path]) // Needed for the highlighterengine autotest.
@@ -96,6 +94,8 @@ QtcPlugin {
"itextmark.h",
"linenumberfilter.cpp",
"linenumberfilter.h",
+ "marginsettings.cpp",
+ "marginsettings.h",
"normalindenter.cpp",
"normalindenter.h",
"outlinefactory.cpp",
@@ -265,9 +265,4 @@ QtcPlugin {
"snippetssettingspage.ui",
]
}
-
- Export {
- Depends { name: "Find" }
- Depends { name: "Locator" }
- }
}
diff --git a/src/plugins/texteditor/texteditor_dependencies.pri b/src/plugins/texteditor/texteditor_dependencies.pri
index 0d4d168776..389caeeaa6 100644
--- a/src/plugins/texteditor/texteditor_dependencies.pri
+++ b/src/plugins/texteditor/texteditor_dependencies.pri
@@ -2,6 +2,4 @@ QTC_PLUGIN_NAME = TextEditor
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
- find \
- locator \
coreplugin
diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp
index a8a95378f3..7e5f9d45dc 100644
--- a/src/plugins/texteditor/texteditoractionhandler.cpp
+++ b/src/plugins/texteditor/texteditoractionhandler.cpp
@@ -35,7 +35,7 @@
#include "texteditorconstants.h"
#include "texteditorplugin.h"
-#include <locator/locatormanager.h>
+#include <coreplugin/locator/locatormanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/actionmanager/actionmanager.h>
@@ -49,9 +49,9 @@
using namespace TextEditor;
using namespace TextEditor::Internal;
-TextEditorActionHandler::TextEditorActionHandler(const char *context,
+TextEditorActionHandler::TextEditorActionHandler(QObject *parent, Core::Id contextId,
uint optionalActions)
- : QObject(Core::ICore::instance()),
+ : QObject(parent),
m_undoAction(0),
m_redoAction(0),
m_copyAction(0),
@@ -103,10 +103,10 @@ TextEditorActionHandler::TextEditorActionHandler(const char *context,
m_jumpToFileAction(0),
m_jumpToFileInNextSplitAction(0),
m_optionalActions(optionalActions),
- m_currentEditor(0),
- m_contextId(context),
- m_initialized(false)
+ m_currentEditorWidget(0),
+ m_contextId(contextId)
{
+ createActions();
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(updateCurrentEditor(Core::IEditor*)));
}
@@ -115,25 +115,6 @@ TextEditorActionHandler::~TextEditorActionHandler()
{
}
-void TextEditorActionHandler::setupActions(BaseTextEditorWidget *editor)
-{
- initializeActions();
- editor->setActionHack(this);
- QObject::connect(editor, SIGNAL(undoAvailable(bool)), this, SLOT(updateUndoAction()));
- QObject::connect(editor, SIGNAL(redoAvailable(bool)), this, SLOT(updateRedoAction()));
- QObject::connect(editor, SIGNAL(copyAvailable(bool)), this, SLOT(updateCopyAction()));
- QObject::connect(editor, SIGNAL(readOnlyChanged()), this, SLOT(updateActions()));
-}
-
-
-void TextEditorActionHandler::initializeActions()
-{
- if (!m_initialized) {
- createActions();
- m_initialized = true;
- }
-}
-
void TextEditorActionHandler::createActions()
{
using namespace Core::Constants;
@@ -371,6 +352,13 @@ void TextEditorActionHandler::createActions()
m_modifyingActions << m_switchUtf8bomAction;
m_modifyingActions << m_indentAction;
m_modifyingActions << m_unindentAction;
+
+ // set enabled state of optional actions
+ m_followSymbolAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor);
+ m_followSymbolInNextSplitAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor);
+ m_jumpToFileAction->setEnabled(m_optionalActions & JumpToFileUnderCursor);
+ m_jumpToFileInNextSplitAction->setEnabled(m_optionalActions & JumpToFileUnderCursor);
+ m_unfoldAllAction->setEnabled(m_optionalActions & UnCollapseAll);
}
QAction *TextEditorActionHandler::registerAction(const Core::Id &id,
@@ -382,7 +370,7 @@ QAction *TextEditorActionHandler::registerAction(const Core::Id &id,
Core::ActionContainer *container)
{
QAction *result = new QAction(title, this);
- Core::Command *command = Core::ActionManager::registerAction(result, id, m_contextId, scriptable);
+ Core::Command *command = Core::ActionManager::registerAction(result, id, Core::Context(m_contextId), scriptable);
if (!keySequence.isEmpty())
command->setDefaultKeySequence(keySequence);
@@ -393,34 +381,16 @@ QAction *TextEditorActionHandler::registerAction(const Core::Id &id,
return result;
}
-TextEditorActionHandler::UpdateMode TextEditorActionHandler::updateMode() const
-{
- Q_ASSERT(m_currentEditor != 0);
- return m_currentEditor->isReadOnly() ? ReadOnlyMode : WriteMode;
-}
-
void TextEditorActionHandler::updateActions()
{
- if (!m_currentEditor || !m_initialized)
- return;
- updateActions(updateMode());
-}
-
-void TextEditorActionHandler::updateActions(UpdateMode um)
-{
+ QTC_ASSERT(m_currentEditorWidget, return);
+ bool isWritable = !m_currentEditorWidget->isReadOnly();
foreach (QAction *a, m_modifyingActions)
- a->setEnabled(um != ReadOnlyMode);
- m_formatAction->setEnabled((m_optionalActions & Format) && um != ReadOnlyMode);
- m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && um != ReadOnlyMode);
- m_followSymbolAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor);
- m_followSymbolInNextSplitAction->setEnabled(m_optionalActions & FollowSymbolUnderCursor);
- m_jumpToFileAction->setEnabled(m_optionalActions & JumpToFileUnderCursor);
- m_jumpToFileInNextSplitAction->setEnabled(m_optionalActions & JumpToFileUnderCursor);
-
- m_unfoldAllAction->setEnabled((m_optionalActions & UnCollapseAll));
- m_visualizeWhitespaceAction->setChecked(m_currentEditor->displaySettings().m_visualizeWhitespace);
- if (m_textWrappingAction)
- m_textWrappingAction->setChecked(m_currentEditor->displaySettings().m_textWrapping);
+ a->setEnabled(isWritable);
+ m_formatAction->setEnabled((m_optionalActions & Format) && isWritable);
+ m_unCommentSelectionAction->setEnabled((m_optionalActions & UnCommentSelection) && isWritable);
+ m_visualizeWhitespaceAction->setChecked(m_currentEditorWidget->displaySettings().m_visualizeWhitespace);
+ m_textWrappingAction->setChecked(m_currentEditorWidget->displaySettings().m_textWrapping);
updateRedoAction();
updateUndoAction();
@@ -429,21 +399,22 @@ void TextEditorActionHandler::updateActions(UpdateMode um)
void TextEditorActionHandler::updateRedoAction()
{
- if (m_redoAction)
- m_redoAction->setEnabled(m_currentEditor && m_currentEditor->document()->isRedoAvailable());
+ QTC_ASSERT(m_currentEditorWidget, return);
+ m_redoAction->setEnabled(m_currentEditorWidget->document()->isRedoAvailable());
}
void TextEditorActionHandler::updateUndoAction()
{
- if (m_undoAction)
- m_undoAction->setEnabled(m_currentEditor && m_currentEditor->document()->isUndoAvailable());
+ QTC_ASSERT(m_currentEditorWidget, return);
+ m_undoAction->setEnabled(m_currentEditorWidget->document()->isUndoAvailable());
}
void TextEditorActionHandler::updateCopyAction()
{
- const bool hasCopyableText = m_currentEditor && m_currentEditor->textCursor().hasSelection();
+ QTC_ASSERT(m_currentEditorWidget, return);
+ const bool hasCopyableText = m_currentEditorWidget->textCursor().hasSelection();
if (m_cutAction)
- m_cutAction->setEnabled(hasCopyableText && updateMode() == WriteMode);
+ m_cutAction->setEnabled(hasCopyableText && !m_currentEditorWidget->isReadOnly());
if (m_copyAction)
m_copyAction->setEnabled(hasCopyableText);
}
@@ -454,42 +425,42 @@ void TextEditorActionHandler::gotoAction()
locatorString += QLatin1Char(' ');
const int selectionStart = locatorString.size();
locatorString += tr("<line>:<column>");
- Locator::LocatorManager::show(locatorString, selectionStart, locatorString.size() - selectionStart);
+ Core::LocatorManager::show(locatorString, selectionStart, locatorString.size() - selectionStart);
}
void TextEditorActionHandler::printAction()
{
- if (m_currentEditor)
- m_currentEditor->print(Core::ICore::printer());
+ if (m_currentEditorWidget)
+ m_currentEditorWidget->print(Core::ICore::printer());
}
void TextEditorActionHandler::setVisualizeWhitespace(bool checked)
{
- if (m_currentEditor) {
- DisplaySettings ds = m_currentEditor->displaySettings();
+ if (m_currentEditorWidget) {
+ DisplaySettings ds = m_currentEditorWidget->displaySettings();
ds.m_visualizeWhitespace = checked;
- m_currentEditor->setDisplaySettings(ds);
+ m_currentEditorWidget->setDisplaySettings(ds);
}
}
void TextEditorActionHandler::setTextWrapping(bool checked)
{
- if (m_currentEditor) {
- DisplaySettings ds = m_currentEditor->displaySettings();
+ if (m_currentEditorWidget) {
+ DisplaySettings ds = m_currentEditorWidget->displaySettings();
ds.m_textWrapping = checked;
- m_currentEditor->setDisplaySettings(ds);
+ m_currentEditorWidget->setDisplaySettings(ds);
}
}
#define FUNCTION(funcname) void TextEditorActionHandler::funcname ()\
{\
- if (m_currentEditor)\
- m_currentEditor->funcname ();\
+ if (m_currentEditorWidget)\
+ m_currentEditorWidget->funcname ();\
}
#define FUNCTION2(funcname, funcname2) void TextEditorActionHandler::funcname ()\
{\
- if (m_currentEditor)\
- m_currentEditor->funcname2 ();\
+ if (m_currentEditorWidget)\
+ m_currentEditorWidget->funcname2 ();\
}
@@ -568,20 +539,21 @@ BaseTextEditorWidget *TextEditorActionHandler::resolveTextEditorWidget(Core::IEd
void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor)
{
- m_currentEditor = 0;
+ if (m_currentEditorWidget)
+ m_currentEditorWidget->disconnect(this);
+ m_currentEditorWidget = 0;
- if (!editor)
+ // don't need to do anything if the editor's context doesn't match
+ // (our actions will be disabled because our context will not be active)
+ if (!editor || !editor->context().contains(m_contextId))
return;
- BaseTextEditorWidget *baseEditor = resolveTextEditorWidget(editor);
-
- if (baseEditor && baseEditor->actionHack() == this) {
- m_currentEditor = baseEditor;
- updateActions();
- }
-}
-
-const QPointer<BaseTextEditorWidget> &TextEditorActionHandler::currentEditor() const
-{
- return m_currentEditor;
+ BaseTextEditorWidget *editorWidget = resolveTextEditorWidget(editor);
+ QTC_ASSERT(editorWidget, return); // editor has our context id, so shouldn't happen
+ m_currentEditorWidget = editorWidget;
+ connect(m_currentEditorWidget, SIGNAL(undoAvailable(bool)), this, SLOT(updateUndoAction()));
+ connect(m_currentEditorWidget, SIGNAL(redoAvailable(bool)), this, SLOT(updateRedoAction()));
+ connect(m_currentEditorWidget, SIGNAL(copyAvailable(bool)), this, SLOT(updateCopyAction()));
+ connect(m_currentEditorWidget, SIGNAL(readOnlyChanged()), this, SLOT(updateActions()));
+ updateActions();
}
diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h
index d365d3247c..fbb03d497e 100644
--- a/src/plugins/texteditor/texteditoractionhandler.h
+++ b/src/plugins/texteditor/texteditoractionhandler.h
@@ -65,23 +65,13 @@ public:
JumpToFileUnderCursor = 16
};
- explicit TextEditorActionHandler(const char *context, uint optionalActions = None);
+ explicit TextEditorActionHandler(QObject *parent, Core::Id contextId, uint optionalActions = None);
~TextEditorActionHandler();
- void setupActions(BaseTextEditorWidget *editor);
-
- void initializeActions();
-
-public slots:
- void updateActions();
- void updateRedoAction();
- void updateUndoAction();
- void updateCopyAction();
-
protected:
virtual BaseTextEditorWidget *resolveTextEditorWidget(Core::IEditor *editor) const;
- const QPointer<BaseTextEditorWidget> &currentEditor() const;
+private:
QAction *registerAction(const Core::Id &id,
const char *slot,
bool scriptable = false,
@@ -90,13 +80,14 @@ protected:
const char *menueGroup = 0,
Core::ActionContainer *container = 0);
- enum UpdateMode { ReadOnlyMode, WriteMode };
- UpdateMode updateMode() const;
-
void createActions();
- void updateActions(UpdateMode um);
private slots:
+ void updateActions();
+ void updateRedoAction();
+ void updateUndoAction();
+ void updateCopyAction();
+
void undoAction();
void redoAction();
void copyAction();
@@ -225,9 +216,8 @@ private:
QList<QAction *> m_modifyingActions;
uint m_optionalActions;
- QPointer<BaseTextEditorWidget> m_currentEditor;
- Core::Context m_contextId;
- bool m_initialized;
+ QPointer<BaseTextEditorWidget> m_currentEditorWidget;
+ Core::Id m_contextId;
};
} // namespace TextEditor
diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp
index 53495e7882..7265ecb215 100644
--- a/src/plugins/texteditor/texteditorplugin.cpp
+++ b/src/plugins/texteditor/texteditorplugin.cpp
@@ -203,11 +203,6 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
m_outlineFactory = new OutlineFactory;
addAutoReleasedObject(m_outlineFactory);
- // We have to initialize the actions because other plugins that
- // depend upon the texteditorplugin expect that actions will be
- // registered in the action manager at plugin initialization time.
- m_editorFactory->actionHandler()->initializeActions();
-
m_baseTextMarkRegistry = new BaseTextMarkRegistry(this);
return true;
@@ -215,7 +210,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
void TextEditorPlugin::extensionsInitialized()
{
- m_searchResultWindow = Find::SearchResultWindow::instance();
+ m_searchResultWindow = Core::SearchResultWindow::instance();
m_outlineFactory->setWidgetFactories(ExtensionSystem::PluginManager::getObjects<TextEditor::IOutlineWidgetFactory>());
@@ -246,14 +241,6 @@ void TextEditorPlugin::extensionsInitialized()
this, SLOT(updateCurrentSelection(QString)));
}
-void TextEditorPlugin::initializeEditor(PlainTextEditorWidget *editor)
-{
- // common actions
- m_editorFactory->actionHandler()->setupActions(editor);
-
- TextEditorSettings::initializeEditor(editor);
-}
-
void TextEditorPlugin::invokeCompletion()
{
Core::IEditor *iface = Core::EditorManager::currentEditor();
diff --git a/src/plugins/texteditor/texteditorplugin.h b/src/plugins/texteditor/texteditorplugin.h
index 1dd5ea7123..3fd323b156 100644
--- a/src/plugins/texteditor/texteditorplugin.h
+++ b/src/plugins/texteditor/texteditorplugin.h
@@ -32,7 +32,7 @@
#include <extensionsystem/iplugin.h>
-namespace Find {
+namespace Core {
class SearchResultWindow;
}
@@ -64,8 +64,6 @@ public:
bool initialize(const QStringList &arguments, QString *errorMessage);
void extensionsInitialized();
- void initializeEditor(PlainTextEditorWidget *editor);
-
PlainTextEditorFactory *editorFactory() { return m_editorFactory; }
LineNumberFilter *lineNumberFilter() { return m_lineNumberFilter; }
BaseTextMarkRegistry *baseTextMarkRegistry() { return m_baseTextMarkRegistry; }
@@ -87,7 +85,7 @@ private:
TextEditorSettings *m_settings;
PlainTextEditorFactory *m_editorFactory;
LineNumberFilter *m_lineNumberFilter;
- Find::SearchResultWindow *m_searchResultWindow;
+ Core::SearchResultWindow *m_searchResultWindow;
OutlineFactory *m_outlineFactory;
BaseTextMarkRegistry *m_baseTextMarkRegistry;
};
diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp
index 1b067cbb8b..53ffe28bd5 100644
--- a/src/plugins/texteditor/texteditorsettings.cpp
+++ b/src/plugins/texteditor/texteditorsettings.cpp
@@ -33,6 +33,7 @@
#include "behaviorsettings.h"
#include "behaviorsettingspage.h"
#include "completionsettings.h"
+#include "marginsettings.h"
#include "displaysettings.h"
#include "displaysettingspage.h"
#include "fontsettingspage.h"
@@ -299,6 +300,8 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
this, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)));
connect(d->m_behaviorSettingsPage, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
this, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)));
+ connect(d->m_displaySettingsPage, SIGNAL(marginSettingsChanged(TextEditor::MarginSettings)),
+ this, SIGNAL(marginSettingsChanged(TextEditor::MarginSettings)));
connect(d->m_displaySettingsPage, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)));
@@ -339,6 +342,8 @@ void TextEditorSettings::initializeEditor(BaseTextEditorWidget *editor)
editor, SLOT(setStorageSettings(TextEditor::StorageSettings)));
connect(m_instance, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
editor, SLOT(setBehaviorSettings(TextEditor::BehaviorSettings)));
+ connect(m_instance, SIGNAL(marginSettingsChanged(const TextEditor::MarginSettings &)),
+ editor, SLOT(setMarginSettings(TextEditor::MarginSettings)));
connect(m_instance, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
editor, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
connect(m_instance, SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)),
@@ -357,6 +362,7 @@ void TextEditorSettings::initializeEditor(BaseTextEditorWidget *editor)
editor->setTypingSettings(typingSettings());
editor->setStorageSettings(storageSettings());
editor->setBehaviorSettings(behaviorSettings());
+ editor->setMarginSettings(marginSettings());
editor->setDisplaySettings(displaySettings());
editor->setCompletionSettings(completionSettings());
editor->setExtraEncodingSettings(extraEncodingSettings());
@@ -383,6 +389,11 @@ const BehaviorSettings &TextEditorSettings::behaviorSettings()
return d->m_behaviorSettingsPage->behaviorSettings();
}
+const MarginSettings &TextEditorSettings::marginSettings()
+{
+ return d->m_displaySettingsPage->marginSettings();
+}
+
const DisplaySettings &TextEditorSettings::displaySettings()
{
return d->m_displaySettingsPage->displaySettings();
diff --git a/src/plugins/texteditor/texteditorsettings.h b/src/plugins/texteditor/texteditorsettings.h
index 7758e35e47..7a7a779a16 100644
--- a/src/plugins/texteditor/texteditorsettings.h
+++ b/src/plugins/texteditor/texteditorsettings.h
@@ -49,6 +49,7 @@ class TabSettings;
class TypingSettings;
class StorageSettings;
class BehaviorSettings;
+class MarginSettings;
class DisplaySettings;
class CompletionSettings;
class HighlighterSettings;
@@ -78,6 +79,7 @@ public:
static const TypingSettings &typingSettings();
static const StorageSettings &storageSettings();
static const BehaviorSettings &behaviorSettings();
+ static const MarginSettings &marginSettings();
static const DisplaySettings &displaySettings();
static const CompletionSettings &completionSettings();
static const HighlighterSettings &highlighterSettings();
@@ -109,6 +111,7 @@ signals:
void typingSettingsChanged(const TextEditor::TypingSettings &);
void storageSettingsChanged(const TextEditor::StorageSettings &);
void behaviorSettingsChanged(const TextEditor::BehaviorSettings &);
+ void marginSettingsChanged(const TextEditor::MarginSettings &);
void displaySettingsChanged(const TextEditor::DisplaySettings &);
void completionSettingsChanged(const TextEditor::CompletionSettings &);
void extraEncodingSettingsChanged(const TextEditor::ExtraEncodingSettings &);
diff --git a/src/plugins/todo/optionsdialog.ui b/src/plugins/todo/optionsdialog.ui
index d8b4f6d963..b07912b5e9 100644
--- a/src/plugins/todo/optionsdialog.ui
+++ b/src/plugins/todo/optionsdialog.ui
@@ -87,14 +87,14 @@
<bool>true</bool>
</property>
<property name="text">
- <string>Scan in the whole project</string>
+ <string>Scan the whole active project</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="scanInCurrentFileRadioButton">
<property name="text">
- <string>Scan in the current opened file</string>
+ <string>Scan only the currently edited document</string>
</property>
<property name="checked">
<bool>true</bool>
diff --git a/src/plugins/todo/optionspage.cpp b/src/plugins/todo/optionspage.cpp
index 3724895524..94ecc6078c 100644
--- a/src/plugins/todo/optionspage.cpp
+++ b/src/plugins/todo/optionspage.cpp
@@ -45,7 +45,7 @@ namespace Internal {
OptionsPage::OptionsPage(const Settings &settings, QObject *parent) :
IOptionsPage(parent),
- m_dialog(0)
+ m_widget(0)
{
setSettings(settings);
@@ -61,16 +61,18 @@ void OptionsPage::setSettings(const Settings &settings)
m_settings = settings;
}
-QWidget *OptionsPage::createPage(QWidget *parent)
+QWidget *OptionsPage::widget()
{
- m_dialog = new OptionsDialog(parent);
- m_dialog->setSettings(m_settings);
- return m_dialog;
+ if (!m_widget) {
+ m_widget = new OptionsDialog;
+ m_widget->setSettings(m_settings);
+ }
+ return m_widget;
}
void OptionsPage::apply()
{
- Settings newSettings = m_dialog->settings();
+ Settings newSettings = m_widget->settings();
if (newSettings != m_settings) {
m_settings = newSettings;
@@ -80,11 +82,7 @@ void OptionsPage::apply()
void OptionsPage::finish()
{
-}
-
-bool OptionsPage::matches(const QString &searchKeyWord) const
-{
- return searchKeyWord == QLatin1String("todo");
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/todo/optionspage.h b/src/plugins/todo/optionspage.h
index bec2354620..7b16e3aee9 100644
--- a/src/plugins/todo/optionspage.h
+++ b/src/plugins/todo/optionspage.h
@@ -35,6 +35,8 @@
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
namespace Todo {
namespace Internal {
@@ -49,16 +51,15 @@ public:
void setSettings(const Settings &settings);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &searchKeyWord) const;
signals:
void settingsChanged(const Settings &settings);
private:
- OptionsDialog *m_dialog;
+ QPointer<OptionsDialog> m_widget;
Settings m_settings;
};
diff --git a/src/plugins/todo/todooutputpane.cpp b/src/plugins/todo/todooutputpane.cpp
index 2e90342145..c937c1cc99 100755
--- a/src/plugins/todo/todooutputpane.cpp
+++ b/src/plugins/todo/todooutputpane.cpp
@@ -194,13 +194,13 @@ void TodoOutputPane::createScopeButtons()
{
m_currentFileButton = new QToolButton();
m_currentFileButton->setCheckable(true);
- m_currentFileButton->setText(tr("Current File"));
- m_currentFileButton->setToolTip(tr("Scan in the current opened file"));
+ m_currentFileButton->setText(tr("Current Document"));
+ m_currentFileButton->setToolTip(tr("Scan only the currently edited document."));
m_wholeProjectButton = new QToolButton();
m_wholeProjectButton->setCheckable(true);
- m_wholeProjectButton->setText(tr("Whole Project"));
- m_wholeProjectButton->setToolTip(tr("Scan in the whole project"));
+ m_wholeProjectButton->setText(tr("Active Project"));
+ m_wholeProjectButton->setToolTip(tr("Scan the whole active project."));
m_scopeButtons = new QButtonGroup();
m_scopeButtons->addButton(m_wholeProjectButton);
diff --git a/src/plugins/updateinfo/settingspage.cpp b/src/plugins/updateinfo/settingspage.cpp
index 80ad3c9500..d5373c85a8 100644
--- a/src/plugins/updateinfo/settingspage.cpp
+++ b/src/plugins/updateinfo/settingspage.cpp
@@ -36,7 +36,7 @@ using namespace UpdateInfo;
using namespace UpdateInfo::Internal;
SettingsPage::SettingsPage(UpdateInfoPlugin *plugin)
- : m_page(0)
+ : m_widget(0)
, m_plugin(plugin)
{
setId(Constants::FILTER_OPTIONS_PAGE);
@@ -46,15 +46,15 @@ SettingsPage::SettingsPage(UpdateInfoPlugin *plugin)
setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE));
}
-QWidget *SettingsPage::createPage(QWidget *parent)
+QWidget *SettingsPage::widget()
{
- m_page = new QWidget(parent);
- m_ui.setupUi(m_page);
- if (m_searchKeywords.isEmpty())
- m_searchKeywords = m_ui.m_info->text();
- m_ui.m_timeTable->setItemText(m_ui.m_timeTable->currentIndex(), QTime(m_plugin->scheduledUpdateTime())
- .toString(QLatin1String("hh:mm")));
- return m_page;
+ if (!m_widget) {
+ m_widget = new QWidget;
+ m_ui.setupUi(m_widget);
+ m_ui.m_timeTable->setItemText(m_ui.m_timeTable->currentIndex(), QTime(m_plugin->scheduledUpdateTime())
+ .toString(QLatin1String("hh:mm")));
+ }
+ return m_widget;
}
void SettingsPage::apply()
@@ -66,9 +66,5 @@ void SettingsPage::apply()
void SettingsPage::finish()
{
-}
-
-bool SettingsPage::matches(const QString &searchKey) const
-{
- return m_searchKeywords.contains(searchKey, Qt::CaseInsensitive);
+ delete m_widget;
}
diff --git a/src/plugins/updateinfo/settingspage.h b/src/plugins/updateinfo/settingspage.h
index 4c7c65b02a..24bf944452 100644
--- a/src/plugins/updateinfo/settingspage.h
+++ b/src/plugins/updateinfo/settingspage.h
@@ -34,6 +34,8 @@
#include <coreplugin/dialogs/ioptionspage.h>
+#include <QPointer>
+
namespace UpdateInfo {
namespace Internal {
@@ -46,15 +48,13 @@ class SettingsPage : public Core::IOptionsPage
public:
explicit SettingsPage(UpdateInfoPlugin *plugin);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
void finish();
- bool matches(const QString &searchKey) const;
private:
- QWidget *m_page;
+ QPointer<QWidget> m_widget;
Ui::SettingsWidget m_ui;
- QString m_searchKeywords;
UpdateInfoPlugin *m_plugin;
};
diff --git a/src/plugins/valgrind/suppressiondialog.cpp b/src/plugins/valgrind/suppressiondialog.cpp
index 14fabc5f0c..c5b7bac661 100644
--- a/src/plugins/valgrind/suppressiondialog.cpp
+++ b/src/plugins/valgrind/suppressiondialog.cpp
@@ -158,6 +158,7 @@ SuppressionDialog::SuppressionDialog(MemcheckErrorView *view, const QList<Error>
}
m_fileChooser->setExpectedKind(Utils::PathChooser::File);
+ m_fileChooser->setHistoryCompleter(QLatin1String("Valgrind.Suppression.History"));
m_fileChooser->setPath(defaultSuppFile.fileName());
m_fileChooser->setPromptDialogFilter(QLatin1String("*.supp"));
m_fileChooser->setPromptDialogTitle(tr("Select Suppression File"));
diff --git a/src/plugins/valgrind/valgrindconfigwidget.cpp b/src/plugins/valgrind/valgrindconfigwidget.cpp
index 56b391b1c8..6efc85687c 100644
--- a/src/plugins/valgrind/valgrindconfigwidget.cpp
+++ b/src/plugins/valgrind/valgrindconfigwidget.cpp
@@ -55,6 +55,7 @@ ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings,
m_model = new QStandardItemModel(this);
m_ui->valgrindExeChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
+ m_ui->valgrindExeChooser->setHistoryCompleter(QLatin1String("Valgrind.Command.History"));
m_ui->valgrindExeChooser->setPromptDialogTitle(tr("Valgrind Command"));
updateUi();
diff --git a/src/plugins/valgrind/valgrindplugin.cpp b/src/plugins/valgrind/valgrindplugin.cpp
index 9ec9523048..d13aa27cb8 100644
--- a/src/plugins/valgrind/valgrindplugin.cpp
+++ b/src/plugins/valgrind/valgrindplugin.cpp
@@ -52,6 +52,7 @@
#include <QtPlugin>
#include <QCoreApplication>
+#include <QPointer>
using namespace Analyzer;
@@ -72,14 +73,25 @@ public:
setCategoryIcon(QLatin1String(":/images/analyzer_category.png"));
}
- QWidget *createPage(QWidget *parent) {
- return new ValgrindConfigWidget(theGlobalSettings, parent, true);
+ QWidget *widget()
+ {
+ if (!m_widget)
+ m_widget = new ValgrindConfigWidget(theGlobalSettings, 0, true);
+ return m_widget;
}
- void apply() {
+ void apply()
+ {
theGlobalSettings->writeSettings();
}
- void finish() {}
+
+ void finish()
+ {
+ delete m_widget;
+ }
+
+private:
+ QPointer<QWidget> m_widget;
};
class ValgrindAction : public AnalyzerAction
diff --git a/src/plugins/vcsbase/basecheckoutwizardpage.cpp b/src/plugins/vcsbase/basecheckoutwizardpage.cpp
index 5c2e60882b..672f3deea9 100644
--- a/src/plugins/vcsbase/basecheckoutwizardpage.cpp
+++ b/src/plugins/vcsbase/basecheckoutwizardpage.cpp
@@ -75,6 +75,7 @@ BaseCheckoutWizardPage::BaseCheckoutWizardPage(QWidget *parent) :
this, SLOT(slotChanged()));
d->ui.pathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
+ d->ui.pathChooser->setHistoryCompleter(QLatin1String("Vcs.CheckoutDir.History"));
connect(d->ui.pathChooser, SIGNAL(validChanged()), this, SLOT(slotChanged()));
d->ui.branchComboBox->setEnabled(false);
diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp
index ad27f66663..ea2fdf5b39 100644
--- a/src/plugins/vcsbase/basevcseditorfactory.cpp
+++ b/src/plugins/vcsbase/basevcseditorfactory.cpp
@@ -54,12 +54,10 @@ public:
BaseVcsEditorFactoryPrivate(const VcsBaseEditorParameters *t);
const VcsBaseEditorParameters *m_type;
- TextEditor::TextEditorActionHandler *m_editorHandler;
};
BaseVcsEditorFactoryPrivate::BaseVcsEditorFactoryPrivate(const VcsBaseEditorParameters *t) :
- m_type(t),
- m_editorHandler(new TextEditor::TextEditorActionHandler(t->context))
+ m_type(t)
{
}
@@ -71,6 +69,7 @@ BaseVcsEditorFactory::BaseVcsEditorFactory(const VcsBaseEditorParameters *t)
setId(t->id);
setDisplayName(QCoreApplication::translate("VCS", t->displayName));
addMimeType(t->mimeType);
+ new TextEditor::TextEditorActionHandler(this, t->context);
}
BaseVcsEditorFactory::~BaseVcsEditorFactory()
@@ -78,17 +77,13 @@ BaseVcsEditorFactory::~BaseVcsEditorFactory()
delete d;
}
-Core::IEditor *BaseVcsEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *BaseVcsEditorFactory::createEditor()
{
- VcsBaseEditorWidget *vcsEditor = createVcsBaseEditor(d->m_type, parent);
+ VcsBaseEditorWidget *vcsEditor = createVcsBaseEditor(d->m_type);
- vcsEditor->setMimeType(mimeTypes().front());
- d->m_editorHandler->setupActions(vcsEditor);
+ vcsEditor->baseTextDocument()->setMimeType(mimeTypes().front());
- // Wire font settings and set initial values
- connect(TextEditor::TextEditorSettings::instance(), SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
- vcsEditor, SLOT(setFontSettings(TextEditor::FontSettings)));
- vcsEditor->setFontSettings(TextEditor::TextEditorSettings::fontSettings());
+ TextEditor::TextEditorSettings::initializeEditor(vcsEditor);
return vcsEditor->editor();
}
diff --git a/src/plugins/vcsbase/basevcseditorfactory.h b/src/plugins/vcsbase/basevcseditorfactory.h
index a58cb20e43..d239b85e56 100644
--- a/src/plugins/vcsbase/basevcseditorfactory.h
+++ b/src/plugins/vcsbase/basevcseditorfactory.h
@@ -48,13 +48,13 @@ public:
explicit BaseVcsEditorFactory(const VcsBaseEditorParameters *type);
~BaseVcsEditorFactory();
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
private:
// Implement to create and initialize (call init()) a
// VcsBaseEditor subclass
virtual VcsBaseEditorWidget *createVcsBaseEditor(const VcsBaseEditorParameters *type,
- QWidget *parent) = 0;
+ QWidget *parent = 0) = 0;
Internal::BaseVcsEditorFactoryPrivate *const d;
};
@@ -70,7 +70,7 @@ public:
private:
VcsBaseEditorWidget *createVcsBaseEditor(const VcsBaseEditorParameters *type,
- QWidget *parent);
+ QWidget *parent = 0);
QObject *m_describeReceiver;
const char *m_describeSlot;
};
diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp
index 15a1f1eb3d..08c265006c 100644
--- a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp
+++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp
@@ -44,9 +44,9 @@ BaseVcsSubmitEditorFactory::~BaseVcsSubmitEditorFactory()
{
}
-Core::IEditor *BaseVcsSubmitEditorFactory::createEditor(QWidget *parent)
+Core::IEditor *BaseVcsSubmitEditorFactory::createEditor()
{
- return createBaseSubmitEditor(m_parameters, parent);
+ return createBaseSubmitEditor(m_parameters);
}
} // namespace VcsBase
diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.h b/src/plugins/vcsbase/basevcssubmiteditorfactory.h
index fa6dbff0bf..acf91cb3a4 100644
--- a/src/plugins/vcsbase/basevcssubmiteditorfactory.h
+++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.h
@@ -50,12 +50,12 @@ protected:
~BaseVcsSubmitEditorFactory();
public:
- Core::IEditor *createEditor(QWidget *parent);
+ Core::IEditor *createEditor();
private:
virtual VcsBaseSubmitEditor
*createBaseSubmitEditor(const VcsBaseSubmitEditorParameters *parameters,
- QWidget *parent) = 0;
+ QWidget *parent = 0) = 0;
const VcsBaseSubmitEditorParameters *const m_parameters; // Not owned.
};
@@ -74,7 +74,7 @@ public:
private:
VcsBaseSubmitEditor *createBaseSubmitEditor
- (const VcsBaseSubmitEditorParameters *parameters, QWidget *parent)
+ (const VcsBaseSubmitEditorParameters *parameters, QWidget *parent = 0)
{
return new Editor(parameters, parent);
}
diff --git a/src/plugins/vcsbase/commonsettingspage.cpp b/src/plugins/vcsbase/commonsettingspage.cpp
index ccb423df12..d10258fb27 100644
--- a/src/plugins/vcsbase/commonsettingspage.cpp
+++ b/src/plugins/vcsbase/commonsettingspage.cpp
@@ -48,13 +48,18 @@ CommonSettingsWidget::CommonSettingsWidget(QWidget *parent) :
{
m_ui->setupUi(this);
m_ui->submitMessageCheckScriptChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
+ m_ui->submitMessageCheckScriptChooser->setHistoryCompleter(QLatin1String("Vcs.MessageCheckScript.History"));
m_ui->nickNameFieldsFileChooser->setExpectedKind(Utils::PathChooser::File);
+ m_ui->nickNameFieldsFileChooser->setHistoryCompleter(QLatin1String("Vcs.NickFields.History"));
m_ui->nickNameMailMapChooser->setExpectedKind(Utils::PathChooser::File);
+ m_ui->nickNameMailMapChooser->setHistoryCompleter(QLatin1String("Vcs.NickMap.History"));
m_ui->sshPromptChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
+ m_ui->sshPromptChooser->setHistoryCompleter(QLatin1String("Vcs.SshPrompt.History"));
const QString patchToolTip = tr("Command used for reverting diff chunks");
m_ui->patchCommandLabel->setToolTip(patchToolTip);
m_ui->patchChooser->setToolTip(patchToolTip);
m_ui->patchChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
+ m_ui->patchChooser->setHistoryCompleter(QLatin1String("Vcs.PatchCommand.History"));
}
CommonSettingsWidget::~CommonSettingsWidget()
@@ -110,12 +115,12 @@ CommonOptionsPage::CommonOptionsPage(QObject *parent) :
setDisplayName(QCoreApplication::translate("VcsBase", Constants::VCS_COMMON_SETTINGS_NAME));
}
-QWidget *CommonOptionsPage::createPage(QWidget *parent)
+QWidget *CommonOptionsPage::widget()
{
- m_widget = new CommonSettingsWidget(parent);
- m_widget->setSettings(m_settings);
- if (m_searchKeyWords.isEmpty())
- m_searchKeyWords = m_widget->searchKeyWordMatchString();
+ if (!m_widget) {
+ m_widget = new CommonSettingsWidget;
+ m_widget->setSettings(m_settings);
+ }
return m_widget;
}
@@ -131,9 +136,9 @@ void CommonOptionsPage::apply()
}
}
-bool CommonOptionsPage::matches(const QString &key) const
+void CommonOptionsPage::finish()
{
- return m_searchKeyWords.contains(key, Qt::CaseInsensitive);
+ delete m_widget;
}
} // namespace Internal
diff --git a/src/plugins/vcsbase/commonsettingspage.h b/src/plugins/vcsbase/commonsettingspage.h
index ebd8b5aac4..3917b86cdc 100644
--- a/src/plugins/vcsbase/commonsettingspage.h
+++ b/src/plugins/vcsbase/commonsettingspage.h
@@ -34,6 +34,7 @@
#include "vcsbaseoptionspage.h"
+#include <QPointer>
#include <QWidget>
namespace VcsBase {
@@ -65,10 +66,9 @@ class CommonOptionsPage : public VcsBaseOptionsPage
public:
explicit CommonOptionsPage(QObject *parent = 0);
- QWidget *createPage(QWidget *parent);
+ QWidget *widget();
void apply();
- void finish() { }
- bool matches(const QString &key) const;
+ void finish();
CommonVcsSettings settings() const { return m_settings; }
@@ -76,9 +76,8 @@ signals:
void settingsChanged(const VcsBase::Internal::CommonVcsSettings &s);
private:
- CommonSettingsWidget *m_widget;
+ QPointer<CommonSettingsWidget> m_widget;
CommonVcsSettings m_settings;
- QString m_searchKeyWords;
};
} // namespace Internal
diff --git a/src/plugins/vcsbase/vcsbase.qbs b/src/plugins/vcsbase/vcsbase.qbs
index ff0b5ce8e8..1abc87493e 100644
--- a/src/plugins/vcsbase/vcsbase.qbs
+++ b/src/plugins/vcsbase/vcsbase.qbs
@@ -8,7 +8,6 @@ QtcPlugin {
Depends { name: "Core" }
Depends { name: "TextEditor" }
Depends { name: "ProjectExplorer" }
- Depends { name: "Find" }
Depends { name: "Qt.widgets" }
Depends { name: "CppTools" }
Depends { name: "CPlusPlus" }
diff --git a/src/plugins/vcsbase/vcsbase_dependencies.pri b/src/plugins/vcsbase/vcsbase_dependencies.pri
index c089267094..7126e57c9f 100644
--- a/src/plugins/vcsbase/vcsbase_dependencies.pri
+++ b/src/plugins/vcsbase/vcsbase_dependencies.pri
@@ -3,5 +3,4 @@ QTC_PLUGIN_DEPENDS += \
coreplugin \
texteditor \
projectexplorer \
- find \
cpptools
diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp
index 31ab75cd64..b4ff6833d8 100644
--- a/src/plugins/vcsbase/vcsbaseclient.cpp
+++ b/src/plugins/vcsbase/vcsbaseclient.cpp
@@ -367,7 +367,9 @@ void VcsBaseClient::diff(const QString &workingDir, const QStringList &files,
QStringList args;
const QStringList paramArgs = paramWidget != 0 ? paramWidget->arguments() : QStringList();
args << vcsCmdString << extraOptions << paramArgs << files;
+ QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VcsBase::VcsBaseEditorWidget::getCodec(source);
Command *command = createCommand(workingDir, editor);
+ command->setCodec(codec);
enqueueJob(command, args, exitCodeInterpreter(DiffCommand, command));
}
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index 7f42d12ada..5719977170 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -562,7 +562,6 @@ public:
const VcsBaseEditorParameters *m_parameters;
- QString m_source;
QString m_workingDirectory;
QRegExp m_diffFilePattern;
@@ -658,7 +657,7 @@ VcsBaseEditorWidget::VcsBaseEditorWidget(const VcsBaseEditorParameters *type, QW
d(new Internal::VcsBaseEditorWidgetPrivate(this, type))
{
viewport()->setMouseTracking(true);
- setMimeType(QLatin1String(d->m_parameters->mimeType));
+ baseTextDocument()->setMimeType(QLatin1String(d->m_parameters->mimeType));
}
void VcsBaseEditorWidget::setDiffFilePattern(const QRegExp &pattern)
@@ -738,12 +737,12 @@ void VcsBaseEditorWidget::setForceReadOnly(bool b)
QString VcsBaseEditorWidget::source() const
{
- return d->m_source;
+ return VcsBasePlugin::source(editor());
}
void VcsBaseEditorWidget::setSource(const QString &source)
{
- d->m_source = source;
+ VcsBasePlugin::setSource(editor(), source);
}
QString VcsBaseEditorWidget::annotateRevisionTextFormat() const
diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp
index 732349e0f6..2d3d261ad2 100644
--- a/src/plugins/vcsbase/vcsbaseplugin.cpp
+++ b/src/plugins/vcsbase/vcsbaseplugin.cpp
@@ -241,8 +241,7 @@ void StateListener::slotStateChanged()
const QList<Core::IEditor *> editors =
Core::EditorManager::documentModel()->editorsForDocument(currentDocument);
if (!editors.isEmpty()) {
- if (QWidget *editorWidget = editors.first()->widget())
- state.currentFile = editorWidget->property("source").toString();
+ state.currentFile = VcsBasePlugin::source(editors.first());
}
}
}
@@ -749,6 +748,18 @@ bool VcsBasePlugin::isSshPromptConfigured()
return !sshPrompt().isEmpty();
}
+static const char SOURCE_PROPERTY[] = "qtcreator_source";
+
+void VcsBasePlugin::setSource(Core::IEditor *editor, const QString &source)
+{
+ editor->setProperty(SOURCE_PROPERTY, source);
+}
+
+QString VcsBasePlugin::source(Core::IEditor *editor)
+{
+ return editor->property(SOURCE_PROPERTY).toString();
+}
+
void VcsBasePlugin::setProcessEnvironment(QProcessEnvironment *e,
bool forceCLocale,
const QString &sshPromptBinary)
diff --git a/src/plugins/vcsbase/vcsbaseplugin.h b/src/plugins/vcsbase/vcsbaseplugin.h
index 03d18b687b..193971b2d6 100644
--- a/src/plugins/vcsbase/vcsbaseplugin.h
+++ b/src/plugins/vcsbase/vcsbaseplugin.h
@@ -48,6 +48,7 @@ namespace Utils { struct SynchronousProcessResponse; }
namespace Core {
class IVersionControl;
class Id;
+class IEditor;
}
namespace VcsBase {
@@ -155,6 +156,11 @@ public:
// Returns whether an SSH prompt is configured.
static bool isSshPromptConfigured();
+ // Sets the source of editor contents, can be directory or file.
+ static void setSource(Core::IEditor *editor, const QString &source);
+ // Returns the source of editor contents.
+ static QString source(Core::IEditor *editor);
+
// Convenience to synchronously run VCS commands
enum RunVcsFlags {
ShowStdOutInLogWindow = 0x1, // Append standard output to VCS output window.
diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
index 069b867ad1..3aafe9398f 100644
--- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
+++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
@@ -46,7 +46,7 @@
#include <utils/synchronousprocess.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
-#include <find/basetextfind.h>
+#include <coreplugin/find/basetextfind.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditorsettings.h>
@@ -241,7 +241,7 @@ VcsBaseSubmitEditor::VcsBaseSubmitEditor(const VcsBaseSubmitEditorParameters *pa
this, SLOT(slotRefreshCommitData()), Qt::QueuedConnection);
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
- aggregate->add(new Find::BaseTextFind(descriptionEdit));
+ aggregate->add(new Core::BaseTextFind(descriptionEdit));
aggregate->add(this);
}
diff --git a/src/qtcreatorplugin.pri b/src/qtcreatorplugin.pri
index c243fa1180..21dc0d78ce 100644
--- a/src/qtcreatorplugin.pri
+++ b/src/qtcreatorplugin.pri
@@ -105,19 +105,15 @@ greaterThan(QT_MAJOR_VERSION, 4) {
pluginspec2json.input = PLUGINSPEC
pluginspec2json.variable_out = GENERATED_FILES
pluginspec2json.output = $${TARGET}.json
- pluginspec2json.commands = $$XMLPATTERNS -no-format -output $$pluginspec2json.output $$PWD/pluginjsonmetadata.xsl $$PLUGINSPEC
+ pluginspec2json.commands = $$XMLPATTERNS -no-format -output $$pluginspec2json.output $$PWD/qtcreatorplugin2json.xsl $$PLUGINSPEC
pluginspec2json.CONFIG += no_link
moc_header.depends += $$pluginspec2json.output
QMAKE_EXTRA_COMPILERS += pluginspec2json
}
macx {
- !isEmpty(TIGER_COMPAT_MODE) {
- QMAKE_LFLAGS_SONAME = -Wl,-install_name,@executable_path/../PlugIns/$${PROVIDER}/
- } else {
- QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/PlugIns/$${PROVIDER}/
- QMAKE_LFLAGS += -Wl,-rpath,@loader_path/../../,-rpath,@executable_path/../
- }
+ QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/PlugIns/$${PROVIDER}/
+ QMAKE_LFLAGS += -Wl,-rpath,@loader_path/../../,-rpath,@executable_path/../
} else:linux-* {
#do the rpath by hand since it's not possible to use ORIGIN in QMAKE_RPATHDIR
QMAKE_RPATHDIR += \$\$ORIGIN
diff --git a/src/pluginjsonmetadata.xsl b/src/qtcreatorplugin2json.xsl
index bd85083a00..bd85083a00 100644
--- a/src/pluginjsonmetadata.xsl
+++ b/src/qtcreatorplugin2json.xsl
diff --git a/src/rpath.pri b/src/rpath.pri
index c352a823b3..de56f11ae5 100644
--- a/src/rpath.pri
+++ b/src/rpath.pri
@@ -1,10 +1,6 @@
macx {
- !isEmpty(TIGER_COMPAT_MODE) {
- QMAKE_LFLAGS_SONAME = -Wl,-install_name,@executable_path/../PlugIns/
- } else {
- QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/PlugIns/
- QMAKE_LFLAGS += -Wl,-rpath,@loader_path/../,-rpath,@executable_path/../
- }
+ QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/PlugIns/
+ QMAKE_LFLAGS += -Wl,-rpath,@loader_path/../,-rpath,@executable_path/../
} else:linux-* {
#do the rpath by hand since it's not possible to use ORIGIN in QMAKE_RPATHDIR
# this expands to $ORIGIN (after qmake and make), it does NOT read a qmake var
diff --git a/src/tools/buildoutputparser/buildoutputparser.pro b/src/tools/buildoutputparser/buildoutputparser.pro
new file mode 100644
index 0000000000..5b9aa4ea24
--- /dev/null
+++ b/src/tools/buildoutputparser/buildoutputparser.pro
@@ -0,0 +1,25 @@
+TEMPLATE = app
+TARGET = buildoutputparser
+QTC_LIB_DEPENDS = utils
+QTC_PLUGIN_DEPENDS = projectexplorer qtsupport qmakeprojectmanager
+
+QT = core gui
+CONFIG += console
+CONFIG -= app_bundle
+
+include(../../../qtcreator.pri)
+include(../../rpath.pri)
+
+LIBS += -L$$IDE_PLUGIN_PATH/QtProject
+win32|equals(TEST, 1):DEFINES += HAS_MSVC_PARSER
+
+DESTDIR = $$IDE_BIN_PATH
+target.path = /bin
+INSTALLS += target
+
+SOURCES = \
+ main.cpp \
+ outputprocessor.cpp
+
+HEADERS = \
+ outputprocessor.h
diff --git a/src/tools/buildoutputparser/buildoutputparser.qbs b/src/tools/buildoutputparser/buildoutputparser.qbs
new file mode 100644
index 0000000000..f1fbd8f795
--- /dev/null
+++ b/src/tools/buildoutputparser/buildoutputparser.qbs
@@ -0,0 +1,20 @@
+import qbs
+import QtcTool
+
+QtcTool {
+ name: "buildoutputparser"
+ Depends { name: "Qt"; submodules: ["core", "widgets"]; }
+ Depends { name: "ProjectExplorer" }
+ Depends { name: "QtSupport" }
+ Depends { name: "QmakeProjectManager" }
+ Depends { name: "Utils" }
+ files: [
+ "main.cpp",
+ "outputprocessor.cpp", "outputprocessor.h",
+ ]
+ cpp.rpaths: base.concat(qbs.targetOS.contains("osx")
+ ? ["@executable_path/../"]
+ : ["$ORIGIN/../" + project.ide_plugin_path + "/QtProject"])
+ cpp.defines: base.concat(qbs.targetOS.contains("windows") || project.testsEnabled
+ ? ["HAS_MSVC_PARSER"] : [])
+}
diff --git a/src/tools/buildoutputparser/main.cpp b/src/tools/buildoutputparser/main.cpp
new file mode 100644
index 0000000000..2953567097
--- /dev/null
+++ b/src/tools/buildoutputparser/main.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "outputprocessor.h"
+
+#include <QCoreApplication>
+#include <QFile>
+#include <QMetaObject>
+#include <QFileInfo>
+#include <QStringList>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+static void printUsage()
+{
+ fprintf(stderr, "Usage: %s [--type <compiler type>] <file>\n",
+ qPrintable(QFileInfo(QCoreApplication::applicationFilePath()).fileName()));
+ fprintf(stderr, "Possible compiler types: gcc, clang%s. Default is gcc.\n",
+#ifdef HAS_MSVC_PARSER
+ ", msvc"
+#else
+ ""
+#endif
+ );
+}
+
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication app(argc, argv);
+
+ QStringList args = app.arguments().mid(1);
+ QString filePath;
+ CompilerType compilerType = CompilerTypeGcc;
+ while (filePath.isEmpty() && !args.isEmpty()) {
+ const QString currentArg = args.takeFirst();
+ if (currentArg == QLatin1String("--type")) {
+ if (args.isEmpty()) {
+ fprintf(stderr, "Error: Option --type needs argument.\n");
+ printUsage();
+ return EXIT_FAILURE;
+ }
+ const QString typeString = args.takeFirst();
+ if (typeString == QLatin1String("gcc")) {
+ compilerType = CompilerTypeGcc;
+ } else if (typeString == QLatin1String("clang")) {
+ compilerType = CompilerTypeClang;
+#ifdef HAS_MSVC_PARSER
+ } else if (typeString == QLatin1String("msvc")) {
+ compilerType = CompilerTypeMsvc;
+#endif
+ } else {
+ fprintf(stderr, "Invalid compiler type '%s'.\n", qPrintable(typeString));
+ printUsage();
+ return EXIT_FAILURE;
+ }
+ } else {
+ filePath = currentArg;
+ }
+ }
+
+ if (filePath.isEmpty()) {
+ fprintf(stderr, "Error: No file supplied.\n");
+ printUsage();
+ return EXIT_FAILURE;
+ }
+
+ if (!args.isEmpty())
+ qDebug("Ignoring extraneous parameters '%s'.\n", qPrintable(args.join(QLatin1String(" "))));
+
+ QFile compilerOutputFile(filePath);
+ if (!compilerOutputFile.open(QIODevice::ReadOnly)) {
+ fprintf(stderr, "Error opening file '%s': %s\n", qPrintable(compilerOutputFile.fileName()),
+ qPrintable(compilerOutputFile.errorString()));
+ return EXIT_FAILURE;
+ }
+ CompilerOutputProcessor cop(compilerType, compilerOutputFile);
+ QMetaObject::invokeMethod(&cop, "start", Qt::QueuedConnection);
+ return app.exec();
+}
diff --git a/src/tools/buildoutputparser/outputprocessor.cpp b/src/tools/buildoutputparser/outputprocessor.cpp
new file mode 100644
index 0000000000..f83edfcb9a
--- /dev/null
+++ b/src/tools/buildoutputparser/outputprocessor.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "outputprocessor.h"
+
+#include <projectexplorer/clangparser.h>
+#include <projectexplorer/gccparser.h>
+#include <projectexplorer/gnumakeparser.h>
+#include <projectexplorer/osparser.h>
+#include <qmakeprojectmanager/qmakeparser.h>
+#include <qtsupport/qtparser.h>
+#include <utils/fileutils.h>
+
+#ifdef HAS_MSVC_PARSER
+#include <projectexplorer/msvcparser.h>
+#endif
+
+#include <QIODevice>
+#include <QTextStream>
+
+#include <stdio.h>
+
+CompilerOutputProcessor::CompilerOutputProcessor(CompilerType compilerType, QIODevice &source)
+ : m_compilerType(compilerType)
+ , m_source(source)
+ , m_ostream(new QTextStream(stdout, QIODevice::WriteOnly))
+{
+}
+
+CompilerOutputProcessor::~CompilerOutputProcessor()
+{
+ delete m_ostream;
+}
+
+void CompilerOutputProcessor::start()
+{
+ ProjectExplorer::OsParser parser;
+ parser.appendOutputParser(new QmakeProjectManager::QMakeParser);
+ parser.appendOutputParser(new ProjectExplorer::GnuMakeParser);
+ parser.appendOutputParser(new QtSupport::QtParser);
+ switch (m_compilerType) {
+ case CompilerTypeGcc:
+ parser.appendOutputParser(new ProjectExplorer::GccParser);
+ break;
+ case CompilerTypeClang:
+ parser.appendOutputParser(new ProjectExplorer::ClangParser);
+ break;
+#ifdef HAS_MSVC_PARSER
+ case CompilerTypeMsvc:
+ parser.appendOutputParser(new ProjectExplorer::MsvcParser);
+ break;
+#endif
+ }
+
+ connect(&parser, SIGNAL(addTask(ProjectExplorer::Task)),
+ SLOT(handleTask(ProjectExplorer::Task)));
+ while (!m_source.atEnd())
+ parser.stdError(QString::fromLocal8Bit(m_source.readLine().trimmed()));
+ qApp->quit();
+}
+
+void CompilerOutputProcessor::handleTask(const ProjectExplorer::Task &task)
+{
+ const QString &fileName = task.file.toString();
+ if (!fileName.isEmpty()) {
+ *m_ostream << fileName;
+ if (task.line != -1)
+ *m_ostream << ':' << task.line;
+ *m_ostream << ": ";
+ }
+ *m_ostream << task.description << endl;
+}
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer_p.h b/src/tools/buildoutputparser/outputprocessor.h
index 852431d718..821fd4f712 100644
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer_p.h
+++ b/src/tools/buildoutputparser/outputprocessor.h
@@ -27,36 +27,36 @@
**
****************************************************************************/
-#ifndef QDECLARATIVECANVASTIMER_P_H
-#define QDECLARATIVECANVASTIMER_P_H
-
-#include <QJSValue>
-#include <qtimer.h>
-#include <qlist.h>
+#include <QObject>
QT_BEGIN_NAMESPACE
+class QIODevice;
+class QTextStream;
+QT_END_NAMESPACE
+
+namespace ProjectExplorer { class Task; }
-class CanvasTimer : public QTimer
+enum CompilerType {
+ CompilerTypeGcc,
+ CompilerTypeClang
+#ifdef HAS_MSVC_PARSER
+ , CompilerTypeMsvc
+#endif
+};
+
+class CompilerOutputProcessor : public QObject
{
Q_OBJECT
-
public:
- CanvasTimer(QObject *parent, const QJSValue &data);
+ CompilerOutputProcessor(CompilerType compilerType, QIODevice &source);
+ ~CompilerOutputProcessor();
-public Q_SLOTS:
- void handleTimeout();
- bool equals(const QJSValue &value){return m_value.equals(value);}
-
-public:
- static void createTimer(QObject *parent, const QJSValue &val, long timeout, bool singleshot);
- static void removeTimer(CanvasTimer *timer);
- static void removeTimer(const QJSValue &);
+private slots:
+ void start();
+ void handleTask(const ProjectExplorer::Task &task);
private:
- QJSValue m_value;
-
+ const CompilerType m_compilerType;
+ QIODevice &m_source;
+ QTextStream * const m_ostream;
};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVECANVASTIMER_P_H
diff --git a/src/tools/sdktool/settings.cpp b/src/tools/sdktool/settings.cpp
index 74b5d18d6c..06c180cdca 100644
--- a/src/tools/sdktool/settings.cpp
+++ b/src/tools/sdktool/settings.cpp
@@ -77,6 +77,6 @@ Utils::FileName Settings::getPath(const QString &file)
result.appendPath(QLatin1String("debuggers"));
else
return Utils::FileName();
- result.append(QLatin1String(".xml"));
+ result.appendString(QLatin1String(".xml"));
return result;
}
diff --git a/src/tools/tools.pro b/src/tools/tools.pro
index 6785bb782a..de0e5d1be5 100644
--- a/src/tools/tools.pro
+++ b/src/tools/tools.pro
@@ -5,7 +5,8 @@ SUBDIRS = qtpromaker \
../plugins/cpaster/frontend \
sdktool \
valgrindfake \
- 3rdparty
+ 3rdparty \
+ buildoutputparser
win32 {
SUBDIRS += qtcdebugger
diff --git a/src/tools/tools.qbs b/src/tools/tools.qbs
index 454ee9b77f..38d2bcc20b 100644
--- a/src/tools/tools.qbs
+++ b/src/tools/tools.qbs
@@ -3,6 +3,7 @@ import qbs
Project {
name: "Tools"
references: [
+ "buildoutputparser/buildoutputparser.qbs",
"qtcdebugger/qtcdebugger.qbs",
"qtcreatorcrashhandler/qtcreatorcrashhandler.qbs",
"qtpromaker/qtpromaker.qbs",
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index cd17e2ea4d..d730f980d8 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -7,6 +7,7 @@ SUBDIRS += \
debugger \
diff \
extensionsystem \
+ externaltool \
environment \
generichighlighter \
profilewriter \
@@ -18,6 +19,12 @@ SUBDIRS += \
filesearch \
valgrind
-#contains (QT_CONFIG, declarative) {
-#SUBDIRS += qml
-#}
+lessThan(QT_MAJOR_VERSION, 5) {
+ contains(QT_CONFIG, declarative) {
+ SUBDIRS += qml
+ }
+} else {
+ qtHaveModule(declarative) {
+ SUBDIRS += qml
+ }
+}
diff --git a/tests/auto/cplusplus/cplusplus.pro b/tests/auto/cplusplus/cplusplus.pro
index c8258f9095..2a783402a0 100644
--- a/tests/auto/cplusplus/cplusplus.pro
+++ b/tests/auto/cplusplus/cplusplus.pro
@@ -9,7 +9,6 @@ SUBDIRS = \
preprocessor \
semantic \
typeprettyprinter \
- simplifytypes \
misc \
cxx11 \
checksymbols \
diff --git a/tests/auto/cplusplus/cplusplus.qbs b/tests/auto/cplusplus/cplusplus.qbs
index 0c64daffb2..c5ec28e1c6 100644
--- a/tests/auto/cplusplus/cplusplus.qbs
+++ b/tests/auto/cplusplus/cplusplus.qbs
@@ -13,7 +13,6 @@ Project {
"misc/misc.qbs",
"preprocessor/preprocessor.qbs",
"semantic/semantic.qbs",
- "simplifytypes/simplifytypes.qbs",
"typeprettyprinter/typeprettyprinter.qbs"
]
}
diff --git a/tests/auto/cplusplus/lexer/tst_lexer.cpp b/tests/auto/cplusplus/lexer/tst_lexer.cpp
index 54fee84ccf..8115399338 100644
--- a/tests/auto/cplusplus/lexer/tst_lexer.cpp
+++ b/tests/auto/cplusplus/lexer/tst_lexer.cpp
@@ -43,11 +43,11 @@ class tst_SimpleLexer: public QObject
Q_OBJECT
private slots:
- void doxygen_comments();
- void doxygen_comments_data();
+ void basic();
+ void basic_data();
};
-void tst_SimpleLexer::doxygen_comments()
+void tst_SimpleLexer::basic()
{
QFETCH(QByteArray, source);
QFETCH(QList<unsigned>, expectedTokenKindList);
@@ -70,7 +70,7 @@ void tst_SimpleLexer::doxygen_comments()
QVERIFY2(i == expectedTokenKindList.size(), "Less tokens than expected.");
}
-void tst_SimpleLexer::doxygen_comments_data()
+void tst_SimpleLexer::basic_data()
{
QTest::addColumn<QByteArray>("source");
QTest::addColumn<QList<unsigned> >("expectedTokenKindList");
@@ -165,6 +165,13 @@ void tst_SimpleLexer::doxygen_comments_data()
<< T_INT << T_IDENTIFIER << T_SEMICOLON << T_CPP_DOXY_COMMENT
<< T_INT << T_IDENTIFIER << T_SEMICOLON << T_CPP_DOXY_COMMENT << T_CPP_DOXY_COMMENT;
QTest::newRow(source) << source << expectedTokenKindList;
+
+ source = "?" "?(?" "?)?" "?<?" "?>a?b:c";
+ expectedTokenKindList = QList<unsigned>()
+ << T_LBRACKET << T_RBRACKET << T_LBRACE << T_RBRACE
+ << T_IDENTIFIER << T_QUESTION << T_IDENTIFIER << T_COLON << T_IDENTIFIER;
+ QTest::newRow(source) << source << expectedTokenKindList;
+
}
QTEST_APPLESS_MAIN(tst_SimpleLexer)
diff --git a/tests/auto/cplusplus/simplifytypes/simplifytypes.pro b/tests/auto/cplusplus/simplifytypes/simplifytypes.pro
deleted file mode 100644
index 7a952dbd25..0000000000
--- a/tests/auto/cplusplus/simplifytypes/simplifytypes.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-include(../shared/shared.pri)
-SOURCES += tst_simplifytypestest.cpp
diff --git a/tests/auto/cplusplus/simplifytypes/simplifytypes.qbs b/tests/auto/cplusplus/simplifytypes/simplifytypes.qbs
deleted file mode 100644
index 877a79e7a8..0000000000
--- a/tests/auto/cplusplus/simplifytypes/simplifytypes.qbs
+++ /dev/null
@@ -1,7 +0,0 @@
-import qbs
-import "../cplusplusautotest.qbs" as CPlusPlusAutotest
-
-CPlusPlusAutotest {
- name: "CPlusPlus simplify types autotest"
- files: "tst_simplifytypestest.cpp"
-}
diff --git a/tests/auto/debugger/debugger.pro b/tests/auto/debugger/debugger.pro
index c3a4c6770b..b280e39352 100644
--- a/tests/auto/debugger/debugger.pro
+++ b/tests/auto/debugger/debugger.pro
@@ -4,4 +4,5 @@ TEMPLATE = subdirs
SUBDIRS += gdb.pro
SUBDIRS += dumpers.pro
SUBDIRS += namedemangler.pro
+SUBDIRS += simplifytypes.pro
diff --git a/tests/auto/debugger/debugger.qbs b/tests/auto/debugger/debugger.qbs
index bd5b373e25..64230f1a0e 100644
--- a/tests/auto/debugger/debugger.qbs
+++ b/tests/auto/debugger/debugger.qbs
@@ -6,6 +6,7 @@ Project {
references: [
"dumpers.qbs",
"gdb.qbs",
- "namedemangler.qbs"
+ "namedemangler.qbs",
+ "simplifytypes.qbs"
]
}
diff --git a/tests/auto/debugger/dumpers.pro b/tests/auto/debugger/dumpers.pro
index 331ddc1024..2b23755c4c 100644
--- a/tests/auto/debugger/dumpers.pro
+++ b/tests/auto/debugger/dumpers.pro
@@ -1,37 +1,36 @@
+QT = core network
-QTC_LIB_DEPENDS += cplusplus utils
-QT += network
-QT -= gui
+win32-msvc* {
+ QTC_LIB_DEPENDS += utils
+}
include(../qttest.pri)
-DEBUGGERDIR = $$IDE_SOURCE_TREE/src/plugins/debugger
-DUMPERDIR = $$IDE_SOURCE_TREE/share/qtcreator/debugger
+win32-msvc* {
+ LIBS += -L$$IDE_PLUGIN_PATH/QtProject
+ DEFINES += Q_PLUGIN_PATH=\"\\\"$$IDE_PLUGIN_PATH/QtProject\\\"\"
-# To access the std::type rewriter
-DEFINES += CPLUSPLUS_BUILD_STATIC_LIB
-include($$IDE_SOURCE_TREE/src/rpath.pri)
-
-LIBS += -L$$IDE_PLUGIN_PATH/QtProject
-DEFINES += Q_PLUGIN_PATH=\"\\\"$$IDE_PLUGIN_PATH/QtProject\\\"\"
-
-win32 {
CDBEXT_PATH = $$IDE_BUILD_TREE\\$$IDE_LIBRARY_BASENAME
# replace '\' with '\\'
DEFINES += CDBEXT_PATH=\"\\\"$$replace(CDBEXT_PATH, \\\\, \\\\)\\\"\"
-} else {
- # empty string
- DEFINES += CDBEXT_PATH=\"\\\"\\\"\"
}
+DEBUGGERDIR = $$IDE_SOURCE_TREE/src/plugins/debugger
+DUMPERDIR = $$IDE_SOURCE_TREE/share/qtcreator/debugger
+
+include($$IDE_SOURCE_TREE/src/rpath.pri)
+
+
SOURCES += \
$$DEBUGGERDIR/debuggerprotocol.cpp \
+ $$DEBUGGERDIR/simplifytype.cpp \
$$DEBUGGERDIR/watchdata.cpp \
$$DEBUGGERDIR/watchutils.cpp \
tst_dumpers.cpp
HEADERS += \
$$DEBUGGERDIR/debuggerprotocol.h \
+ $$DEBUGGERDIR/simplifytype.h \
$$DEBUGGERDIR/watchdata.h \
$$DEBUGGERDIR/watchutils.h \
temporarydir.h
diff --git a/tests/auto/debugger/dumpers.qbs b/tests/auto/debugger/dumpers.qbs
index 816c4195a5..14fca2736e 100644
--- a/tests/auto/debugger/dumpers.qbs
+++ b/tests/auto/debugger/dumpers.qbs
@@ -3,10 +3,9 @@ import "../autotest.qbs" as Autotest
Autotest {
name: "Debugger dumpers autotest"
- Depends { name: "CPlusPlus" }
Depends { name: "Utils" }
- Depends { name: "Qt.widgets" } // For QTextDocument
Depends { name: "Qt.network" } // For QHostAddress
+ Depends { name: "Qt.widgets" }
Group {
name: "Sources from Debugger plugin"
prefix: project.debuggerDir
diff --git a/tests/auto/debugger/gdb.pro b/tests/auto/debugger/gdb.pro
index 2093381960..9cd6e1c475 100644
--- a/tests/auto/debugger/gdb.pro
+++ b/tests/auto/debugger/gdb.pro
@@ -1,5 +1,5 @@
QTC_LIB_DEPENDS += utils
-QT += network
+QT = core network
include(../qttest.pri)
DEBUGGERDIR = $$IDE_SOURCE_TREE/src/plugins/debugger
diff --git a/tests/auto/debugger/simplifytypes.pro b/tests/auto/debugger/simplifytypes.pro
new file mode 100644
index 0000000000..df645f1513
--- /dev/null
+++ b/tests/auto/debugger/simplifytypes.pro
@@ -0,0 +1,12 @@
+QTC_LIB_DEPENDS += utils
+include(../qttest.pri)
+QT += network
+QT -= gui widgets
+
+DEBUGGERDIR = $$IDE_SOURCE_TREE/src/plugins/debugger
+
+INCLUDEPATH += $$DEBUGGERDIR
+
+SOURCES += \
+ tst_simplifytypes.cpp \
+ $$DEBUGGERDIR/simplifytype.cpp \
diff --git a/tests/auto/debugger/simplifytypes.qbs b/tests/auto/debugger/simplifytypes.qbs
new file mode 100644
index 0000000000..a32d882397
--- /dev/null
+++ b/tests/auto/debugger/simplifytypes.qbs
@@ -0,0 +1,17 @@
+import qbs
+import "../autotest.qbs" as Autotest
+
+Autotest {
+ name: "simplifytypes autotest"
+ Depends { name: "Qt.network" } // For QHostAddress
+ Group {
+ name: "Sources from Debugger plugin"
+ prefix: project.debuggerDir
+ files: "debuggerprotocol.cpp"
+ }
+ Group {
+ name: "Test sources"
+ files: "tst_simplifytypes.cpp"
+ }
+ cpp.includePaths: base.concat([project.debuggerDir])
+}
diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp
index a499dd9014..e568a02395 100644
--- a/tests/auto/debugger/tst_dumpers.cpp
+++ b/tests/auto/debugger/tst_dumpers.cpp
@@ -28,14 +28,16 @@
****************************************************************************/
#include "debuggerprotocol.h"
+#include "simplifytype.h"
#include "watchdata.h"
#include "watchutils.h"
-#include <cplusplus/CppRewriter.h>
+#ifdef Q_CC_MSVC
#include <utils/environment.h>
#include <utils/qtcprocess.h>
#include <utils/fileutils.h>
#include <utils/synchronousprocess.h>
+#endif // Q_CC_MSVC
#include "temporarydir.h"
@@ -43,17 +45,17 @@
#include <math.h>
#if QT_VERSION >= 0x050000
-#define MSKIP_SINGLE(x) QSKIP(x)
+#define MSKIP_SINGLE(x) do { disarm(); QSKIP(x); } while (0)
#else
-#define MSKIP_SINGLE(x) QSKIP(x, SkipSingle)
+#define MSKIP_SINGLE(x) do { disarm(); QSKIP(x, SkipSingle); } while (0)
#endif
using namespace Debugger;
-using namespace Utils;
using namespace Internal;
-// Copied from abstractmsvctoolchain.cpp to avoid plugin dependency.
+#ifdef Q_CC_MSVC
+// Copied from abstractmsvctoolchain.cpp to avoid plugin dependency.
static bool generateEnvironmentSettings(Utils::Environment &env,
const QString &batchFile,
const QString &batchArgs,
@@ -144,6 +146,35 @@ static bool generateEnvironmentSettings(Utils::Environment &env,
return true;
}
+
+#ifndef CDBEXT_PATH
+#define CDBEXT_PATH ""
+#endif
+
+static void setupCdb(QString *makeBinary, QProcessEnvironment *environment)
+{
+ QByteArray envBat = qgetenv("QTC_MSVC_ENV_BAT");
+ QMap <QString, QString> envPairs;
+ Utils::Environment env = Utils::Environment::systemEnvironment();
+ QVERIFY(generateEnvironmentSettings(env, QString::fromLatin1(envBat), QString(), envPairs));
+ for (QMap<QString,QString>::const_iterator envIt = envPairs.begin(); envIt != envPairs.end(); ++envIt)
+ env.set(envIt.key(), envIt.value());
+ const QByteArray cdbextPath = CDBEXT_PATH "\\qtcreatorcdbext64";
+ QVERIFY(QFile::exists(QString::fromLatin1(cdbextPath + QByteArray("\\qtcreatorcdbext.dll"))));
+ env.appendOrSet(QLatin1String("_NT_DEBUGGER_EXTENSION_PATH"),
+ QString::fromLatin1(cdbextPath),
+ QLatin1String(";"));
+ *makeBinary = env.searchInPath(QLatin1String("nmake.exe"));
+ *environment = env.toProcessEnvironment();
+}
+
+#else
+
+static void setupCdb(QString *, QProcessEnvironment *) {}
+
+#endif // Q_CC_MSVC
+
+
static QByteArray noValue = "\001";
static QString toHex(const QString &str)
@@ -318,7 +349,7 @@ struct Type
}
}
QByteArray actualType =
- CPlusPlus::simplifySTLType(QString::fromLatin1(actualType0)).toLatin1();
+ simplifyType(QString::fromLatin1(actualType0)).toLatin1();
actualType.replace(' ', "");
actualType.replace("const", "");
QByteArray expectedType = type;
@@ -470,45 +501,56 @@ struct MacLibCppProfile : public Profile
{}
};
-struct GdbVersion
+struct VersionBase
{
// Minimum and maximum are inclusive.
- GdbVersion(int minimum = 0, int maximum = 0)
+ VersionBase(int minimum = 0, int maximum = INT_MAX)
{
- if (minimum && !maximum)
- maximum = minimum;
- if (maximum == 0)
- maximum = INT_MAX;
-
+ isRestricted = minimum != 0 || maximum != INT_MAX;
max = maximum;
min = minimum;
}
+
+ bool isRestricted;
int min;
int max;
};
-struct LldbVersion
+struct QtVersion : VersionBase
{
- // Minimum and maximum are inclusive.
- LldbVersion(int minimum = 0, int maximum = 0)
- {
- if (minimum && !maximum)
- maximum = minimum;
- if (maximum == 0)
- maximum = INT_MAX;
+ QtVersion(int minimum = 0, int maximum = INT_MAX)
+ : VersionBase(minimum, maximum)
+ {}
+};
- max = maximum;
- min = minimum;
- }
- int min;
- int max;
+struct GccVersion : VersionBase
+{
+ GccVersion(int minimum = 0, int maximum = INT_MAX)
+ : VersionBase(minimum, maximum)
+ {}
+};
+
+struct GdbVersion : VersionBase
+{
+ GdbVersion(int minimum = 0, int maximum = INT_MAX)
+ : VersionBase(minimum, maximum)
+ {}
+};
+
+struct LldbVersion : VersionBase
+{
+ LldbVersion(int minimum = 0, int maximum = INT_MAX)
+ : VersionBase(minimum, maximum)
+ {}
};
struct ForceC {};
+struct EigenProfile {};
struct CoreProfile {};
struct CorePrivateProfile {};
struct GuiProfile {};
+struct NetworkProfile {};
struct DataBase
{
@@ -525,6 +567,8 @@ struct DataBase
mutable bool glibcxxDebug;
mutable GdbVersion neededGdbVersion;
mutable LldbVersion neededLldbVersion;
+ mutable QtVersion neededQtVersion;
+ mutable GccVersion neededGccVersion;
};
class Data : public DataBase
@@ -549,6 +593,18 @@ public:
return *this;
}
+ const Data &operator%(const QtVersion &qtVersion) const
+ {
+ neededQtVersion = qtVersion;
+ return *this;
+ }
+
+ const Data &operator%(const GccVersion &gccVersion) const
+ {
+ neededGccVersion = gccVersion;
+ return *this;
+ }
+
const Data &operator%(const GdbVersion &gdbVersion) const
{
neededGdbVersion = gdbVersion;
@@ -567,6 +623,15 @@ public:
return *this;
}
+ const Data &operator%(const EigenProfile &) const
+ {
+ profileExtra +=
+ "INCLUDEPATH += /usr/include/eigen2\n"
+ "INCLUDEPATH += /usr/include/eigen3\n";
+
+ return *this;
+ }
+
const Data &operator%(const CoreProfile &) const
{
profileExtra +=
@@ -579,6 +644,18 @@ public:
return *this;
}
+ const Data &operator%(const NetworkProfile &) const
+ {
+ profileExtra +=
+ "CONFIG += QT\n"
+ "QT += core network\n";
+
+ useQt = true;
+ useQHash = true;
+
+ return *this;
+ }
+
const Data &operator%(const GuiProfile &) const
{
this->operator%(CoreProfile());
@@ -643,6 +720,8 @@ public:
m_gdbVersion = 0;
m_gdbBuildVersion = 0;
m_lldbVersion = 0;
+ m_qtVersion = 0;
+ m_gccVersion = 0;
m_isMacGdb = false;
m_isQnxGdb = false;
m_useGLibCxxDebug = false;
@@ -656,18 +735,21 @@ private slots:
void cleanup();
private:
+ void disarm() { t->buildTemp.setAutoRemove(!keepTemp()); }
bool keepTemp() const { return m_keepTemp || m_forceKeepTemp; }
TempStuff *t;
QByteArray m_debuggerBinary;
QByteArray m_qmakeBinary;
- Environment m_env;
- bool m_usePython;
+ QProcessEnvironment m_env;
DebuggerEngine m_debuggerEngine;
+ QString m_makeBinary;
bool m_keepTemp;
bool m_forceKeepTemp;
int m_gdbVersion; // 7.5.1 -> 70501
int m_gdbBuildVersion;
int m_lldbVersion;
+ int m_qtVersion; // 5.2.0 -> 50200
+ int m_gccVersion;
bool m_isMacGdb;
bool m_isQnxGdb;
bool m_useGLibCxxDebug;
@@ -684,7 +766,8 @@ void tst_Dumpers::initTestCase()
if (m_debuggerBinary.endsWith("cdb.exe"))
m_debuggerEngine = DumpTestCdbEngine;
- if (m_debuggerBinary.endsWith("lldb"))
+ QString base = QFileInfo(QString::fromLatin1(m_debuggerBinary)).baseName();
+ if (base.startsWith(QLatin1String("lldb")))
m_debuggerEngine = DumpTestLldbEngine;
m_qmakeBinary = qgetenv("QTC_QMAKE_PATH_FOR_TEST");
@@ -698,8 +781,6 @@ void tst_Dumpers::initTestCase()
m_forceKeepTemp = qgetenv("QTC_KEEP_TEMP_FOR_TEST").toInt();
qDebug() << "Force keep temp : " << m_forceKeepTemp;
- m_env = Environment::systemEnvironment();
-
if (m_debuggerEngine == DumpTestGdbEngine) {
QProcess debugger;
debugger.start(QString::fromLatin1(m_debuggerBinary)
@@ -710,9 +791,10 @@ void tst_Dumpers::initTestCase()
QVERIFY(ok);
QByteArray output = debugger.readAllStandardOutput();
//qDebug() << "stdout: " << output;
- m_usePython = !output.contains("Python scripting is not supported in this copy of GDB");
- qDebug() << "Python : " << (m_usePython ? "ok" : "*** not ok ***");
+ bool usePython = !output.contains("Python scripting is not supported in this copy of GDB");
+ qDebug() << "Python : " << (usePython ? "ok" : "*** not ok ***");
qDebug() << "Dumper dir : " << DUMPERDIR;
+ QVERIFY(usePython);
QString version = QString::fromLocal8Bit(output);
int pos1 = version.indexOf(QLatin1String("&\"show version\\n"));
@@ -724,20 +806,12 @@ void tst_Dumpers::initTestCase()
version = version.mid(pos1, pos2 - pos1);
extractGdbVersion(version, &m_gdbVersion,
&m_gdbBuildVersion, &m_isMacGdb, &m_isQnxGdb);
+ m_env = QProcessEnvironment::systemEnvironment();
+ m_makeBinary = QLatin1String("make");
qDebug() << "Gdb version : " << m_gdbVersion;
} else if (m_debuggerEngine == DumpTestCdbEngine) {
- QByteArray envBat = qgetenv("QTC_MSVC_ENV_BAT");
- QMap <QString, QString> envPairs;
- QVERIFY(generateEnvironmentSettings(m_env, QString::fromLatin1(envBat), QString(), envPairs));
- for (QMap<QString,QString>::const_iterator envIt = envPairs.begin(); envIt!=envPairs.end(); ++envIt)
- m_env.set(envIt.key(), envIt.value());
- const QByteArray cdbextPath = QByteArray(CDBEXT_PATH) + QByteArray("\\qtcreatorcdbext64");
- QVERIFY(QFile::exists(QString::fromLatin1(cdbextPath + QByteArray("\\qtcreatorcdbext.dll"))));
- m_env.appendOrSet(QLatin1String("_NT_DEBUGGER_EXTENSION_PATH"),
- QString::fromLatin1(cdbextPath),
- QLatin1String(";"));
+ setupCdb(&m_makeBinary, &m_env);
} else if (m_debuggerEngine == DumpTestLldbEngine) {
- m_usePython = true;
QProcess debugger;
QString cmd = QString::fromUtf8(m_debuggerBinary + " -v");
debugger.start(cmd);
@@ -746,14 +820,28 @@ void tst_Dumpers::initTestCase()
QByteArray output = debugger.readAllStandardOutput();
output += debugger.readAllStandardError();
output = output.trimmed();
- // Should be something like LLDB-178
+ // Should be something like "LLDB-178" (Mac OS X 10.8)
+ // or "lldb version 3.5 ( revision )" (Ubuntu 13.10)
QByteArray ba = output.mid(output.indexOf('-') + 1);
int pos = ba.indexOf('.');
if (pos >= 0)
ba = ba.left(pos);
m_lldbVersion = ba.toInt();
+ if (!m_lldbVersion) {
+ if (output.startsWith("lldb version")) {
+ int pos1 = output.indexOf('.', 13);
+ int major = output.mid(13, pos1++ - 13).toInt();
+ int pos2 = output.indexOf(' ', pos1);
+ int minor = output.mid(pos1, pos2++ - pos1).toInt();
+ m_lldbVersion = 100 * major + 10 * minor;
+ }
+ }
+
qDebug() << "Lldb version :" << output << ba << m_lldbVersion;
QVERIFY(m_lldbVersion);
+
+ m_env = QProcessEnvironment::systemEnvironment();
+ m_makeBinary = QLatin1String("make");
}
}
@@ -779,7 +867,7 @@ void tst_Dumpers::dumper()
if (!(data.engines & m_debuggerEngine))
MSKIP_SINGLE("The test is excluded for this debugger engine.");
- if (m_debuggerEngine == DumpTestGdbEngine) {
+ if (data.neededGdbVersion.isRestricted && m_debuggerEngine == DumpTestGdbEngine) {
if (data.neededGdbVersion.min > m_gdbVersion)
MSKIP_SINGLE("Need minimum GDB version "
+ QByteArray::number(data.neededGdbVersion.min));
@@ -788,11 +876,11 @@ void tst_Dumpers::dumper()
+ QByteArray::number(data.neededGdbVersion.max));
}
- if (m_debuggerEngine == DumpTestLldbEngine) {
- if (data.neededLldbVersion.min > m_gdbVersion)
+ if (data.neededLldbVersion.isRestricted && m_debuggerEngine == DumpTestLldbEngine) {
+ if (data.neededLldbVersion.min > m_lldbVersion)
MSKIP_SINGLE("Need minimum LLDB version "
+ QByteArray::number(data.neededLldbVersion.min));
- if (data.neededLldbVersion.max < m_gdbVersion)
+ if (data.neededLldbVersion.max < m_lldbVersion)
MSKIP_SINGLE("Need maximum LLDB version "
+ QByteArray::number(data.neededLldbVersion.max));
}
@@ -801,6 +889,67 @@ void tst_Dumpers::dumper()
QByteArray output;
QByteArray error;
+ if (data.neededQtVersion.isRestricted) {
+ QProcess qmake;
+ qmake.setWorkingDirectory(t->buildPath);
+ cmd = QString::fromLatin1(m_qmakeBinary);
+ qmake.start(cmd, QStringList(QLatin1String("--version")));
+ QVERIFY(qmake.waitForFinished());
+ output = qmake.readAllStandardOutput();
+ error = qmake.readAllStandardError();
+ int pos0 = output.indexOf("Qt version");
+ if (pos0 == -1) {
+ qDebug() << "Output: " << output;
+ qDebug() << "Error: " << error;
+ QVERIFY(false);
+ }
+ pos0 += 11;
+ int pos1 = output.indexOf('.', pos0 + 1);
+ int major = output.mid(pos0, pos1++ - pos0).toInt();
+ int pos2 = output.indexOf('.', pos1 + 1);
+ int minor = output.mid(pos1, pos2++ - pos1).toInt();
+ int pos3 = output.indexOf(' ', pos2 + 1);
+ int patch = output.mid(pos2, pos3++ - pos2).toInt();
+ m_qtVersion = 10000 * major + 100 * minor + patch;
+
+ if (data.neededQtVersion.min > m_qtVersion)
+ MSKIP_SINGLE("Need minimum Qt version "
+ + QByteArray::number(data.neededQtVersion.min));
+ if (data.neededQtVersion.max < m_qtVersion)
+ MSKIP_SINGLE("Need maximum Qt version "
+ + QByteArray::number(data.neededQtVersion.max));
+ }
+
+ if (data.neededGccVersion.isRestricted) {
+ QProcess gcc;
+ gcc.setWorkingDirectory(t->buildPath);
+ cmd = QLatin1String("gcc");
+ gcc.start(cmd, QStringList(QLatin1String("--version")));
+ QVERIFY(gcc.waitForFinished());
+ output = gcc.readAllStandardOutput();
+ error = gcc.readAllStandardError();
+ int pos = output.indexOf('\n');
+ if (pos != -1)
+ output = output.left(pos);
+ qDebug() << "Extracting GCC version from: " << output;
+ pos = output.lastIndexOf(' ');
+ output = output.mid(pos + 1);
+ int pos1 = output.indexOf('.');
+ int major = output.left(pos1++).toInt();
+ int pos2 = output.indexOf('.', pos1 + 1);
+ int minor = output.mid(pos1, pos2++ - pos1).toInt();
+ int patch = output.mid(pos2).toInt();
+ m_gccVersion = 10000 * major + 100 * minor + patch;
+ qDebug() << "GCC version: " << m_gccVersion;
+
+ if (data.neededGccVersion.min > m_gccVersion)
+ MSKIP_SINGLE("Need minimum GCC version "
+ + QByteArray::number(data.neededGccVersion.min));
+ if (data.neededGccVersion.max < m_gccVersion)
+ MSKIP_SINGLE("Need maximum GCC version "
+ + QByteArray::number(data.neededGccVersion.max));
+ }
+
const char *mainFile = data.forceC ? "main.c" : "main.cpp";
QFile proFile(t->buildPath + QLatin1String("/doit.pro"));
@@ -873,12 +1022,9 @@ void tst_Dumpers::dumper()
QProcess make;
make.setWorkingDirectory(t->buildPath);
- make.setProcessEnvironment(m_env.toProcessEnvironment());
+ make.setProcessEnvironment(m_env);
- cmd = m_debuggerEngine == DumpTestCdbEngine ? m_env.searchInPath(QLatin1String("nmake.exe"))
- : QLatin1String("make");
-
- make.start(cmd, QStringList());
+ make.start(m_makeBinary, QStringList());
QVERIFY(make.waitForFinished());
output = make.readAllStandardOutput();
error = make.readAllStandardError();
@@ -933,22 +1079,13 @@ void tst_Dumpers::dumper()
"set print object on\n"
"set auto-load python-scripts no\n";
- if (m_usePython) {
- cmds += "python sys.path.insert(1, '" + dumperDir + "')\n"
- "python sys.path.append('" + uninstalledData + "')\n"
- "python from gdbbridge import *\n"
- "run " + nograb + "\n"
- "python print('@%sS@%s@' % ('N', theDumper.qtNamespace()))\n"
- "bb options:fancy,autoderef,dyntype,pe vars: expanded:" + expanded + " typeformats:\n";
- } else {
- cmds += "run\n";
- foreach (const Check &check, data.checks) {
- QByteArray iname = check.iname;
- //qDebug() << "INAME: " << iname;
- cmds += "-var-create " + iname + " * "
- + check.expectedName.name + "\n";
- }
- }
+ cmds += "python sys.path.insert(1, '" + dumperDir + "')\n"
+ "python sys.path.append('" + uninstalledData + "')\n"
+ "python from gdbbridge import *\n"
+ "run " + nograb + "\n"
+ "python print('@%sS@%s@' % ('N', theDumper.qtNamespace()))\n"
+ "bb options:fancy,autoderef,dyntype,pe vars: expanded:" + expanded + " typeformats:\n";
+
cmds += "quit\n";
} else if (m_debuggerEngine == DumpTestCdbEngine) {
@@ -986,7 +1123,7 @@ void tst_Dumpers::dumper()
t->input = cmds;
QProcess debugger;
- debugger.setProcessEnvironment(m_env.toProcessEnvironment());
+ debugger.setProcessEnvironment(m_env);
debugger.setWorkingDirectory(t->buildPath);
debugger.start(QString::fromLatin1(exe), args);
QVERIFY(debugger.waitForStarted());
@@ -995,7 +1132,8 @@ void tst_Dumpers::dumper()
output = debugger.readAllStandardOutput();
//qDebug() << "stdout: " << output;
error = debugger.readAllStandardError();
- if (!error.isEmpty()) { qDebug() << error; }
+ if (!error.isEmpty())
+ qDebug() << error;
if (keepTemp()) {
QFile logger(t->buildPath + QLatin1String("/output.txt"));
@@ -1032,12 +1170,14 @@ void tst_Dumpers::dumper()
output = output.mid(pos);
contents = output;
- //int posNameSpaceStart = output.indexOf("@NS@");
- //QVERIFY(posNameSpaceStart != -1);
- //posNameSpaceStart += sizeof("@NS@") - 1;
- //int posNameSpaceEnd = output.indexOf("@", posNameSpaceStart);
- //QVERIFY(posNameSpaceEnd != -1);
- //context.nameSpace = output.mid(posNameSpaceStart, posNameSpaceEnd - posNameSpaceStart);
+ int posNameSpaceStart = output.indexOf("@NS@");
+ if (posNameSpaceStart == -1)
+ qDebug() << "OUTPUT: " << output;
+ QVERIFY(posNameSpaceStart != -1);
+ posNameSpaceStart += sizeof("@NS@") - 1;
+ int posNameSpaceEnd = output.indexOf("@", posNameSpaceStart);
+ QVERIFY(posNameSpaceEnd != -1);
+ context.nameSpace = output.mid(posNameSpaceStart, posNameSpaceEnd - posNameSpaceStart);
//qDebug() << "FOUND NS: " << context.nameSpace;
if (context.nameSpace == "::")
context.nameSpace.clear();
@@ -1142,7 +1282,7 @@ void tst_Dumpers::dumper()
qDebug() << "BUILD DIR : " << qPrintable(t->buildPath);
}
QVERIFY(ok);
- t->buildTemp.setAutoRemove(!keepTemp());
+ disarm();
}
void tst_Dumpers::dumper_data()
@@ -1293,16 +1433,29 @@ void tst_Dumpers::dumper_data()
"QTimeZone tz;\n"
"unused(&tz);\n")
% CoreProfile()
+ % QtVersion(50200)
% Check("tz", "(null)", "@QTimeZone");
- QTest::newRow("QTimeZone1")
+ QTest::newRow("QTimeZone1Gdb")
<< Data("#include <QTimeZone>\n",
"QTimeZone tz(\"UTC+05:00\");\n"
"unused(&tz);\n")
+ % DumpTestGdbEngine
% CoreProfile()
+ % QtVersion(50200)
% Check("tz", "\"UTC+05:00\"", "@QTimeZone")
% Check("tz.d.m_name", "\"UTC+05:00\"", "@QString");
+ QTest::newRow("QTimeZone1Lldb")
+ << Data("#include <QTimeZone>\n",
+ "QTimeZone tz(\"UTC+05:00\");\n"
+ "unused(&tz);\n")
+ % DumpTestLldbEngine
+ % CoreProfile()
+ % QtVersion(50200)
+ % Check("tz", "\"UTC+05:00\"", "@QTimeZone")
+ % Check("tz.d.m_id", "\"UTC+05:00\"", "@QByteArray");
+
QTest::newRow("QDate0")
<< Data("#include <QDate>\n",
"QDate date;\n"
@@ -2026,20 +2179,21 @@ void tst_Dumpers::dumper_data()
% Check("map.3.value.2.a", "3", "int")
% Check("x", "<3 items>", "@QList<nsA::nsB::SomeType*>");
-// QTest::newRow("QMultiMapUintFloat")
-// << Data("#include <QMap>\n",
-// "QMultiMap<uint, float> map;\n"
-// "map.insert(11, 11.0);\n"
-// "map.insert(22, 22.0);\n"
-// "map.insert(22, 33.0);\n"
-// "map.insert(22, 34.0);\n"
-// "map.insert(22, 35.0);\n"
-// "map.insert(22, 36.0);\n")
-// // FIXME: Wrong behaviour.
-// % Check("map", "<6 items>", "@QMultiMap<unsigned int, float>")
-// // % Check("map.[0] 11", "[0] 11", "11", "float")
-// % Check("map.5", Value4("A"), "float")
-// % Check("map.5", Value5("B"), "float");
+
+ QTest::newRow("QMultiMapUintFloat")
+ << Data("#include <QMap>\n",
+ "QMultiMap<uint, float> map;\n"
+ "map.insert(11, 11.0);\n"
+ "map.insert(22, 22.0);\n"
+ "map.insert(22, 33.0);\n"
+ "map.insert(22, 34.0);\n"
+ "map.insert(22, 35.0);\n"
+ "map.insert(22, 36.0);\n")
+ % CoreProfile()
+ % Check("map", "<6 items>", "@QMultiMap<unsigned int, float>")
+ % Check("map.0", "[0] 11", "11", "float")
+ % Check("map.5", "[5] 22", "22", "float");
+
QTest::newRow("QMultiMapStringFloat")
<< Data("#include <QMap>\n"
@@ -2921,11 +3075,9 @@ void tst_Dumpers::dumper_data()
% Cxx11Profile()
% MacLibCppProfile()
% Check("pi", Pointer("32"), "std::shared_ptr<int>")
- % Check("pi.data", "32", "int").setForGdbOnly()
- % Check("pi.data", "32", "std::shared_ptr<int>::element_type").setForLldbOnly()
+ % Check("pi.data", "32", "int")
% Check("pf", Pointer(), "std::shared_ptr<Foo>")
- % CheckType("pf.data", "Foo").setForGdbOnly()
- % CheckType("pf.data", "std::shared_ptr<Foo>::element_type").setForLldbOnly();
+ % CheckType("pf.data", "Foo");
QTest::newRow("StdSetInt")
<< Data("#include <set>\n",
@@ -3807,42 +3959,32 @@ void tst_Dumpers::dumper_data()
% Check("vec.1.a", "2", "int");
-// QTest::newRow("QVectorFooStar")
-// << Data(
-// {
-// // This tests the display of a vector of pointers to custom structs");
-// "QVector<Foo *> vec;\n"
-// % Check("vec <0 items> QVector<Foo*>");
-// // Continue");\n"
-// // step over\n"
-// // check that the display is ok");\n"
-// "vec.append(new Foo(1));\n"
-// "vec.append(0);\n"
-// "vec.append(new Foo(2));\n"
-// "vec.append(new Fooooo(3));\n"
-// // switch "Auto derefencing pointers" in Locals context menu\n"
-// // off and on again, and check result looks sane");\n"
-// % Check("vec <4 items> QVector<Foo*>");
-// % Check("vec.0", "Foo");
-// % Check("vec.0.a", "1", "int");
-// % Check("vec.1 0x0 Foo *");
-// % Check("vec.2", "Foo");
-// % Check("vec.2.a", "2", "int");
-// % Check("vec.3", "Fooooo");
-// % Check("vec.3.a", "5", "int");
-
-// QTest::newRow("QVectorBool")
-// << Data(
-// QVector<bool> vec;
-// % Check("vec <0 items> QVector<bool>");
-// // Continue");
-// // step over
-// // check that the display is ok");
-// vec.append(true);
-// vec.append(false);
-// % Check("vec <2 items> QVector<bool>");
-// % Check("vec.0", "true", "bool");
-// % Check("vec.1", "false", "bool");
+ // This tests the display of a vector of pointers to custom structs");
+ QTest::newRow("QVectorFooStar")
+ << Data("#include <QVector>\n" + fooData,
+ "QVector<Foo *> vec;\n"
+ "vec.append(new Foo(1));\n"
+ "vec.append(0);\n"
+ "vec.append(new Foo(5));\n")
+ % CoreProfile()
+ % Check("vec", "<3 items>", "@QVector<Foo*>")
+ % CheckType("vec.0", "[0]", "Foo")
+ % Check("vec.0.a", "1", "int")
+ % Check("vec.1", "[1]", "0x0", "Foo *")
+ % CheckType("vec.2", "[2]", "Foo")
+ % Check("vec.2.a", "5", "int");
+
+
+ QTest::newRow("QVectorBool")
+ << Data("#include <QVector>\n",
+ "QVector<bool> vec;\n"
+ "vec.append(true);\n"
+ "vec.append(false);\n")
+ % CoreProfile()
+ % Check("vec", "<2 items>", "@QVector<bool>")
+ % Check("vec.0", "[0]", "1", "bool")
+ % Check("vec.1", "[1]", "0", "bool");
+
// QTest::newRow("QVectorListInt")
// << Data(
@@ -3880,7 +4022,7 @@ void tst_Dumpers::dumper_data()
// typedef QList<Goo> GooList;
// QTest::newRow("NoArgumentName(int i, int, int k)
-// {
+//
// // This is not supposed to work with the compiled dumpers");
// "GooList list;
// "list.append(Goo("Hello", 1));
@@ -4125,15 +4267,12 @@ void tst_Dumpers::dumper_data()
"unused(&s);\n")
% Check("s", "", "S")
% Check("s.b", "false", "bool")
- % Check("s.c", "false", "bool:1").setForLldbOnly()
- % Check("s.c", "false", "bool").setForGdbOnly()
+ % Check("s.c", "false", "bool")
% Check("s.d", "0", "double")
% Check("s.f", "0", "float")
% Check("s.i", "0", "int")
- % Check("s.x", "0", "unsigned int:1").setForLldbOnly()
- % Check("s.x", "0", "unsigned int").setForGdbOnly()
- % Check("s.y", "0", "unsigned int:1").setForLldbOnly()
- % Check("s.y", "0", "unsigned int").setForGdbOnly();
+ % Check("s.x", "0", "unsigned int")
+ % Check("s.y", "0", "unsigned int");
QTest::newRow("Function")
@@ -4180,23 +4319,24 @@ void tst_Dumpers::dumper_data()
// // Manual: of "Locals and Expressions" view");
// // Manual: Check that order of displayed members changes");
-// QTest::newRow("Typedef")
-// << Data(
-// "namespace ns {\n"
-// " typedef unsigned long long vl;\n"
-// " typedef vl verylong;\n"
-// "}\n"
-
-// "typedef quint32 myType1;\n"
-// "typedef unsigned int myType2;\n"
-// "myType1 t1 = 0;\n"
-// "myType2 t2 = 0;\n"
-// "ns::vl j = 1000;\n"
-// "ns::verylong k = 1000;\n"
-// % Check("j", "1000", "basic::ns::vl");
-// % Check("k", "1000", "basic::ns::verylong");
-// % Check("t1", "0", "basic::myType1");
-// % Check("t2", "0", "basic::myType2");
+ QTest::newRow("Typedef")
+ << Data("#include <QtGlobal>\n"
+ "namespace ns {\n"
+ " typedef unsigned long long vl;\n"
+ " typedef vl verylong;\n"
+ "}\n"
+ "typedef quint32 myType1;\n"
+ "typedef unsigned int myType2;\n",
+ "myType1 t1 = 0;\n"
+ "myType2 t2 = 0;\n"
+ "ns::vl j = 1000;\n"
+ "ns::verylong k = 1000;\n"
+ "unused(&t1, &t2, &j, &k);\n")
+ % CoreProfile()
+ % Check("j", "1000", "ns::vl")
+ % Check("k", "1000", "ns::verylong")
+ % Check("t1", "0", "myType1")
+ % Check("t2", "0", "myType2");
QTest::newRow("Struct")
<< Data(fooData, "Foo f(3);\n"
@@ -4370,20 +4510,17 @@ void tst_Dumpers::dumper_data()
"unused(&a);\n")
% CheckType("m", "member_t");
-// QTest::newRow("PassByReferenceHelper")
-// << Data(fooData
-// (Foo &f)
-// % CheckType("f Foo &");\n"
-// % Check("f.a", "12", "int");\n"
-// // Continue");\n"
-// ++f.a;\n"
-// % CheckType("f Foo &");\n"
-// % Check("f.a", "13", "int");\n"
-
-// QTest::newRow("PassByReference")
-// << Data(
-// "Foo f(12);\n"
-// "testPassByReferenceHelper(f);\n"
+
+ QTest::newRow("PassByReference")
+ << Data(fooData +
+ "void testPassByReference(Foo &f) {\n"
+ " BREAK;\n"
+ "}\n",
+ "Foo f(12);\n"
+ "testPassByReference(f);\n")
+ % CheckType("f", "Foo &")
+ % Check("f.a", "12", "int");
+
QTest::newRow("BigInt")
<< Data("#include <QString>\n"
@@ -4435,14 +4572,20 @@ void tst_Dumpers::dumper_data()
% Check("y2", "", "X")
% Check("y3", "", "X");
- QTest::newRow("RValueReference")
+ QTest::newRow("RValueReferenceLldb")
<< Data(rvalueData)
- % Check("x1", "", "X &").setForGdbOnly()
- % Check("x2", "", "X &").setForGdbOnly()
- % Check("x3", "", "X &").setForGdbOnly()
- % Check("x1", "", "X &&").setForLldbOnly()
- % Check("x2", "", "X &&").setForLldbOnly()
- % Check("x3", "", "X &&").setForLldbOnly();
+ % DumpTestLldbEngine
+ % Check("x1", "", "X &&")
+ % Check("x2", "", "X &&")
+ % Check("x3", "", "X &&");
+
+ QTest::newRow("RValueReferenceGdb")
+ << Data(rvalueData)
+ % DumpTestGdbEngine
+ % GccVersion(0, 40704)
+ % Check("x1", "", "X &")
+ % Check("x2", "", "X &")
+ % Check("x3", "", "X &");
QTest::newRow("SSE")
<< Data("#include <xmmintrin.h>\n"
@@ -4594,265 +4737,230 @@ void tst_Dumpers::dumper_data()
// % Check("ptr2.type KRBase::TYPE_B (1) KRBase::Type");
-
-// QTest::newRow("Eigen")
-// << Data(
-// "using namespace Eigen;\n"
-
-// "Vector3d test = Vector3d::Zero();\n"
-
-// "Matrix3d myMatrix = Matrix3d::Constant(5);\n"
-// "MatrixXd myDynamicMatrix(30, 10);\n"
-
-// "myDynamicMatrix(0, 0) = 0;\n"
-// "myDynamicMatrix(1, 0) = 1;\n"
-// "myDynamicMatrix(2, 0) = 2;\n"
-
-// "Matrix<double, 12, 15, ColMajor> colMajorMatrix;\n"
-// "Matrix<double, 12, 15, RowMajor> rowMajorMatrix;\n"
-
-// "int k = 0;\n"
-// "for (int i = 0; i != 12; ++i) {\n"
-// " for (int j = 0; j != 15; ++j) {\n"
-// " colMajorMatrix(i, j) = k;\n"
-// " rowMajorMatrix(i, j) = k;\n"
-// " ++k;\n"
-// " }\n"
-// "}\n"
-
-
-
-// QTest::newRow("https://bugreports.qt-project.org/browse/QTCREATORBUG-3611")
-// "typedef unsigned char byte;\n"
-// "byte f = '2';\n"
-// "int *x = (int*)&f;\n"
-// % Check("f 50 '2' bug3611::byte");
-
-
-
-// QTest::newRow("https://bugreports.qt-project.org/browse/QTCREATORBUG-4904")
-// << Data(
-
-// "struct CustomStruct {\n"
-// " int id;\n"
-// " double dvalue;\n"
-// "};",
-// "QMap<int, CustomStruct> map;\n"
-// "CustomStruct cs1;\n"
-// "cs1.id = 1;\n"
-// "cs1.dvalue = 3.14;\n"
-// "CustomStruct cs2 = cs1;\n"
-// "cs2.id = -1;\n"
-// "map.insert(cs1.id, cs1);\n"
-// "map.insert(cs2.id, cs2);\n"
-// "QMap<int, CustomStruct>::iterator it = map.begin();\n"
-// % Check("map <2 items> QMap<int, bug4904::CustomStruct>");
-// % Check("map.0 QMapNode<int, bug4904::CustomStruct>");
-// % Check("map.0.key", "-1", "int");
-// % Check("map.0.value", "bug4904::CustomStruct");
-// % Check("map.0.value.dvalue", "3.1400000000000001", "double");
-// % Check("map.0.value.id", "-1", "int");
-
-
-// QTest::newRow("// https://bugreports.qt-project.org/browse/QTCREATORBUG-5106")
-// << Data(
-// "class A5106\n"
-// "{\n"
-// "public:\n"
-// " A5106(int a, int b) : m_a(a), m_b(b) {}\n"
-// " virtual int test() { return 5; }\n"
-// "private:\n"
-// " int m_a, m_b;\n"
-// "};\n"
-
-// "class B5106 : public A5106\n"
-// "{\n"
-// "public:\n"
-// " B5106(int c, int a, int b) : A5106(a, b), m_c(c) {}\n"
-// " virtual int test() { return 4; BREAK_HERE; }\n"
-// "private:\n"
-// " int m_c;\n"
-// "};\n"
-// ,
-// " B5106 b(1,2,3);\n"
-// " b.test();\n"
-// " b.A5106::test();\n"
-// }
-
-
-// // https://bugreports.qt-project.org/browse/QTCREATORBUG-5184
-
-// // Note: The report there shows type field "QUrl &" instead of QUrl");
-// // It's unclear how this can happen. It should never have been like
-// // that with a stock 7.2 and any version of Creator");
-
-// void helper(const QUrl &url)\n"
-// {\n"
-// QNetworkRequest request(url);\n"
-// QList<QByteArray> raw = request.rawHeaderList();\n"
-// % Check("raw <0 items> QList<QByteArray>");
-// % Check("request", "QNetworkRequest");
-// % Check("url "http://127.0.0.1/" QUrl &");
-// }
-
-// QTest::newRow("5184()
-// {
-// QUrl url(QString("http://127.0.0.1/"));\n"
-// helper(url);\n"
-// }
-
-
-//namespace qc42170 {
-
-// // http://www.qtcentre.org/threads/42170-How-to-watch-data-of-actual-type-in-debugger
-
-// struct Object
-// {
-// Object(int id_) : id(id_) {}
-// virtual ~Object() {}
-// int id;
-// };
-
-// struct Point : Object
-// {
-// Point(double x_, double y_) : Object(1), x(x_), y(y_) {}
-// double x, y;
-// };
-
-// struct Circle : Point
-// {
-// Circle(double x_, double y_, double r_) : Point(x_, y_), r(r_) { id = 2; }
-// double r;
-// };
-
-// void helper(Object *obj)
-// {
-// % Check("obj", "qc42170::Circle");
-// // Continue");
-
-// % Check("that obj is shown as a 'Circle' object");
-// unused(obj);
-// }
-
-// QTest::newRow("42170")
-// << Data(
-// {
-// Circle *circle = new Circle(1.5, -2.5, 3.0);
-// Object *obj = circle;
-// helper(circle);
-// helper(obj);
-// }
-
-//} // namespace qc42170
-
-
-//namespace bug5799 {
-
-// // https://bugreports.qt-project.org/browse/QTCREATORBUG-5799
-
-// QTest::newRow("5799()
-// "typedef struct { int m1; int m2; } S1;\n"
-// "struct S2 : S1 { };\n"
-// "typedef struct S3 { int m1; int m2; } S3;\n"
-// "struct S4 : S3 { };\n"
-
-// "S2 s2;\n"
-// "s2.m1 = 5;\n"
-// "S4 s4;\n"
-// "s4.m1 = 5;\n"
-// "S1 a1[10];\n"
-// "typedef S1 Array[10];\n"
-// "Array a2;\n"
-// % CheckType("a1 bug5799::S1 [10]");
-// % Check("a2", "bug5799::Array");
-// % Check("s2", "bug5799::S2");
-// % Check("s2.@1", "bug5799::S1");
-// % Check("s2.@1.m1", "5", "int");
-// % Check("s2.@1.m2", "int");
-// % Check("s4", "bug5799::S4");
-// % Check("s4.@1", "bug5799::S3");
-// % Check("s4.@1.m1", "5", "int");
-// % Check("s4.@1.m2", "int");
-
-
-// // http://www.qtcentre.org/threads/41700-How-to-watch-STL-containers-iterators-during-debugging
-
-// QTest::newRow("41700")
-// << Data(
-// {
-// "using namespace std;\n"
-// "typedef map<string, list<string> > map_t;\n"
-// "map_t m;\n"
-// "m["one"].push_back("a");\n"
-// "m["one"].push_back("b");\n"
-// "m["one"].push_back("c");\n"
-// "m["two"].push_back("1");\n"
-// "m["two"].push_back("2");\n"
-// "m["two"].push_back("3");\n"
-// "map_t::const_iterator it = m.begin();
-// % Check("m <2 items> qc41700::map_t");
-// % Check("m.0 std::pair<std::string const, std::list<std::string>>");
-// % Check("m.0.first "one" std::string");
-// % Check("m.0.second <3 items> std::list<std::string>");
-// % Check("m.0.second.0 "a" std::string");
-// % Check("m.0.second.1 "b" std::string");
-// % Check("m.0.second.2 "c" std::string");
-// % Check("m.1 std::pair<std::string const, std::list<std::string>>");
-// % Check("m.1.first "two" std::string");
-// % Check("m.1.second <3 items> std::list<std::string>");
-// % Check("m.1.second.0 "1" std::string");
-// % Check("m.1.second.1 "2" std::string");
-// % Check("m.1.second.2 "3" std::string");
-
-
-// QTest::newRow("42895()
-// "void g(int c, int d)\n"
-// "{\n"
-// "qDebug() << c << d;\n"
-// "BREAK"\n"
-//\n"
-// "void f(int a, int b)\n"
-// "{\n"
-// " g(a, b);\n"
-// "}\n"
-
-// " f(3, 4);\n"
-
-// % Check("c", "3", "int");
-// % Check("d", "4", "int");
-// % Check("there are frames for g and f in the stack view");
-
-
+#if 0
+ QTest::newRow("Eigen")
+ << Data("#include <Eigen/Core>",
+ "using namespace Eigen;\n"
+ "Vector3d test = Vector3d::Zero();\n"
+ "Matrix3d myMatrix = Matrix3d::Constant(5);\n"
+ "MatrixXd myDynamicMatrix(30, 10);\n"
+
+ "myDynamicMatrix(0, 0) = 0;\n"
+ "myDynamicMatrix(1, 0) = 1;\n"
+ "myDynamicMatrix(2, 0) = 2;\n"
+
+ "Matrix<double, 12, 15, ColMajor> colMajorMatrix;\n"
+ "Matrix<double, 12, 15, RowMajor> rowMajorMatrix;\n"
+
+ "int k = 0;\n"
+ "for (int i = 0; i != 12; ++i) {\n"
+ " for (int j = 0; j != 15; ++j) {\n"
+ " colMajorMatrix(i, j) = k;\n"
+ " rowMajorMatrix(i, j) = k;\n"
+ " ++k;\n"
+ " }\n"
+ "}\n")
+ % EigenProfile()
+ % CheckType("myMatrix", "Eigen::Matrix3d");
+#endif
-// // https://bugreports.qt-project.org/browse/QTCREATORBUG-6465
+ // https://bugreports.qt-project.org/browse/QTCREATORBUG-3611
+ QTest::newRow("Bug3611")
+ << Data("typedef unsigned char byte;\n"
+ "byte f = '2';\n"
+ "int *x = (int*)&f;\n")
+ % Check("f", "50 '2'", "byte");
+
+
+ // https://bugreports.qt-project.org/browse/QTCREATORBUG-4904
+ QTest::newRow("Bug4904")
+ << Data("#include <QMap>\n"
+ "struct CustomStruct {\n"
+ " int id;\n"
+ " double dvalue;\n"
+ "};",
+ "QMap<int, CustomStruct> map;\n"
+ "CustomStruct cs1;\n"
+ "cs1.id = 1;\n"
+ "cs1.dvalue = 3.14;\n"
+ "CustomStruct cs2 = cs1;\n"
+ "cs2.id = -1;\n"
+ "map.insert(cs1.id, cs1);\n"
+ "map.insert(cs2.id, cs2);\n"
+ "QMap<int, CustomStruct>::iterator it = map.begin();\n")
+ % CoreProfile()
+ % Check("map", "<2 items>", "@QMap<int, CustomStruct>")
+ % CheckType("map.0", "[0]", "@QMapNode<int, CustomStruct>")
+ % Check("map.0.key", "-1", "int")
+ % CheckType("map.0.value", "CustomStruct")
+ % Check("map.0.value.dvalue", FloatValue("3.14"), "double")
+ % Check("map.0.value.id", "-1", "int");
-// QTest::newRow("6465()\n"
-// {\n"
-// typedef char Foo[20];\n"
-// Foo foo = "foo";\n"
-// char bar[20] = "baz";
-//namespace bug6857 {
+#if 0
+ // https://bugreports.qt-project.org/browse/QTCREATORBUG-5106
+ QTest::newRow("Bug5106")
+ << Data("struct A5106 {\n"
+ " A5106(int a, int b) : m_a(a), m_b(b) {}\n"
+ " virtual int test() { return 5; }\n"
+ " int m_a, m_b;\n"
+ "};\n"
+
+ "struct B5106 : public A5106 {\n"
+ " B5106(int c, int a, int b) : A5106(a, b), m_c(c) {}\n"
+ " virtual int test() {\n"
+ " BREAK;\n"
+ " }\n"
+ " int m_c;\n"
+ "};\n",
+ "B5106 b(1,2,3);\n"
+ "b.test();\n"
+ "b.A5106::test();\n")
+ % Check(?)
+#endif
-// class MyFile : public QFile
-// {
-// public:
-// MyFile(const QString &fileName)
-// : QFile(fileName) {}
-// };
-// QTest::newRow("6857")
-// << Data(
-// MyFile file("/tmp/tt");
-// file.setObjectName("A file");
-// % Check("file bug6857::MyFile");
-// % Check("file.@1 "/tmp/tt" QFile");
-// % Check("file.@1.@1.@1 "A file" QObject");
+ // https://bugreports.qt-project.org/browse/QTCREATORBUG-5184
+
+ // Note: The report there shows type field "QUrl &" instead of QUrl");
+ // It's unclear how this can happen. It should never have been like
+ // that with a stock 7.2 and any version of Creator");
+ QTest::newRow("Bug5184")
+ << Data("#include <QUrl>\n"
+ "#include <QNetworkRequest>\n"
+ "void helper(const QUrl &url)\n"
+ "{\n"
+ " QNetworkRequest request(url);\n"
+ " QList<QByteArray> raw = request.rawHeaderList();\n"
+ " BREAK;\n"
+ " unused(&url);\n"
+ "}\n",
+ " QUrl url(QString(\"http://127.0.0.1/\"));\n"
+ " helper(url);\n")
+ % NetworkProfile()
+ % Check("raw", "<0 items>", "@QList<@QByteArray>")
+ % CheckType("request", "@QNetworkRequest")
+ % Check("url", "\"http://127.0.0.1/\"", "@QUrl &");
+
+
+ // http://www.qtcentre.org/threads/42170-How-to-watch-data-of-actual-type-in-debugger
+ QTest::newRow("QC42170")
+ << Data("struct Object {\n"
+ " Object(int id_) : id(id_) {}\n"
+ " virtual ~Object() {}\n"
+ " int id;\n"
+ "};\n\n"
+ "struct Point : Object\n"
+ "{\n"
+ " Point(double x_, double y_) : Object(1), x(x_), y(y_) {}\n"
+ " double x, y;\n"
+ "};\n\n"
+ "struct Circle : Point\n"
+ "{\n"
+ " Circle(double x_, double y_, double r_) : Point(x_, y_), r(r_) { id = 2; }\n"
+ " double r;\n"
+ "};\n\n"
+ "void helper(Object *obj)\n"
+ "{\n"
+ " BREAK;\n"
+ " unused(obj);\n"
+ "}\n",
+ "Circle *circle = new Circle(1.5, -2.5, 3.0);\n"
+ "Object *obj = circle;\n"
+ "helper(circle);\n"
+ "helper(obj);\n")
+ % CheckType("obj", "Circle");
+
+
+ // https://bugreports.qt-project.org/browse/QTCREATORBUG-5799
+ QTest::newRow("Bug5799")
+ << Data("typedef struct { int m1; int m2; } S1;\n"
+ "struct S2 : S1 { };\n"
+ "typedef struct S3 { int m1; int m2; } S3;\n"
+ "struct S4 : S3 { };\n",
+ "S2 s2;\n"
+ "s2.m1 = 5;\n"
+ "S4 s4;\n"
+ "s4.m1 = 5;\n"
+ "S1 a1[10];\n"
+ "typedef S1 Array[10];\n"
+ "Array a2;\n"
+ "unused(&s2, &s4, &a1, &a2);\n")
+ % CheckType("a1", "S1 [10]")
+ % CheckType("a2", "Array")
+ % CheckType("s2", "S2")
+ % CheckType("s2.@1", "[S1]", "S1")
+ % Check("s2.@1.m1", "5", "int")
+ % CheckType("s2.@1.m2", "int")
+ % CheckType("s4", "S4")
+ % CheckType("s4.@1", "[S3]", "S3")
+ % Check("s4.@1.m1", "5", "int")
+ % CheckType("s4.@1.m2", "int");
+
+
+ // http://www.qtcentre.org/threads/41700-How-to-watch-STL-containers-iterators-during-debugging
+ QTest::newRow("QC41700")
+ << Data("#include <map>\n"
+ "#include <list>\n"
+ "#include <string>\n"
+ "using namespace std;\n"
+ "typedef map<string, list<string> > map_t;\n",
+ "map_t m;\n"
+ "m[\"one\"].push_back(\"a\");\n"
+ "m[\"one\"].push_back(\"b\");\n"
+ "m[\"one\"].push_back(\"c\");\n"
+ "m[\"two\"].push_back(\"1\");\n"
+ "m[\"two\"].push_back(\"2\");\n"
+ "m[\"two\"].push_back(\"3\");\n"
+ "map_t::const_iterator it = m.begin();\n")
+ % Check("m", "<2 items>", "map_t")
+ % Check("m.0.first", "\"one\"", "std::string")
+ % Check("m.0.second", "<3 items>", "std::list<std::string>")
+ % Check("m.0.second.0", "[0]", "\"a\"", "std::string")
+ % Check("m.0.second.1", "[1]", "\"b\"", "std::string")
+ % Check("m.0.second.2", "[2]", "\"c\"", "std::string")
+ % Check("m.1.first", "\"two\"", "std::string")
+ % Check("m.1.second", "<3 items>", "std::list<std::string>")
+ % Check("m.1.second.0", "[0]", "\"1\"", "std::string")
+ % Check("m.1.second.1", "[1]", "\"2\"", "std::string")
+ % Check("m.1.second.2", "[2]", "\"3\"", "std::string")
+ % CheckType("it", "std::map<std::string, std::list<std::string> >::const_iterator")
+ % Check("it.first", "\"one\"", "std::string")
+ % Check("it.second", "<3 items>", "std::list<std::string>");
+
+
+ // https://bugreports.qt-project.org/browse/QTCREATORBUG-6465
+ QTest::newRow("Bug6465")
+ << Data("typedef char Foo[20];\n"
+ "Foo foo = \"foo\";\n"
+ "char bar[20] = \"baz\";\n")
+ % CheckType("bar", "char[20]");
+
+
+#ifndef Q_OS_WIN
+ // https://bugreports.qt-project.org/browse/QTCREATORBUG-6857
+ QTest::newRow("Bug6857")
+ << Data("#include <QFile>\n"
+ "#include <QString>\n"
+ "struct MyFile : public QFile {\n"
+ " MyFile(const QString &fileName)\n"
+ " : QFile(fileName) {}\n"
+ "};\n",
+ "MyFile file(\"/tmp/tt\");\n"
+ "file.setObjectName(\"A file\");\n")
+ % CoreProfile()
+ % QtVersion(50000)
+ % Check("file", "\"A file\"", "MyFile")
+ % Check("file.@1", "[@QFile]", "\"/tmp/tt\"", "@QFile");
+ // FIXME: The classname in the iname is sub-optimal.
+ //% Check("file.@1.[QFileDevice]", "[@QFileDevice]", "\"A file\"", "@QFileDevice");
+ //% Check("file.@1.@1", "[QFile]", "\"A file\"", "@QObject");
+#endif
#if 0
- QTest::newRow("bug6858")
+ QTest::newRow("Bug6858")
<< Data("#include <QFile>\n"
"#include <QString>\n"
"class MyFile : public QFile\n"
@@ -4898,7 +5006,7 @@ void tst_Dumpers::dumper_data()
//}
- QTest::newRow("bug6933")
+ QTest::newRow("Bug6933")
<< Data("struct Base\n"
"{\n"
" Base() : a(21) {}\n"
@@ -4954,12 +5062,29 @@ void tst_Dumpers::dumper_data()
"c.S1::v = 44;\n"
"c.S2::v = 45;\n"
"unused(&c.S2::v);\n")
+ % DebuggerEngine(~DumpTestLldbEngine)
% Check("c.c", "1", "int")
% Check("c.@1.@2.a", "42", "int")
% Check("c.@1.@4.v", "45", "int")
% Check("c.@2.@2.a", "43", "int")
% Check("c.@2.@4.v", "45", "int");
+ // FIXME: Virtual inheritance doesn't work with LLDB 300
+ QTest::newRow("inheritanceLldb")
+ << Data(inheritanceData,
+ "Combined c;\n"
+ "c.S1::a = 42;\n"
+ "c.S2::a = 43;\n"
+ "c.S1::v = 44;\n"
+ "c.S2::v = 45;\n"
+ "unused(&c.S2::v);\n")
+ % DumpTestLldbEngine
+ % Check("c.c", "1", "int")
+ % Check("c.@1.@1.a", "42", "int")
+ //% Check("c.@1.@4.v", "45", "int")
+ % Check("c.@2.@1.a", "43", "int");
+ //% Check("c.@2.@4.v", "45", "int");
+
QTest::newRow("gdb13393")
<< Data(
@@ -5067,7 +5192,7 @@ void tst_Dumpers::dumper_data()
"struct S { int x, y; } n = {10, 20};\n"
"unused(&v, &n);\n")
% DumpTestLldbEngine
- % Check("v", "", "<anonymous class>")
+ % Check("v", "", Pattern("<anonymous .*>"))
% Check("n", "", "S")
% Check("v.#1.a", "2", "int")
% Check("v.#2.b", "3", "int")
diff --git a/tests/auto/debugger/tst_gdb.cpp b/tests/auto/debugger/tst_gdb.cpp
index 7ea54baa48..bf95d5664a 100644
--- a/tests/auto/debugger/tst_gdb.cpp
+++ b/tests/auto/debugger/tst_gdb.cpp
@@ -269,11 +269,7 @@ void tst_gdb::niceType_data()
<< "std::map<const char*, Foo>";
}
-int main(int argc, char *argv[])
-{
- tst_gdb test;
- return QTest::qExec(&test, argc, argv);
-}
+QTEST_APPLESS_MAIN(tst_gdb);
#include "tst_gdb.moc"
diff --git a/tests/auto/debugger/tst_namedemangler.cpp b/tests/auto/debugger/tst_namedemangler.cpp
index 13d26261cf..89ebd8f68e 100644
--- a/tests/auto/debugger/tst_namedemangler.cpp
+++ b/tests/auto/debugger/tst_namedemangler.cpp
@@ -26,23 +26,20 @@
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
+
#include <namedemangler/namedemangler.h>
#include <namedemangler/parsetreenodes.h>
#include <QObject>
+#include <QDebug>
#include <QTest>
#include <cctype>
-#define TEST_CORRECTLY_MANGLED_NAME(mangled, expectedDemangled) \
- do { \
- QVERIFY2(demangler.demangle(QLatin1String(mangled)), qPrintable(demangler.errorString())); \
- QCOMPARE(demangler.demangledName(), QLatin1String(expectedDemangled)); \
- } while (0)
-
const char *toString(char c) { return (QByteArray("'") + c + "'").constData(); }
using namespace Debugger::Internal;
+using namespace QTest;
class NameDemanglerAutoTest : public QObject
{
@@ -51,6 +48,7 @@ private slots:
void testUnmangledName();
void testDisjunctFirstSets();
void testCorrectlyMangledNames();
+ void testCorrectlyMangledNames_data();
void testIncorrectlyMangledNames();
private:
@@ -66,162 +64,242 @@ void NameDemanglerAutoTest::testUnmangledName()
void NameDemanglerAutoTest::testCorrectlyMangledNames()
{
- TEST_CORRECTLY_MANGLED_NAME("_Z1fv", "f()");
- TEST_CORRECTLY_MANGLED_NAME("_Z1fi", "f(int)");
- TEST_CORRECTLY_MANGLED_NAME("_Z3foo3bar", "foo(bar)");
- TEST_CORRECTLY_MANGLED_NAME("_Zrm1XS_", "operator%(X, X)");
- TEST_CORRECTLY_MANGLED_NAME("_ZplR1XS0_", "operator+(X &, X &)");
- TEST_CORRECTLY_MANGLED_NAME("_ZlsRK1XS1_", "operator<<(X const &, X const &)");
- TEST_CORRECTLY_MANGLED_NAME("_ZN3FooIA4_iE3barE", "Foo<int[4]>::bar");
- TEST_CORRECTLY_MANGLED_NAME("_Z5firstI3DuoEvS0_", "void first<Duo>(Duo)");
- TEST_CORRECTLY_MANGLED_NAME("_Z5firstI3DuoEvT_", "void first<Duo>(Duo)");
- TEST_CORRECTLY_MANGLED_NAME("_Z3fooIiPFidEiEvv",
- "void foo<int, int (*)(double), int>()");
- TEST_CORRECTLY_MANGLED_NAME("_ZN1N1fE", "N::f");
- TEST_CORRECTLY_MANGLED_NAME("_ZN6System5Sound4beepEv",
- "System::Sound::beep()");
- TEST_CORRECTLY_MANGLED_NAME("_ZN5Arena5levelE", "Arena::level");
- TEST_CORRECTLY_MANGLED_NAME("_ZN5StackIiiE5levelE", "Stack<int, int>::level");
- TEST_CORRECTLY_MANGLED_NAME("_Z1fI1XEvPVN1AIT_E1TE",
- "void f<X>(A<X>::T volatile *)");
- TEST_CORRECTLY_MANGLED_NAME("_ZngILi42EEvN1AIXplT_Li2EEE1TE",
- "void operator-<42>(A<42 + 2>::T)");
- TEST_CORRECTLY_MANGLED_NAME("_Z4makeI7FactoryiET_IT0_Ev",
- "Factory<int> make<Factory, int>()");
- TEST_CORRECTLY_MANGLED_NAME("_Z3foo5Hello5WorldS0_S_",
- "foo(Hello, World, World, Hello)");
- TEST_CORRECTLY_MANGLED_NAME("_Z3fooPM2ABi", "foo(int AB::**)");
- TEST_CORRECTLY_MANGLED_NAME("_ZlsRSoRKSs",
- "operator<<(std::basic_ostream<char, std::char_traits<char> > &, "
- "std::basic_string<char, std::char_traits<char>, "
- "std::allocator<char> > const &)");
- TEST_CORRECTLY_MANGLED_NAME("_ZTI7a_class", "typeid(a_class)");
- TEST_CORRECTLY_MANGLED_NAME("_ZZN1A3fooEiE1B", "A::foo(int)::B");
- TEST_CORRECTLY_MANGLED_NAME("_ZZ3foovEN1C1DE", "foo()::C::D");
- TEST_CORRECTLY_MANGLED_NAME("_ZZZ3foovEN1C3barEvEN1E3bazEv",
- "foo()::C::bar()::E::baz()");
- TEST_CORRECTLY_MANGLED_NAME("_ZZN1N1fEiE1p", "N::f(int)::p");
- TEST_CORRECTLY_MANGLED_NAME("_ZZN1N1fEiEs", "N::f(int)::{string literal}");
- TEST_CORRECTLY_MANGLED_NAME("_Z41__static_initialization_and_destruction_0ii",
- "__static_initialization_and_destruction_0(int, int)");
- TEST_CORRECTLY_MANGLED_NAME("_ZN20NameDemanglerPrivate3eoiE",
- "NameDemanglerPrivate::eoi");
- TEST_CORRECTLY_MANGLED_NAME(
- "_ZZN20NameDemanglerPrivate15parseIdentifierEiE8__func__",
- "NameDemanglerPrivate::parseIdentifier(int)::__func__");
- TEST_CORRECTLY_MANGLED_NAME("_ZN4QSetI5QCharED1Ev", "QSet<QChar>::~QSet()");
- TEST_CORRECTLY_MANGLED_NAME("_Zne5QCharS_", "operator!=(QChar, QChar)");
- TEST_CORRECTLY_MANGLED_NAME("_ZN20NameDemanglerPrivate17parseFunctionTypeEv",
- "NameDemanglerPrivate::parseFunctionType()");
- TEST_CORRECTLY_MANGLED_NAME(
- "_ZNK20NameDemanglerPrivate16ArrayNewOperator8makeExprERK11QStringList",
- "NameDemanglerPrivate::ArrayNewOperator::makeExpr(QStringList const &) const");
- TEST_CORRECTLY_MANGLED_NAME("_ZN13QLatin1StringC1EPKc",
- "QLatin1String::QLatin1String(char const *)");
- TEST_CORRECTLY_MANGLED_NAME(
- "_ZN15QtSharedPointer16ExternalRefCountIN20NameDemanglerPrivate8OperatorEE12internalCopyIS2_EEvRKNS0_IT_EE",
- "void QtSharedPointer::ExternalRefCount<NameDemanglerPrivate::Operator>::internalCopy<NameDemanglerPrivate::Operator>(QtSharedPointer::ExternalRefCount<NameDemanglerPrivate::Operator> const &)");
- TEST_CORRECTLY_MANGLED_NAME(
- "_ZN15QtSharedPointer16ExternalRefCountIN20NameDemanglerPrivate8OperatorEE11internalSetEPNS_20ExternalRefCountDataEPS2_",
- "QtSharedPointer::ExternalRefCount<NameDemanglerPrivate::Operator>::internalSet(QtSharedPointer::ExternalRefCountData *, NameDemanglerPrivate::Operator *)");
- TEST_CORRECTLY_MANGLED_NAME("_ZN20NameDemanglerPrivate17parseUnscopedNameEv",
- "NameDemanglerPrivate::parseUnscopedName()");
- TEST_CORRECTLY_MANGLED_NAME("_ZNK7QString3argExiiRK5QChar",
- "QString::arg(long long, int, int, QChar const &) const");
- TEST_CORRECTLY_MANGLED_NAME(
- "_ZN20NameDemanglerPrivate8OperatorC2ERK7QStringS3_",
- "NameDemanglerPrivate::Operator::Operator(QString const &, QString const &)");
- TEST_CORRECTLY_MANGLED_NAME(
- "_ZN15QtSharedPointer16ExternalRefCountIN20NameDemanglerPrivate8OperatorEEC2EN2Qt14InitializationE",
- "QtSharedPointer::ExternalRefCount<NameDemanglerPrivate::Operator>::ExternalRefCount(Qt::Initialization)");
- TEST_CORRECTLY_MANGLED_NAME("_ZN7QString5clearEv", "QString::clear()");
- TEST_CORRECTLY_MANGLED_NAME("_ZNK5QListI7QStringE2atEi",
- "QList<QString>::at(int) const");
- TEST_CORRECTLY_MANGLED_NAME(
- "_ZNK7QString10startsWithERKS_N2Qt15CaseSensitivityE",
- "QString::startsWith(QString const &, Qt::CaseSensitivity) const");
- TEST_CORRECTLY_MANGLED_NAME("_ZNK4QSetI5QCharE8constEndEv",
- "QSet<QChar>::constEnd() const");
- TEST_CORRECTLY_MANGLED_NAME("_Z11qt_assert_xPKcS0_S0_i",
- "qt_assert_x(char const *, char const *, char const *, int)");
- TEST_CORRECTLY_MANGLED_NAME("_ZN9QHashData8willGrowEv",
- "QHashData::willGrow()");
- TEST_CORRECTLY_MANGLED_NAME(
- "_ZNK5QHashI5QChar15QHashDummyValueE14const_iteratorneERKS3_",
- "QHash<QChar, QHashDummyValue>::const_iterator::operator!=(QHash<QChar, QHashDummyValue>::const_iterator const &) const");
- TEST_CORRECTLY_MANGLED_NAME("_ZNK13NameDemangler11errorStringEv",
- "NameDemangler::errorString() const");
- TEST_CORRECTLY_MANGLED_NAME("_ZN7QString7replaceERK7QRegExpRKS_",
- "QString::replace(QRegExp const &, QString const &)");
- TEST_CORRECTLY_MANGLED_NAME("_ZN7QString4freeEPNS_4DataE",
- "QString::free(QString::Data *)");
- TEST_CORRECTLY_MANGLED_NAME(
- "_ZTSN20NameDemanglerPrivate19ArrayAccessOperatorE",
- "typeid(NameDemanglerPrivate::ArrayAccessOperator).name()");
- TEST_CORRECTLY_MANGLED_NAME("_ZN3ns11fERKPFPKiS1_RKhE",
- "ns1::f(int const * (* const &)(int const *, unsigned char const &))");
- TEST_CORRECTLY_MANGLED_NAME("_Z9test_funcMN3ns11cImEEKFPKvPiRlmE",
- "test_func(void const * (ns1::c<unsigned long>::*)(int *, long &, unsigned long) const)");
- TEST_CORRECTLY_MANGLED_NAME("_ZN3ns11fEPKPFPKiS1_RKhE",
- "ns1::f(int const * (* const *)(int const *, unsigned char const &))");
- TEST_CORRECTLY_MANGLED_NAME("_ZNK1CcviEv", "C::operator int() const");
- TEST_CORRECTLY_MANGLED_NAME("_ZN1CppEv", "C::operator++()");
- TEST_CORRECTLY_MANGLED_NAME("_ZN1CmmEv", "C::operator--()");
- TEST_CORRECTLY_MANGLED_NAME("_ZN1CppEi", "C::operator++(int)");
- TEST_CORRECTLY_MANGLED_NAME("_ZN1CmmEi", "C::operator--(int)");
- TEST_CORRECTLY_MANGLED_NAME("_ZNK1CcvT_IPKcEEv", "C::operator char const *<char const *>() const");
- TEST_CORRECTLY_MANGLED_NAME("_Z9weirdfuncIiEvT_KPFS0_S0_E", "void weirdfunc<int>(int, int (* const)(int))");
- TEST_CORRECTLY_MANGLED_NAME("_Z9weirdfuncIiEvT_PFS0_DtfL1p_EE", "void weirdfunc<int>(int, int (*)(decltype({param#1})))");
- TEST_CORRECTLY_MANGLED_NAME("_Z9weirdfuncIiEvT_S0_", "void weirdfunc<int>(int, int)");
- TEST_CORRECTLY_MANGLED_NAME("_Z9weirdfuncIiEvT_DtfL0p_E", "void weirdfunc<int>(int, decltype({param#1}))");
- TEST_CORRECTLY_MANGLED_NAME("_Z9weirdfuncIiEvT_S0_S0_", "void weirdfunc<int>(int, int, int)");
- TEST_CORRECTLY_MANGLED_NAME("_Z9weirdfuncIiEvT_S0_DtfL0p0_E", "void weirdfunc<int>(int, int, decltype({param#2}))");
- TEST_CORRECTLY_MANGLED_NAME("_Z8toStringIiESsT_",
- "std::basic_string<char, std::char_traits<char>, std::allocator<char> > toString<int>(int)");
-
- TEST_CORRECTLY_MANGLED_NAME("_Z4funcIRA5_iEvOT_", "void func<int (&)[5]>(int (&)[5])");
- TEST_CORRECTLY_MANGLED_NAME("_ZSt9make_pairIiRA5_KcESt4pairINSt17__decay_and_stripIT_E6__typeENS4_IT0_E6__typeEEOS5_OS8_",
- "std::pair<std::__decay_and_strip<int>::__type, std::__decay_and_strip<char const (&)[5]>::__type> std::make_pair<int, char const (&)[5]>(int &&, char const (&)[5])");
+ QFETCH(QString, demangled);
+ QString mangled = QString::fromLatin1(currentDataTag());
+
+ QVERIFY2(demangler.demangle(mangled), qPrintable(demangler.errorString()));
+ QCOMPARE(demangler.demangledName(), demangled);
+}
+
+void NameDemanglerAutoTest::testCorrectlyMangledNames_data()
+{
+ addColumn<QString>("demangled");
+
+ newRow("_Z1fv")
+ << "f()";
+ newRow("_Z1fi")
+ << "f(int)";
+#ifdef Q_OS_LINUX
+ newRow("_Z3foo3bar")
+ << "foo(bar)";
+ newRow("_Zrm1XS_")
+ << "operator%(X, X)";
+ newRow("_ZplR1XS0_")
+ << "operator+(X &, X &)";
+ newRow("_ZlsRK1XS1_")
+ << "operator<<(X const &, X const &)";
+ newRow("_ZN3FooIA4_iE3barE")
+ << "Foo<int[4]>::bar";
+ newRow("_Z5firstI3DuoEvS0_")
+ << "void first<Duo>(Duo)";
+ newRow("_Z5firstI3DuoEvT_")
+ << "void first<Duo>(Duo)";
+ newRow("_Z3fooIiPFidEiEvv")
+ << "void foo<int, int (*)(double), int>()";
+ newRow("_ZN1N1fE")
+ << "N::f";
+ newRow("_ZN6System5Sound4beepEv")
+ << "System::Sound::beep()";
+ newRow("_ZN5Arena5levelE")
+ << "Arena::level";
+ newRow("_ZN5StackIiiE5levelE")
+ << "Stack<int, int>::level";
+ newRow("_Z1fI1XEvPVN1AIT_E1TE")
+ << "void f<X>(A<X>::T volatile *)";
+ newRow("_ZngILi42EEvN1AIXplT_Li2EEE1TE")
+ << "void operator-<42>(A<42 + 2>::T)";
+ newRow("_Z4makeI7FactoryiET_IT0_Ev")
+ << "Factory<int> make<Factory, int>()";
+ newRow("_Z3foo5Hello5WorldS0_S_")
+ << "foo(Hello, World, World, Hello)";
+ newRow("_Z3fooPM2ABi")
+ << "foo(int AB::**)";
+ newRow("_ZlsRSoRKSs")
+ << "operator<<(std::basic_ostream<char, std::char_traits<char> > &, "
+ "std::basic_string<char, std::char_traits<char>, "
+ "std::allocator<char> > const &)";
+ newRow("_ZTI7a_class")
+ << "typeid(a_class)";
+ newRow("_ZZN1A3fooEiE1B")
+ << "A::foo(int)::B";
+ newRow("_ZZ3foovEN1C1DE")
+ << "foo()::C::D";
+ newRow("_ZZZ3foovEN1C3barEvEN1E3bazEv")
+ << "foo()::C::bar()::E::baz()";
+ newRow("_ZZN1N1fEiE1p")
+ << "N::f(int)::p";
+ newRow("_ZZN1N1fEiEs")
+ << "N::f(int)::{string literal}";
+ newRow("_Z41__static_initialization_and_destruction_0ii")
+ << "__static_initialization_and_destruction_0(int, int)";
+ newRow("_ZN20NameDemanglerPrivate3eoiE")
+ << "NameDemanglerPrivate::eoi";
+ newRow("_ZZN20NameDemanglerPrivate15parseIdentifierEiE8__func__")
+ << "NameDemanglerPrivate::parseIdentifier(int)::__func__";
+ newRow("_ZN4QSetI5QCharED1Ev")
+ << "QSet<QChar>::~QSet()";
+ newRow("_Zne5QCharS_")
+ << "operator!=(QChar, QChar)";
+ newRow("_ZN20NameDemanglerPrivate17parseFunctionTypeEv")
+ << "NameDemanglerPrivate::parseFunctionType()";
+ newRow("_ZNK20NameDemanglerPrivate16ArrayNewOperator8makeExprERK11QStringList")
+ << "NameDemanglerPrivate::ArrayNewOperator::makeExpr(QStringList const &) const";
+ newRow("_ZN13QLatin1StringC1EPKc")
+ << "QLatin1String::QLatin1String(char const *)";
+ newRow("_ZN15QtSharedPointer16ExternalRefCountIN20NameDemanglerPrivate8OperatorEE12internalCopyIS2_EEvRKNS0_IT_EE")
+ << "void QtSharedPointer::ExternalRefCount<NameDemanglerPrivate::Operator>"
+ "::internalCopy<NameDemanglerPrivate::Operator>(QtSharedPointer"
+ "::ExternalRefCount<NameDemanglerPrivate::Operator> const &)";
+ newRow("_ZN15QtSharedPointer16ExternalRefCountIN20NameDemanglerPrivate8OperatorEE11internalSetEPNS_20ExternalRefCountDataEPS2_")
+ << "QtSharedPointer::ExternalRefCount<NameDemanglerPrivate::Operator>"
+ "::internalSet(QtSharedPointer::ExternalRefCountData *, NameDemanglerPrivate::Operator *)";
+ newRow("_ZN20NameDemanglerPrivate17parseUnscopedNameEv")
+ << "NameDemanglerPrivate::parseUnscopedName()";
+ newRow("_ZNK7QString3argExiiRK5QChar")
+ << "QString::arg(long long, int, int, QChar const &) const";
+ newRow("_ZN20NameDemanglerPrivate8OperatorC2ERK7QStringS3_")
+ << "NameDemanglerPrivate::Operator::Operator(QString const &, QString const &)";
+ newRow("_ZN15QtSharedPointer16ExternalRefCountIN20NameDemanglerPrivate8OperatorEEC2EN2Qt14InitializationE")
+ << "QtSharedPointer::ExternalRefCount<NameDemanglerPrivate::Operator>::ExternalRefCount(Qt::Initialization)";
+ newRow("_ZN7QString5clearEv")
+ << "QString::clear()";
+ newRow("_ZNK5QListI7QStringE2atEi")
+ << "QList<QString>::at(int) const";
+ newRow("_ZNK7QString10startsWithERKS_N2Qt15CaseSensitivityE")
+ << "QString::startsWith(QString const &, Qt::CaseSensitivity) const";
+ newRow("_ZNK4QSetI5QCharE8constEndEv")
+ << "QSet<QChar>::constEnd() const";
+ newRow("_Z11qt_assert_xPKcS0_S0_i")
+ << "qt_assert_x(char const *, char const *, char const *, int)";
+ newRow("_ZN9QHashData8willGrowEv")
+ << "QHashData::willGrow()";
+ newRow("_ZNK5QHashI5QChar15QHashDummyValueE14const_iteratorneERKS3_")
+ << "QHash<QChar, QHashDummyValue>::const_iterator::operator!="
+ "(QHash<QChar, QHashDummyValue>::const_iterator const &) const";
+ newRow("_ZNK13NameDemangler11errorStringEv")
+ << "NameDemangler::errorString() const";
+ newRow("_ZN7QString7replaceERK7QRegExpRKS_")
+ << "QString::replace(QRegExp const &, QString const &)";
+ newRow("_ZN7QString4freeEPNS_4DataE")
+ << "QString::free(QString::Data *)";
+ newRow("_ZTSN20NameDemanglerPrivate19ArrayAccessOperatorE")
+ << "typeid(NameDemanglerPrivate::ArrayAccessOperator).name()";
+ newRow("_ZN3ns11fERKPFPKiS1_RKhE")
+ << "ns1::f(int const * (* const &)(int const *, unsigned char const &))";
+ newRow("_Z9test_funcMN3ns11cImEEKFPKvPiRlmE")
+ << "test_func(void const * (ns1::c<unsigned long>::*)(int *, long &, unsigned long) const)";
+ newRow("_ZN3ns11fEPKPFPKiS1_RKhE")
+ << "ns1::f(int const * (* const *)(int const *, unsigned char const &))";
+ newRow("_ZNK1CcviEv")
+ << "C::operator int() const";
+ newRow("_ZN1CppEv")
+ << "C::operator++()";
+ newRow("_ZN1CmmEv")
+ << "C::operator--()";
+ newRow("_ZN1CppEi")
+ << "C::operator++(int)";
+ newRow("_ZN1CmmEi")
+ << "C::operator--(int)";
+ newRow("_ZNK1CcvT_IPKcEEv")
+ << "C::operator char const *<char const *>() const";
+ newRow("_Z9weirdfuncIiEvT_KPFS0_S0_E")
+ << "void weirdfunc<int>(int, int (* const)(int))";
+ newRow("_Z9weirdfuncIiEvT_PFS0_DtfL1p_EE")
+ << "void weirdfunc<int>(int, int (*)(decltype({param#1})))";
+ newRow("_Z9weirdfuncIiEvT_S0_")
+ << "void weirdfunc<int>(int, int)";
+ newRow("_Z9weirdfuncIiEvT_DtfL0p_E")
+ << "void weirdfunc<int>(int, decltype({param#1}))";
+ newRow("_Z9weirdfuncIiEvT_S0_S0_")
+ << "void weirdfunc<int>(int, int, int)";
+ newRow("_Z9weirdfuncIiEvT_S0_DtfL0p0_E")
+ << "void weirdfunc<int>(int, int, decltype({param#2}))";
+ newRow("_Z8toStringIiESsT_")
+ << "std::basic_string<char, std::char_traits<char>, std::allocator<char> > toString<int>(int)";
+
+ newRow("_Z4funcIRA5_iEvOT_")
+ << "void func<int (&)[5]>(int (&)[5])";
+ newRow("_ZSt9make_pairIiRA5_KcESt4pairINSt17__decay_and_stripIT_E6__typeENS4_IT0_E6__typeEEOS5_OS8_")
+ << "std::pair<std::__decay_and_strip<int>::__type, "
+ "std::__decay_and_strip<char const (&)[5]>::__type> "
+ "std::make_pair<int, char const (&)[5]>(int &&, char const (&)[5])";
// All examples from the ABI spec.
- TEST_CORRECTLY_MANGLED_NAME("_ZN1S1xE", "S::x");
- TEST_CORRECTLY_MANGLED_NAME("_Z1fM1AKFvvE", "f(void (A::*)() const)");
- TEST_CORRECTLY_MANGLED_NAME("_Z1fIiEvT_", "void f<int>(int)");
- TEST_CORRECTLY_MANGLED_NAME("_Z3fooc", "foo(char)");
- TEST_CORRECTLY_MANGLED_NAME("_Z2CBIL_Z3foocEE", "CB<foo(char)>");
- TEST_CORRECTLY_MANGLED_NAME("_Z2CBIL_Z7IsEmptyEE", "CB<IsEmpty>");
- TEST_CORRECTLY_MANGLED_NAME("_ZZ1giEN1S1fE_2i", "g(int)::S::f(int)");
- TEST_CORRECTLY_MANGLED_NAME("_ZZ1gvEN1SC1Ev", "g()::S::S()");
- TEST_CORRECTLY_MANGLED_NAME("_ZZZ1gvEN1SC1EvEs", "g()::S::S()::{string literal}");
- TEST_CORRECTLY_MANGLED_NAME("_ZZ1gvE5str4a", "g()::str4a");
- TEST_CORRECTLY_MANGLED_NAME("_ZZ1gvEs_1", "g()::{string literal}");
- TEST_CORRECTLY_MANGLED_NAME("_ZZ1gvE5str4b", "g()::str4b");
- TEST_CORRECTLY_MANGLED_NAME("_Z1fPFvvEM1SFvvE", "f(void (*)(), void (S::*)())");
- TEST_CORRECTLY_MANGLED_NAME("_ZN1N1TIiiE2mfES0_IddE", "N::T<int, int>::mf(N::T<double, double>)");
- TEST_CORRECTLY_MANGLED_NAME("_ZSt5state", "std::state");
- TEST_CORRECTLY_MANGLED_NAME("_ZNSt3_In4wardE", "std::_In::ward");
- TEST_CORRECTLY_MANGLED_NAME("_Z1fN1SUt_E", "f(S::{unnamed type#1})");
- TEST_CORRECTLY_MANGLED_NAME("_ZZZ1giEN1S1fE_2iEUt1_", "g(int)::S::f(int)::{unnamed type#3}");
- TEST_CORRECTLY_MANGLED_NAME("_ZZZ1giEN1S1fE_2iENUt1_2fxEv", "g(int)::S::f(int)::{unnamed type#3}::fx()");
- TEST_CORRECTLY_MANGLED_NAME("_Z1AIcfE", "A<char, float>");
- TEST_CORRECTLY_MANGLED_NAME("_Z1fIiEvT_PDtfL0pK_E", "void f<int>(int, decltype({param#1 const}) *)");
- TEST_CORRECTLY_MANGLED_NAME("_Z1AILln42EE", "A<-42L>");
- TEST_CORRECTLY_MANGLED_NAME("_Z2f1I1QEDTpldtfp_1xdtL_Z1qE1xET_", "decltype({param#1}.x + q.x) f1<Q>(Q)");
- TEST_CORRECTLY_MANGLED_NAME("_Z2f2I1QEDTpldtfp_1xsrS0_1xET_", "decltype({param#1}.x + Q::x) f2<Q>(Q)");
- TEST_CORRECTLY_MANGLED_NAME("_Z2f3IiEDTplfp_dtL_Z1dEsr1B1XIT_EE1xES1_", "decltype({param#1} + d.B::X<int>::x) f3<int>(int)");
- TEST_CORRECTLY_MANGLED_NAME("_Z3fooILi2EEvRAplT_Li1E_i", "void foo<2>(int (&)[2 + 1])");
- TEST_CORRECTLY_MANGLED_NAME("_ZZ1giENKUlvE_clEv", "g(int)::{lambda()#1}::operator()() const");
- TEST_CORRECTLY_MANGLED_NAME("_ZZ1giENKUlvE0_clEv", "g(int)::{lambda()#2}::operator()() const");
- TEST_CORRECTLY_MANGLED_NAME("_ZNK1SIiE1xMUlvE_clEv", "S<int>::x::{lambda()#1}::operator()() const");
- TEST_CORRECTLY_MANGLED_NAME("_ZN1S4funcEii", "S::func(int, int)");
+ newRow("_ZN1S1xE")
+ << "S::x";
+ newRow("_Z1fM1AKFvvE")
+ << "f(void (A::*)() const)";
+ newRow("_Z1fIiEvT_")
+ << "void f<int>(int)";
+ newRow("_Z3fooc")
+ << "foo(char)";
+ newRow("_Z2CBIL_Z3foocEE")
+ << "CB<foo(char)>";
+ newRow("_Z2CBIL_Z7IsEmptyEE")
+ << "CB<IsEmpty>";
+ newRow("_ZZ1giEN1S1fE_2i")
+ << "g(int)::S::f(int)";
+ newRow("_ZZ1gvEN1SC1Ev")
+ << "g()::S::S()";
+ newRow("_ZZZ1gvEN1SC1EvEs")
+ << "g()::S::S()::{string literal}";
+ newRow("_ZZ1gvE5str4a")
+ << "g()::str4a";
+ newRow("_ZZ1gvEs_1")
+ << "g()::{string literal}";
+ newRow("_ZZ1gvE5str4b")
+ << "g()::str4b";
+ newRow("_Z1fPFvvEM1SFvvE")
+ << "f(void (*)(), void (S::*)())";
+ newRow("_ZN1N1TIiiE2mfES0_IddE")
+ << "N::T<int, int>::mf(N::T<double, double>)";
+ newRow("_ZSt5state")
+ << "std::state";
+ newRow("_ZNSt3_In4wardE")
+ << "std::_In::ward";
+ newRow("_Z1fN1SUt_E")
+ << "f(S::{unnamed type#1})";
+ newRow("_ZZZ1giEN1S1fE_2iEUt1_")
+ << "g(int)::S::f(int)::{unnamed type#3}";
+ newRow("_ZZZ1giEN1S1fE_2iENUt1_2fxEv")
+ << "g(int)::S::f(int)::{unnamed type#3}::fx()";
+ newRow("_Z1AIcfE")
+ << "A<char, float>";
+ newRow("_Z1fIiEvT_PDtfL0pK_E")
+ << "void f<int>(int, decltype({param#1 const}) *)";
+ newRow("_Z1AILln42EE")
+ << "A<-42L>";
+ newRow("_Z2f1I1QEDTpldtfp_1xdtL_Z1qE1xET_")
+ << "decltype({param#1}.x + q.x) f1<Q>(Q)";
+ newRow("_Z2f2I1QEDTpldtfp_1xsrS0_1xET_")
+ << "decltype({param#1}.x + Q::x) f2<Q>(Q)";
+ newRow("_Z2f3IiEDTplfp_dtL_Z1dEsr1B1XIT_EE1xES1_")
+ << "decltype({param#1} + d.B::X<int>::x) f3<int>(int)";
+ newRow("_Z3fooILi2EEvRAplT_Li1E_i")
+ << "void foo<2>(int (&)[2 + 1])";
+ newRow("_ZZ1giENKUlvE_clEv")
+ << "g(int)::{lambda()#1}::operator()() const";
+ newRow("_ZZ1giENKUlvE0_clEv")
+ << "g(int)::{lambda()#2}::operator()() const";
+ newRow("_ZNK1SIiE1xMUlvE_clEv")
+ << "S<int>::x::{lambda()#1}::operator()() const";
+ newRow("_ZN1S4funcEii")
+ << "S::func(int, int)";
// Note: c++filt from binutils 2.22 demangles these wrong (counts default arguments from first instead of from last)
- TEST_CORRECTLY_MANGLED_NAME("_ZZN1S1fEiiEd0_NKUlvE_clEv", "S::f(int, int)::{default arg#1}::{lambda()#1}::operator()() const");
- TEST_CORRECTLY_MANGLED_NAME("_ZZN1S1fEiiEd0_NKUlvE0_clEv", "S::f(int, int)::{default arg#1}::{lambda()#2}::operator()() const");
- TEST_CORRECTLY_MANGLED_NAME("_ZZN1S1fEiiEd_NKUlvE_clEv", "S::f(int, int)::{default arg#2}::{lambda()#1}::operator()() const");
+ newRow("_ZZN1S1fEiiEd0_NKUlvE_clEv")
+ << "S::f(int, int)::{default arg#1}::{lambda()#1}::operator()() const";
+ newRow("_ZZN1S1fEiiEd0_NKUlvE0_clEv")
+ << "S::f(int, int)::{default arg#1}::{lambda()#2}::operator()() const";
+ newRow("_ZZN1S1fEiiEd_NKUlvE_clEv")
+ << "S::f(int, int)::{default arg#2}::{lambda()#1}::operator()() const";
// Note: gcc 4.6.3 encodes this as "_Z2f4I7OpClassEDTadsrT_miES1_".
- TEST_CORRECTLY_MANGLED_NAME("_Z2f4I7OpClassEDTadsrT_onmiES0_", "decltype(&OpClass::operator-) f4<OpClass>(OpClass)");
+ newRow("_Z2f4I7OpClassEDTadsrT_onmiES0_")
+ << "decltype(&OpClass::operator-) f4<OpClass>(OpClass)";
+#else
+ qDebug("Most tests disabled outside Linux");
+#endif
}
void NameDemanglerAutoTest::testIncorrectlyMangledNames()
diff --git a/tests/auto/cplusplus/simplifytypes/tst_simplifytypestest.cpp b/tests/auto/debugger/tst_simplifytypes.cpp
index 0cbbe312fb..6e3a882cfd 100644
--- a/tests/auto/cplusplus/simplifytypes/tst_simplifytypestest.cpp
+++ b/tests/auto/debugger/tst_simplifytypes.cpp
@@ -27,11 +27,14 @@
**
****************************************************************************/
-#include <cplusplus/CppRewriter.h>
+#include "simplifytype.h"
#include <QString>
#include <QtTest>
+using namespace Debugger;
+using namespace Internal;
+
const char *description[] =
{
"g++_stdstring",
@@ -44,7 +47,11 @@ const char *description[] =
"g++_wstringvector",
"g++_unordered_set",
"g++_unordered_map",
+
"libc++_stringvector",
+ "libc++_unordered_map",
+ "libc++_hash_node",
+
"msvc_stdstring",
"msvc_stdwstring",
"msvc_stringmap",
@@ -53,6 +60,9 @@ const char *description[] =
"msvc_stringset",
"msvc_stringvector",
"msvc_wstringvector",
+
+ "boost_shared_ptr",
+ "std_shared_ptr",
};
const char *input[] =
@@ -72,6 +82,11 @@ const char *input[] =
// libc++
"std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >",
+
+"std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float, std::__1::hash<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float> > >",
+
+"std::__1::__hash_node<int, void *>::value_type",
+
// MSVC
"class std::basic_string<char,std::char_traits<char>,std::allocator<char> >",
"class std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >",
@@ -80,7 +95,11 @@ const char *input[] =
"class std::list<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >",
"class std::set<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >",
"class std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >",
-"class std::vector<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >,std::allocator<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> > > >"
+"class std::vector<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >,std::allocator<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> > > >",
+// boost
+"boost::shared_ptr<int>::element_type",
+// std
+"std::shared_ptr<int>::element_type",
};
const char *output[] =
@@ -98,6 +117,8 @@ const char *output[] =
"std::unordered_map<int, int>",
// libc++
"std::vector<std::string>",
+ "std::unordered_map<std::string, float>",
+ "int",
// MSVC
"std::string",
"std::wstring",
@@ -107,6 +128,10 @@ const char *output[] =
"std::set<std::string>",
"std::vector<std::string>",
"std::vector<std::wstring>",
+ // boost
+ "int",
+ // std
+ "int",
};
class SimplifyTypesTest : public QObject
@@ -117,23 +142,23 @@ public:
SimplifyTypesTest();
private Q_SLOTS:
- void testCase1();
- void testCase1_data();
+ void test();
+ void test_data();
};
SimplifyTypesTest::SimplifyTypesTest()
{
}
-void SimplifyTypesTest::testCase1()
+void SimplifyTypesTest::test()
{
QFETCH(QString, input);
QFETCH(QString, expected);
- const QString output = CPlusPlus::simplifySTLType(input);
+ const QString output = simplifyType(input);
QCOMPARE(output, expected);
}
-void SimplifyTypesTest::testCase1_data()
+void SimplifyTypesTest::test_data()
{
QTest::addColumn<QString>("input");
QTest::addColumn<QString>("expected");
@@ -145,4 +170,4 @@ void SimplifyTypesTest::testCase1_data()
QTEST_APPLESS_MAIN(SimplifyTypesTest);
-#include "tst_simplifytypestest.moc"
+#include "tst_simplifytypes.moc"
diff --git a/tests/auto/externaltool/externaltool.pro b/tests/auto/externaltool/externaltool.pro
index 5af23b7e4e..bc16a794f3 100644
--- a/tests/auto/externaltool/externaltool.pro
+++ b/tests/auto/externaltool/externaltool.pro
@@ -1,9 +1,9 @@
-IDE_BUILD_TREE = $$OUT_PWD/../../../
+QTC_PLUGIN_DEPENDS += coreplugin
include(../qttest.pri)
-include(../../../src/plugins/coreplugin/coreplugin.pri)
+include($$IDE_SOURCE_TREE/src/plugins/coreplugin/coreplugin_dependencies.pri)
+include($$IDE_SOURCE_TREE/src/libs/utils/utils_dependencies.pri)
+
LIBS *= -L$$IDE_PLUGIN_PATH/QtProject
-INCLUDEPATH *= $$IDE_SOURCE_TREE/src/plugins/coreplugin
-INCLUDEPATH *= $$IDE_BUILD_TREE/src/plugins/coreplugin
SOURCES += tst_externaltooltest.cpp \
$$IDE_SOURCE_TREE/src/plugins/coreplugin/externaltool.cpp
diff --git a/tests/auto/externaltool/tst_externaltooltest.cpp b/tests/auto/externaltool/tst_externaltooltest.cpp
index 3e6b483205..23ea759f6a 100644
--- a/tests/auto/externaltool/tst_externaltooltest.cpp
+++ b/tests/auto/externaltool/tst_externaltooltest.cpp
@@ -50,8 +50,7 @@ static const char TEST_XML1[] =
" <arguments>%{CurrentProjectFilePath}</arguments>"
" <workingdirectory>%{CurrentProjectPath}</workingdirectory>"
" </executable>"
-"</externaltool>"
-;
+"</externaltool>";
static const char TEST_XML2[] =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -213,7 +212,8 @@ void ExternaltoolTest::testReadLocale()
QCOMPARE(tool->description(), QString::fromLatin1("Grüezi"));
QCOMPARE(tool->displayName(), QString::fromLatin1("Grüezi"));
QCOMPARE(tool->displayCategory(), QString::fromLatin1("Grüezi"));
- delete tool;}
+ delete tool;
+}
QTEST_APPLESS_MAIN(ExternaltoolTest);
diff --git a/tests/auto/qml/codemodel/check/case-fallthrough.qml b/tests/auto/qml/codemodel/check/case-fallthrough.qml
index a1851da564..418d8c022a 100644
--- a/tests/auto/qml/codemodel/check/case-fallthrough.qml
+++ b/tests/auto/qml/codemodel/check/case-fallthrough.qml
@@ -1,6 +1,6 @@
import QtQuick 2.0
-Item {
+Item { // 324 1 4
x: {
switch (a) {
case 1:
diff --git a/tests/auto/qml/codemodel/check/check.pro b/tests/auto/qml/codemodel/check/check.pro
index c8028fe0e9..db5e51419c 100644
--- a/tests/auto/qml/codemodel/check/check.pro
+++ b/tests/auto/qml/codemodel/check/check.pro
@@ -1,12 +1,9 @@
+QTC_LIB_DEPENDS += qmljs
include(../../../qttest.pri)
DEFINES+=QTCREATORDIR=\\\"$$IDE_SOURCE_TREE\\\"
DEFINES+=TESTSRCDIR=\\\"$$PWD\\\"
-include($$IDE_SOURCE_TREE/src/libs/utils/utils-lib.pri)
-include($$IDE_SOURCE_TREE/src/libs/languageutils/languageutils-lib.pri)
-include($$IDE_SOURCE_TREE/src/libs/qmljs/qmljs-lib.pri)
-
TARGET = tst_codemodel_check
SOURCES += \
diff --git a/tests/auto/qml/codemodel/check/check.qbs b/tests/auto/qml/codemodel/check/check.qbs
index ffa48d6ac2..bd37ce8001 100644
--- a/tests/auto/qml/codemodel/check/check.qbs
+++ b/tests/auto/qml/codemodel/check/check.qbs
@@ -5,7 +5,6 @@ Autotest {
name: "QML code model check autotest"
Depends { name: "LanguageUtils" }
Depends { name: "QmlJS" }
- Depends { name: "Utils" }
Depends { name: "Qt.widgets" }
files: "tst_check.cpp"
cpp.defines: base.concat([
diff --git a/tests/auto/qml/persistenttrie/persistenttrie.pro b/tests/auto/qml/persistenttrie/persistenttrie.pro
index c9da2c9dac..46b0c701ce 100644
--- a/tests/auto/qml/persistenttrie/persistenttrie.pro
+++ b/tests/auto/qml/persistenttrie/persistenttrie.pro
@@ -1,11 +1,8 @@
+QTC_LIB_DEPENDS += qmljs
include(../../qttest.pri)
DEFINES+=QTCREATORDIR=\\\"$$IDE_SOURCE_TREE\\\"
-DEFINES+=TESTSRCDIR=\\\"$$PWD\\\"
-
-include($$IDE_SOURCE_TREE/src/libs/utils/utils-lib.pri)
-include($$IDE_SOURCE_TREE/src/libs/languageutils/languageutils-lib.pri)
-include($$IDE_SOURCE_TREE/src/libs/qmljs/qmljs-lib.pri)
+DEFINES+=TESTSRCDIR=\\\"$$_PRO_FILE_PWD_\\\"
TARGET = tst_trie_check
@@ -15,7 +12,6 @@ SOURCES += \
tst_testtrie.cpp
TEMPLATE = app
-TARGET = tester
DEFINES += QMLJS_BUILD_DIR
OTHER_FILES += \
diff --git a/tests/auto/qml/persistenttrie/persistenttrie.qbs b/tests/auto/qml/persistenttrie/persistenttrie.qbs
new file mode 100644
index 0000000000..36181f04ea
--- /dev/null
+++ b/tests/auto/qml/persistenttrie/persistenttrie.qbs
@@ -0,0 +1,14 @@
+import qbs
+import "../../autotest.qbs" as Autotest
+
+Autotest {
+ name: "QML persistenttrie autotest"
+ Depends { name: "QmlJS" }
+ Depends { name: "Qt.widgets" } // TODO: Remove when qbs bug is fixed
+ files: [ "tst_testtrie.h", "tst_testtrie.cpp" ]
+ cpp.defines: base.concat([
+ 'QMLJS_BUILD_DIR',
+ 'QTCREATORDIR="' + project.ide_source_tree + '"',
+ 'TESTSRCDIR="' + path + '"'
+ ])
+}
diff --git a/tests/auto/qml/persistenttrie/tst_testtrie.cpp b/tests/auto/qml/persistenttrie/tst_testtrie.cpp
index 75a4b48b89..238026180e 100644
--- a/tests/auto/qml/persistenttrie/tst_testtrie.cpp
+++ b/tests/auto/qml/persistenttrie/tst_testtrie.cpp
@@ -45,7 +45,7 @@ void tst_TestTrie::initTestCase() {
const bool VERBOSE=false;
-tst_TestTrie::tst_TestTrie() { QObject::QObject(); }
+tst_TestTrie::tst_TestTrie() { }
void tst_TestTrie::testListAll_data()
{
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
index 5b320abd5e..d40c95945b 100644
--- a/tests/auto/qml/qml.pro
+++ b/tests/auto/qml/qml.pro
@@ -1,8 +1,11 @@
TEMPLATE = subdirs
-SUBDIRS += qmldesigner \
+SUBDIRS += \
+ #qmldesigner \
qmleditor \
+ qmljssimplereader \
qmlprojectmanager \
codemodel \
reformatter \
- qrcparser
+ qrcparser \
+ persistenttrie
diff --git a/tests/auto/qml/qml.qbs b/tests/auto/qml/qml.qbs
index e15aba1dfa..76659a5256 100644
--- a/tests/auto/qml/qml.qbs
+++ b/tests/auto/qml/qml.qbs
@@ -9,6 +9,7 @@ Project {
"qmljssimplereader/qmljssimplereader.qbs",
"qmlprojectmanager/qmlprojectmanager.qbs",
"qrcparser/qrcparser.qbs",
- "reformatter/reformatter.qbs"
+ "reformatter/reformatter.qbs",
+ "persistenttrie/persistenttrie.qbs"
]
}
diff --git a/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro b/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro
index 7e07bf38af..5f718690f5 100644
--- a/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro
+++ b/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.pro
@@ -1,18 +1,10 @@
+QTC_LIB_DEPENDS += qmljs
+QTC_PLUGIN_DEPENDS += qmljstools
include(../../../qttest.pri)
-SRCDIR = ../../../../../src
+SRCDIR = $$IDE_SOURCE_TREE/src
-include($$SRCDIR/libs/qmljs/qmljs-lib.pri)
-include($$SRCDIR/libs/utils/utils-lib.pri)
-include($$SRCDIR/libs/languageutils/languageutils-lib.pri)
+LIBS += -L$$IDE_PLUGIN_PATH/QtProject
SOURCES += \
- tst_qmlcodeformatter.cpp \
- $$SRCDIR/plugins/qmljstools/qmljsqtstylecodeformatter.cpp \
- $$SRCDIR/plugins/texteditor/basetextdocumentlayout.cpp \
- $$SRCDIR/plugins/texteditor/itextmark.cpp
-
-HEADERS += \
- $$SRCDIR/plugins/qmljstools/qmljsqtstylecodeformatter.h \
- $$SRCDIR/plugins/texteditor/basetextdocumentlayout.h \
- $$SRCDIR/plugins/texteditor/itextmark.h
+ tst_qmlcodeformatter.cpp
diff --git a/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.qbs b/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.qbs
index 15691fb120..76e3f9d5a7 100644
--- a/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.qbs
+++ b/tests/auto/qml/qmleditor/qmlcodeformatter/qmlcodeformatter.qbs
@@ -3,10 +3,8 @@ import "../../../autotest.qbs" as Autotest
Autotest {
name: "QML code formatter autotest"
- Depends { name: "LanguageUtils" }
Depends { name: "QmlJS" }
Depends { name: "QmlJSTools" }
- Depends { name: "Utils" }
Depends { name: "Qt.widgets" } // TODO: Remove when qbs bug is fixed
files: "tst_qmlcodeformatter.cpp"
}
diff --git a/tests/auto/qml/qmljssimplereader/qmljssimplereader.pro b/tests/auto/qml/qmljssimplereader/qmljssimplereader.pro
index 20722acddf..2c168510d1 100644
--- a/tests/auto/qml/qmljssimplereader/qmljssimplereader.pro
+++ b/tests/auto/qml/qmljssimplereader/qmljssimplereader.pro
@@ -1,10 +1,8 @@
+QTC_LIB_DEPENDS += qmljs
include(../../qttest.pri)
DEFINES+=QTCREATORDIR=\\\"$$IDE_SOURCE_TREE\\\"
-DEFINES+=TESTSRCDIR=\\\"$$PWD\\\"
-
-include($$IDE_SOURCE_TREE/src/libs/utils/utils.pri)
-include($$IDE_SOURCE_TREE/src/libs/qmljs/qmljs.pri)
+DEFINES+=TESTSRCDIR=\\\"$$_PRO_FILE_PWD_\\\"
TARGET = tst_qmljssimplereader
diff --git a/tests/auto/qml/qmljssimplereader/qmljssimplereader.qbs b/tests/auto/qml/qmljssimplereader/qmljssimplereader.qbs
index 48e174b6c7..c607c03ed3 100644
--- a/tests/auto/qml/qmljssimplereader/qmljssimplereader.qbs
+++ b/tests/auto/qml/qmljssimplereader/qmljssimplereader.qbs
@@ -4,7 +4,6 @@ import "../../autotest.qbs" as Autotest
Autotest {
name: "QMLJS simple reader autotest"
Depends { name: "QmlJS" }
- Depends { name: "Utils" }
Depends { name: "Qt.widgets" } // TODO: Remove when qbs bug is fixed
files: "tst_qmljssimplereader.cpp"
cpp.defines: base.concat(["QT_CREATOR"])
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter1.qmlproject b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter1.qmlproject
new file mode 100644
index 0000000000..8e10572a9c
--- /dev/null
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter1.qmlproject
@@ -0,0 +1,6 @@
+import QmlProject 1.0
+
+Project {
+ QmlFiles {
+ }
+}
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter2.qmlproject b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter2.qmlproject
new file mode 100644
index 0000000000..11548bb768
--- /dev/null
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter2.qmlproject
@@ -0,0 +1,7 @@
+import QmlProject 1.0
+
+Project {
+ QmlFiles {
+ recursive: false
+ }
+}
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter3.qmlproject b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter3.qmlproject
new file mode 100644
index 0000000000..814c829234
--- /dev/null
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter3.qmlproject
@@ -0,0 +1,7 @@
+import QmlProject 1.0
+
+Project {
+ QmlFiles {
+ directory: "subdir"
+ }
+}
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter4.qmlproject b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter4.qmlproject
new file mode 100644
index 0000000000..19f1953e81
--- /dev/null
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter4.qmlproject
@@ -0,0 +1,11 @@
+import QmlProject 1.0
+
+Project {
+ QmlFiles {
+ directory: "."
+ recursive: false
+ }
+ QmlFiles {
+ directory: "subdir"
+ }
+}
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter5.qmlproject b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter5.qmlproject
new file mode 100644
index 0000000000..d464bb1c4b
--- /dev/null
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter5.qmlproject
@@ -0,0 +1,8 @@
+import QmlProject 1.0
+
+Project {
+ QmlFiles {
+ paths: [ "file1.qml",
+ "file2.qml" ]
+ }
+}
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter6.qmlproject b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter6.qmlproject
new file mode 100644
index 0000000000..526a8050ef
--- /dev/null
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter6.qmlproject
@@ -0,0 +1,7 @@
+import QmlProject 1.0
+
+Project {
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter7.qmlproject b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter7.qmlproject
new file mode 100644
index 0000000000..4eacf55c84
--- /dev/null
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter7.qmlproject
@@ -0,0 +1,7 @@
+import QmlProject 1.0
+
+Project {
+ ImageFiles {
+ filter: "?mage.[gf]if"
+ }
+}
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter8.qmlproject b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter8.qmlproject
new file mode 100644
index 0000000000..1dd518c680
--- /dev/null
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/data/testFileFilter8.qmlproject
@@ -0,0 +1,7 @@
+import QmlProject 1.1
+
+Project {
+ Files {
+ filter: "image.gif"
+ }
+}
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/data/testLibraryPaths.qmlproject b/tests/auto/qml/qmlprojectmanager/fileformat/data/testLibraryPaths.qmlproject
new file mode 100644
index 0000000000..a9cdc3cb2f
--- /dev/null
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/data/testLibraryPaths.qmlproject
@@ -0,0 +1,5 @@
+import QmlProject 1.0
+
+Project {
+ importPaths: [ "../otherLibrary", "library" ]
+}
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/data/testMainFile.qmlproject b/tests/auto/qml/qmlprojectmanager/fileformat/data/testMainFile.qmlproject
new file mode 100644
index 0000000000..18e1ba8a5d
--- /dev/null
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/data/testMainFile.qmlproject
@@ -0,0 +1,5 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "file1.qml"
+}
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/data/testMatchesFile.qmlproject b/tests/auto/qml/qmlprojectmanager/fileformat/data/testMatchesFile.qmlproject
new file mode 100644
index 0000000000..81398d69d4
--- /dev/null
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/data/testMatchesFile.qmlproject
@@ -0,0 +1,10 @@
+import QmlProject 1.0
+
+Project {
+ QmlFiles {
+ recursive: true
+ }
+ JavaScriptFiles {
+ paths: ["script.js"]
+ }
+}
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/fileformat.pro b/tests/auto/qml/qmlprojectmanager/fileformat/fileformat.pro
index 7169261f00..e85200c64e 100644
--- a/tests/auto/qml/qmlprojectmanager/fileformat/fileformat.pro
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/fileformat.pro
@@ -1,16 +1,17 @@
+QTC_LIB_DEPENDS += qmljs
include(../../../qttest.pri)
QT += script \
declarative
-PLUGIN_DIR=../../../../../src/plugins/qmlprojectmanager
+PLUGIN_DIR=$$IDE_SOURCE_TREE/src/plugins/qmlprojectmanager
include($$PLUGIN_DIR/fileformat/fileformat.pri)
-include($$IDE_SOURCE_TREE/src/libs/utils/utils-lib.pri)
+include($$IDE_SOURCE_TREE/src/libs/utils/utils_dependencies.pri)
INCLUDEPATH += $$PLUGIN_DIR/fileformat
-DEFINES += SRCDIR=\\\"$$PWD\\\"
+DEFINES += SRCDIR=\\\"$$_PRO_FILE_PWD_\\\"
TEMPLATE = app
SOURCES += tst_fileformat.cpp
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/fileformat.qbs b/tests/auto/qml/qmlprojectmanager/fileformat/fileformat.qbs
index 27ac534889..6e6f5266ff 100644
--- a/tests/auto/qml/qmlprojectmanager/fileformat/fileformat.qbs
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/fileformat.qbs
@@ -2,7 +2,6 @@ import qbs
import "../../../autotest.qbs" as Autotest
Autotest {
- condition: false
name: "QmlProjectManager file format autotest"
Depends { name: "QmlProjectManager" }
Depends { name: "Utils" }
diff --git a/tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat.cpp b/tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat.cpp
index 1d197478bd..005917052f 100644
--- a/tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat.cpp
+++ b/tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat.cpp
@@ -54,33 +54,25 @@ private slots:
tst_FileFormat::tst_FileFormat()
{
- QmlProjectFileFormat::registerDeclarativeTypes();
}
QString testDataDir = QLatin1String(SRCDIR "/data");
+static QmlProjectItem *loadQmlProject(QString name, QString *error)
+{
+ return QmlProjectFileFormat::parseProjectFile(testDataDir + "/" + name + ".qmlproject", error);
+}
+
void tst_FileFormat::testFileFilter()
{
+ QString error;
//
// Search for qml files in directory + subdirectories
//
- QString projectFile = QLatin1String(
- "import QmlProject 1.0\n"
- "Project {\n"
- " QmlFiles {"
- " }"
- "}\n");
-
{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(projectFile.toUtf8(), QUrl());
- if (!component.isReady())
- qDebug() << component.errorString();
- QVERIFY(component.isReady());
-
- QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
+ QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter1"), &error);
QVERIFY(project);
+ QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
@@ -88,88 +80,47 @@ void tst_FileFormat::testFileFilter()
<< testDataDir + "/file2.qml"
<< testDataDir + "/subdir/file3.qml");
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
+ delete project;
}
//
// search for all qml files in directory
//
- projectFile = QLatin1String(
- "import QmlProject 1.0\n"
- "Project {\n"
- " QmlFiles {\n"
- " recursive: false\n"
- " }\n"
- "}\n");
-
{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(projectFile.toUtf8(), QUrl());
- if (!component.isReady())
- qDebug() << component.errorString();
- QVERIFY(component.isReady());
-
- QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
+ QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter2"), &error);
QVERIFY(project);
+ QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/file1.qml"
<< testDataDir + "/file2.qml");
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
+ delete project;
}
//
// search for all qml files in subdirectory
//
- projectFile = QLatin1String(
- "import QmlProject 1.0\n"
- "Project {\n"
- " QmlFiles {\n"
- " directory: \"subdir\"\n"
- " }\n"
- "}\n");
-
{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(projectFile.toUtf8(), QUrl());
- QVERIFY(component.isReady());
-
- QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
+ QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter3"), &error);
QVERIFY(project);
+ QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/subdir/file3.qml");
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
+ delete project;
}
//
// multiple entries
//
- projectFile = QLatin1String(
- "import QmlProject 1.0\n"
- "Project {\n"
- " QmlFiles {\n"
- " directory: \".\"\n"
- " recursive: false\n"
- " }"
- " QmlFiles {\n"
- " directory: \"subdir\"\n"
- " }\n"
- "}\n");
-
{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(projectFile.toUtf8(), QUrl());
- if (!component.isReady())
- qDebug() << component.errorString();
- QVERIFY(component.isReady());
-
- QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
+ QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter4"), &error);
QVERIFY(project);
+ QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
@@ -178,151 +129,83 @@ void tst_FileFormat::testFileFilter()
<< testDataDir + "/subdir/file3.qml");
QCOMPARE(project->files().size(), 3);
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
+ delete project;
}
//
// include specific list
//
- projectFile = QLatin1String(
- "import QmlProject 1.0\n"
- "Project {\n"
- " QmlFiles {\n"
- " paths: [ \"file1.qml\",\n"
- "\"file2.qml\" ]\n"
- " }\n"
- "}\n");
-
{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(projectFile.toUtf8(), QUrl());
- if (!component.isReady())
- qDebug() << component.errorString();
- QVERIFY(component.isReady());
-
- QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
+ QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter5"), &error);
QVERIFY(project);
+ QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/file1.qml"
<< testDataDir + "/file2.qml");
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
+ delete project;
}
//
// include specific list
//
- projectFile = QLatin1String(
- "import QmlProject 1.0\n"
- "Project {\n"
- " ImageFiles {\n"
- " directory: \".\"\n"
- " }\n"
- "}\n");
-
{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(projectFile.toUtf8(), QUrl());
- if (!component.isReady())
- qDebug() << component.errorString();
- QVERIFY(component.isReady());
-
- QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
+ QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter6"), &error);
QVERIFY(project);
+ QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/image.gif");
qDebug() << project->files().toSet() << expectedFiles.toSet();
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
+ delete project;
}
//
// use wildcards
//
- projectFile = QLatin1String(
- "import QmlProject 1.0\n"
- "Project {\n"
- " ImageFiles {\n"
- " filter: \"?mage.[gf]if\"\n"
- " }\n"
- "}\n");
-
{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(projectFile.toUtf8(), QUrl());
- if (!component.isReady())
- qDebug() << component.errorString();
- QVERIFY(component.isReady());
-
- QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
+ QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter7"), &error);
QVERIFY(project);
+ QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/image.gif");
qDebug() << project->files().toSet() << expectedFiles.toSet();
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
+ delete project;
}
//
// use Files element (1.1)
//
- projectFile = QLatin1String(
- "import QmlProject 1.1\n"
- "Project {\n"
- " Files {\n"
- " filter: \"image.gif\"\n"
- " }\n"
- "}\n");
-
{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(projectFile.toUtf8(), QUrl());
- if (!component.isReady())
- qDebug() << component.errorString();
- QVERIFY(component.isReady());
-
- QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
+ QmlProjectItem *project = loadQmlProject(QLatin1String("testFileFilter8"), &error);
QVERIFY(project);
+ QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
QStringList expectedFiles(QStringList() << testDataDir + "/image.gif");
qDebug() << project->files().toSet() << expectedFiles.toSet();
QCOMPARE(project->files().toSet(), expectedFiles.toSet());
+ delete project;
}
}
void tst_FileFormat::testMatchesFile()
{
+ QString error;
//
// search for qml files in local directory
//
- QString projectFile = QLatin1String(
- "import QmlProject 1.0\n"
- "Project {\n"
- " QmlFiles {"
- " recursive: true"
- " }"
- " JavaScriptFiles {"
- " paths: [\"script.js\"]"
- " }"
- "}\n");
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(projectFile.toUtf8(), QUrl());
- if (!component.isReady())
- qDebug() << component.errorString();
- QVERIFY(component.isReady());
-
- QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
+ QmlProjectItem *project = loadQmlProject(QLatin1String("testMatchesFile"), &error);
QVERIFY(project);
+ QVERIFY(error.isEmpty());
project->setSourceDirectory(testDataDir);
@@ -331,63 +214,40 @@ void tst_FileFormat::testMatchesFile()
QVERIFY(project->matchesFile(testDataDir + "/subdir/notyetexistingfile.qml"));
QVERIFY(project->matchesFile(testDataDir + "/script.js"));
QVERIFY(!project->matchesFile(testDataDir + "/script.css"));
+ delete project;
}
void tst_FileFormat::testLibraryPaths()
{
+ QString error;
//
// search for qml files in local directory
//
- QString projectFile = QLatin1String(
- "import QmlProject 1.0\n"
- "Project {\n"
- " importPaths: [ \"../otherLibrary\", \"library\" ]\n"
- "}\n");
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(projectFile.toUtf8(), QUrl());
- if (!component.isReady())
- qDebug() << component.errorString();
- QVERIFY(component.isReady());
-
- QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
- QVERIFY(project);
+ QmlProjectItem *project = loadQmlProject(QLatin1String("testLibraryPaths"), &error);
+ QVERIFY(project);
+ QVERIFY(error.isEmpty());
- project->setSourceDirectory(testDataDir);
+ project->setSourceDirectory(testDataDir);
- QStringList expectedPaths(QStringList() << SRCDIR "/otherLibrary"
- << SRCDIR "/data/library");
- qDebug() << expectedPaths << project->importPaths();
- QCOMPARE(project->importPaths().toSet(), expectedPaths.toSet());
- }
+ QStringList expectedPaths(QStringList() << SRCDIR "/otherLibrary"
+ << SRCDIR "/data/library");
+ qDebug() << expectedPaths << project->importPaths();
+ QCOMPARE(project->importPaths().toSet(), expectedPaths.toSet());
+ delete project;
}
void tst_FileFormat::testMainFile()
{
+ QString error;
//
// search for qml files in local directory
//
- QString projectFile = QLatin1String(
- "import QmlProject 1.1\n"
- "Project {\n"
- " mainFile: \"file1.qml\"\n"
- "}\n");
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(projectFile.toUtf8(), QUrl());
- if (!component.isReady())
- qDebug() << component.errorString();
- QVERIFY(component.isReady());
-
- QmlProjectItem *project = qobject_cast<QmlProjectItem*>(component.create());
- QVERIFY(project);
+ QmlProjectItem *project = loadQmlProject(QLatin1String("testMainFile"), &error);
+ QVERIFY(project);
+ QVERIFY(error.isEmpty());
- QCOMPARE(project->mainFile(), QString("file1.qml"));
- }
+ QCOMPARE(project->mainFile(), QString("file1.qml"));
+ delete project;
}
QTEST_MAIN(tst_FileFormat);
diff --git a/tests/auto/qml/qmlprojectmanager/qmlprojectmanager.qbs b/tests/auto/qml/qmlprojectmanager/qmlprojectmanager.qbs
index 82f60bad77..1d1f1ea988 100644
--- a/tests/auto/qml/qmlprojectmanager/qmlprojectmanager.qbs
+++ b/tests/auto/qml/qmlprojectmanager/qmlprojectmanager.qbs
@@ -1,7 +1,6 @@
import qbs
Project {
- condition: false // Known to be broken, nobody cares.
name: "QmlProjectManager autotests"
references: "fileformat/fileformat.qbs"
}
diff --git a/tests/auto/qml/reformatter/reformatter.pro b/tests/auto/qml/reformatter/reformatter.pro
index 37b6d2a9a9..f4eb2fc3ee 100644
--- a/tests/auto/qml/reformatter/reformatter.pro
+++ b/tests/auto/qml/reformatter/reformatter.pro
@@ -1,10 +1,8 @@
+QTC_LIB_DEPENDS += qmljs
include(../../qttest.pri)
DEFINES+=QTCREATORDIR=\\\"$$IDE_SOURCE_TREE\\\"
-DEFINES+=TESTSRCDIR=\\\"$$PWD\\\"
-
-include($$IDE_SOURCE_TREE/src/libs/utils/utils-lib.pri)
-include($$IDE_SOURCE_TREE/src/libs/qmljs/qmljs-lib.pri)
+DEFINES+=TESTSRCDIR=\\\"$$_PRO_FILE_PWD_\\\"
TARGET = tst_reformatter
diff --git a/tests/auto/qml/reformatter/reformatter.qbs b/tests/auto/qml/reformatter/reformatter.qbs
index ace17a2174..0fc2c4dd92 100644
--- a/tests/auto/qml/reformatter/reformatter.qbs
+++ b/tests/auto/qml/reformatter/reformatter.qbs
@@ -4,7 +4,6 @@ import "../../autotest.qbs" as Autotest
Autotest {
name: "QML reformatter autotest"
Depends { name: "QmlJS" }
- Depends { name: "Utils" }
Depends { name: "Qt.widgets" } // TODO: Remove when qbs bug is fixed
files: "tst_reformatter.cpp"
cpp.defines: base.concat([
diff --git a/tests/auto/treeviewfind/treeviewfind.pro b/tests/auto/treeviewfind/treeviewfind.pro
index f2f6250a15..3d1b058d6c 100644
--- a/tests/auto/treeviewfind/treeviewfind.pro
+++ b/tests/auto/treeviewfind/treeviewfind.pro
@@ -1,4 +1,4 @@
-QTC_PLUGIN_DEPENDS += find
+QTC_PLUGIN_DEPENDS += coreplugin
include(../qttest.pri)
LIBS *= -L$$IDE_PLUGIN_PATH/QtProject
diff --git a/tests/auto/treeviewfind/treeviewfind.qbs b/tests/auto/treeviewfind/treeviewfind.qbs
index ec1b77de39..915e6671d0 100644
--- a/tests/auto/treeviewfind/treeviewfind.qbs
+++ b/tests/auto/treeviewfind/treeviewfind.qbs
@@ -3,7 +3,7 @@ import "../autotest.qbs" as Autotest
Autotest {
name: "TreeViewFind autotest"
- Depends { name: "Find" }
+ Depends { name: "Core" }
Depends { name: "Qt.widgets" } // For QTextDocument
files: "tst_treeviewfind.cpp"
}
diff --git a/tests/auto/treeviewfind/tst_treeviewfind.cpp b/tests/auto/treeviewfind/tst_treeviewfind.cpp
index a684e9a7ca..5a9045d14b 100644
--- a/tests/auto/treeviewfind/tst_treeviewfind.cpp
+++ b/tests/auto/treeviewfind/tst_treeviewfind.cpp
@@ -27,7 +27,7 @@
**
****************************************************************************/
-#include <find/treeviewfind.h>
+#include <coreplugin/find/treeviewfind.h>
#include <QtTest>
@@ -69,7 +69,7 @@ void tst_treeviewfind::wrapping()
tree->addTopLevelItems(toplevelitems);
// set up
- Find::TreeViewFind *findSupport = new Find::TreeViewFind(tree);
+ Core::TreeViewFind *findSupport = new Core::TreeViewFind(tree);
tree->setCurrentItem(toplevelitems.at(2)->child(0));
QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("FOO2"));
@@ -80,7 +80,7 @@ void tst_treeviewfind::wrapping()
// backward
tree->setCurrentItem(toplevelitems.at(0)->child(0));
QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("FOO1"));
- findSupport->findStep(QLatin1String("FOO"), Find::FindBackward);
+ findSupport->findStep(QLatin1String("FOO"), Core::FindBackward);
QCOMPARE(tree->currentItem(), toplevelitems.at(2)->child(0));
// clean up
@@ -114,7 +114,7 @@ void tst_treeviewfind::columns()
tree->addTopLevelItems(toplevelitems);
// set up
- Find::TreeViewFind *findSupport = new Find::TreeViewFind(tree);
+ Core::TreeViewFind *findSupport = new Core::TreeViewFind(tree);
tree->setCurrentItem(toplevelitems.at(0));
QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("HEADER1"));
@@ -137,13 +137,13 @@ void tst_treeviewfind::columns()
// backwards
tree->setCurrentItem(toplevelitems.at(2)->child(0));
QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("A"));
- findSupport->findStep(QLatin1String("FOO"), Find::FindBackward);
+ findSupport->findStep(QLatin1String("FOO"), Core::FindBackward);
QCOMPARE(tree->currentItem(), toplevelitems.at(1)->child(0));
- findSupport->findStep(QLatin1String("FOO"), Find::FindBackward);
+ findSupport->findStep(QLatin1String("FOO"), Core::FindBackward);
QCOMPARE(tree->currentItem(), toplevelitems.at(1));
- findSupport->findStep(QLatin1String("FOO"), Find::FindBackward);
+ findSupport->findStep(QLatin1String("FOO"), Core::FindBackward);
QCOMPARE(tree->currentItem(), toplevelitems.at(0)->child(0));
- findSupport->findStep(QLatin1String("FOO"), Find::FindBackward);
+ findSupport->findStep(QLatin1String("FOO"), Core::FindBackward);
QCOMPARE(tree->currentItem(), toplevelitems.at(2)->child(0));
// clean up
diff --git a/tests/manual/debugger/debugger.pro b/tests/manual/debugger/debugger.pro
index f45a4ce400..b662d6f866 100644
--- a/tests/manual/debugger/debugger.pro
+++ b/tests/manual/debugger/debugger.pro
@@ -2,5 +2,4 @@ TEMPLATE=subdirs
SUBDIRS= \
gui \
-helper \
simple
diff --git a/tests/manual/debugger/helper/helper.pro b/tests/manual/debugger/helper/helper.pro
deleted file mode 100644
index 42968d146f..0000000000
--- a/tests/manual/debugger/helper/helper.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-include(../../../../qtcreator.pri)
-TEMPLATE = app
-greaterThan(QT_MAJOR_VERSION, 4):QT *= widgets
-
-win32:DEFINES += _CRT_SECURE_NO_WARNINGS
-SOURCES += $$IDE_SOURCE_TREE/share/qtcreator/debugger/dumper.cpp
-SOURCES += main.cpp