mirror of
https://github.com/QRouland/UTPass.git
synced 2025-07-04 03:02:28 +00:00
Add delete password store feature
This commit is contained in:
24
plugins/Pass/jobs/rmjob.cpp
Normal file
24
plugins/Pass/jobs/rmjob.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "rmjob.h"
|
||||
|
||||
RmJob::RmJob(QString path):
|
||||
m_path(path)
|
||||
{
|
||||
this->setObjectName("RmJob");
|
||||
}
|
||||
|
||||
|
||||
void RmJob::run()
|
||||
{
|
||||
auto info = QFileInfo(this->m_path);
|
||||
if (info.isFile()) {
|
||||
auto file = QFile(this->m_path);
|
||||
file.remove();
|
||||
emit resultReady(false);
|
||||
} else if (info.isDir()) {
|
||||
auto dir = QDir(this->m_path);
|
||||
dir.removeRecursively();
|
||||
emit resultReady(false);
|
||||
} else {
|
||||
emit resultReady(true);
|
||||
}
|
||||
}
|
46
plugins/Pass/jobs/rmjob.h
Normal file
46
plugins/Pass/jobs/rmjob.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef RMJOB_H
|
||||
#define RMJOB_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QDir>
|
||||
|
||||
/**
|
||||
* @class RmJob
|
||||
* @brief A class to handle removing recursively a path in a separate thread.
|
||||
*
|
||||
*/
|
||||
class RmJob : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/**
|
||||
* @brief The main function that performs the rm operation.
|
||||
*
|
||||
* Handles the process of removing recursively a target path.
|
||||
*/
|
||||
void run() override;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the rm operation is complete.
|
||||
*
|
||||
* @param err A boolean indicating whether an error occurred during cloning.
|
||||
* `true` if an error occurred, `false` if the clone was successful.
|
||||
*/
|
||||
void resultReady(const bool err);
|
||||
|
||||
private:
|
||||
QString m_path; ///< The path to be removed.
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor for the RmJob class.
|
||||
*
|
||||
* Initializes the RmJob with the specified path to be removed.
|
||||
*
|
||||
* @param path Path to be remove.
|
||||
*/
|
||||
RmJob(QString path);
|
||||
};
|
||||
|
||||
#endif // RMJOB_H
|
Reference in New Issue
Block a user