Update file selection whenever an item is selected, not just clicked.

* This catches when you use typing to find an item, or select with the
  arrow keys.
This commit is contained in:
baldurk
2018-01-31 21:08:24 +00:00
parent edb85d834e
commit 29f5d7e53d
2 changed files with 14 additions and 0 deletions
@@ -593,6 +593,9 @@ VirtualFileDialog::VirtualFileDialog(ICaptureContext &ctx, QWidget *parent)
// switch to home folder and expand it
changeCurrentDir(m_Model->homeFolder());
ui->dirList->expand(m_DirProxy->mapFromSource(currentDir()));
QObject::connect(ui->fileList->selectionModel(), &QItemSelectionModel::selectionChanged, this,
&VirtualFileDialog::fileList_selectionChanged);
}
VirtualFileDialog::~VirtualFileDialog()
@@ -721,6 +724,14 @@ void VirtualFileDialog::on_fileList_clicked(const QModelIndex &index)
ui->filename->setText(m_FileProxy->data(index, RemoteFileModel::FileNameRole).toString());
}
void VirtualFileDialog::fileList_selectionChanged(const QItemSelection &selected,
const QItemSelection &deselected)
{
QModelIndexList indices = selected.indexes();
if(indices.count() >= 1)
on_fileList_clicked(indices[0]);
}
void VirtualFileDialog::on_fileList_keyPress(QKeyEvent *e)
{
// only process when enter is pressed
@@ -61,6 +61,9 @@ private slots:
void on_forward_clicked();
void on_upFolder_clicked();
// manual slots
void fileList_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
private:
Ui::VirtualFileDialog *ui;