Commit 78a04f0a authored by hjk's avatar hjk

TextEditor: Wiggle codeassist setup

Remove GenericProposalModel convenience constructor,
add GenericProposal instead. Less user side code.

Change-Id: I833f9943df27b50579485c93efb96943ec403f65
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent fef838ee
......@@ -107,8 +107,8 @@ private:
class VirtualFunctionProposal : public GenericProposal
{
public:
VirtualFunctionProposal(int cursorPos, GenericProposalModel *model, bool openInSplit)
: GenericProposal(cursorPos, model)
VirtualFunctionProposal(int cursorPos, const QList<AssistProposalItem *> &items, bool openInSplit)
: GenericProposal(cursorPos, items)
, m_openInSplit(openInSplit)
{}
......@@ -140,9 +140,7 @@ public:
QList<AssistProposalItem *> items;
items << itemFromFunction(m_params.function);
items << hintItem;
return new VirtualFunctionProposal(m_params.cursorPosition,
new GenericProposalModel(items),
m_params.openInNextSplit);
return new VirtualFunctionProposal(m_params.cursorPosition, items, m_params.openInNextSplit);
}
IAssistProposal *perform(const AssistInterface *) QTC_OVERRIDE
......@@ -166,9 +164,7 @@ public:
items << itemFromFunction(func);
items.first()->setOrder(1000); // Ensure top position for function of static type
return new VirtualFunctionProposal(m_params.cursorPosition,
new GenericProposalModel(items),
m_params.openInNextSplit);
return new VirtualFunctionProposal(m_params.cursorPosition, items, m_params.openInNextSplit);
}
private:
......
......@@ -915,8 +915,9 @@ class FakeVimAssistProposalModel : public GenericProposalModel
{
public:
FakeVimAssistProposalModel(const QList<AssistProposalItem *> &items)
: GenericProposalModel(items)
{}
{
loadContent(items);
}
bool supportsPrefixExpansion() const QTC_OVERRIDE
{
......
......@@ -427,14 +427,8 @@ IAssistProposal *GlslCompletionAssistProcessor::perform(const AssistInterface *i
}
m_startPosition = pos + 1;
return createContentProposal();
}
IAssistProposal *GlslCompletionAssistProcessor::createContentProposal() const
{
GenericProposalModel *model = new GenericProposalModel(m_completions);
IAssistProposal *proposal = new GenericProposal(m_startPosition, model);
return proposal;
return new GenericProposal(m_startPosition, m_completions);
}
IAssistProposal *GlslCompletionAssistProcessor::createHintProposal(
......
......@@ -107,7 +107,6 @@ public:
TextEditor::IAssistProposal *perform(const TextEditor::AssistInterface *interface) QTC_OVERRIDE;
private:
TextEditor::IAssistProposal *createContentProposal() const;
TextEditor::IAssistProposal *createHintProposal(const QVector<GLSL::Function *> &symbols);
bool acceptsIdleEditor() const;
void addCompletion(const QString &text, const QIcon &icon, int order = 0);
......
......@@ -512,8 +512,7 @@ QmlJSCompletionAssistProcessor::~QmlJSCompletionAssistProcessor()
IAssistProposal *QmlJSCompletionAssistProcessor::createContentProposal() const
{
GenericProposalModel *model = new QmlJSAssistProposalModel(m_completions);
IAssistProposal *proposal = new GenericProposal(m_startPosition, model);
return proposal;
return new GenericProposal(m_startPosition, model);
}
IAssistProposal *QmlJSCompletionAssistProcessor::createHintProposal(
......
......@@ -66,8 +66,9 @@ class QmlJSAssistProposalModel : public TextEditor::GenericProposalModel
{
public:
QmlJSAssistProposalModel(const QList<TextEditor::AssistProposalItem *> &items)
: TextEditor::GenericProposalModel(items)
{}
{
loadContent(items);
}
void filter(const QString &prefix) QTC_OVERRIDE;
void sort(const QString &prefix) QTC_OVERRIDE;
......
......@@ -92,8 +92,6 @@ public:
if (!interface)
return 0;
QScopedPointer<const AssistInterface> assistInterface(interface);
QIcon icon = QIcon::fromTheme(QLatin1String("edit-paste"), QIcon(QLatin1String(Core::Constants::ICON_PASTE))).pixmap(16);
CircularClipboard * clipboard = CircularClipboard::instance();
QList<AssistProposalItem *> items;
......@@ -106,7 +104,7 @@ public:
items.append(item);
}
return new GenericProposal(interface->position(), new GenericProposalModel(items));
return new GenericProposal(interface->position(), items);
}
};
......
......@@ -38,6 +38,13 @@ GenericProposal::GenericProposal(int cursorPos, GenericProposalModel *model)
, m_model(model)
{}
GenericProposal::GenericProposal(int cursorPos, const QList<AssistProposalItem *> &items)
: m_basePosition(cursorPos)
, m_model(new GenericProposalModel)
{
m_model->loadContent(items);
}
GenericProposal::~GenericProposal()
{}
......
......@@ -37,11 +37,13 @@
namespace TextEditor {
class GenericProposalModel;
class AssistProposalItem;
class TEXTEDITOR_EXPORT GenericProposal : public IAssistProposal
{
public:
GenericProposal(int cursorPos, GenericProposalModel *model);
GenericProposal(int cursorPos, const QList<AssistProposalItem *> &items);
~GenericProposal();
bool isFragile() const QTC_OVERRIDE;
......
......@@ -136,13 +136,6 @@ private:
GenericProposalModel::GenericProposalModel()
{}
GenericProposalModel::GenericProposalModel(const QList<AssistProposalItem *> &items)
: m_currentItems(items)
, m_originalItems(items)
{
mapPersistentIds();
}
GenericProposalModel::~GenericProposalModel()
{
qDeleteAll(m_originalItems);
......@@ -152,11 +145,6 @@ void GenericProposalModel::loadContent(const QList<AssistProposalItem *> &items)
{
m_originalItems = items;
m_currentItems = items;
mapPersistentIds();
}
void GenericProposalModel::mapPersistentIds()
{
for (int i = 0; i < m_originalItems.size(); ++i)
m_idByText.insert(m_originalItems.at(i)->text(), i);
}
......
......@@ -50,7 +50,6 @@ class TEXTEDITOR_EXPORT GenericProposalModel : public IAssistProposalModel
{
public:
GenericProposalModel();
GenericProposalModel(const QList<AssistProposalItem *> &items);
~GenericProposalModel();
void reset() QTC_OVERRIDE;
......@@ -77,8 +76,6 @@ protected:
QList<AssistProposalItem *> m_currentItems;
private:
void mapPersistentIds();
QHash<QString, int> m_idByText;
QList<AssistProposalItem *> m_originalItems;
};
......
......@@ -196,10 +196,10 @@ IAssistProposal *KeywordsCompletionAssistProcessor::perform(const AssistInterfac
IAssistProposal *proposal = new FunctionHintProposal(m_startPosition, model);
return proposal;
} else {
QList<TextEditor::AssistProposalItem *> items;
QList<AssistProposalItem *> items;
addWordsToProposalList(&items, m_keywords.variables(), m_variableIcon);
addWordsToProposalList(&items, m_keywords.functions(), m_functionIcon);
return new GenericProposal(m_startPosition, new GenericProposalModel(items));
return new GenericProposal(m_startPosition, items);
}
}
......
......@@ -72,7 +72,7 @@ IAssistProposal *QuickFixAssistProcessor::perform(const AssistInterface *interfa
item->setOrder(op->priority());
items.append(item);
}
return new GenericProposal(interface->position(), new GenericProposalModel(items));
return new GenericProposal(interface->position(), items);
}
return 0;
......
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