Merge remote branch 'origin/2.1'

Conflicts:
	doc/qtcreator.qdoc
	share/qtcreator/templates/mobileapp/app.pro
This commit is contained in:
Oswald Buddenhagen
2010-10-25 11:27:30 +02:00
83 changed files with 83178 additions and 77579 deletions

View File

@@ -84,7 +84,6 @@ enum {
UPDATE_DOCUMENT_DEFAULT_INTERVAL = 100,
UPDATE_USES_DEFAULT_INTERVAL = 150,
UPDATE_OUTLINE_INTERVAL = 500, // msecs after new semantic info has been arrived / cursor has moved
TOOLTIP_TIMER_INTERVAL = 1000 // delay after we show the Quick ToolBar after a tooltip
};
using namespace QmlJS;
@@ -680,7 +679,6 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
m_modelManager(0),
m_contextPane(0),
m_updateSelectedElements(false),
m_toolTipPosition(0),
m_findReferences(new FindReferences(this))
{
qRegisterMetaType<QmlJSEditor::Internal::SemanticInfo>("QmlJSEditor::Internal::SemanticInfo");
@@ -728,11 +726,6 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
m_cursorPositionTimer->setSingleShot(true);
connect(m_cursorPositionTimer, SIGNAL(timeout()), this, SLOT(updateCursorPositionNow()));
m_toolTipTimer = new QTimer(this);
m_toolTipTimer->setInterval(TOOLTIP_TIMER_INTERVAL);
m_toolTipTimer->setSingleShot(true);
connect(m_toolTipTimer, SIGNAL(timeout()), this, SLOT(updateToolTipNow()));
baseTextDocument()->setSyntaxHighlighter(new Highlighter(document()));
m_modelManager = ExtensionSystem::PluginManager::instance()->getObject<ModelManagerInterface>();
@@ -760,9 +753,6 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
connect(this, SIGNAL(refactorMarkerClicked(TextEditor::Internal::RefactorMarker)),
SLOT(onRefactorMarkerClicked(TextEditor::Internal::RefactorMarker)));
connect(editableInterface(), SIGNAL(tooltipRequested(TextEditor::ITextEditor*, QPoint, int)),
SLOT(onTooltipRequested(TextEditor::ITextEditor*, QPoint, int)));
setRequestMarkEnabled(true);
}
@@ -992,8 +982,8 @@ void QmlJSTextEditor::updateCursorPositionNow()
Node *oldNode = m_semanticInfo.declaringMemberNoProperties(m_oldCursorPosition);
Node *newNode = m_semanticInfo.declaringMemberNoProperties(position());
if (oldNode != newNode && m_oldCursorPosition != -1)
m_contextPane->apply(editableInterface(), m_semanticInfo.lookupContext(), newNode, false);
if (m_contextPane->isAvailable(editableInterface(), m_semanticInfo.lookupContext(), newNode) &&
m_contextPane->apply(editableInterface(), semanticInfo().document, LookupContext::Ptr(),newNode, false);
if (m_contextPane->isAvailable(editableInterface(), semanticInfo().document, newNode) &&
!m_contextPane->widget()->isVisible()) {
QList<TextEditor::Internal::RefactorMarker> markers;
if (UiObjectMember *m = newNode->uiObjectMemberCast()) {
@@ -1463,7 +1453,7 @@ void QmlJSTextEditor::showContextPane()
{
if (m_contextPane && m_semanticInfo.isValid()) {
Node *newNode = m_semanticInfo.declaringMemberNoProperties(position());
m_contextPane->apply(editableInterface(), m_semanticInfo.lookupContext(), newNode, false, true);
m_contextPane->apply(editableInterface(), m_semanticInfo.document, m_semanticInfo.lookupContext(), newNode, false, true);
m_oldCursorPosition = position();
QList<TextEditor::Internal::RefactorMarker> markers;
setRefactorMarkers(markers);
@@ -1476,40 +1466,6 @@ void QmlJSTextEditor::performQuickFix(int index)
op->perform();
}
void QmlJSTextEditor::onTooltipRequested(TextEditor::ITextEditor* /* editor */, QPoint /* point */, int position)
{
m_toolTipPosition = position;
if (m_contextPane) {
m_toolTipTimer->start();
}
}
void QmlJSTextEditor::updateToolTipNow()
{
if (!TextEditor::ToolTip::instance()->isVisible())
return;
if (m_contextPane && m_semanticInfo.isValid()) {
Node *newNode = m_semanticInfo.declaringMemberNoProperties(m_toolTipPosition);
if (m_contextPane->isAvailable(editableInterface(), m_semanticInfo.lookupContext(), newNode)) {
if (UiQualifiedId *q = qualifiedTypeNameId(newNode)) {
const int start = q->identifierToken.begin();
for (; q; q = q->next) {
if (! q->next) {
const int end = q->identifierToken.end();
if (m_toolTipPosition >= start && m_toolTipPosition <= end) {
m_contextPane->apply(editableInterface(), m_semanticInfo.lookupContext(), newNode, false, true);
m_oldCursorPosition = m_toolTipPosition;
QList<TextEditor::Internal::RefactorMarker> markers;
setRefactorMarkers(markers);
}
}
}
}
}
}
}
void QmlJSTextEditor::contextMenuEvent(QContextMenuEvent *e)
{
QMenu *menu = new QMenu();
@@ -1592,7 +1548,7 @@ void QmlJSTextEditor::wheelEvent(QWheelEvent *event)
LookupContext::Ptr lookupContext;
if (m_semanticInfo.isValid())
lookupContext = m_semanticInfo.lookupContext();
m_contextPane->apply(editableInterface(), lookupContext, m_semanticInfo.declaringMemberNoProperties(m_oldCursorPosition), false, true);
m_contextPane->apply(editableInterface(), semanticInfo().document, QmlJS::LookupContext::Ptr(), m_semanticInfo.declaringMemberNoProperties(m_oldCursorPosition), false, true);
}
}
@@ -1842,7 +1798,7 @@ void QmlJSTextEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
if (m_contextPane) {
Node *newNode = m_semanticInfo.declaringMemberNoProperties(position());
if (newNode) {
m_contextPane->apply(editableInterface(), m_semanticInfo.lookupContext(), newNode, true);
m_contextPane->apply(editableInterface(), semanticInfo.document, LookupContext::Ptr(), newNode, true);
m_cursorPositionTimer->start(); //update text marker
}
}
@@ -1895,10 +1851,7 @@ bool QmlJSTextEditor::hideContextPane()
{
bool b = (m_contextPane) && m_contextPane->widget()->isVisible();
if (b) {
LookupContext::Ptr lookupContext;
if (m_semanticInfo.isValid())
lookupContext = m_semanticInfo.lookupContext();
m_contextPane->apply(editableInterface(), lookupContext, 0, false);
m_contextPane->apply(editableInterface(), semanticInfo().document, LookupContext::Ptr(), 0, false);
}
return b;
}
@@ -2006,6 +1959,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
doc = snapshot.documentFromSource(source.code, source.fileName);
doc->setEditorRevision(source.revision);
doc->parse();
snapshot.insert(doc);
}
SemanticInfo semanticInfo;

View File

@@ -281,8 +281,6 @@ private slots:
void onRefactorMarkerClicked(const TextEditor::Internal::RefactorMarker &marker);
void performQuickFix(int index);
void onTooltipRequested(TextEditor::ITextEditor* editor, QPoint point, int position);
void updateToolTipNow();
protected:
void contextMenuEvent(QContextMenuEvent *e);
@@ -320,7 +318,6 @@ private:
QTimer *m_semanticRehighlightTimer;
QTimer *m_updateOutlineTimer;
QTimer *m_updateOutlineIndexTimer;
QTimer *m_toolTipTimer;
QTimer *m_cursorPositionTimer;
QComboBox *m_outlineCombo;
QmlOutlineModel *m_outlineModel;
@@ -338,7 +335,6 @@ private:
QmlJS::IContextPane *m_contextPane;
int m_oldCursorPosition;
bool m_updateSelectedElements;
int m_toolTipPosition;
FindReferences *m_findReferences;
};

View File

@@ -367,11 +367,6 @@ void QmlOutlineModel::update(const SemanticInfo &semanticInfo)
m_treePos.append(0);
m_currentItem = invisibleRootItem();
// Set up lookup context once to do the element type lookup
//
// We're simplifying here by using the root context everywhere; should be
// ok since there is AFAIK no way to introduce new type names in a sub-context.
m_context = semanticInfo.lookupContext();
m_typeToIcon.clear();
m_itemToNode.clear();
m_itemToIdNode.clear();
@@ -381,8 +376,6 @@ void QmlOutlineModel::update(const SemanticInfo &semanticInfo)
QmlOutlineModelSync syncModel(this);
syncModel(m_semanticInfo.document);
m_context.clear();
emit updated();
}
@@ -815,26 +808,18 @@ AST::SourceLocation QmlOutlineModel::getLocation(AST::ExpressionNode *exprNode)
}
QIcon QmlOutlineModel::getIcon(AST::UiQualifiedId *qualifiedId) {
const Interpreter::Value *value = m_context->evaluate(qualifiedId);
QIcon icon;
if (qualifiedId) {
QString name = asString(qualifiedId);
if (name.contains(QLatin1Char('.')))
name = name.split(QLatin1Char('.')).last();
if (const Interpreter::ObjectValue *objectValue = value->asObjectValue()) {
do {
QString module;
QString typeName;
if (const Interpreter::QmlObjectValue *qmlObjectValue =
dynamic_cast<const Interpreter::QmlObjectValue*>(objectValue)) {
module = qmlObjectValue->packageName();
}
typeName = objectValue->className();
QIcon icon = m_icons->icon(module, typeName);
if (! icon.isNull())
return icon;
objectValue = objectValue->prototype(m_context->context());
} while (objectValue);
// TODO: get rid of namespace prefixes.
icon = m_icons->icon("Qt", name);
if (icon.isNull())
icon = m_icons->icon("QtWebkit", name);
}
return QIcon();
return icon;
}
QString QmlOutlineModel::getAnnotation(AST::UiObjectInitializer *objectInitializer) {

View File

@@ -120,7 +120,6 @@ private:
QStandardItem *m_currentItem;
QmlJS::Icons *m_icons;
QmlJS::LookupContext::Ptr m_context;
QHash<QString, QIcon> m_typeToIcon;
QHash<QmlOutlineItem*,QIcon> m_itemToIcon;
QHash<QmlOutlineItem*,QmlJS::AST::Node*> m_itemToNode;

View File

@@ -98,17 +98,14 @@ QuickToolBar::~QuickToolBar()
m_widget.clear();
}
void QuickToolBar::apply(TextEditor::BaseTextEditorEditable *editor, LookupContext::Ptr lookupContext, AST::Node *node, bool update, bool force)
void QuickToolBar::apply(TextEditor::BaseTextEditorEditable *editor, Document::Ptr document, LookupContext::Ptr lookupContext, AST::Node *node, bool update, bool force)
{
if (!QuickToolBarSettings::get().enableContextPane && !force && !update) {
contextWidget()->hide();
return;
}
if (lookupContext.isNull())
return;
Document::Ptr doc = lookupContext->document();
if (doc.isNull())
if (document.isNull())
return;
if (update && editor != m_editor)
@@ -116,24 +113,26 @@ void QuickToolBar::apply(TextEditor::BaseTextEditorEditable *editor, LookupConte
m_blockWriting = true;
const Interpreter::ObjectValue *scopeObject = doc->bind()->findQmlObject(node);
const Interpreter::ObjectValue *scopeObject = document->bind()->findQmlObject(node);
QStringList prototypes;
while (scopeObject) {
prototypes.append(scopeObject->className());
scopeObject = scopeObject->prototype(lookupContext->context());
}
if (!lookupContext.isNull()) {
m_prototypes.clear();
while (scopeObject) {
m_prototypes.append(scopeObject->className());
scopeObject = scopeObject->prototype(lookupContext->context());
}
if (prototypes.contains("PropertyChanges")) {
const Interpreter::ObjectValue *targetObject = getPropertyChangesTarget(node, lookupContext);
prototypes.clear();
while (targetObject) {
prototypes.append(targetObject->className());
targetObject = targetObject->prototype(lookupContext->context());
if (m_prototypes.contains("PropertyChanges")) {
const Interpreter::ObjectValue *targetObject = getPropertyChangesTarget(node, lookupContext);
m_prototypes.clear();
while (targetObject) {
m_prototypes.append(targetObject->className());
targetObject = targetObject->prototype(lookupContext->context());
}
}
}
setEnabled(doc->isParsedCorrectly());
setEnabled(document->isParsedCorrectly());
m_editor = editor;
contextWidget()->setParent(editor->widget()->parentWidget());
contextWidget()->colorDialog()->setParent(editor->widget()->parentWidget());
@@ -158,6 +157,8 @@ void QuickToolBar::apply(TextEditor::BaseTextEditorEditable *editor, LookupConte
end = objectBinding->lastSourceLocation().end();
}
m_prototypes.append(name);
int line1;
int column1;
int line2;
@@ -175,9 +176,9 @@ void QuickToolBar::apply(TextEditor::BaseTextEditorEditable *editor, LookupConte
rect.moveTo(reg.boundingRect().topLeft());
reg = reg.intersect(rect);
if (contextWidget()->acceptsType(prototypes)) {
if (contextWidget()->acceptsType(m_prototypes)) {
m_node = 0;
PropertyReader propertyReader(doc, initializer);
PropertyReader propertyReader(document, initializer);
QTextCursor tc(editor->editor()->document());
tc.setPosition(offset);
QPoint p1 = editor->editor()->mapToParent(editor->editor()->viewport()->mapToParent(editor->editor()->cursorRect(tc).topLeft()) - QPoint(0, contextWidget()->height() + 10));
@@ -188,15 +189,15 @@ void QuickToolBar::apply(TextEditor::BaseTextEditorEditable *editor, LookupConte
offset = QPoint(400 - reg.boundingRect().width() + 10 ,0);
QPoint p3 = editor->editor()->mapToParent(editor->editor()->viewport()->mapToParent(reg.boundingRect().topRight()) + offset);
p2.setX(p1.x());
contextWidget()->setType(prototypes);
contextWidget()->setType(m_prototypes);
if (!update)
contextWidget()->activate(p3 , p1, p2, QuickToolBarSettings::get().pinContextPane);
else
contextWidget()->rePosition(p3 , p1, p2, QuickToolBarSettings::get().pinContextPane);
contextWidget()->setOptions(QuickToolBarSettings::get().enableContextPane, QuickToolBarSettings::get().pinContextPane);
contextWidget()->setPath(doc->path());
contextWidget()->setPath(document->path());
contextWidget()->setProperties(&propertyReader);
m_doc = doc;
m_doc = document;
m_node = node;
} else {
contextWidget()->setParent(0);
@@ -213,34 +214,27 @@ void QuickToolBar::apply(TextEditor::BaseTextEditorEditable *editor, LookupConte
}
bool QuickToolBar::isAvailable(TextEditor::BaseTextEditorEditable *, LookupContext::Ptr lookupContext, AST::Node *node)
bool QuickToolBar::isAvailable(TextEditor::BaseTextEditorEditable *, Document::Ptr document, AST::Node *node)
{
if (lookupContext.isNull())
return false;
Document::Ptr doc = lookupContext->document();
if (doc.isNull())
if (document.isNull())
return false;
if (!node)
return false;
const Interpreter::ObjectValue *scopeObject = doc->bind()->findQmlObject(node);
QString name;
UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(node);
UiObjectBinding *objectBinding = cast<UiObjectBinding*>(node);
if (objectDefinition) {
name = objectDefinition->qualifiedTypeNameId->name->asString();
} else if (objectBinding) {
name = objectBinding->qualifiedTypeNameId->name->asString();
}
QStringList prototypes;
while (scopeObject) {
prototypes.append(scopeObject->className());
scopeObject = scopeObject->prototype(lookupContext->context());
}
if (prototypes.contains("PropertyChanges")) {
const Interpreter::ObjectValue *targetObject = getPropertyChangesTarget(node, lookupContext);
prototypes.clear();
while (targetObject) {
prototypes.append(targetObject->className());
targetObject = targetObject->prototype(lookupContext->context());
}
}
prototypes.append(name);
if (prototypes.contains("Rectangle") ||
prototypes.contains("Image") ||
@@ -248,7 +242,9 @@ bool QuickToolBar::isAvailable(TextEditor::BaseTextEditorEditable *, LookupConte
prototypes.contains("TextEdit") ||
prototypes.contains("TextInput") ||
prototypes.contains("PropertyAnimation") ||
prototypes.contains("Text"))
prototypes.contains("NumberAnimation") ||
prototypes.contains("Text") ||
prototypes.contains("PropertyChanges"))
return true;
return false;

View File

@@ -30,8 +30,8 @@ class QuickToolBar : public QmlJS::IContextPane
public:
QuickToolBar(QObject *parent = 0);
~QuickToolBar();
void apply(TextEditor::BaseTextEditorEditable *editor, QmlJS::LookupContext::Ptr lookupContext, QmlJS::AST::Node *node, bool update, bool force = 0);
bool isAvailable(TextEditor::BaseTextEditorEditable *editor, QmlJS::LookupContext::Ptr lookupContext, QmlJS::AST::Node *node);
void apply(TextEditor::BaseTextEditorEditable *editor, QmlJS::Document::Ptr document, QmlJS::LookupContext::Ptr lookupContext, QmlJS::AST::Node *node, bool update, bool force = false);
bool isAvailable(TextEditor::BaseTextEditorEditable *editor, QmlJS::Document::Ptr document, QmlJS::AST::Node *node);
void setProperty(const QString &propertyName, const QVariant &value);
void removeProperty(const QString &propertyName);
void setEnabled(bool);
@@ -52,6 +52,7 @@ private:
TextEditor::BaseTextEditorEditable *m_editor;
bool m_blockWriting;
QStringList m_propertyOrder;
QStringList m_prototypes;
};
} //QmlDesigner