- u_async.c: process immediate_queue BEFORE epoll_wait in uasync_poll - stcp_link.c: defensive NULL etcp_conn/etcp_link in stcp_link_close - utun_instance.c: move stcp_server_list_destroy_all to Phase J (before ETCP), add deferred drain in both Phase J and L - stcp.h/c: STCP_HS_ENC_CLIENT 6→38, STCP_HS_ENC_SERVER 7→39, exchange ed25519_pubkey in both handshake directions - etcp_connections.c: copy peer_ed25519 from STCP to ETCP_CONN in etcp_link_enter_ready_tcp; guard link->etcp in tcp_link_close_cb - chat_sync.c: fix lk->conn NULL dereference for TCP links - test_stcp.c: update stcp_server_create/stcp_client_connect callsites - tools/chat_tcp_test: change transport udp→tcp
59 lines
1.7 KiB
C++
59 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <QListView>
|
|
#include <QPersistentModelIndex>
|
|
#include <QPoint>
|
|
#include <QPushButton>
|
|
|
|
struct ChatTextSelection {
|
|
QPersistentModelIndex index;
|
|
QPoint clickPos;
|
|
QPoint dragPos;
|
|
int startChar = -1;
|
|
int endChar = -1;
|
|
bool active = false;
|
|
};
|
|
|
|
class ChatView : public QListView {
|
|
Q_OBJECT
|
|
public:
|
|
explicit ChatView(QWidget *parent = nullptr);
|
|
|
|
void setBackgroundImage(const QString &path);
|
|
|
|
bool hasSelection() const { return m_selStart.isValid(); }
|
|
QModelIndex selStart() const { return QModelIndex(m_selStart); }
|
|
QModelIndex selEnd() const { return QModelIndex(m_selEnd); }
|
|
bool isSelecting() const { return m_selecting; }
|
|
const ChatTextSelection &textSelection() const { return m_textSel; }
|
|
|
|
bool isRowSelected(const QModelIndex &idx) const;
|
|
void setTextSelChars(int start, int end) { m_textSel.startChar = start; m_textSel.endChar = end; }
|
|
|
|
signals:
|
|
void hoveredIndexChanged(const QModelIndex &idx);
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
void scrollContentsBy(int dx, int dy) override;
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
void keyPressEvent(QKeyEvent *event) override;
|
|
|
|
private:
|
|
void copySelection();
|
|
void updateScrollDownBtn();
|
|
|
|
QPixmap m_background;
|
|
QPersistentModelIndex m_selStart;
|
|
QPersistentModelIndex m_selEnd;
|
|
ChatTextSelection m_textSel;
|
|
QPersistentModelIndex m_lastHovered;
|
|
QPersistentModelIndex m_pressIndex;
|
|
QPoint m_pressPos;
|
|
bool m_selecting = false;
|
|
QPushButton *m_scrollDownBtn = nullptr;
|
|
};
|