Include model roles and row actions required by subgroup details
This commit is contained in:
1 parent
49b7ac9099
commit
780e7220c3
3 files changed
+11
-2
No files matched your search
@@ -203,10 +203,11 @@ bool AccountDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, cons
|
||||
const bool header = index.data(GroupedMemberModel::GroupHeaderRole).toBool();
|
||||
const bool self = index.data(Qt::UserRole + 2).toBool(), online = index.data(MemberListModel::OnlineRole).toBool();
|
||||
Action action = actionAt(mouse->pos(), option.rect, header ? index.data(GroupedMemberModel::CallAvailableRole).toBool() : !self);
|
||||
if (header && action == Action::None) action = Action::ToggleGroup;
|
||||
if (header && action == Action::None && mouse->pos().x() < option.rect.left() + GroupedMemberModel::DisclosureWidth)
|
||||
action = Action::ToggleGroup;
|
||||
const bool isCall = action == Action::Call || action == Action::RadioCall;
|
||||
const bool enabled = action == Action::Avatar || action == Action::ToggleGroup ||
|
||||
(isCall ? index.data(GroupedMemberModel::CallAvailableRole).toBool() : !self && (!header || online));
|
||||
(isCall ? (header ? index.data(GroupedMemberModel::CallAvailableRole).toBool() : !self && online) : !self && (!header || online));
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
m_pressedIndex = action != Action::None && enabled ? index : QModelIndex();
|
||||
m_pressedNodeId = index.data(GroupedMemberModel::ActionNodeIdRole).toULongLong();
|
||||
|
||||
@@ -72,6 +72,9 @@ QVariant MemberListModel::data(const QModelIndex& index, int role) const {
|
||||
if (role == Qt::UserRole + 4) return bool(item.snapshot.storage);
|
||||
if (role == RadioSpeakingRole) return item.snapshot.is_self ? m_selfTransmitting : m_radioTalkers.contains(item.snapshot.node_id);
|
||||
if (role == OnlineRole) return item.snapshot.online;
|
||||
if (role == NodeIdRole || role == AvatarNodeIdRole) return QVariant::fromValue(quint64(item.snapshot.node_id));
|
||||
if (role == DevgroupRole) return item.snapshot.devgroup_name[0] ?
|
||||
QString::fromLatin1(QByteArray(reinterpret_cast<const char*>(item.snapshot.devgroup), 32).toHex()) : QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -400,6 +403,8 @@ QVariant GroupedMemberModel::data(const QModelIndex& idx, int role) const {
|
||||
if (role == GroupExpandedRole) return m_expanded.contains(group);
|
||||
if (role == Qt::DisplayRole) return QString::fromUtf8(member->devgroup_name);
|
||||
if (role == Qt::DecorationRole) return m_source->data(m_source->index(avatar), role);
|
||||
if (role == MemberListModel::AvatarNodeIdRole || role == MemberListModel::DevgroupRole)
|
||||
return m_source->data(m_source->index(avatar), role);
|
||||
if (role == MemberListModel::OnlineRole) return target >= 0;
|
||||
if (role == Qt::UserRole + 3) {
|
||||
const int shared = CHAT_MEMBER_FLAG_RADIO | CHAT_MEMBER_FLAG_PHONE_KNOWN | CHAT_MEMBER_FLAG_PHONE_BUSY;
|
||||
|
||||
@@ -31,6 +31,9 @@ public:
|
||||
static constexpr int kAvatarSize = kRowHeight - 2;
|
||||
static constexpr int RadioSpeakingRole = Qt::UserRole + 5;
|
||||
static constexpr int OnlineRole = Qt::UserRole + 6; /* живой статус BGP для кнопок вызова */
|
||||
static constexpr int NodeIdRole = Qt::UserRole + 9; // цель действий для обычной строки и её proxy
|
||||
static constexpr int DevgroupRole = Qt::UserRole + 12; // ключ devgroup в hex, пусто без группы
|
||||
static constexpr int AvatarNodeIdRole = Qt::UserRole + 13; // владелец показываемого аватара
|
||||
|
||||
explicit MemberListModel(QObject* parent = nullptr); // parent владеет; собственный timer опрашивает RTT каждые 2 с
|
||||
|
||||
|
||||
Reference in new issue
Block a user