Mercurial > hg > easyhg
comparison hgexpwidget.cpp @ 45:4286836bb3c9
* Some more work on graph layout; ensure LANG is set for parseable UTF8 output when running Hg
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Wed, 10 Nov 2010 12:44:11 +0000 |
parents | bed7ab59f62e |
children | c76782c14371 |
comparison
equal
deleted
inserted
replaced
44:bed7ab59f62e | 45:4286836bb3c9 |
---|---|
10 #include "common.h" | 10 #include "common.h" |
11 #include "logparser.h" | 11 #include "logparser.h" |
12 #include "changeset.h" | 12 #include "changeset.h" |
13 #include "changesetitem.h" | 13 #include "changesetitem.h" |
14 #include "grapher.h" | 14 #include "grapher.h" |
15 #include "panner.h" | |
16 #include "panned.h" | |
15 | 17 |
16 #include <iostream> | 18 #include <iostream> |
17 | 19 |
18 #define REMOTE_REPO_STR "Remote repository: " | 20 #define REMOTE_REPO_STR "Remote repository: " |
19 #define LOCAL_REPO_STR "Local repository: " | 21 #define LOCAL_REPO_STR "Local repository: " |
89 mainLayout -> addWidget(grpLocalRepo, 8); | 91 mainLayout -> addWidget(grpLocalRepo, 8); |
90 mainLayout -> addWidget(grpWorkFolder, 12); | 92 mainLayout -> addWidget(grpWorkFolder, 12); |
91 addTab(workPageWidget, tr("Work")); | 93 addTab(workPageWidget, tr("Work")); |
92 | 94 |
93 // History graph page | 95 // History graph page |
94 historyGraphPageWidget = new QGraphicsView; | 96 historyGraphPageWidget = new QWidget; |
97 Panned *panned = new Panned; | |
98 Panner *panner = new Panner; | |
99 historyGraphWidget = panned; | |
100 historyGraphPanner = panner; | |
101 QGridLayout *layout = new QGridLayout; | |
102 layout->addWidget(historyGraphWidget, 0, 0); | |
103 layout->addWidget(historyGraphPanner, 0, 1); | |
104 panner->setMaximumWidth(80); | |
105 panner->connectToPanned(panned); | |
106 historyGraphPageWidget->setLayout(layout); | |
95 addTab(historyGraphPageWidget, tr("History (graph)")); | 107 addTab(historyGraphPageWidget, tr("History (graph)")); |
96 | 108 |
97 | 109 |
98 //History page | 110 //History page |
99 //History page | 111 //History page |
242 { | 254 { |
243 localRepoHgLogList -> clear(); | 255 localRepoHgLogList -> clear(); |
244 localRepoHgLogList -> addItems(splitChangeSets(hgLogList)); | 256 localRepoHgLogList -> addItems(splitChangeSets(hgLogList)); |
245 | 257 |
246 //!!! | 258 //!!! |
247 QGraphicsView *gv = static_cast<QGraphicsView *>(historyGraphPageWidget); | 259 Panned *panned = static_cast<Panned *>(historyGraphWidget); |
248 gv->scene()->deleteLater(); | 260 Panner *panner = static_cast<Panner *>(historyGraphPanner); |
249 QGraphicsScene *scene = new QGraphicsScene(); | 261 QGraphicsScene *scene = new QGraphicsScene(); |
250 Changesets csets = parseChangeSets(hgLogList); | 262 Changesets csets = parseChangeSets(hgLogList); |
251 if (csets.empty()) return; | 263 if (csets.empty()) return; |
252 ChangesetItemMap csetItemMap; | |
253 foreach (Changeset *cs, csets) { | |
254 ChangesetItem *item = new ChangesetItem(cs); | |
255 item->setX(0); | |
256 item->setY(0); | |
257 csetItemMap[cs] = item; | |
258 scene->addItem(item); | |
259 } | |
260 try { | 264 try { |
261 Grapher().layout(csets, csetItemMap); | 265 Grapher(scene).layout(csets); |
262 } catch (std::string s) { | 266 } catch (std::string s) { |
263 std::cerr << "Internal error: Layout failed: " << s << std::endl; | 267 std::cerr << "Internal error: Layout failed: " << s << std::endl; |
264 } | 268 } |
265 /* | 269 panned->scene()->deleteLater(); |
266 QMap<QString, Changeset *> idCsetMap; | 270 panned->setScene(scene); |
267 foreach (Changeset *cs, csets) { | 271 panner->scene()->deleteLater(); |
268 if (cs->id() == "") { | 272 panner->setScene(scene); |
269 throw std::string("Changeset has no ID"); | |
270 } | |
271 if (idCsetMap.contains(cs->id())) { | |
272 throw std::string("Changeset ID is already in map"); | |
273 } | |
274 idCsetMap[cs->id()] = cs; | |
275 } | |
276 typedef QSet<int> ColumnSet; | |
277 typedef QMap<int, ColumnSet> GridAlloc; | |
278 typedef QMap<Changeset *, ChangesetItem *> ChangesetItemMap; | |
279 ChangesetItemMap csetItemMap; | |
280 foreach (Changeset *cs, csets) { | |
281 ChangesetItem *item = new ChangesetItem(cs); | |
282 item->setX(0); | |
283 item->setY(-cs->number() * 100); | |
284 csetItemMap[cs] = item; | |
285 scene->addItem(item); | |
286 } | |
287 QSet<Changeset *> handled; | |
288 for (int i = csets.size() - 1; i >= 0; --i) { | |
289 Changeset *cs = csets[i]; | |
290 if (handled.contains(cs)) continue; | |
291 | |
292 | |
293 handled.insert(cs); | |
294 } | |
295 */ | |
296 gv->setScene(scene); | |
297 } | 273 } |
298 | 274 |
299 | 275 |
300 | 276 |
301 int HgExpWidget::findLineStart(int nowIndex, QString str) | 277 int HgExpWidget::findLineStart(int nowIndex, QString str) |