From 84ed109c159dcbd0c9395717d54599e902060b26 Mon Sep 17 00:00:00 2001 From: am Date: Tue, 21 Jul 2009 13:48:56 +0000 Subject: -Made CoverItem behave consistent -get QModelIndex from MovieModel by movieId -ArchiveView: added delegates for dvd and size, MovieItem now returns size as int -Finished EditArchiveItemDialog -Reverted covereditor, it became too convoluted git-svn-id: file:///var/svn/repos2/shemov/trunk@393 f440f766-f032-0410-8965-dc7d17de2ca0 --- helper.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'helper.cpp') diff --git a/helper.cpp b/helper.cpp index baaacbb..508e482 100644 --- a/helper.cpp +++ b/helper.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 #include @@ -75,5 +76,42 @@ namespace Helper { } return retval; } + + bool moveToArchive(const QString &path, const QString &md5){ + QFileInfo info(path); + if(!info.exists()){ + return false; + } + QFileInfo destFile = QFileInfo(createArchivePath(path, md5)); + if(destFile.exists()){ + destFile = QFileInfo(createArchivePath(path, md5, true)); + if(destFile.exists()){ + return false; + } + } + return QFile::rename(path, destFile.absoluteFilePath()); + } + + bool removeFromArchive(const QString &fileName, const QString &md5){ + QString file = createArchivePath(fileName, md5); + QFileInfo info(file); + if(!info.exists()){ + return false; + } + return QFile::remove(file); + } + + const QString createArchivePath(const QString &path, const QString &md5, bool withMd5){ + QSettings s; + QString archiveDir = s.value("paths/archivedir").toString(); + QFileInfo info(path); + QString retval; + if(withMd5){ + retval = QString("%1/%2/%3/%4_%5.%6").arg(archiveDir).arg(md5[0]).arg(md5[1]).arg(info.completeBaseName()).arg(md5).arg(info.suffix()); + }else{ + retval = QString("%1/%2/%3/%4").arg(archiveDir).arg(md5[0]).arg(md5[1]).arg(info.fileName()); + } + return retval; + } } -- cgit v1.2.3-70-g09d2