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);
|
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;
|
||||||
}
|
}
|
||||||
|
@ -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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user