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:
thunder2 2010-04-27 21:46:28 +00:00
parent 1b4a70dbb3
commit 9d5db08b7a
2 changed files with 50 additions and 9 deletions

View File

@ -69,7 +69,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
connect( ui.messagestreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) ); connect( ui.messagestreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( 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.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage())); connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
@ -127,6 +127,9 @@ MessagesDialog::MessagesDialog(QWidget *parent)
ui.messagestreeView->setSortingEnabled(true); ui.messagestreeView->setSortingEnabled(true);
ui.messagestreeView->sortByColumn(3, Qt::DescendingOrder); 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 +/- */ /* hide the Tree +/- */
ui.msgList->setRootIsDecorated( false ); ui.msgList->setRootIsDecorated( false );
ui.msgList->setSelectionMode( QAbstractItemView::ExtendedSelection ); ui.msgList->setSelectionMode( QAbstractItemView::ExtendedSelection );
@ -172,11 +175,16 @@ MessagesDialog::MessagesDialog(QWidget *parent)
mFont = QFont("Arial", 10, QFont::Bold); mFont = QFont("Arial", 10, QFont::Bold);
ui.subjectText->setFont(mFont); ui.subjectText->setFont(mFont);
//sertting default filter by column as subject //setting default filter by column as subject
proxyModel->setFilterKeyColumn(ui.filterColumnComboBox->currentIndex()); proxyModel->setFilterKeyColumn(ui.filterColumnComboBox->currentIndex());
ui.clearButton->hide(); 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 */ /* Hide platform specific features */
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
@ -184,6 +192,13 @@ MessagesDialog::MessagesDialog(QWidget *parent)
#endif #endif
} }
MessagesDialog::~MessagesDialog()
{
// stop and delete timer
timer->stop();
delete(timer);
}
void MessagesDialog::keyPressEvent(QKeyEvent *e) void MessagesDialog::keyPressEvent(QKeyEvent *e)
{ {
if(e->key() == Qt::Key_Delete) if(e->key() == Qt::Key_Delete)
@ -761,10 +776,29 @@ void MessagesDialog::insertMessages()
ui.messagestreeView->hideColumn(5); ui.messagestreeView->hideColumn(5);
} }
void MessagesDialog::updateCurrentMessage(const QModelIndex &index ) // current row in messagestreeView has changed
void MessagesDialog::currentChanged(const QModelIndex &index )
{ {
insertMsgTxtAndFiles(index); timer->stop();
setMsgAsRead(index); 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(); updateMessageSummaryList();
} }

View File

@ -42,6 +42,8 @@ public:
/** Default Constructor */ /** Default Constructor */
MessagesDialog(QWidget *parent = 0); MessagesDialog(QWidget *parent = 0);
/** Default Destructor */ /** Default Destructor */
~MessagesDialog();
void insertMsgTxtAndFiles(QModelIndex index = QModelIndex()); void insertMsgTxtAndFiles(QModelIndex index = QModelIndex());
virtual void keyPressEvent(QKeyEvent *) ; virtual void keyPressEvent(QKeyEvent *) ;
void updateMessageSummaryList(); void updateMessageSummaryList();
@ -57,7 +59,9 @@ private slots:
void msgfilelistWidgetCostumPopupMenu(QPoint); void msgfilelistWidgetCostumPopupMenu(QPoint);
void changeBox( int newrow ); void changeBox( int newrow );
void updateCurrentMessage(const QModelIndex&); void updateCurrentMessage();
void currentChanged(const QModelIndex&);
void clicked(const QModelIndex&);
void newmessage(); void newmessage();
@ -127,6 +131,9 @@ private:
QFont mFont; QFont mFont;
// timer and index for showing message
QTimer *timer;
QModelIndex timerIndex;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::MessagesDialog ui; Ui::MessagesDialog ui;