Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

RootModel.h

00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Graeme Foster                                   *
00003  *   email    foster.graeme@gmail.com                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef __ROOT_MODEL_H
00022 #define __ROOT_MODEL_H
00023 
00024 #include <QAbstractItemModel>
00025 #include <QModelIndex>
00026 #include <QVariant>
00027 
00028 #include "dbListManager.h"
00029 #include "RootItem.h"
00030 #include "DataClass.h"
00031 
00032 //class dbListManager;
00033 
00034 class RootModel : public QAbstractItemModel
00035 {
00036         Q_OBJECT
00037 
00038         public: // Methods
00039                 // Constructor destructor
00040                 RootModel(QObject *parent = 0);
00041                 ~RootModel(){};
00042 
00043                 // Inherited from QAbstractItemModel
00044                 virtual QVariant data(const QModelIndex &index, int role) const;
00045                 virtual bool setData (const QModelIndex & index
00046                                                  ,const QVariant & value
00047                                                  ,int role = Qt::EditRole);
00048                 virtual Qt::ItemFlags flags(const QModelIndex &index) const;
00049                 virtual QVariant headerData(int section, Qt::Orientation orientation,
00050                                                                   int role = Qt::DisplayRole) const=0;
00051                 virtual QModelIndex index(int row, int column,
00052                                                                 const QModelIndex &parent = QModelIndex()) const;
00053                 virtual QModelIndex parent(const QModelIndex &index) const;
00054                 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
00055                 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
00056 
00057                 // Get Set Methods
00058                 virtual inline RootItem * getRootItem(){return rootItem;}
00059                 inline RootItem * getRootItem(const QModelIndex &index)const;
00060                 // Methods to add or delete objects to the treeview
00061                 virtual bool insertItem (RootItem * inst, QModelIndex & index, int posn);
00062                 void sort(CompareRI compare, DataClass * dcObj);
00063                 virtual bool deleteItem (DataClass * dcObj);
00064                 
00065                 
00066         protected: // Properties
00067                 RootItem *rootItem;
00068                 
00069         protected: // Methods
00070                 friend class dbListManager;
00071                 void clearData(RootItem * item);
00072 };
00073 
00074 inline RootItem * RootModel::getRootItem(const QModelIndex &index)const
00075 {
00076         return static_cast<RootItem*>(index.internalPointer());
00077 }
00078 
00079 #endif

Generated on Thu Apr 6 16:27:17 2006 for time-table by  doxygen 1.4.4