Isis Developer Reference
Isis::ProjectItemModel Class Reference

Provides access to data stored in a Project through Qt's model-view framework. More...

#include <ProjectItemModel.h>

Inheritance diagram for Isis::ProjectItemModel:
Inheritance graph
Collaboration diagram for Isis::ProjectItemModel:
Collaboration graph

Signals

void itemAdded (ProjectItem *)
 This signal is emitted when a ProjectItem is added to the model. More...
 
void itemRemoved (ProjectItem *)
 This signal is emitted when a ProjectItem is removed to the model. More...
 
void cleanProject (bool)
 This signal is emitted whrn a ProjectItem's name is changed. More...
 
void projectNameEdited (QString)
 This signal is emitted when the project name is edited. More...
 

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...
 
ProjectItemaddProject (Project *project)
 Adds a Project to the model. More...
 
ProjectItemfindItemData (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...
 
ProjectItemcurrentItem ()
 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...
 
QList< ProjectItem * > selectedBOSSImages ()
 ProjectItemModel::selectedBOSSImages. More...
 
void appendRow (ProjectItem *item)
 Appends a top-level item to the model. More...
 
void clean ()
 Used to clean the ProjectItemModel of everything but the headers. 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...
 
ProjectItemitem (int row)
 Returns the top-level item at the given row. More...
 
ProjectItemitemFromIndex (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...
 
ProjectItemtakeItem (int row)
 Removes the top-level row and returns the removed item. More...
 
bool setData (const QModelIndex &index, const QVariant &value, int role)
 This virtual method was added to handle changing the project name by double-clicking the project name on the project tree. More...
 
Qt::ItemFlags flags (const QModelIndex &index) const
 This virtual method was added to handle changing the project name by double-clicking the project name on the project tree. More...
 

Protected Slots

void onSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 Slot to connect to the selectionChanged() signal from a selection model. More...
 

Detailed Description

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.

Image *image = new Image("example.cub");
ProjectItem *item = new ProjectItem(image);
model->appendRow(item);
Author
2015-10-21 Jeffrey Covington

Constructor & Destructor Documentation

◆ ProjectItemModel()

Isis::ProjectItemModel::ProjectItemModel ( QObject parent = 0)

Constructs an empty model.

Parameters
parent(QObject *) The parent.

References onSelectionChanged().

◆ ~ProjectItemModel()

Isis::ProjectItemModel::~ProjectItemModel ( )

Destructs the model.

Member Function Documentation

◆ addProject()

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.

Parameters
project(Project *) The Project to be added.
Returns
ProjectItem* The new item that corresponds to the Project.

References appendRow().

◆ appendRow()

void Isis::ProjectItemModel::appendRow ( ProjectItem item)

Appends a top-level item to the model.

Parameters
item(ProjectItem *) The item to append.

References item().

Referenced by Isis::ProjectItemProxyModel::addChild(), and addProject().

◆ canDropMimeData()

bool Isis::ProjectItemModel::canDropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
) const
virtual

You cannot drop mime data into the ProjectItemModel.

See also
ProjectItemProxyModel
Parameters
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
Returns
bool False

Reimplemented in Isis::ProjectItemProxyModel.

◆ clean()

void Isis::ProjectItemModel::clean ( )

Used to clean the ProjectItemModel of everything but the headers.

References Isis::ProjectItem::child(), item(), Isis::ProjectItem::project(), and removeItem().

◆ cleanProject

void Isis::ProjectItemModel::cleanProject ( bool  )
signal

This signal is emitted whrn a ProjectItem's name is changed.

Referenced by setData().

◆ currentItem()

ProjectItem * Isis::ProjectItemModel::currentItem ( )

Returns the current item of the internal selection model.

Returns
ProjectItem* The current item.

References item(), itemFromIndex(), selectedItems(), and selectionModel().

Referenced by Isis::AbstractProjectItemView::currentItem().

◆ findItemData()

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.

Parameters
data(const QVariant &) The data contained in the item.
role(int) The role of the data (see Qt::ItemDataRole).
Returns
ProjectItem* First project item found.

References Isis::ProjectItem::findItemData(), and item().

Referenced by Isis::JigsawSetupDialog::JigsawSetupDialog(), selectedBOSSImages(), Isis::Project::setActiveControl(), Isis::Project::setActiveImageList(), Isis::ImportImagesWorkOrder::undoExecution(), Isis::ImportMapTemplateWorkOrder::undoExecution(), Isis::ImportRegistrationTemplateWorkOrder::undoExecution(), and Isis::ImportShapesWorkOrder::undoExecution().

◆ flags()

Qt::ItemFlags Isis::ProjectItemModel::flags ( const QModelIndex &  index) const

This virtual method was added to handle changing the project name by double-clicking the project name on the project tree.

It was required by Qt in order to allow editing capabilities.

See also
http://doc.qt.io/qt-5/modelview.html
Parameters
index(const QModelIndex &) Field which has been edited
Returns
Qt::ItemFlags Add the ItemIsEditable to the standard flags.

◆ indexFromItem()

QModelIndex Isis::ProjectItemModel::indexFromItem ( const ProjectItem item)

Returns the QModelIndex corresponding to a given ProjectItem.

Parameters
item(const ProjectItem *) The item.
Returns
QModelIndex The index of the item.

References item().

◆ insertRow()

void Isis::ProjectItemModel::insertRow ( int  row,
ProjectItem item 
)

Inserts a top-level item at the given row.

Parameters
row(int) The row where the item will be inserted.
item(ProjectItem *) The item to insert.

References item().

◆ item()

ProjectItem * Isis::ProjectItemModel::item ( int  row)

Returns the top-level item at the given row.

Parameters
row(int) The row of the item.
Returns
ProjectItem* The item at the row.

Referenced by Isis::ProjectItemProxyModel::addItems(), appendRow(), clean(), currentItem(), findItemData(), indexFromItem(), insertRow(), onSelectionChanged(), removeItem(), Isis::ProjectItemProxyModel::removeItem(), removeItems(), selectedBOSSImages(), setData(), and setItem().

◆ itemAdded

void Isis::ProjectItemModel::itemAdded ( ProjectItem )
signal

This signal is emitted when a ProjectItem is added to the model.

◆ itemFromIndex()

ProjectItem * Isis::ProjectItemModel::itemFromIndex ( const QModelIndex &  index)

◆ itemRemoved

void Isis::ProjectItemModel::itemRemoved ( ProjectItem )
signal

This signal is emitted when a ProjectItem is removed to the model.

◆ onSelectionChanged

void Isis::ProjectItemModel::onSelectionChanged ( const QItemSelection &  selected,
const QItemSelection &  deselected 
)
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.

Parameters
selected(const QItemSelection &) The selected items.
deselected(const QItemSelection &) The deselected items.

References Isis::Image::displayProperties(), Isis::ProjectItem::image(), Isis::ProjectItem::isImage(), item(), itemFromIndex(), selectedItems(), and Isis::ImageDisplayProperties::setSelected().

Referenced by ProjectItemModel().

◆ projectNameEdited

void Isis::ProjectItemModel::projectNameEdited ( QString  )
signal

This signal is emitted when the project name is edited.

Referenced by setData().

◆ removeItem()

◆ removeItems()

void Isis::ProjectItemModel::removeItems ( QList< ProjectItem * >  items)
virtual

Removes a list of items and their children from the model.

Parameters
items(ProjectItem *) The items to be removed.

References item(), and removeItem().

Referenced by Isis::RemoveImagesWorkOrder::execute().

◆ selectedBOSSImages()

QList< ProjectItem * > Isis::ProjectItemModel::selectedBOSSImages ( )

ProjectItemModel::selectedBOSSImages.

Returns
This is a refinement of the selectedItems function which was needed to display a subset of Images/ImageLists in the Bundle Observation Solve Settings (BOSS) tab of the JigsawSetupDialog widget. The primary consumer of the selected images is going to be the SortFilterProxyModel class.

References Isis::ProjectItem::child(), findItemData(), Isis::ProjectItem::isImage(), Isis::ProjectItem::isImageList(), item(), itemFromIndex(), Isis::ProjectItem::parent(), and selectionModel().

◆ selectedItems()

◆ selectionModel()

◆ setData()

bool Isis::ProjectItemModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)

This virtual method was added to handle changing the project name by double-clicking the project name on the project tree.

It was required by Qt in order to allow editing capabilities.

See also
http://doc.qt.io/qt-5/modelview.html
Parameters
index(const QModelIndex &) Field which has been edited
value(const QVariant &) Value contained in the field
role(int) Will always be EditRole since field only contains text
Returns
bool Returns true if successful; otherwise false

References Isis::ProjectItem::bundleSolutionInfo(), cleanProject(), Isis::ProjectItem::controlList(), Isis::ProjectItem::imageList(), Isis::ProjectItem::isBundleSolutionInfo(), Isis::ProjectItem::isControlList(), Isis::ProjectItem::isImageList(), Isis::ProjectItem::isProject(), Isis::ProjectItem::isShapeList(), Isis::ProjectItem::isTemplate(), item(), itemFromIndex(), projectNameEdited(), Isis::BundleSolutionInfo::setName(), Isis::ControlList::setName(), Isis::ImageList::setName(), Isis::ShapeList::setName(), and Isis::ProjectItem::shapeList().

◆ setItem()

void Isis::ProjectItemModel::setItem ( int  row,
ProjectItem item 
)

Sets the item at the top-level row.

Parameters
row(int) The row where the item will be set.
item(ProjectItem *) The item to set the row to.

References item().

◆ takeItem()

ProjectItem * Isis::ProjectItemModel::takeItem ( int  row)

Removes the top-level row and returns the removed item.

Parameters
row(int) The row of the item to remove.
Returns
ProjectItem* The removed item.

The documentation for this class was generated from the following files:
Isis::ProjectItemModel::ProjectItemModel
ProjectItemModel(QObject *parent=0)
Constructs an empty model.
Definition: ProjectItemModel.cpp:44
Isis::ProjectItemModel::item
ProjectItem * item(int row)
Returns the top-level item at the given row.
Definition: ProjectItemModel.cpp:389