From: Masayuki Satoh Date: Mon, 25 Aug 2014 12:48:19 +0000 (+0900) Subject: Ver 0.11pre X-Git-Url: http://git.osdn.net/view?p=gefu%2FGefu.git;a=commitdiff_plain;h=d259624b20d2fab92b51545477cdcaa0e02277a3 Ver 0.11pre --- diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..e8ce75e --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,179 @@ +=============================================================================== + Gefu(げふぅ) - Gefu is an Experimental File Utility - + Version 0.10 +=============================================================================== + 2014/08/24 @miyabi_satoh + +◇ 概要 ◇ + + Gefu(げふぅ)は、クロスプラットフォームのGUIフレームワーク「Qt(キュート)」を + 使用して作成した2画面型のファイラー(ファイル管理ソフト)です。 + + キーボードだけ、あるいはマウスだけでほとんどの操作ができます。 + (さすがにマウスだけで文字入力はできませんが…) + +◇ 動作確認済みOS ◇ + + Windows : Windows Vista Home Premium (SP2) + Windows 7 Enterprise (SP1) + + Mac : OS X 10.9.4 + +◇ ファイル構成 ◇ + Windows + - Gefu.exe ... Gefu本体 + - icudt52.dll ... Qtライブラリ + - icuin52.dll ... 〃 + - icuuc52.dll ... 〃 + - libgcc_s_dw2-1.dll ... 〃 + - libstdc++-6.dll ... 〃 + - libwinpthread-1.dll ... 〃 + - Qt5Core.dll ... 〃 + - Qt5Gui.dll ... 〃 + - Qt5Network.dll ... 〃 + - Qt5Widgets.dll ... 〃 + + Mac + - Gefu.app ... Gefu本体 + +◇ インストール ◇ + Windows + 1. GefuXXX.zip をダウンロード、展開します。 + 2. Gefu_QtDLL.zip をダウンロード、展開します。 + 3. 展開された Gefu.exe とQtライブラリ(*.dll)を同じフォルダに格納します。 + + Mac + 1. GefuXXX.app.zip をダウンロード、展開します。 + 2. 展開された Getu.app を適当なフォルダに格納します。 + +◇ アップデート ◇ + Windows + 1. GefuXXX.zip をダウンロード、展開します。 + 2. Gefu.exe が起動している場合は、終了します。 + 3. 展開された Gefu.exe を、既存の Gefu.exe に上書きします。 + + Mac + 1. GefuXXX.app.zip をダウンロード、展開します。 + 2. Gefu.app が起動している場合は、終了します。 + 3. 展開された Getu.app を、既存の Gefu.app に上書きします。 + +◇ アンインストール ◇ + Windows + 1. Gefu.exe と Qtライブラリ(*.dll)を削除します。 + 2. 設定ファイルまで削除したい場合は、以下のファイルを削除します。 + %APPDATA%¥miyabi¥Gefu.ini + + Mac + 1. Gefu.app を削除します。 + 2. 設定ファイルまで削除したい場合は、以下のファイルを削除します。 + ~/.config/rakusaba.jp/Gefu.ini + +◇ 使い方 ◇ + 基本的には、WindowsのエクスプローラやMacのFinderと同じ感覚で使ってください。 + フォルダをダブルクリックすれば、フォルダを開きます。 + ファイルをダブルクリックすれば、ファイルを開きます。 + ドラッグ&ドロップすれば、コピーします。 + +◇ 免責事項 ◇ + - Gefu(げふぅ)はオープンソース・フリーソフトウェアです。 + 個人・法人に限らず、どなたでも自由にご使用ください。 + - 著作権は @miyabi_satoh が保有します。 + - Gefu(げふぅ)を利用したことによる損害には、一切の責任を負いません。 + 自己の責任の上でご利用ください。 + - 配布・転載を行う場合は @miyabi_satoh までご連絡ください。 + 特に利益を生じる無断配布・無断転載は固く禁じます。 + +◇ 連絡先 ◇ + Web: https://sourceforge.jp/projects/gefu/ + Mail: miyabi.satoh@gmail.com + Twitter: https://twitter.com/miyabi_satoh + +◇ 履歴 ◇ +#### 2014/08/24 Ver0.10 +- SourceForge.jp でプロジェクト公開。 +- 環境設定ダイアログの変更 + - コントロールの活性・非活性切り替えを修正。 + - フォント選択をダイアログ使用に変更。 + - ファイルビューのサンプル表示を実際の形に変更。 + - テキストビューアの設定を追加。 +- 安直な文字コード判別を実装 + - BOMがあれば、それに従う。 + - 先頭1KB中に文字コードを示す文字列("shift_jis"等)があれば、その文字コードに変換する。 + - バイト単位で調べて推測(http://dobon.net/vb/dotnet/string/detectcode.html よりコードを拝借) + +#### 2014/08/24 Ver0.09 +- 左右矢印キーに機能割り当て + - 左ペインで左矢印/右ペインで右矢印 → 親フォルダに移動 + - 左ペインで右矢印/右ペインで左矢印 → 反対側のペインにフォーカス +- ファイル名をクリップボードにコピーを実装。 +- フォルダ名をクリップボードにコピーを実装。 +- 簡易テキストビューアをとりあえず実装。 + → 次バージョンでオプション設定等 +- 不具合修正 + - Windows版で初回起動時、タイトルバーが画面外に出ていた。 + → デフォルト位置・サイズ変更。 + +#### 2014/08/23 Ver0.08 +- 「ターミナルで開く」を実装。 +- Shift+ダブルクリックで、ファイルを外部エディタで開くようにした。 +- Ctrl+ダブルクリックで、フォルダをターミナルで開くようにした。 +- 「色とフォント」にインポート・エクスポート機能を追加。 +- マスク表示(フィルタ)機能を追加。 +- 最新バージョンのチェック機能を追加。 +- 不具合修正 + - Windows版でドライブ直下のフォルダを開くと落ちるのを修正。 + +#### 2014/08/23 Ver0.07 +- ダブルクリック時、ファイルは標準の関連付けで実行するようにした。 +- 設定項目追加。 +- 「外部エディタで開く」を実装。 +- 不具合修正 + - 初期表示時にカーソルがハイライトされない問題を修正。 + +#### 2014/08/22 Ver0.06 +- 外部および内部のドラッグ&ドロップ処理を実装。 +- 一部ダイアログのレイアウト、初期サイズを調整。 +- 不具合修正 + - 同一ファイルに対する強制上書きが考慮されていなかった。 + → 先・元が同一の場合はスキップするようにした。 + +#### 2014/08/22 Ver0.05 +- 外部アプリケーションからのドロップ処理を実装。 + +#### 2014/08/22 Ver0.04 +- 不具合修正 + - ソート順でフォルダ位置が先頭以外の場合、".."もソートされていたのを修正。 + (ソート方法によらず、".."は必ず先頭にした) + - 各ダイアログのフォーカス周りを修正。 + - is "an" Experimental ... とか、バージョン情報ダイアログの修正。 + - MacのDockにアイコンが正しく表示されていなかったのを修正。 + - フォルダ内容変更による再読込時、カーソル位置が初期化されていたのを修正。 +- 「最新の情報に更新」を追加。 + +#### 2014/08/21 Ver0.03 +- 環境設定ダイアログおよびオプションを実装。 + - 終了時の確認ダイアログ。 + - 起動時のウィンドウ位置・サイズ。 + - 起動時に設定をリセット。 + - 色とフォントの設定。 + +#### 2014/08/20 Ver0.02 +- QTableWidget -> QTableView + Modelへ変更し高速化。 +- フォルダ履歴機能を実装。 +- 行の高さを調整。 +- マーク時の背景色、前景色を変更。 +- ウィンドウの位置・サイズを保存するようにした。 + +#### 2014/08/18 Ver0.01 +- 名前変更ダイアログ(単一)のレイアウトを修正。 +- すべて選択等で、カーソル位置が変わらないようにした。 +- マークしているフォルダ数、ファイル数、合計ファイルサイズの表示を追加。 +- ファイルサイズを小数点第一位まで表示するようにした。 +- システム属性ファイルの表示/非表示機能を追加。 +- 名前ソートで大文字小文字を区別しないようにした。 +- ソート方法の選択機能を追加。 + +#### 2014/08/18 Ver0.00 +- 新規作成。 + + diff --git a/clickablelabel.cpp b/clickablelabel.cpp deleted file mode 100644 index 52442a8..0000000 --- a/clickablelabel.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "clickablelabel.h" - -ClickableLabel::ClickableLabel(QWidget *parent) : - QLabel(parent) -{ -} - - -void ClickableLabel::mouseReleaseEvent(QMouseEvent *) -{ - emit clicked(); -} diff --git a/clickablelabel.h b/clickablelabel.h deleted file mode 100644 index 81abe05..0000000 --- a/clickablelabel.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef CLICKABLELABEL_H -#define CLICKABLELABEL_H - -#include - -class ClickableLabel : public QLabel -{ - Q_OBJECT -public: - explicit ClickableLabel(QWidget *parent = 0); - -signals: - void clicked(); - -public slots: - - - // QWidget interface -protected: - void mouseReleaseEvent(QMouseEvent *); -}; - -#endif // CLICKABLELABEL_H diff --git a/filetableview.cpp b/filetableview.cpp deleted file mode 100644 index 2b88e16..0000000 --- a/filetableview.cpp +++ /dev/null @@ -1,1247 +0,0 @@ -#include "common.h" -#include "copymoveworker.h" -#include "deleteworker.h" -#include "filetablemodel.h" -#include "filetableview.h" -#include "historydialog.h" -#include "mainwindow.h" -#include "operationdialog.h" -#include "overwritedialog.h" -#include "renamemultidialog.h" -#include "renamesingledialog.h" -#include "renameworker.h" -#include "sortdialog.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CHECK_FOCUS { \ - if (!hasFocus()) { return; } \ - } - -#define MENU_TRRIGGERED(x) \ - getMainWnd()->findChild(#x), SIGNAL(triggered()) -#define MENU_TOGGLED(x) \ - getMainWnd()->findChild(#x), SIGNAL(toggled(bool)) - -FileTableView::FileTableView(QWidget *parent) : - QTableView(parent), - m_side(), - m_history(), - m_dragStartPos(), - m_dragging(false) -{ - // シグナル/スロットを設定する - connect(MENU_TRRIGGERED(action_Open), this, SLOT(openItem())); - connect(MENU_TRRIGGERED(action_Exec), this, SLOT(openUrl())); - connect(MENU_TRRIGGERED(action_OpenEditor), this, SLOT(openEditor())); - connect(MENU_TRRIGGERED(action_OpenTerminal), this, SLOT(openTerminal())); - connect(MENU_TRRIGGERED(action_Command), this, SLOT(kickProcess())); - - connect(MENU_TRRIGGERED(mark_Toggle), this, SLOT(toggleChecked())); - connect(MENU_TRRIGGERED(mark_All), this, SLOT(checkAllItems())); - connect(MENU_TRRIGGERED(mark_AllFiles), this, SLOT(checkAllFiles())); - connect(MENU_TRRIGGERED(mark_AllOff), this, SLOT(uncheckAllItems())); - connect(MENU_TRRIGGERED(mark_Invert), this, SLOT(invertAllChecked())); - - connect(MENU_TRRIGGERED(view_FromOther), this, SLOT(setPathFromOther())); - connect(MENU_TRRIGGERED(view_ToOther), this, SLOT(setPathToOther())); - connect(MENU_TRRIGGERED(view_Swap), this, SLOT(swapPath())); - connect(MENU_TRRIGGERED(view_Sort), this, SLOT(setSort())); - connect(MENU_TRRIGGERED(view_Refresh), this, SLOT(refresh())); - connect(MENU_TRRIGGERED(view_Filter), this, SLOT(setFilter())); - - connect(MENU_TRRIGGERED(move_Back), this, SLOT(back())); - connect(MENU_TRRIGGERED(move_Forward), this, SLOT(forward())); - connect(MENU_TRRIGGERED(move_History), this, SLOT(showHidtory())); - connect(MENU_TRRIGGERED(move_Home), this, SLOT(jumpToHome())); - connect(MENU_TRRIGGERED(move_Parent), this, SLOT(jumpToParent())); - connect(MENU_TRRIGGERED(move_Root), this, SLOT(jumpToRoot())); - connect(MENU_TRRIGGERED(move_Jump), this, SLOT(jumpTo())); - connect(MENU_TRRIGGERED(move_Down), this, SLOT(cursorDown())); - connect(MENU_TRRIGGERED(move_Up), this, SLOT(cursorUp())); - connect(MENU_TRRIGGERED(move_Begin), this, SLOT(cursorToBegin())); - connect(MENU_TRRIGGERED(move_End), this, SLOT(cursorToEnd())); - - connect(MENU_TRRIGGERED(cmd_Copy), this, SLOT(cmdCopy())); - connect(MENU_TRRIGGERED(cmd_Move), this, SLOT(cmdMove())); - connect(MENU_TRRIGGERED(cmd_Delete), this, SLOT(cmdDelete())); - connect(MENU_TRRIGGERED(cmd_Rename), this, SLOT(cmdRename())); - connect(MENU_TRRIGGERED(cmd_NewFile), this, SLOT(newFile())); - connect(MENU_TRRIGGERED(cmd_NewFolder), this, SLOT(newFolder())); - connect(MENU_TRRIGGERED(copy_Filename), this, SLOT(copyFilenameToClipboard())); - connect(MENU_TRRIGGERED(copy_Fullpath), this, SLOT(copyFullpathToClipboard())); - - connect(getMainWnd(), SIGNAL(showHiddenFiles(bool)), - this, SLOT(showHiddenFiles(bool))); - connect(getMainWnd(), SIGNAL(showSystemFiles(bool)), - this, SLOT(showSystemFiles(bool))); - connect(this, SIGNAL(openRequested(QFileInfo)), - getMainWnd(), SLOT(openRequest(QFileInfo))); - - connect(this, SIGNAL(doubleClicked(QModelIndex)), - this, SLOT(onDoubleClick(QModelIndex))); - - // Drag & Drop - setDragEnabled(true); - setAcceptDrops(true); - setDropIndicatorShown(true); - - // Context Menu - setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, SIGNAL(customContextMenuRequested(QPoint)), - this, SLOT(contextMenuRequested(QPoint))); -} - -FileTableView::~FileTableView() -{ - QSettings settings; - FileTableModel *m = static_cast(model()); - - settings.setValue(side() + slash + IniKey_Dir, m->absolutePath()); -} - -QString FileTableView::side() const -{ - return m_side; -} - -void FileTableView::setSide(const QString &side) -{ - m_side = side; - - // コンストラクタではステータスバーが生成されていないため - // このタイミングでconnectする - connect(this, SIGNAL(indexChanged(QString)), - getMainWnd()->statusBar(), SLOT(showMessage(QString))); -} - -void FileTableView::setRootPath(const QString &path, bool addHistory) -{ - FileTableModel *m = static_cast(model()); - QFileInfo info(path); - - if (info.isDir()) { - getMainWnd()->statusBar()->showMessage(tr("ファイルリストの取得中...")); - - setUpdatesEnabled(false); - m->setPath(info.absoluteFilePath()); - setUpdatesEnabled(true); - - if (addHistory) { - m_history.add(info.absoluteFilePath()); - } - updateMenu(); - - selectRow(0); - getMainWnd()->statusBar()->showMessage(tr("レディ"), 5000); - } -} - -QFileInfoList FileTableView::selectedItems() const -{ - FileTableModel *m = static_cast(model()); - QFileInfoList list = m->checkedItems(); - if (list.isEmpty()) { - QFileInfo info = m->fileInfo(currentIndex()); - if (info.fileName() != "..") { - list.append(info); - } - } - - return list; -} - -void FileTableView::updateMenu() -{ - if (m_history.isEmpty()) { - getMainWnd()->findChild("move_Back")->setEnabled(false); - getMainWnd()->findChild("move_Forward")->setEnabled(false); - - } - else { - getMainWnd()->findChild("move_Back") - ->setEnabled(!m_history.isBegin()); - getMainWnd()->findChild("move_Forward") - ->setEnabled(!m_history.isEnd()); - } -} - -void FileTableView::openItem() -{ - CHECK_FOCUS; - - QModelIndex index = currentIndex(); - if (!index.isValid()) { - return; - } - - FileTableModel *m = static_cast(model()); - if (m->fileInfo(index).isDir()) { - setRootIndex(index); - } - else { - QSettings settings; - if (!settings.value(IniKey_ViewerForceOpen).toBool()) { - QStringList list = settings.value(IniKey_ViewerIgnoreExt).toString().split(","); - foreach (const QString &ext, list) { - if (ext.toLower() == m->fileInfo(index).suffix().toLower()) { - openUrl(index); - return; - } - } - } - emit openRequested(m->fileInfo(index)); - } -} - -void FileTableView::openUrl(const QModelIndex &index) -{ - CHECK_FOCUS; - - if (index.isValid()) { - FileTableModel *m = static_cast(model()); - QString path = QDir::toNativeSeparators(m->fileInfo(index).absoluteFilePath()); - QDesktopServices::openUrl(QUrl("file:///" + path)); - } - else { - QFileInfoList list = selectedItems(); - foreach (const QFileInfo &info, list) { - QString path = QDir::toNativeSeparators(info.absoluteFilePath()); - QDesktopServices::openUrl(QUrl("file:///" + path)); - } - } -} - -void FileTableView::openEditor(const QString &path) -{ - CHECK_FOCUS; - - QSettings settings; - if (settings.value(IniKey_EditorPath).toString().isEmpty()) { - QMessageBox::critical( - this, tr("エラー"), - tr("外部エディタのパスが未定義です。")); - return; - } - - QFileInfo info; - if (path.isEmpty()) { - FileTableModel *m = static_cast(model()); - info.setFile(m->fileInfo(currentIndex()).absoluteFilePath()); - } - else { - info.setFile(path); - } - - QString exe = settings.value(IniKey_EditorPath).toString(); - QString opt = settings.value(IniKey_EditorOption).toString(); - opt.replace("$B", info.completeBaseName()); - opt.replace("$E", info.suffix()); - opt.replace("$F", info.fileName()); - opt.replace("$D", info.absolutePath()); - opt.replace("$P", info.absoluteFilePath()); - - QString command; -#ifdef Q_OS_MAC - command = "open -a " + exe + " " + opt; -#else - command = QQ(exe) + " " + opt; -#endif - qDebug() << command; - QProcess process(this); - process.setWorkingDirectory(info.absolutePath()); - if (!process.startDetached(command)) { - QMessageBox::critical( - this, tr("エラー"), - tr("外部エディタの起動に失敗しました。
") - + command); - } -} - -void FileTableView::openTerminal(const QString &path) -{ - CHECK_FOCUS; - - QSettings settings; - if (settings.value(IniKey_TerminalPath).toString().isEmpty()) { - QMessageBox::critical( - this, tr("エラー"), - tr("ターミナルのパスが未定義です。")); - return; - } - - QFileInfo info; - if (path.isEmpty()) { - FileTableModel *m = static_cast(model()); - info.setFile(m->fileInfo(currentIndex()).absoluteFilePath()); - } - else { - info.setFile(path); - } - - QString exe = settings.value(IniKey_TerminalPath).toString(); - QString opt = settings.value(IniKey_TerminalOption).toString(); - opt.replace("$B", info.completeBaseName()); - opt.replace("$E", info.suffix()); - opt.replace("$F", info.fileName()); - if (info.isDir()) { - opt.replace("$D", info.absoluteFilePath()); - } - else { - opt.replace("$D", info.absolutePath()); - } - opt.replace("$P", info.absoluteFilePath()); - - QString command; -#ifdef Q_OS_MAC - command = "open -a " + exe + " --args " + opt; -#else - command = QQ(exe) + " " + opt; -#endif - qDebug() << command; - QProcess process(this); - process.setWorkingDirectory(info.absolutePath()); - if (!process.startDetached(command)) { - QMessageBox::critical( - this, tr("エラー"), - tr("ターミナルの起動に失敗しました。
") - + command); - } -} - -void FileTableView::kickProcess() -{ - CHECK_FOCUS; - - QFileInfoList list = selectedItems(); - QString command = QString::null; - foreach (const QFileInfo &info, list) { - if (info.isExecutable()) { - command = QQ(info.fileName()) + " " + command; - } - else { - command += " " + QQ(info.fileName()); - } - } - - QInputDialog dlg(this); - dlg.setInputMode(QInputDialog::TextInput); - dlg.setWindowTitle(tr("コマンドを実行")); - dlg.setLabelText(tr("コマンド:")); - dlg.setTextValue(command); - dlg.resize(getMainWnd()->width() * 0.8, dlg.height()); - - int ret = dlg.exec(); - command = dlg.textValue(); - if (ret == QDialog::Accepted && !command.isEmpty()) { - FileTableModel *m = static_cast(model()); - QProcess process(this); - process.setWorkingDirectory(m->absolutePath()); - if (!process.startDetached(command)) { - QMessageBox::critical( - this, tr("エラー"), - tr("コマンドの実行に失敗しました。
") + command); - } - } -} - -void FileTableView::toggleChecked() -{ - CHECK_FOCUS; - - FileTableModel *m = static_cast(model()); - - QModelIndex index = currentIndex(); - - QFileInfo info = m->fileInfo(index); - if (info.fileName() != "..") { - if (m->checkState(index) == Qt::Checked) { - m->setCheckState(index, Qt::Unchecked); - } - else { - m->setCheckState(index, Qt::Checked); - } - } - // 最終行でなければ、次のアイテムに移動する - if (index.row() == m->rowCount() - 1) { - setCurrentIndex(index); - } - else if (index.row() < m->rowCount() - 1) { - setCurrentIndex(m->index(index.row() + 1, 1)); - } -} - -void FileTableView::checkAllItems() -{ - CHECK_FOCUS; - - QModelIndex index = currentIndex(); - FileTableModel *m = static_cast(model()); - setUpdatesEnabled(false); - m->setCheckStateAll(Qt::Checked); - setUpdatesEnabled(true); - setCurrentIndex(index); -} - -void FileTableView::checkAllFiles() -{ - CHECK_FOCUS; - - QModelIndex index = currentIndex(); - FileTableModel *m = static_cast(model()); - setUpdatesEnabled(false); - for (int n = 0; n < m->rowCount(); n++) { - QModelIndex index = m->index(n, 0); - QFileInfo info = m->fileInfo(index); - if (info.isDir()) { - m->setCheckState(index, Qt::Unchecked); - } - else { - m->setCheckState(index, Qt::Checked); - } - update(index); - } - setUpdatesEnabled(true); - setCurrentIndex(index); -} - -void FileTableView::uncheckAllItems() -{ - CHECK_FOCUS; - - QModelIndex index = currentIndex(); - FileTableModel *m = static_cast(model()); - setUpdatesEnabled(false); - m->setCheckStateAll(Qt::Unchecked); - setUpdatesEnabled(true); - setCurrentIndex(index); -} - -void FileTableView::invertAllChecked() -{ - CHECK_FOCUS; - - QModelIndex index = currentIndex(); - FileTableModel *m = static_cast(model()); - setUpdatesEnabled(false); - for (int n = 0; n < m->rowCount(); n++) { - QModelIndex index = m->index(n, 0); - if (m->checkState(index) == Qt::Checked) { - m->setCheckState(index, Qt::Unchecked); - } - else { - m->setCheckState(index, Qt::Checked); - } - update(index); - } - setUpdatesEnabled(true); - setCurrentIndex(index); -} - -void FileTableView::setPathFromOther() -{ - CHECK_FOCUS; - - FileTableView *other = getMainWnd()->otherSideView(this); - if (other == NULL) { - return; - } - - FileTableModel *mOther = static_cast(other->model()); - - setRootPath(mOther->absolutePath(), true); -} - -void FileTableView::setPathToOther() -{ - CHECK_FOCUS; - - FileTableView *other = getMainWnd()->otherSideView(this); - if (other == NULL) { - return; - } - - FileTableModel *m = static_cast(model()); - - other->setRootPath(m->absolutePath(), true); -} - -void FileTableView::swapPath() -{ - CHECK_FOCUS; - - FileTableView *other = getMainWnd()->otherSideView(this); - if (other == NULL) { - return; - } - - FileTableModel *m = static_cast(model()); - FileTableModel *mOther = static_cast(other->model()); - - QString path = m->absolutePath(); - QString pathOther = mOther->absolutePath(); - - setRootPath(pathOther, true); - other->setRootPath(path, true); -} - -void FileTableView::showHiddenFiles(bool show) -{ - FileTableModel *m = static_cast(model()); - if (show) { - m->setFilter(m->filter() | QDir::Hidden); - } - else { - m->setFilter(m->filter() ^ QDir::Hidden); - } - - setUpdatesEnabled(false); - refresh(); - setUpdatesEnabled(true); -} - -void FileTableView::showSystemFiles(bool show) -{ - FileTableModel *m = static_cast(model()); - if (show) { - m->setFilter(m->filter() | QDir::System); - } - else { - m->setFilter(m->filter() ^ QDir::System); - } - - setUpdatesEnabled(false); - refresh(); - setUpdatesEnabled(true); -} - -void FileTableView::setSort() -{ - CHECK_FOCUS; - - SortDialog dlg(this); - dlg.setRightOrLeft(side()); - if (dlg.exec() == QDialog::Accepted) { - QSettings settings; - FileTableModel *m = static_cast(model()); - m->setSorting(QDir::Name); // 0 - - int sortBy = settings.value(side() + slash + IniKey_SortBy).toInt(); - switch (sortBy) { - case SortByDate: m->setSorting(m->sorting() | QDir::Time); break; - case SortBySize: m->setSorting(m->sorting() | QDir::Size); break; - case SortByType: m->setSorting(m->sorting() | QDir::Type); break; - default: m->setSorting(m->sorting() | QDir::Name); break; - } - - // デフォルトだと文字列は昇順で、数値は降順…orz - int orderBy = settings.value(side() + slash + IniKey_OrderBy).toInt(); - if (((sortBy == SortByName || sortBy == SortByType) && orderBy == OrderByDesc) || - ((sortBy == SortByDate || sortBy == SortBySize) && orderBy == OrderByAsc)) - { - m->setSorting(m->sorting() | QDir::Reversed); - } - - switch (settings.value(side() + slash + IniKey_PutDirs).toInt()) { - case PutDirsFirst: m->setSorting(m->sorting() | QDir::DirsFirst); break; - case PutDirsLast: m->setSorting(m->sorting() | QDir::DirsLast); break; - } - - if (settings.value(side() + slash + IniKey_IgnoreCase).toBool()) { - m->setSorting(m->sorting() | QDir::IgnoreCase); - } - - setUpdatesEnabled(false); - refresh(); - setUpdatesEnabled(true); - } -} - -void FileTableView::refresh() -{ - FileTableModel *m = static_cast(model()); - int row = currentIndex().row(); - setRootPath(m->absolutePath(), false); - if (m->rowCount() <= row) { - row = m->rowCount() - 1; - } - setCurrentIndex(m->index(row, 0)); - selectRow(row); -} - -void FileTableView::setFilter() -{ - CHECK_FOCUS; - - QString filters = QString::null; - FileTableModel *m = static_cast(model()); - foreach (const QString &filter, m->nameFilters()) { - filters += filter + " "; - } - - QInputDialog dlg(this); - dlg.setInputMode(QInputDialog::TextInput); - dlg.setWindowTitle(tr("フィルタを設定")); - dlg.setLabelText(tr("フィルタ:")); - dlg.setTextValue(filters); - dlg.resize(getMainWnd()->width() * 0.8, dlg.height()); - - if (dlg.exec() == QDialog::Accepted) { - filters = dlg.textValue(); - if (filters.isEmpty()) { - filters = "*"; - } - m->setNameFilters(filters.split(" ", QString::SkipEmptyParts)); - refresh(); - emit filterChanged(); - } -} - -void FileTableView::back() -{ - CHECK_FOCUS; - - if (!m_history.isBegin()) { - const QString &path = m_history.back(); - setRootPath(path, false); - - updateMenu(); - } -} - -void FileTableView::forward() -{ - CHECK_FOCUS; - - if (!m_history.isEnd()) { - const QString &path = m_history.forward(); - setRootPath(path, false); - - updateMenu(); - } -} - -void FileTableView::showHidtory() -{ - CHECK_FOCUS; - - FileTableView *other = getMainWnd()->otherSideView(this); - - HistoryDialog dlg(this); - if (side() == "Left") { - dlg.setDefaultLeft(true); - dlg.setHistory(&m_history, other->history()); - } - else { - dlg.setDefaultLeft(false); - dlg.setHistory(other->history(), &m_history); - } - - if (dlg.exec() == QDialog::Accepted) { - if (side() == dlg.selectedSide()) { - m_history.setAt(dlg.selectedIndex()); - setRootPath(m_history.current(), false); - } - else { - setRootPath(other->history()->at(dlg.selectedIndex()), true); - } - updateMenu(); - } -} - -void FileTableView::jumpToHome() -{ - CHECK_FOCUS; - - setRootPath(QDir::homePath(), true); -} - -void FileTableView::jumpToParent() -{ - CHECK_FOCUS; - - FileTableModel *m = static_cast(model()); - QDir dir(m->absolutePath()); - if (!dir.isRoot()) { - dir.cdUp(); - setRootPath(dir.absolutePath(), true); - } -} - -void FileTableView::jumpToRoot() -{ - CHECK_FOCUS; - - setRootPath(QDir::rootPath(), true); -} - -void FileTableView::jumpTo() -{ - CHECK_FOCUS; - - FileTableModel *m = static_cast(model()); - QString path = QFileDialog::getExistingDirectory( - this, tr("フォルダを選択"), m->absolutePath()); - if (!path.isEmpty()) { - setRootPath(path, true); - } -} - -void FileTableView::cursorDown() -{ - CHECK_FOCUS; - - int row = currentIndex().row(); - if (row < model()->rowCount() - 1) { - setCurrentIndex(model()->index(row + 1, 1)); - } -} - -void FileTableView::cursorUp() -{ - CHECK_FOCUS; - - int row = currentIndex().row(); - if (row > 0) { - setCurrentIndex(model()->index(row - 1, 1)); - } -} - -void FileTableView::cursorToBegin() -{ - CHECK_FOCUS; - - setCurrentIndex(model()->index(0, 1)); -} - -void FileTableView::cursorToEnd() -{ - CHECK_FOCUS; - - setCurrentIndex(model()->index(model()->rowCount() - 1, 1)); -} - -void FileTableView::cmdCopy() -{ - CHECK_FOCUS; - - QFileInfoList list = selectedItems(); - if (list.isEmpty()) { - return; - } - - QSettings settings; - if (settings.value(IniKey_ConfirmCopy).toBool()) { - int ret = QMessageBox::question(this, tr("確認"), - tr("コピーを実行しますか?")); - if (ret != QMessageBox::Yes) { - return; - } - } - - FileTableView *other = getMainWnd()->otherSideView(this); - FileTableModel *mOther = static_cast(other->model()); - CopyMoveWorker *worker = new CopyMoveWorker(); - connect(worker, SIGNAL(askOverWrite(bool*,int*,int*,QString*,QString,QString)), - this, SLOT(askOverWrite(bool*,int*,int*,QString*,QString,QString))); - worker->setCopyList(&list); - worker->setTargetDir(mOther->absolutePath()); - worker->setMoveMode(false); - - OperationDialog opDlg(this); - opDlg.setWindowTitle(tr("コピー")); - opDlg.setWorker(worker); - opDlg.setAutoClose(settings.value(IniKey_AutoCloseCopy).toBool()); - - opDlg.exec(); - - settings.setValue(IniKey_AutoCloseCopy, opDlg.autoClose()); -} - -void FileTableView::cmdMove() -{ - CHECK_FOCUS; - - QFileInfoList list = selectedItems(); - if (list.isEmpty()) { - return; - } - - QSettings settings; - if (settings.value(IniKey_ConfirmMove).toBool()) { - int ret = QMessageBox::question(this, tr("確認"), - tr("移動を実行しますか?")); - if (ret != QMessageBox::Yes) { - return; - } - } - - FileTableView *other = getMainWnd()->otherSideView(this); - FileTableModel *mOther = static_cast(other->model()); - CopyMoveWorker *worker = new CopyMoveWorker(); - connect(worker, SIGNAL(askOverWrite(bool*,int*,int*,QString*,QString,QString)), - this, SLOT(askOverWrite(bool*,int*,int*,QString*,QString,QString))); - worker->setCopyList(&list); - worker->setTargetDir(mOther->absolutePath()); - worker->setMoveMode(true); - - OperationDialog opDlg(this); - opDlg.setWindowTitle(tr("移動")); - opDlg.setWorker(worker); - opDlg.setAutoClose(settings.value(IniKey_AutoCloseMove).toBool()); - - opDlg.exec(); - - settings.setValue(IniKey_AutoCloseMove, opDlg.autoClose()); -} - -void FileTableView::cmdDelete() -{ - CHECK_FOCUS; - - QFileInfoList list = selectedItems(); - if (list.isEmpty()) { - return; - } - - QSettings settings; - if (settings.value(IniKey_ConfirmDelete).toBool()) { - QString msg; - if (list.size() == 1) { - msg = list[0].fileName(); - } - else { - msg = tr("%1個のアイテム").arg(list.size()); - } - int ret = QMessageBox::question( - this, tr("確認"), - msg + tr("を削除しますか?")); - if (ret != QMessageBox::Yes) { - return; - } - } - DeleteWorker *worker = new DeleteWorker(); - worker->setDeleteList(&list); - - OperationDialog opDlg(this); - opDlg.setWindowTitle(tr("削除")); - opDlg.setWorker(worker); - opDlg.setAutoClose(settings.value(IniKey_AutoCloseDelete).toBool()); - - opDlg.exec(); - - settings.setValue(IniKey_AutoCloseDelete, opDlg.autoClose()); -} - -void FileTableView::cmdRename() -{ - CHECK_FOCUS; - - QFileInfoList list = selectedItems(); - if (list.isEmpty()) { - return; - } - - IRenameDialog *dlg; - if (list.size() == 1) { - dlg = new RenameSingleDialog(this); - } - else { - dlg = new RenameMultiDialog(this); - } - FileTableModel *m = static_cast(model()); - dlg->setWorkingDirectory(m->absolutePath()); - dlg->setNames(list); - int dlgResult = dlg->exec(); - if (dlgResult == QDialog::Accepted && !dlg->renameMap().isEmpty()) { - QSettings settings; - if (settings.value(IniKey_ConfirmRename).toBool()) { - int ret = QMessageBox::question(this, tr("確認"), - tr("名前の変更を実行しますか?")); - if (ret != QMessageBox::Yes) { - return; - } - } - - RenameWorker *worker = new RenameWorker(); - worker->setRenameMap(&dlg->renameMap()); - - OperationDialog opDlg(this); - opDlg.setWindowTitle(tr("名前を変更")); - opDlg.setWorker(worker); - opDlg.setAutoClose(settings.value(IniKey_AutoCloseRename).toBool()); - - opDlg.exec(); - - settings.setValue(IniKey_AutoCloseRename, opDlg.autoClose()); - } -} - -void FileTableView::newFile() -{ - CHECK_FOCUS; - - bool bOk; - QString name = QInputDialog::getText( - this, tr("ファイルを作成"), tr("ファイル名:"), - QLineEdit::Normal, "", &bOk); - if (bOk && !name.isEmpty()) { - FileTableModel *m = static_cast(model()); - QDir dir(m->absolutePath()); - QFile file(dir.absoluteFilePath(name)); - if (!file.open(QIODevice::WriteOnly)) { - QMessageBox::critical( - this, tr("エラー"), - tr("ファイルの作成に失敗しました。")); - } - else { - file.close(); - - QSettings settings; - if (settings.value(IniKey_OpenAfterCreateFile).toBool()) { - openEditor(dir.absoluteFilePath(name)); - } - } - } -} - -void FileTableView::newFolder() -{ - CHECK_FOCUS; - - bool bOk; - QString name = QInputDialog::getText( - this, tr("フォルダを作成"), tr("フォルダ名:"), - QLineEdit::Normal, "", &bOk); - if (bOk && !name.isEmpty()) { - FileTableModel *m = static_cast(model()); - QDir dir(m->absolutePath()); - if (!dir.mkpath(name)) { - QMessageBox::critical( - this, tr("エラー"), - tr("フォルダの作成に失敗しました。")); - } - else { - QSettings settings; - if (settings.value(IniKey_MoveAfterCreateFolder).toBool()) { - setRootPath(dir.absoluteFilePath(name), true); - } - } - } -} - -void FileTableView::copyFilenameToClipboard() -{ - CHECK_FOCUS; - - QModelIndex index = currentIndex(); - if (!index.isValid()) { - return; - } - - FileTableModel *m = static_cast(model()); - QClipboard *clipboard = QApplication::clipboard(); - clipboard->setText(m->fileInfo(index).fileName()); -} - -void FileTableView::copyFullpathToClipboard() -{ - CHECK_FOCUS; - - QModelIndex index = currentIndex(); - if (!index.isValid()) { - return; - } - - FileTableModel *m = static_cast(model()); - QClipboard *clipboard = QApplication::clipboard(); - clipboard->setText(m->fileInfo(index).absoluteFilePath()); -} - -void FileTableView::XXX() -{ - CHECK_FOCUS; - - qDebug() << sender()->objectName() << "に対するスロットは未実装です。"; -} - -void FileTableView::askOverWrite(bool *bOk, int *prevCopyMethod, int *copyMethod, - QString *alias, const QString &srcPath, - const QString &tgtPath) - { - OverWriteDialog dlg; - if (*prevCopyMethod == OverWriteDialog::Undefined) { - QSettings settings; - QString method = settings.value(IniKey_DefaultOnCopy).toString(); - if (method == "owDefOverWrite") { - *prevCopyMethod = OverWriteDialog::OverWrite; - } - else if (method == "owDefSkip") { - *prevCopyMethod = OverWriteDialog::Skip; - } - else if (method == "owDefAppendNumber") { - *prevCopyMethod = OverWriteDialog::AppendNumber; - } - else if (method == "owDefRename") { - *prevCopyMethod = OverWriteDialog::Rename; - } - else { - *prevCopyMethod = OverWriteDialog::OverWriteIfNew; - } - } - dlg.setCopyMethod(*prevCopyMethod); - dlg.setSameMethodChecked(*copyMethod != OverWriteDialog::Undefined); - dlg.setFileInfo(srcPath, tgtPath); - if (dlg.exec() == QDialog::Rejected) { - *bOk = false; - } - else { - *prevCopyMethod = dlg.copyMethod(); - if (dlg.isSameMethodChecked()) { - *copyMethod = *prevCopyMethod; - } - *alias = dlg.alias(); - *bOk = true; - } - CopyMoveWorker *worker = static_cast(sender()); - worker->endAsking(); -} - -void FileTableView::onDoubleClick(const QModelIndex &index) -{ - if (!index.isValid()) { - return; - } - - FileTableModel *m = static_cast(model()); - - if (m->fileInfo(index).isDir()) { - if (QApplication::keyboardModifiers().testFlag(Qt::ControlModifier)) { - openTerminal(m->fileInfo(index).absoluteFilePath()); - } - else { - setRootPath(m->fileInfo(index).absoluteFilePath(), true); - } - } - else if (QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier)){ - openEditor(m->fileInfo(index).absoluteFilePath()); - } - else { - openUrl(index); - } - -} - -void FileTableView::contextMenuRequested(const QPoint &pos) -{ - FileTableModel *m = static_cast(model()); - QModelIndex index = indexAt(pos); - if (!index.isValid()) { - return; - } - - Q_UNUSED(m); -} - -void FileTableView::setRootIndex(const QModelIndex &index) -{ - if (!index.isValid()) { - return; - } - - FileTableModel *m = static_cast(model()); - - if (m->fileInfo(index).isDir()) { - setRootPath(m->fileInfo(index).absoluteFilePath(), true); - } -} - -void FileTableView::keyPressEvent(QKeyEvent *event) -{ - // Macでアクションが処理されないケースがあるため、 - // キーイベントを拾ってアクションシグナルを起動する - QString modifier = QString::null; - if (event->modifiers() & Qt::ShiftModifier) { modifier += "Shift+"; } - if (event->modifiers() & Qt::ControlModifier) { modifier += "Ctrl+"; } - if (event->modifiers() & Qt::AltModifier) { modifier += "Alt+"; } - if (event->modifiers() & Qt::MetaModifier) { modifier += "Meta+"; } - - QString key = QKeySequence(event->key()).toString(); - QString ksq = QKeySequence(modifier + key).toString(); - - if (!ksq.isEmpty()) { - foreach (QObject *obj, getMainWnd()->children()) { - QAction *action = qobject_cast(obj); - if (action && action->isEnabled()) { - foreach (const QKeySequence &keySeq, action->shortcuts()) { - if (ksq == keySeq.toString()) { - qDebug() << "emit " << ksq << " " << action->objectName(); - emit action->triggered(); - event->accept(); - return; - } - } - } - } - } - - if (ksq == "Left" || ksq == "Right") { - if (side() == ksq) { - jumpToParent(); - } - else { - getMainWnd()->otherSideView(this)->setFocus(); - } - event->accept(); - return; - } - - if (!ksq.isEmpty() && ksq != "Down" && ksq != "Up") { - qDebug() << ksq; - } - QTableView::keyPressEvent(event); -} - -void FileTableView::focusInEvent(QFocusEvent *event) -{ - if (!currentIndex().isValid()) { - FileTableModel *m = static_cast(model()); - if (m) { - setCurrentIndex(m->index(0, 0)); - } - } - - updateMenu(); - - QTableView::focusInEvent(event); -} - -void FileTableView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) -{ - Q_UNUSED(previous); - - if (current.isValid()) { - FileTableModel *m = static_cast(model()); - emit indexChanged(m->fileInfo(current).absoluteFilePath()); - } - - QTableView::currentChanged(current, previous); -} - - -void FileTableView::dropEvent(QDropEvent *event) -{ - if (m_dragging) { - event->ignore(); - return; - } - - QFileInfoList list; - foreach (const QUrl &url, event->mimeData()->urls()) { - QFileInfo info(url.toLocalFile()); - QString path = info.canonicalFilePath(); - if (!path.isEmpty()) { - list << path; - } - else { - qDebug() << "path is empty."; - } - } - - if (list.isEmpty()) { - event->ignore(); - return; - } - event->acceptProposedAction(); - - FileTableModel *m = static_cast(model()); - CopyMoveWorker *worker = new CopyMoveWorker(); - connect(worker, SIGNAL(askOverWrite(bool*,int*,int*,QString*,QString,QString)), - this, SLOT(askOverWrite(bool*,int*,int*,QString*,QString,QString))); - worker->setCopyList(&list); - worker->setTargetDir(m->absolutePath()); - worker->setMoveMode(false); - - OperationDialog opDlg(this); - opDlg.setWindowTitle(tr("コピー")); - opDlg.setWorker(worker); - - opDlg.exec(); -} - - -void FileTableView::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasUrls()) { - event->acceptProposedAction(); - return; - } - - QTableView::dragEnterEvent(event); -} - -void FileTableView::mousePressEvent(QMouseEvent *event) -{ - if ((event->buttons() & Qt::LeftButton) || (event->buttons() & Qt::RightButton)) - { - m_dragStartPos = event->pos(); - } - - QTableView::mousePressEvent(event); -} - -void FileTableView::mouseMoveEvent(QMouseEvent *event) -{ - if (!(event->buttons() & Qt::LeftButton) && - !(event->buttons() & Qt::RightButton)) - { - QTableView::mouseMoveEvent(event); - return; - } - if ((event->pos() - m_dragStartPos).manhattanLength() - < QApplication::startDragDistance()) - { - QTableView::mouseMoveEvent(event); - return; - } - - QFileInfoList list = selectedItems(); - if (list.isEmpty()) { - QTableView::mousePressEvent(event); - return; - } - - QList urls; - foreach (const QFileInfo &info, list) { - urls << QUrl::fromLocalFile(info.absoluteFilePath()); - } - - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - mimeData->setUrls(urls); - drag->setMimeData(mimeData); - - m_dragging = true; - if (event->buttons() & Qt::RightButton) { - drag->exec(Qt::CopyAction | Qt::MoveAction); - } - else { - drag->exec(Qt::CopyAction); - } - m_dragging = false; -} diff --git a/filetableview.h b/filetableview.h deleted file mode 100644 index d3ed0e5..0000000 --- a/filetableview.h +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef FILETABLEVIEW_H -#define FILETABLEVIEW_H - -#include "history.h" - -#include -#include - -class FileTableView : public QTableView -{ - Q_OBJECT -public: - explicit FileTableView(QWidget *parent = 0); - ~FileTableView(); - - QString side() const; - void setSide(const QString &side); - - History* history() { return &m_history; } - - void setRootPath(const QString &path, bool addHistory); - -private: - QString m_side; - History m_history; - QPoint m_dragStartPos; - bool m_dragging; - - QFileInfoList selectedItems() const; - void updateMenu(); - -signals: - void indexChanged(const QString &text); - void filterChanged(); - void openRequested(const QFileInfo &info); - -private slots: - void openItem(); - void openUrl(const QModelIndex &index = QModelIndex()); - void openEditor(const QString &path = QString()); - void openTerminal(const QString &path = QString()); - void kickProcess(); - - void toggleChecked(); - void checkAllItems(); - void checkAllFiles(); - void uncheckAllItems(); - void invertAllChecked(); - - void setPathFromOther(); - void setPathToOther(); - void swapPath(); - void showHiddenFiles(bool show); - void showSystemFiles(bool show); - void setSort(); - void refresh(); - void setFilter(); - - void back(); - void forward(); - void showHidtory(); - void jumpToHome(); - void jumpToParent(); - void jumpToRoot(); - void jumpTo(); - void cursorDown(); - void cursorUp(); - void cursorToBegin(); - void cursorToEnd(); - - void cmdCopy(); - void cmdMove(); - void cmdDelete(); - void cmdRename(); - void newFile(); - void newFolder(); - void copyFilenameToClipboard(); - void copyFullpathToClipboard(); - - void XXX(); - -private slots: - void askOverWrite(bool *bOk, int *prevCopyMethod, int *copyMethod, - QString *alias, const QString &srcPath, - const QString &tgtPath); - void onDoubleClick(const QModelIndex &index); - void contextMenuRequested(const QPoint & pos); - - // QAbstractItemView interface -public slots: - void setRootIndex(const QModelIndex &index); - - // QWidget interface -protected: - void keyPressEvent(QKeyEvent *event); - void focusInEvent(QFocusEvent *event); - void dropEvent(QDropEvent *event); - void dragEnterEvent(QDragEnterEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - - // QAbstractItemView interface -protected slots: - void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); -}; - -#endif // FILETABLEVIEW_H diff --git a/folderpanel.cpp b/folderpanel.cpp deleted file mode 100644 index 7a576f1..0000000 --- a/folderpanel.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#include "common.h" -#include "filetablemodel.h" -#include "folderpanel.h" -#include "mainwindow.h" -#include "ui_folderpanel.h" - -#include - -QString FilesizeToString(quint64 size) -{ - if (size >= 1024 * 1024 * 1024) { - return QString("%1GB").arg(int(10 * size / (1024 * 1024 * 1024)) / 10.0); - } - if (size >= 1024 * 1024) { - return QString("%1MB").arg(int(10 * size / (1024 * 1024)) / 10.0); - } - if (size >= 1024) { - return QString("%1KB").arg(int(10 * size / 1024) / 10.0); - } - return QString("%1B").arg(size); -} - -FolderPanel::FolderPanel(QWidget *parent) : - QWidget(parent), - ui(new Ui::FolderPanel) -{ - ui->setupUi(this); - ui->fileTable->setModel(new FileTableModel(this)); - - // リサイズ時の動作を設定する - QHeaderView *header = ui->fileTable->horizontalHeader(); - header->setSectionResizeMode(0, QHeaderView::ResizeToContents); - header->setSectionResizeMode(1, QHeaderView::Stretch); - header->setSectionResizeMode(2, QHeaderView::ResizeToContents); - header->setSectionResizeMode(3, QHeaderView::ResizeToContents); - header->setDefaultSectionSize(header->minimumSectionSize()); - // 行の高さを75%に調整 - QHeaderView *vHeader = ui->fileTable->verticalHeader(); - vHeader->setDefaultSectionSize(vHeader->defaultSectionSize() * 0.75); -} - -FolderPanel::~FolderPanel() -{ - delete ui; -} - -const QString FolderPanel::side() const -{ - return ui->fileTable->side(); -} - -void FolderPanel::setSide(const QString &side) -{ - ui->fileTable->setSide(side); - - QSettings settings; - FileTableModel *model = new FileTableModel(); - connect(model, SIGNAL(rootChanged(QString)), - ui->locationField, SLOT(setText(QString))); - connect(model, SIGNAL(stateChanged(int,int,quint64)), - this, SLOT(onStateChanged(int,int,quint64))); - connect(model, SIGNAL(listUpdated()), - ui->fileTable, SLOT(refresh())); - connect(ui->fileTable, SIGNAL(filterChanged()), - this, SLOT(onFilterChanged())); - - //>>>>> フィルタ初期化 - model->setFilter(QDir::NoDot | QDir::AllDirs | QDir::Files); - if (settings.value(IniKey_ShowHidden).toBool()) { - model->setFilter(model->filter() | QDir::Hidden); - } - if (settings.value(IniKey_ShowSystem).toBool()) { - model->setFilter(model->filter() | QDir::System); - } - //>>>>> ソート順初期化 - model->setSorting(QDir::Name); // 0 - int sortBy = settings.value(side + slash + IniKey_SortBy).toInt(); - switch (sortBy) { - case SortByDate: model->setSorting(model->sorting() | QDir::Time); break; - case SortBySize: model->setSorting(model->sorting() | QDir::Size); break; - case SortByType: model->setSorting(model->sorting() | QDir::Type); break; - default: model->setSorting(model->sorting() | QDir::Name); break; - } - // デフォルトだと文字列は昇順で、数値は降順…orz - int orderBy = settings.value(side + slash + IniKey_OrderBy).toInt(); - if (((sortBy == SortByName || sortBy == SortByType) && orderBy == OrderByDesc) || - ((sortBy == SortByDate || sortBy == SortBySize) && orderBy == OrderByAsc)) - { - model->setSorting(model->sorting() | QDir::Reversed); - } - // フォルダの位置 - switch (settings.value(side + slash + IniKey_PutDirs).toInt()) { - case PutDirsFirst: model->setSorting(model->sorting() | QDir::DirsFirst); break; - case PutDirsLast: model->setSorting(model->sorting() | QDir::DirsLast); break; - } - // 大文字小文字の区別 - if (settings.value(side + slash + IniKey_IgnoreCase).toBool()) { - model->setSorting(model->sorting() | QDir::IgnoreCase); - } - //>>>>> 監視フォルダ初期化 - QString path = settings.value(side + slash + IniKey_Dir).toString(); - - model->updateAppearance(); - ui->fileTable->setModel(model); - ui->fileTable->setRootPath(path, true); - onFilterChanged(); -} - -void FolderPanel::updateAppearance() -{ - QSettings settings; - QPalette palette; - QFont font; - - font = settings.value(IniKey_BoxFont).value(); - palette = ui->locationField->palette(); - palette.setColor(QPalette::Base, - settings.value(IniKey_BoxColorBg).value()); - palette.setColor(QPalette::Text, - settings.value(IniKey_BoxColorFg).value()); - ui->locationField->setFont(font); - ui->locationField->setPalette(palette); - - palette = ui->fileTable->palette(); - palette.setColor(QPalette::Base, - settings.value(IniKey_ViewColorBgNormal).value()); - ui->fileTable->setPalette(palette); - - FileTableModel *model = static_cast(ui->fileTable->model()); - if (model) { - model->updateAppearance(); - } -} - -void FolderPanel::onStateChanged(int checkedFolders, int checkedFiles, quint64 totalSize) -{ - QString msg = ""; - if (checkedFolders > 0) { - msg += tr("%1個のフォルダ ").arg(checkedFolders); - } - if (checkedFiles > 0) { - msg += tr("%1個のファイル ").arg(checkedFiles); - } - if (msg.length() > 0) { - msg += "を選択 合計 "; - msg += FilesizeToString(totalSize); - } - - if (msg.isEmpty()) { - onFilterChanged(); - } - else { - ui->label->setText(msg); - } -} - -void FolderPanel::onFilterChanged() -{ - FileTableModel *m = static_cast(ui->fileTable->model()); - QString filters = "フィルタ:"; - foreach (const QString &filter, m->nameFilters()) { - filters += filter + " "; - } - ui->label->setText(filters); -} - -void FolderPanel::on_locationField_editingFinished() -{ - ui->locationField->blockSignals(true); - - QString path = ui->locationField->text(); - ui->fileTable->setRootPath(path, true); - - ui->locationField->blockSignals(false); -} diff --git a/folderpanel.h b/folderpanel.h deleted file mode 100644 index 2193e5f..0000000 --- a/folderpanel.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef FOLDERPANEL_H -#define FOLDERPANEL_H - -#include - -namespace Ui { -class FolderPanel; -} - -class FolderPanel : public QWidget -{ - Q_OBJECT - -public: - explicit FolderPanel(QWidget *parent = 0); - ~FolderPanel(); - - const QString side() const; - void setSide(const QString &side); - - void updateAppearance(); - -private: - Ui::FolderPanel *ui; - -private slots: - void onStateChanged(int checkedFolders, int checkedFiles, quint64 totalSize); - void onFilterChanged(); - void on_locationField_editingFinished(); -}; - -#endif // FOLDERPANEL_H diff --git a/folderpanel.ui b/folderpanel.ui deleted file mode 100644 index cf22040..0000000 --- a/folderpanel.ui +++ /dev/null @@ -1,117 +0,0 @@ - - - FolderPanel - - - - 0 - 0 - 256 - 238 - - - - - 0 - 0 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - - - Qt::ClickFocus - - - - - - - - - Qt::StrongFocus - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - false - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - Qt::ElideMiddle - - - false - - - false - - - false - - - false - - - - - - - - 0 - 0 - - - - TextLabel - - - - - - - - FileTableView - QTableView -
filetableview.h
-
-
- - fileTable - locationField - - - -
diff --git a/folderview.cpp b/folderview.cpp new file mode 100644 index 0000000..747bf01 --- /dev/null +++ b/folderview.cpp @@ -0,0 +1,6 @@ +#include "folderview.h" + +FolderView::FolderView(QWidget *parent) : + QTableView(parent) +{ +} diff --git a/folderview.h b/folderview.h new file mode 100644 index 0000000..1bf1731 --- /dev/null +++ b/folderview.h @@ -0,0 +1,18 @@ +#ifndef FOLDERVIEW_H +#define FOLDERVIEW_H + +#include + +class FolderView : public QTableView +{ + Q_OBJECT +public: + explicit FolderView(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // FOLDERVIEW_H diff --git a/locationbox.cpp b/locationbox.cpp new file mode 100644 index 0000000..bbd0550 --- /dev/null +++ b/locationbox.cpp @@ -0,0 +1,6 @@ +#include "locationbox.h" + +LocationBox::LocationBox(QWidget *parent) : + QLineEdit(parent) +{ +} diff --git a/locationbox.h b/locationbox.h new file mode 100644 index 0000000..0cd5449 --- /dev/null +++ b/locationbox.h @@ -0,0 +1,18 @@ +#ifndef LOCATIONBOX_H +#define LOCATIONBOX_H + +#include + +class LocationBox : public QLineEdit +{ + Q_OBJECT +public: + explicit LocationBox(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // LOCATIONBOX_H diff --git a/searchbox.cpp b/searchbox.cpp new file mode 100644 index 0000000..4748908 --- /dev/null +++ b/searchbox.cpp @@ -0,0 +1,6 @@ +#include "searchbox.h" + +SearchBox::SearchBox(QWidget *parent) : + QLineEdit(parent) +{ +} diff --git a/searchbox.h b/searchbox.h new file mode 100644 index 0000000..d397e62 --- /dev/null +++ b/searchbox.h @@ -0,0 +1,18 @@ +#ifndef SEARCHBOX_H +#define SEARCHBOX_H + +#include + +class SearchBox : public QLineEdit +{ + Q_OBJECT +public: + explicit SearchBox(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // SEARCHBOX_H diff --git a/singleton.hpp b/singleton.hpp deleted file mode 100644 index 5382cee..0000000 --- a/singleton.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef SINGLETON_HPP -#define SINGLETON_HPP - -#include - -/// -/// シングルトンパターンの基底クラス -/// -template -class Singleton -{ -public: - static T& instance() { - static pointer_type instance(createInstance()); - - return getReference(instance); - } - -protected: - Singleton() { - } - -private: - typedef std::auto_ptr pointer_type; - - static T* createInstance() { return new T(); } - static T& getReference(const pointer_type &p) { return *p; } - - explicit Singleton(const Singleton&); - Singleton& operator=(const Singleton&); -}; - -#endif // SINGLETON_HPP