libavogadro/src/primitiveitemmodel.h

00001 /**********************************************************************
00002   PrimitiveItemModel - Model for representing primitives.
00003 
00004   Copyright (C) 2007 Donald Ephraim Curtis <[email protected]>
00005 
00006   This file is part of the Avogadro molecular editor project.
00007   For more information, see <http://avogadro.openmolecules.net/>
00008 
00009   Avogadro is free software; you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free Software Foundation; either version 2 of the License, or
00012   (at your option) any later version.
00013 
00014   Avogadro is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017   GNU General Public License for more details.
00018 
00019   You should have received a copy of the GNU General Public License
00020   along with this program; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00022   02110-1301, USA.
00023  **********************************************************************/
00024 
00025 #ifndef PRIMITIVEITEMMODEL_H
00026 #define PRIMITIVEITEMMODEL_H
00027 
00028 #include <avogadro/global.h>
00029 #include <avogadro/engine.h>
00030 
00031 #include <QAbstractItemModel>
00032 
00033 class QTreeView;
00034 namespace Avogadro {
00035 
00036   class PrimitiveItemModelPrivate;
00037   class A_EXPORT PrimitiveItemModel : public QAbstractItemModel
00038   {
00039     Q_OBJECT
00040 
00041     public:
00042       enum Role {
00043         PrimitiveRole = Qt::UserRole + 1,
00044         PrimitiveTypeRole
00045       };
00046 
00047     public:
00048       explicit PrimitiveItemModel( Engine *engine, QObject *parent = 0 );
00049       explicit PrimitiveItemModel( Molecule *molecule, QObject *parent = 0 );
00050       ~PrimitiveItemModel();
00051 
00052       QModelIndex parent( const QModelIndex & index ) const;
00053       int rowCount( const QModelIndex & parent = QModelIndex() ) const;
00054       int columnCount( const QModelIndex & parent = QModelIndex() ) const;
00055       QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
00056       Qt::ItemFlags flags ( const QModelIndex & index ) const;
00057 
00058       QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
00059 
00060     private Q_SLOTS:
00061       void engineChanged();
00062       void addPrimitive(Primitive *primitive);
00063       void updatePrimitive(Primitive *primitive);
00064       void removePrimitive(Primitive *primitive);
00065 
00066     private:
00067       PrimitiveItemModelPrivate * const d;
00068 
00069       int primitiveIndex(Primitive *primitive);
00070 
00071   };
00072 
00073 }  // end namespace Avogadro
00074 
00075 #endif // __PRIMITIVEITEMMODEL_H

Generated on Tue Jun 2 02:00:54 2009 for Avogadro by  doxygen 1.5.4