#include <ui_mainwindow.h>
#include <KRecursiveFilterProxyModel>
+#include <KStandardAction>
+#include <KLocalizedString>
-#include <iostream>
+#include <QFileDialog>
#include "model.h"
#include "proxy.h"
proxy->setSourceModel(m_model);
m_ui->results->setModel(proxy);
+ m_ui->pages->setCurrentWidget(m_ui->openPage);
+ // TODO: proper progress report
+ m_ui->loadingProgress->setMinimum(0);
+ m_ui->loadingProgress->setMaximum(0);
+
connect(m_model, &Model::dataReady,
this, &MainWindow::dataReady);
proxy, &Proxy::setFileFilter);
connect(m_ui->filterModule, &QLineEdit::textChanged,
proxy, &Proxy::setModuleFilter);
+
+ auto openFile = KStandardAction::open(this, SLOT(openFile()), this);
+ m_ui->openFile->setDefaultAction(openFile);
+
+ setWindowTitle(i18n("Heaptrack"));
}
MainWindow::~MainWindow()
void MainWindow::dataReady(const QString& summary)
{
m_ui->summary->setText(summary);
+ m_ui->pages->setCurrentWidget(m_ui->resultsPage);
}
void MainWindow::loadFile(const QString& file)
{
- cout << "Loading file " << qPrintable(file) << ", this might take some time - please wait." << endl;
-
+ m_ui->loadingLabel->setText(i18n("Loading file %1, please wait...", file));
+ setWindowTitle(i18nc("%1: file name that is open", "Heaptrack - %1", file));
+ m_ui->pages->setCurrentWidget(m_ui->loadingPage);
m_model->loadFile(file);
}
+
+void MainWindow::openFile()
+{
+ auto dialog = new QFileDialog(this, i18n("Open Heaptrack Output File"), {}, i18n("Heaptrack data files (heaptrack.*)"));
+ dialog->setAttribute(Qt::WA_DeleteOnClose, true);
+ dialog->setFileMode(QFileDialog::ExistingFile);
+ connect(dialog, &QFileDialog::fileSelected,
+ this, &MainWindow::loadFile);
+ dialog->show();
+}
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <widget class="QLabel" name="summary">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QWidget" name="widget" native="true">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QLineEdit" name="filterFunction">
- <property name="placeholderText">
- <string>filter by function...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="filterFile">
- <property name="placeholderText">
- <string>filter by file...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="filterModule">
- <property name="placeholderText">
- <string>filter by module...</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QTreeView" name="results">
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="rootIsDecorated">
- <bool>true</bool>
- </property>
- <property name="uniformRowHeights">
- <bool>true</bool>
- </property>
- <property name="sortingEnabled">
- <bool>true</bool>
- </property>
+ <widget class="QStackedWidget" name="pages">
+ <widget class="QWidget" name="openPage">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QToolButton" name="openFile">
+ <property name="text">
+ <string notr="true">...</string>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextUnderIcon</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="loadingPage">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="loadingLabel">
+ <property name="text">
+ <string>Loading file %1, please wait...</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="loadingProgress">
+ <property name="value">
+ <number>24</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="resultsPage">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="summary">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" name="widget" native="true">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLineEdit" name="filterFunction">
+ <property name="placeholderText">
+ <string>filter by function...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="filterFile">
+ <property name="placeholderText">
+ <string>filter by file...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="filterModule">
+ <property name="placeholderText">
+ <string>filter by module...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTreeView" name="results">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <property name="uniformRowHeights">
+ <bool>true</bool>
+ </property>
+ <property name="sortingEnabled">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>