22 #include <QStringList> 37 #include "ctkLogger.h" 38 #include "boost/shared_ptr.hpp" 39 #include "ctkDICOMDatabase.h" 43 static ctkLogger logger (
"org.commontk.dicom.DICOMModel" );
64 void remove(
const QModelIndex& index);
81 if (!indexValue.isValid())
120 qDebug() <<
"Remove DICOM node " << node->
getValue(0).toString();
148 : Superclass(parentObject)
172 return d->RootNode->getHeaders().size();
190 else if (( role==Qt::DisplayRole )||( role==Qt::EditRole ))
193 return node->
getValue(dataIndex.column());
203 d->fetchChildren(parentValue);
211 if (parentIndex.column() > 0)
223 if (role != Qt::DisplayRole)
226 if (orientation == Qt::Horizontal)
228 QStringList headers = d->RootNode->getHeaders();
230 if (section < 0 || section >= headers.size())
233 return headers[section];
244 if (parentIndex.column() > 0)
245 return QModelIndex();
252 qDebug() <<
"DICOMModel::index() failed to get node for index";
253 return QModelIndex();
256 return this->createIndex(row, column, node.get());
263 if (!indexValue.isValid())
264 return QModelIndex();
270 return QModelIndex();
271 if (parentNode == d->RootNode.get())
272 return QModelIndex();
274 return this->createIndex(parentNode->
getRow(), 0, parentNode);
281 if (parentValue.column() > 0)
293 this->beginResetModel();
297 d->RootNode = d->createNode(-1, QModelIndex());
299 this->endResetModel();
333 this->beginRemoveRows(parent, row, row+count-1);
335 for (
int i=row; i<row+count; ++i)
337 QModelIndex
index = this->
index(i, 0, parent);
341 this->endRemoveRows();
DicomModelNode * nodeFromIndex(const QModelIndex &indexValue) const
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
NodePtr createNode(int row, const QModelIndex &parentValue) const
void setEndLevel(DICOMModel::IndexType level)
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
virtual void fetchMore(const QModelIndex &parent)
QStringList getChildrenUID() const
uids of all loaded and unloaded children.
void setDatabase(QSharedPointer< ctkDICOMDatabase > dataBase)
boost::shared_ptr< class DicomModelNode > NodePtr
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
void removeChild(int index)
DicomModelNode * getParent() const
void remove(const QModelIndex &index)
virtual ~DICOMModelPrivate()
DICOMModelPrivate(DICOMModel &)
DICOMModel(QObject *parent=0)
void fetchChildren(const QModelIndex &indexValue)
const std::vector< NodePtr > & getFetchedChildren() const
all children currently loaded (filled by fetchMore())
Q_DECLARE_METATYPE(Qt::CheckState)
static NodePtr createNode(int row, DicomModelNode *parent, QSharedPointer< ctkDICOMDatabase > dataBase)
virtual DICOMModel::IndexType getType() const =0
QSharedPointer< ctkDICOMDatabase > DataBase
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const
virtual QModelIndex parent(const QModelIndex &index) const
DICOMModel::IndexType endLevel() const
Set it before populating the model.
virtual bool canFetchMore(const QModelIndex &parent) const
static NodePtr getNullNode()
NodePtr getFetchedChildForRow(int row) const
bool canFetchMore() const
QVariant getValue(int column) const
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Namespace for all CustusX production code.