Mercurial > hg > easyhg
diff 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 |
line wrap: on
line diff
--- a/changeset.cpp Mon Nov 29 11:38:25 2010 +0000 +++ b/changeset.cpp Mon Nov 29 17:03:17 2010 +0000 @@ -16,6 +16,7 @@ */ #include "changeset.h" +#include "common.h" #include <QVariant> @@ -36,3 +37,56 @@ } } +QString Changeset::getLogTemplate() +{ + 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"; +} + +QString Changeset::formatHtml() +{ + QString description; + QString rowTemplate = "<tr><td><b>%1</b></td><td>%2</td></tr>"; + + description = "<qt><table border=0>"; + + QString c = comment().trimmed(); + c = c.replace(QRegExp("^\""), ""); + c = c.replace(QRegExp("\"$"), ""); + c = c.replace("\\\"", "\""); + c = xmlEncode(c); + c = c.replace("\\n", "<br>"); + + QStringList propNames, propTexts; + + propNames << "id" + << "user" + << "datetime" + << "branch" + << "tag" + << "comment"; + + propTexts << QObject::tr("Identifier") + << QObject::tr("Author") + << QObject::tr("Date") + << QObject::tr("Branch") + << QObject::tr("Tag") + << QObject::tr("Comment"); + + for (int i = 0; i < propNames.size(); ++i) { + QString prop = propNames[i]; + QString value; + if (prop == "comment") value = c; + else { + value = xmlEncode(property(prop.toLocal8Bit().data()).toString()); + } + if (value != "") { + description += rowTemplate + .arg(xmlEncode(propTexts[i])) + .arg(value); + } + } + + description += "</table></qt>"; + + return description; +}