9ad6746ccd
A C-style cast is equivalent to try casting in the following order: 1. const_cast(...) 2. static_cast(...) 3. const_cast(static_cast(...)) 4. reinterpret_cast(...) 5. const_cast(reinterpret_cast(...)) By using static_cast<T>(...) explicitly we avoid the possibility of an unintentional and dangerous reinterpret_cast. Furthermore static_cast<T>(...) allows for easier grepping of casts.
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include "coincontroltreewidget.h"
|
|
#include "coincontroldialog.h"
|
|
|
|
CoinControlTreeWidget::CoinControlTreeWidget(QWidget *parent) :
|
|
QTreeWidget(parent)
|
|
{
|
|
|
|
}
|
|
|
|
void CoinControlTreeWidget::keyPressEvent(QKeyEvent *event)
|
|
{
|
|
if (event->key() == Qt::Key_Space) // press spacebar -> select checkbox
|
|
{
|
|
event->ignore();
|
|
if (this->currentItem()) {
|
|
int COLUMN_CHECKBOX = 0;
|
|
this->currentItem()->setCheckState(COLUMN_CHECKBOX, ((this->currentItem()->checkState(COLUMN_CHECKBOX) == Qt::Checked) ? Qt::Unchecked : Qt::Checked));
|
|
}
|
|
}
|
|
else if (event->key() == Qt::Key_Escape) // press esc -> close dialog
|
|
{
|
|
event->ignore();
|
|
CoinControlDialog *coinControlDialog = static_cast<CoinControlDialog*>(this->parentWidget());
|
|
coinControlDialog->done(QDialog::Accepted);
|
|
}
|
|
else
|
|
{
|
|
this->QTreeWidget::keyPressEvent(event);
|
|
}
|
|
}
|