removed groupsChanged and used rsEvents::FRIEND_LIST instead

This commit is contained in:
csoler 2025-06-12 21:12:47 +02:00
parent df02d745d8
commit 0ce2dd8486
19 changed files with 106 additions and 23 deletions

View file

@ -24,6 +24,7 @@
#include "GroupSelectionBox.h"
#include "GroupDefs.h"
#include "gui/notifyqt.h"
#include "util/qtthreadsutils.h"
#include <algorithm>
@ -34,11 +35,40 @@ GroupSelectionBox::GroupSelectionBox(QWidget *parent)
{
setSelectionMode(QAbstractItemView::SingleSelection);
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(fillGroups()));
//connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(fillGroups()));
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e)
{
RsQThreadUtils::postToObject([=]()
{
auto fe = dynamic_cast<const RsFriendListEvent*>(e.get());
if(!fe)
return;
switch(fe->mEventCode)
{
case RsFriendListEventCode::GROUP_ADDED:
case RsFriendListEventCode::GROUP_REMOVED:
case RsFriendListEventCode::GROUP_CHANGED: fillGroups();
default:
break;
}
}
, this );
}, mEventHandlerId, RsEventType::FRIEND_LIST );
// Fill with available groups
fillGroups();
}
GroupSelectionBox::~GroupSelectionBox()
{
rsEvents->unregisterEventsHandler(mEventHandlerId);
}
void GroupSelectionBox::fillGroups()
{
std::list<RsNodeGroupId> selectedIds;