COPASI API  4.16.103
Public Slots | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
CQRDFTreeView Class Reference

#include <CQRDFTreeView.h>

Inheritance diagram for CQRDFTreeView:
Inheritance graph
[legend]
Collaboration diagram for CQRDFTreeView:
Collaboration graph
[legend]

Public Slots

virtual void clear ()
 
CQRDFTreeViewItemfind (const CRDFNode *pNode)
 
void insert (const CRDFNode *pNode, CQRDFTreeViewItem *pItem)
 

Public Member Functions

 CQRDFTreeView (QWidget *parent=0, const char *name=0)
 
virtual bool update (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key)
 
virtual ~CQRDFTreeView ()
 
- Public Member Functions inherited from CopasiWidget
 CopasiWidget (QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
 
bool enter (const std::string &key)
 
CCopasiDataModelgetDataModel ()
 
bool getIgnoreUpdates ()
 
virtual bool leave ()
 
virtual void setFramework (int framework)
 
void setIgnoreUpdates (bool v)
 

Protected Member Functions

virtual bool enterProtected ()
 

Private Member Functions

void load ()
 

Private Attributes

std::map< const CRDFNode
*, CQRDFTreeViewItem * > 
mNode2Item
 
CRDFGraphmpGraph
 

Additional Inherited Members

- Protected Slots inherited from CopasiWidget
virtual bool protectedNotify (ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
 
- Protected Attributes inherited from CopasiWidget
int mFramework
 
bool mIgnoreUpdates
 
std::string mKey
 
CCopasiDataModelmpDataModel
 
ListViewsmpListView
 
CCopasiObjectmpObject
 

Detailed Description

Definition at line 32 of file CQRDFTreeView.h.

Constructor & Destructor Documentation

CQRDFTreeView::CQRDFTreeView ( QWidget *  parent = 0,
const char *  name = 0 
)

Definition at line 36 of file CQRDFTreeView.cpp.

36  :
37  CopasiWidget(parent, name),
38  mNode2Item(),
39  mpGraph(NULL)
40 {
41  setupUi(this);
42 }
std::map< const CRDFNode *, CQRDFTreeViewItem * > mNode2Item
Definition: CQRDFTreeView.h:72
CopasiWidget(QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
CRDFGraph * mpGraph
Definition: CQRDFTreeView.h:77
CQRDFTreeView::~CQRDFTreeView ( )
virtual

Definition at line 44 of file CQRDFTreeView.cpp.

References clear().

45 {
46  clear();
47 }
virtual void clear()

Member Function Documentation

void CQRDFTreeView::clear ( )
virtualslot

Clear the listeview

Definition at line 165 of file CQRDFTreeView.cpp.

References mNode2Item, mpGraph, and pdelete.

Referenced by enterProtected(), and ~CQRDFTreeView().

166 {
167  mNode2Item.clear();
168  pdelete(mpGraph);
169  mpTreeWidget->clear();
170 }
#define pdelete(p)
Definition: copasi.h:215
std::map< const CRDFNode *, CQRDFTreeViewItem * > mNode2Item
Definition: CQRDFTreeView.h:72
CRDFGraph * mpGraph
Definition: CQRDFTreeView.h:77
bool CQRDFTreeView::enterProtected ( )
protectedvirtual

Reimplemented from CopasiWidget.

Definition at line 56 of file CQRDFTreeView.cpp.

References CRDFSubject::BLANK_NODE, clear(), CCopasiMessage::clearDeque(), COL_SUBJECT, CRDFGraph::createAboutNode(), find(), FROM_UTF8, CKeyFactory::get(), CCopasiMessage::getAllMessageText(), CRDFSubject::getBlankNodeID(), CCopasiRootContainer::getKeyFactory(), CAnnotation::getMiriamAnnotation(), CRDFSubject::getResource(), CRDFGraph::getTriplets(), CRDFSubject::getType(), CRDFParser::graphFromXml(), insert(), CopasiWidget::mKey, mpGraph, CRDFSubject::RESOURCE, CQRDFTreeViewItem::setTriplet(), CCopasiMessage::size(), and CQMessageBox::warning().

57 {
58  clear();
59 
61 
62  if (pObject != NULL)
63  {
64  CModelEntity * pEntity = NULL;
65  CEvent * pEvent = NULL;
66  CReaction * pReaction = NULL;
67  CFunction * pFunction = NULL;
68  const std::string * pMiriamAnnotation = NULL;
69 
70  if ((pEntity = dynamic_cast< CModelEntity * >(pObject)) != NULL)
71  pMiriamAnnotation = &pEntity->getMiriamAnnotation();
72  else if ((pEvent = dynamic_cast< CEvent * >(pObject)) != NULL)
73  pMiriamAnnotation = &pEvent->getMiriamAnnotation();
74  else if ((pReaction = dynamic_cast< CReaction * >(pObject)) != NULL)
75  pMiriamAnnotation = &pReaction->getMiriamAnnotation();
76  else if ((pFunction = dynamic_cast< CFunction * >(pObject)) != NULL)
77  pMiriamAnnotation = &pFunction->getMiriamAnnotation();
78 
79  if (pMiriamAnnotation && *pMiriamAnnotation != "")
80  mpGraph = CRDFParser::graphFromXml(*pMiriamAnnotation);
81  }
82 
84 
85  if (CCopasiMessage::size() != 0)
86  {
88  CQMessageBox::warning(this, QString("RDF Warning"), Message,
89  QMessageBox::Ok, QMessageBox::Ok);
90  }
91 
92  if (mpGraph == NULL)
93  mpGraph = new CRDFGraph;
94 
95  // We make sure that we always have an about node.
97 
98  // We iterate of all triplets
99  std::set< CRDFTriplet >::const_iterator it = mpGraph->getTriplets().begin();
100  std::set< CRDFTriplet >::const_iterator end = mpGraph->getTriplets().end();
101 
102  for (; it != end; ++it)
103  {
104  CQRDFTreeViewItem * pSubjectItem = find(it->pSubject);
105 
106  if (pSubjectItem == NULL)
107  {
108  pSubjectItem = new CQRDFTreeViewItem(mpTreeWidget, NULL);
109  insert(it->pSubject, pSubjectItem);
110  // Display the subject information
111 
112  const CRDFSubject & Subject = it->pSubject->getSubject();
113 
114  switch (Subject.getType())
115  {
117  pSubjectItem->setText(COL_SUBJECT, FROM_UTF8(Subject.getResource()));
118  break;
119 
121  pSubjectItem->setText(COL_SUBJECT, FROM_UTF8(Subject.getBlankNodeID()));
122  break;
123  }
124  }
125 
126  CQRDFTreeViewItem * pObjectItem = NULL;
127 
128  if (it->Predicate.getURI() == "http://www.w3.org/1999/02/22-rdf-syntax-ns#subject")
129  {
130  pObjectItem = new CQRDFTreeViewItem(pSubjectItem, NULL);
131  insert(it->pObject, pObjectItem);
132  }
133  else
134  pObjectItem = find(it->pObject);
135 
136  if (pObjectItem == NULL)
137  {
138  pObjectItem = new CQRDFTreeViewItem(pSubjectItem, NULL);
139  insert(it->pObject, pObjectItem);
140  }
141  else
142  {
143  QTreeWidgetItem * pParent = pObjectItem->parent();
144 
145  if (pParent == NULL)
146  {
147  mpTreeWidget->invisibleRootItem()->removeChild(pObjectItem);
148  pSubjectItem->addChild(pObjectItem);
149  }
150  else
151  {
152  pParent->removeChild(pObjectItem);
153  pSubjectItem->addChild(pObjectItem);
154  }
155  }
156 
157  pObjectItem->setTriplet(*it);
158  }
159 
160  mpTreeWidget->setFocus();
161 
162  return true;
163 }
Definition: CEvent.h:152
CRDFNode * createAboutNode(const std::string &key)
Definition: CRDFGraph.cpp:416
const std::string & getResource() const
Definition: CRDFSubject.cpp:82
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
CCopasiObject * get(const std::string &key)
const std::string & getBlankNodeID() const
Definition: CRDFSubject.cpp:91
static std::string getAllMessageText(const bool &chronological=true)
virtual void clear()
const std::string & getMiriamAnnotation() const
static void clearDeque()
void insert(const CRDFNode *pNode, CQRDFTreeViewItem *pItem)
static StandardButton warning(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
const std::set< CRDFTriplet > & getTriplets() const
Definition: CRDFGraph.cpp:434
static size_t size()
#define COL_SUBJECT
CQRDFTreeViewItem * find(const CRDFNode *pNode)
static CKeyFactory * getKeyFactory()
void setTriplet(const CRDFTriplet &triplet)
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
CRDFGraph * mpGraph
Definition: CQRDFTreeView.h:77
static CRDFGraph * graphFromXml(const std::string &xml)
Definition: CRDFParser.cpp:30
std::string mKey
Definition: copasiWidget.h:63
const eSubjectType & getType() const
Definition: CRDFSubject.cpp:73
CQRDFTreeViewItem * CQRDFTreeView::find ( const CRDFNode pNode)
slot

Returns the list view item for node if it exists otherwise NULL.

Parameters
constCRDFNode * pSubject
Returns
CQRDFTreeViewItem * listViewItem

Definition at line 172 of file CQRDFTreeView.cpp.

References mNode2Item.

Referenced by enterProtected().

173 {
174  std::map< const CRDFNode *, CQRDFTreeViewItem * >::iterator it = mNode2Item.find(pNode);
175 
176  if (it != mNode2Item.end())
177  return it->second;
178 
179  return NULL;
180 }
std::map< const CRDFNode *, CQRDFTreeViewItem * > mNode2Item
Definition: CQRDFTreeView.h:72
void CQRDFTreeView::insert ( const CRDFNode pNode,
CQRDFTreeViewItem pItem 
)
slot

Insert a map from a CRDFNode to a CRDFListView

Parameters
constCRDFNode * pSubject
CQRDFTreeViewItem* pItem

Definition at line 182 of file CQRDFTreeView.cpp.

References mNode2Item.

Referenced by enterProtected().

183 {
184  mNode2Item[pNode] = pItem;
185 }
std::map< const CRDFNode *, CQRDFTreeViewItem * > mNode2Item
Definition: CQRDFTreeView.h:72
void CQRDFTreeView::load ( )
private
bool CQRDFTreeView::update ( ListViews::ObjectType  objectType,
ListViews::Action  action,
const std::string &  key 
)
virtual

Reimplemented from CopasiWidget.

Definition at line 49 of file CQRDFTreeView.cpp.

52 {
53  return true;
54 }

Member Data Documentation

std::map< const CRDFNode *, CQRDFTreeViewItem * > CQRDFTreeView::mNode2Item
private

A map to look up items associated with a node.

Definition at line 72 of file CQRDFTreeView.h.

Referenced by clear(), find(), and insert().

CRDFGraph* CQRDFTreeView::mpGraph
private

The RDF Graph

Definition at line 77 of file CQRDFTreeView.h.

Referenced by clear(), and enterProtected().


The documentation for this class was generated from the following files: