Added a star column for messages.

Recompile of the gui needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4217 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-05-23 23:45:31 +00:00
parent 3f21835114
commit c45e7562bb
12 changed files with 800 additions and 370 deletions

View File

@ -52,6 +52,7 @@
#define RS_MSG_UNREAD_BY_USER 0x0040 /* Unread by user */ #define RS_MSG_UNREAD_BY_USER 0x0040 /* Unread by user */
#define RS_MSG_REPLIED 0x0080 /* Message is replied */ #define RS_MSG_REPLIED 0x0080 /* Message is replied */
#define RS_MSG_FORWARDED 0x0100 /* Message is forwarded */ #define RS_MSG_FORWARDED 0x0100 /* Message is forwarded */
#define RS_MSG_STAR 0x0200 /* Message is marked with a star */
#define RS_MSGTAGTYPE_IMPORTANT 1 #define RS_MSGTAGTYPE_IMPORTANT 1
#define RS_MSGTAGTYPE_WORK 2 #define RS_MSGTAGTYPE_WORK 2
@ -163,9 +164,10 @@ virtual bool MessageToTrash(const std::string &mid, bool bTrash) = 0;
virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId) = 0; virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId) = 0;
virtual bool MessageDelete(const std::string &mid) = 0; virtual bool MessageDelete(const std::string &mid) = 0;
virtual bool MessageRead(const std::string &mid, bool bUnreadByUser) = 0; virtual bool MessageRead(const std::string &mid, bool unreadByUser) = 0;
virtual bool MessageReplied(const std::string &mid, bool replied) = 0; virtual bool MessageReplied(const std::string &mid, bool replied) = 0;
virtual bool MessageForwarded(const std::string &mid, bool forwarded) = 0; virtual bool MessageForwarded(const std::string &mid, bool forwarded) = 0;
virtual bool MessageStar(const std::string &mid, bool mark) = 0;
/* message tagging */ /* message tagging */

View File

@ -100,12 +100,12 @@ bool p3Msgs::MessageDelete(const std::string &mid)
return mMsgSrv -> removeMsgId(mid); return mMsgSrv -> removeMsgId(mid);
} }
bool p3Msgs::MessageRead(const std::string &mid, bool bUnreadByUser) bool p3Msgs::MessageRead(const std::string &mid, bool unreadByUser)
{ {
//std::cerr << "p3Msgs::MessageRead() "; //std::cerr << "p3Msgs::MessageRead() ";
//std::cerr << "mid: " << mid << std::endl; //std::cerr << "mid: " << mid << std::endl;
return mMsgSrv -> markMsgIdRead(mid, bUnreadByUser); return mMsgSrv -> markMsgIdRead(mid, unreadByUser);
} }
bool p3Msgs::MessageReplied(const std::string &mid, bool replied) bool p3Msgs::MessageReplied(const std::string &mid, bool replied)
@ -123,6 +123,12 @@ bool p3Msgs::getMessageTagTypes(MsgTagType& tags)
return mMsgSrv->getMessageTagTypes(tags); return mMsgSrv->getMessageTagTypes(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::setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color) bool p3Msgs::setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color)
{ {
return mMsgSrv->setMessageTagType(tagId, text, rgb_color); return mMsgSrv->setMessageTagType(tagId, text, rgb_color);

View File

@ -61,9 +61,10 @@ class p3Msgs: public RsMsgs
virtual bool MessageToDraft(MessageInfo &info, const std::string &msgParentId); virtual bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
virtual bool MessageToTrash(const std::string &mid, bool bTrash); virtual bool MessageToTrash(const std::string &mid, bool bTrash);
virtual bool MessageDelete(const std::string &mid); virtual bool MessageDelete(const std::string &mid);
virtual bool MessageRead(const std::string &mid, bool bUnreadByUser); virtual bool MessageRead(const std::string &mid, bool unreadByUser);
virtual bool MessageReplied(const std::string &mid, bool replied); virtual bool MessageReplied(const std::string &mid, bool replied);
virtual bool MessageForwarded(const std::string &mid, bool forwarded); virtual bool MessageForwarded(const std::string &mid, bool forwarded);
virtual bool MessageStar(const std::string &mid, bool star);
virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId); virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId);
virtual bool getMessageTagTypes(MsgTagType& tags); virtual bool getMessageTagTypes(MsgTagType& tags);

View File

@ -188,6 +188,7 @@ const uint32_t RS_MSG_FLAGS_TRASH = 0x0020;
const uint32_t RS_MSG_FLAGS_UNREAD_BY_USER = 0x0040; const uint32_t RS_MSG_FLAGS_UNREAD_BY_USER = 0x0040;
const uint32_t RS_MSG_FLAGS_REPLIED = 0x0080; const uint32_t RS_MSG_FLAGS_REPLIED = 0x0080;
const uint32_t RS_MSG_FLAGS_FORWARDED = 0x0100; const uint32_t RS_MSG_FLAGS_FORWARDED = 0x0100;
const uint32_t RS_MSG_FLAGS_STAR = 0x0200;
class RsMsgItem: public RsItem class RsMsgItem: public RsItem
{ {

View File

@ -683,7 +683,7 @@ bool p3MsgService::removeMsgId(const std::string &mid)
return changed; return changed;
} }
bool p3MsgService::markMsgIdRead(const std::string &mid, bool bUnreadByUser) bool p3MsgService::markMsgIdRead(const std::string &mid, bool unreadByUser)
{ {
std::map<uint32_t, RsMsgItem *>::iterator mit; std::map<uint32_t, RsMsgItem *>::iterator mit;
uint32_t msgId = atoi(mid.c_str()); uint32_t msgId = atoi(mid.c_str());
@ -703,7 +703,7 @@ bool p3MsgService::markMsgIdRead(const std::string &mid, bool bUnreadByUser)
mi->msgFlags &= ~(RS_MSG_FLAGS_NEW); mi->msgFlags &= ~(RS_MSG_FLAGS_NEW);
/* set state from user */ /* set state from user */
if (bUnreadByUser) { if (unreadByUser) {
mi->msgFlags |= RS_MSG_FLAGS_UNREAD_BY_USER; mi->msgFlags |= RS_MSG_FLAGS_UNREAD_BY_USER;
} else { } else {
mi->msgFlags &= ~RS_MSG_FLAGS_UNREAD_BY_USER; mi->msgFlags &= ~RS_MSG_FLAGS_UNREAD_BY_USER;
@ -1311,6 +1311,10 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
{ {
mi.msgflags |= RS_MSG_FORWARDED; mi.msgflags |= RS_MSG_FORWARDED;
} }
if (msg->msgFlags & RS_MSG_FLAGS_STAR)
{
mi.msgflags |= RS_MSG_STAR;
}
mi.ts = msg->sendTime; mi.ts = msg->sendTime;
mi.srcId = msg->PeerId(); mi.srcId = msg->PeerId();
@ -1406,6 +1410,10 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
{ {
mis.msgflags |= RS_MSG_FORWARDED; mis.msgflags |= RS_MSG_FORWARDED;
} }
if (msg->msgFlags & RS_MSG_FLAGS_STAR)
{
mis.msgflags |= RS_MSG_STAR;
}
mis.srcId = msg->PeerId(); mis.srcId = msg->PeerId();
{ {

View File

@ -53,20 +53,23 @@
/* Images for context menu icons */ /* Images for context menu icons */
#define IMAGE_MESSAGE ":/images/folder-draft.png" #define IMAGE_MESSAGE ":/images/folder-draft.png"
#define IMAGE_MESSAGEREPLY ":/images/mail_reply.png" #define IMAGE_MESSAGEREPLY ":/images/mail_reply.png"
#define IMAGE_MESSAGEREPLYALL ":/images/mail_replyall.png" #define IMAGE_MESSAGEREPLYALL ":/images/mail_replyall.png"
#define IMAGE_MESSAGEFORWARD ":/images/mail_forward.png" #define IMAGE_MESSAGEFORWARD ":/images/mail_forward.png"
#define IMAGE_MESSAGEREMOVE ":/images/message-mail-imapdelete.png" #define IMAGE_MESSAGEREMOVE ":/images/message-mail-imapdelete.png"
#define IMAGE_DOWNLOAD ":/images/start.png" #define IMAGE_DOWNLOAD ":/images/start.png"
#define IMAGE_DOWNLOADALL ":/images/startall.png" #define IMAGE_DOWNLOADALL ":/images/startall.png"
#define IMAGE_STAR_ON ":/images/star-on-16.png"
#define IMAGE_STAR_OFF ":/images/star-off-16.png"
#define COLUMN_COUNT 7 #define COLUMN_COUNT 8
#define COLUMN_ATTACHEMENTS 0 #define COLUMN_ATTACHEMENTS 0
#define COLUMN_SUBJECT 1 #define COLUMN_SUBJECT 1
#define COLUMN_UNREAD 2 #define COLUMN_UNREAD 2
#define COLUMN_FROM 3 #define COLUMN_FROM 3
#define COLUMN_DATE 4 #define COLUMN_DATE 4
#define COLUMN_CONTENT 5 #define COLUMN_STAR 5
#define COLUMN_TAGS 6 #define COLUMN_CONTENT 6
#define COLUMN_TAGS 7
#define COLUMN_DATA 0 // column for storing the userdata like msgid and srcid #define COLUMN_DATA 0 // column for storing the userdata like msgid and srcid
@ -211,6 +214,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
MessagesModel->setHeaderData(COLUMN_DATE, Qt::Horizontal, tr("Date")); MessagesModel->setHeaderData(COLUMN_DATE, Qt::Horizontal, tr("Date"));
MessagesModel->setHeaderData(COLUMN_TAGS, Qt::Horizontal, tr("Tags")); MessagesModel->setHeaderData(COLUMN_TAGS, Qt::Horizontal, tr("Tags"));
MessagesModel->setHeaderData(COLUMN_CONTENT, Qt::Horizontal, tr("Content")); MessagesModel->setHeaderData(COLUMN_CONTENT, Qt::Horizontal, tr("Content"));
MessagesModel->setHeaderData(COLUMN_STAR, Qt::Horizontal, QIcon(IMAGE_STAR_ON), Qt::DecorationRole);
MessagesModel->setHeaderData(COLUMN_ATTACHEMENTS, Qt::Horizontal, tr("Click to sort by attachments"), Qt::ToolTipRole); MessagesModel->setHeaderData(COLUMN_ATTACHEMENTS, Qt::Horizontal, tr("Click to sort by attachments"), Qt::ToolTipRole);
MessagesModel->setHeaderData(COLUMN_SUBJECT, Qt::Horizontal, tr("Click to sort by subject"), Qt::ToolTipRole); MessagesModel->setHeaderData(COLUMN_SUBJECT, Qt::Horizontal, tr("Click to sort by subject"), Qt::ToolTipRole);
@ -218,6 +222,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
MessagesModel->setHeaderData(COLUMN_FROM, Qt::Horizontal, tr("Click to sort by from"), Qt::ToolTipRole); MessagesModel->setHeaderData(COLUMN_FROM, Qt::Horizontal, tr("Click to sort by from"), Qt::ToolTipRole);
MessagesModel->setHeaderData(COLUMN_DATE, Qt::Horizontal, tr("Click to sort by date"), Qt::ToolTipRole); MessagesModel->setHeaderData(COLUMN_DATE, Qt::Horizontal, tr("Click to sort by date"), Qt::ToolTipRole);
MessagesModel->setHeaderData(COLUMN_TAGS, Qt::Horizontal, tr("Click to sort by tags"), Qt::ToolTipRole); MessagesModel->setHeaderData(COLUMN_TAGS, Qt::Horizontal, tr("Click to sort by tags"), Qt::ToolTipRole);
MessagesModel->setHeaderData(COLUMN_STAR, Qt::Horizontal, tr("Click to sort by star"), Qt::ToolTipRole);
proxyModel = new QSortFilterProxyModel(this); proxyModel = new QSortFilterProxyModel(this);
proxyModel->setDynamicSortFilter(true); proxyModel->setDynamicSortFilter(true);
@ -229,6 +234,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
RSItemDelegate *itemDelegate = new RSItemDelegate(this); RSItemDelegate *itemDelegate = new RSItemDelegate(this);
itemDelegate->removeFocusRect(COLUMN_UNREAD); itemDelegate->removeFocusRect(COLUMN_UNREAD);
itemDelegate->removeFocusRect(COLUMN_STAR);
itemDelegate->setSpacing(QSize(0, 2)); itemDelegate->setSpacing(QSize(0, 2));
ui.messagestreeView->setItemDelegate(itemDelegate); ui.messagestreeView->setItemDelegate(itemDelegate);
@ -257,6 +263,10 @@ MessagesDialog::MessagesDialog(QWidget *parent)
msgwheader->resizeSection (COLUMN_UNREAD, 16); msgwheader->resizeSection (COLUMN_UNREAD, 16);
msgwheader->resizeSection (COLUMN_FROM, 140); msgwheader->resizeSection (COLUMN_FROM, 140);
msgwheader->resizeSection (COLUMN_DATE, 140); msgwheader->resizeSection (COLUMN_DATE, 140);
msgwheader->resizeSection (COLUMN_STAR, 16);
msgwheader->setResizeMode (COLUMN_STAR, QHeaderView::Fixed);
msgwheader->resizeSection (COLUMN_STAR, 24);
/* Set header resize modes and initial section sizes */ /* Set header resize modes and initial section sizes */
QHeaderView * msglheader = ui.msgList->header () ; QHeaderView * msglheader = ui.msgList->header () ;
@ -307,6 +317,8 @@ MessagesDialog::MessagesDialog(QWidget *parent)
msgwheader->setResizeMode (COLUMN_DATE, QHeaderView::Interactive); msgwheader->setResizeMode (COLUMN_DATE, QHeaderView::Interactive);
msgwheader->setResizeMode (COLUMN_UNREAD, QHeaderView::Fixed); msgwheader->setResizeMode (COLUMN_UNREAD, QHeaderView::Fixed);
msgwheader->resizeSection (COLUMN_UNREAD, 24); msgwheader->resizeSection (COLUMN_UNREAD, 24);
msgwheader->resizeSection (COLUMN_STAR, 24);
msgwheader->setResizeMode (COLUMN_STAR, QHeaderView::Fixed);
// fill folder list // fill folder list
updateMessageSummaryList(); updateMessageSummaryList();
@ -349,6 +361,8 @@ MessagesDialog::~MessagesDialog()
void MessagesDialog::processSettings(bool bLoad) void MessagesDialog::processSettings(bool bLoad)
{ {
int messageTreeVersion = 1; // version number for the settings to solve problems when modifying the column count
m_bProcessSettings = true; m_bProcessSettings = true;
QHeaderView *msgwheader = ui.messagestreeView->header () ; QHeaderView *msgwheader = ui.messagestreeView->header () ;
@ -369,7 +383,9 @@ void MessagesDialog::processSettings(bool bLoad)
ui.filterColumnComboBox->setCurrentIndex(nValue); ui.filterColumnComboBox->setCurrentIndex(nValue);
// state of message tree // state of message tree
msgwheader->restoreState(Settings->value("MessageTree").toByteArray()); if (Settings->value("MessageTreeVersion").toInt() == messageTreeVersion) {
msgwheader->restoreState(Settings->value("MessageTree").toByteArray());
}
// state of tag list // state of tag list
bValue = Settings->value("tagList", true).toBool(); bValue = Settings->value("tagList", true).toBool();
@ -384,6 +400,7 @@ void MessagesDialog::processSettings(bool bLoad)
// state of message tree // state of message tree
Settings->setValue("MessageTree", msgwheader->saveState()); Settings->setValue("MessageTree", msgwheader->saveState());
Settings->setValue("MessageTreeVersion", messageTreeVersion);
// state of tag list // state of tag list
Settings->setValue("tagList", ui.Tags_Button->isChecked()); Settings->setValue("tagList", ui.Tags_Button->isChecked());
@ -473,10 +490,11 @@ void MessagesDialog::fillTags()
// MainPage::keyPressEvent(e) ; // MainPage::keyPressEvent(e) ;
//} //}
int MessagesDialog::getSelectedMsgCount (QList<int> *pRows, QList<int> *pRowsRead, QList<int> *pRowsUnread) int MessagesDialog::getSelectedMsgCount (QList<int> *pRows, QList<int> *pRowsRead, QList<int> *pRowsUnread, QList<int> *pRowsStar)
{ {
if (pRowsRead) pRowsRead->clear(); if (pRowsRead) pRowsRead->clear();
if (pRowsUnread) pRowsUnread->clear(); if (pRowsUnread) pRowsUnread->clear();
if (pRowsStar) pRowsStar->clear();
//To check if the selection has more than one row. //To check if the selection has more than one row.
QList<QModelIndex> selectedIndexList = ui.messagestreeView->selectionModel() -> selectedIndexes (); QList<QModelIndex> selectedIndexList = ui.messagestreeView->selectionModel() -> selectedIndexes ();
@ -488,7 +506,7 @@ int MessagesDialog::getSelectedMsgCount (QList<int> *pRows, QList<int> *pRowsRea
{ {
rowList.append(row); rowList.append(row);
if (pRows || pRowsRead || pRowsUnread) { if (pRows || pRowsRead || pRowsUnread || pRowsStar) {
int mappedRow = proxyModel->mapToSource(*it).row(); int mappedRow = proxyModel->mapToSource(*it).row();
if (pRows) pRows->append(mappedRow); if (pRows) pRows->append(mappedRow);
@ -498,6 +516,12 @@ int MessagesDialog::getSelectedMsgCount (QList<int> *pRows, QList<int> *pRowsRea
} else { } else {
if (pRowsRead) pRowsRead->append(mappedRow); if (pRowsRead) pRowsRead->append(mappedRow);
} }
if (pRowsStar) {
if (MessagesModel->item(mappedRow, COLUMN_DATA)->data(ROLE_MSGFLAGS).toInt() & RS_MSG_STAR) {
pRowsStar->append(mappedRow);
}
}
} }
} }
} }
@ -507,105 +531,87 @@ int MessagesDialog::getSelectedMsgCount (QList<int> *pRows, QList<int> *pRowsRea
bool MessagesDialog::isMessageRead(int nRow) bool MessagesDialog::isMessageRead(int nRow)
{ {
QStandardItem *item; QStandardItem *item = MessagesModel->item(nRow,COLUMN_DATA);
item = MessagesModel->item(nRow,COLUMN_DATA);
return !item->data(ROLE_UNREAD).toBool(); return !item->data(ROLE_UNREAD).toBool();
} }
bool MessagesDialog::hasMessageStar(int nRow)
{
QStandardItem *item = MessagesModel->item(nRow,COLUMN_DATA);
return item->data(ROLE_MSGFLAGS).toInt() & RS_MSG_STAR;
}
void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point ) void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
{ {
QMenu contextMnu( this ); QMenu contextMnu( this );
/** Defines the actions for the context menu */
QAction *replytomsgAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Message" ), &contextMnu );
connect( replytomsgAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) );
contextMnu.addAction( replytomsgAct);
QAction *replyallmsgAct = new QAction(QIcon(IMAGE_MESSAGEREPLYALL), tr( "Reply to All" ), &contextMnu );
connect( replyallmsgAct , SIGNAL( triggered() ), this, SLOT( replyallmessage() ) );
contextMnu.addAction( replyallmsgAct);
QAction *forwardmsgAct = new QAction(QIcon(IMAGE_MESSAGEFORWARD), tr( "Forward Message" ), &contextMnu );
connect( forwardmsgAct , SIGNAL( triggered() ), this, SLOT( forwardmessage() ) );
contextMnu.addAction( forwardmsgAct);
QList<int> RowsRead; QList<int> RowsRead;
QList<int> RowsUnread; QList<int> RowsUnread;
int nCount = getSelectedMsgCount (NULL, &RowsRead, &RowsUnread); QList<int> RowsStar;
int nCount = getSelectedMsgCount (NULL, &RowsRead, &RowsUnread, &RowsStar);
QAction *editAct = new QAction(tr( "Edit..." ), &contextMnu ); /** Defines the actions for the context menu */
connect(editAct, SIGNAL(triggered()), this, SLOT(editmessage()));
contextMnu.addAction(editAct);
if (nCount == 1) { QAction *action = contextMnu.addAction(QIcon(IMAGE_MESSAGEREPLY), tr("Reply to Message"), this, SLOT(replytomessage()));
editAct->setEnabled(true); if (nCount != 1) {
} else { action->setDisabled(true);
editAct->setDisabled(true); }
action = contextMnu.addAction(QIcon(IMAGE_MESSAGEREPLYALL), tr("Reply to All"), this, SLOT(replyallmessage()));
if (nCount != 1) {
action->setDisabled(true);
}
action = contextMnu.addAction(QIcon(IMAGE_MESSAGEFORWARD), tr("Forward Message"), this, SLOT(forwardmessage()));
if (nCount != 1) {
action->setDisabled(true);
}
action = contextMnu.addAction(tr("Edit..."), this, SLOT(editmessage()));
if (nCount != 1) {
action->setDisabled(true);
} }
contextMnu.addSeparator(); contextMnu.addSeparator();
QAction *markAsRead = new QAction(QIcon(":/images/message-mail-read.png"), tr( "Mark as read" ), &contextMnu); action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark as read"), this, SLOT(markAsRead()));
connect(markAsRead , SIGNAL(triggered()), this, SLOT(markAsRead()));
contextMnu.addAction(markAsRead);
if (RowsUnread.size() == 0) { if (RowsUnread.size() == 0) {
markAsRead->setDisabled(true); action->setDisabled(true);
} }
QAction *markAsUnread = new QAction(QIcon(":/images/message-mail.png"), tr( "Mark as unread" ), &contextMnu); action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark as unread"), this, SLOT(markAsUnread()));
connect(markAsUnread , SIGNAL(triggered()), this, SLOT(markAsUnread()));
contextMnu.addAction(markAsUnread);
if (RowsRead.size() == 0) { if (RowsRead.size() == 0) {
markAsUnread->setDisabled(true); action->setDisabled(true);
} }
action = contextMnu.addAction(tr("Add Star"));
action->setCheckable(true);
action->setChecked(RowsStar.size());
connect(action, SIGNAL(triggered(bool)), this, SLOT(markWithStar(bool)));
contextMnu.addSeparator(); contextMnu.addSeparator();
// add tags // add tags
contextMnu.addMenu(ui.tagButton->menu()); contextMnu.addMenu(ui.tagButton->menu());
contextMnu.addSeparator(); contextMnu.addSeparator();
QAction *removemsgAct; action = contextMnu.addAction(QIcon(IMAGE_MESSAGEREMOVE), (nCount > 1) ? tr("Remove Messages") : tr("Remove Message"), this, SLOT(removemessage()));
if (nCount > 1) { if (nCount == 0) {
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Messages" ), &contextMnu ); action->setDisabled(true);
} else {
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Message" ), &contextMnu );
} }
connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) ); int listrow = ui.listWidget->currentRow();
contextMnu.addAction( removemsgAct);
int listrow = ui.listWidget -> currentRow();
if (listrow == ROW_TRASHBOX) { if (listrow == ROW_TRASHBOX) {
QAction *undeleteAct = new QAction(tr( "Undelete" ), &contextMnu ); action = contextMnu.addAction(tr("Undelete"), this, SLOT(undeletemessage()));
connect(undeleteAct, SIGNAL(triggered()), this, SLOT(undeletemessage())); if (nCount == 0) {
contextMnu.addAction(undeleteAct); action->setDisabled(true);
if (nCount) {
undeleteAct->setEnabled(true);
} else {
undeleteAct->setDisabled(true);
} }
} }
contextMnu.addAction( ui.actionSave_as); contextMnu.addAction(ui.actionSave_as);
contextMnu.addAction( ui.actionPrintPreview); contextMnu.addAction(ui.actionPrintPreview);
contextMnu.addAction( ui.actionPrint); contextMnu.addAction(ui.actionPrint);
contextMnu.addSeparator(); contextMnu.addSeparator();
QAction *newmsgAct = new QAction(QIcon(IMAGE_MESSAGE), tr( "New Message" ), &contextMnu ); contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("New Message"), this, SLOT(newmessage()));
connect( newmsgAct , SIGNAL( triggered() ), this, SLOT( newmessage() ) );
contextMnu.addAction( newmsgAct);
if (nCount != 1) {
replytomsgAct->setDisabled(true);
replyallmsgAct->setDisabled(true);
forwardmsgAct->setDisabled(true);
}
if (nCount == 0) {
removemsgAct->setDisabled(true);
}
contextMnu.exec(QCursor::pos()); contextMnu.exec(QCursor::pos());
} }
@ -892,56 +898,64 @@ void MessagesDialog::messagesTagsChanged()
showTagLabels(); showTagLabels();
} }
static void InitIconAndFont(QStandardItem *pItem [COLUMN_COUNT]) static void InitIconAndFont(QStandardItem *item[COLUMN_COUNT])
{ {
QString sText = pItem [COLUMN_SUBJECT]->text(); int msgFlags = item[COLUMN_DATA]->data(ROLE_MSGFLAGS).toInt();
QString mid = pItem [COLUMN_DATA]->data(ROLE_MSGID).toString();
int nFlag = pItem [COLUMN_DATA]->data(ROLE_MSGFLAGS).toInt();
// show the real "New" state // show the real "New" state
if (nFlag & RS_MSG_NEW) { if (msgFlags & RS_MSG_NEW) {
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-state-new.png")); item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-state-new.png"));
} else { } else {
if (nFlag & RS_MSG_UNREAD_BY_USER) { if (msgFlags & RS_MSG_UNREAD_BY_USER) {
if ((nFlag & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) { if ((msgFlags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) {
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-replied.png")); item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-replied.png"));
} else if ((nFlag & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) { } else if ((msgFlags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) {
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-forwarded.png")); item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-forwarded.png"));
} else if ((nFlag & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) { } else if ((msgFlags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) {
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-replied-forw.png")); item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-replied-forw.png"));
} else { } else {
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail.png")); item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail.png"));
} }
} else { } else {
if ((nFlag & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) { if ((msgFlags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) {
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-replied-read.png")); item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-replied-read.png"));
} else if ((nFlag & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) { } else if ((msgFlags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) {
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-forwarded-read.png")); item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-forwarded-read.png"));
} else if ((nFlag & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) { } else if ((msgFlags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == (RS_MSG_REPLIED | RS_MSG_FORWARDED)) {
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-replied-forw-read.png")); item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-replied-forw-read.png"));
} else { } else {
pItem[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-read.png")); item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-read.png"));
} }
} }
} }
bool bNew = nFlag & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER); if (msgFlags & RS_MSG_STAR) {
item[COLUMN_STAR]->setIcon(QIcon(IMAGE_STAR_ON));
item[COLUMN_STAR]->setText("1");
} else {
item[COLUMN_STAR]->setIcon(QIcon(IMAGE_STAR_OFF));
item[COLUMN_STAR]->setText("0");
}
bool isNew = msgFlags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER);
// set icon // set icon
if (bNew) { if (isNew) {
pItem[COLUMN_UNREAD]->setIcon(QIcon(":/images/message-state-unread.png")); item[COLUMN_UNREAD]->setIcon(QIcon(":/images/message-state-unread.png"));
item[COLUMN_UNREAD]->setText("1");
} else { } else {
pItem[COLUMN_UNREAD]->setIcon(QIcon(":/images/message-state-read.png")); item[COLUMN_UNREAD]->setIcon(QIcon(":/images/message-state-read.png"));
item[COLUMN_UNREAD]->setText("0");
} }
// set font // set font
for (int i = 0; i < COLUMN_COUNT; i++) { for (int i = 0; i < COLUMN_COUNT; i++) {
QFont qf = pItem[i]->font(); QFont qf = item[i]->font();
qf.setBold(bNew); qf.setBold(isNew);
pItem[i]->setFont(qf); item[i]->setFont(qf);
} }
pItem[COLUMN_DATA]->setData(bNew, ROLE_UNREAD); item[COLUMN_DATA]->setData(isNew, ROLE_UNREAD);
} }
void MessagesDialog::insertMessages() void MessagesDialog::insertMessages()
@ -1321,15 +1335,27 @@ void MessagesDialog::clicked(const QModelIndex &index )
return; return;
} }
if (index.column() == COLUMN_UNREAD) { switch (index.column()) {
int mappedRow = proxyModel->mapToSource(index).row(); case COLUMN_UNREAD:
{
int mappedRow = proxyModel->mapToSource(index).row();
QList<int> Rows; QList<int> Rows;
Rows.append(mappedRow); Rows.append(mappedRow);
setMsgAsReadUnread(Rows, !isMessageRead(mappedRow)); setMsgAsReadUnread(Rows, !isMessageRead(mappedRow));
insertMsgTxtAndFiles(index, false); insertMsgTxtAndFiles(index, false);
updateMessageSummaryList(); updateMessageSummaryList();
return; return;
}
case COLUMN_STAR:
{
int mappedRow = proxyModel->mapToSource(index).row();
QList<int> Rows;
Rows.append(mappedRow);
setMsgStar(Rows, !hasMessageStar(mappedRow));
return;
}
} }
timer->stop(); timer->stop();
@ -1355,7 +1381,7 @@ void MessagesDialog::updateCurrentMessage()
insertMsgTxtAndFiles(timerIndex); insertMsgTxtAndFiles(timerIndex);
} }
void MessagesDialog::setMsgAsReadUnread(const QList<int> &Rows, bool bRead) void MessagesDialog::setMsgAsReadUnread(const QList<int> &Rows, bool read)
{ {
LockUpdate Lock (this, false); LockUpdate Lock (this, false);
@ -1368,17 +1394,17 @@ void MessagesDialog::setMsgAsReadUnread(const QList<int> &Rows, bool bRead)
std::string mid = item[COLUMN_DATA]->data(ROLE_MSGID).toString().toStdString(); std::string mid = item[COLUMN_DATA]->data(ROLE_MSGID).toString().toStdString();
if (rsMsgs->MessageRead(mid, !bRead)) { if (rsMsgs->MessageRead(mid, !read)) {
int nFlag = item[COLUMN_DATA]->data(ROLE_MSGFLAGS).toInt(); int msgFlag = item[COLUMN_DATA]->data(ROLE_MSGFLAGS).toInt();
nFlag &= ~RS_MSG_NEW; msgFlag &= ~RS_MSG_NEW;
if (bRead) { if (read) {
nFlag &= ~RS_MSG_UNREAD_BY_USER; msgFlag &= ~RS_MSG_UNREAD_BY_USER;
} else { } else {
nFlag |= RS_MSG_UNREAD_BY_USER; msgFlag |= RS_MSG_UNREAD_BY_USER;
} }
item[COLUMN_DATA]->setData(nFlag, ROLE_MSGFLAGS); item[COLUMN_DATA]->setData(msgFlag, ROLE_MSGFLAGS);
InitIconAndFont(item); InitIconAndFont(item);
} }
@ -1390,7 +1416,7 @@ void MessagesDialog::setMsgAsReadUnread(const QList<int> &Rows, bool bRead)
void MessagesDialog::markAsRead() void MessagesDialog::markAsRead()
{ {
QList<int> RowsUnread; QList<int> RowsUnread;
getSelectedMsgCount (NULL, NULL, &RowsUnread); getSelectedMsgCount (NULL, NULL, &RowsUnread, NULL);
setMsgAsReadUnread (RowsUnread, true); setMsgAsReadUnread (RowsUnread, true);
updateMessageSummaryList(); updateMessageSummaryList();
@ -1399,12 +1425,52 @@ void MessagesDialog::markAsRead()
void MessagesDialog::markAsUnread() void MessagesDialog::markAsUnread()
{ {
QList<int> RowsRead; QList<int> RowsRead;
getSelectedMsgCount (NULL, &RowsRead, NULL); getSelectedMsgCount (NULL, &RowsRead, NULL, NULL);
setMsgAsReadUnread (RowsRead, false); setMsgAsReadUnread (RowsRead, false);
updateMessageSummaryList(); updateMessageSummaryList();
} }
void MessagesDialog::markWithStar(bool checked)
{
QList<int> Rows;
getSelectedMsgCount (&Rows, NULL, NULL, NULL);
setMsgStar(Rows, checked);
}
void MessagesDialog::setMsgStar(const QList<int> &Rows, bool star)
{
LockUpdate Lock (this, false);
for (int nRow = 0; nRow < Rows.size(); nRow++) {
QStandardItem* item[COLUMN_COUNT];
for(int nCol = 0; nCol < COLUMN_COUNT; nCol++)
{
item[nCol] = MessagesModel->item(Rows [nRow], nCol);
}
std::string mid = item[COLUMN_DATA]->data(ROLE_MSGID).toString().toStdString();
if (rsMsgs->MessageStar(mid, star)) {
int msgFlag = item[COLUMN_DATA]->data(ROLE_MSGFLAGS).toInt();
msgFlag &= ~RS_MSG_STAR;
if (star) {
msgFlag |= RS_MSG_STAR;
} else {
msgFlag &= ~RS_MSG_STAR;
}
item[COLUMN_DATA]->setData(msgFlag, ROLE_MSGFLAGS);
InitIconAndFont(item);
}
}
// LockUpdate
}
void MessagesDialog::clearTagLabels() void MessagesDialog::clearTagLabels()
{ {
/* clear all tags */ /* clear all tags */
@ -1502,7 +1568,7 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
cid = item->data(ROLE_SRCID).toString().toStdString(); cid = item->data(ROLE_SRCID).toString().toStdString();
mid = item->data(ROLE_MSGID).toString().toStdString(); mid = item->data(ROLE_MSGID).toString().toStdString();
int nCount = getSelectedMsgCount (NULL, NULL, NULL); int nCount = getSelectedMsgCount (NULL, NULL, NULL, NULL);
if (nCount == 1) { if (nCount == 1) {
ui.actionSave_as->setEnabled(true); ui.actionSave_as->setEnabled(true);
ui.actionPrintPreview->setEnabled(true); ui.actionPrintPreview->setEnabled(true);
@ -1744,7 +1810,7 @@ void MessagesDialog::undeletemessage()
LockUpdate Lock (this, true); LockUpdate Lock (this, true);
QList<int> Rows; QList<int> Rows;
getSelectedMsgCount (&Rows, NULL, NULL); getSelectedMsgCount (&Rows, NULL, NULL, NULL);
for (int nRow = 0; nRow < Rows.size(); nRow++) { for (int nRow = 0; nRow < Rows.size(); nRow++) {
QString mid = MessagesModel->item (Rows [nRow], COLUMN_DATA)->data(ROLE_MSGID).toString(); QString mid = MessagesModel->item (Rows [nRow], COLUMN_DATA)->data(ROLE_MSGID).toString();
rsMsgs->MessageToTrash(mid.toStdString(), false); rsMsgs->MessageToTrash(mid.toStdString(), false);
@ -2079,7 +2145,7 @@ void MessagesDialog::tagAboutToShow()
MsgTagInfo tagInfo; MsgTagInfo tagInfo;
QList<int> rows; QList<int> rows;
getSelectedMsgCount (&rows, NULL, NULL); getSelectedMsgCount (&rows, NULL, NULL, NULL);
if (rows.size()) { if (rows.size()) {
QStandardItem* item = MessagesModel->item(rows [0], COLUMN_DATA); QStandardItem* item = MessagesModel->item(rows [0], COLUMN_DATA);
@ -2096,7 +2162,7 @@ void MessagesDialog::tagRemoveAll()
LockUpdate Lock (this, false); LockUpdate Lock (this, false);
QList<int> rows; QList<int> rows;
getSelectedMsgCount (&rows, NULL, NULL); getSelectedMsgCount (&rows, NULL, NULL, NULL);
for (int row = 0; row < rows.size(); row++) { for (int row = 0; row < rows.size(); row++) {
QStandardItem* item = MessagesModel->item(rows [row], COLUMN_DATA); QStandardItem* item = MessagesModel->item(rows [row], COLUMN_DATA);
std::string msgId = item->data(ROLE_MSGID).toString().toStdString(); std::string msgId = item->data(ROLE_MSGID).toString().toStdString();
@ -2119,7 +2185,7 @@ void MessagesDialog::tagSet(int tagId, bool set)
LockUpdate Lock (this, false); LockUpdate Lock (this, false);
QList<int> rows; QList<int> rows;
getSelectedMsgCount (&rows, NULL, NULL); getSelectedMsgCount (&rows, NULL, NULL, NULL);
for (int row = 0; row < rows.size(); row++) { for (int row = 0; row < rows.size(); row++) {
QStandardItem* item = MessagesModel->item(rows [row], COLUMN_DATA); QStandardItem* item = MessagesModel->item(rows [row], COLUMN_DATA);
std::string msgId = item->data(ROLE_MSGID).toString().toStdString(); std::string msgId = item->data(ROLE_MSGID).toString().toStdString();

View File

@ -78,6 +78,7 @@ private slots:
void markAsRead(); void markAsRead();
void markAsUnread(); void markAsUnread();
void markWithStar(bool checked);
void emptyTrash(); void emptyTrash();
@ -122,12 +123,14 @@ private:
void insertMsgTxtAndFiles(QModelIndex index = QModelIndex(), bool bSetToRead = true); void insertMsgTxtAndFiles(QModelIndex index = QModelIndex(), bool bSetToRead = true);
bool getCurrentMsg(std::string &cid, std::string &mid); bool getCurrentMsg(std::string &cid, std::string &mid);
void setMsgAsReadUnread(const QList<int> &Rows, bool bRead); void setMsgAsReadUnread(const QList<int> &Rows, bool read);
void setMsgStar(const QList<int> &Rows, bool mark);
void setCurrentFileName(const QString &fileName); void setCurrentFileName(const QString &fileName);
int getSelectedMsgCount (QList<int> *pRows, QList<int> *pRowsRead, QList<int> *pRowsUnread); int getSelectedMsgCount (QList<int> *pRows, QList<int> *pRowsRead, QList<int> *pRowsUnread, QList<int> *pRowsStar);
bool isMessageRead(int nRow); bool isMessageRead(int nRow);
bool hasMessageStar(int nRow);
/* internal handle splitter */ /* internal handle splitter */
void togglefileview_internal(); void togglefileview_internal();

View File

@ -370,6 +370,8 @@
<file>images/show_toolbox_frame.png</file> <file>images/show_toolbox_frame.png</file>
<file>images/start.png</file> <file>images/start.png</file>
<file>images/stop.png</file> <file>images/stop.png</file>
<file>images/star-on-16.png</file>
<file>images/star-off-16.png</file>
<file>images/StatsCumulative.png</file> <file>images/StatsCumulative.png</file>
<file>images/StatisticsDetail.png</file> <file>images/StatisticsDetail.png</file>
<file>images/status_unknown.png</file> <file>images/status_unknown.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

File diff suppressed because it is too large Load Diff