9#include "ProjectItemModel.h"
11#include <QItemSelection>
18#include <QRegExpValidator>
19#include <QStandardItemModel>
23#include "BundleSolutionInfo.h"
25#include "ControlList.h"
27#include "GuiCameraList.h"
30#include "ProjectItem.h"
32#include "TargetBodyList.h"
33#include "TemplateList.h"
45 const QItemSelection &) ),
48 connect(
this, SIGNAL(rowsInserted(
const QModelIndex &,
int,
int)),
51 connect(
this, SIGNAL(rowsAboutToBeRemoved(
const QModelIndex &,
int,
int)),
79 Qt::DropAction action,
81 const QModelIndex &parent)
const {
107 connect(project, SIGNAL( nameChanged(QString) ),
111 connect(project, SIGNAL( controlAdded(
Control *) ),
113 connect(project, SIGNAL( controlListAdded(
ControlList *) ),
115 connect(project, SIGNAL( imagesAdded(
ImageList *) ),
117 connect(project, SIGNAL( shapesAdded(
ShapeList *) ),
121 connect(project, SIGNAL( templatesAdded(
TemplateList *)),
158 QList<ProjectItem *> items;
161 foreach ( QModelIndex index, selection.indexes() ) {
178 QList<ProjectItem *> items;
179 QModelIndexList indices = selection.indexes();
182 if (indices.size() == 0) {
184 items.append(imageRoot);
185 for (
int i = 0; i < imageRoot->rowCount(); i++) {
187 items.append(imglistItem);
188 for (
int j = 0; j < imglistItem->rowCount(); j++) {
190 if (imgItem->isImage()) {
191 items.append(imgItem);
199 foreach ( QModelIndex ix, indices ) {
207 items.append(
item );
216 if (this->hasChildren(ix)) {
220 bool childrenSelected(
false);
221 int numChildren = this->rowCount(ix);
224 for (
int i = 0; i < numChildren;i++) {
225 QModelIndex ixchild = this->index(i,0,ix);
226 if (indices.contains(ixchild) ){
227 childrenSelected=
true;
232 if (childrenSelected) {
233 for (
int i =0;i < numChildren;i++) {
234 QModelIndex ixchild = this->index(i,0,ix);
235 if (indices.contains(ixchild))
242 for (
int i =0;i < numChildren;i++) {
243 QModelIndex ixchild = this->index(i,0,ix);
256 if (!items.contains(parent)){
257 items.append(parent);
265 if (!items.contains(grandparent)) {
266 items.append(grandparent);
291 for (
int i=0; i<rowCount(); i++) {
319 if (
item->hasChildren()) {
320 for (
int row = (
item->rowCount() - 1); row >= 0; row--) {
327 removeRow(
item->row(), parentItem->index());
330 removeRow(
item->row());
353 QStandardItemModel::appendRow(
item);
365 return QStandardItemModel::indexFromItem(
item);
376 QStandardItemModel::insertRow(row,
item);
388 return static_cast<ProjectItem *
>( QStandardItemModel::item(row) );
400 return static_cast<ProjectItem *
>( QStandardItemModel::itemFromIndex(index) );
411 QStandardItemModel::setItem(row,
item);
423 QList<QStandardItem *> items = QStandardItemModel::takeRow(row);
425 if ( items.isEmpty() ) {
429 return static_cast<ProjectItem *
>( items.first() );
440 Project *project = qobject_cast<Project *>( sender() );
446 for (
int i=0; i<rowCount(); i++) {
448 if (projectItem->project() == project) {
449 projectItem->setText(newName);
467 Project *project = qobject_cast<Project *>( sender() );
468 m_reservedNames.append(bundleSolutionInfo->
name() );
474 for (
int i=0; i<rowCount(); i++) {
476 if (projectItem->project() == project) {
477 for (
int j=0; j < projectItem->rowCount(); j++) {
479 if (resultsItem->text() ==
"Results") {
481 resultsItem->appendRow( pItem );
487 QIcon(
FileName(
"$ISISROOT/appdata/images/icons/office-chart-pie.png")
489 pItem->child(2)->appendRow(bundleSummaryItem);
493 QIcon(
FileName(
"$ISISROOT/appdata/images/icons/office-chart-pie.png")
495 pItem->child(2)->appendRow(residualsItem);
499 QIcon(
FileName(
"$ISISROOT/appdata/images/icons/office-chart-pie.png")
501 pItem->child(2)->appendRow(imagesItem);
505 QIcon(
FileName(
"$ISISROOT/appdata/images/icons/office-chart-pie.png")
507 pItem->child(2)->appendRow(pointsItem);
524 Project *project = qobject_cast<Project *>( sender() );
525 if (!project) {
return; }
529 for (
int i = 0; i<rowCount(); i++) {
531 if (projectItem->project() == project) {
534 for (
int j = 0; j < projectItem->rowCount(); j++) {
536 if (templatesItem->text() ==
"Templates"){
539 QString type = templateList->
type();
540 for (
int k = 0; k < templatesItem->rowCount(); k++) {
542 if (templateType->text().toLower() == type) {
562 Project *project = qobject_cast<Project *>( sender() );
563 m_reservedNames.append(control->
id() );
569 for (
int i=0; i<rowCount(); i++) {
571 if (projectItem->project() == project) {
572 for (
int j=0; j < projectItem->rowCount(); j++) {
574 if (controlsItem->text() ==
"Control Networks") {
575 for (
int k=0; k < controlsItem->rowCount(); k++) {
577 ControlList *controlList = controlListItem->controlList();
578 if ( controlList && controlList->contains(control) ) {
579 controlListItem->appendRow(
new ProjectItem(control) );
601 Project *project = qobject_cast<Project *>( sender() );
602 m_reservedNames.append(controlList->
name() );
608 for (
int i=0; i<rowCount(); i++) {
610 if (projectItem->project() == project) {
611 for (
int j=0; j < projectItem->rowCount(); j++) {
613 if (controlsItem->text() ==
"Control Networks") {
632 Project *project = qobject_cast<Project *>( sender() );
633 m_reservedNames.append(imageList->
name() );
638 for (
int i=0; i<rowCount(); i++) {
640 if (projectItem->project() == project) {
641 for (
int j=0; j < projectItem->rowCount(); j++) {
643 if (imagesItem->text() ==
"Images") {
661 Project *project = qobject_cast<Project *>( sender() );
662 m_reservedNames.append(shapes->
name());
667 for (
int i=0; i<rowCount(); i++) {
669 if (projectItem->project() == project) {
670 for (
int j=0; j < projectItem->rowCount(); j++) {
672 if (shapesItem->text() ==
"Shapes") {
690 Project *project = qobject_cast<Project *>( sender() );
691 m_reservedNames.append(targets->name() );
697 for (
int i=0; i<rowCount(); i++) {
699 if (projectItem->project() == project) {
700 for (
int j=0; j < projectItem->rowCount(); j++) {
702 if (targetsItem->text() ==
"Target Body") {
705 for (
int k=0; k < targetsItem->rowCount(); k++) {
707 if (targetItem->targetBody() == target) {
731 Project *project = qobject_cast<Project *>( sender() );
732 m_reservedNames.append(cameras->name() );
738 for (
int i=0; i<rowCount(); i++) {
740 if (projectItem->project() == project) {
741 for (
int j=0; j < projectItem->rowCount(); j++) {
743 if (camerasItem->text() ==
"Sensors") {
746 for (
int k=0; k < camerasItem->rowCount(); k++) {
748 if (cameraItem->guiCamera() == camera) {
774 const QItemSelection &deselected) {
776 foreach ( QModelIndex index, selected.indexes() ) {
786 QList<ProjectItem *> deselectedItems;
787 foreach ( QModelIndex index, deselected.indexes() ) {
811 for (
int row=start; row <= end; row++) {
812 QModelIndex newIndex = index(row, 0, parent);
829 for (
int row=start; row <= end; row++) {
830 QModelIndex newIndex = index(row, 0, parent);
856 QString name = value.toString();
858 bool rejected =
rejectName(m_reservedNames,name);
861 QMessageBox nameRejected;
862 nameRejected.setText(
"That name is already in use within this project.");
867 m_reservedNames.append(name);
893 else if (
item->isTemplate() && role == Qt::EditRole) {
914 return Qt::ItemIsEditable | QStandardItemModel::flags(index);
930 QRegExpValidator valid;
931 QValidator::State state;
933 foreach (QString name, reserved) {
937 state = valid.validate(target,pos);
951 for (
int i=0; i<rowCount(); i++) {
953 if (projectItem->project()) {
954 for (
int j=0; j < projectItem->rowCount(); j++) {
955 if (projectItem->hasChildren()) {
959 if (subProjectItem->text() ==
"Templates") {
960 if (subProjectItem->hasChildren()) {
961 for (
int k=0; k < subProjectItem->rowCount(); k++) {
963 while (tempProjectItem->hasChildren()) {
970 while (subProjectItem->hasChildren()) {
Container class for BundleAdjustment results.
QString savedPointsFilename()
Returns filename of output bundle points csv file.
void setName(QString name)
Sets the name of the bundle.
QString savedResidualsFilename()
Returns filename of output bundle residuals csv file.
QString name() const
Returns the name of the bundle.
QString savedBundleOutputFilename()
Returns bundleout text filename.
QString savedImagesFilename()
Returns filename of output bundle images csv file.
This represents an ISIS control net in a project-based GUI interface.
QString id() const
Access the unique ID associated with this Control.
Maintains a list of Controls so that control nets can easily be copied from one Project to another,...
QString name() const
Get the human-readable name of this control list.
void setName(QString newName)
Set the human-readable name of this control list.
A container for a filename to be represented as a ProjectItem on the project tree.
File name manipulation and expansion.
List of GuiCameras saved as QSharedPointers.
void setSelected(bool)
Change the selected state associated with this cube.
ImageDisplayProperties * displayProperties()
Get the display (GUI) properties (information) associated with this image.
Internalizes a list of images and allows for operations on the entire list.
void setName(QString newName)
Set the human-readable name of this image list.
QString name() const
Get the human-readable name of this image list.
The main project for ipce.
void setClean(bool value)
Function to change the clean state of the project.
Represents an item of a ProjectItemModel in Qt's model-view framework.
void appendRow(ProjectItem *item)
Appends an item to the children of this item.
BundleSolutionInfo * bundleSolutionInfo() const
Returns the BundleSolutionInfo stored in the data of the item.
ProjectItem * findItemData(const QVariant &value, int role=Qt::UserRole+1)
Finds and returns the first item in the model that contains the data in the role.
bool isProject() const
Returns true if a Project is stored in the data of the item.
ShapeList * shapeList() const
Returns the ShapeList stored in the data of the item.
bool isControlList() const
Returns true if a ControlList is stored in the data of the item.
bool isShapeList() const
Returns true if an ShapeList is stored in the data of the item.
bool isImageList() const
Returns true if an ImageList is stored in the data of the item.
ProjectItem * parent() const
Returns the parent item of this item.
ImageList * imageList() const
Returns the ImageList stored in the data of the item.
Image * image() const
Returns the Image stored in the data of the item.
ControlList * controlList() const
Returns the ControlList stored in the data of the item.
bool isBundleSolutionInfo() const
Returns true if a BundleSolutionInfo is stored in the data of the item.
bool isImage() const
Returns true if an Image is stored in the data of the item.
ProjectItem * child(int row) const
Returns the child item at a given row.
void onTargetsAdded(TargetBodyList *targets)
Slot to connect to the targetsAdded() signal from a Project.
ProjectItemModel(QObject *parent=0)
Constructs an empty model.
QList< ProjectItem * > selectedItems()
Returns a list of the selected items of the internal selection model.
void cleanProject(bool)
This signal is emitted whrn a ProjectItem's name is changed.
void onImagesAdded(ImageList *images)
Slot to connect to the imagesAdded() signal from a Project.
void appendRow(ProjectItem *item)
Appends a top-level item to the model.
void onGuiCamerasAdded(GuiCameraList *cameras)
Slot to connect to the guiCamerasAdded() signal from a Project.
void onBundleSolutionInfoAdded(BundleSolutionInfo *bundleSolutionInfo)
Slot to connect to the bundleSolutionInfoAdded() signal from a project.
void clean()
Used to clean the ProjectItemModel of everything but the headers.
void insertRow(int row, ProjectItem *item)
Inserts a top-level item at the given row.
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Slot to connect to the selectionChanged() signal from a selection model.
void setItem(int row, ProjectItem *item)
Sets the item at the top-level row.
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.
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...
ProjectItem * itemFromIndex(const QModelIndex &index)
Returns the ProjectItem corresponding to a given QModelIndex.
ProjectItem * takeItem(int row)
Removes the top-level row and returns the removed item.
~ProjectItemModel()
Destructs the model.
QList< ProjectItem * > selectedBOSSImages()
ProjectItemModel::selectedBOSSImages.
void onControlListAdded(ControlList *controlList)
Slot to connect to the controlListAdded() signal from a Project.
void itemAdded(ProjectItem *)
This signal is emitted when a ProjectItem is added to the model.
ProjectItem * item(int row)
Returns the top-level item at the given row.
bool rejectName(QStringList &reserved, QString target)
Checks to see if we are adding a reserved name to the project (ex.
virtual void removeItems(QList< ProjectItem * > items)
Removes a list of items and their children from the model.
void onNameChanged(QString newName)
Slot to connect to the nameChanged() signal from a Project.
void onTemplatesAdded(TemplateList *templateList)
Slot connected to the templatesAdded() signal from a project.
void onControlAdded(Control *control)
Slot to connect to the controlAdded() signal from a project.
ProjectItem * addProject(Project *project)
Adds a Project to the model.
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 i...
ProjectItem * currentItem()
Returns the current item of the internal selection model.
void projectNameEdited(QString)
This signal is emitted when the project name is edited.
QModelIndex indexFromItem(const ProjectItem *item)
Returns the QModelIndex corresponding to a given ProjectItem.
void itemRemoved(ProjectItem *)
This signal is emitted when a ProjectItem is removed to the model.
QItemSelectionModel * m_selectionModel
The internal selection model.
void onRowsInserted(const QModelIndex &parent, int start, int end)
Slot to connect to the rowsInserted() signal from QAbstractItemModel.
virtual void removeItem(ProjectItem *item)
Removes an item and its children from the model.
void onRowsRemoved(const QModelIndex &parent, int start, int end)
Slot to connect to the rowsAboutToBeRemoved() signal from QAbstractItemModel.
void onShapesAdded(ShapeList *shapes)
Slot to connect to the shapesAdded() signal from a Project.
Qt::ItemFlags flags(const QModelIndex &index) const
This virtual method was added to handle changing the project name by double-clicking the project name...
QItemSelectionModel * selectionModel()
Returns the internal selection model.
Internalizes a list of shapes and allows for operations on the entire list.
void setName(QString newName)
Set the human-readable name of this shape list.
QString name() const
Get the human-readable name of this shape list.
List for holding TargetBodies.
QString type() const
Get the type of template in this TemplateList.
This is free and unencumbered software released into the public domain.
QSharedPointer< FileItem > FileItemQsp
A FileItem smart pointer.