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@57
|
8 Copyright (c) 2010 Chris Cannam
|
Chris@57
|
9 Copyright (c) 2010 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 CHANGESET_H
|
Chris@43
|
19 #define CHANGESET_H
|
Chris@43
|
20
|
Chris@43
|
21 #include <QObject>
|
Chris@43
|
22 #include <QString>
|
Chris@43
|
23 #include <QStringList>
|
Chris@43
|
24 #include <QList>
|
Chris@106
|
25 #include <QSharedPointer>
|
Chris@106
|
26
|
Chris@106
|
27 #include "logparser.h"
|
Chris@43
|
28
|
Chris@108
|
29 class Changeset;
|
Chris@108
|
30
|
Chris@108
|
31 typedef QList<Changeset *> Changesets; //!!! should be QList<QSharedPointer<Changeset> >
|
Chris@108
|
32
|
Chris@43
|
33 class Changeset : public QObject
|
Chris@43
|
34 {
|
Chris@43
|
35 Q_OBJECT
|
Chris@43
|
36
|
Chris@43
|
37 Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged STORED true);
|
Chris@125
|
38 Q_PROPERTY(QString user READ user WRITE setUser NOTIFY userChanged STORED true);
|
Chris@43
|
39 Q_PROPERTY(QString branch READ branch WRITE setBranch NOTIFY branchChanged STORED true);
|
Chris@44
|
40 Q_PROPERTY(QString tag READ tag WRITE setTag NOTIFY tagChanged STORED true);
|
Chris@52
|
41 Q_PROPERTY(QString datetime READ datetime WRITE setDatetime NOTIFY datetimeChanged STORED true);
|
Chris@52
|
42 Q_PROPERTY(qulonglong timestamp READ timestamp WRITE setTimestamp NOTIFY timestampChanged STORED true);
|
Chris@43
|
43 Q_PROPERTY(QString age READ age WRITE setAge NOTIFY ageChanged STORED true);
|
Chris@43
|
44 Q_PROPERTY(QStringList parents READ parents WRITE setParents NOTIFY parentsChanged STORED true);
|
Chris@47
|
45 Q_PROPERTY(QStringList children READ children WRITE setChildren NOTIFY childrenChanged STORED true);
|
Chris@43
|
46 Q_PROPERTY(QString comment READ comment WRITE setComment NOTIFY commentChanged STORED true);
|
Chris@43
|
47
|
Chris@43
|
48 public:
|
Chris@43
|
49 Changeset() : QObject() { }
|
Chris@106
|
50 explicit Changeset(const LogEntry &e);
|
Chris@43
|
51
|
Chris@43
|
52 QString id() const { return m_id; }
|
Chris@125
|
53 QString user() const { return m_user; }
|
Chris@43
|
54 QString branch() const { return m_branch; }
|
Chris@44
|
55 QString tag() const { return m_tag; }
|
Chris@51
|
56 QString datetime() const { return m_datetime; }
|
Chris@52
|
57 qulonglong timestamp() const { return m_timestamp; }
|
Chris@43
|
58 QString age() const { return m_age; }
|
Chris@43
|
59 QStringList parents() const { return m_parents; }
|
Chris@123
|
60 QString comment() const { return m_comment; }
|
Chris@123
|
61
|
Chris@123
|
62 /**
|
Chris@123
|
63 * The children property is not obtained from Hg, but set in
|
Chris@123
|
64 * Grapher::layout() based on reported parents
|
Chris@123
|
65 */
|
Chris@47
|
66 QStringList children() const { return m_children; }
|
Chris@43
|
67
|
Chris@43
|
68 int number() const {
|
Chris@43
|
69 return id().split(':')[0].toInt();
|
Chris@43
|
70 }
|
Chris@43
|
71
|
Chris@125
|
72 QString userName() const {
|
Chris@125
|
73 QString a = user();
|
Chris@44
|
74 return a.replace(QRegExp("\\s*<[^>]*>"), "");
|
Chris@44
|
75 }
|
Chris@44
|
76
|
Chris@51
|
77 QString date() const {
|
Chris@51
|
78 return datetime().split(' ')[0];
|
Chris@51
|
79 }
|
Chris@51
|
80
|
Chris@108
|
81 bool isOnBranch(QString branch) {
|
Chris@108
|
82 QString b = m_branch;
|
Chris@108
|
83 if (branch == "") branch = "default";
|
Chris@108
|
84 if (b == "") b = "default";
|
Chris@108
|
85 if (branch == b) return true;
|
Chris@108
|
86 return false;
|
Chris@108
|
87 }
|
Chris@108
|
88
|
Chris@108
|
89 static Changesets parseChangesets(QString logText) {
|
Chris@108
|
90 Changesets csets;
|
Chris@108
|
91 LogList log = LogParser(logText).parse();
|
Chris@108
|
92 foreach (LogEntry e, log) {
|
Chris@108
|
93 csets.push_back(new Changeset(e));
|
Chris@108
|
94 }
|
Chris@108
|
95 return csets;
|
Chris@108
|
96 }
|
Chris@108
|
97
|
Chris@125
|
98 static QString getLogTemplate();
|
Chris@125
|
99
|
Chris@125
|
100 QString formatHtml();
|
Chris@125
|
101
|
Chris@43
|
102 signals:
|
Chris@43
|
103 void idChanged(QString id);
|
Chris@125
|
104 void userChanged(QString user);
|
Chris@43
|
105 void branchChanged(QString branch);
|
Chris@44
|
106 void tagChanged(QString tag);
|
Chris@51
|
107 void datetimeChanged(QString datetime);
|
Chris@52
|
108 void timestampChanged(qulonglong timestamp);
|
Chris@43
|
109 void ageChanged(QString age);
|
Chris@43
|
110 void parentsChanged(QStringList parents);
|
Chris@47
|
111 void childrenChanged(QStringList children);
|
Chris@43
|
112 void commentChanged(QString comment);
|
Chris@43
|
113
|
Chris@43
|
114 public slots:
|
Chris@43
|
115 void setId(QString id) { m_id = id; emit idChanged(id); }
|
Chris@125
|
116 void setUser(QString user) { m_user = user; emit userChanged(user); }
|
Chris@43
|
117 void setBranch(QString branch) { m_branch = branch; emit branchChanged(branch); }
|
Chris@44
|
118 void setTag(QString tag) { m_tag = tag; emit tagChanged(tag); }
|
Chris@52
|
119 void setDatetime(QString datetime) { m_datetime = datetime; emit datetimeChanged(datetime); }
|
Chris@52
|
120 void setTimestamp(qulonglong timestamp) { m_timestamp = timestamp; emit timestampChanged(timestamp); }
|
Chris@43
|
121 void setAge(QString age) { m_age = age; emit ageChanged(age); }
|
Chris@43
|
122 void setParents(QStringList parents) { m_parents = parents; emit parentsChanged(parents); }
|
Chris@47
|
123 void setChildren(QStringList children) { m_children = children; emit childrenChanged(m_children); }
|
Chris@47
|
124 void addChild(QString child) { m_children.push_back(child); emit childrenChanged(m_children); }
|
Chris@43
|
125 void setComment(QString comment) { m_comment = comment; emit commentChanged(comment); }
|
Chris@43
|
126
|
Chris@43
|
127 private:
|
Chris@43
|
128 QString m_id;
|
Chris@125
|
129 QString m_user;
|
Chris@43
|
130 QString m_branch;
|
Chris@44
|
131 QString m_tag;
|
Chris@51
|
132 QString m_datetime;
|
Chris@52
|
133 qulonglong m_timestamp;
|
Chris@43
|
134 QString m_age;
|
Chris@43
|
135 QStringList m_parents;
|
Chris@47
|
136 QStringList m_children;
|
Chris@43
|
137 QString m_comment;
|
Chris@43
|
138 };
|
Chris@43
|
139
|
Chris@43
|
140
|
Chris@43
|
141 #endif // CHANGESET_H
|