Provides access to data stored in a Project through Qt's model-view framework. More...
#include <ProjectItemModel.h>
Signals | |
void | itemAdded (ProjectItem *) |
This signal is emitted when a ProjectItem is added to the model. More... | |
void | itemRemoved (ProjectItem *) |
Public Member Functions | |
ProjectItemModel (QObject *parent=0) | |
Constructs an empty model. More... | |
~ProjectItemModel () | |
Destructs the model. More... | |
QItemSelectionModel * | selectionModel () |
Returns the internal selection model. More... | |
ProjectItem * | addProject (Project *project) |
Adds a Project to the model. More... | |
ProjectItem * | findItemData (const QVariant &data, int role=Qt::UserRole+1) |
Returns the first item found that contains the given data in the given role or a null pointer if no item is found. More... | |
virtual bool | canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const |
You cannot drop mime data into the ProjectItemModel. More... | |
virtual void | removeItem (ProjectItem *item) |
Removes an item and its children from the model. More... | |
virtual void | removeItems (QList< ProjectItem * > items) |
Removes a list of items and their children from the model. More... | |
ProjectItem * | currentItem () |
Returns the current item of the internal selection model. More... | |
QList< ProjectItem * > | selectedItems () |
Returns a list of the selected items of the internal selection model. More... | |
void | appendRow (ProjectItem *item) |
Appends a top-level item to the model. More... | |
QModelIndex | indexFromItem (const ProjectItem *item) |
Returns the QModelIndex corresponding to a given ProjectItem. More... | |
void | insertRow (int row, ProjectItem *item) |
Inserts a top-level item at the given row. More... | |
ProjectItem * | item (int row) |
Returns the top-level item at the given row. More... | |
ProjectItem * | itemFromIndex (const QModelIndex &index) |
Returns the ProjectItem corresponding to a given QModelIndex. More... | |
void | setItem (int row, ProjectItem *item) |
Sets the item at the top-level row. More... | |
ProjectItem * | takeItem (int row) |
Removes the top-level row and returns the removed item. More... | |
Protected Slots | |
void | onSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected) |
Slot to connect to the selectionChanged() signal from a selection model. More... | |
Private Slots | |
void | onNameChanged (QString newName) |
Slot to connect to the nameChanged() signal from a Project. More... | |
void | onBundleSolutionInfoAdded (BundleSolutionInfo *bundleSolutionInfo) |
Slot to connect to the bundleSolutionInfoAdded() signal from a project. More... | |
void | onImagesAdded (ImageList *images) |
Slot to connect to the imagesAdded() signal from a Project. More... | |
void | onShapesAdded (ShapeList *shapes) |
Slot to connect to the shapesAdded() signal from a Project. More... | |
void | onControlAdded (Control *control) |
Slot to connect to the controlAdded() signal from a project. More... | |
void | onControlListAdded (ControlList *controlList) |
Slot to connect to the controlListAdded() signal from a Project. More... | |
void | onTargetsAdded (TargetBodyList *targets) |
Slot to connect to the targetsAdded() signal from a Project. More... | |
void | onGuiCamerasAdded (GuiCameraList *cameras) |
Slot to connect to the guiCamerasAdded() signal from a Project. More... | |
void | onRowsInserted (const QModelIndex &parent, int start, int end) |
Slot to connect to the rowsInserted() signal from QAbstractItemModel. More... | |
void | onRowsRemoved (const QModelIndex &parent, int start, int end) |
Slot to connect to the rowsAboutToBeRemoved() signal from QAbstractItemModel. More... | |
Private Attributes | |
QItemSelectionModel * | m_selectionModel |
The internal selection model. More... | |
Provides access to data stored in a Project through Qt's model-view framework.
Items corresponding to data are organized in a tree structure. Data can be accessed through a ProjectItem or through a QModelIndex. Views associated with the model can access it either through the model directly or through a ProjectItemProxyModel.
Top-level items can be accessed through the item() method using the row where the item is stored. Children of items can be accessed through the child() method on the parent item. The data stored in an item can be accessed as a QVariant using the data() method of the item or through the various convenience methods in ProjectItem. Alternatively, the data in an item can be accessed with its corresponding QModelIndex and the model's data() method. It should be noted that the data() method in the model and the data() method of ProjectItem require a Qt::ItemDataRole interpreted as an int. Data stored in the model that correspond to Isis classes are stored as Qt::UserRole + 1.
Top-level items should be added to the model using the appendRow() or the insertRow() method. To add child items to a parent item the appendRow() or insertRow() methods of the parent item should be used.
The model keeps track of selected items and the current item using an internal QItemSelectionModel.
Views that only need access to a subset of the items or the items organized in a different way should use a ProjectItemProxyModel.
2015-10-21 Jeffrey Covington - Original version.
2016-01-13 Jeffrey Covington - Added canDropMimeData() method.
2016-06-27 Ian Humphrey - Added documentation to canDropMimeData(), checked coding standards. Fixes #4006.
2016-07-18 Tracie Sucharski - Added Project Item slots for adding shape models.
2016-08-25 Adam Paquette - Updated documentation. Fixes #4299.
Definition at line 94 of file ProjectItemModel.h.
Isis::ProjectItemModel::ProjectItemModel | ( | QObject * | parent = 0 | ) |
Constructs an empty model.
[in] | parent | (QObject *) The parent. |
Definition at line 51 of file ProjectItemModel.cpp.
References m_selectionModel, onRowsInserted(), onRowsRemoved(), and onSelectionChanged().
Isis::ProjectItemModel::~ProjectItemModel | ( | ) |
Destructs the model.
Definition at line 69 of file ProjectItemModel.cpp.
ProjectItem * Isis::ProjectItemModel::addProject | ( | Project * | project | ) |
Adds a Project to the model.
An item is created that corresponds to the Project as well as children items that correspond to various parts of the Project.
Definition at line 114 of file ProjectItemModel.cpp.
References appendRow(), onBundleSolutionInfoAdded(), onControlAdded(), onControlListAdded(), onGuiCamerasAdded(), onImagesAdded(), onNameChanged(), onShapesAdded(), and onTargetsAdded().
void Isis::ProjectItemModel::appendRow | ( | ProjectItem * | item | ) |
Appends a top-level item to the model.
[in] | item | (ProjectItem *) The item to append. |
Definition at line 230 of file ProjectItemModel.cpp.
Referenced by Isis::ProjectItemProxyModel::addChild(), and addProject().
|
virtual |
You cannot drop mime data into the ProjectItemModel.
data | (const QMimeData *) The data to drop |
action | (Qt::DropAction) The drop action |
row | (int) ??? |
column | (int) ??? |
parent | (const QModelIndex &) The index of the data's parent |
Reimplemented in Isis::ProjectItemProxyModel.
Definition at line 87 of file ProjectItemModel.cpp.
ProjectItem * Isis::ProjectItemModel::currentItem | ( | ) |
Returns the current item of the internal selection model.
Definition at line 144 of file ProjectItemModel.cpp.
References itemFromIndex(), and selectionModel().
Referenced by Isis::AbstractProjectItemView::currentItem(), and Isis::RemoveImagesWorkOrder::syncRedo().
ProjectItem * Isis::ProjectItemModel::findItemData | ( | const QVariant & | data, |
int | role = Qt::UserRole+1 |
||
) |
Returns the first item found that contains the given data in the given role or a null pointer if no item is found.
data | (const QVariant &) The data contained in the item. |
data | (int) The role of the data (see Qt::ItemDataRole). |
Definition at line 176 of file ProjectItemModel.cpp.
References Isis::ProjectItem::findItemData(), and item().
QModelIndex Isis::ProjectItemModel::indexFromItem | ( | const ProjectItem * | item | ) |
Returns the QModelIndex corresponding to a given ProjectItem.
[in] | item | (const ProjectItem *) The item. |
Definition at line 242 of file ProjectItemModel.cpp.
void Isis::ProjectItemModel::insertRow | ( | int | row, |
ProjectItem * | item | ||
) |
Inserts a top-level item at the given row.
[in] | row | (int) The row where the item will be inserted. |
[in] | item | (ProjectItem *) The item to insert. |
Definition at line 253 of file ProjectItemModel.cpp.
ProjectItem * Isis::ProjectItemModel::item | ( | int | row | ) |
Returns the top-level item at the given row.
[in] | row | (int) The row of the item. |
Definition at line 265 of file ProjectItemModel.cpp.
Referenced by Isis::ProjectItemProxyModel::addItems(), findItemData(), onBundleSolutionInfoAdded(), onControlAdded(), onControlListAdded(), onGuiCamerasAdded(), onImagesAdded(), onNameChanged(), onRowsInserted(), onRowsRemoved(), onSelectionChanged(), onShapesAdded(), onTargetsAdded(), and removeItems().
|
signal |
This signal is emitted when a ProjectItem is added to the model.
Referenced by onRowsInserted().
ProjectItem * Isis::ProjectItemModel::itemFromIndex | ( | const QModelIndex & | index | ) |
Returns the ProjectItem corresponding to a given QModelIndex.
[in] | index | (const QModelIndex &) The index of the item. |
Definition at line 277 of file ProjectItemModel.cpp.
Referenced by currentItem(), Isis::ProjectItemProxyModel::mapIndexFromSource(), Isis::ProjectItemProxyModel::mapIndexToSource(), Isis::CubeDnView::onCurrentChanged(), onRowsInserted(), onRowsRemoved(), onSelectionChanged(), and selectedItems().
|
privateslot |
Slot to connect to the bundleSolutionInfoAdded() signal from a project.
Adds a ProjectItem that corresponds to the BundleSolutionInfo to the model. The item is added to the item named "Results" of the item that corresponds to the Project that sent the signal.
[in] | bundleSolutionInfo | (BundleSolutionInfo *) The BundleSolutionInfo added to the Project. |
Definition at line 343 of file ProjectItemModel.cpp.
References Isis::ProjectItem::appendRow(), Isis::ProjectItem::child(), item(), and Isis::ProjectItem::project().
Referenced by addProject().
|
privateslot |
Slot to connect to the controlAdded() signal from a project.
Adds a ProjectItem that corresponds to the Control to the model. The item is added to the item that corresponds to the control's ControlList.
Definition at line 372 of file ProjectItemModel.cpp.
References Isis::ProjectItem::appendRow(), Isis::ProjectItem::child(), Isis::ProjectItem::controlList(), item(), and Isis::ProjectItem::project().
Referenced by addProject().
|
privateslot |
Slot to connect to the controlListAdded() signal from a Project.
Adds a ProjectItem that corresponds to the ControlList to the model. The item is added to the item named "Control Networks" of the item that corresponds to the Project that sent the signal.
[in] | controlList | (ControlList *) The ControlList added to the Project. |
Definition at line 410 of file ProjectItemModel.cpp.
References Isis::ProjectItem::appendRow(), Isis::ProjectItem::child(), item(), and Isis::ProjectItem::project().
Referenced by addProject().
|
privateslot |
Slot to connect to the guiCamerasAdded() signal from a Project.
Adds items that correspond to the cameras to the model. The items are added to the item named "Sensors" of the item that corresponds to the Project that sent the signal.
[in] | cameras | (GuiCameraList *) The GuiCameraList of the Project. |
Definition at line 537 of file ProjectItemModel.cpp.
References Isis::ProjectItem::appendRow(), Isis::ProjectItem::child(), Isis::ProjectItem::guiCamera(), item(), and Isis::ProjectItem::project().
Referenced by addProject().
|
privateslot |
Slot to connect to the imagesAdded() signal from a Project.
Adds a ProjectItem that corresponds to the ImageList to the model. The item is added to the item named "Images" of the item that corresponds to the Project that sent the signal.
Definition at line 439 of file ProjectItemModel.cpp.
References Isis::ProjectItem::appendRow(), Isis::ProjectItem::child(), item(), and Isis::ProjectItem::project().
Referenced by addProject().
|
privateslot |
Slot to connect to the nameChanged() signal from a Project.
Sets the name of the ProjectItem that corresponds with the Project.
[in] | newName | (QString) The new name of the project |
Definition at line 317 of file ProjectItemModel.cpp.
References item(), and Isis::ProjectItem::project().
Referenced by addProject().
|
privateslot |
Slot to connect to the rowsInserted() signal from QAbstractItemModel.
Emits a corresponding itemAdded() signal for each row inserted.
[in] | parent | (const QModelIndex &) The parent index where rows were inserted. |
[in] | start | (int) The first row inserted (inclusive). |
[in] | end | (int) The last row inserted (inclusive). |
Definition at line 615 of file ProjectItemModel.cpp.
References item(), itemAdded(), and itemFromIndex().
Referenced by ProjectItemModel().
|
privateslot |
Slot to connect to the rowsAboutToBeRemoved() signal from QAbstractItemModel.
Emits a corresponding itemRemoved() signal for each row inserted.
[in] | parent | (const QModelIndex &) The parent index where rows are to be removed. |
[in] | start | (int) The first row to be removed (inclusive). |
[in] | end | (int) The last row to be removed (inclusive). |
Definition at line 633 of file ProjectItemModel.cpp.
References item(), and itemFromIndex().
Referenced by ProjectItemModel().
|
protectedslot |
Slot to connect to the selectionChanged() signal from a selection model.
Updates other factors in the model that rely on selected items but do not directly correspond with the selection model. Currently changes the selected property of Images that correspond with selected or deselected items.
[in] | selected | (const QItemSelection &) The selected items. |
[in] | deselected | (const QItemSelection &) The deselected items. |
Definition at line 579 of file ProjectItemModel.cpp.
References Isis::Image::displayProperties(), Isis::ProjectItem::image(), Isis::ProjectItem::isImage(), item(), itemFromIndex(), selectedItems(), and Isis::ImageDisplayProperties::setSelected().
Referenced by ProjectItemModel().
|
privateslot |
Slot to connect to the shapesAdded() signal from a Project.
Adds a ProjectItem that corresponds to the ShapeList to the model. The item is added to the item named "Shape Models" of the item that corresponds to the Project that sent the signal.
Definition at line 469 of file ProjectItemModel.cpp.
References Isis::ProjectItem::appendRow(), Isis::ProjectItem::child(), item(), and Isis::ProjectItem::project().
Referenced by addProject().
|
privateslot |
Slot to connect to the targetsAdded() signal from a Project.
Adds items that correspond to the target bodies to the model. The items are added to the item named "Target Body" of the item that corresponds to the Project that sent the signal.
[in] | targets | (TargetBodyList *) The TargetBodyList of the Project. |
Definition at line 497 of file ProjectItemModel.cpp.
References Isis::ProjectItem::appendRow(), Isis::ProjectItem::child(), item(), Isis::ProjectItem::project(), and Isis::ProjectItem::targetBody().
Referenced by addProject().
|
virtual |
Removes an item and its children from the model.
[in] | item | (ProjectItem *) The item to be removed. |
Reimplemented in Isis::ProjectItemProxyModel.
Definition at line 197 of file ProjectItemModel.cpp.
References Isis::ProjectItem::parent().
Referenced by Isis::ProjectItemProxyModel::removeItem(), removeItems(), and Isis::RemoveImagesWorkOrder::syncRedo().
|
virtual |
Removes a list of items and their children from the model.
[in] | item | (ProjectItem *) The items to be removed. |
Definition at line 218 of file ProjectItemModel.cpp.
References item(), and removeItem().
QList< ProjectItem * > Isis::ProjectItemModel::selectedItems | ( | ) |
Returns a list of the selected items of the internal selection model.
Definition at line 154 of file ProjectItemModel.cpp.
References itemFromIndex(), and selectionModel().
Referenced by Isis::ProjectItemProxyModel::dropMimeData(), onSelectionChanged(), Isis::AbstractProjectItemView::selectedItems(), Isis::CubeDnViewWorkOrder::syncRedo(), and Isis::Footprint2DViewWorkOrder::syncRedo().
QItemSelectionModel * Isis::ProjectItemModel::selectionModel | ( | ) |
Returns the internal selection model.
Definition at line 100 of file ProjectItemModel.cpp.
References m_selectionModel.
Referenced by currentItem(), Isis::CubeDnView::onCubeViewportActivated(), Isis::Footprint2DView::onQueueSelectionChanged(), selectedItems(), Isis::ProjectItemTreeView::setInternalModel(), Isis::ProjectItemProxyModel::setSourceModel(), Isis::ProjectItemProxyModel::updateProxyCurrent(), Isis::ProjectItemProxyModel::updateProxySelection(), Isis::ProjectItemProxyModel::updateSourceCurrent(), and Isis::ProjectItemProxyModel::updateSourceSelection().
void Isis::ProjectItemModel::setItem | ( | int | row, |
ProjectItem * | item | ||
) |
Sets the item at the top-level row.
[in] | row | (int) The row where the item will be set. |
[in] | item | (ProjectItem *) The item to set the row to. |
Definition at line 288 of file ProjectItemModel.cpp.
ProjectItem * Isis::ProjectItemModel::takeItem | ( | int | row | ) |
Removes the top-level row and returns the removed item.
[in] | row | (int) The row of the item to remove. |
Definition at line 300 of file ProjectItemModel.cpp.
|
private |
The internal selection model.
Definition at line 150 of file ProjectItemModel.h.
Referenced by ProjectItemModel(), and selectionModel().
U.S. Department of the Interior | U.S. Geological Survey ISIS | Privacy & Disclaimers | Astrogeology Research Program To contact us, please post comments and questions on the ISIS Support Center File Modified: 07/13/2023 00:08:46 |