1 #include "historydialog.h"
2 #include "ui_historydialog.h"
4 HistoryDialog::HistoryDialog(QWidget *parent) :
6 ui(new Ui::HistoryDialog),
15 HistoryDialog::~HistoryDialog()
20 void HistoryDialog::setHistory(History *left, History *right)
23 m_rightHistory = right;
26 void HistoryDialog::setDefaultLeft(bool bLeft)
29 ui->leftPane->setChecked(true);
32 ui->rightPane->setChecked(true);
36 int HistoryDialog::selectedIndex() const
38 int row = ui->listWidget->currentIndex().row();
39 return m_displaying->size() - row - 1;
42 const QString HistoryDialog::selectedSide() const
44 if (ui->leftPane->isChecked()) {
45 return QString("Left");
48 return QString("Right");
52 void HistoryDialog::showLeftHistory()
54 if (m_displaying != m_leftHistory) {
55 m_displaying = m_leftHistory;
61 void HistoryDialog::showRightHistory()
63 if (m_displaying != m_rightHistory) {
64 m_displaying = m_rightHistory;
69 void HistoryDialog::showHistory()
71 ui->listWidget->clear();
72 for (int n = 0; n < m_displaying->size(); n++) {
73 ui->listWidget->insertItem(0, m_displaying->at(n));
75 ui->listWidget->setCurrentRow(0);
78 void HistoryDialog::showEvent(QShowEvent *event)
82 if (ui->leftPane->isChecked()) {
89 connect(ui->leftPane, SIGNAL(clicked()), this, SLOT(showLeftHistory()));
90 connect(ui->rightPane, SIGNAL(clicked()), this, SLOT(showRightHistory()));
91 connect(ui->listWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept()));