Merge remote-tracking branch 'origin/2.8'

This commit is contained in:
Eike Ziller
2013-05-24 16:22:08 +02:00
126 changed files with 2480 additions and 1039 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -494,23 +494,26 @@
coordinates of an item, or \l{Setting Anchors and Margins}{anchor} it to coordinates of an item, or \l{Setting Anchors and Margins}{anchor} it to
its parent and sibling items. its parent and sibling items.
\section2 Snap to Margins \section2 Snapping to Parent and Sibling Items
When you are working on a design, you can use snap and guides to align When you are working on a design, you can use snapping to align
items on the canvas. Click the items on the canvas. Click the
\inlineimage qmldesigner-snap-to-guides-button.png \inlineimage qmldesigner-snap-to-guides-button.png
button to have the items snap to the guides. button to have the items snap to their parent or sibling items. Snapping
lines automatically appear to help you position the items.
Click the \inlineimage qmldesigner-snap-to-anchors-button.png
button to anchor the item to the items that you snap to.
Choose \gui {Tools > Options > Qt Quick > Qt Quick Designer} to specify Choose \gui {Tools > Options > Qt Quick > Qt Quick Designer} to specify
settings for snap to settings for snapping. In the \gui {Parent item padding} field, specify the
margins. In the \gui {Snap margin} field, specify the position of the guides distance in pixels between the parent item and the snapping lines. In the
as pixels from the edge of the canvas. In the \gui {Item spacing} field, \gui {Sibling item spacing} field, specify the distance in pixels between
specify the space in pixels to leave between items on the screen. sibling items and the snapping lines.
The following image shows the position of the guides when \gui {Snap margin} The following image shows the snapping lines when \gui {Parent item padding}
is set to 5 pixels. is set to 5 pixels.
\image qmldesigner-snap-margins.png "Snap margins on canvas" \image qmldesigner-snap-margins.png "Snapping lines on canvas"
\section2 Hiding Item Boundaries \section2 Hiding Item Boundaries

View File

@@ -1507,6 +1507,13 @@ class Dumper:
#print('data=[' + locals + sep + watchers + ']\n') #print('data=[' + locals + sep + watchers + ']\n')
def templateArgument(self, typeobj, position):
return templateArgument(typeobj, position)
def numericTemplateArgument(self, typeobj, position):
return numericTemplateArgument(typeobj, position)
def lookupType(self, typeName): def lookupType(self, typeName):
return lookupType(typeName) return lookupType(typeName)

View File

@@ -3,29 +3,22 @@ import atexit
import binascii import binascii
import inspect import inspect
import os import os
import platform
import threading import threading
import select import select
import sys import sys
import subprocess import subprocess
uname = platform.uname()[0] proc = subprocess.Popen(args=[sys.argv[1], "-P"], stdout=subprocess.PIPE)
if uname == 'Linux': path = proc.stdout.read().strip()
# /data/dev/llvm-git-2/build/lib/python2.7/site-packages #sys.path.append(path)
proc = subprocess.Popen(args=[sys.argv[1], "-P"], stdout=subprocess.PIPE) sys.path.insert(1, path)
path = proc.stdout.read().strip()
sys.path.append(path)
else:
base = '/Applications/Xcode.app/Contents/'
sys.path.append(base + 'SharedFrameworks/LLDB.framework/Resources/Python')
sys.path.append(base + 'Library/PrivateFrameworks/LLDB.framework/Resources/Python')
import lldb import lldb
cdbLoaded = False cdbLoaded = False
lldbLoaded = True
gdbLoaded = False gdbLoaded = False
lldbLoaded = True
# Encodings. Keep that synchronized with DebuggerEncoding in watchutils.h # Encodings. Keep that synchronized with DebuggerEncoding in watchutils.h
Unencoded8Bit, \ Unencoded8Bit, \
@@ -95,9 +88,6 @@ qqEditable = {}
# This keeps canonical forms of the typenames, without array indices etc. # This keeps canonical forms of the typenames, without array indices etc.
qqStripForFormat = {} qqStripForFormat = {}
def templateArgument(typeobj, index):
return typeobj.GetTemplateArgumentType(index)
def directBaseClass(typeobj, index = 0): def directBaseClass(typeobj, index = 0):
return typeobj.GetDirectBaseClassAtIndex(index) return typeobj.GetDirectBaseClassAtIndex(index)
@@ -275,7 +265,7 @@ def impl_SBValue__add__(self, offset):
pass pass
else: else:
offset = offset.GetValueAsSigned() offset = offset.GetValueAsSigned()
itemsize = self.GetType().GetDereferencedType().GetByteSize() itemsize = self.GetType().GetPointeeType().GetByteSize()
address = self.GetValueAsUnsigned() + offset * itemsize address = self.GetValueAsUnsigned() + offset * itemsize
address = address & 0xFFFFFFFFFFFFFFFF # Force unsigned address = address & 0xFFFFFFFFFFFFFFFF # Force unsigned
return createPointerValue(self, address, self.GetType().GetPointeeType()) return createPointerValue(self, address, self.GetType().GetPointeeType())
@@ -289,8 +279,8 @@ def impl_SBValue__sub__(self, other):
address = address & 0xFFFFFFFFFFFFFFFF # Force unsigned address = address & 0xFFFFFFFFFFFFFFFF # Force unsigned
return self.CreateValueFromAddress(None, address, self.GetType()) return self.CreateValueFromAddress(None, address, self.GetType())
if other.GetType().IsPointerType(): if other.GetType().IsPointerType():
itemsize = self.GetType().GetDereferencedType().GetByteSize() itemsize = self.GetType().GetPointeeType().GetByteSize()
return (int(self) - int(other)) / itemsize return (self.GetValueAsUnsigned() - other.GetValueAsUnsigned()) / itemsize
raise RuntimeError("SBValue.__sub__ not implemented: %s" % self.GetType()) raise RuntimeError("SBValue.__sub__ not implemented: %s" % self.GetType())
return NotImplemented return NotImplemented
@@ -440,8 +430,14 @@ class Children:
class SubItem: class SubItem:
def __init__(self, d, component): def __init__(self, d, component):
self.d = d self.d = d
self.iname = "%s.%s" % (d.currentIName, component) if isinstance(component, lldb.SBValue):
self.name = component # Avoid $$__synth__ suffix on Mac.
value = component
value.SetPreferSyntheticValue(False)
self.name = value.GetName()
else:
self.name = component
self.iname = "%s.%s" % (d.currentIName, self.name)
def __enter__(self): def __enter__(self):
self.d.put('{') self.d.put('{')
@@ -527,6 +523,45 @@ class Dumper:
self.charPtrType_ = None self.charPtrType_ = None
self.voidType_ = None self.voidType_ = None
def extractTemplateArgument(self, typename, index):
level = 0
skipSpace = False
inner = ""
for c in typename[typename.find('<') + 1 : -1]:
if c == '<':
inner += c
level += 1
elif c == '>':
level -= 1
inner += c
elif c == ',':
if level == 0:
if index == 0:
return inner
index -= 1
inner = ""
else:
inner += c
skipSpace = True
else:
if skipSpace and c == ' ':
pass
else:
inner += c
skipSpace = False
return inner
def templateArgument(self, typeobj, index):
type = typeobj.GetTemplateArgumentType(index)
if len(type.GetName()):
return type
inner = self.extractTemplateArgument(typeobj.GetName(), index)
return self.lookupType(inner)
def numericTemplateArgument(self, typeobj, index):
inner = self.extractTemplateArgument(typeobj.GetName(), index)
return int(inner)
def intType(self): def intType(self):
if self.intType_ is None: if self.intType_ is None:
self.intType_ = self.target.GetModuleAtIndex(0).FindFirstType('int') self.intType_ = self.target.GetModuleAtIndex(0).FindFirstType('int')
@@ -692,15 +727,14 @@ class Dumper:
self.report(self.describeError(error)) self.report(self.describeError(error))
def currentThread(self): def currentThread(self):
#return self.process.GetSelectedThread() return self.process.GetSelectedThread()
return self.process.GetThreadAtIndex(0)
def currentFrame(self): def currentFrame(self):
return self.currentThread().GetSelectedFrame() return self.currentThread().GetSelectedFrame()
def reportLocation(self): def reportLocation(self):
thread = self.currentThread() thread = self.currentThread()
frame = thread.GetFrameAtIndex(0) frame = thread.GetSelectedFrame()
file = fileName(frame.line_entry.file) file = fileName(frame.line_entry.file)
line = frame.line_entry.line line = frame.line_entry.line
self.report('location={file="%s",line="%s",addr="%s"}' % (file, line, frame.pc)) self.report('location={file="%s",line="%s",addr="%s"}' % (file, line, frame.pc))
@@ -732,7 +766,9 @@ class Dumper:
self.report('msg="No process"') self.report('msg="No process"')
else: else:
thread = self.currentThread() thread = self.currentThread()
result = 'stack={current-thread="%s",frames=[' % thread.GetThreadID() result = 'stack={current-frame="%s"' % thread.GetSelectedFrame().GetFrameID()
result += ',current-thread="%s"' % thread.GetThreadID()
result += ',frames=['
n = thread.GetNumFrames() n = thread.GetNumFrames()
if n > 4: if n > 4:
n = 4 n = 4
@@ -742,7 +778,7 @@ class Dumper:
result += '{pc="0x%x"' % frame.GetPC() result += '{pc="0x%x"' % frame.GetPC()
result += ',level="%d"' % frame.idx result += ',level="%d"' % frame.idx
result += ',addr="0x%x"' % frame.GetPCAddress().GetLoadAddress(self.target) result += ',addr="0x%x"' % frame.GetPCAddress().GetLoadAddress(self.target)
result += ',func="%s"' % frame.GetFunction().GetName() result += ',func="%s"' % frame.GetFunctionName()
result += ',line="%d"' % lineEntry.GetLine() result += ',line="%d"' % lineEntry.GetLine()
result += ',fullname="%s"' % fileName(lineEntry.file) result += ',fullname="%s"' % fileName(lineEntry.file)
result += ',usable="1"' result += ',usable="1"'
@@ -825,9 +861,7 @@ class Dumper:
typeName = value.GetTypeName() typeName = value.GetTypeName()
# Handle build-in LLDB visualizers if wanted. # Handle build-in LLDB visualizers if wanted.
hasSynth = hasattr(value, 'SetPreferSyntheticValue') if self.useLldbDumpers and value.GetTypeSynthetic().IsValid():
if self.useLldbDumpers and hasSynth and value.GetTypeSynthetic().IsValid():
# FIXME: print "official" summary? # FIXME: print "official" summary?
summary = value.GetTypeSummary() summary = value.GetTypeSummary()
if summary.IsValid(): if summary.IsValid():
@@ -852,8 +886,7 @@ class Dumper:
return return
# Our turf now. # Our turf now.
if hasSynth: value.SetPreferSyntheticValue(False)
value.SetPreferSyntheticValue(False)
# References # References
if value.GetType().IsReferenceType(): if value.GetType().IsReferenceType():
@@ -897,7 +930,7 @@ class Dumper:
n = 10000 n = 10000
for i in xrange(n): for i in xrange(n):
child = value.GetChildAtIndex(i) child = value.GetChildAtIndex(i)
with SubItem(self, child.GetName()): with SubItem(self, child):
self.putItem(child) self.putItem(child)
def reportVariables(self, _ = None): def reportVariables(self, _ = None):
@@ -905,7 +938,7 @@ class Dumper:
self.currentIName = "local" self.currentIName = "local"
self.put('data=[') self.put('data=[')
for value in frame.GetVariables(True, True, False, False): for value in frame.GetVariables(True, True, False, False):
with SubItem(self, value.GetName()): with SubItem(self, value):
self.put('iname="%s",' % self.currentIName) self.put('iname="%s",' % self.currentIName)
self.putItem(value) self.putItem(value)
self.put(']') self.put(']')
@@ -1136,7 +1169,7 @@ class Dumper:
self.currentThread().StepOver() self.currentThread().StepOver()
def executeNextI(self, _ = None): def executeNextI(self, _ = None):
self.currentThread().StepOver() self.currentThread().StepInstruction(lldb.eOnlyThisThread)
def executeStep(self, _ = None): def executeStep(self, _ = None):
self.currentThread().StepInto() self.currentThread().StepInto()
@@ -1145,10 +1178,10 @@ class Dumper:
self.debugger.Terminate() self.debugger.Terminate()
def executeStepI(self, _ = None): def executeStepI(self, _ = None):
self.currentThread().StepInstOver() self.currentThread().StepInstruction(lldb.eOnlyThisThread)
def executeStepOut(self, _ = None): def executeStepOut(self, _ = None):
self.debugger.HandleCommand("thread step-out") self.currentThread().StepOut()
def executeRunToLine(self, args): def executeRunToLine(self, args):
file = args['file'] file = args['file']
@@ -1165,8 +1198,9 @@ class Dumper:
self.report('success="%d",output="%s",error="%s"' self.report('success="%d",output="%s",error="%s"'
% (result.Succeeded(), result.GetOutput(), result.GetError())) % (result.Succeeded(), result.GetOutput(), result.GetError()))
def activateFrame(self, frame): def activateFrame(self, args):
self.handleCommand("frame select " + frame) self.currentThread().SetSelectedFrame(args['index'])
self.reportData()
def selectThread(self, thread): def selectThread(self, thread):
self.handleCommand("thread select " + thread) self.handleCommand("thread select " + thread)

View File

@@ -439,7 +439,7 @@ def qdump__QFiniteStack(d, value):
d.putItemCount(size) d.putItemCount(size)
d.putNumChild(size) d.putNumChild(size)
if d.isExpanded(): if d.isExpanded():
innerType = templateArgument(value.type, 0) innerType = d.templateArgument(value.type, 0)
d.putArrayData(innerType, value["_array"], size) d.putArrayData(innerType, value["_array"], size)
# Stock gdb 7.2 seems to have a problem with types here: # Stock gdb 7.2 seems to have a problem with types here:
@@ -467,7 +467,7 @@ def qdump__QFiniteStack(d, value):
def qdump__QFlags(d, value): def qdump__QFlags(d, value):
i = value["i"] i = value["i"]
try: try:
enumType = templateArgument(value.type.unqualified(), 0) enumType = d.templateArgument(value.type.unqualified(), 0)
d.putValue("%s (%s)" % (i.cast(enumType), i)) d.putValue("%s (%s)" % (i.cast(enumType), i))
except: except:
d.putValue("%s" % i) d.putValue("%s" % i)
@@ -506,8 +506,8 @@ def qdump__QHash(d, value):
bucket += 1 bucket += 1
return node return node
keyType = templateArgument(value.type, 0) keyType = d.templateArgument(value.type, 0)
valueType = templateArgument(value.type, 1) valueType = d.templateArgument(value.type, 1)
d_ptr = value["d"] d_ptr = value["d"]
e_ptr = value["e"] e_ptr = value["e"]
@@ -542,8 +542,8 @@ def qdump__QHash(d, value):
def qdump__QHashNode(d, value): def qdump__QHashNode(d, value):
keyType = templateArgument(value.type, 0) keyType = d.templateArgument(value.type, 0)
valueType = templateArgument(value.type, 1) valueType = d.templateArgument(value.type, 1)
key = value["key"] key = value["key"]
val = value["value"] val = value["value"]
@@ -563,8 +563,8 @@ def qdump__QHashNode(d, value):
def qHashIteratorHelper(d, value): def qHashIteratorHelper(d, value):
typeName = str(value.type) typeName = str(value.type)
hashType = d.lookupType(typeName[0:typeName.rfind("::")]) hashType = d.lookupType(typeName[0:typeName.rfind("::")])
keyType = templateArgument(hashType, 0) keyType = d.templateArgument(hashType, 0)
valueType = templateArgument(hashType, 1) valueType = d.templateArgument(hashType, 1)
d.putNumChild(1) d.putNumChild(1)
d.putEmptyValue() d.putEmptyValue()
if d.isExpanded(): if d.isExpanded():
@@ -608,7 +608,7 @@ def qdump__QList(d, value):
check(size >= 0) check(size >= 0)
checkRef(private["ref"]) checkRef(private["ref"])
innerType = templateArgument(value.type, 0) innerType = d.templateArgument(value.type, 0)
d.putItemCount(size) d.putItemCount(size)
d.putNumChild(size) d.putNumChild(size)
@@ -702,7 +702,7 @@ def qdump__QLinkedList(d, value):
d.putItemCount(n) d.putItemCount(n)
d.putNumChild(n) d.putNumChild(n)
if d.isExpanded(): if d.isExpanded():
innerType = templateArgument(value.type, 0) innerType = d.templateArgument(value.type, 0)
with Children(d, n, maxNumChild=1000, childType=innerType): with Children(d, n, maxNumChild=1000, childType=innerType):
p = e_ptr["n"] p = e_ptr["n"]
for i in d.childRange(): for i in d.childRange():
@@ -772,8 +772,8 @@ def qdumpHelper__Qt4_QMap(d, value, forceLong):
if n > 10000: if n > 10000:
n = 10000 n = 10000
keyType = templateArgument(value.type, 0) keyType = d.templateArgument(value.type, 0)
valueType = templateArgument(value.type, 1) valueType = d.templateArgument(value.type, 1)
isCompact = mapCompact(d.currentItemFormat(), keyType, valueType) isCompact = mapCompact(d.currentItemFormat(), keyType, valueType)
it = e_ptr["forward"].dereference() it = e_ptr["forward"].dereference()
@@ -820,8 +820,8 @@ def qdumpHelper__Qt5_QMap(d, value, forceLong):
if n > 10000: if n > 10000:
n = 10000 n = 10000
keyType = templateArgument(value.type, 0) keyType = d.templateArgument(value.type, 0)
valueType = templateArgument(value.type, 1) valueType = d.templateArgument(value.type, 1)
isCompact = mapCompact(d.currentItemFormat(), keyType, valueType) isCompact = mapCompact(d.currentItemFormat(), keyType, valueType)
nodeType = d.lookupType(d.ns + "QMapNode<%s, %s>" % (keyType, valueType)) nodeType = d.lookupType(d.ns + "QMapNode<%s, %s>" % (keyType, valueType))
if isCompact: if isCompact:
@@ -1110,7 +1110,7 @@ def qdump__QObject(d, value):
pp = 0 pp = 0
with Children(d): with Children(d):
vectorType = connections.type.target().fields()[0].type vectorType = connections.type.target().fields()[0].type
innerType = templateArgument(vectorType, 0) innerType = d.templateArgument(vectorType, 0)
# Should check: innerType == ns::QObjectPrivate::ConnectionList # Should check: innerType == ns::QObjectPrivate::ConnectionList
p = gdb.Value(connections["p"]["array"]).cast(innerType.pointer()) p = gdb.Value(connections["p"]["array"]).cast(innerType.pointer())
for i in xrange(connectionListCount): for i in xrange(connectionListCount):
@@ -1459,7 +1459,7 @@ def qdump__QSet(d, value):
bucket += 1 bucket += 1
return node return node
keyType = templateArgument(value.type, 0) keyType = d.templateArgument(value.type, 0)
d_ptr = value["q_hash"]["d"] d_ptr = value["q_hash"]["d"]
e_ptr = value["q_hash"]["e"] e_ptr = value["q_hash"]["e"]
@@ -1505,7 +1505,7 @@ def qdump__QSharedDataPointer(d, value):
# This replaces the pointer by the pointee, making the # This replaces the pointer by the pointee, making the
# pointer transparent. # pointer transparent.
try: try:
innerType = templateArgument(value.type, 0) innerType = d.templateArgument(value.type, 0)
except: except:
d.putValue(d_ptr) d.putValue(d_ptr)
d.putPlainChildren(value) d.putPlainChildren(value)
@@ -1851,7 +1851,7 @@ def qedit__QVector(expr, value):
ob = gdb.parse_and_eval(expr) ob = gdb.parse_and_eval(expr)
cmd = "call (%s).resize(%d)" % (expr, len(values)) cmd = "call (%s).resize(%d)" % (expr, len(values))
gdb.execute(cmd) gdb.execute(cmd)
innerType = templateArgument(ob.type, 0) innerType = d.templateArgument(ob.type, 0)
ptr = ob["p"]["array"].cast(d.voidPtrType()) ptr = ob["p"]["array"].cast(d.voidPtrType())
cmd = "set {%s[%d]}%s={%s}" % (innerType, len(values), long(ptr), value) cmd = "set {%s[%d]}%s={%s}" % (innerType, len(values), long(ptr), value)
gdb.execute(cmd) gdb.execute(cmd)
@@ -1866,7 +1866,7 @@ def qdump__QVector(d, value):
checkRef(private["ref"]) checkRef(private["ref"])
alloc = int(private["alloc"]) alloc = int(private["alloc"])
size = int(private["size"]) size = int(private["size"])
innerType = templateArgument(value.type, 0) innerType = d.templateArgument(value.type, 0)
try: try:
# Qt 5. Will fail on Qt 4 due to the missing 'offset' member. # Qt 5. Will fail on Qt 4 due to the missing 'offset' member.
offset = private["offset"] offset = private["offset"]
@@ -1909,7 +1909,7 @@ def qdump__QWeakPointer(d, value):
d.putNumChild(3) d.putNumChild(3)
if d.isExpanded(): if d.isExpanded():
with Children(d): with Children(d):
innerType = templateArgument(value.type, 0) innerType = d.templateArgument(value.type, 0)
d.putSubItem("data", val.dereference().cast(innerType)) d.putSubItem("data", val.dereference().cast(innerType))
d.putIntItem("weakref", weakref) d.putIntItem("weakref", weakref)
d.putIntItem("strongref", strongref) d.putIntItem("strongref", strongref)
@@ -1962,16 +1962,16 @@ def qdump____c_style_array__(d, value):
def qdump__std__array(d, value): def qdump__std__array(d, value):
size = numericTemplateArgument(value.type, 1) size = d.numericTemplateArgument(value.type, 1)
d.putItemCount(size) d.putItemCount(size)
d.putNumChild(size) d.putNumChild(size)
if d.isExpanded(): if d.isExpanded():
innerType = templateArgument(value.type, 0) innerType = d.templateArgument(value.type, 0)
d.putArrayData(innerType, value.address, size) d.putArrayData(innerType, value.address, size)
def qdump__std__complex(d, value): def qdump__std__complex(d, value):
innerType = templateArgument(value.type, 0) innerType = d.templateArgument(value.type, 0)
base = value.address.cast(innerType.pointer()) base = value.address.cast(innerType.pointer())
real = base.dereference() real = base.dereference()
imag = (base + 1).dereference() imag = (base + 1).dereference()
@@ -2032,7 +2032,7 @@ def qdump__std__list(d, value):
if d.isExpanded(): if d.isExpanded():
p = node["_M_next"] p = node["_M_next"]
innerType = templateArgument(value.type, 0) innerType = d.templateArgument(value.type, 0)
with Children(d, size, maxNumChild=1000, childType=innerType): with Children(d, size, maxNumChild=1000, childType=innerType):
for i in d.childRange(): for i in d.childRange():
innerPointer = innerType.pointer() innerPointer = innerType.pointer()
@@ -2051,16 +2051,16 @@ def qdump__std__map(d, value):
d.putNumChild(size) d.putNumChild(size)
if d.isExpanded(): if d.isExpanded():
keyType = templateArgument(value.type, 0) keyType = d.templateArgument(value.type, 0)
valueType = templateArgument(value.type, 1) valueType = d.templateArgument(value.type, 1)
try: try:
# Does not work on gcc 4.4, the allocator type (fourth template # Does not work on gcc 4.4, the allocator type (fourth template
# argument) seems not to be available. # argument) seems not to be available.
pairType = templateArgument(templateArgument(value.type, 3), 0) pairType = d.templateArgument(d.templateArgument(value.type, 3), 0)
pairPointer = pairType.pointer() pairPointer = pairType.pointer()
except: except:
# So use this as workaround: # So use this as workaround:
pairType = templateArgument(impl.type, 1) pairType = d.templateArgument(impl.type, 1)
pairPointer = pairType.pointer() pairPointer = pairType.pointer()
isCompact = mapCompact(d.currentItemFormat(), keyType, valueType) isCompact = mapCompact(d.currentItemFormat(), keyType, valueType)
innerType = pairType innerType = pairType
@@ -2106,7 +2106,7 @@ def stdTreeIteratorHelper(d, value):
d.putNumChild(1) d.putNumChild(1)
d.putEmptyValue() d.putEmptyValue()
if d.isExpanded(): if d.isExpanded():
dataType = templateArgument(value.type, 0) dataType = d.templateArgument(value.type, 0)
nodeType = d.lookupType("std::_Rb_tree_node<%s>" % dataType) nodeType = d.lookupType("std::_Rb_tree_node<%s>" % dataType)
data = pnode.cast(nodeType.pointer()).dereference()["_M_value_field"] data = pnode.cast(nodeType.pointer()).dereference()["_M_value_field"]
with Children(d): with Children(d):
@@ -2154,7 +2154,7 @@ def qdump__std__set(d, value):
d.putItemCount(size) d.putItemCount(size)
d.putNumChild(size) d.putNumChild(size)
if d.isExpanded(): if d.isExpanded():
valueType = templateArgument(value.type, 0) valueType = d.templateArgument(value.type, 0)
node = impl["_M_header"]["_M_left"] node = impl["_M_header"]["_M_left"]
with Children(d, size, maxNumChild=1000, childType=valueType): with Children(d, size, maxNumChild=1000, childType=valueType):
for i in d.childRange(): for i in d.childRange():
@@ -2182,7 +2182,7 @@ def qform__std__string():
def qdump__std__string(d, value): def qdump__std__string(d, value):
data = value["_M_dataplus"]["_M_p"] data = value["_M_dataplus"]["_M_p"]
baseType = value.type.strip_typedefs() baseType = value.type.strip_typedefs()
charSize = templateArgument(baseType, 0).sizeof charSize = d.templateArgument(baseType, 0).sizeof
# We can't lookup the std::string::_Rep type without crashing LLDB, # We can't lookup the std::string::_Rep type without crashing LLDB,
# so hard-code assumption on member position # so hard-code assumption on member position
# struct { size_type _M_length, size_type _M_capacity, int _M_refcount; } # struct { size_type _M_length, size_type _M_capacity, int _M_refcount; }
@@ -2225,7 +2225,7 @@ def qdump__std__shared_ptr(d, value):
d.putNumChild(0) d.putNumChild(0)
return return
if isSimpleType(templateArgument(value.type, 0)): if isSimpleType(d.templateArgument(value.type, 0)):
d.putValue("%s @0x%x" % (i.dereference(), long(i))) d.putValue("%s @0x%x" % (i.dereference(), long(i)))
else: else:
i = expensiveDowncast(i) i = expensiveDowncast(i)
@@ -2246,7 +2246,7 @@ def qdump__std__unique_ptr(d, value):
d.putNumChild(0) d.putNumChild(0)
return return
if isSimpleType(templateArgument(value.type, 0)): if isSimpleType(d.templateArgument(value.type, 0)):
d.putValue("%s @0x%x" % (i.dereference(), long(i))) d.putValue("%s @0x%x" % (i.dereference(), long(i)))
else: else:
i = expensiveDowncast(i) i = expensiveDowncast(i)
@@ -2261,7 +2261,7 @@ def qedit__std__vector(expr, value):
values = value.split(',') values = value.split(',')
n = len(values) n = len(values)
ob = gdb.parse_and_eval(expr) ob = gdb.parse_and_eval(expr)
innerType = templateArgument(ob.type, 0) innerType = d.templateArgument(ob.type, 0)
cmd = "set $d = (%s*)calloc(sizeof(%s)*%s,1)" % (innerType, innerType, n) cmd = "set $d = (%s*)calloc(sizeof(%s)*%s,1)" % (innerType, innerType, n)
gdb.execute(cmd) gdb.execute(cmd)
cmd = "set {void*[3]}%s = {$d, $d+%s, $d+%s}" % (ob.address, n, n) cmd = "set {void*[3]}%s = {$d, $d+%s, $d+%s}" % (ob.address, n, n)
@@ -2271,7 +2271,7 @@ def qedit__std__vector(expr, value):
def qdump__std__vector(d, value): def qdump__std__vector(d, value):
impl = value["_M_impl"] impl = value["_M_impl"]
type = templateArgument(value.type, 0) type = d.templateArgument(value.type, 0)
alloc = impl["_M_end_of_storage"] alloc = impl["_M_end_of_storage"]
isBool = str(type) == 'bool' isBool = str(type) == 'bool'
if isBool: if isBool:
@@ -2332,7 +2332,7 @@ def qdump____gnu_cxx__hash_set(d, value):
check(0 <= size and size <= 1000 * 1000 * 1000) check(0 <= size and size <= 1000 * 1000 * 1000)
d.putItemCount(size) d.putItemCount(size)
d.putNumChild(size) d.putNumChild(size)
type = templateArgument(value.type, 0) type = d.templateArgument(value.type, 0)
d.putType("__gnu__cxx::hash_set<%s>" % type) d.putType("__gnu__cxx::hash_set<%s>" % type)
if d.isExpanded(): if d.isExpanded():
with Children(d, size, maxNumChild=1000, childType=type): with Children(d, size, maxNumChild=1000, childType=type):
@@ -2359,8 +2359,8 @@ def qdump____gnu_cxx__hash_set(d, value):
####################################################################### #######################################################################
def qdump__boost__bimaps__bimap(d, value): def qdump__boost__bimaps__bimap(d, value):
leftType = templateArgument(value.type, 0) leftType = d.templateArgument(value.type, 0)
rightType = templateArgument(value.type, 1) rightType = d.templateArgument(value.type, 1)
size = value["core"]["node_count"] size = value["core"]["node_count"]
d.putItemCount(size) d.putItemCount(size)
d.putNumChild(size) d.putNumChild(size)
@@ -2374,7 +2374,7 @@ def qdump__boost__optional(d, value):
d.putNumChild(0) d.putNumChild(0)
else: else:
d.putBetterType(value.type) d.putBetterType(value.type)
type = templateArgument(value.type, 0) type = d.templateArgument(value.type, 0)
storage = value["m_storage"] storage = value["m_storage"]
if type.code == ReferenceCode: if type.code == ReferenceCode:
d.putItem(storage.cast(type.target().pointer()).dereference()) d.putItem(storage.cast(type.target().pointer()).dereference())
@@ -2717,12 +2717,12 @@ def qdump__CPlusPlus__Internal__PPToken(d, value):
# return "Transposed" # return "Transposed"
def qdump__Eigen__Matrix(d, value): def qdump__Eigen__Matrix(d, value):
innerType = templateArgument(value.type, 0) innerType = d.templateArgument(value.type, 0)
storage = value["m_storage"] storage = value["m_storage"]
options = numericTemplateArgument(value.type, 3) options = d.numericTemplateArgument(value.type, 3)
rowMajor = (int(options) & 0x1) rowMajor = (int(options) & 0x1)
argRow = numericTemplateArgument(value.type, 1) argRow = d.numericTemplateArgument(value.type, 1)
argCol = numericTemplateArgument(value.type, 2) argCol = d.numericTemplateArgument(value.type, 2)
nrows = value["m_storage"]["m_rows"] if argRow == -1 else int(argRow) nrows = value["m_storage"]["m_rows"] if argRow == -1 else int(argRow)
ncols = value["m_storage"]["m_cols"] if argCol == -1 else int(argCol) ncols = value["m_storage"]["m_cols"] if argCol == -1 else int(argCol)
p = storage["m_data"] p = storage["m_data"]

View File

@@ -52,6 +52,24 @@ QObject *QuickWindowNodeInstance::parent() const
return 0; return 0;
} }
QImage QuickWindowNodeInstance::renderImage() const
{
/*
Since the content item transucient
we just fill an image with the window color
*/
QRectF renderBoundingRect = boundingRect();
QImage renderImage(renderBoundingRect.size().toSize(), QImage::Format_ARGB32_Premultiplied);
QPalette palette;
renderImage.fill(palette.color(QPalette::Window).rgba());
return renderImage;
}
QuickWindowNodeInstance::Pointer QuickWindowNodeInstance::create(QObject *object) QuickWindowNodeInstance::Pointer QuickWindowNodeInstance::create(QObject *object)
{ {
QQuickWindow *quickWindow = qobject_cast<QQuickWindow*>(object); QQuickWindow *quickWindow = qobject_cast<QQuickWindow*>(object);

View File

@@ -62,7 +62,7 @@ public:
bool isAnchoredBySibling() const Q_DECL_OVERRIDE; bool isAnchoredBySibling() const Q_DECL_OVERRIDE;
QImage renderImage() const Q_DECL_OVERRIDE;
protected: protected:
QuickWindowNodeInstance(QQuickWindow*); QuickWindowNodeInstance(QQuickWindow*);

View File

@@ -33,9 +33,13 @@ import Bauhaus 1.0
QFrame { QFrame {
styleSheetFile: "switch.css"; styleSheetFile: "switch.css";
property variant specialModeIcon; property variant specialModeIcon;
property bool showLayoutModeButton: true
property bool showExtendedModeButton: true
specialModeIcon: "images/standard.png"; specialModeIcon: "images/standard.png";
maximumWidth: 300; maximumWidth: 300;
minimumWidth: 300; minimumWidth: 300;
layout: QHBoxLayout { layout: QHBoxLayout {
topMargin: 0; topMargin: 0;
bottomMargin: 0; bottomMargin: 0;
@@ -58,6 +62,9 @@ QFrame {
extendedPane.visible = false; extendedPane.visible = false;
layoutPane.visible = false; layoutPane.visible = false;
} }
Component.onCompleted: {
standardMode.checked = true;
}
} }
QPushButton { QPushButton {
@@ -66,6 +73,7 @@ QFrame {
checked: false; checked: false;
toolTip: qsTr("Layout"); toolTip: qsTr("Layout");
text: qsTr("Layout"); text: qsTr("Layout");
visible: showLayoutModeButton
onClicked: { onClicked: {
extendedMode.checked = false; extendedMode.checked = false;
standardMode.checked = false; standardMode.checked = false;
@@ -82,6 +90,7 @@ QFrame {
checkable: true; checkable: true;
checked: false; checked: false;
text: qsTr("Advanced") text: qsTr("Advanced")
visible: showExtendedModeButton
onClicked: { onClicked: {
standardMode.checked = false; standardMode.checked = false;
layoutMode.checked = false; layoutMode.checked = false;

View File

@@ -0,0 +1,141 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
import QtQuick 1.0
import Bauhaus 1.0
import HelperWidgets 1.0
PropertyFrame {
id: frame;
x: 0
y: 0
ExpressionEditor {
id: expressionEdit
}
layout: QVBoxLayout {
topMargin: 0;
bottomMargin: 0;
leftMargin: 0;
rightMargin: 0;
spacing: 0;
Type {
}
Geometry {
}
HorizontalWhiteLine {
maximumHeight: 4;
styleSheet: "QLineEdit {border: 2px solid #707070; min-height: 0px; max-height: 0px;}";
}
HorizontalWhiteLine {
}
Switches {
showLayoutModeButton: false
showExtendedModeButton: false
}
ScrollArea {
styleSheetFile: ":/qmldesigner/scrollbar.css";
widgetResizable: true;
finished: finishedNotify;
horizontalScrollBarPolicy: "Qt::ScrollBarAlwaysOff";
id: standardPane;
QFrame {
//minimumHeight: 1100
id: properyEditorStandard
layout: QVBoxLayout {
topMargin: 0;
bottomMargin: 0;
leftMargin: 0;
rightMargin: 0;
spacing: 0;
QWidget {
layout: QVBoxLayout {
topMargin: 0
bottomMargin: 0
leftMargin: 0
rightMargin: 0
spacing: 0
GroupBox {
finished: finishedNotify;
caption: qsTr("Window")
layout: VerticalLayout {
// Qt namespace enums not supported by the rewriter
// QWidget {
// layout: HorizontalLayout {
// Label {
// text: qsTr("Modality")
// }
// ComboBox {
// baseStateFlag: isBaseState
// items : { ["Qt.NonModal", "Qt.WindowModal", "Qt.ApplicationModal"] }
// currentText: backendValues.modality.value;
// onItemsChanged: {
// currentText = backendValues.modality.value;
// }
// backendValue: backendValues.modality
// }
// }
// } //QWidget
QWidget {
layout: HorizontalLayout {
Label {
text: qsTr("Title")
}
LineEdit {
backendValue: backendValues.title
baseStateFlag: isBaseState;
translation: true
}
}
}
}
}
}
}
QScrollArea {
}
} // layout
} //QWidget
} //QScrollArea
ScrollArea {
}
}
}

View File

@@ -3,6 +3,7 @@ import QtQuick.Controls 1.0
import QtQuick.Window 2.0 import QtQuick.Window 2.0
ApplicationWindow { ApplicationWindow {
title: qsTr("Hello World")
width: 640 width: 640
height: 480 height: 480

View File

@@ -175,6 +175,14 @@ protected:
virtual bool visit(Block *symbol) virtual bool visit(Block *symbol)
{ return process(symbol); } { return process(symbol); }
virtual bool visit(Template *symbol)
{
if (symbol->declaration() && symbol->declaration()->isFunction())
return process(symbol);
else
return true;
}
// Objective-C // Objective-C
virtual bool visit(ObjCBaseClass *) { return false; } virtual bool visit(ObjCBaseClass *) { return false; }
virtual bool visit(ObjCBaseProtocol *) { return false; } virtual bool visit(ObjCBaseProtocol *) { return false; }

View File

@@ -249,17 +249,19 @@ QList<LookupItem> LookupContext::lookupByUsing(const Name *name, Scope *scope) c
if (name->isNameId()) { if (name->isNameId()) {
for (unsigned i = 0, count = scope->memberCount(); i < count; ++i) { for (unsigned i = 0, count = scope->memberCount(); i < count; ++i) {
if (UsingDeclaration *u = scope->memberAt(i)->asUsingDeclaration()) { if (UsingDeclaration *u = scope->memberAt(i)->asUsingDeclaration()) {
if (const QualifiedNameId *q = u->name()->asQualifiedNameId()) { if (const Name *usingDeclarationName = u->name()) {
if (q->name()->isEqualTo(name)) { if (const QualifiedNameId *q = usingDeclarationName->asQualifiedNameId()) {
candidates = bindings()->globalNamespace()->find(q); if (q->name() && q->name()->isEqualTo(name)) {
candidates = bindings()->globalNamespace()->find(q);
// if it is not a global scope(scope of scope is not equal 0) // if it is not a global scope(scope of scope is not equal 0)
// then add current using declaration as a candidate // then add current using declaration as a candidate
if (scope->scope()) { if (scope->scope()) {
LookupItem item; LookupItem item;
item.setDeclaration(u); item.setDeclaration(u);
item.setScope(scope); item.setScope(scope);
candidates.append(item); candidates.append(item);
}
} }
} }
} }
@@ -328,9 +330,11 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
} }
} else if (UsingDeclaration *ud = m->asUsingDeclaration()) { } else if (UsingDeclaration *ud = m->asUsingDeclaration()) {
if (name->isNameId()) { if (name->isNameId()) {
if (const QualifiedNameId *q = ud->name()->asQualifiedNameId()) { if (const Name *usingDeclarationName = ud->name()) {
if (q->name()->isEqualTo(name)) { if (const QualifiedNameId *q = usingDeclarationName->asQualifiedNameId()) {
return bindings()->globalNamespace()->lookupType(q); if (q->name() && q->name()->isEqualTo(name)) {
return bindings()->globalNamespace()->lookupType(q);
}
} }
} }
@@ -688,6 +692,16 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
item.setType(ty); // override the type. item.setType(ty); // override the type.
} }
// instantiate function template
if (name->isTemplateNameId() && s->isTemplate() && s->asTemplate()->declaration()
&& s->asTemplate()->declaration()->isFunction()) {
const TemplateNameId *instantiation = name->asTemplateNameId();
Template *specialization = s->asTemplate();
Symbol *instantiatedFunctionTemplate = instantiateTemplateFunction(instantiation,
specialization);
item.setType(instantiatedFunctionTemplate->type()); // override the type.
}
result->append(item); result->append(item);
} }
} }
@@ -1599,3 +1613,29 @@ bool CreateBindings::visit(ObjCMethod *)
return false; return false;
} }
Symbol *CreateBindings::instantiateTemplateFunction(const TemplateNameId *instantiation,
Template *specialization) const
{
const unsigned argumentCountOfInitialization = instantiation->templateArgumentCount();
const unsigned argumentCountOfSpecialization = specialization->templateParameterCount();
Clone cloner(_control.data());
Subst subst(_control.data());
for (unsigned i = 0; i < argumentCountOfSpecialization; ++i) {
const TypenameArgument *tParam
= specialization->templateParameterAt(i)->asTypenameArgument();
if (!tParam)
continue;
const Name *name = tParam->name();
if (!name)
continue;
FullySpecifiedType ty = (i < argumentCountOfInitialization) ?
instantiation->templateArgumentAt(i):
cloner.type(tParam->type(), &subst);
subst.bind(cloner.name(name, &subst), ty);
}
return cloner.symbol(specialization, &subst);
}

View File

@@ -253,6 +253,9 @@ protected:
virtual bool visit(ObjCMethod *); virtual bool visit(ObjCMethod *);
private: private:
Symbol *instantiateTemplateFunction(const TemplateNameId *instantiation,
Template *specialization) const;
Snapshot _snapshot; Snapshot _snapshot;
QSharedPointer<Control> _control; QSharedPointer<Control> _control;
QSet<Namespace *> _processed; QSet<Namespace *> _processed;

View File

@@ -697,6 +697,14 @@ bool ResolveExpression::visit(CallAST *ast)
// Constructor call // Constructor call
FullySpecifiedType ctorTy = control()->namedType(classTy->name()); FullySpecifiedType ctorTy = control()->namedType(classTy->name());
addResult(ctorTy, scope); addResult(ctorTy, scope);
} else if (Template *templateTy = ty->asTemplateType()) {
// template function
if (Symbol *declaration = templateTy->declaration()) {
if (Function *funTy = declaration->asFunction()) {
if (maybeValidPrototype(funTy, actualArgumentCount))
addResult(funTy->returnType().simplified(), scope);
}
}
} }
} }
@@ -938,6 +946,18 @@ private:
ClassOrNamespace *_binding; ClassOrNamespace *_binding;
}; };
static bool isTypeTypedefed(const FullySpecifiedType &originalTy,
const FullySpecifiedType &typedefedTy)
{
return ! originalTy.isEqualTo(typedefedTy);
}
static bool areOriginalAndTypedefedTypePointer(const FullySpecifiedType &originalTy,
const FullySpecifiedType &typedefedTy)
{
return originalTy->isPointerType() && typedefedTy->isPointerType();
}
ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &baseResults, ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &baseResults,
int accessOp, int accessOp,
bool *replacedDotOperator) const bool *replacedDotOperator) const
@@ -1027,23 +1047,12 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
} }
} else if (accessOp == T_DOT) { } else if (accessOp == T_DOT) {
if (replacedDotOperator) { if (replacedDotOperator) {
*replacedDotOperator = originalType->isPointerType() || ty->isPointerType(); if (! isTypeTypedefed(originalType, ty)
// replace . with -> || ! areOriginalAndTypedefedTypePointer(originalType, ty)) {
if (PointerType *ptrTy = originalType->asPointerType()) { *replacedDotOperator = originalType->isPointerType() || ty->isPointerType();
// case when original type is a pointer and if (PointerType *ptrTy = ty->asPointerType()) {
// typedef is for type ty = ptrTy->elementType();
// e.g.: }
// typedef S SType;
// SType *p;
ty = ptrTy->elementType();
}
else if (PointerType *ptrTy = ty->asPointerType()) {
// case when original type is a type and
// typedef is for pointer of type
// e.g.:
// typedef S* SPTR;
// SPTR p;
ty = ptrTy->elementType();
} }
} }

View File

@@ -123,7 +123,7 @@ protected:
private: private:
Scope *_scope; Scope *_scope;
LookupContext _context; const LookupContext& _context;
Bind bind; Bind bind;
QList<LookupItem> _results; QList<LookupItem> _results;
bool _reference; bool _reference;

View File

@@ -190,16 +190,18 @@ void AndroidDeployStep::cleanLibsOnDevice()
+ arguments.join(QLatin1String(" ")), + arguments.join(QLatin1String(" ")),
Core::MessageManager::NoModeSwitch); Core::MessageManager::NoModeSwitch);
process->start(adb, arguments); process->start(adb, arguments);
if (!process->waitForStarted(500))
delete process;
} }
void AndroidDeployStep::cleanLibsFinished() void AndroidDeployStep::cleanLibsFinished()
{ {
QProcess *process = qobject_cast<QProcess *>(sender()); QProcess *process = qobject_cast<QProcess *>(sender());
if (!process) QTC_ASSERT(process, return);
return;
Core::MessageManager::instance()->printToOutputPane(QString::fromLocal8Bit(process->readAll()), Core::MessageManager::NoModeSwitch); Core::MessageManager::instance()->printToOutputPane(QString::fromLocal8Bit(process->readAll()), Core::MessageManager::NoModeSwitch);
Core::MessageManager::instance()->printToOutputPane(tr("adb finished with exit code %1.").arg(process->exitCode()), Core::MessageManager::instance()->printToOutputPane(tr("adb finished with exit code %1.").arg(process->exitCode()),
Core::MessageManager::NoModeSwitch); Core::MessageManager::NoModeSwitch);
process->deleteLater();
} }
void AndroidDeployStep::setDeployAction(AndroidDeployStep::AndroidDeployAction deploy) void AndroidDeployStep::setDeployAction(AndroidDeployStep::AndroidDeployAction deploy)

View File

@@ -757,7 +757,7 @@ QStringList AndroidManager::availablePrebundledLibs(ProjectExplorer::Target *tar
foreach (Qt4ProjectManager::Qt4ProFileNode *node, qt4Project->allProFiles()) foreach (Qt4ProjectManager::Qt4ProFileNode *node, qt4Project->allProFiles())
if (node->projectType() == Qt4ProjectManager::LibraryTemplate) if (node->projectType() == Qt4ProjectManager::LibraryTemplate)
libs << QLatin1String("lib") + node->targetInformation().target + QLatin1String(".so"); libs << node->targetInformation().target;
return libs; return libs;
} }

View File

@@ -290,14 +290,6 @@ void AndroidPackageCreationStep::checkRequiredLibraries()
parseSharedLibs(readelfProc.readAll(), &libs); parseSharedLibs(readelfProc.readAll(), &libs);
AndroidManager::setQtLibs(target(), requiredLibraries(AndroidManager::availableQtLibsWithDependencies(target()), AndroidManager::setQtLibs(target(), requiredLibraries(AndroidManager::availableQtLibsWithDependencies(target()),
AndroidManager::qtLibs(target()), libs)); AndroidManager::qtLibs(target()), libs));
QStringList checkedLibs = AndroidManager::prebundledLibs(target());
QStringList prebundledLibraries;
foreach (const QString &qtLib, AndroidManager::availableQtLibs(target())) {
if (libs.contains(qtLib) || checkedLibs.contains(qtLib))
prebundledLibraries << qtLib;
}
AndroidManager::setPrebundledLibs(target(), prebundledLibraries);
emit updateRequiredLibrariesModels(); emit updateRequiredLibrariesModels();
} }
@@ -348,14 +340,6 @@ void AndroidPackageCreationStep::checkRequiredLibrariesForRun()
QMetaObject::invokeMethod(this, "getBundleInformation"); QMetaObject::invokeMethod(this, "getBundleInformation");
QStringList prebundledLibraries;
foreach (const AndroidManager::Library &qtLib, m_availableQtLibs) {
if (libs.contains(qtLib.name) || m_prebundledLibs.contains(qtLib.name))
prebundledLibraries << qtLib.name;
}
QMetaObject::invokeMethod(this, "setPrebundledLibs", Qt::BlockingQueuedConnection,
Q_ARG(QStringList, prebundledLibraries));
emit updateRequiredLibrariesModels(); emit updateRequiredLibrariesModels();
} }

View File

@@ -70,34 +70,23 @@ using namespace Bazaar::Internal;
using namespace Bazaar; using namespace Bazaar;
static const VcsBase::VcsBaseEditorParameters editorParameters[] = { static const VcsBase::VcsBaseEditorParameters editorParameters[] = {
{ { VcsBase::LogOutput, // type
VcsBase::RegularCommandOutput, //type Constants::FILELOG_ID, // id
Constants::COMMANDLOG_ID, // id Constants::FILELOG_DISPLAY_NAME, // display name
Constants::COMMANDLOG_DISPLAY_NAME, // display name Constants::FILELOG, // context
Constants::COMMANDLOG, // context Constants::LOGAPP}, // mime type
Constants::COMMANDAPP, // mime type
Constants::COMMANDEXT}, //extension
{ VcsBase::LogOutput,
Constants::FILELOG_ID,
Constants::FILELOG_DISPLAY_NAME,
Constants::FILELOG,
Constants::LOGAPP,
Constants::LOGEXT},
{ VcsBase::AnnotateOutput, { VcsBase::AnnotateOutput,
Constants::ANNOTATELOG_ID, Constants::ANNOTATELOG_ID,
Constants::ANNOTATELOG_DISPLAY_NAME, Constants::ANNOTATELOG_DISPLAY_NAME,
Constants::ANNOTATELOG, Constants::ANNOTATELOG,
Constants::ANNOTATEAPP, Constants::ANNOTATEAPP},
Constants::ANNOTATEEXT},
{ VcsBase::DiffOutput, { VcsBase::DiffOutput,
Constants::DIFFLOG_ID, Constants::DIFFLOG_ID,
Constants::DIFFLOG_DISPLAY_NAME, Constants::DIFFLOG_DISPLAY_NAME,
Constants::DIFFLOG, Constants::DIFFLOG,
Constants::DIFFAPP, Constants::DIFFAPP}
Constants::DIFFEXT}
}; };
static const VcsBase::VcsBaseSubmitEditorParameters submitEditorParameters = { static const VcsBase::VcsBaseSubmitEditorParameters submitEditorParameters = {

View File

@@ -46,34 +46,25 @@ const char CHANGESET_ID_EXACT[] = "([.0-9]+)";
const char ANNOTATE_CHANGESET_ID[] = "([.0-9]+)"; const char ANNOTATE_CHANGESET_ID[] = "([.0-9]+)";
// Base editor parameters // Base editor parameters
const char COMMANDLOG_ID[] = "Bazaar Command Log Editor";
const char COMMANDLOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar Command Log Editor");
const char COMMANDLOG[] = "Bazaar Command Log Editor";
const char COMMANDAPP[] = "application/vnd.nokia.text.scs_bazaar_commandlog";
const char COMMANDEXT[] = "vcsBazaarCommand";
const char FILELOG_ID[] = "Bazaar File Log Editor"; const char FILELOG_ID[] = "Bazaar File Log Editor";
const char FILELOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar File Log Editor"); const char FILELOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar File Log Editor");
const char FILELOG[] = "Bazaar File Log Editor"; const char FILELOG[] = "Bazaar File Log Editor";
const char LOGAPP[] = "application/vnd.nokia.text.scs_bazaar_log"; const char LOGAPP[] = "text/vnd.qtcreator.bazaar.log";
const char LOGEXT[] = "vcsBazaarLog";
const char ANNOTATELOG_ID[] = "Bazaar Annotation Editor"; const char ANNOTATELOG_ID[] = "Bazaar Annotation Editor";
const char ANNOTATELOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar Annotation Editor"); const char ANNOTATELOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar Annotation Editor");
const char ANNOTATELOG[] = "Bazaar Annotation Editor"; const char ANNOTATELOG[] = "Bazaar Annotation Editor";
const char ANNOTATEAPP[] = "application/vnd.nokia.text.scs_bazaar_annotatelog"; const char ANNOTATEAPP[] = "text/vnd.qtcreator.bazaar.annotation";
const char ANNOTATEEXT[] = "vcsBazaarAnnotate";
const char DIFFLOG_ID[] = "Bazaar Diff Editor"; const char DIFFLOG_ID[] = "Bazaar Diff Editor";
const char DIFFLOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar Diff Editor"); const char DIFFLOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar Diff Editor");
const char DIFFLOG[] = "Bazaar Diff Editor"; const char DIFFLOG[] = "Bazaar Diff Editor";
const char DIFFAPP[] = "text/x-patch"; const char DIFFAPP[] = "text/x-patch";
const char DIFFEXT[] = "diff";
// Submit editor parameters // Submit editor parameters
const char COMMIT_ID[] = "Bazaar Commit Log Editor"; const char COMMIT_ID[] = "Bazaar Commit Log Editor";
const char COMMIT_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar Commit Log Editor"); const char COMMIT_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar Commit Log Editor");
const char COMMITMIMETYPE[] = "application/vnd.nokia.text.scs_bazaar_commitlog"; const char COMMITMIMETYPE[] = "text/vnd.qtcreator.bazaar.commit";
// Menu items // Menu items
// File menu actions // File menu actions

View File

@@ -37,7 +37,7 @@ namespace ClearCase {
namespace Constants { namespace Constants {
const char VCS_ID_CLEARCASE[] = "E.ClearCase"; const char VCS_ID_CLEARCASE[] = "E.ClearCase";
const char CLEARCASE_SUBMIT_MIMETYPE[] = "application/vnd.audc.text.clearcase.submit"; const char CLEARCASE_SUBMIT_MIMETYPE[] = "text/vnd.qtcreator.clearcase.submit";
const char CLEARCASECHECKINEDITOR[] = "ClearCase Check In Editor"; const char CLEARCASECHECKINEDITOR[] = "ClearCase Check In Editor";
const char CLEARCASECHECKINEDITOR_ID[] = "ClearCase Check In Editor"; const char CLEARCASECHECKINEDITOR_ID[] = "ClearCase Check In Editor";
const char CLEARCASECHECKINEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "ClearCase Check In Editor"); const char CLEARCASECHECKINEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "ClearCase Check In Editor");

View File

@@ -121,29 +121,21 @@ static const char CMD_ID_STATUS[] = "ClearCase.Status";
static const VcsBase::VcsBaseEditorParameters editorParameters[] = { static const VcsBase::VcsBaseEditorParameters editorParameters[] = {
{ {
VcsBase::RegularCommandOutput, VcsBase::LogOutput,
"ClearCase Command Log Editor", // id
QT_TRANSLATE_NOOP("VCS", "ClearCase Command Log Editor"), // display name
"ClearCase Command Log Editor", // context
"application/vnd.audc.text.scs_cc_commandlog",
"scslog"},
{ VcsBase::LogOutput,
"ClearCase File Log Editor", // id "ClearCase File Log Editor", // id
QT_TRANSLATE_NOOP("VCS", "ClearCase File Log Editor"), // display_name QT_TRANSLATE_NOOP("VCS", "ClearCase File Log Editor"), // display_name
"ClearCase File Log Editor", // context "ClearCase File Log Editor", // context
"application/vnd.audc.text.scs_cc_filelog", "text/vnd.qtcreator.clearcase.log"},
"scsfilelog"},
{ VcsBase::AnnotateOutput, { VcsBase::AnnotateOutput,
"ClearCase Annotation Editor", // id "ClearCase Annotation Editor", // id
QT_TRANSLATE_NOOP("VCS", "ClearCase Annotation Editor"), // display_name QT_TRANSLATE_NOOP("VCS", "ClearCase Annotation Editor"), // display_name
"ClearCase Annotation Editor", // context "ClearCase Annotation Editor", // context
"application/vnd.audc.text.scs_cc_annotation", "text/vnd.qtcreator.clearcase.annotation"},
"scsannotate"},
{ VcsBase::DiffOutput, { VcsBase::DiffOutput,
"ClearCase Diff Editor", // id "ClearCase Diff Editor", // id
QT_TRANSLATE_NOOP("VCS", "ClearCase Diff Editor"), // display_name QT_TRANSLATE_NOOP("VCS", "ClearCase Diff Editor"), // display_name
"ClearCase Diff Editor", // context "ClearCase Diff Editor", // context
"text/x-patch","diff"} "text/x-patch"}
}; };
// Utility to find a parameter set by type // Utility to find a parameter set by type

View File

@@ -178,6 +178,9 @@ QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, N
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k); ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
if (!tc) if (!tc)
return results; return results;
Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k);
if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
return results;
ProjectExplorer::Abi targetAbi = tc->targetAbi(); ProjectExplorer::Abi targetAbi = tc->targetAbi();
if (n != ForceNinja) { if (n != ForceNinja) {
if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) { if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) {

View File

@@ -149,15 +149,12 @@ EditorManagerPlaceHolder::~EditorManagerPlaceHolder()
void EditorManagerPlaceHolder::currentModeChanged(Core::IMode *mode) void EditorManagerPlaceHolder::currentModeChanged(Core::IMode *mode)
{ {
if (m_current == this) {
m_current = 0;
EditorManager::instance()->setParent(0);
EditorManager::instance()->hide();
}
if (m_mode == mode) { if (m_mode == mode) {
m_current = this; m_current = this;
layout()->addWidget(EditorManager::instance()); layout()->addWidget(EditorManager::instance());
EditorManager::instance()->show(); EditorManager::instance()->show();
} else if (m_current == this) {
m_current = 0;
} }
} }
@@ -898,11 +895,11 @@ void EditorManager::rootDestroyed(QObject *root)
for (int i = 0; i < d->m_root.size(); ++i) { for (int i = 0; i < d->m_root.size(); ++i) {
SplitterOrView *r = d->m_root.at(i); SplitterOrView *r = d->m_root.at(i);
if (r == root) { if (r == root) {
d->m_root.removeAll(r); d->m_root.removeAt(i);
IContext *context = d->m_rootContext.at(i); IContext *context = d->m_rootContext.takeAt(i);
ICore::removeContextObject(context); ICore::removeContextObject(context);
delete context; delete context;
--i; // we removed the current one
} else if (r->window() == activeWin) { } else if (r->window() == activeWin) {
newActiveRoot = r; newActiveRoot = r;
} }
@@ -2065,12 +2062,27 @@ void EditorManager::showPopupOrSelectDocument() const
if (QApplication::keyboardModifiers() == Qt::NoModifier) { if (QApplication::keyboardModifiers() == Qt::NoModifier) {
windowPopup()->selectAndHide(); windowPopup()->selectAndHide();
} else { } else {
// EditorManager is invisible when invoked from Design Mode. QWidget *activeWindow = qApp->activeWindow();
const QPoint p = isVisible() ? // decide where to show the popup
mapToGlobal(QPoint(0, 0)) : // if the active window has editors, we want that root as a reference
ICore::mainWindow()->mapToGlobal(QPoint(0, 0)); SplitterOrView *activeRoot = 0;
windowPopup()->move((width()-d->m_windowPopup->width())/2 + p.x(), foreach (SplitterOrView *root, d->m_root) {
(height()-d->m_windowPopup->height())/2 + p.y()); if (root->window() == activeWindow) {
activeRoot = root;
break;
}
}
// otherwise we take the "current" root
if (!activeRoot)
activeRoot = findRoot(currentEditorView());
QTC_ASSERT(activeRoot, activeRoot = d->m_root.first());
// root in main window is invisible when invoked from Design Mode.
QWidget *referenceWidget = activeRoot->isVisible() ? activeRoot : activeRoot->window();
QTC_CHECK(referenceWidget->isVisible());
const QPoint p = referenceWidget->mapToGlobal(QPoint(0, 0));
windowPopup()->move((referenceWidget->width() - d->m_windowPopup->width()) / 2 + p.x(),
(referenceWidget->height() - d->m_windowPopup->height()) / 2 + p.y());
windowPopup()->setVisible(true); windowPopup()->setVisible(true);
} }
} }

View File

@@ -535,7 +535,7 @@ bool MimeGlobPattern::matches(const QString &fileName) const
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<!-- Mime types must match the desktop file associations --> <!-- Mime types must match the desktop file associations -->
<mime-type type="application/vnd.nokia.qt.qmakeprofile"> <mime-type type="application/vnd.qt.qmakeprofile">
<comment xml:lang="en">Qt qmake Profile</comment> <comment xml:lang="en">Qt qmake Profile</comment>
<glob pattern="*.pro" weight="50"/> <glob pattern="*.pro" weight="50"/>
</mime-type> </mime-type>

View File

@@ -562,9 +562,13 @@ CPPEditorWidget::CPPEditorWidget(QWidget *parent)
CPPEditorWidget::~CPPEditorWidget() CPPEditorWidget::~CPPEditorWidget()
{ {
if (m_modelManager)
m_modelManager->deleteEditorSupport(editor());
++numberOfClosedEditors; ++numberOfClosedEditors;
if (numberOfClosedEditors == 5) { if (numberOfClosedEditors == 5) {
m_modelManager->GC(); if (m_modelManager)
m_modelManager->GC();
numberOfClosedEditors = 0; numberOfClosedEditors = 0;
} }
@@ -1876,10 +1880,11 @@ Core::Id CPPEditor::id() const
bool CPPEditor::open(QString *errorString, const QString &fileName, const QString &realFileName) bool CPPEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{ {
bool b = TextEditor::BaseTextEditor::open(errorString, fileName, realFileName); if (!TextEditor::BaseTextEditor::open(errorString, fileName, realFileName))
return false;
editorWidget()->setMimeType( editorWidget()->setMimeType(
Core::ICore::mimeDatabase()->findByFile(QFileInfo(fileName)).type()); Core::ICore::mimeDatabase()->findByFile(QFileInfo(fileName)).type());
return b; return true;
} }
const Utils::CommentDefinition *CPPEditor::commentDefinition() const const Utils::CommentDefinition *CPPEditor::commentDefinition() const

View File

@@ -158,6 +158,7 @@ private slots:
void test_quickfix_InsertDefFromDecl_freeFunction(); void test_quickfix_InsertDefFromDecl_freeFunction();
void test_quickfix_InsertDefFromDecl_insideClass(); void test_quickfix_InsertDefFromDecl_insideClass();
void test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitionExists(); void test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitionExists();
void test_quickfix_InsertDefFromDecl_notTriggeringStatement();
void test_quickfix_InsertDeclFromDef(); void test_quickfix_InsertDeclFromDef();
@@ -199,6 +200,7 @@ private slots:
void test_quickfix_AssignToLocalVariable_noFunctionInExpression(); void test_quickfix_AssignToLocalVariable_noFunctionInExpression();
void test_quickfix_AssignToLocalVariable_noReturnClass(); void test_quickfix_AssignToLocalVariable_noReturnClass();
void test_quickfix_AssignToLocalVariable_noReturnFunc(); void test_quickfix_AssignToLocalVariable_noReturnFunc();
void test_quickfix_AssignToLocalVariable_noSignatureMatch();
void test_quickfix_InsertVirtualMethods_onlyDecl(); void test_quickfix_InsertVirtualMethods_onlyDecl();
void test_quickfix_InsertVirtualMethods_onlyDeclWithoutVirtual(); void test_quickfix_InsertVirtualMethods_onlyDeclWithoutVirtual();
@@ -211,6 +213,7 @@ private slots:
void test_quickfix_InsertVirtualMethods_outside(); void test_quickfix_InsertVirtualMethods_outside();
void test_quickfix_InsertVirtualMethods_implementationFile(); void test_quickfix_InsertVirtualMethods_implementationFile();
void test_quickfix_InsertVirtualMethods_notrigger_allImplemented(); void test_quickfix_InsertVirtualMethods_notrigger_allImplemented();
void test_quickfix_InsertVirtualMethods_BaseClassInNamespace();
// The following tests depend on the projects that are loaded on startup // The following tests depend on the projects that are loaded on startup
// and will be skipped in case no projects are loaded. // and will be skipped in case no projects are loaded.

View File

@@ -908,6 +908,24 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitio
data.run(&factory, 1); data.run(&factory, 1);
} }
/// Check not triggering when it is a statement
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringStatement()
{
const QByteArray original =
"class Foo {\n"
"public:\n"
" Foo() {}\n"
"};\n"
"void freeFunc() {\n"
" Foo @f();"
"}\n";
const QByteArray expected = original + "\n";
InsertDefFromDecl factory;
TestCase data(original, expected);
data.run(&factory);
}
// Function for one of InsertDeclDef section cases // Function for one of InsertDeclDef section cases
void insertToSectionDeclFromDef(const QByteArray &section, int sectionIndex) void insertToSectionDeclFromDef(const QByteArray &section, int sectionIndex)
{ {
@@ -2026,6 +2044,23 @@ void CppEditorPlugin::test_quickfix_AssignToLocalVariable_noReturnFunc()
data.run(&factory); data.run(&factory);
} }
/// Check: No trigger for functions which does not match in signature.
void CppEditorPlugin::test_quickfix_AssignToLocalVariable_noSignatureMatch()
{
const QByteArray original =
"int someFunc(int);\n"
"\n"
"void f()\n"
"{\n"
" some@Func();\n"
"}";
const QByteArray expected = original + "\n";
AssignToLocalVariable factory;
TestCase data(original, expected);
data.run(&factory);
}
/// Test dialog for insert virtual functions /// Test dialog for insert virtual functions
class InsertVirtualMethodsDialogTest : public InsertVirtualMethodsDialog class InsertVirtualMethodsDialogTest : public InsertVirtualMethodsDialog
{ {
@@ -2442,3 +2477,56 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_notrigger_allImplemente
TestCase data(original, expected); TestCase data(original, expected);
data.run(&factory); data.run(&factory);
} }
/// Check: Qualified names.
void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
{
QList<TestDocumentPtr> testFiles;
QByteArray original;
QByteArray expected;
// Header File
original =
"namespace BaseNS {enum BaseEnum {EnumA = 1};}\n"
"namespace BaseNS {\n"
"class Base {\n"
"public:\n"
" virtual BaseEnum a(BaseEnum e);\n"
"};\n"
"}\n"
"class Deri@ved : public BaseNS::Base {\n"
"public:\n"
" Derived();\n"
"};";
expected =
"namespace BaseNS {enum BaseEnum {EnumA = 1};}\n"
"namespace BaseNS {\n"
"class Base {\n"
"public:\n"
" virtual BaseEnum a(BaseEnum e);\n"
"};\n"
"}\n"
"class Deri@ved : public BaseNS::Base {\n"
"public:\n"
" Derived();\n"
"\n"
" // Base interface\n"
"public:\n"
" virtual BaseNS::BaseEnum a(BaseNS::BaseEnum e);\n"
"};\n";
testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
// Source File
original = "#include \"file.h\"\n";
expected =
"#include \"file.h\"\n"
"\n\n"
"BaseNS::BaseEnum Derived::a(BaseNS::BaseEnum e)\n"
"{\n}\n";
testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
InsertVirtualMethods factory(new InsertVirtualMethodsDialogTest(
InsertVirtualMethodsDialog::ModeImplementationFile, true));
TestCase data(testFiles);
data.run(&factory);
}

View File

@@ -2609,6 +2609,8 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
for (; idx >= 0; --idx) { for (; idx >= 0; --idx) {
AST *node = path.at(idx); AST *node = path.at(idx);
if (SimpleDeclarationAST *simpleDecl = node->asSimpleDeclaration()) { if (SimpleDeclarationAST *simpleDecl = node->asSimpleDeclaration()) {
if (idx > 0 && path.at(idx - 1)->asStatement())
return;
if (simpleDecl->symbols && ! simpleDecl->symbols->next) { if (simpleDecl->symbols && ! simpleDecl->symbols->next) {
if (Symbol *symbol = simpleDecl->symbols->value) { if (Symbol *symbol = simpleDecl->symbols->value) {
if (Declaration *decl = symbol->asDeclaration()) { if (Declaration *decl = symbol->asDeclaration()) {
@@ -4279,13 +4281,21 @@ void AssignToLocalVariable::match(const CppQuickFixInterface &interface, QuickFi
TypeOfExpression typeOfExpression; TypeOfExpression typeOfExpression;
typeOfExpression.init(interface->semanticInfo().doc, interface->snapshot(), typeOfExpression.init(interface->semanticInfo().doc, interface->snapshot(),
interface->context().bindings()); interface->context().bindings());
// If items are empty, AssignToLocalVariableOperation will fail.
items = typeOfExpression(file->textOf(outerAST).toUtf8(),
file->scopeAt(outerAST->firstToken()),
TypeOfExpression::Preprocess);
if (items.isEmpty())
return;
if (CallAST *callAST = outerAST->asCall()) { if (CallAST *callAST = outerAST->asCall()) {
Scope *scope = file->scopeAt(callAST->base_expression->firstToken()); items = typeOfExpression(file->textOf(callAST->base_expression).toUtf8(),
items = typeOfExpression(file->textOf(callAST->base_expression).toUtf8(), scope, file->scopeAt(callAST->base_expression->firstToken()),
TypeOfExpression::Preprocess); TypeOfExpression::Preprocess);
} else { } else {
Scope *scope = file->scopeAt(nameAST->firstToken()); items = typeOfExpression(file->textOf(nameAST).toUtf8(),
items = typeOfExpression(file->textOf(nameAST).toUtf8(), scope, file->scopeAt(nameAST->firstToken()),
TypeOfExpression::Preprocess); TypeOfExpression::Preprocess);
} }
@@ -4400,6 +4410,10 @@ public:
itemBase->setData(qVariantFromValue((void *) clazz), itemBase->setData(qVariantFromValue((void *) clazz),
InsertVirtualMethodsDialog::ClassOrFunction); InsertVirtualMethodsDialog::ClassOrFunction);
const QString baseClassName = printer.prettyName(clazz->name()); const QString baseClassName = printer.prettyName(clazz->name());
const Qt::CheckState funcItemsCheckState = (baseClassName != QLatin1String("QObject")
&& baseClassName != QLatin1String("QWidget")
&& baseClassName != QLatin1String("QPaintDevice"))
? Qt::Checked : Qt::Unchecked;
for (Scope::iterator it = clazz->firstMember(); it != clazz->lastMember(); ++it) { for (Scope::iterator it = clazz->firstMember(); it != clazz->lastMember(); ++it) {
if (const Function *func = (*it)->type()->asFunctionType()) { if (const Function *func = (*it)->type()->asFunctionType()) {
if (!func->isVirtual()) if (!func->isVirtual())
@@ -4482,6 +4496,7 @@ public:
funcItem->setData(isPureVirtual, InsertVirtualMethodsDialog::PureVirtual); funcItem->setData(isPureVirtual, InsertVirtualMethodsDialog::PureVirtual);
funcItem->setData(acessSpec(*it), InsertVirtualMethodsDialog::AccessSpec); funcItem->setData(acessSpec(*it), InsertVirtualMethodsDialog::AccessSpec);
funcItem->setData(funcExistsInClass, InsertVirtualMethodsDialog::Implemented); funcItem->setData(funcExistsInClass, InsertVirtualMethodsDialog::Implemented);
funcItem->setCheckState(funcItemsCheckState);
itemBase->appendRow(funcItem); itemBase->appendRow(funcItem);
@@ -4495,11 +4510,15 @@ public:
if (itemBase->hasChildren()) { if (itemBase->hasChildren()) {
for (int i = 0; i < itemBase->rowCount(); ++i) { for (int i = 0; i < itemBase->rowCount(); ++i) {
if (itemBase->child(i, 0)->isCheckable()) { if (itemBase->child(i, 0)->isCheckable()) {
itemBase->setCheckable(true); if (!itemBase->isCheckable()) {
itemBase->setTristate(true); itemBase->setCheckable(true);
itemBase->setCheckState(Qt::Checked); itemBase->setTristate(true);
itemBase->setData(false, InsertVirtualMethodsDialog::Implemented); itemBase->setData(false, InsertVirtualMethodsDialog::Implemented);
break; }
if (itemBase->child(i, 0)->checkState() == Qt::Checked) {
itemBase->setCheckState(Qt::Checked);
break;
}
} }
} }
m_factory->classFunctionModel->invisibleRootItem()->appendRow(itemBase); m_factory->classFunctionModel->invisibleRootItem()->appendRow(itemBase);
@@ -4575,12 +4594,23 @@ public:
QLatin1String("QuickFix/InsertVirtualMethods/hideReimplementedFunctions"), QLatin1String("QuickFix/InsertVirtualMethods/hideReimplementedFunctions"),
m_factory->hideReimplementedFunctions()); m_factory->hideReimplementedFunctions());
// Insert declarations (and definition if InsideClass) // Insert declarations (and definition if Inside-/OutsideClass)
Overview printer = CppCodeStyleSettings::currentProjectCodeStyleOverview(); Overview printer = CppCodeStyleSettings::currentProjectCodeStyleOverview();
printer.showFunctionSignatures = true; printer.showFunctionSignatures = true;
printer.showReturnTypes = true; printer.showReturnTypes = true;
printer.showArgumentNames = true; printer.showArgumentNames = true;
ChangeSet headerChangeSet; ChangeSet headerChangeSet;
const CppRefactoringChanges refactoring(assistInterface()->snapshot());
const QString filename = assistInterface()->currentFile()->fileName();
const CppRefactoringFilePtr headerFile = refactoring.file(filename);
const LookupContext targetContext(headerFile->cppDocument(), assistInterface()->snapshot());
const Class *targetClass = m_classAST->symbol;
ClassOrNamespace *targetCoN = targetContext.lookupType(targetClass->scope());
if (!targetCoN)
targetCoN = targetContext.globalNamespace();
UseMinimalNames useMinimalNames(targetCoN);
Control *control = assistInterface()->context().bindings()->control().data();
for (int i = 0; i < m_factory->classFunctionModel->rowCount(); ++i) { for (int i = 0; i < m_factory->classFunctionModel->rowCount(); ++i) {
const QStandardItem *parent = const QStandardItem *parent =
m_factory->classFunctionModel->invisibleRootItem()->child(i, 0); m_factory->classFunctionModel->invisibleRootItem()->child(i, 0);
@@ -4604,11 +4634,23 @@ public:
item->data(InsertVirtualMethodsDialog::ClassOrFunction).value<void *>(); item->data(InsertVirtualMethodsDialog::ClassOrFunction).value<void *>();
// Construct declaration // Construct declaration
QString declaration = InsertDeclOperation::generateDeclaration(func); // setup rewriting to get minimally qualified names
SubstitutionEnvironment env;
env.setContext(assistInterface()->context());
env.switchScope(clazz->enclosingScope());
env.enter(&useMinimalNames);
QString declaration;
const FullySpecifiedType tn = rewriteType(func->type(), &env, control);
declaration += printer.prettyType(tn, func->unqualifiedName());
if (m_factory->insertKeywordVirtual()) if (m_factory->insertKeywordVirtual())
declaration = QLatin1String("virtual ") + declaration; declaration = QLatin1String("virtual ") + declaration;
if (m_factory->implementationMode() & InsertVirtualMethodsDialog::ModeInsideClass) if (m_factory->implementationMode() & InsertVirtualMethodsDialog::ModeInsideClass)
declaration.replace(declaration.size() - 2, 2, QLatin1String("\n{\n}\n")); declaration += QLatin1String("\n{\n}\n");
else
declaration += QLatin1String(";\n");
const InsertionPointLocator::AccessSpec spec = const InsertionPointLocator::AccessSpec spec =
static_cast<InsertionPointLocator::AccessSpec>( static_cast<InsertionPointLocator::AccessSpec>(
item->data(InsertVirtualMethodsDialog::AccessSpec).toInt()); item->data(InsertVirtualMethodsDialog::AccessSpec).toInt());
@@ -4620,54 +4662,12 @@ public:
lastAccessSpecString = accessSpecString; lastAccessSpecString = accessSpecString;
} }
headerChangeSet.insert(m_insertPosDecl, declaration); headerChangeSet.insert(m_insertPosDecl, declaration);
}
}
// Insert outside class // Insert definition outside class
const QString filename = assistInterface()->currentFile()->fileName(); if (m_factory->implementationMode() & InsertVirtualMethodsDialog::ModeOutsideClass) {
const CppRefactoringChanges refactoring(assistInterface()->snapshot()); const QString name = printer.prettyName(targetClass->name()) +
const CppRefactoringFilePtr headerFile = refactoring.file(filename); QLatin1String("::") + printer.prettyName(func->name());
const Document::Ptr headerDoc = headerFile->cppDocument();
Class *targetClass = m_classAST->symbol;
if (m_factory->implementationMode() & InsertVirtualMethodsDialog::ModeOutsideClass) {
// make target lookup context
unsigned line, column;
headerDoc->translationUnit()->getPosition(m_insertPosOutside, &line, &column);
Scope *targetScope = headerDoc->scopeAt(line, column);
const LookupContext targetContext(headerDoc, assistInterface()->snapshot());
ClassOrNamespace *targetCoN = targetContext.lookupType(targetScope);
if (!targetCoN)
targetCoN = targetContext.globalNamespace();
// setup rewriting to get minimally qualified names
SubstitutionEnvironment env;
env.setContext(assistInterface()->context());
env.switchScope(targetClass);
UseMinimalNames q(targetCoN);
env.enter(&q);
Control *control = assistInterface()->context().bindings()->control().data();
const QString fullClassName = printer.prettyName(LookupContext::minimalName(
targetClass, targetCoN, control));
for (int i = 0; i < m_factory->classFunctionModel->rowCount(); ++i) {
const QStandardItem *parent =
m_factory->classFunctionModel->invisibleRootItem()->child(i, 0);
if (!parent->isCheckable() || parent->checkState() == Qt::Unchecked)
continue;
for (int j = 0; j < parent->rowCount(); ++j) {
const QStandardItem *item = parent->child(j, 0);
if (!item->isCheckable() || item->checkState() == Qt::Unchecked)
continue;
const Function *func = (const Function *)
item->data(InsertVirtualMethodsDialog::ClassOrFunction).value<void *>();
// rewrite the function type and name
const FullySpecifiedType tn = rewriteType(func->type(), &env, control);
const QString name = fullClassName + QLatin1String("::") +
printer.prettyName(func->name());
const QString defText = printer.prettyType(tn, name) + QLatin1String("\n{\n}"); const QString defText = printer.prettyType(tn, name) + QLatin1String("\n{\n}");
headerChangeSet.insert(m_insertPosOutside, QLatin1String("\n\n") + defText); headerChangeSet.insert(m_insertPosOutside, QLatin1String("\n\n") + defText);
} }
} }

View File

@@ -408,6 +408,14 @@ Scope *CheckSymbols::enclosingScope() const
if (funDef->symbol) if (funDef->symbol)
return funDef->symbol; return funDef->symbol;
} else if (TemplateDeclarationAST *templateDeclaration = ast->asTemplateDeclaration()) {
if (DeclarationAST *decl = templateDeclaration->declaration) {
if (FunctionDefinitionAST *funDef = decl->asFunctionDefinition()) {
if (funDef->symbol)
return funDef->symbol;
}
}
} else if (CompoundStatementAST *blockStmt = ast->asCompoundStatement()) { } else if (CompoundStatementAST *blockStmt = ast->asCompoundStatement()) {
if (blockStmt->symbol) if (blockStmt->symbol)
return blockStmt->symbol; return blockStmt->symbol;
@@ -869,7 +877,12 @@ ClassOrNamespace *CheckSymbols::checkNestedName(QualifiedNameAST *ast)
const Name *name = class_or_namespace_name->name; const Name *name = class_or_namespace_name->name;
binding = _context.lookupType(name, enclosingScope()); binding = _context.lookupType(name, enclosingScope());
addType(binding, class_or_namespace_name); if (binding)
addType(binding, class_or_namespace_name);
else
// for the case when we use template parameter as qualifier
// e.g.: template <typename T> void fun() { T::type type; }
accept(nested_name_specifier->class_or_namespace_name);
for (it = it->next; it; it = it->next) { for (it = it->next; it; it = it->next) {
NestedNameSpecifierAST *nested_name_specifier = it->value; NestedNameSpecifierAST *nested_name_specifier = it->value;

View File

@@ -1473,7 +1473,61 @@ void CppToolsPlugin::test_completion_member_access_operator_1()
QVERIFY(replaceAccessOperator); QVERIFY(replaceAccessOperator);
} }
void CppToolsPlugin::test_completion_typedef_of_type_and_replace_access_operator() void CppToolsPlugin::test_completion_typedef_of_type_and_decl_of_type_no_replace_access_operator()
{
TestData data;
data.srcText = "\n"
"struct S { int m; };\n"
"typedef S SType;\n"
"SType p;\n"
"@\n"
"}\n"
;
setup(&data);
Utils::ChangeSet change;
QString txt = QLatin1String("p.");
change.insert(data.pos, txt);
QTextCursor cursor(data.doc);
change.apply(&cursor);
data.pos += txt.length();
bool replaceAccessOperator = false;
QStringList completions = getCompletions(data, &replaceAccessOperator);
QCOMPARE(completions.size(), 2);
QVERIFY(completions.contains(QLatin1String("S")));
QVERIFY(completions.contains(QLatin1String("m")));
QVERIFY(! replaceAccessOperator);
}
void CppToolsPlugin::test_completion_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator()
{
TestData data;
data.srcText = "\n"
"struct S { int m; };\n"
"typedef S *SType;\n"
"SType *p;\n"
"@\n"
"}\n"
;
setup(&data);
Utils::ChangeSet change;
QString txt = QLatin1String("p.");
change.insert(data.pos, txt);
QTextCursor cursor(data.doc);
change.apply(&cursor);
data.pos += txt.length();
bool replaceAccessOperator = false;
QStringList completions = getCompletions(data, &replaceAccessOperator);
QCOMPARE(completions.size(), 0);
QVERIFY(! replaceAccessOperator);
}
void CppToolsPlugin::test_completion_typedef_of_type_and_decl_of_pointer_replace_access_operator()
{ {
TestData data; TestData data;
data.srcText = "\n" data.srcText = "\n"
@@ -1501,7 +1555,7 @@ void CppToolsPlugin::test_completion_typedef_of_type_and_replace_access_operator
QVERIFY(replaceAccessOperator); QVERIFY(replaceAccessOperator);
} }
void CppToolsPlugin::test_completion_typedef_of_pointer_of_type_and_replace_access_operator() void CppToolsPlugin::test_completion_typedef_of_pointer_and_decl_of_type_replace_access_operator()
{ {
TestData data; TestData data;
data.srcText = "\n" data.srcText = "\n"
@@ -1529,6 +1583,116 @@ void CppToolsPlugin::test_completion_typedef_of_pointer_of_type_and_replace_acce
QVERIFY(replaceAccessOperator); QVERIFY(replaceAccessOperator);
} }
void CppToolsPlugin::test_completion_predecl_typedef_of_type_and_decl_of_pointer_replace_access_operator()
{
TestData data;
data.srcText = "\n"
"typedef struct S SType;\n"
"struct S { int m; };\n"
"SType *p;\n"
"@\n"
"}\n"
;
setup(&data);
Utils::ChangeSet change;
QString txt = QLatin1String("p.");
change.insert(data.pos, txt);
QTextCursor cursor(data.doc);
change.apply(&cursor);
data.pos += txt.length();
bool replaceAccessOperator = false;
QStringList completions = getCompletions(data, &replaceAccessOperator);
QCOMPARE(completions.size(), 2);
QVERIFY(completions.contains(QLatin1String("S")));
QVERIFY(completions.contains(QLatin1String("m")));
QVERIFY(replaceAccessOperator);
}
void CppToolsPlugin::test_completion_predecl_typedef_of_type_and_decl_type_no_replace_access_operator()
{
TestData data;
data.srcText = "\n"
"typedef struct S SType;\n"
"struct S { int m; };\n"
"SType p;\n"
"@\n"
"}\n"
;
setup(&data);
Utils::ChangeSet change;
QString txt = QLatin1String("p.");
change.insert(data.pos, txt);
QTextCursor cursor(data.doc);
change.apply(&cursor);
data.pos += txt.length();
bool replaceAccessOperator = false;
QStringList completions = getCompletions(data, &replaceAccessOperator);
QCOMPARE(completions.size(), 2);
QVERIFY(completions.contains(QLatin1String("S")));
QVERIFY(completions.contains(QLatin1String("m")));
QVERIFY(! replaceAccessOperator);
}
void CppToolsPlugin::test_completion_predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator()
{
TestData data;
data.srcText = "\n"
"typedef struct S *SType;\n"
"struct S { int m; };\n"
"SType *p;\n"
"@\n"
"}\n"
;
setup(&data);
Utils::ChangeSet change;
QString txt = QLatin1String("p.");
change.insert(data.pos, txt);
QTextCursor cursor(data.doc);
change.apply(&cursor);
data.pos += txt.length();
bool replaceAccessOperator = false;
QStringList completions = getCompletions(data, &replaceAccessOperator);
QCOMPARE(completions.size(), 0);
QVERIFY(! replaceAccessOperator);
}
void CppToolsPlugin::test_completion_predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator()
{
TestData data;
data.srcText = "\n"
"typedef struct S *SType;\n"
"struct S { int m; };\n"
"SType p;\n"
"@\n"
"}\n"
;
setup(&data);
Utils::ChangeSet change;
QString txt = QLatin1String("p.");
change.insert(data.pos, txt);
QTextCursor cursor(data.doc);
change.apply(&cursor);
data.pos += txt.length();
bool replaceAccessOperator = false;
QStringList completions = getCompletions(data, &replaceAccessOperator);
QCOMPARE(completions.size(), 2);
QVERIFY(completions.contains(QLatin1String("S")));
QVERIFY(completions.contains(QLatin1String("m")));
QVERIFY(replaceAccessOperator);
}
void CppToolsPlugin::test_completion_typedef_of_pointer() void CppToolsPlugin::test_completion_typedef_of_pointer()
{ {
TestData data; TestData data;
@@ -1744,7 +1908,6 @@ void CppToolsPlugin::test_completion_typedef_using_templates1()
QVERIFY(completions.contains(QLatin1String("bar"))); QVERIFY(completions.contains(QLatin1String("bar")));
} }
void CppToolsPlugin::test_completion_typedef_using_templates2() void CppToolsPlugin::test_completion_typedef_using_templates2()
{ {
TestData data; TestData data;
@@ -2047,3 +2210,66 @@ void CppToolsPlugin::test_completion_instantiate_template_with_anonymous_class()
QCOMPARE(completions.size(), 1); QCOMPARE(completions.size(), 1);
QVERIFY(completions.contains(QLatin1String("S"))); QVERIFY(completions.contains(QLatin1String("S")));
} }
void CppToolsPlugin::test_completion_instantiate_template_function()
{
TestData data;
data.srcText =
"template <typename T>\n"
"T* templateFunction() { return 0; }\n"
"struct A { int a; };\n"
"void foo()\n"
"{\n"
" @\n"
" // padding so we get the scope right\n"
"}\n"
;
setup(&data);
Utils::ChangeSet change;
QString txt = QLatin1String("templateFunction<A>()->");
change.insert(data.pos, txt);
QTextCursor cursor(data.doc);
change.apply(&cursor);
data.pos += txt.length();
QStringList completions = getCompletions(data);
QCOMPARE(completions.size(), 2);
QVERIFY(completions.contains(QLatin1String("A")));
QVERIFY(completions.contains(QLatin1String("a")));
}
void CppToolsPlugin::test_completion_crash_cloning_template_class_QTCREATORBUG9329()
{
TestData data;
data.srcText =
"struct A {};\n"
"template <typename T>\n"
"struct Templ {};\n"
"struct B : A, Templ<A>\n"
"{\n"
" int f()\n"
" {\n"
" @\n"
" // padding so we get the scope right\n"
" }\n"
"};\n"
;
setup(&data);
Utils::ChangeSet change;
QString txt = QLatin1String("this->");
change.insert(data.pos, txt);
QTextCursor cursor(data.doc);
change.apply(&cursor);
data.pos += txt.length();
QStringList completions = getCompletions(data);
QCOMPARE(completions.size(), 4);
QVERIFY(completions.contains(QLatin1String("A")));
QVERIFY(completions.contains(QLatin1String("B")));
QVERIFY(completions.contains(QLatin1String("Templ")));
QVERIFY(completions.contains(QLatin1String("f")));
}

View File

@@ -245,10 +245,6 @@ CppModelManager::CppModelManager(QObject *parent)
qRegisterMetaType<CPlusPlus::Document::Ptr>("CPlusPlus::Document::Ptr"); qRegisterMetaType<CPlusPlus::Document::Ptr>("CPlusPlus::Document::Ptr");
// Listen for editor closed events so that we can keep track of changing files
connect(Core::ICore::editorManager(), SIGNAL(editorAboutToClose(Core::IEditor*)),
this, SLOT(editorAboutToClose(Core::IEditor*)));
m_completionFallback = new InternalCompletionAssistProvider; m_completionFallback = new InternalCompletionAssistProvider;
m_completionAssistProvider = m_completionFallback; m_completionAssistProvider = m_completionFallback;
ExtensionSystem::PluginManager::addObject(m_completionAssistProvider); ExtensionSystem::PluginManager::addObject(m_completionAssistProvider);
@@ -602,14 +598,13 @@ QList<ProjectPart::Ptr> CppModelManager::projectPart(const QString &fileName) co
} }
/// \brief Removes the CppEditorSupport for the closed editor. /// \brief Removes the CppEditorSupport for the closed editor.
void CppModelManager::editorAboutToClose(Core::IEditor *editor) void CppModelManager::deleteEditorSupport(TextEditor::BaseTextEditor *textEditor)
{ {
if (!isCppEditor(editor))
return;
TextEditor::BaseTextEditor *textEditor = qobject_cast<TextEditor::BaseTextEditor *>(editor);
QTC_ASSERT(textEditor, return); QTC_ASSERT(textEditor, return);
if (!isCppEditor(textEditor))
return;
QMutexLocker locker(&m_editorSupportMutex); QMutexLocker locker(&m_editorSupportMutex);
CppEditorSupport *editorSupport = m_editorSupport.value(textEditor, 0); CppEditorSupport *editorSupport = m_editorSupport.value(textEditor, 0);
m_editorSupport.remove(textEditor); m_editorSupport.remove(textEditor);

View File

@@ -87,6 +87,7 @@ public:
virtual void addEditorSupport(AbstractEditorSupport *editorSupport); virtual void addEditorSupport(AbstractEditorSupport *editorSupport);
virtual void removeEditorSupport(AbstractEditorSupport *editorSupport); virtual void removeEditorSupport(AbstractEditorSupport *editorSupport);
virtual CppEditorSupport *cppEditorSupport(TextEditor::BaseTextEditor *editor); virtual CppEditorSupport *cppEditorSupport(TextEditor::BaseTextEditor *editor);
virtual void deleteEditorSupport(TextEditor::BaseTextEditor *textEditor);
virtual QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context); virtual QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
@@ -139,7 +140,6 @@ Q_SIGNALS:
void aboutToRemoveFiles(const QStringList &files); void aboutToRemoveFiles(const QStringList &files);
public Q_SLOTS: public Q_SLOTS:
void editorAboutToClose(Core::IEditor *editor);
virtual void updateModifiedSourceFiles(); virtual void updateModifiedSourceFiles();
private Q_SLOTS: private Q_SLOTS:

View File

@@ -32,8 +32,9 @@
#include "cpppreprocessor.h" #include "cpppreprocessor.h"
#include "modelmanagertesthelper.h" #include "modelmanagertesthelper.h"
#include <QtTest>
#include <QDebug> #include <QDebug>
#include <QFileInfo>
#include <QtTest>
using namespace CppTools::Internal; using namespace CppTools::Internal;
@@ -44,31 +45,57 @@ typedef CppTools::ProjectFile ProjectFile;
typedef ProjectExplorer::Project Project; typedef ProjectExplorer::Project Project;
namespace { namespace {
QString testDataDir(const QString& subdir, bool cleaned = true)
{
QString path = QLatin1String(SRCDIR "/../../../tests/cppmodelmanager/testdata");
if (!subdir.isEmpty())
path += QLatin1String("/") + subdir;
if (cleaned)
return CppPreprocessor::cleanPath(path);
else
return path;
}
QString testIncludeDir(bool cleaned = true) class TestDataDirectory
{ {
return testDataDir(QLatin1String("include"), cleaned); public:
} TestDataDirectory(const QString &testDataDirectory)
: m_testDataDirectory(QLatin1String(SRCDIR "/../../../tests/cppmodelmanager/")
+ testDataDirectory)
{
QFileInfo testDataDir(m_testDataDirectory);
QVERIFY(testDataDir.exists());
QVERIFY(testDataDir.isDir());
}
QString testFrameworksDir(bool cleaned = true)
{
return testDataDir(QLatin1String("frameworks"), cleaned);
}
QString testSource(const QString &fileName) QString includeDir(bool cleaned = true) const
{ {
return testDataDir(QLatin1String("sources")) + fileName; return testDataDir(QLatin1String("include"), cleaned);
} }
QString frameworksDir(bool cleaned = true) const
{
return testDataDir(QLatin1String("frameworks"), cleaned);
}
QString fileFromSourcesDir(const QString &fileName) const
{
return testDataDir(QLatin1String("sources")) + fileName;
}
/// File from the test data directory (top leve)
QString file(const QString &fileName) const
{
return testDataDir(QString()) + fileName;
}
private:
QString testDataDir(const QString& subdir, bool cleaned = true) const
{
QString path = m_testDataDirectory;
if (!subdir.isEmpty())
path += QLatin1String("/") + subdir;
if (cleaned)
return CppPreprocessor::cleanPath(path);
else
return path;
}
private:
const QString m_testDataDirectory;
};
} // anonymous namespace } // anonymous namespace
void CppToolsPlugin::test_modelmanager_paths() void CppToolsPlugin::test_modelmanager_paths()
@@ -76,6 +103,8 @@ void CppToolsPlugin::test_modelmanager_paths()
ModelManagerTestHelper helper; ModelManagerTestHelper helper;
CppModelManager *mm = CppModelManager::instance(); CppModelManager *mm = CppModelManager::instance();
const TestDataDirectory testDataDir(QLatin1String("testdata"));
Project *project = helper.createProject(QLatin1String("test_modelmanager_paths")); Project *project = helper.createProject(QLatin1String("test_modelmanager_paths"));
ProjectInfo pi = mm->projectInfo(project); ProjectInfo pi = mm->projectInfo(project);
QCOMPARE(pi.project().data(), project); QCOMPARE(pi.project().data(), project);
@@ -85,18 +114,18 @@ void CppToolsPlugin::test_modelmanager_paths()
part->cxxVersion = ProjectPart::CXX98; part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5; part->qtVersion = ProjectPart::Qt5;
part->defines = QByteArray("#define OH_BEHAVE -1\n"); part->defines = QByteArray("#define OH_BEHAVE -1\n");
part->includePaths = QStringList() << testIncludeDir(false); part->includePaths = QStringList() << testDataDir.includeDir(false);
part->frameworkPaths = QStringList() << testFrameworksDir(false); part->frameworkPaths = QStringList() << testDataDir.frameworksDir(false);
mm->updateProjectInfo(pi); mm->updateProjectInfo(pi);
QStringList includePaths = mm->includePaths(); QStringList includePaths = mm->includePaths();
QCOMPARE(includePaths.size(), 1); QCOMPARE(includePaths.size(), 1);
QVERIFY(includePaths.contains(testIncludeDir())); QVERIFY(includePaths.contains(testDataDir.includeDir()));
QStringList frameworkPaths = mm->frameworkPaths(); QStringList frameworkPaths = mm->frameworkPaths();
QCOMPARE(frameworkPaths.size(), 1); QCOMPARE(frameworkPaths.size(), 1);
QVERIFY(frameworkPaths.contains(testFrameworksDir())); QVERIFY(frameworkPaths.contains(testDataDir.frameworksDir()));
} }
void CppToolsPlugin::test_modelmanager_framework_headers() void CppToolsPlugin::test_modelmanager_framework_headers()
@@ -104,6 +133,8 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
ModelManagerTestHelper helper; ModelManagerTestHelper helper;
CppModelManager *mm = CppModelManager::instance(); CppModelManager *mm = CppModelManager::instance();
const TestDataDirectory testDataDir(QLatin1String("testdata"));
Project *project = helper.createProject(QLatin1String("test_modelmanager_framework_headers")); Project *project = helper.createProject(QLatin1String("test_modelmanager_framework_headers"));
ProjectInfo pi = mm->projectInfo(project); ProjectInfo pi = mm->projectInfo(project);
QCOMPARE(pi.project().data(), project); QCOMPARE(pi.project().data(), project);
@@ -113,9 +144,10 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
part->cxxVersion = ProjectPart::CXX98; part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5; part->qtVersion = ProjectPart::Qt5;
part->defines = QByteArray("#define OH_BEHAVE -1\n"); part->defines = QByteArray("#define OH_BEHAVE -1\n");
part->includePaths << testIncludeDir(); part->includePaths << testDataDir.includeDir();
part->frameworkPaths << testFrameworksDir(); part->frameworkPaths << testDataDir.frameworksDir();
const QString &source = testSource(QLatin1String("test_modelmanager_framework_headers.cpp")); const QString &source = testDataDir.fileFromSourcesDir(
QLatin1String("test_modelmanager_framework_headers.cpp"));
part->files << ProjectFile(source, ProjectFile::CXXSource); part->files << ProjectFile(source, ProjectFile::CXXSource);
mm->updateProjectInfo(pi); mm->updateProjectInfo(pi);
@@ -140,15 +172,19 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
} }
/// QTCREATORBUG-9056 /// QTCREATORBUG-9056
void CppToolsPlugin::test_modelmanager_refresh() void CppToolsPlugin::test_modelmanager_refresh_1()
{ {
ModelManagerTestHelper helper; ModelManagerTestHelper helper;
CppModelManager *mm = CppModelManager::instance(); CppModelManager *mm = CppModelManager::instance();
const QString testCpp(testSource(QLatin1String("test_modelmanager_refresh.cpp"))); const TestDataDirectory testDataDir(QLatin1String("testdata"));
const QString testHeader(testSource(QLatin1String("test_modelmanager_refresh.h")));
Project *project = helper.createProject(QLatin1String("test_modelmanager_refresh")); const QString testCpp(testDataDir.fileFromSourcesDir(
QLatin1String("test_modelmanager_refresh.cpp")));
const QString testHeader(testDataDir.fileFromSourcesDir(
QLatin1String("test_modelmanager_refresh.h")));
Project *project = helper.createProject(QLatin1String("test_modelmanager_refresh_1"));
ProjectInfo pi = mm->projectInfo(project); ProjectInfo pi = mm->projectInfo(project);
QCOMPARE(pi.project().data(), project); QCOMPARE(pi.project().data(), project);
@@ -157,7 +193,7 @@ void CppToolsPlugin::test_modelmanager_refresh()
part->cxxVersion = ProjectPart::CXX98; part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5; part->qtVersion = ProjectPart::Qt5;
part->defines = QByteArray("#define OH_BEHAVE -1\n"); part->defines = QByteArray("#define OH_BEHAVE -1\n");
part->includePaths = QStringList() << testIncludeDir(false); part->includePaths = QStringList() << testDataDir.includeDir(false);
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource)); part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
mm->updateProjectInfo(pi); mm->updateProjectInfo(pi);
@@ -186,3 +222,59 @@ void CppToolsPlugin::test_modelmanager_refresh()
QVERIFY(snapshot.contains(testHeader)); QVERIFY(snapshot.contains(testHeader));
QVERIFY(snapshot.contains(testCpp)); QVERIFY(snapshot.contains(testCpp));
} }
/// QTCREATORBUG-9205
void CppToolsPlugin::test_modelmanager_refresh_2()
{
ModelManagerTestHelper helper;
CppModelManager *mm = CppModelManager::instance();
const TestDataDirectory testDataDir(QLatin1String("testdata_refresh"));
const QString testHeader1(testDataDir.file(QLatin1String("defines.h")));
const QString testHeader2(testDataDir.file(QLatin1String("header.h")));
const QString testCpp(testDataDir.file(QLatin1String("source.cpp")));
Project *project = helper.createProject(QLatin1String("test_modelmanager_refresh_2"));
ProjectInfo pi = mm->projectInfo(project);
QCOMPARE(pi.project().data(), project);
ProjectPart::Ptr part(new ProjectPart);
pi.appendProjectPart(part);
part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testHeader1, ProjectFile::CXXHeader));
part->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
mm->updateProjectInfo(pi);
CPlusPlus::Snapshot snapshot;
QStringList refreshedFiles;
CPlusPlus::Document::Ptr document;
for (int i = 0; i < 2; ++i) {
mm->updateSourceFiles(QStringList() << testHeader1 << testHeader2 << testCpp);
refreshedFiles = helper.waitForRefreshedSourceFiles();
QCOMPARE(refreshedFiles.size(), 3);
QVERIFY(refreshedFiles.contains(testHeader1));
QVERIFY(refreshedFiles.contains(testHeader2));
QVERIFY(refreshedFiles.contains(testCpp));
snapshot = mm->snapshot();
QVERIFY(snapshot.contains(testHeader1));
QVERIFY(snapshot.contains(testHeader2));
QVERIFY(snapshot.contains(testCpp));
// No diagnostic messages expected
document = snapshot.document(testHeader1);
QVERIFY(document->diagnosticMessages().isEmpty());
document = snapshot.document(testHeader2);
QVERIFY(document->diagnosticMessages().isEmpty());
document = snapshot.document(testCpp);
QVERIFY(document->diagnosticMessages().isEmpty());
}
}

View File

@@ -215,6 +215,7 @@ public:
virtual void addEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0; virtual void addEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
virtual void removeEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0; virtual void removeEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
virtual CppEditorSupport *cppEditorSupport(TextEditor::BaseTextEditor *editor) = 0; virtual CppEditorSupport *cppEditorSupport(TextEditor::BaseTextEditor *editor) = 0;
virtual void deleteEditorSupport(TextEditor::BaseTextEditor *textEditor) = 0;
virtual QList<int> references(CPlusPlus::Symbol *symbol, virtual QList<int> references(CPlusPlus::Symbol *symbol,
const CPlusPlus::LookupContext &context) = 0; const CPlusPlus::LookupContext &context) = 0;

View File

@@ -138,6 +138,7 @@ void CppPreprocessor::resetEnvironment()
{ {
m_env.reset(); m_env.reset();
m_processed.clear(); m_processed.clear();
m_included.clear();
} }
void CppPreprocessor::getFileContents(const QString &absoluteFilePath, void CppPreprocessor::getFileContents(const QString &absoluteFilePath,

View File

@@ -113,8 +113,17 @@ private slots:
void test_completion_instantiate_template_with_default_argument_type(); void test_completion_instantiate_template_with_default_argument_type();
void test_completion_instantiate_template_with_default_argument_type_as_template(); void test_completion_instantiate_template_with_default_argument_type_as_template();
void test_completion_member_access_operator_1(); void test_completion_member_access_operator_1();
void test_completion_typedef_of_type_and_replace_access_operator();
void test_completion_typedef_of_pointer_of_type_and_replace_access_operator(); void test_completion_typedef_of_type_and_decl_of_type_no_replace_access_operator();
void test_completion_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator();
void test_completion_typedef_of_type_and_decl_of_pointer_replace_access_operator();
void test_completion_typedef_of_pointer_and_decl_of_type_replace_access_operator();
void test_completion_predecl_typedef_of_type_and_decl_of_pointer_replace_access_operator();
void test_completion_predecl_typedef_of_type_and_decl_type_no_replace_access_operator();
void test_completion_predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator();
void test_completion_predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator();
void test_completion_typedef_of_pointer(); void test_completion_typedef_of_pointer();
void test_completion_typedef_of_pointer_inside_function(); void test_completion_typedef_of_pointer_inside_function();
void test_completion_typedef_is_inside_function_before_declaration_block(); void test_completion_typedef_is_inside_function_before_declaration_block();
@@ -127,6 +136,8 @@ private slots:
void test_completion_type_and_using_declaration(); void test_completion_type_and_using_declaration();
void test_completion_type_and_using_declaration_data(); void test_completion_type_and_using_declaration_data();
void test_completion_instantiate_template_with_anonymous_class(); void test_completion_instantiate_template_with_anonymous_class();
void test_completion_instantiate_template_function();
void test_completion_crash_cloning_template_class_QTCREATORBUG9329();
void test_format_pointerdeclaration_in_simpledeclarations(); void test_format_pointerdeclaration_in_simpledeclarations();
void test_format_pointerdeclaration_in_simpledeclarations_data(); void test_format_pointerdeclaration_in_simpledeclarations_data();
@@ -141,7 +152,8 @@ private slots:
void test_modelmanager_paths(); void test_modelmanager_paths();
void test_modelmanager_framework_headers(); void test_modelmanager_framework_headers();
void test_modelmanager_refresh(); void test_modelmanager_refresh_1();
void test_modelmanager_refresh_2();
private: private:
void test_completion(); void test_completion();

View File

@@ -33,7 +33,7 @@
namespace Cvs { namespace Cvs {
namespace Constants { namespace Constants {
const char CVS_SUBMIT_MIMETYPE[] = "application/vnd.nokia.text.cvs.submit"; const char CVS_SUBMIT_MIMETYPE[] = "text/vnd.qtcreator.cvs.submit";
const char CVSCOMMITEDITOR[] = "CVS Commit Editor"; const char CVSCOMMITEDITOR[] = "CVS Commit Editor";
const char CVSCOMMITEDITOR_ID[] = "CVS Commit Editor"; const char CVSCOMMITEDITOR_ID[] = "CVS Commit Editor";
const char CVSCOMMITEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "CVS Commit Editor"); const char CVSCOMMITEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "CVS Commit Editor");

View File

@@ -101,7 +101,7 @@ QString CvsEditor::changeUnderCursor(const QTextCursor &c) const
// Check if we are at the beginning of a line within a reasonable offset. // Check if we are at the beginning of a line within a reasonable offset.
// 2) Log: check for lines like "revision 1.1", cursor past "revision" // 2) Log: check for lines like "revision 1.1", cursor past "revision"
switch (contentType()) { switch (contentType()) {
case VcsBase::RegularCommandOutput: case VcsBase::OtherContent:
case VcsBase::DiffOutput: case VcsBase::DiffOutput:
break; break;
case VcsBase::AnnotateOutput: { case VcsBase::AnnotateOutput: {

View File

@@ -116,29 +116,26 @@ static const char CMD_ID_REPOSITORYUPDATE[] = "CVS.RepositoryUpdate";
static const VcsBaseEditorParameters editorParameters[] = { static const VcsBaseEditorParameters editorParameters[] = {
{ {
RegularCommandOutput, OtherContent,
"CVS Command Log Editor", // id "CVS Command Log Editor", // id
QT_TRANSLATE_NOOP("VCS", "CVS Command Log Editor"), // display name QT_TRANSLATE_NOOP("VCS", "CVS Command Log Editor"), // display name
"CVS Command Log Editor", // context "CVS Command Log Editor", // context
"application/vnd.nokia.text.scs_cvs_commandlog", "text/vnd.qtcreator.cvs.commandlog"},
"scslog"},
{ LogOutput, { LogOutput,
"CVS File Log Editor", // id "CVS File Log Editor", // id
QT_TRANSLATE_NOOP("VCS", "CVS File Log Editor"), // display name QT_TRANSLATE_NOOP("VCS", "CVS File Log Editor"), // display name
"CVS File Log Editor", // context "CVS File Log Editor", // context
"application/vnd.nokia.text.scs_cvs_filelog", "text/vnd.qtcreator.cvs.log"},
"scsfilelog"},
{ AnnotateOutput, { AnnotateOutput,
"CVS Annotation Editor", // id "CVS Annotation Editor", // id
QT_TRANSLATE_NOOP("VCS", "CVS Annotation Editor"), // display name QT_TRANSLATE_NOOP("VCS", "CVS Annotation Editor"), // display name
"CVS Annotation Editor", // context "CVS Annotation Editor", // context
"application/vnd.nokia.text.scs_cvs_annotation", "text/vnd.qtcreator.cvs.annotation"},
"scsannotate"},
{ DiffOutput, { DiffOutput,
"CVS Diff Editor", // id "CVS Diff Editor", // id
QT_TRANSLATE_NOOP("VCS", "CVS Diff Editor"), // display name QT_TRANSLATE_NOOP("VCS", "CVS Diff Editor"), // display name
"CVS Diff Editor", // context "CVS Diff Editor", // context
"text/x-patch","diff"} "text/x-patch"}
}; };
// Utility to find a parameter set by type // Utility to find a parameter set by type
@@ -1025,7 +1022,7 @@ bool CvsPlugin::status(const QString &topLevel, const QStringList &files, const
runCvs(topLevel, args, m_settings.timeOutMS(), 0); runCvs(topLevel, args, m_settings.timeOutMS(), 0);
const bool ok = response.result == CvsResponse::Ok; const bool ok = response.result == CvsResponse::Ok;
if (ok) if (ok)
showOutputInEditor(title, response.stdOut, RegularCommandOutput, topLevel, 0); showOutputInEditor(title, response.stdOut, OtherContent, topLevel, 0);
return ok; return ok;
} }

View File

@@ -124,6 +124,8 @@ public:
QByteArray toString(bool multiline = false, int indent = 0) const; QByteArray toString(bool multiline = false, int indent = 0) const;
qulonglong toAddress() const; qulonglong toAddress() const;
int toInt() const { return m_data.toInt(); } int toInt() const { return m_data.toInt(); }
QString toUtf8() const { return QString::fromUtf8(m_data); }
QString toLatin1() const { return QString::fromLatin1(m_data); }
void fromString(const QByteArray &str); void fromString(const QByteArray &str);
void fromStringMultiple(const QByteArray &str); void fromStringMultiple(const QByteArray &str);

View File

@@ -2546,35 +2546,6 @@ QString GdbEngine::breakLocation(const QString &file) const
return where; return where;
} }
BreakpointPathUsage GdbEngine::defaultEngineBreakpointPathUsage() const
{
// e.g. MinGW gdb 70200 (part of Nokia Qt SDK)
// fails to set breakpoints with absolute paths if
// the source path isn't canonical
if (m_gdbVersion < 70300)
return BreakpointUseShortPath;
// Use short path for file systems with symbolic links. On Windows, main.cpp
// is potentially ambiguous (ANGLE, DLL).
if (startParameters().toolChainAbi.os() != ProjectExplorer::Abi::WindowsOS)
return BreakpointUseShortPath;
//don't set absolute breakpoints for remote targets
switch (startMode()) {
case AttachToRemoteServer:
case AttachToRemoteProcess:
case LoadRemoteCore:
case StartRemoteProcess:
case StartRemoteGdb:
case StartRemoteEngine:
return BreakpointUseShortPath;
default:
break;
}
return BreakpointUseFullPath;
}
QByteArray GdbEngine::breakpointLocation(BreakpointModelId id) QByteArray GdbEngine::breakpointLocation(BreakpointModelId id)
{ {
BreakHandler *handler = breakHandler(); BreakHandler *handler = breakHandler();
@@ -2596,7 +2567,7 @@ QByteArray GdbEngine::breakpointLocation(BreakpointModelId id)
BreakpointPathUsage usage = data.pathUsage; BreakpointPathUsage usage = data.pathUsage;
if (usage == BreakpointPathUsageEngineDefault) if (usage == BreakpointPathUsageEngineDefault)
usage = defaultEngineBreakpointPathUsage(); usage = BreakpointUseShortPath;
const QString fileName = usage == BreakpointUseFullPath const QString fileName = usage == BreakpointUseFullPath
? data.fileName : breakLocation(data.fileName); ? data.fileName : breakLocation(data.fileName);
@@ -2614,7 +2585,7 @@ QByteArray GdbEngine::breakpointLocation2(BreakpointModelId id)
BreakpointPathUsage usage = data.pathUsage; BreakpointPathUsage usage = data.pathUsage;
if (usage == BreakpointPathUsageEngineDefault) if (usage == BreakpointPathUsageEngineDefault)
usage = defaultEngineBreakpointPathUsage(); usage = BreakpointUseShortPath;
const QString fileName = usage == BreakpointUseFullPath const QString fileName = usage == BreakpointUseFullPath
? data.fileName : breakLocation(data.fileName); ? data.fileName : breakLocation(data.fileName);
@@ -3778,7 +3749,7 @@ void GdbEngine::handleThreadInfo(const GdbResponse &response)
selectThread(other); selectThread(other);
} }
updateViews(); // Adjust Threads combobox. updateViews(); // Adjust Threads combobox.
if (false && m_hasInferiorThreadList && debuggerCore()->boolSetting(ShowThreadNames)) { if (m_hasInferiorThreadList && debuggerCore()->boolSetting(ShowThreadNames)) {
postCommand("threadnames " + postCommand("threadnames " +
debuggerCore()->action(MaximalStackDepth)->value().toByteArray(), debuggerCore()->action(MaximalStackDepth)->value().toByteArray(),
Discardable, CB(handleThreadNames)); Discardable, CB(handleThreadNames));

View File

@@ -456,7 +456,6 @@ private: ////////// View & Data Stuff //////////
void handleInfoLine(const GdbResponse &response); void handleInfoLine(const GdbResponse &response);
void extractDataFromInfoBreak(const QString &output, BreakpointModelId); void extractDataFromInfoBreak(const QString &output, BreakpointModelId);
void updateResponse(BreakpointResponse &response, const GdbMi &bkpt); void updateResponse(BreakpointResponse &response, const GdbMi &bkpt);
BreakpointPathUsage defaultEngineBreakpointPathUsage() const;
QByteArray breakpointLocation(BreakpointModelId id); // For gdb/MI. QByteArray breakpointLocation(BreakpointModelId id); // For gdb/MI.
QByteArray breakpointLocation2(BreakpointModelId id); // For gdb/CLI fallback. QByteArray breakpointLocation2(BreakpointModelId id); // For gdb/CLI fallback.
QString breakLocation(const QString &file) const; QString breakLocation(const QString &file) const;

View File

@@ -427,18 +427,18 @@ void LldbEngine::updateBreakpointData(const GdbMi &bkpt, bool added)
const int numChild = locations.children().size(); const int numChild = locations.children().size();
if (numChild > 1) { if (numChild > 1) {
foreach (const GdbMi &location, locations.children()) { foreach (const GdbMi &location, locations.children()) {
const int locid = location["locid"].data().toUShort(); const int locid = location["locid"].toInt();
BreakpointResponse sub; BreakpointResponse sub;
sub.id = BreakpointResponseId(rid.majorPart(), locid); sub.id = BreakpointResponseId(rid.majorPart(), locid);
sub.type = response.type; sub.type = response.type;
sub.address = location["addr"].toAddress(); sub.address = location["addr"].toAddress();
sub.functionName = QString::fromUtf8(location["func"].data()); sub.functionName = location["func"].toUtf8();
handler->insertSubBreakpoint(id, sub); handler->insertSubBreakpoint(id, sub);
} }
} else if (numChild == 1) { } else if (numChild == 1) {
const GdbMi location = locations.childAt(0); const GdbMi location = locations.childAt(0);
response.address = location["addr"].toAddress(); response.address = location["addr"].toAddress();
response.functionName = QString::fromUtf8(location["func"].data()); response.functionName = location["func"].toUtf8();
} else { } else {
QTC_CHECK(false); QTC_CHECK(false);
} }
@@ -460,11 +460,10 @@ void LldbEngine::refreshDisassembly(const GdbMi &data)
if (!agent.isNull()) { if (!agent.isNull()) {
foreach (const GdbMi &line, data["lines"].children()) { foreach (const GdbMi &line, data["lines"].children()) {
DisassemblerLine dl; DisassemblerLine dl;
QByteArray address = line["address"].data(); dl.address = line["address"].toAddress();
dl.address = address.toULongLong(0, 0); dl.data = line["inst"].toUtf8();
dl.data = _(line["inst"].data()); dl.function = line["func-name"].toUtf8();
dl.function = _(line["func-name"].data()); dl.offset = line["offset"].toInt();
dl.offset = line["offset"].data().toUInt();
result.appendLine(dl); result.appendLine(dl);
} }
agent->setContents(result); agent->setContents(result);
@@ -474,7 +473,7 @@ void LldbEngine::refreshDisassembly(const GdbMi &data)
void LldbEngine::refreshMemory(const GdbMi &data) void LldbEngine::refreshMemory(const GdbMi &data)
{ {
int cookie = data["cookie"].toInt(); int cookie = data["cookie"].toInt();
qulonglong addr = data["address"].toInt(); qulonglong addr = data["address"].toAddress();
QPointer<MemoryAgent> agent = m_memoryAgents.key(cookie); QPointer<MemoryAgent> agent = m_memoryAgents.key(cookie);
if (!agent.isNull()) { if (!agent.isNull()) {
QPointer<QObject> token = m_memoryAgentTokens.value(cookie); QPointer<QObject> token = m_memoryAgentTokens.value(cookie);
@@ -524,8 +523,8 @@ void LldbEngine::refreshModules(const GdbMi &modules)
Modules mods; Modules mods;
foreach (const GdbMi &item, modules.children()) { foreach (const GdbMi &item, modules.children()) {
Module module; Module module;
module.modulePath = QString::fromUtf8(item["file"].data()); module.modulePath = item["file"].toUtf8();
module.moduleName = QString::fromUtf8(item["name"].data()); module.moduleName = item["name"].toUtf8();
module.symbolsRead = Module::UnknownReadState; module.symbolsRead = Module::UnknownReadState;
module.startAddress = item["loaded_addr"].toAddress(); module.startAddress = item["loaded_addr"].toAddress();
module.endAddress = 0; // FIXME: End address not easily available. module.endAddress = 0; // FIXME: End address not easily available.
@@ -541,15 +540,15 @@ void LldbEngine::requestModuleSymbols(const QString &moduleName)
void LldbEngine::refreshSymbols(const GdbMi &symbols) void LldbEngine::refreshSymbols(const GdbMi &symbols)
{ {
QString moduleName = QString::fromUtf8(symbols["module"].data()); QString moduleName = symbols["module"].toUtf8();
Symbols syms; Symbols syms;
foreach (const GdbMi &item, symbols["symbols"].children()) { foreach (const GdbMi &item, symbols["symbols"].children()) {
Symbol symbol; Symbol symbol;
symbol.address = _(item["address"].data()); symbol.address = item["address"].toUtf8();
symbol.name = _(item["name"].data()); symbol.name = item["name"].toUtf8();
symbol.state = _(item["state"].data()); symbol.state = item["state"].toUtf8();
symbol.section = _(item["section"].data()); symbol.section = item["section"].toUtf8();
symbol.demangled = _(item["demangled"].data()); symbol.demangled = item["demangled"].toUtf8();
syms.append(symbol); syms.append(symbol);
} }
debuggerCore()->showModuleSymbols(moduleName, syms); debuggerCore()->showModuleSymbols(moduleName, syms);
@@ -828,7 +827,7 @@ void LldbEngine::refreshLocals(const GdbMi &vars)
dummy.name = decodeData(wname.data(), Base64Encoded8Bit); dummy.name = decodeData(wname.data(), Base64Encoded8Bit);
dummy.exp = dummy.name.toUtf8(); dummy.exp = dummy.name.toUtf8();
} else { } else {
dummy.name = _(child["name"].data()); dummy.name = child["name"].toUtf8();
} }
parseWatchData(handler->expandedINames(), dummy, child, &list); parseWatchData(handler->expandedINames(), dummy, child, &list);
} }
@@ -844,9 +843,9 @@ void LldbEngine::refreshStack(const GdbMi &stack)
foreach (const GdbMi &item, stack["frames"].children()) { foreach (const GdbMi &item, stack["frames"].children()) {
StackFrame frame; StackFrame frame;
frame.level = item["level"].toInt(); frame.level = item["level"].toInt();
frame.file = QString::fromLatin1(item["file"].data()); frame.file = item["file"].toUtf8();
frame.function = QString::fromLatin1(item["func"].data()); frame.function = item["func"].toUtf8();
frame.from = QString::fromLatin1(item["func"].data()); frame.from = item["func"].toUtf8();
frame.line = item["line"].toInt(); frame.line = item["line"].toInt();
frame.address = item["addr"].toAddress(); frame.address = item["addr"].toAddress();
frame.usable = QFileInfo(frame.file).isReadable(); frame.usable = QFileInfo(frame.file).isReadable();
@@ -855,6 +854,9 @@ void LldbEngine::refreshStack(const GdbMi &stack)
bool canExpand = stack["hasmore"].toInt(); bool canExpand = stack["hasmore"].toInt();
debuggerCore()->action(ExpandStack)->setEnabled(canExpand); debuggerCore()->action(ExpandStack)->setEnabled(canExpand);
handler->setFrames(frames); handler->setFrames(frames);
int index = stack["current-frame"].toInt();
handler->setCurrentIndex(index);
} }
void LldbEngine::refreshRegisters(const GdbMi &registers) void LldbEngine::refreshRegisters(const GdbMi &registers)
@@ -929,9 +931,9 @@ void LldbEngine::refreshState(const GdbMi &reportedState)
void LldbEngine::refreshLocation(const GdbMi &reportedLocation) void LldbEngine::refreshLocation(const GdbMi &reportedLocation)
{ {
QByteArray file = reportedLocation["file"].data(); QString file = reportedLocation["file"].toUtf8();
int line = reportedLocation["line"].toInt(); int line = reportedLocation["line"].toInt();
gotoLocation(Location(QString::fromUtf8(file), line)); gotoLocation(Location(file, line));
} }
void LldbEngine::reloadRegisters() void LldbEngine::reloadRegisters()
@@ -1035,16 +1037,31 @@ DebuggerEngine *createLldbEngine(const DebuggerStartParameters &startParameters)
// //
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
const LldbEngine::Command &LldbEngine::Command::arg(const char *name, int value) const const LldbEngine::Command &LldbEngine::Command::argHelper(const char *name, const QByteArray &data) const
{ {
args.append('\''); args.append('\'');
args.append(name); args.append(name);
args.append("':"); args.append("':");
args.append(QByteArray::number(value)); args.append(data);
args.append(','); args.append(",");
return *this; return *this;
} }
const LldbEngine::Command &LldbEngine::Command::arg(const char *name, int value) const
{
return argHelper(name, QByteArray::number(value));
}
const LldbEngine::Command &LldbEngine::Command::arg(const char *name, qlonglong value) const
{
return argHelper(name, QByteArray::number(value));
}
const LldbEngine::Command &LldbEngine::Command::arg(const char *name, qulonglong value) const
{
return argHelper(name, QByteArray::number(value));
}
const LldbEngine::Command &LldbEngine::Command::arg(const char *name, const QString &value) const const LldbEngine::Command &LldbEngine::Command::arg(const char *name, const QString &value) const
{ {
return arg(name, value.toUtf8().data()); return arg(name, value.toUtf8().data());

View File

@@ -68,6 +68,8 @@ private:
Command(const char *f) : function(f) {} Command(const char *f) : function(f) {}
const Command &arg(const char *name, int value) const; const Command &arg(const char *name, int value) const;
const Command &arg(const char *name, qlonglong value) const;
const Command &arg(const char *name, qulonglong value) const;
const Command &arg(const char *name, const QString &value) const; const Command &arg(const char *name, const QString &value) const;
const Command &arg(const char *name, const QByteArray &value) const; const Command &arg(const char *name, const QByteArray &value) const;
const Command &arg(const char *name, const char *value) const; const Command &arg(const char *name, const char *value) const;
@@ -78,6 +80,8 @@ private:
QByteArray function; QByteArray function;
mutable QByteArray args; mutable QByteArray args;
private:
const Command &argHelper(const char *name, const QByteArray &value) const;
}; };
// DebuggerEngine implementation // DebuggerEngine implementation

View File

@@ -39,6 +39,9 @@
#include <QStyle> #include <QStyle>
#include <QLabel> #include <QLabel>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QToolBar>
#include <QComboBox>
#include <QFileInfo>
namespace DiffEditor { namespace DiffEditor {
@@ -48,9 +51,12 @@ DiffEditorEditable::DiffEditorEditable(DiffEditorWidget *editorWidget)
: IEditor(0), : IEditor(0),
m_file(new Internal::DiffEditorFile(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE), this)), m_file(new Internal::DiffEditorFile(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE), this)),
m_editorWidget(editorWidget), m_editorWidget(editorWidget),
m_toolWidget(0) m_toolWidget(0),
m_entriesComboBox(0)
{ {
setWidget(editorWidget); setWidget(editorWidget);
connect(m_editorWidget, SIGNAL(navigatedToDiffFile(int)),
this, SLOT(activateEntry(int)));
} }
DiffEditorEditable::~DiffEditorEditable() DiffEditorEditable::~DiffEditorEditable()
@@ -115,7 +121,6 @@ static QToolBar *createToolBar(const QWidget *someWidget)
toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
const int size = someWidget->style()->pixelMetric(QStyle::PM_SmallIconSize); const int size = someWidget->style()->pixelMetric(QStyle::PM_SmallIconSize);
toolBar->setIconSize(QSize(size, size)); toolBar->setIconSize(QSize(size, size));
toolBar->addSeparator();
return toolBar; return toolBar;
} }
@@ -128,12 +133,15 @@ QWidget *DiffEditorEditable::toolBar()
// Create // Create
m_toolWidget = createToolBar(m_editorWidget); m_toolWidget = createToolBar(m_editorWidget);
QWidget *spacerWidget = new QWidget(); m_entriesComboBox = new QComboBox;
QLayout *spacerLayout = new QHBoxLayout(); m_entriesComboBox->setMinimumContentsLength(20);
spacerLayout->setMargin(0); // Make the combo box prefer to expand
spacerLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); QSizePolicy policy = m_entriesComboBox->sizePolicy();
spacerWidget->setLayout(spacerLayout); policy.setHorizontalPolicy(QSizePolicy::Expanding);
m_toolWidget->addWidget(spacerWidget); m_entriesComboBox->setSizePolicy(policy);
connect(m_entriesComboBox, SIGNAL(activated(int)),
this, SLOT(entryActivated(int)));
m_toolWidget->addWidget(m_entriesComboBox);
QToolButton *whitespaceButton = new QToolButton(m_toolWidget); QToolButton *whitespaceButton = new QToolButton(m_toolWidget);
whitespaceButton->setText(tr("Ignore Whitespace")); whitespaceButton->setText(tr("Ignore Whitespace"));
@@ -156,6 +164,78 @@ QWidget *DiffEditorEditable::toolBar()
return m_toolWidget; return m_toolWidget;
} }
void DiffEditorEditable::setDiff(const QList<DiffEditorWidget::DiffFilesContents> &diffFileList,
const QString &workingDirectory)
{
m_entriesComboBox->clear();
const int count = diffFileList.count();
for (int i = 0; i < count; i++) {
const DiffEditorWidget::DiffFileInfo leftEntry = diffFileList.at(i).leftFileInfo;
const DiffEditorWidget::DiffFileInfo rightEntry = diffFileList.at(i).rightFileInfo;
const QString leftShortFileName = QFileInfo(leftEntry.fileName).fileName();
const QString rightShortFileName = QFileInfo(rightEntry.fileName).fileName();
QString itemText;
QString itemToolTip;
if (leftEntry.fileName == rightEntry.fileName) {
itemText = leftShortFileName;
if (leftEntry.typeInfo.isEmpty() && rightEntry.typeInfo.isEmpty()) {
itemToolTip = leftEntry.fileName;
} else {
itemToolTip = tr("[%1] vs. [%2] %3")
.arg(leftEntry.typeInfo, rightEntry.typeInfo, leftEntry.fileName);
}
} else {
if (leftShortFileName == rightShortFileName) {
itemText = leftShortFileName;
} else {
itemText = tr("%1 vs. %2")
.arg(leftShortFileName, rightShortFileName);
}
if (leftEntry.typeInfo.isEmpty() && rightEntry.typeInfo.isEmpty()) {
itemToolTip = tr("%1 vs. %2")
.arg(leftEntry.fileName, rightEntry.fileName);
} else {
itemToolTip = tr("[%1] %2 vs. [%3] %4")
.arg(leftEntry.typeInfo, leftEntry.fileName, rightEntry.typeInfo, rightEntry.fileName);
}
}
m_entriesComboBox->addItem(itemText);
m_entriesComboBox->setItemData(m_entriesComboBox->count() - 1, itemToolTip, Qt::ToolTipRole);
}
updateEntryToolTip();
m_editorWidget->setDiff(diffFileList, workingDirectory);
}
void DiffEditorEditable::clear(const QString &message)
{
m_entriesComboBox->clear();
updateEntryToolTip();
m_editorWidget->clear(message);
}
void DiffEditorEditable::updateEntryToolTip()
{
const QString &toolTip = m_entriesComboBox->itemData(
m_entriesComboBox->currentIndex(), Qt::ToolTipRole).toString();
m_entriesComboBox->setToolTip(toolTip);
}
void DiffEditorEditable::entryActivated(int index)
{
updateEntryToolTip();
m_editorWidget->navigateToDiffFile(index);
}
void DiffEditorEditable::activateEntry(int index)
{
m_entriesComboBox->blockSignals(true);
m_entriesComboBox->setCurrentIndex(index);
m_entriesComboBox->blockSignals(false);
updateEntryToolTip();
}
QByteArray DiffEditorEditable::saveState() const QByteArray DiffEditorEditable::saveState() const
{ {
return QByteArray(); return QByteArray();

View File

@@ -31,16 +31,18 @@
#define DIFFEDITOREDITABLE_H #define DIFFEDITOREDITABLE_H
#include "diffeditor_global.h" #include "diffeditor_global.h"
#include "diffeditorwidget.h"
#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/idocument.h> #include <coreplugin/idocument.h>
#include <QToolBar> QT_BEGIN_NAMESPACE
class QToolBar;
class QComboBox;
QT_END_NAMESPACE
namespace DiffEditor { namespace DiffEditor {
class DiffEditorWidget;
namespace Internal { namespace Internal {
class DiffEditorFile; class DiffEditorFile;
} }
@@ -53,6 +55,10 @@ public:
virtual ~DiffEditorEditable(); virtual ~DiffEditorEditable();
public: public:
void setDiff(const QList<DiffEditorWidget::DiffFilesContents> &diffFileList,
const QString &workingDirectory = QString());
void clear(const QString &message);
// Core::IEditor // Core::IEditor
bool createNew(const QString &contents); bool createNew(const QString &contents);
bool open(QString *errorString, const QString &fileName, const QString &realFileName); bool open(QString *errorString, const QString &fileName, const QString &realFileName);
@@ -69,11 +75,19 @@ public:
QByteArray saveState() const; QByteArray saveState() const;
bool restoreState(const QByteArray &state); bool restoreState(const QByteArray &state);
public slots:
void activateEntry(int index);
private slots:
void entryActivated(int index);
private: private:
void updateEntryToolTip();
Internal::DiffEditorFile *m_file; Internal::DiffEditorFile *m_file;
DiffEditorWidget *m_editorWidget; DiffEditorWidget *m_editorWidget;
QToolBar *m_toolWidget; QToolBar *m_toolWidget;
QComboBox *m_entriesComboBox;
mutable QString m_displayName; mutable QString m_displayName;
}; };

View File

@@ -136,31 +136,28 @@ void DiffEditorPlugin::diff()
const Core::Id editorId = Constants::DIFF_EDITOR_ID; const Core::Id editorId = Constants::DIFF_EDITOR_ID;
//: Editor title //: Editor title
QString title = tr("Diff \"%1\", \"%2\"").arg(fileName1).arg(fileName2); QString title = tr("Diff \"%1\", \"%2\"").arg(fileName1).arg(fileName2);
Core::IEditor *outputEditor = Core::EditorManager::openEditorWithContents(editorId, &title, QString()); DiffEditorEditable *editorEditable = qobject_cast<DiffEditorEditable *>
Core::EditorManager::activateEditor(outputEditor, Core::EditorManager::ModeSwitch); (Core::EditorManager::openEditorWithContents(editorId, &title, QString()));
DiffEditorWidget *editorWidget = getDiffEditorWidget(outputEditor); if (!editorEditable)
if (editorWidget) { return;
const QString text1 = getFileContents(fileName1, editorWidget->codec());
const QString text2 = getFileContents(fileName2, editorWidget->codec());
DiffEditorWidget::DiffFilesContents dfc; Core::EditorManager::activateEditor(editorEditable, Core::EditorManager::ModeSwitch);
dfc.leftFileInfo = fileName1;
dfc.leftText = text1;
dfc.rightFileInfo = fileName2;
dfc.rightText = text2;
QList<DiffEditorWidget::DiffFilesContents> list;
list.append(dfc);
editorWidget->setDiff(list); DiffEditorWidget *editorWidget = editorEditable->editorWidget();
}
}
DiffEditorWidget *DiffEditorPlugin::getDiffEditorWidget(const Core::IEditor *editor) const const QString text1 = getFileContents(fileName1, editorWidget->codec());
{ const QString text2 = getFileContents(fileName2, editorWidget->codec());
if (const DiffEditorEditable *de = qobject_cast<const DiffEditorEditable *>(editor))
return de->editorWidget(); DiffEditorWidget::DiffFilesContents dfc;
return 0; dfc.leftFileInfo = fileName1;
dfc.leftText = text1;
dfc.rightFileInfo = fileName2;
dfc.rightText = text2;
QList<DiffEditorWidget::DiffFilesContents> list;
list.append(dfc);
editorEditable->setDiff(list);
} }
QString DiffEditorPlugin::getFileContents(const QString &fileName, QTextCodec *codec) const QString DiffEditorPlugin::getFileContents(const QString &fileName, QTextCodec *codec) const

View File

@@ -66,7 +66,6 @@ private slots:
void diff(); void diff();
private: private:
DiffEditorWidget *getDiffEditorWidget(const Core::IEditor *editor) const;
QString getFileContents(const QString &fileName, QTextCodec *codec) const; QString getFileContents(const QString &fileName, QTextCodec *codec) const;
}; };

View File

@@ -36,6 +36,7 @@
#include <QScrollBar> #include <QScrollBar>
#include <QPainter> #include <QPainter>
#include <QDir> #include <QDir>
#include <QToolButton>
#include <texteditor/basetexteditor.h> #include <texteditor/basetexteditor.h>
#include <texteditor/snippets/snippeteditor.h> #include <texteditor/snippets/snippeteditor.h>
@@ -130,6 +131,8 @@ public:
void setSkippedLines(int blockNumber, int skippedLines) { m_skippedLines[blockNumber] = skippedLines; setSeparator(blockNumber, true); } void setSkippedLines(int blockNumber, int skippedLines) { m_skippedLines[blockNumber] = skippedLines; setSeparator(blockNumber, true); }
void setSeparator(int blockNumber, bool separator) { m_separators[blockNumber] = separator; } void setSeparator(int blockNumber, bool separator) { m_separators[blockNumber] = separator; }
bool isFileLine(int blockNumber) const { return m_fileInfo.contains(blockNumber); } bool isFileLine(int blockNumber) const { return m_fileInfo.contains(blockNumber); }
int blockNumberForFileIndex(int fileIndex) const;
int fileIndexForBlockNumber(int blockNumber) const;
bool isChunkLine(int blockNumber) const { return m_skippedLines.contains(blockNumber); } bool isChunkLine(int blockNumber) const { return m_skippedLines.contains(blockNumber); }
void clearAll(); void clearAll();
void clearAll(const QString &message); void clearAll(const QString &message);
@@ -242,6 +245,36 @@ void DiffViewEditorWidget::setLineNumber(int blockNumber, int lineNumber)
m_lineNumberDigits = qMax(m_lineNumberDigits, lineNumberString.count()); m_lineNumberDigits = qMax(m_lineNumberDigits, lineNumberString.count());
} }
int DiffViewEditorWidget::blockNumberForFileIndex(int fileIndex) const
{
if (fileIndex < 0 || fileIndex >= m_fileInfo.count())
return -1;
QMap<int, DiffEditorWidget::DiffFileInfo>::const_iterator it
= m_fileInfo.constBegin();
for (int i = 0; i < fileIndex; i++)
++it;
return it.key();
}
int DiffViewEditorWidget::fileIndexForBlockNumber(int blockNumber) const
{
QMap<int, DiffEditorWidget::DiffFileInfo>::const_iterator it
= m_fileInfo.constBegin();
QMap<int, DiffEditorWidget::DiffFileInfo>::const_iterator itEnd
= m_fileInfo.constEnd();
int i = -1;
while (it != itEnd) {
if (it.key() > blockNumber)
break;
++it;
++i;
}
return i;
}
void DiffViewEditorWidget::clearAll() void DiffViewEditorWidget::clearAll()
{ {
clearAll(tr("No difference")); clearAll(tr("No difference"));
@@ -477,10 +510,20 @@ DiffEditorWidget::DiffEditorWidget(QWidget *parent)
: QWidget(parent), : QWidget(parent),
m_contextLinesNumber(3), m_contextLinesNumber(3),
m_ignoreWhitespaces(true), m_ignoreWhitespaces(true),
m_syncScrollBars(true),
m_foldingBlocker(false) m_foldingBlocker(false)
{ {
TextEditor::TextEditorSettings *settings = TextEditorSettings::instance(); TextEditor::TextEditorSettings *settings = TextEditorSettings::instance();
QToolButton *toggleSync = new QToolButton();
toggleSync = new QToolButton;
toggleSync->setText(QLatin1String("S"));
toggleSync->setCheckable(true);
toggleSync->setChecked(m_syncScrollBars);
toggleSync->setToolTip(tr("Synchronize Horizontal Scroll Bars"));
toggleSync->setAutoRaise(true);
connect(toggleSync, SIGNAL(clicked(bool)), this, SLOT(toggleScrollBarSynchronization(bool)));
m_leftEditor = new DiffViewEditorWidget(this); m_leftEditor = new DiffViewEditorWidget(this);
m_leftEditor->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_leftEditor->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_leftEditor->setReadOnly(true); m_leftEditor->setReadOnly(true);
@@ -490,6 +533,7 @@ DiffEditorWidget::DiffEditorWidget(QWidget *parent)
m_leftEditor->setCodeStyle(settings->codeStyle()); m_leftEditor->setCodeStyle(settings->codeStyle());
m_rightEditor = new DiffViewEditorWidget(this); m_rightEditor = new DiffViewEditorWidget(this);
m_rightEditor->setCornerWidget(toggleSync);
m_rightEditor->setReadOnly(true); m_rightEditor->setReadOnly(true);
m_rightEditor->setHighlightCurrentLine(false); m_rightEditor->setHighlightCurrentLine(false);
m_rightEditor->setWordWrapMode(QTextOption::NoWrap); m_rightEditor->setWordWrapMode(QTextOption::NoWrap);
@@ -497,19 +541,32 @@ DiffEditorWidget::DiffEditorWidget(QWidget *parent)
m_rightEditor->setCodeStyle(settings->codeStyle()); m_rightEditor->setCodeStyle(settings->codeStyle());
connect(m_leftEditor->verticalScrollBar(), SIGNAL(valueChanged(int)), connect(m_leftEditor->verticalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(leftSliderChanged())); this, SLOT(leftVSliderChanged()));
connect(m_leftEditor->verticalScrollBar(), SIGNAL(actionTriggered(int)), connect(m_leftEditor->verticalScrollBar(), SIGNAL(actionTriggered(int)),
this, SLOT(leftSliderChanged())); this, SLOT(leftVSliderChanged()));
connect(m_leftEditor->horizontalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(leftHSliderChanged()));
connect(m_leftEditor->horizontalScrollBar(), SIGNAL(actionTriggered(int)),
this, SLOT(leftHSliderChanged()));
connect(m_leftEditor, SIGNAL(cursorPositionChanged()), connect(m_leftEditor, SIGNAL(cursorPositionChanged()),
this, SLOT(leftSliderChanged())); this, SLOT(leftCursorPositionChanged()));
connect(m_leftEditor->document()->documentLayout(), SIGNAL(documentSizeChanged(QSizeF)), connect(m_leftEditor->document()->documentLayout(), SIGNAL(documentSizeChanged(QSizeF)),
this, SLOT(leftDocumentSizeChanged())); this, SLOT(leftDocumentSizeChanged()));
connect(m_rightEditor->verticalScrollBar(), SIGNAL(valueChanged(int)), connect(m_rightEditor->verticalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(rightSliderChanged())); this, SLOT(rightVSliderChanged()));
connect(m_rightEditor->verticalScrollBar(), SIGNAL(actionTriggered(int)), connect(m_rightEditor->verticalScrollBar(), SIGNAL(actionTriggered(int)),
this, SLOT(rightSliderChanged())); this, SLOT(rightVSliderChanged()));
connect(m_rightEditor->horizontalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(rightHSliderChanged()));
connect(m_rightEditor->horizontalScrollBar(), SIGNAL(actionTriggered(int)),
this, SLOT(rightHSliderChanged()));
connect(m_rightEditor, SIGNAL(cursorPositionChanged()), connect(m_rightEditor, SIGNAL(cursorPositionChanged()),
this, SLOT(rightSliderChanged())); this, SLOT(rightCursorPositionChanged()));
connect(m_rightEditor->document()->documentLayout(), SIGNAL(documentSizeChanged(QSizeF)), connect(m_rightEditor->document()->documentLayout(), SIGNAL(documentSizeChanged(QSizeF)),
this, SLOT(rightDocumentSizeChanged())); this, SLOT(rightDocumentSizeChanged()));
@@ -517,6 +574,7 @@ DiffEditorWidget::DiffEditorWidget(QWidget *parent)
m_splitter->addWidget(m_leftEditor); m_splitter->addWidget(m_leftEditor);
m_splitter->addWidget(m_rightEditor); m_splitter->addWidget(m_rightEditor);
QVBoxLayout *l = new QVBoxLayout(this); QVBoxLayout *l = new QVBoxLayout(this);
l->setMargin(0);
l->addWidget(m_splitter); l->addWidget(m_splitter);
clear(); clear();
@@ -600,6 +658,24 @@ void DiffEditorWidget::setIgnoreWhitespaces(bool ignore)
setDiff(m_diffList); setDiff(m_diffList);
} }
void DiffEditorWidget::navigateToDiffFile(int diffFileIndex)
{
const int blockNumber = m_leftEditor->blockNumberForFileIndex(diffFileIndex);
QTextBlock leftBlock = m_leftEditor->document()->findBlockByNumber(blockNumber);
QTextCursor leftCursor = m_leftEditor->textCursor();
leftCursor.setPosition(leftBlock.position());
m_leftEditor->setTextCursor(leftCursor);
QTextBlock rightBlock = m_rightEditor->document()->findBlockByNumber(blockNumber);
QTextCursor rightCursor = m_rightEditor->textCursor();
rightCursor.setPosition(rightBlock.position());
m_rightEditor->setTextCursor(rightCursor);
m_leftEditor->centerCursor();
m_rightEditor->centerCursor();
}
QTextCodec *DiffEditorWidget::codec() const QTextCodec *DiffEditorWidget::codec() const
{ {
return const_cast<QTextCodec *>(m_leftEditor->codec()); return const_cast<QTextCodec *>(m_leftEditor->codec());
@@ -1277,16 +1353,42 @@ void DiffEditorWidget::colorDiff(const QList<FileData> &fileDataList)
+ rightSelections); + rightSelections);
} }
void DiffEditorWidget::leftSliderChanged() void DiffEditorWidget::leftVSliderChanged()
{ {
m_rightEditor->verticalScrollBar()->setValue(m_leftEditor->verticalScrollBar()->value()); m_rightEditor->verticalScrollBar()->setValue(m_leftEditor->verticalScrollBar()->value());
} }
void DiffEditorWidget::rightSliderChanged() void DiffEditorWidget::rightVSliderChanged()
{ {
m_leftEditor->verticalScrollBar()->setValue(m_rightEditor->verticalScrollBar()->value()); m_leftEditor->verticalScrollBar()->setValue(m_rightEditor->verticalScrollBar()->value());
} }
void DiffEditorWidget::leftHSliderChanged()
{
if (m_syncScrollBars)
m_rightEditor->horizontalScrollBar()->setValue(m_leftEditor->horizontalScrollBar()->value());
}
void DiffEditorWidget::rightHSliderChanged()
{
if (m_syncScrollBars)
m_leftEditor->horizontalScrollBar()->setValue(m_rightEditor->horizontalScrollBar()->value());
}
void DiffEditorWidget::leftCursorPositionChanged()
{
leftVSliderChanged();
leftHSliderChanged();
emit navigatedToDiffFile(m_leftEditor->fileIndexForBlockNumber(m_leftEditor->textCursor().blockNumber()));
}
void DiffEditorWidget::rightCursorPositionChanged()
{
rightVSliderChanged();
rightHSliderChanged();
emit navigatedToDiffFile(m_rightEditor->fileIndexForBlockNumber(m_rightEditor->textCursor().blockNumber()));
}
void DiffEditorWidget::leftDocumentSizeChanged() void DiffEditorWidget::leftDocumentSizeChanged()
{ {
synchronizeFoldings(m_leftEditor, m_rightEditor); synchronizeFoldings(m_leftEditor, m_rightEditor);
@@ -1297,6 +1399,11 @@ void DiffEditorWidget::rightDocumentSizeChanged()
synchronizeFoldings(m_rightEditor, m_leftEditor); synchronizeFoldings(m_rightEditor, m_leftEditor);
} }
void DiffEditorWidget::toggleScrollBarSynchronization(bool on)
{
m_syncScrollBars = on;
}
/* Special version of that method (original: TextEditor::BaseTextDocumentLayout::doFoldOrUnfold()) /* Special version of that method (original: TextEditor::BaseTextDocumentLayout::doFoldOrUnfold())
The hack lies in fact, that when unfolding all direct sub-blocks are made visible, The hack lies in fact, that when unfolding all direct sub-blocks are made visible,
while some of them need to stay invisible (i.e. unfolded chunk lines) while some of them need to stay invisible (i.e. unfolded chunk lines)

View File

@@ -86,16 +86,25 @@ public:
public slots: public slots:
void setContextLinesNumber(int lines); void setContextLinesNumber(int lines);
void setIgnoreWhitespaces(bool ignore); void setIgnoreWhitespaces(bool ignore);
void navigateToDiffFile(int diffFileIndex);
signals:
void navigatedToDiffFile(int diffFileIndex);
protected: protected:
TextEditor::SnippetEditorWidget *leftEditor() const; TextEditor::SnippetEditorWidget *leftEditor() const;
TextEditor::SnippetEditorWidget *rightEditor() const; TextEditor::SnippetEditorWidget *rightEditor() const;
private slots: private slots:
void leftSliderChanged(); void leftVSliderChanged();
void rightSliderChanged(); void rightVSliderChanged();
void leftHSliderChanged();
void rightHSliderChanged();
void leftCursorPositionChanged();
void rightCursorPositionChanged();
void leftDocumentSizeChanged(); void leftDocumentSizeChanged();
void rightDocumentSizeChanged(); void rightDocumentSizeChanged();
void toggleScrollBarSynchronization(bool on);
private: private:
struct DiffList { struct DiffList {
@@ -130,6 +139,7 @@ private:
QList<FileData> m_contextFileData; // ultimate data to be shown, contextLinesNumber taken into account QList<FileData> m_contextFileData; // ultimate data to be shown, contextLinesNumber taken into account
int m_contextLinesNumber; int m_contextLinesNumber;
bool m_ignoreWhitespaces; bool m_ignoreWhitespaces;
bool m_syncScrollBars;
bool m_foldingBlocker; bool m_foldingBlocker;
}; };

View File

@@ -40,9 +40,9 @@ const char GENERICMIMETYPE[] = "text/x-generic-project"; // ### FIXME
const char C_FILESEDITOR[] = ".files Editor"; const char C_FILESEDITOR[] = ".files Editor";
const char FILES_EDITOR_ID[] = "QT4.FilesEditor"; const char FILES_EDITOR_ID[] = "QT4.FilesEditor";
const char FILES_MIMETYPE[] = "application/vnd.nokia.qt.generic.files"; const char FILES_MIMETYPE[] = "application/vnd.qtcreator.generic.files";
const char INCLUDES_MIMETYPE[] = "application/vnd.nokia.qt.generic.includes"; const char INCLUDES_MIMETYPE[] = "application/vnd.qtcreator.generic.includes";
const char CONFIG_MIMETYPE[] = "application/vnd.nokia.qt.generic.config"; const char CONFIG_MIMETYPE[] = "application/vnd.qtcreator.generic.config";
// Project // Project
const char GENERICPROJECT_ID[] = "GenericProjectManager.GenericProject"; const char GENERICPROJECT_ID[] = "GenericProjectManager.GenericProject";

View File

@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="text/vnd.qtcreator.git.commit">
<sub-class-of type="text/plain"/>
<comment>Git Commit File</comment>
<glob pattern="COMMIT_MSG"/>
<glob pattern="COMMIT_EDITMSG"/>
</mime-type>
</mime-info>

View File

@@ -62,4 +62,6 @@ include(gitorious/gitorious.pri)
RESOURCES += \ RESOURCES += \
git.qrc git.qrc
OTHER_FILES += Git.mimetypes.xml
include(gerrit/gerrit.pri) include(gerrit/gerrit.pri)

View File

@@ -14,6 +14,7 @@ QtcPlugin {
Depends { name: "Locator" } Depends { name: "Locator" }
files: [ files: [
"Git.mimetypes.xml",
"annotationhighlighter.cpp", "annotationhighlighter.cpp",
"annotationhighlighter.h", "annotationhighlighter.h",
"branchadddialog.cpp", "branchadddialog.cpp",

View File

@@ -2,5 +2,6 @@
<qresource prefix="/git"> <qresource prefix="/git">
<file>images/git.png</file> <file>images/git.png</file>
<file>images/gitorious.png</file> <file>images/gitorious.png</file>
<file>Git.mimetypes.xml</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -75,6 +75,8 @@
static const char GIT_DIRECTORY[] = ".git"; static const char GIT_DIRECTORY[] = ".git";
static const char graphLogFormatC[] = "%h %d %an %s %ci"; static const char graphLogFormatC[] = "%h %d %an %s %ci";
static const char HEAD[] = "HEAD";
namespace Git { namespace Git {
namespace Internal { namespace Internal {
@@ -84,10 +86,32 @@ class GitDiffHandler : public QObject
Q_OBJECT Q_OBJECT
public: public:
GitDiffHandler(const QString &gitPath, enum RevisionType {
WorkingTree,
Index,
Other
};
struct Revision {
Revision() : type(WorkingTree) { }
Revision(RevisionType t) : type(t) { }
Revision(RevisionType t, const QString &i) : type(t), id(i) { }
RevisionType type;
QString id; // can be sha or HEAD
QString infoText() const
{
switch (type) {
case WorkingTree: return tr("Working tree");
case Index: return tr("Index");
default: return id;
}
}
};
GitDiffHandler(DiffEditor::DiffEditorEditable *editor,
const QString &gitPath,
const QString &workingDirectory, const QString &workingDirectory,
const QProcessEnvironment &environment, const QProcessEnvironment &environment,
DiffEditor::DiffEditorWidget *editor,
int timeout); int timeout);
// index -> working tree // index -> working tree
@@ -99,6 +123,10 @@ public:
void diffProjects(const QStringList &projectPaths); void diffProjects(const QStringList &projectPaths);
// index -> working tree // index -> working tree
void diffRepository(); void diffRepository();
// branch HEAD -> working tree
void diffBranch(const QString &branchName);
// id^ -> id
void show(const QString &id);
private slots: private slots:
void slotFileListReceived(const QByteArray &data); void slotFileListReceived(const QByteArray &data);
@@ -106,42 +134,51 @@ private slots:
private: private:
void collectFilesList(const QStringList &additionalArguments); void collectFilesList(const QStringList &additionalArguments);
void prepareForCollection();
void collectFilesContents(); void collectFilesContents();
void feedEditor(); void feedEditor();
QString workingTreeContents(const QString &fileName) const; QString workingTreeContents(const QString &fileName) const;
QPointer<DiffEditor::DiffEditorEditable> m_editor;
const QString m_gitPath; const QString m_gitPath;
const QString m_workingDirectory; const QString m_workingDirectory;
const QProcessEnvironment m_processEnvironment; const QProcessEnvironment m_processEnvironment;
QWeakPointer<DiffEditor::DiffEditorWidget> m_editor;
const int m_timeout; const int m_timeout;
const QString m_waitMessage; const QString m_waitMessage;
enum RevisionType { struct RevisionRange {
Head = 0x01, RevisionRange() { }
Index = 0x02, RevisionRange(const Revision &b, const Revision &e) : begin(b), end(e) { }
WorkingTree = 0x04 Revision begin;
Revision end;
}; };
QStringList m_requestedHeadFileNames; // filename, revision range
QStringList m_requestedIndexFileNames; QMap<QString, QList<RevisionRange> > m_requestedRevisionRanges;
// filename, revision, dummy
QMap<QString, QMap<Revision, bool> > m_pendingRevisions;
// filename, revision, contents
QMap<QString, QMap<Revision, QString> > m_collectedRevisions;
QStringList m_headFileNames; RevisionRange m_requestedRevisionRange;
QStringList m_indexFileNames;
QStringList m_headContents;
QStringList m_indexContents;
}; };
GitDiffHandler::GitDiffHandler(const QString &gitPath, inline bool operator<(const GitDiffHandler::Revision &rev1, const GitDiffHandler::Revision &rev2)
{
if (rev1.type != rev2.type)
return rev1.type < rev2.type;
return rev1.id < rev2.id;
}
GitDiffHandler::GitDiffHandler(DiffEditor::DiffEditorEditable *editor,
const QString &gitPath,
const QString &workingDirectory, const QString &workingDirectory,
const QProcessEnvironment &environment, const QProcessEnvironment &environment,
DiffEditor::DiffEditorWidget *editor,
int timeout) int timeout)
: m_gitPath(gitPath), : m_editor(editor),
m_gitPath(gitPath),
m_workingDirectory(workingDirectory), m_workingDirectory(workingDirectory),
m_processEnvironment(environment), m_processEnvironment(environment),
m_editor(editor),
m_timeout(timeout), m_timeout(timeout),
m_waitMessage(tr("Waiting for data...")) m_waitMessage(tr("Waiting for data..."))
{ {
@@ -149,40 +186,71 @@ GitDiffHandler::GitDiffHandler(const QString &gitPath,
void GitDiffHandler::diffFile(const QString &fileName) void GitDiffHandler::diffFile(const QString &fileName)
{ {
m_requestedIndexFileNames << fileName; m_requestedRevisionRange = RevisionRange(
collectFilesList(QStringList() << QLatin1String("--") << m_requestedIndexFileNames); Revision(Other, QLatin1String(HEAD)),
Revision(WorkingTree));
collectFilesList(QStringList() << QLatin1String("--") << fileName);
} }
void GitDiffHandler::diffFiles(const QStringList &stagedFileNames, const QStringList &unstagedFileNames) void GitDiffHandler::diffFiles(const QStringList &stagedFileNames, const QStringList &unstagedFileNames)
{ {
m_requestedHeadFileNames = stagedFileNames; RevisionRange stagedRange = RevisionRange(
m_requestedHeadFileNames.removeDuplicates(); Revision(Other, QLatin1String(HEAD)),
m_requestedIndexFileNames = unstagedFileNames; Revision(WorkingTree));
m_requestedIndexFileNames.removeDuplicates(); RevisionRange unstagedRange = RevisionRange(
Revision(Index),
Revision(WorkingTree));
m_headFileNames = m_requestedHeadFileNames; for (int i = 0; i < stagedFileNames.count(); i++)
m_indexFileNames = m_requestedIndexFileNames; m_requestedRevisionRanges[stagedFileNames.at(i)].append(stagedRange);
for (int i = 0; i < m_headFileNames.count(); i++) {
const QString headFileName = m_headFileNames.at(i); for (int i = 0; i < unstagedFileNames.count(); i++)
if (!m_indexFileNames.contains(headFileName)) m_requestedRevisionRanges[unstagedFileNames.at(i)].append(unstagedRange);
m_indexFileNames.append(headFileName);
} prepareForCollection();
collectFilesContents(); collectFilesContents();
} }
void GitDiffHandler::diffProjects(const QStringList &projectPaths) void GitDiffHandler::diffProjects(const QStringList &projectPaths)
{ {
m_requestedRevisionRange = RevisionRange(
Revision(Other, QLatin1String(HEAD)),
Revision(WorkingTree));
collectFilesList(QStringList() << QLatin1String("--") << projectPaths); collectFilesList(QStringList() << QLatin1String("--") << projectPaths);
} }
void GitDiffHandler::diffRepository() void GitDiffHandler::diffRepository()
{ {
m_requestedRevisionRange = RevisionRange(
Revision(Other, QLatin1String(HEAD)),
Revision(WorkingTree));
collectFilesList(QStringList()); collectFilesList(QStringList());
} }
void GitDiffHandler::diffBranch(const QString &branchName)
{
m_requestedRevisionRange = RevisionRange(
Revision(Other, branchName),
Revision(WorkingTree));
collectFilesList(QStringList() << branchName);
}
void GitDiffHandler::show(const QString &id)
{
Revision begin(Other, id + QLatin1Char('^'));
Revision end(Other, id);
m_requestedRevisionRange = RevisionRange(begin, end);
collectFilesList(QStringList() << begin.id << end.id);
}
void GitDiffHandler::collectFilesList(const QStringList &additionalArguments) void GitDiffHandler::collectFilesList(const QStringList &additionalArguments)
{ {
m_editor.data()->clear(m_waitMessage); m_editor->clear(m_waitMessage);
VcsBase::Command *command = new VcsBase::Command(m_gitPath, m_workingDirectory, m_processEnvironment); VcsBase::Command *command = new VcsBase::Command(m_gitPath, m_workingDirectory, m_processEnvironment);
connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(slotFileListReceived(QByteArray))); connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(slotFileListReceived(QByteArray)));
QStringList arguments; QStringList arguments;
@@ -196,38 +264,79 @@ void GitDiffHandler::slotFileListReceived(const QByteArray &data)
if (m_editor.isNull()) if (m_editor.isNull())
return; return;
const QString fileList = m_editor.data()->codec()->toUnicode(data); const QString fileList = m_editor->editorWidget()->codec()->toUnicode(data);
m_requestedIndexFileNames = fileList.split(QLatin1Char('\n'), QString::SkipEmptyParts); QStringList fileNames = fileList.split(QLatin1Char('\n'), QString::SkipEmptyParts);
m_requestedIndexFileNames.removeDuplicates(); fileNames.removeDuplicates();
m_indexFileNames = m_requestedIndexFileNames;
for (int i = 0; i < fileNames.count(); i++)
m_requestedRevisionRanges[fileNames.at(i)].append(m_requestedRevisionRange);
prepareForCollection();
collectFilesContents(); collectFilesContents();
} }
void GitDiffHandler::prepareForCollection()
{
QMap<QString, QList<RevisionRange> >::const_iterator it
= m_requestedRevisionRanges.constBegin();
QMap<QString, QList<RevisionRange> >::const_iterator itEnd
= m_requestedRevisionRanges.constEnd();
while (it != itEnd) {
const QString fileName = it.key();
const QList<RevisionRange> &ranges = it.value();
for (int i = 0; i < ranges.count(); i++) {
const RevisionRange &range = ranges.at(i);
m_pendingRevisions[fileName][range.begin] = false;
m_pendingRevisions[fileName][range.end] = false;
}
++it;
}
}
void GitDiffHandler::collectFilesContents() void GitDiffHandler::collectFilesContents()
{ {
const int headFilesReceived = m_headContents.count(); QMap<QString, QMap<Revision, bool> >::iterator itFile
const int indexFilesReceived = m_indexContents.count(); = m_pendingRevisions.begin();
QMap<QString, QMap<Revision, bool> >::iterator itFileEnd
= m_pendingRevisions.end();
while (itFile != itFileEnd) {
const QString fileName = itFile.key();
QMap<Revision, bool> &revisions = itFile.value();
QMap<Revision, bool>::iterator itRev
= revisions.begin();
QMap<Revision, bool>::iterator itRevEnd
= revisions.end();
while (itRev != itRevEnd) {
const Revision revision = itRev.key();
if (revision.type == WorkingTree) {
// collect file here
if (headFilesReceived < m_headFileNames.count()) { m_collectedRevisions[fileName][revision] = workingTreeContents(fileName);
VcsBase::Command *command = new VcsBase::Command(m_gitPath, m_workingDirectory, m_processEnvironment);
connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(slotFileContentsReceived(QByteArray)));
QStringList arguments; itRev = revisions.erase(itRev); // iterate to the next revision
arguments << QLatin1String("show") << QLatin1String("HEAD:./") + m_headFileNames.at(headFilesReceived); } else {
command->addJob(arguments, m_timeout); // prepare job here
command->execute();
} else if (indexFilesReceived < m_indexFileNames.count()) {
VcsBase::Command *command = new VcsBase::Command(m_gitPath, m_workingDirectory, m_processEnvironment);
connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(slotFileContentsReceived(QByteArray)));
QStringList arguments; VcsBase::Command *command = new VcsBase::Command(m_gitPath, m_workingDirectory, m_processEnvironment);
arguments << QLatin1String("show") << QLatin1String(":./") + m_indexFileNames.at(indexFilesReceived); connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(slotFileContentsReceived(QByteArray)));
command->addJob(arguments, m_timeout);
command->execute(); QString revisionArgument = (revision.type == Other)
} else { ? revision.id : QString();
feedEditor(); revisionArgument += QLatin1String(":./");
QStringList arguments;
arguments << QLatin1String("show") << revisionArgument + fileName;
command->addJob(arguments, m_timeout);
command->execute();
return;
}
}
itFile = m_pendingRevisions.erase(itFile); // iterate to the next file
} }
feedEditor();
} }
void GitDiffHandler::slotFileContentsReceived(const QByteArray &data) void GitDiffHandler::slotFileContentsReceived(const QByteArray &data)
@@ -235,13 +344,26 @@ void GitDiffHandler::slotFileContentsReceived(const QByteArray &data)
if (m_editor.isNull()) if (m_editor.isNull())
return; return;
const int headFilesReceived = m_headContents.count(); QMap<QString, QMap<Revision, bool> >::iterator itFile
const int indexFilesReceived = m_indexContents.count(); = m_pendingRevisions.begin();
const QString contents = m_editor.data()->codec()->toUnicode(data); QMap<QString, QMap<Revision, bool> >::iterator itFileEnd
if (headFilesReceived < m_headFileNames.count()) = m_pendingRevisions.end();
m_headContents.append(contents); if (itFile != itFileEnd) {
else if (indexFilesReceived < m_indexFileNames.count()) const QString fileName = itFile.key();
m_indexContents.append(contents); QMap<Revision, bool> &revisions = itFile.value();
QMap<Revision, bool>::iterator itRev
= revisions.begin();
QMap<Revision, bool>::iterator itRevEnd
= revisions.end();
if (itRev != itRevEnd) {
const QString contents = m_editor->editorWidget()->codec()->toUnicode(data);
m_collectedRevisions[fileName][itRev.key()] = contents;
itRev = revisions.erase(itRev);
if (revisions.isEmpty())
m_pendingRevisions.erase(itFile);
}
}
collectFilesContents(); collectFilesContents();
} }
@@ -250,36 +372,29 @@ void GitDiffHandler::feedEditor()
{ {
QList<DiffEditor::DiffEditorWidget::DiffFilesContents> list; QList<DiffEditor::DiffEditorWidget::DiffFilesContents> list;
for (int i = 0; i < m_requestedHeadFileNames.count(); i++) { QMap<QString, QList<RevisionRange> >::const_iterator itFile
const QString fileName = m_requestedHeadFileNames.at(i); = m_requestedRevisionRanges.constBegin();
const QString original = m_headContents.at(i); QMap<QString, QList<RevisionRange> >::const_iterator itFileEnd
const int idx = m_indexFileNames.indexOf(fileName); = m_requestedRevisionRanges.constEnd();
if (idx >= 0) { while (itFile != itFileEnd) {
const QString modified = m_indexContents.at(idx); const QString fileName = itFile.key();
if (original != modified) { const QList<RevisionRange> &ranges = itFile.value();
DiffEditor::DiffEditorWidget::DiffFilesContents dfc; for (int i = 0; i < ranges.count(); i++) {
dfc.leftFileInfo = DiffEditor::DiffEditorWidget::DiffFileInfo(fileName, tr("Head")); const Revision leftRevision = ranges.at(i).begin;
dfc.leftText = original; const Revision rightRevision = ranges.at(i).end;
dfc.rightFileInfo = DiffEditor::DiffEditorWidget::DiffFileInfo(fileName, tr("Index"));
dfc.rightText = modified;
list.append(dfc);
}
}
}
for (int i = 0; i < m_requestedIndexFileNames.count(); i++) {
const QString fileName = m_requestedIndexFileNames.at(i);
const QString original = m_indexContents.at(i);
const QString modified = workingTreeContents(fileName);
if (original != modified) {
DiffEditor::DiffEditorWidget::DiffFilesContents dfc; DiffEditor::DiffEditorWidget::DiffFilesContents dfc;
dfc.leftFileInfo = DiffEditor::DiffEditorWidget::DiffFileInfo(fileName, tr("Index")); dfc.leftFileInfo = DiffEditor::DiffEditorWidget::DiffFileInfo(fileName, leftRevision.infoText());
dfc.leftText = original; dfc.leftText = m_collectedRevisions[fileName][leftRevision];
dfc.rightFileInfo = DiffEditor::DiffEditorWidget::DiffFileInfo(fileName, tr("Working tree")); dfc.rightFileInfo = DiffEditor::DiffEditorWidget::DiffFileInfo(fileName, rightRevision.infoText());
dfc.rightText = modified; dfc.rightText = m_collectedRevisions[fileName][rightRevision];
list.append(dfc); list.append(dfc);
} }
++itFile;
} }
m_editor.data()->setDiff(list, m_workingDirectory);
m_editor->setDiff(list, m_workingDirectory);
deleteLater(); deleteLater();
} }
@@ -290,7 +405,7 @@ QString GitDiffHandler::workingTreeContents(const QString &fileName) const
QFile file(absoluteFileName); QFile file(absoluteFileName);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return m_editor.data()->codec()->toUnicode(file.readAll()); return m_editor->editorWidget()->codec()->toUnicode(file.readAll());
} }
return QString(); return QString();
} }
@@ -728,10 +843,9 @@ VcsBase::VcsBaseEditorWidget *GitClient::findExistingVCSEditor(const char *regis
return rc; return rc;
} }
DiffEditor::DiffEditorWidget *GitClient::findExistingDiffEditor(const char *registerDynamicProperty, DiffEditor::DiffEditorEditable *GitClient::findExistingDiffEditor(const char *registerDynamicProperty,
const QString &dynamicPropertyValue) const const QString &dynamicPropertyValue) const
{ {
DiffEditor::DiffEditorWidget *editorWidget = 0;
Core::IEditor *outputEditor = locateEditor(registerDynamicProperty, dynamicPropertyValue); Core::IEditor *outputEditor = locateEditor(registerDynamicProperty, dynamicPropertyValue);
if (!outputEditor) if (!outputEditor)
return 0; return 0;
@@ -739,9 +853,8 @@ DiffEditor::DiffEditorWidget *GitClient::findExistingDiffEditor(const char *regi
// Exists already // Exists already
Core::EditorManager::activateEditor(outputEditor, Core::EditorManager::ModeSwitch); Core::EditorManager::activateEditor(outputEditor, Core::EditorManager::ModeSwitch);
outputEditor->createNew(m_msgWait); outputEditor->createNew(m_msgWait);
editorWidget = diffEditorWidget(outputEditor);
return editorWidget; return qobject_cast<DiffEditor::DiffEditorEditable *>(outputEditor);
} }
/* Create an editor associated to VCS output of a source file/directory /* Create an editor associated to VCS output of a source file/directory
@@ -787,13 +900,6 @@ VcsBase::VcsBaseEditorWidget *GitClient::createVcsEditor(const Core::Id &id,
return rc; return rc;
} }
DiffEditor::DiffEditorWidget *GitClient::diffEditorWidget(const Core::IEditor *editor) const
{
if (const DiffEditor::DiffEditorEditable *de = qobject_cast<const DiffEditor::DiffEditorEditable *>(editor))
return de->editorWidget();
return 0;
}
void GitClient::diff(const QString &workingDirectory, void GitClient::diff(const QString &workingDirectory,
const QStringList &diffArgs, const QStringList &diffArgs,
const QStringList &unstagedFileNames, const QStringList &unstagedFileNames,
@@ -803,30 +909,27 @@ void GitClient::diff(const QString &workingDirectory,
const Core::Id editorId = DiffEditor::Constants::DIFF_EDITOR_ID; const Core::Id editorId = DiffEditor::Constants::DIFF_EDITOR_ID;
QString title = tr("Git Diff"); QString title = tr("Git Diff");
DiffEditor::DiffEditorWidget *editorWidget = findExistingDiffEditor("originalFileName", workingDirectory); DiffEditor::DiffEditorEditable *editorEditable = findExistingDiffEditor("originalFileName", workingDirectory);
if (!editorWidget) { if (!editorEditable) {
Core::IEditor *outputEditor = Core::EditorManager::openEditorWithContents(editorId, &title, m_msgWait); editorEditable = qobject_cast<DiffEditor::DiffEditorEditable *>(
outputEditor->document()->setProperty("originalFileName", workingDirectory); Core::EditorManager::openEditorWithContents(editorId, &title, m_msgWait));
Core::EditorManager::activateEditor(outputEditor, Core::EditorManager::ModeSwitch); // should probably go outside this block editorEditable->document()->setProperty("originalFileName", workingDirectory);
Core::EditorManager::activateEditor(editorEditable, Core::EditorManager::ModeSwitch); // should probably go outside this block
editorWidget = diffEditorWidget(outputEditor);
} }
int timeout = settings()->intValue(GitSettings::timeoutKey); int timeout = settings()->intValue(GitSettings::timeoutKey);
GitDiffHandler *handler = new GitDiffHandler(gitBinaryPath(), workingDirectory, processEnvironment(), editorWidget, timeout); GitDiffHandler *handler = new GitDiffHandler(editorEditable, gitBinaryPath(), workingDirectory, processEnvironment(), timeout);
if (unstagedFileNames.empty() && stagedFileNames.empty()) { if (unstagedFileNames.empty() && stagedFileNames.empty()) {
// local repository diff // local repository diff
handler->diffRepository(); handler->diffRepository();
} else if (!stagedFileNames.empty()) {
// diff of selected files only with --cached option, used in commit editor
handler->diffFiles(stagedFileNames, unstagedFileNames);
} else { } else {
if (!stagedFileNames.empty()) { // current project diff
// diff of selected files only with --cached option, used in commit editor handler->diffProjects(unstagedFileNames);
handler->diffFiles(stagedFileNames, unstagedFileNames);
} else if (!unstagedFileNames.empty()) {
// current project diff
handler->diffProjects(unstagedFileNames);
}
} }
} else { } else {
const QString binary = settings()->stringValue(GitSettings::binaryPathKey); const QString binary = settings()->stringValue(GitSettings::binaryPathKey);
@@ -894,18 +997,17 @@ void GitClient::diff(const QString &workingDirectory,
QString title = tr("Git Diff \"%1\"").arg(fileName); QString title = tr("Git Diff \"%1\"").arg(fileName);
const QString sourceFile = VcsBase::VcsBaseEditorWidget::getSource(workingDirectory, fileName); const QString sourceFile = VcsBase::VcsBaseEditorWidget::getSource(workingDirectory, fileName);
DiffEditor::DiffEditorWidget *editorWidget = findExistingDiffEditor("originalFileName", sourceFile); DiffEditor::DiffEditorEditable *editorEditable = findExistingDiffEditor("originalFileName", sourceFile);
if (!editorWidget) { if (!editorEditable) {
Core::IEditor *outputEditor = Core::EditorManager::openEditorWithContents(editorId, &title, m_msgWait); editorEditable = qobject_cast<DiffEditor::DiffEditorEditable *>(
outputEditor->document()->setProperty("originalFileName", sourceFile); Core::EditorManager::openEditorWithContents(editorId, &title, m_msgWait));
Core::EditorManager::activateEditor(outputEditor, Core::EditorManager::ModeSwitch); editorEditable->document()->setProperty("originalFileName", sourceFile);
Core::EditorManager::activateEditor(editorEditable, Core::EditorManager::ModeSwitch);
editorWidget = diffEditorWidget(outputEditor);
} }
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
int timeout = settings()->intValue(GitSettings::timeoutKey); int timeout = settings()->intValue(GitSettings::timeoutKey);
GitDiffHandler *handler = new GitDiffHandler(gitBinaryPath(), workingDirectory, processEnvironment(), editorWidget, timeout); GitDiffHandler *handler = new GitDiffHandler(editorEditable, gitBinaryPath(), workingDirectory, processEnvironment(), timeout);
handler->diffFile(fileName); handler->diffFile(fileName);
} }
} else { } else {
@@ -940,25 +1042,42 @@ void GitClient::diffBranch(const QString &workingDirectory,
const QStringList &diffArgs, const QStringList &diffArgs,
const QString &branchName) const QString &branchName)
{ {
const Core::Id editorId = Git::Constants::GIT_DIFF_EDITOR_ID; if (settings()->boolValue(GitSettings::useDiffEditorKey)) {
const QString title = tr("Git Diff Branch \"%1\"").arg(branchName); const Core::Id editorId = DiffEditor::Constants::DIFF_EDITOR_ID;
const QString sourceFile = VcsBase::VcsBaseEditorWidget::getSource(workingDirectory, QStringList()); QString title = tr("Git Diff Branch \"%1\"").arg(branchName);
VcsBase::VcsBaseEditorWidget *editor = findExistingVCSEditor("BranchName", branchName); DiffEditor::DiffEditorEditable *editorEditable = findExistingDiffEditor("BranchName", branchName);
if (!editor) if (!editorEditable) {
editor = createVcsEditor(editorId, title, sourceFile, CodecSource, "BranchName", branchName, editorEditable = qobject_cast<DiffEditor::DiffEditorEditable *>(
new GitBranchDiffArgumentsWidget(this, workingDirectory, Core::EditorManager::openEditorWithContents(editorId, &title, m_msgWait));
diffArgs, branchName)); editorEditable->document()->setProperty("BranchName", branchName);
editor->setDiffBaseDirectory(workingDirectory); Core::EditorManager::activateEditor(editorEditable, Core::EditorManager::ModeSwitch);
}
GitBranchDiffArgumentsWidget *argWidget = qobject_cast<GitBranchDiffArgumentsWidget *>(editor->configurationWidget()); int timeout = settings()->intValue(GitSettings::timeoutKey);
QStringList userDiffArgs = argWidget->arguments(); GitDiffHandler *handler = new GitDiffHandler(editorEditable, gitBinaryPath(), workingDirectory, processEnvironment(), timeout);
handler->diffBranch(branchName);
} else {
const Core::Id editorId = Git::Constants::GIT_DIFF_EDITOR_ID;
const QString title = tr("Git Diff Branch \"%1\"").arg(branchName);
const QString sourceFile = VcsBase::VcsBaseEditorWidget::getSource(workingDirectory, QStringList());
QStringList cmdArgs; VcsBase::VcsBaseEditorWidget *editor = findExistingVCSEditor("BranchName", branchName);
cmdArgs << QLatin1String("diff") << QLatin1String(noColorOption) if (!editor)
<< userDiffArgs << branchName; editor = createVcsEditor(editorId, title, sourceFile, CodecSource, "BranchName", branchName,
new GitBranchDiffArgumentsWidget(this, workingDirectory,
diffArgs, branchName));
editor->setDiffBaseDirectory(workingDirectory);
executeGit(workingDirectory, cmdArgs, editor); GitBranchDiffArgumentsWidget *argWidget = qobject_cast<GitBranchDiffArgumentsWidget *>(editor->configurationWidget());
QStringList userDiffArgs = argWidget->arguments();
QStringList cmdArgs;
cmdArgs << QLatin1String("diff") << QLatin1String(noColorOption)
<< userDiffArgs << branchName;
executeGit(workingDirectory, cmdArgs, editor);
}
} }
void GitClient::merge(const QString &workingDirectory, const QStringList &unmergedFileNames) void GitClient::merge(const QString &workingDirectory, const QStringList &unmergedFileNames)
@@ -1037,26 +1156,44 @@ void GitClient::show(const QString &source, const QString &id, const QStringList
return; return;
} }
const QString title = tr("Git Show \"%1\"").arg(id); if (settings()->boolValue(GitSettings::useDiffEditorKey)) {
const Core::Id editorId = Git::Constants::GIT_DIFF_EDITOR_ID; QString title = tr("Git Show \"%1\"").arg(id);
VcsBase::VcsBaseEditorWidget *editor = findExistingVCSEditor("show", id); const Core::Id editorId = DiffEditor::Constants::DIFF_EDITOR_ID;
if (!editor)
editor = createVcsEditor(editorId, title, source, CodecSource, "show", id,
new GitShowArgumentsWidget(this, source, args, id));
GitShowArgumentsWidget *argWidget = qobject_cast<GitShowArgumentsWidget *>(editor->configurationWidget()); DiffEditor::DiffEditorEditable *editorEditable = findExistingDiffEditor("show", id);
QStringList userArgs = argWidget->arguments();
QStringList arguments; if (!editorEditable) {
arguments << QLatin1String("show") << QLatin1String(noColorOption); editorEditable = qobject_cast<DiffEditor::DiffEditorEditable *>(
arguments << QLatin1String(decorateOption); Core::EditorManager::openEditorWithContents(editorId, &title, m_msgWait));
arguments.append(userArgs); editorEditable->document()->setProperty("show", id);
arguments << id; Core::EditorManager::activateEditor(editorEditable, Core::EditorManager::ModeSwitch); // should probably go outside this block
}
const QFileInfo sourceFi(source); int timeout = settings()->intValue(GitSettings::timeoutKey);
const QString workDir = sourceFi.isDir() ? sourceFi.absoluteFilePath() : sourceFi.absolutePath(); GitDiffHandler *handler = new GitDiffHandler(editorEditable, gitBinaryPath(), source, processEnvironment(), timeout);
editor->setDiffBaseDirectory(workDir); handler->show(id);
executeGit(workDir, arguments, editor); } else {
const QString title = tr("Git Show \"%1\"").arg(id);
const Core::Id editorId = Git::Constants::GIT_DIFF_EDITOR_ID;
VcsBase::VcsBaseEditorWidget *editor = findExistingVCSEditor("show", id);
if (!editor)
editor = createVcsEditor(editorId, title, source, CodecSource, "show", id,
new GitShowArgumentsWidget(this, source, args, id));
GitShowArgumentsWidget *argWidget = qobject_cast<GitShowArgumentsWidget *>(editor->configurationWidget());
QStringList userArgs = argWidget->arguments();
QStringList arguments;
arguments << QLatin1String("show") << QLatin1String(noColorOption);
arguments << QLatin1String(decorateOption);
arguments.append(userArgs);
arguments << id;
const QFileInfo sourceFi(source);
const QString workDir = sourceFi.isDir() ? sourceFi.absoluteFilePath() : sourceFi.absolutePath();
editor->setDiffBaseDirectory(workDir);
executeGit(workDir, arguments, editor);
}
} }
void GitClient::saveSettings() void GitClient::saveSettings()
@@ -1275,7 +1412,7 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
if (files.isEmpty()) if (files.isEmpty())
arguments << QLatin1String("--hard"); arguments << QLatin1String("--hard");
else else
arguments << QLatin1String("HEAD") << QLatin1String("--") << files; arguments << QLatin1String(HEAD) << QLatin1String("--") << files;
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText); const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
const QString output = commandOutputFromLocal8Bit(outputText); const QString output = commandOutputFromLocal8Bit(outputText);
outputWindow()->append(output); outputWindow()->append(output);
@@ -1327,7 +1464,7 @@ bool GitClient::synchronousCheckoutFiles(const QString &workingDirectory,
bool revertStaging /* = true */) bool revertStaging /* = true */)
{ {
if (revertStaging && revision.isEmpty()) if (revertStaging && revision.isEmpty())
revision = QLatin1String("HEAD"); revision = QLatin1String(HEAD);
if (files.isEmpty()) if (files.isEmpty())
files = QStringList(QString(QLatin1Char('.'))); files = QStringList(QString(QLatin1Char('.')));
QByteArray outputText; QByteArray outputText;
@@ -1421,7 +1558,7 @@ bool GitClient::synchronousParentRevisions(const QString &workingDirectory,
QString errorText; QString errorText;
QStringList arguments; QStringList arguments;
if (parents && !isValidRevision(revision)) { // Not Committed Yet if (parents && !isValidRevision(revision)) { // Not Committed Yet
*parents = QStringList(QLatin1String("HEAD")); *parents = QStringList(QLatin1String(HEAD));
return true; return true;
} }
arguments << QLatin1String("--parents") << QLatin1String("--max-count=1") << revision; arguments << QLatin1String("--parents") << QLatin1String("--max-count=1") << revision;
@@ -1467,7 +1604,7 @@ QString GitClient::synchronousCurrentLocalBranch(const QString &workingDirectory
{ {
QByteArray outputTextData; QByteArray outputTextData;
QStringList arguments; QStringList arguments;
arguments << QLatin1String("symbolic-ref") << QLatin1String("HEAD"); arguments << QLatin1String("symbolic-ref") << QLatin1String(HEAD);
if (fullySynchronousGit(workingDirectory, arguments, &outputTextData, 0, false)) { if (fullySynchronousGit(workingDirectory, arguments, &outputTextData, 0, false)) {
QString branch = commandOutputFromLocal8Bit(outputTextData.trimmed()); QString branch = commandOutputFromLocal8Bit(outputTextData.trimmed());
const QString refsHeadsPrefix = QLatin1String("refs/heads/"); const QString refsHeadsPrefix = QLatin1String("refs/heads/");
@@ -1597,7 +1734,7 @@ QString GitClient::synchronousTopRevision(const QString &workingDirectory, QStri
QStringList arguments; QStringList arguments;
QString errorMessage; QString errorMessage;
// get revision // get revision
arguments << QLatin1String("rev-parse") << QLatin1String("HEAD"); arguments << QLatin1String("rev-parse") << QLatin1String(HEAD);
if (!fullySynchronousGit(workingDirectory, arguments, &outputTextData, &errorText, false)) { if (!fullySynchronousGit(workingDirectory, arguments, &outputTextData, &errorText, false)) {
errorMessage = tr("Cannot retrieve top revision of \"%1\": %2") errorMessage = tr("Cannot retrieve top revision of \"%1\": %2")
.arg(QDir::toNativeSeparators(workingDirectory), commandOutputFromLocal8Bit(errorText)); .arg(QDir::toNativeSeparators(workingDirectory), commandOutputFromLocal8Bit(errorText));
@@ -2217,7 +2354,7 @@ void GitClient::continuePreviousGitCommand(const QString &workingDirectory,
QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryURL) QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryURL)
{ {
QStringList arguments(QLatin1String("ls-remote")); QStringList arguments(QLatin1String("ls-remote"));
arguments << repositoryURL << QLatin1String("HEAD") << QLatin1String("refs/heads/*"); arguments << repositoryURL << QLatin1String(HEAD) << QLatin1String("refs/heads/*");
const unsigned flags = const unsigned flags =
VcsBase::VcsBasePlugin::SshPasswordPrompt| VcsBase::VcsBasePlugin::SshPasswordPrompt|
VcsBase::VcsBasePlugin::SuppressStdErrInLogWindow| VcsBase::VcsBasePlugin::SuppressStdErrInLogWindow|

View File

@@ -61,7 +61,7 @@ namespace Utils {
} }
namespace DiffEditor { namespace DiffEditor {
class DiffEditorWidget; class DiffEditorEditable;
} }
namespace Git { namespace Git {
@@ -69,7 +69,6 @@ namespace Internal {
class GitPlugin; class GitPlugin;
class GitOutputWindow; class GitOutputWindow;
class GitDiffEditorWidget;
class CommitData; class CommitData;
struct GitSubmitEditorPanelData; struct GitSubmitEditorPanelData;
class Stash; class Stash;
@@ -133,8 +132,6 @@ public:
QString findRepositoryForDirectory(const QString &dir); QString findRepositoryForDirectory(const QString &dir);
QString findGitDirForRepository(const QString &repositoryDir) const; QString findGitDirForRepository(const QString &repositoryDir) const;
DiffEditor::DiffEditorWidget *diffEditorWidget(const Core::IEditor *editor) const;
void diff(const QString &workingDirectory, const QStringList &diffArgs, const QString &fileName); void diff(const QString &workingDirectory, const QStringList &diffArgs, const QString &fileName);
void diff(const QString &workingDirectory, const QStringList &diffArgs, void diff(const QString &workingDirectory, const QStringList &diffArgs,
const QStringList &unstagedFileNames, const QStringList &stagedFileNames= QStringList()); const QStringList &unstagedFileNames, const QStringList &stagedFileNames= QStringList());
@@ -326,7 +323,7 @@ private:
QTextCodec *getSourceCodec(const QString &file) const; QTextCodec *getSourceCodec(const QString &file) const;
VcsBase::VcsBaseEditorWidget *findExistingVCSEditor(const char *registerDynamicProperty, VcsBase::VcsBaseEditorWidget *findExistingVCSEditor(const char *registerDynamicProperty,
const QString &dynamicPropertyValue) const; const QString &dynamicPropertyValue) const;
DiffEditor::DiffEditorWidget *findExistingDiffEditor(const char *registerDynamicProperty, DiffEditor::DiffEditorEditable *findExistingDiffEditor(const char *registerDynamicProperty,
const QString &dynamicPropertyValue) const; const QString &dynamicPropertyValue) const;
enum CodecType { CodecSource, CodecLogOutput, CodecNone }; enum CodecType { CodecSource, CodecLogOutput, CodecNone };

View File

@@ -47,13 +47,17 @@ const char C_GIT_BLAME_EDITOR[] = "Git Annotation Editor";
const char GIT_DIFF_EDITOR_ID[] = "Git Diff Editor"; const char GIT_DIFF_EDITOR_ID[] = "Git Diff Editor";
const char GIT_DIFF_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git Diff Editor"); const char GIT_DIFF_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git Diff Editor");
const char C_GIT_DIFF_EDITOR[] = "Git Diff Editor"; const char C_GIT_DIFF_EDITOR[] = "Git Diff Editor";
const char GIT_COMMIT_TEXT_EDITOR_ID[] = "Git Commit Editor";
const char GIT_COMMIT_TEXT_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git Commit Editor");
const char C_GIT_COMMIT_TEXT_EDITOR[] = "Git Commit Editor";
const char C_GITSUBMITEDITOR[] = "Git Submit Editor"; const char C_GITSUBMITEDITOR[] = "Git Submit Editor";
const char GITSUBMITEDITOR_ID[] = "Git Submit Editor"; const char GITSUBMITEDITOR_ID[] = "Git Submit Editor";
const char GITSUBMITEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git Submit Editor"); const char GITSUBMITEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git Submit Editor");
const char SUBMIT_CURRENT[] = "Git.SubmitCurrentLog"; const char SUBMIT_CURRENT[] = "Git.SubmitCurrentLog";
const char DIFF_SELECTED[] = "Git.DiffSelectedFilesInLog"; const char DIFF_SELECTED[] = "Git.DiffSelectedFilesInLog";
const char SUBMIT_MIMETYPE[] = "application/vnd.nokia.text.git.submit"; const char SUBMIT_MIMETYPE[] = "text/vnd.qtcreator.git.submit";
const char C_GITEDITORID[] = "Git Editor";
} // namespace Constants } // namespace Constants
} // namespace Git } // namespace Git

View File

@@ -33,9 +33,12 @@
#include "gitplugin.h" #include "gitplugin.h"
#include "gitclient.h" #include "gitclient.h"
#include "gitsettings.h" #include "gitsettings.h"
#include "gitsubmiteditorwidget.h"
#include "gitconstants.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <vcsbase/vcsbaseoutputwindow.h> #include <vcsbase/vcsbaseoutputwindow.h>
#include <texteditor/basetextdocument.h>
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <QRegExp> #include <QRegExp>
@@ -225,6 +228,13 @@ void GitEditor::revertChange()
GitPlugin::instance()->gitClient()->synchronousRevert(workingDirectory, m_currentChange); GitPlugin::instance()->gitClient()->synchronousRevert(workingDirectory, m_currentChange);
} }
void GitEditor::init()
{
VcsBase::VcsBaseEditorWidget::init();
if (editor()->id() == Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID)
new GitSubmitHighlighter(baseTextDocument().data());
}
QString GitEditor::decorateVersion(const QString &revision) const QString GitEditor::decorateVersion(const QString &revision) const
{ {
const QFileInfo fi(source()); const QFileInfo fi(source());

View File

@@ -59,6 +59,7 @@ private slots:
void revertChange(); void revertChange();
private: private:
void init();
QSet<QString> annotationChanges() const; QSet<QString> annotationChanges() const;
QString changeUnderCursor(const QTextCursor &) const; QString changeUnderCursor(const QTextCursor &) const;
VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes, const QColor &bg) const; VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes, const QColor &bg) const;

View File

@@ -58,6 +58,7 @@
#include <coreplugin/infobar.h> #include <coreplugin/infobar.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/mimedatabase.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/parameteraction.h> #include <utils/parameteraction.h>
@@ -81,32 +82,35 @@
#include <QScopedPointer> #include <QScopedPointer>
static const unsigned minimumRequiredVersion = 0x010702; static const unsigned minimumRequiredVersion = 0x010702;
static const char RC_GIT_MIME_XML[] = ":/git/Git.mimetypes.xml";
static const VcsBase::VcsBaseEditorParameters editorParameters[] = { static const VcsBase::VcsBaseEditorParameters editorParameters[] = {
{ {
VcsBase::RegularCommandOutput, VcsBase::OtherContent,
Git::Constants::GIT_COMMAND_LOG_EDITOR_ID, Git::Constants::GIT_COMMAND_LOG_EDITOR_ID,
Git::Constants::GIT_COMMAND_LOG_EDITOR_DISPLAY_NAME, Git::Constants::GIT_COMMAND_LOG_EDITOR_DISPLAY_NAME,
Git::Constants::C_GIT_COMMAND_LOG_EDITOR, Git::Constants::C_GIT_COMMAND_LOG_EDITOR,
"application/vnd.nokia.text.scs_git_commandlog", "text/vnd.qtcreator.git.commandlog"},
"gitlog"},
{ VcsBase::LogOutput, { VcsBase::LogOutput,
Git::Constants::GIT_LOG_EDITOR_ID, Git::Constants::GIT_LOG_EDITOR_ID,
Git::Constants::GIT_LOG_EDITOR_DISPLAY_NAME, Git::Constants::GIT_LOG_EDITOR_DISPLAY_NAME,
Git::Constants::C_GIT_LOG_EDITOR, Git::Constants::C_GIT_LOG_EDITOR,
"application/vnd.nokia.text.scs_git_filelog", "text/vnd.qtcreator.git.log"},
"gitfilelog"},
{ VcsBase::AnnotateOutput, { VcsBase::AnnotateOutput,
Git::Constants::GIT_BLAME_EDITOR_ID, Git::Constants::GIT_BLAME_EDITOR_ID,
Git::Constants::GIT_BLAME_EDITOR_DISPLAY_NAME, Git::Constants::GIT_BLAME_EDITOR_DISPLAY_NAME,
Git::Constants::C_GIT_BLAME_EDITOR, Git::Constants::C_GIT_BLAME_EDITOR,
"application/vnd.nokia.text.scs_git_annotation", "text/vnd.qtcreator.git.annotation"},
"gitsannotate"},
{ VcsBase::DiffOutput, { VcsBase::DiffOutput,
Git::Constants::GIT_DIFF_EDITOR_ID, Git::Constants::GIT_DIFF_EDITOR_ID,
Git::Constants::GIT_DIFF_EDITOR_DISPLAY_NAME, Git::Constants::GIT_DIFF_EDITOR_DISPLAY_NAME,
Git::Constants::C_GIT_DIFF_EDITOR, Git::Constants::C_GIT_DIFF_EDITOR,
"text/x-patch","diff"} "text/x-patch"},
{ VcsBase::DiffOutput,
Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID,
Git::Constants::GIT_COMMIT_TEXT_EDITOR_DISPLAY_NAME,
Git::Constants::C_GIT_COMMIT_TEXT_EDITOR,
"text/vnd.qtcreator.git.commit"},
}; };
// Utility to find a parameter set by type // Utility to find a parameter set by type
@@ -266,7 +270,6 @@ ActionCommandPair
bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{ {
Q_UNUSED(arguments) Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
m_settings.readSettings(Core::ICore::settings()); m_settings.readSettings(Core::ICore::settings());
@@ -659,6 +662,9 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
command = Core::ActionManager::registerAction(m_redoAction, Core::Constants::REDO, submitContext); command = Core::ActionManager::registerAction(m_redoAction, Core::Constants::REDO, submitContext);
if (!Core::ICore::mimeDatabase()->addMimeTypes(QLatin1String(RC_GIT_MIME_XML), errorMessage))
return false;
/* "Gerrit" */ /* "Gerrit" */
m_gerritPlugin = new Gerrit::Internal::GerritPlugin(this); m_gerritPlugin = new Gerrit::Internal::GerritPlugin(this);
const bool ok = m_gerritPlugin->initialize(remoteRepositoryMenu); const bool ok = m_gerritPlugin->initialize(remoteRepositoryMenu);

View File

@@ -55,28 +55,23 @@ static QTextCharFormat commentFormat()
return settings.toTextCharFormat(TextEditor::C_COMMENT); return settings.toTextCharFormat(TextEditor::C_COMMENT);
} }
// Highlighter for git submit messages. Make the first line bold, indicates
// comments as such (retrieving the format from the text editor) and marks up
// keywords (words in front of a colon as in 'Task: <bla>').
class GitSubmitHighlighter : QSyntaxHighlighter {
public:
explicit GitSubmitHighlighter(QTextEdit *parent);
void highlightBlock(const QString &text);
private:
enum State { None = -1, Header, Other };
const QTextCharFormat m_commentFormat;
QRegExp m_keywordPattern;
const QChar m_hashChar;
};
GitSubmitHighlighter::GitSubmitHighlighter(QTextEdit * parent) : GitSubmitHighlighter::GitSubmitHighlighter(QTextEdit * parent) :
QSyntaxHighlighter(parent), TextEditor::SyntaxHighlighter(parent)
m_commentFormat(commentFormat()),
m_keywordPattern(QLatin1String("^[\\w-]+:")),
m_hashChar(QLatin1Char('#'))
{ {
initialize();
}
GitSubmitHighlighter::GitSubmitHighlighter(TextEditor::BaseTextDocument *parent) :
TextEditor::SyntaxHighlighter(parent)
{
initialize();
}
void GitSubmitHighlighter::initialize()
{
m_commentFormat = commentFormat();
m_keywordPattern.setPattern(QLatin1String("^[\\w-]+:"));
m_hashChar = QLatin1Char('#');
QTC_CHECK(m_keywordPattern.isValid()); QTC_CHECK(m_keywordPattern.isValid());
} }

View File

@@ -33,8 +33,12 @@
#include "ui_gitsubmitpanel.h" #include "ui_gitsubmitpanel.h"
#include "gitsettings.h" #include "gitsettings.h"
#include <texteditor/syntaxhighlighter.h>
#include <vcsbase/submiteditorwidget.h> #include <vcsbase/submiteditorwidget.h>
#include <QRegExp>
#include <QSyntaxHighlighter>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QValidator; class QValidator;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -89,6 +93,25 @@ private:
bool m_isInitialized; bool m_isInitialized;
}; };
// Highlighter for git submit messages. Make the first line bold, indicates
// comments as such (retrieving the format from the text editor) and marks up
// keywords (words in front of a colon as in 'Task: <bla>').
class GitSubmitHighlighter : public TextEditor::SyntaxHighlighter
{
public:
explicit GitSubmitHighlighter(QTextEdit *parent);
explicit GitSubmitHighlighter(TextEditor::BaseTextDocument *parent);
void highlightBlock(const QString &text);
void initialize();
private:
enum State { None = -1, Header, Other };
QTextCharFormat m_commentFormat;
QRegExp m_keywordPattern;
QChar m_hashChar;
};
} // namespace Internal } // namespace Internal
} // namespace Git } // namespace Git

View File

@@ -46,34 +46,25 @@ const char CHANGEIDEXACT40[] = "[a-f0-9]{40,40}";
const char DIFFIDENTIFIER[] = "^(?:diff --git a/|[+-]{3} (?:/dev/null|[ab]/(.+$)))"; const char DIFFIDENTIFIER[] = "^(?:diff --git a/|[+-]{3} (?:/dev/null|[ab]/(.+$)))";
// Base editor parameters // Base editor parameters
const char COMMANDLOG_ID[] = "Mercurial Command Log Editor";
const char COMMANDLOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Mercurial Command Log Editor");
const char COMMANDLOG[] = "Mercurial Command Log Editor";
const char COMMANDAPP[] = "application/vnd.nokia.text.scs_mercurial_commandlog";
const char COMMANDEXT[] = "vcsMercurialCommand";
const char FILELOG_ID[] = "Mercurial File Log Editor"; const char FILELOG_ID[] = "Mercurial File Log Editor";
const char FILELOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Mercurial File Log Editor"); const char FILELOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Mercurial File Log Editor");
const char FILELOG[] = "Mercurial File Log Editor"; const char FILELOG[] = "Mercurial File Log Editor";
const char LOGAPP[] = "application/vnd.nokia.text.scs_mercurial_log"; const char LOGAPP[] = "text/vnd.qtcreator.mercurial.log";
const char LOGEXT[] = "vcsMercurialLog";
const char ANNOTATELOG_ID[] = "Mercurial Annotation Editor"; const char ANNOTATELOG_ID[] = "Mercurial Annotation Editor";
const char ANNOTATELOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Mercurial Annotation Editor"); const char ANNOTATELOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Mercurial Annotation Editor");
const char ANNOTATELOG[] = "Mercurial Annotation Editor"; const char ANNOTATELOG[] = "Mercurial Annotation Editor";
const char ANNOTATEAPP[] = "application/vnd.nokia.text.scs_mercurial_annotatelog"; const char ANNOTATEAPP[] = "text/vnd.qtcreator.mercurial.annotation";
const char ANNOTATEEXT[] = "vcsMercurialAnnotate";
const char DIFFLOG_ID[] = "Mercurial Diff Editor"; const char DIFFLOG_ID[] = "Mercurial Diff Editor";
const char DIFFLOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Mercurial Diff Editor"); const char DIFFLOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Mercurial Diff Editor");
const char DIFFLOG[] = "Mercurial Diff Editor"; const char DIFFLOG[] = "Mercurial Diff Editor";
const char DIFFAPP[] = "text/x-patch"; const char DIFFAPP[] = "text/x-patch";
const char DIFFEXT[] = "diff";
// Submit editor parameters // Submit editor parameters
const char COMMIT_ID[] = "Mercurial Commit Log Editor"; const char COMMIT_ID[] = "Mercurial Commit Log Editor";
const char COMMIT_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Mercurial Commit Log Editor"); const char COMMIT_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Mercurial Commit Log Editor");
const char COMMITMIMETYPE[] = "application/vnd.nokia.text.scs_mercurial_commitlog"; const char COMMITMIMETYPE[] = "text/vnd.qtcreator.mercurial.commit";
// File menu actions // File menu actions
const char ADD[] = "Mercurial.AddSingleFile"; const char ADD[] = "Mercurial.AddSingleFile";

View File

@@ -75,33 +75,23 @@ using namespace Utils;
static const VcsBaseEditorParameters editorParameters[] = { static const VcsBaseEditorParameters editorParameters[] = {
{ {
RegularCommandOutput, //type LogOutput,
Constants::COMMANDLOG_ID, // id
Constants::COMMANDLOG_DISPLAY_NAME, // display name
Constants::COMMANDLOG, // context
Constants::COMMANDAPP, // mime type
Constants::COMMANDEXT}, //extension
{ LogOutput,
Constants::FILELOG_ID, Constants::FILELOG_ID,
Constants::FILELOG_DISPLAY_NAME, Constants::FILELOG_DISPLAY_NAME,
Constants::FILELOG, Constants::FILELOG,
Constants::LOGAPP, Constants::LOGAPP},
Constants::LOGEXT},
{ AnnotateOutput, { AnnotateOutput,
Constants::ANNOTATELOG_ID, Constants::ANNOTATELOG_ID,
Constants::ANNOTATELOG_DISPLAY_NAME, Constants::ANNOTATELOG_DISPLAY_NAME,
Constants::ANNOTATELOG, Constants::ANNOTATELOG,
Constants::ANNOTATEAPP, Constants::ANNOTATEAPP},
Constants::ANNOTATEEXT},
{ DiffOutput, { DiffOutput,
Constants::DIFFLOG_ID, Constants::DIFFLOG_ID,
Constants::DIFFLOG_DISPLAY_NAME, Constants::DIFFLOG_DISPLAY_NAME,
Constants::DIFFLOG, Constants::DIFFLOG,
Constants::DIFFAPP, Constants::DIFFAPP}
Constants::DIFFEXT}
}; };
static const VcsBaseSubmitEditorParameters submitEditorParameters = { static const VcsBaseSubmitEditorParameters submitEditorParameters = {

View File

@@ -39,10 +39,6 @@ const char PERFORCE_SUBMIT_EDITOR_ID[] = "Perforce.SubmitEditor";
const char PERFORCE_SUBMIT_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Perforce.SubmitEditor"); const char PERFORCE_SUBMIT_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Perforce.SubmitEditor");
const char PERFORCESUBMITEDITOR_CONTEXT[] = "Perforce Submit Editor"; const char PERFORCESUBMITEDITOR_CONTEXT[] = "Perforce Submit Editor";
const char PERFORCE_COMMANDLOG_EDITOR_ID[] = "Perfoirce.CommandLogEditor";
const char PERFORCE_COMMANDLOG_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Perforce CommandLog Editor");
const char PERFORCE_COMMANDLOG_EDITOR_CONTEXT[] = "Perforce Command Log Editor";
const char PERFORCE_LOG_EDITOR_ID[] = "Perforce.LogEditor"; const char PERFORCE_LOG_EDITOR_ID[] = "Perforce.LogEditor";
const char PERFORCE_LOG_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Perforce Log Editor"); const char PERFORCE_LOG_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Perforce Log Editor");
const char PERFORCE_LOG_EDITOR_CONTEXT[] = "Perforce Log Editor"; const char PERFORCE_LOG_EDITOR_CONTEXT[] = "Perforce Log Editor";
@@ -57,7 +53,7 @@ const char PERFORCE_ANNOTATION_EDITOR_CONTEXT[] = "Perforce Annotation Editor";
const char SUBMIT_CURRENT[] = "Perforce.SubmitCurrentLog"; const char SUBMIT_CURRENT[] = "Perforce.SubmitCurrentLog";
const char DIFF_SELECTED[] = "Perforce.DiffSelectedFilesInLog"; const char DIFF_SELECTED[] = "Perforce.DiffSelectedFilesInLog";
const char SUBMIT_MIMETYPE[] = "application/vnd.nokia.text.p4.submit"; const char SUBMIT_MIMETYPE[] = "text/vnd.qtcreator.p4.submit";
enum { debug = 0 }; enum { debug = 0 };

View File

@@ -74,29 +74,21 @@
static const VcsBase::VcsBaseEditorParameters editorParameters[] = { static const VcsBase::VcsBaseEditorParameters editorParameters[] = {
{ {
VcsBase::RegularCommandOutput, VcsBase::LogOutput,
Perforce::Constants::PERFORCE_COMMANDLOG_EDITOR_ID,
Perforce::Constants::PERFORCE_COMMANDLOG_EDITOR_DISPLAY_NAME,
Perforce::Constants::PERFORCE_COMMANDLOG_EDITOR_CONTEXT,
"application/vnd.nokia.text.scs_commandlog",
"scslog"},
{ VcsBase::LogOutput,
Perforce::Constants::PERFORCE_LOG_EDITOR_ID, Perforce::Constants::PERFORCE_LOG_EDITOR_ID,
Perforce::Constants::PERFORCE_LOG_EDITOR_DISPLAY_NAME, Perforce::Constants::PERFORCE_LOG_EDITOR_DISPLAY_NAME,
Perforce::Constants::PERFORCE_LOG_EDITOR_CONTEXT, Perforce::Constants::PERFORCE_LOG_EDITOR_CONTEXT,
"application/vnd.nokia.text.scs_filelog", "text/vnd.qtcreator.p4.log"},
"scsfilelog"},
{ VcsBase::AnnotateOutput, { VcsBase::AnnotateOutput,
Perforce::Constants::PERFORCE_ANNOTATION_EDITOR_ID, Perforce::Constants::PERFORCE_ANNOTATION_EDITOR_ID,
Perforce::Constants::PERFORCE_ANNOTATION_EDITOR_DISPLAY_NAME, Perforce::Constants::PERFORCE_ANNOTATION_EDITOR_DISPLAY_NAME,
Perforce::Constants::PERFORCE_ANNOTATION_EDITOR_CONTEXT, Perforce::Constants::PERFORCE_ANNOTATION_EDITOR_CONTEXT,
"application/vnd.nokia.text.scs_annotation", "text/vnd.qtcreator.p4.annotation"},
"scsannotate"},
{ VcsBase::DiffOutput, { VcsBase::DiffOutput,
Perforce::Constants::PERFORCE_DIFF_EDITOR_ID, Perforce::Constants::PERFORCE_DIFF_EDITOR_ID,
Perforce::Constants::PERFORCE_DIFF_EDITOR_DISPLAY_NAME, Perforce::Constants::PERFORCE_DIFF_EDITOR_DISPLAY_NAME,
Perforce::Constants::PERFORCE_DIFF_EDITOR_CONTEXT, Perforce::Constants::PERFORCE_DIFF_EDITOR_CONTEXT,
"text/x-patch","diff"} "text/x-patch"}
}; };
// Utility to find a parameter set by type // Utility to find a parameter set by type

View File

@@ -850,14 +850,13 @@ bool replaceFieldHelper(ValueStringTransformation transform,
int nextPos = s->indexOf(delimiter, pos + 1); int nextPos = s->indexOf(delimiter, pos + 1);
if (nextPos == -1) if (nextPos == -1)
break; break;
nextPos++; // Point past 2nd delimiter if (nextPos == pos + 1) {
if (nextPos == pos + 2) {
pos = nextPos; // Skip '%%' pos = nextPos; // Skip '%%'
continue; continue;
} }
// Evaluate field specification for modifiers // Evaluate field specification for modifiers
// "%field:l%" // "%field:l%"
QString fieldSpec = s->mid(pos + 1, nextPos - pos - 2); QString fieldSpec = s->mid(pos + 1, nextPos - pos - 1);
const int fieldSpecSize = fieldSpec.size(); const int fieldSpecSize = fieldSpec.size();
char modifier = '\0'; char modifier = '\0';
if (fieldSpecSize >= 3 && fieldSpec.at(fieldSpecSize - 2) == modifierDelimiter) { if (fieldSpecSize >= 3 && fieldSpec.at(fieldSpecSize - 2) == modifierDelimiter) {

View File

@@ -171,7 +171,7 @@ const char CPP_SOURCE_MIMETYPE[] = "text/x-c++src";
const char CPP_HEADER_MIMETYPE[] = "text/x-c++hdr"; const char CPP_HEADER_MIMETYPE[] = "text/x-c++hdr";
const char FORM_MIMETYPE[] = "application/x-designer"; const char FORM_MIMETYPE[] = "application/x-designer";
const char QML_MIMETYPE[] = "application/x-qml"; // separate def also in qmljstoolsconstants.h const char QML_MIMETYPE[] = "application/x-qml"; // separate def also in qmljstoolsconstants.h
const char RESOURCE_MIMETYPE[] = "application/vnd.nokia.xml.qt.resource"; const char RESOURCE_MIMETYPE[] = "application/vnd.qt.xml.resource";
// Settings page // Settings page
const char PROJECTEXPLORER_SETTINGS_CATEGORY[] = "K.ProjectExplorer"; const char PROJECTEXPLORER_SETTINGS_CATEGORY[] = "K.ProjectExplorer";

View File

@@ -241,21 +241,21 @@ public:
bool isEnabled() const { return true; } bool isEnabled() const { return true; }
protected: void addFolderNodes(const QList<FolderNode*> &subFolders, FolderNode *parentFolder);
// this is just the in-memory representation, a subclass void removeFolderNodes(const QList<FolderNode*> &subFolders, FolderNode *parentFolder);
// will add the persistent stuff
explicit ProjectNode(const QString &projectFilePath); void addFileNodes(const QList<FileNode*> &files, FolderNode *parentFolder);
void removeFileNodes(const QList<FileNode*> &files, FolderNode *parentFolder);
// to be called in implementation of // to be called in implementation of
// the corresponding public methods // the corresponding public methods
void addProjectNodes(const QList<ProjectNode*> &subProjects); void addProjectNodes(const QList<ProjectNode*> &subProjects);
void removeProjectNodes(const QList<ProjectNode*> &subProjects); void removeProjectNodes(const QList<ProjectNode*> &subProjects);
void addFolderNodes(const QList<FolderNode*> &subFolders, FolderNode *parentFolder); protected:
void removeFolderNodes(const QList<FolderNode*> &subFolders, FolderNode *parentFolder); // this is just the in-memory representation, a subclass
// will add the persistent stuff
void addFileNodes(const QList<FileNode*> &files, FolderNode *parentFolder); explicit ProjectNode(const QString &projectFilePath);
void removeFileNodes(const QList<FileNode*> &files, FolderNode *parentFolder);
private slots: private slots:
void watcherDestroyed(QObject *watcher); void watcherDestroyed(QObject *watcher);

View File

@@ -1,5 +1,4 @@
include(../../qtcreatorplugin.pri) include(../../qtcreatorplugin.pri)
include(pythoneditor_dependencies.pri)
DEFINES += \ DEFINES += \
PYTHONEDITOR_LIBRARY PYTHONEDITOR_LIBRARY

View File

@@ -116,7 +116,7 @@ void QbsBuildStep::run(QFutureInterface<bool> &fi)
QbsProject *pro = static_cast<QbsProject *>(project()); QbsProject *pro = static_cast<QbsProject *>(project());
qbs::BuildOptions options(m_qbsBuildOptions); qbs::BuildOptions options(m_qbsBuildOptions);
options.changedFiles = m_changedFiles; options.setChangedFiles(m_changedFiles);
m_job = pro->build(options); m_job = pro->build(options);
@@ -179,18 +179,18 @@ void QbsBuildStep::setQbsConfiguration(const QVariantMap &config)
bool QbsBuildStep::dryRun() const bool QbsBuildStep::dryRun() const
{ {
return m_qbsBuildOptions.dryRun; return m_qbsBuildOptions.dryRun();
} }
bool QbsBuildStep::keepGoing() const bool QbsBuildStep::keepGoing() const
{ {
return m_qbsBuildOptions.keepGoing; return m_qbsBuildOptions.keepGoing();
} }
int QbsBuildStep::maxJobs() const int QbsBuildStep::maxJobs() const
{ {
if (m_qbsBuildOptions.maxJobCount > 0) if (m_qbsBuildOptions.maxJobCount() > 0)
return m_qbsBuildOptions.maxJobCount; return m_qbsBuildOptions.maxJobCount();
return qbs::BuildOptions::defaultMaxJobCount(); return qbs::BuildOptions::defaultMaxJobCount();
} }
@@ -200,9 +200,9 @@ bool QbsBuildStep::fromMap(const QVariantMap &map)
return false; return false;
setQbsConfiguration(map.value(QLatin1String(QBS_CONFIG)).toMap()); setQbsConfiguration(map.value(QLatin1String(QBS_CONFIG)).toMap());
m_qbsBuildOptions.dryRun = map.value(QLatin1String(QBS_DRY_RUN)).toBool(); m_qbsBuildOptions.setDryRun(map.value(QLatin1String(QBS_DRY_RUN)).toBool());
m_qbsBuildOptions.keepGoing = map.value(QLatin1String(QBS_KEEP_GOING)).toBool(); m_qbsBuildOptions.setKeepGoing(map.value(QLatin1String(QBS_KEEP_GOING)).toBool());
m_qbsBuildOptions.maxJobCount = map.value(QLatin1String(QBS_MAXJOBCOUNT)).toInt(); m_qbsBuildOptions.setMaxJobCount(map.value(QLatin1String(QBS_MAXJOBCOUNT)).toInt());
return true; return true;
} }
@@ -210,9 +210,9 @@ QVariantMap QbsBuildStep::toMap() const
{ {
QVariantMap map = ProjectExplorer::BuildStep::toMap(); QVariantMap map = ProjectExplorer::BuildStep::toMap();
map.insert(QLatin1String(QBS_CONFIG), m_qbsConfiguration); map.insert(QLatin1String(QBS_CONFIG), m_qbsConfiguration);
map.insert(QLatin1String(QBS_DRY_RUN), m_qbsBuildOptions.dryRun); map.insert(QLatin1String(QBS_DRY_RUN), m_qbsBuildOptions.dryRun());
map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsBuildOptions.keepGoing); map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsBuildOptions.keepGoing());
map.insert(QLatin1String(QBS_MAXJOBCOUNT), m_qbsBuildOptions.maxJobCount); map.insert(QLatin1String(QBS_MAXJOBCOUNT), m_qbsBuildOptions.maxJobCount());
return map; return map;
} }
@@ -221,7 +221,7 @@ void QbsBuildStep::buildingDone(bool success)
// Report errors: // Report errors:
foreach (const qbs::ErrorData &data, m_job->error().entries()) foreach (const qbs::ErrorData &data, m_job->error().entries())
createTaskAndOutput(ProjectExplorer::Task::Error, data.description(), createTaskAndOutput(ProjectExplorer::Task::Error, data.description(),
data.codeLocation().fileName, data.codeLocation().line); data.codeLocation().fileName(), data.codeLocation().line());
QTC_ASSERT(m_fi, return); QTC_ASSERT(m_fi, return);
m_fi->reportResult(success); m_fi->reportResult(success);
@@ -251,7 +251,7 @@ void QbsBuildStep::handleWarningReport(const qbs::Error &error)
{ {
foreach (const qbs::ErrorData &data, error.entries()) { foreach (const qbs::ErrorData &data, error.entries()) {
createTaskAndOutput(ProjectExplorer::Task::Warning, data.description(), createTaskAndOutput(ProjectExplorer::Task::Warning, data.description(),
data.codeLocation().fileName, data.codeLocation().line); data.codeLocation().fileName(), data.codeLocation().line());
} }
} }
@@ -263,21 +263,21 @@ void QbsBuildStep::handleCommandDescriptionReport(const QString &highlight, cons
void QbsBuildStep::handleProcessResultReport(const qbs::ProcessResult &result) void QbsBuildStep::handleProcessResultReport(const qbs::ProcessResult &result)
{ {
bool hasOutput = !result.stdOut.isEmpty() || !result.stdErr.isEmpty(); bool hasOutput = !result.stdOut().isEmpty() || !result.stdErr().isEmpty();
if (result.success && !hasOutput) if (result.success() && !hasOutput)
return; return;
m_parser->setWorkingDirectory(result.workingDirectory); m_parser->setWorkingDirectory(result.workingDirectory());
QString commandline = result.binary + QLatin1Char(' ') + result.arguments.join(QLatin1String(" ")); QString commandline = result.executableFilePath() + QLatin1Char(' ') + result.arguments().join(QLatin1String(" "));
addOutput(commandline, NormalOutput); addOutput(commandline, NormalOutput);
foreach (const QString &line, result.stdErr) { foreach (const QString &line, result.stdErr()) {
m_parser->stdError(line); m_parser->stdError(line);
addOutput(line, ErrorOutput); addOutput(line, ErrorOutput);
} }
foreach (const QString &line, result.stdOut) { foreach (const QString &line, result.stdOut()) {
m_parser->stdOutput(line); m_parser->stdOutput(line);
addOutput(line, NormalOutput); addOutput(line, NormalOutput);
} }
@@ -312,25 +312,25 @@ QString QbsBuildStep::profile() const
void QbsBuildStep::setDryRun(bool dr) void QbsBuildStep::setDryRun(bool dr)
{ {
if (m_qbsBuildOptions.dryRun == dr) if (m_qbsBuildOptions.dryRun() == dr)
return; return;
m_qbsBuildOptions.dryRun = dr; m_qbsBuildOptions.setDryRun(dr);
emit qbsBuildOptionsChanged(); emit qbsBuildOptionsChanged();
} }
void QbsBuildStep::setKeepGoing(bool kg) void QbsBuildStep::setKeepGoing(bool kg)
{ {
if (m_qbsBuildOptions.keepGoing == kg) if (m_qbsBuildOptions.keepGoing() == kg)
return; return;
m_qbsBuildOptions.keepGoing = kg; m_qbsBuildOptions.setKeepGoing(kg);
emit qbsBuildOptionsChanged(); emit qbsBuildOptionsChanged();
} }
void QbsBuildStep::setMaxJobs(int jobcount) void QbsBuildStep::setMaxJobs(int jobcount)
{ {
if (m_qbsBuildOptions.maxJobCount == jobcount) if (m_qbsBuildOptions.maxJobCount() == jobcount)
return; return;
m_qbsBuildOptions.maxJobCount = jobcount; m_qbsBuildOptions.setMaxJobCount(jobcount);
emit qbsBuildOptionsChanged(); emit qbsBuildOptionsChanged();
} }

View File

@@ -134,12 +134,12 @@ void QbsCleanStep::cancel()
bool QbsCleanStep::dryRun() const bool QbsCleanStep::dryRun() const
{ {
return m_qbsCleanOptions.dryRun; return m_qbsCleanOptions.dryRun();
} }
bool QbsCleanStep::keepGoing() const bool QbsCleanStep::keepGoing() const
{ {
return m_qbsCleanOptions.keepGoing; return m_qbsCleanOptions.keepGoing();
} }
int QbsCleanStep::maxJobs() const int QbsCleanStep::maxJobs() const
@@ -149,7 +149,7 @@ int QbsCleanStep::maxJobs() const
bool QbsCleanStep::cleanAll() const bool QbsCleanStep::cleanAll() const
{ {
return m_qbsCleanOptions.cleanType == qbs::CleanOptions::CleanupAll; return m_qbsCleanOptions.cleanType() == qbs::CleanOptions::CleanupAll;
} }
bool QbsCleanStep::fromMap(const QVariantMap &map) bool QbsCleanStep::fromMap(const QVariantMap &map)
@@ -157,10 +157,10 @@ bool QbsCleanStep::fromMap(const QVariantMap &map)
if (!ProjectExplorer::BuildStep::fromMap(map)) if (!ProjectExplorer::BuildStep::fromMap(map))
return false; return false;
m_qbsCleanOptions.dryRun = map.value(QLatin1String(QBS_DRY_RUN)).toBool(); m_qbsCleanOptions.setDryRun(map.value(QLatin1String(QBS_DRY_RUN)).toBool());
m_qbsCleanOptions.keepGoing = map.value(QLatin1String(QBS_KEEP_GOING)).toBool(); m_qbsCleanOptions.setKeepGoing(map.value(QLatin1String(QBS_KEEP_GOING)).toBool());
m_qbsCleanOptions.cleanType = map.value(QLatin1String(QBS_CLEAN_ALL)).toBool() m_qbsCleanOptions.setCleanType(map.value(QLatin1String(QBS_CLEAN_ALL)).toBool()
? qbs::CleanOptions::CleanupAll : qbs::CleanOptions::CleanupTemporaries; ? qbs::CleanOptions::CleanupAll : qbs::CleanOptions::CleanupTemporaries);
return true; return true;
} }
@@ -168,10 +168,10 @@ bool QbsCleanStep::fromMap(const QVariantMap &map)
QVariantMap QbsCleanStep::toMap() const QVariantMap QbsCleanStep::toMap() const
{ {
QVariantMap map = ProjectExplorer::BuildStep::toMap(); QVariantMap map = ProjectExplorer::BuildStep::toMap();
map.insert(QLatin1String(QBS_DRY_RUN), m_qbsCleanOptions.dryRun); map.insert(QLatin1String(QBS_DRY_RUN), m_qbsCleanOptions.dryRun());
map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsCleanOptions.keepGoing); map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsCleanOptions.keepGoing());
map.insert(QLatin1String(QBS_CLEAN_ALL), map.insert(QLatin1String(QBS_CLEAN_ALL),
m_qbsCleanOptions.cleanType == qbs::CleanOptions::CleanupAll); m_qbsCleanOptions.cleanType() == qbs::CleanOptions::CleanupAll);
return map; return map;
} }
@@ -181,7 +181,7 @@ void QbsCleanStep::cleaningDone(bool success)
// Report errors: // Report errors:
foreach (const qbs::ErrorData &data, m_job->error().entries()) { foreach (const qbs::ErrorData &data, m_job->error().entries()) {
createTaskAndOutput(ProjectExplorer::Task::Error, data.description(), createTaskAndOutput(ProjectExplorer::Task::Error, data.description(),
data.codeLocation().fileName, data.codeLocation().line); data.codeLocation().fileName(), data.codeLocation().line());
} }
QTC_ASSERT(m_fi, return); QTC_ASSERT(m_fi, return);
@@ -217,17 +217,17 @@ void QbsCleanStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, con
void QbsCleanStep::setDryRun(bool dr) void QbsCleanStep::setDryRun(bool dr)
{ {
if (m_qbsCleanOptions.dryRun == dr) if (m_qbsCleanOptions.dryRun() == dr)
return; return;
m_qbsCleanOptions.dryRun = dr; m_qbsCleanOptions.setDryRun(dr);
emit changed(); emit changed();
} }
void QbsCleanStep::setKeepGoing(bool kg) void QbsCleanStep::setKeepGoing(bool kg)
{ {
if (m_qbsCleanOptions.keepGoing == kg) if (m_qbsCleanOptions.keepGoing() == kg)
return; return;
m_qbsCleanOptions.keepGoing = kg; m_qbsCleanOptions.setKeepGoing(kg);
emit changed(); emit changed();
} }
@@ -241,9 +241,9 @@ void QbsCleanStep::setCleanAll(bool ca)
{ {
qbs::CleanOptions::CleanType newType = ca qbs::CleanOptions::CleanType newType = ca
? qbs::CleanOptions::CleanupAll : qbs::CleanOptions::CleanupTemporaries; ? qbs::CleanOptions::CleanupAll : qbs::CleanOptions::CleanupTemporaries;
if (m_qbsCleanOptions.cleanType == newType) if (m_qbsCleanOptions.cleanType() == newType)
return; return;
m_qbsCleanOptions.cleanType = newType; m_qbsCleanOptions.setCleanType(newType);
emit changed(); emit changed();
} }

View File

@@ -126,8 +126,8 @@ void QbsInstallStep::cancel()
QString QbsInstallStep::installRoot() const QString QbsInstallStep::installRoot() const
{ {
if (!m_qbsInstallOptions.installRoot.isEmpty()) if (!m_qbsInstallOptions.installRoot().isEmpty())
return m_qbsInstallOptions.installRoot; return m_qbsInstallOptions.installRoot();
return qbs::InstallOptions::defaultInstallRoot(); return qbs::InstallOptions::defaultInstallRoot();
} }
@@ -143,17 +143,17 @@ QString QbsInstallStep::absoluteInstallRoot() const
bool QbsInstallStep::removeFirst() const bool QbsInstallStep::removeFirst() const
{ {
return m_qbsInstallOptions.removeFirst; return m_qbsInstallOptions.removeExistingInstallation();
} }
bool QbsInstallStep::dryRun() const bool QbsInstallStep::dryRun() const
{ {
return m_qbsInstallOptions.dryRun; return m_qbsInstallOptions.dryRun();
} }
bool QbsInstallStep::keepGoing() const bool QbsInstallStep::keepGoing() const
{ {
return m_qbsInstallOptions.keepGoing; return m_qbsInstallOptions.keepGoing();
} }
bool QbsInstallStep::fromMap(const QVariantMap &map) bool QbsInstallStep::fromMap(const QVariantMap &map)
@@ -162,9 +162,9 @@ bool QbsInstallStep::fromMap(const QVariantMap &map)
return false; return false;
setInstallRoot(map.value(QLatin1String(QBS_INSTALL_ROOT)).toString()); setInstallRoot(map.value(QLatin1String(QBS_INSTALL_ROOT)).toString());
m_qbsInstallOptions.removeFirst = map.value(QLatin1String(QBS_REMOVE_FIRST), false).toBool(); m_qbsInstallOptions.setRemoveExistingInstallation(map.value(QLatin1String(QBS_REMOVE_FIRST), false).toBool());
m_qbsInstallOptions.dryRun = map.value(QLatin1String(QBS_DRY_RUN), false).toBool(); m_qbsInstallOptions.setDryRun(map.value(QLatin1String(QBS_DRY_RUN), false).toBool());
m_qbsInstallOptions.keepGoing = map.value(QLatin1String(QBS_KEEP_GOING), false).toBool(); m_qbsInstallOptions.setKeepGoing(map.value(QLatin1String(QBS_KEEP_GOING), false).toBool());
return true; return true;
} }
@@ -172,20 +172,25 @@ bool QbsInstallStep::fromMap(const QVariantMap &map)
QVariantMap QbsInstallStep::toMap() const QVariantMap QbsInstallStep::toMap() const
{ {
QVariantMap map = ProjectExplorer::BuildStep::toMap(); QVariantMap map = ProjectExplorer::BuildStep::toMap();
map.insert(QLatin1String(QBS_INSTALL_ROOT), m_qbsInstallOptions.installRoot); map.insert(QLatin1String(QBS_INSTALL_ROOT), m_qbsInstallOptions.installRoot());
map.insert(QLatin1String(QBS_REMOVE_FIRST), m_qbsInstallOptions.removeFirst); map.insert(QLatin1String(QBS_REMOVE_FIRST), m_qbsInstallOptions.removeExistingInstallation());
map.insert(QLatin1String(QBS_DRY_RUN), m_qbsInstallOptions.dryRun); map.insert(QLatin1String(QBS_DRY_RUN), m_qbsInstallOptions.dryRun());
map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsInstallOptions.keepGoing); map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsInstallOptions.keepGoing());
return map; return map;
} }
qbs::InstallOptions QbsInstallStep::installOptions() const
{
return m_qbsInstallOptions;
}
void QbsInstallStep::installDone(bool success) void QbsInstallStep::installDone(bool success)
{ {
// Report errors: // Report errors:
foreach (const qbs::ErrorData &data, m_job->error().entries()) { foreach (const qbs::ErrorData &data, m_job->error().entries()) {
createTaskAndOutput(ProjectExplorer::Task::Error, data.description(), createTaskAndOutput(ProjectExplorer::Task::Error, data.description(),
data.codeLocation().fileName, data.codeLocation().line); data.codeLocation().fileName(), data.codeLocation().line());
} }
QTC_ASSERT(m_fi, return); QTC_ASSERT(m_fi, return);
@@ -222,33 +227,33 @@ void QbsInstallStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type,
void QbsInstallStep::setInstallRoot(const QString &ir) void QbsInstallStep::setInstallRoot(const QString &ir)
{ {
if (m_qbsInstallOptions.installRoot == ir) if (m_qbsInstallOptions.installRoot() == ir)
return; return;
m_qbsInstallOptions.installRoot = ir; m_qbsInstallOptions.installRoot() = ir;
emit changed(); emit changed();
} }
void QbsInstallStep::setRemoveFirst(bool rf) void QbsInstallStep::setRemoveFirst(bool rf)
{ {
if (m_qbsInstallOptions.removeFirst == rf) if (m_qbsInstallOptions.removeExistingInstallation() == rf)
return; return;
m_qbsInstallOptions.removeFirst = rf; m_qbsInstallOptions.setRemoveExistingInstallation(rf);
emit changed(); emit changed();
} }
void QbsInstallStep::setDryRun(bool dr) void QbsInstallStep::setDryRun(bool dr)
{ {
if (m_qbsInstallOptions.dryRun == dr) if (m_qbsInstallOptions.dryRun() == dr)
return; return;
m_qbsInstallOptions.dryRun = dr; m_qbsInstallOptions.setDryRun(dr);
emit changed(); emit changed();
} }
void QbsInstallStep::setKeepGoing(bool kg) void QbsInstallStep::setKeepGoing(bool kg)
{ {
if (m_qbsInstallOptions.keepGoing == kg) if (m_qbsInstallOptions.keepGoing() == kg)
return; return;
m_qbsInstallOptions.keepGoing = kg; m_qbsInstallOptions.setKeepGoing(kg);
emit changed(); emit changed();
} }

View File

@@ -63,6 +63,7 @@ public:
bool fromMap(const QVariantMap &map); bool fromMap(const QVariantMap &map);
QVariantMap toMap() const; QVariantMap toMap() const;
qbs::InstallOptions installOptions() const;
QString installRoot() const; QString installRoot() const;
QString absoluteInstallRoot() const; QString absoluteInstallRoot() const;
bool removeFirst() const; bool removeFirst() const;

View File

@@ -48,10 +48,20 @@
// Helpers: // Helpers:
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
namespace QbsProjectManager { static QString displayNameFromPath(const QString &path, const QString &base)
namespace Internal { {
QString dir = base;
if (!base.endsWith(QLatin1Char('/')))
dir.append(QLatin1Char('/'));
QIcon generateIcon() QString name = path;
if (name.startsWith(dir))
name = name.mid(dir.count());
return name;
}
static QIcon generateIcon()
{ {
const QSize desiredSize = QSize(16, 16); const QSize desiredSize = QSize(16, 16);
const QIcon projectBaseIcon(QString::fromLatin1(QtSupport::Constants::ICON_QT_PROJECT)); const QIcon projectBaseIcon(QString::fromLatin1(QtSupport::Constants::ICON_QT_PROJECT));
@@ -65,13 +75,16 @@ QIcon generateIcon()
return result; return result;
} }
namespace QbsProjectManager {
namespace Internal {
QIcon QbsProjectNode::m_projectIcon = generateIcon(); QIcon QbsProjectNode::m_projectIcon = generateIcon();
QIcon QbsProductNode::m_productIcon = generateIcon(); QIcon QbsProductNode::m_productIcon = generateIcon();
QIcon QbsGroupNode::m_groupIcon = generateIcon(); QIcon QbsGroupNode::m_groupIcon = generateIcon();
class FileTreeNode { class FileTreeNode {
public: public:
FileTreeNode(const QString &n, FileTreeNode *p = 0) : explicit FileTreeNode(const QString &n = QString(), FileTreeNode *p = 0) :
parent(p), name(n) parent(p), name(n)
{ {
if (p) if (p)
@@ -127,6 +140,33 @@ public:
reorder(n, basedir, root); reorder(n, basedir, root);
} }
static void moveChildrenUp(FileTreeNode *node)
{
if (!node || !node->parent)
return;
FileTreeNode *newParent = node->parent;
// disconnect node and parent:
node->parent = 0;
newParent->children.removeOne(node);
foreach (FileTreeNode *c, node->children) {
// update path, make sure there will be no / before "C:" on windows:
if (Utils::HostOsInfo::isWindowsHost() && node->name.isEmpty())
c->name = node->name;
else
c->name = node->name + QLatin1Char('/') + c->name;
newParent->children.append(c);
c->parent = newParent;
}
// Delete node
node->children.clear();
delete node;
}
static void simplify(FileTreeNode *node) static void simplify(FileTreeNode *node)
{ {
foreach (FileTreeNode *c, node->children) foreach (FileTreeNode *c, node->children)
@@ -135,24 +175,23 @@ public:
if (!node->parent) if (!node->parent)
return; return;
if (node->children.count() == 1) { if (node->children.count() == 1 && !node->children.at(0)->isFile())
FileTreeNode *child = node->children.at(0); moveChildrenUp(node->children.at(0));
if (child->isFile()) }
return;
if (!Utils::HostOsInfo::isWindowsHost() || !node->name.isEmpty()) static void moveBaseFolderContents(FileTreeNode *root, const QString &baseDir)
node->name = node->name + QLatin1Char('/') + child->name; {
else // Move files/folders found in the base folder up one level. The baseDir must be a child of
node->name = child->name; // the root of the FileNodeTree.
node->children = child->children; FileTreeNode *baseDirNode = 0;
foreach (FileTreeNode *c, root->children) {
foreach (FileTreeNode *tmpChild, node->children) if (c->path() == baseDir) {
tmpChild->parent = node; baseDirNode = c;
break;
child->children.clear(); }
child->parent = 0;
delete child;
} }
moveChildrenUp(baseDirNode);
} }
QString path() QString path()
@@ -273,7 +312,13 @@ QbsGroupNode::QbsGroupNode(const qbs::GroupData *grp, const QString &productPath
m_qbsGroupData(0) m_qbsGroupData(0)
{ {
setIcon(m_groupIcon); setIcon(m_groupIcon);
setQbsGroupData(grp, productPath);
QbsFileNode *idx = new QbsFileNode(grp->location().fileName(),
ProjectExplorer::ProjectFileType, false,
grp->location().line());
addFileNodes(QList<ProjectExplorer::FileNode *>() << idx, this);
updateQbsGroupData(grp, productPath);
} }
bool QbsGroupNode::isEnabled() const bool QbsGroupNode::isEnabled() const
@@ -281,81 +326,80 @@ bool QbsGroupNode::isEnabled() const
return static_cast<QbsProductNode *>(parentFolderNode())->isEnabled() && qbsGroupData()->isEnabled(); return static_cast<QbsProductNode *>(parentFolderNode())->isEnabled() && qbsGroupData()->isEnabled();
} }
void QbsGroupNode::setQbsGroupData(const qbs::GroupData *group, const QString &productPath) void QbsGroupNode::updateQbsGroupData(const qbs::GroupData *grp, const QString &productPath)
{ {
if (group == m_qbsGroupData && productPath == m_productPath) if (grp == m_qbsGroupData && productPath == m_productPath)
return; return;
m_productPath = productPath; m_productPath = productPath;
m_qbsGroupData = grp;
// Set Product file node used to jump to the product setPath(grp->location().fileName());
setPath(group->location().fileName); setDisplayName(grp->name());
setDisplayName(group->name());
// set up file node... QbsFileNode *idx = 0;
QbsFileNode *indexFile = 0; foreach (ProjectExplorer::FileNode *fn, fileNodes()) {
if (!m_qbsGroupData) { idx = qobject_cast<QbsFileNode *>(fn);
indexFile = new QbsFileNode(group->location().fileName, if (idx)
ProjectExplorer::ProjectFileType, false, break;
group->location().line);
addFileNodes(QList<ProjectExplorer::FileNode *>() << indexFile, this);
} else {
indexFile = static_cast<QbsFileNode *>(fileNodes().first());
indexFile->setPath(group->location().fileName);
indexFile->setLine(group->location().line);
indexFile->emitNodeUpdated();
} }
m_qbsGroupData = group; // idx not found, which should never happen!
Q_ASSERT(idx);
idx->setPath(grp->location().fileName());
idx->setLine(grp->location().line());
setQbsGroupData(this, group, productPath, QList<ProjectExplorer::Node *>() << indexFile); setupFiles(this, grp->allFilePaths(), m_productPath);
emitNodeUpdated(); emitNodeUpdated();
} }
void QbsGroupNode::setQbsGroupData(QbsBaseProjectNode *root, const qbs::GroupData *group, void QbsGroupNode::setupFiles(QbsBaseProjectNode *root, const QStringList &files,
const QString &productPath, QList<ProjectExplorer::Node *> keepers) const QString &productPath)
{ {
// Build up a tree of nodes: // Build up a tree of nodes:
FileTreeNode *tree = new FileTreeNode(QString()); FileTreeNode tree;
foreach (const QString &path, group->allFilePaths()) { foreach (const QString &path, files) {
QStringList pathSegments = path.split(QLatin1Char('/'), QString::SkipEmptyParts); QStringList pathSegments = path.split(QLatin1Char('/'), QString::SkipEmptyParts);
FileTreeNode *root = tree; FileTreeNode *root = &tree;
while (!pathSegments.isEmpty()) while (!pathSegments.isEmpty())
root = root->addPart(pathSegments.takeFirst()); root = root->addPart(pathSegments.takeFirst());
} }
FileTreeNode::reorder(tree, productPath, tree); FileTreeNode::reorder(&tree, productPath, &tree);
FileTreeNode::simplify(tree); FileTreeNode::simplify(&tree);
setupFolders(root, root, tree, productPath, keepers); FileTreeNode::moveBaseFolderContents(&tree, productPath);
delete tree;
setupFolder(root, &tree, productPath);
} }
void QbsGroupNode::setupFolders(QbsBaseProjectNode *topLevel, ProjectExplorer::FolderNode *root, void QbsGroupNode::setupFolder(ProjectExplorer::FolderNode *root,
FileTreeNode *node, const QString &baseDirPath, const FileTreeNode *fileTree, const QString &baseDir)
QList<ProjectExplorer::Node *> keepers)
{ {
// We only need to care about FileNodes and FolderNodes here. Everything else is
// handled elsewhere.
// QbsGroupNodes are managed by the QbsProductNode.
// The buildsystem file is either managed by QbsProductNode or by updateQbsGroupData(...).
QList<ProjectExplorer::FileNode *> filesToRemove; QList<ProjectExplorer::FileNode *> filesToRemove;
foreach (ProjectExplorer::FileNode *fn, root->fileNodes()) { foreach (ProjectExplorer::FileNode *fn, root->fileNodes()) {
ProjectExplorer::Node *n = static_cast<ProjectExplorer::Node *>(fn); if (!qobject_cast<QbsFileNode *>(fn))
if (!keepers.contains(n)) filesToRemove << fn;
filesToRemove.append(fn);
} }
QList<ProjectExplorer::FileNode *> filesToAdd; QList<ProjectExplorer::FileNode *> filesToAdd;
QList<ProjectExplorer::Node *> foldersToKeep = keepers;
QList<ProjectExplorer::FolderNode *> foldersToRemove; QList<ProjectExplorer::FolderNode *> foldersToRemove;
foreach (ProjectExplorer::FolderNode *fn, root->subFolderNodes()) { foreach (ProjectExplorer::FolderNode *fn, root->subFolderNodes()) {
ProjectExplorer::Node *n = static_cast<ProjectExplorer::Node *>(fn); if (fn->nodeType() == ProjectExplorer::ProjectNodeType)
if (!keepers.contains(n)) continue; // Skip ProjectNodes mixed into the folders...
foldersToRemove.append(fn); foldersToRemove.append(fn);
} }
// insert subfolders foreach (FileTreeNode *c, fileTree->children) {
foreach (FileTreeNode *c, node->children) {
QString path = c->path(); QString path = c->path();
// Handle files:
if (c->isFile()) { if (c->isFile()) {
ProjectExplorer::FileNode *fn = root->findFile(path); ProjectExplorer::FileNode *fn = root->findFile(path);
if (fn) { if (fn) {
@@ -366,30 +410,22 @@ void QbsGroupNode::setupFolders(QbsBaseProjectNode *topLevel, ProjectExplorer::F
filesToAdd.append(fn); filesToAdd.append(fn);
} }
continue; continue;
}
ProjectExplorer::FolderNode *fn = root->findSubFolder(path);
if (path == baseDirPath) {
setupFolders(topLevel, root, c, c->path(), foldersToKeep);
continue;
}
if (path.startsWith(baseDirPath + QLatin1Char('/')))
path = path.mid(baseDirPath.length() + 1); // remove common prefix
if (fn) {
fn->emitNodeUpdated(); // enabled might have changed
foldersToRemove.removeOne(fn);
} else { } else {
fn = new ProjectExplorer::FolderNode(path); FolderNode *fn = root->findSubFolder(c->path());
topLevel->addFolderNodes(QList<ProjectExplorer::FolderNode *>() << fn, root); if (!fn) {
fn = new FolderNode(c->path());
root->projectNode()->addFolderNodes(QList<FolderNode *>() << fn, root);
} else {
foldersToRemove.removeOne(fn);
}
fn->setDisplayName(displayNameFromPath(c->path(), baseDir));
setupFolder(fn, c, c->path());
} }
foldersToKeep.append(fn);
setupFolders(topLevel, fn, c, c->path());
} }
topLevel->removeFileNodes(filesToRemove, root); root->projectNode()->removeFileNodes(filesToRemove, root);
topLevel->removeFolderNodes(foldersToRemove, root); root->projectNode()->removeFolderNodes(foldersToRemove, root);
topLevel->addFileNodes(filesToAdd, root); root->projectNode()->addFileNodes(filesToAdd, root);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
@@ -397,7 +433,7 @@ void QbsGroupNode::setupFolders(QbsBaseProjectNode *topLevel, ProjectExplorer::F
// -------------------------------------------------------------------- // --------------------------------------------------------------------
QbsProductNode::QbsProductNode(const qbs::ProductData *prd) : QbsProductNode::QbsProductNode(const qbs::ProductData *prd) :
QbsBaseProjectNode(prd->location().fileName), QbsBaseProjectNode(prd->location().fileName()),
m_qbsProductData(0) m_qbsProductData(0)
{ {
setIcon(m_productIcon); setIcon(m_productIcon);
@@ -415,23 +451,27 @@ void QbsProductNode::setQbsProductData(const qbs::ProductData *prd)
return; return;
setDisplayName(prd->name()); setDisplayName(prd->name());
setPath(prd->location().fileName); setPath(prd->location().fileName());
const QString &productPath = QFileInfo(prd->location().fileName).absolutePath(); const QString &productPath = QFileInfo(prd->location().fileName()).absolutePath();
// Set Product file node used to jump to the product // Set Product file node used to jump to the product
QList<ProjectExplorer::FileNode *> files = fileNodes(); QList<ProjectExplorer::FileNode *> files = fileNodes();
QList<ProjectExplorer::Node *> toKeep; QbsFileNode *idx = 0;
if (files.isEmpty()) { if (files.isEmpty()) {
QbsFileNode *idx = new QbsFileNode(prd->location().fileName, idx = new QbsFileNode(prd->location().fileName(),
ProjectExplorer::ProjectFileType, false, ProjectExplorer::ProjectFileType, false,
prd->location().line); prd->location().line());
addFileNodes(QList<ProjectExplorer::FileNode *>() << idx, this); addFileNodes(QList<ProjectExplorer::FileNode *>() << idx, this);
toKeep.append(idx);
} else { } else {
QbsFileNode *idx = static_cast<QbsFileNode *>(files.at(0)); // Find the QbsFileNode we added earlier:
idx->setPath(prd->location().fileName); foreach (ProjectExplorer::FileNode *fn, files) {
idx->setLine(prd->location().line); idx = qobject_cast<QbsFileNode *>(fn);
toKeep.append(idx); if (idx) {
idx->setPath(prd->location().fileName());
idx->setLine(prd->location().line());
break;
}
}
} }
QList<ProjectExplorer::ProjectNode *> toAdd; QList<ProjectExplorer::ProjectNode *> toAdd;
@@ -440,18 +480,16 @@ void QbsProductNode::setQbsProductData(const qbs::ProductData *prd)
foreach (const qbs::GroupData &grp, prd->groups()) { foreach (const qbs::GroupData &grp, prd->groups()) {
if (grp.name() == prd->name() && grp.location() == prd->location()) { if (grp.name() == prd->name() && grp.location() == prd->location()) {
// Set implicit product group right onto this node: // Set implicit product group right onto this node:
QbsGroupNode::setQbsGroupData(this, &grp, productPath, toKeep); QbsGroupNode::setupFiles(this, grp.allFilePaths(), productPath);
continue; continue;
} }
QbsGroupNode *qn = findGroupNode(grp.name()); QbsGroupNode *gn = findGroupNode(grp.name());
if (qn) { if (gn) {
toRemove.removeAll(qn); toRemove.removeOne(gn);
toKeep.append(qn); gn->updateQbsGroupData(&grp, productPath);
qn->setQbsGroupData(&grp, productPath);
} else { } else {
qn = new QbsGroupNode(&grp, productPath); gn = new QbsGroupNode(&grp, productPath);
toAdd.append(qn); toAdd.append(gn);
toKeep.append(qn);
} }
} }
@@ -467,8 +505,10 @@ QList<ProjectExplorer::RunConfiguration *> QbsProductNode::runConfigurationsFor(
Q_UNUSED(node); Q_UNUSED(node);
QList<ProjectExplorer::RunConfiguration *> result; QList<ProjectExplorer::RunConfiguration *> result;
QbsProjectNode *pn = qobject_cast<QbsProjectNode *>(projectNode()); QbsProjectNode *pn = qobject_cast<QbsProjectNode *>(projectNode());
if (!isEnabled() || !pn || pn->qbsProject()->targetExecutable(*m_qbsProductData).isEmpty()) if (!isEnabled() || !pn || pn->qbsProject()->targetExecutable(*m_qbsProductData,
qbs::InstallOptions()).isEmpty()) {
return result; return result;
}
foreach (ProjectExplorer::RunConfiguration *rc, pn->project()->activeTarget()->runConfigurations()) { foreach (ProjectExplorer::RunConfiguration *rc, pn->project()->activeTarget()->runConfigurations()) {
QbsRunConfiguration *qbsRc = qobject_cast<QbsRunConfiguration *>(rc); QbsRunConfiguration *qbsRc = qobject_cast<QbsRunConfiguration *>(rc);

View File

@@ -116,19 +116,18 @@ public:
QbsGroupNode(const qbs::GroupData *grp, const QString &productPath); QbsGroupNode(const qbs::GroupData *grp, const QString &productPath);
bool isEnabled() const; bool isEnabled() const;
void setQbsGroupData(const qbs::GroupData *qbsGroupData, const QString &productPath); void updateQbsGroupData(const qbs::GroupData *grp, const QString &productPath);
const qbs::GroupData *qbsGroupData() const { return m_qbsGroupData; } const qbs::GroupData *qbsGroupData() const { return m_qbsGroupData; }
QString productPath() const; QString productPath() const;
static void setQbsGroupData(QbsBaseProjectNode *root, const qbs::GroupData *qbsGroupData, static void setupFiles(QbsBaseProjectNode *root, const QStringList &files,
const QString &productPath, QList<Node *> keepers); const QString &productPath);
private: private:
static void setupFolders(QbsBaseProjectNode *topLevel, FolderNode *root, FileTreeNode *node, static void setupFolder(ProjectExplorer::FolderNode *folder,
const QString &baseDirPath, const FileTreeNode *subFileTree, const QString &baseDir);
QList<ProjectExplorer::Node *> keepers = QList<ProjectExplorer::Node *>());
const qbs::GroupData *m_qbsGroupData; const qbs::GroupData *m_qbsGroupData;
QString m_productPath; QString m_productPath;

View File

@@ -163,11 +163,11 @@ QStringList QbsProject::files(ProjectExplorer::Project::FilesMode fileMode) cons
foreach (const qbs::GroupData &grp, prd.groups()) { foreach (const qbs::GroupData &grp, prd.groups()) {
foreach (const QString &file, grp.allFilePaths()) foreach (const QString &file, grp.allFilePaths())
result.insert(file); result.insert(file);
result.insert(grp.location().fileName); result.insert(grp.location().fileName());
} }
result.insert(prd.location().fileName); result.insert(prd.location().fileName());
} }
result.insert(m_rootProjectNode->qbsProjectData()->location().fileName); result.insert(m_rootProjectNode->qbsProjectData()->location().fileName());
} }
return result.toList(); return result.toList();
} }
@@ -356,8 +356,8 @@ void QbsProject::generateErrors(const qbs::Error &e)
foreach (const qbs::ErrorData &data, e.entries()) foreach (const qbs::ErrorData &data, e.entries())
taskHub()->addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error, taskHub()->addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error,
data.description(), data.description(),
Utils::FileName::fromString(data.codeLocation().fileName), Utils::FileName::fromString(data.codeLocation().fileName()),
data.codeLocation().line, data.codeLocation().line(),
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
@@ -370,14 +370,14 @@ void QbsProject::parse(const QVariantMap &config, const QString &dir)
QTC_ASSERT(!m_qbsSetupProjectJob, return); QTC_ASSERT(!m_qbsSetupProjectJob, return);
qbs::SetupProjectParameters params; qbs::SetupProjectParameters params;
params.buildConfiguration = m_qbsBuildConfig; params.setBuildConfiguration(m_qbsBuildConfig);
params.buildRoot = m_qbsBuildRoot; params.setBuildRoot(m_qbsBuildRoot);
params.projectFilePath = m_fileName; params.setProjectFilePath(m_fileName);
params.ignoreDifferentProjectFilePath = false; params.setIgnoreDifferentProjectFilePath(false);
qbs::Preferences *prefs = QbsManager::preferences(); qbs::Preferences *prefs = QbsManager::preferences();
const QString buildDir = qbsBuildDir(); const QString buildDir = qbsBuildDir();
params.searchPaths = prefs->searchPaths(buildDir); params.setSearchPaths(prefs->searchPaths(buildDir));
params.pluginPaths = prefs->pluginPaths(buildDir); params.setPluginPaths(prefs->pluginPaths(buildDir));
m_qbsSetupProjectJob m_qbsSetupProjectJob
= qbs::Project::setupProject(params, m_manager->settings(), m_manager->logSink(), 0); = qbs::Project::setupProject(params, m_manager->settings(), m_manager->logSink(), 0);
@@ -417,9 +417,9 @@ void QbsProject::updateDocuments(const qbs::ProjectData *prj)
newFiles.insert(m_fileName); // make sure we always have the project file... newFiles.insert(m_fileName); // make sure we always have the project file...
if (prj) { if (prj) {
newFiles.insert(prj->location().fileName); newFiles.insert(prj->location().fileName());
foreach (const qbs::ProductData &prd, prj->products()) foreach (const qbs::ProductData &prd, prj->products())
newFiles.insert(prd.location().fileName); newFiles.insert(prd.location().fileName());
} }
QSet<QString> oldFiles; QSet<QString> oldFiles;
foreach (Core::IDocument *doc, m_qbsDocuments) foreach (Core::IDocument *doc, m_qbsDocuments)

View File

@@ -202,7 +202,7 @@ QString QbsRunConfiguration::executable() const
if (!product) if (!product)
return QString(); return QString();
return pro->qbsProject()->targetExecutable(*product, installRoot()); return pro->qbsProject()->targetExecutable(*product, installOptions());
} }
ProjectExplorer::LocalApplicationRunConfiguration::RunMode QbsRunConfiguration::runMode() const ProjectExplorer::LocalApplicationRunConfiguration::RunMode QbsRunConfiguration::runMode() const
@@ -306,6 +306,13 @@ QString QbsRunConfiguration::defaultDisplayName()
return defaultName; return defaultName;
} }
qbs::InstallOptions QbsRunConfiguration::installOptions() const
{
if (m_currentInstallStep)
return m_currentInstallStep->installOptions();
return qbs::InstallOptions();
}
QString QbsRunConfiguration::installRoot() const QString QbsRunConfiguration::installRoot() const
{ {
if (m_currentInstallStep) if (m_currentInstallStep)
@@ -362,8 +369,6 @@ QbsRunConfigurationWidget::QbsRunConfigurationWidget(QbsRunConfiguration *rc, QW
m_workingDirectoryEdit = new Utils::PathChooser(this); m_workingDirectoryEdit = new Utils::PathChooser(this);
m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory); m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory);
m_workingDirectoryEdit->setPath(m_rc->baseWorkingDirectory());
m_workingDirectoryEdit->setBaseDirectory(m_rc->target()->project()->projectDirectory());
ProjectExplorer::EnvironmentAspect *aspect ProjectExplorer::EnvironmentAspect *aspect
= m_rc->extraAspect<ProjectExplorer::EnvironmentAspect>(); = m_rc->extraAspect<ProjectExplorer::EnvironmentAspect>();
if (aspect) { if (aspect) {
@@ -392,7 +397,6 @@ QbsRunConfigurationWidget::QbsRunConfigurationWidget(QbsRunConfiguration *rc, QW
toplayout->addRow(QString(), innerBox); toplayout->addRow(QString(), innerBox);
runConfigurationEnabledChange(); runConfigurationEnabledChange();
targetInformationHasChanged();
connect(m_workingDirectoryEdit, SIGNAL(changed(QString)), connect(m_workingDirectoryEdit, SIGNAL(changed(QString)),
this, SLOT(workDirectoryEdited())); this, SLOT(workDirectoryEdited()));
@@ -433,6 +437,7 @@ void QbsRunConfigurationWidget::runConfigurationEnabledChange()
m_disabledIcon->setVisible(!enabled); m_disabledIcon->setVisible(!enabled);
m_disabledReason->setVisible(!enabled); m_disabledReason->setVisible(!enabled);
m_disabledReason->setText(m_rc->disabledReason()); m_disabledReason->setText(m_rc->disabledReason());
targetInformationHasChanged();
} }
void QbsRunConfigurationWidget::workDirectoryEdited() void QbsRunConfigurationWidget::workDirectoryEdited()
@@ -470,6 +475,9 @@ void QbsRunConfigurationWidget::targetInformationHasChanged()
{ {
m_ignoreChange = true; m_ignoreChange = true;
m_executableLineEdit->setText(m_rc->executable()); m_executableLineEdit->setText(m_rc->executable());
m_workingDirectoryEdit->setPath(m_rc->baseWorkingDirectory());
m_workingDirectoryEdit->setBaseDirectory(m_rc->target()->project()->projectDirectory());
m_ignoreChange = false; m_ignoreChange = false;
} }
@@ -558,7 +566,7 @@ QList<Core::Id> QbsRunConfigurationFactory::availableCreationIds(ProjectExplorer
return result; return result;
foreach (const qbs::ProductData &product, project->qbsProjectData()->products()) { foreach (const qbs::ProductData &product, project->qbsProjectData()->products()) {
if (!project->qbsProject()->targetExecutable(product, QString()).isEmpty()) if (!project->qbsProject()->targetExecutable(product, qbs::InstallOptions()).isEmpty())
result << Core::Id::fromString(QString::fromLatin1(QBS_RC_PREFIX) + product.name()); result << Core::Id::fromString(QString::fromLatin1(QBS_RC_PREFIX) + product.name());
} }
return result; return result;

View File

@@ -43,6 +43,10 @@ class QRadioButton;
class QComboBox; class QComboBox;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace qbs {
class InstallOptions;
}
namespace Utils { namespace Utils {
class PathChooser; class PathChooser;
class DetailsWidget; class DetailsWidget;
@@ -112,6 +116,7 @@ private:
void setCommandLineArguments(const QString &argumentsString); void setCommandLineArguments(const QString &argumentsString);
QString rawCommandLineArguments() const; QString rawCommandLineArguments() const;
QString defaultDisplayName(); QString defaultDisplayName();
qbs::InstallOptions installOptions() const;
QString installRoot() const; QString installRoot() const;
void ctor(); void ctor();

View File

@@ -65,7 +65,7 @@ QbsStep::QbsStep(ProjectExplorer::BuildStepList *bsl, Core::Id id) :
ProjectExplorer::BuildStep(bsl, id), ProjectExplorer::BuildStep(bsl, id),
m_job(0) m_job(0)
{ {
m_qbsBuildOptions.maxJobCount = QbsManager::preferences()->jobs(); m_qbsBuildOptions.setMaxJobCount(QbsManager::preferences()->jobs());
} }
QbsStep::QbsStep(ProjectExplorer::BuildStepList *bsl, const QbsStep *other) : QbsStep::QbsStep(ProjectExplorer::BuildStepList *bsl, const QbsStep *other) :
@@ -137,17 +137,17 @@ void QbsStep::cancel()
bool QbsStep::dryRun() const bool QbsStep::dryRun() const
{ {
return m_qbsBuildOptions.dryRun; return m_qbsBuildOptions.dryRun();
} }
bool QbsStep::keepGoing() const bool QbsStep::keepGoing() const
{ {
return m_qbsBuildOptions.keepGoing; return m_qbsBuildOptions.keepGoing();
} }
int QbsStep::maxJobs() const int QbsStep::maxJobs() const
{ {
return m_qbsBuildOptions.maxJobCount; return m_qbsBuildOptions.maxJobCount();
} }
bool QbsStep::fromMap(const QVariantMap &map) bool QbsStep::fromMap(const QVariantMap &map)
@@ -155,12 +155,12 @@ bool QbsStep::fromMap(const QVariantMap &map)
if (!ProjectExplorer::BuildStep::fromMap(map)) if (!ProjectExplorer::BuildStep::fromMap(map))
return false; return false;
m_qbsBuildOptions.dryRun = map.value(QLatin1String(QBS_DRY_RUN)).toBool(); m_qbsBuildOptions.setDryRun(map.value(QLatin1String(QBS_DRY_RUN)).toBool());
m_qbsBuildOptions.keepGoing = map.value(QLatin1String(QBS_KEEP_GOING)).toBool(); m_qbsBuildOptions.setKeepGoing(map.value(QLatin1String(QBS_KEEP_GOING)).toBool());
m_qbsBuildOptions.maxJobCount = map.value(QLatin1String(QBS_MAXJOBCOUNT)).toInt(); m_qbsBuildOptions.setMaxJobCount(map.value(QLatin1String(QBS_MAXJOBCOUNT)).toInt());
if (m_qbsBuildOptions.maxJobCount <= 0) if (m_qbsBuildOptions.maxJobCount() <= 0)
m_qbsBuildOptions.maxJobCount = QbsManager::preferences()->jobs(); m_qbsBuildOptions.setMaxJobCount(QbsManager::preferences()->jobs());
return true; return true;
} }
@@ -168,9 +168,9 @@ bool QbsStep::fromMap(const QVariantMap &map)
QVariantMap QbsStep::toMap() const QVariantMap QbsStep::toMap() const
{ {
QVariantMap map = ProjectExplorer::BuildStep::toMap(); QVariantMap map = ProjectExplorer::BuildStep::toMap();
map.insert(QLatin1String(QBS_DRY_RUN), m_qbsBuildOptions.dryRun); map.insert(QLatin1String(QBS_DRY_RUN), m_qbsBuildOptions.dryRun());
map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsBuildOptions.keepGoing); map.insert(QLatin1String(QBS_KEEP_GOING), m_qbsBuildOptions.keepGoing());
map.insert(QLatin1String(QBS_MAXJOBCOUNT), m_qbsBuildOptions.maxJobCount); map.insert(QLatin1String(QBS_MAXJOBCOUNT), m_qbsBuildOptions.maxJobCount());
return map; return map;
} }
@@ -180,7 +180,7 @@ void QbsStep::jobDone(bool success)
if (m_job) { if (m_job) {
foreach (const qbs::ErrorData &data, m_job->error().entries()) foreach (const qbs::ErrorData &data, m_job->error().entries())
createTaskAndOutput(ProjectExplorer::Task::Error, data.description(), createTaskAndOutput(ProjectExplorer::Task::Error, data.description(),
data.codeLocation().fileName, data.codeLocation().line); data.codeLocation().fileName(), data.codeLocation().line());
m_job->deleteLater(); m_job->deleteLater();
m_job = 0; m_job = 0;
} }
@@ -218,25 +218,25 @@ void QbsStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QS
void QbsStep::setDryRun(bool dr) void QbsStep::setDryRun(bool dr)
{ {
if (m_qbsBuildOptions.dryRun == dr) if (m_qbsBuildOptions.dryRun() == dr)
return; return;
m_qbsBuildOptions.dryRun = dr; m_qbsBuildOptions.setDryRun(dr);
emit qbsBuildOptionsChanged(); emit qbsBuildOptionsChanged();
} }
void QbsStep::setKeepGoing(bool kg) void QbsStep::setKeepGoing(bool kg)
{ {
if (m_qbsBuildOptions.keepGoing == kg) if (m_qbsBuildOptions.keepGoing() == kg)
return; return;
m_qbsBuildOptions.keepGoing = kg; m_qbsBuildOptions.setKeepGoing(kg);
emit qbsBuildOptionsChanged(); emit qbsBuildOptionsChanged();
} }
void QbsStep::setMaxJobs(int jobcount) void QbsStep::setMaxJobs(int jobcount)
{ {
if (m_qbsBuildOptions.maxJobCount == jobcount) if (m_qbsBuildOptions.maxJobCount() == jobcount)
return; return;
m_qbsBuildOptions.maxJobCount = jobcount; m_qbsBuildOptions.setMaxJobCount(jobcount);
emit qbsBuildOptionsChanged(); emit qbsBuildOptionsChanged();
} }

View File

@@ -556,9 +556,9 @@ void FormEditorView::rewriterEndTransaction()
m_transactionCounter--; m_transactionCounter--;
} }
double FormEditorView::margins() const double FormEditorView::containerPadding() const
{ {
return m_formEditorWidget->margins(); return m_formEditorWidget->containerPadding();
} }
double FormEditorView::spacing() const double FormEditorView::spacing() const

View File

@@ -119,7 +119,7 @@ public:
void rewriterBeginTransaction() QTC_OVERRIDE; void rewriterBeginTransaction() QTC_OVERRIDE;
void rewriterEndTransaction() QTC_OVERRIDE; void rewriterEndTransaction() QTC_OVERRIDE;
double margins() const; double containerPadding() const;
double spacing() const; double spacing() const;
void deActivateItemCreator(); void deActivateItemCreator();

View File

@@ -70,14 +70,14 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
m_noSnappingAction->setChecked(true); m_noSnappingAction->setChecked(true);
m_noSnappingAction->setIcon(QPixmap(":/icon/layout/no_snapping.png")); m_noSnappingAction->setIcon(QPixmap(":/icon/layout/no_snapping.png"));
m_snappingAndAnchoringAction = layoutActionGroup->addAction(tr("Snapping with anchoring (W).")); m_snappingAndAnchoringAction = layoutActionGroup->addAction(tr("Snap to parent or sibling items and generate anchors (W)."));
m_snappingAndAnchoringAction->setShortcut(Qt::Key_W); m_snappingAndAnchoringAction->setShortcut(Qt::Key_W);
m_snappingAndAnchoringAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); m_snappingAndAnchoringAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
m_snappingAndAnchoringAction->setCheckable(true); m_snappingAndAnchoringAction->setCheckable(true);
m_snappingAndAnchoringAction->setChecked(true); m_snappingAndAnchoringAction->setChecked(true);
m_snappingAndAnchoringAction->setIcon(QPixmap(":/icon/layout/snapping_and_anchoring.png")); m_snappingAndAnchoringAction->setIcon(QPixmap(":/icon/layout/snapping_and_anchoring.png"));
m_snappingAction = layoutActionGroup->addAction(tr("Snap to guides (E).")); m_snappingAction = layoutActionGroup->addAction(tr("Snap to parent or sibling items but do not generate anchors (E)."));
m_snappingAction->setShortcut(Qt::Key_E); m_snappingAction->setShortcut(Qt::Key_E);
m_snappingAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); m_snappingAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
m_snappingAction->setCheckable(true); m_snappingAction->setCheckable(true);
@@ -290,10 +290,10 @@ double FormEditorWidget::spacing() const
return settings.itemSpacing; return settings.itemSpacing;
} }
double FormEditorWidget::margins() const double FormEditorWidget::containerPadding() const
{ {
DesignerSettings settings = QmlDesignerPlugin::instance()->settings(); DesignerSettings settings = QmlDesignerPlugin::instance()->settings();
return settings.snapMargin; return settings.containerPadding;
} }

View File

@@ -65,7 +65,7 @@ public:
ToolBox *toolBox() const; ToolBox *toolBox() const;
double spacing() const; double spacing() const;
double margins() const; double containerPadding() const;
QString contextHelpId() const; QString contextHelpId() const;

View File

@@ -40,10 +40,10 @@ SnappingLineCreator::SnappingLineCreator(FormEditorItem *formEditorItem)
m_bottomOffset(formEditorItem->formEditorView()->spacing()), m_bottomOffset(formEditorItem->formEditorView()->spacing()),
m_leftOffset(formEditorItem->formEditorView()->spacing()), m_leftOffset(formEditorItem->formEditorView()->spacing()),
m_rightOffset(formEditorItem->formEditorView()->spacing()), m_rightOffset(formEditorItem->formEditorView()->spacing()),
m_topMargin(formEditorItem->formEditorView()->margins()), m_topPadding(formEditorItem->formEditorView()->containerPadding()),
m_bottomMargin(formEditorItem->formEditorView()->margins()), m_bottomPadding(formEditorItem->formEditorView()->containerPadding()),
m_leftMargin(formEditorItem->formEditorView()->margins()), m_leftPadding(formEditorItem->formEditorView()->containerPadding()),
m_rightMargin(formEditorItem->formEditorView()->margins()) m_rightPadding(formEditorItem->formEditorView()->containerPadding())
{ {
Q_ASSERT(m_formEditorItem); Q_ASSERT(m_formEditorItem);
} }
@@ -95,7 +95,7 @@ void SnappingLineCreator::generateLines(const QList<FormEditorItem*> &exceptionL
m_formEditorItem->qmlItemNode().instanceBoundingRect()); m_formEditorItem->qmlItemNode().instanceBoundingRect());
addLines(containerBoundingRectInTransformationSpace, m_formEditorItem); addLines(containerBoundingRectInTransformationSpace, m_formEditorItem);
containerBoundingRectInTransformationSpace.adjust(m_leftMargin, m_topMargin, -m_rightMargin, -m_rightMargin); containerBoundingRectInTransformationSpace.adjust(m_leftPadding, m_topPadding, -m_rightPadding, -m_rightPadding);
addLines(containerBoundingRectInTransformationSpace, m_formEditorItem); addLines(containerBoundingRectInTransformationSpace, m_formEditorItem);
} }
@@ -117,12 +117,12 @@ void SnappingLineCreator::generateLines(const QList<FormEditorItem*> &exceptionL
} }
} }
void SnappingLineCreator::setMargins(double margin) void SnappingLineCreator::setContainerPadding(double containerPadding)
{ {
m_topMargin = margin; m_topPadding = containerPadding;
m_bottomMargin = margin; m_bottomPadding = containerPadding;
m_leftMargin = margin; m_leftPadding = containerPadding;
m_rightMargin = margin; m_rightPadding = containerPadding;
} }
void SnappingLineCreator::setSpacing(double spacing) void SnappingLineCreator::setSpacing(double spacing)
@@ -137,7 +137,7 @@ void SnappingLineCreator::update(const QList<FormEditorItem*> &exceptionList,
FormEditorItem *transformationSpaceItem) FormEditorItem *transformationSpaceItem)
{ {
clearLines(); clearLines();
setMargins(m_formEditorItem->formEditorView()->margins()); setContainerPadding(m_formEditorItem->formEditorView()->containerPadding());
setSpacing(m_formEditorItem->formEditorView()->spacing()); setSpacing(m_formEditorItem->formEditorView()->spacing());
generateLines(exceptionList, transformationSpaceItem); generateLines(exceptionList, transformationSpaceItem);
} }

View File

@@ -63,7 +63,7 @@ public:
SnapLineMap leftOffsets() const; SnapLineMap leftOffsets() const;
SnapLineMap rightOffsets() const; SnapLineMap rightOffsets() const;
void setMargins(double margin); void setContainerPadding(double containerPadding);
void setSpacing(double spacing); void setSpacing(double spacing);
protected: protected:
@@ -92,10 +92,10 @@ private:
double m_bottomOffset; double m_bottomOffset;
double m_leftOffset; double m_leftOffset;
double m_rightOffset; double m_rightOffset;
double m_topMargin; double m_topPadding;
double m_bottomMargin; double m_bottomPadding;
double m_leftMargin; double m_leftPadding;
double m_rightMargin; double m_rightPadding;
}; };
} }

View File

@@ -275,9 +275,9 @@ QList<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const Cont
const CppComponentValue * qmlObjectValue = value_cast<CppComponentValue>(prototype); const CppComponentValue * qmlObjectValue = value_cast<CppComponentValue>(prototype);
if (qmlObjectValue) if (qmlObjectValue)
propertyList.append(getQmlTypes(qmlObjectValue, context, false, rec + 1)); propertyList.append(getQmlTypes(qmlObjectValue, context, false, rec));
else else
propertyList.append(getObjectTypes(prototype, context, false, rec + 1)); propertyList.append(getObjectTypes(prototype, context, false, rec));
} }
return propertyList; return propertyList;
@@ -349,9 +349,9 @@ QList<PropertyInfo> getObjectTypes(const ObjectValue *objectValue, const Context
const CppComponentValue * qmlObjectValue = value_cast<CppComponentValue>(prototype); const CppComponentValue * qmlObjectValue = value_cast<CppComponentValue>(prototype);
if (qmlObjectValue) if (qmlObjectValue)
propertyList.append(getQmlTypes(qmlObjectValue, context, local, rec + 1)); propertyList.append(getQmlTypes(qmlObjectValue, context, local, rec));
else else
propertyList.append(getObjectTypes(prototype, context, local, rec + 1)); propertyList.append(getObjectTypes(prototype, context, local, rec));
} }
return propertyList; return propertyList;

View File

@@ -37,7 +37,7 @@ using namespace QmlDesigner;
DesignerSettings::DesignerSettings() DesignerSettings::DesignerSettings()
: openDesignMode(QmlDesigner::Constants::QML_OPENDESIGNMODE_DEFAULT), : openDesignMode(QmlDesigner::Constants::QML_OPENDESIGNMODE_DEFAULT),
itemSpacing(0), itemSpacing(0),
snapMargin(0), containerPadding(0),
canvasWidth(10000), canvasWidth(10000),
canvasHeight(10000), canvasHeight(10000),
warningsInDesigner(true), warningsInDesigner(true),
@@ -55,8 +55,8 @@ void DesignerSettings::fromSettings(QSettings *settings)
bool(QmlDesigner::Constants::QML_OPENDESIGNMODE_DEFAULT)).toBool(); bool(QmlDesigner::Constants::QML_OPENDESIGNMODE_DEFAULT)).toBool();
itemSpacing = settings->value( itemSpacing = settings->value(
QLatin1String(QmlDesigner::Constants::QML_ITEMSPACING_KEY), QVariant(6)).toInt(); QLatin1String(QmlDesigner::Constants::QML_ITEMSPACING_KEY), QVariant(6)).toInt();
snapMargin = settings->value( containerPadding = settings->value(
QLatin1String(QmlDesigner::Constants::QML_SNAPMARGIN_KEY), QVariant(4)).toInt(); QLatin1String(QmlDesigner::Constants::QML_CONTAINERPADDING_KEY), QVariant(8)).toInt();
canvasWidth = settings->value(QLatin1String(QmlDesigner::Constants::QML_CANVASWIDTH_KEY), QVariant(10000)).toInt(); canvasWidth = settings->value(QLatin1String(QmlDesigner::Constants::QML_CANVASWIDTH_KEY), QVariant(10000)).toInt();
canvasHeight = settings->value(QLatin1String(QmlDesigner::Constants::QML_CANVASHEIGHT_KEY), QVariant(10000)).toInt(); canvasHeight = settings->value(QLatin1String(QmlDesigner::Constants::QML_CANVASHEIGHT_KEY), QVariant(10000)).toInt();
warningsInDesigner = settings->value( warningsInDesigner = settings->value(
@@ -78,7 +78,7 @@ void DesignerSettings::toSettings(QSettings *settings) const
settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_DESIGNER_SETTINGS_GROUP)); settings->beginGroup(QLatin1String(QmlDesigner::Constants::QML_DESIGNER_SETTINGS_GROUP));
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_OPENDESIGNMODE_SETTINGS_KEY), openDesignMode); settings->setValue(QLatin1String(QmlDesigner::Constants::QML_OPENDESIGNMODE_SETTINGS_KEY), openDesignMode);
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_ITEMSPACING_KEY), itemSpacing); settings->setValue(QLatin1String(QmlDesigner::Constants::QML_ITEMSPACING_KEY), itemSpacing);
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_SNAPMARGIN_KEY), snapMargin); settings->setValue(QLatin1String(QmlDesigner::Constants::QML_CONTAINERPADDING_KEY), containerPadding);
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_CANVASWIDTH_KEY), canvasWidth); settings->setValue(QLatin1String(QmlDesigner::Constants::QML_CANVASWIDTH_KEY), canvasWidth);
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_CANVASHEIGHT_KEY), canvasHeight); settings->setValue(QLatin1String(QmlDesigner::Constants::QML_CANVASHEIGHT_KEY), canvasHeight);
settings->setValue(QLatin1String(QmlDesigner::Constants::QML_WARNIN_FOR_FEATURES_IN_DESIGNER_KEY), warningsInDesigner); settings->setValue(QLatin1String(QmlDesigner::Constants::QML_WARNIN_FOR_FEATURES_IN_DESIGNER_KEY), warningsInDesigner);
@@ -93,7 +93,7 @@ void DesignerSettings::toSettings(QSettings *settings) const
bool DesignerSettings::equals(const DesignerSettings &other) const bool DesignerSettings::equals(const DesignerSettings &other) const
{ {
return openDesignMode == other.openDesignMode return openDesignMode == other.openDesignMode
&& snapMargin == other.snapMargin && containerPadding == other.containerPadding
&& canvasWidth == other.canvasWidth && canvasWidth == other.canvasWidth
&& canvasHeight == other.canvasHeight && canvasHeight == other.canvasHeight
&& warningsInDesigner == other.warningsInDesigner && warningsInDesigner == other.warningsInDesigner

View File

@@ -49,7 +49,7 @@ public:
bool equals(const DesignerSettings &other) const; bool equals(const DesignerSettings &other) const;
bool openDesignMode; bool openDesignMode;
int itemSpacing; int itemSpacing;
int snapMargin; int containerPadding;
int canvasWidth; int canvasWidth;
int canvasHeight; int canvasHeight;
bool warningsInDesigner; bool warningsInDesigner;

View File

@@ -55,7 +55,7 @@ const char QML_SETTINGS_GROUP[] = "QML";
const char QML_DESIGNER_SETTINGS_GROUP[] = "Designer"; const char QML_DESIGNER_SETTINGS_GROUP[] = "Designer";
const char QML_OPENDESIGNMODE_SETTINGS_KEY[] = "OpenDesignMode"; const char QML_OPENDESIGNMODE_SETTINGS_KEY[] = "OpenDesignMode";
const char QML_ITEMSPACING_KEY[] = "ItemSpacing"; const char QML_ITEMSPACING_KEY[] = "ItemSpacing";
const char QML_SNAPMARGIN_KEY[] = "SnapMargin"; const char QML_CONTAINERPADDING_KEY[] = "ContainerPadding";
const char QML_CANVASWIDTH_KEY[] = "CanvasWidth"; const char QML_CANVASWIDTH_KEY[] = "CanvasWidth";
const char QML_CANVASHEIGHT_KEY[] = "CanvasHeight"; const char QML_CANVASHEIGHT_KEY[] = "CanvasHeight";
const char QML_CONTEXTPANE_KEY[] = "ContextPaneEnabled"; const char QML_CONTEXTPANE_KEY[] = "ContextPaneEnabled";

View File

@@ -50,7 +50,7 @@ DesignerSettings SettingsPageWidget::settings() const
{ {
DesignerSettings designerSettings; DesignerSettings designerSettings;
designerSettings.itemSpacing = m_ui.spinItemSpacing->value(); designerSettings.itemSpacing = m_ui.spinItemSpacing->value();
designerSettings.snapMargin = m_ui.spinSnapMargin->value(); designerSettings.containerPadding = m_ui.spinSnapMargin->value();
designerSettings.canvasWidth = m_ui.spinCanvasWidth->value(); designerSettings.canvasWidth = m_ui.spinCanvasWidth->value();
designerSettings.canvasHeight = m_ui.spinCanvasHeight->value(); designerSettings.canvasHeight = m_ui.spinCanvasHeight->value();
designerSettings.warningsInDesigner = m_ui.designerWarningsCheckBox->isChecked(); designerSettings.warningsInDesigner = m_ui.designerWarningsCheckBox->isChecked();
@@ -64,7 +64,7 @@ DesignerSettings SettingsPageWidget::settings() const
void SettingsPageWidget::setSettings(const DesignerSettings &designerSettings) void SettingsPageWidget::setSettings(const DesignerSettings &designerSettings)
{ {
m_ui.spinItemSpacing->setValue(designerSettings.itemSpacing); m_ui.spinItemSpacing->setValue(designerSettings.itemSpacing);
m_ui.spinSnapMargin->setValue(designerSettings.snapMargin); m_ui.spinSnapMargin->setValue(designerSettings.containerPadding);
m_ui.spinCanvasWidth->setValue(designerSettings.canvasWidth); m_ui.spinCanvasWidth->setValue(designerSettings.canvasWidth);
m_ui.spinCanvasHeight->setValue(designerSettings.canvasHeight); m_ui.spinCanvasHeight->setValue(designerSettings.canvasHeight);
m_ui.designerWarningsCheckBox->setChecked(designerSettings.warningsInDesigner); m_ui.designerWarningsCheckBox->setChecked(designerSettings.warningsInDesigner);

View File

@@ -97,7 +97,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="snapMarginLabel"> <widget class="QLabel" name="snapMarginLabel">
<property name="text"> <property name="text">
<string>Snap margin:</string> <string>Parent item padding:</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -117,7 +117,7 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="itemSpacingLabel"> <widget class="QLabel" name="itemSpacingLabel">
<property name="text"> <property name="text">
<string>Item spacing:</string> <string>Sibling item spacing:</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@@ -142,61 +142,60 @@ void BarDescriptorPermissionsModel::initModel()
{ {
beginResetModel(); beginResetModel();
m_permissions << BarDescriptorPermission(tr("BlackBerry Messenger"), QLatin1String("bbm_connect"), m_permissions << BarDescriptorPermission(tr("BlackBerry Messenger"), QLatin1String("bbm_connect"),
tr("Allows this app to connect to the BBM Social Platform to access BBM\n" tr("<html><head/><body><p>Allows this app to connect to the BBM Social Platform to access BBM "
"contact lists and user profiles, invite BBM contacts to download your\n" "contact lists and user profiles, invite BBM contacts to download your "
"app, initiate BBM chats and share content from within your app, or\n" "app, initiate BBM chats and share content from within your app, or "
"stream data between apps in real time.")); "stream data between apps in real time.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Calendar"), QLatin1String("access_pimdomain_calendars"), m_permissions << BarDescriptorPermission(tr("Calendar"), QLatin1String("access_pimdomain_calendars"),
tr("Allows this app to access the calendar on the device. This access\n" tr("<html><head/><body><p>Allows this app to access the calendar on the device. This access "
"includes viewing, adding, and deleting calendar appointments.")); "includes viewing, adding, and deleting calendar appointments.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Camera"), QLatin1String("use_camera"), m_permissions << BarDescriptorPermission(tr("Camera"), QLatin1String("use_camera"),
tr("Allows this app to take pictures, record video, and use the flash.")); tr("<html><head/><body><p>Allows this app to take pictures, record video, and use the flash.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Contacts"), QLatin1String("access_pimdomain_contacts"), m_permissions << BarDescriptorPermission(tr("Contacts"), QLatin1String("access_pimdomain_contacts"),
tr("Allows this app to access the contacts stored on the device. This\n" tr("<html><head/><body><p>Allows this app to access the contacts stored on the device. This "
"access includes viewing, creating, and deleting the contacts.")); "access includes viewing, creating, and deleting the contacts.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Device Identifying Information"), QLatin1String("read_device_identifying_information"), m_permissions << BarDescriptorPermission(tr("Device Identifying Information"), QLatin1String("read_device_identifying_information"),
tr("Allows this app to access device identifiers such as serial number and PIN.")); tr("<html><head/><body><p>Allows this app to access device identifiers such as serial number and PIN.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Email and PIN Messages"), QLatin1String("access_pimdomain_messages"), m_permissions << BarDescriptorPermission(tr("Email and PIN Messages"), QLatin1String("access_pimdomain_messages"),
tr("Allows this app to access the email and PIN messages stored on the\n" tr("<html><head/><body><p>Allows this app to access the email and PIN messages stored on the "
"device. This access includes viewing, creating, sending, and deleting\n" "device. This access includes viewing, creating, sending, and deleting the messages.</p></body></html>"));
"the messages."));
m_permissions << BarDescriptorPermission(tr("GPS Location"), QLatin1String("read_geolocation"), m_permissions << BarDescriptorPermission(tr("GPS Location"), QLatin1String("read_geolocation"),
tr("Allows this app to access the current GPS location of the device.")); tr("<html><head/><body><p>Allows this app to access the current GPS location of the device.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Internet"), QLatin1String("access_internet"), m_permissions << BarDescriptorPermission(tr("Internet"), QLatin1String("access_internet"),
tr("Allows this app to use Wi-fi, wired, or other connections to a\n" tr("<html><head/><body><p>Allows this app to use Wi-fi, wired, or other connections to a "
"destination that is not local on the user's device.")); "destination that is not local on the user's device.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Location"), QLatin1String("access_location_services"), m_permissions << BarDescriptorPermission(tr("Location"), QLatin1String("access_location_services"),
tr("Allows this app to access the device's current or saved locations.")); tr("<html><head/><body><p>Allows this app to access the device's current or saved locations.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Microphone"), QLatin1String("record_audio"), m_permissions << BarDescriptorPermission(tr("Microphone"), QLatin1String("record_audio"),
tr("Allows this app to record sound using the microphone.")); tr("<html><head/><body><p>Allows this app to record sound using the microphone.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Notebooks"), QLatin1String("access_pimdomain_notebooks"), m_permissions << BarDescriptorPermission(tr("Notebooks"), QLatin1String("access_pimdomain_notebooks"),
tr("Allows this app to access the content stored in the notebooks on the\n" tr("<html><head/><body><p>Allows this app to access the content stored in the notebooks on the "
"device. This access includes adding and deleting entries and content.")); "device. This access includes adding and deleting entries and content.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Post Notifications"), QLatin1String("post_notification"), m_permissions << BarDescriptorPermission(tr("Post Notifications"), QLatin1String("post_notification"),
tr("Post a notification to the notifications area of the screen.")); tr("<html><head/><body><p>Post a notification to the notifications area of the screen.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Push"), QLatin1String("_sys_use_consumer_push"), m_permissions << BarDescriptorPermission(tr("Push"), QLatin1String("_sys_use_consumer_push"),
tr("Allows this app to use the Push Service with the BlackBerry Internet\n" tr("<html><head/><body><p>Allows this app to use the Push Service with the BlackBerry Internet "
"Service. This access allows the app to receive and request push\n" "Service. This access allows the app to receive and request push "
"messages. To use the Push Service with the BlackBerry Internet Service,\n" "messages. To use the Push Service with the BlackBerry Internet Service, "
"you must register with BlackBerry. When you register, you\n" "you must register with BlackBerry. When you register, you "
"receive a confirmation email message that contains information that\n" "receive a confirmation email message that contains information that "
"your application needs to receive and request push messages. For more\n" "your application needs to receive and request push messages. For more "
"information about registering, visit\n" "information about registering, visit "
"https://developer.blackberry.com/services/push/. If you're using the\n" "https://developer.blackberry.com/services/push/. If you're using the "
"Push Service with the BlackBerry Enterprise Server or the BlackBerry\n" "Push Service with the BlackBerry Enterprise Server or the BlackBerry "
"Device Service, you don't need to register with BlackBerry.")); "Device Service, you don't need to register with BlackBerry.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Run When Backgrounded"), QLatin1String("run_when_backgrounded"), m_permissions << BarDescriptorPermission(tr("Run When Backgrounded"), QLatin1String("run_when_backgrounded"),
tr("Allows background processing. Without this permission, the app is\n" tr("<html><head/><body><p>Allows background processing. Without this permission, the app is "
"stopped when the user switches focus to another app. Apps that use this\n" "stopped when the user switches focus to another app. Apps that use this "
"permission are rigorously reviewed for acceptance to BlackBerry App\n" "permission are rigorously reviewed for acceptance to BlackBerry App "
"World storefront for their use of power.")); "World storefront for their use of power.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Shared Files"), QLatin1String("access_shared"), m_permissions << BarDescriptorPermission(tr("Shared Files"), QLatin1String("access_shared"),
tr("Allows this app to access pictures, music, documents, and other files\n" tr("<html><head/><body><p>Allows this app to access pictures, music, documents, and other files "
"stored on the user's device, at a remote storage provider, on a media\n" "stored on the user's device, at a remote storage provider, on a media "
"card, or in the cloud.")); "card, or in the cloud.</p></body></html>"));
m_permissions << BarDescriptorPermission(tr("Text Messages"), QLatin1String("access_sms_mms"), m_permissions << BarDescriptorPermission(tr("Text Messages"), QLatin1String("access_sms_mms"),
tr("Allows this app to access the text messages stored on the device. The\n" tr("<html><head/><body><p>Allows this app to access the text messages stored on the device. The "
"access includes viewing, creating, sending, and deleting text messages.")); "access includes viewing, creating, sending, and deleting text messages.</p></body></html>"));
endResetModel(); endResetModel();
} }

View File

@@ -116,7 +116,7 @@ bool BlackBerryConfiguration::refresh()
if (!simulatorGdbPath.toFileInfo().exists()) if (!simulatorGdbPath.toFileInfo().exists())
errorMessage += QLatin1Char('\n') + tr("- No GDB debugger found for BB10 Simulator."); errorMessage += QLatin1Char('\n') + tr("- No GDB debugger found for BB10 Simulator.");
QMessageBox::warning(0, tr("Cannot Setup BB10 Configuration"), QMessageBox::warning(0, tr("Cannot Set up BB10 Configuration"),
errorMessage, QMessageBox::Ok); errorMessage, QMessageBox::Ok);
return false; return false;
} }
@@ -305,14 +305,14 @@ QtSupport::BaseQtVersion *BlackBerryConfiguration::createQtVersion()
QtSupport::BaseQtVersion *version = QtSupport::QtVersionManager::instance()->qtVersionForQMakeBinary(m_config.qmakeBinaryFile); QtSupport::BaseQtVersion *version = QtSupport::QtVersionManager::instance()->qtVersionForQMakeBinary(m_config.qmakeBinaryFile);
if (version) { if (version) {
QMessageBox::warning(0, tr("Qt Version Already Known"), QMessageBox::warning(0, tr("Qt Version Already Known"),
tr("This Qt version was already registered"), QMessageBox::Ok); tr("This Qt version was already registered."), QMessageBox::Ok);
return version; return version;
} }
version = new BlackBerryQtVersion(QnxUtils::cpudirToArch(cpuDir), m_config.qmakeBinaryFile, false, QString(), m_config.ndkPath); version = new BlackBerryQtVersion(QnxUtils::cpudirToArch(cpuDir), m_config.qmakeBinaryFile, false, QString(), m_config.ndkPath);
if (!version) { if (!version) {
QMessageBox::warning(0, tr("Invalid Qt version"), QMessageBox::warning(0, tr("Invalid Qt Version"),
tr("Unable to add BlackBerry Qt version"), QMessageBox::Ok); tr("Unable to add BlackBerry Qt version."), QMessageBox::Ok);
return 0; return 0;
} }
@@ -329,7 +329,7 @@ ProjectExplorer::GccToolChain *BlackBerryConfiguration::createGccToolChain()
foreach (ProjectExplorer::ToolChain* tc, ProjectExplorer::ToolChainManager::instance()->toolChains()) { foreach (ProjectExplorer::ToolChain* tc, ProjectExplorer::ToolChainManager::instance()->toolChains()) {
if (tc->compilerCommand() == m_config.gccCompiler) { if (tc->compilerCommand() == m_config.gccCompiler) {
QMessageBox::warning(0, tr("Compiler Already Known"), QMessageBox::warning(0, tr("Compiler Already Known"),
tr("This Compiler was already registered"), QMessageBox::Ok); tr("This compiler was already registered."), QMessageBox::Ok);
return dynamic_cast<ProjectExplorer::GccToolChain*>(tc); return dynamic_cast<ProjectExplorer::GccToolChain*>(tc);
} }
} }
@@ -356,7 +356,7 @@ ProjectExplorer::Kit *BlackBerryConfiguration::createKit(QnxArchitecture arch, Q
&& Debugger::DebuggerKitInformation::debuggerCommand(kit) == m_config.simulatorDebuger) && Debugger::DebuggerKitInformation::debuggerCommand(kit) == m_config.simulatorDebuger)
|| (arch == ArmLeV7 && Debugger::DebuggerKitInformation::debuggerCommand(kit) == m_config.deviceDebuger)) { || (arch == ArmLeV7 && Debugger::DebuggerKitInformation::debuggerCommand(kit) == m_config.deviceDebuger)) {
QMessageBox::warning(0, tr("Kit Already Known"), QMessageBox::warning(0, tr("Kit Already Known"),
tr("This Kit was already registered"), QMessageBox::Ok); tr("This kit was already registered."), QMessageBox::Ok);
return kit; return kit;
} }
} }

View File

@@ -106,7 +106,7 @@ bool QNXPlugin::initialize(const QStringList &arguments, QString *errorString)
barDescriptorMimeType.setSubClassesOf(QStringList() << QLatin1String("application/xml")); barDescriptorMimeType.setSubClassesOf(QStringList() << QLatin1String("application/xml"));
if (!Core::ICore::mimeDatabase()->addMimeType(barDescriptorMimeType)) { if (!Core::ICore::mimeDatabase()->addMimeType(barDescriptorMimeType)) {
*errorString = tr("Could not add mime-type for bar-descriptor.xml editor"); *errorString = tr("Could not add mime-type for bar-descriptor.xml editor.");
return false; return false;
} }
addAutoReleasedObject(new BarDescriptorEditorFactory); addAutoReleasedObject(new BarDescriptorEditorFactory);

View File

@@ -1,16 +1,16 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/vnd.nokia.qt.qmakeprofile"> <mime-type type="application/vnd.qt.qmakeprofile">
<sub-class-of type="text/plain"/> <sub-class-of type="text/plain"/>
<comment>Qt Project file</comment> <comment>Qt Project file</comment>
<glob pattern="*.pro"/> <glob pattern="*.pro"/>
</mime-type> </mime-type>
<mime-type type="application/vnd.nokia.qt.qmakeproincludefile"> <mime-type type="application/vnd.qt.qmakeproincludefile">
<sub-class-of type="text/plain"/> <sub-class-of type="text/plain"/>
<comment>Qt Project include file</comment> <comment>Qt Project include file</comment>
<glob pattern="*.pri"/> <glob pattern="*.pri"/>
</mime-type> </mime-type>
<mime-type type="application/vnd.nokia.qt.qmakeprofeaturefile"> <mime-type type="application/vnd.qt.qmakeprofeaturefile">
<sub-class-of type="text/plain"/> <sub-class-of type="text/plain"/>
<comment>Qt Project feature file</comment> <comment>Qt Project feature file</comment>
<glob pattern="*.prf"/> <glob pattern="*.prf"/>

View File

@@ -152,13 +152,13 @@ void Qt4ProjectManagerPlugin::testQmakeOutputParsers_data()
<< QString(); << QString();
QTest::newRow("qMake warning with location") QTest::newRow("qMake warning with location")
<< QString::fromLatin1("WARNING: e:\\NokiaQtSDK\\Simulator\\Qt\\msvc2008\\lib\\qtmaind.prl:1: Unescaped backslashes are deprecated.") << QString::fromLatin1("WARNING: e:\\QtSDK\\Simulator\\Qt\\msvc2008\\lib\\qtmaind.prl:1: Unescaped backslashes are deprecated.")
<< OutputParserTester::STDERR << OutputParserTester::STDERR
<< QString() << QString() << QString() << QString()
<< (QList<ProjectExplorer::Task>() << (QList<ProjectExplorer::Task>()
<< Task(Task::Warning, << Task(Task::Warning,
QLatin1String("Unescaped backslashes are deprecated."), QLatin1String("Unescaped backslashes are deprecated."),
Utils::FileName::fromUserInput(QLatin1String("e:\\NokiaQtSDK\\Simulator\\Qt\\msvc2008\\lib\\qtmaind.prl")), 1, Utils::FileName::fromUserInput(QLatin1String("e:\\QtSDK\\Simulator\\Qt\\msvc2008\\lib\\qtmaind.prl")), 1,
categoryBuildSystem)) categoryBuildSystem))
<< QString(); << QString();
} }

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