26 QAbstractItemModel(pParent),
30 mEmitDataChanged(true),
54 if (pNode == NULL)
return QVariant();
61 switch (pNode->
getId())
95 if (pParent == NULL)
return createIndex(row, column,
mpRoot);
100 return createIndex(row, column, pNode);
102 return QModelIndex();
110 if (pNode == NULL || pNode ==
mpRoot)
112 return QModelIndex();
116 assert(pParent != NULL);
118 return createIndex(pParent->
getRow(), 0, pParent);
123 CNode * pNode = NULL;
140 if (!parent.isValid())
141 return (
mpRoot != NULL) ? 1 : 0;
153 if (pParent == NULL)
return false;
157 beginRemoveRows(parent, row, row + count - 1);
159 for (
int i = 0; i < count && pNode != NULL; i++)
161 CNode * pTmp = pNode;
176 for (; it != end; ++it)
178 if (it->getData().mId == id)
192 for (; it != end; ++it)
194 if (it->getData().mKey == key)
209 return pNode->
getId();
216 if (pNode == NULL)
return "";
225 if (pNode == NULL || pNode->
getParent() == NULL)
230 QModelIndex Parent =
index(static_cast< CNode * >(pNode->
getParent()));
239 if (pNode == NULL)
return;
245 QModelIndex Index =
index(pNode);
249 emit dataChanged(Index, Index);
255 const std::string & key,
256 const QString & displayRole,
257 const size_t & parentId)
267 beginInsertRows(
index(pParent), row, row);
268 new CNode(
id, key, displayRole, pParent);
348 bool isSpecies =
false;
402 bool changed =
false;
404 for (; pChildData != NULL && it != end; pChildData = pChildData->
getSibling(), ++it)
406 CNode * pChild =
static_cast< CNode *
>(pChildData);
408 pChild->
setKey((*it)->getKey());
418 DisplayRole =
FROM_UTF8((*it)->getObjectName());
429 if (pChildData != NULL)
431 int row =
static_cast< CNode *
>(pChildData)->getRow();
434 while (pChildData != NULL)
447 int last = first + (end - it) - 1;
449 beginInsertRows(
index(pParent), first, last);
451 for (; it != end; ++it)
461 DisplayRole =
FROM_UTF8((*it)->getObjectName());
472 QModelIndex Parent =
index(pParent);
474 emit dataChanged(Parent, Parent);
489 if (pObject == NULL &&
503 const CMetab * pMetab =
dynamic_cast< const CMetab *
>(pObject);
507 const CModel * pModel = pMetab->getModel();
624 return QModelIndex();
629 return index(0, 0, QModelIndex());
632 QModelIndex Parent =
index(static_cast< CNode * >(pNode->
getParent()));
639 if (!index.isValid())
return NULL;
641 QModelIndex Tmp =
index;
642 const QAbstractItemModel *pModel = Tmp.model();
644 while (pModel->inherits(
"QSortFilterProxyModel"))
646 Tmp =
static_cast< const QSortFilterProxyModel *
>(pModel)->mapToSource(index);
647 pModel = Tmp.model();
650 return static_cast< CNode *
>(Tmp.internalPointer());
657 std::stringstream in;
661 std::string delimiter(
"\x0a\x0d");
672 if (delimiter.find(c) != std::string::npos)
break;
677 if (str1 ==
"")
break;
681 int first = data.indexOf(
':');
682 int second = data.indexOf(
':', first + 1);
683 int parentId = data.mid(0, first).toInt();
684 int myId = data.mid(first + 1, second - first - 1).toInt();
685 QString str = data.mid(second + 1, data.length() - second - 1);
687 CNode * pParent = NULL;
717 new CNode(myId,
"", str, pParent);
740 const std::string & key,
741 const QString & displayRole,
747 mData.mDisplayRole = displayRole;
765 mData.mDisplayRole = displayRole;
770 return mData.mDisplayRole;
777 return mData.mDisplayRole;
780 return QString::number(mData.mId);
806 while (pChild != NULL && pChild !=
this)
812 return (pChild != NULL) ? count : -1;
817 os <<
"CQBrowserPaneDM::CNode:" << std::endl;
821 os <<
" mId: " << n.
mData.mId << std::endl;
822 os <<
" mKey: " << n.
mData.mKey << std::endl;
823 os <<
" mDisplayRole: " <<
TO_UTF8(n.
mData.mDisplayRole) << std::endl;
virtual QModelIndex parent(const QModelIndex &index) const
CCopasiVectorN< CFunction > & loadedFunctions()
const CModelParameterSet & getModelParameterSet() const
CNode * findNodeFromKey(const std::string &key) const
CCopasiNode< Data > * getSibling()
CCopasiVectorN< CEvent > & getEvents()
const CCopasiVector< CMetab > & getMetabolites() const
const std::string & getObjectName() const
const CCopasiVectorN< CModelValue > & getModelValues() const
CCopasiObject * get(const std::string &key)
void setCopasiDM(const CCopasiDataModel *pDataModel)
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
std::ostream & operator<<(std::ostream &os, const CQBrowserPaneDM::CNode &n)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
CNode * findNodeFromId(const size_t &id) const
const CCopasiDataModel * mpCopasiDM
void remove(const std::string &key)
static CNode * nodeFromIndex(const QModelIndex &index)
virtual const std::string & getKey() const
const CReportDefinitionVector * getReportDefinitionList() const
const std::string & getKey() const
virtual const std::string & getKey() const
void add(const size_t &id, const std::string &key, const QString &displayRole, const size_t &parentId=C_INVALID_INDEX)
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
virtual bool addChild(CCopasiNode< Data > *pChild, CCopasiNode< Data > *pAfter=NULL)
CCopasiVectorN< CCopasiTask > * getTaskList()
virtual ~CQBrowserPaneDM()
CQBrowserPaneDM(QObject *parent=0)
void rename(const std::string &key, const QString &displayRole)
const size_t & getId() const
void setKey(const std::string &key)
const CCopasiVectorN< CModelParameterSet > & getModelParameterSets() const
const std::string & getKey() const
static CFunctionDB * getFunctionList()
const DataModelGUI * mpGuiDM
const std::string & getKey() const
size_t getNumChildren() const
size_t getIdFromIndex(const QModelIndex &index) const
CCopasiVectorNS< CCompartment > & getCompartments()
static CKeyFactory * getKeyFactory()
const COutputDefinitionVector * getPlotDefinitionList() const
CCopasiNode< Data > * getParent()
const QString & getDisplayRole() const
void setDisplayRole(const QString &displayRole)
CCopasiVectorNS< CReaction > & getReactions()
void setGuiDM(const DataModelGUI *pDataModel)
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
std::string getKeyFromIndex(const QModelIndex &index) const
CCopasiNode< Data > * getChild()
QString getSortRole() const
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
static char DataModeltxt[]
bool slotNotify(ListViews::ObjectType objectType, ListViews::Action action, std::string key="")