comparison src/historywidget.cpp @ 513:ddc7238fc3b0

Add "Show closed branches" toggle to history widget, when some closed branches exist in the repo
author Chris Cannam
date Tue, 18 Oct 2011 12:49:39 +0100
parents 470829a21f98
children 306a62fe851e
comparison
equal deleted inserted replaced
512:67d18eaca830 513:ddc7238fc3b0
25 #include "uncommitteditem.h" 25 #include "uncommitteditem.h"
26 26
27 #include <iostream> 27 #include <iostream>
28 28
29 #include <QGridLayout> 29 #include <QGridLayout>
30 #include <QSettings>
30 31
31 HistoryWidget::HistoryWidget() : 32 HistoryWidget::HistoryWidget() :
32 m_showUncommitted(false), 33 m_showUncommitted(false),
33 m_refreshNeeded(false) 34 m_refreshNeeded(false)
34 { 35 {
37 38
38 m_panned->setDragMode(QGraphicsView::ScrollHandDrag); 39 m_panned->setDragMode(QGraphicsView::ScrollHandDrag);
39 m_panned->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); 40 m_panned->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
40 m_panned->setCacheMode(QGraphicsView::CacheNone); 41 m_panned->setCacheMode(QGraphicsView::CacheNone);
41 42
43 int row = 0;
44
42 QGridLayout *layout = new QGridLayout; 45 QGridLayout *layout = new QGridLayout;
43 layout->addWidget(m_panned, 0, 0); 46 layout->setMargin(10);
44 layout->addWidget(m_panner, 0, 1); 47 layout->addWidget(m_panned, row, 0);
48 layout->addWidget(m_panner, row, 1);
45 m_panner->setMaximumWidth(80); 49 m_panner->setMaximumWidth(80);
46 m_panner->connectToPanned(m_panned); 50 m_panner->connectToPanned(m_panned);
51
52 layout->setRowStretch(row, 20);
53
54 QSettings settings;
55 settings.beginGroup("Presentation");
56 bool showClosed = (settings.value("showclosedbranches", false).toBool());
57
58 m_showClosedBranches = new QCheckBox(tr("Show closed branches"), this);
59 m_showClosedBranches->setChecked(showClosed);
60 connect(m_showClosedBranches, SIGNAL(toggled(bool)),
61 this, SLOT(showClosedChanged(bool)));
62 layout->addWidget(m_showClosedBranches, ++row, 0, Qt::AlignLeft);
63 m_showClosedBranches->hide();
47 64
48 setLayout(layout); 65 setLayout(layout);
49 } 66 }
50 67
51 HistoryWidget::~HistoryWidget() 68 HistoryWidget::~HistoryWidget()
89 106
90 void HistoryWidget::setClosedHeadIds(QSet<QString> closed) 107 void HistoryWidget::setClosedHeadIds(QSet<QString> closed)
91 { 108 {
92 if (closed == m_closedIds) return; 109 if (closed == m_closedIds) return;
93 m_closedIds = closed; 110 m_closedIds = closed;
111 m_showClosedBranches->setVisible(!closed.empty());
94 m_refreshNeeded = true; 112 m_refreshNeeded = true;
95 } 113 }
96 114
97 void HistoryWidget::setShowUncommitted(bool showUncommitted) 115 void HistoryWidget::setShowUncommitted(bool showUncommitted)
98 { 116 {
99 setCurrent(m_currentIds, m_currentBranch, showUncommitted); 117 setCurrent(m_currentIds, m_currentBranch, showUncommitted);
118 }
119
120 void HistoryWidget::showClosedChanged(bool show)
121 {
122 QSettings settings;
123 settings.beginGroup("Presentation");
124 settings.setValue("showclosedbranches", show);
125 layoutAll();
100 } 126 }
101 127
102 void HistoryWidget::parseNewLog(QString log) 128 void HistoryWidget::parseNewLog(QString log)
103 { 129 {
104 DEBUG << "HistoryWidget::parseNewLog: log has " << log.length() << " chars" << endl; 130 DEBUG << "HistoryWidget::parseNewLog: log has " << log.length() << " chars" << endl;