ソースを参照

API clean-up, documentation comments

Miklos Espak 11 年 前
コミット
c7a07df29b

+ 11 - 56
Libs/XNAT/Core/ctkXnatConnection.cpp

@@ -452,20 +452,20 @@ void ctkXnatConnection::fetch(const QSharedPointer<ctkXnatReconstructionResource
 //  }
 //}
 
-//void ctkXnatConnection::remove(ctkXnatProject* project)
-//{
-//  const QString& projectName = project->name();
+void ctkXnatConnection::remove(ctkXnatObject* object)
+{
+  const QString& uri = object->uri();
 
-//  Q_D(ctkXnatConnection);
+  Q_D(ctkXnatConnection);
 
-//  QString query = QString("/REST/projects/%1").arg(projectName);
-//  bool success = d->xnat->sync(d->xnat->del(query));
+  QString query = uri;
+  bool success = d->xnat->sync(d->xnat->del(query));
 
-//  if (!success)
-//  {
-//    throw ctkXnatException("Error occurred while removing the project.");
-//  }
-//}
+  if (!success)
+  {
+    throw ctkXnatException("Error occurred while removing the data.");
+  }
+}
 
 //void ctkXnatConnection::create(ctkXnatSubject* subject)
 //{
@@ -561,19 +561,6 @@ void ctkXnatConnection::fetch(const QSharedPointer<ctkXnatReconstructionResource
 //  // TODO
 //}
 
-//void ctkXnatConnection::removeReconstruction(ctkXnatReconstruction* /*reconstruction*/)
-//{
-////  const QString& reconstructionName = reconstruction->getName();
-////  ctkXnatObject* experiment = reconstruction->getParent()->getParent();
-////  const QString& experimentName = experiment->getName();
-////  ctkXnatObject* subject = experiment->getParent();
-////  const QString& subjectName = subject->getName();
-////  ctkXnatObject* project = subject->getParent();
-////  const QString& projectName = project->getName();
-
-//  // TODO
-//}
-
 //void ctkXnatConnection::downloadReconstructionResourceFiles(ctkXnatReconstructionResource* reconstructionResource, const QString& fileName)
 //{
 //  const QString& reconstructionResourceName = reconstructionResource->getName();
@@ -610,21 +597,6 @@ void ctkXnatConnection::fetch(const QSharedPointer<ctkXnatReconstructionResource
 //  // TODO
 //}
 
-//void ctkXnatConnection::removeReconstructionResource(ctkXnatReconstructionResource* /*reconstructionResource*/)
-//{
-////  const QString& resourceName = reconstructionResource->getName();
-////  ctkXnatObject* reconstruction = reconstructionResource->getParent();
-////  const QString& reconstructionName = reconstruction->getName();
-////  ctkXnatObject* experiment = reconstruction->getParent()->getParent();
-////  const QString& experimentName = experiment->getName();
-////  ctkXnatObject* subject = experiment->getParent();
-////  const QString& subjectName = subject->getName();
-////  ctkXnatObject* project = subject->getParent();
-////  const QString& projectName = project->getName();
-
-//  // TODO
-//}
-
 //void ctkXnatConnection::download(ctkXnatReconstructionResourceFile* reconstructionResourceFile, const QString& fileName)
 //{
 //  const QString& reconstructionResourceFileName = reconstructionResourceFile->getName();
@@ -648,23 +620,6 @@ void ctkXnatConnection::fetch(const QSharedPointer<ctkXnatReconstructionResource
 //  d->xnat->sync(queryId);
 //}
 
-//void ctkXnatConnection::remove(ctkXnatReconstructionResourceFile* /*reconstructionResourceFile*/)
-//{
-////  const QString& filename = reconstructionResourceFile->getName();
-////  ctkXnatObject* reconstructionResource = reconstructionResourceFile->getParent();
-////  const QString& resourceName = reconstructionResource->getName();
-////  ctkXnatObject* reconstruction = reconstructionResource->getParent();
-////  const QString& reconstructionName = reconstruction->getName();
-////  ctkXnatObject* experiment = reconstruction->getParent()->getParent();
-////  const QString& experimentName = experiment->getName();
-////  ctkXnatObject* subject = experiment->getParent();
-////  const QString& subjectName = subject->getName();
-////  ctkXnatObject* project = subject->getParent();
-////  const QString& projectName = project->getName();
-
-//  // TODO
-//}
-
 //void ctkXnatConnection::download(ctkXnatScan* scan, const QString& fileName)
 //{
 //  const QString& scanName = scan->getName();

+ 1 - 4
Libs/XNAT/Core/ctkXnatConnection.h

@@ -87,7 +87,7 @@ public:
   void create(ctkXnatProject* project);
   void create(ctkXnatSubject* subject);
 
-  void remove(ctkXnatProject* project);
+  void remove(ctkXnatObject* object);
 
   /* void downloadScanFiles(ctkXnatExperiment* experiment, const QString& zipFileName); */
   /* void downloadReconstructionFiles(ctkXnatExperiment* experiment, const QString& zipFileName); */
@@ -102,14 +102,11 @@ public:
 
   /* void downloadReconstruction(ctkXnatReconstruction* reconstruction, const QString& zipFilename); */
   /* void addReconstructionResource(ctkXnatReconstruction* reconstruction, const QString& resource); */
-  /* void removeReconstruction(ctkXnatReconstruction* reconstruction); */
 
   /* void downloadReconstructionResourceFiles(ctkXnatReconstructionResource* reconstructionResource, const QString& zipFilename); */
   /* void uploadReconstructionResourceFiles(ctkXnatReconstructionResource* reconstructionResource, const QString& zipFilename); */
-  /* void removeReconstructionResource(ctkXnatReconstructionResource* reconstructionResource); */
 
   /* void download(ctkXnatReconstructionResourceFile* reconstructionResourceFile, const QString& zipFileName); */
-  /* void remove(ctkXnatReconstructionResourceFile* reconstructionResourceFile); */
 
 public slots:
   void processResult(QUuid queryId, QList<QVariantMap> parameters);

+ 0 - 11
Libs/XNAT/Core/ctkXnatExperiment.cpp

@@ -81,14 +81,3 @@ void ctkXnatExperiment::fetchImpl()
   ctkXnatObject::Pointer self = d->selfPtr;
   this->connection()->fetch(self.staticCast<ctkXnatExperiment>());
 }
-
-void ctkXnatExperiment::remove()
-{
-  // ctkXnatObject::remove();
-  // getConnection()->remove(this);
-}
-
-bool ctkXnatExperiment::isFile() const
-{
-  return false;
-}

+ 0 - 8
Libs/XNAT/Core/ctkXnatExperiment.h

@@ -44,14 +44,6 @@ public:
 //  void setUri(const QString& uri);
   
   void reset();
-  void remove();
-  
-  bool isFile() const;
-
-  /* bool receivesFiles() const; */
-  /* bool holdsFiles() const; */
-  /* bool isDeletable() const; */
-  /* bool isModifiable() const; */
   
 private:
   

+ 4 - 40
Libs/XNAT/Core/ctkXnatObject.cpp

@@ -22,7 +22,9 @@
 #include "ctkXnatObject.h"
 #include "ctkXnatObjectPrivate.h"
 
+#include "ctkXnatConnection.h"
 #include "ctkXnatServer.h"
+
 #include <QDebug>
 #include <QVariant>
 
@@ -171,53 +173,15 @@ ctkXnatConnection* ctkXnatObject::connection() const
   return server ? xnatObject->connection() : 0;
 }
 
-
-bool ctkXnatObject::isFile() const
-{
-  return false;
-}
-
-bool ctkXnatObject::receivesFiles() const
-{
-  return false;
-}
-
-bool ctkXnatObject::holdsFiles() const
-{
-  return false;
-}
-
-bool ctkXnatObject::isModifiable() const
-{
-  return false;
-}
-
-bool ctkXnatObject::isDeletable() const
+void ctkXnatObject::remove()
 {
-  return false;
+  this->connection()->remove(this);
 }
 
-
 void ctkXnatObject::download(const QString& /*zipFilename*/)
 {
-  // do nothing
-  // if (!this->isFile())
-  //   return;  
 }
 
 void ctkXnatObject::upload(const QString& /*zipFilename*/)
 {
-  // do nothing
-  // if (!this->isFile())
-  //   return;  
-}
-
-void ctkXnatObject::add(const QString& /*name*/)
-{
-  // do nothing
-}
-
-void ctkXnatObject::remove()
-{
-  // do nothing
 }

+ 48 - 9
Libs/XNAT/Core/ctkXnatObject.h

@@ -33,6 +33,10 @@
 class ctkXnatConnection;
 class ctkXnatObjectPrivate;
 
+//----------------------------------------------------------------------------
+/// \ingroup XNATCore
+/// ctkXnatObject is the base class of the objects that represent the nodes in
+/// the XNAT data hierarchy.
 class CTK_XNAT_CORE_EXPORT ctkXnatObject
 {
 
@@ -41,59 +45,94 @@ public:
   typedef QSharedPointer<ctkXnatObject> Pointer;
   typedef QWeakPointer<ctkXnatObject> WeakPointer;
 
+  /// Destructs the ctkXnatObject.
   virtual ~ctkXnatObject();
 
+  /// Gets the ID of the object.
   QString id() const;
+
+  /// Gets the resource URI of the object that can be used to access it through
+  /// the REST API.
   QString uri() const;
+
+  /// Gets the name of the object.
   QString name() const;
+
+  /// Gets the description of the object.
   QString description() const;
 
+  /// Gets the value of the property with the given name.
   QString property(const QString& name) const;
+
+  /// Sets the value of the property with the given name.
   void setProperty(const QString& name, const QVariant& value);
 
+  /// Gets the list of the properties of the object.
   QList<QString> properties();
   
+  /// Gets the parent of the object in the data hierarchy. The returned pointer
+  /// is 0 for the ctkXnatServer objects and different for any other type of
+  /// XNAT objects.
   ctkXnatObject::Pointer parent() const;
+
+  /// Gets the children of the object.
   QList<ctkXnatObject::Pointer> children() const;
 
+  /// Adds an object to the children of the current one.
   void addChild(Pointer& child);
+
+  /// Removes the object from the children of the current object.
   void removeChild(Pointer& child);
 
+  /// Tells if the children and the properties of the objects have been fetched.
   bool isFetched() const;
 
+  /// Resets the object so that its properties and children needs to be fetched
+  /// again at the next request.
   virtual void reset();
+
+  /// Fetches the children and the properties of the object.
   void fetch();
 
-  virtual void download(const QString&);
-  virtual void upload(const QString&);
-  virtual void add(const QString&);
+  /// Removes the object from the XNAT server.
   virtual void remove();
 
-  virtual bool isFile() const;
-  virtual bool receivesFiles() const;
-  virtual bool holdsFiles() const;
-  virtual bool isDeletable() const;
-  virtual bool isModifiable() const;
+  virtual void download(const QString&);
+  virtual void upload(const QString&);
 
-  
 protected:
 
+  /// Constructs the ctkXnatObject.
   ctkXnatObject();
+
+  /// Constructs the ctkXnatObject with the given private part.
   ctkXnatObject(ctkXnatObjectPrivate& dd);
 
+  /// Gets the object that represents the connection to the XNAT server
+  /// that stores the current object.
   virtual ctkXnatConnection* connection() const;
 
+  /// Sets the ID of the object.
   void setId(const QString& id);
+
+  /// Sets the resource URI of the object that can be used to access it through
+  /// the REST API.
   void setUri(const QString& uri);
+
+  /// Sets the name of the object.
   void setName(const QString& name);
+
+  /// Sets the description of the object.
   void setDescription(const QString& description);
 
+  /// The private implementation part of the object.
   const QScopedPointer<ctkXnatObjectPrivate> d_ptr;
 
 private:
 
   friend class ctkXnatConnection;
 
+  /// The implementation of the fetch mechanism, called by the fetch() function.
   virtual void fetchImpl() = 0;
 
   Q_DECLARE_PRIVATE(ctkXnatObject)

+ 0 - 11
Libs/XNAT/Core/ctkXnatProject.cpp

@@ -122,14 +122,3 @@ void ctkXnatProject::fetchImpl()
   ctkXnatObject::Pointer self = d->selfPtr;
   this->connection()->fetch(self.staticCast<ctkXnatProject>());
 }
-
-void ctkXnatProject::remove()
-{
-  // ctkXnatObject::remove();
-  // getConnection()->remove(this);
-}
-
-bool ctkXnatProject::isFile() const
-{
-  return false;
-}

+ 0 - 8
Libs/XNAT/Core/ctkXnatProject.h

@@ -54,15 +54,7 @@ public:
 //  void setUri(const QString& uri);
 
   void reset();
-  void remove();
   
-  bool isFile() const;
-
-  /* bool receivesFiles() const; */
-  /* bool holdsFiles() const; */
-  /* bool isDeletable() const; */
-  /* bool isModifiable() const; */
-
 private:
 
   friend class qRestResult;

+ 0 - 11
Libs/XNAT/Core/ctkXnatReconstruction.cpp

@@ -81,14 +81,3 @@ void ctkXnatReconstruction::fetchImpl()
   ctkXnatObject::Pointer self = d->selfPtr;
   this->connection()->fetch(self.staticCast<ctkXnatReconstruction>());
 }
-
-void ctkXnatReconstruction::remove()
-{
-  // ctkXnatObject::remove();
-  // getConnection()->remove(this);
-}
-
-bool ctkXnatReconstruction::isFile() const
-{
-  return false;
-}

+ 0 - 8
Libs/XNAT/Core/ctkXnatReconstruction.h

@@ -44,14 +44,6 @@ public:
   void setUri(const QString& uri);
   
   void reset();
-  void remove();
-  
-  bool isFile() const;
-
-  /* bool receivesFiles() const; */
-  /* bool holdsFiles() const; */
-  /* bool isDeletable() const; */
-  /* bool isModifiable() const; */
   
 private:
   

+ 0 - 11
Libs/XNAT/Core/ctkXnatReconstructionFolder.cpp

@@ -83,14 +83,3 @@ void ctkXnatReconstructionFolder::fetchImpl()
   ctkXnatObject::Pointer self = d->selfPtr;
   this->connection()->fetch(self.staticCast<ctkXnatReconstructionFolder>());
 }
-
-void ctkXnatReconstructionFolder::remove()
-{
-  // ctkXnatObject::remove();
-  // getConnection()->remove(this);
-}
-
-bool ctkXnatReconstructionFolder::isFile() const
-{
-  return false;
-}

+ 0 - 8
Libs/XNAT/Core/ctkXnatReconstructionFolder.h

@@ -44,14 +44,6 @@ public:
 //  void setUri(const QString& uri);
   
   void reset();
-  void remove();
-  
-  bool isFile() const;
-
-  /* bool receivesFiles() const; */
-  /* bool holdsFiles() const; */
-  /* bool isDeletable() const; */
-  /* bool isModifiable() const; */
   
 private:
   

+ 0 - 11
Libs/XNAT/Core/ctkXnatReconstructionResource.cpp

@@ -87,14 +87,3 @@ void ctkXnatReconstructionResource::download(const QString& filename)
 {
   this->connection()->download(this, filename);
 }
-
-void ctkXnatReconstructionResource::remove()
-{
-  // ctkXnatObject::remove();
-  // getConnection()->remove(this);
-}
-
-bool ctkXnatReconstructionResource::isFile() const
-{
-  return false;
-}

+ 0 - 8
Libs/XNAT/Core/ctkXnatReconstructionResource.h

@@ -44,17 +44,9 @@ public:
 //  void setUri(const QString& uri);
   
   void reset();
-  void remove();
   
-  bool isFile() const;
-
   void download(const QString& filename);
 
-  /* bool receivesFiles() const; */
-  /* bool holdsFiles() const; */
-  /* bool isDeletable() const; */
-  /* bool isModifiable() const; */
-  
 private:
   
   friend class qRestResult;

+ 0 - 11
Libs/XNAT/Core/ctkXnatReconstructionResourceFile.cpp

@@ -89,14 +89,3 @@ void ctkXnatReconstructionResourceFile::fetchImpl()
 {
 
 }
-
-void ctkXnatReconstructionResourceFile::remove()
-{
-  // ctkXnatObject::remove();
-  // getConnection()->remove(this);
-}
-
-bool ctkXnatReconstructionResourceFile::isFile() const
-{
-  return true;
-}

+ 0 - 8
Libs/XNAT/Core/ctkXnatReconstructionResourceFile.h

@@ -47,14 +47,6 @@ public:
   void upload(const QString& filename);
 
   void reset();
-  void remove();
-  
-  bool isFile() const;
-
-  /* bool receivesFiles() const; */
-  /* bool holdsFiles() const; */
-  /* bool isDeletable() const; */
-  /* bool isModifiable() const; */
   
 private:
   

+ 0 - 11
Libs/XNAT/Core/ctkXnatScan.cpp

@@ -81,14 +81,3 @@ void ctkXnatScan::fetchImpl()
   ctkXnatObject::Pointer self = d->selfPtr;
   this->connection()->fetch(self.staticCast<ctkXnatScan>());
 }
-
-void ctkXnatScan::remove()
-{
-  // ctkXnatObject::remove();
-  // getConnection()->remove(this);
-}
-
-bool ctkXnatScan::isFile() const
-{
-  return false;
-}

+ 0 - 8
Libs/XNAT/Core/ctkXnatScan.h

@@ -44,14 +44,6 @@ public:
   void setUri(const QString& uri);
   
   void reset();
-  void remove();
-  
-  bool isFile() const;
-
-  /* bool receivesFiles() const; */
-  /* bool holdsFiles() const; */
-  /* bool isDeletable() const; */
-  /* bool isModifiable() const; */
   
 private:
   

+ 0 - 11
Libs/XNAT/Core/ctkXnatScanFolder.cpp

@@ -83,14 +83,3 @@ void ctkXnatScanFolder::fetchImpl()
   ctkXnatObject::Pointer self = d->selfPtr;
   this->connection()->fetch(self.staticCast<ctkXnatScanFolder>());
 }
-
-void ctkXnatScanFolder::remove()
-{
-  // ctkXnatObject::remove();
-  // getConnection()->remove(this);
-}
-
-bool ctkXnatScanFolder::isFile() const
-{
-  return false;
-}

+ 0 - 8
Libs/XNAT/Core/ctkXnatScanFolder.h

@@ -44,14 +44,6 @@ public:
 //  void setUri(const QString& uri);
   
   void reset();
-  void remove();
-  
-  bool isFile() const;
-
-  /* bool receivesFiles() const; */
-  /* bool holdsFiles() const; */
-  /* bool isDeletable() const; */
-  /* bool isModifiable() const; */
   
 private:
   

+ 0 - 11
Libs/XNAT/Core/ctkXnatScanResource.cpp

@@ -87,14 +87,3 @@ void ctkXnatScanResource::download(const QString& filename)
 {
   this->connection()->download(this, filename);
 }
-
-void ctkXnatScanResource::remove()
-{
-  // ctkXnatObject::remove();
-  // getConnection()->remove(this);
-}
-
-bool ctkXnatScanResource::isFile() const
-{
-  return false;
-}

+ 0 - 8
Libs/XNAT/Core/ctkXnatScanResource.h

@@ -44,17 +44,9 @@ public:
 //  void setUri(const QString& uri);
   
   void reset();
-  void remove();
   
-  bool isFile() const;
-
   void download(const QString& filename);
 
-  /* bool receivesFiles() const; */
-  /* bool holdsFiles() const; */
-  /* bool isDeletable() const; */
-  /* bool isModifiable() const; */
-  
 private:
   
   friend class qRestResult;

+ 0 - 12
Libs/XNAT/Core/ctkXnatScanResourceFile.cpp

@@ -87,16 +87,4 @@ void ctkXnatScanResourceFile::reset()
 
 void ctkXnatScanResourceFile::fetchImpl()
 {
-
-}
-
-void ctkXnatScanResourceFile::remove()
-{
-  // ctkXnatObject::remove();
-  // getConnection()->remove(this);
-}
-
-bool ctkXnatScanResourceFile::isFile() const
-{
-  return true;
 }

+ 0 - 8
Libs/XNAT/Core/ctkXnatScanResourceFile.h

@@ -47,14 +47,6 @@ public:
   void upload(const QString& filename);
 
   void reset();
-  void remove();
-  
-  bool isFile() const;
-
-  /* bool receivesFiles() const; */
-  /* bool holdsFiles() const; */
-  /* bool isDeletable() const; */
-  /* bool isModifiable() const; */
   
 private:
   

+ 0 - 12
Libs/XNAT/Core/ctkXnatSubject.cpp

@@ -114,15 +114,3 @@ ctkXnatSubject::Pointer ctkXnatSubject::Create()
   subject->d_func()->selfPtr = subject;
   return subject;
 }
-
-
-void ctkXnatSubject::remove()
-{
-  // ctkXnatObject::remove();
-  // getConnection()->remove(this);
-}
-
-bool ctkXnatSubject::isFile() const
-{
-  return false;
-}

+ 0 - 8
Libs/XNAT/Core/ctkXnatSubject.h

@@ -54,14 +54,6 @@ public:
 //  void setUri(const QString& uri);
 
   void reset();
-  void remove();
-  
-  bool isFile() const;
-
-  /* bool receivesFiles() const; */
-  /* bool holdsFiles() const; */
-  /* bool isDeletable() const; */
-  /* bool isModifiable() const; */
   
 private:
 

+ 0 - 26
Libs/XNAT/Widgets/ctkXnatTreeModel.cpp

@@ -264,29 +264,3 @@ void ctkXnatTreeModel::uploadFile(const QModelIndex& index, const QString& zipFi
 
   child->upload(zipFileName);
 }
-
-void ctkXnatTreeModel::addEntry(const QModelIndex& index, const QString& name)
-{
-  if (!index.isValid())
-  {
-    return;
-  }
-
-  ctkXnatObject::Pointer xnatObject = this->xnatObject(index);
-  ctkXnatObject::Pointer child = xnatObject->children()[index.row()];
-
-  child->add(name);
-}
-
-void ctkXnatTreeModel::removeEntry(const QModelIndex& index)
-{
-  if (!index.isValid())
-  {
-    return;
-  }
-
-  ctkXnatObject::Pointer xnatObject = this->xnatObject(index);
-  ctkXnatObject::Pointer child = xnatObject->children()[index.row()];
-
-  child->remove();
-}

+ 2 - 5
Libs/XNAT/Widgets/ctkXnatTreeModel.h

@@ -51,12 +51,9 @@ public:
 
   void addServer(ctkXnatServer::Pointer server);
 
-  void addEntry (const QModelIndex& index, const QString& name);
-  void removeEntry (const QModelIndex& index);
+  bool removeAllRows(const QModelIndex& parent);
 
-  bool removeAllRows (const QModelIndex& parent);
-
-  void uploadFile (const QModelIndex& index, const QString& zipFilename);
+  void uploadFile(const QModelIndex& index, const QString& zipFilename);
   void downloadFile (const QModelIndex& index, const QString& zipFilename);
   
 private: