void MessageWidget::messagesTagsChanged() { showTagLabels(); }
void MessageWidget::fill(const std::string &msgId) { // if (currMsgId == msgId) { // // message doesn't changed // return; // } currMsgId = msgId; if (currMsgId.empty()) { /* blank it */ ui.dateText-> setText(""); ui.toText->setText(""); ui.fromText->setText(""); ui.filesText->setText(""); ui.ccLabel->setVisible(false); ui.ccText->setVisible(false); ui.ccText->clear(); ui.bccLabel->setVisible(false); ui.bccText->setVisible(false); ui.bccText->clear(); ui.subjectText->setText(""); ui.msgList->clear(); ui.msgText->clear(); ui.msgText->resetImagesStatus(false); clearTagLabels(); currMsgFlags = 0; return; } clearTagLabels(); MessageInfo msgInfo; if (rsMail->getMessage(currMsgId, msgInfo) == false) { std::cerr << "MessageWidget::fill() Couldn't find Msg" << std::endl; return; } if (msgInfo.msgflags & RS_MSG_USER_REQUEST){ ui.inviteFrame->show(); } else { ui.inviteFrame->hide(); } const std::list<FileInfo> &recList = msgInfo.files; std::list<FileInfo>::const_iterator it; ui.msgList->clear(); QList<QTreeWidgetItem*> items; for (it = recList.begin(); it != recList.end(); ++it) { QTreeWidgetItem *item = new QTreeWidgetItem; item->setText(COLUMN_FILE_NAME, QString::fromUtf8(it->fname.c_str())); item->setText(COLUMN_FILE_SIZE, misc::friendlyUnit(it->size)); item->setData(COLUMN_FILE_SIZE, Qt::UserRole, QVariant(qulonglong(it->size)) ); item->setText(COLUMN_FILE_HASH, QString::fromStdString(it->hash.toStdString())); item->setTextAlignment( COLUMN_FILE_SIZE, Qt::AlignRight ); /* add to the list */ items.append(item); } /* add the items in! */ ui.msgList->insertTopLevelItems(0, items); /* iterate through the sources */ RetroShareLink link; QString text; for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } for(std::set<RsGxsId >::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } ui.toText->setText(text); if (!msgInfo.rspeerid_msgcc.empty() || !msgInfo.rsgxsid_msgcc.empty()) { ui.ccLabel->setVisible(true); ui.ccText->setVisible(true); text.clear(); for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgcc.begin(); pit != msgInfo.rspeerid_msgcc.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } for(std::set<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgcc.begin(); pit != msgInfo.rsgxsid_msgcc.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } ui.ccText->setText(text); } else { ui.ccLabel->setVisible(false); ui.ccText->setVisible(false); ui.ccText->clear(); } if (!msgInfo.rspeerid_msgbcc.empty() || !msgInfo.rsgxsid_msgbcc.empty()) { ui.bccLabel->setVisible(true); ui.bccText->setVisible(true); text.clear(); for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgbcc.begin(); pit != msgInfo.rspeerid_msgbcc.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } for(std::set<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgbcc.begin(); pit != msgInfo.rsgxsid_msgbcc.end(); ++pit) { link = RetroShareLink::createMessage(*pit, ""); if (link.valid()) text += link.toHtml() + " "; } ui.bccText->setText(text); } else { ui.bccLabel->setVisible(false); ui.bccText->setVisible(false); ui.bccText->clear(); } ui.dateText->setText(DateTime::formatDateTime(msgInfo.ts)); RsPeerId ownId = rsPeers->getOwnId(); QString tooltip_string ; // if ((msgInfo.msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) // outgoing message are from me // { // tooltip_string = PeerDefs::rsidFromId(ownId) ; // link.createMessage(ownId, ""); // } if(msgInfo.msgflags & RS_MSG_DISTANT) // distant message { tooltip_string = PeerDefs::rsidFromId(msgInfo.rsgxsid_srcId) ; link = RetroShareLink::createMessage(msgInfo.rsgxsid_srcId, ""); } else { tooltip_string = PeerDefs::rsidFromId(msgInfo.rspeerid_srcId) ; link = RetroShareLink::createMessage(msgInfo.rspeerid_srcId, ""); } if ((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.rspeerid_srcId == ownId) { ui.fromText->setText("RetroShare"); if (toolButtonReply) toolButtonReply->setEnabled(false); } else { ui.fromText->setText(link.toHtml()); ui.fromText->setToolTip(tooltip_string) ; if (toolButtonReply) toolButtonReply->setEnabled(true); } ui.subjectText->setText(QString::fromUtf8(msgInfo.title.c_str())); // emoticons disabled because of crazy cost. //text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromUtf8(msgInfo.msg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromUtf8(msgInfo.msg.c_str()), RSHTML_FORMATTEXT_EMBED_LINKS); ui.msgText->resetImagesStatus(Settings->getMsgLoadEmbeddedImages() || (msgInfo.msgflags & RS_MSG_LOAD_EMBEDDED_IMAGES)); ui.msgText->setHtml(text); ui.filesText->setText(QString("%1").arg(msgInfo.count)); ui.filesSize->setText(QString(misc::friendlyUnit(msgInfo.size))); showTagLabels(); currMsgFlags = msgInfo.msgflags; }
void MessageWidget::fill(const std::string &msgId) { if (currMsgId == msgId) { // message doesn't changed return; } currMsgId = msgId; if (currMsgId.empty()) { /* blank it */ ui.dateText-> setText(""); ui.toText->setText(""); ui.fromText->setText(""); ui.filesText->setText(""); ui.cclabel->setVisible(false); ui.ccText->setVisible(false); ui.ccText->clear(); ui.bcclabel->setVisible(false); ui.bccText->setVisible(false); ui.bccText->clear(); ui.subjectText->setText(""); ui.msgList->clear(); ui.msgText->clear(); clearTagLabels(); return; } clearTagLabels(); MessageInfo msgInfo; if (rsMsgs->getMessage(currMsgId, msgInfo) == false) { std::cerr << "MessageWidget::fill() Couldn't find Msg" << std::endl; return; } const std::list<FileInfo> &recList = msgInfo.files; std::list<FileInfo>::const_iterator it; ui.msgList->clear(); QList<QTreeWidgetItem*> items; for (it = recList.begin(); it != recList.end(); it++) { QTreeWidgetItem *item = new QTreeWidgetItem; item->setText(COLUMN_FILE_NAME, QString::fromStdString(it->fname)); item->setText(COLUMN_FILE_SIZE, QString::number(it->size)); item->setText(COLUMN_FILE_HASH, QString::fromStdString(it->hash)); /* add to the list */ items.append(item); } /* add the items in! */ ui.msgList->insertTopLevelItems(0, items); /* iterate through the sources */ std::list<std::string>::const_iterator pit; RetroShareLink link; QString text; for(pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++) { if (link.createMessage(*pit, "")) { text += link.toHtml() + " "; } } ui.toText->setText(text); if (msgInfo.msgcc.size() > 0) { ui.cclabel->setVisible(true); ui.ccText->setVisible(true); text.clear(); for(pit = msgInfo.msgcc.begin(); pit != msgInfo.msgcc.end(); pit++) { if (link.createMessage(*pit, "")) { text += link.toHtml() + " "; } } ui.ccText->setText(text); } else { ui.cclabel->setVisible(false); ui.ccText->setVisible(false); ui.ccText->clear(); } if (msgInfo.msgbcc.size() > 0) { ui.bcclabel->setVisible(true); ui.bccText->setVisible(true); text.clear(); for(pit = msgInfo.msgbcc.begin(); pit != msgInfo.msgbcc.end(); pit++) { if (link.createMessage(*pit, "")) { text += link.toHtml() + " "; } } ui.bccText->setText(text); } else { ui.bcclabel->setVisible(false); ui.bccText->setVisible(false); ui.bccText->clear(); } { QDateTime qtime; qtime.setTime_t(msgInfo.ts); QString timestamp = qtime.toString("dd.MM.yyyy hh:mm:ss"); ui.dateText->setText(timestamp); } std::string srcId; if ((msgInfo.msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) { // outgoing message are from me srcId = rsPeers->getOwnId(); } else { srcId = msgInfo.srcId; } link.createMessage(srcId, ""); ui.fromText->setText(link.toHtml()); ui.fromText->setToolTip(PeerDefs::rsidFromId(srcId)); ui.subjectText->setText(QString::fromStdWString(msgInfo.title)); text = RsHtml::formatText(QString::fromStdWString(msgInfo.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); ui.msgText->setHtml(text); ui.filesText->setText(QString("(%1 %2)").arg(msgInfo.count).arg(msgInfo.count == 1 ? tr("File") : tr("Files"))); showTagLabels(); }