# # # patch "guitone/src/view/DiffStatusView.cpp" # from [16c581383793d8294e0568e9e5f2f1c32012b209] # to [d959c820dae2fe20e234f55bae89340f4b3b0a20] # # patch "guitone/src/view/InventoryView.cpp" # from [e15201e1910e94fc32a8511489dbaf5e9f18669b] # to [f525d5d7007128f7c15ff03dace8b8462a5f559c] # ============================================================ --- guitone/src/view/DiffStatusView.cpp 16c581383793d8294e0568e9e5f2f1c32012b209 +++ guitone/src/view/DiffStatusView.cpp d959c820dae2fe20e234f55bae89340f4b3b0a20 @@ -48,96 +48,27 @@ void DiffStatusView::paintEvent(QPaintEv { if (!model) return; - float lineHeight = (float) height() / model->rowCount(); + QPainter painter(this); - qDebug("Line height: %.2f", lineHeight); + float lineHeight = (float) height() / model->rowCount(); + float lastY = 0.f; - 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(); + painter.fillRect( + 0, + (int)ceil(lastY), + width(), + (int)ceil(lineHeight), + 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(); isetClickable(true); createAndConnectContextActions(); + + // diff a patched file on double click + connect( + this, SIGNAL(doubleClicked(const QModelIndex &)), + this, SLOT(slotDiff(void)) + ); } InventoryView::~InventoryView() {} @@ -267,7 +273,7 @@ void InventoryView::slotDiff(void) if (indexList.size() == 0) { - qDebug("InventoryView::slotAdd: You didn't select the file properly!"); + qDebug("InventoryView::slotDiff: No file selection."); return; } @@ -277,9 +283,14 @@ void InventoryView::slotDiff(void) } QModelIndex sourceIndex = static_cast(indexList[0].model())->mapToSource(indexList[0]); - InventoryItem * item = static_cast(sourceIndex.internalPointer()); + if (item->isDirectory() || !item->hasStatus(InventoryItem::Patched)) + { + qDebug("InventoryView::slotDiff: File is a directory or not patched/unknown."); + return; + } + FileDiff dlg(this, item->getPath()); dlg.exec();