irenamedialog.cpp \\r
iworker.cpp \\r
renameworker.cpp \\r
- deleteworker.cpp\r
+ deleteworker.cpp \\r
+ copyworker.cpp \\r
+ overwritedialog.cpp\r
\r
HEADERS += mainwindow.h \\r
folderpanel.h \\r
irenamedialog.h \\r
iworker.h \\r
renameworker.h \\r
- deleteworker.h\r
+ deleteworker.h \\r
+ copyworker.h \\r
+ overwritedialog.h\r
\r
FORMS += mainwindow.ui \\r
folderpanel.ui \\r
renamesingledialog.ui \\r
renamemultidialog.ui \\r
- operationdialog.ui\r
+ operationdialog.ui \\r
+ overwritedialog.ui\r
\r
RESOURCES += \\r
resource.qrc\r
--- /dev/null
+#include "copyworker.h"\r
+#include "overwritedialog.h"\r
+#include <QDir>\r
+#include <QFileInfo>\r
+#include <QDebug>\r
+#include <QDateTime>\r
+#include <QThread>\r
+\r
+CopyWorker::CopyWorker(QObject *parent) :\r
+ IWorker(parent),\r
+ m_CopyList(NULL),\r
+ m_tgtDir(),\r
+ m_CopyMap(),\r
+ m_AskingMutex(),\r
+ m_Asking(false)\r
+{\r
+}\r
+\r
+void CopyWorker::operate()\r
+{\r
+ m_progressText->setText(tr("コピー準備中..."));\r
+\r
+ foreach (const QString &srcPath, *m_CopyList) {\r
+ if (isStopRequested()) {\r
+ emit canceled();\r
+ return;\r
+ }\r
+ Listup(srcPath, m_tgtDir);\r
+ }\r
+\r
+ bool ret;\r
+ int copyMethod = OverWriteDialog::Undefined;\r
+ int prevCopyMethod = OverWriteDialog::Undefined;\r
+ int successCount = 0;\r
+ int skipCount = 0;\r
+ int errorCount = 0;\r
+ QString msg;\r
+ QString alias;\r
+ StringMap::iterator it;\r
+ for (it = m_CopyMap.begin(); it != m_CopyMap.end(); it++) {\r
+ if (isStopRequested()) {\r
+ emit canceled();\r
+ return;\r
+ }\r
+ QFileInfo srcInfo(it.key());\r
+ QFileInfo tgtInfo(it.value());\r
+\r
+ emit operation(tr("コピー:")\r
+ + srcInfo.absoluteFilePath()\r
+ + tr(" -> ")\r
+ + tgtInfo.absoluteFilePath());\r
+\r
+ if (srcInfo.isDir()) {\r
+ if (tgtInfo.exists()) {\r
+ emit success(tr("すでに存在"));\r
+ }\r
+ else if (QDir().mkdir(it.value())) {\r
+ emit success("フォルダ作成");\r
+ }\r
+ else {\r
+ emit error("フォルダの作成に失敗");\r
+ }\r
+ continue;\r
+ }\r
+\r
+ do { // コピーをスキップするのにbreakを使うがためのdo-while\r
+ if (tgtInfo.exists()) {\r
+ // 解決方法を選択\r
+ if (copyMethod == OverWriteDialog::Undefined ||\r
+ copyMethod == OverWriteDialog::Rename)\r
+ {\r
+ bool bOk;\r
+ m_Asking = true;\r
+ emit askOverWrite(&bOk, &prevCopyMethod, ©Method, &alias,\r
+ srcInfo.absoluteFilePath(),\r
+ tgtInfo.absoluteFilePath());\r
+ while (isAsking()) {\r
+ this->thread()->msleep(100);\r
+ }\r
+\r
+ if (!bOk) {\r
+ requestStop();\r
+ msg = tr("%1個のファイルをコピーしました。").arg(successCount);\r
+ if (skipCount > 0) {\r
+ msg += tr("%1個のファイルをスキップしました。").arg(skipCount);\r
+ }\r
+ if (errorCount > 0) {\r
+ msg += tr("%1個のファイルをコピーできませんでした。").arg(errorCount);\r
+ }\r
+ m_progressText->setText(msg);\r
+ emit canceled();\r
+ return;\r
+ }\r
+ }\r
+\r
+ if (prevCopyMethod == OverWriteDialog::OverWrite) {\r
+ QFile(tgtInfo.absoluteFilePath()).remove();\r
+ }\r
+ else if (prevCopyMethod == OverWriteDialog::OverWriteIfNew) {\r
+ if (srcInfo.lastModified() <= tgtInfo.lastModified()) {\r
+ emit success(tr("スキップ"));\r
+ skipCount++;\r
+ break;\r
+ }\r
+ QFile(tgtInfo.absoluteFilePath()).remove();\r
+ }\r
+ else if (prevCopyMethod == OverWriteDialog::AppendNumber) {\r
+ QString baseName = tgtInfo.baseName();\r
+ QString suffix = tgtInfo.completeSuffix();\r
+ for (int n = 1; ; n++) {\r
+ QString newName = baseName + tr("%1.").arg(n) + suffix;\r
+ tgtInfo.setFile(tgtInfo.absolutePath(), newName);\r
+ if (!tgtInfo.exists()) {\r
+ break;\r
+ }\r
+ }\r
+ emit operation(tr("=>") + tgtInfo.fileName() + tr("にリネーム"));\r
+ }\r
+ else if (prevCopyMethod == OverWriteDialog::Skip) {\r
+ emit success(tr("スキップ"));\r
+ skipCount++;\r
+ break;\r
+ }\r
+ else if (prevCopyMethod == OverWriteDialog::Rename) {\r
+ tgtInfo.setFile(tgtInfo.absolutePath(), alias);\r
+ emit operation(tr("=>") + tgtInfo.fileName() + tr("にリネーム"));\r
+ }\r
+ }\r
+\r
+ ret = QFile::copy(srcInfo.absoluteFilePath(), tgtInfo.absoluteFilePath());\r
+ if (ret) {\r
+ successCount++;\r
+ emit success(tr("成功"));\r
+ }\r
+ else {\r
+ errorCount++;\r
+ emit error(tr("失敗"));\r
+ }\r
+ } while (0);\r
+\r
+ msg = tr("%1個のファイルをコピーしました。").arg(successCount);\r
+ if (skipCount > 0) {\r
+ msg += tr("%1個のファイルをスキップしました。").arg(skipCount);\r
+ }\r
+ if (errorCount > 0) {\r
+ msg += tr("%1個のファイルをコピーできませんでした。").arg(errorCount);\r
+ }\r
+ m_progressText->setText(msg);\r
+ }\r
+\r
+ emit finished();\r
+}\r
+\r
+void CopyWorker::Listup(const QString &srcPath, const QString &tgtPath)\r
+{\r
+ if (isStopRequested()) {\r
+ return;\r
+ }\r
+\r
+ QFileInfo info(srcPath);\r
+ QDir tgtDir(tgtPath);\r
+\r
+ m_CopyMap.insert(srcPath, tgtDir.absoluteFilePath(info.fileName()));\r
+// qDebug() << srcPath << " -> " << tgtDir.absoluteFilePath(info.fileName());\r
+ if (info.isDir()) {\r
+ QDir srcDir(srcPath);\r
+ foreach (QFileInfo info2, srcDir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) {\r
+ Listup(info2.absoluteFilePath(),\r
+ tgtDir.absoluteFilePath(info.fileName()));\r
+ }\r
+ }\r
+}\r
--- /dev/null
+#ifndef COPYWORKER_H\r
+#define COPYWORKER_H\r
+\r
+#include "common.h"\r
+#include "iworker.h"\r
+\r
+#include <QFileInfo>\r
+\r
+class CopyWorker : public IWorker\r
+{\r
+ Q_OBJECT\r
+public:\r
+ explicit CopyWorker(QObject *parent = 0);\r
+\r
+ void setCopyList(const QStringList *list) {\r
+ m_CopyList = list;\r
+ }\r
+ void setTargetDir(const QString &path) {\r
+ m_tgtDir = path;\r
+ }\r
+\r
+ void endAsking() {\r
+ QMutexLocker lock(&m_AskingMutex);\r
+ m_Asking = false;\r
+ }\r
+\r
+public slots:\r
+ void operate();\r
+\r
+signals:\r
+ void askOverWrite(bool *bOk, int *prevCopyMethod, int *copyMethod, QString *alias,\r
+ const QString srcPath, const QString tgtPath);\r
+\r
+private:\r
+ const QStringList *m_CopyList;\r
+ QString m_tgtDir;\r
+ StringMap m_CopyMap;\r
+ QMutex m_AskingMutex;\r
+ bool m_Asking;\r
+\r
+ bool isAsking() {\r
+ QMutexLocker lock(&m_AskingMutex);\r
+ return m_Asking;\r
+ }\r
+\r
+ void Listup(const QString &srcPath, const QString &tgtPath);\r
+};\r
+\r
+#endif // COPYWORKER_H\r
\r
foreach (const QString &path, *m_DeleteList) {\r
if (isStopRequested()) {\r
- break;\r
+ emit canceled();\r
+ return;\r
}\r
Listup(path);\r
}\r
\r
- if (!isStopRequested()) {\r
- int successCount = 0;\r
- int errorCount = 0;\r
- foreach (const QString &path, m_Targets) {\r
- if (isStopRequested()) {\r
- break;\r
- }\r
+ bool ret;\r
+ int successCount = 0;\r
+ int errorCount = 0;\r
+ QString msg;\r
+ foreach (const QString &path, m_Targets) {\r
+ if (isStopRequested()) {\r
+ emit canceled();\r
+ return;\r
+ }\r
\r
- emit operation(tr("削除:") + path);\r
+ emit operation(tr("削除:") + path);\r
\r
- QFileInfo info(path);\r
- bool ret;\r
- if (info.isDir()) {\r
- QDir dir(path);\r
- ret = dir.rmdir(path);\r
- }\r
- else {\r
- ret = QFile::remove(path);\r
- }\r
+ QFileInfo info(path);\r
+ if (info.isDir()) {\r
+ QDir dir(path);\r
+ ret = dir.rmdir(path);\r
+ }\r
+ else {\r
+ ret = QFile::remove(path);\r
+ }\r
\r
- if (ret) {\r
- successCount++;\r
- emit success(tr("成功"));\r
- }\r
- else {\r
- errorCount++;\r
- emit error(tr("失敗"));\r
- }\r
+ if (ret) {\r
+ successCount++;\r
+ emit success(tr("成功"));\r
+ }\r
+ else {\r
+ errorCount++;\r
+ emit error(tr("失敗"));\r
+ }\r
\r
- QString msg;\r
- msg = tr("%1個のアイテムを削除しました。").arg(successCount);\r
- if (errorCount > 0) {\r
- msg += tr("%1個のアイテムを削除できませんでした。").arg(errorCount);\r
- }\r
- m_progressText->setText(msg);\r
+ msg = tr("%1個のアイテムを削除しました。").arg(successCount);\r
+ if (errorCount > 0) {\r
+ msg += tr("%1個のアイテムを削除できませんでした。").arg(errorCount);\r
}\r
+ m_progressText->setText(msg);\r
}\r
\r
emit finished();\r
\r
void DeleteWorker::Listup(const QString &path)\r
{\r
- qDebug() << tr("Listup: ") << path;\r
+// qDebug() << tr("Listup: ") << path;\r
\r
if (isStopRequested()) {\r
return;\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
+// qDebug() << info2.fileName();\r
Listup(info2.absoluteFilePath());\r
}\r
}\r
- qDebug() << "Targeting: " << path;\r
+// qDebug() << "Targeting: " << path;\r
m_Targets << path;\r
}\r
\r
bool FolderPanel::eventFilter(QObject *obj, QEvent *event)\r
{\r
- if (event->type() == QEvent::KeyPress) {\r
+ if (this->mainWindow() && event->type() == QEvent::KeyPress) {\r
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);\r
switch (keyEvent->key()) {\r
- case Qt::Key_A: {\r
+ case Qt::Key_A:\r
// A すべてのファイルをマーク\r
// Shift + A すべてマーク\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
- mainWnd->onMarkAll();\r
- }\r
- else {\r
- mainWnd->onMarkAllFiles();\r
- }\r
- }\r
- keyEvent->accept();\r
- return true; }\r
-\r
- case Qt::Key_D: {\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ this->mainWindow()->onMarkAll();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onMarkAllFiles();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
+\r
+ case Qt::Key_C:\r
+ // Ctrl + C ファイルをコピー\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ this->mainWindow()->onCmdCopy();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ }\r
+ break;\r
+\r
+ case Qt::Key_D:\r
// Ctrl + D ファイルを削除\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- if (keyEvent->modifiers() & Qt::ControlModifier) {\r
- mainWnd->onCmdDelete();\r
- }\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ this->mainWindow()->onCmdDelete();\r
+ keyEvent->accept();\r
+ return true;\r
}\r
- keyEvent->accept();\r
- return true; }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ }\r
+ break;\r
\r
- case Qt::Key_E: {\r
+ case Qt::Key_E:\r
// E エディタで開く\r
// Ctrl + E ファイルを作成\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- if (keyEvent->modifiers() & Qt::ControlModifier) {\r
- mainWnd->onCmdNewFile();\r
- }\r
- else {\r
- }\r
- }\r
- keyEvent->accept();\r
- return true; }\r
-\r
- case Qt::Key_G: {\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ this->mainWindow()->onCmdNewFile();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ }\r
+ break;\r
+\r
+ case Qt::Key_G:\r
// G カーソルを先頭に移動\r
// Shift + G カーソルを末尾に移動\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
- mainWnd->onMoveCursorEnd();\r
- }\r
- else {\r
- mainWnd->onMoveCursorBegin();\r
- }\r
- }\r
- keyEvent->accept();\r
- return true; }\r
-\r
- case Qt::Key_H: {\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ this->mainWindow()->onMoveCursorEnd();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onMoveCursorBegin();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
+\r
+ case Qt::Key_H:\r
// H ホームフォルダに移動\r
// Shift + H 隠しファイルを表示/非表示\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
- mainWnd->onViewHidden();\r
- }\r
- else {\r
- mainWnd->onMoveHome();\r
- }\r
- }\r
- keyEvent->accept();\r
- return true; }\r
-\r
- case Qt::Key_I: {\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ this->mainWindow()->onViewHidden();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onMoveHome();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
+\r
+ case Qt::Key_I:\r
// I マークを反転\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- mainWnd->onMarkInvert();\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
}\r
- keyEvent->accept();\r
- return true; }\r
+ else {\r
+ this->mainWindow()->onMarkInvert();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
\r
- case Qt::Key_J: {\r
+ case Qt::Key_J:\r
// J カーソルを下に移動\r
// Shift + J フォルダを選択して移動\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
- mainWnd->onMoveJump();\r
- }\r
- else {\r
- mainWnd->onMoveCursorDown();\r
- }\r
- }\r
- keyEvent->accept();\r
- return true; }\r
-\r
- case Qt::Key_K: {\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ this->mainWindow()->onMoveJump();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onMoveCursorDown();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
+\r
+ case Qt::Key_K:\r
// K カーソルを上に移動\r
// Ctrl + K フォルダを作成\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- if (keyEvent->modifiers() & Qt::ControlModifier) {\r
- mainWnd->onCmdNewFolder();\r
- }\r
- else {\r
- mainWnd->onMoveCursorUp();\r
- }\r
- }\r
- keyEvent->accept();\r
- return true; }\r
-\r
- case Qt::Key_O: {\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ this->mainWindow()->onCmdNewFolder();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onMoveCursorUp();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
+\r
+ case Qt::Key_M:\r
+ // M 開く\r
+ // Shift + M アプリケーションで開く\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ this->mainWindow()->onActionExec();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onActionOpen();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
+\r
+ case Qt::Key_O:\r
// O 隣のパネルと同じフォルダを表示\r
// Shift + O 隣のパネルに同じフォルダを表示\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
- mainWnd->onViewToOther();\r
- }\r
- else {\r
- mainWnd->onViewFromOther();\r
- }\r
- }\r
- keyEvent->accept();\r
- return true; }\r
-\r
- case Qt::Key_Q: {\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ this->mainWindow()->onViewToOther();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onViewFromOther();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
+\r
+ case Qt::Key_Q:\r
// Q アプリケーションを終了\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- mainWnd->onActionQuit();\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onActionQuit();\r
+ keyEvent->accept();\r
+ return true;\r
}\r
- keyEvent->accept();\r
- return true; }\r
+ break;\r
\r
- case Qt::Key_R: {\r
+ case Qt::Key_R:\r
// R 履歴を表示\r
// Ctrl + R 名前を変更\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- if (keyEvent->modifiers() & Qt::ControlModifier) {\r
- mainWnd->onCmdRename();\r
- }\r
- else {\r
-\r
- }\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ this->mainWindow()->onCmdRename();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
}\r
- keyEvent->accept();\r
- return true; }\r
+ else {\r
+ }\r
+ break;\r
\r
- case Qt::Key_U: {\r
+ case Qt::Key_U:\r
// U すべてのマークを解除\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- mainWnd->onMarkAllOff();\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
}\r
- keyEvent->accept();\r
- return true; }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onMarkAllOff();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
\r
- case Qt::Key_W: {\r
+ case Qt::Key_W:\r
// W 表示フォルダを交換\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- mainWnd->onViewSwap();\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onViewSwap();\r
+ keyEvent->accept();\r
+ return true;\r
}\r
- keyEvent->accept();\r
- return true; }\r
+ break;\r
\r
- case Qt::Key_X: {\r
+ case Qt::Key_X:\r
// X コマンドを実行\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- mainWnd->onActionCommand();\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
}\r
- keyEvent->accept();\r
- return true; }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onActionCommand();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
\r
- case Qt::Key_Question: {\r
+ case Qt::Key_Question:\r
// ? アプリケーション情報を表示\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- mainWnd->onHelpAbout();\r
+ if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onHelpAbout();\r
+ keyEvent->accept();\r
+ return true;\r
}\r
- keyEvent->accept();\r
- return true; }\r
+ break;\r
\r
- case Qt::Key_Space: {\r
+ case Qt::Key_Space:\r
// マーク/解除\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- mainWnd->onMarkToggle();\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
}\r
- keyEvent->accept();\r
- return true; }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onMarkToggle();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
\r
- case Qt::Key_Tab: {\r
+ case Qt::Key_Tab:\r
// 隣のパネルに移動\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- mainWnd->onMoveOther();\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
}\r
- keyEvent->accept();\r
- return true; }\r
+ else {\r
+ this->mainWindow()->onMoveOther();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
\r
- case Qt::Key_Backspace: {\r
+ case Qt::Key_Backspace:\r
// BS 親フォルダに移動\r
// Shift + BS ルートフォルダに移動\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
- mainWnd->onMoveRoot();\r
- }\r
- else {\r
- mainWnd->onMoveParent();\r
- }\r
- }\r
- keyEvent->accept();\r
- return true; }\r
-\r
- case Qt::Key_Return: {\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ this->mainWindow()->onMoveRoot();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onMoveParent();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
+\r
+ case Qt::Key_Return:\r
// RET 開く\r
// Shift + RET アプリケーションで開く\r
- MainWindow *mainWnd = this->mainWindow();\r
- if (mainWnd) {\r
- if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
- mainWnd->onActionExec();\r
- }\r
- else {\r
- mainWnd->onActionOpen();\r
- }\r
- }\r
- keyEvent->accept();\r
- return true; }\r
+ if (keyEvent->modifiers() & Qt::ShiftModifier) {\r
+ this->mainWindow()->onActionExec();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::ControlModifier) {\r
+ }\r
+ else if (keyEvent->modifiers() & Qt::AltModifier) {\r
+ }\r
+ else {\r
+ this->mainWindow()->onActionOpen();\r
+ keyEvent->accept();\r
+ return true;\r
+ }\r
+ break;\r
}\r
}\r
\r
}\r
\r
signals:\r
+ void canceled();\r
void finished();\r
void operation(const QString &msg);\r
void success(const QString &msg);\r
a.setApplicationName("Gefu");\r
a.setWindowIcon(QIcon(":/images/Gefu.png"));\r
\r
+ qRegisterMetaType<QFileInfo>();\r
QSettings::setDefaultFormat(QSettings::IniFormat);\r
\r
MainWindow w;\r
+#include "copyworker.h"\r
#include "deleteworker.h"\r
#include "mainwindow.h"\r
#include "operationdialog.h"\r
+#include "overwritedialog.h"\r
#include "renamemultidialog.h"\r
#include "renamesingledialog.h"\r
#include "renameworker.h"\r
connect(ui->view_Hidden, SIGNAL(triggered()), this, SLOT(onViewHidden()));\r
connect(ui->view_Swap, SIGNAL(triggered()), this, SLOT(onViewSwap()));\r
\r
+ connect(ui->cmd_Copy, SIGNAL(triggered()), this, SLOT(onCmdCopy()));\r
connect(ui->cmd_Delete, SIGNAL(triggered()), this, SLOT(onCmdDelete()));\r
connect(ui->cmd_NewFile, SIGNAL(triggered()), this, SLOT(onCmdNewFile()));\r
connect(ui->cmd_NewFolder, SIGNAL(triggered()), this, SLOT(onCmdNewFolder()));\r
fp2->setCurrentFolder(path1);\r
}\r
\r
-void MainWindow::onCmdDelete()\r
+void MainWindow::onCmdCopy()\r
{\r
FolderPanel *fp = activePanel();\r
if (!fp) {\r
return;\r
}\r
\r
- QStringList list;\r
- for (int n = 0; n < fp->fileTable()->rowCount(); n++) {\r
- if (fp->fileTable()->item(n, 0)->checkState() == Qt::Checked) {\r
- list << fp->dir()->absoluteFilePath(fp->fileTable()->item(n, 1)->text());\r
+ QStringList list = selectedItems(fp);\r
+ if (list.isEmpty()) {\r
+ return;\r
+ }\r
+\r
+ CopyWorker *worker = new CopyWorker();\r
+ connect(worker, SIGNAL(askOverWrite(bool*,int*,int*,QString*,QString,QString)),\r
+ this, SLOT(onAskOverWrite(bool*,int*,int*,QString*,QString,QString)));\r
+ worker->setCopyList(&list);\r
+ worker->setTargetDir(inactivePanel()->dir()->absolutePath());\r
+\r
+ OperationDialog opDlg(this);\r
+ opDlg.setWindowTitle(tr("コピー"));\r
+ opDlg.setWorker(worker);\r
+\r
+ ui->folderPanel_L->UninstallWatcher();\r
+ ui->folderPanel_R->UninstallWatcher();\r
+ opDlg.exec();\r
+ ui->folderPanel_L->setCurrentFolder(ui->folderPanel_L->dir()->absolutePath());\r
+ ui->folderPanel_R->setCurrentFolder(ui->folderPanel_R->dir()->absolutePath());\r
+\r
+}\r
+\r
+void MainWindow::onAskOverWrite(bool *bOk, int *prevCopyMethod, int *copyMethod,\r
+ QString *alias, const QString srcPath,\r
+ const QString tgtPath)\r
+{\r
+ OverWriteDialog dlg;\r
+ dlg.setCopyMethod(*prevCopyMethod);\r
+ dlg.setSameMethodChecked(*copyMethod != OverWriteDialog::Undefined);\r
+ dlg.setFileInfo(srcPath, tgtPath);\r
+ if (dlg.exec() == QDialog::Rejected) {\r
+ *bOk = false;\r
+ }\r
+ else {\r
+ *prevCopyMethod = dlg.copyMethod();\r
+ if (dlg.isSameMethodChecked()) {\r
+ *copyMethod = *prevCopyMethod;\r
}\r
+ *alias = dlg.alias();\r
+ *bOk = true;\r
}\r
+ CopyWorker *worker = static_cast<CopyWorker*>(sender());\r
+ worker->endAsking();\r
+}\r
\r
+///\r
+/// \brief MainWindow::onCmdDelete\r
+///\r
+/// ファイルを削除します\r
+///\r
+void MainWindow::onCmdDelete()\r
+{\r
+ FolderPanel *fp = activePanel();\r
+ if (!fp) {\r
+ return;\r
+ }\r
+\r
+ QStringList list = selectedItems(fp);\r
if (list.isEmpty()) {\r
-// int row = fp->fileTable()->currentIndex().row();\r
- int row = fp->fileTable()->currentRow();\r
- QString name = fp->fileTable()->item(row, 1)->text();\r
- if (name == "..") {\r
- return;\r
- }\r
- list << fp->dir()->absoluteFilePath(name);\r
+ return;\r
}\r
\r
QString msg;\r
return;\r
}\r
\r
- QStringList list;\r
- for (int n = 0; n < fp->fileTable()->rowCount(); n++) {\r
- if (fp->fileTable()->item(n, 0)->checkState() == Qt::Checked) {\r
- list << fp->fileTable()->item(n, 1)->text();\r
- }\r
- }\r
-\r
+ QStringList list = selectedItems(fp);\r
if (list.isEmpty()) {\r
-// int row = fp->fileTable()->currentIndex().row();\r
- int row = fp->fileTable()->currentRow();\r
- QString name = fp->fileTable()->item(row, 1)->text();\r
- if (name == "..") {\r
- return;\r
- }\r
- list << name;\r
+ return;\r
}\r
\r
IRenameDialog *dlg;\r
"(げふぅは実験的なファイルユーティリティです)</center>"\r
"<p>Copyright 2014 @miyabi_satoh All rights reserved.</p>"));\r
}\r
+\r
+QStringList MainWindow::selectedItems(FolderPanel *fp)\r
+{\r
+ QStringList list;\r
+ for (int n = 0; n < fp->fileTable()->rowCount(); n++) {\r
+ if (fp->fileTable()->item(n, 0)->checkState() == Qt::Checked) {\r
+ list << fp->dir()->absoluteFilePath(fp->fileTable()->item(n, 1)->text());\r
+ }\r
+ }\r
+\r
+ if (list.isEmpty()) {\r
+ int row = fp->fileTable()->currentRow();\r
+ QString name = fp->fileTable()->item(row, 1)->text();\r
+ if (name != "..") {\r
+ list << fp->dir()->absoluteFilePath(name);\r
+ }\r
+ }\r
+\r
+ return list;\r
+}\r
#ifndef MAINWINDOW_H\r
#define MAINWINDOW_H\r
\r
+#include <QFileInfo>\r
#include <QMainWindow>\r
class FolderPanel;\r
\r
void onViewHidden();\r
void onViewSwap();\r
\r
+ void onCmdCopy();\r
void onCmdDelete();\r
void onCmdNewFile();\r
void onCmdNewFolder();\r
void onHelpAbout();\r
\r
private slots:\r
+ void onAskOverWrite(bool *bOk, int *prevCopyMethod, int *copyMethod,\r
+ QString *alias, const QString srcPath, const QString tgtPath);\r
\r
private:\r
Ui::MainWindow *ui;\r
\r
FolderPanel* activePanel();\r
FolderPanel* inactivePanel();\r
+ QStringList selectedItems(FolderPanel *fp);\r
};\r
\r
#endif // MAINWINDOW_H\r
<rect>\r
<x>0</x>\r
<y>0</y>\r
- <width>442</width>\r
- <height>217</height>\r
+ <width>662</width>\r
+ <height>324</height>\r
</rect>\r
</property>\r
<property name="windowTitle">\r
</property>\r
<widget class="QWidget" name="centralWidget">\r
<layout class="QVBoxLayout" name="verticalLayout">\r
- <property name="spacing">\r
- <number>0</number>\r
- </property>\r
- <property name="leftMargin">\r
- <number>0</number>\r
- </property>\r
- <property name="topMargin">\r
- <number>0</number>\r
- </property>\r
- <property name="rightMargin">\r
- <number>0</number>\r
- </property>\r
- <property name="bottomMargin">\r
- <number>0</number>\r
- </property>\r
<item>\r
<widget class="QSplitter" name="splitter">\r
<property name="orientation">\r
</item>\r
<item>\r
<layout class="QHBoxLayout" name="horizontalLayout">\r
- <property name="spacing">\r
- <number>0</number>\r
- </property>\r
- <property name="sizeConstraint">\r
- <enum>QLayout::SetMinimumSize</enum>\r
- </property>\r
<item>\r
<widget class="QPushButton" name="pushButton_4">\r
+ <property name="minimumSize">\r
+ <size>\r
+ <width>1</width>\r
+ <height>0</height>\r
+ </size>\r
+ </property>\r
<property name="focusPolicy">\r
<enum>Qt::NoFocus</enum>\r
</property>\r
</widget>\r
</item>\r
<item>\r
+ <widget class="QPushButton" name="pushButton_8">\r
+ <property name="minimumSize">\r
+ <size>\r
+ <width>1</width>\r
+ <height>0</height>\r
+ </size>\r
+ </property>\r
+ <property name="text">\r
+ <string>PushButton</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QPushButton" name="pushButton_7">\r
+ <property name="minimumSize">\r
+ <size>\r
+ <width>1</width>\r
+ <height>0</height>\r
+ </size>\r
+ </property>\r
+ <property name="text">\r
+ <string>PushButton</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
<widget class="QPushButton" name="pushButton_3">\r
+ <property name="minimumSize">\r
+ <size>\r
+ <width>1</width>\r
+ <height>0</height>\r
+ </size>\r
+ </property>\r
<property name="focusPolicy">\r
<enum>Qt::NoFocus</enum>\r
</property>\r
</widget>\r
</item>\r
<item>\r
+ <widget class="QPushButton" name="pushButton_6">\r
+ <property name="minimumSize">\r
+ <size>\r
+ <width>1</width>\r
+ <height>0</height>\r
+ </size>\r
+ </property>\r
+ <property name="text">\r
+ <string>PushButton</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QPushButton" name="pushButton_5">\r
+ <property name="minimumSize">\r
+ <size>\r
+ <width>1</width>\r
+ <height>0</height>\r
+ </size>\r
+ </property>\r
+ <property name="text">\r
+ <string>PushButton</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
<widget class="QPushButton" name="pushButton_2">\r
<property name="minimumSize">\r
<size>\r
<rect>\r
<x>0</x>\r
<y>0</y>\r
- <width>442</width>\r
+ <width>662</width>\r
<height>24</height>\r
</rect>\r
</property>\r
QDialog(parent),\r
ui(new Ui::OperationDialog),\r
m_worker(NULL),\r
- m_Error(false),\r
- m_Cancel(false)\r
+ m_Error(false)\r
{\r
ui->setupUi(this);\r
}\r
connect(thread, SIGNAL(started()), m_worker, SLOT(operate()));\r
connect(m_worker, SIGNAL(finished()), thread, SLOT(quit()));\r
\r
- connect(thread, SIGNAL(finished()), this, SLOT(onFinished()));\r
connect(thread, SIGNAL(finished()), m_worker, SLOT(deleteLater()));\r
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));\r
\r
connect(m_worker, SIGNAL(operation(QString)), this, SLOT(onOperation(QString)));\r
connect(m_worker, SIGNAL(success(QString)), this, SLOT(onSuccess(QString)));\r
connect(m_worker, SIGNAL(error(QString)), this, SLOT(onError(QString)));\r
+ connect(m_worker, SIGNAL(finished()), this, SLOT(onFinished()));\r
+ connect(m_worker, SIGNAL(canceled()), this, SLOT(onCanceled()));\r
\r
thread->start();\r
}\r
ui->btnCloseCancel->setText(tr("閉じる"));\r
\r
ui->textEdit->append("");\r
- if (m_Cancel) {\r
- ui->textEdit->append(tr("操作は途中でキャンセルされました。"));\r
- }\r
- else {\r
- ui->textEdit->append(tr("完了"));\r
- if (!m_Error && ui->chkAutoClose->checkState() == Qt::Checked) {\r
- QDialog::accept();\r
- }\r
+ ui->textEdit->append(tr("完了"));\r
+ if (!m_Error && ui->chkAutoClose->checkState() == Qt::Checked) {\r
+ QDialog::accept();\r
}\r
}\r
\r
+void OperationDialog::onCanceled()\r
+{\r
+ ui->progressBar->setMaximum(1);\r
+ ui->progressBar->setValue(1);\r
+ ui->btnCloseCancel->setText(tr("閉じる"));\r
+\r
+ ui->textEdit->append("");\r
+ ui->textEdit->append(tr("操作は途中でキャンセルされました。"));\r
+}\r
+\r
void OperationDialog::on_btnCloseCancel_clicked()\r
{\r
if (ui->btnCloseCancel->text() == tr("閉じる")) {\r
QDialog::accept();\r
}\r
else {\r
- m_Cancel = true;\r
m_worker->requestStop();\r
}\r
}\r
Ui::OperationDialog *ui;\r
IWorker *m_worker;\r
bool m_Error;\r
- bool m_Cancel;\r
\r
private slots:\r
void onOperation(const QString &msg);\r
void onSuccess(const QString &msg);\r
void onError(const QString &msg);\r
void onFinished();\r
+ void onCanceled();\r
void on_btnCloseCancel_clicked();\r
void on_btnShowDetail_clicked();\r
};\r
--- /dev/null
+#include "overwritedialog.h"\r
+#include "ui_overwritedialog.h"\r
+#include <QDir>\r
+#include <QMessageBox>\r
+#include <QDateTime>\r
+\r
+OverWriteDialog::OverWriteDialog(QWidget *parent) :\r
+ QDialog(parent),\r
+ ui(new Ui::OverWriteDialog),\r
+ m_tgtPath()\r
+{\r
+ ui->setupUi(this);\r
+\r
+ ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);\r
+ ui->tableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);\r
+\r
+ connect(ui->rbAppendNumber, SIGNAL(clicked()), this, SLOT(onRenameOrElse()));\r
+ connect(ui->rbOverWrite, SIGNAL(clicked()), this, SLOT(onRenameOrElse()));\r
+ connect(ui->rbOverWriteIfNew, SIGNAL(clicked()), this, SLOT(onRenameOrElse()));\r
+ connect(ui->rbRename, SIGNAL(clicked()), this, SLOT(onRenameOrElse()));\r
+ connect(ui->rbSkip, SIGNAL(clicked()), this, SLOT(onRenameOrElse()));\r
+\r
+}\r
+\r
+OverWriteDialog::~OverWriteDialog()\r
+{\r
+ delete ui;\r
+}\r
+\r
+void OverWriteDialog::setCopyMethod(int method)\r
+{\r
+ switch (method) {\r
+ case OverWriteDialog::OverWrite:\r
+ ui->rbOverWrite->setChecked(true);\r
+ break;\r
+ case OverWriteDialog::AppendNumber:\r
+ ui->rbAppendNumber->setChecked(true);\r
+ break;\r
+ case OverWriteDialog::Skip:\r
+ ui->rbSkip->setChecked(true);\r
+ break;\r
+ case OverWriteDialog::Rename:\r
+ ui->rbRename->setChecked(true);\r
+ ui->lineEdit->setFocus();\r
+ break;\r
+ default:\r
+ ui->rbOverWriteIfNew->setChecked(true);\r
+ break;\r
+ }\r
+ onRenameOrElse();\r
+}\r
+\r
+void OverWriteDialog::setSameMethodChecked(bool checked)\r
+{\r
+ ui->checkBox->setChecked(checked);\r
+}\r
+\r
+void OverWriteDialog::setFileInfo(const QString srcPath, const QString tgtPath)\r
+{\r
+ QFileInfo srcInfo(srcPath);\r
+ QFileInfo tgtInfo(tgtPath);\r
+ m_tgtPath = tgtPath;\r
+ ui->lineEdit->setText(tgtInfo.fileName());\r
+\r
+ QTableWidgetItem *iSrcSize = new QTableWidgetItem(tr("%1 Bytes").arg(srcInfo.size()));\r
+ iSrcSize->setFlags(iSrcSize->flags() ^ Qt::ItemIsEditable);\r
+ iSrcSize->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);\r
+ ui->tableWidget->setItem(0, 0, iSrcSize);\r
+\r
+ QTableWidgetItem *iTgtSize = new QTableWidgetItem(tr("%1 Bytes").arg(tgtInfo.size()));\r
+ iTgtSize->setFlags(iTgtSize->flags() ^ Qt::ItemIsEditable);\r
+ iTgtSize->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);\r
+ ui->tableWidget->setItem(1, 0, iTgtSize);\r
+\r
+ QTableWidgetItem *iSrcDate = new QTableWidgetItem(srcInfo.lastModified().toString("yy/MM/dd hh:mm"));\r
+ iSrcDate->setFlags(iSrcDate->flags() ^ Qt::ItemIsEditable);\r
+ iSrcDate->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);\r
+ ui->tableWidget->setItem(0, 1, iSrcDate);\r
+\r
+ QTableWidgetItem *iTgtDate = new QTableWidgetItem(tgtInfo.lastModified().toString("yy/MM/dd hh:mm"));\r
+ iTgtDate->setFlags(iTgtDate->flags() ^ Qt::ItemIsEditable);\r
+ iTgtDate->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);\r
+ ui->tableWidget->setItem(1, 1, iTgtDate);\r
+}\r
+\r
+int OverWriteDialog::copyMethod()\r
+{\r
+ if (ui->rbAppendNumber->isChecked()) {\r
+ return OverWriteDialog::AppendNumber;\r
+ }\r
+ if (ui->rbOverWrite->isChecked()) {\r
+ return OverWriteDialog::OverWrite;\r
+ }\r
+ if (ui->rbOverWriteIfNew->isChecked()) {\r
+ return OverWriteDialog::OverWriteIfNew;\r
+ }\r
+ if (ui->rbRename->isChecked()) {\r
+ return OverWriteDialog::Rename;\r
+ }\r
+ return OverWriteDialog::Skip;\r
+}\r
+\r
+bool OverWriteDialog::isSameMethodChecked()\r
+{\r
+ return ui->checkBox->isChecked();\r
+}\r
+\r
+const QString OverWriteDialog::alias()\r
+{\r
+ return ui->lineEdit->text();\r
+}\r
+\r
+void OverWriteDialog::onRenameOrElse()\r
+{\r
+ if (ui->rbRename->isChecked()) {\r
+ ui->lineEdit->setEnabled(true);\r
+ }\r
+ else {\r
+ ui->lineEdit->setEnabled(false);\r
+ }\r
+}\r
+\r
+void OverWriteDialog::accept()\r
+{\r
+ if (ui->rbRename->isChecked()) {\r
+ QString newPath = QFileInfo(m_tgtPath).absoluteDir().absoluteFilePath(ui->lineEdit->text());\r
+ if (QFileInfo(newPath).exists()) {\r
+ QMessageBox::critical(\r
+ this,\r
+ tr("エラー"),\r
+ tr("すでに同名のファイルが存在しています。"));\r
+ ui->lineEdit->setFocus();\r
+ return;\r
+ }\r
+ }\r
+\r
+ QDialog::accept();\r
+}\r
--- /dev/null
+#ifndef OVERWRITEDIALOG_H\r
+#define OVERWRITEDIALOG_H\r
+\r
+#include <QDialog>\r
+#include <QFileInfo>\r
+\r
+namespace Ui {\r
+class OverWriteDialog;\r
+}\r
+\r
+class OverWriteDialog : public QDialog\r
+{\r
+ Q_OBJECT\r
+\r
+public:\r
+ enum {\r
+ Undefined = 0x00,\r
+ OverWrite = 0x01,\r
+ OverWriteIfNew = 0x02,\r
+ AppendNumber = 0x04,\r
+ Skip = 0x08,\r
+ Rename = 0x10,\r
+ };\r
+\r
+ explicit OverWriteDialog(QWidget *parent = 0);\r
+ ~OverWriteDialog();\r
+\r
+ void setCopyMethod(int method);\r
+ void setSameMethodChecked(bool checked);\r
+ void setFileInfo(const QString srcPath, const QString tgtPath);\r
+\r
+ int copyMethod();\r
+ bool isSameMethodChecked();\r
+ const QString alias();\r
+\r
+private slots:\r
+ void onRenameOrElse();\r
+ void accept();\r
+\r
+private:\r
+ Ui::OverWriteDialog *ui;\r
+ QString m_tgtPath;\r
+};\r
+\r
+#endif // OVERWRITEDIALOG_H\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ui version="4.0">\r
+ <class>OverWriteDialog</class>\r
+ <widget class="QDialog" name="OverWriteDialog">\r
+ <property name="geometry">\r
+ <rect>\r
+ <x>0</x>\r
+ <y>0</y>\r
+ <width>384</width>\r
+ <height>286</height>\r
+ </rect>\r
+ </property>\r
+ <property name="windowTitle">\r
+ <string>同名のファイルが存在しています</string>\r
+ </property>\r
+ <layout class="QVBoxLayout" name="verticalLayout_2">\r
+ <item>\r
+ <widget class="QTableWidget" name="tableWidget">\r
+ <property name="sizePolicy">\r
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">\r
+ <horstretch>0</horstretch>\r
+ <verstretch>0</verstretch>\r
+ </sizepolicy>\r
+ </property>\r
+ <property name="minimumSize">\r
+ <size>\r
+ <width>0</width>\r
+ <height>87</height>\r
+ </size>\r
+ </property>\r
+ <property name="maximumSize">\r
+ <size>\r
+ <width>16777215</width>\r
+ <height>87</height>\r
+ </size>\r
+ </property>\r
+ <property name="verticalScrollBarPolicy">\r
+ <enum>Qt::ScrollBarAlwaysOff</enum>\r
+ </property>\r
+ <property name="horizontalScrollBarPolicy">\r
+ <enum>Qt::ScrollBarAlwaysOff</enum>\r
+ </property>\r
+ <property name="tabKeyNavigation">\r
+ <bool>false</bool>\r
+ </property>\r
+ <property name="showGrid">\r
+ <bool>false</bool>\r
+ </property>\r
+ <property name="wordWrap">\r
+ <bool>false</bool>\r
+ </property>\r
+ <property name="rowCount">\r
+ <number>2</number>\r
+ </property>\r
+ <property name="columnCount">\r
+ <number>2</number>\r
+ </property>\r
+ <attribute name="horizontalHeaderHighlightSections">\r
+ <bool>false</bool>\r
+ </attribute>\r
+ <attribute name="verticalHeaderHighlightSections">\r
+ <bool>false</bool>\r
+ </attribute>\r
+ <row>\r
+ <property name="text">\r
+ <string>元</string>\r
+ </property>\r
+ </row>\r
+ <row>\r
+ <property name="text">\r
+ <string>先</string>\r
+ </property>\r
+ </row>\r
+ <column>\r
+ <property name="text">\r
+ <string>サイズ</string>\r
+ </property>\r
+ </column>\r
+ <column>\r
+ <property name="text">\r
+ <string>更新日時</string>\r
+ </property>\r
+ </column>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QGroupBox" name="groupBox">\r
+ <property name="title">\r
+ <string>処理方法</string>\r
+ </property>\r
+ <layout class="QVBoxLayout" name="verticalLayout_3">\r
+ <item>\r
+ <layout class="QVBoxLayout" name="verticalLayout">\r
+ <item>\r
+ <widget class="QRadioButton" name="rbOverWrite">\r
+ <property name="text">\r
+ <string>上書き</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QRadioButton" name="rbOverWriteIfNew">\r
+ <property name="text">\r
+ <string>新しければ上書き</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QRadioButton" name="rbAppendNumber">\r
+ <property name="text">\r
+ <string>ファイル名末尾に数字を付与</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QRadioButton" name="rbSkip">\r
+ <property name="text">\r
+ <string>スキップ</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <layout class="QHBoxLayout" name="horizontalLayout">\r
+ <item>\r
+ <widget class="QRadioButton" name="rbRename">\r
+ <property name="text">\r
+ <string>名前を変更</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QLineEdit" name="lineEdit"/>\r
+ </item>\r
+ </layout>\r
+ </item>\r
+ </layout>\r
+ </item>\r
+ </layout>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <layout class="QHBoxLayout" name="horizontalLayout_2">\r
+ <item>\r
+ <widget class="QCheckBox" name="checkBox">\r
+ <property name="text">\r
+ <string>同じ処理を以降の競合にも適用する</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <spacer name="horizontalSpacer">\r
+ <property name="orientation">\r
+ <enum>Qt::Horizontal</enum>\r
+ </property>\r
+ <property name="sizeHint" stdset="0">\r
+ <size>\r
+ <width>40</width>\r
+ <height>20</height>\r
+ </size>\r
+ </property>\r
+ </spacer>\r
+ </item>\r
+ <item>\r
+ <widget class="QDialogButtonBox" name="buttonBox">\r
+ <property name="orientation">\r
+ <enum>Qt::Horizontal</enum>\r
+ </property>\r
+ <property name="standardButtons">\r
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ </layout>\r
+ </item>\r
+ </layout>\r
+ </widget>\r
+ <resources/>\r
+ <connections>\r
+ <connection>\r
+ <sender>buttonBox</sender>\r
+ <signal>accepted()</signal>\r
+ <receiver>OverWriteDialog</receiver>\r
+ <slot>accept()</slot>\r
+ <hints>\r
+ <hint type="sourcelabel">\r
+ <x>248</x>\r
+ <y>254</y>\r
+ </hint>\r
+ <hint type="destinationlabel">\r
+ <x>157</x>\r
+ <y>274</y>\r
+ </hint>\r
+ </hints>\r
+ </connection>\r
+ <connection>\r
+ <sender>buttonBox</sender>\r
+ <signal>rejected()</signal>\r
+ <receiver>OverWriteDialog</receiver>\r
+ <slot>reject()</slot>\r
+ <hints>\r
+ <hint type="sourcelabel">\r
+ <x>316</x>\r
+ <y>260</y>\r
+ </hint>\r
+ <hint type="destinationlabel">\r
+ <x>286</x>\r
+ <y>274</y>\r
+ </hint>\r
+ </hints>\r
+ </connection>\r
+ </connections>\r
+</ui>\r
bool ret;\r
int successCount = 0;\r
int errorCount = 0;\r
+ QString msg;\r
for (it = m_RenameMap->begin(); it != m_RenameMap->end(); it++) {\r
if (isStopRequested()) {\r
- break;\r
+ emit canceled();\r
+ return;\r
}\r
\r
emit operation(tr("名前変更:")\r
errorCount++;\r
emit error(tr("失敗"));\r
}\r
+ msg = tr("%1個の名前を変更しました。").arg(successCount);\r
+ if (errorCount > 0) {\r
+ msg += tr("%1個の名前を変更できませんでした。").arg(errorCount);\r
+ }\r
+ m_progressText->setText(msg);\r
}\r
\r
- QString msg;\r
- msg = tr("%1個の名前を変更しました。").arg(successCount);\r
- if (errorCount > 0) {\r
- msg += tr("%1個の名前を変更できませんでした。").arg(errorCount);\r
- }\r
- m_progressText->setText(msg);\r
-\r
emit finished();\r
}\r