summaryrefslogtreecommitdiffstats
path: root/src/sessiontreemodel.h
blob: b7943aa85db82a00a36ad971c4b6ee01f61b788d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef VMCHOOSER_SESSIONTREEMODEL_H
#define VMCHOOSER_SESSIONTREEMODEL_H

#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>

#include "session.h"

class SessionTreeItem;

class SessionTreeModel : public QAbstractItemModel {
    Q_OBJECT

  public:
    explicit SessionTreeModel(QObject *parent = nullptr, bool ignoreSections = false);
    ~SessionTreeModel();

    QVariant data(const QModelIndex &index, int role) const;
    Qt::ItemFlags flags(const QModelIndex &index) const;
    QVariant headerData(int section, Qt::Orientation orientation,
                        int role = Qt::DisplayRole) const;
    QModelIndex index(int row, int column,
                      const QModelIndex &parent = QModelIndex()) const;
    QModelIndex parent(const QModelIndex &index) const;
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;

    void addItems(const QList<Session*>& sessions);
    void addLabelItem(const QString& label);
    void removeItem(const QString& name);
    QList<Session*> lookForItem(const QString& label);
    QModelIndex getSection(const SectionType type);

    void updateView();


  private:
    SessionTreeItem* root_;
    bool ignoreSections_;
};

#endif // VMCHOOSER_SESSIONTREEMODEL_H