Merge pull request #2260 from PhenomRetroShare/Fix_MessagesQuickView

Fix Message Quick View
This commit is contained in:
csoler 2021-01-30 20:11:57 +01:00 committed by GitHub
commit 651d7a8d3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 60 deletions

View File

@ -373,14 +373,16 @@ uint32_t RsMessageModel::updateFilterStatus(ForumModelIndex /*i*/,int /*column*/
void RsMessageModel::setFilter(FilterType filter_type, const QStringList& strings)
{
std::cerr << "Setting filter to filter_type=" << int(filter_type) << " and strings to " ;
foreach(const QString& str,strings)
std::cerr << "\"" << str.toStdString() << "\" " ;
std::cerr << std::endl;
#ifdef DEBUG_MESSAGE_MODEL
std::cerr << "Setting filter to filter_type=" << int(filter_type) << " and strings to " ;
foreach(const QString& str,strings)
std::cerr << "\"" << str.toStdString() << "\" " ;
std::cerr << std::endl;
#endif
preMods();
preMods();
mFilterType = filter_type;
mFilterType = filter_type;
mFilterStrings = strings;
postMods();
@ -388,7 +390,7 @@ void RsMessageModel::setFilter(FilterType filter_type, const QStringList& string
QVariant RsMessageModel::toolTipRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
{
if(column == COLUMN_THREAD_AUTHOR)
if(column == COLUMN_THREAD_AUTHOR)
{
QString str,comment ;
QList<QIcon> icons;
@ -460,45 +462,44 @@ QVariant RsMessageModel::displayRole(const Rs::Msgs::MsgInfoSummary& fmpe,int co
{
switch(col)
{
case COLUMN_THREAD_SUBJECT: return QVariant(QString::fromUtf8(fmpe.title.c_str()));
case COLUMN_THREAD_ATTACHMENT:return QVariant(QString::number(fmpe.count));
case COLUMN_THREAD_SUBJECT: return QVariant(QString::fromUtf8(fmpe.title.c_str()));
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;
qtime.setTime_t(fmpe.ts);
case COLUMN_THREAD_STAR:
case COLUMN_THREAD_SPAM:
case COLUMN_THREAD_READ:return QVariant();
case COLUMN_THREAD_DATE:{
QDateTime qtime;
qtime.setTime_t(fmpe.ts);
return QVariant(DateTime::formatDateTime(qtime));
}
return QVariant(DateTime::formatDateTime(qtime));
}
case COLUMN_THREAD_TAGS:{
// Tags
Rs::Msgs::MsgTagInfo tagInfo;
rsMsgs->getMessageTag(fmpe.msgId, tagInfo);
case COLUMN_THREAD_TAGS:{
// Tags
Rs::Msgs::MsgTagInfo tagInfo;
rsMsgs->getMessageTag(fmpe.msgId, tagInfo);
Rs::Msgs::MsgTagType Tags;
rsMsgs->getMessageTagTypes(Tags);
Rs::Msgs::MsgTagType Tags;
rsMsgs->getMessageTagTypes(Tags);
QString text;
QString text;
// build tag names
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
for (auto tagit = tagInfo.tagIds.begin(); tagit != tagInfo.tagIds.end(); ++tagit)
{
if (!text.isNull())
text += ",";
// build tag names
for (auto tagit = tagInfo.tagIds.begin(); tagit != tagInfo.tagIds.end(); ++tagit)
{
if (!text.isNull())
text += ",";
auto Tag = Tags.types.find(*tagit);
auto Tag = Tags.types.find(*tagit);
if (Tag != Tags.types.end())
text += TagDefs::name(Tag->first, Tag->second.first);
else
std::cerr << "(WW) unknown tag " << (int)Tag->first << " in message " << fmpe.msgId << std::endl;
}
return text;
}
if (Tag != Tags.types.end())
text += TagDefs::name(Tag->first, Tag->second.first);
else
RS_WARN("Unknown tag ", (int)Tag->first, " in message ", fmpe.msgId);
}
return text;
}
case COLUMN_THREAD_AUTHOR:{
QString name;
RsGxsId id = RsGxsId(fmpe.srcId.toStdString());
@ -510,11 +511,10 @@ QVariant RsMessageModel::displayRole(const Rs::Msgs::MsgInfoSummary& fmpe,int co
return QVariant(tr("[Unknown]"));
}
default:
default:
return QVariant("[ TODO ]");
}
return QVariant("[ERROR]");
}
@ -614,23 +614,24 @@ void RsMessageModel::setMessages(const std::list<Rs::Msgs::MsgInfoSummary>& msgs
void RsMessageModel::setCurrentBox(BoxName bn)
{
if(mCurrentBox != bn)
{
if(mCurrentBox != bn)
{
mCurrentBox = bn;
updateMessages();
}
updateMessages();
}
}
void RsMessageModel::setQuickViewFilter(QuickViewFilter fn)
{
if(fn != mQuickViewFilter)
{
std::cerr << "Changing new quickview filter to " << fn << std::endl;
if(fn != mQuickViewFilter)
{
#ifdef DEBUG_MESSAGE_MODEL
std::cerr << "Changing new quickview filter to " << fn << std::endl;
#endif
preMods();
mQuickViewFilter = fn ;
postMods();
}
mQuickViewFilter = fn ;
updateMessages();
}
}
void RsMessageModel::getMessageSummaries(BoxName box,std::list<Rs::Msgs::MsgInfoSummary>& msgs)
@ -717,8 +718,10 @@ QModelIndex RsMessageModel::getIndexOfMessage(const std::string& mid) const
return createIndex(it->second,0,ref);
}
#ifdef DEBUG_MESSAGE_MODEL
void RsMessageModel::debug_dump() const
{
for(auto it(mMessages.begin());it!=mMessages.end();++it)
std::cerr << "Id: " << it->msgId << ": from " << it->srcId << ": flags=" << it->msgflags << ": title=\"" << it->title << "\"" << std::endl;
for(auto& it : mMessages)
std::cerr << "Id: " << it.msgId << ": from " << it.srcId << ": flags=" << it.msgflags << ": title=\"" << it.title << "\"" << std::endl;
}
#endif

View File

@ -140,15 +140,17 @@ public:
QVariant textColorRole (const Rs::Msgs::MsgInfoSummary& fmpe, int col) const;
QVariant backgroundRole(const Rs::Msgs::MsgInfoSummary& fmpe, int col) const;
/*!
* \brief debug_dump
* Dumps the hierarchy of posts in the terminal, to allow checking whether the internal representation is correct.
*/
void debug_dump() const;
#ifdef DEBUG_MESSAGE_MODEL
/*!
* \brief debug_dump
* Dumps the hierarchy of posts in the terminal, to allow checking whether the internal representation is correct.
*/
void debug_dump() const;
#endif
// control over message flags and so on. This is handled by the model because it will allow it to update accordingly
// 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 setMsgStar(const QModelIndex& index,bool star) ;
void setMsgJunk(const QModelIndex& index,bool junk) ;
public slots: