forked from qt-creator/qt-creator
Clang: Fix text format for completion details
The tooltip text right to the completion list item is prepared for rich text (html) interpretation, but the QLabel the text will finally be displayed with has no explicit text format set and thus defaults to auto detection. The auto detection works fine for e.g. "<i>int optionalArg</ i>" but fails for "const Foo&". Task-number: QTCREATORBUG-15630 Change-Id: Ia58d65ee542730e4823c69150d452cdde98112f8 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
@@ -39,6 +39,11 @@
|
|||||||
namespace ClangCodeModel {
|
namespace ClangCodeModel {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
ClangAssistProposalModel::ClangAssistProposalModel()
|
||||||
|
{
|
||||||
|
setDetailTextFormat(Qt::RichText);
|
||||||
|
}
|
||||||
|
|
||||||
bool ClangAssistProposalModel::isSortable(const QString &/*prefix*/) const
|
bool ClangAssistProposalModel::isSortable(const QString &/*prefix*/) const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@@ -41,6 +41,8 @@ namespace Internal {
|
|||||||
class ClangAssistProposalModel : public TextEditor::GenericProposalModel
|
class ClangAssistProposalModel : public TextEditor::GenericProposalModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
ClangAssistProposalModel();
|
||||||
|
|
||||||
bool isSortable(const QString &prefix) const override;
|
bool isSortable(const QString &prefix) const override;
|
||||||
void sort(const QString &prefix) override;
|
void sort(const QString &prefix) override;
|
||||||
};
|
};
|
||||||
|
@@ -135,6 +135,7 @@ private:
|
|||||||
} // Anonymous
|
} // Anonymous
|
||||||
|
|
||||||
GenericProposalModel::GenericProposalModel()
|
GenericProposalModel::GenericProposalModel()
|
||||||
|
: m_detailTextFormat(Qt::AutoText)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
GenericProposalModel::~GenericProposalModel()
|
GenericProposalModel::~GenericProposalModel()
|
||||||
@@ -150,6 +151,16 @@ void GenericProposalModel::loadContent(const QList<AssistProposalItem *> &items)
|
|||||||
m_idByText.insert(m_originalItems.at(i)->text(), i);
|
m_idByText.insert(m_originalItems.at(i)->text(), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::TextFormat GenericProposalModel::detailTextFormat() const
|
||||||
|
{
|
||||||
|
return m_detailTextFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenericProposalModel::setDetailTextFormat(Qt::TextFormat detailTextFormat)
|
||||||
|
{
|
||||||
|
m_detailTextFormat = detailTextFormat;
|
||||||
|
}
|
||||||
|
|
||||||
void GenericProposalModel::reset()
|
void GenericProposalModel::reset()
|
||||||
{
|
{
|
||||||
m_currentItems = m_originalItems;
|
m_currentItems = m_originalItems;
|
||||||
|
@@ -72,12 +72,16 @@ public:
|
|||||||
void setSortingAllowed(bool isAllowed);
|
void setSortingAllowed(bool isAllowed);
|
||||||
bool isSortingAllowed() const;
|
bool isSortingAllowed() const;
|
||||||
|
|
||||||
|
Qt::TextFormat detailTextFormat() const;
|
||||||
|
void setDetailTextFormat(Qt::TextFormat detailTextFormat);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<AssistProposalItem *> m_currentItems;
|
QList<AssistProposalItem *> m_currentItems;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QString, int> m_idByText;
|
QHash<QString, int> m_idByText;
|
||||||
QList<AssistProposalItem *> m_originalItems;
|
QList<AssistProposalItem *> m_originalItems;
|
||||||
|
Qt::TextFormat m_detailTextFormat;
|
||||||
};
|
};
|
||||||
} // TextEditor
|
} // TextEditor
|
||||||
|
|
||||||
|
@@ -168,6 +168,11 @@ public:
|
|||||||
m_label->setText(text);
|
m_label->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setTextFormat(Qt::TextFormat textFormat)
|
||||||
|
{
|
||||||
|
m_label->setTextFormat(textFormat);
|
||||||
|
}
|
||||||
|
|
||||||
// Workaround QTCREATORBUG-11653
|
// Workaround QTCREATORBUG-11653
|
||||||
void calculateMaximumWidth()
|
void calculateMaximumWidth()
|
||||||
{
|
{
|
||||||
@@ -312,6 +317,7 @@ void GenericProposalWidgetPrivate::maybeShowInfoTip()
|
|||||||
|
|
||||||
m_infoFrame->move(m_completionListView->infoFramePos());
|
m_infoFrame->move(m_completionListView->infoFramePos());
|
||||||
m_infoFrame->setText(infoTip);
|
m_infoFrame->setText(infoTip);
|
||||||
|
m_infoFrame->setTextFormat(m_model->detailTextFormat());
|
||||||
m_infoFrame->calculateMaximumWidth();
|
m_infoFrame->calculateMaximumWidth();
|
||||||
m_infoFrame->adjustSize();
|
m_infoFrame->adjustSize();
|
||||||
m_infoFrame->show();
|
m_infoFrame->show();
|
||||||
|
Reference in New Issue
Block a user