mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
- 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:
parent
44d4cfc8b9
commit
9d33feb6e6
@ -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;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
void insertMsgTxtAndFiles();
|
||||
|
||||
|
||||
virtual void keyPressEvent(QKeyEvent *) ;
|
||||
private slots:
|
||||
|
||||
/** Create the context popup menu and it's submenus */
|
||||
|
Loading…
Reference in New Issue
Block a user