# HG changeset patch # User Chris Cannam # Date 1290815388 0 # Node ID 9734fb0d6fff394752eadc0758373a2db11535bb # Parent d5db15bf250c62bccc89f6715714c2d1256e1f75 * Rudimentary version of the popup showing more information when you click on a changeset in history graph diff -r d5db15bf250c -r 9734fb0d6fff changesetdetailitem.cpp --- a/changesetdetailitem.cpp Fri Nov 26 22:46:29 2010 +0000 +++ b/changesetdetailitem.cpp Fri Nov 26 23:49:48 2010 +0000 @@ -20,22 +20,33 @@ #include "textabbrev.h" #include "colourset.h" #include "debug.h" +#include "common.h" +#include #include ChangesetDetailItem::ChangesetDetailItem(Changeset *cs) : - m_changeset(cs) + m_changeset(cs), m_doc(0) { m_font = QFont(); m_font.setPixelSize(11); m_font.setBold(false); m_font.setItalic(false); + + makeDocument(); +} + +ChangesetDetailItem::~ChangesetDetailItem() +{ + delete m_doc; } QRectF ChangesetDetailItem::boundingRect() const { - return QRectF(0, 0, 350, 200); + int w = 350; + m_doc->setTextWidth(w); + return QRectF(0, -10, w, m_doc->size().height() + 10); } void @@ -70,7 +81,8 @@ int fh = fm.height(); int width = 350; - int height = 200; + m_doc->setTextWidth(width); + int height = m_doc->size().height(); QRectF r(0.5, 0.5, width - 1, height - 1); paint->setBrush(Qt::white); @@ -80,6 +92,17 @@ paint->restore(); return; } + + paint->setBrush(branchColour); + QVector pts; + pts.push_back(QPointF(width/2 - 5, 0)); + pts.push_back(QPointF(width/2 + 5, 0)); + pts.push_back(QPointF(width/2, -10)); + pts.push_back(QPointF(width/2 - 5, 0)); + paint->drawPolygon(QPolygonF(pts)); + + m_doc->drawContents(paint, r); + /* paint->fillRect(QRectF(x0 + 0.5, 0.5, width - 4, fh - 0.5), QBrush(userColour)); @@ -109,12 +132,6 @@ fh = fm.height(); paint->setFont(f); - QString comment = m_changeset->comment().trimmed(); - comment = comment.replace("\\n", " "); - comment = comment.replace(QRegExp("^\"\\s*\\**\\s*"), ""); - comment = comment.replace(QRegExp("\"$"), ""); - comment = comment.replace("\\\"", "\""); - wid = width - 5; int nlines = (height / fh) - 1; if (nlines < 1) nlines = 1; @@ -128,3 +145,60 @@ */ paint->restore(); } + +void +ChangesetDetailItem::makeDocument() +{ + delete m_doc; + + QString description; + QString rowTemplate = "%1%2"; + + description = ""; + + QString comment = m_changeset->comment().trimmed(); + comment = comment.replace(QRegExp("^\""), ""); + comment = comment.replace(QRegExp("\"$"), ""); + comment = comment.replace("\\\"", "\""); + comment = xmlEncode(comment); + comment = comment.replace("\\n", "
"); + + QStringList propNames, propTexts; + + propNames << "id" + << "author" + << "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 = comment; + else { + value = xmlEncode(m_changeset->property + (prop.toLocal8Bit().data()).toString()); + } + if (value != "") { + description += rowTemplate + .arg(xmlEncode(propTexts[i])) + .arg(value); + } + } + + description += "
"; + + DEBUG << "ChangesetDetailItem: description = " << description << endl; + + m_doc = new QTextDocument; + m_doc->setHtml(description); +} + diff -r d5db15bf250c -r 9734fb0d6fff changesetdetailitem.h --- a/changesetdetailitem.h Fri Nov 26 22:46:29 2010 +0000 +++ b/changesetdetailitem.h Fri Nov 26 23:49:48 2010 +0000 @@ -27,6 +27,7 @@ { public: ChangesetDetailItem(Changeset *cs); + virtual ~ChangesetDetailItem(); virtual QRectF boundingRect() const; virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); @@ -36,6 +37,9 @@ private: QFont m_font; Changeset *m_changeset; + QTextDocument *m_doc; + + void makeDocument(); }; #endif // CHANGESETDETAILITEM_H diff -r d5db15bf250c -r 9734fb0d6fff changesetitem.cpp --- a/changesetitem.cpp Fri Nov 26 22:46:29 2010 +0000 +++ b/changesetitem.cpp Fri Nov 26 23:49:48 2010 +0000 @@ -48,7 +48,11 @@ { DEBUG << "ChangesetItem::mousePressEvent" << endl; //!!! how best to handle this? - if (m_detail) return; + if (m_detail) { + delete m_detail; + m_detail = 0; + return; + } m_detail = new ChangesetDetailItem(m_changeset); m_detail->setZValue(zValue() + 1); scene()->addItem(m_detail); diff -r d5db15bf250c -r 9734fb0d6fff filestatuswidget.cpp --- a/filestatuswidget.cpp Fri Nov 26 22:46:29 2010 +0000 +++ b/filestatuswidget.cpp Fri Nov 26 23:49:48 2010 +0000 @@ -83,7 +83,7 @@ m_descriptions[FileStates::Unknown] = tr("These files are in your working folder but are not under version control.
" "Select a file and use Add to place it under version control or Ignore to remove it from this list."); - m_highlightExplanation = tr("Files highlighted in red " + m_highlightExplanation = tr("Files highlighted in red " "have appeared since your most recent commit or update."); for (int i = int(FileStates::FirstState); @@ -367,7 +367,7 @@ foreach (QString file, highPriority) { QListWidgetItem *item = new QListWidgetItem(file); w->addItem(item); - item->setForeground(Qt::red); //!!! and a nice gold star + item->setForeground(QColor("#d40000")); //!!! and a nice gold star item->setSelected(selectedFiles.contains(file)); }