- adde multiple selection to the msgWidget QTreeView and setup context menu in accordance

- added Delete key function to easily delete messages


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@719 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2008-09-04 19:28:35 +00:00
parent 44d4cfc8b9
commit 9d33feb6e6
2 changed files with 117 additions and 88 deletions

View File

@ -115,6 +115,8 @@ MessagesDialog::MessagesDialog(QWidget *parent)
printmenu->addAction(ui.actionPrintPreview);
ui.printbutton->setMenu(printmenu);
ui.msgWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
/* Hide platform specific features */
#ifdef Q_WS_WIN
@ -122,27 +124,48 @@ MessagesDialog::MessagesDialog(QWidget *parent)
#endif
}
void MessagesDialog::keyPressEvent(QKeyEvent *e)
{
if(e->key() == Qt::Key_Delete)
{
removemessage() ;
e->accept() ;
}
else
MainPage::keyPressEvent(e) ;
}
void MessagesDialog::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() ) );
replytomsgAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Message" ), this );
connect( replytomsgAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) );
int nn = ui.msgWidget->selectedItems().size() ;
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Message" ), this );
connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) );
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);
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Message" ), this );
connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) );
contextMnu.addAction( removemsgAct);
}
contextMnu.clear();
contextMnu.addAction( newmsgAct);
contextMnu.addAction( replytomsgAct);
contextMnu.addAction( removemsgAct);
contextMnu.exec( mevent->globalPos() );
}
@ -648,6 +671,7 @@ bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)
void MessagesDialog::removemessage()
{
#ifdef TO_REMOVE
//std::cerr << "MessagesDialog::removemessage()" << std::endl;
std::string cid, mid;
if (!getCurrentMsg(cid, mid))
@ -656,8 +680,12 @@ void MessagesDialog::removemessage()
//std::cerr << " No Message selected" << std::endl;
return;
}
#endif
rsMsgs -> MessageDelete(mid);
QList<QTreeWidgetItem*> list(ui.msgWidget->selectedItems()) ;
for(QList<QTreeWidgetItem*>::const_iterator it(list.begin());it!=list.end();++it)
rsMsgs->MessageDelete((*it)->text(5).toStdString());
return;
}

View File

@ -41,6 +41,7 @@ public:
void insertMsgTxtAndFiles();
virtual void keyPressEvent(QKeyEvent *) ;
private slots:
/** Create the context popup menu and it's submenus */