Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkXnatTreeModel Class Reference

Tree model for browsing the XNAT server hierarchy with MITK-specific enhancements. More...

#include <QmitkXnatTreeModel.h>

Inheritance diagram for QmitkXnatTreeModel:
Collaboration diagram for QmitkXnatTreeModel:

Signals

void Error (const QModelIndex &idx)
 Emitted when fetching child data for an index fails due to an HTTP error. More...
 
void ResourceDropped (const QList< mitk::DataNode * > &nodes, ctkXnatObject *target, const QModelIndex &index)
 Emitted when MITK data nodes are dropped onto an XNAT tree node. More...
 

Public Member Functions

 QmitkXnatTreeModel ()
 Default constructor. More...
 
QVariant data (const QModelIndex &index, int role) const override
 Return data for the given index and role, with MITK-specific icon decoration. More...
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 Handle dropped MIME data containing MITK data node pointers. More...
 
virtual Qt::DropActions supportedDropActions ()
 Return supported drop actions (Qt::CopyAction). More...
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 Return item flags for the given index. More...
 
ctkXnatObject * GetXnatObjectFromUrl (const QString &url)
 Look up an XNAT object by its REST URL. More...
 
void fetchMore (const QModelIndex &index) override
 Fetch child data for the given index, with error handling. More...
 
QModelIndexList match (const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const override
 Find model indices that do NOT match the given value (inverse matching). More...
 

Detailed Description

Tree model for browsing the XNAT server hierarchy with MITK-specific enhancements.

QmitkXnatTreeModel extends ctkXnatTreeModel to provide MITK-specific icon decoration for different XNAT object types (server, project, subject, experiment, resource, scan, file), drag-and-drop support for uploading MITK data nodes to XNAT resources, and error handling that displays user-facing error dialogs through QmitkHttpStatusCodeHandler.

The model supports inverse matching in its match() override (returns non-matching indices), and allows dropping data nodes onto subjects, experiments, resources, and resource folders.

See also
QmitkHttpStatusCodeHandler, QmitkSelectXnatUploadDestinationDialog, ctkXnatTreeModel

Definition at line 40 of file QmitkXnatTreeModel.h.

Constructor & Destructor Documentation

◆ QmitkXnatTreeModel()

QmitkXnatTreeModel::QmitkXnatTreeModel ( )

Default constructor.

Member Function Documentation

◆ data()

QVariant QmitkXnatTreeModel::data ( const QModelIndex &  index,
int  role 
) const
override

Return data for the given index and role, with MITK-specific icon decoration.

For Qt::DecorationRole, returns icons specific to the XNAT object type at the given index (server, project, subject, experiment, resource folder, resource, scan folder, scan, or file). For all other roles, delegates to ctkXnatTreeModel::data().

Parameters
[in]indexThe model index to retrieve data for.
[in]roleThe Qt item data role.
Returns
The data for the given role, or an invalid QVariant if the index is not valid.

◆ dropMimeData()

bool QmitkXnatTreeModel::dropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
)
override

Handle dropped MIME data containing MITK data node pointers.

When data nodes are dropped onto an XNAT tree node, emits the ResourceDropped signal with the list of dropped nodes, the target XNAT object, and the parent index.

Parameters
[in]dataThe MIME data containing serialized data node pointers.
[in]actionThe drop action being performed.
[in]rowThe target row (unused).
[in]columnThe target column (unused).
[in]parentThe model index of the drop target.
Returns
true if the data was in the expected MITK data node format, false otherwise.

◆ Error

void QmitkXnatTreeModel::Error ( const QModelIndex &  idx)
signal

Emitted when fetching child data for an index fails due to an HTTP error.

Parameters
[in]idxThe model index for which the fetch operation failed.

◆ fetchMore()

void QmitkXnatTreeModel::fetchMore ( const QModelIndex &  index)
override

Fetch child data for the given index, with error handling.

Delegates to ctkXnatTreeModel::fetchMore() and catches ctkRuntimeException to display an error dialog via QmitkHttpStatusCodeHandler. Emits the Error signal on failure.

Parameters
[in]indexThe model index to fetch children for.

◆ flags()

Qt::ItemFlags QmitkXnatTreeModel::flags ( const QModelIndex &  index) const
override

Return item flags for the given index.

Adds Qt::ItemIsDropEnabled for indices representing subjects, experiments, resources, or resource folders. Other XNAT object types do not accept drops.

Parameters
[in]indexThe model index to query flags for.
Returns
The item flags for the given index.

◆ GetXnatObjectFromUrl()

ctkXnatObject* QmitkXnatTreeModel::GetXnatObjectFromUrl ( const QString &  url)

Look up an XNAT object by its REST URL.

Traverses the XNAT hierarchy (project, subject, experiment, scan) by matching URL segments, fetching children as needed. Returns the deepest matching object, or the "Resources" folder of the deepest matched parent.

Parameters
[in]urlThe XNAT REST URL to resolve (e.g., ".../projects/P/subjects/S/experiments/E").
Returns
Pointer to the matching ctkXnatObject, or nullptr if the root is not valid.

◆ match()

QModelIndexList QmitkXnatTreeModel::match ( const QModelIndex &  start,
int  role,
const QVariant &  value,
int  hits,
Qt::MatchFlags  flags 
) const
override

Find model indices that do NOT match the given value (inverse matching).

Unlike the standard QAbstractItemModel::match(), this implementation returns indices whose data does not match the specified value and match flags. This is useful for filtering out matching items.

Parameters
[in]startThe starting index for the search.
[in]roleThe item data role to match against.
[in]valueThe value to compare against.
[in]hitsMaximum number of results to return (-1 for unlimited).
[in]flagsMatch flags controlling the comparison type and recursion.
Returns
List of model indices whose data does not match the given value.

◆ ResourceDropped

void QmitkXnatTreeModel::ResourceDropped ( const QList< mitk::DataNode * > &  nodes,
ctkXnatObject *  target,
const QModelIndex &  index 
)
signal

Emitted when MITK data nodes are dropped onto an XNAT tree node.

Parameters
[in]nodesThe list of dropped MITK data nodes.
[in]targetThe XNAT object that received the drop.
[in]indexThe model index of the drop target.

◆ supportedDropActions()

virtual Qt::DropActions QmitkXnatTreeModel::supportedDropActions ( )
virtual

Return supported drop actions (Qt::CopyAction).

Returns
Qt::CopyAction.

The documentation for this class was generated from the following file: