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

@ -390,6 +390,8 @@ MainWindow::~MainWindow()
Settings->setValueToGroup("MainWindow", "SplitterState", ui->splitter->saveState());
Settings->setValueToGroup("MainWindow", "State", saveState());
rsEvents->unregisterEventsHandler(mEventHandlerId);
delete statusComboBox;
delete peerstatus;
delete natstatus;

View file

@ -38,6 +38,7 @@
#include "gui/notifyqt.h"
#include "util/QtVersion.h"
#include "util/misc.h"
#include "util/qtthreadsutils.h"
#include "gui/common/FilesDefs.h"
/* Images for context menu icons */
@ -73,7 +74,23 @@ ShareManager::ShareManager()
connect(ui.shareddirList, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(doubleClickedCell(int,int)));
connect(ui.shareddirList, SIGNAL(cellChanged(int,int)), this, SLOT(handleCellChange(int,int)));
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(reload()));
// connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(reload()));
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e)
{
RsQThreadUtils::postToObject([=]()
{
auto fe = dynamic_cast<const RsFriendListEvent*>(e.get());
if(!fe)
return;
reload();
}
, this );
}, mEventHandlerId, RsEventType::FRIEND_LIST );
QHeaderView* header = ui.shareddirList->horizontalHeader();
QHeaderView_setSectionResizeModeColumn(header, COLUMN_PATH, QHeaderView::Stretch);
@ -152,6 +169,7 @@ ShareManager::~ShareManager()
{
_instance = NULL;
rsEvents->unregisterEventsHandler(mEventHandlerId);
Settings->saveWidgetInformation(this);
}

View file

@ -77,6 +77,7 @@ private:
Ui::ShareManager ui;
std::vector<SharedDirInfo> mDirInfos ;
RsEventsHandlerId_t mEventHandlerId;
};
#endif

View file

@ -101,8 +101,8 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
connect(ui->friendList, SIGNAL(itemSelectionChanged()), this, SIGNAL(itemSelectionChanged()));
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged(int)));
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int)));
//connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged(int)));
//connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int)));
mCompareRole = new RSTreeWidgetItemCompareRole;
mActionSortByState = new QAction(tr("Sort by state"), this);
@ -159,7 +159,21 @@ void FriendSelectionWidget::handleEvent_main_thread(std::shared_ptr<const RsEven
updateDisplay(true);
update(); // Qt flush
break;
default: break ;
case RsFriendListEventCode::GROUP_ADDED:
case RsFriendListEventCode::GROUP_REMOVED:
case RsFriendListEventCode::GROUP_CHANGED:
groupsChanged();
break;
case RsFriendListEventCode::NODE_STATUS_CHANGED:
{
StatusInfo i;
rsStatus->getStatus(fp->mSslId,i);
peerStatusChanged(fp->mSslId,i.status);
}
default:
break ;
}
}
@ -770,21 +784,18 @@ template<> inline void FriendSelectionWidget::setSelectedIds<RsGxsId,FriendSelec
loadIdentities();
}
void FriendSelectionWidget::groupsChanged(int /*type*/)
void FriendSelectionWidget::groupsChanged()
{
if (mShowTypes & SHOW_GROUP) {
fillList();
}
}
void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
void FriendSelectionWidget::peerStatusChanged(const RsPeerId& peerid, int status)
{
if(!isVisible())
return ;
if(RsAutoUpdatePage::eventsLocked())
return ;
RsPeerId peerid(peerId.toStdString()) ;
QString gpgId;
int gpgStatus = RS_STATUS_OFFLINE;
@ -850,7 +861,8 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
break;
case IDTYPE_SSL:
{
if (item->data(COLUMN_DATA, ROLE_ID).toString() == peerId) {
if (RsPeerId(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString()) == peerid)
{
if (status != (int) RS_STATUS_OFFLINE) {
item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline());
} else {

View file

@ -137,8 +137,7 @@ public slots:
void filterConnected(bool filter);
private slots:
void groupsChanged(int type);
void peerStatusChanged(const QString& peerId, int status);
void peerStatusChanged(const RsPeerId &peerid, int status);
void filterItems(const QString &text);
void contextMenuRequested(const QPoint &pos);
void itemDoubleClicked(QTreeWidgetItem *item, int column);
@ -147,7 +146,8 @@ private slots:
void deselectAll() ;
private:
void fillList();
void groupsChanged();
void fillList();
void secured_fillList();
void selectedIds_internal(IdType idType, std::set<std::string> &ids, bool onlyDirectSelected);

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;

View file

@ -21,6 +21,7 @@
#include <QListWidget>
#include <QDialog>
#include <retroshare/rsids.h>
#include <retroshare/rsevents.h>
class GroupSelectionBox: public QListWidget
{
@ -28,6 +29,7 @@ class GroupSelectionBox: public QListWidget
public:
GroupSelectionBox(QWidget *parent);
virtual ~GroupSelectionBox();
static void selectGroups(const std::list<RsNodeGroupId>& default_groups) ;
@ -38,6 +40,9 @@ public:
private slots:
void fillGroups();
private:
RsEventsHandlerId_t mEventHandlerId ;
};
class GroupSelectionDialog: public QDialog

View file

@ -195,9 +195,9 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par
ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
ui->filterLineEdit->showFilterIcon();
// mEventHandlerId_pssc=0; // forces initialization
mEventHandlerId_peer=0; // forces initialization
mEventHandlerId_gssp=0; // forces initialization
mEventHandlerId_pssc=0; // forces initialization
// rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_pssc, RsEventType::PEER_STATE_CHANGED );
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::FRIEND_LIST );
@ -293,7 +293,7 @@ NewFriendList::~NewFriendList()
{
rsEvents->unregisterEventsHandler(mEventHandlerId_peer);
rsEvents->unregisterEventsHandler(mEventHandlerId_gssp);
rsEvents->unregisterEventsHandler(mEventHandlerId_pssc);
// rsEvents->unregisterEventsHandler(mEventHandlerId_pssc);
delete mModel;
delete mProxyModel;

View file

@ -127,7 +127,7 @@ private:
bool mShowState;
RsEventsHandlerId_t mEventHandlerId_peer;
RsEventsHandlerId_t mEventHandlerId_gssp;
RsEventsHandlerId_t mEventHandlerId_pssc;
// RsEventsHandlerId_t mEventHandlerId_pssc;
std::set<RsNodeGroupId> openGroups;
std::set<RsPgpId> openPeers;

View file

@ -85,6 +85,10 @@ PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId,
updateItem();
}
PeerItem::~PeerItem()
{
rsEvents->unregisterEventsHandler(mEventHandlerId);
}
uint64_t PeerItem::uniqueIdentifier() const
{
return hash_64bits("PeerItem " + mPeerId.toStdString() + " " + QString::number(mType).toStdString()) ;

View file

@ -40,6 +40,7 @@ class PeerItem : public FeedItem, private Ui::PeerItem
public:
/** Default Constructor */
PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, uint32_t type, bool isHome);
virtual ~PeerItem();
void updateItemStatic();

View file

@ -99,6 +99,10 @@ SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &g
updateItem();
}
SecurityItem::~SecurityItem()
{
rsEvents->unregisterEventsHandler(mEventHandlerId);
}
uint64_t SecurityItem::uniqueIdentifier() const
{
return hash_64bits("SecurityItem " + QString::number(mType).toStdString() + " " + mSslId.toStdString());

View file

@ -39,6 +39,7 @@ class SecurityItem : public FeedItem, private Ui::SecurityItem
public:
/** Default Constructor */
SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_addr,uint32_t type, bool isHome);
~SecurityItem();
void updateItemStatic();

View file

@ -53,7 +53,7 @@ RsGxsChannelPostsModel::RsGxsChannelPostsModel(QObject *parent)
RsGxsChannelPostsModel::~RsGxsChannelPostsModel()
{
rsEvents->unregisterEventsHandler(mEventHandlerId);
// rsEvents->unregisterEventsHandler(mEventHandlerId);
}
void RsGxsChannelPostsModel::setMode(TreeMode mode)

View file

@ -256,6 +256,6 @@ private:
QColor mTextColorNotSubscribed ;
QColor mTextColorMissing ;
RsEventsHandlerId_t mEventHandlerId ;
//RsEventsHandlerId_t mEventHandlerId ;
friend class const_iterator;
};

View file

@ -618,13 +618,14 @@ void NotifyQt::notifyListChange(int list, int type)
#endif
emit lobbyListChanged();
break;
#ifdef TO_REMOVE
case NOTIFY_LIST_GROUPLIST:
#ifdef NOTIFY_DEBUG
std::cerr << "received groups changed" << std::endl ;
#endif
emit groupsChanged(type);
break;
#endif
default:
break;
}

View file

@ -126,7 +126,7 @@ class NotifyQt: public QObject, public NotifyClient
void peerStatusChangedSummary() const;
void gxsChange(const RsGxsChanges& /* changes */);
void chatMessageReceived(ChatMessage msg);
void groupsChanged(int type) const ;
// void groupsChanged(int type) const ;
void discInfoChanged() const ;
void historyChanged(uint msgId, int type);
void chatLobbyInviteReceived() ;

View file

@ -85,7 +85,6 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
, manager(NULL), mOngoingConnectivityCheck(-1)
, mIsHiddenNode(false), mHiddenType(RS_HIDDEN_TYPE_NONE)
, mSamAccessible(false)
, mEventHandlerId(0)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
@ -262,10 +261,15 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
if (ui.tabWidget->currentIndex() == TAB_HIDDEN_SERVICE)
updateOutProxyIndicator();
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId, RsEventType::NETWORK );
}
ServerPage::~ServerPage()
{
rsEvents->unregisterEventsHandler(mEventHandlerId);
}
void ServerPage::handleEvent(std::shared_ptr<const RsEvent> e)
{
if(e->mType != RsEventType::NETWORK)

View file

@ -53,7 +53,7 @@ class ServerPage: public ConfigPage, public autoProxyCallback
public:
ServerPage(QWidget * parent = 0, Qt::WindowFlags flags = 0);
~ServerPage() {}
~ServerPage() ;
/** Loads the settings for this page */
virtual void load();