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
@ -17,10 +17,10 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#include "MessagesDialog.h"
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#include "MessagesDialog.h"
|
||||
#include "msgs/ChanMsgDialog.h"
|
||||
#include "gui/toaster/MessageToaster.h"
|
||||
#include "util/printpreview.h"
|
||||
@ -37,29 +37,29 @@
|
||||
#include <QPoint>
|
||||
#include <QMouseEvent>
|
||||
#include <QPixmap>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrinter>
|
||||
#include <QDateTime>
|
||||
#include <QHeaderView>
|
||||
|
||||
|
||||
/* Images for context menu icons */
|
||||
/* Images for context menu icons */
|
||||
#define IMAGE_MESSAGE ":/images/folder-draft.png"
|
||||
#define IMAGE_MESSAGEREPLY ":/images/mail_reply.png"
|
||||
#define IMAGE_MESSAGEREMOVE ":/images/mail_delete.png"
|
||||
#define IMAGE_DOWNLOAD ":/images/start.png"
|
||||
#define IMAGE_DOWNLOADALL ":/images/startall.png"
|
||||
|
||||
|
||||
/** Constructor */
|
||||
MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
: MainPage(parent)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
connect( ui.msgWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
|
||||
connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) );
|
||||
|
||||
/** Constructor */
|
||||
MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
: MainPage(parent)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
connect( ui.msgWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
|
||||
connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) );
|
||||
connect( ui.msgWidget, SIGNAL( itemClicked ( QTreeWidgetItem *, int) ), this, SLOT( updateMessages ( QTreeWidgetItem *, int) ) );
|
||||
connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
|
||||
|
||||
@ -82,21 +82,21 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
ui.msgWidget->setRootIsDecorated( false );
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * msgwheader = ui.msgWidget->header () ;
|
||||
QHeaderView * msgwheader = ui.msgWidget->header () ;
|
||||
msgwheader->setResizeMode (0, QHeaderView::Custom);
|
||||
msgwheader->setResizeMode (3, QHeaderView::Interactive);
|
||||
|
||||
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.msgList->header () ;
|
||||
msglheader->setResizeMode (0, QHeaderView::Interactive);
|
||||
msglheader->setResizeMode (1, QHeaderView::Interactive);
|
||||
QHeaderView * msglheader = ui.msgList->header () ;
|
||||
msglheader->setResizeMode (0, QHeaderView::Interactive);
|
||||
msglheader->setResizeMode (1, QHeaderView::Interactive);
|
||||
msglheader->setResizeMode (2, QHeaderView::Interactive);
|
||||
msglheader->setResizeMode (3, QHeaderView::Interactive);
|
||||
|
||||
msglheader->setResizeMode (3, QHeaderView::Interactive);
|
||||
|
||||
msglheader->resizeSection ( 0, 200 );
|
||||
msglheader->resizeSection ( 1, 100 );
|
||||
msglheader->resizeSection ( 2, 100 );
|
||||
@ -110,61 +110,84 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
/*Disabled Reply Button */
|
||||
//ui.replymessageButton->setEnabled(false);
|
||||
|
||||
QMenu * printmenu = new QMenu();
|
||||
printmenu->addAction(ui.actionPrint);
|
||||
printmenu->addAction(ui.actionPrintPreview);
|
||||
QMenu * printmenu = new QMenu();
|
||||
printmenu->addAction(ui.actionPrint);
|
||||
printmenu->addAction(ui.actionPrintPreview);
|
||||
ui.printbutton->setMenu(printmenu);
|
||||
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
|
||||
{
|
||||
|
||||
QMenu contextMnu( this );
|
||||
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
||||
|
||||
newmsgAct = new QAction(QIcon(IMAGE_MESSAGE), tr( "New Message" ), this );
|
||||
ui.msgWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
#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() ) );
|
||||
|
||||
removemsgAct = new QAction(QIcon(IMAGE_MESSAGEREMOVE), tr( "Remove Message" ), this );
|
||||
connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) );
|
||||
|
||||
|
||||
|
||||
contextMnu.clear();
|
||||
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 );
|
||||
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.addAction( newmsgAct);
|
||||
contextMnu.addAction( replytomsgAct);
|
||||
contextMnu.addAction( removemsgAct);
|
||||
contextMnu.exec( mevent->globalPos() );
|
||||
}
|
||||
contextMnu.exec( mevent->globalPos() );
|
||||
}
|
||||
|
||||
|
||||
void MessagesDialog::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 );
|
||||
void MessagesDialog::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 );
|
||||
getAllRecAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Download All" ), this );
|
||||
connect( getAllRecAct , SIGNAL( triggered() ), this, SLOT( getallrecommended() ) );
|
||||
|
||||
|
||||
contextMnu.clear();
|
||||
|
||||
contextMnu.clear();
|
||||
// contextMnu.addAction( getRecAct);
|
||||
contextMnu.addAction( getAllRecAct);
|
||||
contextMnu.exec( mevent->globalPos() );
|
||||
}
|
||||
contextMnu.exec( mevent->globalPos() );
|
||||
}
|
||||
|
||||
void MessagesDialog::newmessage()
|
||||
{
|
||||
@ -180,7 +203,7 @@ void MessagesDialog::newmessage()
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void MessagesDialog::replytomessage()
|
||||
void MessagesDialog::replytomessage()
|
||||
{
|
||||
/* put msg on msgBoard, and switch to it. */
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -679,27 +707,27 @@ void MessagesDialog::markMsgAsRead()
|
||||
return;
|
||||
}
|
||||
|
||||
void MessagesDialog::print()
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setFullPage(true);
|
||||
QPrintDialog *dlg = new QPrintDialog(&printer, this);
|
||||
if (ui.msgText->textCursor().hasSelection())
|
||||
dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
|
||||
dlg->setWindowTitle(tr("Print Document"));
|
||||
if (dlg->exec() == QDialog::Accepted) {
|
||||
ui.msgText->print(&printer);
|
||||
}
|
||||
delete dlg;
|
||||
#endif
|
||||
void MessagesDialog::print()
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setFullPage(true);
|
||||
QPrintDialog *dlg = new QPrintDialog(&printer, this);
|
||||
if (ui.msgText->textCursor().hasSelection())
|
||||
dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
|
||||
dlg->setWindowTitle(tr("Print Document"));
|
||||
if (dlg->exec() == QDialog::Accepted) {
|
||||
ui.msgText->print(&printer);
|
||||
}
|
||||
delete dlg;
|
||||
#endif
|
||||
}
|
||||
|
||||
void MessagesDialog::printpreview()
|
||||
{
|
||||
PrintPreview *preview = new PrintPreview(ui.msgText->document(), this);
|
||||
preview->setWindowModality(Qt::WindowModal);
|
||||
preview->setAttribute(Qt::WA_DeleteOnClose);
|
||||
preview->show();
|
||||
void MessagesDialog::printpreview()
|
||||
{
|
||||
PrintPreview *preview = new PrintPreview(ui.msgText->document(), this);
|
||||
preview->setWindowModality(Qt::WindowModal);
|
||||
preview->setAttribute(Qt::WA_DeleteOnClose);
|
||||
preview->show();
|
||||
}
|
||||
|
||||
|
@ -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