2 #include "mainwindow.h"
3 #include "historydialog.h"
4 #include "ui_historydialog.h"
6 HistoryDialog::HistoryDialog(QWidget *parent) :
8 ui(new Ui::HistoryDialog),
14 resize(parent->width() * 0.8, height());
17 HistoryDialog::~HistoryDialog()
22 void HistoryDialog::setHistory(const History *left, const History *right)
25 m_rightHistory = right;
28 void HistoryDialog::setDefaultLeft(bool bLeft)
31 ui->leftPane->setChecked(true);
34 ui->rightPane->setChecked(true);
38 int HistoryDialog::selectedIndex() const
40 int row = ui->listWidget->currentIndex().row();
41 return m_displaying->size() - row - 1;
44 const QString HistoryDialog::selectedSide() const
46 if (ui->leftPane->isChecked()) {
47 return QString("Left");
50 return QString("Right");
54 void HistoryDialog::showLeftHistory()
56 if (m_displaying != m_leftHistory) {
57 m_displaying = m_leftHistory;
63 void HistoryDialog::showRightHistory()
65 if (m_displaying != m_rightHistory) {
66 m_displaying = m_rightHistory;
71 void HistoryDialog::showHistory()
73 ui->listWidget->clear();
74 for (int n = 0; n < m_displaying->size(); n++) {
75 ui->listWidget->insertItem(0, m_displaying->at(n));
77 ui->listWidget->setCurrentRow(0);
80 void HistoryDialog::showEvent(QShowEvent *event)
84 if (ui->leftPane->isChecked()) {
91 connect(ui->leftPane, SIGNAL(clicked()), this, SLOT(showLeftHistory()));
92 connect(ui->rightPane, SIGNAL(clicked()), this, SLOT(showRightHistory()));
93 connect(ui->listWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept()));