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
|
|
|
};
|
|
|
|
|
2021-07-13 22:07:06 +02:00
|
|
|
class Config : public QObject
|
2021-07-06 19:09:20 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2021-07-13 20:42:19 +02:00
|
|
|
|
|
|
|
///@brief Name of this summary (generally, "Summary")
|
2021-07-20 15:49:03 +02:00
|
|
|
Q_PROPERTY( QString title READ title NOTIFY titleChanged )
|
2021-07-13 20:42:19 +02:00
|
|
|
///@brief Description of what the summary means
|
2021-07-20 15:49:03 +02:00
|
|
|
Q_PROPERTY( QString message READ message NOTIFY messageChanged )
|
2021-07-13 20:42:19 +02:00
|
|
|
|
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-20 16:00:53 +02:00
|
|
|
explicit Config( QObject* parent = nullptr );
|
2021-07-06 19:09:20 +02:00
|
|
|
|
2021-07-13 22:07:06 +02:00
|
|
|
///@brief Called later, to load the model once all viewsteps are there
|
2021-07-20 16:00:53 +02:00
|
|
|
void collectSummaries( const Calamares::ViewStep* upToHere );
|
2021-10-04 12:10:17 +02:00
|
|
|
///@brief Clear the model of steps (to avoid dangling widgets)
|
|
|
|
void clearSummaries();
|
2021-07-06 19:09:20 +02:00
|
|
|
|
2021-07-13 21:28:46 +02:00
|
|
|
QAbstractListModel* summaryModel() const { return m_summary; }
|
2021-07-06 19:09:20 +02:00
|
|
|
|
2021-07-20 15:49:03 +02:00
|
|
|
QString title() const { return m_title; }
|
|
|
|
QString message() const { return m_message; }
|
|
|
|
|
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 10:36:05 +02:00
|
|
|
SummaryModel* m_summary;
|
2021-07-06 19:09:20 +02:00
|
|
|
|
|
|
|
QString m_title;
|
2021-07-20 15:49:03 +02:00
|
|
|
QString m_message;
|
2021-07-06 19:09:20 +02:00
|
|
|
|
2021-07-20 15:49:03 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void titleChanged( QString title );
|
|
|
|
void messageChanged( QString message );
|
2021-07-06 19:09:20 +02:00
|
|
|
};
|
|
|
|
#endif
|