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

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

sync with github

File size: 2.8 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za>
4 *   Copyright 2017, Adriaan de Groot <groot@kde.org>
5 *
6 *   Calamares is free software: you can redistribute it and/or modify
7 *   it under the terms of the GNU General Public License as published by
8 *   the Free Software Foundation, either version 3 of the License, or
9 *   (at your option) any later version.
10 *
11 *   Calamares is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *   GNU General Public License for more details.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef PACKAGETREEITEM_H
21#define PACKAGETREEITEM_H
22
23#include <QList>
24#include <QVariant>
25#include <QStandardItem>
26
27class PackageTreeItem : public QStandardItem
28{
29public:
30    struct ItemData
31    {
32        QString name;
33        QString description;
34        QString preScript;
35        QString packageName;
36        QString postScript;
37        bool isCritical = false;
38        bool isHidden = false;
39        Qt::CheckState selected = Qt::Unchecked;
40    };
41    explicit PackageTreeItem( const ItemData& data, PackageTreeItem* parent = nullptr );
42    explicit PackageTreeItem( const QString packageName, PackageTreeItem* parent = nullptr );
43    explicit PackageTreeItem( PackageTreeItem* parent );
44    explicit PackageTreeItem();  // The root of the tree; always selected, named <root>
45    ~PackageTreeItem() override;
46
47    void appendChild( PackageTreeItem* child );
48    PackageTreeItem* child( int row );
49    int childCount() const;
50    int columnCount() const;
51    QVariant data( int column ) const override;
52    int row() const;
53
54    PackageTreeItem* parentItem();
55    const PackageTreeItem* parentItem() const;
56
57    QString prettyName() const;
58    QString description() const;
59    QString preScript() const;
60    QString packageName() const;
61    QString postScript() const;
62
63    bool isHidden() const;
64    void setHidden( bool isHidden );
65    /**
66     * @brief Is this hidden item, considered "selected"?
67     *
68     * This asserts when called on a non-hidden item.
69     * A hidden item has its own selected state, but really
70     * falls under the selectedness of the parent item.
71     */
72    bool hiddenSelected() const;
73
74    bool isCritical() const;
75    void setCritical( bool isCritical );
76
77    Qt::CheckState isSelected() const;
78    void setSelected( Qt::CheckState isSelected );
79    void setChildrenSelected( Qt::CheckState isSelected );
80    int type() const override;
81private:
82    PackageTreeItem* m_parentItem;
83    QList<PackageTreeItem*> m_childItems;
84    ItemData m_data;
85    const int m_columns = 2; // Name, description
86};
87
88#endif // PACKAGETREEITEM_H
Note: See TracBrowser for help on using the repository browser.