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

omgexperimentitemmodel.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Tim Sutton   *
00003  *   tim@linfiniti.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 #include "omgexperimentitemmodel.h" 
00022 #include <QStringList>
00023 #include <QFileInfo>
00024 
00025 OmgExperimentItemModel::OmgExperimentItemModel() : QAbstractItemModel()
00026 {
00027 
00028 }
00029 OmgExperimentItemModel::~OmgExperimentItemModel()
00030 {
00031 
00032 }
00033 void OmgExperimentItemModel::setExperiment(OmgExperiment * const thepExperiment)
00034 {
00035   //first clear the table
00036   beginRemoveRows(QModelIndex(),0,rowCount()-1);
00037   endRemoveRows();
00038   beginRemoveColumns(QModelIndex(),0,columnCount()-1);
00039   endRemoveColumns();
00040   //update the localities
00041   mpExperiment = thepExperiment;;
00042   //now repopulate it
00043   beginInsertRows(QModelIndex(),0,rowCount()-1); //notify any views of data updates
00044   endInsertRows(); //notify any views of data updates
00045   beginInsertColumns(QModelIndex(),0,columnCount()-1); //notify any views of data updates
00046   endInsertColumns(); //notify any views of data updates
00047 }
00048 
00049 QModelIndex OmgExperimentItemModel::parent(const QModelIndex&) const
00050 {
00051   return QModelIndex();
00052 
00053 }
00054 QModelIndex OmgExperimentItemModel::index ( int theRow, 
00055      int theColumn, 
00056      const QModelIndex & theParent /*= QModelIndex() */) const 
00057 {
00058   if (!mpExperiment)
00059   {
00060     return QModelIndex();
00061   }
00062   if (!theParent.isValid())
00063   {
00064     return QModelIndex();
00065   }
00066   if (!mpExperiment->count())
00067   {
00068     return QModelIndex();
00069   }
00070 
00071   //return QVariant(mpExperiment->getModel(theRow)->name());
00072   return QModelIndex();
00073 }
00074 
00075 int OmgExperimentItemModel::columnCount ( const QModelIndex & theParent /*= QModelIndex()*/ ) const
00076 {
00077     return 1;
00078 }
00079 int OmgExperimentItemModel::rowCount ( const QModelIndex & theParent /*= QModelIndex()*/ ) const
00080 {
00081   if (!mpExperiment)
00082   {
00083     return 0;
00084   }
00085   if (!mpExperiment->count())
00086   {
00087     return 0;
00088   }
00089   return mpExperiment->count();
00090 }
00091 QVariant OmgExperimentItemModel::data ( const QModelIndex & theIndex, 
00092     int theRole /*= Qt::DisplayRole*/ ) const
00093 {
00094   if (!mpExperiment)
00095   {
00096     return QVariant();
00097   }
00098   if (!theIndex.isValid())
00099   {
00100     return QVariant();
00101   }
00102   if (theRole != Qt::DisplayRole)
00103   {
00104     return QVariant();
00105   }
00106   if (!mpExperiment->count())
00107   {
00108     return QVariant();
00109   }
00110   return QVariant(mpExperiment->getModel(theIndex.row())->name());
00111 }
00112 
00113 
00114 QVariant OmgExperimentItemModel::headerData(
00115     int theSection, 
00116     Qt::Orientation theOrientation,
00117     int theRole) const
00118 {
00119   if (!mpExperiment)
00120   {
00121     return QVariant();
00122   }
00123   if (theRole != Qt::DisplayRole)
00124   {
00125     return QVariant();
00126   }
00127   if (theOrientation == Qt::Horizontal)
00128   {
00129     return QString(tr("Experiment"));
00130   }
00131   else
00132   {
00133     // do nothing for row headers
00134     return QString("%1").arg(theSection);
00135   }
00136   return QVariant();
00137 }
00138 

Generated on Mon Apr 28 15:08:24 2008 for openModellerDesktop by  doxygen 1.4.1-20050210