summaryrefslogblamecommitdiffstats
path: root/src/sessiontreemodel.h
blob: b8fd7ab2e11f48652721cadf0c8f8ebbcc03d5d1 (plain) (tree)
1
2
3
4
5
6
7
8
9






                                    

                               




















                                                                           

                                                                    
 

                      


                           
                                   


                                      
#ifndef VMCHOOSER_SESSIONTREEMODEL_H
#define VMCHOOSER_SESSIONTREEMODEL_H

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

#include "sessionsiconholder.h"

class SessionTreeItem;
class Session;

class SessionTreeModel : public QAbstractItemModel {
    Q_OBJECT

  public:
    explicit SessionTreeModel(QObject *parent = 0);
    ~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, const QString& section);
    void addLabelItem(const QString& label, const QString& section);
    void removeItem(const QString& name, const QString& section);

    void updateView();


  private:
    SessionTreeItem* root_;
    SessionsIconHolder* iconHolder;
};

#endif // VMCHOOSER_SESSIONTREEMODEL_H