ctkXnatObject.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*=============================================================================
  2. Plugin: org.commontk.xnat
  3. Copyright (c) University College London,
  4. Centre for Medical Image Computing
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #include "ctkXnatObject.h"
  16. #include <QDebug>
  17. class ctkXnatObjectPrivate
  18. {
  19. public:
  20. ctkXnatObject* parent;
  21. int parentIndex;
  22. QList<QString> childrenNames;
  23. QList<ctkXnatObject*> children;
  24. };
  25. ctkXnatObject::ctkXnatObject(ctkXnatObject* parent)
  26. : QObject(parent)
  27. , d_ptr(new ctkXnatObjectPrivate())
  28. {
  29. Q_D(ctkXnatObject);
  30. d->parent = parent;
  31. d->parentIndex = -1;
  32. }
  33. ctkXnatObject::~ctkXnatObject()
  34. {
  35. }
  36. void ctkXnatObject::setParent(ctkXnatObject* parent)
  37. {
  38. Q_D(ctkXnatObject);
  39. QObject::setParent(parent);
  40. d->parent = parent;
  41. }
  42. int ctkXnatObject::parentIndex()
  43. {
  44. Q_D(ctkXnatObject);
  45. return d->parentIndex;
  46. }
  47. void ctkXnatObject::setParentIndex(int parentIndex)
  48. {
  49. Q_D(ctkXnatObject);
  50. d->parentIndex = parentIndex;
  51. }
  52. void ctkXnatObject::fetch(ctkXnatConnection* /*connection*/)
  53. {
  54. // connection->fetch(this);
  55. }
  56. QString ctkXnatObject::getName() const
  57. {
  58. Q_D(const ctkXnatObject);
  59. return d->parent ? d->parent->childName(d->parentIndex) : 0;
  60. }
  61. ctkXnatObject* ctkXnatObject::getParent() const
  62. {
  63. Q_D(const ctkXnatObject);
  64. return d->parent;
  65. }
  66. const QList<ctkXnatObject*>& ctkXnatObject::getChildren() const
  67. {
  68. Q_D(const ctkXnatObject);
  69. return d->children;
  70. }
  71. QString ctkXnatObject::childName(int childIndex) const
  72. {
  73. Q_D(const ctkXnatObject);
  74. return d->childrenNames[childIndex];
  75. }
  76. void ctkXnatObject::addChild(const QString& name, ctkXnatObject* child)
  77. {
  78. Q_D(ctkXnatObject);
  79. int index = d->childrenNames.indexOf(name);
  80. if (index == -1)
  81. {
  82. index = d->childrenNames.size();
  83. d->childrenNames.push_back(name);
  84. d->children.push_back(child);
  85. }
  86. else
  87. {
  88. d->children[index] = child;
  89. }
  90. child->setParent(this);
  91. child->setParentIndex(index);
  92. }
  93. void ctkXnatObject::removeChild(int childIndex)
  94. {
  95. Q_D(ctkXnatObject);
  96. if (d->children[childIndex])
  97. {
  98. delete d->children[childIndex];
  99. d->children[childIndex] = NULL;
  100. }
  101. }
  102. void ctkXnatObject::download(ctkXnatConnection* /*connection*/, const QString& /*zipFilename*/)
  103. {
  104. // do nothing
  105. }
  106. void ctkXnatObject::upload(ctkXnatConnection* /*connection*/, const QString& /*zipFilename*/)
  107. {
  108. // do nothing
  109. }
  110. void ctkXnatObject::add(ctkXnatConnection* /*connection*/, const QString& /*name*/)
  111. {
  112. // do nothing
  113. }
  114. void ctkXnatObject::remove(ctkXnatConnection* /*connection*/)
  115. {
  116. // do nothing
  117. }
  118. QString ctkXnatObject::getKind() const
  119. {
  120. return NULL;
  121. }
  122. QString ctkXnatObject::getModifiableChildKind() const
  123. {
  124. return NULL;
  125. }
  126. QString ctkXnatObject::getModifiableParentName() const
  127. {
  128. return NULL;
  129. }
  130. bool ctkXnatObject::isFile() const
  131. {
  132. return false;
  133. }
  134. bool ctkXnatObject::holdsFiles() const
  135. {
  136. return false;
  137. }
  138. bool ctkXnatObject::receivesFiles() const
  139. {
  140. return false;
  141. }
  142. bool ctkXnatObject::isModifiable(int /*childIndex*/) const
  143. {
  144. return false;
  145. }
  146. bool ctkXnatObject::isModifiable() const
  147. {
  148. return false;
  149. }
  150. bool ctkXnatObject::isDeletable() const
  151. {
  152. return false;
  153. }