# HG changeset patch # User Chris Cannam # Date 1318933800 -3600 # Node ID c623ce6b3104b755814bff920a37c8e139a8ac51 # Parent 6f371814509d8d0b2c87410d73e89f00670de837 Refactor: make closed a changeset property (not a changeset item one) diff -r 6f371814509d -r c623ce6b3104 src/changeset.cpp --- a/src/changeset.cpp Tue Oct 18 11:21:20 2011 +0100 +++ b/src/changeset.cpp Tue Oct 18 11:30:00 2011 +0100 @@ -21,7 +21,8 @@ #include -Changeset::Changeset(const LogEntry &e) +Changeset::Changeset(const LogEntry &e) : + m_closed(false) { foreach (QString key, e.keys()) { if (key == "parents") { diff -r 6f371814509d -r c623ce6b3104 src/changeset.h --- a/src/changeset.h Tue Oct 18 11:21:20 2011 +0100 +++ b/src/changeset.h Tue Oct 18 11:30:00 2011 +0100 @@ -65,6 +65,12 @@ */ QStringList children() const { return m_children; } + /** + * The closed property is not obtained from Hg, but set in + * Grapher::layout() based on traversing closed branch graphs + */ + bool closed() const { return m_closed; } + int number() const { return id().split(':')[0].toInt(); } @@ -119,6 +125,7 @@ void ageChanged(QString age); void parentsChanged(QStringList parents); void childrenChanged(QStringList children); + void closedChanged(bool closed); void commentChanged(QString comment); public slots: @@ -133,6 +140,7 @@ void setParents(QStringList parents) { m_parents = parents; emit parentsChanged(parents); } void setChildren(QStringList children) { m_children = children; emit childrenChanged(m_children); } void addChild(QString child) { m_children.push_back(child); emit childrenChanged(m_children); } + void setClosed(bool closed) { m_closed = closed; emit closedChanged(closed); } void setComment(QString comment) { m_comment = comment; emit commentChanged(comment); } private: @@ -145,6 +153,7 @@ QString m_age; QStringList m_parents; QStringList m_children; + bool m_closed; QString m_comment; }; diff -r 6f371814509d -r c623ce6b3104 src/changesetitem.cpp --- a/src/changesetitem.cpp Tue Oct 18 11:21:20 2011 +0100 +++ b/src/changesetitem.cpp Tue Oct 18 11:30:00 2011 +0100 @@ -38,7 +38,7 @@ ChangesetItem::ChangesetItem(Changeset *cs) : m_changeset(cs), m_detail(0), m_showBranch(false), m_column(0), m_row(0), m_wide(false), - m_current(false), m_closed(false), m_closing(false), m_new(false) + m_current(false), m_closing(false), m_new(false) { m_font = QFont(); m_font.setPixelSize(11); @@ -257,13 +257,19 @@ return (m_changeset && m_changeset->parents().size() > 1); } +bool +ChangesetItem::isClosed() const +{ + return (m_changeset && m_changeset->closed()); +} + void ChangesetItem::paintNormal(QPainter *paint) { paint->save(); int alpha = 255; - if (m_closed) alpha = 90; + if (isClosed()) alpha = 90; ColourSet *colourSet = ColourSet::instance(); QColor branchColour = colourSet->getColourFor(m_changeset->branch()); @@ -438,7 +444,7 @@ paint->save(); int alpha = 255; - if (m_closed) alpha = 90; + if (isClosed()) alpha = 90; ColourSet *colourSet = ColourSet::instance(); QColor branchColour = colourSet->getColourFor(m_changeset->branch()); diff -r 6f371814509d -r c623ce6b3104 src/changesetitem.h --- a/src/changesetitem.h Tue Oct 18 11:21:20 2011 +0100 +++ b/src/changesetitem.h Tue Oct 18 11:30:00 2011 +0100 @@ -52,8 +52,7 @@ void setCurrent(bool c) { m_current = c; } // Closed is true if this changeset is on a closed branch - bool isClosed() const { return m_closed; } - void setClosed(bool c) { m_closed = c; } + bool isClosed() const; // Closing is true if this changeset is the commit that closed its // branch (i.e. is at the end of a closed branch) @@ -107,7 +106,6 @@ int m_row; bool m_wide; bool m_current; - bool m_closed; bool m_closing; bool m_new; diff -r 6f371814509d -r c623ce6b3104 src/grapher.cpp --- a/src/grapher.cpp Tue Oct 18 11:21:20 2011 +0100 +++ b/src/grapher.cpp Tue Oct 18 11:30:00 2011 +0100 @@ -451,7 +451,7 @@ break; } - item->setClosed(true); + cs->setClosed(true); int pcount = cs->parents().size(); if (pcount >= 1) {