Merge pull request #1625 from csoler/v0.6-FriendList

fixed connection for "deny friend" function in FriendList
This commit is contained in:
csoler 2019-08-30 14:05:58 +02:00 committed by GitHub
commit a51259beb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 19 deletions

View file

@ -151,9 +151,12 @@ void RsFriendListModel::setDisplayGroups(bool b)
void RsFriendListModel::preMods() void RsFriendListModel::preMods()
{ {
emit layoutAboutToBeChanged(); emit layoutAboutToBeChanged();
beginResetModel();
} }
void RsFriendListModel::postMods() void RsFriendListModel::postMods()
{ {
endResetModel();
emit layoutChanged(); emit layoutChanged();
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL)); emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
} }

View file

@ -21,7 +21,6 @@
#include <algorithm> #include <algorithm>
#include <QShortcut> #include <QShortcut>
#include <QTimer>
#include <QWidgetAction> #include <QWidgetAction>
#include <QDateTime> #include <QDateTime>
#include <QPainter> #include <QPainter>
@ -155,7 +154,7 @@ private:
bool m_showOfflineNodes; 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); 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 // workaround for Qt bug, should be solved in next Qt release 4.7.0
// http://bugreports.qt.nokia.com/browse/QTBUG-8270 // http://bugreports.qt.nokia.com/browse/QTBUG-8270
QShortcut *Shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), ui->peerTreeWidget, 0, 0, Qt::WidgetShortcut); 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()); QFontMetricsF fontMetrics(ui->peerTreeWidget->font());
@ -215,10 +214,12 @@ NewFriendList::NewFriendList(QWidget *parent) : RsAutoUpdatePage(5000,parent), u
connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(toggleSortByState(bool))); connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(toggleSortByState(bool)));
connect(ui->peerTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu())); connect(ui->peerTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu()));
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(forceUpdateDisplay())); // Using Queued connections here is pretty important since the notifications may come from a different thread.
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(forceUpdateDisplay()));
connect(NotifyQt::getInstance(), SIGNAL(peerConnected(const QString&)), this, SLOT(forceUpdateDisplay())); connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
connect(NotifyQt::getInstance(), SIGNAL(peerDisconnected(const QString&)), this, SLOT(forceUpdateDisplay())); 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->actionShowOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setShowUnconnected(bool)));
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)) ); connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)) );
@ -226,7 +227,7 @@ NewFriendList::NewFriendList(QWidget *parent) : RsAutoUpdatePage(5000,parent), u
connect(ui->actionExportFriendlist, SIGNAL(triggered()) , this, SLOT(exportFriendlistClicked())); connect(ui->actionExportFriendlist, SIGNAL(triggered()) , this, SLOT(exportFriendlistClicked()));
connect(ui->actionImportFriendlist, SIGNAL(triggered()) , this, SLOT(importFriendlistClicked())); 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))); connect(h, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint)));
// #ifdef RS_DIRECT_CHAT // #ifdef RS_DIRECT_CHAT
@ -567,7 +568,7 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu()
case RsFriendListModel::ENTRY_TYPE_PROFILE: case RsFriendListModel::ENTRY_TYPE_PROFILE:
{ {
contextMenu.addAction(QIcon(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configureProfile())); 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; RsFriendListModel::RsProfileDetails details;
mModel->getProfileData(index,details); mModel->getProfileData(index,details);
@ -902,6 +903,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) 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); rsPeers->removeFriendLocation(det.id);
checkInternalData(true);
} }
void NewFriendList::removeProfile() void NewFriendList::removeProfile()
@ -913,6 +916,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) 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); rsPeers->removeFriend(det.gpg_id);
checkInternalData(true);
} }
void NewFriendList::connectNode() void NewFriendList::connectNode()
@ -969,10 +973,10 @@ void NewFriendList::forceUpdateDisplay()
checkInternalData(true); checkInternalData(true);
} }
void NewFriendList::updateDisplay() // void NewFriendList::updateDisplay()
{ // {
checkInternalData(false); // checkInternalData(false);
} // }
void NewFriendList::moveToGroup() void NewFriendList::moveToGroup()
{ {

View file

@ -38,7 +38,7 @@ class QTreeWidgetItem;
class QToolButton; class QToolButton;
class FriendListSortFilterProxyModel; class FriendListSortFilterProxyModel;
class NewFriendList: public RsAutoUpdatePage class NewFriendList: public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -61,7 +61,7 @@ public:
std::string getSelectedGroupId() const; std::string getSelectedGroupId() const;
void updateDisplay() override; //void updateDisplay() override;
QColor textColorGroup() const { return mModel->mTextColorGroup; } QColor textColorGroup() const { return mModel->mTextColorGroup; }
QColor textColorStatusOffline() const { return mModel->mTextColorStatus[RS_STATUS_OFFLINE ]; } QColor textColorStatusOffline() const { return mModel->mTextColorStatus[RS_STATUS_OFFLINE ]; }

View file

@ -64,6 +64,9 @@
<property name="sortingEnabled"> <property name="sortingEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>