From 4d96c71942337f51b5178742836be9a218c0c21e Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 30 Aug 2019 11:11:40 +0200 Subject: [PATCH 1/2] fixed connection for "deny friend" function in FriendList --- retroshare-gui/src/gui/common/NewFriendList.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 751c18403..d4a474eb6 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -567,7 +567,7 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu() case RsFriendListModel::ENTRY_TYPE_PROFILE: { contextMenu.addAction(QIcon(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configureProfile())); - contextMenu.addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removefriend())); + contextMenu.addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removeProfile())); RsFriendListModel::RsProfileDetails details; mModel->getProfileData(index,details); @@ -902,6 +902,8 @@ void NewFriendList::removeNode() if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this node?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes) rsPeers->removeFriendLocation(det.id); + + checkInternalData(true); } void NewFriendList::removeProfile() @@ -913,6 +915,7 @@ void NewFriendList::removeProfile() if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this Friend?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes) rsPeers->removeFriend(det.gpg_id); + checkInternalData(true); } void NewFriendList::connectNode() From 15e6947b0703c09e82ee8d2a90f2018945329d61 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 30 Aug 2019 13:57:27 +0200 Subject: [PATCH 2/2] use queued connections for notification signals in friend list, added a call to begin/endResetModel() --- .../src/gui/common/FriendListModel.cpp | 3 ++ .../src/gui/common/NewFriendList.cpp | 33 ++++++++++--------- retroshare-gui/src/gui/common/NewFriendList.h | 4 +-- .../src/gui/common/NewFriendList.ui | 3 ++ 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index ff69a0231..4216394e8 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -151,9 +151,12 @@ void RsFriendListModel::setDisplayGroups(bool b) void RsFriendListModel::preMods() { emit layoutAboutToBeChanged(); + + beginResetModel(); } void RsFriendListModel::postMods() { + endResetModel(); emit layoutChanged(); emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL)); } diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index d4a474eb6..a9baca5fd 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -155,7 +154,7 @@ private: bool m_showOfflineNodes; }; -NewFriendList::NewFriendList(QWidget *parent) : RsAutoUpdatePage(5000,parent), ui(new Ui::NewFriendList()) +NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent),*/ ui(new Ui::NewFriendList()) { ui->setupUi(this); @@ -192,7 +191,7 @@ NewFriendList::NewFriendList(QWidget *parent) : RsAutoUpdatePage(5000,parent), u // workaround for Qt bug, should be solved in next Qt release 4.7.0 // http://bugreports.qt.nokia.com/browse/QTBUG-8270 QShortcut *Shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), ui->peerTreeWidget, 0, 0, Qt::WidgetShortcut); - connect(Shortcut, SIGNAL(activated()), this, SLOT(removefriend())); + connect(Shortcut, SIGNAL(activated()), this, SLOT(removefriend()),Qt::QueuedConnection); QFontMetricsF fontMetrics(ui->peerTreeWidget->font()); @@ -215,18 +214,20 @@ NewFriendList::NewFriendList(QWidget *parent) : RsAutoUpdatePage(5000,parent), u connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(toggleSortByState(bool))); connect(ui->peerTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu())); - connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(forceUpdateDisplay())); - connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(forceUpdateDisplay())); - connect(NotifyQt::getInstance(), SIGNAL(peerConnected(const QString&)), this, SLOT(forceUpdateDisplay())); - connect(NotifyQt::getInstance(), SIGNAL(peerDisconnected(const QString&)), this, SLOT(forceUpdateDisplay())); + // Using Queued connections here is pretty important since the notifications may come from a different thread. + + connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection); + connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection); + connect(NotifyQt::getInstance(), SIGNAL(peerConnected(const QString&)) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection); + connect(NotifyQt::getInstance(), SIGNAL(peerDisconnected(const QString&)), this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection); connect(ui->actionShowOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setShowUnconnected(bool))); - connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool))); - connect(ui->actionShowGroups, SIGNAL(triggered(bool)), this, SLOT(setShowGroups(bool))); - connect(ui->actionExportFriendlist, SIGNAL(triggered()), this, SLOT(exportFriendlistClicked())); - connect(ui->actionImportFriendlist, SIGNAL(triggered()), this, SLOT(importFriendlistClicked())); + connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)) ); + connect(ui->actionShowGroups, SIGNAL(triggered(bool)), this, SLOT(setShowGroups(bool)) ); + connect(ui->actionExportFriendlist, SIGNAL(triggered()) , this, SLOT(exportFriendlistClicked())); + connect(ui->actionImportFriendlist, SIGNAL(triggered()) , this, SLOT(importFriendlistClicked())); - connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); + connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)),Qt::QueuedConnection); connect(h, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint))); // #ifdef RS_DIRECT_CHAT @@ -972,10 +973,10 @@ void NewFriendList::forceUpdateDisplay() checkInternalData(true); } -void NewFriendList::updateDisplay() -{ - checkInternalData(false); -} +// void NewFriendList::updateDisplay() +// { +// checkInternalData(false); +// } void NewFriendList::moveToGroup() { diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index 0c87aee6a..9faff0b83 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -38,7 +38,7 @@ class QTreeWidgetItem; class QToolButton; class FriendListSortFilterProxyModel; -class NewFriendList: public RsAutoUpdatePage +class NewFriendList: public QWidget { Q_OBJECT @@ -61,7 +61,7 @@ public: std::string getSelectedGroupId() const; - void updateDisplay() override; + //void updateDisplay() override; QColor textColorGroup() const { return mModel->mTextColorGroup; } QColor textColorStatusOffline() const { return mModel->mTextColorStatus[RS_STATUS_OFFLINE ]; } diff --git a/retroshare-gui/src/gui/common/NewFriendList.ui b/retroshare-gui/src/gui/common/NewFriendList.ui index 177a8f494..3ec1c6c03 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.ui +++ b/retroshare-gui/src/gui/common/NewFriendList.ui @@ -64,6 +64,9 @@ true + + false +