ctkDICOMModel.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Library:   CTK
00004  
00005   Copyright (c) 2010  Kitware Inc.
00006 
00007   Licensed under the Apache License, Version 2.0 (the "License");
00008   you may not use this file except in compliance with the License.
00009   You may obtain a copy of the License at
00010 
00011       http://www.commontk.org/LICENSE
00012 
00013   Unless required by applicable law or agreed to in writing, software
00014   distributed under the License is distributed on an "AS IS" BASIS,
00015   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016   See the License for the specific language governing permissions and
00017   limitations under the License.
00018  
00019 =========================================================================*/
00020 
00021 #ifndef __ctkDICOMModel_h
00022 #define __ctkDICOMModel_h
00023 
00024 // Qt includes 
00025 #include <QAbstractItemModel>
00026 #include <QSqlDatabase>
00027 
00028 // CTK includes
00029 #include <ctkPimpl.h>
00030 
00031 #include "CTKDICOMCoreExport.h"
00032 
00033 class ctkDICOMModelPrivate;
00034 class CTK_DICOM_CORE_EXPORT ctkDICOMModel : public QAbstractItemModel
00035 {
00036   Q_OBJECT
00037 public:
00038   explicit ctkDICOMModel(QObject* parent = 0);
00039   virtual ~ctkDICOMModel();
00040 
00041   void setDatabase(const QSqlDatabase& dataBase);
00042 
00043   virtual bool canFetchMore ( const QModelIndex & parent ) const;
00044   virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
00045   virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
00046   virtual void fetchMore ( const QModelIndex & parent );
00047   virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
00048   // can return true even if rowCount returns 0, you should use canFetchMore/fetchMore to populate
00049   // the children.
00050   virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const;
00051   virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole)const;
00052   virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
00053   virtual QModelIndex parent ( const QModelIndex & index ) const;
00054   virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
00055   virtual bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole );
00056   // Sorting resets the model because fetched/unfetched items could disappear/appear respectively.
00057   virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
00058 
00059 private:
00060   CTK_DECLARE_PRIVATE(ctkDICOMModel);
00061 };
00062 
00063 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines