| 564 | }; |
| 565 | |
| 566 | VirtualFileDialog::VirtualFileDialog(ICaptureContext &ctx, QString initialDirectory, QWidget *parent) |
| 567 | : QDialog(parent), ui(new Ui::VirtualFileDialog) |
| 568 | { |
| 569 | ui->setupUi(this); |
| 570 | |
| 571 | setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); |
| 572 | |
| 573 | m_Model = new RemoteFileModel(ctx.Replay(), this); |
| 574 | |
| 575 | m_DirProxy = new RemoteFileProxy(this); |
| 576 | m_DirProxy->setSourceModel(m_Model); |
| 577 | |
| 578 | m_DirProxy->showFiles = false; |
| 579 | m_DirProxy->showHidden = ui->showHidden->isChecked(); |
| 580 | m_DirProxy->maxColCount = 1; |
| 581 | |
| 582 | m_FileProxy = new RemoteFileProxy(this); |
| 583 | m_FileProxy->setSourceModel(m_Model); |
| 584 | |
| 585 | m_FileProxy->showHidden = ui->showHidden->isChecked(); |
| 586 | |
| 587 | ui->dirList->setModel(m_DirProxy); |
| 588 | ui->fileList->setModel(m_FileProxy); |
| 589 | |
| 590 | ui->fileList->hideGridLines(); |
| 591 | |
| 592 | ui->fileList->sortByColumn(0, Qt::AscendingOrder); |
| 593 | |
| 594 | RDHeaderView *header = new RDHeaderView(Qt::Horizontal, this); |
| 595 | ui->fileList->setHeader(header); |
| 596 | header->setColumnStretchHints({1, -1, -1, -1}); |
| 597 | |
| 598 | ui->filter->addItems({tr("Executables"), tr("All Files")}); |
| 599 | |
| 600 | ui->back->setEnabled(false); |
| 601 | ui->forward->setEnabled(false); |
| 602 | ui->upFolder->setEnabled(false); |
| 603 | |
| 604 | ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(false); |
| 605 | |
| 606 | QModelIndex index; |
| 607 | |
| 608 | if(!initialDirectory.isEmpty()) |
| 609 | index = m_Model->indexForPath(initialDirectory); |
| 610 | |
| 611 | if(!index.isValid()) |
| 612 | index = m_Model->homeFolder(); |
| 613 | |
| 614 | if(index.data(RemoteFileModel::FileIsHiddenRole).toBool()) |
| 615 | ui->showHidden->setChecked(true); |
| 616 | |
| 617 | // switch to home folder and expand it |
| 618 | changeCurrentDir(index); |
| 619 | ui->dirList->expand(m_DirProxy->mapFromSource(currentDir())); |
| 620 | |
| 621 | QObject::connect(ui->fileList->selectionModel(), &QItemSelectionModel::selectionChanged, this, |
| 622 | &VirtualFileDialog::fileList_selectionChanged); |
| 623 | QObject::connect(ui->dirList->selectionModel(), &QItemSelectionModel::selectionChanged, this, |
nothing calls this directly
no test coverage detected