Add calculating stats with script
This commit is contained in:
+21
-18
@@ -1,5 +1,6 @@
|
||||
#include "batchprocessing.h"
|
||||
#include "ui_batchprocessing.h"
|
||||
#include <functional>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QStandardPaths>
|
||||
@@ -16,28 +17,30 @@
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
|
||||
void scanDirectory(const QString &path, QStringList &files)
|
||||
{
|
||||
QFileInfo info(path);
|
||||
if(info.isDir())
|
||||
{
|
||||
QDir dir(path);
|
||||
QStringList entries = dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
||||
for(QString &entry : entries)
|
||||
scanDirectory(dir.absoluteFilePath(entry), files);
|
||||
}
|
||||
else if(info.isFile())
|
||||
{
|
||||
files.append(path);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList scanDirectories(const QStringList &paths)
|
||||
{
|
||||
QStringList files;
|
||||
QStringList scannedDirs;
|
||||
|
||||
std::function<void(const QString &path)> scanDirectory = [&](const QString &path)
|
||||
{
|
||||
QFileInfo info(path);
|
||||
if(info.isDir() && !scannedDirs.contains(info.canonicalPath()))
|
||||
{
|
||||
scannedDirs.append(info.canonicalPath());
|
||||
QDir dir(path);
|
||||
QStringList entries = dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
||||
for(QString &entry : entries)
|
||||
scanDirectory(dir.absoluteFilePath(entry));
|
||||
}
|
||||
else if(info.isFile())
|
||||
{
|
||||
files.append(path);
|
||||
}
|
||||
};
|
||||
|
||||
for(const QString &path : paths)
|
||||
scanDirectory(path, files);
|
||||
scanDirectory(path);
|
||||
|
||||
return files;
|
||||
}
|
||||
@@ -205,7 +208,7 @@ void BatchProcessing::scriptFinished()
|
||||
_ui->startButton->setEnabled(true);
|
||||
_ui->stopButton->setEnabled(false);
|
||||
qDebug() << "script finished";
|
||||
delete _engineThread;
|
||||
_engineThread->deleteLater();
|
||||
_engineThread = nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user