summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--newmoviewizard.cpp30
-rw-r--r--newmoviewizard.h1
-rw-r--r--shemov.cpp1
3 files changed, 32 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();
diff --git a/newmoviewizard.h b/newmoviewizard.h
index d02cd62..d2deda3 100644
--- a/newmoviewizard.h
+++ b/newmoviewizard.h
@@ -61,6 +61,7 @@ class MovieInfoPage : public QWizardPage {
public slots:
void initCompleters();
+ void guessOld(const QString &fullPath);
private slots:
void extractTitle();
diff --git a/shemov.cpp b/shemov.cpp
index 42e6784..82033bf 100644
--- a/shemov.cpp
+++ b/shemov.cpp
@@ -300,6 +300,7 @@ void SheMov::newMovieWizardWithFiles(){
mNewMovieWizard->infoPage()->setCurrentDir(mFSWidget->currentDir());
foreach(QModelIndex sel, selected){
mNewMovieWizard->infoPage()->addFile(sel.data(SmDirModel::FullPathRole).toString());
+ mNewMovieWizard->infoPage()->guessOld(sel.data(SmDirModel::FullPathRole).toString());
}
QSettings s;
bool autoAddCovers = s.value("ui/autoaddcovers", false).toBool();