Only edit entries on doubleclick (not single) or with enter key.

https://github.com/keepassx/keepassx/pull/19
This commit is contained in:
Jens Dieskau 2013-09-29 17:33:45 +02:00 committed by Felix Geyer
parent 5c84aa308d
commit 035271d469
2 changed files with 16 additions and 1 deletions

View File

@ -17,6 +17,8 @@
#include "EntryView.h"
#include <QtGui/QKeyEvent>
#include "gui/SortFilterHideProxyModel.h"
EntryView::EntryView(QWidget* parent)
@ -42,12 +44,22 @@ EntryView::EntryView(QWidget* parent)
// QAbstractItemView::startDrag() uses this property as the default drag action
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(m_model, SIGNAL(switchedToEntryListMode()), SLOT(switchToEntryListMode()));
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)
{
m_model->setGroup(group);

View File

@ -50,6 +50,9 @@ Q_SIGNALS:
void entryActivated(Entry* entry, EntryModel::ModelColumn column);
void entrySelectionChanged();
protected:
void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
private Q_SLOTS:
void emitEntryActivated(const QModelIndex& index);
void switchToEntryListMode();