LogView changes - registerCategory() now take two QBrush: text and background. If NoBrush the no changes in colors
This commit is contained in:
@@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.0)
|
|||||||
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||||
project(qad)
|
project(qad)
|
||||||
set(qad_MAJOR 1)
|
set(qad_MAJOR 1)
|
||||||
set(qad_MINOR 14)
|
set(qad_MINOR 15)
|
||||||
set(qad_REVISION 4)
|
set(qad_REVISION 0)
|
||||||
set(qad_SUFFIX )
|
set(qad_SUFFIX )
|
||||||
set(qad_COMPANY SHS)
|
set(qad_COMPANY SHS)
|
||||||
set(qad_DOMAIN org.SHS)
|
set(qad_DOMAIN org.SHS)
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ int LogView::linesLimit() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LogView::registerCategory(const QString & label, QString keyword, const QImage & icon, QColor color, bool bold) {
|
void LogView::registerCategory(const QString & label, QString keyword, const QImage & icon, QBrush text_brush, QBrush background, bool bold) {
|
||||||
QRegularExpression regexp(keyword,
|
QRegularExpression regexp(keyword,
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||||
QRegularExpression::PatternOptions(QRegularExpression::CaseInsensitiveOption)
|
QRegularExpression::PatternOptions(QRegularExpression::CaseInsensitiveOption)
|
||||||
@@ -105,18 +105,19 @@ void LogView::registerCategory(const QString & label, QString keyword, const QIm
|
|||||||
Qt::CaseInsensitive
|
Qt::CaseInsensitive
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
registerCategory(label, regexp, icon, color, bold);
|
registerCategory(label, regexp, icon, text_brush, background, bold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LogView::registerCategory(const QString & label, QRegularExpression regexp, const QImage & icon, QColor color, bool bold) {
|
void LogView::registerCategory(const QString & label, QRegularExpression regexp, const QImage & icon, QBrush text_brush, QBrush background, bool bold) {
|
||||||
if (!regexp.isValid() || regexp.pattern().isEmpty()) return;
|
if (!regexp.isValid() || regexp.pattern().isEmpty()) return;
|
||||||
removeCategory(regexp);
|
removeCategory(regexp);
|
||||||
Category c;
|
Category c;
|
||||||
c.regexp = regexp;
|
c.regexp = regexp;
|
||||||
c.label = label;
|
c.label = label;
|
||||||
c.image = icon;
|
c.image = icon;
|
||||||
c.color = color;
|
c.text_brush = text_brush;
|
||||||
|
c.background = background;
|
||||||
c.bold = bold;
|
c.bold = bold;
|
||||||
c.makeIcon(iconImageSize(), preferredIconSize(1., this));
|
c.makeIcon(iconImageSize(), preferredIconSize(1., this));
|
||||||
categories.append(c);
|
categories.append(c);
|
||||||
@@ -223,7 +224,10 @@ void LogView::newLine(const QString & keyword) {
|
|||||||
if (matched) {
|
if (matched) {
|
||||||
QTextCharFormat cf = def_cf;
|
QTextCharFormat cf = def_cf;
|
||||||
QTextBlockFormat bf = def_bf;
|
QTextBlockFormat bf = def_bf;
|
||||||
bf.setBackground(c.color);
|
if (c.text_brush != Qt::NoBrush)
|
||||||
|
cf.setForeground(c.text_brush);
|
||||||
|
if (c.background != Qt::NoBrush)
|
||||||
|
bf.setBackground(c.background);
|
||||||
if (c.bold)
|
if (c.bold)
|
||||||
cf.setFontWeight(QFont::Bold);
|
cf.setFontWeight(QFont::Bold);
|
||||||
tc.setCharFormat(cf);
|
tc.setCharFormat(cf);
|
||||||
@@ -246,8 +250,8 @@ void LogView::newLine(const QString & keyword) {
|
|||||||
if (isFilterVisible())
|
if (isFilterVisible())
|
||||||
filterBlock(tc.block(), fs, regexp);
|
filterBlock(tc.block(), fs, regexp);
|
||||||
tc.movePosition(QTextCursor::End);
|
tc.movePosition(QTextCursor::End);
|
||||||
tc.insertBlock();
|
|
||||||
tc.setCharFormat(def_cf);
|
tc.setCharFormat(def_cf);
|
||||||
|
tc.insertBlock();
|
||||||
tc.setBlockFormat(def_bf);
|
tc.setBlockFormat(def_bf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,13 +60,15 @@ public:
|
|||||||
void registerCategory(const QString & label,
|
void registerCategory(const QString & label,
|
||||||
QString keyword = QString(),
|
QString keyword = QString(),
|
||||||
const QImage & icon = QImage(),
|
const QImage & icon = QImage(),
|
||||||
QColor color = QColor(),
|
QBrush text_brush = Qt::NoBrush,
|
||||||
|
QBrush background = Qt::NoBrush,
|
||||||
bool bold = false);
|
bool bold = false);
|
||||||
|
|
||||||
void registerCategory(const QString & label,
|
void registerCategory(const QString & label,
|
||||||
QRegularExpression regexp,
|
QRegularExpression regexp,
|
||||||
const QImage & icon = QImage(),
|
const QImage & icon = QImage(),
|
||||||
QColor color = QColor(),
|
QBrush text_brush = Qt::NoBrush,
|
||||||
|
QBrush background = Qt::NoBrush,
|
||||||
bool bold = false);
|
bool bold = false);
|
||||||
void removeCategory(QString keyword);
|
void removeCategory(QString keyword);
|
||||||
void removeCategory(QRegularExpression regexp);
|
void removeCategory(QRegularExpression regexp);
|
||||||
@@ -83,7 +85,8 @@ private:
|
|||||||
QRegularExpression regexp;
|
QRegularExpression regexp;
|
||||||
QImage image, icon_image;
|
QImage image, icon_image;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
QColor color;
|
QBrush text_brush;
|
||||||
|
QBrush background;
|
||||||
bool bold;
|
bool bold;
|
||||||
inline bool operator ==(const Category & it) const {return (regexp.pattern() == it.regexp.pattern());}
|
inline bool operator ==(const Category & it) const {return (regexp.pattern() == it.regexp.pattern());}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user