### TODO
- 初期表示時にカーソルがハイライトされないorz
+- ファイルはダブルクリックで開くようにする
+- コンテキストメニュー
- オプション
- ファンクションキー
- 各処理時の確認・完了ダイアログ表示有無
- 上書き時の規定の動作
-- ドラッグ&ドロップ
+ - フォルダ作ったら、そこに移動
- ファイル検索
- 簡易テキストビューア
- 簡易画像ビューア
- 簡易アーカイバ
+- 最新版チェック、ダウンロード
- SNS連携(タイムライン表示とか) ← ファイラーの機能か?
-#### 2014/08/22 Ver0.05
+#### 2014/08/22 Ver0.06 公開
+- 外部および内部のドラッグ&ドロップ処理を実装。
+- 一部ダイアログのレイアウト、初期サイズを調整。
+- 不具合修正
+ - 同一ファイルに対する強制上書きが考慮されていなかった。⇛ 先・元が同一の場合はスキップするようにした。
+
+#### 2014/08/22 Ver0.05 公開
- 外部アプリケーションからのドロップ処理を実装。
#### 2014/08/22 Ver0.04 公開
extern MainWindow* getMainWnd();\r
extern QString FilesizeToString(quint64 size);\r
\r
-#define VERSION_VALUE 0.05\r
+#define VERSION_VALUE 0.06\r
\r
#define slash QString("/")\r
#define QQ(x) ("\"" + (x) + "\"")\r
}\r
\r
if (prevCopyMethod == OverWriteDialog::OverWrite) {\r
+ if (srcInfo.absoluteFilePath() == tgtInfo.absoluteFilePath()) {\r
+ emit success(tr("同一ファイルへの操作のためスキップ"));\r
+ skipCount++;\r
+ break;\r
+ }\r
QFile(tgtInfo.absoluteFilePath()).remove();\r
}\r
else if (prevCopyMethod == OverWriteDialog::OverWriteIfNew) {\r
if (srcInfo.lastModified() <= tgtInfo.lastModified()) {\r
- emit success(tr("スキップ"));\r
+ emit success(tr("古いファイルのためスキップ"));\r
+ skipCount++;\r
+ break;\r
+ }\r
+ if (srcInfo.absoluteFilePath() == tgtInfo.absoluteFilePath()) {\r
+ emit success(tr("同一ファイルへの操作のためスキップ"));\r
skipCount++;\r
break;\r
}\r
if (ret) {\r
successCount++;\r
emit success(tr("成功"));\r
- if (m_Move) {\r
+ if (m_Move && srcInfo.absoluteFilePath() != tgtInfo.absoluteFilePath()) {\r
ret = QFile(srcInfo.absoluteFilePath()).remove();\r
if (!ret) {\r
errDelCount++;\r
#include <QDebug>\r
#include <QApplication>\r
#include <QSettings>\r
-#include <QMenuBar>\r
-#include <QMimeData>\r
-#include <QUrl>\r
-#include <QMessageBox>\r
+#include <QPalette>\r
#ifdef Q_OS_WIN32\r
#include <windows.h>\r
#endif\r
m_fsWatcher = new QFileSystemWatcher(this);\r
m_fsWatcher->addPath(path);\r
connect(m_fsWatcher, SIGNAL(directoryChanged(QString)),\r
-// this, SLOT(refresh()));\r
this, SIGNAL(listUpdated()));\r
\r
endResetModel();\r
endResetModel();\r
}\r
\r
-//void FileTableModel::refresh()\r
-//{\r
-// setPath(m_dir.absolutePath());\r
-\r
-//}\r
-\r
void FileTableModel::stateChanged()\r
{\r
int numFolder = 0;\r
if (index.column() == 0) {\r
flags |= Qt::ItemIsUserCheckable;\r
}\r
-// TODO\r
-// flags |= Qt::ItemIsDragEnabled;\r
flags |= Qt::ItemIsDropEnabled;\r
}\r
return flags;\r
\r
return types;\r
}\r
-\r
-bool FileTableModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)\r
-{\r
- Q_UNUSED(parent);\r
-\r
- qDebug() << action << row << column;\r
-\r
- if (action == Qt::IgnoreAction) {\r
- return true;\r
- }\r
-\r
- if (!data->hasFormat("text/uri-list")) {\r
- return false;\r
- }\r
-\r
- if (column > 0) {\r
- return false;\r
- }\r
-\r
- QFileInfoList list;\r
- foreach (const QUrl &url, data->urls()) {\r
- QFileInfo info(url.toLocalFile());\r
- QString path = info.canonicalFilePath();\r
- if (!path.isEmpty()) {\r
- qDebug() << path;\r
- list << path;\r
- }\r
- else {\r
- qDebug() << "path is empty.";\r
- qDebug() << url;\r
- }\r
- }\r
-\r
- if (list.isEmpty()) {\r
- return false;\r
- }\r
-\r
- emit filesDropped(list);\r
-\r
- return true;\r
-}\r
void rootChanged(const QString &root);\r
void stateChanged(int checkedFoldrs, int checkedFiles, quint64 totalSize);\r
void listUpdated();\r
- void filesDropped(const QFileInfoList &list);\r
\r
public slots:\r
-// void refresh();\r
\r
private:\r
QDir m_dir;\r
bool setData(const QModelIndex &index, const QVariant &value, int role);\r
Qt::DropActions supportedDropActions() const;\r
QStringList mimeTypes() const;\r
- bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);\r
};\r
\r
-\r
-\r
#endif // FILETABLEMODEL_H\r
#include <QFileDialog>\r
#include <QKeyEvent>\r
#include <QStatusBar>\r
+#include <QMimeData>\r
+#include <QDrag>\r
+#include <QApplication>\r
\r
#define CHECK_FOCUS { \\r
if (!hasFocus()) { return; } \\r
FileTableView::FileTableView(QWidget *parent) :\r
QTableView(parent),\r
m_side(),\r
- m_history()\r
+ m_history(),\r
+ m_dragStartPos(),\r
+ m_dragging(false)\r
{\r
// シグナル/スロットを設定する\r
connect(MENU_TRRIGGERED(action_Open), this, SLOT(setPath()));\r
setDragEnabled(true);\r
setAcceptDrops(true);\r
setDropIndicatorShown(true);\r
-// setDragDropMode(QAbstractItemView::DragDrop);\r
}\r
\r
FileTableView::~FileTableView()\r
dlg.setWindowTitle(tr("コマンドを実行"));\r
dlg.setLabelText(tr("コマンド:"));\r
dlg.setTextValue(command);\r
-\r
- QSize szMainWnd = getMainWnd()->size();\r
- QSize szDialog = dlg.size();\r
- szDialog.setWidth(szMainWnd.width() * 0.8);\r
- dlg.resize(szDialog);\r
+ dlg.resize(getMainWnd()->width() * 0.8, dlg.height());\r
\r
int ret = dlg.exec();\r
command = dlg.textValue();\r
setCurrentIndex(index);\r
}\r
else if (index.row() < m->rowCount() - 1) {\r
- qDebug() << "set = " << index.row() + 1;\r
setCurrentIndex(m->index(index.row() + 1, 1));\r
}\r
}\r
dlg.setHistory(other->history(), &m_history);\r
}\r
\r
- QSize szMainWnd = getMainWnd()->size();\r
- QSize szDialog = dlg.size();\r
- szDialog.setWidth(szMainWnd.width() * 0.8);\r
- dlg.resize(szDialog);\r
if (dlg.exec() == QDialog::Accepted) {\r
if (side() == dlg.selectedSide()) {\r
m_history.setAt(dlg.selectedIndex());\r
setRootPath(other->history()->at(dlg.selectedIndex()), true);\r
}\r
updateMenu();\r
- qDebug() << dlg.selectedIndex();\r
}\r
}\r
\r
worker->endAsking();\r
}\r
\r
-void FileTableView::acceptDrops(const QFileInfoList &list)\r
-{\r
- if (list.isEmpty()) {\r
- return;\r
- }\r
-\r
- FileTableModel *m = static_cast<FileTableModel*>(model());\r
- CopyMoveWorker *worker = new CopyMoveWorker();\r
- connect(worker, SIGNAL(askOverWrite(bool*,int*,int*,QString*,QString,QString)),\r
- this, SLOT(askOverWrite(bool*,int*,int*,QString*,QString,QString)));\r
- worker->setCopyList(&list);\r
- worker->setTargetDir(m->absolutePath());\r
- worker->setMoveMode(false);\r
-\r
- OperationDialog opDlg(this);\r
- opDlg.setWindowTitle(tr("コピー"));\r
- opDlg.setWorker(worker);\r
-\r
- opDlg.exec();\r
-}\r
-\r
void FileTableView::setRootIndex(const QModelIndex &index)\r
{\r
if (!index.isValid()) {\r
\r
QTableView::currentChanged(current, previous);\r
}\r
+\r
+\r
+void FileTableView::dropEvent(QDropEvent *event)\r
+{\r
+ if (m_dragging) {\r
+ event->ignore();\r
+ return;\r
+ }\r
+\r
+ QFileInfoList list;\r
+ foreach (const QUrl &url, event->mimeData()->urls()) {\r
+ QFileInfo info(url.toLocalFile());\r
+ QString path = info.canonicalFilePath();\r
+ if (!path.isEmpty()) {\r
+ list << path;\r
+ }\r
+ else {\r
+ qDebug() << "path is empty.";\r
+ }\r
+ }\r
+\r
+ if (list.isEmpty()) {\r
+ event->ignore();\r
+ return;\r
+ }\r
+ event->acceptProposedAction();\r
+\r
+ FileTableModel *m = static_cast<FileTableModel*>(model());\r
+ CopyMoveWorker *worker = new CopyMoveWorker();\r
+ connect(worker, SIGNAL(askOverWrite(bool*,int*,int*,QString*,QString,QString)),\r
+ this, SLOT(askOverWrite(bool*,int*,int*,QString*,QString,QString)));\r
+ worker->setCopyList(&list);\r
+ worker->setTargetDir(m->absolutePath());\r
+ worker->setMoveMode(false);\r
+\r
+ OperationDialog opDlg(this);\r
+ opDlg.setWindowTitle(tr("コピー"));\r
+ opDlg.setWorker(worker);\r
+\r
+ opDlg.exec();\r
+}\r
+\r
+\r
+void FileTableView::dragEnterEvent(QDragEnterEvent *event)\r
+{\r
+ if (event->mimeData()->hasUrls()) {\r
+ event->acceptProposedAction();\r
+ return;\r
+ }\r
+\r
+ QTableView::dragEnterEvent(event);\r
+}\r
+\r
+void FileTableView::mousePressEvent(QMouseEvent *event)\r
+{\r
+ if ((event->buttons() & Qt::LeftButton) || (event->buttons() & Qt::RightButton))\r
+ {\r
+ m_dragStartPos = event->pos();\r
+ }\r
+\r
+ QTableView::mousePressEvent(event);\r
+}\r
+\r
+void FileTableView::mouseMoveEvent(QMouseEvent *event)\r
+{\r
+ if (!(event->buttons() & Qt::LeftButton) &&\r
+ !(event->buttons() & Qt::RightButton))\r
+ {\r
+ QTableView::mouseMoveEvent(event);\r
+ return;\r
+ }\r
+ if ((event->pos() - m_dragStartPos).manhattanLength()\r
+ < QApplication::startDragDistance())\r
+ {\r
+ QTableView::mouseMoveEvent(event);\r
+ return;\r
+ }\r
+\r
+ QFileInfoList list = selectedItems();\r
+ if (list.isEmpty()) {\r
+ QTableView::mousePressEvent(event);\r
+ return;\r
+ }\r
+\r
+ QList<QUrl> urls;\r
+ foreach (const QFileInfo &info, list) {\r
+ urls << QUrl::fromLocalFile(info.absoluteFilePath());\r
+ }\r
+\r
+ QDrag *drag = new QDrag(this);\r
+ QMimeData *mimeData = new QMimeData;\r
+ mimeData->setUrls(urls);\r
+ drag->setMimeData(mimeData);\r
+\r
+ m_dragging = true;\r
+ if (event->buttons() & Qt::RightButton) {\r
+ drag->exec(Qt::CopyAction | Qt::MoveAction);\r
+ }\r
+ else {\r
+ drag->exec(Qt::CopyAction);\r
+ }\r
+ m_dragging = false;\r
+}\r
private:\r
QString m_side;\r
History m_history;\r
+ QPoint m_dragStartPos;\r
+ bool m_dragging;\r
\r
QFileInfoList selectedItems() const;\r
void updateMenu();\r
void askOverWrite(bool *bOk, int *prevCopyMethod, int *copyMethod,\r
QString *alias, const QString &srcPath,\r
const QString &tgtPath);\r
- void acceptDrops(const QFileInfoList &list);\r
\r
// QAbstractItemView interface\r
public slots:\r
protected:\r
void keyPressEvent(QKeyEvent *event);\r
void focusInEvent(QFocusEvent *event);\r
+ void dropEvent(QDropEvent *event);\r
+ void dragEnterEvent(QDragEnterEvent *event);\r
+ void mousePressEvent(QMouseEvent *event);\r
+ void mouseMoveEvent(QMouseEvent *event);\r
\r
// QAbstractItemView interface\r
protected slots:\r
delete ui;\r
}\r
\r
-QTableView* FolderPanel::fileTable()\r
-{\r
- return ui->fileTable;\r
-}\r
-\r
-const QTableView *FolderPanel::fileTable() const\r
-{\r
- return ui->fileTable;\r
-}\r
-\r
const QString FolderPanel::side() const\r
{\r
return ui->fileTable->side();\r
this, SLOT(onStateChanged(int,int,quint64)));\r
connect(model, SIGNAL(listUpdated()),\r
ui->fileTable, SLOT(refresh()));\r
- connect(model, SIGNAL(filesDropped(QFileInfoList)),\r
- ui->fileTable, SLOT(acceptDrops(QFileInfoList)));\r
-\r
\r
//>>>>> フィルタ初期化\r
model->setFilter(QDir::NoDot | QDir::AllDirs | QDir::Files);\r
\r
ui->locationField->blockSignals(false);\r
}\r
-\r
#define FOLDERPANEL_H\r
\r
#include <QWidget>\r
-#include <QDir>\r
-#include <QTableWidget>\r
-#include <QFileIconProvider>\r
-#include <QFileSystemWatcher>\r
-#include "filetableview.h"\r
-class MainWindow;\r
\r
namespace Ui {\r
class FolderPanel;\r
explicit FolderPanel(QWidget *parent = 0);\r
~FolderPanel();\r
\r
- QTableView *fileTable();\r
- const QTableView* fileTable() const;\r
-\r
const QString side() const;\r
void setSide(const QString &side);\r
\r
+#include "common.h"
+#include "mainwindow.h"
#include "historydialog.h"
#include "ui_historydialog.h"
m_displaying(NULL)
{
ui->setupUi(this);
-
+ resize(getMainWnd()->width() * 0.8, height());
}
HistoryDialog::~HistoryDialog()
-#include "copymoveworker.h"\r
-#include "deleteworker.h"\r
+#include "common.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
-#include "sortdialog.h"\r
#include "preferencedialog.h"\r
+#include "filetableview.h"\r
#include "ui_mainwindow.h"\r
\r
#include <QCheckBox>\r
ui->LPanel->setSide("Left");\r
ui->LPanel->updateAppearance();\r
ui->RPanel->updateAppearance();\r
- ui->LPanel->fileTable()->setFocus();\r
\r
QSettings settings;\r
// メニュー項目のチェック状態を初期化する\r
void MainWindow::toggleShowHiddenFiles()\r
{\r
// キーボードがトリガーの場合、メニュー項目のチェック状態は\r
- // 変わらないので、QSettingsを使う\r
+ // 変わらない(Mac)ので、QSettingsを使う\r
QSettings settings;\r
bool show = !settings.value(IniKey_ShowHidden, false).toBool();\r
settings.setValue(IniKey_ShowHidden, show);\r
\r
void MainWindow::closeEvent(QCloseEvent *event)\r
{\r
- qDebug() << "closeEvent();";\r
-\r
QSettings settings;\r
\r
if (settings.value(IniKey_ConfirmExit, true).toBool()) {\r
+#include "common.h"\r
+#include "mainwindow.h"\r
#include "operationdialog.h"\r
#include "ui_operationdialog.h"\r
+\r
#include <QThread>\r
\r
OperationDialog::OperationDialog(QWidget *parent) :\r
m_Error(false)\r
{\r
ui->setupUi(this);\r
+ resize(getMainWnd()->width() * 0.8, height());\r
}\r
\r
OperationDialog::~OperationDialog()\r
<rect>\r
<x>0</x>\r
<y>0</y>\r
- <width>462</width>\r
- <height>319</height>\r
+ <width>452</width>\r
+ <height>331</height>\r
</rect>\r
</property>\r
<property name="windowTitle">\r
<property name="title">\r
<string>処理方法</string>\r
</property>\r
- <layout class="QVBoxLayout" name="verticalLayout_3">\r
+ <property name="alignment">\r
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>\r
+ </property>\r
+ <layout class="QVBoxLayout" name="verticalLayout">\r
<item>\r
- <layout class="QVBoxLayout" name="verticalLayout">\r
- <item>\r
- <widget class="QRadioButton" name="rbOverWrite">\r
- <property name="focusPolicy">\r
- <enum>Qt::StrongFocus</enum>\r
- </property>\r
- <property name="text">\r
- <string>上書き</string>\r
- </property>\r
- </widget>\r
- </item>\r
- <item>\r
- <widget class="QRadioButton" name="rbOverWriteIfNew">\r
- <property name="focusPolicy">\r
- <enum>Qt::StrongFocus</enum>\r
- </property>\r
- <property name="text">\r
- <string>新しければ上書き</string>\r
- </property>\r
- </widget>\r
- </item>\r
+ <widget class="QRadioButton" name="rbOverWrite">\r
+ <property name="focusPolicy">\r
+ <enum>Qt::StrongFocus</enum>\r
+ </property>\r
+ <property name="text">\r
+ <string>上書き</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QRadioButton" name="rbOverWriteIfNew">\r
+ <property name="focusPolicy">\r
+ <enum>Qt::StrongFocus</enum>\r
+ </property>\r
+ <property name="text">\r
+ <string>新しければ上書き</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QRadioButton" name="rbSkip">\r
+ <property name="focusPolicy">\r
+ <enum>Qt::StrongFocus</enum>\r
+ </property>\r
+ <property name="text">\r
+ <string>スキップ</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QRadioButton" name="rbAppendNumber">\r
+ <property name="focusPolicy">\r
+ <enum>Qt::StrongFocus</enum>\r
+ </property>\r
+ <property name="text">\r
+ <string>ファイル名末尾に数字を付与</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QRadioButton" name="rbRename">\r
+ <property name="focusPolicy">\r
+ <enum>Qt::StrongFocus</enum>\r
+ </property>\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="rbAppendNumber">\r
- <property name="focusPolicy">\r
- <enum>Qt::StrongFocus</enum>\r
- </property>\r
- <property name="text">\r
- <string>ファイル名末尾に数字を付与</string>\r
+ <spacer name="horizontalSpacer_2">\r
+ <property name="orientation">\r
+ <enum>Qt::Horizontal</enum>\r
</property>\r
- </widget>\r
- </item>\r
- <item>\r
- <widget class="QRadioButton" name="rbSkip">\r
- <property name="focusPolicy">\r
- <enum>Qt::StrongFocus</enum>\r
+ <property name="sizeType">\r
+ <enum>QSizePolicy::Fixed</enum>\r
</property>\r
- <property name="text">\r
- <string>スキップ</string>\r
+ <property name="sizeHint" stdset="0">\r
+ <size>\r
+ <width>20</width>\r
+ <height>20</height>\r
+ </size>\r
</property>\r
- </widget>\r
+ </spacer>\r
</item>\r
<item>\r
- <layout class="QHBoxLayout" name="horizontalLayout">\r
- <item>\r
- <widget class="QRadioButton" name="rbRename">\r
- <property name="focusPolicy">\r
- <enum>Qt::StrongFocus</enum>\r
- </property>\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
+ <widget class="QLineEdit" name="lineEdit"/>\r
</item>\r
</layout>\r
</item>\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="focusPolicy">\r
<enum>Qt::StrongFocus</enum>\r