Commit 77ac9d5f authored by Leandro Melo's avatar Leandro Melo
Browse files

Added a "central" method to check for item datas customizations.

parent 06fc31d4
......@@ -308,18 +308,25 @@ void Highlighter::applyFormat(int offset,
QTextCharFormat format = m_genericFormats.value(itemData->style());
// Apply personalizations (if specified) for this particular item data from the current
// definition only.
if (itemData->color().isValid())
format.setForeground(itemData->color());
if (itemData->isItalicSpecified())
format.setFontItalic(itemData->isItalic());
if (itemData->isBoldSpecified())
format.setFontWeight(toFontWeight(itemData->isBold()));
if (itemData->isUnderlinedSpecified())
format.setFontUnderline(itemData->isUnderlined());
if (itemData->isStrikedOutSpecified())
format.setFontStrikeOut(itemData->isStrikedOut());
if (itemData->isCustomized()) {
// Please notice that the following are applied every time for item datas which have
// customizations. The configureFormats method could be used to provide a "one time"
// configuration, but it would probably require to traverse all item datas from all
// definitions available/loaded (either to set the values or for some "notifying"
// strategy). This is because the highlighter does not really know on which definition(s)
// it is working. Since not many item datas specify customizations I think this approach
// would fit better. If there are other ideas...
if (itemData->color().isValid())
format.setForeground(itemData->color());
if (itemData->isItalicSpecified())
format.setFontItalic(itemData->isItalic());
if (itemData->isBoldSpecified())
format.setFontWeight(toFontWeight(itemData->isBold()));
if (itemData->isUnderlinedSpecified())
format.setFontUnderline(itemData->isUnderlined());
if (itemData->isStrikedOutSpecified())
format.setFontStrikeOut(itemData->isStrikedOut());
}
setFormat(offset, count, format);
}
......@@ -424,7 +431,7 @@ void Highlighter::setCurrentContext()
{
if (m_contexts.isEmpty()) {
// This is not supposed to happen. However, there might be broken files (for example, the
// PHP definition) which will cause this behaviour. In such cases just pushing the default
// php.xml) which will cause this behaviour. In such cases just pushing the default
// context is enough to keep highlighter working.
m_contexts.push_back(m_defaultContext);
}
......
......@@ -52,7 +52,8 @@ ItemData::ItemData() :
m_italicSpecified(false),
m_boldSpecified(false),
m_underlinedSpecified(false),
m_strikedOutSpecified(false)
m_strikedOutSpecified(false),
m_isCustomized(false)
{}
void ItemData::setStyle(const QString &style)
......@@ -62,13 +63,23 @@ const QString &ItemData::style() const
{ return m_style; }
void ItemData::setColor(const QString &color)
{ m_color.setNamedColor(color); }
{
if (!color.isEmpty()) {
m_color.setNamedColor(color);
m_isCustomized = true;
}
}
const QColor &ItemData::color() const
{ return m_color; }
void ItemData::setSelectionColor(const QString &color)
{ m_selectionColor.setNamedColor(color); }
{
if (!color.isEmpty()) {
m_selectionColor.setNamedColor(color);
m_isCustomized = true;
}
}
const QColor &ItemData::selectionColor() const
{ return m_selectionColor; }
......@@ -78,6 +89,7 @@ void ItemData::setItalic(const QString &italic)
if (!italic.isEmpty()) {
m_italic = toBool(italic);
m_italicSpecified = true;
m_isCustomized = true;
}
}
......@@ -92,6 +104,7 @@ void ItemData::setBold(const QString &bold)
if (!bold.isEmpty()) {
m_bold = toBool(bold);
m_boldSpecified = true;
m_isCustomized = true;
}
}
......@@ -106,6 +119,7 @@ void ItemData::setUnderlined(const QString &underlined)
if (!underlined.isEmpty()) {
m_underlined = toBool(underlined);
m_underlinedSpecified = true;
m_isCustomized = true;
}
}
......@@ -120,6 +134,7 @@ void ItemData::setStrikedOut(const QString &striked)
if (!striked.isEmpty()) {
m_strikedOut = toBool(striked);
m_strikedOutSpecified = true;
m_isCustomized = true;
}
}
......@@ -128,3 +143,6 @@ bool ItemData::isStrikedOut() const
bool ItemData::isStrikedOutSpecified() const
{ return m_strikedOutSpecified; }
bool ItemData::isCustomized() const
{ return m_isCustomized; }
......@@ -69,6 +69,8 @@ public:
bool isStrikedOut() const;
bool isStrikedOutSpecified() const;
bool isCustomized() const;
static const QLatin1String kDsNormal;
static const QLatin1String kDsKeyword;
static const QLatin1String kDsDataType;
......@@ -96,6 +98,7 @@ private:
bool m_underlinedSpecified;
bool m_strikedOut;
bool m_strikedOutSpecified;
bool m_isCustomized;
};
} // namespace Internal
......
Supports Markdown
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