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@141
|
54 connect(item, SIGNAL(tag(QString)),
|
Chris@141
|
55 this, SIGNAL(tag(QString)));
|
Chris@141
|
56 }
|
Chris@141
|
57
|
Chris@141
|
58 void
|
Chris@141
|
59 ChangesetScene::addUncommittedItem(UncommittedItem *item)
|
Chris@141
|
60 {
|
Chris@141
|
61 addItem(item);
|
Chris@141
|
62
|
Chris@141
|
63 connect(item, SIGNAL(commit()),
|
Chris@141
|
64 this, SIGNAL(commit()));
|
Chris@141
|
65
|
Chris@141
|
66 connect(item, SIGNAL(revert()),
|
Chris@141
|
67 this, SIGNAL(revert()));
|
Chris@141
|
68
|
Chris@141
|
69 connect(item, SIGNAL(diff()),
|
Chris@141
|
70 this, SIGNAL(diffWorkingFolder()));
|
Chris@153
|
71
|
Chris@168
|
72 connect(item, SIGNAL(showSummary()),
|
Chris@168
|
73 this, SIGNAL(showSummary()));
|
Chris@168
|
74
|
Chris@153
|
75 connect(item, SIGNAL(showWork()),
|
Chris@153
|
76 this, SIGNAL(showWork()));
|
Chris@141
|
77 }
|
Chris@141
|
78
|
Chris@141
|
79 void
|
Chris@168
|
80 ChangesetScene::addDateItem(DateItem *item)
|
Chris@168
|
81 {
|
Chris@168
|
82 addItem(item);
|
Chris@168
|
83
|
Chris@168
|
84 connect(item, SIGNAL(clicked()),
|
Chris@168
|
85 this, SLOT(dateItemClicked()));
|
Chris@168
|
86 }
|
Chris@168
|
87
|
Chris@168
|
88 void
|
Chris@119
|
89 ChangesetScene::changesetDetailShown()
|
Chris@119
|
90 {
|
Chris@119
|
91 ChangesetItem *csi = qobject_cast<ChangesetItem *>(sender());
|
Chris@119
|
92 if (!csi) return;
|
Chris@119
|
93
|
Chris@124
|
94 if (m_detailShown && m_detailShown != csi) {
|
Chris@119
|
95 m_detailShown->hideDetail();
|
Chris@119
|
96 }
|
Chris@119
|
97 m_detailShown = csi;
|
Chris@119
|
98 }
|
Chris@119
|
99
|
Chris@168
|
100 void
|
Chris@168
|
101 ChangesetScene::changesetDetailHidden()
|
Chris@168
|
102 {
|
Chris@168
|
103 m_detailShown = 0;
|
Chris@168
|
104 }
|
Chris@168
|
105
|
Chris@168
|
106 void
|
Chris@168
|
107 ChangesetScene::dateItemClicked()
|
Chris@168
|
108 {
|
Chris@168
|
109 if (m_detailShown) {
|
Chris@168
|
110 m_detailShown->hideDetail();
|
Chris@168
|
111 }
|
Chris@168
|
112 }
|
Chris@168
|
113
|
Chris@281
|
114 ChangesetItem *
|
Chris@281
|
115 ChangesetScene::getItemById(QString id)
|
Chris@281
|
116 {
|
Chris@281
|
117 foreach (QGraphicsItem *it, items()) {
|
Chris@281
|
118 ChangesetItem *csit = dynamic_cast<ChangesetItem *>(it);
|
Chris@281
|
119 if (csit && csit->getId() == id) return csit;
|
Chris@281
|
120 }
|
Chris@288
|
121 return 0;
|
Chris@281
|
122 }
|
Chris@281
|
123
|
Chris@281
|
124
|