refactor: STCP connections as ETCP links (is_tcp)
- Add is_tcp, tcp_link, tcp_reconnect_* fields to ETCP_LINK - Remove transport_link from ETCP_CONN, add tcp_link_count - stcp_link: replace embedded etcp_conn with pointer; add etcp_link backpointer - stcp_link: link_rx_cb routes ETCP data to etcp_conn_input - stcp_link: call on_close_cb in close - New TCP functions: etcp_link_enter_ready_tcp, etcp_tcp_link_start_connect, etcp_tcp_link_start_reconnect, tcp_link_close_cb, etcp_tcp_send - etcp_link_new: handle NULL conn for TCP links; skip enter_init for TCP - etcp_link_close: close stcp_link for TCP - etcp_encrypt_send: redirect TCP to etcp_tcp_send (skips AES-CCM) - tcp_server_on_link: create ETCP_LINK(is_tcp=1) + enter_ready_tcp - etcp_connect: TCP addrs -> etcp_tcp_link_start_connect - Remove ctx->tcp_link/tcp_ready - test_stcp_traffic: find stcp_link via links->is_tcp instead of transport_link - 66/68 tests pass; 2 STCP tests expected to fail (integration not complete)
This commit is contained in:
1 parent
937af4c26a
commit
d773f1724a
1705 files changed
+187
-1082154
No files matched your search
@@ -1,63 +0,0 @@
|
||||
#include "accountdelegate.h"
|
||||
#include "memberlistmodel.h"
|
||||
#include <QPainter>
|
||||
#include <QFont>
|
||||
|
||||
AccountDelegate::AccountDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent) {}
|
||||
|
||||
void AccountDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const {
|
||||
painter->save();
|
||||
|
||||
if (option.state & QStyle::State_Selected)
|
||||
painter->fillRect(option.rect, option.palette.highlight());
|
||||
else if (option.state & QStyle::State_MouseOver)
|
||||
painter->fillRect(option.rect, option.palette.light());
|
||||
else
|
||||
painter->fillRect(option.rect, option.palette.alternateBase());
|
||||
|
||||
const int margin = 4;
|
||||
const int iconSz = 24;
|
||||
|
||||
QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
|
||||
if (!icon.isNull())
|
||||
icon.paint(painter, option.rect.left() + margin, option.rect.top() + (option.rect.height() - iconSz) / 2, iconSz, iconSz);
|
||||
|
||||
const int x = option.rect.left() + iconSz + margin * 3;
|
||||
const int w = option.rect.right() - x - margin;
|
||||
const int yMid = option.rect.top() + option.rect.height() / 2;
|
||||
|
||||
QFont nameFont = painter->font();
|
||||
nameFont.setBold(true);
|
||||
nameFont.setPixelSize(13);
|
||||
painter->setFont(nameFont);
|
||||
|
||||
QColor textColor = option.palette.color(QPalette::Text);
|
||||
if (option.state & QStyle::State_Selected) textColor = option.palette.color(QPalette::HighlightedText);
|
||||
if (index.data(Qt::UserRole + 2).toBool()) textColor = QColor("#4CAF50");
|
||||
painter->setPen(textColor);
|
||||
|
||||
QString name = index.data(Qt::DisplayRole).toString();
|
||||
painter->drawText(QRect(x, option.rect.top() + 2, w, yMid - option.rect.top() - 2),
|
||||
Qt::AlignLeft | Qt::AlignBottom, name);
|
||||
|
||||
QFont subFont = painter->font();
|
||||
subFont.setBold(false);
|
||||
subFont.setPixelSize(10);
|
||||
painter->setFont(subFont);
|
||||
painter->setPen(QColor(130, 130, 130));
|
||||
|
||||
QString sub = index.data(Qt::UserRole + 1).toString();
|
||||
if (!sub.isEmpty())
|
||||
painter->drawText(QRect(x, yMid + 2, w, option.rect.bottom() - yMid - 2),
|
||||
Qt::AlignLeft | Qt::AlignTop, sub);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QSize AccountDelegate::sizeHint(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const {
|
||||
(void)option; (void)index;
|
||||
return QSize(160, 36);
|
||||
}
|
||||
Reference in new issue
Block a user