#include "filesystemwidget.h" #include #include FilesystemWidget::FilesystemWidget(QAbstractItemModel *model, QWidget *parent) : QWidget(parent) , m_model(model) { m_listView = new QListView(this); m_listView->setModel(model); QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_listView); setLayout(layout); connect(m_listView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(fileClicked(QModelIndex))); } void FilesystemWidget::setDir(const QString &dir) { //m_model->setRootPath(dir); //m_treeView->setRootIndex(m_model->index(m_model->rootPath())); } void FilesystemWidget::selectFile(int row) { QModelIndex index = m_model->index(row, 0); m_listView->selectionModel()->clearSelection(); m_listView->selectionModel()->select(index, QItemSelectionModel::SelectCurrent); m_listView->scrollTo(index); } void FilesystemWidget::fileClicked(const QModelIndex &index) { emit fileSelected(index.row()); }