mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 16:39:43 -05:00
started widget for graphic display of identities and groups
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7321 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
cc6a141b68
commit
7a9e2e865d
@ -72,9 +72,7 @@
|
||||
#include "gui/GetStartedDialog.h"
|
||||
#endif
|
||||
|
||||
#ifdef SUSPENDED
|
||||
#include "gui/People/PeopleDialog.h"
|
||||
#endif
|
||||
#include "gui/FileTransfer/TurtleRouterDialog.h"
|
||||
#include "idle/idle.h"
|
||||
|
||||
@ -249,11 +247,11 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
|
||||
ui->stackPages->add(friendsDialog = new FriendsDialog(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_PEERS), tr("Network"), grp));
|
||||
notify.push_back(QPair<MainPage*, QAction*>(friendsDialog, action));
|
||||
#ifdef SUSPENDED
|
||||
|
||||
PeopleDialog *peopleDialog = NULL;
|
||||
ui->stackPages->add(peopleDialog = new PeopleDialog(ui->stackPages), action = createPageAction(QIcon(IMAGE_IDENTITY), tr("People"), grp));
|
||||
notify.push_back(QPair<MainPage*, QAction*>(peopleDialog, action));
|
||||
#endif
|
||||
|
||||
IdDialog *idDialog = NULL;
|
||||
ui->stackPages->add(idDialog = new IdDialog(ui->stackPages), action = createPageAction(QIcon(IMAGE_IDENTITY), tr("Itentities"), grp));
|
||||
notify.push_back(QPair<MainPage*, QAction*>(idDialog, action));
|
||||
|
383
retroshare-gui/src/gui/People/GroupListView.cpp
Normal file
383
retroshare-gui/src/gui/People/GroupListView.cpp
Normal file
@ -0,0 +1,383 @@
|
||||
#include <iostream>
|
||||
#include <QDebug>
|
||||
#include <QGraphicsScene>
|
||||
#include <QWheelEvent>
|
||||
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include "GroupListView.h"
|
||||
#include "IdentityItem.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
const uint32_t GroupListView::GLVIEW_IDLIST = 0x0001 ;
|
||||
const uint32_t GroupListView::GLVIEW_IDDETAILS = 0x0002 ;
|
||||
const uint32_t GroupListView::GLVIEW_REFRESH = 0x0003 ;
|
||||
const uint32_t GroupListView::GLVIEW_REPLIST = 0x0004 ;
|
||||
|
||||
GroupListView::GroupListView(QWidget *)
|
||||
: timerId(0), mIsFrozen(false)
|
||||
{
|
||||
mStateHelper = new UIStateHelper(this);
|
||||
//mStateHelper->addWidget(IDDIALOG_IDLIST, ui.treeWidget_IdList);
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||
|
||||
QGraphicsScene *scene = new QGraphicsScene(QRectF(0,0,width(),height()),this);
|
||||
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
scene->clear() ;
|
||||
setScene(scene);
|
||||
scene->setSceneRect(0, 0, width(), height());
|
||||
|
||||
setCacheMode(CacheBackground);
|
||||
setViewportUpdateMode(BoundingRectViewportUpdate);
|
||||
setRenderHint(QPainter::Antialiasing);
|
||||
setTransformationAnchor(AnchorUnderMouse);
|
||||
setResizeAnchor(AnchorViewCenter);
|
||||
_friction_factor = 1.0f ;
|
||||
|
||||
setMouseTracking(true) ;
|
||||
//scale(qreal(0.8), qreal(0.8));
|
||||
}
|
||||
|
||||
void GroupListView::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
scene()->setSceneRect(0, 0, e->size().width(), e->size().height());
|
||||
}
|
||||
|
||||
void GroupListView::clearGraph()
|
||||
{
|
||||
// QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
// scene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
// setScene(scene);
|
||||
|
||||
// scene->addItem(centerNode);
|
||||
// centerNode->setPos(0, 0);
|
||||
|
||||
// if (oldscene != NULL)
|
||||
// {
|
||||
// delete oldscene;
|
||||
// }
|
||||
|
||||
scene()->clear();
|
||||
scene()->setSceneRect(-200, -200, 1000, 1000);
|
||||
// _edges.clear();
|
||||
// _nodes.clear();
|
||||
_friction_factor = 1.0f ;
|
||||
}
|
||||
|
||||
// GroupListView::NodeId GroupListView::addNode(const std::string& node_short_string,const std::string& node_complete_string,NodeType type,AuthType auth,const RsPeerId& ssl_id,const RsPgpId& gpg_id)
|
||||
// {
|
||||
// Node *node = new Node(node_short_string,type,auth,this,ssl_id,gpg_id);
|
||||
// node->setToolTip(QString::fromUtf8(node_complete_string.c_str())) ;
|
||||
// _nodes.push_back(node) ;
|
||||
// scene()->addItem(node);
|
||||
//
|
||||
// std::map<std::string,QPointF>::const_iterator it(_node_cached_positions.find(gpg_id.toStdString())) ;
|
||||
// if(_node_cached_positions.end() != it)
|
||||
// node->setPos(it->second) ;
|
||||
// else
|
||||
// {
|
||||
// qreal x1,y1,x2,y2 ;
|
||||
// sceneRect().getCoords(&x1,&y1,&x2,&y2) ;
|
||||
//
|
||||
// float f1 = (type == GroupListView::ELASTIC_NODE_TYPE_OWN)?0.5:(rand()/(float)RAND_MAX) ;
|
||||
// float f2 = (type == GroupListView::ELASTIC_NODE_TYPE_OWN)?0.5:(rand()/(float)RAND_MAX) ;
|
||||
//
|
||||
// node->setPos(x1+f1*(x2-x1),y1+f2*(y2-y1));
|
||||
// }
|
||||
// #ifdef DEBUG_ELASTIC
|
||||
// std::cerr << "Added node " << _nodes.size()-1 << std::endl ;
|
||||
// #endif
|
||||
// return _nodes.size()-1 ;
|
||||
// }
|
||||
|
||||
void GroupListView::itemMoved()
|
||||
{
|
||||
if (!timerId)
|
||||
{
|
||||
#ifdef DEBUG_ELASTIC
|
||||
std::cout << "starting timer" << std::endl;
|
||||
#endif
|
||||
timerId = startTimer(1000 / 25); // hit timer 25 times per second.
|
||||
_friction_factor = 1.0f ;
|
||||
}
|
||||
}
|
||||
|
||||
void GroupListView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
switch (event->key()) {
|
||||
// case Qt::Key_Up:
|
||||
// centerNode->moveBy(0, -20);
|
||||
// break;
|
||||
// case Qt::Key_Down:
|
||||
// centerNode->moveBy(0, 20);
|
||||
// break;
|
||||
// case Qt::Key_Left:
|
||||
// centerNode->moveBy(-20, 0);
|
||||
// break;
|
||||
// case Qt::Key_Right:
|
||||
// centerNode->moveBy(20, 0);
|
||||
// break;
|
||||
case Qt::Key_Plus:
|
||||
scaleView(qreal(1.2));
|
||||
break;
|
||||
case Qt::Key_Minus:
|
||||
scaleView(1 / qreal(1.2));
|
||||
break;
|
||||
case Qt::Key_Space:
|
||||
case Qt::Key_Enter:
|
||||
requestIdList() ;
|
||||
// foreach (QGraphicsItem *item, scene()->items()) {
|
||||
// if (qgraphicsitem_cast<Node *>(item))
|
||||
// item->setPos(-150 + qrand() % 300, -150 + qrand() % 300);
|
||||
// }
|
||||
break;
|
||||
default:
|
||||
QGraphicsView::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupListView::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
if(!isVisible())
|
||||
return ;
|
||||
|
||||
if (mIsFrozen)
|
||||
{
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
QRectF R(scene()->sceneRect()) ;
|
||||
|
||||
// if (!itemsMoved) {
|
||||
// killTimer(timerId);
|
||||
//#ifdef DEBUG_ELASTIC
|
||||
// std::cerr << "Killing timr" << std::endl ;
|
||||
//#endif
|
||||
// timerId = 0;
|
||||
// }
|
||||
_friction_factor *= 1.001f ;
|
||||
// std::cerr << "Friction factor = " << _friction_factor << std::endl;
|
||||
}
|
||||
|
||||
void GroupListView::setEdgeLength(uint32_t l)
|
||||
{
|
||||
_edge_length = l ;
|
||||
|
||||
if(!timerId)
|
||||
{
|
||||
#ifdef DEBUG_ELASTIC
|
||||
std::cout << "starting timer" << std::endl;
|
||||
#endif
|
||||
timerId = startTimer(1000 / 25);
|
||||
_friction_factor = 1.0f ;
|
||||
}
|
||||
}
|
||||
void GroupListView::insertIdList(uint32_t token)
|
||||
{
|
||||
std::cerr << "**** In insertIdList() ****" << std::endl;
|
||||
|
||||
mStateHelper->setLoading(GLVIEW_IDLIST, false);
|
||||
|
||||
// int accept = ui.filterComboBox->itemData(ui.filterComboBox->currentIndex()).toInt();
|
||||
|
||||
RsGxsIdGroup data;
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
std::vector<RsGxsIdGroup>::iterator vit;
|
||||
|
||||
if (!rsIdentity->getGroupData(token, datavector))
|
||||
{
|
||||
std::cerr << "IdDialog::insertIdList() Error getting GroupData";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setLoading(GLVIEW_IDDETAILS, false);
|
||||
mStateHelper->setLoading(GLVIEW_REPLIST, false);
|
||||
mStateHelper->setActive(GLVIEW_IDLIST, false);
|
||||
mStateHelper->setActive(GLVIEW_IDDETAILS, false);
|
||||
mStateHelper->setActive(GLVIEW_REPLIST, false);
|
||||
mStateHelper->clear(GLVIEW_IDLIST);
|
||||
mStateHelper->clear(GLVIEW_IDDETAILS);
|
||||
mStateHelper->clear(GLVIEW_REPLIST);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setActive(GLVIEW_IDLIST, true);
|
||||
|
||||
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
|
||||
|
||||
/* Insert items */
|
||||
int i=0 ;
|
||||
|
||||
for (vit = datavector.begin(); vit != datavector.end(); ++vit)
|
||||
if(_identity_items.find((*vit).mMeta.mGroupId) == _identity_items.end())
|
||||
{
|
||||
std::cerr << "Loading data vector identity ID = " << (*vit).mMeta.mGroupId << std::endl;
|
||||
|
||||
IdentityItem *new_item = new IdentityItem(*vit) ;
|
||||
_identity_items[(*vit).mMeta.mGroupId] = new_item ;
|
||||
|
||||
new_item->setPos(15+IdentityItem::IMG_SIZE/2,(40+IdentityItem::IMG_SIZE)*(i+0.5)) ;
|
||||
|
||||
QObject::connect(new_item,SIGNAL(itemChanged()),this,SLOT(forceRedraw())) ;
|
||||
|
||||
scene()->addItem(new_item) ;
|
||||
++i ;
|
||||
}
|
||||
else
|
||||
std::cerr << "Updating data vector identity ID = " << (*vit).mMeta.mGroupId << std::endl;
|
||||
|
||||
// filterIds();
|
||||
|
||||
// fix up buttons.
|
||||
// updateSelection();
|
||||
}
|
||||
|
||||
void GroupListView::requestIdList()
|
||||
{
|
||||
std::cerr << "Requesting ID list..." << std::endl;
|
||||
|
||||
if (!mIdQueue)
|
||||
return;
|
||||
|
||||
mStateHelper->setLoading(GLVIEW_IDLIST, true);
|
||||
//mStateHelper->setLoading(GLVIEW_IDDETAILS, true);
|
||||
//mStateHelper->setLoading(GLVIEW_REPLIST, true);
|
||||
|
||||
mIdQueue->cancelActiveRequestTokens(GLVIEW_IDLIST);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
uint32_t token;
|
||||
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, GLVIEW_IDLIST);
|
||||
}
|
||||
|
||||
void GroupListView::forceRedraw()
|
||||
{
|
||||
std::cerr << "force redraw" << std::endl;
|
||||
for(std::map<RsGxsGroupId,IdentityItem*>::const_iterator it(_identity_items.begin());it!=_identity_items.end();++it)
|
||||
it->second->update( it->second->boundingRect()) ;
|
||||
|
||||
updateSceneRect(sceneRect()) ;
|
||||
scaleView(1.0);
|
||||
}
|
||||
void GroupListView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
//scaleView(pow((double)2, -event->delta() / 240.0));
|
||||
}
|
||||
void GroupListView::loadRequest(const TokenQueue * /*queue*/, const TokenRequest &req)
|
||||
{
|
||||
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
|
||||
switch(req.mUserType)
|
||||
{
|
||||
case GLVIEW_IDLIST:
|
||||
insertIdList(req.mToken);
|
||||
break;
|
||||
|
||||
case GLVIEW_IDDETAILS:
|
||||
//insertIdDetails(req.mToken);
|
||||
break;
|
||||
|
||||
case GLVIEW_REPLIST:
|
||||
//insertRepList(req.mToken);
|
||||
break;
|
||||
|
||||
case GLVIEW_REFRESH:
|
||||
updateDisplay(true);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "IdDialog::loadRequest() ERROR";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GroupListView::updateDisplay(bool)
|
||||
{
|
||||
std::cerr << "update display" << std::endl;
|
||||
}
|
||||
|
||||
void GroupListView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
//Q_UNUSED(rect);
|
||||
|
||||
std::cerr << "drawing background..." << std::endl;
|
||||
// Shadow
|
||||
QRectF sceneRect = this->sceneRect();
|
||||
|
||||
// QRectF rightShadow(sceneRect.right(), sceneRect.top() + 5, 5, sceneRect.height());
|
||||
// QRectF bottomShadow(sceneRect.left() + 5, sceneRect.bottom(), sceneRect.width(), 5);
|
||||
// if (rightShadow.intersects(rect) || rightShadow.contains(rect))
|
||||
// painter->fillRect(rightShadow, Qt::darkGray);
|
||||
// if (bottomShadow.intersects(rect) || bottomShadow.contains(rect))
|
||||
// painter->fillRect(bottomShadow, Qt::darkGray);
|
||||
|
||||
// Fill
|
||||
QLinearGradient gradient(sceneRect.topLeft(), sceneRect.bottomRight());
|
||||
gradient.setColorAt(0, Qt::white);
|
||||
gradient.setColorAt(1, Qt::lightGray);
|
||||
painter->fillRect(rect.intersected(sceneRect), gradient);
|
||||
//painter->setBrush(Qt::NoBrush);
|
||||
//painter->drawRect(sceneRect);
|
||||
|
||||
// Text
|
||||
// QRectF textRect(sceneRect.left() + 4, sceneRect.top() + 4,
|
||||
// sceneRect.width() - 4, sceneRect.height() - 4);
|
||||
// QString message(tr("Click and drag the nodes around, and zoom with the mouse "
|
||||
// "wheel or the '+' and '-' keys"));
|
||||
|
||||
// QFont font = painter->font();
|
||||
// font.setBold(true);
|
||||
// font.setPointSize(14);
|
||||
// painter->setFont(font);
|
||||
// painter->setPen(Qt::lightGray);
|
||||
// painter->drawText(textRect.translated(2, 2), message);
|
||||
// painter->setPen(Qt::black);
|
||||
// painter->drawText(textRect, message);
|
||||
|
||||
// Now draw information about current Identity
|
||||
//
|
||||
if(IdentityItem::_selected_node != NULL)
|
||||
{
|
||||
std::cerr << "Drawing selected info" << std::endl;
|
||||
painter->setPen(Qt::black);
|
||||
QFont font = painter->font();
|
||||
font.setBold(true);
|
||||
font.setPointSize(14);
|
||||
painter->setFont(font);
|
||||
|
||||
const RsGxsIdGroup& group_info(IdentityItem::_selected_node->groupInfo()) ;
|
||||
|
||||
painter->drawText(QPointF(IdentityItem::IMG_SIZE*2.5,50), QString("Id: ")+QString::fromStdString(group_info.mMeta.mGroupId.toStdString() ));
|
||||
painter->drawText(QPointF(100,100), QString("Id: ")+QString::fromStdString(group_info.mMeta.mGroupId.toStdString() ));
|
||||
}
|
||||
}
|
||||
|
||||
void GroupListView::scaleView(qreal scaleFactor)
|
||||
{
|
||||
qreal factor = matrix().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
|
||||
if (factor < 0.07 || factor > 100)
|
||||
return;
|
||||
|
||||
scale(scaleFactor, scaleFactor);
|
||||
}
|
||||
|
||||
//void GroupListView::setFreeze(bool freeze)
|
||||
//{
|
||||
// mIsFrozen = freeze;
|
||||
//}
|
||||
//
|
||||
//bool GroupListView::isFrozen() const
|
||||
//{
|
||||
// return mIsFrozen;
|
||||
//}
|
74
retroshare-gui/src/gui/People/GroupListView.h
Normal file
74
retroshare-gui/src/gui/People/GroupListView.h
Normal file
@ -0,0 +1,74 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <QGraphicsView>
|
||||
#include <stdint.h>
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
||||
|
||||
class UIStateHelper;
|
||||
class IdentityItem ;
|
||||
|
||||
class GroupListView : public QGraphicsView, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static const uint32_t GLVIEW_IDLIST ;
|
||||
static const uint32_t GLVIEW_IDDETAILS ;
|
||||
static const uint32_t GLVIEW_REPLIST ;
|
||||
static const uint32_t GLVIEW_REFRESH ;
|
||||
|
||||
GroupListView(QWidget * = NULL);
|
||||
|
||||
void clearGraph() ;
|
||||
|
||||
// Derives from RsGxsUpdateBroadcastPage
|
||||
virtual void updateDisplay(bool) ;
|
||||
|
||||
virtual void itemMoved();
|
||||
|
||||
void setEdgeLength(uint32_t l) ;
|
||||
uint32_t edgeLength() const { return _edge_length ; }
|
||||
|
||||
void loadRequest(const TokenQueue * /*queue*/, const TokenRequest &req) ;
|
||||
void requestIdList() ;
|
||||
void insertIdList(uint32_t token) ;
|
||||
|
||||
protected slots:
|
||||
void forceRedraw() ;
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void drawBackground(QPainter *painter, const QRectF &rect);
|
||||
|
||||
void scaleView(qreal scaleFactor);
|
||||
|
||||
virtual void keyPressEvent(QKeyEvent *event);
|
||||
virtual void resizeEvent(QResizeEvent *e) ;
|
||||
|
||||
static QImage makeDefaultIcon(const RsGxsId& id) ;
|
||||
|
||||
private:
|
||||
int timerId;
|
||||
//Node *centerNode;
|
||||
bool mDeterminedBB ;
|
||||
bool mIsFrozen;
|
||||
|
||||
//std::vector<Node *> _groups ;
|
||||
//std::map<std::pair<NodeId,NodeId>,Edge *> _edges ;
|
||||
//std::map<std::string,QPointF> _node_cached_positions ;
|
||||
|
||||
uint32_t _edge_length ;
|
||||
float _friction_factor ;
|
||||
//NodeId _current_node ;
|
||||
|
||||
TokenQueue *mIdQueue;
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
std::map<RsGxsGroupId,IdentityItem *> _identity_items ;
|
||||
};
|
||||
|
217
retroshare-gui/src/gui/People/IdentityItem.cpp
Normal file
217
retroshare-gui/src/gui/People/IdentityItem.cpp
Normal file
@ -0,0 +1,217 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QMenu>
|
||||
#include <QStyle>
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
#include "IdentityItem.h"
|
||||
|
||||
#define IMAGE_MAKEFRIEND ""
|
||||
|
||||
IdentityItem *IdentityItem::_selected_node = NULL ;
|
||||
|
||||
IdentityItem::IdentityItem(const RsGxsIdGroup& group_info)
|
||||
: _group_info(group_info)
|
||||
{
|
||||
std::cerr << "Created identity item for id=" <<group_info.mMeta.mGroupId << std::endl;
|
||||
|
||||
// setFlag(ItemIsMovable);
|
||||
setAcceptHoverEvents(true) ;
|
||||
#if QT_VERSION >= 0x040600
|
||||
setFlag(ItemSendsGeometryChanges);
|
||||
#endif
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
_selected = false ;
|
||||
|
||||
mDeterminedBB = false ;
|
||||
mBBWidth = 40 ;
|
||||
}
|
||||
|
||||
void IdentityItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e)
|
||||
{
|
||||
std::cerr << "Object was entered!" << std::endl;
|
||||
_selected = true ;
|
||||
_selected_node = this ;
|
||||
|
||||
emit itemChanged() ;
|
||||
update() ;
|
||||
}
|
||||
void IdentityItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
||||
{
|
||||
std::cerr << "Object was left!" << std::endl;
|
||||
_selected = false ;
|
||||
_selected_node = NULL ;
|
||||
|
||||
emit itemChanged() ;
|
||||
update() ;
|
||||
}
|
||||
|
||||
|
||||
QRectF IdentityItem::boundingRect() const
|
||||
{
|
||||
static const bool mDeterminedBB = false ;
|
||||
static const int mBBWidth = 40 ;
|
||||
|
||||
return QRectF(-(int)IMG_SIZE/2-10, -(int)IMG_SIZE/2-10, (int)IMG_SIZE+20,(int)IMG_SIZE+35) ;
|
||||
}
|
||||
|
||||
//QPainterPath IdentityItem::shape() const
|
||||
//{
|
||||
// QPainterPath path;
|
||||
// path.addRect(-(int)IMG_SIZE, -(int)IMG_SIZE, 2*(int)IMG_SIZE, 2*(int)IMG_SIZE);
|
||||
// return path;
|
||||
//}
|
||||
|
||||
QImage IdentityItem::makeDefaultIcon(const RsGxsGroupId& id)
|
||||
{
|
||||
int S = 128 ;
|
||||
QImage pix(S,S,QImage::Format_RGB32) ;
|
||||
|
||||
uint64_t n = reinterpret_cast<const uint64_t*>(id.toByteArray())[0] ;
|
||||
|
||||
uint8_t a[8] ;
|
||||
for(int i=0;i<8;++i)
|
||||
{
|
||||
a[i] = n&0xff ;
|
||||
n >>= 8 ;
|
||||
}
|
||||
QColor val[16] = {
|
||||
QColor::fromRgb( 255, 110, 180),
|
||||
QColor::fromRgb( 238, 92, 66),
|
||||
QColor::fromRgb( 255, 127, 36),
|
||||
QColor::fromRgb( 255, 193, 193),
|
||||
QColor::fromRgb( 127, 255, 212),
|
||||
QColor::fromRgb( 0, 255, 255),
|
||||
QColor::fromRgb( 224, 255, 255),
|
||||
QColor::fromRgb( 199, 21, 133),
|
||||
QColor::fromRgb( 50, 205, 50),
|
||||
QColor::fromRgb( 107, 142, 35),
|
||||
QColor::fromRgb( 30, 144, 255),
|
||||
QColor::fromRgb( 95, 158, 160),
|
||||
QColor::fromRgb( 143, 188, 143),
|
||||
QColor::fromRgb( 233, 150, 122),
|
||||
QColor::fromRgb( 151, 255, 255),
|
||||
QColor::fromRgb( 162, 205, 90),
|
||||
};
|
||||
|
||||
int c1 = (a[0]^a[1]) & 0xf ;
|
||||
int c2 = (a[1]^a[2]) & 0xf ;
|
||||
int c3 = (a[2]^a[3]) & 0xf ;
|
||||
int c4 = (a[3]^a[4]) & 0xf ;
|
||||
|
||||
for(int i=0;i<S/2;++i)
|
||||
for(int j=0;j<S/2;++j)
|
||||
{
|
||||
float res1 = 0.0f ;
|
||||
float res2 = 0.0f ;
|
||||
float f = 1.70;
|
||||
|
||||
for(int k1=0;k1<4;++k1)
|
||||
for(int k2=0;k2<4;++k2)
|
||||
{
|
||||
res1 += cos( (2*M_PI*i/(float)S) * k1 * f) * (a[k1 ] & 0xf) + sin( (2*M_PI*j/(float)S) * k2 * f) * (a[k2 ] >> 4) + sin( (2*M_PI*i/(float)S) * k1 * f) * cos( (2*M_PI*j/(float)S) * k2 * f) * (a[k1+k2] >> 4) ;
|
||||
res2 += cos( (2*M_PI*i/(float)S) * k2 * f) * (a[k1+2] & 0xf) + sin( (2*M_PI*j/(float)S) * k1 * f) * (a[k2+1] >> 4) + sin( (2*M_PI*i/(float)S) * k2 * f) * cos( (2*M_PI*j/(float)S) * k1 * f) * (a[k1^k2] >> 4) ;
|
||||
}
|
||||
|
||||
uint32_t q = 0 ;
|
||||
if(res1 >= 0.0f) q += val[c1].rgb() ; else q += val[c2].rgb() ;
|
||||
if(res2 >= 0.0f) q += val[c3].rgb() ; else q += val[c4].rgb() ;
|
||||
|
||||
pix.setPixel( i, j, q) ;
|
||||
pix.setPixel( S-1-i, j, q) ;
|
||||
pix.setPixel( S-1-i, S-1-j, q) ;
|
||||
pix.setPixel( i, S-1-j, q) ;
|
||||
}
|
||||
return pix.scaled(IMG_SIZE,IMG_SIZE,Qt::KeepAspectRatio,Qt::SmoothTransformation) ;
|
||||
}
|
||||
|
||||
|
||||
void IdentityItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
|
||||
{
|
||||
static QColor type_color[4] = { QColor(Qt::yellow), QColor(Qt::green), QColor(Qt::cyan), QColor(Qt::black) } ;
|
||||
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(Qt::lightGray);
|
||||
//painter->drawEllipse(-7, -7, 20, 20);
|
||||
|
||||
QRadialGradient gradient(-10, -IMG_SIZE/3.0, IMG_SIZE*1.5);
|
||||
gradient.setColorAt(0.0f,Qt::lightGray) ;
|
||||
gradient.setColorAt(1.0f,Qt::darkGray) ;
|
||||
painter->setBrush(gradient);
|
||||
|
||||
if(_selected)
|
||||
painter->setOpacity(0.7) ;
|
||||
else
|
||||
painter->setOpacity(1.0) ;
|
||||
|
||||
painter->setPen(QPen(Qt::black, 0));
|
||||
|
||||
painter->drawRoundedRect(QRectF(-(int)IMG_SIZE/2-10, -(int)IMG_SIZE/2-10, 20+IMG_SIZE, 20+IMG_SIZE),20,15) ;
|
||||
painter->drawImage(QPoint(-(int)IMG_SIZE/2, -(int)IMG_SIZE/2), makeDefaultIcon(_group_info.mMeta.mGroupId)) ;
|
||||
//painter->drawRect(-(int)IMG_SIZE/2, -(int)IMG_SIZE/2, IMG_SIZE, IMG_SIZE);
|
||||
|
||||
//std::string desc_string = _group_info.mMeta.mGroupId.toStdString() ;
|
||||
std::string desc_string = _group_info.mMeta.mGroupName ;
|
||||
|
||||
painter->drawText(-8*desc_string.size()/2, IMG_SIZE/2+24, QString::fromUtf8(desc_string.c_str()));
|
||||
|
||||
if (!mDeterminedBB)
|
||||
{
|
||||
QRect textBox = painter->boundingRect(-10, 0, 400, 20, 0, QString::fromUtf8(desc_string.c_str()));
|
||||
mBBWidth = textBox.width();
|
||||
mDeterminedBB = true;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant IdentityItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
// switch (change) {
|
||||
// case ItemPositionHasChanged:
|
||||
// foreach (Edge *edge, edgeList)
|
||||
// edge->adjust();
|
||||
// graph->itemMoved();
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// };
|
||||
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
void IdentityItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
//_selected_node = this ;
|
||||
//graph->forceRedraw() ;
|
||||
}
|
||||
|
||||
update();
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
void IdentityItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
QMenu contextMnu ;
|
||||
|
||||
//if(_type == GraphWidget::ELASTIC_NODE_TYPE_FRIEND)
|
||||
// contextMnu.addAction(QIcon(IMAGE_DENIED), QObject::tr( "Deny friend" ), this, SLOT(denyFriend()) );
|
||||
//else if(_type != GraphWidget::ELASTIC_NODE_TYPE_OWN)
|
||||
// contextMnu.addAction(QIcon(IMAGE_MAKEFRIEND), QObject::tr( "Make friend" ), this, SLOT(makeFriend()) );
|
||||
|
||||
contextMnu.addAction(QIcon(IMAGE_MAKEFRIEND), QObject::tr( "Peer details" ), this, SLOT(peerDetails()) );
|
||||
|
||||
contextMnu.exec(event->screenPos());
|
||||
}
|
||||
|
||||
void IdentityItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
//_selected_node = NULL ;
|
||||
//graph->forceRedraw() ;
|
||||
|
||||
update();
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
|
43
retroshare-gui/src/gui/People/IdentityItem.h
Normal file
43
retroshare-gui/src/gui/People/IdentityItem.h
Normal file
@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <QGraphicsItem>
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
class IdentityItem: public QObject, public QGraphicsItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IdentityItem(const RsGxsIdGroup& gxs_group_info) ;
|
||||
|
||||
QRectF boundingRect() const ;
|
||||
//QPainterPath shape() const ;
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) ;
|
||||
|
||||
static QImage makeDefaultIcon(const RsGxsGroupId& id) ;
|
||||
|
||||
static const int IMG_SIZE = 64;
|
||||
static IdentityItem *_selected_node ;
|
||||
|
||||
const RsGxsIdGroup& groupInfo() const { return _group_info ; }
|
||||
signals:
|
||||
void itemChanged() ;
|
||||
|
||||
private:
|
||||
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *e);
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *e);
|
||||
virtual QVariant itemChange(GraphicsItemChange change,const QVariant& value) ;
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *) ;
|
||||
|
||||
RsGxsIdGroup _group_info ;
|
||||
|
||||
bool mDeterminedBB;
|
||||
bool mBBWidth;
|
||||
bool _selected ;
|
||||
};
|
||||
|
605
retroshare-gui/src/gui/People/PeopleDialog.cpp
Normal file
605
retroshare-gui/src/gui/People/PeopleDialog.cpp
Normal file
@ -0,0 +1,605 @@
|
||||
/*
|
||||
* Retroshare Identity.
|
||||
*
|
||||
* Copyright 2014-2014 by Cyril Soler
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare.project@gmail.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "PeopleDialog.h"
|
||||
#include "gui/gxs/GxsIdTreeWidgetItem.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/******
|
||||
* #define ID_DEBUG 1
|
||||
*****/
|
||||
|
||||
// Data Requests.
|
||||
#define IDDIALOG_IDLIST 1
|
||||
#define IDDIALOG_IDDETAILS 2
|
||||
#define IDDIALOG_REPLIST 3
|
||||
#define IDDIALOG_REFRESH 4
|
||||
|
||||
/****************************************************************
|
||||
*/
|
||||
|
||||
#define RSID_COL_NICKNAME 0
|
||||
#define RSID_COL_KEYID 1
|
||||
#define RSID_COL_IDTYPE 2
|
||||
|
||||
#define RSIDREP_COL_NAME 0
|
||||
#define RSIDREP_COL_OPINION 1
|
||||
#define RSIDREP_COL_COMMENT 2
|
||||
#define RSIDREP_COL_REPUTATION 3
|
||||
|
||||
#define RSID_FILTER_YOURSELF 0x0001
|
||||
#define RSID_FILTER_FRIENDS 0x0002
|
||||
#define RSID_FILTER_OTHERS 0x0004
|
||||
#define RSID_FILTER_PSEUDONYMS 0x0008
|
||||
#define RSID_FILTER_ALL 0xffff
|
||||
|
||||
/** Constructor */
|
||||
PeopleDialog::PeopleDialog(QWidget *parent)
|
||||
: RsGxsUpdateBroadcastPage(rsIdentity, parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
#if 0
|
||||
/* Setup UI helper */
|
||||
mStateHelper = new UIStateHelper(this);
|
||||
mStateHelper->addWidget(IDDIALOG_IDLIST, ui.treeWidget_IdList);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDLIST, ui.treeWidget_IdList, false);
|
||||
mStateHelper->addClear(IDDIALOG_IDLIST, ui.treeWidget_IdList);
|
||||
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.toolButton_Reputation);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.toolButton_Delete);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.toolButton_EditId);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingOwn);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.line_RatingPeers);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repModButton);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_Accept);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_Ban);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_Negative);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_Positive);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_Custom);
|
||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui.repMod_spinBox);
|
||||
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingOwn);
|
||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDDETAILS, ui.line_RatingPeers);
|
||||
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_Nickname);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_KeyId);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgHash);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgId);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.lineEdit_GpgName);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingOverall);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingImplicit);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingOwn);
|
||||
mStateHelper->addClear(IDDIALOG_IDDETAILS, ui.line_RatingPeers);
|
||||
|
||||
//mStateHelper->addWidget(IDDIALOG_REPLIST, ui.treeWidget_RepList);
|
||||
//mStateHelper->addLoadPlaceholder(IDDIALOG_REPLIST, ui.treeWidget_RepList);
|
||||
//mStateHelper->addClear(IDDIALOG_REPLIST, ui.treeWidget_RepList);
|
||||
|
||||
/* Connect signals */
|
||||
connect(ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(addIdentity()));
|
||||
connect(ui.todoPushButton, SIGNAL(clicked()), this, SLOT(todo()));
|
||||
connect(ui.toolButton_EditId, SIGNAL(clicked()), this, SLOT(editIdentity()));
|
||||
connect(ui.treeWidget_IdList, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelection()));
|
||||
|
||||
connect(ui.filterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterComboBoxChanged()));
|
||||
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||
connect(ui.repModButton, SIGNAL(clicked()), this, SLOT(modifyReputation()));
|
||||
|
||||
/* Add filter types */
|
||||
ui.filterComboBox->addItem(tr("All"), RSID_FILTER_ALL);
|
||||
ui.filterComboBox->addItem(tr("Yourself"), RSID_FILTER_YOURSELF);
|
||||
ui.filterComboBox->addItem(tr("Friends / Friends of Friends"), RSID_FILTER_FRIENDS);
|
||||
ui.filterComboBox->addItem(tr("Others"), RSID_FILTER_OTHERS);
|
||||
ui.filterComboBox->addItem(tr("Pseudonyms"), RSID_FILTER_PSEUDONYMS);
|
||||
ui.filterComboBox->setCurrentIndex(0);
|
||||
|
||||
/* Add filter actions */
|
||||
QTreeWidgetItem *headerItem = ui.treeWidget_IdList->headerItem();
|
||||
QString headerText = headerItem->text(RSID_COL_NICKNAME);
|
||||
ui.filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText));
|
||||
headerText = headerItem->text(RSID_COL_KEYID);
|
||||
ui.filterLineEdit->addFilter(QIcon(), headerItem->text(RSID_COL_KEYID), RSID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText));
|
||||
|
||||
/* Setup tree */
|
||||
ui.treeWidget_IdList->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||
|
||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||
|
||||
// Hiding RepList until that part is finished.
|
||||
//ui.treeWidget_RepList->setVisible(false);
|
||||
ui.toolButton_Reputation->setVisible(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PeopleDialog::updateDisplay(bool /*complete*/)
|
||||
{
|
||||
/* Update identity list */
|
||||
circles_view->requestIdList();
|
||||
}
|
||||
|
||||
#if 0
|
||||
void IdDialog::todo()
|
||||
{
|
||||
QMessageBox::information(this, "Todo",
|
||||
"<b>Open points:</b><ul>"
|
||||
"<li>Delete ID"
|
||||
"<li>Reputation"
|
||||
"<li>Load/save settings"
|
||||
"</ul>");
|
||||
}
|
||||
|
||||
void IdDialog::filterComboBoxChanged()
|
||||
{
|
||||
requestIdList();
|
||||
}
|
||||
|
||||
void IdDialog::filterChanged(const QString& /*text*/)
|
||||
{
|
||||
filterIds();
|
||||
}
|
||||
|
||||
void IdDialog::updateSelection()
|
||||
{
|
||||
QTreeWidgetItem *item = ui.treeWidget_IdList->currentItem();
|
||||
RsGxsGroupId id;
|
||||
|
||||
if (item)
|
||||
{
|
||||
id = RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString());
|
||||
}
|
||||
|
||||
requestIdDetails(id);
|
||||
}
|
||||
|
||||
bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept)
|
||||
{
|
||||
bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) || (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
||||
|
||||
/* do filtering */
|
||||
bool ok = false;
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
{
|
||||
if (isOwnId && (accept & RSID_FILTER_YOURSELF))
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
if (accept & RSID_FILTER_FRIENDS)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (accept & RSID_FILTER_OTHERS)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (accept & RSID_FILTER_PSEUDONYMS)
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (isOwnId && (accept & RSID_FILTER_YOURSELF))
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!item)
|
||||
{
|
||||
item = new QTreeWidgetItem();
|
||||
}
|
||||
item->setText(RSID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str()));
|
||||
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId.toStdString()));
|
||||
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
{
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
RsPeerDetails details;
|
||||
rsPeers->getGPGDetails(data.mPgpId, details);
|
||||
item->setText(RSID_COL_IDTYPE, QString::fromUtf8(details.name.c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setText(RSID_COL_IDTYPE, tr("PGP Linked Id"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setText(RSID_COL_IDTYPE, tr("Anon Id"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void IdDialog::requestIdDetails(RsGxsGroupId &id)
|
||||
{
|
||||
mIdQueue->cancelActiveRequestTokens(IDDIALOG_IDDETAILS);
|
||||
|
||||
if (id.isNull())
|
||||
{
|
||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->setLoading(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->clear(IDDIALOG_IDDETAILS);
|
||||
mStateHelper->clear(IDDIALOG_REPLIST);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setLoading(IDDIALOG_IDDETAILS, true);
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, true);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
uint32_t token;
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(id);
|
||||
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_IDDETAILS);
|
||||
}
|
||||
|
||||
void IdDialog::insertIdDetails(uint32_t token)
|
||||
{
|
||||
mStateHelper->setLoading(IDDIALOG_IDDETAILS, false);
|
||||
|
||||
/* get details from libretroshare */
|
||||
RsGxsIdGroup data;
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
if (!rsIdentity->getGroupData(token, datavector))
|
||||
{
|
||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->clear(IDDIALOG_IDDETAILS);
|
||||
mStateHelper->clear(IDDIALOG_REPLIST);
|
||||
|
||||
ui.lineEdit_KeyId->setText("ERROR GETTING KEY!");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (datavector.size() != 1)
|
||||
{
|
||||
std::cerr << "IdDialog::insertIdDetails() Invalid datavector size";
|
||||
|
||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->clear(IDDIALOG_IDDETAILS);
|
||||
mStateHelper->clear(IDDIALOG_REPLIST);
|
||||
|
||||
ui.lineEdit_KeyId->setText("INVALID DV SIZE");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, true);
|
||||
|
||||
data = datavector[0];
|
||||
|
||||
/* get GPG Details from rsPeers */
|
||||
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
|
||||
|
||||
ui.lineEdit_Nickname->setText(QString::fromUtf8(data.mMeta.mGroupName.c_str()));
|
||||
ui.lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId.toStdString()));
|
||||
ui.lineEdit_GpgHash->setText(QString::fromStdString(data.mPgpIdHash.toStdString()));
|
||||
ui.lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId.toStdString()));
|
||||
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
RsPeerDetails details;
|
||||
rsPeers->getGPGDetails(data.mPgpId, details);
|
||||
ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
{
|
||||
ui.lineEdit_GpgName->setText(tr("Unknown real name"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.lineEdit_GpgName->setText(tr("Anonymous Id"));
|
||||
}
|
||||
}
|
||||
|
||||
bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) || (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
||||
|
||||
if (isOwnId)
|
||||
{
|
||||
ui.radioButton_IdYourself->setChecked(true);
|
||||
}
|
||||
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
{
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
if (rsPeers->isGPGAccepted(data.mPgpId))
|
||||
{
|
||||
ui.radioButton_IdFriend->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.radioButton_IdFOF->setChecked(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.radioButton_IdOther->setChecked(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.radioButton_IdPseudo->setChecked(true);
|
||||
}
|
||||
|
||||
if (isOwnId)
|
||||
{
|
||||
mStateHelper->setWidgetEnabled(ui.toolButton_Reputation, false);
|
||||
// No Delete Ids yet!
|
||||
mStateHelper->setWidgetEnabled(ui.toolButton_Delete, /*true*/ false);
|
||||
mStateHelper->setWidgetEnabled(ui.toolButton_EditId, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No Reputation yet!
|
||||
mStateHelper->setWidgetEnabled(ui.toolButton_Reputation, /*true*/ false);
|
||||
mStateHelper->setWidgetEnabled(ui.toolButton_Delete, false);
|
||||
mStateHelper->setWidgetEnabled(ui.toolButton_EditId, false);
|
||||
}
|
||||
|
||||
/* now fill in the reputation information */
|
||||
ui.line_RatingOverall->setText("Overall Rating TODO");
|
||||
ui.line_RatingOwn->setText("Own Rating TODO");
|
||||
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
ui.line_RatingImplicit->setText("+50 Known PGP");
|
||||
}
|
||||
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
{
|
||||
ui.line_RatingImplicit->setText("+10 UnKnown PGP");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.line_RatingImplicit->setText("+5 Anon Id");
|
||||
}
|
||||
|
||||
{
|
||||
QString rating = QString::number(data.mReputation.mOverallScore);
|
||||
ui.line_RatingOverall->setText(rating);
|
||||
}
|
||||
|
||||
{
|
||||
QString rating = QString::number(data.mReputation.mIdScore);
|
||||
ui.line_RatingImplicit->setText(rating);
|
||||
}
|
||||
|
||||
{
|
||||
QString rating = QString::number(data.mReputation.mOwnOpinion);
|
||||
ui.line_RatingOwn->setText(rating);
|
||||
}
|
||||
|
||||
{
|
||||
QString rating = QString::number(data.mReputation.mPeerOpinion);
|
||||
ui.line_RatingPeers->setText(rating);
|
||||
}
|
||||
|
||||
/* request network ratings */
|
||||
// Removing this for the moment.
|
||||
// requestRepList(data.mMeta.mGroupId);
|
||||
}
|
||||
|
||||
void IdDialog::modifyReputation()
|
||||
{
|
||||
std::cerr << "IdDialog::modifyReputation()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsGxsId id(ui.lineEdit_KeyId->text().toStdString());
|
||||
|
||||
int mod = 0;
|
||||
if (ui.repMod_Accept->isChecked())
|
||||
{
|
||||
mod += 100;
|
||||
}
|
||||
else if (ui.repMod_Positive->isChecked())
|
||||
{
|
||||
mod += 10;
|
||||
}
|
||||
else if (ui.repMod_Negative->isChecked())
|
||||
{
|
||||
mod += -10;
|
||||
}
|
||||
else if (ui.repMod_Ban->isChecked())
|
||||
{
|
||||
mod += -100;
|
||||
}
|
||||
else if (ui.repMod_Custom->isChecked())
|
||||
{
|
||||
mod += ui.repMod_spinBox->value();
|
||||
}
|
||||
else
|
||||
{
|
||||
// invalid
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr << "IdDialog::modifyReputation() ID: " << id << " Mod: " << mod;
|
||||
std::cerr << std::endl;
|
||||
|
||||
uint32_t token;
|
||||
if (!rsIdentity->submitOpinion(token, id, false, mod))
|
||||
{
|
||||
std::cerr << "IdDialog::modifyReputation() Error submitting Opinion";
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
|
||||
std::cerr << "IdDialog::modifyReputation() queuingRequest(), token: " << token;
|
||||
std::cerr << std::endl;
|
||||
|
||||
// trigger refresh when finished.
|
||||
// basic / anstype are not needed.
|
||||
mIdQueue->queueRequest(token, 0, 0, IDDIALOG_REFRESH);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void IdDialog::addIdentity()
|
||||
{
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupNewId(false);
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
void IdDialog::editIdentity()
|
||||
{
|
||||
QTreeWidgetItem *item = ui.treeWidget_IdList->currentItem();
|
||||
if (!item)
|
||||
{
|
||||
std::cerr << "IdDialog::editIdentity() Invalid item";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
|
||||
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupExistingId(keyId);
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
void IdDialog::filterIds()
|
||||
{
|
||||
int filterColumn = ui.filterLineEdit->currentFilter();
|
||||
QString text = ui.filterLineEdit->text();
|
||||
|
||||
ui.treeWidget_IdList->filterItems(filterColumn, text);
|
||||
}
|
||||
|
||||
void IdDialog::requestRepList(const RsGxsGroupId &aboutId)
|
||||
{
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, true);
|
||||
|
||||
mIdQueue->cancelActiveRequestTokens(IDDIALOG_REPLIST);
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(aboutId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
uint32_t token;
|
||||
mIdQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_REPLIST);
|
||||
}
|
||||
|
||||
void IdDialog::insertRepList(uint32_t token)
|
||||
{
|
||||
mStateHelper->setLoading(IDDIALOG_REPLIST, false);
|
||||
#if 0
|
||||
|
||||
std::vector<RsGxsIdOpinion> opinions;
|
||||
std::vector<RsGxsIdOpinion>::iterator vit;
|
||||
if (!rsIdentity->getMsgData(token, opinions))
|
||||
{
|
||||
std::cerr << "IdDialog::insertRepList() Error getting Opinions";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||
mStateHelper->clear(IDDIALOG_REPLIST);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for(vit = opinions.begin(); vit != opinions.end(); vit++)
|
||||
{
|
||||
RsGxsIdOpinion &op = (*vit);
|
||||
GxsIdTreeWidgetItem *item = new GxsIdTreeWidgetItem();
|
||||
|
||||
/* insert 4 columns */
|
||||
|
||||
/* friend name */
|
||||
item->setId(op.mMeta.mAuthorId, RSIDREP_COL_NAME);
|
||||
|
||||
/* score */
|
||||
item->setText(RSIDREP_COL_OPINION, QString::number(op.getOpinion()));
|
||||
|
||||
/* comment */
|
||||
item->setText(RSIDREP_COL_COMMENT, QString::fromUtf8(op.mComment.c_str()));
|
||||
|
||||
/* local reputation */
|
||||
item->setText(RSIDREP_COL_REPUTATION, QString::number(op.getReputation()));
|
||||
|
||||
ui.treeWidget_RepList->addTopLevelItem(item);
|
||||
}
|
||||
#endif
|
||||
mStateHelper->setActive(IDDIALOG_REPLIST, true);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
46
retroshare-gui/src/gui/People/PeopleDialog.h
Normal file
46
retroshare-gui/src/gui/People/PeopleDialog.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Retroshare Identity.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
|
||||
#include "ui_PeopleDialog.h"
|
||||
|
||||
class UIStateHelper;
|
||||
|
||||
class PeopleDialog : public RsGxsUpdateBroadcastPage, public Ui::PeopleDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PeopleDialog(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
virtual void updateDisplay(bool complete);
|
||||
|
||||
};
|
||||
|
142
retroshare-gui/src/gui/People/PeopleDialog.ui
Normal file
142
retroshare-gui/src/gui/People/PeopleDialog.ui
Normal file
@ -0,0 +1,142 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PeopleDialog</class>
|
||||
<widget class="QWidget" name="PeopleDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>913</width>
|
||||
<height>524</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QFrame" name="titleBarFrame_2">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="titleBarPixmap_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../images.qrc">:/images/identity/identities_32.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="titleBarLabel_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Circles</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="titleBarSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_NewId_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Create new Identity</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New ID</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/identity/identity_create_32.png</normaloff>:/images/identity/identity_create_32.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="GroupListView" name="circles_view"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>GroupListView</class>
|
||||
<extends>QGraphicsView</extends>
|
||||
<header>gui/People/GroupListView.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -1072,7 +1072,15 @@ thewire {
|
||||
gui/TheWire/PulseAddDialog.cpp \
|
||||
|
||||
}
|
||||
|
||||
|
||||
HEADERS += gui/People/PeopleDialog.h
|
||||
HEADERS += gui/People/IdentityItem.h
|
||||
HEADERS += gui/People/GroupListView.h
|
||||
FORMS += gui/People/PeopleDialog.ui
|
||||
SOURCES += gui/People/PeopleDialog.cpp
|
||||
SOURCES += gui/People/GroupListView.cpp
|
||||
SOURCES += gui/People/IdentityItem.cpp
|
||||
|
||||
identities {
|
||||
|
||||
HEADERS += \
|
||||
|
Loading…
Reference in New Issue
Block a user