Merge remote-tracking branch 'origin/3.4'

Change-Id: I66ac8be7a8e99fc730131f75710bafc73809f593
This commit is contained in:
Eike Ziller
2015-03-02 12:11:32 +01:00
357 changed files with 2741 additions and 1622 deletions

50
dist/changes-3.3.1 vendored Normal file
View File

@@ -0,0 +1,50 @@
Qt Creator version 3.3.1 contains bug fixes.
The most important changes are listed in this document. For a complete
list of changes, see the Git log for the Qt Creator sources that
you can check out from the public Git repository. For example:
git clone git://gitorious.org/qt-creator/qt-creator.git
git log --cherry-pick --pretty=oneline v3.3.0..v3.3.1
Editing
* Fixed crash with some highlighting files (QTCREATORBUG-13883)
CMake Projects
* Fixed include completion (QTCREATORBUG-13567)
* Fixed highlighting for CMake files (QTCREATORBUG-13588)
C++ Support
* Fixed comment continuation (QTCREATORBUG-13415)
* Fixed Convert to Pointer refactoring action for auto variables
(QTCREATORBUG-13605)
* Fixed that triggering refactoring actions from the context menu
worked only if the text cursor was set first (QTCREATORBUG-13388)
* Fixed crash if no kits are available (QTCREATORBUG-13730)
* Fixed infinite loop when parsing some files (QTCREATORBUG-13703)
* Fixed crash when #if nesting is deeper than 512 levels
Version Control Systems
* Git
* Fixed reverting chunks in diff viewer when diff.mnemonicprefix is set
(QTCREATORBUG-13782)
* ClearCase
* Fixed that check out was requested even though the file was already
checked out (QTCREATORBUG-13782)
Code Pasting
* Fixed pasting to pastebin.ca (QTCREATORBUG-13802)
Platform Specific
OS X
* Fixed dropping files from Finder onto Qt Creator (QTBUG-40449)
Android
* Fixed crash when removing auto-detected kits (QTCREATORBUG-13736)
* Fixed debugging applications that link many modules (QTCREATORBUG-13691)
WinRT
* Fixed installing custom files into package root (QTCREATORBUG-13835)
* Fixed occasional crashes when debugging

2
dist/known-issues vendored
View File

@@ -1,6 +1,6 @@
The Qt Creator Manual lists known issues in Qt Creator: The Qt Creator Manual lists known issues in Qt Creator:
http://qt-project.org/doc/qtcreator/creator-known-issues.html http://doc.qt.io/qtcreator/creator-known-issues.html
For a complete list of reported issues, see the Qt Bug Tracker: For a complete list of reported issues, see the Qt Bug Tracker:

View File

@@ -891,7 +891,7 @@
for signals and slots inside connect statements to safely make for signals and slots inside connect statements to safely make
signal and slot lookup a few cycles faster. You can use signal and slot lookup a few cycles faster. You can use
$QTDIR/util/normalize to normalize existing code. For more $QTDIR/util/normalize to normalize existing code. For more
information, see \l{http://qt-project.org/doc/qt-4.8/qmetaobject.html#normalizedSignature}{QMetaObject::normalizedSignature}. information, see QMetaObject::normalizedSignature.
\endlist \endlist
\section2 File Headers \section2 File Headers

View File

@@ -227,7 +227,7 @@
for use in \QC, by using the information you gave above. for use in \QC, by using the information you gave above.
For more information about qmake, and writing .pro files in general, For more information about qmake, and writing .pro files in general,
see the \l{http://qt-project.org/doc/qt-4.8/qmake-manual.html}{qmake Manual}. see the \l{qmake Manual}.
\section1 Plugin Meta Data Template \section1 Plugin Meta Data Template

View File

@@ -23,7 +23,7 @@
\section1 Introduction \section1 Introduction
If the functionality provided by template-based If the functionality provided by template-based
\l{http://doc.qt.digia.com/qtcreator-snapshot/creator-project-wizards.html}{custom wizards} \l{http://doc.qt.io/qtcreator/creator-project-wizards.html}{custom wizards}
is not sufficient for your case, you can write wizards in code. is not sufficient for your case, you can write wizards in code.
A wizard in Qt Creator is an instance of a class implementing A wizard in Qt Creator is an instance of a class implementing

View File

@@ -53,7 +53,7 @@
to which you can add your own snippets. to which you can add your own snippets.
\list \list
\li \l{http://doc.qt.digia.com/qtcreator/creator-completing-code.html#editing-code-snippets} \li \l{http://doc.qt.io/qtcreator/creator-completing-code.html#editing-code-snippets}
{Snippets User Interface} {Snippets User Interface}
\li \l{Snippets} {Adding Snippets Groups} \li \l{Snippets} {Adding Snippets Groups}
\endlist \endlist
@@ -64,7 +64,7 @@
own own
file and project templates by writing XML definition files for them. file and project templates by writing XML definition files for them.
\list \list
\li \l{http://doc.qt.digia.com/qtcreator/creator-project-wizards.html} \li \l{http://doc.qt.io/qtcreator/creator-project-wizards.html}
{Adding New Custom Wizards} {Adding New Custom Wizards}
\li \l{User Interface Text Guidelines} \li \l{User Interface Text Guidelines}
\endlist \endlist
@@ -96,7 +96,7 @@
the MIME type definitions in Qt Creator to your specific setup, the MIME type definitions in Qt Creator to your specific setup,
by adding or removing file extensions and specifying magic headers. by adding or removing file extensions and specifying magic headers.
\list \list
\li \l{http://doc.qt.digia.com/qtcreator/creator-mime-types.html} \li \l{http://doc.qt.io/qtcreator/creator-mime-types.html}
{Editing MIME Types} {Editing MIME Types}
\li \l{http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html} \li \l{http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html}
{MIME Type Specification Files} {MIME Type Specification Files}
@@ -110,7 +110,7 @@
provided by the Kate Editor. You can download highlight definition files provided by the Kate Editor. You can download highlight definition files
for use with Qt Creator and create your own definition files. for use with Qt Creator and create your own definition files.
\list \list
\li \l{http://doc.qt.digia.com/qtcreator/creator-editor-options.html#generic-highlighting} \li \l{http://doc.qt.io/qtcreator/creator-editor-options.html#generic-highlighting}
{Generic Highlighting} {Generic Highlighting}
\li \l{http://kate-editor.org/2005/03/24/writing-a-syntax-highlighting-file/} \li \l{http://kate-editor.org/2005/03/24/writing-a-syntax-highlighting-file/}
{Writing a Syntax Highlighting File} {Writing a Syntax Highlighting File}
@@ -162,7 +162,7 @@
to fill a feature suggestion. to fill a feature suggestion.
The tool descriptions are saved as XML files that you can share. The tool descriptions are saved as XML files that you can share.
\list \list
\li \l{http://doc.qt.digia.com/qtcreator/creator-editor-external.html} \li \l{http://doc.qt.io/qtcreator/creator-editor-external.html}
{Using External Tools} {Using External Tools}
\li \l{External Tool Specification Files} \li \l{External Tool Specification Files}
\endlist \endlist
@@ -189,7 +189,7 @@
If you need a way to configure the tool in Qt Creator, you can add an If you need a way to configure the tool in Qt Creator, you can add an
\uicontrol Options page for it. \uicontrol Options page for it.
\list \list
\li \l{http://doc.qt.digia.com/qtcreator/creator-editor-external.html} \li \l{http://doc.qt.io/qtcreator/creator-editor-external.html}
{Using External Tools} {Using External Tools}
\li \l{External Tool Specification Files} \li \l{External Tool Specification Files}
\li \l{Creating Plugins} \li \l{Creating Plugins}
@@ -214,7 +214,7 @@
the \uicontrol {Issues} output the \uicontrol {Issues} output
pane. pane.
\list \list
\li \l{http://doc.qt.digia.com/qtcreator/creator-task-lists.html} \li \l{http://doc.qt.io/qtcreator/creator-task-lists.html}
{Showing Task List Files in the Issues Pane} {Showing Task List Files in the Issues Pane}
\li \l{Creating Plugins} \li \l{Creating Plugins}
\li \l{Qt Creator Coding Rules} \li \l{Qt Creator Coding Rules}

View File

@@ -61,7 +61,7 @@
\section1 Configuring the Documentation Project \section1 Configuring the Documentation Project
\QC documentation is written by using QDoc. For more information about using \QC documentation is written by using QDoc. For more information about using
QDoc, see the \l{http://qt-project.org/doc/qt-5.1/qdoc/qdoc-index.html} QDoc, see the \l{http://doc.qt.io/qt-5/qdoc-index.html}
{QDoc Manual}. {QDoc Manual}.
QDoc finds the new topics automatically, when you place them as .qdoc files QDoc finds the new topics automatically, when you place them as .qdoc files
@@ -299,7 +299,7 @@
on OS X. You can view the HTML files in a browser and the help files in on OS X. You can view the HTML files in a browser and the help files in
the \QC \uicontrol Help mode. For more information about adding the help files to the \QC \uicontrol Help mode. For more information about adding the help files to
\QC, see \QC, see
\l{http://qt-project.org/doc/qtcreator/creator-help.html#adding-external-documentation} \l{http://doc.qt.io/qtcreator/creator-help.html#adding-external-documentation}
{Adding External Documentation}. {Adding External Documentation}.
Besides \c docs, you have the following options: Besides \c docs, you have the following options:

View File

@@ -1,6 +1,6 @@
project = "QtCreator" project = "QtCreator"
description = "Qt Creator Manual" description = "Qt Creator Manual"
url = http://qt-project.org/doc/qtcreator url = http://doc.qt.io/qtcreator
headerdirs = headerdirs =
sourcedirs = $SRCDIR/src sourcedirs = $SRCDIR/src

View File

@@ -27,7 +27,7 @@
To use Qbs to build a project, you must create a .qbs file for the project. To use Qbs to build a project, you must create a .qbs file for the project.
You can use \QC to create a C or C++ project that is built with Qbs. You can use \QC to create a C or C++ project that is built with Qbs.
For more information about Qbs, see For more information about Qbs, see
the \l{http://qt-project.org/doc/qbs/index.html}{Qbs Manual}. the \l{http://doc.qt.io/qbs/index.html}{Qbs Manual}.
\section1 Building Qbs \section1 Building Qbs
@@ -89,7 +89,7 @@
\li In the \uicontrol Properties field, specify the properties to pass \li In the \uicontrol Properties field, specify the properties to pass
to the project. Use colons (:) to separate keys from values. to the project. Use colons (:) to separate keys from values.
For more information, see For more information, see
\l{http://qt-project.org/doc/qbs/language-introduction.html} \l{http://doc.qt.io/qbs/language-introduction.html}
{Modules} in the Qbs Manual. {Modules} in the Qbs Manual.
\li In the \uicontrol Flags field: \li In the \uicontrol Flags field:

View File

@@ -114,7 +114,7 @@
the build step and add a custom build step that specifies another shell the build step and add a custom build step that specifies another shell
command. command.
\QC is integrated to \l{http://doc.qt.digia.com/QtQuickCompiler/} \QC is integrated to \l{http://doc.qt.io/QtQuickCompiler/}
{Qt Quick Compiler} (commercial only) that enables you to compile QML source {Qt Quick Compiler} (commercial only) that enables you to compile QML source
code into the final binary. This code into the final binary. This
improves the startup time of the application and eliminates the need to improves the startup time of the application and eliminates the need to

View File

@@ -65,7 +65,8 @@ if [ $LLVM_INSTALL_DIR ]; then
_CLANG_CODEMODEL_LIB="$1/Contents/PlugIns/libClangCodeModel.dylib" _CLANG_CODEMODEL_LIB="$1/Contents/PlugIns/libClangCodeModel.dylib"
fi fi
# this will just fail when run a second time on libClangCodeModel # this will just fail when run a second time on libClangCodeModel
xcrun install_name_tool -rpath "$LLVM_INSTALL_DIR/lib" "@loader_path/" "$_CLANG_CODEMODEL_LIB" || true xcrun install_name_tool -delete_rpath "$LLVM_INSTALL_DIR/lib" "$_CLANG_CODEMODEL_LIB" || true
xcrun install_name_tool -add_rpath "@loader_path/" "$_CLANG_CODEMODEL_LIB" || true
fi fi
#### macdeployqt #### macdeployqt

View File

@@ -1566,6 +1566,9 @@ class Dumper(DumperBase):
return typeobj return typeobj
def stackListFrames(self, args): def stackListFrames(self, args):
def fromNativePath(str):
return str.replace(os.path.sep, '/')
limit = int(args['limit']) limit = int(args['limit'])
if limit <= 0: if limit <= 0:
limit = 10000 limit = 10000
@@ -1594,9 +1597,9 @@ class Dumper(DumperBase):
line = sal.line line = sal.line
symtab = sal.symtab symtab = sal.symtab
if not symtab is None: if not symtab is None:
objfile = symtab.objfile.filename objfile = fromNativePath(symtab.objfile.filename)
fileName = symtab.filename fileName = fromNativePath(symtab.filename)
fullName = symtab.fullname() fullName = fromNativePath(symtab.fullname())
if self.nativeMixed: if self.nativeMixed:
if self.isReportableQmlFrame(functionName): if self.isReportableQmlFrame(functionName):

View File

@@ -69,7 +69,7 @@ Value = lldb.SBValue
def impl_SBValue__add__(self, offset): def impl_SBValue__add__(self, offset):
if self.GetType().IsPointerType(): if self.GetType().IsPointerType():
if isinstance(offset, int): if isinstance(offset, int) or isinstance(offset, long):
pass pass
else: else:
offset = offset.GetValueAsSigned() offset = offset.GetValueAsSigned()
@@ -647,8 +647,19 @@ class Dumper(DumperBase):
self.platform_ = args.get('platform', '') self.platform_ = args.get('platform', '')
self.ignoreStops = 0 self.ignoreStops = 0
if self.useTerminal_ and platform.system() == "Linux": self.silentStops = 0
self.ignoreStops = 2 if platform.system() == "Linux":
if self.startMode_ == AttachCore:
pass
else:
if self.useTerminal_:
self.ignoreStops = 2
else:
self.silentStops = 1
else:
if self.useTerminal_:
self.ignoreStops = 1
if self.platform_: if self.platform_:
self.debugger.SetCurrentPlatform(self.platform_) self.debugger.SetCurrentPlatform(self.platform_)
@@ -656,6 +667,7 @@ class Dumper(DumperBase):
if self.sysRoot_: if self.sysRoot_:
self.debugger.SetCurrentPlatformSDKRoot(self.sysRoot_) self.debugger.SetCurrentPlatformSDKRoot(self.sysRoot_)
if os.path.isfile(self.executable_): if os.path.isfile(self.executable_):
self.target = self.debugger.CreateTarget(self.executable_, None, None, True, error) self.target = self.debugger.CreateTarget(self.executable_, None, None, True, error)
else: else:
@@ -668,12 +680,12 @@ class Dumper(DumperBase):
state = "inferiorsetupok" if self.target.IsValid() else "inferiorsetupfailed" state = "inferiorsetupok" if self.target.IsValid() else "inferiorsetupfailed"
self.report('state="%s",msg="%s",exe="%s"' % (state, error, self.executable_)) self.report('state="%s",msg="%s",exe="%s"' % (state, error, self.executable_))
def runEngine(self, _): def runEngine(self, args):
self.prepare() self.prepare(args)
s = threading.Thread(target=self.loop, args=[]) s = threading.Thread(target=self.loop, args=[])
s.start() s.start()
def prepare(self): def prepare(self, args):
error = lldb.SBError() error = lldb.SBError()
listener = self.debugger.GetListener() listener = self.debugger.GetListener()
@@ -700,6 +712,11 @@ class Dumper(DumperBase):
# and later detects that it did stop after all, so it is be # and later detects that it did stop after all, so it is be
# better to mirror that and wait for the spontaneous stop. # better to mirror that and wait for the spontaneous stop.
self.reportState("enginerunandinferiorrunok") self.reportState("enginerunandinferiorrunok")
elif self.startMode_ == AttachCore:
coreFile = args.get('coreFile', '');
self.process = self.target.LoadCore(coreFile)
self.reportState("enginerunokandinferiorunrunnable")
#self.reportContinuation(args)
else: else:
launchInfo = lldb.SBLaunchInfo(self.processArgs_) launchInfo = lldb.SBLaunchInfo(self.processArgs_)
launchInfo.SetWorkingDirectory(os.getcwd()) launchInfo.SetWorkingDirectory(os.getcwd())
@@ -744,13 +761,12 @@ class Dumper(DumperBase):
thread = self.currentThread() thread = self.currentThread()
return None if thread is None else thread.GetSelectedFrame() return None if thread is None else thread.GetSelectedFrame()
def reportLocation(self): def reportLocation(self, frame):
thread = self.currentThread() if int(frame.pc) != 0xffffffffffffffff:
frame = thread.GetSelectedFrame() file = fileName(frame.line_entry.file)
file = fileName(frame.line_entry.file) line = frame.line_entry.line
line = frame.line_entry.line self.report('location={file="%s",line="%s",addr="%s"}'
self.report('location={file="%s",line="%s",addr="%s"}' % (file, line, frame.pc))
% (file, line, frame.pc))
def firstStoppedThread(self): def firstStoppedThread(self):
for i in xrange(0, self.process.GetNumThreads()): for i in xrange(0, self.process.GetNumThreads()):
@@ -1218,7 +1234,11 @@ class Dumper(DumperBase):
for group in frame.GetRegisters(): for group in frame.GetRegisters():
for reg in group: for reg in group:
result += '{name="%s"' % reg.GetName() result += '{name="%s"' % reg.GetName()
result += ',value="%s"' % reg.GetValue() value = reg.GetValue()
if value is None:
result += ',value=""'
else:
result += ',value="%s"' % value
result += ',size="%s"' % reg.GetByteSize() result += ',size="%s"' % reg.GetByteSize()
result += ',type="%s"},' % reg.GetType() result += ',type="%s"},' % reg.GetType()
result += ']' result += ']'
@@ -1304,6 +1324,8 @@ class Dumper(DumperBase):
elif self.ignoreStops > 0: elif self.ignoreStops > 0:
self.ignoreStops -= 1 self.ignoreStops -= 1
self.process.Continue() self.process.Continue()
elif self.silentStops > 0:
self.silentStops -= 1
#elif bp and bp in self.qmlBreakpointResolvers: #elif bp and bp in self.qmlBreakpointResolvers:
# self.report("RESOLVER HIT") # self.report("RESOLVER HIT")
# self.qmlBreakpointResolvers[bp]() # self.qmlBreakpointResolvers[bp]()
@@ -1320,7 +1342,8 @@ class Dumper(DumperBase):
self.process.SetSelectedThread(stoppedThread) self.process.SetSelectedThread(stoppedThread)
self.reportStackTop() self.reportStackTop()
self.reportThreads() self.reportThreads()
self.reportLocation() if stoppedThread:
self.reportLocation(stoppedThread.GetSelectedFrame())
elif eventType == lldb.SBProcess.eBroadcastBitInterrupt: # 2 elif eventType == lldb.SBProcess.eBroadcastBitInterrupt: # 2
pass pass
elif eventType == lldb.SBProcess.eBroadcastBitSTDOUT: elif eventType == lldb.SBProcess.eBroadcastBitSTDOUT:
@@ -1545,16 +1568,14 @@ class Dumper(DumperBase):
self.reportState("running") self.reportState("running")
self.reportState("stopped") self.reportState("stopped")
self.reportError(error) self.reportError(error)
self.reportLocation() self.reportLocation(self.currentFrame())
else: else:
self.reportData() self.reportData()
def executeJumpToLocation(self, args): def executeJumpToLocation(self, args):
frame = self.currentFrame() frame = self.currentFrame()
self.reportState("stopped")
if not frame: if not frame:
self.reportStatus("No frame available.") self.reportStatus("No frame available.")
self.reportLocation()
return return
addr = args.get('address', 0) addr = args.get('address', 0)
if addr: if addr:
@@ -1565,12 +1586,15 @@ class Dumper(DumperBase):
if bp.GetNumLocations() == 0: if bp.GetNumLocations() == 0:
self.target.BreakpointDelete(bp.GetID()) self.target.BreakpointDelete(bp.GetID())
self.reportStatus("No target location found.") self.reportStatus("No target location found.")
self.reportLocation() self.reportLocation(frame)
return return
loc = bp.GetLocationAtIndex(0) loc = bp.GetLocationAtIndex(0)
self.target.BreakpointDelete(bp.GetID()) self.target.BreakpointDelete(bp.GetID())
frame.SetPC(loc.GetLoadAddress()) if frame.SetPC(loc.GetLoadAddress()):
self.reportData() self.report("Jumped.")
else:
self.report("Cannot jump.")
self.reportLocation(frame)
def breakList(self): def breakList(self):
result = lldb.SBCommandReturnObject() result = lldb.SBCommandReturnObject()
@@ -1587,7 +1611,6 @@ class Dumper(DumperBase):
def selectThread(self, args): def selectThread(self, args):
self.process.SetSelectedThreadByID(args['id']) self.process.SetSelectedThreadByID(args['id'])
self.reportData()
def requestModuleSymbols(self, frame): def requestModuleSymbols(self, frame):
self.handleCommand("target module list " + frame) self.handleCommand("target module list " + frame)

View File

@@ -68,7 +68,6 @@ ComboBoxStyle {
anchors.fill: parent anchors.fill: parent
anchors.margins: -1 anchors.margins: -1
color: "transparent" color: "transparent"
radius: 4
opacity: 0.3 opacity: 0.3
visible: control.activeFocus visible: control.activeFocus
} }

View File

@@ -70,7 +70,6 @@ SpinBoxStyle {
implicitWidth: Math.max(64, styleData.contentWidth) implicitWidth: Math.max(64, styleData.contentWidth)
implicitHeight: 23 implicitHeight: 23
border.color: borderColor border.color: borderColor
radius: 3
gradient: Gradient { gradient: Gradient {
GradientStop {color: "#2c2c2c" ; position: 0} GradientStop {color: "#2c2c2c" ; position: 0}
GradientStop {color: "#343434" ; position: 0.15} GradientStop {color: "#343434" ; position: 0.15}
@@ -81,7 +80,6 @@ SpinBoxStyle {
anchors.fill: parent anchors.fill: parent
anchors.margins: -1 anchors.margins: -1
color: "transparent" color: "transparent"
radius: 4
opacity: 0.3 opacity: 0.3
visible: control.activeFocus visible: control.activeFocus
} }

View File

@@ -123,7 +123,6 @@ Controls.TextField {
implicitWidth: 100 implicitWidth: 100
implicitHeight: 23 implicitHeight: 23
border.color: borderColor border.color: borderColor
radius: 3
gradient: Gradient { gradient: Gradient {
GradientStop {color: "#2c2c2c" ; position: 0} GradientStop {color: "#2c2c2c" ; position: 0}
GradientStop {color: "#343434" ; position: 0.15} GradientStop {color: "#343434" ; position: 0.15}

View File

@@ -48,7 +48,7 @@ Rectangle {
property bool roundRight: false property bool roundRight: false
radius: roundLeft || roundRight ? 4 : 0 radius: roundLeft || roundRight ? 1 : 0
gradient: Gradient { gradient: Gradient {
GradientStop {color: '#555' ; position: 0} GradientStop {color: '#555' ; position: 0}
GradientStop {color: '#444' ; position: 1} GradientStop {color: '#444' ; position: 1}

View File

@@ -68,12 +68,10 @@ Item {
Behavior on rotation {NumberAnimation{duration: 80}} Behavior on rotation {NumberAnimation{duration: 80}}
} }
gradient: Gradient { color: "#444"
GradientStop {color: '#555' ; position: 0}
GradientStop {color: '#444' ; position: 1}
}
Rectangle { Rectangle {
visible: false
color:"#333" color:"#333"
width: parent.width width: parent.width
height: 1 height: 1

View File

@@ -45,7 +45,6 @@ TextFieldStyle {
implicitWidth: 100 implicitWidth: 100
implicitHeight: font.pixelSize + padding.top + padding.bottom implicitHeight: font.pixelSize + padding.top + padding.bottom
border.color: "#222222" border.color: "#222222"
radius: 3
gradient: Gradient { gradient: Gradient {
GradientStop {color: "#2c2c2c" ; position: 0} GradientStop {color: "#2c2c2c" ; position: 0}
GradientStop {color: "#343434" ; position: 0.15} GradientStop {color: "#343434" ; position: 0.15}

View File

@@ -36,17 +36,12 @@ Rectangle {
border.width: 1 border.width: 1
property bool isBaseState property bool isBaseState
property bool isCurrentState property bool isCurrentState
property color gradiantBaseColor property color baseColor
property string delegateStateName property string delegateStateName
property string delegateStateImageSource property string delegateStateImageSource
property int delegateStateImageSize property int delegateStateImageSize
gradient: Gradient { color: baseColor
GradientStop { position: 0.0; color: Qt.lighter(gradiantBaseColor, 1.5) }
GradientStop { position: 0.1; color: Qt.lighter(gradiantBaseColor, 1) }
GradientStop { position: 0.8; color: gradiantBaseColor }
GradientStop { position: 1.0; color: Qt.darker(gradiantBaseColor) }
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
@@ -63,7 +58,7 @@ Rectangle {
style: ButtonStyle { style: ButtonStyle {
background: Rectangle { background: Rectangle {
color: control.hovered ? Qt.lighter(gradiantBaseColor, 1.4) : "transparent" color: control.hovered ? Qt.lighter(baseColor, 1.2) : "transparent"
radius: 2 radius: 2
} }
} }

View File

@@ -102,14 +102,24 @@ FocusScope {
id: addStateButton id: addStateButton
visible: canAddNewStates visible: canAddNewStates
tooltip: qsTr("Add a new state.")
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: padding anchors.rightMargin: 8
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: Math.max(parent.height / 2, 24) width: Math.max(parent.height / 2 - 8, 18)
height: width height: width
iconSource: "images/plus.png" iconSource: "images/plus.png"
onClicked: root.createNewState() onClicked: root.createNewState()
style: ButtonStyle {
background: Rectangle {
property color buttonBaseColor: "#6f6f6f"
color: control.hovered ? Qt.lighter(buttonBaseColor, 1.2) : buttonBaseColor
border.width: 1
}
}
} }
} }
@@ -136,7 +146,7 @@ FocusScope {
height: delegateHeight height: delegateHeight
isBaseState: 0 == internalNodeId isBaseState: 0 == internalNodeId
isCurrentState: root.currentStateInternalId == internalNodeId isCurrentState: root.currentStateInternalId == internalNodeId
gradiantBaseColor: isCurrentState ? Qt.darker(highlightColor, 1.2) : background.color baseColor: isCurrentState ? Qt.darker(highlightColor, 1.2) : background.color
delegateStateName: stateName delegateStateName: stateName
delegateStateImageSource: stateImageSource delegateStateImageSource: stateImageSource
delegateStateImageSize: stateImageSize delegateStateImageSize: stateImageSize

Binary file not shown.

Before

Width:  |  Height:  |  Size: 469 B

After

Width:  |  Height:  |  Size: 197 B

View File

@@ -35,6 +35,6 @@ DummyContextObject {
property variant model: QtObject { property variant model: QtObject {
property string name: "Calculator" property string name: "Calculator"
property string description: "his demo shows how to write a simple calculator application in QML and JavaScript." property string description: "his demo shows how to write a simple calculator application in QML and JavaScript."
property string imageSource: "http://qt-project.org/doc/qt-4.8/images/qml-calculator-example-small.png" property string imageSource: "http://doc.qt.io/qt-4.8/images/qml-calculator-example-small.png"
} }
} }

View File

@@ -34,27 +34,27 @@ ListModel {
ListElement { ListElement {
name: "Calculator with more info on something bla bla on Qt if you know" name: "Calculator with more info on something bla bla on Qt if you know"
description: "his demo shows how to write a simple calculator application in QML and JavaScript." description: "his demo shows how to write a simple calculator application in QML and JavaScript."
imageSource: "http://qt-project.org/doc/qt-4.8/images/qml-calculator-example-small.png" imageSource: "http://doc.qt.io/qt-4.8/images/qml-calculator-example-small.png"
} }
ListElement { ListElement {
name: "RSS News Reader" name: "RSS News Reader"
description: "This demo shows how to write a RSS news reader in QML." description: "This demo shows how to write a RSS news reader in QML."
imageSource: "http://qt-project.org/doc/qt-4.8/images/qml-rssnews-demo-small.png" imageSource: "http://doc.qt.io/qt-4.8/images/qml-rssnews-demo-small.png"
} }
ListElement { ListElement {
name: "Twitter" name: "Twitter"
description: "This demo shows how to write a mobile Twitter search client in QML. Use it to see what people think about Qt Quick!" description: "This demo shows how to write a mobile Twitter search client in QML. Use it to see what people think about Qt Quick!"
imageSource: "http://qt-project.org/doc/qt-4.8/images/qml-twitter-demo-small.png" imageSource: "http://doc.qt.io/qt-4.8/images/qml-twitter-demo-small.png"
} }
ListElement { ListElement {
name: "Basic Drawing Example" name: "Basic Drawing Example"
description: "The Basic Drawing example shows how to display basic graphics primitives in a variety of styles using the QPainter class." description: "The Basic Drawing example shows how to display basic graphics primitives in a variety of styles using the QPainter class."
imageSource: "http://qt-project.org/doc/qt-4.8/images/basicdrawing-example.png" imageSource: "http://doc.qt.io/qt-4.8/images/basicdrawing-example.png"
} }
ListElement { ListElement {
name: "Border Layout Example" name: "Border Layout Example"
description: "The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules. The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules. The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules. The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules." description: "The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules. The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules. The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules. The Border Layout example shows how to create a custom layout that arranges child widgets according to a simple set of rules."
imageSource: "http://qt-project.org/doc/qt-4.8/images/borderlayout-example.png" imageSource: "http://doc.qt.io/qt-4.8/images/borderlayout-example.png"
} }
} }

View File

@@ -510,6 +510,24 @@ void calculateConstantValue(const Symbol *symbol, EnumeratorDeclaration *e, Cont
} }
} }
const StringLiteral *valueOfEnumerator(const Enum *e, const Identifier *value) {
const int enumMemberCount = e->memberCount();
for (int i = 0; i < enumMemberCount; ++i) {
const Symbol *member = e->memberAt(i);
if (const Declaration *decl = member->asDeclaration()) {
if (const EnumeratorDeclaration *enumDecl = decl->asEnumeratorDeclarator()) {
if (const Name *enumDeclName = enumDecl->name()) {
if (const Identifier *enumDeclIdentifier = enumDeclName->identifier()) {
if (enumDeclIdentifier->equalTo(value))
return enumDecl->constantValue();
}
}
}
}
}
return 0;
}
} // anonymous namespace } // anonymous namespace
void Bind::enumerator(EnumeratorAST *ast, Enum *symbol) void Bind::enumerator(EnumeratorAST *ast, Enum *symbol)
@@ -528,12 +546,21 @@ void Bind::enumerator(EnumeratorAST *ast, Enum *symbol)
EnumeratorDeclaration *e = control()->newEnumeratorDeclaration(ast->identifier_token, name); EnumeratorDeclaration *e = control()->newEnumeratorDeclaration(ast->identifier_token, name);
e->setType(control()->integerType(IntegerType::Int)); // ### introduce IntegerType::Enumerator e->setType(control()->integerType(IntegerType::Int)); // ### introduce IntegerType::Enumerator
if (ExpressionAST *expr = ast->expression) if (ExpressionAST *expr = ast->expression) {
e->setConstantValue(asStringLiteral(expr->firstToken(), expr->lastToken())); const int firstToken = expr->firstToken();
else if (!symbol->isEmpty()) const int lastToken = expr->lastToken();
const StringLiteral *constantValue = asStringLiteral(firstToken, lastToken);
const StringLiteral *resolvedValue = 0;
if (lastToken - firstToken == 1) {
if (const Identifier *constantId = identifier(firstToken))
resolvedValue = valueOfEnumerator(symbol, constantId);
}
e->setConstantValue(resolvedValue ? resolvedValue : constantValue);
} else if (!symbol->isEmpty()) {
calculateConstantValue(*(symbol->memberEnd()-1), e, control()); calculateConstantValue(*(symbol->memberEnd()-1), e, control());
else } else {
e->setConstantValue(control()->stringLiteral("0", 1)); e->setConstantValue(control()->stringLiteral("0", 1));
}
symbol->addMember(e); symbol->addMember(e);
} }

View File

@@ -674,7 +674,7 @@ static inline int classify7(const char *s, LanguageFeatures features)
} }
} }
} }
else if (features.qtEnabled && s[0] == 's') { else if (features.qtKeywordsEnabled && s[0] == 's') {
if (s[1] == 'i') { if (s[1] == 'i') {
if (s[2] == 'g') { if (s[2] == 'g') {
if (s[3] == 'n') { if (s[3] == 'n') {

View File

@@ -5696,7 +5696,13 @@ bool Parser::parseDesignatedInitializer(ExpressionAST *&node)
if (LA() == T_EQUAL) { if (LA() == T_EQUAL) {
ast->equal_token = consumeToken(); ast->equal_token = consumeToken();
if (parseAssignmentExpression(ast->initializer)) {
if (LA() == T_LBRACE) {
if (parseBracedInitList0x(node)) {
node = ast;
return true;
}
} else if (parseAssignmentExpression(ast->initializer)) {
node = ast; node = ast;
return true; return true;
} }

View File

@@ -100,7 +100,7 @@ void CloneType::visit(NamedType *type)
const Name *name = _clone->name(type->name(), _subst); const Name *name = _clone->name(type->name(), _subst);
FullySpecifiedType ty; FullySpecifiedType ty;
if (_subst) if (_subst)
ty = _subst->apply(name); ty = _clone->type(_subst->apply(name), 0);
if (! ty.isValid()) if (! ty.isValid())
ty = _control->namedType(name); ty = _control->namedType(name);
_type.setType(ty.type()); _type.setType(ty.type());

View File

@@ -38,6 +38,7 @@
using namespace CPlusPlus; using namespace CPlusPlus;
BackwardsScanner::BackwardsScanner(const QTextCursor &cursor, BackwardsScanner::BackwardsScanner(const QTextCursor &cursor,
const LanguageFeatures &languageFeatures,
int maxBlockCount, int maxBlockCount,
const QString &suffix, const QString &suffix,
bool skipComments) bool skipComments)
@@ -46,13 +47,7 @@ BackwardsScanner::BackwardsScanner(const QTextCursor &cursor,
, _block(cursor.block()) , _block(cursor.block())
, _maxBlockCount(maxBlockCount) , _maxBlockCount(maxBlockCount)
{ {
// FIXME: Why these defaults? _tokenize.setLanguageFeatures(languageFeatures);
LanguageFeatures features;
features.qtMocRunEnabled = true;
features.qtEnabled = true;
features.qtKeywordsEnabled = true;
features.objCEnabled = true;
_tokenize.setLanguageFeatures(features);
_tokenize.setSkipComments(skipComments); _tokenize.setSkipComments(skipComments);
_text = _block.text().left(cursor.position() - cursor.block().position()); _text = _block.text().left(cursor.position() - cursor.block().position());

View File

@@ -43,10 +43,11 @@ class CPLUSPLUS_EXPORT BackwardsScanner
enum { MAX_BLOCK_COUNT = 10 }; enum { MAX_BLOCK_COUNT = 10 };
public: public:
explicit BackwardsScanner(const QTextCursor &cursor, BackwardsScanner(const QTextCursor &cursor,
int maxBlockCount = MAX_BLOCK_COUNT, const LanguageFeatures &languageFeatures,
const QString &suffix = QString(), int maxBlockCount = MAX_BLOCK_COUNT,
bool skipComments = true); const QString &suffix = QString(),
bool skipComments = true);
int startToken() const; int startToken() const;

View File

@@ -40,8 +40,9 @@
using namespace CPlusPlus; using namespace CPlusPlus;
ExpressionUnderCursor::ExpressionUnderCursor() ExpressionUnderCursor::ExpressionUnderCursor(const LanguageFeatures &languageFeatures)
: _jumpedComma(false) : _jumpedComma(false)
, _languageFeatures(languageFeatures)
{ } { }
int ExpressionUnderCursor::startOfExpression(BackwardsScanner &tk, int index) int ExpressionUnderCursor::startOfExpression(BackwardsScanner &tk, int index)
@@ -243,7 +244,7 @@ bool ExpressionUnderCursor::isAccessToken(const Token &tk)
QString ExpressionUnderCursor::operator()(const QTextCursor &cursor) QString ExpressionUnderCursor::operator()(const QTextCursor &cursor)
{ {
BackwardsScanner scanner(cursor); BackwardsScanner scanner(cursor, _languageFeatures);
_jumpedComma = false; _jumpedComma = false;
@@ -257,7 +258,7 @@ QString ExpressionUnderCursor::operator()(const QTextCursor &cursor)
int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor) const int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor) const
{ {
BackwardsScanner scanner(cursor); BackwardsScanner scanner(cursor, _languageFeatures);
int index = scanner.startToken(); int index = scanner.startToken();

View File

@@ -32,6 +32,7 @@
#define CPLUSPLUS_EXPRESSIONUNDERCURSOR_H #define CPLUSPLUS_EXPRESSIONUNDERCURSOR_H
#include <cplusplus/CPlusPlusForwardDeclarations.h> #include <cplusplus/CPlusPlusForwardDeclarations.h>
#include <cplusplus/Token.h>
#include <QList> #include <QList>
@@ -47,7 +48,7 @@ class BackwardsScanner;
class CPLUSPLUS_EXPORT ExpressionUnderCursor class CPLUSPLUS_EXPORT ExpressionUnderCursor
{ {
public: public:
ExpressionUnderCursor(); ExpressionUnderCursor(const LanguageFeatures &languageFeatures);
QString operator()(const QTextCursor &cursor); QString operator()(const QTextCursor &cursor);
int startOfFunctionCall(const QTextCursor &cursor) const; int startOfFunctionCall(const QTextCursor &cursor) const;
@@ -59,6 +60,7 @@ private:
private: private:
bool _jumpedComma; bool _jumpedComma;
LanguageFeatures _languageFeatures;
}; };
} // namespace CPlusPlus } // namespace CPlusPlus

View File

@@ -324,7 +324,7 @@ ClassOrNamespace *LookupContext::globalNamespace() const
} }
ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope, ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
ClassOrNamespace* enclosingTemplateInstantiation, ClassOrNamespace *enclosingBinding,
QSet<const Declaration *> typedefsBeingResolved) const QSet<const Declaration *> typedefsBeingResolved) const
{ {
if (! scope || ! name) { if (! scope || ! name) {
@@ -367,7 +367,7 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
} }
// try to find it in block (rare case but has priority before enclosing scope) // try to find it in block (rare case but has priority before enclosing scope)
// e.g.: void foo() { struct S {}; S s; } // e.g.: void foo() { struct S {}; S s; }
if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingTemplateInstantiation)) { if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingBinding)) {
if (ClassOrNamespace *classOrNamespaceNestedInNestedBlock = b->lookupType(name, block)) if (ClassOrNamespace *classOrNamespaceNestedInNestedBlock = b->lookupType(name, block))
return classOrNamespaceNestedInNestedBlock; return classOrNamespaceNestedInNestedBlock;
} }
@@ -376,13 +376,13 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
if (ClassOrNamespace *found = lookupType(name, scope->enclosingScope())) if (ClassOrNamespace *found = lookupType(name, scope->enclosingScope()))
return found; return found;
} else if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingTemplateInstantiation)) { } else if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingBinding)) {
return b->lookupType(name); return b->lookupType(name);
} else if (Class *scopeAsClass = scope->asClass()) { } else if (Class *scopeAsClass = scope->asClass()) {
if (scopeAsClass->enclosingScope()->isBlock()) { if (scopeAsClass->enclosingScope()->isBlock()) {
if (ClassOrNamespace *b = lookupType(scopeAsClass->name(), if (ClassOrNamespace *b = lookupType(scopeAsClass->name(),
scopeAsClass->enclosingScope(), scopeAsClass->enclosingScope(),
enclosingTemplateInstantiation, enclosingBinding,
typedefsBeingResolved)) { typedefsBeingResolved)) {
return b->lookupType(name); return b->lookupType(name);
} }
@@ -393,9 +393,9 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
} }
ClassOrNamespace *LookupContext::lookupType(Symbol *symbol, ClassOrNamespace *LookupContext::lookupType(Symbol *symbol,
ClassOrNamespace* enclosingTemplateInstantiation) const ClassOrNamespace *enclosingBinding) const
{ {
return bindings()->lookupType(symbol, enclosingTemplateInstantiation); return bindings()->lookupType(symbol, enclosingBinding);
} }
QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
@@ -1521,19 +1521,20 @@ ClassOrNamespace *CreateBindings::globalNamespace() const
return _globalNamespace; return _globalNamespace;
} }
ClassOrNamespace *CreateBindings::lookupType(Symbol *symbol, ClassOrNamespace* enclosingTemplateInstantiation) ClassOrNamespace *CreateBindings::lookupType(Symbol *symbol, ClassOrNamespace *enclosingBinding)
{ {
const QList<const Name *> path = LookupContext::path(symbol); const QList<const Name *> path = LookupContext::path(symbol);
return lookupType(path, enclosingTemplateInstantiation); return lookupType(path, enclosingBinding);
} }
ClassOrNamespace *CreateBindings::lookupType(const QList<const Name *> &path, ClassOrNamespace* enclosingTemplateInstantiation) ClassOrNamespace *CreateBindings::lookupType(const QList<const Name *> &path,
ClassOrNamespace *enclosingBinding)
{ {
if (path.isEmpty()) if (path.isEmpty())
return _globalNamespace; return _globalNamespace;
if (enclosingTemplateInstantiation) { if (enclosingBinding) {
if (ClassOrNamespace *b = enclosingTemplateInstantiation->lookupType(path.last())) if (ClassOrNamespace *b = enclosingBinding->lookupType(path.last()))
return b; return b;
} }

View File

@@ -202,10 +202,9 @@ public:
ClassOrNamespace *globalNamespace() const; ClassOrNamespace *globalNamespace() const;
/// Finds the binding associated to the given symbol. /// Finds the binding associated to the given symbol.
ClassOrNamespace *lookupType(Symbol *symbol, ClassOrNamespace *lookupType(Symbol *symbol, ClassOrNamespace *enclosingBinding = 0);
ClassOrNamespace* enclosingTemplateInstantiation = 0);
ClassOrNamespace *lookupType(const QList<const Name *> &path, ClassOrNamespace *lookupType(const QList<const Name *> &path,
ClassOrNamespace* enclosingTemplateInstantiation = 0); ClassOrNamespace *enclosingBinding = 0);
/// Returns the Control that must be used to create temporary symbols. /// Returns the Control that must be used to create temporary symbols.
/// \internal /// \internal
@@ -310,11 +309,11 @@ public:
QList<LookupItem> lookup(const Name *name, Scope *scope) const; QList<LookupItem> lookup(const Name *name, Scope *scope) const;
ClassOrNamespace *lookupType(const Name *name, Scope *scope, ClassOrNamespace *lookupType(const Name *name, Scope *scope,
ClassOrNamespace* enclosingTemplateInstantiation = 0, ClassOrNamespace *enclosingBinding = 0,
QSet<const Declaration *> typedefsBeingResolved QSet<const Declaration *> typedefsBeingResolved
= QSet<const Declaration *>()) const; = QSet<const Declaration *>()) const;
ClassOrNamespace *lookupType(Symbol *symbol, ClassOrNamespace *lookupType(Symbol *symbol,
ClassOrNamespace* enclosingTemplateInstantiation = 0) const; ClassOrNamespace *enclosingBinding = 0) const;
ClassOrNamespace *lookupParent(Symbol *symbol) const; ClassOrNamespace *lookupParent(Symbol *symbol) const;
/// \internal /// \internal

View File

@@ -154,7 +154,8 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri
if (text.isEmpty() || !shouldInsertMatchingText(la)) if (text.isEmpty() || !shouldInsertMatchingText(la))
return QString(); return QString();
BackwardsScanner tk(tc, MAX_NUM_LINES, textToProcess.left(*skippedChars)); BackwardsScanner tk(tc, LanguageFeatures::defaultFeatures(), MAX_NUM_LINES,
textToProcess.left(*skippedChars));
const int startToken = tk.startToken(); const int startToken = tk.startToken();
int index = startToken; int index = startToken;
@@ -215,7 +216,7 @@ static bool shouldInsertNewline(const QTextCursor &tc)
QString MatchingText::insertParagraphSeparator(const QTextCursor &tc) QString MatchingText::insertParagraphSeparator(const QTextCursor &tc)
{ {
BackwardsScanner tk(tc, MAX_NUM_LINES); BackwardsScanner tk(tc, LanguageFeatures::defaultFeatures(), MAX_NUM_LINES);
int index = tk.startToken(); int index = tk.startToken();
if (tk[index - 1].isNot(T_LBRACE)) if (tk[index - 1].isNot(T_LBRACE))

View File

@@ -612,7 +612,7 @@ bool ResolveExpression::visit(UnaryExpressionAST *ast)
added = true; added = true;
} else if (namedTy != 0) { } else if (namedTy != 0) {
const Name *starOp = control()->operatorNameId(OperatorNameId::StarOp); const Name *starOp = control()->operatorNameId(OperatorNameId::StarOp);
if (ClassOrNamespace *b = _context.lookupType(namedTy->name(), p.scope())) { if (ClassOrNamespace *b = _context.lookupType(namedTy->name(), p.scope(), p.binding())) {
foreach (const LookupItem &r, b->find(starOp)) { foreach (const LookupItem &r, b->find(starOp)) {
Symbol *overload = r.declaration(); Symbol *overload = r.declaration();
if (Function *funTy = overload->type()->asFunctionType()) { if (Function *funTy = overload->type()->asFunctionType()) {
@@ -730,6 +730,7 @@ bool ResolveExpression::visit(SimpleNameAST *ast)
continue; continue;
TypeOfExpression exprTyper; TypeOfExpression exprTyper;
exprTyper.setExpandTemplates(true);
Document::Ptr doc = _context.snapshot().document(QString::fromLocal8Bit(decl->fileName())); Document::Ptr doc = _context.snapshot().document(QString::fromLocal8Bit(decl->fileName()));
exprTyper.init(doc, _context.snapshot(), _context.bindings(), exprTyper.init(doc, _context.snapshot(), _context.bindings(),
QSet<const Declaration* >(_autoDeclarationsBeingResolved) << decl); QSet<const Declaration* >(_autoDeclarationsBeingResolved) << decl);
@@ -754,10 +755,12 @@ bool ResolveExpression::visit(SimpleNameAST *ast)
if (n == 0) { if (n == 0) {
item.setType(newType); item.setType(newType);
item.setScope(typeItems[n].scope()); item.setScope(typeItems[n].scope());
item.setBinding(typeItems[n].binding());
} else { } else {
LookupItem newItem(item); LookupItem newItem(item);
newItem.setType(newType); newItem.setType(newType);
newItem.setScope(typeItems[n].scope()); newItem.setScope(typeItems[n].scope());
newItem.setBinding(typeItems[n].binding());
newCandidates.push_back(newItem); newCandidates.push_back(newItem);
} }
} }
@@ -1015,20 +1018,20 @@ bool ResolveExpression::visit(MemberAccessAST *ast)
} }
ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &originalTy, Scope *scope, ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &originalTy, Scope *scope,
ClassOrNamespace* enclosingTemplateInstantiation) const ClassOrNamespace *enclosingBinding) const
{ {
FullySpecifiedType ty = originalTy.simplified(); FullySpecifiedType ty = originalTy.simplified();
ClassOrNamespace *binding = 0; ClassOrNamespace *binding = 0;
if (Class *klass = ty->asClassType()) { if (Class *klass = ty->asClassType()) {
if (scope->isBlock()) if (scope->isBlock())
binding = _context.lookupType(klass->name(), scope, enclosingTemplateInstantiation); binding = _context.lookupType(klass->name(), scope, enclosingBinding);
if (!binding) if (!binding)
binding = _context.lookupType(klass, enclosingTemplateInstantiation); binding = _context.lookupType(klass, enclosingBinding);
} }
else if (NamedType *namedTy = ty->asNamedType()) else if (NamedType *namedTy = ty->asNamedType())
binding = _context.lookupType(namedTy->name(), scope, enclosingTemplateInstantiation); binding = _context.lookupType(namedTy->name(), scope, enclosingBinding);
else if (Function *funTy = ty->asFunctionType()) else if (Function *funTy = ty->asFunctionType())
return findClass(funTy->returnType(), scope); return findClass(funTy->returnType(), scope);
@@ -1078,8 +1081,9 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
ClassOrNamespace *binding ClassOrNamespace *binding
= findClassForTemplateParameterInExpressionScope(r.binding(), = findClassForTemplateParameterInExpressionScope(r.binding(),
ty); ty);
if (! binding) if (! binding)
binding = findClass(ty, scope); binding = findClass(ty, scope, r.binding());
if (binding){ if (binding){
// lookup for overloads of operator-> // lookup for overloads of operator->
@@ -1145,13 +1149,13 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
return binding; return binding;
} }
ClassOrNamespace *enclosingTemplateInstantiation = 0; ClassOrNamespace *enclosingBinding = 0;
if (ClassOrNamespace *binding = r.binding()) { if (ClassOrNamespace *binding = r.binding()) {
if (binding->instantiationOrigin()) if (binding->instantiationOrigin())
enclosingTemplateInstantiation = binding; enclosingBinding = binding;
} }
if (ClassOrNamespace *binding = findClass(ty, scope, enclosingTemplateInstantiation)) if (ClassOrNamespace *binding = findClass(ty, scope, enclosingBinding))
return binding; return binding;
} }
} }

View File

@@ -61,7 +61,7 @@ public:
protected: protected:
ClassOrNamespace *findClass(const FullySpecifiedType &ty, Scope *scope, ClassOrNamespace *findClass(const FullySpecifiedType &ty, Scope *scope,
ClassOrNamespace* enclosingTemplateInstantiation = 0) const; ClassOrNamespace *enclosingBinding = 0) const;
QList<LookupItem> expression(ExpressionAST *ast); QList<LookupItem> expression(ExpressionAST *ast);

View File

@@ -129,17 +129,10 @@ int SimpleLexer::tokenAt(const Tokens &tokens, unsigned utf16charsOffset)
Token SimpleLexer::tokenAt(const QString &text, Token SimpleLexer::tokenAt(const QString &text,
unsigned utf16charsOffset, unsigned utf16charsOffset,
int state, int state,
bool qtMocRunEnabled) const LanguageFeatures &languageFeatures)
{ {
// FIXME: Check default values.
LanguageFeatures features;
features.qtMocRunEnabled = qtMocRunEnabled;
features.qtEnabled = qtMocRunEnabled;
features.qtKeywordsEnabled = qtMocRunEnabled;
features.objCEnabled = qtMocRunEnabled;
features.cxx11Enabled = qtMocRunEnabled;
SimpleLexer tokenize; SimpleLexer tokenize;
tokenize.setLanguageFeatures(features); tokenize.setLanguageFeatures(languageFeatures);
const QVector<Token> tokens = tokenize(text, state); const QVector<Token> tokens = tokenize(text, state);
const int tokenIdx = tokenAt(tokens, utf16charsOffset); const int tokenIdx = tokenAt(tokens, utf16charsOffset);
return (tokenIdx == -1) ? Token() : tokens.at(tokenIdx); return (tokenIdx == -1) ? Token() : tokens.at(tokenIdx);

View File

@@ -68,7 +68,7 @@ public:
static Token tokenAt(const QString &text, static Token tokenAt(const QString &text,
unsigned utf16charsOffset, unsigned utf16charsOffset,
int state, int state,
bool qtMocRunEnabled = false); const LanguageFeatures &languageFeatures);
static int tokenBefore(const Tokens &tokens, unsigned utf16charsOffset); static int tokenBefore(const Tokens &tokens, unsigned utf16charsOffset);

View File

@@ -103,8 +103,8 @@ TimelineRenderPass::State *TimelineSelectionRenderPass::update(
// left and width the error on the left border is inherited by the right border. Like this // left and width the error on the left border is inherited by the right border. Like this
// they're independent. // they're independent.
QRectF outer(QPointF(qFloor(left * parentState->scale()), top), QRectF outer(QPointF(left * parentState->scale(), top),
QPointF(qCeil(right * parentState->scale()), top + height)); QPointF(right * parentState->scale(), top + height));
float scaleConversion = parentState->scale() / spacing; float scaleConversion = parentState->scale() / spacing;
float missing = 3.0 - outer.width() / scaleConversion; float missing = 3.0 - outer.width() / scaleConversion;

View File

@@ -548,9 +548,9 @@ QFileInfo FileName::toFileInfo() const
} }
/// \returns a QString for passing on to QString based APIs /// \returns a QString for passing on to QString based APIs
QString FileName::toString() const const QString &FileName::toString() const
{ {
return QString(*this); return *this;
} }
/// \returns a QString to display to the user /// \returns a QString to display to the user

View File

@@ -71,7 +71,7 @@ public:
static FileName fromLatin1(const QByteArray &filename); static FileName fromLatin1(const QByteArray &filename);
static FileName fromUserInput(const QString &filename); static FileName fromUserInput(const QString &filename);
static FileName fromUtf8(const char *filename, int filenameSize = -1); static FileName fromUtf8(const char *filename, int filenameSize = -1);
QString toString() const; const QString &toString() const;
QString toUserOutput() const; QString toUserOutput() const;
QString fileName(int pathComponents = 0) const; QString fileName(int pathComponents = 0) const;
bool exists() const; bool exists() const;

View File

@@ -175,12 +175,16 @@ MimeType MimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileName
// Extension is unknown, or matches multiple mimetypes. // Extension is unknown, or matches multiple mimetypes.
// Pass 2) Match on content, if we can read the data // Pass 2) Match on content, if we can read the data
const bool openedByUs = !device->isOpen() && device->open(QIODevice::ReadOnly);
if (device->isOpen()) { if (device->isOpen()) {
// Read 16K in one go (QIODEVICE_BUFFERSIZE in qiodevice_p.h). // Read 16K in one go (QIODEVICE_BUFFERSIZE in qiodevice_p.h).
// This is much faster than seeking back and forth into QIODevice. // This is much faster than seeking back and forth into QIODevice.
const QByteArray data = device->peek(16384); const QByteArray data = device->peek(16384);
if (openedByUs)
device->close();
int magicAccuracy = 0; int magicAccuracy = 0;
MimeType candidateByData(findByData(data, &magicAccuracy)); MimeType candidateByData(findByData(data, &magicAccuracy));
@@ -319,8 +323,11 @@ QString MimeDatabase::allFiltersString(QString *allFilesFilter)
{ {
MimeDatabase mdb; MimeDatabase mdb;
QSet<QString> uniqueFilters; QSet<QString> uniqueFilters;
foreach (const MimeType &mt, mdb.allMimeTypes()) foreach (const MimeType &mt, mdb.allMimeTypes()) {
uniqueFilters.insert(mt.filterString()); const QString &filterString = mt.filterString();
if (!filterString.isEmpty())
uniqueFilters.insert(mt.filterString());
}
QStringList filters; QStringList filters;
foreach (const QString &filter, uniqueFilters) foreach (const QString &filter, uniqueFilters)
filters.append(filter); filters.append(filter);
@@ -345,79 +352,6 @@ QStringList MimeDatabase::allGlobPatterns()
return patterns; return patterns;
} }
static MimeType mimeForName(const QList<MimeType> &types, const QString &name)
{
foreach (const MimeType &mt, types)
if (mt.matchesName(name))
return mt;
return MimeType();
}
MimeType MimeDatabase::bestMatch(const QString &fileName, const QList<MimeType> &types)
{
// Copied together from mimeTypeForFile(QFileInfo) code path ...
// It would be better to be able to work on a list of mime types directly
// Check for directory. We just ignore the code path for special unix nodes.
if (fileName.endsWith(QLatin1Char('/')))
return mimeForName(types, QLatin1String("inode/directory"));
auto d = MimeDatabasePrivate::instance();
QMutexLocker locker(&d->mutex);
QStringList candidatesByName = d->provider()->bestMatchByFileName(QFileInfo(fileName).fileName(),
types);
if (candidatesByName.count() == 1) {
MimeType mt = mimeForName(types, candidatesByName.first());
if (mt.isValid())
return mt;
candidatesByName.clear();
}
// Extension is unknown, or matches multiple mimetypes.
// Pass 2) Match on content, if we can read the data
QFile file(QFileInfo(fileName).absoluteFilePath());
file.open(QIODevice::ReadOnly);
if (file.isOpen()) {
// Read 16K in one go (QIODEVICE_BUFFERSIZE in qiodevice_p.h).
// This is much faster than seeking back and forth into QIODevice.
const QByteArray data = file.peek(16384);
int magicAccuracy = 0;
MimeType candidateByData;
if (data.isEmpty()) {
magicAccuracy = 100;
candidateByData = mimeForName(types, QLatin1String("application/x-zerosize"));
} else {
candidateByData = d->provider()->bestMatchByMagic(data, types, &magicAccuracy);
if (!candidateByData.isValid()) {
if (isTextFile(data)) {
magicAccuracy = 5;
candidateByData = mimeForName(types, QLatin1String("text/plain"));
}
}
}
// Disambiguate conflicting extensions (if magic matching found something)
if (candidateByData.isValid() && magicAccuracy > 0) {
// "for glob_match in glob_matches:"
// "if glob_match is subclass or equal to sniffed_type, use glob_match"
const QString sniffedMime = candidateByData.name();
foreach (const QString &m, candidatesByName) {
if (d->inherits(m, sniffedMime)) {
// We have magic + pattern pointing to this, so it's a pretty good match
return mimeForName(types, m);
}
}
return candidateByData;
}
}
if (candidatesByName.count() > 1) {
candidatesByName.sort();
return mimeForName(types, candidatesByName.first());
}
return MimeType();
}
/*! /*!
\fn MimeType MimeDatabase::mimeTypeForName(const QString &nameOrAlias) const; \fn MimeType MimeDatabase::mimeTypeForName(const QString &nameOrAlias) const;
Returns a MIME type for \a nameOrAlias or an invalid one if none found. Returns a MIME type for \a nameOrAlias or an invalid one if none found.
@@ -485,7 +419,6 @@ MimeType MimeDatabase::mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode
int priority = 0; int priority = 0;
switch (mode) { switch (mode) {
case MatchDefault: case MatchDefault:
file.open(QIODevice::ReadOnly); // isOpen() will be tested by method below
return d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority); return d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority);
case MatchExtension: case MatchExtension:
locker.unlock(); locker.unlock();
@@ -655,10 +588,7 @@ MimeType MimeDatabase::mimeTypeForUrl(const QUrl &url) const
MimeType MimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device) const MimeType MimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device) const
{ {
int accuracy = 0; int accuracy = 0;
const bool openedByUs = !device->isOpen() && device->open(QIODevice::ReadOnly);
const MimeType result = d->mimeTypeForFileNameAndData(fileName, device, &accuracy); const MimeType result = d->mimeTypeForFileNameAndData(fileName, device, &accuracy);
if (openedByUs)
device->close();
return result; return result;
} }

View File

@@ -87,7 +87,6 @@ public:
static void addMimeTypes(const QString &fileName); static void addMimeTypes(const QString &fileName);
static QString allFiltersString(QString *allFilesFilter = 0); static QString allFiltersString(QString *allFilesFilter = 0);
static QStringList allGlobPatterns(); static QStringList allGlobPatterns();
static MimeType bestMatch(const QString &fileName, const QList<MimeType> &types);
static QMap<int, QList<Internal::MimeMagicRule> > magicRulesForMimeType(const MimeType &mimeType); // priority -> rules static QMap<int, QList<Internal::MimeMagicRule> > magicRulesForMimeType(const MimeType &mimeType); // priority -> rules
static void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns); static void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns);
static void setMagicRulesForMimeType(const MimeType &mimeType, static void setMagicRulesForMimeType(const MimeType &mimeType,

View File

@@ -719,38 +719,6 @@ QStringList MimeXMLProvider::findByFileName(const QString &fileName, QString *fo
return matchingMimeTypes; return matchingMimeTypes;
} }
QStringList MimeXMLProvider::bestMatchByFileName(const QString &fileName, const QList<MimeType> &types)
{
ensureLoaded();
// this is slow :(
// this would be much better if MimeType had references to their globs & magics
MimeAllGlobPatterns globs;
// fast patterns are fast (hash lookup), no need to reduce that set
globs.m_fastPatterns = m_mimeTypeGlobs.m_fastPatterns;
// fill highWeight and lowWeight glob lists
QSet<QString> names;
foreach (const MimeType &mt, types)
names.insert(mt.name());
foreach (const MimeGlobPattern &pattern, m_mimeTypeGlobs.m_highWeightGlobs) {
if (names.contains(pattern.mimeType()))
globs.m_highWeightGlobs.append(pattern);
}
foreach (const MimeGlobPattern &pattern, m_mimeTypeGlobs.m_lowWeightGlobs) {
if (names.contains(pattern.mimeType()))
globs.m_lowWeightGlobs.append(pattern);
}
QString foundSuffix;
const QStringList matchingMimeTypes = globs.matchingGlobs(fileName, &foundSuffix);
// result can still contain types that are not in our list, because of the fast patterns
QStringList result;
foreach (const QString &match, matchingMimeTypes) {
if (names.contains(match))
result.append(match);
}
return result;
}
MimeType MimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr) MimeType MimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr)
{ {
ensureLoaded(); ensureLoaded();
@@ -769,30 +737,6 @@ MimeType MimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr)
return mimeTypeForName(candidate); return mimeTypeForName(candidate);
} }
MimeType MimeXMLProvider::bestMatchByMagic(const QByteArray &data, const QList<MimeType> &types, int *accuracyPtr)
{
ensureLoaded();
QSet<QString> names;
foreach (const MimeType &mt, types)
names.insert(mt.name());
QString candidate;
foreach (const MimeMagicRuleMatcher &matcher, m_magicMatchers) {
if (!names.contains(matcher.mimetype()))
continue;
if (matcher.matches(data)) {
const int priority = matcher.priority();
if (priority > *accuracyPtr) {
*accuracyPtr = priority;
candidate = matcher.mimetype();
}
}
}
return mimeTypeForName(candidate);
}
QMap<int, QList<MimeMagicRule> > MimeXMLProvider::magicRulesForMimeType(const MimeType &mimeType) QMap<int, QList<MimeMagicRule> > MimeXMLProvider::magicRulesForMimeType(const MimeType &mimeType)
{ {
QMap<int, QList<MimeMagicRule> > result; QMap<int, QList<MimeMagicRule> > result;

View File

@@ -75,8 +75,6 @@ public:
virtual void loadGenericIcon(MimeTypePrivate &) {} virtual void loadGenericIcon(MimeTypePrivate &) {}
// Qt Creator additions // Qt Creator additions
virtual QStringList bestMatchByFileName(const QString &fileName, const QList<MimeType> &types) = 0;
virtual MimeType bestMatchByMagic(const QByteArray &data, const QList<MimeType> &types, int *accuracyPtr) = 0;
virtual QMap<int, QList<MimeMagicRule> > magicRulesForMimeType(const MimeType &mimeType) = 0; virtual QMap<int, QList<MimeMagicRule> > magicRulesForMimeType(const MimeType &mimeType) = 0;
virtual void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns) = 0; virtual void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns) = 0;
virtual void setMagicRulesForMimeType(const MimeType &mimeType, const QMap<int, QList<MimeMagicRule> > &rules) = 0; virtual void setMagicRulesForMimeType(const MimeType &mimeType, const QMap<int, QList<MimeMagicRule> > &rules) = 0;
@@ -158,8 +156,6 @@ public:
// Qt Creator additions // Qt Creator additions
void addFile(const QString &filePath); void addFile(const QString &filePath);
QStringList bestMatchByFileName(const QString &fileName, const QList<MimeType> &types);
MimeType bestMatchByMagic(const QByteArray &data, const QList<MimeType> &types, int *accuracyPtr);
QMap<int, QList<MimeMagicRule> > magicRulesForMimeType(const MimeType &mimeType); QMap<int, QList<MimeMagicRule> > magicRulesForMimeType(const MimeType &mimeType);
void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns); void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns);
void setMagicRulesForMimeType(const MimeType &mimeType, const QMap<int, QList<MimeMagicRule> > &rules); void setMagicRulesForMimeType(const MimeType &mimeType, const QMap<int, QList<MimeMagicRule> > &rules);

View File

@@ -432,7 +432,9 @@ QString MimeType::filterString() const
bool MimeType::matchesName(const QString &nameOrAlias) const bool MimeType::matchesName(const QString &nameOrAlias) const
{ {
return d->name == nameOrAlias || aliases().contains(nameOrAlias); if (d->name == nameOrAlias)
return true;
return MimeDatabasePrivate::instance()->provider()->resolveAlias(nameOrAlias) == d->name;
} }
void MimeType::setPreferredSuffix(const QString &suffix) void MimeType::setPreferredSuffix(const QString &suffix)

View File

@@ -20,3 +20,4 @@ SOURCES += \
$$PWD/mimeglobpattern.cpp \ $$PWD/mimeglobpattern.cpp \
$$PWD/mimeprovider.cpp $$PWD/mimeprovider.cpp
OTHER_FILES += $$[QT_HOST_DATA/src]/src/corelib/mimetypes/mime/packages/freedesktop.org.xml

View File

@@ -33,86 +33,101 @@
#include "theme/theme.h" #include "theme/theme.h"
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QTextCursor>
using namespace Utils; namespace Utils {
namespace Internal {
class OutputFormatterPrivate
{
public:
OutputFormatterPrivate()
: plainTextEdit(0), overwriteOutput(false)
{}
QPlainTextEdit *plainTextEdit;
QTextCharFormat formats[NumberOfFormats];
QFont font;
QTextCursor cursor;
AnsiEscapeCodeHandler escapeCodeHandler;
bool overwriteOutput;
};
} // namespace Internal
OutputFormatter::OutputFormatter() OutputFormatter::OutputFormatter()
: QObject() : d(new Internal::OutputFormatterPrivate)
, m_plainTextEdit(0)
, m_formats(0)
, m_escapeCodeHandler(new AnsiEscapeCodeHandler)
, m_overwriteOutput(false)
{ {
} }
OutputFormatter::~OutputFormatter() OutputFormatter::~OutputFormatter()
{ {
delete[] m_formats; delete d;
delete m_escapeCodeHandler;
} }
QPlainTextEdit *OutputFormatter::plainTextEdit() const QPlainTextEdit *OutputFormatter::plainTextEdit() const
{ {
return m_plainTextEdit; return d->plainTextEdit;
} }
void OutputFormatter::setPlainTextEdit(QPlainTextEdit *plainText) void OutputFormatter::setPlainTextEdit(QPlainTextEdit *plainText)
{ {
m_plainTextEdit = plainText; d->plainTextEdit = plainText;
d->cursor = plainText ? plainText->textCursor() : QTextCursor();
initFormats(); initFormats();
} }
void OutputFormatter::appendMessage(const QString &text, OutputFormat format) void OutputFormatter::appendMessage(const QString &text, OutputFormat format)
{ {
appendMessage(text, m_formats[format]); appendMessage(text, d->formats[format]);
} }
void OutputFormatter::appendMessage(const QString &text, const QTextCharFormat &format) void OutputFormatter::appendMessage(const QString &text, const QTextCharFormat &format)
{ {
QTextCursor cursor(m_plainTextEdit->document()); if (!d->cursor.atEnd())
cursor.movePosition(QTextCursor::End); d->cursor.movePosition(QTextCursor::End);
foreach (const FormattedText &output, parseAnsi(text, format)) { foreach (const FormattedText &output, parseAnsi(text, format)) {
int startPos = 0; int startPos = 0;
int crPos = -1; int crPos = -1;
while ((crPos = output.text.indexOf(QLatin1Char('\r'), startPos)) >= 0) { while ((crPos = output.text.indexOf(QLatin1Char('\r'), startPos)) >= 0) {
append(cursor, output.text.mid(startPos, crPos - startPos), output.format); append(d->cursor, output.text.mid(startPos, crPos - startPos), output.format);
startPos = crPos + 1; startPos = crPos + 1;
m_overwriteOutput = true; d->overwriteOutput = true;
} }
if (startPos < output.text.count()) if (startPos < output.text.count())
append(cursor, output.text.mid(startPos), output.format); append(d->cursor, output.text.mid(startPos), output.format);
} }
} }
QTextCharFormat OutputFormatter::charFormat(OutputFormat format) const QTextCharFormat OutputFormatter::charFormat(OutputFormat format) const
{ {
return m_formats[format]; return d->formats[format];
} }
QList<FormattedText> OutputFormatter::parseAnsi(const QString &text, const QTextCharFormat &format) QList<FormattedText> OutputFormatter::parseAnsi(const QString &text, const QTextCharFormat &format)
{ {
return m_escapeCodeHandler->parseText(FormattedText(text, format)); return d->escapeCodeHandler.parseText(FormattedText(text, format));
} }
void OutputFormatter::append(QTextCursor &cursor, const QString &text, void OutputFormatter::append(QTextCursor &cursor, const QString &text,
const QTextCharFormat &format) const QTextCharFormat &format)
{ {
if (m_overwriteOutput) { if (d->overwriteOutput) {
cursor.clearSelection(); cursor.clearSelection();
cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
m_overwriteOutput = false; d->overwriteOutput = false;
} }
cursor.insertText(text, format); cursor.insertText(text, format);
} }
void OutputFormatter::clearLastLine() void OutputFormatter::clearLastLine()
{ {
QTextCursor cursor(m_plainTextEdit->document()); if (!d->cursor.atEnd())
cursor.movePosition(QTextCursor::End); d->cursor.movePosition(QTextCursor::End);
cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); d->cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
cursor.removeSelectedText(); d->cursor.removeSelectedText();
} }
void OutputFormatter::initFormats() void OutputFormatter::initFormats()
@@ -120,33 +135,31 @@ void OutputFormatter::initFormats()
if (!plainTextEdit()) if (!plainTextEdit())
return; return;
QFont boldFont = m_font; QFont boldFont = d->font;
boldFont.setBold(true); boldFont.setBold(true);
m_formats = new QTextCharFormat[NumberOfFormats];
Theme *theme = creatorTheme(); Theme *theme = creatorTheme();
// NormalMessageFormat // NormalMessageFormat
m_formats[NormalMessageFormat].setFont(boldFont); d->formats[NormalMessageFormat].setFont(boldFont);
m_formats[NormalMessageFormat].setForeground(theme->color(Theme::OutputFormatter_NormalMessageTextColor)); d->formats[NormalMessageFormat].setForeground(theme->color(Theme::OutputFormatter_NormalMessageTextColor));
// ErrorMessageFormat // ErrorMessageFormat
m_formats[ErrorMessageFormat].setFont(boldFont); d->formats[ErrorMessageFormat].setFont(boldFont);
m_formats[ErrorMessageFormat].setForeground(theme->color(Theme::OutputFormatter_ErrorMessageTextColor)); d->formats[ErrorMessageFormat].setForeground(theme->color(Theme::OutputFormatter_ErrorMessageTextColor));
// StdOutFormat // StdOutFormat
m_formats[StdOutFormat].setFont(m_font); d->formats[StdOutFormat].setFont(d->font);
m_formats[StdOutFormat].setForeground(theme->color(Theme::OutputFormatter_StdOutTextColor)); d->formats[StdOutFormat].setForeground(theme->color(Theme::OutputFormatter_StdOutTextColor));
m_formats[StdOutFormatSameLine] = m_formats[StdOutFormat]; d->formats[StdOutFormatSameLine] = d->formats[StdOutFormat];
// StdErrFormat // StdErrFormat
m_formats[StdErrFormat].setFont(m_font); d->formats[StdErrFormat].setFont(d->font);
m_formats[StdErrFormat].setForeground(theme->color(Theme::OutputFormatter_StdErrTextColor)); d->formats[StdErrFormat].setForeground(theme->color(Theme::OutputFormatter_StdErrTextColor));
m_formats[StdErrFormatSameLine] = m_formats[StdErrFormat]; d->formats[StdErrFormatSameLine] = d->formats[StdErrFormat];
m_formats[DebugFormat].setFont(m_font); d->formats[DebugFormat].setFont(d->font);
m_formats[DebugFormat].setForeground(theme->color(Theme::OutputFormatter_DebugTextColor)); d->formats[DebugFormat].setForeground(theme->color(Theme::OutputFormatter_DebugTextColor));
} }
void OutputFormatter::handleLink(const QString &href) void OutputFormatter::handleLink(const QString &href)
@@ -156,16 +169,18 @@ void OutputFormatter::handleLink(const QString &href)
QFont OutputFormatter::font() const QFont OutputFormatter::font() const
{ {
return m_font; return d->font;
} }
void OutputFormatter::setFont(const QFont &font) void OutputFormatter::setFont(const QFont &font)
{ {
m_font = font; d->font = font;
initFormats(); initFormats();
} }
void OutputFormatter::flush() void OutputFormatter::flush()
{ {
m_escapeCodeHandler->endFormatScope(); d->escapeCodeHandler.endFormatScope();
} }
} // namespace Utils

View File

@@ -38,7 +38,6 @@
#include <QFont> #include <QFont>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QColor;
class QPlainTextEdit; class QPlainTextEdit;
class QTextCharFormat; class QTextCharFormat;
class QTextCursor; class QTextCursor;
@@ -46,9 +45,10 @@ QT_END_NAMESPACE
namespace Utils { namespace Utils {
class AnsiEscapeCodeHandler;
class FormattedText; class FormattedText;
namespace Internal { class OutputFormatterPrivate; }
class QTCREATOR_UTILS_EXPORT OutputFormatter : public QObject class QTCREATOR_UTILS_EXPORT OutputFormatter : public QObject
{ {
Q_OBJECT Q_OBJECT
@@ -58,7 +58,7 @@ public:
virtual ~OutputFormatter(); virtual ~OutputFormatter();
QPlainTextEdit *plainTextEdit() const; QPlainTextEdit *plainTextEdit() const;
void setPlainTextEdit(QPlainTextEdit *plainText); virtual void setPlainTextEdit(QPlainTextEdit *plainText);
QFont font() const; QFont font() const;
void setFont(const QFont &font); void setFont(const QFont &font);
@@ -76,11 +76,7 @@ protected:
void append(QTextCursor &cursor, const QString &text, const QTextCharFormat &format); void append(QTextCursor &cursor, const QString &text, const QTextCharFormat &format);
private: private:
QPlainTextEdit *m_plainTextEdit; Internal::OutputFormatterPrivate *d;
QTextCharFormat *m_formats;
QFont m_font;
AnsiEscapeCodeHandler *m_escapeCodeHandler;
bool m_overwriteOutput;
}; };
} // namespace Utils } // namespace Utils

View File

@@ -36,6 +36,7 @@
#include <QApplication> #include <QApplication>
#include <QFileInfo> #include <QFileInfo>
#include <QMetaEnum> #include <QMetaEnum>
#include <QPalette>
#include <QSettings> #include <QSettings>
namespace Utils { namespace Utils {

View File

@@ -33,11 +33,11 @@
#include "../utils_global.h" #include "../utils_global.h"
#include <QFlags> #include <QBrush> // QGradientStops
#include <QPalette> #include <QObject>
#include <QStyle>
QT_FORWARD_DECLARE_CLASS(QSettings) QT_FORWARD_DECLARE_CLASS(QSettings)
QT_FORWARD_DECLARE_CLASS(QPalette)
namespace Utils { namespace Utils {

View File

@@ -37,7 +37,6 @@
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
#include <QRect> #include <QRect>
#include <QFont>
/* /*
* In its current form QToolTip is not extensible. So this is an attempt to provide a more * In its current form QToolTip is not extensible. So this is an attempt to provide a more

View File

@@ -52,6 +52,7 @@
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <utils/algorithm.h>
#include <utils/fancymainwindow.h> #include <utils/fancymainwindow.h>
#include <utils/styledbar.h> #include <utils/styledbar.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -93,8 +94,6 @@ const char INITIAL_DOCK_AREA[] = "initial_dock_area";
class AnalyzerMode : public IMode class AnalyzerMode : public IMode
{ {
Q_OBJECT
public: public:
AnalyzerMode(QObject *parent = 0) AnalyzerMode(QObject *parent = 0)
: IMode(parent) : IMode(parent)
@@ -123,8 +122,6 @@ public:
class AnalyzerManagerPrivate : public QObject class AnalyzerManagerPrivate : public QObject
{ {
Q_OBJECT
public: public:
typedef QHash<QString, QVariant> FancyMainWindowSettings; typedef QHash<QString, QVariant> FancyMainWindowSettings;
@@ -154,7 +151,7 @@ public:
void saveToolSettings(Id toolId); void saveToolSettings(Id toolId);
void loadToolSettings(Id toolId); void loadToolSettings(Id toolId);
void startTool(); void startTool();
void selectToolboxAction(int); void selectToolboxAction(const QString &item);
void modeChanged(IMode *mode); void modeChanged(IMode *mode);
void resetLayout(); void resetLayout();
void updateRunActions(); void updateRunActions();
@@ -180,6 +177,9 @@ public:
// list of dock widgets to prevent memory leak // list of dock widgets to prevent memory leak
typedef QPointer<QDockWidget> DockPtr; typedef QPointer<QDockWidget> DockPtr;
QList<DockPtr> m_dockWidgets; QList<DockPtr> m_dockWidgets;
private:
void rebuildToolBox();
}; };
AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq): AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq):
@@ -196,7 +196,7 @@ AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq):
m_statusLabel(new StatusLabel) m_statusLabel(new StatusLabel)
{ {
m_toolBox->setObjectName(QLatin1String("AnalyzerManagerToolBox")); m_toolBox->setObjectName(QLatin1String("AnalyzerManagerToolBox"));
connect(m_toolBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), connect(m_toolBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated),
this, &AnalyzerManagerPrivate::selectToolboxAction); this, &AnalyzerManagerPrivate::selectToolboxAction);
setupActions(); setupActions();
@@ -217,7 +217,6 @@ AnalyzerManagerPrivate::~AnalyzerManagerPrivate()
void AnalyzerManagerPrivate::setupActions() void AnalyzerManagerPrivate::setupActions()
{ {
const Context globalcontext(C_GLOBAL);
Command *command = 0; Command *command = 0;
// Menus // Menus
@@ -236,18 +235,18 @@ void AnalyzerManagerPrivate::setupActions()
m_startAction = new QAction(tr("Start"), m_menu); m_startAction = new QAction(tr("Start"), m_menu);
m_startAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_START_ICON))); m_startAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_START_ICON)));
ActionManager::registerAction(m_startAction, "Analyzer.Start", globalcontext); ActionManager::registerAction(m_startAction, "Analyzer.Start");
connect(m_startAction, &QAction::triggered, this, &AnalyzerManagerPrivate::startTool); connect(m_startAction, &QAction::triggered, this, &AnalyzerManagerPrivate::startTool);
m_stopAction = new QAction(tr("Stop"), m_menu); m_stopAction = new QAction(tr("Stop"), m_menu);
m_stopAction->setEnabled(false); m_stopAction->setEnabled(false);
m_stopAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_STOP_ICON))); m_stopAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_STOP_ICON)));
command = ActionManager::registerAction(m_stopAction, "Analyzer.Stop", globalcontext); command = ActionManager::registerAction(m_stopAction, "Analyzer.Stop");
m_menu->addAction(command, G_ANALYZER_CONTROL); m_menu->addAction(command, G_ANALYZER_CONTROL);
m_menu->addSeparator(globalcontext, G_ANALYZER_TOOLS); m_menu->addSeparator(G_ANALYZER_TOOLS);
m_menu->addSeparator(globalcontext, G_ANALYZER_REMOTE_TOOLS); m_menu->addSeparator(G_ANALYZER_REMOTE_TOOLS);
m_menu->addSeparator(globalcontext, G_ANALYZER_OPTIONS); m_menu->addSeparator(G_ANALYZER_OPTIONS);
} }
void AnalyzerManagerPrivate::delayedInit() void AnalyzerManagerPrivate::delayedInit()
@@ -378,12 +377,10 @@ void AnalyzerManagerPrivate::activateDock(Qt::DockWidgetArea area, QDockWidget *
dockWidget->setParent(m_mainWindow); dockWidget->setParent(m_mainWindow);
m_mainWindow->addDockWidget(area, dockWidget); m_mainWindow->addDockWidget(area, dockWidget);
Context globalContext(C_GLOBAL);
QAction *toggleViewAction = dockWidget->toggleViewAction(); QAction *toggleViewAction = dockWidget->toggleViewAction();
toggleViewAction->setText(dockWidget->windowTitle()); toggleViewAction->setText(dockWidget->windowTitle());
Command *cmd = ActionManager::registerAction(toggleViewAction, Command *cmd = ActionManager::registerAction(toggleViewAction,
Id("Analyzer.").withSuffix(dockWidget->objectName()), globalContext); Id("Analyzer.").withSuffix(dockWidget->objectName()));
cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_Hide);
ActionContainer *viewsMenu = ActionManager::actionContainer(Id(M_WINDOW_VIEWS)); ActionContainer *viewsMenu = ActionManager::actionContainer(Id(M_WINDOW_VIEWS));
@@ -456,18 +453,21 @@ void AnalyzerManagerPrivate::selectSavedTool()
selectAction(m_actions.first()); selectAction(m_actions.first());
} }
void AnalyzerManagerPrivate::selectToolboxAction(int index) void AnalyzerManagerPrivate::selectToolboxAction(const QString &item)
{ {
selectAction(m_actions[index]); selectAction(Utils::findOrDefault(m_actions, [item](const AnalyzerAction *action) {
return action->text() == item;
}));
} }
void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action) void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
{ {
QTC_ASSERT(action, return);
if (m_currentAction == action) if (m_currentAction == action)
return; return;
const int actionIndex = m_actions.indexOf(action); const int toolboxIndex = m_toolBox->findText(action->text());
QTC_ASSERT(actionIndex >= 0, return); QTC_ASSERT(toolboxIndex >= 0, return);
// Clean up old tool. // Clean up old tool.
if (m_currentAction) { if (m_currentAction) {
@@ -495,34 +495,49 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
QTC_CHECK(m_controlsWidgetFromTool.contains(toolId)); QTC_CHECK(m_controlsWidgetFromTool.contains(toolId));
m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(toolId)); m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(toolId));
m_toolBox->setCurrentIndex(actionIndex); m_toolBox->setCurrentIndex(toolboxIndex);
updateRunActions(); updateRunActions();
} }
void AnalyzerManagerPrivate::rebuildToolBox()
{
const bool blocked = m_toolBox->blockSignals(true); // Do not make current.
QStringList integratedTools;
QStringList externalTools;
foreach (AnalyzerAction * const action, m_actions) {
if (action->menuGroup() == Constants::G_ANALYZER_TOOLS)
integratedTools << action->text();
else
externalTools << action->text();
}
m_toolBox->clear();
m_toolBox->addItems(integratedTools);
m_toolBox->addItems(externalTools);
if (!integratedTools.isEmpty() && !externalTools.isEmpty())
m_toolBox->insertSeparator(integratedTools.count());
m_toolBox->blockSignals(blocked);
m_toolBox->setEnabled(true);
}
void AnalyzerManagerPrivate::addAction(AnalyzerAction *action) void AnalyzerManagerPrivate::addAction(AnalyzerAction *action)
{ {
delayedInit(); // Make sure that there is a valid IMode instance. delayedInit(); // Make sure that there is a valid IMode instance.
const bool blocked = m_toolBox->blockSignals(true); // Do not make current.
Id menuGroup = action->menuGroup(); Id menuGroup = action->menuGroup();
if (menuGroup.isValid()) { if (menuGroup.isValid()) {
Command *command = ActionManager::registerAction(action, action->actionId(), Context(C_GLOBAL)); Command *command = ActionManager::registerAction(action, action->actionId());
m_menu->addAction(command, menuGroup); m_menu->addAction(command, menuGroup);
} }
m_actions.append(action); m_actions.append(action);
m_toolBox->addItem(action->text()); rebuildToolBox();
m_toolBox->blockSignals(blocked);
connect(action, &QAction::triggered, this, [this, action] { connect(action, &QAction::triggered, this, [this, action] {
AnalyzerManager::showMode(); AnalyzerManager::showMode();
selectAction(action); selectAction(action);
startTool(); startTool();
}); });
m_toolBox->setEnabled(true);
} }
void AnalyzerManagerPrivate::handleToolStarted() void AnalyzerManagerPrivate::handleToolStarted()
@@ -698,5 +713,3 @@ AnalyzerRunControl *AnalyzerManager::createRunControl(
} }
} // namespace Analyzer } // namespace Analyzer
#include "analyzermanager.moc"

View File

@@ -65,6 +65,10 @@ bool AnalyzerPlugin::initialize(const QStringList &arguments, QString *errorStri
(void) new AnalyzerManager(this); (void) new AnalyzerManager(this);
// Task integration.
//: Category under which Analyzer tasks are listed in Issues view
ProjectExplorer::TaskHub::addCategory(Constants::ANALYZERTASK_ID, tr("Analyzer"));
return true; return true;
} }

View File

@@ -34,6 +34,7 @@
#include <cpptools/cppmodelmanager.h> #include <cpptools/cppmodelmanager.h>
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <texteditor/textdocument.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -78,7 +79,7 @@ CPlusPlus::Symbol *AnalyzerUtils::findSymbolUnderCursor()
QTC_ASSERT(doc, return 0); QTC_ASSERT(doc, return 0);
// fetch the expression's code // fetch the expression's code
CPlusPlus::ExpressionUnderCursor expressionUnderCursor; CPlusPlus::ExpressionUnderCursor expressionUnderCursor(doc->languageFeatures());
moveCursorToEndOfName(&tc); moveCursorToEndOfName(&tc);
const QString &expression = expressionUnderCursor(tc); const QString &expression = expressionUnderCursor(tc);
CPlusPlus::Scope *scope = doc->scopeAt(line, column); CPlusPlus::Scope *scope = doc->scopeAt(line, column);

View File

@@ -225,8 +225,9 @@ void DetailedErrorDelegate::copyToClipboard()
QApplication::clipboard()->setText(textualRepresentation()); QApplication::clipboard()->setText(textualRepresentation());
} }
DetailedErrorView::DetailedErrorView(QWidget *parent) DetailedErrorView::DetailedErrorView(QWidget *parent) :
: QListView(parent) QListView(parent),
m_copyAction(0)
{ {
} }

View File

@@ -46,10 +46,24 @@ using namespace Utils;
namespace Analyzer { namespace Analyzer {
namespace Internal { namespace Internal {
class SshKitChooser : public KitChooser
{
public:
SshKitChooser(QWidget *parent = 0) : KitChooser(parent) { }
private:
bool kitMatches(const Kit *kit) const {
if (!KitChooser::kitMatches(kit))
return false;
const IDevice::ConstPtr device = DeviceKitInformation::device(kit);
return device && !device->sshParameters().host.isEmpty();
}
};
class StartRemoteDialogPrivate class StartRemoteDialogPrivate
{ {
public: public:
KitChooser *kitChooser; SshKitChooser *kitChooser;
QLineEdit *executable; QLineEdit *executable;
QLineEdit *arguments; QLineEdit *arguments;
QLineEdit *workingDirectory; QLineEdit *workingDirectory;
@@ -65,7 +79,7 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Start Remote Analysis")); setWindowTitle(tr("Start Remote Analysis"));
d->kitChooser = new KitChooser(this); d->kitChooser = new Internal::SshKitChooser(this);
d->executable = new QLineEdit(this); d->executable = new QLineEdit(this);
d->arguments = new QLineEdit(this); d->arguments = new QLineEdit(this);
d->workingDirectory = new QLineEdit(this); d->workingDirectory = new QLineEdit(this);

View File

@@ -47,6 +47,7 @@
#include <projectexplorer/toolchainmanager.h> #include <projectexplorer/toolchainmanager.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <debugger/debuggeritemmanager.h> #include <debugger/debuggeritemmanager.h>
#include <debugger/debuggeritem.h>
#include <debugger/debuggerkitinformation.h> #include <debugger/debuggerkitinformation.h>
#include <qtsupport/baseqtversion.h> #include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>

View File

@@ -31,7 +31,7 @@
#ifndef ANDROIDMANIFESTDOCUMENT_H #ifndef ANDROIDMANIFESTDOCUMENT_H
#define ANDROIDMANIFESTDOCUMENT_H #define ANDROIDMANIFESTDOCUMENT_H
#include <texteditor/texteditor.h> #include <texteditor/textdocument.h>
namespace Android { namespace Android {
namespace Internal { namespace Internal {

View File

@@ -39,6 +39,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QToolBar; class QToolBar;
class QActionGroup;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Android { namespace Android {

View File

@@ -32,6 +32,7 @@
#include "androidconstants.h" #include "androidconstants.h"
#include <texteditor/codeassist/keywordscompletionassist.h> #include <texteditor/codeassist/keywordscompletionassist.h>
#include <coreplugin/id.h>
using namespace Android; using namespace Android;
using namespace Android::Internal; using namespace Android::Internal;

View File

@@ -30,6 +30,8 @@
#include "bazaarclient.h" #include "bazaarclient.h"
#include "constants.h" #include "constants.h"
#include <coreplugin/id.h>
#include <vcsbase/vcsbaseplugin.h> #include <vcsbase/vcsbaseplugin.h>
#include <vcsbase/vcsoutputwindow.h> #include <vcsbase/vcsoutputwindow.h>
#include <vcsbase/vcsbaseeditorparameterwidget.h> #include <vcsbase/vcsbaseeditorparameterwidget.h>

View File

@@ -32,6 +32,7 @@
#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h> #include <texteditor/fontsettings.h>
#include <utils/completingtextedit.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QSyntaxHighlighter> #include <QSyntaxHighlighter>

View File

@@ -32,6 +32,8 @@
#include <vcsbase/vcsbaseconstants.h> #include <vcsbase/vcsbaseconstants.h>
#include <utils/fileutils.h>
#include <QFileInfo> #include <QFileInfo>
#include <QVariant> #include <QVariant>
#include <QStringList> #include <QStringList>

View File

@@ -601,7 +601,7 @@ void BazaarPlugin::showCommitWidget(const QList<VcsBaseClient::StatusItem> &stat
const QString msg = tr("Commit changes for \"%1\"."). const QString msg = tr("Commit changes for \"%1\".").
arg(QDir::toNativeSeparators(m_submitRepository)); arg(QDir::toNativeSeparators(m_submitRepository));
commitEditor->document()->setDisplayName(msg); commitEditor->document()->setPreferredDisplayName(msg);
const BranchInfo branch = m_client->synchronousBranchQuery(m_submitRepository); const BranchInfo branch = m_client->synchronousBranchQuery(m_submitRepository);
commitEditor->setFields(m_submitRepository, branch, commitEditor->setFields(m_submitRepository, branch,

View File

@@ -42,7 +42,7 @@ CommitEditor::CommitEditor(const VcsBase::VcsBaseSubmitEditorParameters *paramet
: VcsBase::VcsBaseSubmitEditor(parameters, new BazaarCommitWidget), : VcsBase::VcsBaseSubmitEditor(parameters, new BazaarCommitWidget),
m_fileModel(0) m_fileModel(0)
{ {
document()->setDisplayName(tr("Commit Editor")); document()->setPreferredDisplayName(tr("Commit Editor"));
} }
BazaarCommitWidget *CommitEditor::commitWidget() BazaarCommitWidget *CommitEditor::commitWidget()

View File

@@ -79,11 +79,8 @@ bool ArtisticStyle::initialize()
menu->menu()->setTitle(QLatin1String(Constants::ArtisticStyle::DISPLAY_NAME)); menu->menu()->setTitle(QLatin1String(Constants::ArtisticStyle::DISPLAY_NAME));
m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this);
Core::Command *cmd menu->addAction(Core::ActionManager::registerAction(m_formatFile,
= Core::ActionManager::registerAction(m_formatFile, Constants::ArtisticStyle::ACTION_FORMATFILE));
Constants::ArtisticStyle::ACTION_FORMATFILE,
Core::Context(Core::Constants::C_GLOBAL));
menu->addAction(cmd);
connect(m_formatFile, &QAction::triggered, this, &ArtisticStyle::formatFile); connect(m_formatFile, &QAction::triggered, this, &ArtisticStyle::formatFile);
Core::ActionManager::actionContainer(Constants::MENU_ID)->addMenu(menu); Core::ActionManager::actionContainer(Constants::MENU_ID)->addMenu(menu);

View File

@@ -77,15 +77,13 @@ bool ClangFormat::initialize()
m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this);
Core::Command *cmd Core::Command *cmd
= Core::ActionManager::registerAction(m_formatFile, = Core::ActionManager::registerAction(m_formatFile,
Constants::ClangFormat::ACTION_FORMATFILE, Constants::ClangFormat::ACTION_FORMATFILE);
Core::Context(Core::Constants::C_GLOBAL));
menu->addAction(cmd); menu->addAction(cmd);
connect(m_formatFile, &QAction::triggered, this, &ClangFormat::formatFile); connect(m_formatFile, &QAction::triggered, this, &ClangFormat::formatFile);
m_formatRange = new QAction(BeautifierPlugin::msgFormatSelectedText(), this); m_formatRange = new QAction(BeautifierPlugin::msgFormatSelectedText(), this);
cmd = Core::ActionManager::registerAction(m_formatRange, cmd = Core::ActionManager::registerAction(m_formatRange,
Constants::ClangFormat::ACTION_FORMATSELECTED, Constants::ClangFormat::ACTION_FORMATSELECTED);
Core::Context(Core::Constants::C_GLOBAL));
menu->addAction(cmd); menu->addAction(cmd);
connect(m_formatRange, &QAction::triggered, this, &ClangFormat::formatSelectedText); connect(m_formatRange, &QAction::triggered, this, &ClangFormat::formatSelectedText);

View File

@@ -80,8 +80,7 @@ bool Uncrustify::initialize()
m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this);
Core::Command *cmd Core::Command *cmd
= Core::ActionManager::registerAction(m_formatFile, = Core::ActionManager::registerAction(m_formatFile,
Constants::Uncrustify::ACTION_FORMATFILE, Constants::Uncrustify::ACTION_FORMATFILE);
Core::Context(Core::Constants::C_GLOBAL));
menu->addAction(cmd); menu->addAction(cmd);
connect(m_formatFile, &QAction::triggered, this, &Uncrustify::formatFile); connect(m_formatFile, &QAction::triggered, this, &Uncrustify::formatFile);

View File

@@ -42,6 +42,7 @@
#include <coreplugin/id.h> #include <coreplugin/id.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <texteditor/textdocument.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <QtPlugin> #include <QtPlugin>
@@ -56,16 +57,22 @@ using namespace TextEditor;
namespace Bookmarks { namespace Bookmarks {
namespace Internal { namespace Internal {
BookmarksPlugin::BookmarksPlugin() BookmarksPlugin::BookmarksPlugin() :
: m_bookmarkManager(0), m_bookmarkManager(0),
m_bookmarkMarginActionLineNumber(0) m_toggleAction(0),
m_prevAction(0),
m_nextAction(0),
m_docPrevAction(0),
m_docNextAction(0),
m_editBookmarkAction(0),
m_bookmarkMarginAction(0),
m_bookmarkMarginActionLineNumber(0)
{ {
} }
bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *) bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
{ {
Context textcontext(TextEditor::Constants::C_TEXTEDITOR); Context textcontext(TextEditor::Constants::C_TEXTEDITOR);
Context globalcontext(Core::Constants::C_GLOBAL);
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS); ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
ActionContainer *mbm = ActionManager::createMenu(Id(BOOKMARKS_MENU)); ActionContainer *mbm = ActionManager::createMenu(Id(BOOKMARKS_MENU));
@@ -82,26 +89,26 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
//Previous //Previous
m_prevAction = new QAction(tr("Previous Bookmark"), this); m_prevAction = new QAction(tr("Previous Bookmark"), this);
cmd = ActionManager::registerAction(m_prevAction, BOOKMARKS_PREV_ACTION, globalcontext); cmd = ActionManager::registerAction(m_prevAction, BOOKMARKS_PREV_ACTION);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+,") : tr("Ctrl+,"))); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+,") : tr("Ctrl+,")));
mbm->addAction(cmd); mbm->addAction(cmd);
//Next //Next
m_nextAction = new QAction(tr("Next Bookmark"), this); m_nextAction = new QAction(tr("Next Bookmark"), this);
cmd = ActionManager::registerAction(m_nextAction, BOOKMARKS_NEXT_ACTION, globalcontext); cmd = ActionManager::registerAction(m_nextAction, BOOKMARKS_NEXT_ACTION);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+.") : tr("Ctrl+."))); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+.") : tr("Ctrl+.")));
mbm->addAction(cmd); mbm->addAction(cmd);
mbm->addSeparator(globalcontext); mbm->addSeparator();
//Previous Doc //Previous Doc
m_docPrevAction = new QAction(tr("Previous Bookmark in Document"), this); m_docPrevAction = new QAction(tr("Previous Bookmark in Document"), this);
cmd = ActionManager::registerAction(m_docPrevAction, BOOKMARKS_PREVDOC_ACTION, globalcontext); cmd = ActionManager::registerAction(m_docPrevAction, BOOKMARKS_PREVDOC_ACTION);
mbm->addAction(cmd); mbm->addAction(cmd);
//Next Doc //Next Doc
m_docNextAction = new QAction(tr("Next Bookmark in Document"), this); m_docNextAction = new QAction(tr("Next Bookmark in Document"), this);
cmd = ActionManager::registerAction(m_docNextAction, BOOKMARKS_NEXTDOC_ACTION, globalcontext); cmd = ActionManager::registerAction(m_docNextAction, BOOKMARKS_NEXTDOC_ACTION);
mbm->addAction(cmd); mbm->addAction(cmd);
m_editBookmarkAction = new QAction(tr("Edit Bookmark"), this); m_editBookmarkAction = new QAction(tr("Edit Bookmark"), this);

View File

@@ -200,15 +200,14 @@ IAssistProcessor *ClangCompletionAssistProvider::createProcessor() const
} }
AssistInterface *ClangCompletionAssistProvider::createAssistInterface( AssistInterface *ClangCompletionAssistProvider::createAssistInterface(
const QString &filePath, const QString &filePath, QTextDocument *document,
QTextDocument *document, bool isObjCEnabled, int position, AssistReason reason) const const LanguageFeatures &languageFeatures, int position, AssistReason reason) const
{ {
Q_UNUSED(isObjCEnabled);
CppModelManager *modelManager = CppModelManager::instance(); CppModelManager *modelManager = CppModelManager::instance();
QList<ProjectPart::Ptr> parts = modelManager->projectPart(filePath); QList<ProjectPart::Ptr> parts = modelManager->projectPart(filePath);
if (parts.isEmpty()) if (parts.isEmpty())
parts += modelManager->fallbackProjectPart(); parts += modelManager->fallbackProjectPart();
LanguageFeatures features = languageFeatures;
ProjectPart::HeaderPaths headerPaths; ProjectPart::HeaderPaths headerPaths;
QStringList options; QStringList options;
PchInfo::Ptr pchInfo; PchInfo::Ptr pchInfo;
@@ -220,13 +219,14 @@ AssistInterface *ClangCompletionAssistProvider::createAssistInterface(
if (!pchInfo.isNull()) if (!pchInfo.isNull())
options.append(Utils::createPCHInclusionOptions(pchInfo->fileName())); options.append(Utils::createPCHInclusionOptions(pchInfo->fileName()));
headerPaths = part->headerPaths; headerPaths = part->headerPaths;
features = part->languageFeatures;
break; break;
} }
return new ClangCompletionAssistInterface( return new ClangCompletionAssistInterface(
m_clangCompletionWrapper, m_clangCompletionWrapper,
document, position, filePath, reason, document, position, filePath, reason,
options, headerPaths, pchInfo); options, headerPaths, pchInfo, features);
} }
// ------------------------ // ------------------------
@@ -545,12 +545,14 @@ ClangCompletionAssistInterface::ClangCompletionAssistInterface(ClangCompleter::P
AssistReason reason, AssistReason reason,
const QStringList &options, const QStringList &options,
const QList<ProjectPart::HeaderPath> &headerPaths, const QList<ProjectPart::HeaderPath> &headerPaths,
const PchInfo::Ptr &pchInfo) const PchInfo::Ptr &pchInfo,
const LanguageFeatures &features)
: AssistInterface(document, position, fileName, reason) : AssistInterface(document, position, fileName, reason)
, m_clangWrapper(clangWrapper) , m_clangWrapper(clangWrapper)
, m_options(options) , m_options(options)
, m_headerPaths(headerPaths) , m_headerPaths(headerPaths)
, m_savedPchPointer(pchInfo) , m_savedPchPointer(pchInfo)
, m_languageFeatures(features)
{ {
Q_ASSERT(!clangWrapper.isNull()); Q_ASSERT(!clangWrapper.isNull());
@@ -637,7 +639,7 @@ int ClangCompletionAssistProcessor::startCompletionHelper()
return m_startPosition; return m_startPosition;
} }
ExpressionUnderCursor expressionUnderCursor; ExpressionUnderCursor expressionUnderCursor(m_interface->languageFeatures());
QTextCursor tc(m_interface->textDocument()); QTextCursor tc(m_interface->textDocument());
if (m_model->m_completionOperator == T_COMMA) { if (m_model->m_completionOperator == T_COMMA) {
@@ -703,7 +705,7 @@ int ClangCompletionAssistProcessor::startOfOperator(int pos,
} }
if (*kind == T_COMMA) { if (*kind == T_COMMA) {
ExpressionUnderCursor expressionUnderCursor; ExpressionUnderCursor expressionUnderCursor(m_interface->languageFeatures());
if (expressionUnderCursor.startOfFunctionCall(tc) == -1) { if (expressionUnderCursor.startOfFunctionCall(tc) == -1) {
*kind = T_EOF_SYMBOL; *kind = T_EOF_SYMBOL;
start = pos; start = pos;
@@ -711,10 +713,7 @@ int ClangCompletionAssistProcessor::startOfOperator(int pos,
} }
SimpleLexer tokenize; SimpleLexer tokenize;
LanguageFeatures lf = tokenize.languageFeatures(); tokenize.setLanguageFeatures(m_interface->languageFeatures());
lf.qtMocRunEnabled = true;
lf.objCEnabled = true;
tokenize.setLanguageFeatures(lf);
tokenize.setSkipComments(false); tokenize.setSkipComments(false);
const Tokens &tokens = tokenize(tc.block().text(), BackwardsScanner::previousBlockState(tc.block())); const Tokens &tokens = tokenize(tc.block().text(), BackwardsScanner::previousBlockState(tc.block()));
const int tokenIdx = SimpleLexer::tokenBefore(tokens, qMax(0, tc.positionInBlock() - 1)); // get the token at the left of the cursor const int tokenIdx = SimpleLexer::tokenBefore(tokens, qMax(0, tc.positionInBlock() - 1)); // get the token at the left of the cursor
@@ -932,7 +931,7 @@ int ClangCompletionAssistProcessor::startCompletionInternal(const QString fileNa
QTextCursor tc(m_interface->textDocument()); QTextCursor tc(m_interface->textDocument());
tc.setPosition(index); tc.setPosition(index);
ExpressionUnderCursor euc; ExpressionUnderCursor euc(m_interface->languageFeatures());
index = euc.startOfFunctionCall(tc); index = euc.startOfFunctionCall(tc);
int nameStart = findStartOfName(index); int nameStart = findStartOfName(index);
QTextCursor tc2(m_interface->textDocument()); QTextCursor tc2(m_interface->textDocument());

View File

@@ -58,9 +58,9 @@ public:
virtual TextEditor::IAssistProcessor *createProcessor() const; virtual TextEditor::IAssistProcessor *createProcessor() const;
virtual TextEditor::AssistInterface *createAssistInterface( virtual TextEditor::AssistInterface *createAssistInterface(
const QString &filePath, const QString &filePath, QTextDocument *document,
QTextDocument *document, bool isObjCEnabled, int position, const CPlusPlus::LanguageFeatures &languageFeatures,
TextEditor::AssistReason reason) const; int position, TextEditor::AssistReason reason) const;
private: private:
ClangCodeModel::ClangCompleter::Ptr m_clangCompletionWrapper; ClangCodeModel::ClangCompleter::Ptr m_clangCompletionWrapper;
@@ -78,7 +78,8 @@ public:
TextEditor::AssistReason reason, TextEditor::AssistReason reason,
const QStringList &options, const QStringList &options,
const QList<CppTools::ProjectPart::HeaderPath> &headerPaths, const QList<CppTools::ProjectPart::HeaderPath> &headerPaths,
const Internal::PchInfo::Ptr &pchInfo); const Internal::PchInfo::Ptr &pchInfo,
const CPlusPlus::LanguageFeatures &features);
ClangCodeModel::ClangCompleter::Ptr clangWrapper() const ClangCodeModel::ClangCompleter::Ptr clangWrapper() const
{ return m_clangWrapper; } { return m_clangWrapper; }
@@ -94,12 +95,16 @@ public:
const QList<CppTools::ProjectPart::HeaderPath> &headerPaths() const const QList<CppTools::ProjectPart::HeaderPath> &headerPaths() const
{ return m_headerPaths; } { return m_headerPaths; }
CPlusPlus::LanguageFeatures languageFeatures() const
{ return m_languageFeatures; }
private: private:
ClangCodeModel::ClangCompleter::Ptr m_clangWrapper; ClangCodeModel::ClangCompleter::Ptr m_clangWrapper;
ClangCodeModel::Internal::UnsavedFiles m_unsavedFiles; ClangCodeModel::Internal::UnsavedFiles m_unsavedFiles;
QStringList m_options; QStringList m_options;
QList<CppTools::ProjectPart::HeaderPath> m_headerPaths; QList<CppTools::ProjectPart::HeaderPath> m_headerPaths;
Internal::PchInfo::Ptr m_savedPchPointer; Internal::PchInfo::Ptr m_savedPchPointer;
CPlusPlus::LanguageFeatures m_languageFeatures;
}; };
class CLANG_EXPORT ClangCompletionAssistProcessor : public CppTools::CppCompletionAssistProcessor class CLANG_EXPORT ClangCompletionAssistProcessor : public CppTools::CppCompletionAssistProcessor

View File

@@ -54,6 +54,7 @@
#include <coreplugin/messagemanager.h> #include <coreplugin/messagemanager.h>
#include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/locator/commandlocator.h> #include <coreplugin/locator/commandlocator.h>
#include <texteditor/textdocument.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/iprojectmanager.h> #include <projectexplorer/iprojectmanager.h>

View File

@@ -70,7 +70,8 @@ ClearCaseSettings::ClearCaseSettings() :
autoAssignActivityName(true), autoAssignActivityName(true),
autoCheckOut(true), autoCheckOut(true),
promptToCheckIn(false), promptToCheckIn(false),
disableIndexer(false) disableIndexer(false),
extDiffAvailable(false)
{ {
} }

View File

@@ -41,7 +41,7 @@ using namespace ClearCase::Internal;
ClearCaseSubmitEditor::ClearCaseSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters) : ClearCaseSubmitEditor::ClearCaseSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters) :
VcsBase::VcsBaseSubmitEditor(parameters, new ClearCaseSubmitEditorWidget) VcsBase::VcsBaseSubmitEditor(parameters, new ClearCaseSubmitEditorWidget)
{ {
document()->setDisplayName(tr("ClearCase Check In")); document()->setPreferredDisplayName(tr("ClearCase Check In"));
} }
ClearCaseSubmitEditorWidget *ClearCaseSubmitEditor::submitEditorWidget() ClearCaseSubmitEditorWidget *ClearCaseSubmitEditor::submitEditorWidget()

View File

@@ -568,4 +568,11 @@ bool MenuBarActionContainer::canBeAddedToMenu() const
} }
} // namespace Internal } // namespace Internal
Command *ActionContainer::addSeparator(Id group)
{
static const Context context(Constants::C_GLOBAL);
return addSeparator(context, group);
}
} // namespace Core } // namespace Core

View File

@@ -71,6 +71,7 @@ public:
virtual void addAction(Command *action, Id group = Id()) = 0; virtual void addAction(Command *action, Id group = Id()) = 0;
virtual void addMenu(ActionContainer *menu, Id group = Id()) = 0; virtual void addMenu(ActionContainer *menu, Id group = Id()) = 0;
virtual void addMenu(ActionContainer *before, ActionContainer *menu, Id group = Id()) = 0; virtual void addMenu(ActionContainer *before, ActionContainer *menu, Id group = Id()) = 0;
Command *addSeparator(Id group = Id());
virtual Command *addSeparator(const Context &context, Id group = Id(), QAction **outSeparator = 0) = 0; virtual Command *addSeparator(const Context &context, Id group = Id(), QAction **outSeparator = 0) = 0;
// This clears this menu and submenus from all actions and submenus. // This clears this menu and submenus from all actions and submenus.

View File

@@ -243,6 +243,8 @@ ActionContainer *ActionManager::createMenuBar(Id id)
same \a id as long as the \a context is different. In this case same \a id as long as the \a context is different. In this case
a trigger of the actual action is forwarded to the registered QAction a trigger of the actual action is forwarded to the registered QAction
for the currently active context. for the currently active context.
If the optional \a context argument is not specified, the global context
will be assumed.
A scriptable action can be called from a script without the need for the user A scriptable action can be called from a script without the need for the user
to interact with it. to interact with it.
*/ */
@@ -384,8 +386,8 @@ void ActionManager::setContext(const Context &context)
\internal \internal
*/ */
ActionManagerPrivate::ActionManagerPrivate() ActionManagerPrivate::ActionManagerPrivate() :
: m_presentationModeEnabled(false) m_presentationModeEnabled(false)
{ {
} }

View File

@@ -32,7 +32,8 @@
#define ACTIONMANAGER_H #define ACTIONMANAGER_H
#include "coreplugin/core_global.h" #include "coreplugin/core_global.h"
#include "coreplugin/id.h" #include "coreplugin/coreconstants.h"
#include "coreplugin/icontext.h"
#include <coreplugin/actionmanager/command.h> #include <coreplugin/actionmanager/command.h>
#include <QObject> #include <QObject>
@@ -62,7 +63,9 @@ public:
static ActionContainer *createMenu(Id id); static ActionContainer *createMenu(Id id);
static ActionContainer *createMenuBar(Id id); static ActionContainer *createMenuBar(Id id);
static Command *registerAction(QAction *action, Id id, const Context &context, bool scriptable = false); static Command *registerAction(QAction *action, Id id,
const Context &context = Context(Constants::C_GLOBAL),
bool scriptable = false);
static Command *command(Id id); static Command *command(Id id);
static ActionContainer *actionContainer(Id id); static ActionContainer *actionContainer(Id id);

View File

@@ -90,8 +90,6 @@ public:
Context m_context; Context m_context;
bool m_presentationModeEnabled; bool m_presentationModeEnabled;
QLabel *m_presentationLabel;
QTimer m_presentationLabelTimer;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -40,6 +40,7 @@
#include <QDir> #include <QDir>
#include <QIcon> #include <QIcon>
#include <QMimeData> #include <QMimeData>
#include <QSet>
#include <QUrl> #include <QUrl>
namespace Core { namespace Core {
@@ -69,16 +70,46 @@ public:
int indexOfFilePath(const Utils::FileName &filePath) const; int indexOfFilePath(const Utils::FileName &filePath) const;
int indexOfDocument(IDocument *document) const; int indexOfDocument(IDocument *document) const;
bool disambiguateDisplayNames(DocumentModel::Entry *entry);
private slots: private slots:
friend class DocumentModel; friend class DocumentModel;
void itemChanged(); void itemChanged();
private: private:
class DynamicEntry
{
public:
DocumentModel::Entry *entry;
int pathComponents;
DynamicEntry(DocumentModel::Entry *e) :
entry(e),
pathComponents(0)
{
}
DocumentModel::Entry *operator->() const { return entry; }
void disambiguate()
{
entry->document->setUniqueDisplayName(entry->fileName().fileName(++pathComponents));
}
void setNumberedName(int number)
{
entry->document->setUniqueDisplayName(QStringLiteral("%1 (%2)")
.arg(entry->document->displayName())
.arg(number));
}
};
const QIcon m_lockedIcon; const QIcon m_lockedIcon;
const QIcon m_unlockedIcon; const QIcon m_unlockedIcon;
QList<DocumentModel::Entry *> m_entries; QList<DocumentModel::Entry *> m_entries;
QMap<IDocument *, QList<IEditor *> > m_editors; QMap<IDocument *, QList<IEditor *> > m_editors;
QHash<QString, DocumentModel::Entry *> m_entryByFixedPath;
}; };
DocumentModelPrivate::DocumentModelPrivate() : DocumentModelPrivate::DocumentModelPrivate() :
@@ -138,6 +169,11 @@ QString DocumentModel::Entry::displayName() const
return document ? document->displayName() : m_displayName; return document ? document->displayName() : m_displayName;
} }
QString DocumentModel::Entry::plainDisplayName() const
{
return document ? document->plainDisplayName() : m_displayName;
}
Id DocumentModel::Entry::id() const Id DocumentModel::Entry::id() const
{ {
return document ? document->id() : m_id; return document ? document->id() : m_id;
@@ -191,45 +227,123 @@ DocumentModel::Entry *DocumentModel::firstRestoredEntry()
void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry) void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry)
{ {
const Utils::FileName fileName = entry->fileName(); const Utils::FileName fileName = entry->fileName();
QString fixedPath;
if (!fileName.isEmpty())
fixedPath = DocumentManager::fixFileName(fileName.toString(), DocumentManager::ResolveLinks);
// replace a non-loaded entry (aka 'restored') if possible // replace a non-loaded entry (aka 'restored') if possible
int previousIndex = indexOfFilePath(fileName); int previousIndex = indexOfFilePath(fileName);
if (previousIndex >= 0) { if (previousIndex >= 0) {
if (entry->document && m_entries.at(previousIndex)->document == 0) { DocumentModel::Entry *previousEntry = m_entries.at(previousIndex);
DocumentModel::Entry *previousEntry = m_entries.at(previousIndex); const bool replace = entry->document && !previousEntry->document;
m_entries[previousIndex] = entry; if (replace) {
delete previousEntry; delete previousEntry;
connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged())); m_entries[previousIndex] = entry;
if (!fixedPath.isEmpty())
m_entryByFixedPath[fixedPath] = entry;
} else { } else {
delete entry; delete entry;
entry = previousEntry;
} }
previousEntry = 0;
disambiguateDisplayNames(entry);
if (replace)
connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged()));
return; return;
} }
int index; int index;
QString displayName = entry->displayName(); const QString displayName = entry->plainDisplayName();
for (index = 0; index < m_entries.count(); ++index) { for (index = 0; index < m_entries.count(); ++index) {
if (displayName.localeAwareCompare(m_entries.at(index)->displayName()) < 0) int cmp = displayName.localeAwareCompare(m_entries.at(index)->plainDisplayName());
if (cmp < 0)
break;
if (cmp == 0 && fileName < d->m_entries.at(index)->fileName())
break; break;
} }
int row = index + 1/*<no document>*/; int row = index + 1/*<no document>*/;
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
m_entries.insert(index, entry); m_entries.insert(index, entry);
disambiguateDisplayNames(entry);
if (!fixedPath.isEmpty())
m_entryByFixedPath[fixedPath] = entry;
if (entry->document) if (entry->document)
connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged())); connect(entry->document, SIGNAL(changed()), this, SLOT(itemChanged()));
endInsertRows(); endInsertRows();
} }
bool DocumentModelPrivate::disambiguateDisplayNames(DocumentModel::Entry *entry)
{
const QString displayName = entry->plainDisplayName();
int minIdx = -1, maxIdx = -1;
QList<DynamicEntry> dups;
for (int i = 0, total = m_entries.count(); i < total; ++i) {
DocumentModel::Entry *e = m_entries.at(i);
if (!e->document)
continue;
if (e == entry || e->plainDisplayName() == displayName) {
e->document->setUniqueDisplayName(QString());
dups += DynamicEntry(e);
maxIdx = i;
if (minIdx < 0)
minIdx = i;
}
}
const int dupsCount = dups.count();
if (dupsCount == 0)
return false;
if (dupsCount > 1) {
int serial = 0;
int count = 0;
// increase uniqueness unless no dups are left
forever {
bool seenDups = false;
for (int i = 0; i < dupsCount - 1; ++i) {
DynamicEntry &e = dups[i];
const Utils::FileName myFileName = e->document->filePath();
if (e->document->isTemporary() || myFileName.isEmpty() || count > 10) {
// path-less entry, append number
e.setNumberedName(++serial);
continue;
}
for (int j = i + 1; j < dupsCount; ++j) {
DynamicEntry &e2 = dups[j];
if (e->displayName() == e2->displayName()) {
const Utils::FileName otherFileName = e2->document->filePath();
if (otherFileName.isEmpty())
continue;
seenDups = true;
e2.disambiguate();
if (j > maxIdx)
maxIdx = j;
}
}
if (seenDups) {
e.disambiguate();
++count;
break;
}
}
if (!seenDups)
break;
}
}
emit dataChanged(index(minIdx + 1, 0), index(maxIdx + 1, 0));
return true;
}
int DocumentModelPrivate::indexOfFilePath(const Utils::FileName &filePath) const int DocumentModelPrivate::indexOfFilePath(const Utils::FileName &filePath) const
{ {
if (filePath.isEmpty()) if (filePath.isEmpty())
return -1; return -1;
const QString fixedPath = DocumentManager::fixFileName(filePath.toString(), const QString fixedPath = DocumentManager::fixFileName(filePath.toString(),
DocumentManager::ResolveLinks); DocumentManager::ResolveLinks);
return Utils::indexOf(m_entries, [&fixedPath](DocumentModel::Entry *entry) { return m_entries.indexOf(m_entryByFixedPath.value(fixedPath));
return DocumentManager::fixFileName(entry->fileName().toString(),
DocumentManager::ResolveLinks) == fixedPath;
});
} }
void DocumentModel::removeEntry(DocumentModel::Entry *entry) void DocumentModel::removeEntry(DocumentModel::Entry *entry)
@@ -271,8 +385,16 @@ void DocumentModelPrivate::removeDocument(int idx)
beginRemoveRows(QModelIndex(), row, row); beginRemoveRows(QModelIndex(), row, row);
DocumentModel::Entry *entry = d->m_entries.takeAt(idx); DocumentModel::Entry *entry = d->m_entries.takeAt(idx);
endRemoveRows(); endRemoveRows();
const QString fileName = entry->fileName().toString();
if (!fileName.isEmpty()) {
const QString fixedPath = DocumentManager::fixFileName(fileName,
DocumentManager::ResolveLinks);
m_entryByFixedPath.remove(fixedPath);
}
if (IDocument *document = entry->document) if (IDocument *document = entry->document)
disconnect(document, SIGNAL(changed()), this, SLOT(itemChanged())); disconnect(document, SIGNAL(changed()), this, SLOT(itemChanged()));
disambiguateDisplayNames(entry);
delete entry; delete entry;
} }
@@ -286,6 +408,14 @@ void DocumentModel::removeAllRestoredEntries()
d->endRemoveRows(); d->endRemoveRows();
} }
} }
QSet<QString> displayNames;
foreach (DocumentModel::Entry *entry, d->m_entries) {
const QString displayName = entry->plainDisplayName();
if (displayNames.contains(displayName))
continue;
displayNames.insert(displayName);
d->disambiguateDisplayNames(entry);
}
} }
QList<IEditor *> DocumentModel::editorsForDocument(IDocument *document) QList<IEditor *> DocumentModel::editorsForDocument(IDocument *document)
@@ -394,10 +524,12 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const
} }
const DocumentModel::Entry *e = m_entries.at(entryIndex); const DocumentModel::Entry *e = m_entries.at(entryIndex);
switch (role) { switch (role) {
case Qt::DisplayRole: case Qt::DisplayRole: {
return (e->document && e->document->isModified()) QString name = e->displayName();
? e->displayName() + QLatin1Char('*') if (e->document && e->document->isModified())
: e->displayName(); name += QLatin1Char('*');
return name;
}
case Qt::DecorationRole: case Qt::DecorationRole:
{ {
bool showLock = false; bool showLock = false;
@@ -408,9 +540,7 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const
return showLock ? m_lockedIcon : QIcon(); return showLock ? m_lockedIcon : QIcon();
} }
case Qt::ToolTipRole: case Qt::ToolTipRole:
return e->fileName().isEmpty() return e->fileName().isEmpty() ? e->displayName() : e->fileName().toUserOutput();
? e->displayName()
: e->fileName().toUserOutput();
default: default:
return QVariant(); return QVariant();
} }
@@ -451,8 +581,31 @@ void DocumentModelPrivate::itemChanged()
int idx = indexOfDocument(document); int idx = indexOfDocument(document);
if (idx < 0) if (idx < 0)
return; return;
QModelIndex mindex = index(idx + 1/*<no document>*/, 0); const QString fileName = document->filePath().toString();
emit dataChanged(mindex, mindex); QString fixedPath;
if (!fileName.isEmpty())
fixedPath = DocumentManager::fixFileName(fileName, DocumentManager::ResolveLinks);
DocumentModel::Entry *entry = d->m_entries.at(idx);
bool found = false;
// The entry's fileName might have changed, so find the previous fileName that was associated
// with it and remove it, then add the new fileName.
for (auto it = m_entryByFixedPath.begin(), end = m_entryByFixedPath.end(); it != end; ++it) {
if (it.value() == entry) {
found = true;
if (it.key() != fixedPath) {
m_entryByFixedPath.remove(it.key());
if (!fixedPath.isEmpty())
m_entryByFixedPath[fixedPath] = entry;
}
break;
}
}
if (!found && !fixedPath.isEmpty())
m_entryByFixedPath[fixedPath] = entry;
if (!disambiguateDisplayNames(d->m_entries.at(idx))) {
QModelIndex mindex = index(idx + 1/*<no document>*/, 0);
emit dataChanged(mindex, mindex);
}
} }
QList<DocumentModel::Entry *> DocumentModel::entries() QList<DocumentModel::Entry *> DocumentModel::entries()

View File

@@ -61,6 +61,8 @@ public:
IDocument *document; IDocument *document;
Utils::FileName fileName() const; Utils::FileName fileName() const;
QString displayName() const; QString displayName() const;
QString plainDisplayName() const;
QString uniqueDisplayName() const;
Id id() const; Id id() const;
Utils::FileName m_fileName; Utils::FileName m_fileName;
QString m_displayName; QString m_displayName;

View File

@@ -102,6 +102,8 @@ static const char reloadBehaviorKey[] = "EditorManager/ReloadBehavior";
static const char autoSaveEnabledKey[] = "EditorManager/AutoSaveEnabled"; static const char autoSaveEnabledKey[] = "EditorManager/AutoSaveEnabled";
static const char autoSaveIntervalKey[] = "EditorManager/AutoSaveInterval"; static const char autoSaveIntervalKey[] = "EditorManager/AutoSaveInterval";
static const char scratchBufferKey[] = "_q_emScratchBuffer";
//===================EditorClosingCoreListener====================== //===================EditorClosingCoreListener======================
namespace Core { namespace Core {
@@ -1660,7 +1662,7 @@ bool EditorManagerPrivate::saveDocument(IDocument *document)
document->checkPermissions(); document->checkPermissions();
const QString &fileName = document->filePath().toString(); const QString fileName = document->filePath().toString();
if (fileName.isEmpty()) if (fileName.isEmpty())
return saveDocumentAs(document); return saveDocumentAs(document);
@@ -2329,20 +2331,8 @@ QStringList EditorManager::getOpenFileNames()
return DocumentManager::getOpenFileNames(fileFilters, QString(), &selectedFilter); return DocumentManager::getOpenFileNames(fileFilters, QString(), &selectedFilter);
} }
static QString makeTitleUnique(QString *titlePattern)
IEditor *EditorManager::openEditorWithContents(Id editorId,
QString *titlePattern,
const QByteArray &contents,
OpenEditorFlags flags)
{ {
if (debugEditorManager)
qDebug() << Q_FUNC_INFO << editorId.name() << titlePattern << contents;
if (flags & EditorManager::OpenInOtherSplit)
EditorManager::gotoOtherSplit();
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QString title; QString title;
if (titlePattern) { if (titlePattern) {
const QChar dollar = QLatin1Char('$'); const QChar dollar = QLatin1Char('$');
@@ -2371,8 +2361,42 @@ IEditor *EditorManager::openEditorWithContents(Id editorId,
} }
*titlePattern = title; *titlePattern = title;
} }
return title;
}
IEditor *edt = EditorManagerPrivate::createEditor(editorId, title); IEditor *EditorManager::openEditorWithContents(Id editorId,
QString *titlePattern,
const QByteArray &contents,
const QString &uniqueId,
OpenEditorFlags flags)
{
if (debugEditorManager)
qDebug() << Q_FUNC_INFO << editorId.name() << titlePattern << uniqueId << contents;
if (flags & EditorManager::OpenInOtherSplit)
EditorManager::gotoOtherSplit();
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
const QString title = makeTitleUnique(titlePattern);
IEditor *edt = 0;
if (!uniqueId.isEmpty()) {
foreach (IDocument *document, DocumentModel::openedDocuments())
if (document->property(scratchBufferKey).toString() == uniqueId) {
edt = DocumentModel::editorsForDocument(document).first();
document->setContents(contents);
if (!title.isEmpty())
edt->document()->setPreferredDisplayName(title);
QApplication::restoreOverrideCursor();
activateEditor(edt, flags);
return edt;
}
}
edt = EditorManagerPrivate::createEditor(editorId, title);
if (!edt) { if (!edt) {
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
return 0; return 0;
@@ -2385,9 +2409,11 @@ IEditor *EditorManager::openEditorWithContents(Id editorId,
return 0; return 0;
} }
if (!title.isEmpty()) if (!uniqueId.isEmpty())
edt->document()->setDisplayName(title); edt->document()->setProperty(scratchBufferKey, uniqueId);
if (!title.isEmpty())
edt->document()->setPreferredDisplayName(title);
EditorManagerPrivate::addEditor(edt); EditorManagerPrivate::addEditor(edt);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();

View File

@@ -120,6 +120,7 @@ public:
bool *newEditor = 0); bool *newEditor = 0);
static IEditor *openEditorWithContents(Id editorId, QString *titlePattern = 0, static IEditor *openEditorWithContents(Id editorId, QString *titlePattern = 0,
const QByteArray &contents = QByteArray(), const QByteArray &contents = QByteArray(),
const QString &uniqueId = QString(),
OpenEditorFlags flags = NoFlags); OpenEditorFlags flags = NoFlags);
static bool openExternalEditor(const QString &fileName, Id editorId); static bool openExternalEditor(const QString &fileName, Id editorId);

View File

@@ -225,7 +225,8 @@ void OpenEditorsWindow::addHistoryItems(const QList<EditLocation> &history, Edit
if (hi.document.isNull() || documentsDone.contains(hi.document)) if (hi.document.isNull() || documentsDone.contains(hi.document))
continue; continue;
documentsDone.insert(hi.document.data()); documentsDone.insert(hi.document.data());
QString title = hi.document->displayName(); DocumentModel::Entry *entry = DocumentModel::entryForDocument(hi.document);
QString title = entry ? entry->displayName() : hi.document->displayName();
QTC_ASSERT(!title.isEmpty(), continue); QTC_ASSERT(!title.isEmpty(), continue);
QTreeWidgetItem *item = new QTreeWidgetItem(); QTreeWidgetItem *item = new QTreeWidgetItem();
if (hi.document->isModified()) if (hi.document->isModified())

View File

@@ -97,8 +97,11 @@ EditorToolBarPrivate::EditorToolBarPrivate(QWidget *parent, EditorToolBar *q) :
m_closeEditorButton(new QToolButton(q)), m_closeEditorButton(new QToolButton(q)),
m_lockButton(new QToolButton(q)), m_lockButton(new QToolButton(q)),
m_dragHandle(new QToolButton(q)), m_dragHandle(new QToolButton(q)),
m_dragHandleMenu(0),
m_goBackAction(new QAction(QIcon(QLatin1String(Constants::ICON_PREV)), EditorManager::tr("Go Back"), parent)), m_goBackAction(new QAction(QIcon(QLatin1String(Constants::ICON_PREV)), EditorManager::tr("Go Back"), parent)),
m_goForwardAction(new QAction(QIcon(QLatin1String(Constants::ICON_NEXT)), EditorManager::tr("Go Forward"), parent)), m_goForwardAction(new QAction(QIcon(QLatin1String(Constants::ICON_NEXT)), EditorManager::tr("Go Forward"), parent)),
m_backButton(new QToolButton(q)),
m_forwardButton(new QToolButton(q)),
m_splitButton(new QToolButton(q)), m_splitButton(new QToolButton(q)),
m_horizontalSplitAction(new QAction(QIcon(QLatin1String(Constants::ICON_SPLIT_HORIZONTAL)), EditorManager::tr("Split"), parent)), m_horizontalSplitAction(new QAction(QIcon(QLatin1String(Constants::ICON_SPLIT_HORIZONTAL)), EditorManager::tr("Split"), parent)),
m_verticalSplitAction(new QAction(QIcon(QLatin1String(Constants::ICON_SPLIT_VERTICAL)), EditorManager::tr("Split Side by Side"), parent)), m_verticalSplitAction(new QAction(QIcon(QLatin1String(Constants::ICON_SPLIT_VERTICAL)), EditorManager::tr("Split Side by Side"), parent)),
@@ -154,10 +157,8 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
d->m_toolBarPlaceholder->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); d->m_toolBarPlaceholder->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
d->m_backButton = new QToolButton(this);
d->m_backButton->setDefaultAction(d->m_goBackAction); d->m_backButton->setDefaultAction(d->m_goBackAction);
d->m_forwardButton= new QToolButton(this);
d->m_forwardButton->setDefaultAction(d->m_goForwardAction); d->m_forwardButton->setDefaultAction(d->m_goForwardAction);
if (Utils::HostOsInfo::isMacHost()) { if (Utils::HostOsInfo::isMacHost()) {

View File

@@ -244,7 +244,7 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<ExternalT
MessageManager::write(runner->errorString()); MessageManager::write(runner->errorString());
}); });
command = ActionManager::registerAction(action, externalToolsPrefix.withSuffix(toolId), Context(Constants::C_GLOBAL)); command = ActionManager::registerAction(action, externalToolsPrefix.withSuffix(toolId));
command->setAttribute(Command::CA_UpdateText); command->setAttribute(Command::CA_UpdateText);
} }
action->setText(tool->displayName()); action->setText(tool->displayName());

View File

@@ -94,8 +94,10 @@ public:
FindPluginPrivate::FindPluginPrivate(FindPlugin *q) : FindPluginPrivate::FindPluginPrivate(FindPlugin *q) :
m_currentDocumentFind(0), m_findToolBar(0), m_findDialog(0), m_currentDocumentFind(0), m_findToolBar(0), m_findDialog(0),
m_searchResultWindow(0),
m_findCompletionModel(new QStringListModel(q)), m_findCompletionModel(new QStringListModel(q)),
m_replaceCompletionModel(new QStringListModel(q)) m_replaceCompletionModel(new QStringListModel(q)),
m_openFindDialog(0)
{ {
} }
@@ -201,17 +203,16 @@ void FindPlugin::setupMenu()
mfind->appendGroup(Constants::G_FIND_FILTERS); mfind->appendGroup(Constants::G_FIND_FILTERS);
mfind->appendGroup(Constants::G_FIND_FLAGS); mfind->appendGroup(Constants::G_FIND_FLAGS);
mfind->appendGroup(Constants::G_FIND_ACTIONS); mfind->appendGroup(Constants::G_FIND_ACTIONS);
Context globalcontext(Constants::C_GLOBAL);
Command *cmd; Command *cmd;
mfind->addSeparator(globalcontext, Constants::G_FIND_FLAGS); mfind->addSeparator(Constants::G_FIND_FLAGS);
mfind->addSeparator(globalcontext, Constants::G_FIND_ACTIONS); mfind->addSeparator(Constants::G_FIND_ACTIONS);
ActionContainer *mfindadvanced = ActionManager::createMenu(Constants::M_FIND_ADVANCED); ActionContainer *mfindadvanced = ActionManager::createMenu(Constants::M_FIND_ADVANCED);
mfindadvanced->menu()->setTitle(tr("Advanced Find")); mfindadvanced->menu()->setTitle(tr("Advanced Find"));
mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS); mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS);
d->m_openFindDialog = new QAction(tr("Open Advanced Find..."), this); d->m_openFindDialog = new QAction(tr("Open Advanced Find..."), this);
d->m_openFindDialog->setIconText(tr("Advanced...")); d->m_openFindDialog->setIconText(tr("Advanced..."));
cmd = ActionManager::registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND, globalcontext); cmd = ActionManager::registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F")));
mfindadvanced->addAction(cmd); mfindadvanced->addAction(cmd);
connect(d->m_openFindDialog, &QAction::triggered, connect(d->m_openFindDialog, &QAction::triggered,
@@ -223,7 +224,6 @@ void FindPlugin::setupFilterMenuItems()
QList<IFindFilter*> findInterfaces = QList<IFindFilter*> findInterfaces =
ExtensionSystem::PluginManager::getObjects<IFindFilter>(); ExtensionSystem::PluginManager::getObjects<IFindFilter>();
Command *cmd; Command *cmd;
Context globalcontext(Constants::C_GLOBAL);
ActionContainer *mfindadvanced = ActionManager::actionContainer(Constants::M_FIND_ADVANCED); ActionContainer *mfindadvanced = ActionManager::actionContainer(Constants::M_FIND_ADVANCED);
d->m_filterActions.clear(); d->m_filterActions.clear();
@@ -236,8 +236,7 @@ void FindPlugin::setupFilterMenuItems()
haveEnabledFilters = true; haveEnabledFilters = true;
action->setEnabled(isEnabled); action->setEnabled(isEnabled);
action->setData(qVariantFromValue(filter)); action->setData(qVariantFromValue(filter));
cmd = ActionManager::registerAction(action, cmd = ActionManager::registerAction(action, base.withSuffix(filter->id()));
base.withSuffix(filter->id()), globalcontext);
cmd->setDefaultKeySequence(filter->defaultShortcut()); cmd->setDefaultKeySequence(filter->defaultShortcut());
mfindadvanced->addAction(cmd); mfindadvanced->addAction(cmd);
d->m_filterActions.insert(filter, action); d->m_filterActions.insert(filter, action);

View File

@@ -153,7 +153,6 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
QMetaTypeId<QStringList>::qt_metatype_id(); QMetaTypeId<QStringList>::qt_metatype_id();
// register actions // register actions
Context globalcontext(Constants::C_GLOBAL);
Context findcontext(Constants::C_FINDTOOLBAR); Context findcontext(Constants::C_FINDTOOLBAR);
ActionContainer *mfind = ActionManager::actionContainer(Constants::M_FIND); ActionContainer *mfind = ActionManager::actionContainer(Constants::M_FIND);
Command *cmd; Command *cmd;
@@ -168,7 +167,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
QIcon icon = QIcon::fromTheme(QLatin1String("edit-find-replace")); QIcon icon = QIcon::fromTheme(QLatin1String("edit-find-replace"));
m_findInDocumentAction = new QAction(icon, tr("Find/Replace"), this); m_findInDocumentAction = new QAction(icon, tr("Find/Replace"), this);
cmd = ActionManager::registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT, globalcontext); cmd = ActionManager::registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT);
cmd->setDefaultKeySequence(QKeySequence::Find); cmd->setDefaultKeySequence(QKeySequence::Find);
mfind->addAction(cmd, Constants::G_FIND_CURRENTDOCUMENT); mfind->addAction(cmd, Constants::G_FIND_CURRENTDOCUMENT);
connect(m_findInDocumentAction, SIGNAL(triggered()), this, SLOT(openFind())); connect(m_findInDocumentAction, SIGNAL(triggered()), this, SLOT(openFind()));
@@ -183,7 +182,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
if (QApplication::clipboard()->supportsFindBuffer()) { if (QApplication::clipboard()->supportsFindBuffer()) {
m_enterFindStringAction = new QAction(tr("Enter Find String"), this); m_enterFindStringAction = new QAction(tr("Enter Find String"), this);
cmd = ActionManager::registerAction(m_enterFindStringAction, "Find.EnterFindString", globalcontext); cmd = ActionManager::registerAction(m_enterFindStringAction, "Find.EnterFindString");
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E")));
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_enterFindStringAction, &QAction::triggered, this, &FindToolBar::putSelectionToFindClipboard); connect(m_enterFindStringAction, &QAction::triggered, this, &FindToolBar::putSelectionToFindClipboard);
@@ -191,7 +190,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
} }
m_findNextAction = new QAction(tr("Find Next"), this); m_findNextAction = new QAction(tr("Find Next"), this);
cmd = ActionManager::registerAction(m_findNextAction, Constants::FIND_NEXT, globalcontext); cmd = ActionManager::registerAction(m_findNextAction, Constants::FIND_NEXT);
cmd->setDefaultKeySequence(QKeySequence::FindNext); cmd->setDefaultKeySequence(QKeySequence::FindNext);
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_findNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindNext); connect(m_findNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindNext);
@@ -202,7 +201,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_ui.findNextButton->setDefaultAction(m_localFindNextAction); m_ui.findNextButton->setDefaultAction(m_localFindNextAction);
m_findPreviousAction = new QAction(tr("Find Previous"), this); m_findPreviousAction = new QAction(tr("Find Previous"), this);
cmd = ActionManager::registerAction(m_findPreviousAction, Constants::FIND_PREVIOUS, globalcontext); cmd = ActionManager::registerAction(m_findPreviousAction, Constants::FIND_PREVIOUS);
cmd->setDefaultKeySequence(QKeySequence::FindPrevious); cmd->setDefaultKeySequence(QKeySequence::FindPrevious);
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_findPreviousAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindPrevious); connect(m_findPreviousAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindPrevious);
@@ -213,19 +212,19 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_ui.findPreviousButton->setDefaultAction(m_localFindPreviousAction); m_ui.findPreviousButton->setDefaultAction(m_localFindPreviousAction);
m_findNextSelectedAction = new QAction(tr("Find Next (Selected)"), this); m_findNextSelectedAction = new QAction(tr("Find Next (Selected)"), this);
cmd = ActionManager::registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED, globalcontext); cmd = ActionManager::registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F3"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F3")));
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_findNextSelectedAction, &QAction::triggered, this, &FindToolBar::findNextSelected); connect(m_findNextSelectedAction, &QAction::triggered, this, &FindToolBar::findNextSelected);
m_findPreviousSelectedAction = new QAction(tr("Find Previous (Selected)"), this); m_findPreviousSelectedAction = new QAction(tr("Find Previous (Selected)"), this);
cmd = ActionManager::registerAction(m_findPreviousSelectedAction, Constants::FIND_PREV_SELECTED, globalcontext); cmd = ActionManager::registerAction(m_findPreviousSelectedAction, Constants::FIND_PREV_SELECTED);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F3"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F3")));
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_findPreviousSelectedAction, &QAction::triggered, this, &FindToolBar::findPreviousSelected); connect(m_findPreviousSelectedAction, &QAction::triggered, this, &FindToolBar::findPreviousSelected);
m_replaceAction = new QAction(tr("Replace"), this); m_replaceAction = new QAction(tr("Replace"), this);
cmd = ActionManager::registerAction(m_replaceAction, Constants::REPLACE, globalcontext); cmd = ActionManager::registerAction(m_replaceAction, Constants::REPLACE);
cmd->setDefaultKeySequence(QKeySequence()); cmd->setDefaultKeySequence(QKeySequence());
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_replaceAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplace); connect(m_replaceAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplace);
@@ -236,7 +235,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_ui.replaceButton->setDefaultAction(m_localReplaceAction); m_ui.replaceButton->setDefaultAction(m_localReplaceAction);
m_replaceNextAction = new QAction(tr("Replace && Find"), this); m_replaceNextAction = new QAction(tr("Replace && Find"), this);
cmd = ActionManager::registerAction(m_replaceNextAction, Constants::REPLACE_NEXT, globalcontext); cmd = ActionManager::registerAction(m_replaceNextAction, Constants::REPLACE_NEXT);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+="))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+=")));
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_replaceNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceNext); connect(m_replaceNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceNext);
@@ -248,7 +247,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_ui.replaceNextButton->setDefaultAction(m_localReplaceNextAction); m_ui.replaceNextButton->setDefaultAction(m_localReplaceNextAction);
m_replacePreviousAction = new QAction(tr("Replace && Find Previous"), this); m_replacePreviousAction = new QAction(tr("Replace && Find Previous"), this);
cmd = ActionManager::registerAction(m_replacePreviousAction, Constants::REPLACE_PREVIOUS, globalcontext); cmd = ActionManager::registerAction(m_replacePreviousAction, Constants::REPLACE_PREVIOUS);
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_replacePreviousAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplacePrevious); connect(m_replacePreviousAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplacePrevious);
m_localReplacePreviousAction = new QAction(m_replacePreviousAction->text(), this); m_localReplacePreviousAction = new QAction(m_replacePreviousAction->text(), this);
@@ -257,7 +256,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
connect(m_localReplacePreviousAction, &QAction::triggered, this, &FindToolBar::invokeReplacePrevious); connect(m_localReplacePreviousAction, &QAction::triggered, this, &FindToolBar::invokeReplacePrevious);
m_replaceAllAction = new QAction(tr("Replace All"), this); m_replaceAllAction = new QAction(tr("Replace All"), this);
cmd = ActionManager::registerAction(m_replaceAllAction, Constants::REPLACE_ALL, globalcontext); cmd = ActionManager::registerAction(m_replaceAllAction, Constants::REPLACE_ALL);
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_replaceAllAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceAll); connect(m_replaceAllAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceAll);
m_localReplaceAllAction = new QAction(m_replaceAllAction->text(), this); m_localReplaceAllAction = new QAction(m_replaceAllAction->text(), this);
@@ -270,7 +269,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_caseSensitiveAction->setIcon(QIcon(QLatin1String(":/find/images/casesensitively.png"))); m_caseSensitiveAction->setIcon(QIcon(QLatin1String(":/find/images/casesensitively.png")));
m_caseSensitiveAction->setCheckable(true); m_caseSensitiveAction->setCheckable(true);
m_caseSensitiveAction->setChecked(false); m_caseSensitiveAction->setChecked(false);
cmd = ActionManager::registerAction(m_caseSensitiveAction, Constants::CASE_SENSITIVE, globalcontext); cmd = ActionManager::registerAction(m_caseSensitiveAction, Constants::CASE_SENSITIVE);
mfind->addAction(cmd, Constants::G_FIND_FLAGS); mfind->addAction(cmd, Constants::G_FIND_FLAGS);
connect(m_caseSensitiveAction, &QAction::toggled, this, &FindToolBar::setCaseSensitive); connect(m_caseSensitiveAction, &QAction::toggled, this, &FindToolBar::setCaseSensitive);
@@ -278,7 +277,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_wholeWordAction->setIcon(QIcon(QLatin1String(":/find/images/wholewords.png"))); m_wholeWordAction->setIcon(QIcon(QLatin1String(":/find/images/wholewords.png")));
m_wholeWordAction->setCheckable(true); m_wholeWordAction->setCheckable(true);
m_wholeWordAction->setChecked(false); m_wholeWordAction->setChecked(false);
cmd = ActionManager::registerAction(m_wholeWordAction, Constants::WHOLE_WORDS, globalcontext); cmd = ActionManager::registerAction(m_wholeWordAction, Constants::WHOLE_WORDS);
mfind->addAction(cmd, Constants::G_FIND_FLAGS); mfind->addAction(cmd, Constants::G_FIND_FLAGS);
connect(m_wholeWordAction, &QAction::toggled, this, &FindToolBar::setWholeWord); connect(m_wholeWordAction, &QAction::toggled, this, &FindToolBar::setWholeWord);
@@ -286,7 +285,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_regularExpressionAction->setIcon(QIcon(QLatin1String(":/find/images/regexp.png"))); m_regularExpressionAction->setIcon(QIcon(QLatin1String(":/find/images/regexp.png")));
m_regularExpressionAction->setCheckable(true); m_regularExpressionAction->setCheckable(true);
m_regularExpressionAction->setChecked(false); m_regularExpressionAction->setChecked(false);
cmd = ActionManager::registerAction(m_regularExpressionAction, Constants::REGULAR_EXPRESSIONS, globalcontext); cmd = ActionManager::registerAction(m_regularExpressionAction, Constants::REGULAR_EXPRESSIONS);
mfind->addAction(cmd, Constants::G_FIND_FLAGS); mfind->addAction(cmd, Constants::G_FIND_FLAGS);
connect(m_regularExpressionAction, &QAction::toggled, this, &FindToolBar::setRegularExpressions); connect(m_regularExpressionAction, &QAction::toggled, this, &FindToolBar::setRegularExpressions);
@@ -294,7 +293,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_preserveCaseAction->setIcon(QPixmap(QLatin1String(":/find/images/preservecase.png"))); m_preserveCaseAction->setIcon(QPixmap(QLatin1String(":/find/images/preservecase.png")));
m_preserveCaseAction->setCheckable(true); m_preserveCaseAction->setCheckable(true);
m_preserveCaseAction->setChecked(false); m_preserveCaseAction->setChecked(false);
cmd = ActionManager::registerAction(m_preserveCaseAction, Constants::PRESERVE_CASE, globalcontext); cmd = ActionManager::registerAction(m_preserveCaseAction, Constants::PRESERVE_CASE);
mfind->addAction(cmd, Constants::G_FIND_FLAGS); mfind->addAction(cmd, Constants::G_FIND_FLAGS);
connect(m_preserveCaseAction, &QAction::toggled, this, &FindToolBar::setPreserveCase); connect(m_preserveCaseAction, &QAction::toggled, this, &FindToolBar::setPreserveCase);

View File

@@ -41,6 +41,7 @@
#include <QAction> #include <QAction>
#include <QComboBox> #include <QComboBox>
#include <QCoreApplication>
#include <QDebug> #include <QDebug>
#include <QFont> #include <QFont>
#include <QLabel> #include <QLabel>
@@ -79,14 +80,17 @@ namespace Internal {
class SearchResultWindowPrivate : public QObject class SearchResultWindowPrivate : public QObject
{ {
Q_OBJECT Q_DECLARE_TR_FUNCTIONS(Core::SearchResultWindow)
public: public:
SearchResultWindowPrivate(SearchResultWindow *window); SearchResultWindowPrivate(SearchResultWindow *window, QWidget *newSearchPanel);
bool isSearchVisible() const; bool isSearchVisible() const { return m_currentIndex > 0; }
int visibleSearchIndex() const; int visibleSearchIndex() const { return m_currentIndex - 1; }
void setCurrentIndex(int index, bool focus); void setCurrentIndex(int index, bool focus);
void setCurrentIndexWithFocus(int index) { setCurrentIndex(index, true); }
void moveWidgetToTop();
void popupRequested(bool focus);
void handleExpandCollapseToolButton(bool checked);
FindPlugin *m_plugin;
SearchResultWindow *q; SearchResultWindow *q;
QList<Internal::SearchResultWidget *> m_searchResultWidgets; QList<Internal::SearchResultWidget *> m_searchResultWidgets;
QToolButton *m_expandCollapseButton; QToolButton *m_expandCollapseButton;
@@ -103,26 +107,47 @@ namespace Internal {
SearchResultColor m_color; SearchResultColor m_color;
int m_tabWidth; int m_tabWidth;
public slots:
void setCurrentIndex(int index);
void moveWidgetToTop();
void popupRequested(bool focus);
}; };
SearchResultWindowPrivate::SearchResultWindowPrivate(SearchResultWindow *window) SearchResultWindowPrivate::SearchResultWindowPrivate(SearchResultWindow *window, QWidget *nsp) :
: q(window), q(window),
m_tabWidth(8) m_expandCollapseButton(0),
m_expandCollapseAction(new QAction(tr("Expand All"), window)),
m_spacer(new QWidget),
m_historyLabel(new QLabel(tr("History:"))),
m_spacer2(new QWidget),
m_recentSearchesBox(new QComboBox),
m_widget(new QStackedWidget),
m_currentIndex(0),
m_tabWidth(8)
{ {
} m_spacer->setMinimumWidth(30);
m_spacer2->setMinimumWidth(5);
m_recentSearchesBox->setProperty("drawleftborder", true);
m_recentSearchesBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
m_recentSearchesBox->addItem(tr("New Search"));
connect(m_recentSearchesBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
this, &SearchResultWindowPrivate::setCurrentIndexWithFocus);
bool SearchResultWindowPrivate::isSearchVisible() const m_widget->setWindowTitle(q->displayName());
{
return m_currentIndex > 0; auto newSearchArea = new InternalScrollArea(m_widget);
} newSearchArea->setWidget(nsp);
newSearchArea->setFocusProxy(nsp);
m_widget->addWidget(newSearchArea);
m_expandCollapseButton = new QToolButton(m_widget);
m_expandCollapseButton->setAutoRaise(true);
m_expandCollapseAction->setCheckable(true);
m_expandCollapseAction->setIcon(QIcon(QLatin1String(":/find/images/expand.png")));
Command *cmd = ActionManager::registerAction(m_expandCollapseAction, "Find.ExpandAll");
cmd->setAttribute(Command::CA_UpdateText);
m_expandCollapseButton->setDefaultAction(cmd->action());
connect(m_expandCollapseAction, &QAction::toggled, this,
&SearchResultWindowPrivate::handleExpandCollapseToolButton);
int SearchResultWindowPrivate::visibleSearchIndex() const
{
return m_currentIndex - 1;
} }
void SearchResultWindowPrivate::setCurrentIndex(int index, bool focus) void SearchResultWindowPrivate::setCurrentIndex(int index, bool focus)
@@ -145,11 +170,6 @@ namespace Internal {
q->navigateStateChanged(); q->navigateStateChanged();
} }
void SearchResultWindowPrivate::setCurrentIndex(int index)
{
setCurrentIndex(index, true/*focus*/);
}
void SearchResultWindowPrivate::moveWidgetToTop() void SearchResultWindowPrivate::moveWidgetToTop()
{ {
SearchResultWidget *widget = qobject_cast<SearchResultWidget *>(sender()); SearchResultWidget *widget = qobject_cast<SearchResultWidget *>(sender());
@@ -277,43 +297,9 @@ SearchResultWindow *SearchResultWindow::m_instance = 0;
\internal \internal
*/ */
SearchResultWindow::SearchResultWindow(QWidget *newSearchPanel) SearchResultWindow::SearchResultWindow(QWidget *newSearchPanel)
: d(new SearchResultWindowPrivate(this)) : d(new SearchResultWindowPrivate(this, newSearchPanel))
{ {
m_instance = this; m_instance = this;
d->m_spacer = new QWidget;
d->m_spacer->setMinimumWidth(30);
d->m_historyLabel = new QLabel(tr("History:"));
d->m_spacer2 = new QWidget;
d->m_spacer2->setMinimumWidth(5);
d->m_recentSearchesBox = new QComboBox;
d->m_recentSearchesBox->setProperty("drawleftborder", true);
d->m_recentSearchesBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
d->m_recentSearchesBox->addItem(tr("New Search"));
connect(d->m_recentSearchesBox, SIGNAL(activated(int)), d, SLOT(setCurrentIndex(int)));
d->m_widget = new QStackedWidget;
d->m_widget->setWindowTitle(displayName());
InternalScrollArea *newSearchArea = new InternalScrollArea(d->m_widget);
newSearchArea->setWidget(newSearchPanel);
newSearchArea->setFocusProxy(newSearchPanel);
d->m_widget->addWidget(newSearchArea);
d->m_currentIndex = 0;
d->m_expandCollapseButton = new QToolButton(d->m_widget);
d->m_expandCollapseButton->setAutoRaise(true);
d->m_expandCollapseAction = new QAction(tr("Expand All"), this);
d->m_expandCollapseAction->setCheckable(true);
d->m_expandCollapseAction->setIcon(QIcon(QLatin1String(":/find/images/expand.png")));
Command *cmd = ActionManager::registerAction(
d->m_expandCollapseAction, "Find.ExpandAll",
Context(Constants::C_GLOBAL));
cmd->setAttribute(Command::CA_UpdateText);
d->m_expandCollapseButton->setDefaultAction(cmd->action());
connect(d->m_expandCollapseAction, SIGNAL(toggled(bool)), this, SLOT(handleExpandCollapseToolButton(bool)));
readSettings(); readSettings();
} }
@@ -401,12 +387,15 @@ SearchResult *SearchResultWindow::startNewSearch(const QString &label,
d->m_currentIndex = d->m_recentSearchesBox->count() - 1; d->m_currentIndex = d->m_recentSearchesBox->count() - 1;
} }
} }
Internal::SearchResultWidget *widget = new Internal::SearchResultWidget; auto widget = new SearchResultWidget;
d->m_searchResultWidgets.prepend(widget); d->m_searchResultWidgets.prepend(widget);
d->m_widget->insertWidget(1, widget); d->m_widget->insertWidget(1, widget);
connect(widget, SIGNAL(navigateStateChanged()), this, SLOT(navigateStateChanged())); connect(widget, &SearchResultWidget::navigateStateChanged,
connect(widget, SIGNAL(restarted()), d, SLOT(moveWidgetToTop())); this, &SearchResultWindow::navigateStateChanged);
connect(widget, SIGNAL(requestPopup(bool)), d, SLOT(popupRequested(bool))); connect(widget, &SearchResultWidget::restarted,
d, &SearchResultWindowPrivate::moveWidgetToTop);
connect(widget, &SearchResultWidget::requestPopup,
d, &SearchResultWindowPrivate::popupRequested);
widget->setTextEditorFont(d->m_font, d->m_color); widget->setTextEditorFont(d->m_font, d->m_color);
widget->setTabWidth(d->m_tabWidth); widget->setTabWidth(d->m_tabWidth);
widget->setSupportPreserveCase(preserveCaseMode == PreserveCaseEnabled); widget->setSupportPreserveCase(preserveCaseMode == PreserveCaseEnabled);
@@ -415,12 +404,12 @@ SearchResult *SearchResultWindow::startNewSearch(const QString &label,
widget->setInfo(label, toolTip, searchTerm); widget->setInfo(label, toolTip, searchTerm);
if (searchOrSearchAndReplace == SearchAndReplace) if (searchOrSearchAndReplace == SearchAndReplace)
widget->setDontAskAgainGroup(cfgGroup); widget->setDontAskAgainGroup(cfgGroup);
SearchResult *result = new SearchResult(widget); auto result = new SearchResult(widget);
d->m_searchResults.prepend(result); d->m_searchResults.prepend(result);
d->m_recentSearchesBox->insertItem(1, tr("%1 %2").arg(label, searchTerm)); d->m_recentSearchesBox->insertItem(1, tr("%1 %2").arg(label, searchTerm));
if (d->m_currentIndex > 0) if (d->m_currentIndex > 0)
++d->m_currentIndex; // so setCurrentIndex still knows about the right "currentIndex" and its widget ++d->m_currentIndex; // so setCurrentIndex still knows about the right "currentIndex" and its widget
d->setCurrentIndex(1); d->setCurrentIndexWithFocus(1);
return result; return result;
} }
@@ -509,24 +498,21 @@ void SearchResultWindow::setTabWidth(int tabWidth)
void SearchResultWindow::openNewSearchPanel() void SearchResultWindow::openNewSearchPanel()
{ {
d->setCurrentIndex(0); d->setCurrentIndexWithFocus(0);
popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus | IOutputPane::EnsureSizeHint); popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus | IOutputPane::EnsureSizeHint);
} }
/*! void SearchResultWindowPrivate::handleExpandCollapseToolButton(bool checked)
\internal
*/
void SearchResultWindow::handleExpandCollapseToolButton(bool checked)
{ {
if (!d->isSearchVisible()) if (!isSearchVisible())
return; return;
d->m_searchResultWidgets.at(d->visibleSearchIndex())->setAutoExpandResults(checked); m_searchResultWidgets.at(visibleSearchIndex())->setAutoExpandResults(checked);
if (checked) { if (checked) {
d->m_expandCollapseAction->setText(tr("Collapse All")); m_expandCollapseAction->setText(tr("Collapse All"));
d->m_searchResultWidgets.at(d->visibleSearchIndex())->expandAll(); m_searchResultWidgets.at(visibleSearchIndex())->expandAll();
} else { } else {
d->m_expandCollapseAction->setText(tr("Expand All")); m_expandCollapseAction->setText(tr("Expand All"));
d->m_searchResultWidgets.at(d->visibleSearchIndex())->collapseAll(); m_searchResultWidgets.at(visibleSearchIndex())->collapseAll();
} }
} }
@@ -612,18 +598,15 @@ bool SearchResultWindow::canNavigate() const
SearchResult::SearchResult(SearchResultWidget *widget) SearchResult::SearchResult(SearchResultWidget *widget)
: m_widget(widget) : m_widget(widget)
{ {
connect(widget, SIGNAL(activated(Core::SearchResultItem)), connect(widget, &SearchResultWidget::activated, this, &SearchResult::activated);
this, SIGNAL(activated(Core::SearchResultItem))); connect(widget, &SearchResultWidget::replaceButtonClicked,
connect(widget, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)), this, &SearchResult::replaceButtonClicked);
this, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool))); connect(widget, &SearchResultWidget::cancelled, this, &SearchResult::cancelled);
connect(widget, SIGNAL(cancelled()), connect(widget, &SearchResultWidget::paused, this, &SearchResult::paused);
this, SIGNAL(cancelled())); connect(widget, &SearchResultWidget::visibilityChanged,
connect(widget, SIGNAL(paused(bool)), this, &SearchResult::visibilityChanged);
this, SIGNAL(paused(bool))); connect(widget, &SearchResultWidget::searchAgainRequested,
connect(widget, SIGNAL(visibilityChanged(bool)), this, &SearchResult::searchAgainRequested);
this, SIGNAL(visibilityChanged(bool)));
connect(widget, SIGNAL(searchAgainRequested()),
this, SIGNAL(searchAgainRequested()));
} }
/*! /*!

View File

@@ -186,9 +186,6 @@ public:
public slots: public slots:
void clearContents(); void clearContents();
private slots:
void handleExpandCollapseToolButton(bool checked);
public: // Used by plugin, do not use public: // Used by plugin, do not use
void writeSettings(); void writeSettings();

View File

@@ -83,7 +83,8 @@ public:
QString mimeType; QString mimeType;
Utils::FileName filePath; Utils::FileName filePath;
QString displayName; QString preferredDisplayName;
QString uniqueDisplayName;
QString autoSaveName; QString autoSaveName;
InfoBar *infoBar; InfoBar *infoBar;
Id id; Id id;
@@ -128,7 +129,7 @@ bool IDocument::setContents(const QByteArray &contents)
return false; return false;
} }
Utils::FileName IDocument::filePath() const const Utils::FileName &IDocument::filePath() const
{ {
return d->filePath; return d->filePath;
} }
@@ -258,13 +259,16 @@ void IDocument::setFilePath(const Utils::FileName &filePath)
/*! /*!
Returns the string to display for this document, e.g. in the open document combo box Returns the string to display for this document, e.g. in the open document combo box
and pane. and pane.
The returned string has the following priority:
* Unique display name set by the document model
* Preferred display name set by the owner
* Base name of the document's file name
\sa setDisplayName() \sa setDisplayName()
*/ */
QString IDocument::displayName() const QString IDocument::displayName() const
{ {
if (!d->displayName.isEmpty()) return d->uniqueDisplayName.isEmpty() ? plainDisplayName() : d->uniqueDisplayName;
return d->displayName;
return d->filePath.fileName();
} }
/*! /*!
@@ -274,12 +278,30 @@ QString IDocument::displayName() const
\sa displayName() \sa displayName()
\sa filePath() \sa filePath()
*/ */
void IDocument::setDisplayName(const QString &name) void IDocument::setPreferredDisplayName(const QString &name)
{ {
if (name == d->displayName) if (name == d->preferredDisplayName)
return; return;
d->displayName = name; d->preferredDisplayName = name;
emit changed(); emit changed();
} }
/*!
\internal
Returns displayName without disambiguation.
*/
QString IDocument::plainDisplayName() const
{
return d->preferredDisplayName.isEmpty() ? d->filePath.fileName() : d->preferredDisplayName;
}
/*!
\internal
Sets unique display name for the document. Used by the document model.
*/
void IDocument::setUniqueDisplayName(const QString &name)
{
d->uniqueDisplayName = name;
}
} // namespace Core } // namespace Core

View File

@@ -89,10 +89,12 @@ public:
virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false) = 0; virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false) = 0;
virtual bool setContents(const QByteArray &contents); virtual bool setContents(const QByteArray &contents);
Utils::FileName filePath() const; const Utils::FileName &filePath() const;
virtual void setFilePath(const Utils::FileName &filePath); virtual void setFilePath(const Utils::FileName &filePath);
QString displayName() const; QString displayName() const;
void setDisplayName(const QString &name); void setPreferredDisplayName(const QString &name);
QString plainDisplayName() const;
void setUniqueDisplayName(const QString &name);
virtual bool isFileReadOnly() const; virtual bool isFileReadOnly() const;
bool isTemporary() const; bool isTemporary() const;

View File

@@ -98,8 +98,7 @@ void Locator::initialize(CorePlugin *corePlugin, const QStringList &, QString *)
m_corePlugin->addAutoReleasedObject(view); m_corePlugin->addAutoReleasedObject(view);
QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this); QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this);
Command *cmd = ActionManager::registerAction(action, Constants::LOCATE, Command *cmd = ActionManager::registerAction(action, Constants::LOCATE);
Context(Constants::C_GLOBAL));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+K"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+K")));
connect(action, &QAction::triggered, this, &Locator::openLocator); connect(action, &QAction::triggered, this, &Locator::openLocator);
connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePlaceholderText())); connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePlaceholderText()));

View File

@@ -327,8 +327,7 @@ void LocatorWidget::updateFilterList()
if (!actionCopy.contains(filterId)) { if (!actionCopy.contains(filterId)) {
// register new action // register new action
action = new QAction(filter->displayName(), this); action = new QAction(filter->displayName(), this);
cmd = ActionManager::registerAction(action, locatorId, cmd = ActionManager::registerAction(action, locatorId);
Context(Constants::C_GLOBAL));
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
connect(action, SIGNAL(triggered()), this, SLOT(filterSelected())); connect(action, SIGNAL(triggered()), this, SLOT(filterSelected()));
action->setData(qVariantFromValue(filter)); action->setData(qVariantFromValue(filter));

View File

@@ -50,10 +50,12 @@ OpenDocumentsFilter::OpenDocumentsFilter()
setPriority(High); setPriority(High);
setIncludedByDefault(true); setIncludedByDefault(true);
connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)), connect(DocumentModel::model(), &QAbstractItemModel::dataChanged,
this, SLOT(refreshInternally())); this, &OpenDocumentsFilter::refreshInternally);
connect(EditorManager::instance(), SIGNAL(editorsClosed(QList<Core::IEditor*>)), connect(DocumentModel::model(), &QAbstractItemModel::rowsInserted,
this, SLOT(refreshInternally())); this, &OpenDocumentsFilter::refreshInternally);
connect(DocumentModel::model(), &QAbstractItemModel::rowsRemoved,
this, &OpenDocumentsFilter::refreshInternally);
} }
QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future, const QString &entry_) QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future, const QString &entry_)
@@ -78,9 +80,8 @@ QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Locat
continue; continue;
QString displayName = editorEntry.displayName(); QString displayName = editorEntry.displayName();
if (regexp.exactMatch(displayName)) { if (regexp.exactMatch(displayName)) {
QFileInfo fi(fileName);
LocatorFilterEntry fiEntry(this, displayName, QString(fileName + lineNoSuffix)); LocatorFilterEntry fiEntry(this, displayName, QString(fileName + lineNoSuffix));
fiEntry.extraInfo = FileUtils::shortNativePath(FileName(fi)); fiEntry.extraInfo = FileUtils::shortNativePath(FileName::fromString(fileName));
fiEntry.fileName = fileName; fiEntry.fileName = fileName;
QList<LocatorFilterEntry> &category = displayName.startsWith(entry, caseSensitivityForPrefix) QList<LocatorFilterEntry> &category = displayName.startsWith(entry, caseSensitivityForPrefix)
? betterEntries : goodEntries; ? betterEntries : goodEntries;

View File

@@ -468,30 +468,28 @@ void MainWindow::registerDefaultActions()
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW); ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
ActionContainer *mhelp = ActionManager::actionContainer(Constants::M_HELP); ActionContainer *mhelp = ActionManager::actionContainer(Constants::M_HELP);
Context globalContext(Constants::C_GLOBAL);
// File menu separators // File menu separators
mfile->addSeparator(globalContext, Constants::G_FILE_SAVE); mfile->addSeparator(Constants::G_FILE_SAVE);
mfile->addSeparator(globalContext, Constants::G_FILE_PRINT); mfile->addSeparator(Constants::G_FILE_PRINT);
mfile->addSeparator(globalContext, Constants::G_FILE_CLOSE); mfile->addSeparator(Constants::G_FILE_CLOSE);
mfile->addSeparator(globalContext, Constants::G_FILE_OTHER); mfile->addSeparator(Constants::G_FILE_OTHER);
// Edit menu separators // Edit menu separators
medit->addSeparator(globalContext, Constants::G_EDIT_COPYPASTE); medit->addSeparator(Constants::G_EDIT_COPYPASTE);
medit->addSeparator(globalContext, Constants::G_EDIT_SELECTALL); medit->addSeparator(Constants::G_EDIT_SELECTALL);
medit->addSeparator(globalContext, Constants::G_EDIT_FIND); medit->addSeparator(Constants::G_EDIT_FIND);
medit->addSeparator(globalContext, Constants::G_EDIT_ADVANCED); medit->addSeparator(Constants::G_EDIT_ADVANCED);
// Return to editor shortcut: Note this requires Qt to fix up // Return to editor shortcut: Note this requires Qt to fix up
// handling of shortcut overrides in menus, item views, combos.... // handling of shortcut overrides in menus, item views, combos....
m_focusToEditor = new QAction(tr("Return to Editor"), this); m_focusToEditor = new QAction(tr("Return to Editor"), this);
Command *cmd = ActionManager::registerAction(m_focusToEditor, Constants::S_RETURNTOEDITOR, globalContext); Command *cmd = ActionManager::registerAction(m_focusToEditor, Constants::S_RETURNTOEDITOR);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_Escape)); cmd->setDefaultKeySequence(QKeySequence(Qt::Key_Escape));
connect(m_focusToEditor, SIGNAL(triggered()), this, SLOT(setFocusToEditor())); connect(m_focusToEditor, SIGNAL(triggered()), this, SLOT(setFocusToEditor()));
// New File Action // New File Action
QIcon icon = QIcon::fromTheme(QLatin1String("document-new"), QIcon(QLatin1String(Constants::ICON_NEWFILE))); QIcon icon = QIcon::fromTheme(QLatin1String("document-new"), QIcon(QLatin1String(Constants::ICON_NEWFILE)));
m_newAction = new QAction(icon, tr("&New File or Project..."), this); m_newAction = new QAction(icon, tr("&New File or Project..."), this);
cmd = ActionManager::registerAction(m_newAction, Constants::NEW, globalContext); cmd = ActionManager::registerAction(m_newAction, Constants::NEW);
cmd->setDefaultKeySequence(QKeySequence::New); cmd->setDefaultKeySequence(QKeySequence::New);
mfile->addAction(cmd, Constants::G_FILE_NEW); mfile->addAction(cmd, Constants::G_FILE_NEW);
connect(m_newAction, SIGNAL(triggered()), this, SLOT(newFile())); connect(m_newAction, SIGNAL(triggered()), this, SLOT(newFile()));
@@ -499,14 +497,14 @@ void MainWindow::registerDefaultActions()
// Open Action // Open Action
icon = QIcon::fromTheme(QLatin1String("document-open"), QIcon(QLatin1String(Constants::ICON_OPENFILE))); icon = QIcon::fromTheme(QLatin1String("document-open"), QIcon(QLatin1String(Constants::ICON_OPENFILE)));
m_openAction = new QAction(icon, tr("&Open File or Project..."), this); m_openAction = new QAction(icon, tr("&Open File or Project..."), this);
cmd = ActionManager::registerAction(m_openAction, Constants::OPEN, globalContext); cmd = ActionManager::registerAction(m_openAction, Constants::OPEN);
cmd->setDefaultKeySequence(QKeySequence::Open); cmd->setDefaultKeySequence(QKeySequence::Open);
mfile->addAction(cmd, Constants::G_FILE_OPEN); mfile->addAction(cmd, Constants::G_FILE_OPEN);
connect(m_openAction, SIGNAL(triggered()), this, SLOT(openFile())); connect(m_openAction, SIGNAL(triggered()), this, SLOT(openFile()));
// Open With Action // Open With Action
m_openWithAction = new QAction(tr("Open File &With..."), this); m_openWithAction = new QAction(tr("Open File &With..."), this);
cmd = ActionManager::registerAction(m_openWithAction, Constants::OPEN_WITH, globalContext); cmd = ActionManager::registerAction(m_openWithAction, Constants::OPEN_WITH);
mfile->addAction(cmd, Constants::G_FILE_OPEN); mfile->addAction(cmd, Constants::G_FILE_OPEN);
connect(m_openWithAction, SIGNAL(triggered()), this, SLOT(openFileWith())); connect(m_openWithAction, SIGNAL(triggered()), this, SLOT(openFileWith()));
@@ -520,7 +518,7 @@ void MainWindow::registerDefaultActions()
icon = QIcon::fromTheme(QLatin1String("document-save"), QIcon(QLatin1String(Constants::ICON_SAVEFILE))); icon = QIcon::fromTheme(QLatin1String("document-save"), QIcon(QLatin1String(Constants::ICON_SAVEFILE)));
QAction *tmpaction = new QAction(icon, tr("&Save"), this); QAction *tmpaction = new QAction(icon, tr("&Save"), this);
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::SAVE, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::SAVE);
cmd->setDefaultKeySequence(QKeySequence::Save); cmd->setDefaultKeySequence(QKeySequence::Save);
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
cmd->setDescription(tr("Save")); cmd->setDescription(tr("Save"));
@@ -530,7 +528,7 @@ void MainWindow::registerDefaultActions()
icon = QIcon::fromTheme(QLatin1String("document-save-as")); icon = QIcon::fromTheme(QLatin1String("document-save-as"));
tmpaction = new QAction(icon, tr("Save &As..."), this); tmpaction = new QAction(icon, tr("Save &As..."), this);
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::SAVEAS, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::SAVEAS);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+S") : QString())); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+S") : QString()));
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
cmd->setDescription(tr("Save As...")); cmd->setDescription(tr("Save As..."));
@@ -538,7 +536,7 @@ void MainWindow::registerDefaultActions()
// SaveAll Action // SaveAll Action
m_saveAllAction = new QAction(tr("Save A&ll"), this); m_saveAllAction = new QAction(tr("Save A&ll"), this);
cmd = ActionManager::registerAction(m_saveAllAction, Constants::SAVEALL, globalContext); cmd = ActionManager::registerAction(m_saveAllAction, Constants::SAVEALL);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? QString() : tr("Ctrl+Shift+S"))); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? QString() : tr("Ctrl+Shift+S")));
mfile->addAction(cmd, Constants::G_FILE_SAVE); mfile->addAction(cmd, Constants::G_FILE_SAVE);
connect(m_saveAllAction, SIGNAL(triggered()), this, SLOT(saveAll())); connect(m_saveAllAction, SIGNAL(triggered()), this, SLOT(saveAll()));
@@ -547,7 +545,7 @@ void MainWindow::registerDefaultActions()
icon = QIcon::fromTheme(QLatin1String("document-print")); icon = QIcon::fromTheme(QLatin1String("document-print"));
tmpaction = new QAction(icon, tr("&Print..."), this); tmpaction = new QAction(icon, tr("&Print..."), this);
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::PRINT, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::PRINT);
cmd->setDefaultKeySequence(QKeySequence::Print); cmd->setDefaultKeySequence(QKeySequence::Print);
mfile->addAction(cmd, Constants::G_FILE_PRINT); mfile->addAction(cmd, Constants::G_FILE_PRINT);
@@ -555,7 +553,7 @@ void MainWindow::registerDefaultActions()
icon = QIcon::fromTheme(QLatin1String("application-exit")); icon = QIcon::fromTheme(QLatin1String("application-exit"));
m_exitAction = new QAction(icon, tr("E&xit"), this); m_exitAction = new QAction(icon, tr("E&xit"), this);
m_exitAction->setMenuRole(QAction::QuitRole); m_exitAction->setMenuRole(QAction::QuitRole);
cmd = ActionManager::registerAction(m_exitAction, Constants::EXIT, globalContext); cmd = ActionManager::registerAction(m_exitAction, Constants::EXIT);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Q"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Q")));
mfile->addAction(cmd, Constants::G_FILE_OTHER); mfile->addAction(cmd, Constants::G_FILE_OTHER);
connect(m_exitAction, SIGNAL(triggered()), this, SLOT(exit())); connect(m_exitAction, SIGNAL(triggered()), this, SLOT(exit()));
@@ -563,7 +561,7 @@ void MainWindow::registerDefaultActions()
// Undo Action // Undo Action
icon = QIcon::fromTheme(QLatin1String("edit-undo"), QIcon(QLatin1String(Constants::ICON_UNDO))); icon = QIcon::fromTheme(QLatin1String("edit-undo"), QIcon(QLatin1String(Constants::ICON_UNDO)));
tmpaction = new QAction(icon, tr("&Undo"), this); tmpaction = new QAction(icon, tr("&Undo"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::UNDO, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::UNDO);
cmd->setDefaultKeySequence(QKeySequence::Undo); cmd->setDefaultKeySequence(QKeySequence::Undo);
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
cmd->setDescription(tr("Undo")); cmd->setDescription(tr("Undo"));
@@ -573,7 +571,7 @@ void MainWindow::registerDefaultActions()
// Redo Action // Redo Action
icon = QIcon::fromTheme(QLatin1String("edit-redo"), QIcon(QLatin1String(Constants::ICON_REDO))); icon = QIcon::fromTheme(QLatin1String("edit-redo"), QIcon(QLatin1String(Constants::ICON_REDO)));
tmpaction = new QAction(icon, tr("&Redo"), this); tmpaction = new QAction(icon, tr("&Redo"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::REDO, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::REDO);
cmd->setDefaultKeySequence(QKeySequence::Redo); cmd->setDefaultKeySequence(QKeySequence::Redo);
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
cmd->setDescription(tr("Redo")); cmd->setDescription(tr("Redo"));
@@ -583,7 +581,7 @@ void MainWindow::registerDefaultActions()
// Cut Action // Cut Action
icon = QIcon::fromTheme(QLatin1String("edit-cut"), QIcon(QLatin1String(Constants::ICON_CUT))); icon = QIcon::fromTheme(QLatin1String("edit-cut"), QIcon(QLatin1String(Constants::ICON_CUT)));
tmpaction = new QAction(icon, tr("Cu&t"), this); tmpaction = new QAction(icon, tr("Cu&t"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::CUT, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::CUT);
cmd->setDefaultKeySequence(QKeySequence::Cut); cmd->setDefaultKeySequence(QKeySequence::Cut);
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE); medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
@@ -591,7 +589,7 @@ void MainWindow::registerDefaultActions()
// Copy Action // Copy Action
icon = QIcon::fromTheme(QLatin1String("edit-copy"), QIcon(QLatin1String(Constants::ICON_COPY))); icon = QIcon::fromTheme(QLatin1String("edit-copy"), QIcon(QLatin1String(Constants::ICON_COPY)));
tmpaction = new QAction(icon, tr("&Copy"), this); tmpaction = new QAction(icon, tr("&Copy"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::COPY, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::COPY);
cmd->setDefaultKeySequence(QKeySequence::Copy); cmd->setDefaultKeySequence(QKeySequence::Copy);
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE); medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
@@ -599,7 +597,7 @@ void MainWindow::registerDefaultActions()
// Paste Action // Paste Action
icon = QIcon::fromTheme(QLatin1String("edit-paste"), QIcon(QLatin1String(Constants::ICON_PASTE))); icon = QIcon::fromTheme(QLatin1String("edit-paste"), QIcon(QLatin1String(Constants::ICON_PASTE)));
tmpaction = new QAction(icon, tr("&Paste"), this); tmpaction = new QAction(icon, tr("&Paste"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::PASTE, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::PASTE);
cmd->setDefaultKeySequence(QKeySequence::Paste); cmd->setDefaultKeySequence(QKeySequence::Paste);
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE); medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
@@ -607,7 +605,7 @@ void MainWindow::registerDefaultActions()
// Select All // Select All
icon = QIcon::fromTheme(QLatin1String("edit-select-all")); icon = QIcon::fromTheme(QLatin1String("edit-select-all"));
tmpaction = new QAction(icon, tr("Select &All"), this); tmpaction = new QAction(icon, tr("Select &All"), this);
cmd = ActionManager::registerAction(tmpaction, Constants::SELECTALL, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::SELECTALL);
cmd->setDefaultKeySequence(QKeySequence::SelectAll); cmd->setDefaultKeySequence(QKeySequence::SelectAll);
medit->addAction(cmd, Constants::G_EDIT_SELECTALL); medit->addAction(cmd, Constants::G_EDIT_SELECTALL);
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
@@ -615,36 +613,36 @@ void MainWindow::registerDefaultActions()
// Goto Action // Goto Action
icon = QIcon::fromTheme(QLatin1String("go-jump")); icon = QIcon::fromTheme(QLatin1String("go-jump"));
tmpaction = new QAction(icon, tr("&Go to Line..."), this); tmpaction = new QAction(icon, tr("&Go to Line..."), this);
cmd = ActionManager::registerAction(tmpaction, Constants::GOTO, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::GOTO);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+L"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+L")));
medit->addAction(cmd, Constants::G_EDIT_OTHER); medit->addAction(cmd, Constants::G_EDIT_OTHER);
tmpaction->setEnabled(false); tmpaction->setEnabled(false);
// Options Action // Options Action
mtools->appendGroup(Constants::G_TOOLS_OPTIONS); mtools->appendGroup(Constants::G_TOOLS_OPTIONS);
mtools->addSeparator(globalContext, Constants::G_TOOLS_OPTIONS); mtools->addSeparator(Constants::G_TOOLS_OPTIONS);
m_optionsAction = new QAction(tr("&Options..."), this); m_optionsAction = new QAction(tr("&Options..."), this);
m_optionsAction->setMenuRole(QAction::PreferencesRole); m_optionsAction->setMenuRole(QAction::PreferencesRole);
cmd = ActionManager::registerAction(m_optionsAction, Constants::OPTIONS, globalContext); cmd = ActionManager::registerAction(m_optionsAction, Constants::OPTIONS);
cmd->setDefaultKeySequence(QKeySequence::Preferences); cmd->setDefaultKeySequence(QKeySequence::Preferences);
mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS); mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS);
connect(m_optionsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog())); connect(m_optionsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog()));
mwindow->addSeparator(globalContext, Constants::G_WINDOW_LIST); mwindow->addSeparator(Constants::G_WINDOW_LIST);
if (UseMacShortcuts) { if (UseMacShortcuts) {
// Minimize Action // Minimize Action
QAction *minimizeAction = new QAction(tr("Minimize"), this); QAction *minimizeAction = new QAction(tr("Minimize"), this);
minimizeAction->setEnabled(false); // actual implementation in WindowSupport minimizeAction->setEnabled(false); // actual implementation in WindowSupport
cmd = ActionManager::registerAction(minimizeAction, Constants::MINIMIZE_WINDOW, globalContext); cmd = ActionManager::registerAction(minimizeAction, Constants::MINIMIZE_WINDOW);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+M"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+M")));
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
// Zoom Action // Zoom Action
QAction *zoomAction = new QAction(tr("Zoom"), this); QAction *zoomAction = new QAction(tr("Zoom"), this);
zoomAction->setEnabled(false); // actual implementation in WindowSupport zoomAction->setEnabled(false); // actual implementation in WindowSupport
cmd = ActionManager::registerAction(zoomAction, Constants::ZOOM_WINDOW, globalContext); cmd = ActionManager::registerAction(zoomAction, Constants::ZOOM_WINDOW);
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
} }
@@ -652,29 +650,29 @@ void MainWindow::registerDefaultActions()
QAction *toggleFullScreenAction = new QAction(tr("Full Screen"), this); QAction *toggleFullScreenAction = new QAction(tr("Full Screen"), this);
toggleFullScreenAction->setCheckable(!HostOsInfo::isMacHost()); toggleFullScreenAction->setCheckable(!HostOsInfo::isMacHost());
toggleFullScreenAction->setEnabled(false); // actual implementation in WindowSupport toggleFullScreenAction->setEnabled(false); // actual implementation in WindowSupport
cmd = ActionManager::registerAction(toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext); cmd = ActionManager::registerAction(toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11"))); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11")));
if (HostOsInfo::isMacHost()) if (HostOsInfo::isMacHost())
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
if (UseMacShortcuts) { if (UseMacShortcuts) {
mwindow->addSeparator(globalContext, Constants::G_WINDOW_SIZE); mwindow->addSeparator(Constants::G_WINDOW_SIZE);
QAction *closeAction = new QAction(tr("Close Window"), this); QAction *closeAction = new QAction(tr("Close Window"), this);
closeAction->setEnabled(false); closeAction->setEnabled(false);
cmd = ActionManager::registerAction(closeAction, Constants::CLOSE_WINDOW, globalContext); cmd = ActionManager::registerAction(closeAction, Constants::CLOSE_WINDOW);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Meta+W"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Meta+W")));
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
mwindow->addSeparator(globalContext, Constants::G_WINDOW_SIZE); mwindow->addSeparator(Constants::G_WINDOW_SIZE);
} }
// Show Sidebar Action // Show Sidebar Action
m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Constants::ICON_TOGGLE_SIDEBAR)), m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Constants::ICON_TOGGLE_SIDEBAR)),
tr(Constants::TR_SHOW_SIDEBAR), this); tr(Constants::TR_SHOW_SIDEBAR), this);
m_toggleSideBarAction->setCheckable(true); m_toggleSideBarAction->setCheckable(true);
cmd = ActionManager::registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR, globalContext); cmd = ActionManager::registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR);
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+0") : tr("Alt+0"))); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+0") : tr("Alt+0")));
connect(m_toggleSideBarAction, &QAction::triggered, this, &MainWindow::setSidebarVisible); connect(m_toggleSideBarAction, &QAction::triggered, this, &MainWindow::setSidebarVisible);
@@ -685,7 +683,7 @@ void MainWindow::registerDefaultActions()
// Show Mode Selector Action // Show Mode Selector Action
m_toggleModeSelectorAction = new QAction(tr("Show Mode Selector"), this); m_toggleModeSelectorAction = new QAction(tr("Show Mode Selector"), this);
m_toggleModeSelectorAction->setCheckable(true); m_toggleModeSelectorAction->setCheckable(true);
cmd = ActionManager::registerAction(m_toggleModeSelectorAction, Constants::TOGGLE_MODE_SELECTOR, globalContext); cmd = ActionManager::registerAction(m_toggleModeSelectorAction, Constants::TOGGLE_MODE_SELECTOR);
connect(m_toggleModeSelectorAction, &QAction::triggered, ModeManager::instance(), &ModeManager::setModeSelectorVisible); connect(m_toggleModeSelectorAction, &QAction::triggered, ModeManager::instance(), &ModeManager::setModeSelectorVisible);
mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS); mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS);
@@ -695,9 +693,9 @@ void MainWindow::registerDefaultActions()
mviews->menu()->setTitle(tr("&Views")); mviews->menu()->setTitle(tr("&Views"));
// "Help" separators // "Help" separators
mhelp->addSeparator(globalContext, Constants::G_HELP_SUPPORT); mhelp->addSeparator(Constants::G_HELP_SUPPORT);
if (!HostOsInfo::isMacHost()) if (!HostOsInfo::isMacHost())
mhelp->addSeparator(globalContext, Constants::G_HELP_ABOUT); mhelp->addSeparator(Constants::G_HELP_ABOUT);
// About IDE Action // About IDE Action
icon = QIcon::fromTheme(QLatin1String("help-about")); icon = QIcon::fromTheme(QLatin1String("help-about"));
@@ -706,7 +704,7 @@ void MainWindow::registerDefaultActions()
else else
tmpaction = new QAction(icon, tr("About &Qt Creator..."), this); tmpaction = new QAction(icon, tr("About &Qt Creator..."), this);
tmpaction->setMenuRole(QAction::AboutRole); tmpaction->setMenuRole(QAction::AboutRole);
cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_QTCREATOR, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_QTCREATOR);
mhelp->addAction(cmd, Constants::G_HELP_ABOUT); mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
tmpaction->setEnabled(true); tmpaction->setEnabled(true);
connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutQtCreator); connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutQtCreator);
@@ -714,13 +712,13 @@ void MainWindow::registerDefaultActions()
//About Plugins Action //About Plugins Action
tmpaction = new QAction(tr("About &Plugins..."), this); tmpaction = new QAction(tr("About &Plugins..."), this);
tmpaction->setMenuRole(QAction::ApplicationSpecificRole); tmpaction->setMenuRole(QAction::ApplicationSpecificRole);
cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_PLUGINS, globalContext); cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_PLUGINS);
mhelp->addAction(cmd, Constants::G_HELP_ABOUT); mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
tmpaction->setEnabled(true); tmpaction->setEnabled(true);
connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutPlugins); connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutPlugins);
// About Qt Action // About Qt Action
// tmpaction = new QAction(tr("About &Qt..."), this); // tmpaction = new QAction(tr("About &Qt..."), this);
// cmd = ActionManager::registerAction(tmpaction, Constants:: ABOUT_QT, globalContext); // cmd = ActionManager::registerAction(tmpaction, Constants:: ABOUT_QT);
// mhelp->addAction(cmd, Constants::G_HELP_ABOUT); // mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
// tmpaction->setEnabled(true); // tmpaction->setEnabled(true);
// connect(tmpaction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); // connect(tmpaction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
@@ -728,7 +726,7 @@ void MainWindow::registerDefaultActions()
if (!HostOsInfo::isMacHost()) { // doesn't have the "About" actions in the Help menu if (!HostOsInfo::isMacHost()) { // doesn't have the "About" actions in the Help menu
tmpaction = new QAction(this); tmpaction = new QAction(this);
tmpaction->setSeparator(true); tmpaction->setSeparator(true);
cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About", globalContext); cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About");
mhelp->addAction(cmd, Constants::G_HELP_ABOUT); mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
} }
} }

View File

@@ -180,7 +180,7 @@ void ModeManager::objectAdded(QObject *obj)
// Register mode shortcut // Register mode shortcut
const Id actionId = mode->id().withPrefix("QtCreator.Mode."); const Id actionId = mode->id().withPrefix("QtCreator.Mode.");
QAction *action = new QAction(tr("Switch to <b>%1</b> mode").arg(mode->displayName()), this); QAction *action = new QAction(tr("Switch to <b>%1</b> mode").arg(mode->displayName()), this);
Command *cmd = ActionManager::registerAction(action, actionId, Context(Constants::C_GLOBAL)); Command *cmd = ActionManager::registerAction(action, actionId);
d->m_modeCommands.insert(index, cmd); d->m_modeCommands.insert(index, cmd);
connect(cmd, SIGNAL(keySequenceChanged()), m_instance, SLOT(updateModeToolTip())); connect(cmd, SIGNAL(keySequenceChanged()), m_instance, SLOT(updateModeToolTip()));

View File

@@ -203,7 +203,6 @@ static inline int paneShortCut(int number)
void OutputPaneManager::init() void OutputPaneManager::init()
{ {
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW); ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
const Context globalContext(Constants::C_GLOBAL);
// Window->Output Panes // Window->Output Panes
ActionContainer *mpanes = ActionManager::createMenu(Constants::M_WINDOW_PANES); ActionContainer *mpanes = ActionManager::createMenu(Constants::M_WINDOW_PANES);
@@ -214,21 +213,21 @@ void OutputPaneManager::init()
Command *cmd; Command *cmd;
cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear", globalContext); cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear");
m_clearButton->setDefaultAction(cmd->action()); m_clearButton->setDefaultAction(cmd->action());
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalContext); cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem");
cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6"))); cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6")));
m_prevToolButton->setDefaultAction(cmd->action()); m_prevToolButton->setDefaultAction(cmd->action());
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalContext); cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem");
m_nextToolButton->setDefaultAction(cmd->action()); m_nextToolButton->setDefaultAction(cmd->action());
cmd->setDefaultKeySequence(QKeySequence(tr("F6"))); cmd->setDefaultKeySequence(QKeySequence(tr("F6")));
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalContext); cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax");
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+9") : tr("Alt+9"))); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+9") : tr("Alt+9")));
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
cmd->setAttribute(Command::CA_UpdateIcon); cmd->setAttribute(Command::CA_UpdateIcon);
@@ -236,7 +235,7 @@ void OutputPaneManager::init()
connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax())); connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
m_minMaxButton->setDefaultAction(cmd->action()); m_minMaxButton->setDefaultAction(cmd->action());
mpanes->addSeparator(globalContext, "Coreplugin.OutputPane.ActionsGroup"); mpanes->addSeparator("Coreplugin.OutputPane.ActionsGroup");
QFontMetrics titleFm = m_titleLabel->fontMetrics(); QFontMetrics titleFm = m_titleLabel->fontMetrics();
int minTitleWidth = 0; int minTitleWidth = 0;
@@ -278,7 +277,7 @@ void OutputPaneManager::init()
suffix.remove(QLatin1Char(' ')); suffix.remove(QLatin1Char(' '));
const Id id = baseId.withSuffix(suffix); const Id id = baseId.withSuffix(suffix);
QAction *action = new QAction(outPane->displayName(), this); QAction *action = new QAction(outPane->displayName(), this);
Command *cmd = ActionManager::registerAction(action, id, globalContext); Command *cmd = ActionManager::registerAction(action, id);
mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup"); mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
m_actions.append(action); m_actions.append(action);

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