Developer documentation | Axl-2.5.1

axlInspectorObjectController.cpp
Go to the documentation of this file.
1 /* axlInspectorObjectController.h ---
2  *
3  * Author: Meriadeg Perrinel
4  * Copyright (C) 2008 - Meriadeg Perrinel, Inria.
5  * Created: Tue Nov 9 16:58:59 2010 (+0100)
6  * Version: $Id$
7  * Last-Updated: Tue Nov 9 17:09:38 2010 (+0100)
8  * By: Meriadeg Perrinel
9  * Update #: 19
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
21 
22 #include <dtkCoreSupport/dtkAbstractData.h>
23 #include <dtkCoreSupport/dtkGlobal.h>
25 
27 
28 class axlInspectorObjectControllerPrivate
29 {
30 public:
31  QHash<dtkAbstractData *, axlInspectorObjectManagerTreeItem *> items;
32 };
33 
34 // /////////////////////////////////////////////////////////////////
35 // axlInspectorObjectController
36 // /////////////////////////////////////////////////////////////////
37 
38 axlInspectorObjectController::axlInspectorObjectController(void) : QObject(), d(new axlInspectorObjectControllerPrivate)
39 {
40 
41 }
42 
44 {
45  delete d;
46 
47  d = NULL;
48 }
49 
51 {
52  return d->items.key(item);
53 }
54 
56 {
57  return d->items.value(data);
58 }
59 
60 dtkAbstractData *axlInspectorObjectController::data(QString dataname)
61 {
62  // Be carefull, we considered here that two different data cannot have the same name.
63 
65  {
66  if ((item->text(0)) == dataname)
67  return data(item);
68  }
69 
70  return NULL;
71 }
72 
73 
74 QList<axlInspectorObjectManagerTreeItem *> axlInspectorObjectController::items()
75 {
76  return d->items.values();
77 }
78 
79 QList<dtkAbstractData *> axlInspectorObjectController::datas()
80 {
81  return d->items.keys();
82 }
83 
85 {
86  if(!data) {
87  qDebug() << DTK_PRETTY_FUNCTION << " no data !";
88  return false;
89  }
90 
91  if(!item) {
92  qDebug() << DTK_PRETTY_FUNCTION << " no item !";
93  return false;
94  }
95 
96  d->items.insert(data, item);
97 
98  emit inserted();
99 
100  return true;
101 }
102 
104 {
105  return d->items.size();
106 }
107 
108 void axlInspectorObjectController::remove(dtkAbstractData *data)
109 {
110  d->items.remove(data);
111 }
112 
113 void axlInspectorObjectController::onDataRemoved(QList<dtkAbstractData *> dataToRemoved)
114 {
115  foreach(dtkAbstractData *data, dataToRemoved)
116  d->items.remove(data);
117 }
118 
119 
121 {
122  return "axlInspectorObjectController";
123 }
bool insert(dtkAbstractData *data, axlInspectorObjectManagerTreeItem *item)
QList< dtkAbstractData * > datas(void)
virtual QString description(void) const
dtkAbstractData * data(axlInspectorObjectManagerTreeItem *item)
void onDataRemoved(QList< dtkAbstractData * > dataToRemoved)
axlInspectorObjectManagerTreeItem * item(dtkAbstractData *data)
QList< axlInspectorObjectManagerTreeItem * > items(void)