From c92ad7dcf86f2e5e71d71a68e24e79fbdeceb56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 18 Aug 2013 20:52:17 +0200 Subject: Drag and Drop, mod management. --- depends/util/src/pathutils.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'depends/util/src/pathutils.cpp') diff --git a/depends/util/src/pathutils.cpp b/depends/util/src/pathutils.cpp index 97287840..5bafdf0f 100644 --- a/depends/util/src/pathutils.cpp +++ b/depends/util/src/pathutils.cpp @@ -17,6 +17,8 @@ #include #include +#include +#include QString PathCombine(QString path1, QString path2) { @@ -70,7 +72,7 @@ bool ensurePathExists(QString filenamepath) { QFileInfo a ( filenamepath ); QDir dir; - return (dir.mkpath ( a.path() )); + return (dir.mkpath ( a.filePath() )); } bool copyPath(QString src, QString dst) @@ -78,12 +80,14 @@ bool copyPath(QString src, QString dst) QDir dir(src); if (!dir.exists()) return false; + if(!ensurePathExists(dst)) + return false; foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { - QString dst_path = dst + QDir::separator() + d; - dir.mkpath(dst_path); - copyPath(src+ QDir::separator() + d, dst_path); + QString inner_src = src+ QDir::separator() + d; + QString inner_dst = dst + QDir::separator() + d; + copyPath(inner_src, inner_dst); } foreach (QString f, dir.entryList(QDir::Files)) @@ -92,3 +96,19 @@ bool copyPath(QString src, QString dst) } return true; } + +void openDirInDefaultProgram ( QString path, bool ensureExists ) +{ + QDir parentPath; + QDir dir( path ); + if(!dir.exists()) + { + parentPath.mkpath(dir.absolutePath()); + } + QDesktopServices::openUrl ( "file:///" + dir.absolutePath() ); +} + +void openFileInDefaultProgram ( QString filename ) +{ + QDesktopServices::openUrl ( "file:///" + QFileInfo ( filename ).absolutePath() ); +} -- cgit v1.2.3