Cleanup and rename leaked in gui to consumed.
authorMilian Wolff <mail@milianw.de>
Tue, 22 Sep 2015 07:10:06 +0000 (09:10 +0200)
committerMilian Wolff <mail@milianw.de>
Tue, 22 Sep 2015 07:15:20 +0000 (09:15 +0200)
gui/chartmodel.cpp
gui/chartmodel.h
gui/chartproxy.cpp
gui/chartproxy.h
gui/mainwindow.cpp
gui/mainwindow.ui
gui/parser.cpp
gui/parser.h

index 67099fd..1e0fcde 100644 (file)
@@ -71,8 +71,8 @@ QVariant ChartModel::headerData(int section, Qt::Orientation orientation, int ro
                 return i18n("Memory Allocated");
             case Allocations:
                 return i18n("Memory Allocations");
-            case Leaked:
-                return i18n("Memory Leaked");
+            case Consumed:
+                return i18n("Memory Consumed");
             }
         }
     }
@@ -91,11 +91,11 @@ QVariant ChartModel::data(const QModelIndex& index, int role) const
     if ( role == KChart::LineAttributesRole ) {
         KChart::LineAttributes attributes;
         attributes.setDisplayArea(true);
-//         if (index == m_selection) {
-//             attributes.setTransparency(255);
-//         } else {
+        if (index.column() > 1) {
+            attributes.setTransparency(127);
+        } else {
             attributes.setTransparency(50);
-//         }
+        }
         return QVariant::fromValue(attributes);
     }
 
index e8477b9..c5627c1 100644 (file)
@@ -43,7 +43,7 @@ class ChartModel : public QAbstractTableModel
     Q_OBJECT
 public:
     enum Type {
-        Leaked,
+        Consumed,
         Allocations,
         Allocated,
     };
index bab96ef..70b8e79 100644 (file)
 #include "chartproxy.h"
 #include "chartmodel.h"
 
-#include <KLocalizedString>
-
-#include <QDebug>
-
 ChartProxy::ChartProxy(bool showTotal, QObject* parent)
     : QSortFilterProxyModel(parent)
     , m_showTotal(showTotal)
@@ -32,19 +28,6 @@ ChartProxy::ChartProxy(bool showTotal, QObject* parent)
 
 ChartProxy::~ChartProxy() = default;
 
-/*
-QVariant ChartProxy::data(const QModelIndex& proxyIndex, int role) const
-{
-    static_assert(ChartModel::TimeStampColumn == 0, "The code below assumes the time stamp column comes with value 0.");
-    if (role == Qt::ToolTipRole) {
-        // KChart queries the tooltip for the timestamp column, which is not useful for us
-        // instead, we want to use the m_column, or in proxy column value that is 1
-        return QSortFilterProxyModel::data(index(proxyIndex.row(), proxyIndex.column() + 1, proxyIndex.parent()), role);
-    } else {
-        return QSortFilterProxyModel::data(proxyIndex, role);
-    }
-}*/
-
 bool ChartProxy::filterAcceptsColumn(int sourceColumn, const QModelIndex& /*sourceParent*/) const
 {
     if (m_showTotal && sourceColumn >= 2)
index 968bade..8b97601 100644 (file)
@@ -30,8 +30,6 @@ public:
     explicit ChartProxy(bool showTotal, QObject* parent = nullptr);
     virtual ~ChartProxy();
 
-//     QVariant data(const QModelIndex & proxyIndex, int role = Qt::DisplayRole) const override;
-
 protected:
     bool filterAcceptsColumn(int sourceColumn, const QModelIndex& sourceParent) const override;
 
index caa1950..e50dd1a 100644 (file)
@@ -49,8 +49,8 @@ MainWindow::MainWindow(QWidget* parent)
     m_ui->loadingProgress->setMinimum(0);
     m_ui->loadingProgress->setMaximum(0);
 
-    auto leakedModel = new ChartModel(ChartModel::Leaked, this);
-    m_ui->leakedTab->setModel(leakedModel);
+    auto consumedModel = new ChartModel(ChartModel::Consumed, this);
+    m_ui->consumedTab->setModel(consumedModel);
     auto allocationsModel = new ChartModel(ChartModel::Allocations, this);
     m_ui->allocationsTab->setModel(allocationsModel);
     auto allocatedModel = new ChartModel(ChartModel::Allocated, this);
@@ -60,8 +60,8 @@ MainWindow::MainWindow(QWidget* parent)
             m_bottomUpModel, &TreeModel::resetData);
     connect(m_parser, &Parser::topDownDataAvailable,
             m_topDownModel, &TreeModel::resetData);
-    connect(m_parser, &Parser::leakedChartDataAvailable,
-            leakedModel, &ChartModel::resetData);
+    connect(m_parser, &Parser::consumedChartDataAvailable,
+            consumedModel, &ChartModel::resetData);
     connect(m_parser, &Parser::allocatedChartDataAvailable,
             allocatedModel, &ChartModel::resetData);
     connect(m_parser, &Parser::allocationsChartDataAvailable,
index c91db49..8187984 100644 (file)
             </item>
            </layout>
           </widget>
-          <widget class="ChartWidget" name="leakedTab">
+          <widget class="ChartWidget" name="consumedTab">
            <attribute name="title">
-            <string>Leaked</string>
+            <string>Consumed</string>
            </attribute>
           </widget>
           <widget class="ChartWidget" name="allocationsTab">
index 6c41d01..fe920e2 100644 (file)
@@ -92,7 +92,7 @@ struct StringCache
 struct ChartMergeData
 {
     QString function;
-    quint64 leaked;
+    quint64 consumed;
     quint64 allocations;
     quint64 allocated;
     bool operator<(const QString& rhs) const
@@ -106,11 +106,11 @@ struct ParserData final : public AccumulatedTraceData
     ParserData()
     {
         // start off with null data at the origin
-        leakedChartData.data.rows.push_back({});
+        consumedChartData.data.rows.push_back({});
         allocatedChartData.data.rows.push_back({});
         allocationsChartData.data.rows.push_back({});
         // index 0 indicates the total row
-        leakedChartData.labelIds.insert(i18n("total"), 0);
+        consumedChartData.labelIds.insert(i18n("total"), 0);
         allocatedChartData.labelIds.insert(i18n("total"), 0);
         allocationsChartData.labelIds.insert(i18n("total"), 0);
     }
@@ -118,13 +118,7 @@ struct ParserData final : public AccumulatedTraceData
     void handleTimeStamp(uint64_t /*oldStamp*/, uint64_t newStamp)
     {
         stringCache.update(strings);
-        maxLeakedSinceLastTimeStamp = max(maxLeakedSinceLastTimeStamp, leaked);
-        ChartRows leakedData;
-        leakedData.timeStamp = newStamp;
-        leakedData.cost.insert(0, maxLeakedSinceLastTimeStamp);
-        ChartRows allocationsData;
-        allocationsData.timeStamp = newStamp;
-        allocationsData.cost.insert(0, totalAllocations);
+        maxConsumedSinceLastTimeStamp = max(maxConsumedSinceLastTimeStamp, leaked);
 
         // merge data for top 10 functions in this timestamp
         vector<ChartMergeData> mergedData;
@@ -134,7 +128,7 @@ struct ParserData final : public AccumulatedTraceData
             if (it != mergedData.end() && it->function == function) {
                 it->allocated += allocation.allocated;
                 it->allocations += allocation.allocations;
-                it->leaked += allocation.leaked;
+                it->consumed += allocation.leaked;
             } else {
                 it = mergedData.insert(it, {function, allocation.leaked, allocation.allocations, allocation.allocated});
             }
@@ -168,15 +162,15 @@ struct ParserData final : public AccumulatedTraceData
                 }
             }
         };
-        addChartData(&ChartMergeData::leaked, &leakedChartData, maxLeakedSinceLastTimeStamp);
+        addChartData(&ChartMergeData::consumed, &consumedChartData, maxConsumedSinceLastTimeStamp);
         addChartData(&ChartMergeData::allocated, &allocatedChartData, totalAllocated);
         addChartData(&ChartMergeData::allocations, &allocationsChartData, totalAllocations);
-        maxLeakedSinceLastTimeStamp = 0;
+        maxConsumedSinceLastTimeStamp = 0;
     }
 
     void handleAllocation()
     {
-        maxLeakedSinceLastTimeStamp = max(maxLeakedSinceLastTimeStamp, leaked);
+        maxConsumedSinceLastTimeStamp = max(maxConsumedSinceLastTimeStamp, leaked);
     }
 
     void handleDebuggee(const char* command)
@@ -191,10 +185,10 @@ struct ParserData final : public AccumulatedTraceData
         ChartData data;
         QHash<QString, int> labelIds;
     };
-    ChartDataWithLabels leakedChartData;
+    ChartDataWithLabels consumedChartData;
     ChartDataWithLabels allocationsChartData;
     ChartDataWithLabels allocatedChartData;
-    uint64_t maxLeakedSinceLastTimeStamp = 0;
+    uint64_t maxConsumedSinceLastTimeStamp = 0;
 
     StringCache stringCache;
 };
@@ -327,7 +321,7 @@ void Parser::parse(const QString& path)
         emit summaryAvailable(generateSummary(data));
         const auto mergedAllocations = mergeAllocations(data);
         emit bottomUpDataAvailable(mergedAllocations);
-        emit leakedChartDataAvailable(data.leakedChartData.data);
+        emit consumedChartDataAvailable(data.consumedChartData.data);
         emit allocationsChartDataAvailable(data.allocationsChartData.data);
         emit allocatedChartDataAvailable(data.allocatedChartData.data);
         const auto topDownData = toTopDownData(mergedAllocations);
index 00b0d49..46b1755 100644 (file)
@@ -41,7 +41,7 @@ signals:
     void summaryAvailable(const QString& summary);
     void bottomUpDataAvailable(const TreeData& data);
     void topDownDataAvailable(const TreeData& data);
-    void leakedChartDataAvailable(const ChartData& data);
+    void consumedChartDataAvailable(const ChartData& data);
     void allocationsChartDataAvailable(const ChartData& data);
     void allocatedChartDataAvailable(const ChartData& data);
     void flameGraphDataAvailable(FrameGraphicsItem* rootItem);