# # # add_file "guitone/src/view/DiffStatusView.cpp" # content [16c581383793d8294e0568e9e5f2f1c32012b209] # # add_file "guitone/src/view/DiffStatusView.h" # content [20ff76f2cd2dad267879768b896672cbc66ab964] # # patch "guitone/guitone.pro" # from [887d92b03fc61fa83d4611baf7f8af26cf0cce14] # to [48b6b4edd159d5211be15bdf4cc30754bb91a5e3] # # patch "guitone/res/dialogs/file_diff.ui" # from [cec958f624f1b2884161a18632baf0ce38ed04e5] # to [461cfac4a7157098a892c2ce1f3e5100f5fd6318] # # patch "guitone/res/i18n/guitone_de.ts" # from [937a8f5b866eb89c76155a55c1c51c5efa2e2e3a] # to [8878f9f2068242a95a9fe95838b40260d1a7262a] # # patch "guitone/src/view/InventoryView.cpp" # from [126de4eea74e374aecc2b2e6871327a2700b6dda] # to [e15201e1910e94fc32a8511489dbaf5e9f18669b] # # patch "guitone/src/view/dialogs/FileDiff.cpp" # from [87b557e1445814d58ace8a28e3ca8cf3b5dd605f] # to [c6f55eaf9f12040e496d8c079c9e6ca406eee6a8] # ============================================================ --- guitone/src/view/DiffStatusView.cpp 16c581383793d8294e0568e9e5f2f1c32012b209 +++ guitone/src/view/DiffStatusView.cpp 16c581383793d8294e0568e9e5f2f1c32012b209 @@ -0,0 +1,144 @@ +/*************************************************************************** + * Copyright (C) 2006 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "DiffStatusView.h" +#include "../util/Settings.h" + +#include +#include +#include + +DiffStatusView::DiffStatusView(QWidget* parent) +: QWidget(parent) +{ + model = 0; +} + +DiffStatusView::~DiffStatusView() {} + +QSize DiffStatusView::minimumSizeHint() const +{ + return QSize(10, 100); +} + +QSize DiffStatusView::sizeHint() const +{ + return QSize(10, 200); +} + + +void DiffStatusView::paintEvent(QPaintEvent *) +{ + if (!model) return; + + float lineHeight = (float) height() / model->rowCount(); + + qDebug("Line height: %.2f", lineHeight); + + QVector colorArray; + + for (int i=0, j=model->rowCount(); iindex(i, 0, QModelIndex()); + QVariant var = model->data(index, Qt::BackgroundRole); + + if (var.canConvert()) + { + brush = var.value(); + } + + // one pixel row stands for more than one physical row + // we use the color which was present in most of the lines + // + // FIXME: this still doesn't work properly, but I have no idea how + // this could be fixed ATM + if (lineHeight < 1.f) + { + // round down + int lookAhead = (int) ceil(1.f/lineHeight); + + // we can't store a QColor directly in a map, so we need + // to work around this limitation by using the color's hex value + // name as identifier + QMap colorLineCount; + + for (int k=i, l=i+lookAhead; kindex(k, 0, QModelIndex()); + QVariant var = model->data(index, Qt::BackgroundRole); + if (!var.canConvert()) continue; + + QBrush tmpBrush = var.value(); + QString color = tmpBrush.color().name(); + + if (colorLineCount.contains(color)) + { + int count = colorLineCount.value(color); + colorLineCount.insert(color, ++count); + } + else + { + colorLineCount.insert(color, 1); + } + } + + QMapIterator it(colorLineCount); + + int maxCount = 0; + QString color; + while (it.hasNext()) + { + it.next(); + if (it.value() > maxCount) + { + maxCount = it.value(); + color = it.key(); + } + } + + QColor markColor; + markColor.setNamedColor(color); + brush.setColor(markColor); + + i += lookAhead; + } + + colorArray.push_back(brush); + } + + QPainter painter(this); + + float lastY = 0.f; + + for (int i=0, j=colorArray.size(); i + +class DiffStatusView : public QWidget +{ + Q_OBJECT + +public: + DiffStatusView(QWidget*); + ~DiffStatusView(); + void paintEvent(QPaintEvent*); + inline void setModel(GetFileProxyModel * m) { model = m; } + QSize minimumSizeHint() const; + QSize sizeHint() const; + +private: + GetFileProxyModel * model; +}; + +#endif ============================================================ --- guitone/guitone.pro 887d92b03fc61fa83d4611baf7f8af26cf0cce14 +++ guitone/guitone.pro 48b6b4edd159d5211be15bdf4cc30754bb91a5e3 @@ -11,6 +11,7 @@ HEADERS += src/view/Guitone.h \ src/view/InventoryView.h \ src/view/AttributesView.h \ src/view/DiffView.h \ + src/view/DiffStatusView.h \ src/view/dialogs/SwitchWorkspaceRevision.h \ src/view/dialogs/Preferences.h \ src/view/dialogs/AncestryGraph.h \ @@ -39,6 +40,7 @@ SOURCES += src/view/Guitone.cpp \ src/view/InventoryView.cpp \ src/view/AttributesView.cpp \ src/view/DiffView.cpp \ + src/view/DiffStatusView.cpp \ src/view/dialogs/SwitchWorkspaceRevision.cpp \ src/view/dialogs/Preferences.cpp \ src/view/dialogs/AncestryGraph.cpp \ ============================================================ --- guitone/res/dialogs/file_diff.ui cec958f624f1b2884161a18632baf0ce38ed04e5 +++ guitone/res/dialogs/file_diff.ui 461cfac4a7157098a892c2ce1f3e5100f5fd6318 @@ -28,7 +28,20 @@ 6 - + + + 0 + + + 6 + + + + + + + + @@ -111,6 +124,11 @@ QTreeView
../DiffView.h
+ + DiffStatusView + QWidget +
../DiffStatusView.h
+
============================================================ --- guitone/res/i18n/guitone_de.ts 937a8f5b866eb89c76155a55c1c51c5efa2e2e3a +++ guitone/res/i18n/guitone_de.ts 8878f9f2068242a95a9fe95838b40260d1a7262a @@ -113,6 +113,57 @@ + FileDiffDialog + + + File differences of "%1" + Unterschiede in der Datei "%1" + + + + Show Version + Zeige Version + + + + Left + links + + + + Right + rechts + + + + Both + beide + + + + Close + Schliessen + + + + GetFile + + + File is binary. + Datei ist eine Binärdatei. + + + + Line + Zeile + + + + Content + Inhalt + + + Guitone @@ -294,12 +345,12 @@ InventoryItem - + File Datei - + Status Status @@ -309,27 +360,27 @@ ein Verzeichnis höher - + Rename Source Quelle für Umbenennen - + Rename Target Ziel für Umbenennen - + Added hinzugefügt - + Dropped entfernt - + Missing fehlend @@ -339,22 +390,22 @@ verändert - + Unchanged unverändert - + Unknown unbekannt - + Ignored ignoriert - + Modified Verändert @@ -362,117 +413,133 @@ InventoryView - + &Add &Hinzufügen - + Ctrl+A Add - + Add to workspace Zum Arbeitsbereich hinzufügen - + &Remove En&tfernen - + Ctrl+R Remove - + Remove from workspace Vom Arbeitsbereich entfernen - + &Commit &Einpflegen - + Ctrl+C Commit - + Commit Einpflegen - + I&gnore Datei &ignorieren - + Ctrl+G Ignore - + Ignore file Datei ignorieren - + &Unignore Datei nicht ign&orieren - + Ctrl+U Unignore - + Unignore file Datei nicht mehr ignorieren - + R&evert &Zurücksetzen - + Ctrl+E Revert - + Revert uncommitted changes Nicht eingepflegte Änderungen verwerfen - + Rena&me Um&benennen - + Ctrl+M Rename - + Rename file Datei umbenennen + + + D&iff + U&nterschiede anzeigen + + + + Ctrl+D + Diff + + + + + Diff against base revision + Unterschiede im Vergleich zur Basisrevision anzeigen + KeyManagment @@ -580,17 +647,17 @@ korrekt installiert? korrekt installiert? - + Unable to process command '%1': %2 Das Kommando '%1' konnte nicht abgearbeitet werden: %2 - + Monotone failed to start (Code %1). Please configure the path in the Preferences dialog. Monotone konnte nicht gestartet werden (Code %1). Bitte konfigurieren Sie den Pfad im Eintellungsdialog. - + The connection to the monotone process was terminated (Code %1). Check your configuration and reload the current workspace afterwards. Die Verbindung zum monotone-Prozess wurde beendet (Code %1). Prüfen Sie Ihre Konfiguration und laden Sie ggf. den Arbeitsbereich danach neu. ============================================================ --- guitone/src/view/InventoryView.cpp 126de4eea74e374aecc2b2e6871327a2700b6dda +++ guitone/src/view/InventoryView.cpp e15201e1910e94fc32a8511489dbaf5e9f18669b @@ -116,8 +116,9 @@ void InventoryView::contextMenuEvent(QCo { menu.addAction(actRevert); - // added files can't be diffed - if (item->hasNotStatus(InventoryItem::Added)) + // added files and directories can't be diffed + if (item->hasNotStatus(InventoryItem::Added) && + !item->isDirectory()) { menu.addAction(actDiff); } ============================================================ --- guitone/src/view/dialogs/FileDiff.cpp 87b557e1445814d58ace8a28e3ca8cf3b5dd605f +++ guitone/src/view/dialogs/FileDiff.cpp c6f55eaf9f12040e496d8c079c9e6ca406eee6a8 @@ -62,6 +62,7 @@ void FileDiff::init(QString fileName) fileProxyModel->setSourceModel(fileModel); diffView->setModel(fileProxyModel); + diffStatusView->setModel(fileProxyModel); // make the line number col a little smaller diffView->header()->resizeSection(0, 40); @@ -78,6 +79,7 @@ void FileDiff::init(QString fileName) if (diffWaiter.wait()) { fileModel->applyDiff(diffModel->getDiff(fileName)); + diffStatusView->update(); } else { @@ -100,5 +102,7 @@ void FileDiff::versionToggled(bool dummy fileProxyModel->setFileVersion(GetFileProxyModel::Right); if (showVersionBoth->isChecked()) fileProxyModel->setFileVersion(GetFileProxyModel::Both); + + diffStatusView->update(); }