Enabled space to switch the read state in MessagesDialog and ForumsDialog.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4183 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-05-02 21:50:20 +00:00
parent 06bc6029f2
commit ac18995bdf
4 changed files with 46 additions and 2 deletions

View File

@ -23,7 +23,7 @@
#include <QFile>
#include <QDateTime>
#include <QMessageBox>
#include <QItemDelegate>
#include <QKeyEvent>
#include "ForumsDialog.h"
#include "forums/CreateForum.h"
@ -208,6 +208,8 @@ ForumsDialog::ForumsDialog(QWidget *parent)
insertThreads();
ui.threadTreeWidget->installEventFilter(this);
/* Hide platform specific features */
#ifdef Q_WS_WIN
@ -399,6 +401,23 @@ void ForumsDialog::threadListCustomPopupMenu( QPoint point )
contextMnu.exec(QCursor::pos());
}
bool ForumsDialog::eventFilter(QObject *obj, QEvent *event)
{
if (obj == ui.threadTreeWidget) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent && keyEvent->key() == Qt::Key_Space) {
// Space pressed
QTreeWidgetItem *item = ui.threadTreeWidget->currentItem ();
clickedThread (item, COLUMN_THREAD_READ);
return true; // eat event
}
}
}
// pass the event on to the parent class
return RsAutoUpdatePage::eventFilter(obj, event);
}
void ForumsDialog::restoreForumKeys(void)
{
rsForums->forumRestoreKeys(mCurrForumId);

View File

@ -41,6 +41,9 @@ public:
/* overloaded from RsAuthUpdatePage */
virtual void updateDisplay();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
private slots:
/** Create the context popup menu and it's submenus */
void forumListCustomPopupMenu( QPoint point );

View File

@ -19,7 +19,6 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QItemDelegate>
#include <QMessageBox>
#include <QPainter>
#include <QPaintEvent>
@ -371,6 +370,8 @@ MessagesDialog::MessagesDialog(QWidget *parent)
timer->setSingleShot(true);
connect(timer, SIGNAL(timeout()), this, SLOT(updateCurrentMessage()));
ui.messagestreeView->installEventFilter(this);
/* Hide platform specific features */
#ifdef Q_WS_WIN
@ -439,6 +440,24 @@ void MessagesDialog::processSettings(bool bLoad)
m_bProcessSettings = false;
}
bool MessagesDialog::eventFilter(QObject *obj, QEvent *event)
{
if (obj == ui.messagestreeView) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent && keyEvent->key() == Qt::Key_Space) {
// Space pressed
QModelIndex currentIndex = ui.messagestreeView->currentIndex();
QModelIndex index = ui.messagestreeView->model()->index(currentIndex.row(), COLUMN_UNREAD, currentIndex.parent());
clicked(index);
return true; // eat event
}
}
}
// pass the event on to the parent class
return MainPage::eventFilter(obj, event);
}
void MessagesDialog::fillTags()
{
MsgTagType Tags;

View File

@ -48,6 +48,9 @@ public:
// replaced by shortcut
// virtual void keyPressEvent(QKeyEvent *) ;
protected:
bool eventFilter(QObject *obj, QEvent *ev);
public slots:
void insertMessages();
void messagesTagsChanged();