X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=historydialog.cpp;h=7da26ff0c06044e7a348e99d0ccec70f490ea7d2;hb=HEAD;hp=02f5fb8a2781e0fd4034054ebc94d0241aaf710a;hpb=b7b4abb0288ef12a9d9b77af7378754790a00ce5;p=gefu%2FGefu.git diff --git a/historydialog.cpp b/historydialog.cpp index 02f5fb8..7da26ff 100644 --- a/historydialog.cpp +++ b/historydialog.cpp @@ -1,94 +1,112 @@ -#include "common.h" -#include "mainwindow.h" +#include "foldermodel.h" #include "historydialog.h" #include "ui_historydialog.h" +/////////////////////////////////////////////////////////////////////////////// +/// \brief HistoryDialog::HistoryDialog +/// \param parent 親ウィジェット +/// +/// コンストラクタ +/// HistoryDialog::HistoryDialog(QWidget *parent) : QDialog(parent), ui(new Ui::HistoryDialog), - m_leftHistory(NULL), - m_rightHistory(NULL), - m_displaying(NULL) + m_leftModel(NULL), + m_rightModel(NULL), + m_activeModel(NULL) { ui->setupUi(this); - resize(getMainWnd()->width() * 0.8, height()); + resize(parent->width() * 0.8, height()); + + connect(ui->listLeft, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept())); + connect(ui->listRight, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept())); } +/////////////////////////////////////////////////////////////////////////////// +/// \brief HistoryDialog::~HistoryDialog +/// +/// デストラクタ +/// HistoryDialog::~HistoryDialog() { delete ui; } -void HistoryDialog::setHistory(History *left, History *right) +/////////////////////////////////////////////////////////////////////////////// +/// \brief HistoryDialog::setModel +/// \param left 左パネルのモデル +/// \param right 右パネルのモデル +/// \param active アクティブモデル +/// +/// モデルを設定します。 +/// +void HistoryDialog::setModel(const FolderModel *left, const FolderModel *right, FolderModel *active) { - m_leftHistory = left; - m_rightHistory = right; -} + m_leftModel = left; + m_rightModel = right; + m_activeModel = active; -void HistoryDialog::setDefaultLeft(bool bLeft) -{ - if (bLeft) { - ui->leftPane->setChecked(true); + if (active == left) { + ui->radioLeft->click(); } else { - ui->rightPane->setChecked(true); + ui->radioRight->click(); } -} -int HistoryDialog::selectedIndex() const -{ - int row = ui->listWidget->currentIndex().row(); - return m_displaying->size() - row - 1; -} - -const QString HistoryDialog::selectedSide() const -{ - if (ui->leftPane->isChecked()) { - return QString("Left"); + for (int n = left->history().size() - 1; n >= 0; --n) { + ui->listLeft->addItem(left->history().at(n)); } - else { - return QString("Right"); + for (int n = right->history().size() - 1; n >= 0; --n) { + ui->listRight->addItem(right->history().at(n)); } } -void HistoryDialog::showLeftHistory() +/////////////////////////////////////////////////////////////////////////////// +/// \brief HistoryDialog::on_radioLeft_clicked +/// +/// 左パネルラジオボタンクリック時の処理を行います。 +/// +void HistoryDialog::on_radioLeft_clicked() { - if (m_displaying != m_leftHistory) { - m_displaying = m_leftHistory; - showHistory(); - } - + ui->listRight->setVisible(false); + ui->listLeft->setVisible(true); } -void HistoryDialog::showRightHistory() +/////////////////////////////////////////////////////////////////////////////// +/// \brief HistoryDialog::on_radioRight_clicked +/// +/// 右パネルラジオボタンクリック時の処理を行います。 +/// +void HistoryDialog::on_radioRight_clicked() { - if (m_displaying != m_rightHistory) { - m_displaying = m_rightHistory; - showHistory(); - } + ui->listLeft->setVisible(false); + ui->listRight->setVisible(true); } -void HistoryDialog::showHistory() +/////////////////////////////////////////////////////////////////////////////// +/// \brief HistoryDialog::accept +/// +/// OKボタンクリック時の処理を行います。 +/// +void HistoryDialog::accept() { - ui->listWidget->clear(); - for (int n = 0; n < m_displaying->size(); n++) { - ui->listWidget->insertItem(0, m_displaying->at(n)); + QString path; + const FolderModel *selected; + if (ui->radioLeft->isChecked()) { + selected = m_leftModel; + path = ui->listLeft->currentItem()->text(); + } + else { + selected = m_rightModel; + path = ui->listRight->currentItem()->text(); } - ui->listWidget->setCurrentRow(0); -} - -void HistoryDialog::showEvent(QShowEvent *event) -{ - Q_UNUSED(event); - if (ui->leftPane->isChecked()) { - showLeftHistory(); + if (selected == m_activeModel) { + m_activeModel->setHistoryAt(path); } else { - showRightHistory(); + m_activeModel->setRootPath(path); } - connect(ui->leftPane, SIGNAL(clicked()), this, SLOT(showLeftHistory())); - connect(ui->rightPane, SIGNAL(clicked()), this, SLOT(showRightHistory())); - connect(ui->listWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept())); + QDialog::accept(); }