#include <KLocalizedString>
#include <QFileDialog>
+#include <QStatusBar>
#include "treemodel.h"
#include "treeproxy.h"
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
, m_ui(new Ui::MainWindow)
- , m_bottomUpModel(new TreeModel(this))
- , m_topDownModel(new TreeModel(this))
, m_parser(new Parser(this))
{
m_ui->setupUi(this);
m_ui->loadingProgress->setMinimum(0);
m_ui->loadingProgress->setMaximum(0);
+ auto bottomUpModel = new TreeModel(this);
+ auto topDownModel = new TreeModel(this);
+
auto consumedModel = new ChartModel(ChartModel::Consumed, this);
m_ui->consumedTab->setModel(consumedModel);
auto allocationsModel = new ChartModel(ChartModel::Allocations, this);
auto sizeHistogramModel = new HistogramModel(this);
m_ui->sizesTab->setModel(sizeHistogramModel);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->consumedTab), false);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->allocationsTab), false);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->allocatedTab), false);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->temporaryTab), false);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->sizesTab), false);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->topDownTab), false);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->flameGraphTab), false);
+
connect(m_parser, &Parser::bottomUpDataAvailable,
- m_bottomUpModel, &TreeModel::resetData);
+ this, [=] (const TreeData& data) {
+ bottomUpModel->resetData(data);
+ m_ui->flameGraphTab->setBottomUpData(data);
+ m_ui->progressLabel->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
+ statusBar()->addWidget(m_ui->progressLabel, 1);
+ statusBar()->addWidget(m_ui->loadingProgress);
+ m_ui->pages->setCurrentWidget(m_ui->resultsPage);
+ });
connect(m_parser, &Parser::topDownDataAvailable,
- m_topDownModel, &TreeModel::resetData);
+ this, [=] (const TreeData& data) {
+ topDownModel->resetData(data);
+ m_ui->flameGraphTab->setTopDownData(data);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->topDownTab), true);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->flameGraphTab), true);
+ });
connect(m_parser, &Parser::consumedChartDataAvailable,
- consumedModel, &ChartModel::resetData);
+ this, [=] (const ChartData& data) {
+ consumedModel->resetData(data);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->consumedTab), true);
+ });
connect(m_parser, &Parser::allocatedChartDataAvailable,
- allocatedModel, &ChartModel::resetData);
+ this, [=] (const ChartData& data) {
+ allocatedModel->resetData(data);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->allocatedTab), true);
+ });
connect(m_parser, &Parser::allocationsChartDataAvailable,
- allocationsModel, &ChartModel::resetData);
+ this, [=] (const ChartData& data) {
+ allocationsModel->resetData(data);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->allocationsTab), true);
+ });
connect(m_parser, &Parser::temporaryChartDataAvailable,
- temporaryModel, &ChartModel::resetData);
+ this, [=] (const ChartData& data) {
+ temporaryModel->resetData(data);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->temporaryTab), true);
+ });
connect(m_parser, &Parser::sizeHistogramDataAvailable,
- sizeHistogramModel, &HistogramModel::resetData);
+ this, [=] (const HistogramData& data) {
+ sizeHistogramModel->resetData(data);
+ m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->sizesTab), true);
+ });
connect(m_parser, &Parser::summaryAvailable,
m_ui->summary, &QLabel::setText);
connect(m_parser, &Parser::progressMessageAvailable,
m_ui->progressLabel, &QLabel::setText);
- connect(m_parser, &Parser::topDownDataAvailable,
- m_ui->flameGraphTab, &FlameGraph::setTopDownData);
- connect(m_parser, &Parser::bottomUpDataAvailable,
- m_ui->flameGraphTab, &FlameGraph::setBottomUpData);
connect(m_parser, &Parser::finished,
- this, [&] { m_ui->pages->setCurrentWidget(m_ui->resultsPage); });
+ this, [=] {
+ statusBar()->removeWidget(m_ui->progressLabel);
+ statusBar()->removeWidget(m_ui->loadingProgress);
+ });
- auto bottomUpProxy = new TreeProxy(m_bottomUpModel);
- bottomUpProxy->setSourceModel(m_bottomUpModel);
+ auto bottomUpProxy = new TreeProxy(bottomUpModel);
+ bottomUpProxy->setSourceModel(bottomUpModel);
bottomUpProxy->setSortRole(TreeModel::SortRole);
m_ui->bottomUpResults->setModel(bottomUpProxy);
m_ui->bottomUpResults->hideColumn(TreeModel::FunctionColumn);
connect(m_ui->bottomUpFilterModule, &QLineEdit::textChanged,
bottomUpProxy, &TreeProxy::setModuleFilter);
- auto topDownProxy = new TreeProxy(m_topDownModel);
- topDownProxy->setSourceModel(m_topDownModel);
+ auto topDownProxy = new TreeProxy(topDownModel);
+ topDownProxy->setSourceModel(topDownModel);
topDownProxy->setSortRole(TreeModel::SortRole);
m_ui->topDownResults->setModel(topDownProxy);
m_ui->topDownResults->hideColumn(TreeModel::FunctionColumn);