Close AutoTypeSelectDialog when there are no entries left.

This happens when the entries were deleted or the database
has been closed.
This commit is contained in:
Felix Geyer 2013-03-22 21:01:47 +01:00
parent 21a80101ba
commit 095bf158b6
2 changed files with 9 additions and 0 deletions

View File

@ -51,6 +51,7 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)
connect(m_view, SIGNAL(activated(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
connect(m_view, SIGNAL(clicked(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
connect(m_view->model(), SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(entryRemoved()));
layout->addWidget(m_view);
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel, Qt::Horizontal, this);
@ -76,3 +77,10 @@ void AutoTypeSelectDialog::emitEntryActivated(const QModelIndex& index)
accept();
Q_EMIT entryActivated(entry, m_sequences[entry]);
}
void AutoTypeSelectDialog::entryRemoved()
{
if (m_view->model()->rowCount() == 0) {
reject();
}
}

View File

@ -40,6 +40,7 @@ Q_SIGNALS:
private Q_SLOTS:
void emitEntryActivated(const QModelIndex& index);
void entryRemoved();
private:
AutoTypeSelectView* const m_view;