Commit 2979e388 authored by Igor Kushnir's avatar Igor Kushnir Committed by Kevin Funk
Browse files

Report man pages loading error

If kio-extras is not installed, Man page loading progress bar is stuck at zero.
Showing an error message helps to identify the problem and fix it.

REVIEW: 128943
(cherry picked from commit 99d2e785)
parent e7fd2ef3
......@@ -40,7 +40,7 @@ ManPageDocumentationWidget::ManPageDocumentationWidget(QWidget *parent)
if(!model->isLoaded()){
m_loadingWidget = new QWidget(this);
m_progressBar = new QProgressBar(m_loadingWidget);
QLabel* label = new QLabel(i18n("Loading man pages ..."));
m_statusLabel = new QLabel(i18n("Loading man pages ..."));
if(model->sectionCount() == 0){
connect(model, &ManPageModel::sectionListUpdated, this, &ManPageDocumentationWidget::sectionListUpdated );
} else {
......@@ -48,14 +48,17 @@ ManPageDocumentationWidget::ManPageDocumentationWidget(QWidget *parent)
}
connect(model, &ManPageModel::sectionParsed, this, &ManPageDocumentationWidget::sectionParsed );
connect(model, &ManPageModel::manPagesLoaded, this, &ManPageDocumentationWidget::manIndexLoaded);
label->setAlignment(Qt::AlignHCenter);
connect(model, &ManPageModel::error, this, &ManPageDocumentationWidget::handleError);
m_statusLabel->setAlignment(Qt::AlignHCenter);
QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget(label);
layout->addWidget(m_statusLabel);
layout->addWidget(m_progressBar);
layout->addStretch();
m_loadingWidget->setLayout(layout);
addWidget(m_loadingWidget);
setCurrentWidget(m_loadingWidget);
if(model->hasError())
handleError(model->errorString());
} else {
manIndexLoaded();
}
......@@ -85,3 +88,11 @@ void ManPageDocumentationWidget::sectionParsed()
ManPageModel* model = ManPageDocumentation::s_provider->model();
m_progressBar->setValue(model->nbSectionLoaded());
}
void ManPageDocumentationWidget::handleError(const QString& errorString)
{
delete m_progressBar;
m_progressBar = nullptr;
m_statusLabel->setWordWrap(true);
m_statusLabel->setText(i18n("Man pages loading error") + '\n' + errorString);
}
......@@ -23,6 +23,8 @@
#include <QStackedWidget>
class QString;
class QLabel;
class QTreeView;
class QProgressBar;
......@@ -35,9 +37,11 @@ public slots:
void manIndexLoaded();
void sectionListUpdated();
void sectionParsed();
void handleError(const QString& errorString);
private:
QWidget* m_loadingWidget;
QTreeView* m_treeView;
QLabel* m_statusLabel;
QProgressBar* m_progressBar;
};
......
......@@ -120,8 +120,14 @@ void ManPageModel::indexEntries(KIO::Job* /*job*/, const KIO::UDSEntryList& entr
}
}
void ManPageModel::indexLoaded()
void ManPageModel::indexLoaded(KJob* job)
{
if (job->error() != 0) {
m_errorString = job->errorString();
emit error(m_errorString);
return;
}
emit sectionListUpdated();
iterator = new QListIterator<ManSection>(m_sectionList);
......@@ -224,3 +230,12 @@ bool ManPageModel::identifierInSection(const QString& identifier, const QString&
return false;
}
bool ManPageModel::hasError() const
{
return !m_errorString.isEmpty();
}
const QString& ManPageModel::errorString() const
{
return m_errorString;
}
......@@ -56,10 +56,14 @@ public:
bool isLoaded() const;
int nbSectionLoaded() const;
bool identifierInSection(const QString &identifier, const QString &section) const;
bool hasError() const;
const QString& errorString() const;
signals:
void sectionParsed();
void sectionListUpdated();
void manPagesLoaded();
void error(const QString& errorString);
public slots:
void showItem(const QModelIndex& idx);
......@@ -69,7 +73,7 @@ private slots:
void initModel();
void indexEntries(KIO::Job* job, const KIO::UDSEntryList& entries);
void indexLoaded();
void indexLoaded(KJob* job);
void sectionEntries(KIO::Job* job, const KIO::UDSEntryList& entries);
void sectionLoaded();
......@@ -86,6 +90,7 @@ private:
bool m_loaded;
int m_nbSectionLoaded;
QString m_errorString;
};
#endif // MANPAGEMODEL_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment