1 #include "foldermodel.h"
2 #include "historydialog.h"
3 #include "ui_historydialog.h"
5 HistoryDialog::HistoryDialog(QWidget *parent) :
7 ui(new Ui::HistoryDialog),
13 resize(parent->width() * 0.8, height());
15 connect(ui->listLeft, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept()));
16 connect(ui->listRight, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept()));
19 HistoryDialog::~HistoryDialog()
24 void HistoryDialog::setModel(const FolderModel *left, const FolderModel *right, FolderModel *active)
28 m_activeModel = active;
31 ui->radioLeft->click();
34 ui->radioRight->click();
37 for (int n = left->history().size() - 1; n >= 0; --n) {
38 ui->listLeft->addItem(left->history().at(n));
40 for (int n = right->history().size() - 1; n >= 0; --n) {
41 ui->listRight->addItem(right->history().at(n));
45 void HistoryDialog::on_radioLeft_clicked()
47 ui->listRight->setVisible(false);
48 ui->listLeft->setVisible(true);
51 void HistoryDialog::on_radioRight_clicked()
53 ui->listLeft->setVisible(false);
54 ui->listRight->setVisible(true);
57 void HistoryDialog::accept()
60 const FolderModel *selected;
61 if (ui->radioLeft->isChecked()) {
62 selected = m_leftModel;
63 path = ui->listLeft->currentItem()->text();
66 selected = m_rightModel;
67 path = ui->listRight->currentItem()->text();
70 if (selected == m_activeModel) {
71 m_activeModel->setHistoryAt(path);
74 m_activeModel->setRootPath(path);