Commit f679e80c authored by mae's avatar mae
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents 522cf96b 2216cda2
......@@ -140,7 +140,6 @@ struct EditorManagerPrivate {
Internal::SplitterOrView *m_splitter;
QPointer<IEditor> m_currentEditor;
QPointer<SplitterOrView> m_currentView;
QStackedLayout *m_stackedLayout;
ICore *m_core;
......@@ -182,7 +181,6 @@ struct EditorManagerPrivate {
EditorManagerPrivate::EditorManagerPrivate(ICore *core, QWidget *parent) :
m_view(0),
m_splitter(0),
m_stackedLayout(0),
m_core(core),
m_revertToSavedAction(new QAction(EditorManager::tr("Revert to Saved"), parent)),
m_saveAction(new QAction(parent)),
......@@ -388,8 +386,10 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
m_d->m_view = m_d->m_splitter->view();
m_d->m_stackedLayout = new QStackedLayout(this);
m_d->m_stackedLayout->addWidget(m_d->m_splitter);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(m_d->m_splitter);
updateActions();
......@@ -423,11 +423,6 @@ void EditorManager::init()
pluginManager()->addObject(m_d->m_openEditorsFactory);
}
QSize EditorManager::minimumSizeHint() const
{
return QSize(400, 300);
}
QString EditorManager::defaultExternalEditor() const
{
#ifdef Q_OS_MAC
......
......@@ -151,8 +151,6 @@ public:
void saveSettings(QSettings *settings);
void readSettings(QSettings *settings);
QSize minimumSizeHint() const;
Internal::OpenEditorsWindow *windowPopup() const;
void showWindowPopup() const;
......
......@@ -656,6 +656,13 @@ SplitterOrView *SplitterOrView::findNextView_helper(SplitterOrView *view, bool *
return 0;
}
QSize SplitterOrView::minimumSizeHint() const
{
if (m_splitter)
return m_splitter->minimumSizeHint();
return QSize(64, 64);
}
void SplitterOrView::split(Qt::Orientation orientation)
{
Q_ASSERT(m_view && m_splitter == 0);
......
......@@ -179,8 +179,8 @@ public:
SplitterOrView *findNextView(SplitterOrView *view);
QSize sizeHint() const { return QSize(32, 32); }
QSize minimumSizeHint() const { return QSize(32, 32); }
QSize sizeHint() const { return minimumSizeHint(); }
QSize minimumSizeHint() const;
protected:
void focusInEvent(QFocusEvent *);
......
......@@ -432,7 +432,7 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
return -1;
m_editor = editor;
m_startPosition = findStartOfName(editor);
m_startPosition = findStartOfName();
m_completionOperator = T_EOF_SYMBOL;
int endOfOperator = m_startPosition;
......@@ -520,7 +520,7 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
if (m_completionOperator == T_LPAREN && completeFunction(exprTy, resolvedTypes, context)) {
return m_startPosition;
} if ((m_completionOperator == T_DOT || m_completionOperator == T_ARROW) &&
} else if ((m_completionOperator == T_DOT || m_completionOperator == T_ARROW) &&
completeMember(resolvedTypes, context)) {
return m_startPosition;
} else if (m_completionOperator == T_COLON_COLON && completeScope(resolvedTypes, context)) {
......@@ -531,6 +531,32 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
return m_startPosition;
}
}
if (m_completionOperator == T_LPAREN) {
// Find the expression that precedes the current name
int index = endOfExpression;
while (m_editor->characterAt(index - 1).isSpace())
--index;
index = findStartOfName(index);
QTextCursor tc(edit->document());
tc.setPosition(index);
QString baseExpression = expressionUnderCursor(tc);
// Resolve the type of this expression
QList<TypeOfExpression::Result> results =
typeOfExpression(baseExpression, thisDocument, symbol, TypeOfExpression::Preprocess);
// If it's a class, add completions for the constructors
foreach (const TypeOfExpression::Result &result, results) {
if (result.first->isClass()) {
FullySpecifiedType exprTy = result.first;
if (completeConstructors(exprTy->asClass()))
return m_startPosition;
break;
}
}
}
}
// nothing to do.
......@@ -541,26 +567,14 @@ bool CppCodeCompletion::completeFunction(FullySpecifiedType exprTy,
const QList<TypeOfExpression::Result> &resolvedTypes,
const LookupContext &)
{
ConvertToCompletionItem toCompletionItem(this);
Overview o;
o.setShowReturnTypes(true);
o.setShowArgumentNames(true);
if (Class *klass = exprTy->asClass()) {
for (unsigned i = 0; i < klass->memberCount(); ++i) {
Symbol *member = klass->memberAt(i);
if (! member->type()->isFunction())
continue;
else if (! member->identity())
continue;
else if (! member->identity()->isEqualTo(klass->identity()))
continue;
if (TextEditor::CompletionItem item = toCompletionItem(member)) {
item.m_text = o(member->type(), member->name());
m_completions.append(item);
}
}
completeConstructors(klass);
} else {
ConvertToCompletionItem toCompletionItem(this);
Overview o;
o.setShowReturnTypes(true);
o.setShowArgumentNames(true);
QSet<QString> signatures;
foreach (TypeOfExpression::Result p, resolvedTypes) {
FullySpecifiedType ty = p.first;
......@@ -873,6 +887,30 @@ void CppCodeCompletion::completeClass(const QList<Symbol *> &candidates,
}
}
bool CppCodeCompletion::completeConstructors(Class *klass)
{
ConvertToCompletionItem toCompletionItem(this);
Overview o;
o.setShowReturnTypes(true);
o.setShowArgumentNames(true);
for (unsigned i = 0; i < klass->memberCount(); ++i) {
Symbol *member = klass->memberAt(i);
if (! member->type()->isFunction())
continue;
else if (! member->identity())
continue;
else if (! member->identity()->isEqualTo(klass->identity()))
continue;
if (TextEditor::CompletionItem item = toCompletionItem(member)) {
item.m_text = o(member->type(), member->name());
m_completions.append(item);
}
}
return ! m_completions.isEmpty();
}
bool CppCodeCompletion::completeQtMethod(CPlusPlus::FullySpecifiedType,
const QList<TypeOfExpression::Result> &results,
const LookupContext &context,
......@@ -1135,14 +1173,15 @@ void CppCodeCompletion::cleanup()
typeOfExpression.setSnapshot(Snapshot());
}
int CppCodeCompletion::findStartOfName(const TextEditor::ITextEditor *editor)
int CppCodeCompletion::findStartOfName(int pos) const
{
int pos = editor->position();
if (pos == -1)
pos = m_editor->position();
QChar chr;
// Skip to the start of a name
do {
chr = editor->characterAt(--pos);
chr = m_editor->characterAt(--pos);
} while (chr.isLetterOrNumber() || chr == QLatin1Char('_'));
return pos + 1;
......
......@@ -103,6 +103,8 @@ private:
const CPlusPlus::LookupContext &context,
bool staticLookup = true);
bool completeConstructors(CPlusPlus::Class *klass);
bool completeQtMethod(CPlusPlus::FullySpecifiedType exprTy,
const QList<CPlusPlus::TypeOfExpression::Result> &,
const CPlusPlus::LookupContext &context,
......@@ -118,7 +120,7 @@ private:
const CPlusPlus::LookupContext &context)
{ return completeQtMethod(exprTy, results, context, false); }
static int findStartOfName(const TextEditor::ITextEditor *editor);
int findStartOfName(int pos = -1) const;
QList<TextEditor::CompletionItem> m_completions;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment