Workaround for erroneously accept of Qt::Key_Delete on QAbstractItemView

see http://bugreports.qt.nokia.com/browse/QTBUG-8270

solved for PeersDialog, MessagesDialog and TransfersDialog


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2858 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-05-06 14:39:50 +00:00
parent 47f97e20b9
commit aae947ecd8
6 changed files with 72 additions and 44 deletions

View File

@ -130,6 +130,11 @@ MessagesDialog::MessagesDialog(QWidget *parent)
// connect after setting model // connect after setting model
connect( ui.messagestreeView->selectionModel(), SIGNAL(currentChanged ( QModelIndex, QModelIndex ) ) , this, SLOT( currentChanged( const QModelIndex & ) ) ); connect( ui.messagestreeView->selectionModel(), SIGNAL(currentChanged ( QModelIndex, QModelIndex ) ) , this, SLOT( currentChanged( const QModelIndex & ) ) );
// workaround for Qt bug, should be solved in next Qt release 4.7.0
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
QShortcut *Shortcut = new QShortcut(QKeySequence (Qt::Key_Delete), ui.messagestreeView, 0, 0, Qt::WidgetShortcut);
connect(Shortcut, SIGNAL(activated()), this, SLOT( removemessage ()));
/* hide the Tree +/- */ /* hide the Tree +/- */
ui.msgList->setRootIsDecorated( false ); ui.msgList->setRootIsDecorated( false );
ui.msgList->setSelectionMode( QAbstractItemView::ExtendedSelection ); ui.msgList->setSelectionMode( QAbstractItemView::ExtendedSelection );
@ -199,16 +204,17 @@ MessagesDialog::~MessagesDialog()
delete(timer); delete(timer);
} }
void MessagesDialog::keyPressEvent(QKeyEvent *e) // replaced by shortcut
{ //void MessagesDialog::keyPressEvent(QKeyEvent *e)
if(e->key() == Qt::Key_Delete) //{
{ // if(e->key() == Qt::Key_Delete)
removemessage() ; // {
e->accept() ; // removemessage() ;
} // e->accept() ;
else // }
MainPage::keyPressEvent(e) ; // else
} // MainPage::keyPressEvent(e) ;
//}
void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point ) void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
{ {

View File

@ -45,7 +45,8 @@ public:
~MessagesDialog(); ~MessagesDialog();
void insertMsgTxtAndFiles(QModelIndex index = QModelIndex()); void insertMsgTxtAndFiles(QModelIndex index = QModelIndex());
virtual void keyPressEvent(QKeyEvent *) ; // replaced by shortcut
// virtual void keyPressEvent(QKeyEvent *) ;
void updateMessageSummaryList(); void updateMessageSummaryList();
public slots: public slots:

View File

@ -220,6 +220,11 @@ PeersDialog::PeersDialog(QWidget *parent)
loadmypersonalstatus(); loadmypersonalstatus();
loadEmoticonsgroupchat(); loadEmoticonsgroupchat();
// workaround for Qt bug, should be solved in next Qt release 4.7.0
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
QShortcut *Shortcut = new QShortcut(QKeySequence (Qt::Key_Delete), ui.peertreeWidget, 0, 0, Qt::WidgetShortcut);
connect(Shortcut, SIGNAL(activated()), this, SLOT( removefriend ()));
/* Hide platform specific features */ /* Hide platform specific features */
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
@ -334,16 +339,17 @@ void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
contextMnu.exec( mevent->globalPos() ); contextMnu.exec( mevent->globalPos() );
} }
void PeersDialog::keyPressEvent(QKeyEvent *e) // replaced by shortcut
{ //void PeersDialog::keyPressEvent(QKeyEvent *e)
if(e->key() == Qt::Key_Delete) //{
{ // if(e->key() == Qt::Key_Delete)
removefriend() ; // {
e->accept() ; // removefriend() ;
} // e->accept() ;
else // }
MainPage::keyPressEvent(e) ; // else
} // MainPage::keyPressEvent(e) ;
//}
void PeersDialog::updateDisplay() void PeersDialog::updateDisplay()
{ {

View File

@ -55,7 +55,8 @@ public:
QPixmap picture; QPixmap picture;
virtual void updateDisplay() ; // overloaded from RsAutoUpdatePage virtual void updateDisplay() ; // overloaded from RsAutoUpdatePage
virtual void keyPressEvent(QKeyEvent *) ; // replaced by shortcut
// virtual void keyPressEvent(QKeyEvent *) ;
public slots: public slots:

View File

@ -105,6 +105,11 @@ TransfersDialog::TransfersDialog(QWidget *parent)
ui.downloadList->setAutoScroll(false) ; ui.downloadList->setAutoScroll(false) ;
// workaround for Qt bug, should be solved in next Qt release 4.7.0
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
QShortcut *Shortcut = new QShortcut(QKeySequence (Qt::Key_Delete), ui.downloadList, 0, 0, Qt::WidgetShortcut);
connect(Shortcut, SIGNAL(activated()), this, SLOT( cancel ()));
//Selection Setup //Selection Setup
selection = ui.downloadList->selectionModel(); selection = ui.downloadList->selectionModel();
@ -257,16 +262,17 @@ TransfersDialog::TransfersDialog(QWidget *parent)
connect( playAct , SIGNAL( triggered() ), this, SLOT( openTransfer() ) ); connect( playAct , SIGNAL( triggered() ), this, SLOT( openTransfer() ) );
} }
void TransfersDialog::keyPressEvent(QKeyEvent *e) // replaced by shortcut
{ //void TransfersDialog::keyPressEvent(QKeyEvent *e)
if(e->key() == Qt::Key_Delete) //{
{ // if(e->key() == Qt::Key_Delete)
cancel() ; // {
e->accept() ; // cancel() ;
} // e->accept() ;
else // }
RsAutoUpdatePage::keyPressEvent(e) ; // else
} // RsAutoUpdatePage::keyPressEvent(e) ;
//}
void TransfersDialog::downloadListCostumPopupMenu( QPoint point ) void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
{ {
@ -877,18 +883,25 @@ QString TransfersDialog::getPeerName(const std::string& id) const
void TransfersDialog::cancel() void TransfersDialog::cancel()
{ {
QString queryWrn2; bool first = true;
queryWrn2.clear(); for(int i = 0; i < DLListModel->rowCount(); i++) {
queryWrn2.append(tr("Are you sure that you want to cancel and delete these files?")); if(selection->isRowSelected(i, QModelIndex())) {
if (first) {
first = false;
QString queryWrn2;
queryWrn2.clear();
queryWrn2.append(tr("Are you sure that you want to cancel and delete these files?"));
if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok) if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::No) {
for(int i = 0; i <= DLListModel->rowCount(); i++) break;
if(selection->isRowSelected(i, QModelIndex())) }
{ }
std::string id = getID(i, DLListModel).toStdString();
rsFiles->FileCancel(id); /* hash */ std::string id = getID(i, DLListModel).toStdString();
}
rsFiles->FileCancel(id); /* hash */
}
}
} }
//void TransfersDialog::handleDownloadRequest(const QString& url) //void TransfersDialog::handleDownloadRequest(const QString& url)

View File

@ -55,7 +55,8 @@ public:
/** Default Destructor */ /** Default Destructor */
~TransfersDialog(); ~TransfersDialog();
virtual void keyPressEvent(QKeyEvent *) ; // replaced by shortcut
// virtual void keyPressEvent(QKeyEvent *) ;
virtual void updateDisplay() ; // derived from RsAutoUpdateWidget virtual void updateDisplay() ; // derived from RsAutoUpdateWidget
static DetailsDialog *detailsdlg; static DetailsDialog *detailsdlg;