diff --git a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp index 79e85d1cc..8ed0bfc47 100644 --- a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp +++ b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp @@ -25,16 +25,16 @@ #include #include -#include "gui/Circles/CreateCircleDialog.h" -#include "gui/gxs/GxsIdDetails.h" #include #include + +#include "gui/common/AvatarDefs.h" +#include "gui/Circles/CreateCircleDialog.h" +#include "gui/gxs/GxsIdDetails.h" #include "gui/Identity/IdDialog.h" #include "gui/Identity/IdEditDialog.h" -#include - //#define DEBUG_CREATE_CIRCLE_DIALOG 1 #define CREATECIRCLEDIALOG_CIRCLEINFO 2 @@ -258,8 +258,9 @@ void CreateCircleDialog::addMember() QString keyId = item->text(RSCIRCLEID_COL_KEYID); QString idtype = item->text(RSCIRCLEID_COL_IDTYPE); QString nickname = item->text(RSCIRCLEID_COL_NICKNAME); + QIcon icon = item->icon(RSCIRCLEID_COL_NICKNAME); - addMember(keyId, idtype, nickname); + addMember(keyId, idtype, nickname, icon); } void CreateCircleDialog::addMember(const RsGxsIdGroup &idGroup) @@ -267,15 +268,27 @@ void CreateCircleDialog::addMember(const RsGxsIdGroup &idGroup) QString keyId = QString::fromStdString(idGroup.mMeta.mGroupId.toStdString()); QString nickname = QString::fromUtf8(idGroup.mMeta.mGroupName.c_str()); QString idtype = tr("Anon Id"); + + QPixmap pixmap ; + + if(idGroup.mImage.mSize == 0 || !pixmap.loadFromData(idGroup.mImage.mData, idGroup.mImage.mSize, "PNG")) + pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(idGroup.mMeta.mGroupId))); + if (idGroup.mPgpKnown){ RsPeerDetails details; rsPeers->getGPGDetails(idGroup.mPgpId, details); idtype = QString::fromUtf8(details.name.c_str()); }//if (idGroup.mPgpKnown) - addMember(keyId, idtype, nickname); + addMember(keyId, idtype, nickname, QIcon(pixmap)); } void CreateCircleDialog::addMember(const QString& keyId, const QString& idtype, const QString& nickname ) +{ + QIcon icon; + addMember(keyId, idtype, nickname, icon); +} + +void CreateCircleDialog::addMember(const QString& keyId, const QString& idtype, const QString& nickname, const QIcon& icon) { QTreeWidget *tree = ui.treeWidget_membership; @@ -293,9 +306,9 @@ void CreateCircleDialog::addMember(const QString& keyId, const QString& idtype, QTreeWidgetItem *member = new QTreeWidgetItem(); member->setText(RSCIRCLEID_COL_NICKNAME, nickname); + member->setIcon(RSCIRCLEID_COL_NICKNAME, icon); member->setText(RSCIRCLEID_COL_KEYID, keyId); member->setText(RSCIRCLEID_COL_IDTYPE, idtype); - //member->setIcon(RSCIRCLEID_COL_NICKNAME, pixmap); tree->addTopLevelItem(member); @@ -317,14 +330,19 @@ void CreateCircleDialog::addCircle(const RsGxsCircleDetails &cirDetails) QString nickname = QString::fromUtf8(gxs_details.mNickname.c_str()); QString idtype = tr("Anon Id"); - addMember(keyId, idtype, nickname); + QPixmap pixmap ; + + if(gxs_details.mAvatar.mSize == 0 || !pixmap.loadFromData(gxs_details.mAvatar.mData, gxs_details.mAvatar.mSize, "PNG")) + pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(gxs_details.mId)); + + addMember(keyId, idtype, nickname, QIcon(pixmap)); }//if(!gxs_id.isNull() && rsIdentity->getIdDetails(gxs_id,gxs_details)) }//for (itUnknownPeers it = cirDetails.mUnknownPeers.begin() typedef std::set::const_iterator itAllowedPeers; for (itAllowedPeers it = cirDetails.mAllowedNodes.begin() ; it != cirDetails.mAllowedNodes.end() ; ++it ) - { + { RsPgpId gpg_id = *it; RsPeerDetails details ; if(!gpg_id.isNull() && rsPeers->getGPGDetails(gpg_id,details)) { @@ -333,7 +351,10 @@ void CreateCircleDialog::addCircle(const RsGxsCircleDetails &cirDetails) QString nickname = QString::fromUtf8(details.name.c_str()); QString idtype = tr("PGP Identity"); - addMember(keyId, idtype, nickname); + QPixmap avatar; + AvatarDefs::getAvatarFromGpgId(gpg_id, avatar); + + addMember(keyId, idtype, nickname, QIcon(avatar)); }//if(!gpg_id.isNull() && rsPeers->getGPGDetails(gpg_id,details)) }//for (itAllowedPeers it = cirDetails.mAllowedPeers.begin() @@ -756,7 +777,7 @@ void CreateCircleDialog::loadIdentities(uint32_t token) bool acceptAllPGP = ui.radioButton_ListAllPGP->isChecked(); //bool acceptKnownPGP = ui.radioButton_ListKnownPGP->isChecked(); - RsGxsIdGroup data; + RsGxsIdGroup idGroup; std::vector datavector; std::vector::iterator vit; if (!rsIdentity->getGroupData(token, datavector)) { @@ -765,67 +786,68 @@ void CreateCircleDialog::loadIdentities(uint32_t token) return; } - for(vit = datavector.begin(); vit != datavector.end(); ++vit) - { - data = (*vit); + for(vit = datavector.begin(); vit != datavector.end(); ++vit) + { + idGroup = (*vit); - /* do filtering */ - bool ok = false; - if (acceptAnonymous) - ok = true; - else if (acceptAllPGP) - ok = data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ; - else if (data.mPgpKnown) - ok = data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ; + /* do filtering */ + bool ok = false; + if (acceptAnonymous) + ok = true; + else if (acceptAllPGP) + ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ; + else if (idGroup.mPgpKnown) + ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ; - if (!ok) { + if (!ok) { #ifdef DEBUG_CREATE_CIRCLE_DIALOG - std::cerr << "CreateCircleDialog::insertIdentities() Skipping ID: " << data.mMeta.mGroupId; - std::cerr << std::endl; + std::cerr << "CreateCircleDialog::insertIdentities() Skipping ID: " << data.mMeta.mGroupId; + std::cerr << std::endl; #endif - continue; - } + continue; + } - QString keyId = QString::fromStdString(data.mMeta.mGroupId.toStdString()); - QString nickname = QString::fromUtf8(data.mMeta.mGroupName.c_str()); - QString idtype = tr("Anon Id"); - - QPixmap pixmap ; + QString keyId = QString::fromStdString(idGroup.mMeta.mGroupId.toStdString()); + QString nickname = QString::fromUtf8(idGroup.mMeta.mGroupName.c_str()); + QString idtype = tr("Anon Id"); - if(data.mImage.mSize == 0 || !pixmap.loadFromData(data.mImage.mData, data.mImage.mSize, "PNG")) - pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ; + QPixmap pixmap ; - if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) - { - if (data.mPgpKnown) { - RsPeerDetails details; - rsPeers->getGPGDetails(data.mPgpId, details); - idtype = QString::fromUtf8(details.name.c_str()); - } - else - idtype = tr("PGP Linked Id"); - - } + if(idGroup.mImage.mSize == 0 || !pixmap.loadFromData(idGroup.mImage.mData, idGroup.mImage.mSize, "PNG")) + pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(idGroup.mMeta.mGroupId))) ; - QTreeWidgetItem *item = new QTreeWidgetItem(); - item->setText(RSCIRCLEID_COL_NICKNAME, nickname); - item->setIcon(RSCIRCLEID_COL_NICKNAME, QIcon(pixmap)); - item->setText(RSCIRCLEID_COL_KEYID, keyId); - item->setText(RSCIRCLEID_COL_IDTYPE, idtype); - tree->addTopLevelItem(item); + if (idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) + { + if (idGroup.mPgpKnown) { + RsPeerDetails details; + rsPeers->getGPGDetails(idGroup.mPgpId, details); + idtype = QString::fromUtf8(details.name.c_str()); + } + else + idtype = tr("PGP Linked Id"); - // External Circle. - if (mIsExistingCircle) - { - // check if its in the circle. + } - // We use an explicit cast - // + QTreeWidgetItem *item = new QTreeWidgetItem(); + item->setText(RSCIRCLEID_COL_NICKNAME, nickname); + item->setIcon(RSCIRCLEID_COL_NICKNAME, QIcon(pixmap)); + item->setText(RSCIRCLEID_COL_KEYID, keyId); + item->setText(RSCIRCLEID_COL_IDTYPE, idtype); + tree->addTopLevelItem(item); - if ( mCircleGroup.mInvitedMembers.find(RsGxsId(data.mMeta.mGroupId)) != mCircleGroup.mInvitedMembers.end()) /* found it */ - addMember(keyId, idtype, nickname); - } - } + // External Circle. + if (mIsExistingCircle) + { + // check if its in the circle. + + // We use an explicit cast + // + + if ( mCircleGroup.mInvitedMembers.find(RsGxsId(idGroup.mMeta.mGroupId)) != mCircleGroup.mInvitedMembers.end()) /* found it */ + addMember(keyId, idtype, nickname, QIcon(pixmap)); + + } + } } void CreateCircleDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req) diff --git a/retroshare-gui/src/gui/Circles/CreateCircleDialog.h b/retroshare-gui/src/gui/Circles/CreateCircleDialog.h index 2cb050c04..2a6ce94de 100644 --- a/retroshare-gui/src/gui/Circles/CreateCircleDialog.h +++ b/retroshare-gui/src/gui/Circles/CreateCircleDialog.h @@ -41,6 +41,7 @@ public: void editNewId(bool isExternal); void editExistingId(const RsGxsGroupId &circleId, const bool &clearList = true, bool readonly=true); + void addMember(const QString &keyId, const QString &idtype, const QString &nickname, const QIcon &icon); void addMember(const QString &keyId, const QString &idtype, const QString &nickname); void addMember(const RsGxsIdGroup &idGroup); void addCircle(const RsGxsCircleDetails &cirDetails); diff --git a/retroshare-gui/src/gui/People/IdentityWidget.h b/retroshare-gui/src/gui/People/IdentityWidget.h index 8daebc6c1..c9ade98e3 100644 --- a/retroshare-gui/src/gui/People/IdentityWidget.h +++ b/retroshare-gui/src/gui/People/IdentityWidget.h @@ -42,6 +42,7 @@ public: const QString idtype() const { return _idtype; } const QString nickname() const { return _nickname; } const QString gxsId() const { return _gxsId; } + const QImage avatar() const { return _avatar; } signals: void addButtonClicked(); diff --git a/retroshare-gui/src/gui/People/PeopleDialog.cpp b/retroshare-gui/src/gui/People/PeopleDialog.cpp index 842627338..5098da953 100644 --- a/retroshare-gui/src/gui/People/PeopleDialog.cpp +++ b/retroshare-gui/src/gui/People/PeopleDialog.cpp @@ -557,7 +557,7 @@ void PeopleDialog::addToCircleInt() 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()); + dlg.addMember(idWidget->keyId(), idWidget->idtype(), idWidget->nickname(), QIcon(QPixmap::fromImage(idWidget->avatar())) ); }//if((itFound=_pgp_identity_widgets.find(pgp_id)) != _pgp_identity_widgets.end()) dlg.editExistingId(circle->groupInfo().mGroupId, false,false); @@ -769,7 +769,7 @@ void PeopleDialog::fl_flowLayoutItemDroppedInt(QListflListItem IdentityWidget* idDest = qobject_cast(dest); if (idDest) { if (idDest->havePGPDetail()){ - dlg.addMember(idDest->keyId(), idDest->idtype(), idDest->nickname()); + dlg.addMember(idDest->keyId(), idDest->idtype(), idDest->nickname(), QIcon(QPixmap::fromImage(idDest->avatar())) ); }//if (idDest->havePGPDetail()) }//if (idDest) @@ -790,7 +790,7 @@ void PeopleDialog::fl_flowLayoutItemDroppedInt(QListflListItem } else {//if (cirDropped) IdentityWidget* idDropped = qobject_cast(flCurs); if (idDropped){ - dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname()); + dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname(), QIcon(QPixmap::fromImage(idDropped->avatar())) ); }//if (idDropped) }//else (cirDropped) @@ -980,7 +980,7 @@ void PeopleDialog::pf_dropEventOccursInt(QDropEvent *event) IdentityWidget* idDropped = qobject_cast(flCurs); if (idDropped){ if (idDropped->havePGPDetail()){ - dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname()); + dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname(), QIcon(QPixmap::fromImage(idDropped->avatar())) ); atLeastOne = true; }//if (idDropped->havePGPDetail()) }//if (idDropped) @@ -1015,7 +1015,7 @@ void PeopleDialog::pf_dropEventOccursInt(QDropEvent *event) IdentityWidget* idDropped = qobject_cast(flCurs); if (idDropped){ if (idDropped->havePGPDetail()){ - dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname()); + dlg.addMember(idDropped->keyId(), idDropped->idtype(), idDropped->nickname(), QIcon(QPixmap::fromImage(idDropped->avatar())) ); atLeastOne = true; }//if (idDropped->havePGPDetail())