Kerberos: add kerberos_inject_longterm_key() helper function
[wireshark-sm.git] / ui / qt / models / url_link_delegate.cpp
bloba2c32bef94f826a0f0689d4568eab9335142638d
1 /* url_link_delegate.cpp
2 * Delegates for displaying links as links, including elide model
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
11 #include <ui/qt/models/url_link_delegate.h>
13 #include <QPainter>
15 #include <ui/qt/utils/color_utils.h>
17 UrlLinkDelegate::UrlLinkDelegate(QObject *parent)
18 : QStyledItemDelegate(parent),
19 re_col_(-1),
20 url_re_(new QRegularExpression())
23 UrlLinkDelegate::~UrlLinkDelegate()
25 delete url_re_;
28 void UrlLinkDelegate::setColCheck(int column, QString &pattern)
30 re_col_ = column;
31 url_re_->setPattern(pattern);
34 void UrlLinkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
35 if (re_col_ >= 0 && url_re_) {
36 QModelIndex re_idx = index.model()->index(index.row(), re_col_);
37 QString col_text = index.model()->data(re_idx).toString();
38 if (!url_re_->match(col_text).hasMatch()) {
39 QStyledItemDelegate::paint(painter, option, index);
40 return;
44 QStyleOptionViewItem opt = option;
45 initStyleOption(&opt, index);
47 opt.font.setUnderline(true);
48 opt.palette.setColor(QPalette::Text, ColorUtils::themeLinkBrush().color());
50 QStyledItemDelegate::paint(painter, opt, index);