mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-27 23:07:11 -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) {
|
else if (m_newEntry) {
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
m_newEntry->setGroup(m_newParent);
|
m_newEntry->setGroup(m_newParent);
|
||||||
|
m_entryView->setFocus();
|
||||||
|
m_entryView->setCurrentEntry(m_newEntry);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delete m_newEntry;
|
delete m_newEntry;
|
||||||
|
@ -35,6 +35,13 @@ Entry* EntryModel::entryFromIndex(const QModelIndex& index) const
|
|||||||
return m_group->entries().at(index.row());
|
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)
|
void EntryModel::setGroup(Group* group)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
@ -30,6 +30,7 @@ class EntryModel : public QAbstractTableModel
|
|||||||
public:
|
public:
|
||||||
explicit EntryModel(QObject* parent = 0);
|
explicit EntryModel(QObject* parent = 0);
|
||||||
Entry* entryFromIndex(const QModelIndex& index) const;
|
Entry* entryFromIndex(const QModelIndex& index) const;
|
||||||
|
QModelIndex indexFromEntry(Entry* entry) const;
|
||||||
|
|
||||||
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
|
@ -60,3 +60,8 @@ bool EntryView::isSingleEntrySelected()
|
|||||||
{
|
{
|
||||||
return (selectionModel()->selectedRows().size() == 1);
|
return (selectionModel()->selectedRows().size() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntryView::setCurrentEntry(Entry* entry)
|
||||||
|
{
|
||||||
|
setCurrentIndex(m_model->indexFromEntry(entry));
|
||||||
|
}
|
||||||
|
@ -33,6 +33,7 @@ public:
|
|||||||
void setModel(QAbstractItemModel* model);
|
void setModel(QAbstractItemModel* model);
|
||||||
Entry* currentEntry();
|
Entry* currentEntry();
|
||||||
bool isSingleEntrySelected();
|
bool isSingleEntrySelected();
|
||||||
|
void setCurrentEntry(Entry* entry);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setGroup(Group* group);
|
void setGroup(Group* group);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user