瀏覽代碼

Rename ctkDICOMModel::displayLevel

It should be obsolete because of ctkFlatProxyModel which does the same and even more (flatten hierarchies)
Julien Finet 13 年之前
父節點
當前提交
8adfa4a116
共有 3 個文件被更改,包括 28 次插入11 次删除
  1. 17 9
      Libs/DICOM/Core/ctkDICOMModel.cpp
  2. 10 1
      Libs/DICOM/Core/ctkDICOMModel.h
  3. 1 1
      Libs/DICOM/Widgets/ctkDICOMAppWidget.cpp

+ 17 - 9
Libs/DICOM/Core/ctkDICOMModel.cpp

@@ -51,8 +51,6 @@ public:
   virtual ~ctkDICOMModelPrivate();
   void init();
 
-
- 
   void fetch(const QModelIndex& indexValue, int limit);
   Node* createNode(int row, const QModelIndex& parentValue)const;
   Node* nodeFromIndex(const QModelIndex& indexValue)const;
@@ -71,7 +69,8 @@ public:
   QString      Sort;
   QMap<QString, QVariant> SearchParameters;
 
-  ctkDICOMModel::IndexType displayLevel;
+  ctkDICOMModel::IndexType StartLevel;
+  ctkDICOMModel::IndexType EndLevel;
 };
 
 //------------------------------------------------------------------------------
@@ -103,7 +102,8 @@ struct Node
 ctkDICOMModelPrivate::ctkDICOMModelPrivate(ctkDICOMModel& o):q_ptr(&o)
 {
   this->RootNode     = 0;
-  this->displayLevel = ctkDICOMModel::ImageType;
+  this->StartLevel = ctkDICOMModel::RootType;
+  this->EndLevel = ctkDICOMModel::ImageType;
 }
 
 //------------------------------------------------------------------------------
@@ -544,8 +544,8 @@ bool ctkDICOMModel::hasChildren ( const QModelIndex & parentIndex ) const
     return false;
     }
 
-  // We want to show only until displayLevel
-  if(node->Type >= d->displayLevel)return false;
+  // We want to show only until EndLevel
+  if(node->Type >= d->EndLevel)return false;
 
   // It's not because we don't have row that we don't have children, maybe it
   // just means that the children haven't been fetched yet
@@ -853,10 +853,18 @@ void ctkDICOMModel::setDatabase(const QSqlDatabase &db,const QMap<QString, QVari
   d->fetch(QModelIndex(), 256);
 }
 
-void ctkDICOMModel::setDisplayLevel(ctkDICOMModel::IndexType level){
-    Q_D(ctkDICOMModel);
+//------------------------------------------------------------------------------
+ctkDICOMModel::IndexType  ctkDICOMModel::endLevel()const
+{
+  Q_D(const ctkDICOMModel);
+  return d->EndLevel;
+}
 
-    d->displayLevel = level;
+//------------------------------------------------------------------------------
+void ctkDICOMModel::setEndLevel(ctkDICOMModel::IndexType level)
+{
+  Q_D(ctkDICOMModel);
+  d->EndLevel = level;
 }
 
 //------------------------------------------------------------------------------

+ 10 - 1
Libs/DICOM/Core/ctkDICOMModel.h

@@ -23,6 +23,7 @@
 
 // Qt includes 
 #include <QAbstractItemModel>
+#include <QMetaType>
 #include <QSqlDatabase>
 #include <QStringList>
 
@@ -35,6 +36,9 @@ class CTK_DICOM_CORE_EXPORT ctkDICOMModel
 {
   Q_OBJECT
   typedef QAbstractItemModel Superclass;
+  Q_ENUMS(IndexType)
+  /// startLevel contains the hierarchy depth the model contains
+  Q_PROPERTY(IndexType endLevel READ endLevel WRITE setEndLevel);
 public:
 
   enum {
@@ -55,7 +59,10 @@ public:
 
   void setDatabase(const QSqlDatabase& dataBase);
   void setDatabase(const QSqlDatabase& dataBase, const QMap<QString,QVariant>& parameters);
-  void setDisplayLevel(ctkDICOMModel::IndexType level);
+
+  /// Set it before populating the model
+  ctkDICOMModel::IndexType endLevel()const;
+  void setEndLevel(ctkDICOMModel::IndexType level);
 
   virtual bool canFetchMore ( const QModelIndex & parent ) const;
   virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
@@ -86,4 +93,6 @@ private:
   Q_DISABLE_COPY(ctkDICOMModel);
 };
 
+Q_DECLARE_METATYPE(ctkDICOMModel::IndexType)
+
 #endif

+ 1 - 1
Libs/DICOM/Widgets/ctkDICOMAppWidget.cpp

@@ -218,7 +218,7 @@ void ctkDICOMAppWidget::setDatabaseDirectory(const QString& directory)
     }
   
   d->DICOMModel.setDatabase(d->DICOMDatabase->database());
-  d->DICOMModel.setDisplayLevel(ctkDICOMModel::SeriesType);
+  d->DICOMModel.setEndLevel(ctkDICOMModel::SeriesType);
   d->TreeView->resizeColumnToContents(0);
 
   //pass DICOM database instance to Import widget