Tree model for browsing the XNAT server hierarchy with MITK-specific enhancements.
More...
#include <QmitkXnatTreeModel.h>
|
| 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...
|
| |
|
| | 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...
|
| |
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.
◆ QmitkXnatTreeModel()
| QmitkXnatTreeModel::QmitkXnatTreeModel |
( |
| ) |
|
◆ 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] | index | The model index to retrieve data for. |
| [in] | role | The 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] | data | The MIME data containing serialized data node pointers. |
| [in] | action | The drop action being performed. |
| [in] | row | The target row (unused). |
| [in] | column | The target column (unused). |
| [in] | parent | The 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] | idx | The 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] | index | The 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] | index | The 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] | url | The 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] | start | The starting index for the search. |
| [in] | role | The item data role to match against. |
| [in] | value | The value to compare against. |
| [in] | hits | Maximum number of results to return (-1 for unlimited). |
| [in] | flags | Match 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] | nodes | The list of dropped MITK data nodes. |
| [in] | target | The XNAT object that received the drop. |
| [in] | index | The 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: