Mercurial > hg > easyhg
changeset 288:ca6edd303c9d
Add "Summarise changes" options to changeset item right-button menu (already existed for uncommitted item)
author | Chris Cannam |
---|---|
date | Mon, 21 Feb 2011 11:37:58 +0000 |
parents | 769ab0fa125d |
children | 37f67999b661 |
files | changesetitem.cpp changesetitem.h changesetscene.cpp changesetscene.h hgaction.h hgtabwidget.cpp hgtabwidget.h historywidget.cpp historywidget.h mainwindow.cpp mainwindow.h |
diffstat | 11 files changed, 113 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/changesetitem.cpp Mon Feb 21 09:13:22 2011 +0000 +++ b/changesetitem.cpp Mon Feb 21 11:37:58 2011 +0000 @@ -108,6 +108,7 @@ ChangesetItem::activateMenu() { m_parentDiffActions.clear(); + m_summaryActions.clear(); QMenu *menu = new QMenu; QLabel *label = new QLabel(tr("<qt><b> Revision: </b>%1</qt>") @@ -120,16 +121,13 @@ QAction *copyId = menu->addAction(tr("Copy identifier to clipboard")); connect(copyId, SIGNAL(triggered()), this, SLOT(copyIdActivated())); - menu->addSeparator(); - QStringList parents = m_changeset->parents(); + QString leftId, rightId; + bool havePositions = false; + 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]); @@ -144,37 +142,59 @@ havePositions = true; } } + } + if (parents.size() > 1) { + if (havePositions) { + QAction *stat = menu->addAction(tr("Summarise changes from left parent")); + connect(stat, SIGNAL(triggered()), this, SLOT(showSummaryToParentActivated())); + m_summaryActions[stat] = leftId; + + stat = menu->addAction(tr("Summarise changes from right parent")); + connect(stat, SIGNAL(triggered()), this, SLOT(showSummaryToParentActivated())); + m_summaryActions[stat] = rightId; + } else { + + foreach (QString parentId, parents) { + QString text = tr("Summarise changes from parent %1").arg(Changeset::hashOf(parentId)); + QAction *stat = menu->addAction(text); + connect(stat, SIGNAL(triggered()), this, SLOT(showSummaryToParentActivated())); + m_summaryActions[stat] = parentId; + } + + } + } else { + QAction *stat = menu->addAction(tr("Summarise changes")); + connect(stat, SIGNAL(triggered()), this, SLOT(showSummaryToParentActivated())); + } + + menu->addSeparator(); + + if (parents.size() > 1) { if (havePositions) { - QAction *diffParent = menu->addAction(tr("Diff to left parent")); - connect(diffParent, SIGNAL(triggered()), - this, SLOT(diffToParentActivated())); - m_parentDiffActions[diffParent] = leftId; + QAction *diff = menu->addAction(tr("Diff to left parent")); + connect(diff, SIGNAL(triggered()), this, SLOT(diffToParentActivated())); + m_parentDiffActions[diff] = leftId; - diffParent = menu->addAction(tr("Diff to right parent")); - connect(diffParent, SIGNAL(triggered()), - this, SLOT(diffToParentActivated())); - m_parentDiffActions[diffParent] = rightId; + diff = menu->addAction(tr("Diff to right parent")); + connect(diff, SIGNAL(triggered()), this, SLOT(diffToParentActivated())); + m_parentDiffActions[diff] = 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; + QString text = tr("Diff to parent %1").arg(Changeset::hashOf(parentId)); + QAction *diff = menu->addAction(text); + connect(diff, SIGNAL(triggered()), this, SLOT(diffToParentActivated())); + m_parentDiffActions[diff] = parentId; } } } else { - QAction *diffParent = - menu->addAction(tr("Diff to parent")); - connect(diffParent, SIGNAL(triggered()), - this, SLOT(diffToParentActivated())); + QAction *diff = menu->addAction(tr("Diff to parent")); + connect(diff, SIGNAL(triggered()), this, SLOT(diffToParentActivated())); } QAction *diffCurrent = menu->addAction(tr("Diff to current working folder")); @@ -223,14 +243,31 @@ emit diffToParent(getId(), parentId); } +void ChangesetItem::showSummaryToParentActivated() +{ + QAction *a = qobject_cast<QAction *>(sender()); + QString parentId; + if (m_summaryActions.contains(a)) { + parentId = m_summaryActions[a]; + DEBUG << "ChangesetItem::showSummaryToParentActivated: specific parent " + << parentId << " selected" << endl; + } else { + parentId = m_changeset->parents()[0]; + DEBUG << "ChangesetItem::showSummaryToParentActivated: " + << "no specific parent selected, using first parent " + << parentId << endl; + } + + emit showSummaryToParent(getId(), parentId); +} + void ChangesetItem::updateActivated() { emit updateTo(getId()); } void ChangesetItem::diffToCurrentActivated() { emit diffToCurrent(getId()); } void ChangesetItem::mergeActivated() { emit mergeFrom(getId()); } void ChangesetItem::tagActivated() { emit tag(getId()); } void -ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *option, - QWidget *w) +ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *, QWidget *) { paint->save();
--- a/changesetitem.h Mon Feb 21 09:13:22 2011 +0000 +++ b/changesetitem.h Mon Feb 21 11:37:58 2011 +0000 @@ -63,6 +63,7 @@ void updateTo(QString); void diffToCurrent(QString); void diffToParent(QString child, QString parent); + void showSummaryToParent(QString child, QString parent); void mergeFrom(QString); void tag(QString); @@ -74,6 +75,7 @@ void copyIdActivated(); void updateActivated(); void diffToParentActivated(); + void showSummaryToParentActivated(); void diffToCurrentActivated(); void mergeActivated(); void tagActivated(); @@ -95,6 +97,7 @@ bool m_new; QMap<QAction *, QString> m_parentDiffActions; + QMap<QAction *, QString> m_summaryActions; }; #endif // CHANGESETITEM_H
--- a/changesetscene.cpp Mon Feb 21 09:13:22 2011 +0000 +++ b/changesetscene.cpp Mon Feb 21 11:37:58 2011 +0000 @@ -45,6 +45,9 @@ connect(item, SIGNAL(diffToParent(QString, QString)), this, SIGNAL(diffToParent(QString, QString))); + connect(item, SIGNAL(showSummaryToParent(QString, QString)), + this, SIGNAL(showSummaryToParent(QString, QString))); + connect(item, SIGNAL(mergeFrom(QString)), this, SIGNAL(mergeFrom(QString))); @@ -115,6 +118,7 @@ ChangesetItem *csit = dynamic_cast<ChangesetItem *>(it); if (csit && csit->getId() == id) return csit; } + return 0; }
--- a/changesetscene.h Mon Feb 21 09:13:22 2011 +0000 +++ b/changesetscene.h Mon Feb 21 11:37:58 2011 +0000 @@ -46,6 +46,7 @@ void updateTo(QString id); void diffToParent(QString id, QString parent); + void showSummaryToParent(QString id, QString parent); void diffToCurrent(QString id); void mergeFrom(QString id); void tag(QString id);
--- a/hgaction.h Mon Feb 21 09:13:22 2011 +0000 +++ b/hgaction.h Mon Feb 21 11:37:58 2011 +0000 @@ -43,6 +43,7 @@ ACT_INIT, ACT_COMMIT, ACT_ANNOTATE, + ACT_UNCOMMITTED_SUMMARY, ACT_DIFF_SUMMARY, ACT_FOLDERDIFF, ACT_CHGSETDIFF,
--- a/hgtabwidget.cpp Mon Feb 21 09:13:22 2011 +0000 +++ b/hgtabwidget.cpp Mon Feb 21 11:37:58 2011 +0000 @@ -69,6 +69,9 @@ connect(m_historyWidget, SIGNAL(diffToParent(QString, QString)), this, SIGNAL(diffToParent(QString, QString))); + connect(m_historyWidget, SIGNAL(showSummaryToParent(QString, QString)), + this, SIGNAL(showSummaryToParent(QString, QString))); + connect(m_historyWidget, SIGNAL(mergeFrom(QString)), this, SIGNAL(mergeFrom(QString)));
--- a/hgtabwidget.h Mon Feb 21 09:13:22 2011 +0000 +++ b/hgtabwidget.h Mon Feb 21 11:37:58 2011 +0000 @@ -91,6 +91,7 @@ void updateTo(QString id); void diffToParent(QString id, QString parent); + void showSummaryToParent(QString id, QString parent); void diffToCurrent(QString id); void mergeFrom(QString id); void tag(QString id);
--- a/historywidget.cpp Mon Feb 21 09:13:22 2011 +0000 +++ b/historywidget.cpp Mon Feb 21 11:37:58 2011 +0000 @@ -277,6 +277,9 @@ connect(scene, SIGNAL(diffToParent(QString, QString)), this, SIGNAL(diffToParent(QString, QString))); + connect(scene, SIGNAL(showSummaryToParent(QString, QString)), + this, SIGNAL(showSummaryToParent(QString, QString))); + connect(scene, SIGNAL(mergeFrom(QString)), this, SIGNAL(mergeFrom(QString)));
--- a/historywidget.h Mon Feb 21 09:13:22 2011 +0000 +++ b/historywidget.h Mon Feb 21 11:37:58 2011 +0000 @@ -54,6 +54,7 @@ void updateTo(QString id); void diffToParent(QString id, QString parent); + void showSummaryToParent(QString id, QString parent); void diffToCurrent(QString id); void mergeFrom(QString id); void tag(QString id);
--- a/mainwindow.cpp Mon Feb 21 09:13:22 2011 +0000 +++ b/mainwindow.cpp Mon Feb 21 11:37:58 2011 +0000 @@ -545,7 +545,7 @@ params << "diff" << "--stat"; - m_runner->requestAction(HgAction(ACT_DIFF_SUMMARY, m_workFolderPath, params)); + m_runner->requestAction(HgAction(ACT_UNCOMMITTED_SUMMARY, m_workFolderPath, params)); } void MainWindow::hgFolderDiff() @@ -601,6 +601,18 @@ } +void MainWindow::hgShowSummaryToParent(QString child, QString parent) +{ + QStringList params; + + params << "diff" << "--stat" + << "--rev" << Changeset::hashOf(parent) + << "--rev" << Changeset::hashOf(child); + + m_runner->requestAction(HgAction(ACT_DIFF_SUMMARY, m_workFolderPath, params)); +} + + void MainWindow::hgUpdate() { QStringList params; @@ -1897,13 +1909,28 @@ m_shouldHgStat = true; break; - case ACT_DIFF_SUMMARY: + case ACT_UNCOMMITTED_SUMMARY: QMessageBox::information(this, tr("Change summary"), format3(tr("Summary of uncommitted changes"), "", output)); break; + case ACT_DIFF_SUMMARY: + if (output == "") { + // Can happen, for a merge commit + QMessageBox::information(this, tr("Change summary"), + format3(tr("Summary of changes"), + tr("No changes"), + output)); + } else { + QMessageBox::information(this, tr("Change summary"), + format3(tr("Summary of changes"), + "", + output)); + } + break; + case ACT_FOLDERDIFF: case ACT_CHGSETDIFF: case ACT_SERVE: @@ -2079,6 +2106,9 @@ connect(m_hgTabs, SIGNAL(diffToParent(QString, QString)), this, SLOT(hgDiffToParent(QString, QString))); + connect(m_hgTabs, SIGNAL(showSummaryToParent(QString, QString)), + this, SLOT(hgShowSummaryToParent(QString, QString))); + connect(m_hgTabs, SIGNAL(mergeFrom(QString)), this, SLOT(hgMergeFrom(QString)));
--- a/mainwindow.h Mon Feb 21 09:13:22 2011 +0000 +++ b/mainwindow.h Mon Feb 21 11:37:58 2011 +0000 @@ -69,6 +69,7 @@ void hgAdd(); void hgCommit(); void hgShowSummary(); + void hgShowSummaryToParent(QString, QString); void hgFolderDiff(); void hgDiffToCurrent(QString); void hgDiffToParent(QString, QString);