diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.cpp b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.cpp index 889d89d..2701828 100644 --- a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.cpp +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.cpp @@ -98,7 +98,7 @@ void ObjectStatisticsDialog::updateStatisticsWidget() StatisticsGraphWidget::StatisticsItem item; item.portion = percentage / qreal(100.0); item.color = colors[colorId++ % colors.size()]; - item.texts = QStringList() << classText << locale.toString(percentage) << locale.toString(statisticsItem.count) << locale.toString(statisticsItem.bytes); + item.texts = QStringList() << classText << locale.toString(percentage, 'f', 2) << locale.toString(statisticsItem.count) << locale.toString(statisticsItem.bytes); statistics.items.emplace_back(qMove(item)); }; @@ -147,7 +147,7 @@ void ObjectStatisticsDialog::updateStatisticsWidget() StatisticsGraphWidget::StatisticsItem item; item.portion = percentage / qreal(100.0); item.color = colors[colorId++ % colors.size()]; - item.texts = QStringList() << pdf::PDFObjectUtils::getObjectTypeName(type) << locale.toString(percentage) << locale.toString(currentObjectCount); + item.texts = QStringList() << pdf::PDFObjectUtils::getObjectTypeName(type) << locale.toString(percentage, 'f', 2) << locale.toString(currentObjectCount); statistics.items.emplace_back(qMove(item)); } } diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/statisticsgraphwidget.cpp b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/statisticsgraphwidget.cpp index 4167426..7140857 100644 --- a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/statisticsgraphwidget.cpp +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/statisticsgraphwidget.cpp @@ -92,7 +92,7 @@ StatisticsGraphWidget::GeometryHint StatisticsGraphWidget::getGeometryHint() con for (int i = 0; i < item.texts.size(); ++i) { - hint.textWidths[i] = qMax(hint.textWidths[i], fontMetricsHeader.horizontalAdvance(m_statistics.headers[i])); + hint.textWidths[i] = qMax(hint.textWidths[i], fontMetricsHeader.horizontalAdvance(item.texts[i])); } } @@ -152,6 +152,7 @@ void StatisticsGraphWidget::paintEvent(QPaintEvent* event) top = currentRect.bottom(); QColor color = (m_selectedColorBox == i) ? selectedColor: item.color; + color.setAlphaF(0.8); painter.fillRect(currentRect, color); m_colorBoxes.push_back(currentRect); } @@ -201,6 +202,9 @@ void StatisticsGraphWidget::paintEvent(QPaintEvent* event) textRect.setLeft(maxLinePoint.x() + geometryHint.textMargin); textRect.setHeight(geometryHint.textLineHeight); + std::vector horizontalLines; + horizontalLines.reserve(m_statistics.items.size()); + auto drawTexts = [&](const QStringList& texts, bool isHeader) { pdf::PDFPainterStateGuard guard(&painter); @@ -221,6 +225,15 @@ void StatisticsGraphWidget::paintEvent(QPaintEvent* event) cellRect.translate(cellRect.width(), 0); } + if (!isHeader) + { + QPoint startPoint = textRect.center(); + startPoint.setX(textRect.left()); + + QPoint endPoint(maxLinePoint.x(), startPoint.y()); + horizontalLines.emplace_back(startPoint, endPoint); + } + textRect.translate(0, textRect.height()); }; @@ -242,6 +255,22 @@ void StatisticsGraphWidget::paintEvent(QPaintEvent* event) painter.setPen(pen); painter.drawLine(minLinePoint, maxLinePoint); + + for (const QLine& line : horizontalLines) + { + painter.drawLine(line); + } + + pen = painter.pen(); + pen.setColor(Qt::black); + pen.setWidth(geometryHint.markerSize); + pen.setCapStyle(Qt::RoundCap); + painter.setPen(pen); + + for (const QLine& line : horizontalLines) + { + painter.drawPoint(line.p1()); + } } }