Skip to content
Permalink
Browse files

implemented select a storage.(refs #77)

  • Loading branch information...
haraki committed Jun 8, 2019
1 parent 7d34a50 commit 1e4a613192d156eddd1b315a63af01aaa45bc29d
Showing with 37 additions and 0 deletions.
  1. +9 −0 doublefolderpanel.cpp
  2. +5 −0 folderform.cpp
  3. +14 −0 selectstoragefavoritedialog.cpp
  4. +9 −0 selectstoragefavoritedialog.h
@@ -319,12 +319,21 @@ bool DoubleFolderPanel::eventFilter(QObject *watched, QEvent *e)

void DoubleFolderPanel::onSelectStorageFavorite()
{
FolderForm* activeForm = getActiveFolderForm();
if(activeForm == Q_NULLPTR)
{
return;
}

SelectStorageFavoriteDialog dialog(parentWidget());
if(dialog.exec() != QDialog::Accepted)
{
return;
}

QString selectedPath = dialog.getSelectedPath();

activeForm->setPath(selectedPath);
}

void DoubleFolderPanel::onSetPaneMode(PaneMode paneMode)
@@ -187,6 +187,11 @@ Qt::SortOrder FolderForm::getSortOrder() const

int FolderForm::setPath(const QString& dirPath)
{
if(m_folderModel->rootPath() == dirPath)
{
return 0;
}

// ディレクトリが空(".." も存在しない)場合は Open できないとみなしてエラー
if(QDir(dirPath).isEmpty(QDir::AllEntries | QDir::NoDot))
{
@@ -10,11 +10,25 @@ SelectStorageFavoriteDialog::SelectStorageFavoriteDialog(QWidget *parent/* = Q_N
ui(new Ui::SelectStorageFavoriteDialog)
{
ui->setupUi(this);

m_sfInfoModel = new StorageFavoriteInfoModel();

ui->storagesFavoritesListView->setModel(m_sfInfoModel);
ui->storagesFavoritesListView->setCurrentIndex(m_sfInfoModel->index(0));
}

SelectStorageFavoriteDialog::~SelectStorageFavoriteDialog()
{
delete m_sfInfoModel;

delete ui;
}

void SelectStorageFavoriteDialog::accept()
{
m_selectedPath = m_sfInfoModel->data(ui->storagesFavoritesListView->currentIndex(), StorageFavoriteInfoModel::PathRole).toString();

QDialog::accept();
}

} // namespace Farman
@@ -2,6 +2,7 @@
#define SELECTSTORAGEFAVORITEDIALOG_H

#include <QDialog>
#include "storagefavoriteinfomodel.h"

namespace Ui {
class SelectStorageFavoriteDialog;
@@ -18,10 +19,18 @@ class SelectStorageFavoriteDialog : public QDialog
explicit SelectStorageFavoriteDialog(QWidget *parent = Q_NULLPTR);
~SelectStorageFavoriteDialog();

const QString& getSelectedPath() { return m_selectedPath; }

void accept();

private:
void initialize();

Ui::SelectStorageFavoriteDialog *ui;

StorageFavoriteInfoModel *m_sfInfoModel;

QString m_selectedPath;
};

} // namespace Farman

0 comments on commit 1e4a613

Please sign in to comment.
You can’t perform that action at this time.