mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
MessagesDialog:
- enabled navigation through the messages with cursor keys - used timer for better handling after keypress git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2804 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1b4a70dbb3
commit
9d5db08b7a
@ -69,7 +69,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
|
||||
connect( ui.messagestreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
|
||||
connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) );
|
||||
connect( ui.messagestreeView, SIGNAL(clicked ( const QModelIndex &) ) , this, SLOT( updateCurrentMessage( const QModelIndex & ) ) );
|
||||
connect( ui.messagestreeView, SIGNAL(clicked ( const QModelIndex &) ) , this, SLOT( clicked( const QModelIndex & ) ) );
|
||||
connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
|
||||
|
||||
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
|
||||
@ -127,6 +127,9 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
ui.messagestreeView->setSortingEnabled(true);
|
||||
ui.messagestreeView->sortByColumn(3, Qt::DescendingOrder);
|
||||
|
||||
// connect after setting model
|
||||
connect( ui.messagestreeView->selectionModel(), SIGNAL(currentChanged ( QModelIndex, QModelIndex ) ) , this, SLOT( currentChanged( const QModelIndex & ) ) );
|
||||
|
||||
/* hide the Tree +/- */
|
||||
ui.msgList->setRootIsDecorated( false );
|
||||
ui.msgList->setSelectionMode( QAbstractItemView::ExtendedSelection );
|
||||
@ -172,11 +175,16 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
mFont = QFont("Arial", 10, QFont::Bold);
|
||||
ui.subjectText->setFont(mFont);
|
||||
|
||||
//sertting default filter by column as subject
|
||||
//setting default filter by column as subject
|
||||
proxyModel->setFilterKeyColumn(ui.filterColumnComboBox->currentIndex());
|
||||
|
||||
ui.clearButton->hide();
|
||||
|
||||
// create timer for navigation
|
||||
timer = new QTimer(this);
|
||||
timer->setInterval(300);
|
||||
timer->setSingleShot(true);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(updateCurrentMessage()));
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
@ -184,6 +192,13 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
||||
#endif
|
||||
}
|
||||
|
||||
MessagesDialog::~MessagesDialog()
|
||||
{
|
||||
// stop and delete timer
|
||||
timer->stop();
|
||||
delete(timer);
|
||||
}
|
||||
|
||||
void MessagesDialog::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
if(e->key() == Qt::Key_Delete)
|
||||
@ -761,10 +776,29 @@ void MessagesDialog::insertMessages()
|
||||
ui.messagestreeView->hideColumn(5);
|
||||
}
|
||||
|
||||
void MessagesDialog::updateCurrentMessage(const QModelIndex &index )
|
||||
// current row in messagestreeView has changed
|
||||
void MessagesDialog::currentChanged(const QModelIndex &index )
|
||||
{
|
||||
insertMsgTxtAndFiles(index);
|
||||
setMsgAsRead(index);
|
||||
timer->stop();
|
||||
timerIndex = index;
|
||||
timer->start();
|
||||
}
|
||||
|
||||
// click in messagestreeView
|
||||
void MessagesDialog::clicked(const QModelIndex &index )
|
||||
{
|
||||
timer->stop();
|
||||
timerIndex = index;
|
||||
// show current message directly
|
||||
updateCurrentMessage();
|
||||
}
|
||||
|
||||
// show current message directly
|
||||
void MessagesDialog::updateCurrentMessage()
|
||||
{
|
||||
timer->stop();
|
||||
insertMsgTxtAndFiles(timerIndex);
|
||||
setMsgAsRead(timerIndex);
|
||||
updateMessageSummaryList();
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
/** Default Constructor */
|
||||
MessagesDialog(QWidget *parent = 0);
|
||||
/** Default Destructor */
|
||||
~MessagesDialog();
|
||||
|
||||
void insertMsgTxtAndFiles(QModelIndex index = QModelIndex());
|
||||
virtual void keyPressEvent(QKeyEvent *) ;
|
||||
void updateMessageSummaryList();
|
||||
@ -57,7 +59,9 @@ private slots:
|
||||
void msgfilelistWidgetCostumPopupMenu(QPoint);
|
||||
|
||||
void changeBox( int newrow );
|
||||
void updateCurrentMessage(const QModelIndex&);
|
||||
void updateCurrentMessage();
|
||||
void currentChanged(const QModelIndex&);
|
||||
void clicked(const QModelIndex&);
|
||||
|
||||
void newmessage();
|
||||
|
||||
@ -127,6 +131,9 @@ private:
|
||||
|
||||
QFont mFont;
|
||||
|
||||
// timer and index for showing message
|
||||
QTimer *timer;
|
||||
QModelIndex timerIndex;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::MessagesDialog ui;
|
||||
|
Loading…
Reference in New Issue
Block a user