From 0769dabb2e61b00d743f1263654fefe9b5a70267 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 8 Sep 2015 22:40:35 -0400 Subject: [PATCH] incorporated defnax changes --- .../src/gui/People/IdentityWidget.cpp | 409 ++-- .../src/gui/People/IdentityWidget.ui | 290 +-- .../src/gui/People/PeopleDialog.cpp | 1975 +++++++++-------- retroshare-gui/src/gui/People/PeopleDialog.h | 214 +- retroshare-gui/src/gui/People/PeopleDialog.ui | 524 +++-- 5 files changed, 1767 insertions(+), 1645 deletions(-) diff --git a/retroshare-gui/src/gui/People/IdentityWidget.cpp b/retroshare-gui/src/gui/People/IdentityWidget.cpp index 35b464069..515cf4c6f 100644 --- a/retroshare-gui/src/gui/People/IdentityWidget.cpp +++ b/retroshare-gui/src/gui/People/IdentityWidget.cpp @@ -1,199 +1,210 @@ -#include "gui/People/IdentityWidget.h" -#include "ui_IdentityWidget.h" - -#include "gui/common/AvatarDefs.h" -#include - -#include -#include -#include - -IdentityWidget::IdentityWidget(QString name/*=QString()*/, QWidget *parent/*=0*/) : - FlowLayoutItem(name, parent), - ui(new Ui::IdentityWidget) -{ - ui->setupUi(this); - _haveGXSId = false; - _havePGPDetail = false; - - m_myName = name; - ui->labelName->setText(m_myName); - ui->labelName->setToolTip(m_myName); - QFont font = ui->labelName->font(); - font.setItalic(false); - ui->labelName->setFont(font); - - _keyId=""; - ui->labelKeyId->setText(_keyId); - ui->labelKeyId->setToolTip(_keyId); - ui->labelKeyId->setVisible(false); - - ui->labelGXSId->setText(_keyId); - ui->labelGXSId->setToolTip(_keyId); - ui->labelGXSId->setVisible(false); - - ui->pbAdd->setVisible(false); - QObject::connect(ui->pbAdd, SIGNAL(clicked()), this, SLOT(pbAdd_clicked())); - - _scene = new QGraphicsScene(this); - ui->graphicsView->setScene(_scene); - - //To grab events - ui->graphicsView->setEnabled(false); - - ui->graphicsView->setAlignment(Qt::AlignLeft | Qt::AlignTop); - - setIsCurrent(false); - setIsSelected(false); - setAcceptDrops(true); -} - -IdentityWidget::~IdentityWidget() -{ - delete _scene; - delete ui; -} - -void IdentityWidget::updateData(const RsGxsIdGroup &gxs_group_info) -{ - //if (_group_info != gxs_group_info) { - _group_info = gxs_group_info; - _haveGXSId = true; - - m_myName = QString::fromUtf8(_group_info.mMeta.mGroupName.c_str()); - ui->labelName->setText(m_myName); - if (_havePGPDetail) { - ui->labelName->setToolTip(tr("GXS name:").append(" "+m_myName).append("\n") - .append(tr("PGP name:").append(" "+_nickname))); - } else {//if (m_myName != _nickname) - ui->labelName->setToolTip(tr("GXS name:").append(" "+m_myName)); - }//else (m_myName != _nickname) - - - _gxsId = QString::fromStdString(_group_info.mMeta.mGroupId.toStdString()); - ui->labelGXSId->setText(_gxsId); - ui->labelGXSId->setToolTip(tr("GXS id:").append(" "+_gxsId)); - - if (!_havePGPDetail) { - QFont font = ui->labelName->font(); - font.setItalic(false); - ui->labelName->setFont(font); - - _keyId=QString::fromStdString(_group_info.mMeta.mGroupId.toStdString()); - ui->labelKeyId->setText(_keyId); - ui->labelKeyId->setToolTip(tr("GXS id:").append(" "+_keyId)); - ui->labelKeyId->setVisible(false); - - /// (TODO) Get real ident icon - QImage image = GxsIdDetails::makeDefaultIcon(RsGxsId(_group_info.mMeta.mGroupId)); - if (_avatar != image) { - _avatar = image; - _scene->clear(); - _scene->addPixmap(QPixmap::fromImage(image.scaled(ui->graphicsView->width(),ui->graphicsView->height()))); - emit imageUpdated(); - } - } -} - -void IdentityWidget::updateData(const RsPeerDetails &pgp_details) -{ - //if (_details != pgp_details) { - _details = pgp_details; - _havePGPDetail = true; - - _nickname = QString::fromUtf8(_details.name.c_str()); - if (!_haveGXSId) m_myName = _nickname; - ui->labelName->setText(m_myName); - if (_haveGXSId) { - ui->labelName->setToolTip(tr("GXS name:").append(" "+m_myName).append("\n") - .append(tr("PGP name:").append(" "+_nickname))); - } else {//if (m_myName != _nickname) - ui->labelName->setToolTip(tr("PGP name:").append(" "+_nickname)); - }//else (m_myName != _nickname) - - QFont font = ui->labelName->font(); - font.setItalic(true); - ui->labelName->setFont(font); - - _keyId = QString::fromStdString(_details.gpg_id.toStdString()); - ui->labelKeyId->setText(_keyId); - ui->labelKeyId->setToolTip(tr("PGP id:").append(" "+_keyId)); - - QPixmap avatar; - AvatarDefs::getAvatarFromGpgId(_details.gpg_id, avatar); - if (_avatar != avatar.toImage()) - { - _avatar = avatar.toImage(); - _scene->clear(); - _scene->addPixmap(avatar.scaled(ui->graphicsView->width(),ui->graphicsView->height())); - emit imageUpdated(); - } -} - -void IdentityWidget::updateData(const RsGxsIdGroup &gxs_group_info, const RsPeerDetails &pgp_details) -{ - updateData(gxs_group_info); - updateData(pgp_details); -} - -QSize IdentityWidget::sizeHint() -{ - QSize size; - size.setHeight(ui->graphicsView->size().height() + ui->labelName->size().height()); - size.setWidth(ui->graphicsView->size().width() > ui->labelName->size().width() - ?ui->graphicsView->size().width() : ui->labelName->size().width()); - return size; -} - -const QPixmap IdentityWidget::getImage() -{ -#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) - return ui->graphicsView->grab(); - //return this->grab(); //QT5 -#else - return QPixmap::grabWidget(ui->graphicsView); - //return QPixmap::grabWidget(this); -#endif -} - -const QPixmap IdentityWidget::getDragImage() -{ -#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) - return ui->graphicsView->grab(); - //return this->grab(); //QT5 -#else - return QPixmap::grabWidget(ui->graphicsView); - //return QPixmap::grabWidget(this); -#endif -} - -void IdentityWidget::setIsSelected(bool value) -{ - m_isSelected=value; - QFont font=ui->labelName->font(); - font.setBold(value); - ui->labelName->setFont(font); -} -/* -bool IdentityWidget::isSelected() -{ - return m_isSelected; -}*/ - -void IdentityWidget::setIsCurrent(bool value) -{ - m_isCurrent=value; - ui->labelKeyId->setVisible(value); - ui->labelGXSId->setVisible(value && (_haveGXSId && _havePGPDetail)); - ui->pbAdd->setVisible(value); -} -/* -bool IdentityWidget::isCurrent() -{ - return m_isCurrent; -}*/ - -void IdentityWidget::pbAdd_clicked() -{ - emit addButtonClicked(); -} +#include "gui/People/IdentityWidget.h" +#include "ui_IdentityWidget.h" + +#include "gui/common/AvatarDefs.h" +#include + +#include +#include +#include + +IdentityWidget::IdentityWidget(QString name/*=QString()*/, QWidget *parent/*=0*/) : + FlowLayoutItem(name, parent), + ui(new Ui::IdentityWidget) +{ + ui->setupUi(this); + _haveGXSId = false; + _havePGPDetail = false; + + m_myName = name; + ui->labelName->setText(m_myName); + ui->labelName->setToolTip(m_myName); + QFont font = ui->labelName->font(); + font.setItalic(false); + ui->labelName->setFont(font); + + _keyId=""; + ui->labelKeyId->setText(_keyId); + ui->labelKeyId->setToolTip(_keyId); + ui->labelKeyId->setVisible(false); + + ui->labelGXSId->setText(_keyId); + ui->labelGXSId->setToolTip(_keyId); + ui->labelGXSId->setVisible(false); + + ui->pbAdd->setVisible(false); + QObject::connect(ui->pbAdd, SIGNAL(clicked()), this, SLOT(pbAdd_clicked())); + + _scene = new QGraphicsScene(this); + ui->graphicsView->setScene(_scene); + + //To grab events + ui->graphicsView->setEnabled(false); + + ui->graphicsView->setAlignment(Qt::AlignLeft | Qt::AlignTop); + + setIsCurrent(false); + setIsSelected(false); + setAcceptDrops(true); +} + +IdentityWidget::~IdentityWidget() +{ + delete _scene; + delete ui; +} + +void IdentityWidget::updateData(const RsGxsIdGroup &gxs_group_info) +{ + //if (_group_info != gxs_group_info) { + _group_info = gxs_group_info; + _haveGXSId = true; + + m_myName = QString::fromUtf8(_group_info.mMeta.mGroupName.c_str()); + ui->labelName->setText(m_myName); + if (_havePGPDetail) { + ui->labelName->setToolTip(tr("GXS name:").append(" "+m_myName).append("\n") + .append(tr("PGP name:").append(" "+_nickname))); + } else {//if (m_myName != _nickname) + ui->labelName->setToolTip(tr("GXS name:").append(" "+m_myName)); + }//else (m_myName != _nickname) + + + _gxsId = QString::fromStdString(_group_info.mMeta.mGroupId.toStdString()); + ui->labelGXSId->setText(_gxsId); + ui->labelGXSId->setToolTip(tr("GXS id:").append(" "+_gxsId)); + + if (!_havePGPDetail) { + QFont font = ui->labelName->font(); + font.setItalic(false); + ui->labelName->setFont(font); + + _keyId=QString::fromStdString(_group_info.mMeta.mGroupId.toStdString()); + ui->labelKeyId->setText(_keyId); + ui->labelKeyId->setToolTip(tr("GXS id:").append(" "+_keyId)); + ui->labelKeyId->setVisible(false); + + /// (TODO) Get real ident icon + QImage image; + + if(_group_info.mImage.mSize > 0 && image.loadFromData(_group_info.mImage.mData, _group_info.mImage.mSize, "PNG")) + image = image; + else + image = GxsIdDetails::makeDefaultIcon(RsGxsId(_group_info.mMeta.mGroupId)); + + if (_avatar != image) { + _avatar = image; + _scene->clear(); + _scene->addPixmap(QPixmap::fromImage(image.scaled(ui->graphicsView->width(),ui->graphicsView->height()))); + emit imageUpdated(); + }//if (_avatar != image) + }//if (!_havePGPDetail) + + //}//if (_group_info != gxs_group_info) +} + +void IdentityWidget::updateData(const RsPeerDetails &pgp_details) +{ + //if (_details != pgp_details) { + _details = pgp_details; + _havePGPDetail = true; + + _nickname = QString::fromUtf8(_details.name.c_str()); + if (!_haveGXSId) m_myName = _nickname; + ui->labelName->setText(m_myName); + if (_haveGXSId) { + ui->labelName->setToolTip(tr("GXS name:").append(" "+m_myName).append("\n") + .append(tr("PGP name:").append(" "+_nickname))); + } else {//if (m_myName != _nickname) + ui->labelName->setToolTip(tr("PGP name:").append(" "+_nickname)); + }//else (m_myName != _nickname) + + QFont font = ui->labelName->font(); + font.setItalic(true); + ui->labelName->setFont(font); + + _keyId = QString::fromStdString(_details.gpg_id.toStdString()); + ui->labelKeyId->setText(_keyId); + ui->labelKeyId->setToolTip(tr("PGP id:").append(" "+_keyId)); + + QPixmap avatar; + /*AvatarDefs::getAvatarFromGpgId(_details.gpg_id, avatar); + if (_avatar != avatar.toImage()) { + _avatar = avatar.toImage(); + _scene->clear(); + _scene->addPixmap(avatar.scaled(ui->graphicsView->width(),ui->graphicsView->height())); + emit imageUpdated(); + }*///if (_avatar != avatar.toImage()) + + + //}//if (_details != gpg_details) +} + +void IdentityWidget::updateData(const RsGxsIdGroup &gxs_group_info, const RsPeerDetails &pgp_details) +{ + updateData(gxs_group_info); + updateData(pgp_details); +} + +QSize IdentityWidget::sizeHint() +{ + QSize size; + size.setHeight(ui->graphicsView->size().height() + ui->labelName->size().height()); + size.setWidth(ui->graphicsView->size().width() > ui->labelName->size().width() + ?ui->graphicsView->size().width() : ui->labelName->size().width()); + return size; +} + +const QPixmap IdentityWidget::getImage() +{ +#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) + return ui->graphicsView->grab(); + //return this->grab(); //QT5 +#else + return QPixmap::grabWidget(ui->graphicsView); + //return QPixmap::grabWidget(this); +#endif +} + +const QPixmap IdentityWidget::getDragImage() +{ +#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) + return ui->graphicsView->grab(); + //return this->grab(); //QT5 +#else + return QPixmap::grabWidget(ui->graphicsView); + //return QPixmap::grabWidget(this); +#endif +} + +void IdentityWidget::setIsSelected(bool value) +{ + m_isSelected=value; + QFont font=ui->labelName->font(); + font.setBold(value); + ui->labelName->setFont(font); +} +/* +bool IdentityWidget::isSelected() +{ + return m_isSelected; +}*/ + +void IdentityWidget::setIsCurrent(bool value) +{ + m_isCurrent=value; + ui->labelKeyId->setVisible(value); + ui->labelGXSId->setVisible(value && (_haveGXSId && _havePGPDetail)); + ui->pbAdd->setVisible(value); +} +/* +bool IdentityWidget::isCurrent() +{ + return m_isCurrent; +}*/ + +void IdentityWidget::pbAdd_clicked() +{ + emit addButtonClicked(); +} + diff --git a/retroshare-gui/src/gui/People/IdentityWidget.ui b/retroshare-gui/src/gui/People/IdentityWidget.ui index 27a6a6610..9a9ed0e90 100644 --- a/retroshare-gui/src/gui/People/IdentityWidget.ui +++ b/retroshare-gui/src/gui/People/IdentityWidget.ui @@ -1,144 +1,146 @@ - - - IdentityWidget - - - - 0 - 0 - 102 - 158 - - - - - 0 - - - 1 - - - - - - 100 - 100 - - - - - 100 - 100 - - - - QFrame::NoFrame - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - - 0.000000000000000 - 0.000000000000000 - 100.000000000000000 - 100.000000000000000 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - 15 - - - - - 100 - 16777215 - - - - Name - - - true - - - Qt::AlignCenter - - - - - - - - 0 - 15 - - - - - 100 - 16777215 - - - - KeyId - - - Qt::AlignCenter - - - - - - - - 0 - 15 - - - - - 100 - 16777215 - - - - GXSId - - - Qt::AlignCenter - - - - - - - Add - - - - - - - - - ElidedLabel - QLabel -
gui/common/ElidedLabel.h
- 1 -
-
- -
+ + + IdentityWidget + + + + 0 + 0 + 102 + 170 + + + + + 0 + + + 1 + + + + + + 100 + 100 + + + + + 100 + 100 + + + + QFrame::NoFrame + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + 0.000000000000000 + 0.000000000000000 + 100.000000000000000 + 100.000000000000000 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 15 + + + + + 100 + 16777215 + + + + Name + + + true + + + Qt::AlignCenter + + + + + + + + 0 + 15 + + + + + 100 + 16777215 + + + + KeyId + + + Qt::AlignCenter + + + + + + + + 0 + 15 + + + + + 100 + 16777215 + + + + GXSId + + + Qt::AlignCenter + + + + + + + Add + + + + + + + + ElidedLabel + QLabel +
gui/common/ElidedLabel.h
+ 1 +
+
+ + + + +
diff --git a/retroshare-gui/src/gui/People/PeopleDialog.cpp b/retroshare-gui/src/gui/People/PeopleDialog.cpp index e2289f987..11d295322 100644 --- a/retroshare-gui/src/gui/People/PeopleDialog.cpp +++ b/retroshare-gui/src/gui/People/PeopleDialog.cpp @@ -1,932 +1,1043 @@ -/* - * 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 "PeopleDialog.h" -#include "gui/Circles/CreateCircleDialog.h" -#include "gui/common/FlowLayout.h" -#include "gui/settings/rsharesettings.h" - -#include "retroshare/rspeers.h" -#include "retroshare/rsidentity.h" -#include "retroshare/rsgxscircles.h" -#include "retroshare/rsgxsflags.h" - -#include -#include -#include - -/****** - * #define PEOPLE_DIALOG_DEBUG 1 - *****/ - - -const uint32_t PeopleDialog::PD_IDLIST = 0x0001 ; -const uint32_t PeopleDialog::PD_IDDETAILS = 0x0002 ; -const uint32_t PeopleDialog::PD_REFRESH = 0x0003 ; -const uint32_t PeopleDialog::PD_CIRCLES = 0x0004 ; - -/** Constructor */ -PeopleDialog::PeopleDialog(QWidget *parent) - : RsGxsUpdateBroadcastPage(rsIdentity, parent) -{ - setupUi(this); - - /* Setup TokenQueue */ - mIdentityQueue = new TokenQueue(rsIdentity->getTokenService(), this); - mCirclesQueue = new TokenQueue(rsGxsCircles->getTokenService(), this); - - //need erase QtCreator Layout first(for Win) - delete idExternal->layout(); - delete idInternal->layout(); - //QT Designer don't accept Custom Layout, maybe on QT5 - _flowLayoutExt = new FlowLayout(idExternal); - _flowLayoutInt = new FlowLayout(idInternal); - - {//First Get Item created in Qt Designer for External - int count = idExternal->children().count(); - for (int curs = 0; curs < count; ++curs){ - QObject *obj = idExternal->children().at(curs); - QWidget *wid = qobject_cast(obj); - if (wid) _flowLayoutExt->addWidget(wid); - }//for (int curs = 0; curs < count; ++curs) - }//End First Get Item created in Qt Designer for External - - {//First Get Item created in Qt Designer for Internal - int count = idInternal->children().count(); - for (int curs = 0; curs < count; ++curs){ - QObject *obj = idInternal->children().at(curs); - QWidget *wid = qobject_cast(obj); - if (wid) _flowLayoutInt->addWidget(wid); - }//for (int curs = 0; curs < count; ++curs) - }//End First Get Item created in Qt Designer for Internal - - pictureFlowWidgetExternal->setAcceptDrops(true); - QObject::connect(pictureFlowWidgetExternal, SIGNAL(centerIndexChanged(int)), this, SLOT(pf_centerIndexChanged(int))); - QObject::connect(pictureFlowWidgetExternal, SIGNAL(mouseMoveOverSlideEvent(QMouseEvent*,int)), this, SLOT(pf_mouseMoveOverSlideEvent(QMouseEvent*,int))); - QObject::connect(pictureFlowWidgetExternal, SIGNAL(dragEnterEventOccurs(QDragEnterEvent*)), this, SLOT(pf_dragEnterEventOccurs(QDragEnterEvent*))); - QObject::connect(pictureFlowWidgetExternal, SIGNAL(dragMoveEventOccurs(QDragMoveEvent*)), this, SLOT(pf_dragMoveEventOccurs(QDragMoveEvent*))); - QObject::connect(pictureFlowWidgetExternal, SIGNAL(dropEventOccurs(QDropEvent*)), this, SLOT(pf_dropEventOccursExt(QDropEvent*))); - pictureFlowWidgetExternal->setMinimumHeight(60); - pictureFlowWidgetExternal->setSlideSizeRatio(4/4.0); - - pictureFlowWidgetInternal->setAcceptDrops(true); - QObject::connect(pictureFlowWidgetInternal, SIGNAL(centerIndexChanged(int)), this, SLOT(pf_centerIndexChanged(int))); - QObject::connect(pictureFlowWidgetInternal, SIGNAL(mouseMoveOverSlideEvent(QMouseEvent*,int)), this, SLOT(pf_mouseMoveOverSlideEvent(QMouseEvent*,int))); - QObject::connect(pictureFlowWidgetInternal, SIGNAL(dragEnterEventOccurs(QDragEnterEvent*)), this, SLOT(pf_dragEnterEventOccurs(QDragEnterEvent*))); - QObject::connect(pictureFlowWidgetInternal, SIGNAL(dragMoveEventOccurs(QDragMoveEvent*)), this, SLOT(pf_dragMoveEventOccurs(QDragMoveEvent*))); - QObject::connect(pictureFlowWidgetInternal, SIGNAL(dropEventOccurs(QDropEvent*)), this, SLOT(pf_dropEventOccursInt(QDropEvent*))); - pictureFlowWidgetInternal->setMinimumHeight(60); - pictureFlowWidgetInternal->setSlideSizeRatio(4/4.0); - - QByteArray geometryExt = Settings->valueFromGroup("PeopleDialog", "SplitterExtState", QByteArray()).toByteArray(); - if (geometryExt.isEmpty() == false) { - splitterExternal->restoreState(geometryExt); - } - QByteArray geometryInt = Settings->valueFromGroup("PeopleDialog", "SplitterIntState", QByteArray()).toByteArray(); - if (geometryInt.isEmpty() == false) { - splitterInternal->restoreState(geometryInt); - } -} - -/** Destructor. */ -PeopleDialog::~PeopleDialog() -{ - delete mIdentityQueue; - delete mCirclesQueue; - - Settings->setValueToGroup("PeopleDialog", "SplitterExtState", splitterExternal->saveState()); - Settings->setValueToGroup("PeopleDialog", "SplitterIntState", splitterInternal->saveState()); -} - -void PeopleDialog::updateDisplay(bool complete) -{ - Q_UNUSED(complete); - reloadAll(); -} - -void PeopleDialog::reloadAll() -{ - /* Update identity list */ - requestIdList(); - requestCirclesList(); - - /* grab all ids */ - std::list friend_pgpIds; - std::list all_pgpIds; - std::list::iterator it; - - std::set friend_set; - - rsPeers->getGPGAcceptedList(friend_pgpIds); - //rsPeers->getGPGAllList(all_pgpIds); - - - for(it = friend_pgpIds.begin(); it != friend_pgpIds.end(); ++it) { - RsPeerDetails details; - if(rsPeers->getGPGDetails(*it, details)){ - std::map::iterator itFound; - if((itFound=_pgp_identity_widgets.find(*it)) == _pgp_identity_widgets.end()) { - IdentityWidget *new_item = new IdentityWidget(); - new_item->updateData(details) ; - _pgp_identity_widgets[*it] = new_item ; - - QObject::connect(new_item, SIGNAL(addButtonClicked()), this, SLOT(iw_AddButtonClickedInt())); - QObject::connect(new_item, SIGNAL(flowLayoutItemDropped(QList,bool&)), this, SLOT(fl_flowLayoutItemDroppedInt(QList,bool&))); - _flowLayoutInt->addWidget(new_item); - } else {//if((itFound=_pgp_identity_widgets.find(gdItem.mPgpId)) == _pgp_identity_widgets.end()) - IdentityWidget *idWidget = itFound->second; - - idWidget->updateData(details) ; - }//else ((itFound=_pgp_identity_widgets.find(gdItem.mPgpId)) == _pgp_identity_widgets.end()) - - friend_set.insert(*it); - }//if(rsPeers->getGPGDetails(*it, details)) - }//for(it = friend_pgpIds.begin(); it != friend_pgpIds.end(); ++it) - - for(it = all_pgpIds.begin(); it != all_pgpIds.end(); ++it) { - if(friend_set.end() != friend_set.find(*it)) { - // already added as a friend. - continue; - }//if(friend_set.end() != friend_set.find(*it)) - - RsPeerDetails details; - if (rsPeers->getGPGDetails(*it, details)) { - std::map::iterator itFound; - if((itFound=_pgp_identity_widgets.find(*it)) == _pgp_identity_widgets.end()) { - IdentityWidget *new_item = new IdentityWidget(); - new_item->updateData(details) ; - _pgp_identity_widgets[*it] = new_item ; - - QObject::connect(new_item, SIGNAL(addButtonClicked()), this, SLOT(iw_AddButtonClickedInt())); - QObject::connect(new_item, SIGNAL(flowLayoutItemDropped(QList,bool&)), this, SLOT(fl_flowLayoutItemDroppedInt(QList,bool&))); - _flowLayoutInt->addWidget(new_item); - } else {//if((itFound=_pgp_identity_widgets.find(gdItem.mPgpId)) == _pgp_identity_widgets.end()) - IdentityWidget *idWidget = itFound->second; - - idWidget->updateData(details) ; - }//else ((itFound=_pgp_identity_widgets.find(gdItem.mPgpId)) == _pgp_identity_widgets.end()) - }//if(rsPeers->getGPGDetails(*it, details)) - }//for(it = all_pgpIds.begin(); it != all_pgpIds.end(); ++it) -} - -void PeopleDialog::insertIdList(uint32_t token) -{ - std::cerr << "**** In insertIdList() ****" << std::endl; - - std::vector gdataVector; - std::vector::iterator gdIt; - - if (!rsIdentity->getGroupData(token, gdataVector)) { - std::cerr << "PeopleDialog::insertIdList() Error getting GroupData"; - std::cerr << std::endl; - - return; - }//if (!rsIdentity->getGroupData(token, gdataVector)) - - //RsPgpId ownPgpId = rsPeers->getGPGOwnId(); - - /* Insert items */ - int i=0 ; - for (gdIt = gdataVector.begin(); gdIt != gdataVector.end(); ++gdIt){ - RsGxsIdGroup gdItem = (*gdIt); - bool bGotDetail = false; - - RsPeerDetails details; - if (gdItem.mPgpKnown) { - bGotDetail = rsPeers->getGPGDetails(gdItem.mPgpId, details); - }//if (gdItem.mPgpKnown) - - std::map::iterator itFound; - if((itFound=_gxs_identity_widgets.find(RsGxsId(gdItem.mMeta.mGroupId))) == _gxs_identity_widgets.end()) { - std::cerr << "Loading data vector identity GXS ID = " << gdItem.mMeta.mGroupId << ", i="<< i << std::endl; - - IdentityWidget *new_item = new IdentityWidget(); - if (bGotDetail) { - new_item->updateData(gdItem, details); - } else {//if (bGotDetail) - new_item->updateData(gdItem); - }//else (bGotDetail) - _gxs_identity_widgets[RsGxsId(gdItem.mMeta.mGroupId)] = new_item ; - - QObject::connect(new_item, SIGNAL(addButtonClicked()), this, SLOT(iw_AddButtonClickedExt())); - QObject::connect(new_item, SIGNAL(flowLayoutItemDropped(QList,bool&)), this, SLOT(fl_flowLayoutItemDroppedExt(QList,bool&))); - _flowLayoutExt->addWidget(new_item); - ++i ; - } else {//if((itFound=_gxs_identity_widgets.find(RsGxsId(gdItem.mMeta.mGroupId))) == _gxs_identity_widgets.end()) - - std::cerr << "Updating data vector identity GXS ID = " << gdItem.mMeta.mGroupId << std::endl; - IdentityWidget *idWidget = itFound->second; - - if (bGotDetail) { - idWidget->updateData(gdItem, details) ; - } else {//if (bGotDetail) - idWidget->updateData(gdItem) ; - }//else (bGotDetail) - - }//else ((itFound=_gxs_identity_widgets.find(RsGxsId(gdItem.mMeta.mGroupId))) == _gxs_identity_widgets.end())) - }//for (gdIt = gdataVector.begin(); gdIt != gdataVector.end(); ++gdIt) -} - -void PeopleDialog::insertCircles(uint32_t token) -{ - std::cerr << "PeopleDialog::insertExtCircles(token==" << token << ")" << std::endl; - - std::list gSummaryList; - std::list::iterator gsIt; - - if (!rsGxsCircles->getGroupSummary(token,gSummaryList)) { - std::cerr << "PeopleDialog::insertExtCircles() Error getting GroupSummary"; - std::cerr << std::endl; - - return; - }//if (!rsGxsCircles->getGroupSummary(token,gSummaryList)) - - for(gsIt = gSummaryList.begin(); gsIt != gSummaryList.end(); ++gsIt) { - RsGroupMetaData gsItem = (*gsIt); - - RsGxsCircleDetails details ; - if(!rsGxsCircles->getCircleDetails(RsGxsCircleId(gsItem.mGroupId), details)){ - std::cerr << "(EE) Cannot get details for circle id " << gsItem.mGroupId << ". Circle item is not created!" << std::endl; - continue ; - }//if(!rsGxsCircles->getCircleDetails(RsGxsCircleId(git->mGroupId), details)) - - if (!details.mIsExternal){ - std::map::iterator itFound; - if((itFound=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end()) { - std::cerr << "PeopleDialog::insertExtCircles() add new Internal GroupId: " << gsItem.mGroupId; - std::cerr << " GroupName: " << gsItem.mGroupName; - std::cerr << std::endl; - - CircleWidget *gitem = new CircleWidget() ; - QObject::connect(gitem, SIGNAL(flowLayoutItemDropped(QList,bool&)), this, SLOT(fl_flowLayoutItemDroppedInt(QList,bool&))); - QObject::connect(gitem, SIGNAL(askForGXSIdentityWidget(RsGxsId)), this, SLOT(cw_askForGXSIdentityWidget(RsGxsId))); - QObject::connect(gitem, SIGNAL(askForPGPIdentityWidget(RsPgpId)), this, SLOT(cw_askForPGPIdentityWidget(RsPgpId))); - QObject::connect(gitem, SIGNAL(imageUpdated()), this, SLOT(cw_imageUpdatedInt())); - gitem->updateData( gsItem, details ); - _int_circles_widgets[gsItem.mGroupId] = gitem ; - - _flowLayoutInt->addWidget(gitem); - - QPixmap pixmap = gitem->getImage(); - pictureFlowWidgetInternal->addSlide( pixmap ); - _intListCir << gitem; - } else {//if((itFound=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end()) - std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId; - std::cerr << " GroupName: " << gsItem.mGroupName; - std::cerr << std::endl; - - CircleWidget *cirWidget = itFound->second; - cirWidget->updateData( gsItem, details ); - - //int index = _intListCir.indexOf(cirWidget); - //QPixmap pixmap = cirWidget->getImage(); - //pictureFlowWidgetInternal->setSlide(index, pixmap); - }//if((item=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end()) - } else {//if (!details.mIsExternal) - std::map::iterator itFound; - if((itFound=_ext_circles_widgets.find(gsItem.mGroupId)) == _ext_circles_widgets.end()) { - std::cerr << "PeopleDialog::insertExtCircles() add new GroupId: " << gsItem.mGroupId; - std::cerr << " GroupName: " << gsItem.mGroupName; - std::cerr << std::endl; - - CircleWidget *gitem = new CircleWidget() ; - QObject::connect(gitem, SIGNAL(flowLayoutItemDropped(QList,bool&)), this, SLOT(fl_flowLayoutItemDroppedExt(QList,bool&))); - QObject::connect(gitem, SIGNAL(askForGXSIdentityWidget(RsGxsId)), this, SLOT(cw_askForGXSIdentityWidget(RsGxsId))); - QObject::connect(gitem, SIGNAL(askForPGPIdentityWidget(RsPgpId)), this, SLOT(cw_askForPGPIdentityWidget(RsPgpId))); - QObject::connect(gitem, SIGNAL(imageUpdated()), this, SLOT(cw_imageUpdatedExt())); - gitem->updateData( gsItem, details ); - _ext_circles_widgets[gsItem.mGroupId] = gitem ; - - _flowLayoutExt->addWidget(gitem); - - QPixmap pixmap = gitem->getImage(); - pictureFlowWidgetExternal->addSlide( pixmap ); - _extListCir << gitem; - } else {//if((itFound=_circles_widgets.find(gsItem.mGroupId)) == _circles_widgets.end()) - std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId; - std::cerr << " GroupName: " << gsItem.mGroupName; - std::cerr << std::endl; - - CircleWidget *cirWidget = itFound->second; - cirWidget->updateData( gsItem, details ); - - //int index = _extListCir.indexOf(cirWidget); - //QPixmap pixmap = cirWidget->getImage(); - //pictureFlowWidgetExternal->setSlide(index, pixmap); - }//if((item=_circles_items.find(gsItem.mGroupId)) == _circles_items.end()) - }//else (!details.mIsExternal) - }//for(gsIt = gSummaryList.begin(); gsIt != gSummaryList.end(); ++gsIt) -} - -void PeopleDialog::requestIdList() -{ - std::cerr << "Requesting ID list..." << std::endl; - - if (!mIdentityQueue) return; - - mIdentityQueue->cancelActiveRequestTokens(PD_IDLIST); - - RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; - - uint32_t token; - - mIdentityQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, PD_IDLIST); -} - -void PeopleDialog::requestCirclesList() -{ - std::cerr << "Requesting Circles list..." << std::endl; - - if (!mCirclesQueue) return; - - mCirclesQueue->cancelActiveRequestTokens(PD_CIRCLES); - - RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; - - uint32_t token; - mCirclesQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, PD_CIRCLES); -} - -void PeopleDialog::loadRequest(const TokenQueue * /*queue*/, const TokenRequest &req) -{ - std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType; - std::cerr << std::endl; - - switch(req.mUserType) { - case PD_IDLIST: - insertIdList(req.mToken); - break; - - case PD_IDDETAILS: - //insertIdDetails(req.mToken); - break; - - case PD_CIRCLES: - insertCircles(req.mToken); - break; - - case PD_REFRESH: - updateDisplay(true); - break; - default: - std::cerr << "IdDialog::loadRequest() ERROR"; - std::cerr << std::endl; - break; - }//switch(req.mUserType) -} - -void PeopleDialog::iw_AddButtonClickedExt() -{ - IdentityWidget *dest= - qobject_cast(QObject::sender()); - if (dest) { - QMenu contextMnu( this ); - - std::map::iterator itCurs; - for( itCurs =_ext_circles_widgets.begin(); - itCurs != _ext_circles_widgets.end(); - ++itCurs) { - CircleWidget *curs = itCurs->second; - QIcon icon = QIcon(curs->getImage()); - QString name = curs->getName(); - - QAction *action = contextMnu.addAction(icon, name, this, SLOT(addToCircleExt())); - action->setData(QString::fromStdString(curs->groupInfo().mGroupId.toStdString()) - + ";" + QString::fromStdString(dest->groupInfo().mMeta.mGroupId.toStdString())); - }//for( itCurs =_ext_circles_widgets.begin(); - - contextMnu.exec(QCursor::pos()); - }//if (dest) -} - -void PeopleDialog::iw_AddButtonClickedInt() -{ - IdentityWidget *dest= - qobject_cast(QObject::sender()); - if (dest) { - QMenu contextMnu( this ); - - std::map::iterator itCurs; - for( itCurs =_int_circles_widgets.begin(); - itCurs != _int_circles_widgets.end(); - ++itCurs) { - CircleWidget *curs = itCurs->second; - QIcon icon = QIcon(curs->getImage()); - QString name = curs->getName(); - - QAction *action = contextMnu.addAction(icon, name, this, SLOT(addToCircleInt())); - action->setData(QString::fromStdString(curs->groupInfo().mGroupId.toStdString()) - + ";" + QString::fromStdString(dest->details().gpg_id.toStdString())); - }//for( itCurs =_int_circles_widgets.begin(); - - contextMnu.exec(QCursor::pos()); - }//if (dest) -} - -void PeopleDialog::addToCircleExt() -{ - QAction *action = - qobject_cast(QObject::sender()); - if (action) { - QString data = action->data().toString(); - QStringList idList = data.split(";"); - - RsGxsGroupId groupId = RsGxsGroupId(idList.at(0).toStdString()); - std::map::iterator itCirFound; - if((itCirFound=_ext_circles_widgets.find(groupId)) != _ext_circles_widgets.end()) { - CircleWidget *circle = itCirFound->second; - CreateCircleDialog dlg; - dlg.addCircle(circle->circleDetails()); - - RsGxsId gxs_id = RsGxsId(idList.at(1).toStdString()); - - std::map::iterator itIdFound; - if((itIdFound=_gxs_identity_widgets.find(gxs_id)) != _gxs_identity_widgets.end()) { - IdentityWidget *idWidget = itIdFound->second; - dlg.addMember(idWidget->groupInfo()); - }//if((itFound=_gxs_identity_widgets.find(gxs_id)) != _gxs_identity_widgets.end()) - - dlg.editExistingId(circle->groupInfo().mGroupId, false); - dlg.exec(); - }//if((itFound=_ext_circles_widgets.find(groupId)) != _ext_circles_widgets.end()) - }//if (action) -} - -void PeopleDialog::addToCircleInt() -{ - QAction *action = - qobject_cast(QObject::sender()); - if (action) { - QString data = action->data().toString(); - QStringList idList = data.split(";"); - - RsGxsGroupId groupId = RsGxsGroupId(idList.at(0).toStdString()); - std::map::iterator itCirFound; - if((itCirFound=_int_circles_widgets.find(groupId)) != _int_circles_widgets.end()) { - CircleWidget *circle = itCirFound->second; - CreateCircleDialog dlg; - dlg.addCircle(circle->circleDetails()); - - RsPgpId pgp_id = RsPgpId(idList.at(1).toStdString()); - - std::map::iterator itIdFound; - if((itIdFound=_pgp_identity_widgets.find(pgp_id)) != _pgp_identity_widgets.end()) { - IdentityWidget *idWidget = itIdFound->second; - dlg.addMember(idWidget->keyId(), idWidget->idtype(), idWidget->nickname()); - }//if((itFound=_pgp_identity_widgets.find(pgp_id)) != _pgp_identity_widgets.end()) - - dlg.editExistingId(circle->groupInfo().mGroupId, false); - dlg.exec(); - }//if((itFound=_ext_circles_widgets.find(groupId)) != _ext_circles_widgets.end()) - }//if (action) -} - -void PeopleDialog::cw_askForGXSIdentityWidget(RsGxsId gxs_id) -{ - CircleWidget *dest = - qobject_cast(QObject::sender()); - if (dest) { - - std::map::iterator itFound; - if((itFound=_gxs_identity_widgets.find(gxs_id)) != _gxs_identity_widgets.end()) { - IdentityWidget *idWidget = itFound->second; - dest->addIdent(idWidget); - }//if((itFound=_gxs_identity_widgets.find(gxs_id)) != _gxs_identity_widgets.end()) { - }//if (dest) -} - -void PeopleDialog::cw_askForPGPIdentityWidget(RsPgpId pgp_id) -{ - CircleWidget *dest = - qobject_cast(QObject::sender()); - if (dest) { - - std::map::iterator itFound; - if((itFound=_pgp_identity_widgets.find(pgp_id)) != _pgp_identity_widgets.end()) { - IdentityWidget *idWidget = itFound->second; - dest->addIdent(idWidget); - }//if((itFound=_pgp_identity_widgets.find(gxs_id)) != _pgp_identity_widgets.end()) { - }//if (dest) -} - -void PeopleDialog::cw_imageUpdatedInt() -{ - CircleWidget *cirWidget = - qobject_cast(QObject::sender()); - if (cirWidget){ - int index = _intListCir.indexOf(cirWidget); - QPixmap pixmap = cirWidget->getImage(); - pictureFlowWidgetInternal->setSlide(index, pixmap); - }//if (cirWidget) -} - -void PeopleDialog::cw_imageUpdatedExt() -{ - CircleWidget *cirWidget = - qobject_cast(QObject::sender()); - if (cirWidget){ - int index = _extListCir.indexOf(cirWidget); - QPixmap pixmap = cirWidget->getImage(); - pictureFlowWidgetExternal->setSlide(index, pixmap); - }//if (cirWidget) -} - -void PeopleDialog::fl_flowLayoutItemDroppedExt(QListflListItem, bool &bAccept) -{ - bAccept=false; - bool bCreateNewCircle=false; - QApplication::restoreOverrideCursor(); - - FlowLayoutItem *dest = - qobject_cast(QObject::sender()); - if (dest) { - CreateCircleDialog dlg; - - CircleWidget* cirDest = qobject_cast(dest); - if (cirDest) { - dlg.addCircle(cirDest->circleDetails()); - - } else {//if (cirDest) - bCreateNewCircle=true; - IdentityWidget* idDest = qobject_cast(dest); - if (idDest) { - if (idDest->haveGXSId()){ - dlg.addMember(idDest->groupInfo()); - - }//if (idDest->haveGXSId()) - }//if (idDest) - }//else (cirDest) - - - typedef QList::Iterator itList; - for (itList listCurs = flListItem.begin() - ; listCurs != flListItem.end() - ; ++listCurs) { - FlowLayoutItem *flCurs = *listCurs; - CircleWidget* cirDropped = qobject_cast(flCurs); - //Create new circle if circle dropped in circle or ident - if (cirDropped) { - bCreateNewCircle = true; - dlg.addCircle(cirDropped->circleDetails()); - - } else {//if (cirDropped) - IdentityWidget* idDropped = qobject_cast(flCurs); - if (idDropped){ - if (idDropped->haveGXSId()){ - dlg.addMember(idDropped->groupInfo()); - - }//if (idDropped->haveGXSId()) - }//if (idDropped) - }//else (cirDropped) - - }//for (itList listCurs = flListItem.begin() - - if (bCreateNewCircle){ - dlg.editNewId(true); - } else {//if (bCreateNewCircle) - dlg.editExistingId(cirDest->groupInfo().mGroupId, false); - }//else (bCreateNewCircle) - - dlg.exec(); - - bAccept=true; - }//if (dest) -} - -void PeopleDialog::fl_flowLayoutItemDroppedInt(QListflListItem, bool &bAccept) -{ - bAccept=false; - bool bCreateNewCircle=false; - QApplication::restoreOverrideCursor(); - - FlowLayoutItem *dest = - qobject_cast(QObject::sender()); - if (dest) { - CreateCircleDialog dlg; - - CircleWidget* cirDest = qobject_cast(dest); - if (cirDest) { - dlg.addCircle(cirDest->circleDetails()); - - } else {//if (cirDest) - bCreateNewCircle=true; - IdentityWidget* idDest = qobject_cast(dest); - if (idDest) { - if (idDest->havePGPDetail()){ - dlg.addMember(idDest->keyId(), idDest->idtype(), idDest->nickname()); - - }//if (idDest->havePGPDetail()) - }//if (idDest) - }//else (cirDest) - - - typedef QList::Iterator itList; - for (itList listCurs = flListItem.begin() - ; listCurs != flListItem.end() - ; ++listCurs) { - FlowLayoutItem *flCurs = *listCurs; - CircleWidget* cirDropped = qobject_cast(flCurs); - //Create new circle if circle dropped in circle or ident - if (cirDropped) { - bCreateNewCircle = true; - dlg.addCircle(cirDropped->circleDetails()); - - } else {//if (cirDropped) - IdentityWidget* idDropped = qobject_cast(flCurs); - if (idDropped){ - dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname()); - - }//if (idDropped) - }//else (cirDropped) - - }//for (itList listCurs = flListItem.begin() - - if (bCreateNewCircle){ - dlg.editNewId(false); - } else {//if (bCreateNewCircle) - dlg.editExistingId(cirDest->groupInfo().mGroupId, false); - }//else (bCreateNewCircle) - - dlg.exec(); - - bAccept=true; - }//if (dest) -} - -void PeopleDialog::pf_centerIndexChanged(int index) -{ - Q_UNUSED(index) -} - -void PeopleDialog::pf_mouseMoveOverSlideEvent(QMouseEvent* event, int slideIndex) -{ - Q_UNUSED(event) - Q_UNUSED(slideIndex) -} - -void PeopleDialog::pf_dragEnterEventOccurs(QDragEnterEvent *event) -{ - FlowLayoutItem *flItem = - qobject_cast(event->source()); - if (flItem) { - event->setDropAction(Qt::CopyAction); - event->accept(); - return; - }//if (flItem) - QWidget *wid = - qobject_cast(event->source());//QT5 return QObject - FlowLayout *layout = 0; - if (wid) layout = - qobject_cast(wid->layout()); - if (layout) { - event->setDropAction(Qt::CopyAction); - event->accept(); - return; - }//if (layout) -} - -void PeopleDialog::pf_dragMoveEventOccurs(QDragMoveEvent *event) -{ - FlowLayoutItem *flItem = - qobject_cast(event->source()); - if (flItem) { - event->setDropAction(Qt::CopyAction); - event->accept(); - return; - }//if (flItem) - QWidget *wid = - qobject_cast(event->source());//QT5 return QObject - FlowLayout *layout = 0; - if (wid) layout = - qobject_cast(wid->layout()); - if (layout) { - event->setDropAction(Qt::CopyAction); - event->accept(); - return; - }//if (layout) -} - -void PeopleDialog::pf_dropEventOccursExt(QDropEvent *event) -{ - bool bCreateNewCircle=false; - bool atLeastOne = false; - QApplication::restoreOverrideCursor(); - - int index = pictureFlowWidgetExternal->centerIndex(); - CircleWidget* cirDest = _extListCir[index]; - if (cirDest) { - CreateCircleDialog dlg; - - dlg.addCircle(cirDest->circleDetails()); - - {//Test if source is only one FlowLayoutItem - FlowLayoutItem *flCurs = - qobject_cast(event->source()); - if (flCurs) { - CircleWidget* cirDropped = qobject_cast(flCurs); - //Create new circle if circle dropped in circle or ident - if (cirDropped) { - bCreateNewCircle = true; - dlg.addCircle(cirDropped->circleDetails()); - atLeastOne = true; - - } else {//if (cirDropped) - IdentityWidget* idDropped = qobject_cast(flCurs); - if (idDropped){ - if (idDropped->haveGXSId()){ - dlg.addMember(idDropped->groupInfo()); - atLeastOne = true; - }//if (idDropped->haveGXSId()) - }//if (idDropped) - }//else (cirDropped) - - }//if (flCurs) - }//End Test if source is only one FlowLayoutItem - - QWidget *wid = - qobject_cast(event->source());//QT5 return QObject - FlowLayout *layout; - if (wid) layout = - qobject_cast(wid->layout()); - if (layout) { - - QList list = layout->selectionList(); - int count = list.count(); - for (int curs = 0; curs < count; ++curs){ - QLayoutItem *layoutItem = list.at(curs); - if (layoutItem){ - FlowLayoutItem *flCurs = - qobject_cast(layoutItem->widget()); - if (flCurs){ - CircleWidget* cirDropped = qobject_cast(flCurs); - //Create new circle if circle dropped in circle or ident - if (cirDropped) { - bCreateNewCircle = true; - dlg.addCircle(cirDropped->circleDetails()); - atLeastOne = true; - - } else {//if (cirDropped) - IdentityWidget* idDropped = qobject_cast(flCurs); - if (idDropped){ - if (idDropped->haveGXSId()){ - dlg.addMember(idDropped->groupInfo()); - atLeastOne = true; - }//if (idDropped->haveGXSId()) - - }//if (idDropped) - }//else (cirDropped) - - }//if (flCurs) - }//if (layoutItem) - }//for (int curs = 0; curs < count; ++curs) - }//if (layout) - - if (atLeastOne) { - if (bCreateNewCircle){ - dlg.editNewId(true); - } else {//if (bCreateNewCircle) - dlg.editExistingId(cirDest->groupInfo().mGroupId, false); - }//else (bCreateNewCircle) - - dlg.exec(); - - event->setDropAction(Qt::CopyAction); - event->accept(); - }//if (atLeastOne) - }//if (cirDest) -} - -void PeopleDialog::pf_dropEventOccursInt(QDropEvent *event) - { - bool bCreateNewCircle=false; - bool atLeastOne = false; - QApplication::restoreOverrideCursor(); - - int index = pictureFlowWidgetInternal->centerIndex(); - CircleWidget* cirDest = _intListCir[index]; - if (cirDest) { - CreateCircleDialog dlg; - - dlg.addCircle(cirDest->circleDetails()); - - {//Test if source is only one FlowLayoutItem - FlowLayoutItem *flCurs = - qobject_cast(event->source()); - if (flCurs) { - CircleWidget* cirDropped = qobject_cast(flCurs); - //Create new circle if circle dropped in circle or ident - if (cirDropped) { - bCreateNewCircle = true; - dlg.addCircle(cirDropped->circleDetails()); - atLeastOne = true; - - } else {//if (cirDropped) - IdentityWidget* idDropped = qobject_cast(flCurs); - if (idDropped){ - if (idDropped->havePGPDetail()){ - dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname()); - atLeastOne = true; - }//if (idDropped->havePGPDetail()) - }//if (idDropped) - }//else (cirDropped) - - }//if (flCurs) - }//End Test if source is only one FlowLayoutItem - - QWidget *wid = - qobject_cast(event->source());//QT5 return QObject - FlowLayout *layout; - if (wid) layout = - qobject_cast(wid->layout()); - if (layout) { - - QList list = layout->selectionList(); - int count = list.count(); - for (int curs = 0; curs < count; ++curs){ - QLayoutItem *layoutItem = list.at(curs); - if (layoutItem){ - FlowLayoutItem *flCurs = - qobject_cast(layoutItem->widget()); - if (flCurs){ - CircleWidget* cirDropped = qobject_cast(flCurs); - //Create new circle if circle dropped in circle or ident - if (cirDropped) { - bCreateNewCircle = true; - dlg.addCircle(cirDropped->circleDetails()); - atLeastOne = true; - - } else {//if (cirDropped) - IdentityWidget* idDropped = qobject_cast(flCurs); - if (idDropped){ - if (idDropped->havePGPDetail()){ - dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname()); - atLeastOne = true; - }//if (idDropped->havePGPDetail()) - - }//if (idDropped) - }//else (cirDropped) - - }//if (flCurs) - }//if (layoutItem) - }//for (int curs = 0; curs < count; ++curs) - }//if (layout) - - if (atLeastOne) { - if (bCreateNewCircle){ - dlg.editNewId(false); - } else {//if (bCreateNewCircle) - dlg.editExistingId(cirDest->groupInfo().mGroupId, false); - }//else (bCreateNewCircle) - - dlg.exec(); - - event->setDropAction(Qt::CopyAction); - event->accept(); - }//if (atLeastOne) - }//if (cirDest) -} - -void PeopleDialog::populatePictureFlowExt() - { - std::map::iterator it; - for (it=_ext_circles_widgets.begin(); it!=_ext_circles_widgets.end(); ++it) { - CircleWidget *item = it->second; - QPixmap pixmap = item->getImage(); - pictureFlowWidgetExternal->addSlide( pixmap ); - }//for (it=_ext_circles_widgets.begin(); it!=_ext_circles_widgets.end(); ++it) - pictureFlowWidgetExternal->setSlideSizeRatio(4/4.0); - } - -void PeopleDialog::populatePictureFlowInt() - { - std::map::iterator it; - for (it=_int_circles_widgets.begin(); it!=_int_circles_widgets.end(); ++it) { - CircleWidget *item = it->second; - QPixmap pixmap = item->getImage(); - pictureFlowWidgetInternal->addSlide( pixmap ); - }//for (it=_int_circles_widgets.begin(); it!=_int_circles_widgets.end(); ++it) - pictureFlowWidgetInternal->setSlideSizeRatio(4/4.0); -} +/* + * 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 "PeopleDialog.h" +#include "gui/Circles/CreateCircleDialog.h" +#include "gui/common/FlowLayout.h" +#include "gui/settings/rsharesettings.h" +#include "gui/msgs/MessageComposer.h" +#include "gui/gxs/GxsIdDetails.h" +#include "gui/Identity/IdDetailsDialog.h" + +#include "retroshare/rspeers.h" +#include "retroshare/rsidentity.h" +#include "retroshare/rsgxscircles.h" +#include "retroshare/rsgxsflags.h" +#include "retroshare/rsmsgs.h" + +#include +#include +#include + +/****** + * #define PEOPLE_DIALOG_DEBUG 1 + *****/ + + +const uint32_t PeopleDialog::PD_IDLIST = 0x0001 ; +const uint32_t PeopleDialog::PD_IDDETAILS = 0x0002 ; +const uint32_t PeopleDialog::PD_REFRESH = 0x0003 ; +const uint32_t PeopleDialog::PD_CIRCLES = 0x0004 ; + +/** Constructor */ +PeopleDialog::PeopleDialog(QWidget *parent) + : RsGxsUpdateBroadcastPage(rsIdentity, parent) +{ + setupUi(this); + + /* Setup TokenQueue */ + mIdentityQueue = new TokenQueue(rsIdentity->getTokenService(), this); + mCirclesQueue = new TokenQueue(rsGxsCircles->getTokenService(), this); + + + tabWidget->removeTab(1); + + //need erase QtCreator Layout first(for Win) + delete idExternal->layout(); + delete idInternal->layout(); + //QT Designer don't accept Custom Layout, maybe on QT5 + _flowLayoutExt = new FlowLayout(idExternal); + _flowLayoutInt = new FlowLayout(idInternal); + + {//First Get Item created in Qt Designer for External + int count = idExternal->children().count(); + for (int curs = 0; curs < count; ++curs){ + QObject *obj = idExternal->children().at(curs); + QWidget *wid = qobject_cast(obj); + if (wid) _flowLayoutExt->addWidget(wid); + }//for (int curs = 0; curs < count; ++curs) + }//End First Get Item created in Qt Designer for External + + {//First Get Item created in Qt Designer for Internal + int count = idInternal->children().count(); + for (int curs = 0; curs < count; ++curs){ + QObject *obj = idInternal->children().at(curs); + QWidget *wid = qobject_cast(obj); + if (wid) _flowLayoutInt->addWidget(wid); + }//for (int curs = 0; curs < count; ++curs) + }//End First Get Item created in Qt Designer for Internal + + pictureFlowWidgetExternal->setAcceptDrops(true); + QObject::connect(pictureFlowWidgetExternal, SIGNAL(centerIndexChanged(int)), this, SLOT(pf_centerIndexChanged(int))); + QObject::connect(pictureFlowWidgetExternal, SIGNAL(mouseMoveOverSlideEvent(QMouseEvent*,int)), this, SLOT(pf_mouseMoveOverSlideEvent(QMouseEvent*,int))); + QObject::connect(pictureFlowWidgetExternal, SIGNAL(dragEnterEventOccurs(QDragEnterEvent*)), this, SLOT(pf_dragEnterEventOccurs(QDragEnterEvent*))); + QObject::connect(pictureFlowWidgetExternal, SIGNAL(dragMoveEventOccurs(QDragMoveEvent*)), this, SLOT(pf_dragMoveEventOccurs(QDragMoveEvent*))); + QObject::connect(pictureFlowWidgetExternal, SIGNAL(dropEventOccurs(QDropEvent*)), this, SLOT(pf_dropEventOccursExt(QDropEvent*))); + pictureFlowWidgetExternal->setMinimumHeight(60); + pictureFlowWidgetExternal->setSlideSizeRatio(4/4.0); + + pictureFlowWidgetInternal->setAcceptDrops(true); + QObject::connect(pictureFlowWidgetInternal, SIGNAL(centerIndexChanged(int)), this, SLOT(pf_centerIndexChanged(int))); + QObject::connect(pictureFlowWidgetInternal, SIGNAL(mouseMoveOverSlideEvent(QMouseEvent*,int)), this, SLOT(pf_mouseMoveOverSlideEvent(QMouseEvent*,int))); + QObject::connect(pictureFlowWidgetInternal, SIGNAL(dragEnterEventOccurs(QDragEnterEvent*)), this, SLOT(pf_dragEnterEventOccurs(QDragEnterEvent*))); + QObject::connect(pictureFlowWidgetInternal, SIGNAL(dragMoveEventOccurs(QDragMoveEvent*)), this, SLOT(pf_dragMoveEventOccurs(QDragMoveEvent*))); + QObject::connect(pictureFlowWidgetInternal, SIGNAL(dropEventOccurs(QDropEvent*)), this, SLOT(pf_dropEventOccursInt(QDropEvent*))); + pictureFlowWidgetInternal->setMinimumHeight(60); + pictureFlowWidgetInternal->setSlideSizeRatio(4/4.0); + + QByteArray geometryExt = Settings->valueFromGroup("PeopleDialog", "SplitterExtState", QByteArray()).toByteArray(); + if (geometryExt.isEmpty() == false) { + splitterExternal->restoreState(geometryExt); + } + QByteArray geometryInt = Settings->valueFromGroup("PeopleDialog", "SplitterIntState", QByteArray()).toByteArray(); + if (geometryInt.isEmpty() == false) { + splitterInternal->restoreState(geometryInt); + } +} + +/** Destructor. */ +PeopleDialog::~PeopleDialog() +{ + delete mIdentityQueue; + delete mCirclesQueue; + + Settings->setValueToGroup("PeopleDialog", "SplitterExtState", splitterExternal->saveState()); + Settings->setValueToGroup("PeopleDialog", "SplitterIntState", splitterInternal->saveState()); +} + +void PeopleDialog::updateDisplay(bool complete) +{ + Q_UNUSED(complete); + reloadAll(); +} + +void PeopleDialog::reloadAll() +{ + /* Update identity list */ + requestIdList(); + requestCirclesList(); + + /* grab all ids */ + std::list friend_pgpIds; + std::list all_pgpIds; + std::list::iterator it; + + std::set friend_set; + + rsPeers->getGPGAcceptedList(friend_pgpIds); + //rsPeers->getGPGAllList(all_pgpIds); + + + for(it = friend_pgpIds.begin(); it != friend_pgpIds.end(); ++it) { + RsPeerDetails details; + if(rsPeers->getGPGDetails(*it, details)){ + std::map::iterator itFound; + if((itFound=_pgp_identity_widgets.find(*it)) == _pgp_identity_widgets.end()) { + IdentityWidget *new_item = new IdentityWidget(); + new_item->updateData(details) ; + _pgp_identity_widgets[*it] = new_item ; + + QObject::connect(new_item, SIGNAL(addButtonClicked()), this, SLOT(iw_AddButtonClickedInt())); + QObject::connect(new_item, SIGNAL(flowLayoutItemDropped(QList,bool&)), this, SLOT(fl_flowLayoutItemDroppedInt(QList,bool&))); + _flowLayoutInt->addWidget(new_item); + } else {//if((itFound=_pgp_identity_widgets.find(gdItem.mPgpId)) == _pgp_identity_widgets.end()) + IdentityWidget *idWidget = itFound->second; + + idWidget->updateData(details) ; + }//else ((itFound=_pgp_identity_widgets.find(gdItem.mPgpId)) == _pgp_identity_widgets.end()) + + friend_set.insert(*it); + }//if(rsPeers->getGPGDetails(*it, details)) + }//for(it = friend_pgpIds.begin(); it != friend_pgpIds.end(); ++it) + + for(it = all_pgpIds.begin(); it != all_pgpIds.end(); ++it) { + if(friend_set.end() != friend_set.find(*it)) { + // already added as a friend. + continue; + }//if(friend_set.end() != friend_set.find(*it)) + + RsPeerDetails details; + if (rsPeers->getGPGDetails(*it, details)) { + std::map::iterator itFound; + if((itFound=_pgp_identity_widgets.find(*it)) == _pgp_identity_widgets.end()) { + IdentityWidget *new_item = new IdentityWidget(); + new_item->updateData(details) ; + _pgp_identity_widgets[*it] = new_item ; + + QObject::connect(new_item, SIGNAL(addButtonClicked()), this, SLOT(iw_AddButtonClickedInt())); + QObject::connect(new_item, SIGNAL(flowLayoutItemDropped(QList,bool&)), this, SLOT(fl_flowLayoutItemDroppedInt(QList,bool&))); + _flowLayoutInt->addWidget(new_item); + } else {//if((itFound=_pgp_identity_widgets.find(gdItem.mPgpId)) == _pgp_identity_widgets.end()) + IdentityWidget *idWidget = itFound->second; + + idWidget->updateData(details) ; + }//else ((itFound=_pgp_identity_widgets.find(gdItem.mPgpId)) == _pgp_identity_widgets.end()) + }//if(rsPeers->getGPGDetails(*it, details)) + }//for(it = all_pgpIds.begin(); it != all_pgpIds.end(); ++it) +} + +void PeopleDialog::insertIdList(uint32_t token) +{ + std::cerr << "**** In insertIdList() ****" << std::endl; + + std::vector gdataVector; + std::vector::iterator gdIt; + + if (!rsIdentity->getGroupData(token, gdataVector)) { + std::cerr << "PeopleDialog::insertIdList() Error getting GroupData"; + std::cerr << std::endl; + + return; + }//if (!rsIdentity->getGroupData(token, gdataVector)) + + //RsPgpId ownPgpId = rsPeers->getGPGOwnId(); + + /* Insert items */ + int i=0 ; + for (gdIt = gdataVector.begin(); gdIt != gdataVector.end(); ++gdIt){ + RsGxsIdGroup gdItem = (*gdIt); + bool bGotDetail = false; + + RsPeerDetails details; + if (gdItem.mPgpKnown) { + bGotDetail = rsPeers->getGPGDetails(gdItem.mPgpId, details); + }//if (gdItem.mPgpKnown) + + std::map::iterator itFound; + if((itFound=_gxs_identity_widgets.find(RsGxsId(gdItem.mMeta.mGroupId))) == _gxs_identity_widgets.end()) { + std::cerr << "Loading data vector identity GXS ID = " << gdItem.mMeta.mGroupId << ", i="<< i << std::endl; + + IdentityWidget *new_item = new IdentityWidget(); + if (bGotDetail) { + new_item->updateData(gdItem, details); + } else {//if (bGotDetail) + new_item->updateData(gdItem); + }//else (bGotDetail) + _gxs_identity_widgets[RsGxsId(gdItem.mMeta.mGroupId)] = new_item ; + + QObject::connect(new_item, SIGNAL(addButtonClicked()), this, SLOT(iw_AddButtonClickedExt())); + QObject::connect(new_item, SIGNAL(flowLayoutItemDropped(QList,bool&)), this, SLOT(fl_flowLayoutItemDroppedExt(QList,bool&))); + _flowLayoutExt->addWidget(new_item); + ++i ; + } else {//if((itFound=_gxs_identity_widgets.find(RsGxsId(gdItem.mMeta.mGroupId))) == _gxs_identity_widgets.end()) + + std::cerr << "Updating data vector identity GXS ID = " << gdItem.mMeta.mGroupId << std::endl; + IdentityWidget *idWidget = itFound->second; + + if (bGotDetail) { + idWidget->updateData(gdItem, details) ; + } else {//if (bGotDetail) + idWidget->updateData(gdItem) ; + }//else (bGotDetail) + + }//else ((itFound=_gxs_identity_widgets.find(RsGxsId(gdItem.mMeta.mGroupId))) == _gxs_identity_widgets.end())) + }//for (gdIt = gdataVector.begin(); gdIt != gdataVector.end(); ++gdIt) +} + +void PeopleDialog::insertCircles(uint32_t token) +{ + std::cerr << "PeopleDialog::insertExtCircles(token==" << token << ")" << std::endl; + + std::list gSummaryList; + std::list::iterator gsIt; + + if (!rsGxsCircles->getGroupSummary(token,gSummaryList)) { + std::cerr << "PeopleDialog::insertExtCircles() Error getting GroupSummary"; + std::cerr << std::endl; + + return; + }//if (!rsGxsCircles->getGroupSummary(token,gSummaryList)) + + for(gsIt = gSummaryList.begin(); gsIt != gSummaryList.end(); ++gsIt) { + RsGroupMetaData gsItem = (*gsIt); + + RsGxsCircleDetails details ; + if(!rsGxsCircles->getCircleDetails(RsGxsCircleId(gsItem.mGroupId), details)){ + std::cerr << "(EE) Cannot get details for circle id " << gsItem.mGroupId << ". Circle item is not created!" << std::endl; + continue ; + }//if(!rsGxsCircles->getCircleDetails(RsGxsCircleId(git->mGroupId), details)) + + if (!details.mIsExternal){ + std::map::iterator itFound; + if((itFound=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end()) { + std::cerr << "PeopleDialog::insertExtCircles() add new Internal GroupId: " << gsItem.mGroupId; + std::cerr << " GroupName: " << gsItem.mGroupName; + std::cerr << std::endl; + + CircleWidget *gitem = new CircleWidget() ; + QObject::connect(gitem, SIGNAL(flowLayoutItemDropped(QList,bool&)), this, SLOT(fl_flowLayoutItemDroppedInt(QList,bool&))); + QObject::connect(gitem, SIGNAL(askForGXSIdentityWidget(RsGxsId)), this, SLOT(cw_askForGXSIdentityWidget(RsGxsId))); + QObject::connect(gitem, SIGNAL(askForPGPIdentityWidget(RsPgpId)), this, SLOT(cw_askForPGPIdentityWidget(RsPgpId))); + QObject::connect(gitem, SIGNAL(imageUpdated()), this, SLOT(cw_imageUpdatedInt())); + gitem->updateData( gsItem, details ); + _int_circles_widgets[gsItem.mGroupId] = gitem ; + + _flowLayoutInt->addWidget(gitem); + + QPixmap pixmap = gitem->getImage(); + pictureFlowWidgetInternal->addSlide( pixmap ); + _intListCir << gitem; + } else {//if((itFound=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end()) + std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId; + std::cerr << " GroupName: " << gsItem.mGroupName; + std::cerr << std::endl; + + CircleWidget *cirWidget = itFound->second; + cirWidget->updateData( gsItem, details ); + + //int index = _intListCir.indexOf(cirWidget); + //QPixmap pixmap = cirWidget->getImage(); + //pictureFlowWidgetInternal->setSlide(index, pixmap); + }//if((item=_int_circles_widgets.find(gsItem.mGroupId)) == _int_circles_widgets.end()) + } else {//if (!details.mIsExternal) + std::map::iterator itFound; + if((itFound=_ext_circles_widgets.find(gsItem.mGroupId)) == _ext_circles_widgets.end()) { + std::cerr << "PeopleDialog::insertExtCircles() add new GroupId: " << gsItem.mGroupId; + std::cerr << " GroupName: " << gsItem.mGroupName; + std::cerr << std::endl; + + CircleWidget *gitem = new CircleWidget() ; + QObject::connect(gitem, SIGNAL(flowLayoutItemDropped(QList,bool&)), this, SLOT(fl_flowLayoutItemDroppedExt(QList,bool&))); + QObject::connect(gitem, SIGNAL(askForGXSIdentityWidget(RsGxsId)), this, SLOT(cw_askForGXSIdentityWidget(RsGxsId))); + QObject::connect(gitem, SIGNAL(askForPGPIdentityWidget(RsPgpId)), this, SLOT(cw_askForPGPIdentityWidget(RsPgpId))); + QObject::connect(gitem, SIGNAL(imageUpdated()), this, SLOT(cw_imageUpdatedExt())); + gitem->updateData( gsItem, details ); + _ext_circles_widgets[gsItem.mGroupId] = gitem ; + + _flowLayoutExt->addWidget(gitem); + + QPixmap pixmap = gitem->getImage(); + pictureFlowWidgetExternal->addSlide( pixmap ); + _extListCir << gitem; + } else {//if((itFound=_circles_widgets.find(gsItem.mGroupId)) == _circles_widgets.end()) + std::cerr << "PeopleDialog::insertExtCircles() Update GroupId: " << gsItem.mGroupId; + std::cerr << " GroupName: " << gsItem.mGroupName; + std::cerr << std::endl; + + CircleWidget *cirWidget = itFound->second; + cirWidget->updateData( gsItem, details ); + + //int index = _extListCir.indexOf(cirWidget); + //QPixmap pixmap = cirWidget->getImage(); + //pictureFlowWidgetExternal->setSlide(index, pixmap); + }//if((item=_circles_items.find(gsItem.mGroupId)) == _circles_items.end()) + }//else (!details.mIsExternal) + }//for(gsIt = gSummaryList.begin(); gsIt != gSummaryList.end(); ++gsIt) +} + +void PeopleDialog::requestIdList() +{ + std::cerr << "Requesting ID list..." << std::endl; + + if (!mIdentityQueue) return; + + mIdentityQueue->cancelActiveRequestTokens(PD_IDLIST); + + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; + + uint32_t token; + + mIdentityQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, PD_IDLIST); +} + +void PeopleDialog::requestCirclesList() +{ + std::cerr << "Requesting Circles list..." << std::endl; + + if (!mCirclesQueue) return; + + mCirclesQueue->cancelActiveRequestTokens(PD_CIRCLES); + + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; + + uint32_t token; + mCirclesQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, PD_CIRCLES); +} + +void PeopleDialog::loadRequest(const TokenQueue * /*queue*/, const TokenRequest &req) +{ + std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType; + std::cerr << std::endl; + + switch(req.mUserType) { + case PD_IDLIST: + insertIdList(req.mToken); + break; + + case PD_IDDETAILS: + //insertIdDetails(req.mToken); + break; + + case PD_CIRCLES: + insertCircles(req.mToken); + break; + + case PD_REFRESH: + updateDisplay(true); + break; + default: + std::cerr << "IdDialog::loadRequest() ERROR"; + std::cerr << std::endl; + break; + }//switch(req.mUserType) +} + +void PeopleDialog::iw_AddButtonClickedExt() +{ + IdentityWidget *dest= + qobject_cast(QObject::sender()); + if (dest) { + QMenu contextMnu( this ); + + std::map::iterator itCurs; + for( itCurs =_ext_circles_widgets.begin(); + itCurs != _ext_circles_widgets.end(); + ++itCurs) { + CircleWidget *curs = itCurs->second; + QIcon icon = QIcon(curs->getImage()); + QString name = curs->getName(); + + QAction *action = contextMnu.addAction(icon, name, this, SLOT(addToCircleExt())); + action->setData(QString::fromStdString(curs->groupInfo().mGroupId.toStdString()) + + ";" + QString::fromStdString(dest->groupInfo().mMeta.mGroupId.toStdString())); + }//for( itCurs =_ext_circles_widgets.begin(); + + std::list own_identities ; + rsIdentity->getOwnIds(own_identities) ; + + if(own_identities.size() <= 1) + { + QAction *action = contextMnu.addAction(QIcon(":/images/chat_24.png"), tr("Chat with this person"), this, SLOT(chatIdentity())); + + if(own_identities.empty()) + action->setEnabled(false) ; + else + action->setData(QString::fromStdString((own_identities.front()).toStdString()) + ";" + QString::fromStdString(dest->groupInfo().mMeta.mGroupId.toStdString())) ; + } + else + { + QMenu *mnu = contextMnu.addMenu(QIcon(":/images/chat_24.png"),tr("Chat with this person as...")) ; + + for(std::list::const_iterator it=own_identities.begin();it!=own_identities.end();++it) + { + RsIdentityDetails idd ; + rsIdentity->getIdDetails(*it,idd) ; + + QPixmap pixmap ; + + if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG")) + pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ; + + QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity())); + action->setData(QString::fromStdString((*it).toStdString()) + ";" + QString::fromStdString(dest->groupInfo().mMeta.mGroupId.toStdString())) ; + } + } + + QAction *actionsendmsg = contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMessage())); + actionsendmsg->setData( QString::fromStdString(dest->groupInfo().mMeta.mGroupId.toStdString())); + + contextMnu.addSeparator(); + + QAction *actionDetails = contextMnu.addAction(QIcon(":/images/info16.png"), tr("Person details"), this, SLOT(personDetails())); + actionDetails->setData( QString::fromStdString(dest->groupInfo().mMeta.mGroupId.toStdString())); + + contextMnu.exec(QCursor::pos()); + }//if (dest) +} + +void PeopleDialog::iw_AddButtonClickedInt() +{ + IdentityWidget *dest= + qobject_cast(QObject::sender()); + if (dest) { + QMenu contextMnu( this ); + + std::map::iterator itCurs; + for( itCurs =_int_circles_widgets.begin(); + itCurs != _int_circles_widgets.end(); + ++itCurs) { + CircleWidget *curs = itCurs->second; + QIcon icon = QIcon(curs->getImage()); + QString name = curs->getName(); + + QAction *action = contextMnu.addAction(icon, name, this, SLOT(addToCircleInt())); + action->setData(QString::fromStdString(curs->groupInfo().mGroupId.toStdString()) + + ";" + QString::fromStdString(dest->details().gpg_id.toStdString())); + }//for( itCurs =_int_circles_widgets.begin(); + + contextMnu.exec(QCursor::pos()); + }//if (dest) +} + +void PeopleDialog::addToCircleExt() +{ + QAction *action = + qobject_cast(QObject::sender()); + if (action) { + QString data = action->data().toString(); + QStringList idList = data.split(";"); + + RsGxsGroupId groupId = RsGxsGroupId(idList.at(0).toStdString()); + std::map::iterator itCirFound; + if((itCirFound=_ext_circles_widgets.find(groupId)) != _ext_circles_widgets.end()) { + CircleWidget *circle = itCirFound->second; + CreateCircleDialog dlg; + dlg.addCircle(circle->circleDetails()); + + RsGxsId gxs_id = RsGxsId(idList.at(1).toStdString()); + + std::map::iterator itIdFound; + if((itIdFound=_gxs_identity_widgets.find(gxs_id)) != _gxs_identity_widgets.end()) { + IdentityWidget *idWidget = itIdFound->second; + dlg.addMember(idWidget->groupInfo()); + }//if((itFound=_gxs_identity_widgets.find(gxs_id)) != _gxs_identity_widgets.end()) + + dlg.editExistingId(circle->groupInfo().mGroupId, false); + dlg.exec(); + }//if((itFound=_ext_circles_widgets.find(groupId)) != _ext_circles_widgets.end()) + }//if (action) +} + +void PeopleDialog::addToCircleInt() +{ + QAction *action = + qobject_cast(QObject::sender()); + if (action) { + QString data = action->data().toString(); + QStringList idList = data.split(";"); + + RsGxsGroupId groupId = RsGxsGroupId(idList.at(0).toStdString()); + std::map::iterator itCirFound; + if((itCirFound=_int_circles_widgets.find(groupId)) != _int_circles_widgets.end()) { + CircleWidget *circle = itCirFound->second; + CreateCircleDialog dlg; + dlg.addCircle(circle->circleDetails()); + + RsPgpId pgp_id = RsPgpId(idList.at(1).toStdString()); + + std::map::iterator itIdFound; + if((itIdFound=_pgp_identity_widgets.find(pgp_id)) != _pgp_identity_widgets.end()) { + IdentityWidget *idWidget = itIdFound->second; + dlg.addMember(idWidget->keyId(), idWidget->idtype(), idWidget->nickname()); + }//if((itFound=_pgp_identity_widgets.find(pgp_id)) != _pgp_identity_widgets.end()) + + dlg.editExistingId(circle->groupInfo().mGroupId, false); + dlg.exec(); + }//if((itFound=_ext_circles_widgets.find(groupId)) != _ext_circles_widgets.end()) + }//if (action) +} + +void PeopleDialog::chatIdentity() +{ + QAction *action = + qobject_cast(QObject::sender()); + if (action) { + QString data = action->data().toString(); + QStringList idList = data.split(";"); + + RsGxsId from_gxs_id = RsGxsId(idList.at(0).toStdString()); + RsGxsId gxs_id = RsGxsId(idList.at(1).toStdString()); + + uint32_t error_code ; + + if(!rsMsgs->initiateDistantChatConnexion(RsGxsId(gxs_id), from_gxs_id, error_code)) + QMessageBox::information(NULL, tr("Distant chat cannot work"), QString("%1 %2: %3").arg(tr("Distant chat refused with this person.")).arg(tr("Error code")).arg(error_code)) ; + + } +} + +void PeopleDialog::sendMessage() +{ + QAction *action = + qobject_cast(QObject::sender()); + if (action) { + QString data = action->data().toString(); + + MessageComposer *nMsgDialog = MessageComposer::newMsg(); + if (nMsgDialog == NULL) { + return; + } + + RsGxsId gxs_id = RsGxsId(data.toStdString());; + + nMsgDialog->addRecipient(MessageComposer::TO, RsGxsId(gxs_id)); + nMsgDialog->show(); + nMsgDialog->activateWindow(); + + /* window will destroy itself! */ + + } + +} + +void PeopleDialog::personDetails() +{ + QAction *action = + qobject_cast(QObject::sender()); + if (action) { + QString data = action->data().toString(); + + RsGxsId gxs_id = RsGxsId(data.toStdString()); + + if (RsGxsGroupId(gxs_id).isNull()) { + return; + } + + IdDetailsDialog *dialog = new IdDetailsDialog(RsGxsGroupId(gxs_id)); + dialog->show(); + + /* Dialog will destroy itself */ + + } + +} + +void PeopleDialog::cw_askForGXSIdentityWidget(RsGxsId gxs_id) +{ + CircleWidget *dest = + qobject_cast(QObject::sender()); + if (dest) { + + std::map::iterator itFound; + if((itFound=_gxs_identity_widgets.find(gxs_id)) != _gxs_identity_widgets.end()) { + IdentityWidget *idWidget = itFound->second; + dest->addIdent(idWidget); + }//if((itFound=_gxs_identity_widgets.find(gxs_id)) != _gxs_identity_widgets.end()) { + }//if (dest) +} + +void PeopleDialog::cw_askForPGPIdentityWidget(RsPgpId pgp_id) +{ + CircleWidget *dest = + qobject_cast(QObject::sender()); + if (dest) { + + std::map::iterator itFound; + if((itFound=_pgp_identity_widgets.find(pgp_id)) != _pgp_identity_widgets.end()) { + IdentityWidget *idWidget = itFound->second; + dest->addIdent(idWidget); + }//if((itFound=_pgp_identity_widgets.find(gxs_id)) != _pgp_identity_widgets.end()) { + }//if (dest) +} + +void PeopleDialog::cw_imageUpdatedInt() +{ + CircleWidget *cirWidget = + qobject_cast(QObject::sender()); + if (cirWidget){ + int index = _intListCir.indexOf(cirWidget); + QPixmap pixmap = cirWidget->getImage(); + pictureFlowWidgetInternal->setSlide(index, pixmap); + }//if (cirWidget) +} + +void PeopleDialog::cw_imageUpdatedExt() +{ + CircleWidget *cirWidget = + qobject_cast(QObject::sender()); + if (cirWidget){ + int index = _extListCir.indexOf(cirWidget); + QPixmap pixmap = cirWidget->getImage(); + pictureFlowWidgetExternal->setSlide(index, pixmap); + }//if (cirWidget) +} + +void PeopleDialog::fl_flowLayoutItemDroppedExt(QListflListItem, bool &bAccept) +{ + bAccept=false; + bool bCreateNewCircle=false; + QApplication::restoreOverrideCursor(); + + FlowLayoutItem *dest = + qobject_cast(QObject::sender()); + if (dest) { + CreateCircleDialog dlg; + + CircleWidget* cirDest = qobject_cast(dest); + if (cirDest) { + dlg.addCircle(cirDest->circleDetails()); + + } else {//if (cirDest) + bCreateNewCircle=true; + IdentityWidget* idDest = qobject_cast(dest); + if (idDest) { + if (idDest->haveGXSId()){ + dlg.addMember(idDest->groupInfo()); + + }//if (idDest->haveGXSId()) + }//if (idDest) + }//else (cirDest) + + + typedef QList::Iterator itList; + for (itList listCurs = flListItem.begin() + ; listCurs != flListItem.end() + ; ++listCurs) { + FlowLayoutItem *flCurs = *listCurs; + CircleWidget* cirDropped = qobject_cast(flCurs); + //Create new circle if circle dropped in circle or ident + if (cirDropped) { + bCreateNewCircle = true; + dlg.addCircle(cirDropped->circleDetails()); + + } else {//if (cirDropped) + IdentityWidget* idDropped = qobject_cast(flCurs); + if (idDropped){ + if (idDropped->haveGXSId()){ + dlg.addMember(idDropped->groupInfo()); + + }//if (idDropped->haveGXSId()) + }//if (idDropped) + }//else (cirDropped) + + }//for (itList listCurs = flListItem.begin() + + if (bCreateNewCircle){ + dlg.editNewId(true); + } else {//if (bCreateNewCircle) + dlg.editExistingId(cirDest->groupInfo().mGroupId, false); + }//else (bCreateNewCircle) + + dlg.exec(); + + bAccept=true; + }//if (dest) +} + +void PeopleDialog::fl_flowLayoutItemDroppedInt(QListflListItem, bool &bAccept) +{ + bAccept=false; + bool bCreateNewCircle=false; + QApplication::restoreOverrideCursor(); + + FlowLayoutItem *dest = + qobject_cast(QObject::sender()); + if (dest) { + CreateCircleDialog dlg; + + CircleWidget* cirDest = qobject_cast(dest); + if (cirDest) { + dlg.addCircle(cirDest->circleDetails()); + + } else {//if (cirDest) + bCreateNewCircle=true; + IdentityWidget* idDest = qobject_cast(dest); + if (idDest) { + if (idDest->havePGPDetail()){ + dlg.addMember(idDest->keyId(), idDest->idtype(), idDest->nickname()); + + }//if (idDest->havePGPDetail()) + }//if (idDest) + }//else (cirDest) + + + typedef QList::Iterator itList; + for (itList listCurs = flListItem.begin() + ; listCurs != flListItem.end() + ; ++listCurs) { + FlowLayoutItem *flCurs = *listCurs; + CircleWidget* cirDropped = qobject_cast(flCurs); + //Create new circle if circle dropped in circle or ident + if (cirDropped) { + bCreateNewCircle = true; + dlg.addCircle(cirDropped->circleDetails()); + + } else {//if (cirDropped) + IdentityWidget* idDropped = qobject_cast(flCurs); + if (idDropped){ + dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname()); + + }//if (idDropped) + }//else (cirDropped) + + }//for (itList listCurs = flListItem.begin() + + if (bCreateNewCircle){ + dlg.editNewId(false); + } else {//if (bCreateNewCircle) + dlg.editExistingId(cirDest->groupInfo().mGroupId, false); + }//else (bCreateNewCircle) + + dlg.exec(); + + bAccept=true; + }//if (dest) +} + +void PeopleDialog::pf_centerIndexChanged(int index) +{ + Q_UNUSED(index) +} + +void PeopleDialog::pf_mouseMoveOverSlideEvent(QMouseEvent* event, int slideIndex) +{ + Q_UNUSED(event) + Q_UNUSED(slideIndex) +} + +void PeopleDialog::pf_dragEnterEventOccurs(QDragEnterEvent *event) +{ + FlowLayoutItem *flItem = + qobject_cast(event->source()); + if (flItem) { + event->setDropAction(Qt::CopyAction); + event->accept(); + return; + }//if (flItem) + QWidget *wid = + qobject_cast(event->source());//QT5 return QObject + FlowLayout *layout = 0; + if (wid) layout = + qobject_cast(wid->layout()); + if (layout) { + event->setDropAction(Qt::CopyAction); + event->accept(); + return; + }//if (layout) +} + +void PeopleDialog::pf_dragMoveEventOccurs(QDragMoveEvent *event) +{ + FlowLayoutItem *flItem = + qobject_cast(event->source()); + if (flItem) { + event->setDropAction(Qt::CopyAction); + event->accept(); + return; + }//if (flItem) + QWidget *wid = + qobject_cast(event->source());//QT5 return QObject + FlowLayout *layout = 0; + if (wid) layout = + qobject_cast(wid->layout()); + if (layout) { + event->setDropAction(Qt::CopyAction); + event->accept(); + return; + }//if (layout) +} + +void PeopleDialog::pf_dropEventOccursExt(QDropEvent *event) +{ + bool bCreateNewCircle=false; + bool atLeastOne = false; + QApplication::restoreOverrideCursor(); + + int index = pictureFlowWidgetExternal->centerIndex(); + CircleWidget* cirDest = _extListCir[index]; + if (cirDest) { + CreateCircleDialog dlg; + + dlg.addCircle(cirDest->circleDetails()); + + {//Test if source is only one FlowLayoutItem + FlowLayoutItem *flCurs = + qobject_cast(event->source()); + if (flCurs) { + CircleWidget* cirDropped = qobject_cast(flCurs); + //Create new circle if circle dropped in circle or ident + if (cirDropped) { + bCreateNewCircle = true; + dlg.addCircle(cirDropped->circleDetails()); + atLeastOne = true; + + } else {//if (cirDropped) + IdentityWidget* idDropped = qobject_cast(flCurs); + if (idDropped){ + if (idDropped->haveGXSId()){ + dlg.addMember(idDropped->groupInfo()); + atLeastOne = true; + }//if (idDropped->haveGXSId()) + }//if (idDropped) + }//else (cirDropped) + + }//if (flCurs) + }//End Test if source is only one FlowLayoutItem + + QWidget *wid = + qobject_cast(event->source());//QT5 return QObject + FlowLayout *layout; + if (wid) layout = + qobject_cast(wid->layout()); + if (layout) { + + QList list = layout->selectionList(); + int count = list.count(); + for (int curs = 0; curs < count; ++curs){ + QLayoutItem *layoutItem = list.at(curs); + if (layoutItem){ + FlowLayoutItem *flCurs = + qobject_cast(layoutItem->widget()); + if (flCurs){ + CircleWidget* cirDropped = qobject_cast(flCurs); + //Create new circle if circle dropped in circle or ident + if (cirDropped) { + bCreateNewCircle = true; + dlg.addCircle(cirDropped->circleDetails()); + atLeastOne = true; + + } else {//if (cirDropped) + IdentityWidget* idDropped = qobject_cast(flCurs); + if (idDropped){ + if (idDropped->haveGXSId()){ + dlg.addMember(idDropped->groupInfo()); + atLeastOne = true; + }//if (idDropped->haveGXSId()) + + }//if (idDropped) + }//else (cirDropped) + + }//if (flCurs) + }//if (layoutItem) + }//for (int curs = 0; curs < count; ++curs) + }//if (layout) + + if (atLeastOne) { + if (bCreateNewCircle){ + dlg.editNewId(true); + } else {//if (bCreateNewCircle) + dlg.editExistingId(cirDest->groupInfo().mGroupId, false); + }//else (bCreateNewCircle) + + dlg.exec(); + + event->setDropAction(Qt::CopyAction); + event->accept(); + }//if (atLeastOne) + }//if (cirDest) +} + +void PeopleDialog::pf_dropEventOccursInt(QDropEvent *event) + { + bool bCreateNewCircle=false; + bool atLeastOne = false; + QApplication::restoreOverrideCursor(); + + int index = pictureFlowWidgetInternal->centerIndex(); + CircleWidget* cirDest = _intListCir[index]; + if (cirDest) { + CreateCircleDialog dlg; + + dlg.addCircle(cirDest->circleDetails()); + + {//Test if source is only one FlowLayoutItem + FlowLayoutItem *flCurs = + qobject_cast(event->source()); + if (flCurs) { + CircleWidget* cirDropped = qobject_cast(flCurs); + //Create new circle if circle dropped in circle or ident + if (cirDropped) { + bCreateNewCircle = true; + dlg.addCircle(cirDropped->circleDetails()); + atLeastOne = true; + + } else {//if (cirDropped) + IdentityWidget* idDropped = qobject_cast(flCurs); + if (idDropped){ + if (idDropped->havePGPDetail()){ + dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname()); + atLeastOne = true; + }//if (idDropped->havePGPDetail()) + }//if (idDropped) + }//else (cirDropped) + + }//if (flCurs) + }//End Test if source is only one FlowLayoutItem + + QWidget *wid = + qobject_cast(event->source());//QT5 return QObject + FlowLayout *layout; + if (wid) layout = + qobject_cast(wid->layout()); + if (layout) { + + QList list = layout->selectionList(); + int count = list.count(); + for (int curs = 0; curs < count; ++curs){ + QLayoutItem *layoutItem = list.at(curs); + if (layoutItem){ + FlowLayoutItem *flCurs = + qobject_cast(layoutItem->widget()); + if (flCurs){ + CircleWidget* cirDropped = qobject_cast(flCurs); + //Create new circle if circle dropped in circle or ident + if (cirDropped) { + bCreateNewCircle = true; + dlg.addCircle(cirDropped->circleDetails()); + atLeastOne = true; + + } else {//if (cirDropped) + IdentityWidget* idDropped = qobject_cast(flCurs); + if (idDropped){ + if (idDropped->havePGPDetail()){ + dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname()); + atLeastOne = true; + }//if (idDropped->havePGPDetail()) + + }//if (idDropped) + }//else (cirDropped) + + }//if (flCurs) + }//if (layoutItem) + }//for (int curs = 0; curs < count; ++curs) + }//if (layout) + + if (atLeastOne) { + if (bCreateNewCircle){ + dlg.editNewId(false); + } else {//if (bCreateNewCircle) + dlg.editExistingId(cirDest->groupInfo().mGroupId, false); + }//else (bCreateNewCircle) + + dlg.exec(); + + event->setDropAction(Qt::CopyAction); + event->accept(); + }//if (atLeastOne) + }//if (cirDest) +} + +void PeopleDialog::populatePictureFlowExt() + { + std::map::iterator it; + for (it=_ext_circles_widgets.begin(); it!=_ext_circles_widgets.end(); ++it) { + CircleWidget *item = it->second; + QPixmap pixmap = item->getImage(); + pictureFlowWidgetExternal->addSlide( pixmap ); + }//for (it=_ext_circles_widgets.begin(); it!=_ext_circles_widgets.end(); ++it) + pictureFlowWidgetExternal->setSlideSizeRatio(4/4.0); + } + +void PeopleDialog::populatePictureFlowInt() + { + std::map::iterator it; + for (it=_int_circles_widgets.begin(); it!=_int_circles_widgets.end(); ++it) { + CircleWidget *item = it->second; + QPixmap pixmap = item->getImage(); + pictureFlowWidgetInternal->addSlide( pixmap ); + }//for (it=_int_circles_widgets.begin(); it!=_int_circles_widgets.end(); ++it) + pictureFlowWidgetInternal->setSlideSizeRatio(4/4.0); +} diff --git a/retroshare-gui/src/gui/People/PeopleDialog.h b/retroshare-gui/src/gui/People/PeopleDialog.h index 977abf30b..dfb26f2d3 100644 --- a/retroshare-gui/src/gui/People/PeopleDialog.h +++ b/retroshare-gui/src/gui/People/PeopleDialog.h @@ -1,105 +1,109 @@ -/* - * 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 - -#include - -#include "gui/People/CircleWidget.h" -#include "gui/People/IdentityWidget.h" -#include "gui/gxs/RsGxsUpdateBroadcastPage.h" -#include "util/TokenQueue.h" - -#include "ui_PeopleDialog.h" - -#define IMAGE_IDENTITY ":/icons/friends_128.png" - -class PeopleDialog : public RsGxsUpdateBroadcastPage, public Ui::PeopleDialog, public TokenResponse -{ - Q_OBJECT - - public: - static const uint32_t PD_IDLIST ; - static const uint32_t PD_IDDETAILS ; - static const uint32_t PD_REFRESH ; - static const uint32_t PD_CIRCLES ; - - PeopleDialog(QWidget *parent = 0); - ~PeopleDialog(); - - virtual QIcon iconPixmap() const { return QIcon(IMAGE_IDENTITY) ; } //MainPage - virtual QString pageName() const { return tr("People") ; } //MainPage - virtual QString helpText() const { return ""; } //MainPage - - void loadRequest(const TokenQueue * /*queue*/, const TokenRequest &req) ; - - void requestIdList() ; - void requestCirclesList() ; - - void insertIdList(uint32_t token) ; - void insertCircles(uint32_t token) ; - - protected: - // Derives from RsGxsUpdateBroadcastPage - virtual void updateDisplay(bool complete); - //End RsGxsUpdateBroadcastPage - -private slots: - void iw_AddButtonClickedExt(); - void iw_AddButtonClickedInt(); - void addToCircleExt(); - void addToCircleInt(); - void cw_askForGXSIdentityWidget(RsGxsId gxs_id); - void cw_askForPGPIdentityWidget(RsPgpId pgp_id); - void cw_imageUpdatedExt(); - void cw_imageUpdatedInt(); - void fl_flowLayoutItemDroppedExt(QList flListItem, bool &bAccept); - void fl_flowLayoutItemDroppedInt(QList flListItem, bool &bAccept); - void pf_centerIndexChanged(int index); - void pf_mouseMoveOverSlideEvent(QMouseEvent* event, int slideIndex); - void pf_dragEnterEventOccurs(QDragEnterEvent *event); - void pf_dragMoveEventOccurs(QDragMoveEvent *event); - void pf_dropEventOccursExt(QDropEvent *event); - void pf_dropEventOccursInt(QDropEvent *event); - -private: - void reloadAll(); - void populatePictureFlowExt(); - void populatePictureFlowInt(); - - TokenQueue *mIdentityQueue; - TokenQueue *mCirclesQueue; - - FlowLayout *_flowLayoutExt; - std::map _gxs_identity_widgets ; - std::map _ext_circles_widgets ; - QList _extListCir; - - FlowLayout *_flowLayoutInt; - std::map _pgp_identity_widgets ; - std::map _int_circles_widgets ; - QList _intListCir; -}; - +/* + * 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 + +#include + +#include "gui/People/CircleWidget.h" +#include "gui/People/IdentityWidget.h" +#include "gui/gxs/RsGxsUpdateBroadcastPage.h" +#include "util/TokenQueue.h" + +#include "ui_PeopleDialog.h" + +#define IMAGE_IDENTITY ":/icons/friends_128.png" + +class PeopleDialog : public RsGxsUpdateBroadcastPage, public Ui::PeopleDialog, public TokenResponse +{ + Q_OBJECT + + public: + static const uint32_t PD_IDLIST ; + static const uint32_t PD_IDDETAILS ; + static const uint32_t PD_REFRESH ; + static const uint32_t PD_CIRCLES ; + + PeopleDialog(QWidget *parent = 0); + ~PeopleDialog(); + + virtual QIcon iconPixmap() const { return QIcon(IMAGE_IDENTITY) ; } //MainPage + virtual QString pageName() const { return tr("People") ; } //MainPage + virtual QString helpText() const { return ""; } //MainPage + + void loadRequest(const TokenQueue * /*queue*/, const TokenRequest &req) ; + + void requestIdList() ; + void requestCirclesList() ; + + void insertIdList(uint32_t token) ; + void insertCircles(uint32_t token) ; + + protected: + // Derives from RsGxsUpdateBroadcastPage + virtual void updateDisplay(bool complete); + //End RsGxsUpdateBroadcastPage + +private slots: + void iw_AddButtonClickedExt(); + void iw_AddButtonClickedInt(); + void addToCircleExt(); + void addToCircleInt(); + void cw_askForGXSIdentityWidget(RsGxsId gxs_id); + void cw_askForPGPIdentityWidget(RsPgpId pgp_id); + void cw_imageUpdatedExt(); + void cw_imageUpdatedInt(); + void fl_flowLayoutItemDroppedExt(QList flListItem, bool &bAccept); + void fl_flowLayoutItemDroppedInt(QList flListItem, bool &bAccept); + void pf_centerIndexChanged(int index); + void pf_mouseMoveOverSlideEvent(QMouseEvent* event, int slideIndex); + void pf_dragEnterEventOccurs(QDragEnterEvent *event); + void pf_dragMoveEventOccurs(QDragMoveEvent *event); + void pf_dropEventOccursExt(QDropEvent *event); + void pf_dropEventOccursInt(QDropEvent *event); + + void chatIdentity(); + void sendMessage(); + void personDetails(); + +private: + void reloadAll(); + void populatePictureFlowExt(); + void populatePictureFlowInt(); + + TokenQueue *mIdentityQueue; + TokenQueue *mCirclesQueue; + + FlowLayout *_flowLayoutExt; + std::map _gxs_identity_widgets ; + std::map _ext_circles_widgets ; + QList _extListCir; + + FlowLayout *_flowLayoutInt; + std::map _pgp_identity_widgets ; + std::map _int_circles_widgets ; + QList _intListCir; +}; + diff --git a/retroshare-gui/src/gui/People/PeopleDialog.ui b/retroshare-gui/src/gui/People/PeopleDialog.ui index 514217d1f..bf5b7239f 100644 --- a/retroshare-gui/src/gui/People/PeopleDialog.ui +++ b/retroshare-gui/src/gui/People/PeopleDialog.ui @@ -1,265 +1,259 @@ - - - PeopleDialog - - - - 0 - 0 - 727 - 524 - - - - - 0 - 0 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::Box - - - QFrame::Sunken - - - - 2 - - - - - - 0 - 0 - - - - - 24 - 24 - - - - - - - :/images/identity/identities_32.png - - - true - - - - - - - People - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 0 - - - - - 0 - 0 - - - - External - - - - - - Qt::Vertical - - - - - 0 - 250 - - - - true - - - - - 0 - 0 - 685 - 248 - - - - - - - - - - - - 0 - 0 - - - - Drag your circles or people to each other. - - - Qt::AlignCenter - - - - - - - true - - - - - - - - - - - - - 0 - 0 - - - - Internal - - - - - - Qt::Vertical - - - - - 0 - 250 - - - - true - - - - - 0 - 0 - 685 - 248 - - - - - - - - - - - - 0 - 0 - - - - Drag your circles or people to each other. - - - Qt::AlignCenter - - - - - - - true - - - - - - - - - - - - - - - - StyledLabel - QLabel -
gui/common/StyledLabel.h
-
- - PictureFlow - QWidget -
gui/common/PictureFlow.h
- 1 -
- - FlowLayoutWidget - QWidget -
gui/common/FlowLayout.h
- 1 -
-
- - - - -
+ + + PeopleDialog + + + + 0 + 0 + 727 + 524 + + + + + 0 + 0 + + + + + + + + 0 + + + + + QFrame::Box + + + QFrame::Sunken + + + + 2 + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + + + :/images/identity/identities_32.png + + + true + + + + + + + People + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + true + + + 1 + + + + + 0 + 0 + + + + People + + + + + + Qt::Vertical + + + + + 0 + 250 + + + + true + + + + + 0 + 0 + 701 + 248 + + + + + + + + + + + + 0 + 0 + + + + Drag your circles or people to each other. + + + Qt::AlignCenter + + + + + + + true + + + + + + + + + + + + + 0 + 0 + + + + Internal + + + + + + Qt::Vertical + + + + + 0 + 250 + + + + true + + + + + 0 + 0 + 701 + 248 + + + + + + + + + + + + 0 + 0 + + + + Drag your circles or people to each other. + + + Qt::AlignCenter + + + + + + + true + + + + + + + + + + + + + + + + StyledLabel + QLabel +
gui/common/StyledLabel.h
+
+ + PictureFlow + QWidget +
gui/common/PictureFlow.h
+ 1 +
+ + FlowLayoutWidget + QWidget +
gui/common/FlowLayout.h
+ 1 +
+
+ + + + +