# HG changeset patch # User Chris Cannam # Date 1300013974 0 # Node ID 70ad221e1619cf1a9259b6811d02f7d71d097fc9 # Parent acfe9390d5c671c6f9704c28f5ec9556c6bf87bb Improve the Annotate output diff -r acfe9390d5c6 -r 70ad221e1619 annotatedialog.cpp --- a/annotatedialog.cpp Sun Mar 13 10:31:32 2011 +0000 +++ b/annotatedialog.cpp Sun Mar 13 10:59:34 2011 +0000 @@ -17,6 +17,7 @@ #include "annotatedialog.h" #include "common.h" +#include "colourset.h" #include "debug.h" #include @@ -28,8 +29,8 @@ AnnotateDialog::AnnotateDialog(QWidget *w, QString text) : QDialog(w) { - setMinimumWidth(600); - setMinimumHeight(700); + setMinimumWidth(800); + setMinimumHeight(500); text.replace("\r\n", "\n"); QStringList lines = text.split("\n"); @@ -42,21 +43,39 @@ table->setRowCount(lines.size()); table->setColumnCount(4); table->horizontalHeader()->setStretchLastSection(true); + table->verticalHeader()->setDefaultSectionSize + (table->verticalHeader()->fontMetrics().height() + 2); QStringList labels; labels << tr("User") << tr("Revision") << tr("Date") << tr("Content"); table->setHorizontalHeaderLabels(labels); + table->setShowGrid(false); + + QFont monofont("Monospace"); + monofont.setStyleHint(QFont::TypeWriter); + int row = 0; foreach (QString line, lines) { if (annotateLineRE.indexIn(line) == 0) { QStringList items = annotateLineRE.capturedTexts(); + QString id = items[2]; + QColor colour = ColourSet::instance()->getColourFor(id); + QColor bg = QColor::fromHsv(colour.hue(), + 30, + 230); // note items[0] is the whole match, so we want 1-4 for (int col = 0; col+1 < items.size(); ++col) { - std::cerr << "row " << row << " col " << col << " text " - << items[col+1] << std::endl; - table->setItem(row, col, new QTableWidgetItem(items[col+1])); + QString item = items[col+1]; + if (col == 0) item = item.trimmed(); + QTableWidgetItem *wi = new QTableWidgetItem(item); + wi->setFlags(Qt::ItemIsEnabled); + wi->setBackground(bg); + if (col == 3) { // id, content + wi->setFont(monofont); + } + table->setItem(row, col, wi); } } else { DEBUG << "AnnotateDialog: Failed to match RE in line: " << line << " at row " << row << endl; diff -r acfe9390d5c6 -r 70ad221e1619 mainwindow.cpp --- a/mainwindow.cpp Sun Mar 13 10:31:32 2011 +0000 +++ b/mainwindow.cpp Sun Mar 13 10:59:34 2011 +0000 @@ -363,7 +363,7 @@ QStringList params; if (!files.isEmpty()) { - params << "annotate" << "-udc" << "--" << files; + params << "annotate" << "-udqc" << "--" << files; m_runner->requestAction(HgAction(ACT_ANNOTATE, m_workFolderPath, params)); } }