aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/models/url_link_delegate.h
blob: c35a611d18cc611ad6fa1744f1e10692ca34de2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* url_link_delegate.h
 * Delegates for displaying links as links, including elide model
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0+
 */

#ifndef URL_LINK_DELEGATE_H
#define URL_LINK_DELEGATE_H

#include <QStyledItemDelegate>
#include <QStyleOptionViewItem>
#include <QModelIndex>

class QRegExp;

class UrlLinkDelegate : public QStyledItemDelegate
{
    Q_OBJECT

public:
    explicit UrlLinkDelegate(QObject *parent = Q_NULLPTR);
    ~UrlLinkDelegate();
    // If pattern matches the string in column, render as a URL.
    // Otherwise render as plain text.
    void setColCheck(int column, QString &pattern);

protected:
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;

private:
    int re_col_;
    QRegExp *url_re_;
};
#endif // URL_LINK_DELEGATE_H

/*
 * Editor modelines
 *
 * Local Variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * ex: set shiftwidth=4 tabstop=8 expandtab:
 */