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

View File

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