| 3683 | } |
| 3684 | |
| 3685 | void AddFilterSelections(QTextCursor cursor, int &idx, QColor backCol, QColor foreCol, |
| 3686 | QVector<FilterExpression> &exprs, QList<QTextEdit::ExtraSelection> &sels) |
| 3687 | { |
| 3688 | QTextEdit::ExtraSelection sel; |
| 3689 | |
| 3690 | sel.cursor = cursor; |
| 3691 | |
| 3692 | bool hasMust = false; |
| 3693 | for(const FilterExpression &f : exprs) |
| 3694 | hasMust |= (f.matchType == MatchType::MustMatch); |
| 3695 | |
| 3696 | for(FilterExpression &f : exprs) |
| 3697 | { |
| 3698 | bool ignored = false; |
| 3699 | if(hasMust && f.matchType == MatchType::Normal) |
| 3700 | ignored = true; |
| 3701 | |
| 3702 | // we use 6 colours around the wheel to get reasonable distinction. Note that this is not |
| 3703 | // critical information and selecting each entry will underline it in the phrase, since we want |
| 3704 | // to be colour blind friendly where possible. |
| 3705 | // we avoid the 60 degrees near red (which is at 0) to avoid confusion with errors. |
| 3706 | QColor col = QColor::fromHslF((float(idx) / 6.0f) * (300.0f / 360.0f) + (0.5f / 6.0f), |
| 3707 | ignored ? 0.0f : 1.0f, |
| 3708 | qBound(0.05, 0.2 * 0.5 + 0.8 * backCol.lightnessF(), 0.95)); |
| 3709 | |
| 3710 | idx = (idx + 1) % 6; |
| 3711 | |
| 3712 | f.col = col; |
| 3713 | |
| 3714 | sel.cursor.setPosition(f.position, QTextCursor::MoveAnchor); |
| 3715 | sel.cursor.setPosition(f.position + f.length, QTextCursor::KeepAnchor); |
| 3716 | sel.format.setBackground(QBrush(col)); |
| 3717 | sel.format.setForeground(QBrush(contrastingColor(col, foreCol))); |
| 3718 | sel.format.setFontStrikeOut(ignored); |
| 3719 | |
| 3720 | sels.push_back(sel); |
| 3721 | |
| 3722 | if(!ignored) |
| 3723 | AddFilterSelections(cursor, idx, backCol, foreCol, f.exprs, sels); |
| 3724 | } |
| 3725 | } |
| 3726 | |
| 3727 | ParseErrorTipLabel::ParseErrorTipLabel(QWidget *widget) : QLabel(NULL), m_Widget(widget) |
| 3728 | { |
no test coverage detected