File indexing completed on 2024-12-22 04:17:45

0001 /***************************************************************************
0002  *                                                                         *
0003  *   copyright : (C) 2007 The University of Toronto                        *
0004  *                   netterfield@astro.utoronto.ca                         *
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  ***************************************************************************/
0012 
0013 #ifndef SESSIONMODEL_H
0014 #define SESSIONMODEL_H
0015 
0016 
0017 #include <QAbstractItemModel>
0018 #include "dataobject.h"
0019 #include "object.h"
0020 #include "relation.h"
0021 
0022 namespace Kst {
0023 
0024 class ObjectStore;
0025 
0026 class SessionModel : public QAbstractItemModel
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031   explicit SessionModel(ObjectStore *store);
0032   ~SessionModel();
0033 
0034   int columnCount(const QModelIndex& parent = QModelIndex()) const;
0035   int rowCount(const QModelIndex& parent = QModelIndex()) const;
0036   QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
0037   QModelIndex index(int row, int col, const QModelIndex& parent = QModelIndex()) const;
0038   QModelIndex parent(const QModelIndex& index) const;
0039   QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
0040   void generateObjectList();
0041   ObjectList<Object> *objectList() {return &_objectList;}
0042 
0043 public Q_SLOTS:
0044   void triggerReset();
0045 
0046 private:
0047   QVariant dataObjectOutputData(DataObjectPtr parent, const QModelIndex& index) const;
0048   QVariant primitiveData(PrimitivePtr parent, const QModelIndex& index) const;
0049   QVariant dataSourceData(DataSourcePtr parent, const QModelIndex& index) const;
0050   QVariant dataObjectData(DataObjectPtr dataObject, const QModelIndex& index) const;
0051   QVariant relationData(RelationPtr relation, const QModelIndex& index) const;
0052 
0053   ObjectList<Object> _objectList;
0054 
0055   ObjectStore *_store;
0056 };
0057 
0058 }
0059 
0060 #endif
0061 
0062 // vim: ts=2 sw=2 et