comparison historywidget.cpp @ 129:4986642800f0

* Initial work on showing uncommitted changes (as dashed box) in history graph
author Chris Cannam
date Mon, 29 Nov 2010 20:53:34 +0000
parents fcaf09ee825d
children aaeab914f2a3
comparison
equal deleted inserted replaced
128:fcaf09ee825d 129:4986642800f0
20 #include "changesetscene.h" 20 #include "changesetscene.h"
21 #include "panned.h" 21 #include "panned.h"
22 #include "panner.h" 22 #include "panner.h"
23 #include "grapher.h" 23 #include "grapher.h"
24 #include "debug.h" 24 #include "debug.h"
25 #include "uncommitteditem.h"
25 26
26 #include <iostream> 27 #include <iostream>
27 28
28 #include <QGridLayout> 29 #include <QGridLayout>
29 30
30 HistoryWidget::HistoryWidget() 31 HistoryWidget::HistoryWidget()
31 { 32 {
32 m_panned = new Panned; 33 m_panned = new Panned;
33 m_panner = new Panner; 34 m_panner = new Panner;
35 m_uncommitted = new UncommittedItem();
36 m_uncommitted->setRow(-1);
34 37
35 QGridLayout *layout = new QGridLayout; 38 QGridLayout *layout = new QGridLayout;
36 layout->addWidget(m_panned, 0, 0); 39 layout->addWidget(m_panned, 0, 0);
37 layout->addWidget(m_panner, 0, 1); 40 layout->addWidget(m_panner, 0, 1);
38 m_panner->setMaximumWidth(80); 41 m_panner->setMaximumWidth(80);
42 } 45 }
43 46
44 HistoryWidget::~HistoryWidget() 47 HistoryWidget::~HistoryWidget()
45 { 48 {
46 clearChangesets(); 49 clearChangesets();
50 delete m_uncommitted;
47 } 51 }
48 52
49 void HistoryWidget::clearChangesets() 53 void HistoryWidget::clearChangesets()
50 { 54 {
51 foreach (Changeset *cs, m_changesets) delete cs; 55 foreach (Changeset *cs, m_changesets) delete cs;
60 updateCurrentItems(); 64 updateCurrentItems();
61 } 65 }
62 66
63 void HistoryWidget::showUncommittedChanges(bool show) 67 void HistoryWidget::showUncommittedChanges(bool show)
64 { 68 {
65 //!!! implement! 69 QGraphicsScene *scene = m_panned->scene();
70 if (!scene) return;
71
72 if (show) {
73 if (m_uncommitted->scene() == scene) return;
74 scene->addItem(m_uncommitted);
75 m_uncommitted->ensureVisible();
76 } else {
77 if (m_uncommitted->scene() != scene) return;
78 scene->removeItem(m_uncommitted);
79 }
66 } 80 }
67 81
68 void HistoryWidget::parseNewLog(QString log) 82 void HistoryWidget::parseNewLog(QString log)
69 { 83 {
70 DEBUG << "HistoryWidget::parseNewLog: log has " << log.length() << " chars" << endl; 84 DEBUG << "HistoryWidget::parseNewLog: log has " << log.length() << " chars" << endl;
88 } 102 }
89 103
90 void HistoryWidget::layoutAll() 104 void HistoryWidget::layoutAll()
91 { 105 {
92 setChangesetParents(); 106 setChangesetParents();
107 showUncommittedChanges(false); // detach the item from our scene
93 108
94 ChangesetScene *scene = new ChangesetScene(); 109 ChangesetScene *scene = new ChangesetScene();
95 ChangesetItem *tipItem = 0; 110 ChangesetItem *tipItem = 0;
96 111
97 if (!m_changesets.empty()) { 112 if (!m_changesets.empty()) {
144 bool current = m_currentIds.contains(id); 159 bool current = m_currentIds.contains(id);
145 if (current) { 160 if (current) {
146 DEBUG << "id " << id << " is current" << endl; 161 DEBUG << "id " << id << " is current" << endl;
147 } 162 }
148 csit->setCurrent(current); 163 csit->setCurrent(current);
164 m_uncommitted->setRow(csit->row() - 1);
165 m_uncommitted->setColumn(csit->column());
166 m_uncommitted->setWide(csit->isWide());
167 m_uncommitted->setBranch(csit->getChangeset()->branch());
149 } 168 }
150 } 169 }
151 } 170 }
152 171