Mercurial > hg > easyhg
comparison grapher.cpp @ 114:bb2d2eecdd60
* minor output fixes
| author | Chris Cannam |
|---|---|
| date | Fri, 26 Nov 2010 21:17:24 +0000 |
| parents | 4bd17f36d059 |
| children | 005a54380502 |
comparison
equal
deleted
inserted
replaced
| 113:5fc7b4fc77a8 | 114:bb2d2eecdd60 |
|---|---|
| 16 */ | 16 */ |
| 17 | 17 |
| 18 #include "grapher.h" | 18 #include "grapher.h" |
| 19 #include "connectionitem.h" | 19 #include "connectionitem.h" |
| 20 #include "dateitem.h" | 20 #include "dateitem.h" |
| 21 #include "debug.h" | |
| 21 | 22 |
| 22 #include <QGraphicsScene> | 23 #include <QGraphicsScene> |
| 23 | 24 |
| 24 #include <iostream> | 25 #include <iostream> |
| 25 | 26 |
| 56 if (!m_items.contains(id)) { | 57 if (!m_items.contains(id)) { |
| 57 throw LayoutException(QString("Changeset %1 not in item map").arg(id)); | 58 throw LayoutException(QString("Changeset %1 not in item map").arg(id)); |
| 58 } | 59 } |
| 59 Changeset *cs = m_changesets[id]; | 60 Changeset *cs = m_changesets[id]; |
| 60 ChangesetItem *item = m_items[id]; | 61 ChangesetItem *item = m_items[id]; |
| 61 std::cerr << "layoutRow: Looking at " << id.toStdString() << std::endl; | 62 DEBUG << "layoutRow: Looking at " << id.toStdString() << endl; |
| 62 | 63 |
| 63 int row = 0; | 64 int row = 0; |
| 64 int nparents = cs->parents().size(); | 65 int nparents = cs->parents().size(); |
| 65 | 66 |
| 66 if (nparents > 0) { | 67 if (nparents > 0) { |
| 100 | 101 |
| 101 if (!m_rowDates.contains(row)) { | 102 if (!m_rowDates.contains(row)) { |
| 102 m_rowDates[row] = date; | 103 m_rowDates[row] = date; |
| 103 } | 104 } |
| 104 | 105 |
| 105 std::cerr << "putting " << cs->id().toStdString() << " at row " << row | 106 DEBUG << "putting " << cs->id().toStdString() << " at row " << row |
| 106 << std::endl; | 107 << endl; |
| 107 | 108 |
| 108 item->setRow(row); | 109 item->setRow(row); |
| 109 m_handled.insert(id); | 110 m_handled.insert(id); |
| 110 } | 111 } |
| 111 | 112 |
| 112 void Grapher::layoutCol(QString id) | 113 void Grapher::layoutCol(QString id) |
| 113 { | 114 { |
| 114 if (m_handled.contains(id)) { | 115 if (m_handled.contains(id)) { |
| 115 std::cerr << "Already looked at " << id.toStdString() << std::endl; | 116 DEBUG << "Already looked at " << id.toStdString() << endl; |
| 116 return; | 117 return; |
| 117 } | 118 } |
| 118 if (!m_changesets.contains(id)) { | 119 if (!m_changesets.contains(id)) { |
| 119 throw LayoutException(QString("Changeset %1 not in ID map").arg(id)); | 120 throw LayoutException(QString("Changeset %1 not in ID map").arg(id)); |
| 120 } | 121 } |
| 121 if (!m_items.contains(id)) { | 122 if (!m_items.contains(id)) { |
| 122 throw LayoutException(QString("Changeset %1 not in item map").arg(id)); | 123 throw LayoutException(QString("Changeset %1 not in item map").arg(id)); |
| 123 } | 124 } |
| 124 | 125 |
| 125 Changeset *cs = m_changesets[id]; | 126 Changeset *cs = m_changesets[id]; |
| 126 // std::cerr << "layoutCol: Looking at " << id.toStdString() << std::endl; | 127 // DEBUG << "layoutCol: Looking at " << id.toStdString() << endl; |
| 127 | 128 |
| 128 ChangesetItem *item = m_items[id]; | 129 ChangesetItem *item = m_items[id]; |
| 129 | 130 |
| 130 int col = 0; | 131 int col = 0; |
| 131 int row = item->row(); | 132 int row = item->row(); |
| 178 col = findAvailableColumn(item->row(), col, false); | 179 col = findAvailableColumn(item->row(), col, false); |
| 179 } | 180 } |
| 180 break; | 181 break; |
| 181 } | 182 } |
| 182 | 183 |
| 183 // std::cerr << "putting " << cs->id().toStdString() << " at col " << col << std::endl; | 184 // DEBUG << "putting " << cs->id().toStdString() << " at col " << col << endl; |
| 184 | 185 |
| 185 m_alloc[row].insert(col); | 186 m_alloc[row].insert(col); |
| 186 item->setColumn(col); | 187 item->setColumn(col); |
| 187 m_handled.insert(id); | 188 m_handled.insert(id); |
| 188 | 189 |
| 298 } | 299 } |
| 299 m_branchHomes[branch] = home; | 300 m_branchHomes[branch] = home; |
| 300 } | 301 } |
| 301 | 302 |
| 302 foreach (QString branch, m_branchRanges.keys()) { | 303 foreach (QString branch, m_branchRanges.keys()) { |
| 303 std::cerr << branch.toStdString() << ": " << m_branchRanges[branch].first << " - " << m_branchRanges[branch].second << ", home " << m_branchHomes[branch] << std::endl; | 304 DEBUG << branch.toStdString() << ": " << m_branchRanges[branch].first << " - " << m_branchRanges[branch].second << ", home " << m_branchHomes[branch] << endl; |
| 304 } | 305 } |
| 305 } | 306 } |
| 306 | 307 |
| 307 static bool | 308 static bool |
| 308 compareChangesetsByDate(Changeset *const &a, Changeset *const &b) | 309 compareChangesetsByDate(Changeset *const &a, Changeset *const &b) |
| 327 if (csets.empty()) return; | 328 if (csets.empty()) return; |
| 328 | 329 |
| 329 foreach (Changeset *cs, csets) { | 330 foreach (Changeset *cs, csets) { |
| 330 | 331 |
| 331 QString id = cs->id(); | 332 QString id = cs->id(); |
| 332 std::cerr << id.toStdString() << std::endl; | 333 DEBUG << id.toStdString() << endl; |
| 333 | 334 |
| 334 if (id == "") { | 335 if (id == "") { |
| 335 throw LayoutException("Changeset has no ID"); | 336 throw LayoutException("Changeset has no ID"); |
| 336 } | 337 } |
| 337 if (m_changesets.contains(id)) { | 338 if (m_changesets.contains(id)) { |
| 388 // above | 389 // above |
| 389 | 390 |
| 390 qStableSort(csets.begin(), csets.end(), compareChangesetsByDate); | 391 qStableSort(csets.begin(), csets.end(), compareChangesetsByDate); |
| 391 | 392 |
| 392 foreach (Changeset *cs, csets) { | 393 foreach (Changeset *cs, csets) { |
| 393 std::cerr << "id " << cs->id().toStdString() << ", ts " << cs->timestamp() << ", date " << cs->datetime().toStdString() << std::endl; | 394 DEBUG << "id " << cs->id().toStdString() << ", ts " << cs->timestamp() << ", date " << cs->datetime().toStdString() << endl; |
| 394 } | 395 } |
| 395 | 396 |
| 396 m_handled.clear(); | 397 m_handled.clear(); |
| 397 foreach (Changeset *cs, csets) { | 398 foreach (Changeset *cs, csets) { |
| 398 layoutRow(cs->id()); | 399 layoutRow(cs->id()); |
