Mercurial > hg > easyhg
comparison src/changeset.cpp @ 370:b9c153e00e84
Move source files to src/
author | Chris Cannam |
---|---|
date | Thu, 24 Mar 2011 10:27:51 +0000 |
parents | changeset.cpp@8fd71f570884 |
children | 69b2338c06e1 |
comparison
equal
deleted
inserted
replaced
369:19cce6d2c470 | 370:b9c153e00e84 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 EasyMercurial | |
5 | |
6 Based on HgExplorer by Jari Korhonen | |
7 Copyright (c) 2010 Jari Korhonen | |
8 Copyright (c) 2011 Chris Cannam | |
9 Copyright (c) 2011 Queen Mary, University of London | |
10 | |
11 This program is free software; you can redistribute it and/or | |
12 modify it under the terms of the GNU General Public License as | |
13 published by the Free Software Foundation; either version 2 of the | |
14 License, or (at your option) any later version. See the file | |
15 COPYING included with this distribution for more information. | |
16 */ | |
17 | |
18 #include "changeset.h" | |
19 #include "common.h" | |
20 | |
21 #include <QVariant> | |
22 | |
23 Changeset::Changeset(const LogEntry &e) | |
24 { | |
25 foreach (QString key, e.keys()) { | |
26 if (key == "parents") { | |
27 QStringList parents = e.value(key).split | |
28 (" ", QString::SkipEmptyParts); | |
29 setParents(parents); | |
30 } else if (key == "tag") { | |
31 QStringList tags = e.value(key).split | |
32 (" ", QString::SkipEmptyParts); | |
33 setTags(tags); | |
34 } else if (key == "timestamp") { | |
35 setTimestamp(e.value(key).split(" ")[0].toULongLong()); | |
36 } else if (key == "changeset") { | |
37 setId(e.value(key)); | |
38 } else { | |
39 setProperty(key.toLocal8Bit().data(), e.value(key)); | |
40 } | |
41 } | |
42 } | |
43 | |
44 QString Changeset::getLogTemplate() | |
45 { | |
46 return "id: {rev}:{node|short}\\nauthor: {author}\\nbranch: {branches}\\ntag: {tags}\\ndatetime: {date|isodate}\\ntimestamp: {date|hgdate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n"; | |
47 } | |
48 | |
49 QString Changeset::formatHtml() | |
50 { | |
51 QString description; | |
52 QString rowTemplate = "<tr><td><b>%1</b> </td><td>%2</td></tr>"; | |
53 | |
54 description = "<qt><table border=0>"; | |
55 | |
56 QString c = comment().trimmed(); | |
57 c = c.replace(QRegExp("^\""), ""); | |
58 c = c.replace(QRegExp("\"$"), ""); | |
59 c = c.replace("\\\"", "\""); | |
60 c = xmlEncode(c); | |
61 c = c.replace("\\n", "<br>"); | |
62 | |
63 QStringList propNames, propTexts; | |
64 | |
65 propNames << "id" | |
66 << "author" | |
67 << "datetime" | |
68 << "branch" | |
69 << "tags" | |
70 << "comment"; | |
71 | |
72 propTexts << QObject::tr("Identifier:") | |
73 << QObject::tr("Author:") | |
74 << QObject::tr("Date:") | |
75 << QObject::tr("Branch:") | |
76 << QObject::tr("Tag:") | |
77 << QObject::tr("Comment:"); | |
78 | |
79 for (int i = 0; i < propNames.size(); ++i) { | |
80 QString prop = propNames[i]; | |
81 QString value; | |
82 if (prop == "id") { | |
83 value = hashOf(id()); | |
84 } else if (prop == "comment") { | |
85 value = c; | |
86 } else if (prop == "tags") { | |
87 value = tags().join(" "); | |
88 } else { | |
89 value = xmlEncode(property(prop.toLocal8Bit().data()).toString()); | |
90 } | |
91 if (value != "") { | |
92 description += rowTemplate | |
93 .arg(xmlEncode(propTexts[i])) | |
94 .arg(value); | |
95 } | |
96 } | |
97 | |
98 description += "</table></qt>"; | |
99 | |
100 return description; | |
101 } |