mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added checkbox to hide offline peers in permission matrix (modified patch from sehraf)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8180 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f659ba71e5
commit
bb2f131464
@ -32,6 +32,7 @@
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "RSPermissionMatrixWidget.h"
|
||||
#include "gui/settings/ServicePermissionsPage.h"
|
||||
#include <retroshare/rsstatus.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsservicecontrol.h>
|
||||
@ -176,37 +177,13 @@ RSPermissionMatrixWidget::~RSPermissionMatrixWidget()
|
||||
delete _painter;
|
||||
}
|
||||
|
||||
bool sortRsPeerIdByStatusNameLocation(const RsPeerId &a, const RsPeerId &b)
|
||||
bool sortRsPeerIdByNameLocation(const RsPeerId &a, const RsPeerId &b)
|
||||
{
|
||||
RsPeerDetails detailsA, detailsB;
|
||||
rsPeers->getPeerDetails(a, detailsA);
|
||||
rsPeers->getPeerDetails(b, detailsB);
|
||||
QString stringA, stringB;
|
||||
|
||||
// connection state
|
||||
switch (detailsA.connectState) {
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_TCP:
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_TOR:
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_UDP:
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN:
|
||||
stringA = "a";
|
||||
break;
|
||||
default:
|
||||
stringA = "b";
|
||||
break;
|
||||
}
|
||||
switch (detailsB.connectState) {
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_TCP:
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_TOR:
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_UDP:
|
||||
case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN:
|
||||
stringB = "a";
|
||||
break;
|
||||
default:
|
||||
stringB = "b";
|
||||
break;
|
||||
}
|
||||
|
||||
// name
|
||||
stringA += QString::fromUtf8(detailsA.name.c_str());
|
||||
stringB += QString::fromUtf8(detailsB.name.c_str());
|
||||
@ -241,7 +218,35 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
||||
// draw one line per friend.
|
||||
std::list<RsPeerId> ssllist ;
|
||||
rsPeers->getFriendList(ssllist) ;
|
||||
ssllist.sort(sortRsPeerIdByStatusNameLocation);
|
||||
|
||||
// sort list
|
||||
{
|
||||
// RSPermissionMatrixWidgets parent is ServicePermissionsPage which holds the checkbox
|
||||
ServicePermissionsPage *spp = dynamic_cast<ServicePermissionsPage*>(parentWidget());
|
||||
if(spp != NULL) {
|
||||
// sort out offline peers
|
||||
if(spp->isHideOfflineChecked()) {
|
||||
RsPeerDetails peerDetails;
|
||||
for(std::list<RsPeerId>::iterator it = ssllist.begin(); it != ssllist.end();) {
|
||||
rsPeers->getPeerDetails(*it, peerDetails);
|
||||
|
||||
switch (peerDetails.connectState) {
|
||||
case RS_PEER_CONNECTSTATE_OFFLINE:
|
||||
case RS_PEER_CONNECTSTATE_TRYING_TCP:
|
||||
case RS_PEER_CONNECTSTATE_TRYING_UDP:
|
||||
it = ssllist.erase(it);
|
||||
break;
|
||||
default:
|
||||
it++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sort by name
|
||||
ssllist.sort(sortRsPeerIdByNameLocation);
|
||||
}
|
||||
|
||||
RsPeerServiceInfo ownServices;
|
||||
rsServiceControl->getOwnServices(ownServices);
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsservicecontrol.h>
|
||||
|
||||
//#include <retroshare/rsservicecontrol.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <QTimer>
|
||||
|
||||
@ -34,7 +32,7 @@
|
||||
#define ServiceIdUserRole (Qt::UserRole + 1)
|
||||
#define PeerIdUserRole (Qt::UserRole + 2)
|
||||
|
||||
ServicePermissionsPage::ServicePermissionsPage(QWidget * parent, Qt::WindowFlags flags)
|
||||
ServicePermissionsPage::ServicePermissionsPage(QWidget * parent, Qt::WindowFlags /*flags*/)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
@ -60,5 +58,9 @@ QString ServicePermissionsPage::helpText() const
|
||||
stop all anonymous transfer, distant chat and distant messaging.</p>");
|
||||
}
|
||||
|
||||
bool ServicePermissionsPage::isHideOfflineChecked()
|
||||
{
|
||||
return ui.cb_hideOffline->checkState() == Qt::Checked;
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,6 +44,8 @@ public:
|
||||
virtual QString pageName() const { return tr("Permissions") ; }
|
||||
virtual QString helpText() const ;
|
||||
|
||||
bool isHideOfflineChecked();
|
||||
|
||||
private:
|
||||
|
||||
Ui::ServicePermissionsPage ui;
|
||||
|
@ -20,6 +20,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_hideOffline">
|
||||
<property name="text">
|
||||
<string>hide offline</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
|
Loading…
Reference in New Issue
Block a user