annotate src/grapher.h @ 587:4ed384ea7f39 fswatcher

comment only
author Chris Cannam
date Wed, 14 Mar 2012 12:00:20 +0000
parents 533519ebc0cb
children ae67ea0af696
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@560 8 Copyright (c) 2012 Chris Cannam
Chris@560 9 Copyright (c) 2012 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@145 23 #include "uncommitteditem.h"
Chris@119 24 #include "changesetscene.h"
Chris@44 25
cannam@45 26 #include <QSet>
cannam@45 27 #include <QMap>
Chris@46 28 #include <QPair>
cannam@45 29
cannam@45 30 #include <exception>
Chris@44 31
Chris@44 32 class Grapher
Chris@44 33 {
Chris@44 34 public:
Chris@273 35 Grapher(ChangesetScene *scene);
cannam@45 36
Chris@153 37 void layout(Changesets csets,
Chris@153 38 QStringList uncommittedParents,
Chris@153 39 QString uncommittedBranch);
cannam@45 40
Chris@53 41 ChangesetItem *getItemFor(Changeset *cs);
Chris@371 42 ChangesetItem *getItemFor(QString id);
Chris@53 43
Chris@145 44 UncommittedItem *getUncommittedItem() { return m_uncommitted; }
Chris@145 45
Chris@506 46 void setClosedHeadIds(QSet<QString> closed) { m_closedIds = closed; }
Chris@506 47
cannam@45 48 class LayoutException : public std::exception {
cannam@45 49 public:
cannam@45 50 LayoutException(QString message) throw() : m_message(message) { }
cannam@45 51 virtual ~LayoutException() throw() { }
cannam@45 52 virtual const char *what() const throw() {
cannam@45 53 return m_message.toLocal8Bit().data();
cannam@45 54 }
cannam@45 55 protected:
cannam@45 56 QString m_message;
cannam@45 57 };
cannam@45 58
cannam@45 59 private:
Chris@119 60 ChangesetScene *m_scene;
cannam@45 61
cannam@45 62 typedef QMap<QString, Changeset *> IdChangesetMap;
Chris@46 63 IdChangesetMap m_changesets;
cannam@45 64
cannam@45 65 typedef QMap<QString, ChangesetItem *> IdItemMap;
cannam@45 66 IdItemMap m_items;
cannam@45 67
cannam@45 68 typedef QSet<int> ColumnSet;
cannam@45 69 typedef QMap<int, ColumnSet> GridAlloc;
cannam@45 70 GridAlloc m_alloc;
cannam@45 71
Chris@46 72 typedef QPair<int, int> Range;
Chris@46 73 typedef QMap<QString, Range> BranchRangeMap;
Chris@46 74 BranchRangeMap m_branchRanges;
Chris@46 75
Chris@46 76 typedef QMap<QString, int> BranchColumnMap;
Chris@46 77 BranchColumnMap m_branchHomes;
Chris@46 78
cannam@45 79 typedef QSet<QString> IdSet;
cannam@45 80 IdSet m_handled;
Chris@46 81
Chris@51 82 typedef QMap<int, QString> RowDateMap;
Chris@51 83 RowDateMap m_rowDates;
Chris@51 84
Chris@506 85 QSet<QString> m_closedIds;
Chris@506 86
Chris@273 87 bool m_showDates;
Chris@512 88 bool m_showClosedBranches;
Chris@273 89
Chris@153 90 QStringList m_uncommittedParents;
Chris@145 91 int m_uncommittedParentRow;
Chris@145 92 UncommittedItem *m_uncommitted;
Chris@145 93 bool m_haveAllocatedUncommittedColumn;
Chris@145 94
Chris@46 95 void layoutRow(QString id);
Chris@46 96 void layoutCol(QString id);
Chris@46 97 void allocateBranchHomes(Changesets csets);
Chris@46 98 bool rangesConflict(const Range &r1, const Range &r2);
Chris@268 99 int findAvailableColumn(int row, int parent, bool preferParentCol);
Chris@145 100 bool isAvailable(int row, int col);
Chris@517 101 void markClosedChangesets();
Chris@517 102 void markClosedChangesetsFrom(QString id, QSet<QString> &deferred);
Chris@44 103 };
Chris@44 104
Chris@44 105 #endif