summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/hawd/dataset.cpp25
-rw-r--r--tests/hawd/dataset.h4
2 files changed, 18 insertions, 11 deletions
diff --git a/tests/hawd/dataset.cpp b/tests/hawd/dataset.cpp
index e1cc3a4..49f8c75 100644
--- a/tests/hawd/dataset.cpp
+++ b/tests/hawd/dataset.cpp
@@ -31,6 +31,7 @@ namespace HAWD
31 31
32static const QString s_annotationKey("__annotation__"); 32static const QString s_annotationKey("__annotation__");
33static const QString s_hashKey("__commithash__"); 33static const QString s_hashKey("__commithash__");
34static const int s_fieldWidth(15);
34 35
35Dataset::Row::Row(const Row &other) 36Dataset::Row::Row(const Row &other)
36 : m_key(other.m_key), 37 : m_key(other.m_key),
@@ -150,11 +151,11 @@ QString Dataset::tableHeaders(const QStringList &cols, int standardCols, const Q
150 QStringList strings; 151 QStringList strings;
151 152
152 if (standardCols & Row::Timestamp) { 153 if (standardCols & Row::Timestamp) {
153 strings << QObject::tr("Timestamp"); 154 strings << QObject::tr("Timestamp").leftJustified(s_fieldWidth, ' ');
154 } 155 }
155 156
156 if (standardCols & Row::CommitHash) { 157 if (standardCols & Row::CommitHash) {
157 strings << QObject::tr("Commit"); 158 strings << QObject::tr("Commit").leftJustified(s_fieldWidth, ' ');
158 } 159 }
159 160
160 QHashIterator<QString, DataDefinition> it(m_definition.columns()); 161 QHashIterator<QString, DataDefinition> it(m_definition.columns());
@@ -165,12 +166,12 @@ QString Dataset::tableHeaders(const QStringList &cols, int standardCols, const Q
165 if (!it.value().unit().isEmpty()) { 166 if (!it.value().unit().isEmpty()) {
166 header.append(" (").append(it.value().unit()).append(")"); 167 header.append(" (").append(it.value().unit()).append(")");
167 } 168 }
168 strings << header; 169 strings << header.leftJustified(s_fieldWidth, ' ');
169 } 170 }
170 } 171 }
171 172
172 if (standardCols & Row::Annotation) { 173 if (standardCols & Row::Annotation) {
173 strings << QObject::tr("Annotation"); 174 strings << QObject::tr("Annotation").leftJustified(s_fieldWidth, ' ');
174 } 175 }
175 176
176 return strings.join(seperator); 177 return strings.join(seperator);
@@ -185,23 +186,29 @@ QString Dataset::Row::toString(const QStringList &cols, int standardCols, const
185 QStringList strings; 186 QStringList strings;
186 187
187 if (standardCols & Timestamp) { 188 if (standardCols & Timestamp) {
188 strings << QString::number(m_key); 189 QDateTime dt;
190 dt.setMSecsSinceEpoch(m_key);
191 strings << dt.toString("yyMMdd:hhmmss").leftJustified(s_fieldWidth, ' ');
189 } 192 }
190 193
191 if (standardCols & CommitHash) { 194 if (standardCols & CommitHash) {
192 strings << m_commitHash; 195 strings << m_commitHash.leftJustified(s_fieldWidth, ' ');
193 } 196 }
194 197
195 QHashIterator<QString, QVariant> it(m_data); 198 QHashIterator<QString, QVariant> it(m_data);
196 while (it.hasNext()) { 199 while (it.hasNext()) {
197 it.next(); 200 it.next();
198 if (cols.isEmpty() || cols.contains(it.key())) { 201 if (cols.isEmpty() || cols.contains(it.key())) {
199 strings << it.value().toString(); 202 if (it.value().canConvert<double>()) {
203 strings << QString("%1").arg(it.value().toDouble(), s_fieldWidth, 'f', 3);
204 } else {
205 strings << it.value().toString().leftJustified(s_fieldWidth, ' ');
206 }
200 } 207 }
201 } 208 }
202 209
203 if (standardCols & Annotation) { 210 if (standardCols & Annotation) {
204 strings << m_annotation; 211 strings << m_annotation.leftJustified(s_fieldWidth, ' ');
205 } 212 }
206 213
207 return strings.join(seperator); 214 return strings.join(seperator);
@@ -270,7 +277,7 @@ void Dataset::eachRow(const std::function<void(const Row &row)> &resultHandler)
270Dataset::Row Dataset::row(qint64 key) 277Dataset::Row Dataset::row(qint64 key)
271{ 278{
272 if (key < 1) { 279 if (key < 1) {
273 Row row(*this); 280 Row row(*this, Akonadi2::Storage::maxRevision(m_transaction));
274 row.setCommitHash(m_commitHash); 281 row.setCommitHash(m_commitHash);
275 return row; 282 return row;
276 } 283 }
diff --git a/tests/hawd/dataset.h b/tests/hawd/dataset.h
index b6aa863..cf84d7b 100644
--- a/tests/hawd/dataset.h
+++ b/tests/hawd/dataset.h
@@ -52,7 +52,7 @@ public:
52 void setCommitHash(const QString &hash); 52 void setCommitHash(const QString &hash);
53 qint64 key() const; 53 qint64 key() const;
54 QByteArray toBinary() const; 54 QByteArray toBinary() const;
55 QString toString(const QStringList &cols = QStringList(), int standardCols = All, const QString &seperator = "\t") const; 55 QString toString(const QStringList &cols = QStringList(), int standardCols = All, const QString &seperator = "|") const;
56 56
57 private: 57 private:
58 Row(); 58 Row();
@@ -73,7 +73,7 @@ public:
73 73
74 bool isValid() const; 74 bool isValid() const;
75 const DatasetDefinition &definition() const; 75 const DatasetDefinition &definition() const;
76 QString tableHeaders(const QStringList &cols = QStringList(), int standardCols = Row::All, const QString &seperator = "\t") const; 76 QString tableHeaders(const QStringList &cols = QStringList(), int standardCols = Row::All, const QString &seperator = "|") const;
77 77
78 qint64 insertRow(const Row &row); 78 qint64 insertRow(const Row &row);
79 void removeRow(const Row &row); 79 void removeRow(const Row &row);