Chris@57
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@57
|
2
|
Chris@57
|
3 /*
|
Chris@57
|
4 EasyMercurial
|
Chris@57
|
5
|
Chris@57
|
6 Based on HgExplorer by Jari Korhonen
|
Chris@57
|
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@57
|
10
|
Chris@57
|
11 This program is free software; you can redistribute it and/or
|
Chris@57
|
12 modify it under the terms of the GNU General Public License as
|
Chris@57
|
13 published by the Free Software Foundation; either version 2 of the
|
Chris@57
|
14 License, or (at your option) any later version. See the file
|
Chris@57
|
15 COPYING included with this distribution for more information.
|
Chris@57
|
16 */
|
Chris@57
|
17
|
Chris@43
|
18 #ifndef CHANGESETITEM_H
|
Chris@43
|
19 #define CHANGESETITEM_H
|
Chris@43
|
20
|
Chris@168
|
21 #include <QGraphicsObject>
|
Chris@53
|
22 #include <QFont>
|
Chris@43
|
23
|
Chris@43
|
24 class Changeset;
|
Chris@117
|
25 class ChangesetDetailItem;
|
Chris@43
|
26
|
Chris@153
|
27 class QAction;
|
Chris@390
|
28 class QImage;
|
Chris@153
|
29
|
Chris@168
|
30 class ChangesetItem : public QGraphicsObject
|
Chris@43
|
31 {
|
Chris@119
|
32 Q_OBJECT
|
Chris@119
|
33
|
Chris@43
|
34 public:
|
Chris@53
|
35 ChangesetItem(Changeset *cs);
|
Chris@43
|
36
|
Chris@43
|
37 virtual QRectF boundingRect() const;
|
Chris@43
|
38 virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
Chris@43
|
39
|
Chris@53
|
40 Changeset *getChangeset() { return m_changeset; }
|
Chris@141
|
41 QString getId();
|
Chris@53
|
42
|
Chris@44
|
43 int column() const { return m_column; }
|
Chris@44
|
44 int row() const { return m_row; }
|
Chris@46
|
45 void setColumn(int c) { m_column = c; setX(c * 100); }
|
Chris@53
|
46 void setRow(int r) { m_row = r; setY(r * 90); }
|
Chris@44
|
47
|
Chris@55
|
48 bool isWide() const { return m_wide; }
|
Chris@55
|
49 void setWide(bool w) { m_wide = w; }
|
Chris@55
|
50
|
Chris@128
|
51 bool isCurrent() const { return m_current; }
|
Chris@128
|
52 void setCurrent(bool c) { m_current = c; }
|
Chris@128
|
53
|
Chris@508
|
54 // Closed is true if this changeset is on a closed branch
|
Chris@510
|
55 bool isClosed() const;
|
Chris@506
|
56
|
Chris@508
|
57 // Closing is true if this changeset is the commit that closed its
|
Chris@508
|
58 // branch (i.e. is at the end of a closed branch)
|
Chris@508
|
59 bool isClosingCommit() const { return m_closing; }
|
Chris@508
|
60 void setClosingCommit(bool c) { m_closing = c; }
|
Chris@508
|
61
|
Chris@133
|
62 bool isNew() const { return m_new; }
|
Chris@133
|
63 void setNew(bool n) { m_new = n; }
|
Chris@133
|
64
|
Chris@153
|
65 bool showBranch() const { return m_showBranch; }
|
Chris@74
|
66 void setShowBranch(bool s) { m_showBranch = s; }
|
Chris@74
|
67
|
Chris@555
|
68 bool setSearchText(QString text); // return true if it matches
|
Chris@555
|
69
|
Chris@119
|
70 signals:
|
Chris@119
|
71 void detailShown();
|
Chris@119
|
72 void detailHidden();
|
Chris@119
|
73
|
Chris@141
|
74 void updateTo(QString);
|
Chris@141
|
75 void diffToCurrent(QString);
|
Chris@148
|
76 void diffToParent(QString child, QString parent);
|
Chris@289
|
77 void showSummary(Changeset *);
|
Chris@141
|
78 void mergeFrom(QString);
|
Chris@278
|
79 void newBranch(QString);
|
Chris@514
|
80 void closeBranch(QString);
|
Chris@141
|
81 void tag(QString);
|
Chris@141
|
82
|
Chris@119
|
83 public slots:
|
Chris@119
|
84 void showDetail();
|
Chris@119
|
85 void hideDetail();
|
Chris@119
|
86
|
Chris@141
|
87 private slots:
|
Chris@153
|
88 void copyIdActivated();
|
Chris@141
|
89 void updateActivated();
|
Chris@153
|
90 void diffToParentActivated();
|
Chris@289
|
91 void showSummaryActivated();
|
Chris@141
|
92 void diffToCurrentActivated();
|
Chris@141
|
93 void mergeActivated();
|
Chris@141
|
94 void tagActivated();
|
Chris@278
|
95 void newBranchActivated();
|
Chris@514
|
96 void closeBranchActivated();
|
Chris@141
|
97
|
Chris@117
|
98 protected:
|
Chris@117
|
99 virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
|
Chris@474
|
100 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *);
|
Chris@117
|
101
|
Chris@43
|
102 private:
|
Chris@140
|
103 void activateMenu();
|
Chris@140
|
104
|
Chris@53
|
105 QFont m_font;
|
Chris@43
|
106 Changeset *m_changeset;
|
Chris@117
|
107 ChangesetDetailItem *m_detail;
|
Chris@74
|
108 bool m_showBranch;
|
Chris@44
|
109 int m_column;
|
Chris@44
|
110 int m_row;
|
Chris@55
|
111 bool m_wide;
|
Chris@128
|
112 bool m_current;
|
Chris@508
|
113 bool m_closing;
|
Chris@133
|
114 bool m_new;
|
Chris@555
|
115 QString m_searchText;
|
Chris@555
|
116 bool m_searchMatches;
|
Chris@153
|
117
|
Chris@153
|
118 QMap<QAction *, QString> m_parentDiffActions;
|
Chris@288
|
119 QMap<QAction *, QString> m_summaryActions;
|
Chris@387
|
120
|
Chris@390
|
121 static QImage *m_star;
|
Chris@390
|
122
|
Chris@387
|
123 bool isMerge() const;
|
Chris@399
|
124 void paintNormal(QPainter *);
|
Chris@508
|
125 void paintSimple(QPainter *);
|
Chris@43
|
126 };
|
Chris@43
|
127
|
Chris@43
|
128 #endif // CHANGESETITEM_H
|