From 38af9244a6e0b2d1049c5b526ffdbaeb9117e26f Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 8 May 2020 23:21:38 +0200 Subject: [PATCH] added spam box --- libretroshare/src/retroshare/rsmsgs.h | 10 +++ libretroshare/src/rsitems/rsmsgitems.h | 1 + libretroshare/src/rsserver/p3msgs.cc | 6 +- libretroshare/src/rsserver/p3msgs.h | 1 + libretroshare/src/services/p3msgservice.cc | 5 ++ retroshare-gui/src/gui/images.qrc | 3 + retroshare-gui/src/gui/images/junk-on24.png | Bin 0 -> 1197 bytes retroshare-gui/src/gui/images/junk.png | Bin 0 -> 384 bytes retroshare-gui/src/gui/images/junk_off.png | Bin 0 -> 3326 bytes retroshare-gui/src/gui/images/junk_on.png | Bin 0 -> 3397 bytes retroshare-gui/src/gui/msgs/MessageModel.cpp | 23 +++++- retroshare-gui/src/gui/msgs/MessageModel.h | 13 ++-- .../src/gui/msgs/MessagesDialog.cpp | 71 +++++++++++++++--- retroshare-gui/src/gui/msgs/MessagesDialog.h | 4 +- 14 files changed, 120 insertions(+), 17 deletions(-) create mode 100644 retroshare-gui/src/gui/images/junk-on24.png create mode 100644 retroshare-gui/src/gui/images/junk.png create mode 100644 retroshare-gui/src/gui/images/junk_off.png create mode 100644 retroshare-gui/src/gui/images/junk_on.png diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index 1aca4fd1a..614a99707 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -62,6 +62,7 @@ #define RS_MSG_SIGNED 0x004000 /* message was signed and signature didn't check */ #define RS_MSG_LOAD_EMBEDDED_IMAGES 0x008000 /* load embedded images */ #define RS_MSG_PUBLISH_KEY 0x020000 /* publish key */ +#define RS_MSG_SPAM 0x040000 /* Message is marked as spam */ #define RS_MSG_SYSTEM (RS_MSG_USER_REQUEST | RS_MSG_FRIEND_RECOMMENDATION | RS_MSG_PUBLISH_KEY) @@ -703,6 +704,15 @@ public: */ virtual bool MessageStar(const std::string &msgId, bool mark) = 0; + /** + * @brief MessageJunk + * @jsonapi{development} + * @param[in] msgId + * @param[in] mark + * @return true on success + */ + virtual bool MessageJunk(const std::string &msgId, bool mark) = 0; + /** * @brief MessageLoadEmbeddedImages * @jsonapi{development} diff --git a/libretroshare/src/rsitems/rsmsgitems.h b/libretroshare/src/rsitems/rsmsgitems.h index 7757288e7..27447aec0 100644 --- a/libretroshare/src/rsitems/rsmsgitems.h +++ b/libretroshare/src/rsitems/rsmsgitems.h @@ -68,6 +68,7 @@ const uint32_t RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES = 0x00040000; const uint32_t RS_MSG_FLAGS_DECRYPTED = 0x00080000; const uint32_t RS_MSG_FLAGS_ROUTED = 0x00100000; const uint32_t RS_MSG_FLAGS_PUBLISH_KEY = 0x00200000; +const uint32_t RS_MSG_FLAGS_SPAM = 0x00400000; const uint32_t RS_MSG_FLAGS_SYSTEM = RS_MSG_FLAGS_USER_REQUEST | RS_MSG_FLAGS_FRIEND_RECOMMENDATION | RS_MSG_FLAGS_PUBLISH_KEY; diff --git a/libretroshare/src/rsserver/p3msgs.cc b/libretroshare/src/rsserver/p3msgs.cc index 48a694fb0..b877c0282 100644 --- a/libretroshare/src/rsserver/p3msgs.cc +++ b/libretroshare/src/rsserver/p3msgs.cc @@ -376,11 +376,15 @@ bool p3Msgs::getMessageTagTypes(MsgTagType& tags) } bool p3Msgs::MessageStar(const std::string &mid, bool star) - { return mMsgSrv->setMsgFlag(mid, star ? RS_MSG_FLAGS_STAR : 0, RS_MSG_FLAGS_STAR); } +bool p3Msgs::MessageJunk(const std::string &mid, bool junk) +{ + return mMsgSrv->setMsgFlag(mid, junk ? RS_MSG_FLAGS_SPAM : 0, RS_MSG_FLAGS_SPAM); +} + bool p3Msgs::setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color) { return mMsgSrv->setMessageTagType(tagId, text, rgb_color); diff --git a/libretroshare/src/rsserver/p3msgs.h b/libretroshare/src/rsserver/p3msgs.h index 955018d26..91d044ee5 100644 --- a/libretroshare/src/rsserver/p3msgs.h +++ b/libretroshare/src/rsserver/p3msgs.h @@ -78,6 +78,7 @@ public: virtual bool MessageReplied(const std::string &mid, bool replied); virtual bool MessageForwarded(const std::string &mid, bool forwarded); virtual bool MessageStar(const std::string &mid, bool star); + virtual bool MessageJunk(const std::string &mid, bool junk); virtual bool MessageLoadEmbeddedImages(const std::string &mid, bool load); virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId); diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index a04ba5fce..01a825bb3 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -1737,6 +1737,7 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi) if (msg->msgFlags & RS_MSG_FLAGS_REPLIED) mi.msgflags |= RS_MSG_REPLIED; if (msg->msgFlags & RS_MSG_FLAGS_FORWARDED) mi.msgflags |= RS_MSG_FORWARDED; if (msg->msgFlags & RS_MSG_FLAGS_STAR) mi.msgflags |= RS_MSG_STAR; + if (msg->msgFlags & RS_MSG_FLAGS_SPAM) mi.msgflags |= RS_MSG_SPAM; if (msg->msgFlags & RS_MSG_FLAGS_USER_REQUEST) mi.msgflags |= RS_MSG_USER_REQUEST; if (msg->msgFlags & RS_MSG_FLAGS_FRIEND_RECOMMENDATION) mi.msgflags |= RS_MSG_FRIEND_RECOMMENDATION; if (msg->msgFlags & RS_MSG_FLAGS_PUBLISH_KEY) mi.msgflags |= RS_MSG_PUBLISH_KEY; @@ -1831,6 +1832,10 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis) { mis.msgflags |= RS_MSG_STAR; } + if (msg->msgFlags & RS_MSG_FLAGS_SPAM) + { + mis.msgflags |= RS_MSG_SPAM; + } if (msg->msgFlags & RS_MSG_FLAGS_USER_REQUEST) { mis.msgflags |= RS_MSG_USER_REQUEST; diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index f33664066..52dbea31d 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -214,6 +214,9 @@ images/im-user-busy.png images/im-user-inactive.png images/informations_24x24.png + images/junk.png + images/junk_on.png + images/junk_off.png images/connect_friend.png images/kalarm.png images/kbackgammon.png diff --git a/retroshare-gui/src/gui/images/junk-on24.png b/retroshare-gui/src/gui/images/junk-on24.png new file mode 100644 index 0000000000000000000000000000000000000000..155c2a23095a17a74db033f5cf0c24b02ecf0ee5 GIT binary patch literal 1197 zcmV;e1XBBnP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;VI^GGzb&1RhC5K~zXftyO9zR4Qv(}c$)RAiy z!tz%zzTEfs_m2DY+}HQdlPLIX&))ZWpU?Aop6C6(w=?`#1j}M0$W}9VZb8C%WEaUc zu%o#F2}TCX?7L|V&??YsWue)F#Ii|r)W5?n`pcsHwBN%*vj>T1kl>iQGigfg+zi^w zbe77(vjYjGkl-!#{rOXYOUI$zDR7&Gbr8ovmdV_igOZFSc2zC61^nmhF*SS+TC)>V zW%g5yqJuc?WPcMsgB{Hblu$HP9wTVo??O9Mt((7L6-^LZ#V9(+f0is5+`W99)^v6} zJ*4gS2x)uFsN#7B+CVMD_bkx7ZpaOfL2}zaWi%bcT|ivXKkz}2*6ZZ|`|Fz68oh?w zX5+N8HIVi?AXY>|{qkkVO$Fe#MGr8V4&u(^+zEleP$&3Z%OvvMEOd9=*lgR$RWA)_ zy*nUPSs_)&KxubDX)DCdEw)LD+ZZ*(%^$1GrU_~wx2^^GJ~ATK1g z3BI8XkZIChN`o_PW(a`6Wy$JboxK2j%7hDv$@IJ{8I*Sx`MWRA4!juU10scj0D34hCN_ z<9byh)Pvd7#A0eD5tlbwILdc2sqh$BXS&7Jub?Y>7)oOX)Fy{6E_W<}cp?>oHyzUH zRp2`w!Zw)nN)c66&kxnDk$;r$~)a3&V~GWHpFjI!S^M= zcQy{b{&)!8iy?JnLT$~}rx5B=(7o26d7Xv`CKVnh*BIOvN^Oejq3bxb3~EcBF2r{y zV)8pXCVsMjJAW?~i--7iI+SC?p(#fz7ooe*beYNA9aJFB>oQKnA2d-BD^0NwVrLrtJ{*t_IM7!dAyV$sOlEoz(b@mJnGd}ZwK-3}f5DrC$$?mK zKia^Zivi!804X%V(HvZQD^8{EJ6QV6Knb4yl6&~Ex+PFPdqD4&@3~L!JoGJulgZ%Q zGV$}4`J%VbG!mMerOq5(PD8QRW%6Cz8mA4{CSttxesIT=F}g1SLzQvC-eR*rjT|KL z|Nj?C$w^&KV?|F<#J8thMj!3{w7)`y8!7e#qs<*i)Wo(kfWhz&@hOgNo>(ry00000 LNkvXXu0mjfCZjXc literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/images/junk.png b/retroshare-gui/src/gui/images/junk.png new file mode 100644 index 0000000000000000000000000000000000000000..4fbd66128ca5889ce9e5940a85e26ee8b5505c76 GIT binary patch literal 384 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf2?p zUk71ECym(^Ktah8*NBqf{Irtt#G+J&^73-M%)IR4>^(8z%CwSAVh)#BcChRVW8B7d);NJjqG0;V zO^2%Mb0?_v2k$c2y#0*bv@McMDy9vd&uVww;ww<|yvXM6V0${6?*j)<<6({q<-E3@ zf49tSXkOBbEo)GV)aL06j+xuLHn^G`J?hM| zgKb~9iGJg3r2}W;8oTWkydT^-bFVn?pOvab? YxTAHd$F4_$z<^-zboFyt=akR{0DLcxqyPW_ literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/images/junk_off.png b/retroshare-gui/src/gui/images/junk_off.png new file mode 100644 index 0000000000000000000000000000000000000000..9b838c89f2995ab7820725a7c87e39728fc52712 GIT binary patch literal 3326 zcmVKLZ*U+IBfRs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26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0007TNkl~xFGsxh zhzQd#!@(TRTt(C(A}7M-b+@HtpJj^Nh;L{8z$tf zk53%l>mVzdt_s9>vXHoqL@h*WI#-~*pnf^-fd zg|u3TYUuakFp3gP>5!;JgCo!DS05bl-1mR$s;Zvlb&Vvm1WAgdv-qyZ%@)keL+|Ju z(n;BIF?reiw(kp*Qs4aNjn4=y#BFRhL-)7PN8X})Tez7L7sWhzWs7mq+}bCwQ`A3< zwwo7EUTTMO_()@u65Zdzbt;U~{PB2FPl{&k(#nfp4$Q*JQumWc$=xHp`1r!3eM&~&2iB`B00000NkvXXu0mjfz+iB| literal 0 HcmV?d00001 diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index f5680effe..5e35a7c56 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -42,6 +42,9 @@ #define IMAGE_STAR_ON ":/images/star-on-16.png" #define IMAGE_STAR_OFF ":/images/star-off-16.png" +#define IMAGE_SPAM ":/images/junk.png" +#define IMAGE_SPAM_ON ":/images/junk_on.png" +#define IMAGE_SPAM_OFF ":/images/junk_off.png" std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere @@ -173,6 +176,7 @@ QVariant RsMessageModel::headerData(int section, Qt::Orientation orientation, in switch(section) { case COLUMN_THREAD_STAR: return FilesDefs::getIconFromQtResourcePath(IMAGE_STAR_ON); + case COLUMN_THREAD_SPAM: return FilesDefs::getIconFromQtResourcePath(IMAGE_SPAM); case COLUMN_THREAD_READ: return FilesDefs::getIconFromQtResourcePath(":/images/message-state-header.png"); case COLUMN_THREAD_ATTACHMENT: return FilesDefs::getIconFromQtResourcePath(":/icons/png/attachements.png"); default: @@ -189,6 +193,7 @@ QVariant RsMessageModel::headerData(int section, Qt::Orientation orientation, in case COLUMN_THREAD_DATE: return tr("Click to sort by date"); case COLUMN_THREAD_TAGS: return tr("Click to sort by tags"); case COLUMN_THREAD_STAR: return tr("Click to sort by star"); + case COLUMN_THREAD_SPAM: return tr("Click to sort by junk status"); default: return QVariant(); } @@ -336,7 +341,8 @@ bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int colum (mQuickViewFilter==QUICK_VIEW_ALL) || (std::find(fmpe.msgtags.begin(),fmpe.msgtags.end(),mQuickViewFilter) != fmpe.msgtags.end()) || (mQuickViewFilter==QUICK_VIEW_STARRED && (fmpe.msgflags & RS_MSG_STAR)) - || (mQuickViewFilter==QUICK_VIEW_SYSTEM && (fmpe.msgflags & RS_MSG_SYSTEM)); + || (mQuickViewFilter==QUICK_VIEW_SYSTEM && (fmpe.msgflags & RS_MSG_SYSTEM)) + || (mQuickViewFilter==QUICK_VIEW_SPAM && (fmpe.msgflags & RS_MSG_SPAM)); #ifdef DEBUG_MESSAGE_MODEL std::cerr << "Passes filter: type=" << mFilterType << " s=\"" << s.toStdString() << "MsgFlags=" << fmpe.msgflags << " msgtags=" ; foreach(uint32_t i,fmpe.msgtags) std::cerr << i << " " ; @@ -434,6 +440,8 @@ QVariant RsMessageModel::sortRole(const Rs::Msgs::MsgInfoSummary& fmpe,int colum case COLUMN_THREAD_STAR: return QVariant((fmpe.msgflags & RS_MSG_STAR)? 1:0); + case COLUMN_THREAD_SPAM: return QVariant((fmpe.msgflags & RS_MSG_SPAM)? 1:0); + case COLUMN_THREAD_AUTHOR:{ QString name; @@ -453,6 +461,7 @@ QVariant RsMessageModel::displayRole(const Rs::Msgs::MsgInfoSummary& fmpe,int co case COLUMN_THREAD_ATTACHMENT:return QVariant(QString::number(fmpe.count)); case COLUMN_THREAD_STAR: + case COLUMN_THREAD_SPAM: case COLUMN_THREAD_READ:return QVariant(); case COLUMN_THREAD_DATE:{ QDateTime qtime; @@ -551,6 +560,9 @@ QVariant RsMessageModel::decorationRole(const Rs::Msgs::MsgInfoSummary& fmpe,int case COLUMN_THREAD_STAR: return FilesDefs::getIconFromQtResourcePath((fmpe.msgflags & RS_MSG_STAR) ? (IMAGE_STAR_ON ): (IMAGE_STAR_OFF)); + case COLUMN_THREAD_SPAM: + return FilesDefs::getIconFromQtResourcePath((fmpe.msgflags & RS_MSG_SPAM) ? (IMAGE_SPAM_ON ): (IMAGE_SPAM_OFF)); + case COLUMN_THREAD_AUTHOR://Return icon as place holder. return FilesDefs::getIconFromGxsIdCache(RsGxsId(fmpe.srcId.toStdString()),QIcon(), exist); } @@ -680,6 +692,15 @@ void RsMessageModel::setMsgStar(const QModelIndex& i,bool star) emit dataChanged(i.sibling(i.row(),0),i.sibling(i.row(),COLUMN_THREAD_NB_COLUMNS-1)); } +void RsMessageModel::setMsgJunk(const QModelIndex& i,bool junk) +{ + preMods(); + rsMsgs->MessageJunk(i.data(MsgIdRole).toString().toStdString(),junk); + + emit dataChanged(i.sibling(i.row(),0),i.sibling(i.row(),COLUMN_THREAD_NB_COLUMNS-1)); +} + + QModelIndex RsMessageModel::getIndexOfMessage(const std::string& mid) const { // Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map. diff --git a/retroshare-gui/src/gui/msgs/MessageModel.h b/retroshare-gui/src/gui/msgs/MessageModel.h index d6939fff1..262f53900 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.h +++ b/retroshare-gui/src/gui/msgs/MessageModel.h @@ -58,11 +58,12 @@ public: COLUMN_THREAD_SUBJECT = 0x02, COLUMN_THREAD_READ = 0x03, COLUMN_THREAD_AUTHOR = 0x04, - COLUMN_THREAD_DATE = 0x05, - COLUMN_THREAD_TAGS = 0x06, - COLUMN_THREAD_MSGID = 0x07, - COLUMN_THREAD_NB_COLUMNS = 0x08, - COLUMN_THREAD_CONTENT = 0x08, + COLUMN_THREAD_SPAM = 0x05, + COLUMN_THREAD_DATE = 0x06, + COLUMN_THREAD_TAGS = 0x07, + COLUMN_THREAD_MSGID = 0x08, + COLUMN_THREAD_NB_COLUMNS = 0x0a, + COLUMN_THREAD_CONTENT = 0x09 }; enum QuickViewFilter { @@ -74,6 +75,7 @@ public: QUICK_VIEW_LATER = 0x05, QUICK_VIEW_STARRED = 0x06, QUICK_VIEW_SYSTEM = 0x07, + QUICK_VIEW_SPAM = 0x08, QUICK_VIEW_USER = 100 }; @@ -147,6 +149,7 @@ public: // control over message flags and so on. This is handled by the model because it will allow it to update accordingly void setMsgReadStatus(const QModelIndex& i, bool read_status); void setMsgStar(const QModelIndex& index,bool star) ; + void setMsgJunk(const QModelIndex& index,bool junk) ; public slots: void updateMessages(); diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index a53b582c5..5c73b2e67 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -61,6 +61,8 @@ #define IMAGE_DECRYPTMESSAGE ":/images/decrypt-mail.png" #define IMAGE_AUTHOR_INFO ":/images/info16.png" #define IMAGE_NOTFICATION ":/icons/notification.png" +#define IMAGE_SPAM_ON ":/images/junk_on.png" +#define IMAGE_SPAM_OFF ":/images/junk_off.png" #define IMAGE_INBOX ":/images/folder-inbox.png" #define IMAGE_OUTBOX ":/images/folder-outbox.png" @@ -79,6 +81,7 @@ #define QUICKVIEW_STATIC_ID_STARRED 1 #define QUICKVIEW_STATIC_ID_SYSTEM 2 +#define QUICKVIEW_STATIC_ID_SPAM 3 #define ROW_INBOX 0 #define ROW_OUTBOX 1 @@ -194,6 +197,7 @@ MessagesDialog::MessagesDialog(QWidget *parent) msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_STAR, fm.width('0')*1.5); msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_ATTACHMENT, fm.width('0')*1.5); msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_READ, fm.width('0')*1.5); + msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_SPAM, fm.width('0')*1.5); msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_SUBJECT, fm.width("You have a message")*3.0); msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_AUTHOR, fm.width("[Retroshare]")*1.1); @@ -206,6 +210,7 @@ MessagesDialog::MessagesDialog(QWidget *parent) QHeaderView_setSectionResizeModeColumn(msgwheader, RsMessageModel::COLUMN_THREAD_STAR, QHeaderView::Fixed); QHeaderView_setSectionResizeModeColumn(msgwheader, RsMessageModel::COLUMN_THREAD_ATTACHMENT, QHeaderView::Fixed); QHeaderView_setSectionResizeModeColumn(msgwheader, RsMessageModel::COLUMN_THREAD_READ, QHeaderView::Fixed); + QHeaderView_setSectionResizeModeColumn(msgwheader, RsMessageModel::COLUMN_THREAD_SPAM, QHeaderView::Fixed); ui.messageTreeWidget->setSortingEnabled(true); @@ -432,6 +437,16 @@ void MessagesDialog::fillQuickView() itemToSelect = item; } + item = new QListWidgetItem(tr("Spam"), ui.quickViewWidget); + item->setIcon(QIcon(IMAGE_SPAM_ON)); + item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_STATIC); + item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_SPAM); + item->setData(ROLE_QUICKVIEW_TEXT, item->text()); // for updateMessageSummaryList + + if (selectedType == QUICKVIEW_TYPE_STATIC && selectedId == QUICKVIEW_STATIC_ID_SPAM) { + itemToSelect = item; + } + for (tag = tags.types.begin(); tag != tags.types.end(); ++tag) { text = TagDefs::name(tag->first, tag->second.first); @@ -469,7 +484,7 @@ int MessagesDialog::getSelectedMessages(QList& mid) return mid.size(); } -int MessagesDialog::getSelectedMsgCount (QList *items, QList *itemsRead, QList *itemsUnread, QList *itemsStar) +int MessagesDialog::getSelectedMsgCount (QList *items, QList *itemsRead, QList *itemsUnread, QList *itemsStar, QList *itemsJunk) { QModelIndexList qmil = ui.messageTreeWidget->selectionModel()->selectedRows(); @@ -477,6 +492,7 @@ int MessagesDialog::getSelectedMsgCount (QList *items, QListclear(); if (itemsUnread) itemsUnread->clear(); if (itemsStar) itemsStar->clear(); + if (itemsJunk) itemsJunk->clear(); foreach(const QModelIndex& m, qmil) { @@ -511,6 +527,14 @@ bool MessagesDialog::hasMessageStar(const QModelIndex& real_index) return real_index.data(RsMessageModel::MsgFlagsRole).toInt() & RS_MSG_STAR; } +bool MessagesDialog::hasMessageSpam(const QModelIndex& real_index) +{ + if (!real_index.isValid()) + return false; + + return real_index.data(RsMessageModel::MsgFlagsRole).toInt() & RS_MSG_SPAM; +} + void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/) { std::string cid; @@ -529,8 +553,9 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/) QList itemsRead; QList itemsUnread; QList itemsStar; + QList itemsJunk; - int nCount = getSelectedMsgCount (NULL, &itemsRead, &itemsUnread, &itemsStar); + int nCount = getSelectedMsgCount (NULL, &itemsRead, &itemsUnread, &itemsStar, &itemsJunk); /** Defines the actions for the context menu */ @@ -576,6 +601,11 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/) action->setChecked(itemsStar.size()); connect(action, SIGNAL(triggered(bool)), this, SLOT(markWithStar(bool))); + action = contextMnu.addAction(tr("Mark as Junk")); + action->setCheckable(true); + action->setChecked(itemsStar.size()); + connect(action, SIGNAL(triggered(bool)), this, SLOT(markWithJunk(bool))); + contextMnu.addSeparator(); // add tags @@ -801,23 +831,27 @@ void MessagesDialog::changeQuickView(int newrow) ui.tabWidget->setTabText(0, tr("System")); ui.tabWidget->setTabIcon(0, QIcon(IMAGE_SYSTEM)); break; - case 0x02: f = RsMessageModel::QUICK_VIEW_IMPORTANT; + case 0x02: f = RsMessageModel::QUICK_VIEW_SPAM ; + ui.tabWidget->setTabText(0, tr("Spam")); + ui.tabWidget->setTabIcon(0, QIcon(IMAGE_SPAM_ON)); + break; + case 0x03: f = RsMessageModel::QUICK_VIEW_IMPORTANT; ui.tabWidget->setTabText(0, tr("Important")); ui.tabWidget->setTabIcon(0, QIcon(IMAGE_FOLDER)); break; - case 0x03: f = RsMessageModel::QUICK_VIEW_WORK ; + case 0x04: f = RsMessageModel::QUICK_VIEW_WORK ; ui.tabWidget->setTabText(0, tr("Work")); ui.tabWidget->setTabIcon(0, QIcon(IMAGE_FOLDER)); break; - case 0x04: f = RsMessageModel::QUICK_VIEW_PERSONAL ; + case 0x05: f = RsMessageModel::QUICK_VIEW_PERSONAL ; ui.tabWidget->setTabText(0, tr("Personal")); ui.tabWidget->setTabIcon(0, QIcon(IMAGE_FOLDER)); break; - case 0x05: f = RsMessageModel::QUICK_VIEW_TODO ; + case 0x06: f = RsMessageModel::QUICK_VIEW_TODO ; ui.tabWidget->setTabText(0, tr("Todo")); ui.tabWidget->setTabIcon(0, QIcon(IMAGE_FOLDER)); break; - case 0x06: f = RsMessageModel::QUICK_VIEW_LATER ; + case 0x07: f = RsMessageModel::QUICK_VIEW_LATER ; ui.tabWidget->setTabText(0, tr("Later")); ui.tabWidget->setTabIcon(0, QIcon(IMAGE_FOLDER)); break; @@ -873,6 +907,11 @@ void MessagesDialog::clicked(const QModelIndex& proxy_index) mMessageModel->setMsgStar(real_index, !hasMessageStar(proxy_index)); return; } + case RsMessageModel::COLUMN_THREAD_SPAM: + { + mMessageModel->setMsgJunk(real_index, !hasMessageSpam(proxy_index)); + return; + } } // show current message directly @@ -921,7 +960,7 @@ void MessagesDialog::updateCurrentMessage() void MessagesDialog::markAsRead() { QList itemsUnread; - getSelectedMsgCount (NULL, NULL, &itemsUnread, NULL); + getSelectedMsgCount (NULL, NULL, &itemsUnread, NULL, NULL); foreach(const QModelIndex& index,itemsUnread) mMessageModel->setMsgReadStatus(index,true); @@ -932,7 +971,7 @@ void MessagesDialog::markAsRead() void MessagesDialog::markAsUnread() { QList itemsRead; - getSelectedMsgCount (NULL, &itemsRead, NULL, NULL); + getSelectedMsgCount (NULL, &itemsRead, NULL, NULL, NULL); foreach(const QModelIndex& index,itemsRead) mMessageModel->setMsgReadStatus(index,false); @@ -948,7 +987,13 @@ void MessagesDialog::markWithStar(bool checked) mMessageModel->setMsgStar(index, checked); } +void MessagesDialog::markWithJunk(bool checked) +{ + QModelIndexList lst = ui.messageTreeWidget->selectionModel()->selectedRows(); + foreach(const QModelIndex& index,lst) + mMessageModel->setMsgJunk(index, checked); +} void MessagesDialog::insertMsgTxtAndFiles(const QModelIndex& proxy_index) { @@ -1117,6 +1162,7 @@ void MessagesDialog::updateMessageSummaryList() unsigned int trashboxCount = 0; unsigned int starredCount = 0; unsigned int systemCount = 0; + unsigned int spamCount = 0; /* calculating the new messages */ @@ -1145,6 +1191,10 @@ void MessagesDialog::updateMessageSummaryList() ++systemCount; } + if (it->msgflags & RS_MSG_SPAM) { + ++spamCount; + } + /* calculate box */ if (it->msgflags & RS_MSG_TRASH) { ++trashboxCount; @@ -1304,6 +1354,9 @@ void MessagesDialog::updateMessageSummaryList() case QUICKVIEW_STATIC_ID_SYSTEM: text += " (" + QString::number(systemCount) + ")"; break; + case QUICKVIEW_STATIC_ID_SPAM: + text += " (" + QString::number(spamCount) + ")"; + break; } item->setText(text); diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index 766268a79..abc80349d 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -94,6 +94,7 @@ private slots: void markAsRead(); void markAsUnread(); void markWithStar(bool checked); + void markWithJunk(bool checked); void emptyTrash(); @@ -118,9 +119,10 @@ private: bool getCurrentMsg(std::string &cid, std::string &mid); void setMsgAsReadUnread(const QList &items, bool read); - int getSelectedMsgCount (QList *items, QList *itemsRead, QList *itemsUnread, QList *itemsStar); + int getSelectedMsgCount (QList *items, QList *itemsRead, QList *itemsUnread, QList *itemsStar, QList *itemsJunk); bool isMessageRead(const QModelIndex &real_index); bool hasMessageStar(const QModelIndex &index); + bool hasMessageSpam(const QModelIndex &index); void processSettings(bool load);