Browse Source

more basic stuff

master
hex 5 years ago
parent
commit
1b47c4b995
  1. 1
      include/window.h
  2. 21
      src/window.cpp

1
include/window.h

@ -13,6 +13,7 @@ public: @@ -13,6 +13,7 @@ public:
explicit Window(QWidget *parent = 0);
public slots:
void moveUp();
void changeIndex(const QModelIndex& index);
private:

21
src/window.cpp

@ -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)));
}
}

Loading…
Cancel
Save