Skip to content

Guidev #19

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jan 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/
/.project
/CMakeLists.txt.user
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ endif()

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ ${CMAKE_MODULE_PATH})
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
Expand Down
11 changes: 10 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
include_directories(${CMAKE_CURRENT_BINARY_DIR})

add_executable(hotspot
main.cpp
hotspot.cpp
util.cpp

parsers/perf/perfparser.cpp

models/costmodel.cpp

mainwindow.cpp

# ui files:
mainwindow.ui

# resources:
resources.qrc
)

target_link_libraries(hotspot
Expand Down
75 changes: 0 additions & 75 deletions src/hotspot.cpp

This file was deleted.

Binary file added src/images/hotspot_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/results_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 5 additions & 21 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,9 @@

#include <QApplication>
#include <QCommandLineParser>
#include <QTextStream>
#include <cstdio>

#include "hotspot.h"
#include "hotspot-config.h"

namespace {
void printUsage(const QCommandLineParser& parser, const QString& errorMessage)
{
QTextStream qerr(stderr);
if (!errorMessage.isEmpty()) {
qerr << errorMessage << "\n\n";
}
qerr << parser.helpText() << endl;
}
}
#include "mainwindow.h"

int main(int argc, char** argv)
{
Expand All @@ -64,14 +51,11 @@ int main(int argc, char** argv)

parser.process(app);

if (!parser.isSet(input)) {
printUsage(parser, QCoreApplication::translate("main", "Error: Input file is missing."));
return 1;
MainWindow window;
if (parser.isSet(input)) {
window.openFile(parser.value(input));
}

Hotspot hotspot;

hotspot.openFile(parser.value(input));
window.show();

return app.exec();
}
122 changes: 122 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
mainwindow.cpp

This file is part of Hotspot, the Qt GUI for performance analysis.

Copyright (C) 2016-2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Author: Nate Rogers <nate.rogers@kdab.com>

Licensees holding valid commercial KDAB Hotspot licenses may use this file in
accordance with Hotspot Commercial License Agreement provided with the Software.

Contact info@kdab.com if any conditions of this licensing are not clear to you.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QDebug>
#include <QFileDialog>
#include <QSortFilterProxyModel>

#include "models/costmodel.h"
#include "models/framedata.h"
#include "parsers/perf/perfparser.h"

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
m_bottomUpCostModel(new CostModel(this)),
m_parser(new PerfParser(this))
{
ui->setupUi(this);
ui->mainToolBar->hide();

ui->mainPageStack->setCurrentWidget(ui->startPage);
ui->openFileButton->setFocus();

auto proxy = new QSortFilterProxyModel(this);
proxy->setSourceModel(m_bottomUpCostModel);

ui->bottomUpTreeView->setSortingEnabled(true);
ui->bottomUpTreeView->sortByColumn(CostModel::SelfCost);
ui->bottomUpTreeView->setModel(proxy);

connect(m_parser, &PerfParser::bottomUpDataAvailable,
this, [this] (const FrameData& data) {
m_bottomUpCostModel->setData(data);
});

hideLoadingResults();
ui->loadingResultsErrorLabel->hide();

connect(m_parser, &PerfParser::parsingFinished,
this, [this] () {
ui->resultsButton->setEnabled(true);
ui->mainPageStack->setCurrentWidget(ui->resultsPage);
ui->resultsTabWidget->setCurrentWidget(ui->summaryTab);
ui->resultsTabWidget->setFocus();
hideLoadingResults();
});

connect(m_parser, &PerfParser::parsingFailed,
this, [this] (const QString& errorMessage) {
qWarning() << errorMessage;
hideLoadingResults();
ui->loadingResultsErrorLabel->setText(errorMessage);
ui->loadingResultsErrorLabel->show();
});
}

MainWindow::~MainWindow() = default;

void MainWindow::on_openFileButton_clicked()
{
const auto fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath(), tr("Data Files (*.data)"));

openFile(fileName);
}

void MainWindow::on_startButton_clicked()
{
ui->mainPageStack->setCurrentWidget(ui->startPage);
}

void MainWindow::on_resultsButton_clicked()
{
ui->mainPageStack->setCurrentWidget(ui->resultsPage);
}

void MainWindow::openFile(const QString& path)
{
showLoadingResults();

// TODO: support input files of different types via plugins
m_parser->startParseFile(path);
}

void MainWindow::showLoadingResults()
{
ui->openFileProgressBar->show();
ui->loadingResultsLabel->show();
ui->loadingResultsErrorLabel->hide();
}

void MainWindow::hideLoadingResults()
{
ui->openFileProgressBar->hide();
ui->loadingResultsLabel->hide();
}
29 changes: 22 additions & 7 deletions src/hotspot.h → src/mainwindow.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
hotspot.h
mainwindow.h

This file is part of Hotspot, the Qt GUI for performance analysis.

Copyright (C) 2016-2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
Author: Milian Wolff <milian.wolff@kdab.com>
Author: Nate Rogers <nate.rogers@kdab.com>

Licensees holding valid commercial KDAB Hotspot licenses may use this file in
accordance with Hotspot Commercial License Agreement provided with the Software.
Expand All @@ -27,22 +27,37 @@

#pragma once

#include <QObject>
#include <QMainWindow>
#include <QScopedPointer>

namespace Ui {
class MainWindow;
}

class CostModel;
class PerfParser;

class Hotspot : public QObject
class MainWindow : public QMainWindow
{
Q_OBJECT

public:
Hotspot(QObject* parent = nullptr);
~Hotspot();
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

public slots:
void openFile(const QString& path);

private slots:
void on_openFileButton_clicked();
void on_startButton_clicked();
void on_resultsButton_clicked();

private:
CostModel* m_model;
Ui::MainWindow *ui;
CostModel* m_bottomUpCostModel;
PerfParser* m_parser;

void showLoadingResults();
void hideLoadingResults();
};
Loading