rewrite MessagesPopupDialog for Messages Toaster

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1709 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2009-10-03 23:22:24 +00:00
parent 1383ca61f6
commit a1fbe33e43
4 changed files with 60 additions and 1371 deletions

View File

@ -21,6 +21,8 @@
#include "MessagesPopupDialog.h"
#include "MessagesDialog.h"
#include "msgs/ChanMsgDialog.h"
#include "util/printpreview.h"
@ -42,89 +44,20 @@
#include <QHeaderView>
/* Images for context menu icons */
#define IMAGE_MESSAGE ":/images/folder-draft.png"
#define IMAGE_MESSAGEREPLY ":/images/mail_reply.png"
#define IMAGE_MESSAGEFORWARD ":/images/mail_forward.png"
#define IMAGE_MESSAGEREMOVE ":/images/message-mail-imapdelete.png"
#define IMAGE_DOWNLOAD ":/images/start.png"
#define IMAGE_DOWNLOADALL ":/images/startall.png"
/** Constructor */
MessagesPopupDialog::MessagesPopupDialog(QWidget* parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect( ui.messagesWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.messagesList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.messagesWidget, SIGNAL( itemClicked ( QTreeWidgetItem *, int) ), this, SLOT( updateMessages ( QTreeWidgetItem *, int) ) );
connect( ui.messageslistWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
/*connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
connect(ui.removemessageButton, SIGNAL(clicked()), this, SLOT(removemessage()));
connect(ui.replymessageButton, SIGNAL(clicked()), this, SLOT(replytomessage()));
connect(ui.forwardmessageButton, SIGNAL(clicked()), this, SLOT(forwardmessage()));*/
messagesdlg = new MessagesDialog();
connect(ui.actionCompose, SIGNAL(triggered()), this, SLOT(newmessage()));
connect(ui.actionReplyMessage, SIGNAL(triggered()), this, SLOT(removemessage()));
connect(ui.actionForwardMessage, SIGNAL(triggered()), this, SLOT(replytomessage()));
connect(ui.actionRemove, SIGNAL(triggered()), this, SLOT(forwardmessage()));
//connect(ui.printbutton, SIGNAL(clicked()), this, SLOT(print()));
connect(ui.actionPrint, SIGNAL(triggered()), this, SLOT(print()));
connect(ui.actionPrintPreview, SIGNAL(triggered()), this, SLOT(printpreview()));
connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview()));
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended()));
mCurrCertId = "";
mCurrMsgId = "";
/* hide the Tree +/- */
ui.messagesList->setRootIsDecorated( false );
ui.messagesWidget->setRootIsDecorated( false );
/* Set header resize modes and initial section sizes */
QHeaderView * msgwheader = ui.messagesWidget->header () ;
msgwheader->setResizeMode (0, QHeaderView::Custom);
msgwheader->setResizeMode (3, QHeaderView::Interactive);
msgwheader->resizeSection ( 0, 24 );
msgwheader->resizeSection ( 2, 250 );
msgwheader->resizeSection ( 3, 140 );
/* Set header resize modes and initial section sizes */
QHeaderView * msglheader = ui.messagesList->header () ;
msglheader->setResizeMode (0, QHeaderView::Interactive);
msglheader->setResizeMode (1, QHeaderView::Interactive);
msglheader->setResizeMode (2, QHeaderView::Interactive);
msglheader->setResizeMode (3, QHeaderView::Interactive);
msglheader->resizeSection ( 0, 200 );
msglheader->resizeSection ( 1, 100 );
msglheader->resizeSection ( 2, 100 );
msglheader->resizeSection ( 3, 200 );
/*ui.newmessageButton->setIcon(QIcon(QString(":/images/folder-draft24-pressed.png")));
ui.replymessageButton->setIcon(QIcon(QString(":/images/replymail-pressed.png")));
ui.forwardmessageButton->setIcon(QIcon(QString(":/images/mailforward24-hover.png")));
ui.removemessageButton->setIcon(QIcon(QString(":/images/deletemail-pressed.png")));
ui.printbutton->setIcon(QIcon(QString(":/images/print24.png")));
ui.forwardmessageButton->setToolTip(tr("Forward selected Message"));*/
QMenu * printmenu2 = new QMenu();
printmenu2->addAction(ui.actionPrint);
printmenu2->addAction(ui.actionPrintPreview);
ui.actionPrintMenu->setMenu(printmenu2);
ui.messagesWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
ui.messagesWidget->sortItems( 3, Qt::DescendingOrder );
QVBoxLayout *layout = new QVBoxLayout(ui.centralwidget);
layout->addWidget(messagesdlg);
setLayout(layout);
layout->setSpacing( 0 );
layout->setMargin( 0 );
/* Hide platform specific features */
@ -133,651 +66,8 @@ MessagesPopupDialog::MessagesPopupDialog(QWidget* parent, Qt::WFlags flags)
#endif
}
void MessagesPopupDialog::keyPressEvent(QKeyEvent *e)
MessagesPopupDialog::~MessagesPopupDialog()
{
if(e->key() == Qt::Key_Delete)
{
removemessage() ;
e->accept() ;
}
else
QMainWindow::keyPressEvent(e) ;
}
void MessagesPopupDialog::messageslistWidgetCostumPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
contextMnu.clear();
newmsgAct = new QAction(QIcon(IMAGE_MESSAGE), tr( "New Message" ), this );
connect( newmsgAct , SIGNAL( triggered() ), this, SLOT( newmessage() ) );
int nn = ui.messagesWidget->selectedItems().size() ;
if(nn > 1)
{
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);
forwardmsgAct = new QAction(QIcon(IMAGE_MESSAGEFORWARD), tr( "Forward Message" ), this );
connect( forwardmsgAct , SIGNAL( triggered() ), this, SLOT( forwardmessage() ) );
contextMnu.addAction( forwardmsgAct);
contextMnu.addSeparator();
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Message" ), this );
connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) );
contextMnu.addAction( removemsgAct);
}
contextMnu.addAction( newmsgAct);
contextMnu.exec( mevent->globalPos() );
}
void MessagesPopupDialog::msgfilelistWidgetCostumPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
// getRecAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), this );
// connect( getRecAct , SIGNAL( triggered() ), this, SLOT( getcurrentrecommended() ) );
getAllRecAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Download All" ), this );
connect( getAllRecAct , SIGNAL( triggered() ), this, SLOT( getallrecommended() ) );
contextMnu.clear();
// contextMnu.addAction( getRecAct);
contextMnu.addAction( getAllRecAct);
contextMnu.exec( mevent->globalPos() );
}
void MessagesPopupDialog::newmessage()
{
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
/* fill it in */
//std::cerr << "MessagesDialog::newmessage()" << std::endl;
nMsgDialog->newMsg();
nMsgDialog->show();
nMsgDialog->activateWindow();
/* window will destroy itself! */
}
void MessagesPopupDialog::replytomessage()
{
/* put msg on msgBoard, and switch to it. */
std::string cid;
std::string mid;
if(!getCurrentMsg(cid, mid))
return ;
mCurrCertId = cid;
mCurrMsgId = mid;
MessageInfo msgInfo;
if (!rsMsgs -> getMessage(mid, msgInfo))
return ;
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
/* fill it in */
//std::cerr << "MessagesDialog::newmessage()" << std::endl;
nMsgDialog->newMsg();
nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
nMsgDialog->setWindowTitle(tr("Re: ") + QString::fromStdWString(msgInfo.title) ) ;
QTextDocument doc ;
doc.setHtml(QString::fromStdWString(msgInfo.msg)) ;
std::string cited_text(doc.toPlainText().toStdString()) ;
nMsgDialog->insertPastedText(cited_text) ;
nMsgDialog->addRecipient( msgInfo.srcId ) ;
nMsgDialog->show();
nMsgDialog->activateWindow();
}
void MessagesPopupDialog::forwardmessage()
{
/* put msg on msgBoard, and switch to it. */
std::string cid;
std::string mid;
if(!getCurrentMsg(cid, mid))
return ;
mCurrCertId = cid;
mCurrMsgId = mid;
MessageInfo msgInfo;
if (!rsMsgs -> getMessage(mid, msgInfo))
return ;
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
/* fill it in */
//std::cerr << "MessagesDialog::newmessage()" << std::endl;
nMsgDialog->newMsg();
nMsgDialog->insertTitleText( (QString("Fwd: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
nMsgDialog->setWindowTitle(tr("Fwd: ") + QString::fromStdWString(msgInfo.title) ) ;
QTextDocument doc ;
doc.setHtml(QString::fromStdWString(msgInfo.msg)) ;
std::string cited_text(doc.toPlainText().toStdString()) ;
nMsgDialog->insertForwardPastedText(cited_text) ;
nMsgDialog->addRecipient( msgInfo.srcId ) ;
nMsgDialog->show();
nMsgDialog->activateWindow();
}
void MessagesPopupDialog::togglefileview()
{
/* if msg header visible -> hide by changing splitter
* three widgets...
*/
QList<int> sizeList = ui.msgSplitter->sizes();
QList<int>::iterator it;
int listSize = 0;
int msgSize = 0;
int recommendSize = 0;
int i = 0;
for(it = sizeList.begin(); it != sizeList.end(); it++, i++)
{
if (i == 0)
{
listSize = (*it);
}
else if (i == 1)
{
msgSize = (*it);
}
else if (i == 2)
{
recommendSize = (*it);
}
}
int totalSize = listSize + msgSize + recommendSize;
bool toShrink = true;
if (recommendSize < (int) totalSize / 10)
{
toShrink = false;
}
QList<int> newSizeList;
if (toShrink)
{
newSizeList.push_back(listSize + recommendSize / 3);
newSizeList.push_back(msgSize + recommendSize * 2 / 3);
newSizeList.push_back(0);
ui.expandFilesButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
ui.expandFilesButton->setToolTip("Expand");
}
else
{
/* no change */
int nlistSize = (totalSize * 2 / 3) * listSize / (listSize + msgSize);
int nMsgSize = (totalSize * 2 / 3) - listSize;
newSizeList.push_back(nlistSize);
newSizeList.push_back(nMsgSize);
newSizeList.push_back(totalSize * 1 / 3);
ui.expandFilesButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
ui.expandFilesButton->setToolTip("Hide");
}
ui.msgSplitter->setSizes(newSizeList);
}
/* download the recommendations... */
void MessagesPopupDialog::getcurrentrecommended()
{
}
void MessagesPopupDialog::getallrecommended()
{
/* get Message */
MessageInfo msgInfo;
if (!rsMsgs -> getMessage(mCurrMsgId, msgInfo))
{
return;
}
const std::list<FileInfo> &recList = msgInfo.files;
std::list<FileInfo>::const_iterator it;
std::list<std::string> fnames;
std::list<std::string> hashes;
std::list<int> sizes;
for(it = recList.begin(); it != recList.end(); it++)
{
fnames.push_back(it->fname);
hashes.push_back(it->hash);
sizes.push_back(it->size);
}
/* now do requests */
std::list<std::string>::const_iterator fit;
std::list<std::string>::const_iterator hit;
std::list<int>::const_iterator sit;
for(fit = fnames.begin(), hit = hashes.begin(), sit = sizes.begin();
fit != fnames.end(); fit++, hit++, sit++)
{
std::cerr << "MessagesDialog::getallrecommended() Calling File Request";
std::cerr << std::endl;
std::list<std::string> srcIds;
srcIds.push_back(msgInfo.srcId);
rsFiles -> FileRequest(*fit, *hit, *sit, "", 0, srcIds);
}
}
void MessagesPopupDialog::changeBox( int newrow )
{
//std::cerr << "MessagesDialog::changeBox()" << std::endl;
insertMessages();
insertMsgTxtAndFiles();
}
void MessagesPopupDialog::insertMessages()
{
std::list<MsgInfoSummary> msgList;
std::list<MsgInfoSummary>::const_iterator it;
rsMsgs -> getMessageSummaries(msgList);
/* get a link to the table */
QTreeWidget *msgWidget = ui.messagesWidget;
/* get the MsgId of the current one ... */
std::string cid;
std::string mid;
bool oldSelected = getCurrentMsg(cid, mid);
QTreeWidgetItem *newSelected = NULL;
/* remove old items ??? */
int listrow = ui.messageslistWidget -> currentRow();
//std::cerr << "MessagesDialog::insertMessages()" << std::endl;
//std::cerr << "Current Row: " << listrow << std::endl;
/* check the mode we are in */
unsigned int msgbox = 0;
switch(listrow)
{
case 3:
msgbox = RS_MSG_SENTBOX;
break;
case 2:
msgbox = RS_MSG_DRAFTBOX;
break;
case 1:
msgbox = RS_MSG_OUTBOX;
break;
case 0:
default:
msgbox = RS_MSG_INBOX;
break;
}
QList<QTreeWidgetItem *> items;
for(it = msgList.begin(); it != msgList.end(); it++)
{
/* check the message flags, to decide which
* 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 ((it -> msgflags & RS_MSG_BOXMASK) != msgbox)
{
//std::cerr << "Msg from other box: " << it->msgflags;
//std::cerr << std::endl;
continue;
}
/* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
/* 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 qtime;
qtime.setTime_t(it->ts);
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
item -> setText(3, timestamp);
}
// From ....
{
item -> setText(1, QString::fromStdString(rsPeers->getPeerName(it->srcId)));
}
// Subject
item -> setText(2, QString::fromStdWString(it->title));
item -> setIcon(2, (QIcon(":/images/message-mail-read.png")));
// No of Files.
{
std::ostringstream out;
out << it -> count;
item -> setText(0, QString::fromStdString(out.str()));
item -> setTextAlignment( 0, Qt::AlignCenter );
}
item -> setText(4, QString::fromStdString(it->srcId));
item -> setText(5, QString::fromStdString(it->msgId));
if ((oldSelected) && (mid == it->msgId))
{
newSelected = item;
}
if (it -> msgflags & RS_MSG_NEW)
{
for(int i = 0; i < 10; i++)
{
QFont qf = item->font(i);
qf.setBold(true);
item->setFont(i, qf);
item -> setIcon(2, (QIcon(":/images/message-mail.png")));
//std::cerr << "Setting Item BOLD!" << std::endl;
}
}
/* add to the list */
items.append(item);
}
/* add the items in! */
msgWidget->clear();
msgWidget->insertTopLevelItems(0, items);
if (newSelected)
{
msgWidget->setCurrentItem(newSelected);
}
}
void MessagesPopupDialog::updateMessages( QTreeWidgetItem * item, int column )
{
//std::cerr << "MessagesDialog::insertMsgTxtAndFiles()" << std::endl;
insertMsgTxtAndFiles();
}
void MessagesPopupDialog::insertMsgTxtAndFiles()
{
/* Locate the current Message */
QTreeWidget *msglist = ui.messagesWidget;
std::cerr << "MessagesDialog::insertMsgTxtAndFiles()" << std::endl;
/* get its Ids */
std::string cid;
std::string mid;
QTreeWidgetItem *qtwi = msglist -> currentItem();
if (!qtwi)
{
/* blank it */
ui.dateText-> setText("");
ui.toText->setText("");
ui.fromText->setText("");
ui.filesText->setText("");
ui.subjectText->setText("");
ui.messagesList->clear();
return;
}
else
{
cid = qtwi -> text(4).toStdString();
mid = qtwi -> text(5).toStdString();
}
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() mid:" << mid << std::endl;
/* Save the Data.... for later */
mCurrCertId = cid;
mCurrMsgId = mid;
MessageInfo msgInfo;
if (!rsMsgs -> getMessage(mid, msgInfo))
{
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;
return;
}
const std::list<FileInfo> &recList = msgInfo.files;
std::list<FileInfo>::const_iterator it;
/* get a link to the table */
QTreeWidget *tree = ui.messagesList;
/* get the MessageInfo */
tree->clear();
tree->setColumnCount(5);
QList<QTreeWidgetItem *> items;
for(it = recList.begin(); it != recList.end(); it++)
{
/* make a widget per person */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
/* (0) Filename */
item -> setText(0, QString::fromStdString(it->fname));
//std::cerr << "Msg FileItem(" << it->fname.length() << ") :" << it->fname << std::endl;
/* (1) Size */
{
std::ostringstream out;
out << it->size;
item -> setText(1, QString::fromStdString(out.str()));
}
/* (2) Rank */
{
std::ostringstream out;
out << it->rank;
item -> setText(2, QString::fromStdString(out.str()));
}
item -> setText(3, QString::fromStdString(it->hash));
/* add to the list */
items.append(item);
}
/* add the items in! */
tree->insertTopLevelItems(0, items);
/* iterate through the sources */
std::list<std::string>::const_iterator pit;
QString msgTxt;
for(pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++)
{
msgTxt += QString::fromStdString(*pit);
msgTxt += " <";
msgTxt += QString::fromStdString(rsPeers->getPeerName(*pit));
msgTxt += ">, ";
}
if (msgInfo.msgcc.size() > 0)
msgTxt += "\nCc: ";
for(pit = msgInfo.msgcc.begin(); pit != msgInfo.msgcc.end(); pit++)
{
msgTxt += QString::fromStdString(*pit);
msgTxt += " <";
msgTxt += QString::fromStdString(rsPeers->getPeerName(*pit));
msgTxt += ">, ";
}
if (msgInfo.msgbcc.size() > 0)
msgTxt += "\nBcc: ";
for(pit = msgInfo.msgbcc.begin(); pit != msgInfo.msgbcc.end(); pit++)
{
msgTxt += QString::fromStdString(*pit);
msgTxt += " <";
msgTxt += QString::fromStdString(rsPeers->getPeerName(*pit));
msgTxt += ">, ";
}
{
QDateTime qtime;
qtime.setTime_t(msgInfo.ts);
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
ui.dateText-> setText(timestamp);
}
ui.toText->setText(msgTxt);
ui.fromText->setText(QString::fromStdString(rsPeers->getPeerName(msgInfo.srcId)));
ui.subjectText->setText(QString::fromStdWString(msgInfo.title));
ui.messagesText->setHtml(QString::fromStdWString(msgInfo.msg));
{
std::ostringstream out;
out << "(" << msgInfo.count << " Files)";
ui.filesText->setText(QString::fromStdString(out.str()));
}
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Msg Displayed OK!" << std::endl;
/* finally mark message as read! */
rsMsgs -> MessageRead(mid);
}
bool MessagesPopupDialog::getCurrentMsg(std::string &cid, std::string &mid)
{
/* Locate the current Message */
QTreeWidget *msglist = ui.messagesWidget;
//std::cerr << "MessagesDialog::getCurrentMsg()" << std::endl;
/* get its Ids */
QTreeWidgetItem *qtwi = msglist -> currentItem();
if (qtwi)
{
cid = qtwi -> text(4).toStdString();
mid = qtwi -> text(5).toStdString();
return true;
}
return false;
}
void MessagesPopupDialog::removemessage()
{
#ifdef TO_REMOVE
//std::cerr << "MessagesDialog::removemessage()" << std::endl;
std::string cid, mid;
if (!getCurrentMsg(cid, mid))
{
//std::cerr << "MessagesDialog::removemessage()";
//std::cerr << " No Message selected" << std::endl;
return;
}
#endif
QList<QTreeWidgetItem*> list(ui.messagesWidget->selectedItems()) ;
for(QList<QTreeWidgetItem*>::const_iterator it(list.begin());it!=list.end();++it)
rsMsgs->MessageDelete((*it)->text(5).toStdString());
return;
}
void MessagesPopupDialog::markMsgAsRead()
{
//std::cerr << "MessagesDialog::markMsgAsRead()" << std::endl;
std::string cid, mid;
if (!getCurrentMsg(cid, mid))
{
//std::cerr << "MessagesDialog::markMsgAsRead()";
//std::cerr << " No Message selected" << std::endl;
return;
}
rsMsgs -> MessageRead(mid);
return;
}
void MessagesPopupDialog::print()
{
#ifndef QT_NO_PRINTER
QPrinter printer(QPrinter::HighResolution);
printer.setFullPage(true);
QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (ui.messagesText->textCursor().hasSelection())
dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
dlg->setWindowTitle(tr("Print Document"));
if (dlg->exec() == QDialog::Accepted) {
ui.messagesText->print(&printer);
}
delete dlg;
#endif
}
void MessagesPopupDialog::printpreview()
{
PrintPreview *preview = new PrintPreview(ui.messagesText->document(), this);
preview->setWindowModality(Qt::WindowModal);
preview->setAttribute(Qt::WA_DeleteOnClose);
preview->show();
delete messagesdlg;
}

View File

@ -26,6 +26,8 @@
#include "ui_MessagesPopupDialog.h"
class MessagesDialog;
class MessagesPopupDialog : public QMainWindow
{
Q_OBJECT
@ -34,57 +36,15 @@ public:
/** Default Constructor */
MessagesPopupDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default Destructor */
~MessagesPopupDialog();
void insertMessages();
void insertMsgTxtAndFiles();
virtual void keyPressEvent(QKeyEvent *) ;
private slots:
/** Create the context popup menu and it's submenus */
void messageslistWidgetCostumPopupMenu( QPoint point );
void msgfilelistWidgetCostumPopupMenu(QPoint);
void changeBox( int newrow );
void updateMessages ( QTreeWidgetItem * item, int column );
void newmessage();
void replytomessage();
void forwardmessage();
void print();
void printpreview();
void removemessage();
void markMsgAsRead();
void getcurrentrecommended();
void getallrecommended();
/* handle splitter */
void togglefileview();
private:
bool getCurrentMsg(std::string &cid, std::string &mid);
MessagesDialog *messagesdlg;
std::string mCurrCertId;
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* forwardmsgAct;
QAction* removemsgAct;
QAction* getRecAct;
QAction* getAllRecAct;
/** Qt Designer generated object */
Ui::MessagesPopupDialog ui;

View File

@ -1,648 +1,85 @@
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MessagesPopupDialog</class>
<widget class="QMainWindow" name="MessagesPopupDialog" >
<property name="geometry" >
<widget class="QMainWindow" name="MessagesPopupDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>777</width>
<height>582</height>
<width>657</width>
<height>478</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Messages</string>
</property>
<property name="windowIcon" >
<iconset resource="images.qrc" >:/images/rstray3.png</iconset>
<property name="windowIcon">
<iconset resource="images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<property name="toolButtonStyle" >
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
<widget class="QWidget" name="centralwidget" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QSplitter" name="splitter_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<widget class="QListWidget" name="messageslistWidget" >
<property name="maximumSize" >
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="lineWidth" >
<number>1</number>
</property>
<property name="midLineWidth" >
<number>0</number>
</property>
<property name="resizeMode" >
<enum>QListView::Fixed</enum>
</property>
<property name="spacing" >
<number>0</number>
</property>
<property name="gridSize" >
<size>
<width>100</width>
<height>16</height>
</size>
</property>
<property name="modelColumn" >
<number>0</number>
</property>
<property name="uniformItemSizes" >
<bool>false</bool>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
<item>
<property name="text" >
<string>Inbox</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/folder-inbox.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string>Outbox</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/folder-outbox.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string>Draft</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/folder-draft.png</iconset>
</property>
</item>
<item>
<property name="text" >
<string>Sent</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/folder-sent.png</iconset>
</property>
</item>
</widget>
<widget class="QSplitter" name="msgSplitter" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<widget class="QTreeWidget" name="messagesWidget" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>5</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="indentation" >
<number>16</number>
</property>
<property name="sortingEnabled" >
<bool>true</bool>
</property>
<property name="columnCount" >
<number>4</number>
</property>
<column>
<property name="text" >
<string/>
</property>
</column>
<column>
<property name="text" >
<string>From</string>
</property>
</column>
<column>
<property name="text" >
<string>Subject</string>
</property>
</column>
<column>
<property name="text" >
<string>Date</string>
</property>
</column>
</widget>
<widget class="QWidget" name="layoutWidget" >
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" >
<property name="horizontalSpacing" >
<number>0</number>
</property>
<property name="verticalSpacing" >
<number>3</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="subjectlabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>12</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="font" >
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Subject:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLabel" name="subjectText" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>12</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="fromlabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>12</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="font" >
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>From:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLabel" name="fromText" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>12</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="datelabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>12</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="font" >
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Date:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLabel" name="dateText" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>12</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="tolabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>60</width>
<height>12</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="font" >
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>To:</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLabel" name="toText" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>12</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QTextBrowser" name="messagesText" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<string/>
</property>
<property name="pixmap" >
<pixmap/>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-size:10pt; font-weight:600;">Recommended Files&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
</property>
</widget>
</item>
<item row="0" column="3" >
<widget class="QLabel" name="filesText" >
<property name="font" >
<font>
<pointsize>10</pointsize>
<italic>true</italic>
</font>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QPushButton" name="expandFilesButton" >
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/edit_add24.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>351</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="downloadButton" >
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Download all Recommended Files&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="text" >
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/down.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QTreeWidget" name="messagesList" >
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled" >
<bool>true</bool>
</property>
<column>
<property name="text" >
<string>File Name</string>
</property>
</column>
<column>
<property name="text" >
<string>Size</string>
</property>
</column>
<column>
<property name="text" >
<string>Sources</string>
</property>
</column>
<column>
<property name="text" >
<string>Hash</string>
</property>
</column>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>777</width>
<height>30</height>
</rect>
<widget class="QWidget" name="centralwidget"/>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionCompose">
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/folder-draft24.png</normaloff>:/images/folder-draft24.png</iconset>
</property>
</widget>
<widget class="QStatusBar" name="statusbar" />
<widget class="QToolBar" name="toolBar" >
<property name="windowTitle" >
<string>toolBar</string>
</property>
<attribute name="toolBarArea" >
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak" >
<bool>false</bool>
</attribute>
<addaction name="actionCompose" />
<addaction name="separator" />
<addaction name="actionReplyMessage" />
<addaction name="actionForwardMessage" />
<addaction name="actionRemove" />
<addaction name="separator" />
<addaction name="actionPrintMenu" />
</widget>
<action name="actionCompose" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/folder-draft24.png</iconset>
</property>
<property name="text" >
<property name="text">
<string>Compose</string>
</property>
</action>
<action name="actionReplyMessage" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/replymail24.png</iconset>
<action name="actionReplyMessage">
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/replymail24.png</normaloff>:/images/replymail24.png</iconset>
</property>
<property name="text" >
<property name="text">
<string>Reply</string>
</property>
</action>
<action name="actionForwardMessage" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/mailforward24-hover.png</iconset>
<action name="actionForwardMessage">
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/mailforward24-hover.png</normaloff>:/images/mailforward24-hover.png</iconset>
</property>
<property name="text" >
<property name="text">
<string>Forward</string>
</property>
</action>
<action name="actionRemove" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/deletemail24.png</iconset>
<action name="actionRemove">
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/deletemail24.png</normaloff>:/images/deletemail24.png</iconset>
</property>
<property name="text" >
<property name="text">
<string>Remove</string>
</property>
</action>
<action name="actionPrintMenu" >
<property name="icon" >
<iconset resource="images.qrc" >:/images/print24.png</iconset>
<action name="actionPrintMenu">
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/print24.png</normaloff>:/images/print24.png</iconset>
</property>
<property name="text" >
<property name="text">
<string>Print</string>
</property>
</action>
<action name="actionPrintPreview" >
<property name="text" >
<action name="actionPrintPreview">
<property name="text">
<string>PrintPreview</string>
</property>
</action>
<action name="actionPrint" >
<property name="text" >
<action name="actionPrint">
<property name="text">
<string>Print</string>
</property>
</action>
</widget>
<resources>
<include location="images.qrc" />
<include location="images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -18,6 +18,7 @@
*/
#include "MessageToaster.h"
#include "gui/MessagesPopupDialog.h"
MessageToaster::MessageToaster( QWidget * parent, Qt::WFlags f)
: QWidget(parent, f)
@ -94,7 +95,8 @@ void MessageToaster::closeClicked()
void MessageToaster::openmessageClicked()
{
//
static MessagesPopupDialog *msgdialog = new MessagesPopupDialog();
msgdialog->show();
}
void MessageToaster::setMessage(const QString & message)