Show auto generated slots (e.g. onClicked) only when performing a global completion.

This commit is contained in:
Roberto Raggi
2010-01-26 10:10:11 +01:00
parent c65a028f74
commit 2a5506b1d0
3 changed files with 58 additions and 7 deletions

View File

@@ -381,8 +381,19 @@ class EnumerateProperties: private Interpreter::MemberProcessor
{
QSet<const Interpreter::ObjectValue *> _processed;
QHash<QString, const Interpreter::Value *> _properties;
bool _globalCompletion;
public:
EnumerateProperties()
: _globalCompletion(false)
{
}
void setGlobalCompletion(bool globalCompletion)
{
_globalCompletion = globalCompletion;
}
QHash<QString, const Interpreter::Value *> operator()(const Interpreter::Value *value,
bool lookAtScope = false)
{
@@ -393,12 +404,19 @@ public:
}
private:
virtual bool process(const QString &name, const Interpreter::Value *value)
virtual bool processProperty(const QString &name, const Interpreter::Value *value)
{
_properties.insert(name, value);
return true;
}
virtual bool processSlot(const QString &name, const Interpreter::Value *value)
{
if (_globalCompletion)
_properties.insert(name, value);
return true;
}
void enumerateProperties(const Interpreter::Value *value, bool lookAtScope)
{
if (! value)
@@ -881,6 +899,7 @@ int QmlCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
}
EnumerateProperties enumerateProperties;
enumerateProperties.setGlobalCompletion(true);
QHashIterator<QString, const Interpreter::Value *> it(enumerateProperties(scope, /* lookAtScope = */ true));
while (it.hasNext()) {
it.next();