Hide unnecessary parts of GUI in each display mode.
authorRuben Ayrapetyan <r.ayrapetyan@samsung.com>
Thu, 14 Sep 2017 13:29:59 +0000 (16:29 +0300)
committerRuben Ayrapetyan <r.ayrapetyan@samsung.com>
Thu, 14 Sep 2017 13:19:55 +0000 (16:19 +0300)
src/analyze/gui/flamegraph.cpp
src/analyze/gui/mainwindow.cpp

index 03d9942de3d98832c99c525bf03b80e5df69d292..74785cabe15eebcefdd41cbe132505825972eefe 100644 (file)
@@ -433,29 +433,32 @@ FlameGraph::FlameGraph(QWidget* parent, Qt::WindowFlags flags)
 {
     qRegisterMetaType<FrameGraphicsItem*>();
 
-    m_costSource->addItem(i18n("Allocations"), QVariant::fromValue(Allocations));
-    m_costSource->setItemData(0, i18n("Show a flame graph over the number of allocations triggered by "
-                                      "functions in your code."),
-                              Qt::ToolTipRole);
-    m_costSource->addItem(i18n("Temporary Allocations"), QVariant::fromValue(Temporary));
-    m_costSource->setItemData(1, i18n("Show a flame graph over the number of temporary allocations "
-                                      "triggered by functions in your code. "
-                                      "Allocations are marked as temporary when they are immediately "
-                                      "followed by their deallocation."),
-                              Qt::ToolTipRole);
     m_costSource->addItem(i18n("Memory Peak"), QVariant::fromValue(Peak));
-    m_costSource->setItemData(2, i18n("Show a flame graph over the contributions to the peak heap "
+    m_costSource->setItemData(0, i18n("Show a flame graph over the contributions to the peak heap "
                                       "memory consumption of your application."),
                               Qt::ToolTipRole);
     m_costSource->addItem(i18n("Leaked"), QVariant::fromValue(Leaked));
-    m_costSource->setItemData(3, i18n("Show a flame graph over the leaked heap memory of your application. "
+    m_costSource->setItemData(1, i18n("Show a flame graph over the leaked heap memory of your application. "
                                       "Memory is considered to be leaked when it never got deallocated. "),
                               Qt::ToolTipRole);
-    m_costSource->addItem(i18n("Allocated"), QVariant::fromValue(Allocated));
-    m_costSource->setItemData(4, i18n("Show a flame graph over the total memory allocated by functions in "
-                                      "your code. "
-                                      "This aggregates all memory allocations and ignores deallocations."),
-                              Qt::ToolTipRole);
+    if(AllocationData::display == AllocationData::DisplayId::malloc)
+    {
+        m_costSource->addItem(i18n("Allocations"), QVariant::fromValue(Allocations));
+        m_costSource->setItemData(2, i18n("Show a flame graph over the number of allocations triggered by "
+                                          "functions in your code."),
+                                  Qt::ToolTipRole);
+        m_costSource->addItem(i18n("Temporary Allocations"), QVariant::fromValue(Temporary));
+        m_costSource->setItemData(3, i18n("Show a flame graph over the number of temporary allocations "
+                                          "triggered by functions in your code. "
+                                          "Allocations are marked as temporary when they are immediately "
+                                          "followed by their deallocation."),
+                                  Qt::ToolTipRole);
+        m_costSource->addItem(i18n("Allocated"), QVariant::fromValue(Allocated));
+        m_costSource->setItemData(4, i18n("Show a flame graph over the total memory allocated by functions in "
+                                          "your code. "
+                                          "This aggregates all memory allocations and ignores deallocations."),
+                                  Qt::ToolTipRole);
+    }
     connect(m_costSource, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
             &FlameGraph::showData);
     m_costSource->setToolTip(i18n("Select the data source that should be visualized in the flame graph."));
index 05a0d38626c8e12715f5d192283843c3c553113f..f644292f9d73ca7949d75db68e6637e5aae34384 100644 (file)
@@ -259,6 +259,8 @@ MainWindow::MainWindow(QWidget* parent)
                            format.formatByteSize(data.totalSystemMemory, 1, KFormat::MetricBinaryDialect))
                    << "</dl></qt>";
         }
+
+        if(AllocationData::display == AllocationData::DisplayId::malloc)
         {
             QTextStream stream(&textCenter);
             stream << "<qt><dl>" << i18n("<dt><b>calls to allocation functions</b>:</dt><dd>%1 "
@@ -316,24 +318,28 @@ MainWindow::MainWindow(QWidget* parent)
 #if KChart_FOUND
     addChartTab(m_ui->tabWidget, i18n("Consumed"), ChartModel::Consumed, m_parser, &Parser::consumedChartDataAvailable,
                 this);
-    addChartTab(m_ui->tabWidget, i18n("Allocations"), ChartModel::Allocations, m_parser,
-                &Parser::allocationsChartDataAvailable, this);
-    addChartTab(m_ui->tabWidget, i18n("Temporary Allocations"), ChartModel::Temporary, m_parser,
-                &Parser::temporaryChartDataAvailable, this);
-    addChartTab(m_ui->tabWidget, i18n("Allocated"), ChartModel::Allocated, m_parser, &Parser::allocatedChartDataAvailable,
-                this);
 
-    auto sizesTab = new HistogramWidget(this);
-    m_ui->tabWidget->addTab(sizesTab, i18n("Sizes"));
-    m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(sizesTab), false);
-    auto sizeHistogramModel = new HistogramModel(this);
-    sizesTab->setModel(sizeHistogramModel);
-    connect(this, &MainWindow::clearData, sizeHistogramModel, &HistogramModel::clearData);
-
-    connect(m_parser, &Parser::sizeHistogramDataAvailable, this, [=](const HistogramData& data) {
-        sizeHistogramModel->resetData(data);
-        m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(sizesTab), true);
-    });
+    if(AllocationData::display == AllocationData::DisplayId::malloc)
+    {
+        addChartTab(m_ui->tabWidget, i18n("Allocations"), ChartModel::Allocations, m_parser,
+                    &Parser::allocationsChartDataAvailable, this);
+        addChartTab(m_ui->tabWidget, i18n("Temporary Allocations"), ChartModel::Temporary, m_parser,
+                    &Parser::temporaryChartDataAvailable, this);
+        addChartTab(m_ui->tabWidget, i18n("Allocated"), ChartModel::Allocated, m_parser, &Parser::allocatedChartDataAvailable,
+                    this);
+
+        auto sizesTab = new HistogramWidget(this);
+        m_ui->tabWidget->addTab(sizesTab, i18n("Sizes"));
+        m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(sizesTab), false);
+        auto sizeHistogramModel = new HistogramModel(this);
+        sizesTab->setModel(sizeHistogramModel);
+        connect(this, &MainWindow::clearData, sizeHistogramModel, &HistogramModel::clearData);
+
+        connect(m_parser, &Parser::sizeHistogramDataAvailable, this, [=](const HistogramData& data) {
+                sizeHistogramModel->resetData(data);
+                m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(sizesTab), true);
+                });
+    }
 #endif
 
     auto costDelegate = new CostDelegate(this);
@@ -386,12 +392,22 @@ MainWindow::MainWindow(QWidget* parent)
     m_ui->topPeak->setItemDelegate(costDelegate);
     setupTopView(bottomUpModel, m_ui->topLeaked, TopProxy::Leaked);
     m_ui->topLeaked->setItemDelegate(costDelegate);
-    setupTopView(bottomUpModel, m_ui->topAllocations, TopProxy::Allocations);
-    m_ui->topAllocations->setItemDelegate(costDelegate);
-    setupTopView(bottomUpModel, m_ui->topTemporary, TopProxy::Temporary);
-    m_ui->topTemporary->setItemDelegate(costDelegate);
-    setupTopView(bottomUpModel, m_ui->topAllocated, TopProxy::Allocated);
-    m_ui->topAllocated->setItemDelegate(costDelegate);
+
+    if(AllocationData::display == AllocationData::DisplayId::malloc)
+    {
+        setupTopView(bottomUpModel, m_ui->topAllocations, TopProxy::Allocations);
+        m_ui->topAllocations->setItemDelegate(costDelegate);
+        setupTopView(bottomUpModel, m_ui->topTemporary, TopProxy::Temporary);
+        m_ui->topTemporary->setItemDelegate(costDelegate);
+        setupTopView(bottomUpModel, m_ui->topAllocated, TopProxy::Allocated);
+        m_ui->topAllocated->setItemDelegate(costDelegate);
+    }
+    else
+    {
+        m_ui->widget_7->hide();
+        m_ui->widget_8->hide();
+        m_ui->widget_9->hide();
+    }
 
     setWindowTitle(i18n("Heaptrack"));
     // closing the current file shows the stack page to open a new one