m_ui->summary, &QLabel::setText);
connect(m_parser, &Parser::progressMessageAvailable,
m_ui->progressLabel, &QLabel::setText);
- connect(m_parser, &Parser::finished,
- this, [=] {
+ auto removeProgress = [this] {
statusBar()->removeWidget(m_ui->progressLabel);
statusBar()->removeWidget(m_ui->loadingProgress);
+ };
+ connect(m_parser, &Parser::finished,
+ this, removeProgress);
+ connect(m_parser, &Parser::failedToOpen,
+ this, [this, removeProgress] (const QString& failedFile) {
+ removeProgress();
+ m_ui->pages->setCurrentWidget(m_ui->openPage);
+ m_ui->messages->setText(i18n("Failed to parse file %1.", failedFile));
+ m_ui->messages->show();
});
+ m_ui->messages->hide();
auto bottomUpProxy = new TreeProxy(bottomUpModel);
bottomUpProxy->setSourceModel(bottomUpModel);
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <layout class="QVBoxLayout" name="verticalLayout_6">
+ <item>
+ <widget class="KMessageWidget" name="messages">
+ <property name="messageType">
+ <enum>KMessageWidget::Information</enum>
+ </property>
+ <property name="icon">
+ <iconset theme="dialog-error"/>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QStackedWidget" name="pages">
<widget class="QWidget" name="openPage">
</widget>
<customwidgets>
<customwidget>
+ <class>KMessageWidget</class>
+ <extends>QFrame</extends>
+ <header>kmessagewidget.h</header>
+ </customwidget>
+ <customwidget>
<class>ChartWidget</class>
<extends>QWidget</extends>
<header>chartwidget.h</header>
const auto stdPath = path.toStdString();
auto data = make_shared<ParserData>();
emit progressMessageAvailable(i18n("parsing data..."));
- data->read(stdPath);
+ if (!data->read(stdPath)) {
+ emit failedToOpen(path);
+ return;
+ }
+
data->updateStringCache();
emit summaryAvailable(generateSummary(*data));
void temporaryChartDataAvailable(const ChartData& data);
void sizeHistogramDataAvailable(const HistogramData& data);
void finished();
+ void failedToOpen(const QString& path);
};
#endif // PARSER_H