![Roland Knall](/assets/img/avatar_default.png)
Rewrite of the about dialog, to use QTableView and Models instead of HTML files. Everything is now model based, and the model is generic enough to support any variation which can be put into a QStringList row. Change-Id: Ie32bf66b2fe2a7754c0bf07205a7b068d46b0070 Reviewed-on: https://code.wireshark.org/review/24534 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
/* html_text_delegate.cpp
|
|
* 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+
|
|
*/
|
|
|
|
#include <ui/qt/models/html_text_delegate.h>
|
|
|
|
#include <QComboBox>
|
|
#include <QEvent>
|
|
#include <QLineEdit>
|
|
#include <QPainter>
|
|
#include <QTextDocument>
|
|
#include <QRect>
|
|
#include <QStyledItemDelegate>
|
|
#include <QStyleOptionViewItem>
|
|
#include <QString>
|
|
|
|
HTMLTextDelegate::HTMLTextDelegate(QObject *parent)
|
|
: QStyledItemDelegate(parent)
|
|
{}
|
|
|
|
void HTMLTextDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
|
QStyleOptionViewItem options = option;
|
|
initStyleOption(&options, index);
|
|
|
|
painter->save();
|
|
|
|
QTextDocument doc;
|
|
doc.setHtml(options.text);
|
|
|
|
options.text = QStringLiteral("");
|
|
options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &option, painter);
|
|
|
|
painter->translate(options.rect.left(), options.rect.top());
|
|
QRect clip(0, 0, options.rect.width(), options.rect.height());
|
|
doc.drawContents(painter, clip);
|
|
|
|
painter->restore();
|
|
}
|
|
|
|
QSize HTMLTextDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
|
QStyleOptionViewItem options = option;
|
|
initStyleOption(&options, index);
|
|
|
|
QTextDocument doc;
|
|
doc.setHtml(options.text);
|
|
doc.setTextWidth(options.rect.width());
|
|
return QSize(doc.idealWidth(), doc.size().height());
|
|
}
|
|
|
|
/* * Editor modelines
|
|
*
|
|
* Local Variables:
|
|
* c-basic-offset: 4
|
|
* tab-width: 8
|
|
* indent-tabs-mode: nil
|
|
* End:
|
|
*
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
*/
|