#include "deleteworker.h"\r
+\r
#include <QFileInfo>\r
#include <QDir>\r
#include <QDebug>\r
+#include <QThread>\r
+\r
+const int SLEEP_TIME = 1;\r
\r
-DeleteWorker::DeleteWorker(QObject *parent) :\r
- IWorker(parent),\r
- m_DeleteList(NULL),\r
+DeleteWorker::DeleteWorker() :\r
+ OperationWorker(),\r
+ m_DeleteList(),\r
m_Targets()\r
{\r
}\r
\r
-void DeleteWorker::operate()\r
+void DeleteWorker::Listup(const QString &path)\r
{\r
- m_progressText->setText(tr("削除準備中..."));\r
+ if (isAborted()) {\r
+ return;\r
+ }\r
+ this->thread()->msleep(SLEEP_TIME);\r
+\r
+ if (QFileInfo(path).isDir()) {\r
+ QDir dir(path);\r
+ QFileInfoList list = dir.entryInfoList(QDir::NoDotAndDotDot |\r
+ QDir::System |\r
+ QDir::Hidden |\r
+ QDir::AllDirs |\r
+ QDir::Files,\r
+ QDir::DirsFirst);\r
+ foreach (const QFileInfo &info, list) {\r
+ Listup(info.absoluteFilePath());\r
+ }\r
+ }\r
+\r
+ m_Targets << path;\r
+}\r
\r
- foreach (const QString &path, *m_DeleteList) {\r
- if (isStopRequested()) {\r
- emit canceled();\r
+\r
+void DeleteWorker::run()\r
+{\r
+ foreach (const QFileInfo &info, m_DeleteList) {\r
+ if (isAborted()) {\r
+ emit finished(true);\r
return;\r
}\r
- Listup(path);\r
+ Listup(info.absoluteFilePath());\r
}\r
\r
bool ret;\r
int errorCount = 0;\r
QString msg;\r
foreach (const QString &path, m_Targets) {\r
- if (isStopRequested()) {\r
- emit canceled();\r
+ this->thread()->msleep(SLEEP_TIME);\r
+ if (isAborted()) {\r
+ emit finished(true);\r
return;\r
}\r
\r
- emit operation(tr("削除:") + path);\r
+ emit progress(tr("削除:%1").arg(path));\r
\r
QFileInfo info(path);\r
if (info.isDir()) {\r
if (errorCount > 0) {\r
msg += tr("%1アイテム失敗。").arg(errorCount);\r
}\r
- m_progressText->setText(msg);\r
+ emit information(msg);\r
}\r
\r
emit finished();\r
}\r
\r
-void DeleteWorker::Listup(const QString &path)\r
+QString DeleteWorker::initialText() const\r
{\r
-// qDebug() << tr("Listup: ") << path;\r
-\r
- if (isStopRequested()) {\r
- return;\r
- }\r
-\r
- QFileInfo info(path);\r
-\r
- if (info.isDir()) {\r
- QDir dir(path);\r
- foreach (QFileInfo info2, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) {\r
-// qDebug() << info2.fileName();\r
- Listup(info2.absoluteFilePath());\r
- }\r
- }\r
-// qDebug() << "Targeting: " << path;\r
- m_Targets << path;\r
+ return tr("削除準備中...");\r
}\r