mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 01:31:30 -05: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 <QMouseEvent>
|
||||||
|
|
||||||
#include "RSPermissionMatrixWidget.h"
|
#include "RSPermissionMatrixWidget.h"
|
||||||
|
#include "gui/settings/ServicePermissionsPage.h"
|
||||||
#include <retroshare/rsstatus.h>
|
#include <retroshare/rsstatus.h>
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
#include <retroshare/rsservicecontrol.h>
|
#include <retroshare/rsservicecontrol.h>
|
||||||
@ -176,37 +177,13 @@ RSPermissionMatrixWidget::~RSPermissionMatrixWidget()
|
|||||||
delete _painter;
|
delete _painter;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sortRsPeerIdByStatusNameLocation(const RsPeerId &a, const RsPeerId &b)
|
bool sortRsPeerIdByNameLocation(const RsPeerId &a, const RsPeerId &b)
|
||||||
{
|
{
|
||||||
RsPeerDetails detailsA, detailsB;
|
RsPeerDetails detailsA, detailsB;
|
||||||
rsPeers->getPeerDetails(a, detailsA);
|
rsPeers->getPeerDetails(a, detailsA);
|
||||||
rsPeers->getPeerDetails(b, detailsB);
|
rsPeers->getPeerDetails(b, detailsB);
|
||||||
QString stringA, stringB;
|
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
|
// name
|
||||||
stringA += QString::fromUtf8(detailsA.name.c_str());
|
stringA += QString::fromUtf8(detailsA.name.c_str());
|
||||||
stringB += QString::fromUtf8(detailsB.name.c_str());
|
stringB += QString::fromUtf8(detailsB.name.c_str());
|
||||||
@ -241,7 +218,35 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
|||||||
// draw one line per friend.
|
// draw one line per friend.
|
||||||
std::list<RsPeerId> ssllist ;
|
std::list<RsPeerId> ssllist ;
|
||||||
rsPeers->getFriendList(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;
|
RsPeerServiceInfo ownServices;
|
||||||
rsServiceControl->getOwnServices(ownServices);
|
rsServiceControl->getOwnServices(ownServices);
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
#include <retroshare/rsservicecontrol.h>
|
#include <retroshare/rsservicecontrol.h>
|
||||||
|
|
||||||
//#include <retroshare/rsservicecontrol.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@ -34,7 +32,7 @@
|
|||||||
#define ServiceIdUserRole (Qt::UserRole + 1)
|
#define ServiceIdUserRole (Qt::UserRole + 1)
|
||||||
#define PeerIdUserRole (Qt::UserRole + 2)
|
#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 */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
@ -60,5 +58,9 @@ QString ServicePermissionsPage::helpText() const
|
|||||||
stop all anonymous transfer, distant chat and distant messaging.</p>");
|
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 pageName() const { return tr("Permissions") ; }
|
||||||
virtual QString helpText() const ;
|
virtual QString helpText() const ;
|
||||||
|
|
||||||
|
bool isHideOfflineChecked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Ui::ServicePermissionsPage ui;
|
Ui::ServicePermissionsPage ui;
|
||||||
|
@ -20,6 +20,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user