+#include "bookmarkdialog.h"\r
#include "copymoveworker.h"\r
#include "deleteworker.h"\r
-#include "mainwindow.h"\r
+#include "foldermodel.h"\r
+#include "folderpanel.h"\r
+#include "global.h"\r
+#include "historydialog.h"\r
#include "operationdialog.h"\r
#include "overwritedialog.h"\r
-#include "renamemultidialog.h"\r
-#include "renamesingledialog.h"\r
+#include "preferences.h"\r
+#include "preferencedialog.h"\r
#include "renameworker.h"\r
+#include "renamesingledialog.h"\r
+#include "renamemultidialog.h"\r
+#include "simpletextview.h"\r
+#include "simpleimageview.h"\r
+#include "sortdialog.h"\r
+#include "version.h"\r
+#include "mainwindow.h"\r
#include "ui_mainwindow.h"\r
-#include <QFileSystemModel>\r
+\r
+#include <QCheckBox>\r
+#include <QClipboard>\r
+#include <QCloseEvent>\r
#include <QDebug>\r
-#include <QKeyEvent>\r
#include <QDesktopServices>\r
-#include <QSettings>\r
#include <QFileDialog>\r
+#include <QInputDialog>\r
#include <QMessageBox>\r
+#include <QMimeData>\r
+#include <QNetworkAccessManager>\r
#include <QProcess>\r
-#include <QThread>\r
-#include <QInputDialog>\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::MainWindow\r
+/// \param parent 親ウィジェット\r
+///\r
+/// コンストラクタ\r
+///\r
MainWindow::MainWindow(QWidget *parent) :\r
QMainWindow(parent),\r
- ui(new Ui::MainWindow)\r
+ ui(new Ui::MainWindow),\r
+ m_overwriteDialog(this),\r
+ m_viewMode(ModeBasic),\r
+ m_prevMode(ModeBasic),\r
+ m_actions()\r
{\r
ui->setupUi(this);\r
-\r
- QSettings settings;\r
- bool checked = settings.value("Common/ShowHidden", false).toBool();\r
- ui->view_Hidden->setChecked(checked);\r
-\r
- // メニューのシグナル/スロットを設定する\r
- connect(ui->action_Command, SIGNAL(triggered()), this, SLOT(onActionCommand()));\r
- connect(ui->action_Exec, SIGNAL(triggered()), this, SLOT(onActionExec()));\r
- connect(ui->action_Open, SIGNAL(triggered()), this, SLOT(onActionOpen()));\r
- connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(onActionQuit()));\r
- connect(ui->action_Setting, SIGNAL(triggered()), this, SLOT(onActionSetting()));\r
-\r
- connect(ui->mark_All, SIGNAL(triggered()), this, SLOT(onMarkAll()));\r
- connect(ui->mark_AllFiles, SIGNAL(triggered()), this, SLOT(onMarkAllFiles()));\r
- connect(ui->mark_AllOff, SIGNAL(triggered()), this, SLOT(onMarkAllOff()));\r
- connect(ui->mark_Invert, SIGNAL(triggered()), this, SLOT(onMarkInvert()));\r
- connect(ui->mark_Toggle, SIGNAL(triggered()), this, SLOT(onMarkToggle()));\r
-\r
- connect(ui->move_Down, SIGNAL(triggered()), this, SLOT(onMoveCursorDown()));\r
- connect(ui->move_Up, SIGNAL(triggered()), this, SLOT(onMoveCursorUp()));\r
- connect(ui->move_Begin, SIGNAL(triggered()), this, SLOT(onMoveCursorBegin()));\r
- connect(ui->move_End, SIGNAL(triggered()), this, SLOT(onMoveCursorEnd()));\r
- connect(ui->move_Back, SIGNAL(triggered()), this, SLOT(onMoveBack()));\r
- connect(ui->move_Forward, SIGNAL(triggered()), this, SLOT(onMoveForward()));\r
- connect(ui->move_Home, SIGNAL(triggered()), this, SLOT(onMoveHome()));\r
- connect(ui->move_Jump, SIGNAL(triggered()), this, SLOT(onMoveJump()));\r
- connect(ui->move_Parent, SIGNAL(triggered()), this, SLOT(onMoveParent()));\r
- connect(ui->move_Root, SIGNAL(triggered()), this, SLOT(onMoveRoot()));\r
-\r
- connect(ui->view_FromOther, SIGNAL(triggered()), this, SLOT(onViewFromOther()));\r
- connect(ui->view_ToOther, SIGNAL(triggered()), this, SLOT(onViewToOther()));\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_Move, SIGNAL(triggered()), this, SLOT(onCmdMove()));\r
- connect(ui->cmd_NewFile, SIGNAL(triggered()), this, SLOT(onCmdNewFile()));\r
- connect(ui->cmd_NewFolder, SIGNAL(triggered()), this, SLOT(onCmdNewFolder()));\r
- connect(ui->cmd_Rename, SIGNAL(triggered()), this, SLOT(onCmdRename()));\r
-\r
- connect(ui->help_About, SIGNAL(triggered()), this, SLOT(onHelpAbout()));\r
-\r
- // ウィンドウタイトルを設定する\r
- setWindowTitle(tr("げふぅ v0.00"));\r
- // ウィンドウアイコンを設定する\r
- setWindowIcon(QIcon(":/images/Gefu.png"));\r
-\r
- // ウィンドウ初期サイズを設定する\r
- resize(800, 600);\r
-\r
- QString path;\r
-\r
- path = settings.value("Left/dir", QDir::homePath()).toString();\r
- ui->folderPanel_L->setCurrentFolder(path);\r
-\r
- path = settings.value("Right/dir", QDir::homePath()).toString();\r
- ui->folderPanel_R->setCurrentFolder(path);\r
+ connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)), this, SLOT(app_focusChange(QWidget*,QWidget*)));\r
+\r
+ // ステータスバーにウィジェットを設定する\r
+ QLabel *label = new QLabel(this);\r
+ label->setAlignment(Qt::AlignRight);\r
+ label->setObjectName("Right");\r
+ statusBar()->addPermanentWidget(label, 0);\r
+\r
+ // アプリケーション情報を初期化する\r
+ qApp->setApplicationName("Gefu");\r
+ qApp->setApplicationVersion(QString("%1").arg(VERSION_VALUE));\r
+ qApp->setOrganizationDomain("sourceforge.jp");\r
+ qApp->setOrganizationName("gefu");\r
+ qApp->setWindowIcon(QIcon("://images/file-manager.png"));\r
+\r
+ // 古い設定ファイルを削除する\r
+#ifdef Q_OS_MAC\r
+ QSettings::setDefaultFormat(QSettings::IniFormat);\r
+ QSettings settings(this);\r
+ if (QFileInfo::exists(settings.fileName())) {\r
+ QFile(settings.fileName()).remove();\r
+ QDir().rmdir(QFileInfo(settings.fileName()).absolutePath());\r
+ }\r
+#endif\r
+\r
+ // 設定の初期化\r
+ Preferences prefs(this);\r
+ if (prefs.isReset()) {\r
+ prefs.clear();\r
+ }\r
+\r
+ // パネルにモデルを割り当てる\r
+ ui->LPanel->setModel(new FolderModel(this));\r
+ ui->RPanel->setModel(new FolderModel(this));\r
+ setActiveModel(ui->LPanel->model());\r
+\r
+ // パネルを初期化する\r
+ ui->LPanel->initialize(this);\r
+ ui->RPanel->initialize(this);\r
+ ui->FPanel->initialize(this);\r
+ ui->FPanel->setVisible(false);\r
+\r
+ // モデルを初期化する\r
+ prefs.restoreModel("Left", ui->LPanel->model());\r
+ prefs.restoreModel("Right", ui->RPanel->model());\r
+\r
+ // アクションを初期化する\r
+ initActions();\r
+\r
+ // ブックマークメニューを初期化する\r
+ initBookmarkMenu();\r
+\r
+ // メインウィンドウを初期化する\r
+ setWindowTitle(tr("げふぅ Ver%1").arg(VERSION_VALUE));\r
+ setWindowIcon(QIcon("://images/file-manager.png"));\r
+ prefs.restoreWindow(this);\r
+\r
+ // 最新バージョンをチェックする\r
+ if (prefs.isCheckUpdate()) {\r
+ onCheckUpdate(true);\r
+ }\r
+\r
+ ui->LPanel->updateAppearance(prefs);\r
+ ui->LPanel->model()->updateAppearance(prefs);\r
+ ui->RPanel->updateAppearance(prefs);\r
+ ui->RPanel->model()->updateAppearance(prefs);\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::~MainWindow\r
+///\r
+/// デストラクタ\r
+///\r
MainWindow::~MainWindow()\r
{\r
- QSettings settings;\r
-\r
- settings.setValue("Left/dir", ui->folderPanel_L->dir()->absolutePath());\r
- settings.setValue("Right/dir", ui->folderPanel_R->dir()->absolutePath());\r
-\r
delete ui;\r
}\r
\r
-void MainWindow::setStatusText(const QString &str)\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::app_focusChange\r
+/// \param old フォーカスを失うウィジェット\r
+/// \param now フォーカスを得るウィジェット\r
+///\r
+/// フォーカス変更時の処理\r
+///\r
+void MainWindow::app_focusChange(QWidget *old, QWidget *now)\r
{\r
- ui->statusBar->showMessage(str);\r
-}\r
+ qDebug() << "MainWindow::app_focusChange()";\r
+ if (old) qDebug() << " old is" << old->objectName();\r
+ if (now) qDebug() << " now is" << now->objectName();\r
\r
-FolderPanel* MainWindow::activePanel()\r
-{\r
- if (ui->folderPanel_L->fileTable()->hasFocus()) {\r
- return ui->folderPanel_L;\r
+ // フォルダビューがフォーカスを得た場合\r
+ if (now && (now->objectName() == "folderView" ||\r
+ now->objectName() == "thumbnailView"))\r
+ {\r
+ connect(focusItemView()->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),\r
+ this, SLOT(view_currentChanged(QModelIndex,QModelIndex)));\r
+ FolderModel *m = static_cast<FolderModel*>(focusItemView()->model());\r
+ setActiveModel(m);\r
+ statusBar()->showMessage(m->filePath(focusItemView()->currentIndex()));\r
}\r
- if (ui->folderPanel_R->fileTable()->hasFocus()) {\r
- return ui->folderPanel_R;\r
+\r
+ // 検索ボックスがフォーカスを失った場合\r
+ if (old && old->objectName() == "searchBox") {\r
+ // 検索モード終了\r
+ ui->toggle_Search->setChecked(false);\r
}\r
\r
- return NULL;\r
+ // アクションの有効/無効を設定する\r
+ if (now) {\r
+ updateActions();\r
+ }\r
}\r
\r
-FolderPanel* MainWindow::inactivePanel()\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::model_PreReset\r
+///\r
+/// FolderModelリセット前の処理\r
+///\r
+void MainWindow::model_PreReset()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == ui->folderPanel_L) {\r
- return ui->folderPanel_R;\r
- }\r
- if (fp == ui->folderPanel_R) {\r
- return ui->folderPanel_L;\r
- }\r
+ qDebug() << "MainWindow::model_PreReset()";\r
\r
- return NULL;\r
+ statusBar()->showMessage(tr("ファイルリストを取得しています..."));\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::model_PostReset\r
///\r
-/// \brief MainWindow::onActionCommand\r
+/// FolderModelリセット後の処理\r
///\r
-/// コマンドを実行します(X)\r
-///\r
-void MainWindow::onActionCommand()\r
+void MainWindow::model_PostReset()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
-\r
- QString command = "";\r
- for (int n = 0; n < fp->fileTable()->rowCount(); n++) {\r
- if (fp->fileTable()->item(n, 0)->checkState() == Qt::Checked) {\r
- QString path = fp->fileTable()->item(n, 1)->text();\r
- path = fp->dir()->absoluteFilePath(path);\r
- path = QDir::cleanPath(path);\r
- path = QDir::toNativeSeparators(path);\r
+ qDebug() << "MainWindow::model_PostReset()";\r
\r
- QFileInfo info(path);\r
- if (info.isExecutable()) {\r
- command = "\"" + path + "\" " + command;\r
- }\r
- else {\r
- command += " \"" + path + "\"";\r
- }\r
- }\r
+ FolderModel *m = static_cast<FolderModel*>(sender());\r
+ if (!m->error().isEmpty()) {\r
+ statusBar()->showMessage(m->error());\r
}\r
+ else {\r
+ statusBar()->showMessage(tr("レディ"));\r
+ }\r
+}\r
\r
- if (command.isEmpty()) {\r
- int row = fp->fileTable()->currentRow();\r
- QString path = fp->fileTable()->item(row, 1)->text();\r
- path = fp->dir()->absoluteFilePath(path);\r
- path = QDir::cleanPath(path);\r
- path = QDir::toNativeSeparators(path);\r
-\r
- command = "\"" + path + "\"";\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onRunCommand\r
+///\r
+/// 入力されたコマンドを実行します。\r
+///\r
+void MainWindow::onRunCommand()\r
+{\r
+ qDebug() << "MainWindow::onRunCommand";\r
+\r
+ QFileInfoList list = selectedItems();\r
+ QString command = QString::null;\r
+ foreach (const QFileInfo &info, list) {\r
+#ifdef Q_OS_MAC\r
+ QString path = info.absoluteFilePath();\r
+#else\r
+ QString path = info.fileName();\r
+#endif\r
+ if (info.isExecutable()) {\r
+ command = QQ(path) + " " + command;\r
+ }\r
+ else {\r
+ command += " " + QQ(path);\r
+ }\r
}\r
\r
QInputDialog dlg(this);\r
dlg.setInputMode(QInputDialog::TextInput);\r
- dlg.setLabelText(tr("コマンドを入力:"));\r
dlg.setWindowTitle(tr("コマンドを実行"));\r
+ dlg.setLabelText(tr("コマンド:"));\r
dlg.setTextValue(command);\r
- dlg.resize(500, 100);\r
+ dlg.resize(width() * 0.8, dlg.height());\r
+\r
int ret = dlg.exec();\r
command = dlg.textValue();\r
if (ret == QDialog::Accepted && !command.isEmpty()) {\r
- QProcess process(this);\r
- process.setWorkingDirectory(fp->dir()->absolutePath());\r
- if (!process.startDetached(command)) {\r
- QMessageBox::critical(\r
- this,\r
- tr("エラー"),\r
- tr("コマンドの実行に失敗しました。<br/>") + command);\r
- }\r
+ startProcess(command, tr("コマンドの実行に失敗しました。"));\r
}\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onExpandLeft\r
///\r
-/// \brief MainWindow::onActionExec\r
-///\r
-/// アプリケーションで開きます(Shift + Enter)\r
+/// 左パネルを拡大します。\r
///\r
-void MainWindow::onActionExec()\r
+void MainWindow::onExpandLeft()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::onExpandLeft()";\r
\r
- QStringList list = selectedItems(fp);\r
- foreach (const QString &path, list) {\r
- QDesktopServices::openUrl(QUrl("file:///" + QDir::toNativeSeparators(path)));\r
- }\r
+ QList<int> sizes = ui->splitter->sizes();\r
+ QList<int> newSizes;\r
+\r
+ newSizes << sizes[0] + 30;\r
+ newSizes << sizes[1] - 30;\r
+\r
+ ui->splitter->setSizes(newSizes);\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onExpandRight\r
///\r
-/// \brief MainWindow::onActionOpen\r
-///\r
-/// フォルダを開きます(Enter)\r
+/// 右パネルを拡大します。\r
///\r
-void MainWindow::onActionOpen()\r
+void MainWindow::onExpandRight()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::onExpandLeft()";\r
\r
- int row = fp->fileTable()->currentRow();\r
- QString path = fp->fileTable()->item(row, 1)->text();\r
- path = fp->dir()->absoluteFilePath(path);\r
- QFileInfo info(path);\r
+ QList<int> sizes = ui->splitter->sizes();\r
+ QList<int> newSizes;\r
\r
- if (info.isDir()) {\r
- fp->setCurrentFolder(path);\r
- }\r
+ newSizes << sizes[0] - 30;\r
+ newSizes << sizes[1] + 30;\r
+\r
+ ui->splitter->setSizes(newSizes);\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onToggleMark\r
///\r
-/// \brief MainWindow::onActionQuit\r
+/// マーク状態を反転します。\r
///\r
-/// アプリケーションを終了します(Q)\r
-///\r
-void MainWindow::onActionQuit()\r
+void MainWindow::onToggleMark()\r
{\r
- qApp->quit();\r
+ qDebug() << "MainWindow::onToggleMark()";\r
+\r
+ QModelIndex index = focusItemView()->currentIndex();\r
+ if (activeModel()->isMarked(index)) {\r
+ activeModel()->setData(index, Qt::Unchecked, Qt::CheckStateRole);\r
+ }\r
+ else {\r
+ activeModel()->setData(index, Qt::Checked, Qt::CheckStateRole);\r
+ }\r
+\r
+ if (index.row() < activeModel()->rowCount() - 1) {\r
+ index = activeModel()->index(index.row() + 1, 0);\r
+ focusItemView()->setCurrentIndex(index);\r
+ }\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::view_statusChanged\r
+/// \param text ステータス文字列\r
///\r
-/// \brief MainWindow::onActionSetting\r
-///\r
-/// 環境設定ダイアログを表示します(Z)\r
+/// ビューから受け取った文字列をステータスバーに表示します。\r
///\r
-void MainWindow::onActionSetting()\r
+void MainWindow::view_statusChanged(const QString &text)\r
{\r
- QMessageBox::information(this, tr("情報"), tr("環境設定機能は未実装です。"));\r
+ statusBar()->findChild<QLabel*>("Right")->setText(text);\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::view_currentChanged\r
+/// \param current 新しいカレントインデックス\r
+/// \param previous (使用しません)\r
///\r
-/// \brief MainWindow::on_mark_All_triggered\r
+/// カレントインデックスが変更された場合の処理を行います。\r
///\r
-/// すべてマークします(Shift + A)\r
-///\r
-void MainWindow::onMarkAll()\r
+void MainWindow::view_currentChanged(const QModelIndex ¤t, const QModelIndex &previous)\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
+ qDebug() << "MainWindow::view_currentChanged()" << current;\r
+ Q_UNUSED(previous);\r
+\r
+ if (focusItemView() != sender()->parent()) {\r
return;\r
}\r
\r
- int row = 0;\r
- if (fp->fileTable()->item(row, 1)->text() == "..") {\r
- row++;\r
- }\r
+ statusBar()->showMessage(activeModel()->filePath(current));\r
\r
- fp->beginUpdate();\r
- int curRow = fp->fileTable()->currentRow();\r
- int rowCount = fp->fileTable()->rowCount();\r
- for (; row < rowCount; row++) {\r
- fp->fileTable()->item(row, 0)->setCheckState(Qt::Checked);\r
+ if (m_viewMode == ModePreview) {\r
+ inactivePanel()->setViewItem(current);\r
}\r
- fp->fileTable()->setCurrentIndex(\r
- fp->fileTable()->model()->index(curRow, 1));\r
- fp->endUpdate();\r
+\r
+ updateActions();\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::view_finished\r
///\r
-/// \brief MainWindow::onMarkAllFiles\r
+/// ビューアの終了\r
///\r
-/// すべての「ファイル」をマークします(A)\r
-///\r
-void MainWindow::onMarkAllFiles()\r
+void MainWindow::view_finished()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
-\r
- int row = 0;\r
- if (fp->fileTable()->item(row, 1)->text() == "..") {\r
- row++;\r
- }\r
+ qDebug() << "MainWindow::view_finished()";\r
\r
- fp->beginUpdate();\r
- int curRow = fp->fileTable()->currentRow();\r
- int rowCount = fp->fileTable()->rowCount();\r
- for (; row < rowCount; row++) {\r
- QString path = fp->fileTable()->item(row, 1)->text();\r
- path = fp->dir()->absoluteFilePath(path);\r
+ statusBar()->findChild<QLabel*>("Right")->setText("");\r
\r
- QFileInfo info(path);\r
- if (info.isDir()) {\r
- fp->fileTable()->item(row, 0)->setCheckState(Qt::Unchecked);\r
- }\r
- else {\r
- fp->fileTable()->item(row, 0)->setCheckState(Qt::Checked);\r
- }\r
- }\r
- fp->fileTable()->setCurrentIndex(\r
- fp->fileTable()->model()->index(curRow, 1));\r
- fp->endUpdate();\r
+ setViewMode(m_prevMode);\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onMove\r
///\r
-/// \brief MainWindow::onMarkAllOff\r
+/// 選択アイテムを隣のパネルに移動します。\r
///\r
-/// すべてのマークを解除します(U)\r
-///\r
-void MainWindow::onMarkAllOff()\r
+void MainWindow::onMove()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
+ qDebug() << "MainWindow::onMove";\r
+\r
+ QStringList list;\r
+ foreach (const QFileInfo &fi, selectedItems()) {\r
+ list << fi.absoluteFilePath();\r
+ }\r
+ if (list.isEmpty()) {\r
return;\r
}\r
\r
- int row = 0;\r
- if (fp->fileTable()->item(row, 1)->text() == "..") {\r
- row++;\r
- }\r
+ int row = focusItemView()->currentIndex().row();\r
\r
- fp->beginUpdate();\r
- int curRow = fp->fileTable()->currentRow();\r
- int rowCount = fp->fileTable()->rowCount();\r
- for (; row < rowCount; row++) {\r
- fp->fileTable()->item(row, 0)->setCheckState(Qt::Unchecked);\r
+ QString tgtPath = inactiveModel()->rootPath();\r
+ moveItems(list, tgtPath);\r
+\r
+ if (row >= activeModel()->rowCount()) {\r
+ row = activeModel()->rowCount() - 1;\r
}\r
- fp->fileTable()->setCurrentIndex(\r
- fp->fileTable()->model()->index(curRow, 1));\r
- fp->endUpdate();\r
+ focusItemView()->setCurrentIndex(activeModel()->index(row, 1));\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onKeyLeft\r
///\r
-/// \brief MainWindow::onMarkInvert\r
-///\r
-/// マークを反転します(I)\r
+/// ←キー押下時の処理を行います。\r
///\r
-void MainWindow::onMarkInvert()\r
+void MainWindow::onKeyLeft()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
-\r
- int row = 0;\r
- if (fp->fileTable()->item(row, 1)->text() == "..") {\r
- row++;\r
- }\r
-\r
- fp->beginUpdate();\r
- int curRow = fp->fileTable()->currentRow();\r
- int rowCount = fp->fileTable()->rowCount();\r
- for (; row < rowCount; row++) {\r
- QTableWidgetItem *item = fp->fileTable()->item(row, 0);\r
- if (item->checkState() == Qt::Checked) {\r
- item->setCheckState(Qt::Unchecked);\r
+ qDebug() << "MainWindow::onKeyLeft()";\r
+\r
+ QWidget *w = qApp->focusWidget();\r
+ if (w->objectName() == "folderView")\r
+ {\r
+ QWidget *panel = w->parentWidget()->parentWidget();\r
+ if (panel == ui->LPanel) {\r
+ activeModel()->onCdUp();\r
}\r
- else {\r
- item->setCheckState(Qt::Checked);\r
+ else if (ui->LPanel->folderPanel()->isVisible()){\r
+ ui->LPanel->folderPanel()->itemView()->setFocus();\r
}\r
}\r
- fp->fileTable()->setCurrentIndex(\r
- fp->fileTable()->model()->index(curRow, 1));\r
- fp->endUpdate();\r
+ else {\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_PageUp, Qt::NoModifier);\r
+ qApp->sendEvent(w, &event);\r
+ }\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onKeyRight\r
///\r
-/// \brief MainWindow::onMarkToggle\r
+/// →キー押下時の処理を行います。\r
///\r
-/// マークを設定または解除します(Space)\r
-///\r
-void MainWindow::onMarkToggle()\r
+void MainWindow::onKeyRight()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
-\r
- int row = fp->fileTable()->currentRow();\r
- QTableWidgetItem *item = fp->fileTable()->item(row, 0);\r
- if (fp->fileTable()->item(row, 1)->text() != "..") {\r
- if (item->checkState() == Qt::Checked) {\r
- item->setCheckState(Qt::Unchecked);\r
- }\r
- else {\r
- item->setCheckState(Qt::Checked);\r
- }\r
+ qDebug() << "MainWindow::onKeyRight()";\r
+\r
+ QWidget *w = qApp->focusWidget();\r
+ if (w->objectName() == "folderView")\r
+ {\r
+ QWidget *panel = w->parentWidget()->parentWidget();\r
+ if (panel == ui->RPanel) {\r
+ activeModel()->onCdUp();\r
+ }\r
+ else if (ui->RPanel->folderPanel()->isVisible()){\r
+ ui->RPanel->folderPanel()->itemView()->setFocus();\r
+ }\r
}\r
- // 最終行でなければ、次のアイテムに移動する\r
- if (row < fp->fileTable()->rowCount() - 1) {\r
- QModelIndex nextIndex = fp->fileTable()->model()->index(row + 1, 1);\r
- fp->fileTable()->setCurrentIndex(nextIndex);\r
+ else {\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_PageDown, Qt::NoModifier);\r
+ qApp->sendEvent(w, &event);\r
}\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onChooseFolder\r
///\r
-/// \brief MainWindow::onMoveCursorDown\r
+/// 選択したフォルダに移動します。\r
///\r
-/// カーソルを下に移動します(J)\r
-///\r
-void MainWindow::onMoveCursorDown()\r
+void MainWindow::onChooseFolder()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::onChooseFolder()";\r
\r
- int row = fp->fileTable()->currentRow();\r
- if (row < fp->fileTable()->rowCount() - 1) {\r
- QModelIndex nextIndex = fp->fileTable()->model()->index(row + 1, 1);\r
- fp->fileTable()->setCurrentIndex(nextIndex);\r
+ QString path = QFileDialog::getExistingDirectory(\r
+ this, tr("フォルダを選択"), activeModel()->rootPath());\r
+ if (!path.isEmpty()) {\r
+ activeModel()->setRootPath(path);\r
}\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onCopyFileName\r
///\r
-/// \brief MainWindow::onMoveCursorUp\r
-///\r
-/// カーソルを上に移動します(K)\r
+/// ファイル名をクリップボードにコピーします。\r
///\r
-void MainWindow::onMoveCursorUp()\r
+void MainWindow::onCopyFileName()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::onCopyFileName()";\r
\r
- int row = fp->fileTable()->currentRow();\r
- if (row > 0) {\r
- QModelIndex nextIndex = fp->fileTable()->model()->index(row - 1, 1);\r
- fp->fileTable()->setCurrentIndex(nextIndex);\r
- }\r
+ QClipboard *clipboard = qApp->clipboard();\r
+ clipboard->setText(activeModel()->fileName(focusItemView()->currentIndex()));\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onCopyFilePath\r
///\r
-/// \brief MainWindow::onMoveCursorBegin\r
-///\r
-/// カーソルを先頭に移動します(G)\r
+/// フルパスをクリップボードにコピーします。\r
///\r
-void MainWindow::onMoveCursorBegin()\r
+void MainWindow::onCopyFilePath()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::onCopyFilePath()";\r
\r
- QModelIndex nextIndex = fp->fileTable()->model()->index(0, 1);\r
- fp->fileTable()->setCurrentIndex(nextIndex);\r
+ QClipboard *clipboard = qApp->clipboard();\r
+ clipboard->setText(activeModel()->filePath(focusItemView()->currentIndex()));\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::askOverWrite\r
+/// \param copyMethod 上書き方法\r
+/// \param alias 別名\r
+/// \param srcPath コピー元パス\r
+/// \param tgtPath コピー先パス\r
///\r
-/// \brief MainWindow::onMoveCursorEnd\r
+/// 上書きの処理方法を選択するダイアログを表示します。\r
///\r
-/// カーソルを末尾に移動します(Shift + G)\r
-void MainWindow::onMoveCursorEnd()\r
+void MainWindow::askOverWrite(QString *copyMethod,\r
+ QString *alias,\r
+ const QString &srcPath,\r
+ const QString &tgtPath)\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
+ qDebug() << "MainWindow::askOverWrite()";\r
+\r
+ CopyMoveWorker *worker = static_cast<CopyMoveWorker*>(sender());\r
+ if (!m_overwriteDialog.isKeepSetting() ||\r
+ m_overwriteDialog.copyMethod() == "rbRename")\r
+ {\r
+ m_overwriteDialog.setFileInfo(srcPath, tgtPath);\r
+ if (m_overwriteDialog.exec() == QDialog::Rejected) {\r
+ worker->abort();\r
+ }\r
}\r
+ *copyMethod = m_overwriteDialog.copyMethod();\r
+ *alias = m_overwriteDialog.alias();\r
\r
- int row = fp->fileTable()->rowCount() - 1;\r
- QModelIndex nextIndex = fp->fileTable()->model()->index(row, 1);\r
- fp->fileTable()->setCurrentIndex(nextIndex);\r
+ worker->endAsking();\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onAddBookmark\r
///\r
-/// \brief MainWindow::onMoveBack\r
-///\r
-/// 前の履歴に戻ります(Alt + ←)\r
+/// ブックマークを追加します。\r
///\r
-void MainWindow::onMoveBack()\r
+void MainWindow::onAddBookmark()\r
{\r
- QMessageBox::information(this, tr("情報"), tr("履歴機能は未実装です。"));\r
-}\r
+ qDebug() << "MainWindow::onAddBookmark()";\r
+ qDebug() << sender()->objectName();\r
\r
-///\r
-/// \brief MainWindow::onMoveForward\r
-///\r
-/// 次の履歴に進みます(Alt + →)\r
-///\r
-void MainWindow::onMoveForward()\r
-{\r
- QMessageBox::information(this, tr("情報"), tr("履歴機能は未実装です。"));\r
+ FolderModel *m;\r
+ if (sender()->objectName() == "bookmarkBtn") {\r
+ FolderPanel *p = static_cast<FolderPanel*>(sender()->parent());\r
+ m = p->model();\r
+ }\r
+ else {\r
+ m = activeModel();\r
+ }\r
\r
+ QFileInfo fi(m->rootPath());\r
+ Preferences(this).addBookmark(fi.fileName(), fi.absoluteFilePath());\r
+ initBookmarkMenu();\r
+\r
+ activePanel()->folderPanel()->itemView()->setFocus();\r
+ statusBar()->showMessage(tr("%1をブックマークに追加しました").arg(fi.absoluteFilePath()));\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::view_copyAvailable\r
+/// \param yes コピー可能ならtrue\r
///\r
-/// \brief MainWindow::onMoveHome\r
-///\r
-/// ホームフォルダに移動します(H)\r
+/// 選択範囲の有無をメニューに反映します。\r
///\r
-void MainWindow::onMoveHome()\r
+void MainWindow::view_copyAvailable(bool yes)\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
- }\r
-\r
- fp->setCurrentFolder(QDir::homePath());\r
+ ui->text_Copy->setEnabled(yes);\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::copyItems\r
+/// \param list コピー元リスト\r
+/// \param tgtDir コピー先フォルダ\r
///\r
-/// \brief MainWindow::onMoveJump\r
+/// アイテムをコピーします。\r
///\r
-/// フォルダを選択して移動します(Shift + J)\r
-void MainWindow::onMoveJump()\r
+void MainWindow::copyItems(const QStringList &list, const QString &tgtDir)\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
+ qDebug() << "MainWindow::copyItems()" << tgtDir;\r
+\r
+ Preferences prefs(this);\r
+ if (prefs.isConfirmCopy() &&\r
+ QMessageBox::question(this, tr("確認"), tr("コピーを実行しますか?"))\r
+ != QMessageBox::Yes)\r
+ {\r
return;\r
}\r
\r
- QString path = QFileDialog::getExistingDirectory(\r
- this,\r
- tr("フォルダを選択"),\r
- fp->dir()->absolutePath());\r
- if (!path.isEmpty()) {\r
- fp->setCurrentFolder(path);\r
- }\r
-}\r
+ // 上書き確認ダイアログを初期化する\r
+ m_overwriteDialog.reset();\r
\r
-///\r
-/// \brief MainWindow::onMoveOther\r
-///\r
-/// キーボードフォーカスを他方のパネルに移動します(TAB)\r
-///\r
-void MainWindow::onMoveOther()\r
-{\r
- FolderPanel *fp = this->inactivePanel();\r
- if (fp) {\r
- fp->fileTable()->setFocus();\r
- }\r
+ // ワーカースレッドを作成する\r
+ CopyMoveWorker *worker = new CopyMoveWorker();\r
+ connect(worker, SIGNAL(askOverWrite(QString*,QString*,QString,QString)),\r
+ this, SLOT(askOverWrite(QString*,QString*,QString,QString)));\r
+ worker->setCopyList(list);\r
+ worker->setTargetDir(tgtDir);\r
+ worker->setMoveMode(false);\r
+\r
+ // 進捗ダイアログを表示して、処理を開始する\r
+ OperationDialog opDlg(this);\r
+ opDlg.setWindowTitle(tr("コピー"));\r
+ opDlg.setWorker(worker);\r
+ opDlg.setAutoClose(prefs.isAutoCloseCopy());\r
+\r
+ opDlg.exec();\r
+\r
+ prefs.setAutoCloseCopy(opDlg.autoClose());\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::moveItems\r
+/// \param list 移動元リスト\r
+/// \param tgtDir 移動先フォルダ\r
///\r
-/// \brief MainWindow::onMoveParent\r
-///\r
-/// 親フォルダに移動します(Backspace)\r
+/// アイテムを移動します。\r
///\r
-void MainWindow::onMoveParent()\r
+void MainWindow::moveItems(const QStringList &list, const QString &tgtDir)\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
+ qDebug() << "MainWindow::moveItems()" << tgtDir;\r
+\r
+ Preferences prefs(this);\r
+ if (prefs.isConfirmMove() &&\r
+ QMessageBox::question(this, tr("確認"), tr("移動を実行しますか?"))\r
+ != QMessageBox::Yes)\r
+ {\r
return;\r
}\r
\r
- if (!fp->dir()->isRoot()) {\r
- QString path = fp->dir()->absoluteFilePath("..");\r
- fp->setCurrentFolder(path);\r
- }\r
+ // 上書き確認ダイアログを初期化する\r
+ m_overwriteDialog.reset();\r
+\r
+ // ワーカースレッドを作成する\r
+ CopyMoveWorker *worker = new CopyMoveWorker();\r
+ connect(worker, SIGNAL(askOverWrite(QString*,QString*,QString,QString)),\r
+ this, SLOT(askOverWrite(QString*,QString*,QString,QString)));\r
+ worker->setCopyList(list);\r
+ worker->setTargetDir(tgtDir);\r
+ worker->setMoveMode(true);\r
+\r
+ // 進捗ダイアログを表示して、処理を開始する\r
+ OperationDialog opDlg(this);\r
+ opDlg.setWindowTitle(tr("移動"));\r
+ opDlg.setWorker(worker);\r
+ opDlg.setAutoClose(prefs.isAutoCloseMove());\r
+\r
+ opDlg.exec();\r
+\r
+ prefs.setAutoCloseMove(opDlg.autoClose());\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onContextMenuEvent\r
+/// \param obj イベントが発生したオブジェクト\r
+/// \param e コンテキストメニューイベント\r
+/// \return 処理した場合はtrue, 処理しなかった場合はfalseを返します。\r
///\r
-/// \brief MainWindow::onMoveRoot\r
-///\r
-/// ルートフォルダに移動します()\r
-void MainWindow::onMoveRoot()\r
+bool MainWindow::onContextMenuEvent(QObject *obj, QContextMenuEvent *e)\r
{\r
- FolderPanel *fp = activePanel();\r
- if (fp == NULL) {\r
- return;\r
+ QMenu menu(this);\r
+ if (obj->objectName() == "textView") {\r
+ menu.addAction(ui->text_ConvertFromEUC);\r
+ menu.addAction(ui->text_ConvertFromJIS);\r
+ menu.addAction(ui->text_ConvertFromSJIS);\r
+ menu.addAction(ui->text_ConvertFromUTF8);\r
+ menu.addAction(ui->text_ConvertFromUTF16);\r
+ menu.addAction(ui->text_ConvertFromUTF16BE);\r
+ menu.addAction(ui->text_ConvertFromUTF16LE);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->text_Copy);\r
+ if (m_viewMode == ModeView) {\r
+ menu.addSeparator();\r
+ menu.addAction(ui->view_Back);\r
+ }\r
}\r
-\r
- if (!fp->dir()->isRoot()) {\r
- fp->setCurrentFolder(QDir::rootPath());\r
+ else if (obj->objectName() == "imageView") {\r
+ menu.addAction(ui->image_FitToWindow);\r
+ menu.addAction(ui->action_ScaleDown);\r
+ menu.addAction(ui->action_ScaleUp);\r
+ menu.addAction(ui->image_ScaleNormal);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->image_Rotate90);\r
+ menu.addAction(ui->image_Rotate180);\r
+\r
+ if (m_viewMode == ModeView) {\r
+ menu.addSeparator();\r
+ menu.addAction(ui->view_Back);\r
+ }\r
+ }\r
+ else if (obj->objectName() == "folderView" || obj->objectName() == "thumbnailView") {\r
+ menu.addAction(ui->action_OpenWith);\r
+ menu.addAction(ui->action_OpenEditor);\r
+ menu.addAction(ui->action_OpenTerminal);\r
+ menu.addAction(ui->action_OpenArchiver);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->action_Copy);\r
+ menu.addAction(ui->action_Move);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->action_Delete);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->action_CopyFileName);\r
+ menu.addAction(ui->action_CopyFilePath);\r
+ menu.addSeparator();\r
+ menu.addAction(ui->action_Rename);\r
+ }\r
+ else {\r
+ qDebug() << "No context menu" << obj->objectName();\r
+ return false;\r
}\r
-}\r
\r
-///\r
-/// \brief MainWindow::onViewFromOther\r
-///\r
-/// 隣のパネルと同じフォルダを表示します(O)\r
-///\r
-void MainWindow::onViewFromOther()\r
-{\r
- FolderPanel *fp1 = activePanel();\r
- FolderPanel *fp2 = inactivePanel();\r
- if (fp1 == NULL || fp2 == NULL) {\r
- return;\r
+ QAction *selected = menu.exec(e->globalPos());\r
+ if (selected == ui->action_ScaleDown || selected == ui->action_ScaleUp) {\r
+ ui->image_FitToWindow->blockSignals(true);\r
+ ui->image_FitToWindow->setChecked(false);\r
+ ui->image_FitToWindow->blockSignals(false);\r
}\r
\r
- fp1->setCurrentFolder(fp2->dir()->absolutePath());\r
+ return true;\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onKeyPressEvent\r
+/// \param obj イベントが発生したオブジェクト\r
+/// \param e キーイベントオブジェクト\r
+/// \return 処理した場合はtrue, 処理しなかった場合はfalseを返します。\r
///\r
-/// \brief MainWindow::onViewToOther\r
-///\r
-/// 隣のパネルに同じフォルダを表示します(Shift + O)\r
-///\r
-void MainWindow::onViewToOther()\r
+bool MainWindow::onKeyPressEvent(QObject *obj, QKeyEvent *e)\r
{\r
- FolderPanel *fp1 = activePanel();\r
- FolderPanel *fp2 = inactivePanel();\r
- if (fp1 == NULL || fp2 == NULL) {\r
- return;\r
+ qDebug() << "MainWindow::onKeyPressEvent()";\r
+\r
+ QString modifier = QString::null;\r
+ if (e->modifiers() & Qt::ShiftModifier) { modifier += "Shift+"; }\r
+ if (e->modifiers() & Qt::ControlModifier) { modifier += "Ctrl+"; }\r
+ if (e->modifiers() & Qt::AltModifier) { modifier += "Alt+"; }\r
+ if (e->modifiers() & Qt::MetaModifier) { modifier += "Meta+"; }\r
+\r
+ QString key = modifier + QKeySequence(e->key()).toString();\r
+\r
+ foreach (QAction *action, findChildren<QAction*>()) {\r
+ if (action->isEnabled()) {\r
+ foreach (const QKeySequence &ks, action->shortcuts()) {\r
+ if (ks.toString() == key) {\r
+ qDebug() << "emit" << action->objectName();\r
+ if (action->isCheckable()) {\r
+ action->toggle();\r
+ }\r
+ else {\r
+ action->trigger();\r
+ }\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if (obj->objectName() == "folderView" || obj->objectName() == "thumbnailView")\r
+ {\r
+ // カーソル移動系のみ有効にする\r
+ switch (e->key()) {\r
+ case Qt::Key_Down:\r
+ case Qt::Key_Up:\r
+ case Qt::Key_Left:\r
+ case Qt::Key_Right:\r
+ case Qt::Key_Home:\r
+ case Qt::Key_End:\r
+ case Qt::Key_PageDown:\r
+ case Qt::Key_PageUp:\r
+ case Qt::Key_Tab:\r
+ return false;\r
+ }\r
+ return true;\r
}\r
\r
- fp2->setCurrentFolder(fp1->dir()->absolutePath());\r
+ return false;\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onCopy\r
///\r
-/// \brief MainWindow::onViewHidden\r
+/// 選択アイテムを隣のパネルにコピーします。\r
///\r
-/// 隠しファイルの表示/非表示を切り替えます(Shift + H)\r
-void MainWindow::onViewHidden()\r
+void MainWindow::onCopy()\r
{\r
- QSettings settings;\r
- bool checked = !settings.value("Common/ShowHidden", false).toBool();\r
- settings.setValue("Common/ShowHidden", checked);\r
+ qDebug() << "MainWindow::onCopy";\r
\r
- if (checked) {\r
- ui->folderPanel_L->dir()->setFilter(ui->folderPanel_L->dir()->filter() | QDir::Hidden);\r
- ui->folderPanel_R->dir()->setFilter(ui->folderPanel_R->dir()->filter() | QDir::Hidden);\r
+ QStringList list;\r
+ foreach (const QFileInfo &fi, selectedItems()) {\r
+ list << fi.absoluteFilePath();\r
}\r
- else {\r
- ui->folderPanel_L->dir()->setFilter(ui->folderPanel_L->dir()->filter() ^ QDir::Hidden);\r
- ui->folderPanel_R->dir()->setFilter(ui->folderPanel_R->dir()->filter() ^ QDir::Hidden);\r
+ if (list.isEmpty()) {\r
+ return;\r
}\r
\r
- ui->folderPanel_L->setCurrentFolder(ui->folderPanel_L->dir()->absolutePath());\r
- ui->folderPanel_R->setCurrentFolder(ui->folderPanel_R->dir()->absolutePath());\r
+ QString tgtPath = inactiveModel()->rootPath();\r
+ copyItems(list, tgtPath);\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onCreateFile\r
///\r
-/// \brief MainWindow::onViewSwap\r
+/// ファイルを作成します。\r
///\r
-/// パネルの表示内容を交換します(W)\r
-///\r
-void MainWindow::onViewSwap()\r
+void MainWindow::onCreateFile()\r
{\r
- FolderPanel *fp1 = activePanel();\r
- FolderPanel *fp2 = inactivePanel();\r
- if (fp1 == NULL || fp2 == NULL) {\r
+ qDebug() << "MainWindow::onCreateFile";\r
+\r
+ bool bOk;\r
+ QString name = QInputDialog::getText(\r
+ this, tr("ファイルを作成"), tr("ファイル名:"),\r
+ QLineEdit::Normal, "", &bOk);\r
+ if (!bOk || name.isEmpty()) {\r
return;\r
}\r
\r
- QString path1 = fp1->dir()->absolutePath();\r
- QString path2 = fp2->dir()->absolutePath();\r
+ QModelIndex index = activeModel()->touch(name);\r
+ if (!index.isValid()) {\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("ファイルの作成に失敗しました。"));\r
+ return;\r
+ }\r
\r
- fp1->setCurrentFolder(path2);\r
- fp2->setCurrentFolder(path1);\r
+ focusItemView()->setCurrentIndex(index);\r
+ if (Preferences(this).isOpenAfterCreation()) {\r
+ onOpenEditor(index);\r
+ }\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onCreateFolder\r
///\r
-/// \brief MainWindow::onCmdMove\r
-///\r
-/// ファイルを移動します(Ctrl + M)\r
+/// フォルダを作成します。\r
///\r
-void MainWindow::onCmdMove()\r
+void MainWindow::onCreateFolder()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
+ qDebug() << "MainWindow::onCreateFolder";\r
+\r
+ bool bOk;\r
+ QString name = QInputDialog::getText(\r
+ this, tr("フォルダを作成"), tr("フォルダ名:"),\r
+ QLineEdit::Normal, "", &bOk);\r
+ if (!bOk || name.isEmpty()) {\r
return;\r
}\r
\r
- QStringList list = selectedItems(fp);\r
- if (list.isEmpty()) {\r
+ QModelIndex index = activeModel()->mkdir(name);\r
+ if (!index.isValid()) {\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("フォルダの作成に失敗しました。"));\r
return;\r
}\r
\r
- CopyMoveWorker *worker = new CopyMoveWorker();\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
- worker->setMoveMode(true);\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
+ focusItemView()->setCurrentIndex(index);\r
+ if (Preferences(this).isMoveAfterCreation()) {\r
+ onOpen(index);\r
+ }\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onDelete\r
///\r
-/// \brief MainWindow::onCmdCopy\r
+/// 選択アイテムを削除します。\r
///\r
-/// ファイルをコピーします(Ctrl + C)\r
-///\r
-void MainWindow::onCmdCopy()\r
+void MainWindow::onDelete()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::onDelete";\r
\r
- QStringList list = selectedItems(fp);\r
+ QFileInfoList list = selectedItems();\r
if (list.isEmpty()) {\r
return;\r
}\r
\r
- CopyMoveWorker *worker = new CopyMoveWorker();\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
- worker->setMoveMode(false);\r
+ Preferences prefs(this);\r
+ if (prefs.isConfirmDelete()) {\r
+ QString msg;\r
+ if (list.size() == 1) {\r
+ msg = list[0].fileName();\r
+ }\r
+ else {\r
+ msg = tr("%1個のアイテム").arg(list.size());\r
+ }\r
+ int ret = QMessageBox::question(\r
+ this, tr("確認"),\r
+ tr("%1を削除しますか?").arg(msg));\r
+ if (ret != QMessageBox::Yes) {\r
+ return;\r
+ }\r
+ }\r
+\r
+ DeleteWorker *worker = new DeleteWorker();\r
+ worker->setDeleteList(list);\r
\r
OperationDialog opDlg(this);\r
- opDlg.setWindowTitle(tr("コピー"));\r
+ opDlg.setWindowTitle(tr("削除"));\r
opDlg.setWorker(worker);\r
+ opDlg.setAutoClose(prefs.isAutoCloseDelete());\r
+\r
+// int row = focusItemView()->currentIndex().row();\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
+// if (row >= activeModel()->rowCount()) {\r
+// row = activeModel()->rowCount() - 1;\r
+// }\r
+// focusItemView()->setCurrentIndex(activeModel()->index(row, 1));\r
+\r
+ prefs.setAutoCloseDelete(opDlg.autoClose());\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onOpen\r
+/// \param index (使用しません)\r
///\r
-/// \brief MainWindow::onAskOverWrite\r
-/// \param bOk\r
-/// \param prevCopyMethod\r
-/// \param copyMethod\r
-/// \param alias\r
-/// \param srcPath\r
-/// \param tgtPath\r
+/// アイテムを開きます。\r
///\r
-/// 上書き処理の方法をユーザに問い合わせます\r
-///\r
-void MainWindow::onAskOverWrite(bool *bOk, int *prevCopyMethod, int *copyMethod,\r
- QString *alias, const QString srcPath,\r
- const QString tgtPath)\r
+void MainWindow::onOpen(const QModelIndex &index)\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
+ Q_UNUSED(index);\r
+ qDebug() << "MainWindow::onOpen()" << index;\r
+\r
+ QModelIndex current = focusItemView()->currentIndex();\r
+ if (activeModel()->isDir(current)) {\r
+ activeModel()->setRootPath(activeModel()->filePath(current));\r
+ return;\r
}\r
- else {\r
- *prevCopyMethod = dlg.copyMethod();\r
- if (dlg.isSameMethodChecked()) {\r
- *copyMethod = *prevCopyMethod;\r
+\r
+ // 外部アプリを優先する場合\r
+ QString ext = activeModel()->fileInfo(current).suffix().toLower();\r
+ QStringList list = Preferences(this).getPreferExtensions().split(",", QString::SkipEmptyParts);\r
+ foreach (const QString& s, list) {\r
+ if (ext == s.trimmed().toLower()) {\r
+ QString path = QDir::toNativeSeparators(activeModel()->filePath(current));\r
+ QDesktopServices::openUrl(QUrl("file:///" + path));\r
+ return;\r
}\r
- *alias = dlg.alias();\r
- *bOk = true;\r
}\r
- CopyMoveWorker *worker = static_cast<CopyMoveWorker*>(sender());\r
- worker->endAsking();\r
+\r
+ // 内蔵ビューアで表示する\r
+ setViewMode(ModeView);\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onOpenEditor\r
+/// \param path\r
///\r
-/// \brief MainWindow::onCmdDelete\r
+/// 選択アイテムを外部エディタで開きます。\r
///\r
-/// ファイルを削除します\r
-///\r
-void MainWindow::onCmdDelete()\r
+void MainWindow::onOpenEditor(const QModelIndex &index)\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::onOpenEditor";\r
\r
- QStringList list = selectedItems(fp);\r
- if (list.isEmpty()) {\r
+ QString exe = Preferences(this).getEditorPath();\r
+ if (exe.isEmpty()) {\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("外部エディタのパスが未定義です。"));\r
return;\r
}\r
\r
- QString msg;\r
- if (list.size() == 1) {\r
- msg = QFileInfo(list.at(0)).fileName();\r
+ QFileInfoList list;\r
+ if (index.isValid()) {\r
+ list << activeModel()->fileInfo(index);\r
}\r
else {\r
- msg = tr("%1個のアイテム").arg(list.size());\r
+ list = selectedItems();\r
}\r
- int ret = QMessageBox::question(\r
- this,\r
- tr("確認"),\r
- msg + tr("を削除します<br/>よろしいですか?"));\r
- if (ret == QMessageBox::Yes) {\r
- DeleteWorker *worker = new DeleteWorker();\r
- worker->setDeleteList(&list);\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
+ QString files;\r
+ foreach (const QFileInfo &info, list) {\r
+ files += " " + QQ(info.absoluteFilePath());\r
+ }\r
+#ifdef Q_OS_MAC\r
+ QString command = "open -a " + exe + files;\r
+#else\r
+ QString command = exe + files;\r
+#endif\r
+ if (!startProcess(command, tr("外部エディタの起動に失敗しました。"))) {\r
+ qDebug() << command;\r
}\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onOpenTerminal\r
///\r
-/// \brief MainWindow::onCmdNewFile\r
+/// 選択アイテムをターミナルで開きます。\r
///\r
-/// ファイルを作成します\r
-///\r
-void MainWindow::onCmdNewFile()\r
+void MainWindow::onOpenTerminal()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
+ qDebug() << "MainWindow::onOpenTerminal";\r
+\r
+ QString exe = Preferences(this).getTerminalPath();\r
+ if (exe.isEmpty()) {\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("ターミナルのパスが未定義です。"));\r
return;\r
}\r
\r
- bool bOk;\r
- QString name = QInputDialog::getText(\r
- this,\r
- tr("ファイルを作成"),\r
- tr("ファイル名"),\r
- QLineEdit::Normal,\r
- "",\r
- &bOk);\r
- if (bOk && !name.isEmpty()) {\r
- QFile file(fp->dir()->absoluteFilePath(name));\r
- if (!file.open(QIODevice::WriteOnly)) {\r
- QMessageBox::critical(this,\r
- tr("エラー"),\r
- tr("ファイルの作成に失敗しました。"));\r
+ QSet<QString> dirs;\r
+ foreach (const QFileInfo &info, selectedItems()) {\r
+ if (info.isDir()) {\r
+ dirs.insert(info.absoluteFilePath());\r
}\r
else {\r
- file.close();\r
+ dirs.insert(info.absolutePath());\r
+ }\r
+ }\r
+\r
+ foreach (const QString &dir, dirs) {\r
+#ifdef Q_OS_MAC\r
+ QString command = "open -n -a " + exe + " " + QQ(dir);\r
+#else\r
+ QString command = exe + " " + QQ(dir);\r
+#endif\r
+ if (!startProcess(command, tr("ターミナルの起動に失敗しました。"))) {\r
+ qDebug() << command;\r
+ break;\r
}\r
}\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onOpenArchiver\r
///\r
-/// \brief MainWindow::onCmdNewFolder\r
-///\r
-/// フォルダを作成します\r
+/// 選択アイテムをアーカイバで開きます。\r
///\r
-void MainWindow::onCmdNewFolder()\r
+void MainWindow::onOpenArchiver()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
+ qDebug() << "MainWindow::onOpenArchiver";\r
+\r
+ QString exe = Preferences(this).getArchiverPath();\r
+ if (exe.isEmpty()) {\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("アーカイバのパスが未定義です。"));\r
return;\r
}\r
\r
- bool bOk;\r
- QString name = QInputDialog::getText(\r
- this,\r
- tr("フォルダを作成"),\r
- tr("フォルダ名"),\r
- QLineEdit::Normal,\r
- "",\r
- &bOk);\r
- if (bOk && !name.isEmpty()) {\r
- if (!fp->dir()->mkpath(name)) {\r
- QMessageBox::critical(this,\r
- tr("エラー"),\r
- tr("フォルダの作成に失敗しました。"));\r
- }\r
+ QString files;\r
+ foreach (const QFileInfo &info, selectedItems()) {\r
+ files += " " + QQ(info.absoluteFilePath());\r
+ }\r
+#ifdef Q_OS_MAC\r
+ QString command = "open -a " + exe + files;\r
+#else\r
+ QString command = exe + files;\r
+#endif\r
+ if (!startProcess(command, tr("アーカイバの起動に失敗しました。"))) {\r
+ qDebug() << command;\r
}\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onOpenBookmark\r
///\r
-/// \brief MainWindow::onCmdRename\r
+/// ブックマークのメニュー項目をクリックしたときの処理を行います。\r
///\r
-/// 名前を変更します\r
+void MainWindow::onOpenBookmark()\r
+{\r
+ qDebug() << "MainWindow::onOpenBookmark()";\r
+\r
+ QAction *action = qobject_cast<QAction*>(sender());\r
+ Q_CHECK_PTR(action);\r
+\r
+ int i = action->data().toInt();\r
+ activeModel()->setRootPath(Preferences(this).getBookmarkPath(i));\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onRename\r
+///\r
+/// 選択アイテムの名前を変更します。\r
///\r
-void MainWindow::onCmdRename()\r
+void MainWindow::onRename()\r
{\r
- FolderPanel *fp = activePanel();\r
- if (!fp) {\r
- return;\r
- }\r
+ qDebug() << "MainWindow::onRename";\r
\r
- QStringList list = selectedItems(fp);\r
+ QFileInfoList list = selectedItems();\r
if (list.isEmpty()) {\r
return;\r
}\r
\r
- IRenameDialog *dlg;\r
+ AbstractRenameDialog *dlg;\r
if (list.size() == 1) {\r
dlg = new RenameSingleDialog(this);\r
}\r
else {\r
dlg = new RenameMultiDialog(this);\r
}\r
- dlg->setWorkingDirectory(fp->dir()->absolutePath());\r
+ dlg->setWorkingDirectory(activeModel()->rootPath());\r
dlg->setNames(list);\r
int dlgResult = dlg->exec();\r
- if (dlgResult == QDialog::Accepted && !dlg->renameMap().isEmpty()) {\r
- RenameWorker *worker = new RenameWorker();\r
- worker->setRenameMap(&dlg->renameMap());\r
+ if (dlgResult != QDialog::Accepted || dlg->renameMap().isEmpty()) {\r
+ return;\r
+ }\r
+\r
+ Preferences prefs(this);\r
+ if (prefs.isConfirmRename() &&\r
+ QMessageBox::question(this, tr("確認"), tr("名前の変更を実行しますか?"))\r
+ != QMessageBox::Yes)\r
+ {\r
+ return;\r
+ }\r
+\r
+ RenameWorker *worker = new RenameWorker();\r
+ worker->setRenameMap(&dlg->renameMap());\r
+\r
+ OperationDialog opDlg(this);\r
+ opDlg.setWindowTitle(tr("名前を変更"));\r
+ opDlg.setWorker(worker);\r
+ opDlg.setAutoClose(prefs.isAutoCloseRename());\r
+\r
+ opDlg.exec();\r
\r
- OperationDialog opDlg(this);\r
- opDlg.setWindowTitle(tr("名前を変更"));\r
- opDlg.setWorker(worker);\r
+ QFileInfo fi(dlg->renameMap().first());\r
+ focusItemView()->setCurrentIndex(activeModel()->search(fi.fileName()));\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
+ prefs.setAutoCloseRename(opDlg.autoClose());\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onOpenWith\r
+///\r
+/// 関連付けられたアプリで開きます。\r
+///\r
+void MainWindow::onOpenWith()\r
+{\r
+ qDebug() << "MainWindow::onOpenWith";\r
+\r
+ foreach (const QFileInfo &info, selectedItems()) {\r
+ QString path = QDir::toNativeSeparators(info.absoluteFilePath());\r
+ QDesktopServices::openUrl(QUrl("file:///" + path));\r
}\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::showBookmarkDialog\r
///\r
-/// \brief MainWindow::onHelpAbout\r
+/// ブックマーク一覧ダイアログを表示します。\r
+///\r
+void MainWindow::showBookmarkDialog()\r
+{\r
+ qDebug() << "MainWindow::showBookmarkDialog()";\r
+\r
+ BookmarkDialog dlg(this);\r
+ dlg.setEditMode(false);\r
+ if (dlg.exec() == QDialog::Accepted) {\r
+ int n = dlg.selectedIndex();\r
+ activeModel()->setRootPath(Preferences(this).getBookmarkPath(n + 1));\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onEditBookmark\r
///\r
-/// ã\82¢ã\83\97ã\83ªã\82±ã\83¼ã\82·ã\83§ã\83³ã\81®æ¦\82è¦\81ã\82\92表示ã\81\97ã\81¾ã\81\99(?)\r
+/// ã\83\96ã\83\83ã\82¯ã\83\9eã\83¼ã\82¯ã\81®ç·¨é\9b\86ã\83\80ã\82¤ã\82¢ã\83ã\82°ã\82\92表示ã\81\97ã\81¾ã\81\99ã\80\82\r
///\r
-void MainWindow::onHelpAbout()\r
+void MainWindow::onEditBookmark()\r
{\r
- QMessageBox::about(\r
- this,\r
- tr("げふぅ について"),\r
- tr("<h3>Gefu Ver%1</h3>").arg(VERSION_VALUE) +\r
- tr("<center>Gefu is Experimental File Utility.<br/>"\r
- "(げふぅは実験的なファイルユーティリティです)</center>"\r
- "<p>Copyright 2014 @miyabi_satoh All rights reserved.</p>"));\r
+ qDebug() << "MainWindow::onEditBookmark()";\r
+\r
+ BookmarkDialog dlg(this);\r
+ dlg.setEditMode(true);\r
+\r
+ if (dlg.exec() == QDialog::Accepted) {\r
+ initBookmarkMenu();\r
+ }\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::showFilterDialog\r
///\r
-/// \brief MainWindow::selectedItems\r
-/// \param fp フォルダパネルへのポインタ\r
-/// \return 選択アイテムのフルパスのリスト\r
+/// フィルタ設定ダイアログを表示します。\r
///\r
-/// 選択アイテムのフルパスのリストを取得します\r
+void MainWindow::showFilterDialog()\r
+{\r
+ qDebug() << "MainWindow::showFilterDialog()";\r
+\r
+ QString filters = activeModel()->nameFilters().join(" ");\r
+\r
+ QInputDialog dlg(this);\r
+ dlg.setInputMode(QInputDialog::TextInput);\r
+ dlg.setWindowTitle(tr("フィルタを設定"));\r
+ dlg.setLabelText(tr("フィルタ:"));\r
+ dlg.setTextValue(filters);\r
+ dlg.resize(width() * 0.8, dlg.height());\r
+\r
+ if (dlg.exec() == QDialog::Accepted) {\r
+ filters = dlg.textValue();\r
+ if (filters.isEmpty()) {\r
+ filters = "*";\r
+ }\r
+\r
+ activeModel()->setNameFilters(filters.split(" ", QString::SkipEmptyParts));\r
+ activeModel()->refresh();\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::showHistoryDialog\r
+///\r
+/// 履歴選択ダイアログを表示します。\r
///\r
-QStringList MainWindow::selectedItems(FolderPanel *fp)\r
+void MainWindow::showHistoryDialog()\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
+ qDebug() << "MainWindow::showHistoryDialog()";\r
+\r
+ HistoryDialog dlg(this);\r
+ dlg.setModel(ui->LPanel->model(), ui->RPanel->model(), activeModel());\r
+ dlg.exec();\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::showSortDialog\r
+///\r
+/// ソート方法選択ダイアログを表示します。\r
+///\r
+void MainWindow::showSortDialog()\r
+{\r
+ qDebug() << "MainWindow::showSortDialog()";\r
+\r
+ SortDialog dlg(this);\r
+ dlg.setModel(activeModel());\r
+ dlg.exec();\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onSplitCenter\r
+///\r
+/// パネルを中央で分割します。\r
+///\r
+void MainWindow::onSplitCenter()\r
+{\r
+ qDebug() << "MainWindow::onSplitCenter()";\r
+\r
+ QList<int> sizes = ui->splitter->sizes();\r
+ int sizeTotal = sizes[0] + sizes[1];\r
+ sizes[0] = sizeTotal / 2;\r
+ sizes[1] = sizeTotal - sizes[0];\r
+ ui->splitter->setSizes(sizes);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onSwap\r
+///\r
+/// 左右のパネルでモデルを入れ替えます。\r
+///\r
+void MainWindow::onSwap()\r
+{\r
+ qDebug() << "MainWindow::onSwap()";\r
+\r
+ FolderModel *tmp = ui->LPanel->model();\r
+ ui->LPanel->setModel(ui->RPanel->model());\r
+ ui->RPanel->setModel(tmp);\r
+\r
+ // アクティブ状態も変更する\r
+ if (ui->LPanel->model()->isActive()) {\r
+ setActiveModel(ui->RPanel->model());\r
+ }\r
+ else {\r
+ setActiveModel(ui->LPanel->model());\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onTogglePreviewMode\r
+/// \param checked メニューのチェック状態\r
+///\r
+/// 通常モード/プレビューモードを切り替えます。\r
+///\r
+void MainWindow::onTogglePreviewMode(bool checked)\r
+{\r
+ qDebug() << "MainWindow::onTogglePreviewMode()" << checked;\r
+\r
+ if (checked) {\r
+ setViewMode(ModePreview);\r
+ }\r
+ else {\r
+ setViewMode(ModeBasic);\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onSearchNext\r
+///\r
+/// 次のアイテムを検索します。\r
+///\r
+void MainWindow::onSearchNext()\r
+{\r
+ qDebug() << "MainWindow::onSearchNext";\r
+\r
+ static_cast<FolderPanel*>(qApp->focusWidget()->parentWidget())->searchNext();\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onSearchPrev\r
+///\r
+/// 前のアイテムを検索します。\r
+///\r
+void MainWindow::onSearchPrev()\r
+{\r
+ qDebug() << "MainWindow::onSearchPrev";\r
+\r
+ static_cast<FolderPanel*>(qApp->focusWidget()->parentWidget())->searchNext(-1);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onKeyDown\r
+///\r
+/// フォーカスウィジェットに↓キーイベントを送信します。\r
+///\r
+void MainWindow::onKeyDown()\r
+{\r
+ qDebug() << "MainWindow::onKeyDown()";\r
+\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);\r
+ qApp->sendEvent(qApp->focusWidget(), &event);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onKeyEnd\r
+///\r
+/// フォーカスウィジェットにEND, Ctrl+ENDキーイベントを送信します。\r
+///\r
+void MainWindow::onKeyEnd()\r
+{\r
+ qDebug() << "MainWindow::onKeyEnd()";\r
+\r
+ QKeyEvent event1 = QKeyEvent(QEvent::KeyPress, Qt::Key_End, Qt::NoModifier);\r
+ qApp->sendEvent(qApp->focusWidget(), &event1);\r
+\r
+ QKeyEvent event2 = QKeyEvent(QEvent::KeyPress, Qt::Key_End, Qt::ControlModifier);\r
+ qApp->sendEvent(qApp->focusWidget(), &event2);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onKeyHome\r
+///\r
+/// フォーカスウィジェットにHOME, Ctrl+HOMEキーイベントを送信します。\r
+///\r
+void MainWindow::onKeyHome()\r
+{\r
+ qDebug() << "MainWindow::onKeyHome()";\r
+\r
+ QKeyEvent event1 = QKeyEvent(QEvent::KeyPress, Qt::Key_Home, Qt::NoModifier);\r
+ qApp->sendEvent(qApp->focusWidget(), &event1);\r
+\r
+ QKeyEvent event2 = QKeyEvent(QEvent::KeyPress, Qt::Key_Home, Qt::ControlModifier);\r
+ qApp->sendEvent(qApp->focusWidget(), &event2);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onKeyUp\r
+///\r
+/// フォーカスウィジェットに↑キーイベントを送信します。\r
+///\r
+void MainWindow::onKeyUp()\r
+{\r
+ qDebug() << "MainWindow::onKeyUp()";\r
+\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);\r
+ qApp->sendEvent(qApp->focusWidget(), &event);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onKeyHomeOther\r
+///\r
+/// 非フォーカスビューにHOME, Ctrl+HOMEキーイベントを送信します。\r
+///\r
+void MainWindow::onKeyHomeOther()\r
+{\r
+ qDebug() << "MainWindow::onKeyHomeOther()";\r
+\r
+ QKeyEvent event1 = QKeyEvent(QEvent::KeyPress, Qt::Key_Home, Qt::NoModifier);\r
+ sendEventOther(&event1);\r
+\r
+ QKeyEvent event2 = QKeyEvent(QEvent::KeyPress, Qt::Key_Home, Qt::ControlModifier);\r
+ sendEventOther(&event2);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onKeyDownOther\r
+///\r
+/// 非フォーカスビューに↓キーイベントを送信します。\r
+///\r
+void MainWindow::onKeyDownOther()\r
+{\r
+ qDebug() << "MainWindow::onKeyDownOther()";\r
+\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);\r
+ sendEventOther(&event);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onKeyUpOther\r
+///\r
+/// 非フォーカスビューに↑キーイベントを送信します。\r
+///\r
+void MainWindow::onKeyUpOther()\r
+{\r
+ qDebug() << "MainWindow::onKeyUpOther()";\r
+\r
+ QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier);\r
+ sendEventOther(&event);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onKeyEndOther\r
+///\r
+/// 非フォーカスビューにEND, Ctrl+ENDキーイベントを送信します。\r
+///\r
+void MainWindow::onKeyEndOther()\r
+{\r
+ qDebug() << "MainWindow::onKeyEndOther()";\r
+\r
+ QKeyEvent event1 = QKeyEvent(QEvent::KeyPress, Qt::Key_End, Qt::NoModifier);\r
+ sendEventOther(&event1);\r
+\r
+ QKeyEvent event2 = QKeyEvent(QEvent::KeyPress, Qt::Key_End, Qt::ControlModifier);\r
+ sendEventOther(&event2);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onScaleDown\r
+///\r
+/// 表示を縮小します。\r
+///\r
+void MainWindow::onScaleDown()\r
+{\r
+ qDebug() << "MainWindow::onScaleDown()";\r
+\r
+ AbstractView *view = dynamic_cast<AbstractView*>(qApp->focusWidget());\r
+ if (view) {\r
+ view->scaleDown();\r
+ }\r
+\r
+ Preferences prefs(this);\r
+ if (ui->LPanel->isVisible()) {\r
+ ui->LPanel->updateAppearance(prefs);\r
+ ui->LPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->RPanel->isVisible()) {\r
+ ui->RPanel->updateAppearance(prefs);\r
+ ui->RPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->FPanel->isVisible()) {\r
+ ui->FPanel->updateAppearance(prefs);\r
+ ui->FPanel->model()->updateAppearance(prefs);\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onScaleUp\r
+///\r
+/// 表示を拡大します。\r
+///\r
+void MainWindow::onScaleUp()\r
+{\r
+ qDebug() << "MainWindow::onScaleUp()";\r
+\r
+ AbstractView *view = dynamic_cast<AbstractView*>(qApp->focusWidget());\r
+ if (view) {\r
+ view->scaleUp();\r
+ }\r
+\r
+ Preferences prefs(this);\r
+ if (ui->LPanel->isVisible()) {\r
+ ui->LPanel->updateAppearance(prefs);\r
+ ui->LPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->RPanel->isVisible()) {\r
+ ui->RPanel->updateAppearance(prefs);\r
+ ui->RPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->FPanel->isVisible()) {\r
+ ui->FPanel->updateAppearance(prefs);\r
+ ui->FPanel->model()->updateAppearance(prefs);\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::initBookmarkMenu\r
+///\r
+/// ブックマークメニューを初期化します。\r
+///\r
+void MainWindow::initBookmarkMenu()\r
+{\r
+ qDebug() << "MainWindow::initBookmarkMenu()";\r
+\r
+ Preferences prefs(this);\r
+ QFileIconProvider iconProvider;\r
+\r
+ ui->menu_Bookmark->clear();\r
+ ui->menu_Bookmark->addAction(ui->action_AddBookmark);\r
+ ui->menu_Bookmark->addAction(ui->action_EditBookmark);\r
+ ui->menu_Bookmark->addSeparator();\r
+ for (int n = 1; ; n++) {\r
+ QString name = prefs.getBookmarkEntry(n);\r
+ if (name.isEmpty()) {\r
+ break;\r
}\r
+ QString path = prefs.getBookmarkPath(n);\r
+\r
+ QAction *action = ui->menu_Bookmark->addAction(\r
+ iconProvider.icon(QFileInfo(path)), name, this,\r
+ SLOT(onOpenBookmark()));\r
+ action->setData(n);\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
+ m_actions = findChildren<QAction*>();\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::sendEventOther\r
+/// \param event 送信するイベント\r
+///\r
+/// 非フォーカスのビューにイベントを送信します。\r
+///\r
+void MainWindow::sendEventOther(QEvent *event)\r
+{\r
+ qDebug() << "MainWindow::sendEventOther()";\r
+\r
+ // フォーカスを持たない、可視状態のビューを検索する\r
+ foreach (QWidget *w, findChildren<QWidget*>()) {\r
+ AbstractView *view = dynamic_cast<AbstractView*>(w);\r
+ if (view) {\r
+ if (w->isVisible() && !w->hasFocus()) {\r
+ qDebug() << "Send event to" << w->objectName();\r
+ qApp->sendEvent(w, event);\r
+ }\r
}\r
}\r
+}\r
\r
- return list;\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onSyncPanel\r
+///\r
+/// 隣のパネルと同じフォルダを表示します。\r
+///\r
+void MainWindow::onSyncPanel()\r
+{\r
+ qDebug() << "MainWindow::onSyncPanel()";\r
+\r
+ activeModel()->setRootPath(inactiveModel()->rootPath());\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onSyncPanelTo\r
+///\r
+/// 隣のパネルに同じフォルダを表示します。\r
+///\r
+void MainWindow::onSyncPanelTo()\r
+{\r
+ qDebug() << "MainWindow::onSyncPanelTo()";\r
+\r
+ inactiveModel()->setRootPath(activeModel()->rootPath());\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onToggleFullMode\r
+/// \param checked メニューのチェック状態\r
+///\r
+/// 単画面/二画面を切り替えます。\r
+///\r
+void MainWindow::onToggleFullMode(bool checked)\r
+{\r
+ qDebug() << "MainWindow::onToggleFullMode()" << checked;\r
+\r
+ if (checked) {\r
+ setViewMode(ModeFull);\r
+ }\r
+ else {\r
+ setViewMode(ModeBasic);\r
+ }\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onToggleSearch\r
+/// \param checked メニューのチェック状態\r
+///\r
+/// 検索ボックスの表示/非表示を切り替えます。\r
+///\r
+void MainWindow::onToggleSearch(bool checked)\r
+{\r
+ qDebug() << "MainWindow::onToggleSearch" << checked;\r
+\r
+ // 丸投げ\r
+ ui->LPanel->folderPanel()->toggleSearch(checked);\r
+ ui->RPanel->folderPanel()->toggleSearch(checked);\r
+ ui->FPanel->folderPanel()->toggleSearch(checked);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::showPreferenceDialog\r
+///\r
+/// 環境設定ダイアログを表示します。\r
+///\r
+void MainWindow::showPreferenceDialog()\r
+{\r
+ qDebug() << "MainWindow::showPreferenceDialog";\r
+\r
+ PreferenceDialog dlg(this);\r
+ if (dlg.exec() == QDialog::Accepted) {\r
+ Preferences prefs(this);\r
+ if (ui->LPanel->isVisible()) {\r
+ ui->LPanel->updateAppearance(prefs);\r
+ ui->LPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->RPanel->isVisible()) {\r
+ ui->RPanel->updateAppearance(prefs);\r
+ ui->RPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->FPanel->isVisible()) {\r
+ ui->FPanel->updateAppearance(prefs);\r
+ ui->FPanel->model()->updateAppearance(prefs);\r
+ }\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onToggleHidden\r
+/// \param checked メニューのチェック状態\r
+///\r
+/// 隠しファイルの表示/非表示を切り替えます。\r
+///\r
+void MainWindow::onToggleHidden(bool checked)\r
+{\r
+ qDebug() << "MainWindow::onToggleHidden" << checked;\r
+\r
+ if (checked) {\r
+ activeModel()->setFilter(activeModel()->filter() | QDir::Hidden);\r
+ }\r
+ else {\r
+ activeModel()->setFilter(activeModel()->filter() ^ QDir::Hidden);\r
+ }\r
+\r
+ activeModel()->refresh();\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onToggleSystem\r
+/// \param checked メニューのチェック状態\r
+///\r
+/// システムファイルの表示/非表示を切り替えます。\r
+///\r
+void MainWindow::onToggleSystem(bool checked)\r
+{\r
+ qDebug() << "MainWindow::onToggleSystem" << checked;\r
+\r
+ if (checked) {\r
+ activeModel()->setFilter(activeModel()->filter() | QDir::System);\r
+ }\r
+ else {\r
+ activeModel()->setFilter(activeModel()->filter() ^ QDir::System);\r
+ }\r
+\r
+ activeModel()->refresh();\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onToggleThumbnailMode\r
+/// \param checked メニューのチェック状態\r
+///\r
+/// サムネイルモードの切り替えを行います。\r
+///\r
+void MainWindow::onToggleThumbnailMode(bool checked)\r
+{\r
+ qDebug() << "MainWindow::onToggleThumbnailMode()" << checked;\r
+\r
+ activePanel()->folderPanel()->toggleView(checked);\r
}\r
\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onToggleToolbar\r
+/// \param checked メニューのチェック状態\r
+///\r
+/// ツールバーの表示/非表示を切り替えます。\r
///\r
-/// \brief getMainWnd\r
-/// \return メインウィンドウのポインタ\r
+void MainWindow::onToggleToolbar(bool checked)\r
+{\r
+ ui->mainToolBar->setVisible(checked);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onCheckUpdate\r
+/// \param silent 最新版を使用している場合に何も表示しないならtrue\r
///\r
-/// ã\83¡ã\82¤ã\83³ã\82¦ã\82£ã\83³ã\83\89ã\82¦ã\82\92å\8f\96å¾\97ã\81\97ã\81¾ã\81\99\r
+/// ã\82¢ã\83\83ã\83\97ã\83\87ã\83¼ã\83\88ã\81®æ\9c\89ç\84¡ã\82\92確èª\8dã\81\97ã\81¾ã\81\99ã\80\82\r
///\r
-MainWindow* getMainWnd()\r
+void MainWindow::onCheckUpdate(bool silent)\r
+{\r
+ qDebug() << "MainWindow::onCheckUpdate()" << silent;\r
+\r
+ QNetworkAccessManager *manager = new QNetworkAccessManager(this);\r
+\r
+ if (silent) {\r
+ connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(checkUpdateFinishedSilent(QNetworkReply*)));\r
+ }\r
+ else {\r
+ connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(checkUpdateFinished(QNetworkReply*)));\r
+ }\r
+#ifdef Q_OS_WIN\r
+ manager->get(QNetworkRequest(QUrl("http://gefu.sourceforge.jp/gefu_latest_win.html")));\r
+#elif defined(Q_OS_MAC)\r
+ manager->get(QNetworkRequest(QUrl("http://gefu.sourceforge.jp/gefu_latest_mac.html")));\r
+#endif\r
+}\r
+\r
+void MainWindow::checkUpdateFinishedSilent(QNetworkReply *reply)\r
+{\r
+ qDebug() << "MainWindow::checkUpdateFinishedSilent";\r
+\r
+ checkUpdateFinished(reply, true);\r
+}\r
+\r
+void MainWindow::checkUpdateFinished(QNetworkReply *reply, bool silent)\r
{\r
- foreach (QWidget *w, qApp->topLevelWidgets()) {\r
- if (w->objectName() == "MainWindow") {\r
- return static_cast<MainWindow*>(w);\r
+ qDebug() << "MainWindow::checkUpdateFinished" << silent;\r
+\r
+ if (reply->error() == QNetworkReply::NoError) {\r
+ QString str = reply->readAll();\r
+ str = str.split(QRegExp("[\r\n]"), QString::SkipEmptyParts).at(0);\r
+ QRegExp rx("Gefu([0-9]+)");\r
+ rx.indexIn(str);\r
+ QString version = rx.cap(1);\r
+ if (version.toInt() > VERSION_VALUE * 100) {\r
+ QMessageBox::information(\r
+ this, tr("情報"),\r
+ tr("最新のバージョンが存在します。<br/>") +\r
+ tr("<a href='%1'>こちらからダウンロードしてください。</a>").arg(str));\r
+ }\r
+ else if (!silent) {\r
+ QMessageBox::information(\r
+ this, tr("情報"),\r
+ tr("お使いのバージョンは最新です。"));\r
}\r
}\r
- qDebug() << "MainWindow not found !?";\r
+ else if (!silent){\r
+ QMessageBox::critical(\r
+ this, tr("エラー"),\r
+ tr("最新バージョンのチェックに失敗しました。<br/>") +\r
+ reply->errorString());\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::initActions\r
+///\r
+/// アクションを初期化します。\r
+///\r
+void MainWindow::initActions()\r
+{\r
+ qDebug() << "MainWindow::initActions()";\r
+\r
+ QList<QKeySequence> shortcuts;\r
+\r
+ //>>>>> 追加のショートカットキーを設定する\r
+ appendActionShortcut(ui->action_Open, "M");\r
+ appendActionShortcut(ui->action_OpenWith, "Shift+M");\r
+ appendActionShortcut(ui->view_Back, "Backspace");\r
+ // MacだとShift+の形で認識されてしまうもの\r
+ appendActionShortcut(ui->action_ScaleUp, "Shift++");\r
+ appendActionShortcut(ui->action_Filter, "Shift+*");\r
+ appendActionShortcut(ui->action_OpenTerminal, "Shift+>");\r
+ appendActionShortcut(ui->action_About, "Shift+?");\r
+ appendActionShortcut(ui->image_ScaleNormal, "Shift+=");\r
+\r
+ // SIGNAL -> SLOT\r
+ connect(ui->action_About, SIGNAL(triggered()), this, SLOT(onAbout()));\r
+ connect(ui->action_AddBookmark, SIGNAL(triggered()), this, SLOT(onAddBookmark()));\r
+ connect(ui->action_Cd, SIGNAL(triggered()), this, SLOT(onChooseFolder()));\r
+ connect(ui->action_CheckUpdate, SIGNAL(triggered()), this, SLOT(onCheckUpdate()));\r
+ connect(ui->action_Copy, SIGNAL(triggered()), this, SLOT(onCopy()));\r
+ connect(ui->action_CopyFileName, SIGNAL(triggered()), this, SLOT(onCopyFileName()));\r
+ connect(ui->action_CopyFilePath, SIGNAL(triggered()), this, SLOT(onCopyFilePath()));\r
+ connect(ui->action_CreateFile, SIGNAL(triggered()), this, SLOT(onCreateFile()));\r
+ connect(ui->action_CreateFolder, SIGNAL(triggered()), this, SLOT(onCreateFolder()));\r
+ connect(ui->action_Delete, SIGNAL(triggered()), this, SLOT(onDelete()));\r
+ connect(ui->action_EditBookmark, SIGNAL(triggered()), this, SLOT(onEditBookmark()));\r
+ connect(ui->action_ExpandLeft, SIGNAL(triggered()), this, SLOT(onExpandLeft()));\r
+ connect(ui->action_ExpandRight, SIGNAL(triggered()), this, SLOT(onExpandRight()));\r
+ connect(ui->action_Filter, SIGNAL(triggered()), this, SLOT(showFilterDialog()));\r
+ connect(ui->action_History, SIGNAL(triggered()), this, SLOT(showHistoryDialog()));\r
+ connect(ui->action_KeyDown, SIGNAL(triggered()), this, SLOT(onKeyDown()));\r
+ connect(ui->action_KeyDownOther, SIGNAL(triggered()), this, SLOT(onKeyDownOther()));\r
+ connect(ui->action_KeyEnd, SIGNAL(triggered()), this, SLOT(onKeyEnd()));\r
+ connect(ui->action_KeyEndOther, SIGNAL(triggered()), this, SLOT(onKeyEndOther()));\r
+ connect(ui->action_KeyHome, SIGNAL(triggered()), this, SLOT(onKeyHome()));\r
+ connect(ui->action_KeyHomeOther, SIGNAL(triggered()), this, SLOT(onKeyHomeOther()));\r
+ connect(ui->action_KeyLeft, SIGNAL(triggered()), this, SLOT(onKeyLeft()));\r
+ connect(ui->action_KeyUp, SIGNAL(triggered()), this, SLOT(onKeyUp()));\r
+ connect(ui->action_KeyUpOther, SIGNAL(triggered()), this, SLOT(onKeyUpOther()));\r
+ connect(ui->action_Move, SIGNAL(triggered()), this, SLOT(onMove()));\r
+ connect(ui->action_Open, SIGNAL(triggered()), this, SLOT(onOpen()));\r
+ connect(ui->action_OpenArchiver, SIGNAL(triggered()), this, SLOT(onOpenArchiver()));\r
+ connect(ui->action_OpenEditor, SIGNAL(triggered()), this, SLOT(onOpenEditor()));\r
+ connect(ui->action_OpenTerminal, SIGNAL(triggered()), this, SLOT(onOpenTerminal()));\r
+ connect(ui->action_OpenWith, SIGNAL(triggered()), this, SLOT(onOpenWith()));\r
+ connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(close()));\r
+ connect(ui->action_Rename, SIGNAL(triggered()), this, SLOT(onRename()));\r
+ connect(ui->action_KeyRight, SIGNAL(triggered()), this, SLOT(onKeyRight()));\r
+ connect(ui->action_RunCommand, SIGNAL(triggered()), this, SLOT(onRunCommand()));\r
+ connect(ui->action_ScaleDown, SIGNAL(triggered()), this, SLOT(onScaleDown()));\r
+ connect(ui->action_ScaleUp, SIGNAL(triggered()), this, SLOT(onScaleUp()));\r
+ connect(ui->action_SearchNext, SIGNAL(triggered()), this, SLOT(onSearchNext()));\r
+ connect(ui->action_SearchPrev, SIGNAL(triggered()), this, SLOT(onSearchPrev()));\r
+ connect(ui->action_Setting, SIGNAL(triggered()), this, SLOT(showPreferenceDialog()));\r
+ connect(ui->action_ShowBookmark, SIGNAL(triggered()), this, SLOT(showBookmarkDialog()));\r
+ connect(ui->action_Sort, SIGNAL(triggered()), this, SLOT(showSortDialog()));\r
+ connect(ui->action_SplitCenter, SIGNAL(triggered()), this, SLOT(onSplitCenter()));\r
+ connect(ui->action_Swap, SIGNAL(triggered()), this, SLOT(onSwap()));\r
+ connect(ui->action_SyncPanel, SIGNAL(triggered()), this, SLOT(onSyncPanel()));\r
+ connect(ui->action_SyncPanelTo, SIGNAL(triggered()), this, SLOT(onSyncPanelTo()));\r
+\r
+ connect(ui->toggle_FullMode, SIGNAL(toggled(bool)), this, SLOT(onToggleFullMode(bool)));\r
+ connect(ui->toggle_Hidden, SIGNAL(toggled(bool)), this, SLOT(onToggleHidden(bool)));\r
+ connect(ui->toggle_Mark, SIGNAL(triggered()), this, SLOT(onToggleMark()));\r
+ connect(ui->toggle_PreviewMode, SIGNAL(toggled(bool)), this, SLOT(onTogglePreviewMode(bool)));\r
+ connect(ui->toggle_Search, SIGNAL(toggled(bool)), this, SLOT(onToggleSearch(bool)));\r
+ connect(ui->toggle_System, SIGNAL(toggled(bool)), this, SLOT(onToggleSystem(bool)));\r
+ connect(ui->toggle_ThumbnailMode, SIGNAL(toggled(bool)), this, SLOT(onToggleThumbnailMode(bool)));\r
+ connect(ui->toggle_Toolbar, SIGNAL(toggled(bool)), this, SLOT(onToggleToolbar(bool)));\r
+\r
+ connect(ui->view_Back, SIGNAL(triggered()), this, SLOT(view_finished()));\r
+\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::setActiveModel\r
+/// \param m 新しいアクティブモデル\r
+///\r
+/// アクティブモデルを変更します。\r
+///\r
+void MainWindow::setActiveModel(FolderModel *m)\r
+{\r
+ qDebug() << "MainWindow::setActiveModel()" << m;\r
+\r
+ if (activeModel()) {\r
+ activeModel()->disconnect(this);\r
+ ui->action_CdHome->disconnect();\r
+ ui->action_CdRoot->disconnect();\r
+ ui->action_CdUp->disconnect();\r
+ ui->action_historyBack->disconnect();\r
+ ui->action_HistoryForward->disconnect();\r
+ ui->action_MarkAll->disconnect();\r
+ ui->action_MarkAllFiles->disconnect();\r
+ ui->action_MarkAllOff->disconnect();\r
+ ui->action_MarkInvert->disconnect();\r
+ ui->action_Refresh->disconnect();\r
+ }\r
+\r
+ m->setActive();\r
+\r
+ connect(activeModel(), SIGNAL(modelAboutToBeReset()), this, SLOT(model_PreReset()));\r
+ connect(activeModel(), SIGNAL(modelReset()), this, SLOT(model_PostReset()));\r
+ connect(ui->action_CdHome, SIGNAL(triggered()), activeModel(), SLOT(onCdHome()));\r
+ connect(ui->action_CdRoot, SIGNAL(triggered()), activeModel(), SLOT(onCdRoot()));\r
+ connect(ui->action_CdUp, SIGNAL(triggered()), activeModel(), SLOT(onCdUp()));\r
+ connect(ui->action_historyBack, SIGNAL(triggered()), activeModel(), SLOT(onHistoryBack()));\r
+ connect(ui->action_HistoryForward, SIGNAL(triggered()), activeModel(), SLOT(onHistoryForward()));\r
+ connect(ui->action_MarkAll, SIGNAL(triggered()), activeModel(), SLOT(onMarkAll()));\r
+ connect(ui->action_MarkAllFiles, SIGNAL(triggered()), activeModel(), SLOT(onMarkAllFiles()));\r
+ connect(ui->action_MarkAllOff, SIGNAL(triggered()), activeModel(), SLOT(onMarkAllOff()));\r
+ connect(ui->action_MarkInvert, SIGNAL(triggered()), activeModel(), SLOT(onMarkInvert()));\r
+ connect(ui->action_Refresh, SIGNAL(triggered()), activeModel(), SLOT(refresh()));\r
+\r
+ Preferences prefs(this);\r
+ if (ui->LPanel->isVisible()) {\r
+ ui->LPanel->updateAppearance(prefs);\r
+ ui->LPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->RPanel->isVisible()) {\r
+ ui->RPanel->updateAppearance(prefs);\r
+ ui->RPanel->model()->updateAppearance(prefs);\r
+ }\r
+ if (ui->FPanel->isVisible()) {\r
+ ui->FPanel->updateAppearance(prefs);\r
+ ui->FPanel->model()->updateAppearance(prefs);\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::activeModel\r
+/// \return アクティブなフォルダモデルを返します。\r
+///\r
+FolderModel *MainWindow::activeModel() const\r
+{\r
+ return FolderModel::activeModel();\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::activePanel\r
+/// \return アクティブモデルを所有している可視状態のパネルを返します。\r
+///\r
+Panel *MainWindow::activePanel() const\r
+{\r
+ if (ui->FPanel->model() == activeModel() && ui->FPanel->isVisible()) {\r
+ return ui->FPanel;\r
+ }\r
+ if (ui->LPanel->model() == activeModel() && ui->LPanel->isVisible()) {\r
+ return ui->LPanel;\r
+ }\r
+ if (ui->RPanel->model() == activeModel() && ui->RPanel->isVisible()) {\r
+ return ui->RPanel;\r
+ }\r
+\r
+ qDebug() << ">>>>>>>>>> activePanel() Logic error <<<<<<<<<<";\r
+ return NULL;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::inactiveModel\r
+/// \return 非アクティブなフォルダモデルを返します。\r
+///\r
+FolderModel *MainWindow::inactiveModel() const\r
+{\r
+ if (ui->LPanel->model()->isActive()) {\r
+ return ui->RPanel->model();\r
+ }\r
+ Q_ASSERT(ui->RPanel->model()->isActive());\r
+ return ui->LPanel->model();\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::inactivePanel\r
+/// \return 非アクティブモデルを所有している可視状態のパネルを返します。\r
+///\r
+Panel *MainWindow::inactivePanel() const\r
+{\r
+ if (ui->LPanel->model() == inactiveModel() && ui->LPanel->isVisible()) {\r
+ return ui->LPanel;\r
+ }\r
+ if (ui->RPanel->model() == inactiveModel() && ui->RPanel->isVisible()) {\r
+ return ui->RPanel;\r
+ }\r
+ if (ui->FPanel->model() == inactiveModel() && ui->FPanel->isVisible()) {\r
+ return ui->FPanel;\r
+ }\r
+\r
+ qDebug() << ">>>>>>>>>> inactivePanel() Logic error <<<<<<<<<<";\r
return NULL;\r
}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::selectedItems\r
+/// \return マークされているアイテムまたはカレントアイテムのリスト\r
+///\r
+QFileInfoList MainWindow::selectedItems() const\r
+{\r
+ QFileInfoList list = activeModel()->markedItems();\r
+ if (list.isEmpty()) {\r
+ qDebug() << focusItemView();\r
+ qDebug() << focusItemView()->currentIndex();\r
+ Q_ASSERT(focusItemView()->currentIndex().isValid());\r
+ list << activeModel()->fileInfo(focusItemView()->currentIndex());\r
+ }\r
+\r
+ return list;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::focusItemView\r
+/// \return フォーカスを持つアイテムビュー\r
+///\r
+QAbstractItemView *MainWindow::focusItemView() const\r
+{\r
+ return static_cast<QAbstractItemView*>(qApp->focusWidget());\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::setViewMode\r
+/// \param mode 新しいビューモード\r
+///\r
+/// ビューモードを変更します。\r
+///\r
+void MainWindow::setViewMode(Mode mode)\r
+{\r
+ qDebug() << "MainWindow::setViewMode()" << mode;\r
+\r
+ QWidget *newFocusWidget = NULL;\r
+\r
+ switch (mode) {\r
+ case ModeBasic:\r
+ ui->FPanel->setVisible(false);\r
+ ui->splitter->setVisible(true);\r
+ ui->LPanel->setViewItem();\r
+ ui->RPanel->setViewItem();\r
+ if (m_viewMode == ModeFull) {\r
+ activePanel()->folderPanel()->setItemView(focusItemView()->objectName());\r
+ activePanel()->folderPanel()->itemView()->setCurrentIndex(\r
+ focusItemView()->currentIndex());\r
+ ui->FPanel->setModel(NULL);\r
+ }\r
+ newFocusWidget = activePanel()->folderPanel()->itemView();\r
+ break;\r
+\r
+ case ModeFull:\r
+ if (m_viewMode == ModeBasic) {\r
+ ui->FPanel->setModel(activeModel());\r
+ ui->splitter->setVisible(false);\r
+ ui->FPanel->setVisible(true);\r
+ ui->FPanel->folderPanel()->setItemView(focusItemView()->objectName());\r
+ ui->FPanel->folderPanel()->itemView()->setCurrentIndex(\r
+ focusItemView()->currentIndex());\r
+ }\r
+ ui->FPanel->setViewItem();\r
+ newFocusWidget = activePanel()->folderPanel()->itemView();\r
+ break;\r
+\r
+ case ModeView:\r
+ ui->FPanel->updateAppearance(Preferences(this));\r
+ ui->FPanel->setViewItem(focusItemView()->currentIndex());\r
+ ui->splitter->setVisible(false);\r
+ ui->FPanel->setVisible(true);\r
+ newFocusWidget = ui->FPanel->visibleView();\r
+ break;\r
+\r
+ case ModePreview:\r
+ inactivePanel()->setViewItem(focusItemView()->currentIndex());\r
+ break;\r
+ }\r
+\r
+ m_prevMode = m_viewMode;\r
+ m_viewMode = mode;\r
+\r
+ if (newFocusWidget)\r
+ newFocusWidget->setFocus();\r
+ else\r
+ updateActions();\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::startProcess\r
+/// \param cmd 実行するコマンド\r
+/// \param errMsg エラー時の表示メッセージ\r
+/// \return true:成功, false:失敗\r
+///\r
+bool MainWindow::startProcess(const QString &cmd, const QString &errMsg)\r
+{\r
+ qDebug() << "MainWindow::startProcess" << cmd << errMsg;\r
+\r
+ QProcess process(this);\r
+ process.setWorkingDirectory(activeModel()->rootPath());\r
+ if (!process.startDetached(cmd)) {\r
+ QMessageBox::critical(this, tr("エラー"), errMsg + "<br/>" + cmd);\r
+ return false;\r
+ }\r
+ return true;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::updateActions\r
+///\r
+/// アクションの有効/無効を設定します。\r
+///\r
+void MainWindow::updateActions()\r
+{\r
+ qDebug() << "MainWindow::updateActions";\r
+\r
+ bool isView = true;\r
+ bool isSearch = false;\r
+ bool isImageView = false;\r
+ bool toggleSearch = true;\r
+\r
+ QWidget *w = qApp->focusWidget();\r
+ if (w->objectName() == "folderView" || w->objectName() == "thumbnailView") {\r
+ setEnabledAllActions(true);\r
+ // 履歴\r
+ ui->action_historyBack->setEnabled(!activeModel()->isHistoryBegin());\r
+ ui->action_HistoryForward->setEnabled(!activeModel()->isHistoryEnd());\r
+ // チェック状態\r
+ ui->toggle_Hidden->blockSignals(true);\r
+ ui->toggle_Hidden->setChecked(activeModel()->filter() & QDir::Hidden);\r
+ ui->toggle_Hidden->blockSignals(false);\r
+\r
+ ui->toggle_System->blockSignals(true);\r
+ ui->toggle_System->setChecked(activeModel()->filter() & QDir::System);\r
+ ui->toggle_System->blockSignals(false);\r
+\r
+ ui->toggle_ThumbnailMode->blockSignals(true);\r
+ ui->toggle_ThumbnailMode->setChecked(w->objectName() == "thumbnailView");\r
+ ui->toggle_ThumbnailMode->blockSignals(false);\r
+\r
+ // 現在の選択アイテムが".."の場合、ファイル操作系アクションは無効にする\r
+ QFileInfoList list = selectedItems();\r
+ if (list.size() == 1 && list[0].fileName() == "..") {\r
+ ui->action_Copy->setEnabled(false);\r
+ ui->action_Delete->setEnabled(false);\r
+ ui->action_Move->setEnabled(false);\r
+ ui->action_Rename->setEnabled(false);\r
+ }\r
+\r
+ // 単画面またはプレビューモードの場合\r
+ if (!ui->LPanel->folderPanel()->isVisible() ||\r
+ !ui->RPanel->folderPanel()->isVisible())\r
+ {\r
+ ui->action_Copy->setEnabled(false);\r
+ ui->action_Move->setEnabled(false);\r
+ ui->action_Swap->setEnabled(false);\r
+ ui->action_SyncPanel->setEnabled(false);\r
+ ui->action_SyncPanelTo->setEnabled(false);\r
+ }\r
+\r
+ // 単画面の場合\r
+ if (m_viewMode == ModeFull) {\r
+ ui->toggle_PreviewMode->setEnabled(false);\r
+ ui->action_SplitCenter->setEnabled(false);\r
+ ui->action_ExpandLeft->setEnabled(false);\r
+ ui->action_ExpandRight->setEnabled(false);\r
+ ui->action_KeyDownOther->setEnabled(false);\r
+ ui->action_KeyEndOther->setEnabled(false);\r
+ ui->action_KeyHomeOther->setEnabled(false);\r
+ ui->action_KeyUpOther->setEnabled(false);\r
+ }\r
+ }\r
+ else if (w->objectName() == "searchBox"){\r
+ setEnabledAllActions(false);\r
+ isView = false;\r
+ isSearch = true;\r
+ }\r
+ else if (w->objectName() == "locationBox") {\r
+ setEnabledAllActions(false);\r
+ isView = false;\r
+ }\r
+ else if (w->objectName() == "textView") {\r
+ SimpleTextView *v = static_cast<SimpleTextView*>(w);\r
+ setEnabledAllActions(false);\r
+ toggleSearch = false;\r
+\r
+ reconnectAction(ui->text_ConvertFromEUC, SIGNAL(triggered()), v, SLOT(convertFromEUC()));\r
+ reconnectAction(ui->text_ConvertFromJIS, SIGNAL(triggered()), v, SLOT(convertFromJIS()));\r
+ reconnectAction(ui->text_ConvertFromSJIS, SIGNAL(triggered()), v, SLOT(convertFromSJIS()));\r
+ reconnectAction(ui->text_ConvertFromUTF8, SIGNAL(triggered()), v, SLOT(convertFromUTF8()));\r
+ reconnectAction(ui->text_ConvertFromUTF16, SIGNAL(triggered()), v, SLOT(convertFromUTF16()));\r
+ reconnectAction(ui->text_ConvertFromUTF16BE, SIGNAL(triggered()), v, SLOT(convertFromUTF16BE()));\r
+ reconnectAction(ui->text_ConvertFromUTF16LE, SIGNAL(triggered()), v, SLOT(convertFromUTF16LE()));\r
+ reconnectAction(ui->text_Copy, SIGNAL(triggered()), v, SLOT(copy()));\r
+ }\r
+ else if (w->objectName() == "imageView") {\r
+ SimpleImageView *v = static_cast<SimpleImageView*>(w);\r
+ setEnabledAllActions(false);\r
+ toggleSearch = false;\r
+ isImageView = true;\r
+\r
+ reconnectAction(ui->image_FitToWindow, SIGNAL(toggled(bool)), v, SLOT(fitToWindow(bool)));\r
+ reconnectAction(ui->image_ScaleNormal, SIGNAL(toggled(bool)), v, SLOT(scaleNormal()));\r
+ reconnectAction(ui->image_Rotate90, SIGNAL(triggered()), v, SLOT(rotate90()));\r
+ reconnectAction(ui->image_Rotate180, SIGNAL(triggered()), v, SLOT(rotate180()));\r
+ }\r
+\r
+ ui->toggle_Toolbar->blockSignals(true);\r
+ ui->toggle_Toolbar->setChecked(ui->mainToolBar->isVisible());\r
+ ui->toggle_Toolbar->blockSignals(false);\r
+\r
+ ui->action_About->setEnabled(true);\r
+ ui->action_CheckUpdate->setEnabled(true);\r
+ ui->action_KeyDown->setEnabled(isView);\r
+ ui->action_KeyEnd->setEnabled(isView);\r
+ ui->action_KeyHome->setEnabled(isView);\r
+ ui->action_KeyUp->setEnabled(isView);\r
+ ui->action_Quit->setEnabled(true);\r
+ ui->action_ScaleDown->setEnabled(isView);\r
+ ui->action_ScaleUp->setEnabled(isView);\r
+ ui->action_SearchNext->setEnabled(isSearch);\r
+ ui->action_SearchPrev->setEnabled(isSearch);\r
+ ui->action_Setting->setEnabled(true);\r
+ ui->toggle_Search->setEnabled(toggleSearch);\r
+ ui->view_Back->setEnabled(m_viewMode == ModeView);\r
+\r
+ if (isImageView) {\r
+ ui->action_ScaleDown->setText(tr("縮小"));\r
+ ui->action_ScaleUp->setText(tr("拡大"));\r
+ }\r
+ else {\r
+ ui->action_ScaleDown->setText(tr("文字を小さく"));\r
+ ui->action_ScaleUp->setText(tr("文字を大きく"));\r
+ }\r
+\r
+ ui->toggle_FullMode->setEnabled(m_viewMode == ModeBasic || m_viewMode == ModeFull);\r
+\r
+ if (w->objectName() == "thumbnailView") {\r
+ ui->action_KeyLeft->setEnabled(false);\r
+ ui->action_KeyRight->setEnabled(false);\r
+ }\r
+ else {\r
+ ui->action_KeyLeft->setEnabled(isView);\r
+ ui->action_KeyRight->setEnabled(isView);\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::setEnabledAllActions\r
+/// \param enable 有効にする場合はtrue\r
+///\r
+/// 全てのアクションを有効または無効にします。\r
+///\r
+void MainWindow::setEnabledAllActions(bool enable)\r
+{\r
+ qDebug() << "MainWindow::setEnabledAllActions()" << enable;\r
+ foreach (QAction *action, m_actions) {\r
+ action->setEnabled(enable);\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::onAbout\r
+///\r
+/// Aboutダイアログを表示します。\r
+///\r
+void MainWindow::onAbout()\r
+{\r
+ QMessageBox::about(\r
+ this,\r
+ tr("げふぅ について"),\r
+ windowTitle() +\r
+ tr("<center>Gefu is an Experimental File Utility.<br/>"\r
+ "<small>(げふぅは実験的なファイルユーティリティです)</small></center>"\r
+ "<p>最新版の情報は<a href='http://gefu.sourceforge.jp/'>公式サイト</a>で公開しています。</p>"\r
+ "<p><small>Copyright 2014 @miyabi_satoh All rights reserved.</small></p>"));\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::closeEvent\r
+/// \param event クローズイベント\r
+///\r
+/// 終了処理を行います。\r
+///\r
+void MainWindow::closeEvent(QCloseEvent *event)\r
+{\r
+ qDebug() << "MainWindow::closeEvent()";\r
+ Preferences prefs(this);\r
+\r
+ if (prefs.isConfirmQuit()) {\r
+ QMessageBox msgBox;\r
+ QCheckBox *checkBox = new QCheckBox();\r
+ checkBox->setText(tr("次回以降は確認しない"));\r
+ msgBox.setCheckBox(checkBox);\r
+ msgBox.setText(tr("終了しますか?"));\r
+ msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);\r
+ msgBox.setIcon(QMessageBox::Question);\r
+\r
+ if (msgBox.exec() == QMessageBox::No) {\r
+ qDebug() << ">>>>> ユーザによりキャンセルされました <<<<<";\r
+ event->ignore();\r
+ return;\r
+ }\r
+ prefs.setConfirmQuit(!checkBox->isChecked());\r
+ }\r
+\r
+ prefs.saveModel("Left", ui->LPanel->model());\r
+ prefs.saveModel("Right", ui->RPanel->model());\r
+ prefs.saveWindow(this);\r
+ QMainWindow::closeEvent(event);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+/// \brief MainWindow::eventFilter\r
+/// \param watched イベントの発生元オブジェクト\r
+/// \param e 発生したイベント\r
+/// \return イベントを処理した場合はtrueを返します。\r
+///\r
+bool MainWindow::eventFilter(QObject *watched, QEvent *e)\r
+{\r
+ switch (e->type()) {\r
+ case QEvent::KeyPress:\r
+ // キーイベントの処理\r
+ return onKeyPressEvent(watched, static_cast<QKeyEvent*>(e));\r
+\r
+ case QEvent::ContextMenu:\r
+ // コンテキストメニューイベントの処理\r
+ return onContextMenuEvent(watched, static_cast<QContextMenuEvent*>(e));\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return false;\r
+}\r