|
|
|
@ -6,28 +6,43 @@
@@ -6,28 +6,43 @@
|
|
|
|
|
#include <QFileSystemModel> |
|
|
|
|
#include <QString> |
|
|
|
|
#include <QHBoxLayout> |
|
|
|
|
#include <QVBoxLayout> |
|
|
|
|
#include <QDesktopServices> |
|
|
|
|
#include <QUrl> |
|
|
|
|
|
|
|
|
|
Window::Window(QWidget *parent) : |
|
|
|
|
QWidget(parent) |
|
|
|
|
{ |
|
|
|
|
QVBoxLayout* navbar = new QVBoxLayout(this); |
|
|
|
|
mButton = new QPushButton("^"); |
|
|
|
|
navbar->addWidget(mButton); |
|
|
|
|
|
|
|
|
|
QHBoxLayout* splitter = new QHBoxLayout(this); |
|
|
|
|
mListView = new QListView(this); |
|
|
|
|
splitter->addWidget(mListView); |
|
|
|
|
this->setLayout(splitter); |
|
|
|
|
//mButton = new QPushButton("add", this);
|
|
|
|
|
navbar->addItem(splitter); |
|
|
|
|
this->setLayout(navbar); |
|
|
|
|
|
|
|
|
|
mModel = new QFileSystemModel(); |
|
|
|
|
mListView->setModel(mModel); |
|
|
|
|
|
|
|
|
|
mModel->setRootPath("/home/user/"); |
|
|
|
|
mModel->setRootPath("/"); |
|
|
|
|
mListView->setRootIndex(mModel->index("/home/user/")); |
|
|
|
|
|
|
|
|
|
QObject::connect(mListView, &QListView::doubleClicked, |
|
|
|
|
this, &Window::changeIndex); |
|
|
|
|
QObject::connect(mButton, &QPushButton::clicked, |
|
|
|
|
this, &Window::moveUp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Window::moveUp() { |
|
|
|
|
mListView->setRootIndex(mListView->rootIndex().parent()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Window::changeIndex(const QModelIndex& index) { |
|
|
|
|
if (mModel->isDir(index)) { |
|
|
|
|
mListView->setRootIndex(index); |
|
|
|
|
} else { |
|
|
|
|
QDesktopServices::openUrl(QUrl::fromLocalFile(mModel->filePath(index))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|