2021-07-06 19:09:20 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
|
|
|
*
|
|
|
|
* SPDX-FileCopyrightText: 2019-2020, Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2020, Camilo Higuita <milo.h@aol.com>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*
|
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SUMMARY_CONFIG_H
|
|
|
|
#define SUMMARY_CONFIG_H
|
|
|
|
|
2021-07-13 10:36:05 +02:00
|
|
|
#include "viewpages/ViewStep.h"
|
2021-07-13 21:25:57 +02:00
|
|
|
|
2021-07-06 19:09:20 +02:00
|
|
|
#include <QAbstractListModel>
|
2021-07-13 10:36:05 +02:00
|
|
|
#include <QObject>
|
2021-07-06 19:09:20 +02:00
|
|
|
#include <QQmlParserStatus>
|
|
|
|
|
2021-07-13 22:04:01 +02:00
|
|
|
class Config;
|
|
|
|
|
2021-07-13 11:02:24 +02:00
|
|
|
/** @brief Data for one step
|
|
|
|
*
|
|
|
|
* A step generally has a text description, but **may** have a
|
|
|
|
* QWidget. There is no ownership of the QWidget, that is assumed
|
|
|
|
* to be handed off to some owning parent-widget.
|
|
|
|
*/
|
2021-07-06 19:09:20 +02:00
|
|
|
struct StepSummary
|
|
|
|
{
|
|
|
|
QString title;
|
|
|
|
QString message;
|
2021-07-13 11:02:24 +02:00
|
|
|
QWidget* widget = nullptr;
|
2021-07-06 19:09:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class SummaryModel : public QAbstractListModel
|
|
|
|
{
|
2021-07-13 10:36:05 +02:00
|
|
|
Q_OBJECT
|
2021-07-13 22:04:01 +02:00
|
|
|
friend class Config;
|
|
|
|
|
2021-07-06 19:09:20 +02:00
|
|
|
public:
|
2021-07-13 10:36:05 +02:00
|
|
|
explicit SummaryModel( QObject* parent = nullptr );
|
2021-07-06 19:09:20 +02:00
|
|
|
int rowCount( const QModelIndex& = QModelIndex() ) const override;
|
|
|
|
QVariant data( const QModelIndex& index, int role ) const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QHash< int, QByteArray > roleNames() const override;
|
2021-07-13 10:36:05 +02:00
|
|
|
|
2021-07-06 19:09:20 +02:00
|
|
|
private:
|
2021-07-13 22:04:01 +02:00
|
|
|
/** @brief Sets the model data from @p steps
|
|
|
|
*
|
|
|
|
* Replaces the list of summaries with summaries given by
|
|
|
|
* the jobs and ViewSteps objects in @p steps. If @p withWidgets
|
|
|
|
* is @c true, then also queries for widget summaries alongside
|
|
|
|
* the text summaries for each step.
|
|
|
|
*/
|
|
|
|
void setSummaryList( const Calamares::ViewStepList& steps, bool withWidgets = false );
|
|
|
|
|
2021-07-13 11:02:24 +02:00
|
|
|
QVector< StepSummary > m_summary;
|
2021-07-06 19:09:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class Config : public QObject, public QQmlParserStatus
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2021-07-13 20:42:19 +02:00
|
|
|
|
|
|
|
///@brief Name of this summary (generally, "Summary")
|
|
|
|
Q_PROPERTY( QString title MEMBER m_title NOTIFY titleChanged )
|
|
|
|
///@brief Description of what the summary means
|
|
|
|
Q_PROPERTY( QString message MEMBER m_message NOTIFY messageChanged )
|
|
|
|
|
2021-07-13 21:28:46 +02:00
|
|
|
Q_PROPERTY( QAbstractListModel* summaryModel READ summaryModel CONSTANT FINAL )
|
2021-07-06 19:09:20 +02:00
|
|
|
|
|
|
|
public:
|
2021-07-13 21:25:57 +02:00
|
|
|
explicit Config( Calamares::ViewStep* parent = nullptr );
|
2021-07-06 19:09:20 +02:00
|
|
|
virtual void componentComplete() override;
|
|
|
|
virtual void classBegin() override {}
|
|
|
|
|
|
|
|
void refresh();
|
|
|
|
void init();
|
|
|
|
|
2021-07-13 21:28:46 +02:00
|
|
|
QAbstractListModel* summaryModel() const { return m_summary; }
|
2021-07-06 19:09:20 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps ) const;
|
2021-07-13 20:42:19 +02:00
|
|
|
void retranslate();
|
|
|
|
|
2021-07-13 21:25:57 +02:00
|
|
|
const Calamares::ViewStep* m_thisViewStep;
|
2021-07-13 10:36:05 +02:00
|
|
|
SummaryModel* m_summary;
|
2021-07-06 19:09:20 +02:00
|
|
|
|
|
|
|
QString m_message;
|
|
|
|
QString m_title;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void messageChanged();
|
|
|
|
void titleChanged();
|
|
|
|
};
|
|
|
|
#endif
|