Chris@331: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@331: Chris@331: /* Chris@331: EasyMercurial Chris@331: Chris@331: Based on hgExplorer by Jari Korhonen Chris@331: Copyright (c) 2010 Jari Korhonen Chris@331: Copyright (c) 2011 Chris Cannam Chris@331: Copyright (c) 2011 Queen Mary, University of London Chris@331: Chris@331: This program is free software; you can redistribute it and/or Chris@331: modify it under the terms of the GNU General Public License as Chris@331: published by the Free Software Foundation; either version 2 of the Chris@331: License, or (at your option) any later version. See the file Chris@331: COPYING included with this distribution for more information. Chris@331: */ Chris@331: Chris@331: #include "annotatedialog.h" Chris@331: #include "common.h" Chris@331: #include "debug.h" Chris@331: Chris@331: #include Chris@331: #include Chris@331: #include Chris@331: #include Chris@331: #include Chris@331: Chris@331: AnnotateDialog::AnnotateDialog(QWidget *w, QString text) : Chris@331: QDialog(w) Chris@331: { Chris@331: setMinimumWidth(600); Chris@331: setMinimumHeight(700); Chris@331: Chris@331: text.replace("\r\n", "\n"); Chris@331: QStringList lines = text.split("\n"); Chris@331: Chris@331: QGridLayout *layout = new QGridLayout; Chris@331: QTableWidget *table = new QTableWidget; Chris@331: Chris@331: QRegExp annotateLineRE = QRegExp("^([^:]+) ([a-z0-9]{12}) ([0-9-]+): (.*)$"); Chris@331: Chris@331: table->setRowCount(lines.size()); Chris@331: table->setColumnCount(4); Chris@331: table->horizontalHeader()->setStretchLastSection(true); Chris@331: Chris@331: QStringList labels; Chris@331: labels << tr("User") << tr("Revision") << tr("Date") << tr("Content"); Chris@331: table->setHorizontalHeaderLabels(labels); Chris@331: Chris@331: int row = 0; Chris@331: Chris@331: foreach (QString line, lines) { Chris@331: if (annotateLineRE.indexIn(line) == 0) { Chris@331: QStringList items = annotateLineRE.capturedTexts(); Chris@331: // note items[0] is the whole match, so we want 1-4 Chris@331: for (int col = 0; col+1 < items.size(); ++col) { Chris@331: std::cerr << "row " << row << " col " << col << " text " Chris@331: << items[col+1] << std::endl; Chris@331: table->setItem(row, col, new QTableWidgetItem(items[col+1])); Chris@331: } Chris@331: } else { Chris@331: DEBUG << "AnnotateDialog: Failed to match RE in line: " << line << " at row " << row << endl; Chris@331: } Chris@331: ++row; Chris@331: } Chris@331: Chris@331: QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok); Chris@331: connect(bb, SIGNAL(accepted()), this, SLOT(accept())); Chris@331: Chris@331: layout->addWidget(table, 0, 0); Chris@331: layout->addWidget(bb, 1, 0); Chris@331: Chris@331: setLayout(layout); Chris@331: } Chris@331: