mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-06-14 09:49:43 -04:00
Only edit entries on doubleclick (not single) or with enter key.
https://github.com/keepassx/keepassx/pull/19
This commit is contained in:
parent
5c84aa308d
commit
035271d469
2 changed files with 16 additions and 1 deletions
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "EntryView.h"
|
#include "EntryView.h"
|
||||||
|
|
||||||
|
#include <QtGui/QKeyEvent>
|
||||||
|
|
||||||
#include "gui/SortFilterHideProxyModel.h"
|
#include "gui/SortFilterHideProxyModel.h"
|
||||||
|
|
||||||
EntryView::EntryView(QWidget* parent)
|
EntryView::EntryView(QWidget* parent)
|
||||||
|
@ -42,12 +44,22 @@ EntryView::EntryView(QWidget* parent)
|
||||||
// QAbstractItemView::startDrag() uses this property as the default drag action
|
// QAbstractItemView::startDrag() uses this property as the default drag action
|
||||||
setDefaultDropAction(Qt::MoveAction);
|
setDefaultDropAction(Qt::MoveAction);
|
||||||
|
|
||||||
connect(this, SIGNAL(activated(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
|
connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
|
||||||
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged()));
|
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged()));
|
||||||
connect(m_model, SIGNAL(switchedToEntryListMode()), SLOT(switchToEntryListMode()));
|
connect(m_model, SIGNAL(switchedToEntryListMode()), SLOT(switchToEntryListMode()));
|
||||||
connect(m_model, SIGNAL(switchedToGroupMode()), SLOT(switchToGroupMode()));
|
connect(m_model, SIGNAL(switchedToGroupMode()), SLOT(switchToGroupMode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntryView::keyPressEvent(QKeyEvent* event)
|
||||||
|
{
|
||||||
|
if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) && currentIndex().isValid()) {
|
||||||
|
Q_EMIT emitEntryActivated(currentIndex());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QTreeView::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EntryView::setGroup(Group* group)
|
void EntryView::setGroup(Group* group)
|
||||||
{
|
{
|
||||||
m_model->setGroup(group);
|
m_model->setGroup(group);
|
||||||
|
|
|
@ -50,6 +50,9 @@ Q_SIGNALS:
|
||||||
void entryActivated(Entry* entry, EntryModel::ModelColumn column);
|
void entryActivated(Entry* entry, EntryModel::ModelColumn column);
|
||||||
void entrySelectionChanged();
|
void entrySelectionChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void emitEntryActivated(const QModelIndex& index);
|
void emitEntryActivated(const QModelIndex& index);
|
||||||
void switchToEntryListMode();
|
void switchToEntryListMode();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue