calamares/src/modules/netinstall/PackageModel.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

94 lines
3.0 KiB
C
Raw Normal View History

2017-11-06 11:42:13 +01:00
/* === This file is part of Calamares - <https://calamares.io> ===
2017-01-23 13:42:40 +01:00
*
2020-08-22 01:19:58 +02:00
* SPDX-FileCopyrightText: 2017 Kyle Robbertze <kyle@aims.ac.za>
* SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
2017-01-23 13:42:40 +01:00
*
* Calamares is Free Software: see the License-Identifier above.
2017-01-23 13:42:40 +01:00
*
*/
#ifndef PACKAGEMODEL_H
#define PACKAGEMODEL_H
#include "PackageTreeItem.h"
#include <QAbstractItemModel>
#include <QObject>
#include <QString>
namespace YAML
{
2020-02-18 11:02:53 +01:00
class Node;
}
2017-01-23 13:42:40 +01:00
class PackageModel : public QAbstractItemModel
{
Q_OBJECT
2017-01-23 14:04:07 +01:00
public:
// Names for columns (unused in the code)
static constexpr const int NameColumn = 0;
static constexpr const int DescriptionColumn = 1;
/* The only interesting roles are DisplayRole (with text depending
* on the column, and MetaExpandRole which tells if an index
* should be initially expanded.
*/
static constexpr const int MetaExpandRole = Qt::UserRole + 1;
explicit PackageModel( QObject* parent = nullptr );
2017-09-13 20:07:09 +02:00
~PackageModel() override;
2017-01-23 13:42:40 +01:00
void setupModelData( const QVariantList& l );
2017-01-25 09:34:18 +01:00
QVariant data( const QModelIndex& index, int role ) const override;
2020-02-18 11:02:53 +01:00
bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override;
2017-01-25 09:34:18 +01:00
Qt::ItemFlags flags( const QModelIndex& index ) const override;
2020-02-18 11:02:53 +01:00
QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override;
2017-01-25 09:34:18 +01:00
QModelIndex parent( const QModelIndex& index ) const override;
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
2017-01-25 09:34:18 +01:00
int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
/** @brief Sets the checked flag on matching groups in the tree
*
* Recursively traverses the tree pointed to by m_rootItem and
* checks if a group name matches any of the items in @p selectNames.
* If a match is found, set check the box for that group and it's children.
*
* Individual packages will not be matched.
*
*/
void setSelections( const QStringList& selectNames );
PackageTreeItem::List getPackages() const;
PackageTreeItem::List getItemPackages( PackageTreeItem* item ) const;
2017-01-23 13:42:40 +01:00
/** @brief Appends groups to the tree
*
* Uses the data from @p groupList to add elements to the
* existing tree that m_rootItem points to. If m_rootItem
* is not valid, it does nothing
*
* Before adding anything to the model, it ensures that there
* is no existing data from the same source. If there is, that
* data is pruned first
*
*/
void appendModelData( const QVariantList& groupList );
2017-01-23 14:04:07 +01:00
private:
friend class ItemTests;
void setupModelData( const QVariantList& l, PackageTreeItem* parent );
2017-01-23 13:42:40 +01:00
PackageTreeItem* m_rootItem = nullptr;
PackageTreeItem::List m_hiddenItems;
2017-01-23 13:42:40 +01:00
};
2020-02-18 11:02:53 +01:00
#endif // PACKAGEMODEL_H