Measurement database keyboard navigation.
--HG-- branch : develop
This commit is contained in:
parent
758fbc714f
commit
6533579b52
|
@ -30,6 +30,8 @@
|
|||
#include "ui_dialogmdatabase.h"
|
||||
#include "../mapplication.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
|
||||
:QDialog(parent),
|
||||
|
@ -57,6 +59,8 @@ DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
|
|||
ui->setupUi(this);
|
||||
InitDataBase(list);
|
||||
|
||||
ui->treeWidget->installEventFilter(this);
|
||||
|
||||
connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &DialogMDataBase::UpdateChecks);
|
||||
connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &DialogMDataBase::ShowDescription);
|
||||
|
||||
|
@ -91,6 +95,8 @@ DialogMDataBase::DialogMDataBase(QWidget *parent)
|
|||
ui->setupUi(this);
|
||||
InitDataBase();
|
||||
|
||||
ui->treeWidget->installEventFilter(this);
|
||||
|
||||
connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &DialogMDataBase::ShowDescription);
|
||||
|
||||
ReadSettings();
|
||||
|
@ -165,6 +171,38 @@ void DialogMDataBase::changeEvent(QEvent *event)
|
|||
QDialog::changeEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogMDataBase::eventFilter(QObject *target, QEvent *event)
|
||||
{
|
||||
if (target == ui->treeWidget)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
switch(keyEvent->key())
|
||||
{
|
||||
case Qt::Key_Up:
|
||||
{
|
||||
const QModelIndex model = ui->treeWidget->indexAbove(ui->treeWidget->currentIndex());
|
||||
QTreeWidgetItem *item = ui->treeWidget->itemAbove(ui->treeWidget->currentItem());
|
||||
emit ShowDescription(item, model.column());
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Down:
|
||||
{
|
||||
const QModelIndex model = ui->treeWidget->indexBelow(ui->treeWidget->currentIndex());
|
||||
QTreeWidgetItem *item = ui->treeWidget->itemBelow(ui->treeWidget->currentItem());
|
||||
emit ShowDescription(item, model.column());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QDialog::eventFilter(target, event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogMDataBase::UpdateChecks(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
|
||||
virtual bool eventFilter(QObject *target, QEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private slots:
|
||||
void UpdateChecks(QTreeWidgetItem *item, int column);
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerMinimumSectionSize">
|
||||
<number>57</number>
|
||||
</attribute>
|
||||
|
@ -63,6 +66,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::TabFocus</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
@ -73,6 +79,11 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>treeWidget</tabstop>
|
||||
<tabstop>textEdit</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../share/resources/tapeicon.qrc"/>
|
||||
</resources>
|
||||
|
@ -84,8 +95,8 @@
|
|||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
<x>257</x>
|
||||
<y>540</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
|
@ -100,8 +111,8 @@
|
|||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
<x>325</x>
|
||||
<y>540</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
|
|
Loading…
Reference in New Issue
Block a user