Add filesystem widget

This commit is contained in:
2021-04-20 12:00:30 +02:00
parent 47360b5227
commit 1ba6a0ff19
7 changed files with 203 additions and 31 deletions
+36
View File
@@ -0,0 +1,36 @@
#include "filesystemwidget.h"
#include <QSettings>
#include <QVBoxLayout>
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());
}