mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-14 00:39:53 -05:00
Select newly created entries.
This commit is contained in:
parent
8122ab2b2c
commit
09248fdb14
@ -223,6 +223,8 @@ void DatabaseWidget::switchToView(bool accepted)
|
||||
else if (m_newEntry) {
|
||||
if (accepted) {
|
||||
m_newEntry->setGroup(m_newParent);
|
||||
m_entryView->setFocus();
|
||||
m_entryView->setCurrentEntry(m_newEntry);
|
||||
}
|
||||
else {
|
||||
delete m_newEntry;
|
||||
|
@ -35,6 +35,13 @@ Entry* EntryModel::entryFromIndex(const QModelIndex& index) const
|
||||
return m_group->entries().at(index.row());
|
||||
}
|
||||
|
||||
QModelIndex EntryModel::indexFromEntry(Entry* entry) const
|
||||
{
|
||||
int row = m_group->entries().indexOf(entry);
|
||||
Q_ASSERT(row != -1);
|
||||
return index(row, 0);
|
||||
}
|
||||
|
||||
void EntryModel::setGroup(Group* group)
|
||||
{
|
||||
beginResetModel();
|
||||
|
@ -30,6 +30,7 @@ class EntryModel : public QAbstractTableModel
|
||||
public:
|
||||
explicit EntryModel(QObject* parent = 0);
|
||||
Entry* entryFromIndex(const QModelIndex& index) const;
|
||||
QModelIndex indexFromEntry(Entry* entry) const;
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
|
@ -60,3 +60,8 @@ bool EntryView::isSingleEntrySelected()
|
||||
{
|
||||
return (selectionModel()->selectedRows().size() == 1);
|
||||
}
|
||||
|
||||
void EntryView::setCurrentEntry(Entry* entry)
|
||||
{
|
||||
setCurrentIndex(m_model->indexFromEntry(entry));
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
void setModel(QAbstractItemModel* model);
|
||||
Entry* currentEntry();
|
||||
bool isSingleEntrySelected();
|
||||
void setCurrentEntry(Entry* entry);
|
||||
|
||||
public Q_SLOTS:
|
||||
void setGroup(Group* group);
|
||||
|
Loading…
Reference in New Issue
Block a user