calamares/src/modules/netinstall/PackageTreeItem.h

90 lines
2.9 KiB
C
Raw Normal View History

/* === 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>
* Copyright 2017, 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:
struct ItemData
{
QString name;
QString description;
QString preScript;
2017-01-25 09:34:18 +01:00
QString packageName;
2017-01-23 14:04:07 +01:00
QString postScript;
2017-01-25 09:34:18 +01:00
bool isCritical = false;
bool isHidden = false;
Qt::CheckState selected = Qt::Unchecked;
2017-01-23 14:04:07 +01:00
};
2017-09-13 20:07:09 +02:00
explicit PackageTreeItem( const ItemData& data, PackageTreeItem* parent = nullptr );
explicit PackageTreeItem( const QString packageName, PackageTreeItem* parent = nullptr );
explicit PackageTreeItem( PackageTreeItem* parent );
explicit PackageTreeItem(); // The root of the tree; always selected, named <root>
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;
int columnCount() 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-01-23 14:04:07 +01:00
PackageTreeItem* parentItem();
const PackageTreeItem* parentItem() const;
2017-01-23 14:04:07 +01:00
QString prettyName() const;
QString description() const;
QString preScript() const;
QString packageName() const;
QString postScript() const;
2017-01-23 14:04:07 +01:00
bool isHidden() const;
void setHidden( bool isHidden );
/**
* @brief Is this hidden item, considered "selected"?
*
* 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;
2017-01-23 14:04:07 +01:00
bool isCritical() const;
void setCritical( bool isCritical );
2017-01-23 14:04:07 +01:00
Qt::CheckState isSelected() const;
void setSelected( Qt::CheckState isSelected );
void setChildrenSelected( Qt::CheckState isSelected );
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-02-18 11:02:53 +01:00
QList< PackageTreeItem* > m_childItems;
2017-01-23 14:04:07 +01:00
ItemData m_data;
2020-02-18 11:02:53 +01:00
const int m_columns = 2; // Name, description
2017-01-23 13:42:40 +01:00
};
2020-02-18 11:02:53 +01:00
#endif // PACKAGETREEITEM_H