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 1db0ac9ddfd811e8e186887fd08f635e42120c11..8778819a32447cb1440ac0c8cb00a9fe1d12b674 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 fbbc05d8a9b13e38b12dc525f979036466078cdd..8dc2b709e3f8279b15a414d873671f28ea56bde4 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 c2ef130d1433a358a717bd3383b7b225020b4c9e..88dddca89ee9d872e6c4c516711928c32636cc11 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 cb1e09271813e6d5693b06f7117ef5b71d6d8a21..5cdd7a58b48262b56affeeabe1953ac0ffa1b69d 100644 (file)
 
 #include <KChartGlobal>
 
+#ifdef NO_K_LIB
+#include "noklib.h"
+#else
 #include <KFormat>
 #include <KLocalizedString>
+#endif
 
 #include <QBrush>
 #include <QColor>
index 44b16955f8502cf4ed7867731a3a3f8d312f8716..996e206c48cb5a803ecc4cf759e966d4bb6cc770 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 074c527b5c5910fbdae1e94eb52ffbd632c6dd24..5ecef666f6fc0b67cf694726109da227e3bf80e9 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 c29737b53a1c523e589511b13a031e57531f3799..cd8ac2e1d94e0182285662566923349a0de0699d 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 3d9498cc9fb32935482dd982316c010b15bf2937..3a29d8b9f8df085533d036b9854f328f0144f07d 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 ad6165ccb5166e03b71b1591a862a4a639371796..994a7feb1913c557ce7ff2f80ab7bad928e5ea4c 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 b99c4d2f7b9ce3390adfc21582bca724bb11674f..e891fbf8ba3fa330ca4de26bc80328a9c8ebd132 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 \