comparison changeset.cpp @ 125:63c2f3f61c79

* Add Incoming dialog and better layouts for dialogs generally
author Chris Cannam
date Mon, 29 Nov 2010 17:03:17 +0000
parents 8ae3b44c0073
children fcaf09ee825d
comparison
equal deleted inserted replaced
124:1f27f71a7034 125:63c2f3f61c79
14 License, or (at your option) any later version. See the file 14 License, or (at your option) any later version. See the file
15 COPYING included with this distribution for more information. 15 COPYING included with this distribution for more information.
16 */ 16 */
17 17
18 #include "changeset.h" 18 #include "changeset.h"
19 #include "common.h"
19 20
20 #include <QVariant> 21 #include <QVariant>
21 22
22 Changeset::Changeset(const LogEntry &e) 23 Changeset::Changeset(const LogEntry &e)
23 { 24 {
34 setProperty(key.toLocal8Bit().data(), e.value(key)); 35 setProperty(key.toLocal8Bit().data(), e.value(key));
35 } 36 }
36 } 37 }
37 } 38 }
38 39
40 QString Changeset::getLogTemplate()
41 {
42 return "id: {rev}:{node|short}\\nuser: {author}\\nbranch: {branches}\\ntag: {tag}\\ndatetime: {date|isodate}\\ntimestamp: {date|hgdate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n";
43 }
44
45 QString Changeset::formatHtml()
46 {
47 QString description;
48 QString rowTemplate = "<tr><td><b>%1</b></td><td>%2</td></tr>";
49
50 description = "<qt><table border=0>";
51
52 QString c = comment().trimmed();
53 c = c.replace(QRegExp("^\""), "");
54 c = c.replace(QRegExp("\"$"), "");
55 c = c.replace("\\\"", "\"");
56 c = xmlEncode(c);
57 c = c.replace("\\n", "<br>");
58
59 QStringList propNames, propTexts;
60
61 propNames << "id"
62 << "user"
63 << "datetime"
64 << "branch"
65 << "tag"
66 << "comment";
67
68 propTexts << QObject::tr("Identifier")
69 << QObject::tr("Author")
70 << QObject::tr("Date")
71 << QObject::tr("Branch")
72 << QObject::tr("Tag")
73 << QObject::tr("Comment");
74
75 for (int i = 0; i < propNames.size(); ++i) {
76 QString prop = propNames[i];
77 QString value;
78 if (prop == "comment") value = c;
79 else {
80 value = xmlEncode(property(prop.toLocal8Bit().data()).toString());
81 }
82 if (value != "") {
83 description += rowTemplate
84 .arg(xmlEncode(propTexts[i]))
85 .arg(value);
86 }
87 }
88
89 description += "</table></qt>";
90
91 return description;
92 }