annotate grapher.h @ 131:2550aaa09240

* Add connecting line to uncommitted item; turn Revert icon blue; cut down menus to things that actually work (well, mostly)
author Chris Cannam
date Tue, 30 Nov 2010 11:17:30 +0000
parents 005a54380502
children 644bd31e8301
rev   line source
Chris@57 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@57 2
Chris@57 3 /*
Chris@57 4 EasyMercurial
Chris@57 5
Chris@57 6 Based on HgExplorer by Jari Korhonen
Chris@57 7 Copyright (c) 2010 Jari Korhonen
Chris@57 8 Copyright (c) 2010 Chris Cannam
Chris@57 9 Copyright (c) 2010 Queen Mary, University of London
Chris@57 10
Chris@57 11 This program is free software; you can redistribute it and/or
Chris@57 12 modify it under the terms of the GNU General Public License as
Chris@57 13 published by the Free Software Foundation; either version 2 of the
Chris@57 14 License, or (at your option) any later version. See the file
Chris@57 15 COPYING included with this distribution for more information.
Chris@57 16 */
Chris@57 17
Chris@44 18 #ifndef GRAPHER_H
Chris@44 19 #define GRAPHER_H
Chris@44 20
Chris@44 21 #include "changeset.h"
Chris@44 22 #include "changesetitem.h"
Chris@119 23 #include "changesetscene.h"
Chris@44 24
cannam@45 25 #include <QSet>
cannam@45 26 #include <QMap>
Chris@46 27 #include <QPair>
cannam@45 28
cannam@45 29 #include <exception>
Chris@44 30
Chris@44 31 class Grapher
Chris@44 32 {
Chris@44 33 public:
Chris@119 34 Grapher(ChangesetScene *scene) { m_scene = scene; }
cannam@45 35
cannam@45 36 void layout(Changesets csets);
cannam@45 37
Chris@53 38 ChangesetItem *getItemFor(Changeset *cs);
Chris@53 39
cannam@45 40 class LayoutException : public std::exception {
cannam@45 41 public:
cannam@45 42 LayoutException(QString message) throw() : m_message(message) { }
cannam@45 43 virtual ~LayoutException() throw() { }
cannam@45 44 virtual const char *what() const throw() {
cannam@45 45 return m_message.toLocal8Bit().data();
cannam@45 46 }
cannam@45 47 protected:
cannam@45 48 QString m_message;
cannam@45 49 };
cannam@45 50
cannam@45 51 private:
Chris@119 52 ChangesetScene *m_scene;
cannam@45 53
cannam@45 54 typedef QMap<QString, Changeset *> IdChangesetMap;
Chris@46 55 IdChangesetMap m_changesets;
cannam@45 56
cannam@45 57 typedef QMap<QString, ChangesetItem *> IdItemMap;
cannam@45 58 IdItemMap m_items;
cannam@45 59
cannam@45 60 typedef QSet<int> ColumnSet;
cannam@45 61 typedef QMap<int, ColumnSet> GridAlloc;
cannam@45 62 GridAlloc m_alloc;
cannam@45 63
Chris@46 64 typedef QPair<int, int> Range;
Chris@46 65 typedef QMap<QString, Range> BranchRangeMap;
Chris@46 66 BranchRangeMap m_branchRanges;
Chris@46 67
Chris@46 68 typedef QMap<QString, int> BranchColumnMap;
Chris@46 69 BranchColumnMap m_branchHomes;
Chris@46 70
cannam@45 71 typedef QSet<QString> IdSet;
cannam@45 72 IdSet m_handled;
Chris@46 73
Chris@51 74 typedef QMap<int, QString> RowDateMap;
Chris@51 75 RowDateMap m_rowDates;
Chris@51 76
Chris@46 77 void layoutRow(QString id);
Chris@46 78 void layoutCol(QString id);
Chris@46 79 void allocateBranchHomes(Changesets csets);
Chris@46 80 bool rangesConflict(const Range &r1, const Range &r2);
Chris@46 81 int findAvailableColumn(int row, int parent, bool preferParentCol);
Chris@44 82 };
Chris@44 83
Chris@44 84 #endif