chore: clang format & cleanup
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
3f6cc17818
commit
b9e2c3524c
@ -6,12 +6,11 @@
|
|||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "ui_BlockedModsDialog.h"
|
#include "ui_BlockedModsDialog.h"
|
||||||
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, const QString& text, QList<BlockedMod>& mods)
|
BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, const QString& text, QList<BlockedMod>& mods)
|
||||||
: QDialog(parent), ui(new Ui::BlockedModsDialog), m_mods(mods)
|
: QDialog(parent), ui(new Ui::BlockedModsDialog), m_mods(mods)
|
||||||
@ -29,8 +28,6 @@ BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, cons
|
|||||||
|
|
||||||
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &BlockedModsDialog::directoryChanged);
|
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &BlockedModsDialog::directoryChanged);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
qDebug() << "[Blocked Mods Dialog] Mods List: " << mods;
|
qDebug() << "[Blocked Mods Dialog] Mods List: " << mods;
|
||||||
|
|
||||||
setupWatch();
|
setupWatch();
|
||||||
@ -50,15 +47,16 @@ BlockedModsDialog::~BlockedModsDialog()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockedModsDialog::dragEnterEvent(QDragEnterEvent *e) {
|
void BlockedModsDialog::dragEnterEvent(QDragEnterEvent* e)
|
||||||
|
{
|
||||||
if (e->mimeData()->hasUrls()) {
|
if (e->mimeData()->hasUrls()) {
|
||||||
e->acceptProposedAction();
|
e->acceptProposedAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockedModsDialog::dropEvent(QDropEvent *e)
|
void BlockedModsDialog::dropEvent(QDropEvent* e)
|
||||||
{
|
{
|
||||||
foreach (const QUrl &url, e->mimeData()->urls()) {
|
foreach (const QUrl& url, e->mimeData()->urls()) {
|
||||||
QString filePath = url.toLocalFile();
|
QString filePath = url.toLocalFile();
|
||||||
qDebug() << "[Blocked Mods Dialog] Dropped file:" << filePath;
|
qDebug() << "[Blocked Mods Dialog] Dropped file:" << filePath;
|
||||||
addHashTask(filePath);
|
addHashTask(filePath);
|
||||||
@ -80,12 +78,11 @@ void BlockedModsDialog::openAll()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockedModsDialog::addDownloadFolder() {
|
void BlockedModsDialog::addDownloadFolder()
|
||||||
QString dir = QFileDialog::getExistingDirectory(
|
{
|
||||||
this,
|
QString dir =
|
||||||
tr("Select directory where you downloaded the mods"),
|
QFileDialog::getExistingDirectory(this, tr("Select directory where you downloaded the mods"),
|
||||||
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation),
|
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation), QFileDialog::ShowDirsOnly);
|
||||||
QFileDialog::ShowDirsOnly);
|
|
||||||
qDebug() << "[Blocked Mods Dialog] Adding watch path:" << dir;
|
qDebug() << "[Blocked Mods Dialog] Adding watch path:" << dir;
|
||||||
m_watcher.addPath(dir);
|
m_watcher.addPath(dir);
|
||||||
scanPath(dir, true);
|
scanPath(dir, true);
|
||||||
@ -165,12 +162,12 @@ void BlockedModsDialog::scanPath(QString path, bool start_task)
|
|||||||
if (start_task) {
|
if (start_task) {
|
||||||
runHashTask();
|
runHashTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief add a hashing task for the file located at path, add the path to the pending set if the hasing task is already running
|
/// @brief add a hashing task for the file located at path, add the path to the pending set if the hasing task is already running
|
||||||
/// @param path the path to the local file being hashed
|
/// @param path the path to the local file being hashed
|
||||||
void BlockedModsDialog::addHashTask(QString path) {
|
void BlockedModsDialog::addHashTask(QString path)
|
||||||
|
{
|
||||||
if (m_hashing_task->isRunning()) {
|
if (m_hashing_task->isRunning()) {
|
||||||
qDebug() << "[Blocked Mods Dialog] adding a Hash task for" << path << "to the pending set.";
|
qDebug() << "[Blocked Mods Dialog] adding a Hash task for" << path << "to the pending set.";
|
||||||
m_pending_hash_paths.insert(path);
|
m_pending_hash_paths.insert(path);
|
||||||
@ -182,7 +179,8 @@ void BlockedModsDialog::addHashTask(QString path) {
|
|||||||
/// @brief add a hashing task for the file located at path and connect it to check that hash against
|
/// @brief add a hashing task for the file located at path and connect it to check that hash against
|
||||||
/// our blocked mods list
|
/// our blocked mods list
|
||||||
/// @param path the path to the local file being hashed
|
/// @param path the path to the local file being hashed
|
||||||
void BlockedModsDialog::buildHashTask(QString path) {
|
void BlockedModsDialog::buildHashTask(QString path)
|
||||||
|
{
|
||||||
auto hash_task = Hashing::createBlockedModHasher(path, ModPlatform::Provider::FLAME, "sha1");
|
auto hash_task = Hashing::createBlockedModHasher(path, ModPlatform::Provider::FLAME, "sha1");
|
||||||
|
|
||||||
qDebug() << "[Blocked Mods Dialog] Creating Hash task for path: " << path;
|
qDebug() << "[Blocked Mods Dialog] Creating Hash task for path: " << path;
|
||||||
@ -247,7 +245,8 @@ bool BlockedModsDialog::allModsMatched()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief ensure matched file paths still exist
|
/// @brief ensure matched file paths still exist
|
||||||
void BlockedModsDialog::validateMatchedMods() {
|
void BlockedModsDialog::validateMatchedMods()
|
||||||
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for (auto& mod : m_mods) {
|
for (auto& mod : m_mods) {
|
||||||
if (mod.matched) {
|
if (mod.matched) {
|
||||||
@ -264,8 +263,9 @@ void BlockedModsDialog::validateMatchedMods() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief run hast task or mark a pending run if it is already runing
|
/// @brief run hash task or mark a pending run if it is already runing
|
||||||
void BlockedModsDialog::runHashTask() {
|
void BlockedModsDialog::runHashTask()
|
||||||
|
{
|
||||||
if (!m_hashing_task->isRunning()) {
|
if (!m_hashing_task->isRunning()) {
|
||||||
m_rehash_pending = false;
|
m_rehash_pending = false;
|
||||||
m_hashing_task->start();
|
m_hashing_task->start();
|
||||||
@ -276,7 +276,8 @@ void BlockedModsDialog::runHashTask() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockedModsDialog::hashTaskFinished() {
|
void BlockedModsDialog::hashTaskFinished()
|
||||||
|
{
|
||||||
qDebug() << "[Blocked Mods Dialog] All hash tasks finished";
|
qDebug() << "[Blocked Mods Dialog] All hash tasks finished";
|
||||||
if (m_rehash_pending) {
|
if (m_rehash_pending) {
|
||||||
qDebug() << "[Blocked Mods Dialog] there was a pending rehash, building and running tasks";
|
qDebug() << "[Blocked Mods Dialog] there was a pending rehash, building and running tasks";
|
||||||
|
@ -33,8 +33,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void dragEnterEvent(QDragEnterEvent *event) override;
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||||
// void dragMoveEvent(QDragMoveEvent *event) override;
|
|
||||||
// void dragLeaveEvent(QDragLeaveEvent *event) override;
|
|
||||||
void dropEvent(QDropEvent *event) override;
|
void dropEvent(QDropEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user