NO_K_CHART mode added (if it's not defined but NO_K_LIB is defined then only KChart...
authorAlexey Chernobaev <achernobaev@dev.rtsoft.ru>
Mon, 19 Feb 2018 18:12:51 +0000 (21:12 +0300)
committerAlexey Chernobaev <achernobaev@dev.rtsoft.ru>
Mon, 19 Feb 2018 18:12:51 +0000 (21:12 +0300)
src/analyze/gui/chartmodel.cpp
src/analyze/gui/chartwidget.cpp
src/analyze/gui/gui_config.h
src/analyze/gui/histogrammodel.cpp
src/analyze/gui/histogramwidget.cpp
src/analyze/gui/mainwindow.cpp
src/analyze/gui/treemodel.cpp
src/analyze/gui/util.cpp
src/analyze/gui/util.h
src/heaptrack_gui.pro

index 1db0ac9..8778819 100644 (file)
 
 #include <KChartGlobal>
 #include <KChartLineAttributes>
+#ifdef NO_K_LIB
+#include "noklib.h"
+#else
 #include <KFormat>
 #include <KLocalizedString>
+#endif
 
 #include <QBrush>
 #include <QDebug>
@@ -125,8 +129,7 @@ QVariant ChartModel::data(const QModelIndex& index, int role) const
         const QString time = Util::formatTime(data.timeStamp);
         auto byteCost = [cost]() -> QString
         {
-            KFormat format;
-            const auto formatted = format.formatByteSize(cost, 1, KFormat::JEDECBinaryDialect);
+            const auto formatted = Util::formatByteSize(cost, 1);
             if (cost > 1024) {
                 return i18nc("%1: the formatted byte size, e.g. \"1.2KB\", %2: the raw byte size, e.g. \"1300\"",
                              "%1 (%2 bytes)", formatted, cost);
index fbbc05d..8dc2b70 100644 (file)
 #include <KChartHeaderFooter>
 #include <KChartLegend>
 
+#ifdef NO_K_LIB
+#include "noklib.h"
+#else
 #include <KColorScheme>
 #include <KFormat>
 #include <KLocalizedString>
+#endif
 
 #include "chartmodel.h"
 #include "chartproxy.h"
@@ -68,8 +72,8 @@ public:
 
     const QString customizedLabel(const QString& label) const override
     {
-        KFormat format(QLocale::system());
-        return format.formatByteSize(label.toDouble(), 1, KFormat::JEDECBinaryDialect);
+//!!        KFormat format(QLocale::system());
+        return Util::formatByteSize(label.toDouble(), 1);
     }
 };
 }
@@ -136,8 +140,13 @@ void ChartWidget::setModel(ChartModel* model, bool minimalMode)
         totalPlotter->setModel(totalProxy);
         totalPlotter->setType(Plotter::Stacked);
 
+#ifdef NO_K_LIB
+        QPalette pal;
+        const QPen foreground(pal.color(QPalette::Active, QPalette::Foreground));
+#else
         KColorScheme scheme(QPalette::Active, KColorScheme::Window);
         const QPen foreground(scheme.foreground().color());
+#endif
         auto bottomAxis = new TimeAxis(totalPlotter);
         auto axisTextAttributes = bottomAxis->textAttributes();
         axisTextAttributes.setPen(foreground);
index c2ef130..88dddca 100644 (file)
@@ -19,7 +19,7 @@
 #ifndef HEAPTRACK_GUI_CONFIG_H
 #define HEAPTRACK_GUI_CONFIG_H
 
-#ifndef NO_K_LIB
+#ifndef NO_K_CHART
 #define KChart_FOUND 1
 #endif
 
index cb1e092..5cdd7a5 100644 (file)
 
 #include <KChartGlobal>
 
+#ifdef NO_K_LIB
+#include "noklib.h"
+#else
 #include <KFormat>
 #include <KLocalizedString>
+#endif
 
 #include <QBrush>
 #include <QColor>
index 44b1695..996e206 100644 (file)
 #include <KChartHeaderFooter>
 #include <KChartLegend>
 
+#ifdef NO_K_LIB
+#include "noklib.h"
+#else
 #include <KColorScheme>
 #include <KFormat>
 #include <KLocalizedString>
+#endif
+
+#include "util.h"
 
 #include "histogrammodel.h"
 
@@ -52,8 +58,8 @@ public:
 
     const QString customizedLabel(const QString& label) const override
     {
-        KFormat format(QLocale::system());
-        return format.formatByteSize(label.toDouble(), 1, KFormat::JEDECBinaryDialect);
+//!!        KFormat format(QLocale::system());
+        return Util::formatByteSize(label.toDouble(), 1);
     }
 };
 
@@ -99,8 +105,13 @@ HistogramWidget::HistogramWidget(QWidget* parent)
     {
         m_total->setAntiAliasing(true);
 
+#ifdef NO_K_LIB
+        QPalette pal;
+        const QPen foreground(pal.color(QPalette::Active, QPalette::Foreground));
+#else
         KColorScheme scheme(QPalette::Active, KColorScheme::Window);
         QPen foreground(scheme.foreground().color());
+#endif
         auto bottomAxis = new CartesianAxis(m_total);
         auto axisTextAttributes = bottomAxis->textAttributes();
         axisTextAttributes.setPen(foreground);
index 074c527..5ecef66 100644 (file)
@@ -308,9 +308,6 @@ MainWindow::MainWindow(QWidget* parent)
         bottomUpModelFilterOutLeaves->setSummary(data);
         topDownModel->setSummary(data);
         callerCalleeModel->setSummary(data);
-#ifndef NO_K_LIB
-        KFormat format;
-#endif
         QString textLeft;
         QString textCenter;
         QString textRight;
index c29737b..cd8ac2e 100644 (file)
@@ -231,9 +231,6 @@ QVariant TreeModel::data(const QModelIndex& index, int role) const
         }
         stream << '\n';
         stream << '\n';
-#ifndef NO_K_LIB
-        KFormat format;
-#endif
         const auto allocatedFraction =
             QString::number(double(row->cost.allocated) * 100. / m_maxCost.cost.allocated, 'g', 3);
         const auto peakFraction = QString::number(double(row->cost.peak) * 100. / m_maxCost.cost.peak, 'g', 3);
index 3d9498c..3a29d8b 100644 (file)
@@ -35,7 +35,7 @@ QString Util::formatTime(qint64 ms)
     }
 }
 
-QString Util::formatByteSize(int64_t size, int precision)
+QString Util::formatByteSize(double size, int precision)
 {
 #ifndef NO_K_LIB
     static KFormat format;
@@ -73,12 +73,13 @@ QString Util::formatByteSize(int64_t size, int precision)
     QString result;
     if (divider > 1)
     {
-        result = QString::number(size / (double)divider, 'f', precision);
+        size /= divider;
     }
-    else
+    else if ((int32_t)size == size)
     {
-        result = QString::number(size);
+        precision = 0;
     }
+    result = QString::number(size, 'f', precision);
     result += ' ';
     result += suffix;
     return result;
index ad6165c..994a7fe 100644 (file)
@@ -27,7 +27,7 @@ namespace Util {
 
 QString formatTime(qint64 ms);
 
-QString formatByteSize(int64_t size, int precision = 1);
+QString formatByteSize(double size, int precision = 1);
 
 }
 
index b99c4d2..e891fbf 100644 (file)
@@ -10,8 +10,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
 INCLUDEPATH += $$PWD/analyze/gui
 
 win32 {
-    CONFIG += NO_K_LIB
-    DEFINES += NO_K_LIB
+    CONFIG += NO_K_LIB NO_K_CHART
+    DEFINES += NO_K_LIB NO_K_CHART
     INCLUDEPATH += $$(BOOST_LIB)
     LIBS += -L$$(BOOST_LIB)/stage/lib
 }
@@ -72,9 +72,12 @@ HEADERS += \
     QT += KIOWidgets
 
     QT += KItemModels
-    QT += KChart
 
     QT += ThreadWeaver
+}
+
+!NO_K_CHART {
+    QT += KChart
 
     SOURCES += \
         analyze/gui/chartmodel.cpp \