34 lines
1.7 KiB
C++
34 lines
1.7 KiB
C++
/* Строка участника: аватар, имя и три действия — звук рации, вызов рации, обычный звонок.
|
|
* Вызывает signals только после клика без перетаскивания; вызовы доступны online-пирам. */
|
|
#pragma once
|
|
|
|
#include <QStyledItemDelegate>
|
|
#include <QPersistentModelIndex>
|
|
|
|
class AccountDelegate : public QStyledItemDelegate {
|
|
Q_OBJECT
|
|
public:
|
|
explicit AccountDelegate(QObject *parent = nullptr);
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|
const QModelIndex &index) const override;
|
|
QSize sizeHint(const QStyleOptionViewItem &option,
|
|
const QModelIndex &index) const override;
|
|
bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option,
|
|
const QModelIndex& index) override;
|
|
bool helpEvent(QHelpEvent* event, QAbstractItemView* view, const QStyleOptionViewItem& option,
|
|
const QModelIndex& index) override;
|
|
signals:
|
|
void radioCallRequested(const QModelIndex& index);
|
|
void callRequested(const QModelIndex& index);
|
|
void avatarRequested(const QModelIndex& index);
|
|
void radioMuteRequested(const QModelIndex& index);
|
|
private:
|
|
enum class Action { None, Avatar, RadioMute, RadioCall, Call };
|
|
static QRect actionRect(const QRect& row, Action action);
|
|
static Action actionAt(const QPoint& position, const QRect& row, bool self);
|
|
QPersistentModelIndex m_pressedIndex; /* строка, на которой начался клик */
|
|
QPoint m_pressedPosition;
|
|
Action m_pressedAction = Action::None;
|
|
};
|