Improved MessagesDialog:

- corrected calculation of message counts
- p3MsgService::checkOutgoingMessages -> notify when message was sent
- refill of message list without clear, selected messages and scroll position are not changed
- corrected sorting of date with only time for today
- changed context menu in message list

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2863 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-05-07 22:23:38 +00:00
parent 5813a6454a
commit f239e7e4d4
4 changed files with 396 additions and 359 deletions

View File

@ -186,66 +186,75 @@ int p3MsgService::checkOutgoingMessages()
* if online, send * if online, send
*/ */
const std::string ownId = mConnMgr->getOwnId(); bool changed = false ;
std::list<uint32_t>::iterator it;
std::list<uint32_t> toErase;
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
std::map<uint32_t, RsMsgItem *>::iterator mit;
for(mit = msgOutgoing.begin(); mit != msgOutgoing.end(); mit++)
{ {
const std::string ownId = mConnMgr->getOwnId();
/* find the certificate */ std::list<uint32_t>::iterator it;
std::string pid = mit->second->PeerId(); std::list<uint32_t> toErase;
peerConnectState pstate;
bool toSend = false;
if (mConnMgr->getFriendNetStatus(pid, pstate)) RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
std::map<uint32_t, RsMsgItem *>::iterator mit;
for(mit = msgOutgoing.begin(); mit != msgOutgoing.end(); mit++)
{ {
if (pstate.state & RS_PEER_S_CONNECTED)
/* find the certificate */
std::string pid = mit->second->PeerId();
peerConnectState pstate;
bool toSend = false;
if (mConnMgr->getFriendNetStatus(pid, pstate))
{
if (pstate.state & RS_PEER_S_CONNECTED)
{
toSend = true;
}
}
else if (pid == ownId) /* FEEDBACK Msg to Ourselves */
{ {
toSend = true; toSend = true;
} }
}
else if (pid == ownId) /* FEEDBACK Msg to Ourselves */ if (toSend)
{ {
toSend = true; /* send msg */
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
"p3MsgService::checkOutGoingMessages() Sending out message");
/* remove the pending flag */
(mit->second)->msgFlags &= ~RS_MSG_FLAGS_PENDING;
sendItem(mit->second);
toErase.push_back(mit->first);
changed = true ;
}
else
{
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
"p3MsgService::checkOutGoingMessages() Delaying until available...");
}
} }
if (toSend) /* clean up */
for(it = toErase.begin(); it != toErase.end(); it++)
{ {
/* send msg */ mit = msgOutgoing.find(*it);
pqioutput(PQL_DEBUG_BASIC, msgservicezone, if (mit != msgOutgoing.end())
"p3MsgService::checkOutGoingMessages() Sending out message"); {
/* remove the pending flag */ msgOutgoing.erase(mit);
(mit->second)->msgFlags &= ~RS_MSG_FLAGS_PENDING; }
sendItem(mit->second);
toErase.push_back(mit->first);
} }
else
if (toErase.size() > 0)
{ {
pqioutput(PQL_DEBUG_BASIC, msgservicezone, IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
"p3MsgService::checkOutGoingMessages() Delaying until available...");
} }
} }
/* clean up */ if(changed)
for(it = toErase.begin(); it != toErase.end(); it++) rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
{
mit = msgOutgoing.find(*it);
if (mit != msgOutgoing.end())
{
msgOutgoing.erase(mit);
}
}
if (toErase.size() > 0)
{
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
}
return 0; return 0;
} }

View File

@ -79,7 +79,9 @@ MessagesDialog::MessagesDialog(QWidget *parent)
connect(ui.forwardmessageButton, SIGNAL(clicked()), this, SLOT(forwardmessage())); connect(ui.forwardmessageButton, SIGNAL(clicked()), this, SLOT(forwardmessage()));
connect(ui.actionPrint, SIGNAL(triggered()), this, SLOT(print())); connect(ui.actionPrint, SIGNAL(triggered()), this, SLOT(print()));
ui.actionPrint->setDisabled(true);
connect(ui.actionPrintPreview, SIGNAL(triggered()), this, SLOT(printpreview())); connect(ui.actionPrintPreview, SIGNAL(triggered()), this, SLOT(printpreview()));
ui.actionPrintPreview->setDisabled(true);
connect(ui.printbutton, SIGNAL(clicked()), this, SLOT(print())); connect(ui.printbutton, SIGNAL(clicked()), this, SLOT(print()));
@ -93,6 +95,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
connect(ui.actionTextUnderIcon, SIGNAL(triggered()), this, SLOT(buttonstextundericon())); connect(ui.actionTextUnderIcon, SIGNAL(triggered()), this, SLOT(buttonstextundericon()));
connect(ui.actionSave_as, SIGNAL(triggered()), this, SLOT(fileSaveAs())); connect(ui.actionSave_as, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
ui.actionSave_as->setDisabled(true);
connect( ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); connect( ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
connect( ui.filterPatternLineEdit, SIGNAL( textChanged(const QString &)), this, SLOT(toggleclearButton())); connect( ui.filterPatternLineEdit, SIGNAL( textChanged(const QString &)), this, SLOT(toggleclearButton()));
@ -120,6 +123,8 @@ MessagesDialog::MessagesDialog(QWidget *parent)
proxyModel = new QSortFilterProxyModel(this); proxyModel = new QSortFilterProxyModel(this);
proxyModel->setDynamicSortFilter(true); proxyModel->setDynamicSortFilter(true);
proxyModel->setSourceModel(MessagesModel); proxyModel->setSourceModel(MessagesModel);
proxyModel->setSortRole(Qt::UserRole);
proxyModel->sort (3, Qt::DescendingOrder);
ui.messagestreeView->setModel(proxyModel); ui.messagestreeView->setModel(proxyModel);
ui.messagestreeView->setSelectionBehavior(QTreeView::SelectRows); ui.messagestreeView->setSelectionBehavior(QTreeView::SelectRows);
@ -216,82 +221,102 @@ MessagesDialog::~MessagesDialog()
// MainPage::keyPressEvent(e) ; // MainPage::keyPressEvent(e) ;
//} //}
int MessagesDialog::getSelectedMsgCount ()
{
//To check if the selection has more than one row.
QList<QModelIndex> selectedIndexList = ui.messagestreeView->selectionModel() -> selectedIndexes ();
QList<int> rowList;
for(QList<QModelIndex>::iterator it = selectedIndexList.begin(); it != selectedIndexList.end(); it++)
{
int row = it->row();
if (rowList.contains(row) == false)
{
rowList.append(row);
}
}
return rowList.size();
}
void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point ) void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
{ {
QMenu contextMnu( this ); QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier ); QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
contextMnu.clear(); contextMnu.clear();
newmsgAct = new QAction(QIcon(IMAGE_MESSAGE), tr( "New Message" ), this ); /** Defines the actions for the context menu */
connect( newmsgAct , SIGNAL( triggered() ), this, SLOT( newmessage() ) ); QAction* newmsgAct = NULL;
QAction* replytomsgAct = NULL;
QAction* replyallmsgAct = NULL;
QAction* forwardmsgAct = NULL;
QAction* removemsgAct = NULL;
//To check if the selection has more than one row. replytomsgAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Message" ), this );
QList<QModelIndex> selectedIndexList = ui.messagestreeView->selectionModel() -> selectedIndexes (); connect( replytomsgAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) );
QList<int> rowList; contextMnu.addAction( replytomsgAct);
for(QList<QModelIndex>::iterator it = selectedIndexList.begin(); it != selectedIndexList.end(); it++)
{
int row = it->row(); replyallmsgAct = new QAction(QIcon(IMAGE_MESSAGEREPLYALL), tr( "Reply to All" ), this );
if (rowList.contains(row) == false) connect( replyallmsgAct , SIGNAL( triggered() ), this, SLOT( replyallmessage() ) );
{ contextMnu.addAction( replyallmsgAct);
rowList.append(row);
}
}
int nn = rowList.size(); forwardmsgAct = new QAction(QIcon(IMAGE_MESSAGEFORWARD), tr( "Forward Message" ), this );
if(nn > 1) connect( forwardmsgAct , SIGNAL( triggered() ), this, SLOT( forwardmessage() ) );
{ contextMnu.addAction( forwardmsgAct);
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Messages" ), this );
connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) );
contextMnu.addAction( removemsgAct);
}
else if(nn == 1)
{
replytomsgAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Message" ), this );
connect( replytomsgAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) );
contextMnu.addAction( replytomsgAct);
replyallmsgAct = new QAction(QIcon(IMAGE_MESSAGEREPLYALL), tr( "Reply to All" ), this ); contextMnu.addSeparator();
connect( replyallmsgAct , SIGNAL( triggered() ), this, SLOT( replyallmessage() ) );
contextMnu.addAction( replyallmsgAct);
forwardmsgAct = new QAction(QIcon(IMAGE_MESSAGEFORWARD), tr( "Forward Message" ), this ); int nCount = getSelectedMsgCount ();
connect( forwardmsgAct , SIGNAL( triggered() ), this, SLOT( forwardmessage() ) );
contextMnu.addAction( forwardmsgAct);
contextMnu.addSeparator(); if (nCount > 1) {
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Messages" ), this );
} else {
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Message" ), this );
}
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Message" ), this ); connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) );
connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) ); contextMnu.addAction( removemsgAct);
contextMnu.addAction( removemsgAct);
} 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();
contextMnu.addAction( newmsgAct); newmsgAct = new QAction(QIcon(IMAGE_MESSAGE), tr( "New Message" ), this );
contextMnu.exec( mevent->globalPos() ); 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( mevent->globalPos() );
} }
void MessagesDialog::msgfilelistWidgetCostumPopupMenu( QPoint point ) void MessagesDialog::msgfilelistWidgetCostumPopupMenu( QPoint point )
{ {
QAction* getRecAct = NULL;
QAction* getAllRecAct = NULL;
QMenu contextMnu( this ); QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier ); QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
getRecAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), this ); getRecAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), this );
connect( getRecAct , SIGNAL( triggered() ), this, SLOT( getcurrentrecommended() ) ); connect( getRecAct , SIGNAL( triggered() ), this, SLOT( getcurrentrecommended() ) );
// getAllRecAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Download" ), this ); // getAllRecAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Download" ), this );
// connect( getAllRecAct , SIGNAL( triggered() ), this, SLOT( getallrecommended() ) ); // connect( getAllRecAct , SIGNAL( triggered() ), this, SLOT( getallrecommended() ) );
contextMnu.clear();
contextMnu.clear(); contextMnu.addAction( getRecAct);
contextMnu.addAction( getRecAct); // contextMnu.addAction( getAllRecAct);
// contextMnu.addAction( getAllRecAct); contextMnu.exec( mevent->globalPos() );
contextMnu.exec( mevent->globalPos() );
} }
void MessagesDialog::newmessage() void MessagesDialog::newmessage()
@ -572,6 +597,8 @@ void MessagesDialog::getallrecommended()
void MessagesDialog::changeBox(int) void MessagesDialog::changeBox(int)
{ {
MessagesModel->removeRows (0, MessagesModel->rowCount());
insertMessages(); insertMessages();
insertMsgTxtAndFiles(); insertMsgTxtAndFiles();
} }
@ -580,33 +607,21 @@ void MessagesDialog::insertMessages()
{ {
std::cerr <<"MessagesDialog::insertMessages called"; std::cerr <<"MessagesDialog::insertMessages called";
fflush(0); fflush(0);
int c;
c = MessagesModel->rowCount();
MessagesModel->removeRows(0,c);
//ui.messagestreeView->showColumn(4);
//ui.messagestreeView->showColumn(5);
std::list<MsgInfoSummary> msgList; std::list<MsgInfoSummary> msgList;
std::list<MsgInfoSummary>::const_iterator it; std::list<MsgInfoSummary>::const_iterator it;
rsMsgs -> getMessageSummaries(msgList); rsMsgs -> getMessageSummaries(msgList);
/* get the MsgId of the current one ... */
std::string cid;
std::string mid;
bool oldSelected = getCurrentMsg(cid, mid);
QStandardItem *newSelected = NULL;
/* remove old items ??? */
int listrow = ui.listWidget -> currentRow(); int listrow = ui.listWidget -> currentRow();
std::cerr << "MessagesDialog::insertMessages()" << std::endl; std::cerr << "MessagesDialog::insertMessages()" << std::endl;
std::cerr << "Current Row: " << listrow << std::endl; std::cerr << "Current Row: " << listrow << std::endl;
fflush(0); fflush(0);
/* check the mode we are in */ /* check the mode we are in */
unsigned int msgbox = 0; unsigned int msgbox = 0;
bool bFill = true;
switch(listrow) switch(listrow)
{ {
case 3: case 3:
@ -619,182 +634,235 @@ void MessagesDialog::insertMessages()
msgbox = RS_MSG_OUTBOX; msgbox = RS_MSG_OUTBOX;
break; break;
case 0: case 0:
default:
msgbox = RS_MSG_INBOX; msgbox = RS_MSG_INBOX;
break; break;
default:
bFill = false;
} }
//std::list<std::string>::iterator it; if (bFill) {
for(it = msgList.begin(); it != msgList.end(); it++) /* remove old items */
{ int nRowCount = MessagesModel->rowCount();
/* check the message flags, to decide which int nRow = 0;
* group it should go in... for (nRow = 0; nRow < nRowCount; ) {
* for(it = msgList.begin(); it != msgList.end(); it++) {
* InBox if ((it->msgflags & RS_MSG_BOXMASK) != msgbox) {
* OutBox continue;
* Drafts }
* Sent
*
* FLAGS = OUTGOING.
* -> Outbox/Drafts/Sent
* + SENT -> Sent
* + IN_PROGRESS -> Draft.
* + nuffing -> Outbox.
* FLAGS = INCOMING = (!OUTGOING)
* -> + NEW -> Bold.
*
*/
if ((it -> msgflags & RS_MSG_BOXMASK) != msgbox) if (it->msgId == MessagesModel->item(nRow, 5)->text().toStdString()) {
{ break;
//std::cerr << "Msg from other box: " << it->msgflags; }
//std::cerr << std::endl; }
continue;
if (it == msgList.end ()) {
MessagesModel->removeRow (nRow);
nRowCount = MessagesModel->rowCount();
} else {
nRow++;
}
} }
/* make a widget per friend */ for(it = msgList.begin(); it != msgList.end(); it++)
QStandardItem *item0 = new QStandardItem();
QStandardItem *item1 = new QStandardItem();
QStandardItem *item2 = new QStandardItem();
QStandardItem *item3 = new QStandardItem();
QStandardItem *item4 = new QStandardItem();
QStandardItem *item5 = new QStandardItem();
//set this false if you want to expand on double click
item0->setEditable(false);
item1->setEditable(false);
item2->setEditable(false);
item3->setEditable(false);
item4->setEditable(false);
/* So Text should be:
* (1) Msg / Broadcast
* (1b) Person / Channel Name
* (2) Rank
* (3) Date
* (4) Title
* (5) Msg
* (6) File Count
* (7) File Total
*/
// Date First.... (for sorting)
{ {
QDateTime qdatetime; /* check the message flags, to decide which
qdatetime.setTime_t(it->ts); * group it should go in...
*
* InBox
* OutBox
* Drafts
* Sent
*
* FLAGS = OUTGOING.
* -> Outbox/Drafts/Sent
* + SENT -> Sent
* + IN_PROGRESS -> Draft.
* + nuffing -> Outbox.
* FLAGS = INCOMING = (!OUTGOING)
* -> + NEW -> Bold.
*
*/
//if the mail is on same date show only time. if ((it -> msgflags & RS_MSG_BOXMASK) != msgbox)
if (qdatetime.daysTo(QDateTime::currentDateTime()) == 0)
{ {
QTime qtime = qdatetime.time(); //std::cerr << "Msg from other box: " << it->msgflags;
QVariant varTime(qtime); //std::cerr << std::endl;
item3->setData(varTime, Qt::DisplayRole); continue;
}
// search exisisting items
nRowCount = MessagesModel->rowCount();
for (nRow = 0; nRow < nRowCount; nRow++) {
if (it->msgId == MessagesModel->item(nRow, 5)->text().toStdString()) {
break;
}
}
/* make a widget per friend */
QStandardItem *item0 = NULL;
QStandardItem *item1 = NULL;
QStandardItem *item2 = NULL;
QStandardItem *item3 = NULL;
QStandardItem *item4 = NULL;
QStandardItem *item5 = NULL;
bool bInsert = false;
if (nRow < nRowCount) {
item0 = MessagesModel->item(nRow, 0);
item1 = MessagesModel->item(nRow, 1);
item2 = MessagesModel->item(nRow, 2);
item3 = MessagesModel->item(nRow, 3);
item4 = MessagesModel->item(nRow, 4);
item5 = MessagesModel->item(nRow, 5);
} else {
item0 = new QStandardItem();
item1 = new QStandardItem();
item2 = new QStandardItem();
item3 = new QStandardItem();
item4 = new QStandardItem();
item5 = new QStandardItem();
bInsert = true;
}
//set this false if you want to expand on double click
item0->setEditable(false);
item1->setEditable(false);
item2->setEditable(false);
item3->setEditable(false);
item4->setEditable(false);
/* So Text should be:
* (1) Msg / Broadcast
* (1b) Person / Channel Name
* (2) Rank
* (3) Date
* (4) Title
* (5) Msg
* (6) File Count
* (7) File Total
*/
// Date First.... (for sorting)
{
QDateTime qdatetime;
qdatetime.setTime_t(it->ts);
//if the mail is on same date show only time.
if (qdatetime.daysTo(QDateTime::currentDateTime()) == 0)
{
QTime qtime = qdatetime.time();
QVariant varTime(qtime);
item3->setData(varTime, Qt::DisplayRole);
}
else
{
QVariant varDateTime(qdatetime);
item3->setData(varDateTime, Qt::DisplayRole);
}
// for sorting
item3->setData(qdatetime, Qt::UserRole);
}
// From ....
{
item2 -> setText(QString::fromStdString(rsPeers->getPeerName(it->srcId)));
item2->setData(item2->text(), Qt::UserRole);
}
// Subject
item1 -> setText(QString::fromStdWString(it->title));
item1->setData(item1->text(), Qt::UserRole);
if ((it -> msgflags & RS_MSG_NEW) == RS_MSG_NEW)
{
QFont qf = item1->font();
qf.setBold(true);
item1->setFont(qf);
}
// Change Message icon when Subject is Re: or Fwd:
QString text = QString::fromStdWString(it->title);
if (text.startsWith("Re:", Qt::CaseInsensitive))
{
item1 -> setIcon(QIcon(":/images/message-mail-replied-read.png"));
}
else if (text.startsWith("Fwd:", Qt::CaseInsensitive))
{
item1 -> setIcon(QIcon(":/images/message-mail-forwarded-read.png"));
} }
else else
{ {
QVariant varDateTime(qdatetime); item1 -> setIcon(QIcon(":/images/message-mail-read.png"));
item3->setData(varDateTime, Qt::DisplayRole);
} }
}
// From .... if (it -> msgflags & RS_MSG_NEW)
{
item2 -> setText(QString::fromStdString(rsPeers->getPeerName(it->srcId)));
}
// Subject
item1 -> setText(QString::fromStdWString(it->title));
if ((it -> msgflags & RS_MSG_NEW) == RS_MSG_NEW)
{
QFont qf = item1->font();
qf.setBold(true);
item1->setFont(qf);
}
// Change Message icon when Subject is Re: or Fwd:
QString text = QString::fromStdWString(it->title);
if (text.startsWith("Re:", Qt::CaseInsensitive))
{
item1 -> setIcon(QIcon(":/images/message-mail-replied-read.png"));
}
else if (text.startsWith("Fwd:", Qt::CaseInsensitive))
{
item1 -> setIcon(QIcon(":/images/message-mail-forwarded-read.png"));
}
else
{
item1 -> setIcon(QIcon(":/images/message-mail-read.png"));
}
if (it -> msgflags & RS_MSG_NEW)
{
for(int i = 0; i < 10; i++)
{ {
/*QFont qf = item->font(i); for(int i = 0; i < 10; i++)
qf.setBold(true); {
item->setFont(i, qf);*/ /*QFont qf = item->font(i);
qf.setBold(true);
item->setFont(i, qf);*/
}
QString text = QString::fromStdWString(it->title);
if (text.startsWith("Re:", Qt::CaseInsensitive))
{
item1 -> setIcon(QIcon(":/images/message-mail-replied.png"));
}
else if (text.startsWith("Fwd:", Qt::CaseInsensitive))
{
item1 -> setIcon(QIcon(":/images/message-mail-forwarded.png"));
}
else
{
item1 -> setIcon(QIcon(":/images/message-mail.png"));
}
} }
QString text = QString::fromStdWString(it->title);
if (text.startsWith("Re:", Qt::CaseInsensitive)) if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX )
{ {
item1 -> setIcon(QIcon(":/images/message-mail-replied.png")); MessagesModel->setHeaderData(2, Qt::Horizontal, tr("Recipient"));
} }
else if (text.startsWith("Fwd:", Qt::CaseInsensitive)) else
{ {
item1 -> setIcon(QIcon(":/images/message-mail-forwarded.png")); MessagesModel->setHeaderData(2, Qt::Horizontal, tr("From"));
} }
else
{ // No of Files.
item1 -> setIcon(QIcon(":/images/message-mail.png")); {
} std::ostringstream out;
out << it -> count;
item0 -> setText(QString::fromStdString(out.str()));
item0->setData(item0->text(), Qt::UserRole);
//item -> setTextAlignment( 0, Qt::AlignCenter );
}
item4 -> setText(QString::fromStdString(it->srcId));
item5 -> setText(QString::fromStdString(it->msgId));
if (bInsert) {
/* add to the list */
QList<QStandardItem *> itemList;
itemList.append(item0);
itemList.append(item1);
itemList.append(item2);
itemList.append(item3);
itemList.append(item4);
itemList.append(item5);
MessagesModel->appendRow(itemList);
}
} }
} else {
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX ) MessagesModel->removeRows (0, MessagesModel->rowCount());
{
MessagesModel->setHeaderData(2, Qt::Horizontal, tr("Recipient"));
}
else
{
MessagesModel->setHeaderData(2, Qt::Horizontal, tr("From"));
}
// No of Files.
{
std::ostringstream out;
out << it -> count;
item0 -> setText(QString::fromStdString(out.str()));
//item -> setTextAlignment( 0, Qt::AlignCenter );
}
item4 -> setText(QString::fromStdString(it->srcId));
item5 -> setText(QString::fromStdString(it->msgId));
if ((oldSelected) && (mid == it->msgId))
{
//newSelected = item;
}
/* add to the list */
QList<QStandardItem *> itemList;
itemList.append(item0);
itemList.append(item1);
itemList.append(item2);
itemList.append(item3);
itemList.append(item4);
itemList.append(item5);
MessagesModel->appendRow(itemList);
} }
updateMessageSummaryList(); updateMessageSummaryList();
ui.messagestreeView->hideColumn(4); ui.messagestreeView->hideColumn(4);
ui.messagestreeView->hideColumn(5); ui.messagestreeView->hideColumn(5);
} }
// current row in messagestreeView has changed // current row in messagestreeView has changed
@ -890,6 +958,10 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index)
ui.msgList->clear(); ui.msgList->clear();
ui.msgText->clear(); ui.msgText->clear();
ui.actionSave_as->setDisabled(true);
ui.actionPrintPreview->setDisabled(true);
ui.actionPrint->setDisabled(true);
return; return;
} }
else else
@ -903,6 +975,16 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index)
mid = item->text().toStdString(); mid = item->text().toStdString();
} }
int nCount = getSelectedMsgCount ();
if (nCount == 1) {
ui.actionSave_as->setEnabled(true);
ui.actionPrintPreview->setEnabled(true);
ui.actionPrint->setEnabled(true);
} else {
ui.actionSave_as->setDisabled(true);
ui.actionPrintPreview->setDisabled(true);
ui.actionPrint->setDisabled(true);
}
/* Save the Data.... for later */ /* Save the Data.... for later */
@ -1312,34 +1394,34 @@ void MessagesDialog::updateMessageSummaryList()
/*calculating the new messages*/ /*calculating the new messages*/
for(it = msgList.begin(); it != msgList.end(); it++) for(it = msgList.begin(); it != msgList.end(); it++)
{ {
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_INBOX && ((it -> msgflags & RS_MSG_NEW) == RS_MSG_NEW)) if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_INBOX)
{
newInboxCount ++;
}
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_INBOX )
{ {
inboxCount ++; inboxCount ++;
if ((it -> msgflags & RS_MSG_NEW) == RS_MSG_NEW) {
newInboxCount ++;
}
} }
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX ) if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX)
{ {
newOutboxCount ++; newOutboxCount ++;
} }
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_DRAFTBOX ) if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_DRAFTBOX)
{ {
newDraftCount ++; newDraftCount ++;
} }
if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_SENTBOX ) if ((it -> msgflags & RS_MSG_BOXMASK) == RS_MSG_SENTBOX )
{ {
newSentboxCount ++; newSentboxCount ++;
} }
} }
QString textItem; QString textItem;
/*updating the labels in leftcolumn*/ /*updating the labels in leftcolumn*/
if(newInboxCount != 0)
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
QListWidgetItem* item = ui.listWidget->item(0);
if (newInboxCount != 0)
{ {
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
QListWidgetItem* item = ui.listWidget->item(0);
textItem = tr("Inbox") + " " + "(" + QString::number(newInboxCount)+")"; textItem = tr("Inbox") + " " + "(" + QString::number(newInboxCount)+")";
item->setText(textItem); item->setText(textItem);
QFont qf = item->font(); QFont qf = item->font();
@ -1350,8 +1432,6 @@ void MessagesDialog::updateMessageSummaryList()
} }
else else
{ {
QListWidgetItem* item = ui.listWidget->item(0);
textItem = tr("Inbox"); textItem = tr("Inbox");
item->setText(textItem); item->setText(textItem);
QFont qf = item->font(); QFont qf = item->font();
@ -1361,11 +1441,10 @@ void MessagesDialog::updateMessageSummaryList()
item->setForeground(QBrush(QColor(0, 0, 0))); item->setForeground(QBrush(QColor(0, 0, 0)));
} }
if(newOutboxCount != 0) //QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
item = ui.listWidget->item(1);
if (newOutboxCount != 0)
{ {
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
QListWidgetItem* item = ui.listWidget->item(1);
textItem = tr("Outbox") + " " + "(" + QString::number(newOutboxCount)+")"; textItem = tr("Outbox") + " " + "(" + QString::number(newOutboxCount)+")";
item->setText(textItem); item->setText(textItem);
QFont qf = item->font(); QFont qf = item->font();
@ -1374,8 +1453,6 @@ void MessagesDialog::updateMessageSummaryList()
} }
else else
{ {
QListWidgetItem* item = ui.listWidget->item(1);
textItem = tr("Outbox"); textItem = tr("Outbox");
item->setText(textItem); item->setText(textItem);
QFont qf = item->font(); QFont qf = item->font();
@ -1384,11 +1461,11 @@ void MessagesDialog::updateMessageSummaryList()
} }
if(newDraftCount != 0)
{
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
QListWidgetItem* item = ui.listWidget->item(2);
//QList<QListWidgetItem *> QListWidget::findItems ( const QString & text, Qt::MatchFlags flags ) const
item = ui.listWidget->item(2);
if (newDraftCount != 0)
{
textItem = tr("Draft") + "(" + QString::number(newDraftCount)+")"; textItem = tr("Draft") + "(" + QString::number(newDraftCount)+")";
item->setText(textItem); item->setText(textItem);
QFont qf = item->font(); QFont qf = item->font();
@ -1397,8 +1474,6 @@ void MessagesDialog::updateMessageSummaryList()
} }
else else
{ {
QListWidgetItem* item = ui.listWidget->item(2);
textItem = tr("Draft"); textItem = tr("Draft");
item->setText(textItem); item->setText(textItem);
QFont qf = item->font(); QFont qf = item->font();
@ -1408,48 +1483,14 @@ void MessagesDialog::updateMessageSummaryList()
} }
/* Total Inbox */ /* Total Inbox */
if(inboxCount != 0) item = ui.listWidget->item(5);
{ textItem = tr("Total Inbox:") + " " + QString::number(inboxCount);
QListWidgetItem* item = ui.listWidget->item(5); item->setText(textItem);
textItem = tr("Total Inbox:") + " " + QString::number(inboxCount);
item->setText(textItem);
/*QFont qf = item->font();
qf.setBold(true);
item->setFont(qf);*/
}
else
{
QListWidgetItem* item = ui.listWidget->item(5);
textItem = tr("Total Inbox:") + " " + "0";
item->setText(textItem);
/*QFont qf = item->font();
qf.setBold(false);
item->setFont(qf);*/
}
/* Total Sent */ /* Total Sent */
if(newSentboxCount != 0) item = ui.listWidget->item(6);
{ textItem = tr("Total Sent:") + " " + QString::number(newSentboxCount);
QListWidgetItem* item = ui.listWidget->item(6); item->setText(textItem);
textItem = tr("Total Sent:") + " " + QString::number(newSentboxCount);
item->setText(textItem);
/*QFont qf = item->font();
qf.setBold(true);
item->setFont(qf);*/
}
else
{
QListWidgetItem* item = ui.listWidget->item(6);
textItem = tr("Total Sent:") + " " + "0";
item->setText(textItem);
/*QFont qf = item->font();
qf.setBold(false);
item->setFont(qf);*/
}
} }
/** clear Filter **/ /** clear Filter **/

View File

@ -110,24 +110,11 @@ private:
void setCurrentFileName(const QString &fileName); void setCurrentFileName(const QString &fileName);
int getSelectedMsgCount ();
std::string mCurrCertId; std::string mCurrCertId;
std::string mCurrMsgId; std::string mCurrMsgId;
/** Define the popup menus for the Context menu */
QMenu* contextMnu;
/** Defines the actions for the context menu */
QAction* newmsgAct;
QAction* replytomsgAct;
QAction* replyallmsgAct;
QAction* forwardmsgAct;
QAction* removemsgAct;
QAction* getRecAct;
QAction* getAllRecAct;
QString fileName; QString fileName;
QFont mFont; QFont mFont;

View File

@ -948,13 +948,13 @@ border-image: url(:/images/closepressed.png)
<widget class="QListWidget" name="listWidget"> <widget class="QListWidget" name="listWidget">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>120</width> <width>140</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>120</width> <width>140</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>