OSDN Git Service

Ver0.05
authorMasayuki Satoh <miyabi.satoh@gmail.com>
Thu, 21 Aug 2014 23:50:07 +0000 (08:50 +0900)
committerMasayuki Satoh <miyabi.satoh@gmail.com>
Thu, 21 Aug 2014 23:50:07 +0000 (08:50 +0900)
README.md
common.h
copymoveworker.cpp
filetablemodel.cpp
filetablemodel.h
filetableview.cpp
filetableview.h
folderpanel.cpp
history.cpp
mainwindow.cpp

index 648ec19..075dfbc 100644 (file)
--- a/README.md
+++ b/README.md
@@ -7,12 +7,17 @@ Gefu is an Experimental File Utility.
 - 初期表示時にカーソルがハイライトされないorz
 - オプション
     - ファンクションキー
+    - 各処理時の確認・完了ダイアログ表示有無
+    - 上書き時の規定の動作
 - ドラッグ&ドロップ
 - ファイル検索
 - 簡易テキストビューア
 - 簡易画像ビューア
 - 簡易アーカイバ
-- SNS連携(タイムライン表示とか)
+- SNS連携(タイムライン表示とか) ← ファイラーの機能か?
+
+#### 2014/08/22 Ver0.05
+- 外部アプリケーションからのドロップ処理を実装。
 
 #### 2014/08/22 Ver0.04 公開
 - 不具合修正
index 9022a37..04fd5cd 100644 (file)
--- a/common.h
+++ b/common.h
@@ -8,7 +8,7 @@ class MainWindow;
 extern MainWindow* getMainWnd();\r
 extern QString FilesizeToString(quint64 size);\r
 \r
-#define VERSION_VALUE   0.04\r
+#define VERSION_VALUE   0.05\r
 \r
 #define slash   QString("/")\r
 #define QQ(x)   ("\"" + (x) + "\"")\r
index 972e435..ca86b74 100644 (file)
@@ -188,7 +188,7 @@ void CopyMoveWorker::Listup(const QString &srcPath, const QString &tgtPath)
     QDir tgtDir(tgtPath);\r
 \r
     m_CopyMap.insert(srcPath, tgtDir.absoluteFilePath(info.fileName()));\r
-//    qDebug() << 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
index 0143924..fd7607e 100644 (file)
@@ -398,22 +398,37 @@ bool FileTableModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
 \r
     qDebug() << action << row << column;\r
 \r
-    if (action == Qt::IgnoreAction)\r
+    if (action == Qt::IgnoreAction) {\r
         return true;\r
+    }\r
 \r
-    if (!data->hasFormat("text/uri-list"))\r
+    if (!data->hasFormat("text/uri-list")) {\r
         return false;\r
+    }\r
 \r
-    if (column > 0)\r
+    if (column > 0) {\r
         return false;\r
+    }\r
 \r
-    QString msg;\r
-    msg = "ドロップを検知しました。<br/>";\r
+    QFileInfoList list;\r
     foreach (const QUrl &url, data->urls()) {\r
-        msg += url.toLocalFile() + "<br/>";\r
-        qDebug() << url.toLocalFile();\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
-    QMessageBox::information(NULL, "info", msg);\r
+\r
+    if (list.isEmpty()) {\r
+        return false;\r
+    }\r
+\r
+    emit filesDropped(list);\r
 \r
     return true;\r
 }\r
index 8ef11c3..91108de 100644 (file)
@@ -38,6 +38,7 @@ signals:
     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
index 4acb56b..7443d7c 100644 (file)
@@ -755,7 +755,28 @@ void FileTableView::askOverWrite(bool *bOk, int *prevCopyMethod, int *copyMethod
      }\r
      CopyMoveWorker *worker = static_cast<CopyMoveWorker*>(sender());\r
      worker->endAsking();\r
- }\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
@@ -821,16 +842,3 @@ void FileTableView::currentChanged(const QModelIndex &current, const QModelIndex
 \r
     QTableView::currentChanged(current, previous);\r
 }\r
-\r
-\r
-//void FileTableView::dropEvent(QDropEvent *event)\r
-//{\r
-//    foreach (const QString &str, event->mimeData()->formats()) {\r
-//        qDebug() << str;\r
-//    }\r
-//}\r
-\r
-//void FileTableView::dragEnterEvent(QDragEnterEvent *event)\r
-//{\r
-//    event->acceptProposedAction();\r
-//}\r
index 2a94975..7a03db6 100644 (file)
@@ -74,6 +74,7 @@ private slots:
     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
@@ -83,8 +84,6 @@ public slots:
 protected:\r
     void keyPressEvent(QKeyEvent *event);\r
     void focusInEvent(QFocusEvent *event);\r
-//    void dropEvent(QDropEvent *event);\r
-//    void dragEnterEvent(QDragEnterEvent *event);\r
 \r
     // QAbstractItemView interface\r
 protected slots:\r
index b0019b4..e0eb93f 100644 (file)
@@ -3,16 +3,8 @@
 #include "folderpanel.h"\r
 #include "mainwindow.h"\r
 #include "ui_folderpanel.h"\r
-#include <QCheckBox>\r
-#include <QMessageBox>\r
-#include <QKeyEvent>\r
-#include <QDebug>\r
-#include <QDateTime>\r
-#include <QDesktopServices>\r
+\r
 #include <QSettings>\r
-#ifdef Q_OS_WIN32\r
-    #include <windows.h>\r
-#endif\r
 \r
 QString FilesizeToString(quint64 size)\r
 {\r
@@ -79,6 +71,9 @@ void FolderPanel::setSide(const QString &side)
             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
index 83cd5b1..733ceb4 100644 (file)
@@ -14,7 +14,7 @@ void History::add(const QString &path)
     }
     // 現在位置と異なるパスであれば追加する
     if (isEmpty() || (m_list[m_pos] != path)) {
-        m_list.push_back(path);
+        m_list << path;
     }
     m_pos = m_list.size() - 1;
 }
index ac7ee57..8c8930c 100644 (file)
@@ -9,18 +9,13 @@
 #include "sortdialog.h"\r
 #include "preferencedialog.h"\r
 #include "ui_mainwindow.h"\r
-#include <QFileSystemModel>\r
-#include <QDebug>\r
-#include <QKeyEvent>\r
-#include <QDesktopServices>\r
-#include <QSettings>\r
-#include <QFileDialog>\r
-#include <QMessageBox>\r
-#include <QProcess>\r
-#include <QThread>\r
-#include <QInputDialog>\r
+\r
 #include <QCheckBox>\r
+#include <QCloseEvent>\r
+#include <QDebug>\r
 #include <QDesktopWidget>\r
+#include <QMessageBox>\r
+#include <QSettings>\r
 \r
 MainWindow::MainWindow(QWidget *parent) :\r
     QMainWindow(parent),\r
@@ -156,7 +151,7 @@ void MainWindow::toggleShowHiddenFiles()
 void MainWindow::toggleShowSystemFiles()\r
 {\r
     // キーボードがトリガーの場合、メニュー項目のチェック状態は\r
-    // 変わらないので、QSettingsを使う\r
+    // 変わらない(Mac)ので、QSettingsを使う\r
     QSettings settings;\r
     bool show = !settings.value(IniKey_ShowSystem, false).toBool();\r
     settings.setValue(IniKey_ShowSystem, show);\r
@@ -174,7 +169,7 @@ void MainWindow::onHelpAbout()
                 tr("<h3>Gefu Ver%1</h3>").arg(VERSION_VALUE) +\r
                 tr("<center>Gefu is an Experimental File Utility.<br/>"\r
                    "<small>(げふぅは実験的なファイルユーティリティです)</small></center>"\r
-                   "<p>最新版の情報は<a href='http://miyabi.rakusaba.jp'>喫茶・雅</a>で公開しています。</p>"\r
+                   "<p>最新版の情報は<a href='http://miyabi.rakusaba.jp'>喫茶[雅]</a>で公開しています。</p>"\r
                    "<p><small>Copyright 2014 @miyabi_satoh All rights reserved.</small></p>"));\r
 }\r
 \r