Initally select first entry in EntryView.

Closes #104
This commit is contained in:
Felix Geyer 2014-05-16 19:10:30 +02:00
parent 552ca7bf71
commit 4ab887c773
2 changed files with 14 additions and 2 deletions

View File

@ -62,13 +62,24 @@ void EntryView::keyPressEvent(QKeyEvent* event)
void EntryView::setGroup(Group* group) void EntryView::setGroup(Group* group)
{ {
m_model->setGroup(group); m_model->setGroup(group);
Q_EMIT entrySelectionChanged(); setFirstEntryActive();
} }
void EntryView::setEntryList(const QList<Entry*>& entries) void EntryView::setEntryList(const QList<Entry*>& entries)
{ {
m_model->setEntryList(entries); m_model->setEntryList(entries);
Q_EMIT entrySelectionChanged(); setFirstEntryActive();
}
void EntryView::setFirstEntryActive()
{
if(m_model->rowCount() > 0) {
QModelIndex index = m_sortModel->mapToSource(m_sortModel->index(0, 0));
setCurrentEntry(m_model->entryFromIndex(index));
}
else {
Q_EMIT entrySelectionChanged();
}
} }
bool EntryView::inEntryListMode() bool EntryView::inEntryListMode()

View File

@ -42,6 +42,7 @@ public:
void setEntryList(const QList<Entry*>& entries); void setEntryList(const QList<Entry*>& entries);
bool inEntryListMode(); bool inEntryListMode();
int numberOfSelectedEntries(); int numberOfSelectedEntries();
void setFirstEntryActive();
public Q_SLOTS: public Q_SLOTS:
void setGroup(Group* group); void setGroup(Group* group);