Chris@57: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@57: Chris@57: /* Chris@57: EasyMercurial Chris@57: Chris@57: Based on HgExplorer by Jari Korhonen Chris@57: Copyright (c) 2010 Jari Korhonen Chris@57: Copyright (c) 2010 Chris Cannam Chris@57: Copyright (c) 2010 Queen Mary, University of London Chris@57: Chris@57: This program is free software; you can redistribute it and/or Chris@57: modify it under the terms of the GNU General Public License as Chris@57: published by the Free Software Foundation; either version 2 of the Chris@57: License, or (at your option) any later version. See the file Chris@57: COPYING included with this distribution for more information. Chris@57: */ Chris@57: Chris@44: #ifndef GRAPHER_H Chris@44: #define GRAPHER_H Chris@44: Chris@44: #include "changeset.h" Chris@44: #include "changesetitem.h" Chris@145: #include "uncommitteditem.h" Chris@119: #include "changesetscene.h" Chris@44: cannam@45: #include cannam@45: #include Chris@46: #include cannam@45: cannam@45: #include Chris@44: Chris@44: class Grapher Chris@44: { Chris@44: public: Chris@119: Grapher(ChangesetScene *scene) { m_scene = scene; } cannam@45: Chris@153: void layout(Changesets csets, Chris@153: QStringList uncommittedParents, Chris@153: QString uncommittedBranch); cannam@45: Chris@53: ChangesetItem *getItemFor(Changeset *cs); Chris@53: Chris@145: UncommittedItem *getUncommittedItem() { return m_uncommitted; } Chris@145: cannam@45: class LayoutException : public std::exception { cannam@45: public: cannam@45: LayoutException(QString message) throw() : m_message(message) { } cannam@45: virtual ~LayoutException() throw() { } cannam@45: virtual const char *what() const throw() { cannam@45: return m_message.toLocal8Bit().data(); cannam@45: } cannam@45: protected: cannam@45: QString m_message; cannam@45: }; cannam@45: cannam@45: private: Chris@119: ChangesetScene *m_scene; cannam@45: cannam@45: typedef QMap IdChangesetMap; Chris@46: IdChangesetMap m_changesets; cannam@45: cannam@45: typedef QMap IdItemMap; cannam@45: IdItemMap m_items; cannam@45: cannam@45: typedef QSet ColumnSet; cannam@45: typedef QMap GridAlloc; cannam@45: GridAlloc m_alloc; cannam@45: Chris@46: typedef QPair Range; Chris@46: typedef QMap BranchRangeMap; Chris@46: BranchRangeMap m_branchRanges; Chris@46: Chris@46: typedef QMap BranchColumnMap; Chris@46: BranchColumnMap m_branchHomes; Chris@46: cannam@45: typedef QSet IdSet; cannam@45: IdSet m_handled; Chris@46: Chris@51: typedef QMap RowDateMap; Chris@51: RowDateMap m_rowDates; Chris@51: Chris@153: QStringList m_uncommittedParents; Chris@145: int m_uncommittedParentRow; Chris@145: UncommittedItem *m_uncommitted; Chris@145: bool m_haveAllocatedUncommittedColumn; Chris@145: Chris@46: void layoutRow(QString id); Chris@46: void layoutCol(QString id); Chris@46: void allocateBranchHomes(Changesets csets); Chris@46: bool rangesConflict(const Range &r1, const Range &r2); Chris@185: int findAvailableColumn(int row, int parent, int sign, bool preferParentCol); Chris@145: bool isAvailable(int row, int col); Chris@44: }; Chris@44: Chris@44: #endif