source: calamares/trunk/fuentes/src/modules/netinstall/PackageModel.h @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 17 months ago

sync with github

File size: 2.5 KB
Line 
1
2/* === This file is part of Calamares - <https://github.com/calamares> ===
3 *
4 *   Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za>
5 *   Copyright 2017, Adriaan de Groot <groot@kde.org>
6 *
7 *   Calamares is free software: you can redistribute it and/or modify
8 *   it under the terms of the GNU General Public License as published by
9 *   the Free Software Foundation, either version 3 of the License, or
10 *   (at your option) any later version.
11 *
12 *   Calamares is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef PACKAGEMODEL_H
22#define PACKAGEMODEL_H
23
24#include "PackageTreeItem.h"
25
26#include <QAbstractItemModel>
27#include <QObject>
28#include <QString>
29
30#include <yaml-cpp/yaml.h>
31
32class PackageModel : public QAbstractItemModel
33{
34    Q_OBJECT
35
36public:
37    using PackageItemDataList = QList< PackageTreeItem::ItemData >;
38
39    explicit PackageModel( const YAML::Node& data, QObject* parent = nullptr );
40    ~PackageModel() override;
41
42    QVariant data( const QModelIndex& index, int role ) const override;
43    bool setData( const QModelIndex& index, const QVariant& value,
44                  int role = Qt::EditRole ) override;
45    bool setHeaderData( int section, Qt::Orientation orientation,
46                        const QVariant& value, int role = Qt::EditRole ) override;
47    Qt::ItemFlags flags( const QModelIndex& index ) const override;
48    QVariant headerData( int section, Qt::Orientation orientation,
49                         int role = Qt::DisplayRole ) const override;
50    QModelIndex index( int row, int column,
51                       const QModelIndex& parent = QModelIndex() ) const override;
52    QModelIndex parent( const QModelIndex& index ) const override;
53    int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
54    int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
55    PackageItemDataList getPackages() const;
56    QList<PackageTreeItem*> getItemPackages( PackageTreeItem* item ) const;
57
58private:
59    void setupModelData( const YAML::Node& data, PackageTreeItem* parent );
60
61    PackageTreeItem* m_rootItem;
62    QList<PackageTreeItem*> m_hiddenItems;
63    QVariantList m_columnHeadings;
64};
65
66#endif // PACKAGEMODEL_H
Note: See TracBrowser for help on using the repository browser.