2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2017-01-23 13:42:40 +01:00
|
|
|
*
|
|
|
|
* Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za>
|
2020-02-18 17:40:15 +01:00
|
|
|
* Copyright 2017, 2020, Adriaan de Groot <groot@kde.org>
|
2017-01-23 13:42:40 +01:00
|
|
|
*
|
|
|
|
* Calamares is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PACKAGETREEITEM_H
|
|
|
|
#define PACKAGETREEITEM_H
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
#include <QStandardItem>
|
2020-02-18 11:02:53 +01:00
|
|
|
#include <QVariant>
|
2017-01-23 13:42:40 +01:00
|
|
|
|
|
|
|
class PackageTreeItem : public QStandardItem
|
|
|
|
{
|
2017-01-23 14:04:07 +01:00
|
|
|
public:
|
2020-03-20 19:48:29 +01:00
|
|
|
using PackageList = QList< PackageTreeItem* >;
|
|
|
|
|
|
|
|
///@brief A package (individual package)
|
|
|
|
explicit PackageTreeItem( const QString& packageName, PackageTreeItem* parent = nullptr );
|
|
|
|
///@brief A root item, always selected, named "<root>"
|
|
|
|
explicit PackageTreeItem();
|
2017-09-13 20:07:09 +02:00
|
|
|
~PackageTreeItem() override;
|
2017-01-23 13:42:40 +01:00
|
|
|
|
2017-01-23 14:04:07 +01:00
|
|
|
void appendChild( PackageTreeItem* child );
|
|
|
|
PackageTreeItem* child( int row );
|
|
|
|
int childCount() const;
|
2017-01-25 09:34:18 +01:00
|
|
|
QVariant data( int column ) const override;
|
2017-01-23 14:04:07 +01:00
|
|
|
int row() const;
|
2017-11-21 12:13:42 +01:00
|
|
|
|
2017-01-23 14:04:07 +01:00
|
|
|
PackageTreeItem* parentItem();
|
2017-11-21 12:13:42 +01:00
|
|
|
const PackageTreeItem* parentItem() const;
|
|
|
|
|
2020-03-20 19:48:29 +01:00
|
|
|
QString name() const { return m_name; }
|
|
|
|
QString packageName() const { return m_packageName; }
|
|
|
|
|
|
|
|
QString description() const { return m_description; }
|
|
|
|
QString preScript() const { return m_preScript; }
|
|
|
|
QString postScript() const { return m_postScript; }
|
2017-11-21 12:13:42 +01:00
|
|
|
|
2020-03-10 18:59:41 +01:00
|
|
|
/** @brief Is this item hidden?
|
|
|
|
*
|
|
|
|
* Hidden items (generally only groups) are maintained separately,
|
|
|
|
* not shown to the user, but do enter into the package-installation process.
|
|
|
|
*/
|
2020-03-20 19:48:29 +01:00
|
|
|
bool isHidden() const { return m_isHidden; }
|
2020-03-10 18:59:41 +01:00
|
|
|
|
|
|
|
/** @brief Is this hidden item, considered "selected"?
|
2017-11-21 12:13:42 +01:00
|
|
|
*
|
|
|
|
* This asserts when called on a non-hidden item.
|
|
|
|
* A hidden item has its own selected state, but really
|
|
|
|
* falls under the selectedness of the parent item.
|
|
|
|
*/
|
|
|
|
bool hiddenSelected() const;
|
|
|
|
|
2020-03-10 18:59:41 +01:00
|
|
|
/** @brief Is this group critical?
|
|
|
|
*
|
|
|
|
* A critical group must be successfully installed, for the Calamares
|
|
|
|
* installation to continue.
|
|
|
|
*/
|
2020-03-20 19:48:29 +01:00
|
|
|
bool isCritical() const { return m_isCritical; }
|
2017-11-21 12:13:42 +01:00
|
|
|
|
2020-03-10 18:59:41 +01:00
|
|
|
/** @brief Is this group expanded on start?
|
|
|
|
*
|
|
|
|
* This does not affect installation, only the UI. A group
|
|
|
|
* that expands on start is shown expanded (not collapsed)
|
|
|
|
* in the treeview when the page is loaded.
|
|
|
|
*/
|
2020-03-20 19:48:29 +01:00
|
|
|
bool expandOnStart() const { return m_startExpanded; }
|
|
|
|
|
|
|
|
/** @brief Turns this item into a variant for PackageOperations use
|
|
|
|
*
|
|
|
|
* For "plain" items, this is just the package name; items with
|
|
|
|
* scripts return a map. See the package module for how it's interpreted.
|
|
|
|
*/
|
|
|
|
QVariant toOperation() const;
|
2020-03-10 18:59:41 +01:00
|
|
|
|
2017-01-23 14:04:07 +01:00
|
|
|
Qt::CheckState isSelected() const;
|
|
|
|
void setSelected( Qt::CheckState isSelected );
|
|
|
|
void setChildrenSelected( Qt::CheckState isSelected );
|
2020-03-20 19:48:29 +01:00
|
|
|
|
|
|
|
// QStandardItem methods
|
2017-01-25 09:34:18 +01:00
|
|
|
int type() const override;
|
2020-02-18 11:02:53 +01:00
|
|
|
|
2017-01-23 14:04:07 +01:00
|
|
|
private:
|
2017-01-25 09:34:18 +01:00
|
|
|
PackageTreeItem* m_parentItem;
|
2020-03-20 19:48:29 +01:00
|
|
|
PackageList m_childItems;
|
|
|
|
|
|
|
|
// An entry can be a packkage, or a group.
|
|
|
|
QString m_name;
|
|
|
|
QString m_packageName;
|
|
|
|
Qt::CheckState m_selected = Qt::Unchecked;
|
|
|
|
|
|
|
|
// These are only useful for groups
|
|
|
|
QString m_description;
|
|
|
|
QString m_preScript;
|
|
|
|
QString m_postScript;
|
|
|
|
bool m_isCritical = false;
|
|
|
|
bool m_isHidden = false;
|
|
|
|
bool m_startExpanded = false;
|
2017-01-23 13:42:40 +01:00
|
|
|
};
|
|
|
|
|
2020-02-18 11:02:53 +01:00
|
|
|
#endif // PACKAGETREEITEM_H
|