diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 9772702e5..fae14df66 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -36,6 +36,7 @@ #include "common/PeerDefs.h" #include "common/RSItemDelegate.h" #include "gui/gxs/GxsIdTreeWidgetItem.h" +#include "gui/gxs/GxsIdDetails.h" #include "util/DateTime.h" #include "util/RsProtectedTimer.h" #include "util/QtVersion.h" @@ -1058,7 +1059,7 @@ void MessagesDialog::insertMessages() continue; } } else { - item = new GxsIdRSTreeWidgetItem(mMessageCompareRole); + item = new GxsIdRSTreeWidgetItem(mMessageCompareRole,GxsIdDetails::ICON_TYPE_AVATAR); insertItem = true; } diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 097276afb..c9c3ec6cd 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -36,6 +36,7 @@ #include "gui/common/FriendSelectionDialog.h" #include "gui/gxs/GxsIdTreeWidgetItem.h" #include "gui/gxs/GxsIdChooser.h" +#include "gui/gxs/GxsIdDetails.h" #include "util/HandleRichText.h" #include @@ -394,7 +395,7 @@ void ChatLobbyDialog::updateParticipantsList() { // TE: Add Wigdet to participantsList with Checkbox, to mute Participant - widgetitem = new GxsIdRSTreeWidgetItem(mParticipantCompareRole); + widgetitem = new GxsIdRSTreeWidgetItem(mParticipantCompareRole,GxsIdDetails::ICON_TYPE_AVATAR); widgetitem->setId(it2->first,COLUMN_NAME, true) ; //widgetitem->setText(COLUMN_NAME, participant); widgetitem->setText(COLUMN_ACTIVITY,QString::number(time(NULL))); diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp index f79fe8a4d..562d3d428 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp @@ -869,45 +869,55 @@ QString nickname = details.mNickname.empty()?tr("[Unknown]"):QString::fromUtf8(d return comment; } -void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList &icons) +void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList &icons,uint32_t icon_types) { QPixmap pix ; - if(details.mAvatar.mSize == 0 || !pix.loadFromData(details.mAvatar.mData, details.mAvatar.mSize, "PNG")) + if(icon_types & ICON_TYPE_AVATAR) + { + if(details.mAvatar.mSize == 0 || !pix.loadFromData(details.mAvatar.mData, details.mAvatar.mSize, "PNG")) #if QT_VERSION < 0x040700 - pix = QPixmap::fromImage(makeDefaultIcon(details.mId)); + pix = QPixmap::fromImage(makeDefaultIcon(details.mId)); #else - pix.convertFromImage(makeDefaultIcon(details.mId)); + pix.convertFromImage(makeDefaultIcon(details.mId)); #endif - QIcon idIcon(pix); - //CreateIdIcon(id, idIcon); - icons.push_back(idIcon); + QIcon idIcon(pix); + //CreateIdIcon(id, idIcon); + icons.push_back(idIcon); + } - // ICON Logic. - QIcon baseIcon; - if (details.mPgpLinked) - { - if (details.mPgpKnown) - baseIcon = QIcon(IMAGE_PGPKNOWN); - else - baseIcon = QIcon(IMAGE_PGPUNKNOWN); - } - else - baseIcon = QIcon(IMAGE_ANON); + if(icon_types & ICON_TYPE_PGP) + { + // ICON Logic. + QIcon baseIcon; + if (details.mPgpLinked) + { + if (details.mPgpKnown) + baseIcon = QIcon(IMAGE_PGPKNOWN); + else + baseIcon = QIcon(IMAGE_PGPUNKNOWN); + } + else + baseIcon = QIcon(IMAGE_ANON); - icons.push_back(baseIcon); - // Add In RecognTags Icons. - std::list::const_iterator it; - for (it = details.mRecognTags.begin(); it != details.mRecognTags.end(); ++it) - { - QIcon tagIcon; - if (findTagIcon(it->tag_class, it->tag_type, tagIcon)) - { - icons.push_back(tagIcon); - } - } + icons.push_back(baseIcon); + } + + if(icon_types & ICON_TYPE_RECOGN) + { + // Add In RecognTags Icons. + std::list::const_iterator it; + for (it = details.mRecognTags.begin(); it != details.mRecognTags.end(); ++it) + { + QIcon tagIcon; + if (findTagIcon(it->tag_class, it->tag_type, tagIcon)) + { + icons.push_back(tagIcon); + } + } + } } void GxsIdDetails::GenerateCombinedPixmap(QPixmap &pixmap, const QList &icons, int iconSize) diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.h b/retroshare-gui/src/gui/gxs/GxsIdDetails.h index 1ff069d63..8f2de451b 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.h +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.h @@ -49,6 +49,11 @@ class GxsIdDetails : public QObject Q_OBJECT public: + static const int ICON_TYPE_AVATAR = 0x0001 ; + static const int ICON_TYPE_PGP = 0x0002 ; + static const int ICON_TYPE_RECOGN = 0x0004 ; + static const int ICON_TYPE_ALL = 0x0007 ; + GxsIdDetails(); virtual ~GxsIdDetails(); @@ -57,7 +62,7 @@ public: static QString getName(const RsIdentityDetails &details); static QString getComment(const RsIdentityDetails &details); - static void getIcons(const RsIdentityDetails &details, QList &icons); + static void getIcons(const RsIdentityDetails &details, QList &icons,uint32_t icon_types=ICON_TYPE_ALL); static QString getEmptyIdText(); static QString getLoadingText(const RsGxsId &id); diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp index f66af976a..056744060 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -27,14 +27,14 @@ #include "util/HandleRichText.h" /** Constructor */ -GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidget *parent) - : QObject(NULL), RSTreeWidgetItem(compareRole, parent), mColumn(0) +GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, uint32_t icon_mask,QTreeWidget *parent) + : QObject(NULL), RSTreeWidgetItem(compareRole, parent), mColumn(0), mIconTypeMask(icon_mask) { init(); } -GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidgetItem *parent) - : QObject(NULL), RSTreeWidgetItem(compareRole, parent), mColumn(0) +GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, uint32_t icon_mask,QTreeWidgetItem *parent) + : QObject(NULL), RSTreeWidgetItem(compareRole, parent), mColumn(0), mIconTypeMask(icon_mask) { init(); } @@ -69,7 +69,7 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde break; case GXS_ID_DETAILS_TYPE_DONE: - GxsIdDetails::getIcons(details, icons); + GxsIdDetails::getIcons(details, icons, item->iconTypeMask()); item->processResult(true); break; } diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h index a43ffec64..53a408878 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h @@ -27,6 +27,7 @@ #include #include "gui/common/RSTreeWidgetItem.h" +#include "gui/gxs/GxsIdDetails.h" /***** * NOTE: When the tree item is created within a thread you have to move the object @@ -39,15 +40,15 @@ class GxsIdRSTreeWidgetItem : public QObject, public RSTreeWidgetItem Q_OBJECT public: - GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidget *parent = NULL); - GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidgetItem *parent); + GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, uint32_t icon_mask=GxsIdDetails::ICON_TYPE_ALL,QTreeWidget *parent = NULL); + GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, uint32_t icon_mask,QTreeWidgetItem *parent); void setId(const RsGxsId &id, int column, bool retryWhenFailed); bool getId(RsGxsId &id); int idColumn() { return mColumn; } - void processResult(bool success); - + void processResult(bool success); + uint32_t iconTypeMask() const { return mIconTypeMask ;} private slots: void startProcess(); @@ -58,6 +59,7 @@ private: int mColumn; bool mIdFound; bool mRetryWhenFailed; + uint32_t mIconTypeMask; }; #endif diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index c38e53754..b5f50c86c 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -32,6 +32,7 @@ #include "gui/common/RSItemDelegate.h" #include "gui/settings/rsharesettings.h" #include "gui/gxs/GxsIdTreeWidgetItem.h" +#include "gui/gxs/GxsIdDetails.h" #include "util/HandleRichText.h" #include "CreateGxsForumMsg.h" #include "gui/msgs/MessageComposer.h" @@ -810,7 +811,7 @@ void GxsForumThreadWidget::fillThreadStatus(QString text) QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn) { - GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole); + GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_ALL); item->moveToThread(ui->threadTreeWidget->thread()); QString text; @@ -893,7 +894,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum QTreeWidgetItem *GxsForumThreadWidget::generateMissingItem(const RsGxsMessageId &msgId) { - GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole); + GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_ALL); item->setText(COLUMN_THREAD_TITLE, tr("[ ... Missing Message ... ]")); item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(msgId.toStdString())); item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING, true);