summaryrefslogtreecommitdiffstats
path: root/src/sessiontreeitem.h
blob: 7c1a58f9854a236a14af363691fca036fb36744a (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
#ifndef SESSIONTREEITEM_H
#define SESSIONTREEITEM_H

#include <QList>
#include <QVariant>

#include "session.h"
#include "globals.h"
#include <QString>

class SessionTreeItem {
  public:
    SessionTreeItem(const Session* session, SessionTreeItem *parent = nullptr);
    SessionTreeItem(const SectionType type, SessionTreeItem *parent = nullptr);
    SessionTreeItem(const QString& text, SessionTreeItem *parent = nullptr);
    ~SessionTreeItem();

    void appendChild(SessionTreeItem *child);
    void removeChild(SessionTreeItem *child);

    SessionTreeItem *child(int row);
    int childCount() const;
    int columnCount() const { return 1; }
    int row() const;
    SessionTreeItem *parent();
    const Session* session() const { return session_; }
    const QString text() const { return text_; }
    SectionType sectionType() const { return sectionType_; }

  private:
    QList<SessionTreeItem*> children_;
    SessionTreeItem *parent_;
    const Session *session_;
    const SectionType sectionType_;
    const QString text_;

    static QString typeToName(const SectionType type);
};

#endif // SESSIONTREEITEM_H