From b2c2b7fc85fef86bff04367f1211d8fed111789e Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 1 Feb 2015 14:38:19 +0000 Subject: [PATCH] implemented dedicated widget for service permission matrix. Permissions are not saved yet, and we also need a default switch git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7898 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/p3servicecontrol.cc | 23 + .../src/retroshare/rsservicecontrol.h | 5 +- retroshare-gui/src/gui/images.qrc | 5 + retroshare-gui/src/gui/images/switch.png | Bin 0 -> 3337 bytes retroshare-gui/src/gui/images/switch00.png | Bin 0 -> 3328 bytes retroshare-gui/src/gui/images/switch01.png | Bin 0 -> 3638 bytes retroshare-gui/src/gui/images/switch10.png | Bin 0 -> 3650 bytes retroshare-gui/src/gui/images/switch11.png | Bin 0 -> 3876 bytes .../gui/settings/RSPermissionMatrixWidget.cpp | 445 ++++++++++++++++++ .../gui/settings/RSPermissionMatrixWidget.h | 103 ++++ .../gui/settings/ServicePermissionsPage.cpp | 19 +- .../src/gui/settings/ServicePermissionsPage.h | 34 +- .../gui/settings/ServicePermissionsPage.ui | 66 +-- retroshare-gui/src/retroshare-gui.pro | 2 + 14 files changed, 625 insertions(+), 77 deletions(-) create mode 100644 retroshare-gui/src/gui/images/switch.png create mode 100644 retroshare-gui/src/gui/images/switch00.png create mode 100644 retroshare-gui/src/gui/images/switch01.png create mode 100644 retroshare-gui/src/gui/images/switch10.png create mode 100644 retroshare-gui/src/gui/images/switch11.png create mode 100644 retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp create mode 100644 retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h diff --git a/libretroshare/src/pqi/p3servicecontrol.cc b/libretroshare/src/pqi/p3servicecontrol.cc index b7c6aef98..1df7ff8e8 100644 --- a/libretroshare/src/pqi/p3servicecontrol.cc +++ b/libretroshare/src/pqi/p3servicecontrol.cc @@ -1239,6 +1239,29 @@ bool RsServicePermissions::peerHasPermission(const RsPeerId &peerId) const } } +void RsServicePermissions::setPermission(const RsPeerId& peerId) +{ + std::set::const_iterator it; + if (mDefaultAllowed) + { + it = mPeersDenied.find(peerId); + mPeersDenied.erase(it) ; + } + else + mPeersAllowed.insert(peerId); +} +void RsServicePermissions::resetPermission(const RsPeerId& peerId) +{ + std::set::const_iterator it; + if (!mDefaultAllowed) + { + it = mPeersAllowed.find(peerId); + mPeersAllowed.erase(it) ; + } + else + mPeersDenied.insert(peerId); +} + RsServiceInfo::RsServiceInfo( const uint16_t service_type, const std::string service_name, diff --git a/libretroshare/src/retroshare/rsservicecontrol.h b/libretroshare/src/retroshare/rsservicecontrol.h index 3a7c468ad..49dbb0385 100644 --- a/libretroshare/src/retroshare/rsservicecontrol.h +++ b/libretroshare/src/retroshare/rsservicecontrol.h @@ -84,7 +84,10 @@ class RsServicePermissions public: RsServicePermissions(); - bool peerHasPermission(const RsPeerId &peerId) const; + bool peerHasPermission(const RsPeerId &peerId) const; + + void setPermission(const RsPeerId& peerId) ; + void resetPermission(const RsPeerId& peerId) ; uint32_t mServiceId; std::string mServiceName; diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index f259220f2..1d61d0e71 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -1,5 +1,10 @@ + images/switch.png + images/switch00.png + images/switch01.png + images/switch10.png + images/switch11.png images/add_chat24.png images/RSS_004_32.png images/mail-encrypted-full.png diff --git a/retroshare-gui/src/gui/images/switch.png b/retroshare-gui/src/gui/images/switch.png new file mode 100644 index 0000000000000000000000000000000000000000..46d1a765df7396b268fad845b3f57ac9e106e63b GIT binary patch literal 3337 zcmV+k4fgVhP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^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M@JiaHglx!!M)@5?ax?P_>J!F?z;S%rr@nxAJNm(bL21RV*>!A Um!ls4CjbBd07*qoM6N<$f?F!%TmS$7 literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/images/switch11.png b/retroshare-gui/src/gui/images/switch11.png new file mode 100644 index 0000000000000000000000000000000000000000..625cc8a460923975621cbae0c8a2031f061f0911 GIT binary patch literal 3876 zcmV+<58LpGP)Oz@Z0f2-7z;ux~O9+4z06=<WDR*FRcSTFz- zW=q650N5=6FiBTtNC2?60Km==3$g$R3;-}uh=nNt1bYBr$Ri_o0EC$U6h`t_Jn<{8 z5a%iY0C<_QJh>z}MS)ugEpZ1|S1ukX&Pf+56gFW3VVXcL!g-k)GJ!M?;PcD?0HBc- z5#WRK{dmp}uFlRjj{U%*%WZ25jX z{P*?XzTzZ-GF^d31o+^>%=Ap99M6&ogks$0k4OBs3;+Bb(;~!4V!2o<6ys46agIcq zjPo+3B8fthDa9qy|77CdEc*jK-!%ZRYCZvbku9iQV*~a}ClFY4z~c7+0P?$U!PF=S z1Au6Q;m>#f??3%Vpd|o+W=WE9003S@Bra6Svp>fO002awfhw>;8}z{#EWidF!3EsG z3;bXU&9EIRU@z1_9W=mEXoiz;4lcq~xDGvV5BgyU zp1~-*fe8db$Osc*A=-!mVv1NJjtCc-h4>-CNCXm#Bp}I%6j35eku^v$Qi@a{RY)E3 zJ#qp$hg?Rwkvqr$GJ^buyhkyVfwECO)C{#lxu`c9ghrwZ&}4KmnvWKso6vH!8a<3Q zq36)6Xb;+tK10Vaz~~qUGsJ8#F2=(`u{bOVlVi)VBCHIn#u~6ztOL7=^<&SmcLWlF zMZgI*1b0FpVIDz9SWH+>*hr`#93(Um+6gxa1B6k+CnA%mOSC4s5&6UzVlpv@SV$}* z))J2sFA#f(L&P^E5{W}HC%KRUNwK6<(h|}}(r!{C=`5+6G)NjFlgZj-YqAG9lq?`C z$c5yc>d>VnA`E_*3F2Qp##d8RZb=H01_mm@+|Cqnc9PsG(F5HI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RB +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "RSPermissionMatrixWidget.h" +#include +#include + +#define NOT_IMPLEMENTED std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl; + +// The behavior of the widget is the following: +// - when default is changed, switch all icons to the default position. Then every icon switch back by the user will be +// in the white list. +// - each peer/service slot has a switch. If the peer doesn't allow the service, the switch is shown with some +// indication. When both the current and adverse permissions are granted, the switch should show it as well. +// - we should use tooltips + +const int RSPermissionMatrixWidget::ICON_SIZE_X = 40 ; +const int RSPermissionMatrixWidget::ICON_SIZE_Y = 40 ; +const int RSPermissionMatrixWidget::ROW_SIZE = 42 ; +const int RSPermissionMatrixWidget::COL_SIZE = 42 ; +const int RSPermissionMatrixWidget::MATRIX_START_X = 5 ; +const int RSPermissionMatrixWidget::MATRIX_START_Y = 55 ; + +/** Default contructor */ +RSPermissionMatrixWidget::RSPermissionMatrixWidget(QWidget *parent) + :QFrame(parent) +{ + _painter = new QPainter(); + + setMouseTracking(true) ; + + //_timer = new QTimer ; + //QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(update())) ; + //_timer->start(1000); +} + +void RSPermissionMatrixWidget::mousePressEvent(QMouseEvent *e) +{ + std::cerr << "mouse pressed at x=" << e->x() << ", y=" << e->y() << std::endl; + + uint32_t service_id ; + RsPeerId peer_id ; + + if(!computeServiceAndPeer(e->x(),e->y(),service_id,peer_id)) + { + QFrame::mousePressEvent(e) ; + return ; + } + + std::cerr << "Peer id: " << peer_id << ", service: " << service_id << std::endl; + + switchPermission(service_id,peer_id) ; + + update() ; +} + +void RSPermissionMatrixWidget::switchPermission(uint32_t service,const RsPeerId& pid) +{ + RsServicePermissions serv_perms ; + + if(!rsServiceControl->getServicePermissions(service,serv_perms)) + return ; + + if(serv_perms.peerHasPermission(pid)) + serv_perms.resetPermission(pid) ; + else + serv_perms.setPermission(pid) ; + + rsServiceControl->updateServicePermissions(service,serv_perms); +} + +void RSPermissionMatrixWidget::mouseMoveEvent(QMouseEvent *e) +{ + uint32_t service_id ; + RsPeerId peer_id ; + + if(!computeServiceAndPeer(e->x(),e->y(),service_id,peer_id)) + { + service_id = ~0 ; + peer_id.clear() ; + } + + if(_current_service_id != service_id || _current_peer_id != peer_id) + { + _current_service_id = service_id ; + _current_peer_id = peer_id ; + + // redraw! + update() ; + } +} + +/** Default destructor */ +RSPermissionMatrixWidget::~RSPermissionMatrixWidget() +{ + delete _painter; +} + +/** Overloads default QWidget::paintEvent. Draws the actual + * bandwidth graph. */ +void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) +{ + //std::cerr << "In paint event!" << std::endl; + + /* Set current graph dimensions */ + _rec = this->frameRect(); + + /* Start the painter */ + _painter->begin(this); + + /* We want antialiased lines and text */ + _painter->setRenderHint(QPainter::Antialiasing); + _painter->setRenderHint(QPainter::TextAntialiasing); + + /* Fill in the background */ + _painter->fillRect(_rec, QBrush(BACK_COLOR)); + _painter->drawRect(_rec); + + // draw one line per friend. + std::list ssllist ; + rsPeers->getFriendList(ssllist) ; + + RsPeerServiceInfo ownServices; + rsServiceControl->getOwnServices(ownServices); + + // Display friend names at the beginning of each column + + const QFont& font(_painter->font()) ; + QFontMetrics fm(font); + int peer_name_size = 0 ; + float line_height = 2 + fm.height() ; + + std::vector names ; + + for(std::list::const_iterator it(ssllist.begin());it!=ssllist.end();++it) + { + RsPeerDetails details ; + rsPeers->getPeerDetails(*it,details) ; + + QString name = QString::fromUtf8(details.name.c_str()); + peer_name_size = std::max(peer_name_size, fm.width(name)) ; + names.push_back(name) ; + } + + QPen pen ; + pen.setWidth(2) ; + pen.setBrush(Qt::black) ; + + _painter->setPen(pen) ; + int i=0; + int x=5 ; + int y=MATRIX_START_Y ; + + for(std::list::const_iterator it(ssllist.begin());it!=ssllist.end();++it,++i) + { + float X = MATRIX_START_X + peer_name_size - fm.width(names[i]) ; + float Y = MATRIX_START_Y + (i+0.5)*ROW_SIZE + line_height/2.0f-2 ; + + _painter->drawText(QPointF(X,Y),names[i]) ; + + if(*it == _current_peer_id) + _painter->drawLine(QPointF(X,Y+3),QPointF(X+fm.width(names[i]),Y+3)) ; + + y += line_height ; + } + + matrix_start_x = 5 + MATRIX_START_X + peer_name_size ; + + // now draw the service names + + i=0 ; + std::vector last_width(10,0) ; + + for(std::map::const_iterator it(ownServices.mServiceList.begin());it!=ownServices.mServiceList.end();++it,++i) + { + QString name = QString::fromUtf8(it->second.mServiceName.c_str()) ; + int text_width = fm.width(name) ; + + int X = matrix_start_x + COL_SIZE/2 - 2 + i*COL_SIZE - text_width/2; + + int height_index = 0 ; + while(last_width[height_index] > X-5 && height_index < last_width.size()-1) + ++height_index ; + + int Y = MATRIX_START_Y - 2 - line_height * height_index; + + last_width[height_index] = X + text_width ; + // draw a half-transparent rectangle + + QBrush brush ; + brush.setColor(QColor::fromHsvF(0.0f,0.0f,1.0f,0.8f)); + brush.setStyle(Qt::SolidPattern) ; + + QPen pen ; + pen.setWidth(2) ; + + if(_current_service_id == it->second.mServiceType) + pen.setBrush(Qt::black) ; + else + pen.setBrush(Qt::gray) ; + + _painter->setPen(pen) ; + + QRect info_pos( X-5,Y-line_height-2, text_width + 10, line_height + 5) ; + + //_painter->fillRect(info_pos,brush) ; + //_painter->drawRect(info_pos) ; + + _painter->drawLine(QPointF(X,Y+3),QPointF(X+text_width,Y+3)) ; + _painter->drawLine(QPointF(X+text_width/2, Y+3), QPointF(X+text_width/2,MATRIX_START_Y+5)) ; + + pen.setBrush(Qt::black) ; + _painter->setPen(pen) ; + + _painter->drawText(QPointF(X,Y),name); + } + + // Now draw the switches. + + peer_ids.clear() ; + for(std::list::const_iterator it(ssllist.begin());it!=ssllist.end();++it) + peer_ids.push_back(*it) ; + service_ids.clear() ; + for(std::map::const_iterator sit(ownServices.mServiceList.begin());sit!=ownServices.mServiceList.end();++sit) + service_ids.push_back(sit->first) ; + + // We draw for each service. + + static const std::string pixmap_names[4] = { ":/images/switch00.png", + ":/images/switch01.png", + ":/images/switch10.png", + ":/images/switch11.png" } ; + + int n_col = 0 ; + int n_col_selected = -1 ; + int n_row_selected = -1 ; + + for(std::map::const_iterator sit(ownServices.mServiceList.begin());sit!=ownServices.mServiceList.end();++sit,++n_col) + { + RsServicePermissions service_perms ; + + rsServiceControl->getServicePermissions(sit->first,service_perms) ; + + // draw the default switch. + + + // draw one switch per friend. + + int n_row = 0 ; + + for(std::list::const_iterator it(ssllist.begin());it!=ssllist.end();++it,++n_row) + { + RsPeerServiceInfo local_service_perms ; + RsPeerServiceInfo remote_service_perms ; + + rsServiceControl->getServicesAllowed (*it, local_service_perms) ; + rsServiceControl->getServicesProvided(*it,remote_service_perms) ; + + bool local_allowed = local_service_perms.mServiceList.find(sit->first) != local_service_perms.mServiceList.end() ; + bool remote_allowed = remote_service_perms.mServiceList.find(sit->first) != remote_service_perms.mServiceList.end() ; + + QPixmap pix(pixmap_names[(local_allowed << 1) + remote_allowed].c_str()) ; + + bool selected = (sit->first == _current_service_id && *it == _current_peer_id) ; + QRect position = computeNodePosition(n_row,n_col,selected) ; + + if(selected) + { + n_row_selected = n_row ; + n_col_selected = n_col ; + } + _painter->drawPixmap(position,pix,QRect(0,0,ICON_SIZE_X,ICON_SIZE_Y)) ; + } + } + + // now display some info about current node. + + if(n_row_selected < peer_ids.size() && n_col_selected < service_ids.size()) + { + QRect position = computeNodePosition(n_row_selected,n_col_selected,false) ; + + // draw text info + + RsServicePermissions service_perms ; + + rsServiceControl->getServicePermissions(service_ids[n_col_selected],service_perms) ; + + QString service_name = tr("Service name: ")+QString::fromUtf8(service_perms.mServiceName.c_str()) ; + QString service_default = service_perms.mDefaultAllowed?tr("Allowed by default"):tr("Denied by default"); + QString peer_name = tr("Peer name: ") + names[n_row_selected] ; + QString peer_id = tr("Peer Id: ")+QString::fromStdString(_current_peer_id.toStdString()) ; + + RsPeerServiceInfo pserv_info ; + rsServiceControl->getServicesAllowed(_current_peer_id,pserv_info) ; + + QString local_status = (pserv_info.mServiceList.find(_current_service_id) != pserv_info.mServiceList.end())?tr("Locally enabled"):tr("Locally disabled") ; + + rsServiceControl->getServicesProvided(_current_peer_id,pserv_info) ; + + QString remote_status = (pserv_info.mServiceList.find(_current_service_id) != pserv_info.mServiceList.end())?tr("Enabled by remote peer"):tr("Disabled by remote peer") ; + + const QFont& font(_painter->font()) ; + QFontMetrics fm(font); + + int text_size_x = 0 ; + text_size_x = std::max(text_size_x,fm.width(service_name)); + text_size_x = std::max(text_size_x,fm.width(peer_name)); + text_size_x = std::max(text_size_x,fm.width(peer_id)); + text_size_x = std::max(text_size_x,fm.width(local_status)); + text_size_x = std::max(text_size_x,fm.width(remote_status)); + + // draw a half-transparent rectangle + + QBrush brush ; + brush.setColor(QColor::fromHsvF(0.0f,0.0f,1.0f,0.8f)); + brush.setStyle(Qt::SolidPattern) ; + + QPen pen ; + pen.setWidth(2) ; + pen.setBrush(Qt::black) ; + + _painter->setPen(pen) ; + + QRect info_pos( position.x() + 50, position.y() - 10, text_size_x + 10, line_height * 5 + 5) ; + + _painter->fillRect(info_pos,brush) ; + _painter->drawRect(info_pos) ; + + // draw the text + + float x = info_pos.x() + 5 ; + float y = info_pos.y() + line_height + 1 ; + + _painter->drawText(QPointF(x,y), service_name) ; y += line_height ; + _painter->drawText(QPointF(x,y), peer_name) ; y += line_height ; + _painter->drawText(QPointF(x,y), peer_id) ; y += line_height ; + _painter->drawText(QPointF(x,y), remote_status) ; y += line_height ; + _painter->drawText(QPointF(x,y), local_status) ; y += line_height ; + } + + /* Stop the painter */ + _painter->end(); +} + +QRect RSPermissionMatrixWidget::computeNodePosition(int n_row,int n_col,bool selected) const +{ + float fact = selected?1.2f:1.0f; + + return QRect(matrix_start_x + n_col * COL_SIZE + (COL_SIZE-ICON_SIZE_X*fact)/2, + MATRIX_START_Y + n_row * ROW_SIZE + (ROW_SIZE-ICON_SIZE_Y*fact)/2, + ICON_SIZE_X*fact, + ICON_SIZE_Y*fact) ; +} + +// This function is the inverse of the previous function. Given a mouse position, it +// computes the peer/service switch that is under the mouse. The zoom factor is not +// accounted for, on purpose. + +bool RSPermissionMatrixWidget::computeServiceAndPeer(int x,int y,uint32_t& service_id,RsPeerId& peer_id) const +{ + // 1 - make sure that x and y are on a widget + + x -= matrix_start_x ; + y -= MATRIX_START_Y ; + + if(x < 0 || x >= service_ids.size() * COL_SIZE) return false ; + if(y < 0 || y >= peer_ids.size() * ROW_SIZE) return false ; + + if( (x % COL_SIZE) < (COL_SIZE - ICON_SIZE_X)/2) return false ; + if( (x % COL_SIZE) > (COL_SIZE + ICON_SIZE_X)/2) return false ; + + if( (y % ROW_SIZE) < (ROW_SIZE - ICON_SIZE_Y)/2) return false ; + if( (y % ROW_SIZE) > (ROW_SIZE + ICON_SIZE_Y)/2) return false ; + + // 2 - find which widget, by looking into the service perm matrix + + service_id = service_ids[x / COL_SIZE] ; + peer_id = peer_ids[y / COL_SIZE] ; + + return true ; +} + +void RSPermissionMatrixWidget::defaultPermissionSwitched(uint32_t ServiceId,bool b) +{ + NOT_IMPLEMENTED ; +} + +void RSPermissionMatrixWidget::userPermissionSwitched(uint32_t ServiceId,const RsPeerId& friend_id,bool b) +{ + NOT_IMPLEMENTED ; +} + +// void RSGraphWidget::paintLegend() +// { +// int bottom = _rec.height(); +// +// std::vector vals ; +// _source->getCurrentValues(vals) ; +// +// for(uint i=0;ilegend(i,vals[i]) ; +// +// QPen oldPen = _painter->pen(); +// _painter->setPen(QPen(getColor(i), Qt::SolidLine)); +// _painter->drawLine(QPointF(SCALE_WIDTH+10.0, pos), QPointF(SCALE_WIDTH+30.0, pos)); +// _painter->setPen(oldPen); +// +// _painter->setPen(SCALE_COLOR); +// _painter->drawText(QPointF(SCALE_WIDTH + 40,pos + 0.5*FONT_SIZE), text) ; +// } +// } + diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h new file mode 100644 index 000000000..53379e0c1 --- /dev/null +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h @@ -0,0 +1,103 @@ +/**************************************************************** + * This file is distributed under the following license: + * + * Copyright (C) 2014 RetroShare Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#pragma once + +#include +#include + +#include +#include +#include + +#include +#include + +#define HOR_SPC 2 /** Space between data points */ +#define SCALE_WIDTH 75 /** Width of the scale */ + +#define BACK_COLOR Qt::white +#define SCALE_COLOR Qt::black +#define GRID_COLOR Qt::lightGray +#define RSDHT_COLOR Qt::magenta +#define ALLDHT_COLOR Qt::yellow + +#define FONT_SIZE 11 + +// This class provides a widget to represent an edit a matrix of permissions +// for services and friends. The widget allows to: +// - set permission for each friend/service combination +// - set permissions for a given service all friends at once +// - set permissions for a given friend, all services at once +// +// The code can also be used to display bandwidth for each (friend,service) combination. +// Maybe we should in the future make a base class with the matrix structure and use it for +// various display usages. +// +class RSPermissionMatrixWidget: public QFrame +{ + Q_OBJECT + +public: + RSPermissionMatrixWidget(QWidget *parent=NULL); + virtual ~RSPermissionMatrixWidget() ; + +protected slots: + // Calls the internal source for a new data points; called by the timer. You might want to overload this + // if the collection system needs it. Otherwise, the default method will call getValues() + void updateDisplay() {} + + void defaultPermissionSwitched(uint32_t ServiceId,bool b); + void userPermissionSwitched(uint32_t ServiceId,const RsPeerId& friend_id,bool b); + + virtual void mousePressEvent(QMouseEvent *e) ; + virtual void mouseMoveEvent(QMouseEvent *e) ; +protected: + /** Overloaded QWidget::paintEvent() */ + void paintEvent(QPaintEvent *event); + +private: + bool computeServiceAndPeer(int x,int y,uint32_t& service_id,RsPeerId& peer_id) const ; + QRect computeNodePosition(int row,int col,bool selected) const ; + + void switchPermission(uint32_t service_id,const RsPeerId& peer_id) ; + + std::vector peer_ids ; + std::vector service_ids ; + + uint32_t _current_service_id ; + RsPeerId _current_peer_id ; + int matrix_start_x ; + + /** A QPainter object that handles drawing the various graph elements. */ + QPainter* _painter; + /** The current dimensions of the graph. */ + QRect _rec; + + static const int ROW_SIZE ; + static const int COL_SIZE ; + static const int ICON_SIZE_X ; + static const int ICON_SIZE_Y ; + static const int MATRIX_START_X ; + static const int MATRIX_START_Y ; +}; + + diff --git a/retroshare-gui/src/gui/settings/ServicePermissionsPage.cpp b/retroshare-gui/src/gui/settings/ServicePermissionsPage.cpp index 394ffb7ca..b5871923f 100644 --- a/retroshare-gui/src/gui/settings/ServicePermissionsPage.cpp +++ b/retroshare-gui/src/gui/settings/ServicePermissionsPage.cpp @@ -40,8 +40,7 @@ ServicePermissionsPage::ServicePermissionsPage(QWidget * parent, Qt::WindowFlags /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); - QObject::connect(ui.tableWidget,SIGNAL(itemChanged(QTableWidgetItem *)), - this, SLOT(tableItemChanged(QTableWidgetItem *))); + //QObject::connect(ui.tableWidget,SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(tableItemChanged(QTableWidgetItem *))); /* Hide platform specific features */ #ifdef Q_WS_WIN @@ -58,6 +57,7 @@ QString ServicePermissionsPage::helpText() const /** Saves the changes on this page */ bool ServicePermissionsPage::save(QString &/*errmsg*/) { +#ifdef SUSPENDED std::cerr << "ServicePermissionsPage::save()"; std::cerr << std::endl; size_t row, column; @@ -142,8 +142,9 @@ bool ServicePermissionsPage::save(QString &/*errmsg*/) } rsServiceControl->updateServicePermissions(serviceId, permissions); } - } - return true; + } +#endif + return true; } @@ -183,6 +184,7 @@ void ServicePermissionsPage::load() std::map::const_iterator sit; rsServiceControl->getOwnServices(ownServices); +#ifdef SUSPENDED mStdRowCount = ownServices.mServiceList.size(); mStdColumnCount = peerList.size() + 1; ui.tableWidget->setRowCount(mStdRowCount); @@ -363,11 +365,13 @@ void ServicePermissionsPage::load() } ui.tableWidget->setHorizontalHeaderLabels(columnHeaders); - ui.tableWidget->setVerticalHeaderLabels(rowHeaders); + ui.tableWidget->setVerticalHeaderLabels(rowHeaders); +#endif } -void ServicePermissionsPage::tableItemChanged ( QTableWidgetItem * item ) +void ServicePermissionsPage::tableItemChanged ( int row, int col ) { +#ifdef SUSPENDED std::cerr << "ServicePermissionsPage::tableItemChanged()"; std::cerr << std::endl; std::cerr << "\t Node: Row: " << item->row() << " Column: " << item->column(); @@ -397,7 +401,8 @@ void ServicePermissionsPage::tableItemChanged ( QTableWidgetItem * item ) bool defaultOn = (Qt::Checked == defitem->checkState()); item->setBackground(getColor(defaultOn, item->checkState())); } - } + } +#endif } diff --git a/retroshare-gui/src/gui/settings/ServicePermissionsPage.h b/retroshare-gui/src/gui/settings/ServicePermissionsPage.h index 511974c01..217bdc60f 100644 --- a/retroshare-gui/src/gui/settings/ServicePermissionsPage.h +++ b/retroshare-gui/src/gui/settings/ServicePermissionsPage.h @@ -29,28 +29,28 @@ class ServicePermissionsPage: public ConfigPage { - Q_OBJECT + Q_OBJECT - public: - ServicePermissionsPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); - ~ServicePermissionsPage() {} +public: + ServicePermissionsPage(QWidget * parent = 0, Qt::WindowFlags flags = 0); + ~ServicePermissionsPage() {} - /** Saves the changes on this page */ - virtual bool save(QString &/*errmsg*/); - /** Loads the settings for this page */ - virtual void load(); + /** Saves the changes on this page */ + virtual bool save(QString &/*errmsg*/); + /** Loads the settings for this page */ + virtual void load(); - virtual QPixmap iconPixmap() const { return QPixmap(":/images/admin-24.png") ; } - virtual QString pageName() const { return tr("Permissions") ; } - virtual QString helpText() const ; + virtual QPixmap iconPixmap() const { return QPixmap(":/images/admin-24.png") ; } + virtual QString pageName() const { return tr("Permissions") ; } + virtual QString helpText() const ; - public slots: - void tableItemChanged ( QTableWidgetItem * item ); - private: +public slots: + void tableItemChanged(int row,int col); +private: - size_t mStdRowCount; - size_t mStdColumnCount; - Ui::ServicePermissionsPage ui; + size_t mStdRowCount; + size_t mStdColumnCount; + Ui::ServicePermissionsPage ui; }; #endif //SERVICEPERMISSIONSPAGE_H diff --git a/retroshare-gui/src/gui/settings/ServicePermissionsPage.ui b/retroshare-gui/src/gui/settings/ServicePermissionsPage.ui index 6ee653efd..7460cda4e 100644 --- a/retroshare-gui/src/gui/settings/ServicePermissionsPage.ui +++ b/retroshare-gui/src/gui/settings/ServicePermissionsPage.ui @@ -58,59 +58,13 @@ - - - Permission changes are not saved permanently. (TODO) + + + QFrame::StyledPanel + + + QFrame::Raised - - - - - - - Chat - - - - - Row2 - - - - - Shares - - - - - Channels - - - - - Default - - - - - Joe - - - - - Sally - - - - - Anne - - - - - Jacki - - @@ -119,6 +73,14 @@ + + + RSPermissionMatrixWidget + QFrame +
gui/settings/RSPermissionMatrixWidget.h
+ 1 +
+
diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 0599b8522..1985fdaed 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -398,6 +398,7 @@ HEADERS += rshare.h \ gui/msgs/textformat.h \ gui/msgs/MessageUserNotify.h \ gui/images/retroshare_win.rc.h \ + gui/settings/RSPermissionMatrixWidget.h \ gui/settings/rsharesettings.h \ gui/settings/RsharePeerSettings.h \ gui/settings/rsettings.h \ @@ -780,6 +781,7 @@ SOURCES += main.cpp \ gui/common/StyledElidedLabel.cpp \ gui/style/RSStyle.cpp \ gui/style/StyleDialog.cpp \ + gui/settings/RSPermissionMatrixWidget.cpp \ gui/settings/rsharesettings.cpp \ gui/settings/RsharePeerSettings.cpp \ gui/settings/rsettings.cpp \