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:
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:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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 string name: "Calculator"
property string description: "his demo shows how to write a simple calculator application in QML and JavaScript."
property string imageSource: "http://qt-project.org/doc/qt-4.8/images/qml-calculator-example-small.png"
property string imageSource: "http://doc.qt.io/qt-4.8/images/qml-calculator-example-small.png"
}
}

View File

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

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
void Bind::enumerator(EnumeratorAST *ast, Enum *symbol)
@@ -528,12 +546,21 @@ void Bind::enumerator(EnumeratorAST *ast, Enum *symbol)
EnumeratorDeclaration *e = control()->newEnumeratorDeclaration(ast->identifier_token, name);
e->setType(control()->integerType(IntegerType::Int)); // ### introduce IntegerType::Enumerator
if (ExpressionAST *expr = ast->expression)
e->setConstantValue(asStringLiteral(expr->firstToken(), expr->lastToken()));
else if (!symbol->isEmpty())
if (ExpressionAST *expr = ast->expression) {
const int firstToken = expr->firstToken();
const int lastToken = expr->lastToken();
const StringLiteral *constantValue = asStringLiteral(firstToken, lastToken);
const StringLiteral *resolvedValue = 0;
if (lastToken - firstToken == 1) {
if (const Identifier *constantId = identifier(firstToken))
resolvedValue = valueOfEnumerator(symbol, constantId);
}
e->setConstantValue(resolvedValue ? resolvedValue : constantValue);
} else if (!symbol->isEmpty()) {
calculateConstantValue(*(symbol->memberEnd()-1), e, control());
else
} else {
e->setConstantValue(control()->stringLiteral("0", 1));
}
symbol->addMember(e);
}

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[2] == 'g') {
if (s[3] == 'n') {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -61,7 +61,7 @@ public:
protected:
ClassOrNamespace *findClass(const FullySpecifiedType &ty, Scope *scope,
ClassOrNamespace* enclosingTemplateInstantiation = 0) const;
ClassOrNamespace *enclosingBinding = 0) const;
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,
unsigned utf16charsOffset,
int state,
bool qtMocRunEnabled)
const LanguageFeatures &languageFeatures)
{
// FIXME: Check default values.
LanguageFeatures features;
features.qtMocRunEnabled = qtMocRunEnabled;
features.qtEnabled = qtMocRunEnabled;
features.qtKeywordsEnabled = qtMocRunEnabled;
features.objCEnabled = qtMocRunEnabled;
features.cxx11Enabled = qtMocRunEnabled;
SimpleLexer tokenize;
tokenize.setLanguageFeatures(features);
tokenize.setLanguageFeatures(languageFeatures);
const QVector<Token> tokens = tokenize(text, state);
const int tokenIdx = tokenAt(tokens, utf16charsOffset);
return (tokenIdx == -1) ? Token() : tokens.at(tokenIdx);

View File

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

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
// they're independent.
QRectF outer(QPointF(qFloor(left * parentState->scale()), top),
QPointF(qCeil(right * parentState->scale()), top + height));
QRectF outer(QPointF(left * parentState->scale(), top),
QPointF(right * parentState->scale(), top + height));
float scaleConversion = parentState->scale() / spacing;
float missing = 3.0 - outer.width() / scaleConversion;

View File

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

View File

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

View File

@@ -175,12 +175,16 @@ MimeType MimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileName
// Extension is unknown, or matches multiple mimetypes.
// Pass 2) Match on content, if we can read the data
const bool openedByUs = !device->isOpen() && device->open(QIODevice::ReadOnly);
if (device->isOpen()) {
// Read 16K in one go (QIODEVICE_BUFFERSIZE in qiodevice_p.h).
// This is much faster than seeking back and forth into QIODevice.
const QByteArray data = device->peek(16384);
if (openedByUs)
device->close();
int magicAccuracy = 0;
MimeType candidateByData(findByData(data, &magicAccuracy));
@@ -319,8 +323,11 @@ QString MimeDatabase::allFiltersString(QString *allFilesFilter)
{
MimeDatabase mdb;
QSet<QString> uniqueFilters;
foreach (const MimeType &mt, mdb.allMimeTypes())
foreach (const MimeType &mt, mdb.allMimeTypes()) {
const QString &filterString = mt.filterString();
if (!filterString.isEmpty())
uniqueFilters.insert(mt.filterString());
}
QStringList filters;
foreach (const QString &filter, uniqueFilters)
filters.append(filter);
@@ -345,79 +352,6 @@ QStringList MimeDatabase::allGlobPatterns()
return patterns;
}
static MimeType mimeForName(const QList<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;
Returns a MIME type for \a nameOrAlias or an invalid one if none found.
@@ -485,7 +419,6 @@ MimeType MimeDatabase::mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode
int priority = 0;
switch (mode) {
case MatchDefault:
file.open(QIODevice::ReadOnly); // isOpen() will be tested by method below
return d->mimeTypeForFileNameAndData(fileInfo.absoluteFilePath(), &file, &priority);
case MatchExtension:
locker.unlock();
@@ -655,10 +588,7 @@ MimeType MimeDatabase::mimeTypeForUrl(const QUrl &url) const
MimeType MimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device) const
{
int accuracy = 0;
const bool openedByUs = !device->isOpen() && device->open(QIODevice::ReadOnly);
const MimeType result = d->mimeTypeForFileNameAndData(fileName, device, &accuracy);
if (openedByUs)
device->close();
return result;
}

View File

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

View File

@@ -719,38 +719,6 @@ QStringList MimeXMLProvider::findByFileName(const QString &fileName, QString *fo
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)
{
ensureLoaded();
@@ -769,30 +737,6 @@ MimeType MimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr)
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> > result;

View File

@@ -75,8 +75,6 @@ public:
virtual void loadGenericIcon(MimeTypePrivate &) {}
// 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 void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns) = 0;
virtual void setMagicRulesForMimeType(const MimeType &mimeType, const QMap<int, QList<MimeMagicRule> > &rules) = 0;
@@ -158,8 +156,6 @@ public:
// Qt Creator additions
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);
void setGlobPatternsForMimeType(const MimeType &mimeType, const QStringList &patterns);
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
{
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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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
a trigger of the actual action is forwarded to the registered QAction
for the currently active context.
If the optional \a context argument is not specified, the global context
will be assumed.
A scriptable action can be called from a script without the need for the user
to interact with it.
*/
@@ -384,8 +386,8 @@ void ActionManager::setContext(const Context &context)
\internal
*/
ActionManagerPrivate::ActionManagerPrivate()
: m_presentationModeEnabled(false)
ActionManagerPrivate::ActionManagerPrivate() :
m_presentationModeEnabled(false)
{
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -244,7 +244,7 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<ExternalT
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);
}
action->setText(tool->displayName());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -180,7 +180,7 @@ void ModeManager::objectAdded(QObject *obj)
// Register mode shortcut
const Id actionId = mode->id().withPrefix("QtCreator.Mode.");
QAction *action = new QAction(tr("Switch to <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);
connect(cmd, SIGNAL(keySequenceChanged()), m_instance, SLOT(updateModeToolTip()));

View File

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

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