annotate changesetscene.cpp @ 318:124a3ea9fafb easyhg_v0.4

Merge, and add a helpful warning when you try to push before committing your merge (I just did this and the ensuing warning was misleading)
author Chris Cannam
date Wed, 02 Mar 2011 12:38:17 +0000
parents 4811eb34e819
children
rev   line source
Chris@119 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@119 2
Chris@119 3 /*
Chris@119 4 EasyMercurial
Chris@119 5
Chris@119 6 Based on HgExplorer by Jari Korhonen
Chris@119 7 Copyright (c) 2010 Jari Korhonen
Chris@244 8 Copyright (c) 2011 Chris Cannam
Chris@244 9 Copyright (c) 2011 Queen Mary, University of London
Chris@119 10
Chris@119 11 This program is free software; you can redistribute it and/or
Chris@119 12 modify it under the terms of the GNU General Public License as
Chris@119 13 published by the Free Software Foundation; either version 2 of the
Chris@119 14 License, or (at your option) any later version. See the file
Chris@119 15 COPYING included with this distribution for more information.
Chris@119 16 */
Chris@119 17
Chris@119 18 #include "changesetscene.h"
Chris@119 19 #include "changesetitem.h"
Chris@141 20 #include "uncommitteditem.h"
Chris@168 21 #include "dateitem.h"
Chris@119 22
Chris@119 23 ChangesetScene::ChangesetScene()
Chris@119 24 : QGraphicsScene(), m_detailShown(0)
Chris@119 25 {
Chris@119 26 }
Chris@119 27
Chris@119 28 void
Chris@141 29 ChangesetScene::addChangesetItem(ChangesetItem *item)
Chris@141 30 {
Chris@141 31 addItem(item);
Chris@141 32
Chris@141 33 connect(item, SIGNAL(detailShown()),
Chris@141 34 this, SLOT(changesetDetailShown()));
Chris@141 35
Chris@168 36 connect(item, SIGNAL(detailHidden()),
Chris@168 37 this, SLOT(changesetDetailHidden()));
Chris@168 38
Chris@141 39 connect(item, SIGNAL(updateTo(QString)),
Chris@141 40 this, SIGNAL(updateTo(QString)));
Chris@141 41
Chris@141 42 connect(item, SIGNAL(diffToCurrent(QString)),
Chris@141 43 this, SIGNAL(diffToCurrent(QString)));
Chris@141 44
Chris@148 45 connect(item, SIGNAL(diffToParent(QString, QString)),
Chris@148 46 this, SIGNAL(diffToParent(QString, QString)));
Chris@141 47
Chris@289 48 connect(item, SIGNAL(showSummary(Changeset *)),
Chris@289 49 this, SIGNAL(showSummary(Changeset *)));
Chris@288 50
Chris@141 51 connect(item, SIGNAL(mergeFrom(QString)),
Chris@141 52 this, SIGNAL(mergeFrom(QString)));
Chris@141 53
Chris@278 54 connect(item, SIGNAL(newBranch(QString)),
Chris@278 55 this, SIGNAL(newBranch(QString)));
Chris@278 56
Chris@141 57 connect(item, SIGNAL(tag(QString)),
Chris@141 58 this, SIGNAL(tag(QString)));
Chris@141 59 }
Chris@141 60
Chris@141 61 void
Chris@141 62 ChangesetScene::addUncommittedItem(UncommittedItem *item)
Chris@141 63 {
Chris@141 64 addItem(item);
Chris@141 65
Chris@141 66 connect(item, SIGNAL(commit()),
Chris@141 67 this, SIGNAL(commit()));
Chris@141 68
Chris@141 69 connect(item, SIGNAL(revert()),
Chris@141 70 this, SIGNAL(revert()));
Chris@141 71
Chris@141 72 connect(item, SIGNAL(diff()),
Chris@141 73 this, SIGNAL(diffWorkingFolder()));
Chris@153 74
Chris@168 75 connect(item, SIGNAL(showSummary()),
Chris@168 76 this, SIGNAL(showSummary()));
Chris@168 77
Chris@153 78 connect(item, SIGNAL(showWork()),
Chris@153 79 this, SIGNAL(showWork()));
Chris@311 80
Chris@311 81 connect(item, SIGNAL(newBranch()),
Chris@311 82 this, SIGNAL(newBranch()));
Chris@311 83
Chris@311 84 connect(item, SIGNAL(noBranch()),
Chris@311 85 this, SIGNAL(noBranch()));
Chris@311 86
Chris@141 87 }
Chris@141 88
Chris@141 89 void
Chris@168 90 ChangesetScene::addDateItem(DateItem *item)
Chris@168 91 {
Chris@168 92 addItem(item);
Chris@168 93
Chris@168 94 connect(item, SIGNAL(clicked()),
Chris@168 95 this, SLOT(dateItemClicked()));
Chris@168 96 }
Chris@168 97
Chris@168 98 void
Chris@119 99 ChangesetScene::changesetDetailShown()
Chris@119 100 {
Chris@119 101 ChangesetItem *csi = qobject_cast<ChangesetItem *>(sender());
Chris@119 102 if (!csi) return;
Chris@119 103
Chris@124 104 if (m_detailShown && m_detailShown != csi) {
Chris@119 105 m_detailShown->hideDetail();
Chris@119 106 }
Chris@119 107 m_detailShown = csi;
Chris@119 108 }
Chris@119 109
Chris@168 110 void
Chris@168 111 ChangesetScene::changesetDetailHidden()
Chris@168 112 {
Chris@168 113 m_detailShown = 0;
Chris@168 114 }
Chris@168 115
Chris@168 116 void
Chris@168 117 ChangesetScene::dateItemClicked()
Chris@168 118 {
Chris@168 119 if (m_detailShown) {
Chris@168 120 m_detailShown->hideDetail();
Chris@168 121 }
Chris@168 122 }
Chris@168 123
Chris@281 124 ChangesetItem *
Chris@281 125 ChangesetScene::getItemById(QString id)
Chris@281 126 {
Chris@281 127 foreach (QGraphicsItem *it, items()) {
Chris@281 128 ChangesetItem *csit = dynamic_cast<ChangesetItem *>(it);
Chris@281 129 if (csit && csit->getId() == id) return csit;
Chris@281 130 }
Chris@288 131 return 0;
Chris@281 132 }
Chris@281 133
Chris@281 134