2021-11-30 13:01:36 +00:00
|
|
|
/** @file
|
|
|
|
*
|
2017-11-22 15:54:32 +00:00
|
|
|
* Delegates for displaying links as links, including elide model
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-07 11:26:45 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2017-11-22 15:54:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef URL_LINK_DELEGATE_H
|
|
|
|
#define URL_LINK_DELEGATE_H
|
|
|
|
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
#include <QStyleOptionViewItem>
|
|
|
|
#include <QModelIndex>
|
2021-11-25 11:20:25 +00:00
|
|
|
#include <QRegularExpression>
|
2017-11-22 15:54:32 +00:00
|
|
|
|
|
|
|
class UrlLinkDelegate : public QStyledItemDelegate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit UrlLinkDelegate(QObject *parent = Q_NULLPTR);
|
2018-01-31 20:03:49 +00:00
|
|
|
~UrlLinkDelegate();
|
|
|
|
// If pattern matches the string in column, render as a URL.
|
|
|
|
// Otherwise render as plain text.
|
|
|
|
void setColCheck(int column, QString &pattern);
|
2017-11-22 15:54:32 +00:00
|
|
|
|
|
|
|
protected:
|
2019-05-29 14:06:38 +00:00
|
|
|
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
2018-01-31 20:03:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int re_col_;
|
2021-11-25 11:20:25 +00:00
|
|
|
QRegularExpression *url_re_;
|
2017-11-22 15:54:32 +00:00
|
|
|
};
|
|
|
|
#endif // URL_LINK_DELEGATE_H
|