Share UI: Allow typing in a sharee

Previously you *had* to select one of the completion options, even
if the text in the lineedit was identical to one of the options.
This commit is contained in:
Christian Kamm 2015-12-10 13:49:47 +01:00
Родитель df1b309b36
Коммит e2d1a5a41d
2 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -73,7 +73,7 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, const QString &sh
_manager = new ShareManager(_account, this);
connect(_manager, SIGNAL(sharesFetched(QList<QSharedPointer<Share>>)), SLOT(slotSharesFetched(QList<QSharedPointer<Share>>)));
connect(_manager, SIGNAL(shareCreated(QSharedPointer<Share>)), SLOT(getShares()));
// connect(_ui->shareeLineEdit, SIGNAL(returnPressed()), SLOT(on_searchPushButton_clicked()));
connect(_ui->shareeLineEdit, SIGNAL(returnPressed()), SLOT(slotLineEditReturn()));
connect(_completer, SIGNAL(activated(QModelIndex)), SLOT(slotCompleterActivated(QModelIndex)));
// Queued connection so this signal is recieved after textChanged
@ -105,6 +105,23 @@ void ShareUserGroupWidget::slotLineEditTextEdited(const QString& text)
}
}
void ShareUserGroupWidget::slotLineEditReturn()
{
// did the user type in one of the options?
const auto text = _ui->shareeLineEdit->text();
for (int i = 0; i < _completerModel->rowCount(); ++i) {
const auto sharee = _completerModel->getSharee(i);
if (sharee->format() == text) {
slotCompleterActivated(_completerModel->index(i));
break;
}
}
// nothing found? try to refresh completion
_completionTimer.start();
}
void ShareUserGroupWidget::searchForSharees()
{

Просмотреть файл

@ -104,6 +104,7 @@ private slots:
void searchForSharees();
void slotLineEditTextEdited(const QString &text);
void slotLineEditReturn();
void slotCompleterActivated(const QModelIndex & index);
void slotShareesReady();
void slotAdjustScrollWidgetSize();