00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00036 beginRemoveRows(QModelIndex(),0,rowCount()-1);
00037 endRemoveRows();
00038 beginRemoveColumns(QModelIndex(),0,columnCount()-1);
00039 endRemoveColumns();
00040
00041 mpExperiment = thepExperiment;;
00042
00043 beginInsertRows(QModelIndex(),0,rowCount()-1);
00044 endInsertRows();
00045 beginInsertColumns(QModelIndex(),0,columnCount()-1);
00046 endInsertColumns();
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 ) 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
00072 return QModelIndex();
00073 }
00074
00075 int OmgExperimentItemModel::columnCount ( const QModelIndex & theParent ) const
00076 {
00077 return 1;
00078 }
00079 int OmgExperimentItemModel::rowCount ( const QModelIndex & theParent ) 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 ) 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
00134 return QString("%1").arg(theSection);
00135 }
00136 return QVariant();
00137 }
00138