File: TulipQVariantBuilder.cpp

package info (click to toggle)
tulip 3.7.0dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 39,428 kB
  • sloc: cpp: 231,403; php: 11,023; python: 1,128; sh: 671; yacc: 522; makefile: 315; xml: 63; lex: 55
file content (546 lines) | stat: -rwxr-xr-x 22,285 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
#include "TulipQVariantBuilder.h"
#include <tulip/TlpQtTools.h>
#include <tulip/GlGraphStaticData.h>
#include <tulip/EdgeExtremityGlyphManager.h>
#include "GlyphPreviewGenerator.h"
using namespace tlp;
using namespace std;

TulipQVariantBuilder::TulipQVariantBuilder() {
}

QVariant TulipQVariantBuilder::data(Graph* graph,int displayRole,ElementType elementType,unsigned int elementId,TulipPropertyType propertyType,PropertyInterface* property)const {
  switch(displayRole) {
  case Qt::DisplayRole: {
    switch(propertyType) {
    case NODEGLYPHPROPERTY_RTTI:
      return QVariant(QString::fromUtf8(GlyphManager::getInst().glyphName(((IntegerProperty*)property)->getNodeValue(node(elementId))).c_str()));
      break;

    case EDGESHAPEPROPERTY_RTTI:
      return QVariant(QString::fromUtf8(GlGraphStaticData::edgeShapeName(
                                          ((IntegerProperty*)property)->getEdgeValue(edge(elementId))).c_str()));
      break;

    case EDGEEXTREMITYGLYPHPROPERTY_RTTI:
      return QVariant(QString::fromUtf8(EdgeExtremityGlyphManager::getInst().glyphName(
                                          ((IntegerProperty*)property)->getEdgeValue(edge(elementId))).c_str()));
      break;

    default: {
      if(elementType == NODE)
        return QVariant(QString::fromUtf8(property->getNodeStringValue(node(elementId)).c_str()));
      else return QVariant(QString::fromUtf8(property->getEdgeStringValue(edge(elementId)).c_str()));
    }
    }

    break;
  }
  break;

  case Qt::EditRole: {
    switch(propertyType) {
    case NODEGLYPHPROPERTY_RTTI: {
      GlyphFactory::initFactory();
      int value = elementType==NODE?((IntegerProperty*)property)->getNodeValue(node(elementId)):((IntegerProperty*)property)->getEdgeValue(edge(elementId));
      ElementCollection collection;
      string glyphName;
      forEach(glyphName,GlyphFactory::factory->availablePlugins()) {
        collection.addElement(tlpStringToQString(glyphName));
        int elementIndex = collection.rowCount()-1;
        int glyphIndex = GlyphManager::getInst().glyphId(glyphName);
        //Associate the last added element to the shape id
        collection.setData(collection.index(elementIndex,0),QVariant(glyphIndex),Qt::UserRole);
        //Set the glyph preview.
        collection.setData(collection.index(elementIndex,0),QVariant(GlyphPreviewGenerator::getInst().getPreview(glyphIndex)),Qt::DecorationRole);
        //If the shape id is the same than the selected mark the last added element as selected
        collection.setElementSelection(elementIndex,glyphIndex == value);
      }
      return QVariant::fromValue<ElementCollection>(collection);
    }
    break;

    case EDGESHAPEPROPERTY_RTTI: {
      ElementCollection collection;
      int value = elementType==NODE?((IntegerProperty*)property)->getNodeValue(node(elementId)):((IntegerProperty*)property)->getEdgeValue(edge(elementId));

      for (int i = 0; i < GlGraphStaticData::edgeShapesCount; i++) {
        collection.addElement(tlpStringToQString(GlGraphStaticData::edgeShapeName(GlGraphStaticData::edgeShapeIds[i])));
        int elementIndex = collection.rowCount()-1;
        //Associate the last added element to the shape id
        collection.setData(collection.index(elementIndex,0),QVariant(GlGraphStaticData::edgeShapeIds[i]),Qt::UserRole);
        //If the shape id is the same than the selected mark the last added element as selected
        collection.setElementSelection(elementIndex,GlGraphStaticData::edgeShapeIds[i] == value);
      }

      return QVariant::fromValue<ElementCollection>(collection);
    }
    break;

    case EDGEEXTREMITYGLYPHPROPERTY_RTTI: {
      EdgeExtremityGlyphFactory::initFactory();
      int value = elementType==NODE?((IntegerProperty*)property)->getNodeValue(node(elementId)):((IntegerProperty*)property)->getEdgeValue(edge(elementId));
      ElementCollection collection;
      //Add the no edge extremity shape code to the list.
      collection.addElement(QString("NONE"));
      collection.setData(collection.index(0,0),QVariant(EdgeExtremityGlyphManager::NoEdgeExtremetiesId),Qt::UserRole);
      collection.setElementSelection(0,EdgeExtremityGlyphManager::NoEdgeExtremetiesId == value);
      string glyphName;
      forEach(glyphName,EdgeExtremityGlyphFactory::factory->availablePlugins()) {
        collection.addElement(tlpStringToQString(glyphName));
        int elementIndex = collection.rowCount()-1;
        int glyphIndex = EdgeExtremityGlyphManager::getInst().glyphId(glyphName);
        collection.setData(collection.index(elementIndex,0),QVariant(EdgeExtremityGlyphPreviewGenerator::getInst().getPreview(glyphIndex)),Qt::DecorationRole);
        //Associate the last added element to the shape id
        collection.setData(collection.index(elementIndex,0),QVariant(glyphIndex),Qt::UserRole);
        //If the shape id is the same than the selected mark the last added element as selected
        collection.setElementSelection(elementIndex,glyphIndex == value);
      }
      return QVariant::fromValue<ElementCollection>(collection);
    }
    break;

    case INTEGER_PROPERTY_RTTI:
      return createQVariantFromTulipProperty<IntegerProperty,int,int >(elementType,elementId,(IntegerProperty*)property);
      break;

    case BOOLEAN_PROPERTY_RTTI:
      return createQVariantFromTulipProperty<BooleanProperty,bool,bool>(elementType,elementId,(BooleanProperty*)property);
      break;

    case DOUBLEPROPERTY_RTTI:
      return createQVariantFromTulipProperty<DoubleProperty,double,double>(elementType,elementId,(DoubleProperty*)property);
      break;

    case LAYOUTPROPERTY_RTTI:
      return createQVariantFromTulipProperty<LayoutProperty,Coord,vector<Coord> >(elementType,elementId,(LayoutProperty*)property);
      break;

    case COLORPROPERTY_RTTI:
      return createQVariantFromTulipProperty<ColorProperty,Color,Color>(elementType,elementId,(ColorProperty*)property);
      break;

    case SIZEPROPERTY_RTTI:
      return createQVariantFromTulipProperty<SizeProperty,Size,Size>(elementType,elementId,(SizeProperty*)property);
      break;

    case BOOLEANVECTORPROPERTY_RTTI:
      return createQVariantFromTulipProperty<BooleanVectorProperty,vector<bool>,vector<bool> >(elementType,elementId,(BooleanVectorProperty*)property);
      break;

    case COLORVECTORPROPERTY_RTTI:
      return createQVariantFromTulipProperty<ColorVectorProperty,vector<Color>,vector<Color> >(elementType,elementId,(ColorVectorProperty*)property);
      break;

    case COORDVECTORPROPERTY_RTTI:
      return createQVariantFromTulipProperty<CoordVectorProperty,vector<Coord>,vector<Coord> >(elementType,elementId,(CoordVectorProperty*)property);
      break;

    case DOUBLEVECTORPROPERTY_RTTI:
      return createQVariantFromTulipProperty<DoubleVectorProperty,vector<double>,vector<double> >(elementType,elementId,(DoubleVectorProperty*)property);
      break;

    case INTEGERVECTORPROPERTY_RTTI:
      return createQVariantFromTulipProperty<IntegerVectorProperty,vector<int>,vector<int> >(elementType,elementId,(IntegerVectorProperty*)property);
      break;

    case SIZEVECTORPROPERTY_RTTI:
      return createQVariantFromTulipProperty<SizeVectorProperty,vector<Size>,vector<Size> >(elementType,elementId,(SizeVectorProperty*)property);
      break;

    case STRINGVECTORPROPERTY_RTTI:
      return createQVariantFromTulipProperty<StringVectorProperty,vector<string>,vector<string> >(elementType,elementId,(StringVectorProperty*)property);
      break;

    case FONTFILEPROPERTY_RTTI: {
      string value = (elementType==NODE?((StringProperty*)property)->getNodeValue(node(elementId)):((StringProperty*)property)->getEdgeValue(edge(elementId)));
      //Create an object containing the original file and the filter options.
      FilteredUrl url(tlpStringToQString(value),QString("Font (*.ttf)"));
      return QVariant::fromValue<FilteredUrl>(url);
    }
    break;

    case TEXTUREPROPERTY_RTTI: {
      string value = (elementType==NODE?((StringProperty*)property)->getNodeValue(node(elementId)):((StringProperty*)property)->getEdgeValue(edge(elementId)));
      FilteredUrl url(tlpStringToQString(value),QString("Images (*.png *.jpeg *.jpg *.bmp)"));
      return QVariant::fromValue<FilteredUrl>(url);
    }
    break;

    default:

      if(elementType == NODE) {
        return QVariant(QString::fromUtf8(property->getNodeStringValue(node(elementId)).c_str()));
      }
      else {
        return QVariant(QString::fromUtf8(property->getEdgeStringValue(edge(elementId)).c_str()));
      }

      break;
    }
  }
  break;

  case Qt::DecorationRole: {
    switch(propertyType) {
    case COLORPROPERTY_RTTI: {
      const Color& color = (elementType == NODE ? ((ColorProperty*)property)->getNodeValue(node(elementId)):((ColorProperty*)property)->getEdgeValue(edge(elementId)));
      return QVariant(QColor(colorToQColor(color)));
    }
    break;

    case NODEGLYPHPROPERTY_RTTI:
      return QVariant(GlyphPreviewGenerator::getInst().getPreview(((IntegerProperty*)property)->getNodeValue(node(elementId))));
      break;

    case EDGEEXTREMITYGLYPHPROPERTY_RTTI:
      return QVariant(EdgeExtremityGlyphPreviewGenerator::getInst().getPreview(((IntegerProperty*)property)->getEdgeValue(edge(elementId))));
      break;

    default:
      return QVariant();
      break;
    }
  }
  break;

  //If we can compute
  case NormalizedValueRole: {
    switch(propertyType) {
    case DOUBLEPROPERTY_RTTI: {
      DoubleProperty* doubleProp = dynamic_cast<DoubleProperty*>(property);
      double min = 0;
      double max = 0;
      double value = 0;

      //Compute the normalization of the elements.
      if(elementType == NODE) {
        min = doubleProp->getNodeMin(graph);
        max = doubleProp->getNodeMax(graph);
        value = doubleProp->getNodeValue(node(elementId));
      }
      else {
        min = doubleProp->getEdgeMin(graph);
        max = doubleProp->getEdgeMax(graph);
        value = doubleProp->getEdgeValue(edge(elementId));
      }

      if(min != max) {
        return QVariant(( value - min ) / (max - min));
      }
      else {
        return QVariant();
      }

    }
    break;

    default:
      return QVariant();
    }
  }
  break;

  default:
    return QVariant();
  }
}

TulipPropertyType TulipQVariantBuilder::getPropertyType(ElementType elementType,PropertyInterface* property) const {
  if (property->getName().compare("viewShape") == 0) {
    return elementType==NODE?NODEGLYPHPROPERTY_RTTI:EDGESHAPEPROPERTY_RTTI;
  }
  else if (property->getName().compare("viewLabelPosition")==0) {
    return LABELPOSITIONPROPERTY_RTTI;
  }
  else if (property->getName().compare("viewTexture")==0) {
    return TEXTUREPROPERTY_RTTI;
  }
  else if (property->getName().compare("viewFont")==0) {
    return FONTFILEPROPERTY_RTTI;
  }
  else if(property->getName().compare("viewTgtAnchorShape")==0) {
    return elementType==EDGE?EDGEEXTREMITYGLYPHPROPERTY_RTTI:INVALID_PROPERTY_RTTI;
  }
  else if(property->getName().compare("viewSrcAnchorShape")==0  ) {
    return elementType==EDGE?EDGEEXTREMITYGLYPHPROPERTY_RTTI:INVALID_PROPERTY_RTTI;
  }
  else if(property->getName().compare("viewSrcAnchorSize")==0 ) {
    return elementType==EDGE?SIZEPROPERTY_RTTI:INVALID_PROPERTY_RTTI;
  }
  else if(property->getName().compare("viewTgtAnchorSize")==0 ) {
    return elementType==EDGE?SIZEPROPERTY_RTTI:INVALID_PROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(BooleanProperty)) {
    return BOOLEAN_PROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(ColorProperty)) {
    return COLORPROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(DoubleProperty)) {
    return DOUBLEPROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(IntegerProperty)) {
    return INTEGER_PROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(SizeProperty)) {
    return SIZEPROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(LayoutProperty)) {
    return LAYOUTPROPERTY_RTTI;
  }
  else if(typeid(*property) == typeid(StringProperty)) {
    return STRINGPROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(StringVectorProperty)) {
    return STRINGVECTORPROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(ColorVectorProperty)) {
    return COLORVECTORPROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(SizeVectorProperty)) {
    return SIZEVECTORPROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(BooleanVectorProperty)) {
    return BOOLEANVECTORPROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(DoubleVectorProperty)) {
    return DOUBLEVECTORPROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(IntegerVectorProperty)) {
    return INTEGERVECTORPROPERTY_RTTI;
  }
  else if (typeid(*property) == typeid(CoordVectorProperty)) {
    return COORDVECTORPROPERTY_RTTI;
  }
  else {
    return INVALID_PROPERTY_RTTI;
  }
}

bool TulipQVariantBuilder::setData(const QVariant& value, ElementType elementType, unsigned int elementId, TulipPropertyType propertyType, PropertyInterface* property) const {
  if(!value.isValid()) {
    return false;
  }

  switch(propertyType) {
  case BOOLEAN_PROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<BooleanProperty,bool,bool>(value,elementType,elementId,(BooleanProperty*)property);
    break;

  case DOUBLEPROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<DoubleProperty,double,double>(value,elementType,elementId,(DoubleProperty*)property);
    break;

  case NODEGLYPHPROPERTY_RTTI:
  case EDGESHAPEPROPERTY_RTTI:
  case EDGEEXTREMITYGLYPHPROPERTY_RTTI: {
    ElementCollection collection = value.value<ElementCollection>();
    //Get the selected element
    QList<int> selectedElements = collection.selectedElement();

    if(!selectedElements.empty()) {
      //Extract the code associated with the selected element.
      return setValueToTulipPropertyFromQVariant<IntegerProperty,int,int>(collection.data(collection.index(selectedElements.front(),0),Qt::UserRole),elementType,elementId,(IntegerProperty*)property);
    }
    else {
      return false;
    }
  }
  break;

  case INTEGER_PROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<IntegerProperty,int,int>(value,elementType,elementId,(IntegerProperty*)property);
    break;

  case LAYOUTPROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<LayoutProperty,Coord,vector<Coord> >(value,elementType,elementId,(LayoutProperty*)property);
    break;

  case COLORPROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<ColorProperty,Color,Color >(value,elementType,elementId,(ColorProperty*)property);
    break;

  case SIZEPROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<SizeProperty,Size,Size >(value,elementType,elementId,(SizeProperty*)property);
    break;

  case BOOLEANVECTORPROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<BooleanVectorProperty,vector<bool>,vector<bool> >(value,elementType,elementId,(BooleanVectorProperty*)property);
    break;

  case COLORVECTORPROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<ColorVectorProperty,vector<Color>,vector<Color> >(value,elementType,elementId,(ColorVectorProperty*)property);
    break;

  case COORDVECTORPROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<CoordVectorProperty,vector<Coord>,vector<Coord> >(value,elementType,elementId,(CoordVectorProperty*)property);
    break;

  case DOUBLEVECTORPROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<DoubleVectorProperty,vector<double>,vector<double> >(value,elementType,elementId,(DoubleVectorProperty*)property);
    break;

  case INTEGERVECTORPROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<IntegerVectorProperty,vector<int>,vector<int> >(value,elementType,elementId,(IntegerVectorProperty*)property);
    break;

  case SIZEVECTORPROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<SizeVectorProperty,vector<Size>,vector<Size> >(value,elementType,elementId,(SizeVectorProperty*)property);
    break;

  case STRINGVECTORPROPERTY_RTTI:
    return setValueToTulipPropertyFromQVariant<StringVectorProperty,vector<string>,vector<string> >(value,elementType,elementId,(StringVectorProperty*)property);
    break;

  case FONTFILEPROPERTY_RTTI:
  case TEXTUREPROPERTY_RTTI: {
    FilteredUrl url = value.value<FilteredUrl>();
    (elementType == NODE ?((StringProperty*)property)->setNodeValue(node(elementId),QStringToTlpString(url.path())):((StringProperty*)property)->setEdgeValue(edge(elementId),QStringToTlpString(url.path())));
    return true;
  }
  break;

  default:

    if(elementType == NODE) {
      const string& oldValue = property->getNodeStringValue(node(elementId));
      string newValue = value.toString().toStdString();

      if(oldValue.compare(newValue)!=0) {
        return property->setNodeStringValue(node(elementId),newValue);
      }
    }
    else {
      const string& oldValue = property->getEdgeStringValue(edge(elementId));
      string newValue = value.toString().toStdString();

      if(oldValue.compare(newValue)!=0) {
        return property->setEdgeStringValue(edge(elementId),newValue);
      }
    }

    return false;
    break;
  }
}

bool TulipQVariantBuilder::setAllElementData(const QVariant& value,tlp::ElementType elementType,TulipPropertyType propertyType,tlp::PropertyInterface* property) {
  if(!value.isValid()) {
    return false;
  }

  switch(propertyType) {
  case BOOLEAN_PROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<BooleanProperty,bool,bool>(value,elementType,(BooleanProperty*)property);
    break;

  case DOUBLEPROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<DoubleProperty,double,double>(value,elementType,(DoubleProperty*)property);
    break;

  case NODEGLYPHPROPERTY_RTTI:
  case EDGESHAPEPROPERTY_RTTI:
  case EDGEEXTREMITYGLYPHPROPERTY_RTTI: {
    ElementCollection collection = value.value<ElementCollection>();
    //Get the selected element
    QList<int> selectedElements = collection.selectedElement();

    if(!selectedElements.empty()) {
      //Extract the code associated with the selected element.
      return setAllValuesToTulipPropertyFromQVariant<IntegerProperty,int,int>(collection.data(collection.index(selectedElements.front(),0),Qt::UserRole),elementType,(IntegerProperty*)property);
    }
    else {
      return false;
    }
  }
  break;

  case INTEGER_PROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<IntegerProperty,int,int>(value,elementType,(IntegerProperty*)property);
    break;

  case LAYOUTPROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<LayoutProperty,Coord,vector<Coord> >(value,elementType,(LayoutProperty*)property);
    break;

  case COLORPROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<ColorProperty,Color,Color >(value,elementType,(ColorProperty*)property);
    break;

  case SIZEPROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<SizeProperty,Size,Size >(value,elementType,(SizeProperty*)property);
    break;

  case BOOLEANVECTORPROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<BooleanVectorProperty,vector<bool>,vector<bool> >(value,elementType,(BooleanVectorProperty*)property);
    break;

  case COLORVECTORPROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<ColorVectorProperty,vector<Color>,vector<Color> >(value,elementType,(ColorVectorProperty*)property);
    break;

  case COORDVECTORPROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<CoordVectorProperty,vector<Coord>,vector<Coord> >(value,elementType,(CoordVectorProperty*)property);
    break;

  case DOUBLEVECTORPROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<DoubleVectorProperty,vector<double>,vector<double> >(value,elementType,(DoubleVectorProperty*)property);
    break;

  case INTEGERVECTORPROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<IntegerVectorProperty,vector<int>,vector<int> >(value,elementType,(IntegerVectorProperty*)property);
    break;

  case SIZEVECTORPROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<SizeVectorProperty,vector<Size>,vector<Size> >(value,elementType,(SizeVectorProperty*)property);
    break;

  case STRINGVECTORPROPERTY_RTTI:
    return setAllValuesToTulipPropertyFromQVariant<StringVectorProperty,vector<string>,vector<string> >(value,elementType,(StringVectorProperty*)property);
    break;

  case FONTFILEPROPERTY_RTTI:
  case TEXTUREPROPERTY_RTTI: {
    FilteredUrl url = value.value<FilteredUrl>();
    (elementType == NODE ?((StringProperty*)property)->setAllNodeValue(QStringToTlpString(url.path())):((StringProperty*)property)->setAllEdgeValue(QStringToTlpString(url.path())));
    return true;
  }
  break;

  default:

    if(elementType == NODE) {
      const string& oldValue = property->getNodeDefaultStringValue();
      string newValue = value.toString().toStdString();

      if(oldValue.compare(newValue)!=0) {
        return property->setAllNodeStringValue(newValue);
      }
    }
    else {
      const string& oldValue = property->getEdgeDefaultStringValue();
      string newValue = value.toString().toStdString();

      if(oldValue.compare(newValue)!=0) {
        return property->setAllEdgeStringValue(newValue);
      }
    }

    return false;
    break;
  }
}

Qt::ItemFlags TulipQVariantBuilder::flags(Qt::ItemFlags defaultFlags,ElementType,unsigned int ,TulipPropertyType propertyType,PropertyInterface*)const {
  switch(propertyType) {
    //If we try to display an edge extremity property for nodes desactivate the row.
  case INVALID_PROPERTY_RTTI:
    return Qt::NoItemFlags;
    break;

  default:
    return defaultFlags | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
    break;
  }
}