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
11 #include <ui/qt/models/url_link_delegate.h>
16 UrlLinkDelegate::UrlLinkDelegate(QObject *parent)
17 : QStyledItemDelegate(parent),
19 url_re_(new QRegExp())
22 UrlLinkDelegate::~UrlLinkDelegate()
27 void UrlLinkDelegate::setColCheck(int column, QString &pattern)
30 url_re_->setPattern(pattern);
33 void UrlLinkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
34 if (re_col_ >= 0 && url_re_) {
35 QModelIndex re_idx = index.model()->index(index.row(), re_col_);
36 QString col_text = index.model()->data(re_idx).toString();
37 if (url_re_->indexIn(col_text) < 0) {
38 QStyledItemDelegate::paint(painter, option, index);
43 QStyleOptionViewItem opt = option;
44 initStyleOption(&opt, index);
46 opt.font.setUnderline(true);
47 opt.palette.setColor(QPalette::Text, opt.palette.link().color());
49 QStyledItemDelegate::paint(painter, opt, index);
58 * indent-tabs-mode: nil
61 * ex: set shiftwidth=4 tabstop=8 expandtab:
62 * :indentSize=4:tabSize=8:noTabs=true: