summaryrefslogtreecommitdiffstats
path: root/filesystemwidget.cpp
diff options
context:
space:
mode:
authoram <am@f440f766-f032-0410-8965-dc7d17de2ca0>2009-07-06 08:44:14 +0000
committeram <am@f440f766-f032-0410-8965-dc7d17de2ca0>2009-07-06 08:44:14 +0000
commitea9e5d0f1e02ca8c8859bbf59f2081b819f1d329 (patch)
treebf8309ded6ad5a44885b0aa756df0569586031d4 /filesystemwidget.cpp
parent2b2b3b79bf8b2d9be52a6058e3af03bf314bd9db (diff)
downloadSheMov-ea9e5d0f1e02ca8c8859bbf59f2081b819f1d329.tar.gz
SheMov-ea9e5d0f1e02ca8c8859bbf59f2081b819f1d329.tar.bz2
SheMov-ea9e5d0f1e02ca8c8859bbf59f2081b819f1d329.zip
-added some artwork
-started implementing FilesystemView git-svn-id: file:///var/svn/repos2/shemov/trunk@377 f440f766-f032-0410-8965-dc7d17de2ca0
Diffstat (limited to 'filesystemwidget.cpp')
-rw-r--r--filesystemwidget.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp
index 5e30b66..3798dcc 100644
--- a/filesystemwidget.cpp
+++ b/filesystemwidget.cpp
@@ -7,16 +7,69 @@
#include <QDirModel>
#include <QTreeView>
+#include <QSettings>
+#include <QDir>
+#include <QSplitter>
+#include <QVBoxLayout>
#include "filesystemwidget.h"
#include "filesystemdirproxy.h"
+#include "fileview.h"
+#include "shemoviconprovider.h"
FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent) {
mModel = new QDirModel;
mModel->setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);
+ mModel->setSorting(QDir::DirsFirst | QDir::IgnoreCase);
+ SheMovIconProvider *p = new SheMovIconProvider;
+ mModel->setIconProvider(p);
+
mDirProxy = new FilesystemDirProxy;
mDirProxy->setSourceModel(mModel);
mDirView = new QTreeView;
mDirView->setModel(mDirProxy);
+ mDirView->setColumnHidden(1, true);
+ mDirView->setColumnHidden(2, true);
+ mDirView->setColumnHidden(3, true);
+ mDirView->setRootIsDecorated(false);
+
+ mFileView = new FileView;
+ mFileView->setModel(mModel);
+ connect(mDirView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(directoryChanged(const QModelIndex &)));
+
+ QSettings s;
+ QString startDir = s.value("paths/start", QDir::homePath()).toString();
+ QModelIndex startIndex = mModel->index(startDir);
+ if(startIndex.isValid()){
+ QModelIndex proxyIndex = mDirProxy->mapFromSource(startIndex);
+ mDirView->setCurrentIndex(proxyIndex);
+ mDirView->setExpanded(proxyIndex, true);
+ QModelIndex parent = proxyIndex.parent();
+ mFileView->setRootIndex(startIndex);
+ do {
+ mDirView->setExpanded(parent, true);
+ parent = parent.parent();
+ }while(parent.isValid());
+ }
+
+ mFileView->resizeColumnToContents(0);
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ QSplitter *splitter = new QSplitter;
+ splitter->addWidget(mDirView);
+ splitter->addWidget(mFileView);
+ splitter->setStretchFactor(0, 1);
+ splitter->setStretchFactor(1, 2);
+ mainLayout->addWidget(splitter);
+
+ setLayout(mainLayout);
+}
+
+void FilesystemWidget::directoryChanged(const QModelIndex &index){
+ QModelIndex real = mDirProxy->mapToSource(index);
+ if(!index.isValid()){
+ return;
+ }
+ mFileView->setRootIndex(real);
}
+