gapMea  1.0-rc1-1.5.3.2
GapMea est un outil visuel écrit en c++ à l'aide de la bibliothèque QT qui sert de base entre autre à l'environnement graphique de KDE.Il permet de dessiner des schémas recueillant et structurant les informations nécessaires à un domaine de gestion. Le schéma obtenu est enregistré dans un fichier texte au format xml.
 All Classes Functions Variables
xmeareader.cpp
1 #include "xmeareader.h"
2 #include "lien.h"
3 #include <QDebug>
4 
6 {
7  mum=maman;
8 }
9 
10 bool XMeaReader::readFile(QIODevice *device)
11 {
12  qDebug()<<"bool XMeaReader::readFile(QIODevice *device)";
13  setDevice(device);
14 
15  if (readNextStartElement()) {
16  if (name() == "xmea" && attributes().value("version") == "1.0")
17  {
18  //efacer tout
19  mum->effaceTout();
20  readMea();
21  }
22  else
23  raiseError(QObject::tr("The file is not an XMEA version 1.0 file."));
24  }
25 
26  return !error();
27 
28 }
29 
31 {
32  qDebug()<<"void XMeaReader::readMea()";
33  Q_ASSERT(isStartElement() && name() == "xmea");
34 
35  readNextStartElement();
36 
37  if (name() == "entities")
38  readEntites();
39  readNextStartElement();
40  if (name() == "links")
41  readLiens();
42 }
44 {
45  qDebug()<<"void XMeaReader::readField(Entite* lEntite)";
46  Q_ASSERT(isStartElement() && name() == "property");
47  QString nom=attributes().value("fieldname").toString();
48  QString type=attributes().value("fieldtype").toString();
49  QString taille=attributes().value("fieldsize").toString();
50  QString role=attributes().value("fieldrole").toString();
51  //creation du champ
52  //Property* laPropriete=new Property(mum,true,mum->getScene(),nom,type,role,taille,lEntite);
53  //ajout dans les propriétés de l'entité
54  mum->tableAjouterChamp(lEntite,nom,type,role,taille);
55  skipCurrentElement();
56 }
57 
59 {
60  qDebug()<<"void XMeaReader::readFields(Entite* lEntite)";
61  Q_ASSERT(isStartElement() && name() == "fields");
62  //les champs
63  while (readNextStartElement())
64  {
65  if (name() == "property")
66  readField(lEntite);
67  else
68  return;
69  }//fin du while
70 }
71 
73 {
74  qDebug()<<"void XMeaReader::readEntite()";
75  Q_ASSERT(isStartElement() && name() == "entity");
76  QString nom=attributes().value("name").toString();
77  QString left=attributes().value("left").toString();
78  QString top=attributes().value("top").toString();
79  QString type=attributes().value("type").toString();
80  QStringList listeDesChamps;
81  bool isAssoc=type=="association";
82  //creation de l'entite
83  if(!isAssoc)
84  {
85  Entite * lEntite=new Entite(mum,nom,left.toFloat(),top.toFloat(),0,mum->getScene(),listeDesChamps,isAssoc);
86  //peut-être ajout au vecteur de la maman
87  mum->ajouteTable(lEntite);
88  lEntite->setPos(left.toFloat(),top.toFloat());
89  mum->getScene()->addItem(lEntite);
90  lEntite->redraw();
91 
92  //les champs
93  while (readNextStartElement())
94  {
95  if (name() == "fields")
96  readFields(lEntite);
97  else
98  return;
99  }//fin du while
100 
101  }
102  else
103  {
104  Association* lEntite=new Association(mum,nom,left.toFloat(),top.toFloat(),0,mum->getScene(),listeDesChamps,isAssoc);
105  //peut-être ajout au vecteur de la maman
106  mum->ajouteTable(lEntite);
107  lEntite->setPos(left.toFloat(),top.toFloat());
108  mum->getScene()->addItem(lEntite);
109  lEntite->redraw();
110 
111  //les champs
112  while (readNextStartElement())
113  {
114  if (name() == "fields")
115  readFields(lEntite);
116  else
117  return;
118  }//fin du while
119 
120  }
121 
122  //on passe au suivant
123  //skipCurrentElement();
124 }
125 
127 {
128  qDebug()<<"void XMeaReader::readLien()";
129  Q_ASSERT(isStartElement() && name() == "link");
130  QString nomt1=attributes().value("t1").toString();
131  QString nomt2=attributes().value("t2").toString();
132  QString nomType=attributes().value("type").toString();
133  QString nomCard1=attributes().value("card1").toString();
134  QString nomCard2=attributes().value("card2").toString();
135  QString role=attributes().value("role").toString();
136  //creation du lien on va chercher les deux entités
137  Entite* t1=mum->getEntiteByName(nomt1);
138  Entite* t2=mum->getEntiteByName(nomt2);
139  Lien * nouveauLien= new Lien(t2,t1,0,nomType,"",role);
140  mum->getScene()->addItem(nouveauLien);
141  //on passe au suivant
142  skipCurrentElement();
143 }
144 
146 {
147  qDebug()<<"void XMeaReader::readEntites()";
148  Q_ASSERT(isStartElement() && name() == "entities");
149 
150  while (readNextStartElement())
151  {
152  if (name() == "entity")
153  readEntite();
154  else
155  //skipCurrentElement();
156  return;
157  }//fin du while
158 }
159 
161 {
162  qDebug()<<"void XMeaReader::readLiens()";
163  Q_ASSERT(isStartElement() && name() == "links");
164 
165  while (readNextStartElement())
166  {
167  if (name() == "link")
168  readLien();
169  else
170  return;
171  }//fin du while
172 }
173 
175 {
176 
177 }
178 
QCustomGraphicsScene * getScene()
getScene
Definition: mainwindow.h:71
void readMea()
readMea read MEA main content
Definition: xmeareader.cpp:30
void tableAjouterChamp(Entite *lEntite, QString nomDuChamp="property name", QString typeDuChamp="Son type", QString roleDuChamp="Son rôle dans l'objet", QString tailleDuChamp="")
tableAjouterChamp
Definition: mainwindow.cpp:134
The Lien class a link is betwwen to objects it contains a line a role text cardinality ...
Definition: lien.h:17
XMeaReader(MainWindow *)
XMeaReader Constructor.
Definition: xmeareader.cpp:5
void readField(Entite *lEntite)
readField
Definition: xmeareader.cpp:43
The Association class Association inherit Entite Association is a relation between at least two entit...
Definition: association.h:9
void readEntite()
readEntite read one Entity
Definition: xmeareader.cpp:72
void readLien()
readLien read one link
Definition: xmeareader.cpp:126
bool readFile(QIODevice *device)
readFile
Definition: xmeareader.cpp:10
~XMeaReader()
destructor
Definition: xmeareader.cpp:174
void effaceTout()
effaceTout remove all from vectors and scene
Definition: mainwindow.cpp:61
void redraw()
redraw
Definition: entite.cpp:52
void readEntites()
readEntites read Entites Section
Definition: xmeareader.cpp:145
Entite * getEntiteByName(QString nom)
getEntiteByName
Definition: mainwindow.cpp:608
void ajouteTable(Entite *t)
ajouteTable
Definition: mainwindow.cpp:124
void readLiens()
readLiens read Links Section
Definition: xmeareader.cpp:160
The Entite class Entity is an object we have to deal with.
Definition: entite.h:20
The MainWindow class main code of application.
Definition: mainwindow.h:20
void readFields(Entite *lEntite)
readFields
Definition: xmeareader.cpp:58