From 7a7ebed9d2f3764afb7e89371ee195f265acc74b Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 10 Feb 2019 15:13:39 +0100 Subject: [PATCH] improved Mail model --- retroshare-gui/src/gui/MessagesDialog.cpp | 2 ++ retroshare-gui/src/gui/msgs/MessageModel.cpp | 19 ++++++++++++------- retroshare-gui/src/gui/msgs/MessageModel.h | 1 - 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 74f370540..684c08de9 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -195,6 +195,8 @@ MessagesDialog::MessagesDialog(QWidget *parent) mMessageProxyModel->setSortRole(RsMessageModel::SortRole); ui.messageTreeWidget->setModel(mMessageProxyModel); + mMessageModel->updateMessages(); + mMessageProxyModel->setFilterRole(RsMessageModel::FilterRole); mMessageProxyModel->setFilterRegExp(QRegExp(QString(RsMessageModel::FilterString))) ; diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index b1572a844..47430fab3 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -36,6 +36,8 @@ #define IS_MESSAGE_UNREAD(flags) (flags & RS_MSG_UNREAD_BY_USER) +#define IMAGE_STAR_ON ":/images/star-on-16.png" + std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere const QString RsMessageModel::FilterString("filtered"); @@ -161,7 +163,9 @@ QVariant RsMessageModel::headerData(int section, Qt::Orientation orientation, in switch(section) { case COLUMN_THREAD_DATE: return tr("Date"); - case COLUMN_THREAD_AUTHOR: return tr("Author"); + case COLUMN_THREAD_AUTHOR: return tr("From"); + case COLUMN_THREAD_SUBJECT: return tr("Subject"); + case COLUMN_THREAD_TAGS: return tr("Tags"); default: return QVariant(); } @@ -169,6 +173,7 @@ QVariant RsMessageModel::headerData(int section, Qt::Orientation orientation, in if(role == Qt::DecorationRole) switch(section) { + case COLUMN_THREAD_STAR: return QIcon(IMAGE_STAR_ON); case COLUMN_THREAD_READ: return QIcon(":/images/message-state-read.png"); default: return QVariant(); @@ -179,7 +184,7 @@ QVariant RsMessageModel::headerData(int section, Qt::Orientation orientation, in QVariant RsMessageModel::data(const QModelIndex &index, int role) const { -#ifdef DEBUG_FORUMMODEL +#ifdef DEBUG_MESSAGE_MODEL std::cerr << "calling data(" << index << ") role=" << role << std::endl; #endif @@ -196,13 +201,13 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const quintptr ref = (index.isValid())?index.internalId():0 ; uint32_t entry = 0; -#ifdef DEBUG_FORUMMODEL +#ifdef DEBUG_MESSAGE_MODEL std::cerr << "data(" << index << ")" ; #endif if(!ref) { -#ifdef DEBUG_FORUMMODEL +#ifdef DEBUG_MESSAGE_MODEL std::cerr << " [empty]" << std::endl; #endif return QVariant() ; @@ -210,7 +215,7 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const if(!convertInternalIdToMsgIndex(ref,entry) || entry >= mMessages.size()) { -#ifdef DEBUG_FORUMMODEL +#ifdef DEBUG_MESSAGE_MODEL std::cerr << "Bad pointer: " << (void*)ref << std::endl; #endif return QVariant() ; @@ -225,7 +230,7 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const return QVariant(font); } -#ifdef DEBUG_FORUMMODEL +#ifdef DEBUG_MESSAGE_MODEL std::cerr << " [ok]" << std::endl; #endif @@ -439,7 +444,7 @@ void RsMessageModel::setMessages(const std::list& msgs // now update prow for all posts -#ifdef DEBUG_FORUMMODEL +#ifdef DEBUG_MESSAGE_MODEL debug_dump(); #endif diff --git a/retroshare-gui/src/gui/msgs/MessageModel.h b/retroshare-gui/src/gui/msgs/MessageModel.h index 89b0894f8..438a3aa5f 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.h +++ b/retroshare-gui/src/gui/msgs/MessageModel.h @@ -164,7 +164,6 @@ private: static bool convertInternalIdToMsgIndex(quintptr ref,uint32_t& index); static void computeReputationLevel(uint32_t forum_sign_flags, ForumModelPostEntry& entry); - void update_posts(const RsGxsGroupId &group_id); uint32_t updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings); static void generateMissingItem(const RsGxsMessageId &msgId,ForumModelPostEntry& entry);