Mercurial > hg > easyhg
changeset 282:1ec306df738e
Merge
author | Chris Cannam |
---|---|
date | Fri, 18 Feb 2011 13:39:16 +0000 |
parents | 9162f14c5ab7 (diff) a98e76fa58f2 (current diff) |
children | bc39f2e28da8 a68801b31ceb 769ab0fa125d |
files | mainwindow.cpp |
diffstat | 4 files changed, 56 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/changesetitem.cpp Thu Feb 17 12:10:09 2011 +0000 +++ b/changesetitem.cpp Fri Feb 18 13:39:16 2011 +0000 @@ -16,6 +16,7 @@ */ #include "changesetitem.h" +#include "changesetscene.h" #include "changesetdetailitem.h" #include "changeset.h" #include "textabbrev.h" @@ -121,15 +122,51 @@ menu->addSeparator(); - if (m_changeset->parents().size() > 1) { + QStringList parents = m_changeset->parents(); - foreach (QString parentId, m_changeset->parents()) { - QAction *diffParent = - menu->addAction(tr("Diff to parent %1") - .arg(Changeset::hashOf(parentId))); + if (parents.size() > 1) { + + QString leftId, rightId; + ChangesetScene *cs = dynamic_cast<ChangesetScene *>(scene()); + bool havePositions = false; + + if (cs && parents.size() == 2) { + ChangesetItem *i0 = cs->getItemById(parents[0]); + ChangesetItem *i1 = cs->getItemById(parents[1]); + if (i0 && i1) { + if (i0->x() < i1->x()) { + leftId = parents[0]; + rightId = parents[1]; + } else { + leftId = parents[1]; + rightId = parents[0]; + } + havePositions = true; + } + } + + if (havePositions) { + + QAction *diffParent = menu->addAction(tr("Diff to left parent")); connect(diffParent, SIGNAL(triggered()), this, SLOT(diffToParentActivated())); - m_parentDiffActions[diffParent] = parentId; + m_parentDiffActions[diffParent] = leftId; + + diffParent = menu->addAction(tr("Diff to right parent")); + connect(diffParent, SIGNAL(triggered()), + this, SLOT(diffToParentActivated())); + m_parentDiffActions[diffParent] = rightId; + + } else { + + foreach (QString parentId, parents) { + QString text = tr("Diff to parent %1") + .arg(Changeset::hashOf(parentId)); + QAction *diffParent = menu->addAction(text); + connect(diffParent, SIGNAL(triggered()), + this, SLOT(diffToParentActivated())); + m_parentDiffActions[diffParent] = parentId; + } } } else {
--- a/changesetscene.cpp Thu Feb 17 12:10:09 2011 +0000 +++ b/changesetscene.cpp Fri Feb 18 13:39:16 2011 +0000 @@ -108,3 +108,13 @@ } } +ChangesetItem * +ChangesetScene::getItemById(QString id) +{ + foreach (QGraphicsItem *it, items()) { + ChangesetItem *csit = dynamic_cast<ChangesetItem *>(it); + if (csit && csit->getId() == id) return csit; + } +} + +
--- a/changesetscene.h Thu Feb 17 12:10:09 2011 +0000 +++ b/changesetscene.h Fri Feb 18 13:39:16 2011 +0000 @@ -35,6 +35,8 @@ void addUncommittedItem(UncommittedItem *item); void addDateItem(DateItem *item); + ChangesetItem *getItemById(QString id); // Slow: traversal required + signals: void commit(); void revert();
--- a/mainwindow.cpp Thu Feb 17 12:10:09 2011 +0000 +++ b/mainwindow.cpp Fri Feb 18 13:39:16 2011 +0000 @@ -590,7 +590,7 @@ QStringList params; - // Diff given revision against working folder + // Diff given revision against parent revision params << "--config" << "extensions.extdiff=" << "extdiff"; params << "--program" << diff;