#include <hildon-mime.h>
#include <dbus/dbus.h>
+#include "fileoperator.h"
+
FileList::FileList(QWidget *parent) :
QListView(parent),
bool FileList::changePath(QString path) {
+ path = FileOperator::unwindPath(path);
QDir dir(fileSystemModel->rootPath());
if (dir.cd(path)) {
setRootIndex(fileSystemModel->setRootPath(dir.absolutePath()));
QString FileOperator::shortenPath(const QString &path) {
QString homePath = QFSFileEngine::homePath();
- QString result = path;
+
if (path.indexOf(homePath, 0) == 0) {
+ QString result = path;
+
result.replace(0, homePath.size(), "~");
+ return result;
+ }
+
+ return path;
+}
+
+
+QString FileOperator::unwindPath(const QString &path) {
+ QString result = path;
+ // if ~ is the first character and / or nothing follows it, replace with home dir
+ if (path == "~" || path.indexOf("~/", 0) == 0) {
+ QString homePath = QFSFileEngine::homePath();
+ result.replace(0, 1, homePath);
+ // in case someone wants to enter a dir called ~ in the current dir, he can escape it with \~
+ } else if (path == "\\~" || path.indexOf("\\~/", 0) == 0) {
+ result.replace(0, 2, "~");
}
return result;
FileOperator(QWidget *parent = 0);
static QString shortenPath(const QString &path);
+ static QString unwindPath(const QString &path);
void deleteFiles(const QFileInfoList &files);
void copyFiles(const QFileInfoList &files, QDir &destination);