Commit 49f3442a authored by Eike Ziller's avatar Eike Ziller

CodeAssist: Use settable property for IAssistProposal::isFragile

Removes the need to create yet another subclass (for overriding a
virtual method) in some situations.

Change-Id: I55d70de60b4f8d127a175d996f797700c2f172a6
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
parent f97657b1
......@@ -106,9 +106,9 @@ public:
bool openInSplit)
: GenericProposal(cursorPos, items)
, m_openInSplit(openInSplit)
{}
bool isFragile() const override { return true; }
{
setFragile(true);
}
IAssistProposalWidget *createWidget() const override
{ return new VirtualFunctionProposalWidget(m_openInSplit); }
......
......@@ -32,16 +32,13 @@ using namespace TextEditor;
FunctionHintProposal::FunctionHintProposal(int cursorPos, IFunctionHintProposalModel *model)
: IAssistProposal(cursorPos)
, m_model(model)
{}
{
setFragile(true);
}
FunctionHintProposal::~FunctionHintProposal()
{}
bool FunctionHintProposal::isFragile() const
{
return true;
}
IAssistProposalModel *FunctionHintProposal::model() const
{
return m_model;
......
......@@ -38,7 +38,6 @@ public:
FunctionHintProposal(int cursorPos, IFunctionHintProposalModel *model);
~FunctionHintProposal();
bool isFragile() const override;
IAssistProposalModel *model() const override;
IAssistProposalWidget *createWidget() const override;
......
......@@ -44,11 +44,6 @@ GenericProposal::GenericProposal(int cursorPos, const QList<AssistProposalItemIn
GenericProposal::~GenericProposal()
{}
bool GenericProposal::isFragile() const
{
return false;
}
bool GenericProposal::hasItemsToPropose(const QString &prefix, AssistReason reason) const
{
if (!prefix.isEmpty()) {
......
......@@ -40,7 +40,6 @@ public:
GenericProposal(int cursorPos, const QList<AssistProposalItemInterface *> &items);
~GenericProposal();
bool isFragile() const override;
bool hasItemsToPropose(const QString &prefix, AssistReason reason) const override;
IAssistProposalModel *model() const override;
IAssistProposalWidget *createWidget() const override;
......
......@@ -85,6 +85,11 @@ int IAssistProposal::basePosition() const
return m_basePosition;
}
bool IAssistProposal::isFragile() const
{
return m_isFragile;
}
/*!
\fn bool TextEditor::IAssistProposal::isCorrective() const
......@@ -110,6 +115,11 @@ void IAssistProposal::makeCorrection(TextEditorWidget *editorWidget)
Q_UNUSED(editorWidget);
}
void IAssistProposal::setFragile(bool fragile)
{
m_isFragile = fragile;
}
/*!
\fn IAssistModel *TextEditor::IAssistProposal::model() const
......
......@@ -42,15 +42,17 @@ public:
virtual ~IAssistProposal();
int basePosition() const;
bool isFragile() const;
virtual bool hasItemsToPropose(const QString &, AssistReason) const { return true; }
virtual bool isFragile() const = 0;
virtual bool isCorrective(TextEditorWidget *editorWidget) const;
virtual void makeCorrection(TextEditorWidget *editorWidget);
virtual IAssistProposalModel *model() const = 0;
virtual IAssistProposalWidget *createWidget() const = 0;
void setFragile(bool fragile);
protected:
int m_basePosition;
bool m_isFragile = false;
};
} // TextEditor
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