summaryrefslogtreecommitdiffstats
path: root/newmoviewizard.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2017-12-28 13:24:30 +0100
committerArno <arno@disconnect.de>2017-12-28 13:24:30 +0100
commit0e1e44409e8cc225210f3e22f6deb18d62ee8298 (patch)
tree7007f454d54e8691d009ce80b3c7c958753eb8fd /newmoviewizard.cpp
parentc6c4900e4cf9aa69b2de3c9c5af701800c0c25de (diff)
downloadSheMov-0e1e44409e8cc225210f3e22f6deb18d62ee8298.tar.gz
SheMov-0e1e44409e8cc225210f3e22f6deb18d62ee8298.tar.bz2
SheMov-0e1e44409e8cc225210f3e22f6deb18d62ee8298.zip
Guess if the file was reencoded
It's really simple: If we have a file with the same name, but another extension, add it as FT_ORIGIN to the list.
Diffstat (limited to 'newmoviewizard.cpp')
-rw-r--r--newmoviewizard.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp
index 427f1ad..8a4e961 100644
--- a/newmoviewizard.cpp
+++ b/newmoviewizard.cpp
@@ -25,6 +25,8 @@
#include <QHeaderView>
#include <QSortFilterProxyModel>
#include <QJsonObject>
+#include <QRegularExpression>
+#include <QDirIterator>
#include "newmoviewizard.h"
#include "smtreeitem.h"
@@ -511,6 +513,34 @@ void MovieInfoPage::addOld(){
oldFileDlg->deleteLater();
}
+void MovieInfoPage::guessOld(const QString &fullPath){
+ QFileInfo fi(fullPath);
+ QString baseName = fi.baseName();
+ QRegularExpression fnRe(baseName);
+ QModelIndex parent;
+ QDirIterator it(fi.dir());
+ QList<QVariant> itemData;
+ while(it.hasNext()){
+ QFileInfo curFi = it.next();
+ QString curBaseName = curFi.baseName();
+ for(int i = 0; i < mFileModel->rowCount(mFileModel->rootIndex()); ++i){
+ QModelIndex curIdx = mFileModel->index(i, WizardTreeModel::FileName, mFileModel->rootIndex());
+ if(curIdx.isValid()){
+ if(fnRe.match(curBaseName).hasMatch()){
+ if(curFi.absoluteFilePath() != fi.absoluteFilePath()){
+ parent = curIdx;
+ itemData << curFi.fileName() << curFi.size() << FT_ORIGIN << QVariant() << curFi.absoluteFilePath();
+ mOrigins << curFi.absoluteFilePath();
+ mFileModel->appendRow(itemData, parent);
+ break;
+ }
+ }
+ }
+ }
+ }
+ mFileView->expandAll();
+}
+
void MovieInfoPage::addFiles(){
QSettings s;
QString startDir = s.value("paths/addfilespath", QDir::homePath()).toString();