21 #include "IsisDebug.h" 25 #include <QItemSelection> 27 #include <QMessageBox> 29 #include <QModelIndex> 32 #include <QRegExpValidator> 33 #include <QStandardItemModel> 39 #include "ControlList.h" 41 #include "GuiCameraList.h" 42 #include "ImageList.h" 45 #include "ShapeList.h" 46 #include "TargetBodyList.h" 59 const QItemSelection &) ),
62 connect(
this, SIGNAL(rowsInserted(
const QModelIndex &,
int,
int)),
65 connect(
this, SIGNAL(rowsAboutToBeRemoved(
const QModelIndex &,
int,
int)),
93 Qt::DropAction action,
95 const QModelIndex &parent)
const {
121 connect(project, SIGNAL( nameChanged(QString) ),
125 connect(project, SIGNAL( controlAdded(
Control *) ),
127 connect(project, SIGNAL( controlListAdded(
ControlList *) ),
129 connect(project, SIGNAL( imagesAdded(
ImageList *) ),
131 connect(project, SIGNAL( shapesAdded(
ShapeList *) ),
135 connect(project, SIGNAL( templatesAdded(
TemplateList *)),
175 foreach ( QModelIndex index, selection.indexes() ) {
193 QModelIndexList indices = selection.indexes();
196 if (indices.size() == 0) {
198 items.append(imageRoot);
199 for (
int i = 0; i < imageRoot->rowCount(); i++) {
201 items.append(imglistItem);
202 for (
int j = 0; j < imglistItem->rowCount(); j++) {
205 items.append(imgItem);
213 foreach ( QModelIndex ix, indices ) {
221 items.append(
item );
230 if (this->hasChildren(ix)) {
234 bool childrenSelected(
false);
235 int numChildren = this->rowCount(ix);
238 for (
int i = 0; i < numChildren;i++) {
239 QModelIndex ixchild = this->index(i,0,ix);
240 if (indices.contains(ixchild) ){
241 childrenSelected=
true;
246 if (childrenSelected) {
247 for (
int i =0;i < numChildren;i++) {
248 QModelIndex ixchild = this->index(i,0,ix);
249 if (indices.contains(ixchild))
250 items.append(this->itemFromIndex(ixchild ));
256 for (
int i =0;i < numChildren;i++) {
257 QModelIndex ixchild = this->index(i,0,ix);
270 if (!items.contains(parent)){
271 items.append(parent);
279 if (!items.contains(grandparent)) {
280 items.append(grandparent);
305 for (
int i=0; i<rowCount(); i++) {
333 if (
item->hasChildren()) {
334 for (
int row = (
item->rowCount() - 1); row >= 0; row--) {
341 removeRow(
item->row(), parentItem->index());
344 removeRow(
item->row());
367 QStandardItemModel::appendRow(
item);
379 return QStandardItemModel::indexFromItem(
item);
390 QStandardItemModel::insertRow(row,
item);
402 return static_cast<ProjectItem *
>( QStandardItemModel::item(row) );
414 return static_cast<ProjectItem *
>( QStandardItemModel::itemFromIndex(index) );
425 QStandardItemModel::setItem(row,
item);
439 if ( items.isEmpty() ) {
443 return static_cast<ProjectItem *
>( items.first() );
460 for (
int i=0; i<rowCount(); i++) {
462 if (projectItem->
project() == project) {
463 projectItem->setText(newName);
482 m_reservedNames.append(bundleSolutionInfo->
name() );
488 for (
int i=0; i<rowCount(); i++) {
490 if (projectItem->
project() == project) {
491 for (
int j=0; j < projectItem->rowCount(); j++) {
493 if (resultsItem->text() ==
"Results") {
501 QIcon(
FileName(
"$base/icons/office-chart-pie.png")
507 QIcon(
FileName(
"$base/icons/office-chart-pie.png")
513 QIcon(
FileName(
"$base/icons/office-chart-pie.png")
519 QIcon(
FileName(
"$base/icons/office-chart-pie.png")
539 if (!project) {
return; }
543 for (
int i = 0; i<rowCount(); i++) {
545 if (projectItem->
project() == project) {
548 for (
int j = 0; j < projectItem->rowCount(); j++) {
550 if (templatesItem->text() ==
"Templates"){
553 QString type = templateList->
type();
554 for (
int k = 0; k < templatesItem->rowCount(); k++) {
556 if (templateType->text().toLower() == type) {
577 m_reservedNames.append(control->
id() );
583 for (
int i=0; i<rowCount(); i++) {
585 if (projectItem->
project() == project) {
586 for (
int j=0; j < projectItem->rowCount(); j++) {
588 if (controlsItem->text() ==
"Control Networks") {
589 for (
int k=0; k < controlsItem->rowCount(); k++) {
592 if ( controlList && controlList->contains(control) ) {
616 m_reservedNames.append(controlList->
name() );
622 for (
int i=0; i<rowCount(); i++) {
624 if (projectItem->
project() == project) {
625 for (
int j=0; j < projectItem->rowCount(); j++) {
627 if (controlsItem->text() ==
"Control Networks") {
647 m_reservedNames.append(imageList->
name() );
652 for (
int i=0; i<rowCount(); i++) {
654 if (projectItem->
project() == project) {
655 for (
int j=0; j < projectItem->rowCount(); j++) {
657 if (imagesItem->text() ==
"Images") {
676 m_reservedNames.append(shapes->
name());
681 for (
int i=0; i<rowCount(); i++) {
683 if (projectItem->
project() == project) {
684 for (
int j=0; j < projectItem->rowCount(); j++) {
686 if (shapesItem->text() ==
"Shapes") {
705 m_reservedNames.append(targets->
name() );
711 for (
int i=0; i<rowCount(); i++) {
713 if (projectItem->
project() == project) {
714 for (
int j=0; j < projectItem->rowCount(); j++) {
716 if (targetsItem->text() ==
"Target Body") {
719 for (
int k=0; k < targetsItem->rowCount(); k++) {
746 m_reservedNames.append(cameras->
name() );
752 for (
int i=0; i<rowCount(); i++) {
754 if (projectItem->
project() == project) {
755 for (
int j=0; j < projectItem->rowCount(); j++) {
757 if (camerasItem->text() ==
"Sensors") {
760 for (
int k=0; k < camerasItem->rowCount(); k++) {
788 const QItemSelection &deselected) {
790 foreach ( QModelIndex index, selected.indexes() ) {
801 foreach ( QModelIndex index, deselected.indexes() ) {
825 for (
int row=start; row <= end; row++) {
826 QModelIndex newIndex = index(row, 0, parent);
843 for (
int row=start; row <= end; row++) {
844 QModelIndex newIndex = index(row, 0, parent);
870 QString name = value.toString();
872 bool rejected =
rejectName(m_reservedNames,name);
875 QMessageBox nameRejected;
876 nameRejected.setText(
"That name is already in use within this project.");
881 m_reservedNames.append(name);
907 else if (
item->isTemplate() && role == Qt::EditRole) {
928 return Qt::ItemIsEditable | QStandardItemModel::flags(index);
944 QRegExpValidator valid;
945 QValidator::State state;
947 foreach (QString name, reserved) {
951 state = valid.validate(target,pos);
965 for (
int i=0; i<rowCount(); i++) {
968 for (
int j=0; j < projectItem->rowCount(); j++) {
969 if (projectItem->hasChildren()) {
973 if (subProjectItem->text() ==
"Templates") {
974 if (subProjectItem->hasChildren()) {
975 for (
int k=0; k < subProjectItem->rowCount(); k++) {
977 while (tempProjectItem->hasChildren()) {
984 while (subProjectItem->hasChildren()) {
QModelIndex indexFromItem(const ProjectItem *item)
Returns the QModelIndex corresponding to a given ProjectItem.
This represents an ISIS control net in a project-based GUI interface.
Internalizes a list of shapes and allows for operations on the entire list.
void insertRow(int row, ProjectItem *item)
Inserts a top-level item at the given 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 isImageList() const
Returns true if an ImageList is stored in the data of the item.
void itemAdded(ProjectItem *)
This signal is emitted when a ProjectItem is added to the model.
ProjectItem * takeItem(int row)
Removes the top-level row and returns the removed item.
QString name() const
Get the human-readable name of this image list.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
bool isShapeList() const
Returns true if an ShapeList is stored in the data of the item.
Internalizes a list of images and allows for operations on the entire list.
void onControlAdded(Control *control)
Slot to connect to the controlAdded() signal from a project.
bool rejectName(QStringList &reserved, QString target)
Checks to see if we are adding a reserved name to the project (ex.
GuiCameraQsp guiCamera() const
Returns the GuiCameraQsp stored in the data of the item.
The main project for ipce.
bool isImage() const
Returns true if an Image is stored in the data of the item.
void appendRow(ProjectItem *item)
Appends an item to the children of this item.
QSharedPointer< FileItem > FileItemQsp
A FileItem smart pointer.
File name manipulation and expansion.
ProjectItem * itemFromIndex(const QModelIndex &index)
Returns the ProjectItem corresponding to a given QModelIndex.
Container class for BundleAdjustment results.
ControlList * controlList() const
Returns the ControlList stored in the data of the item.
QString savedResidualsFilename()
Returns filename of output bundle residuals csv file.
void cleanProject(bool)
This signal is emitted whrn a ProjectItem's name is changed.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Maintains a list of Controls so that control nets can easily be copied from one Project to another...
void setName(QString newName)
Set the human-readable name of this control list.
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...
bool isProject() const
Returns true if a Project is stored in the data of the item.
ProjectItem * currentItem()
Returns the current item of the internal selection model.
void onImagesAdded(ImageList *images)
Slot to connect to the imagesAdded() signal from a Project.
List for holding TargetBodies.
void setSelected(bool)
Change the selected state associated with this cube.
QString name() const
Returns the name of the bundle.
Project * project() const
Returns the Project stored in the data of the item.
void onControlListAdded(ControlList *controlList)
Slot to connect to the controlListAdded() signal from a Project.
QString savedPointsFilename()
Returns filename of output bundle points csv file.
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. ...
void onBundleSolutionInfoAdded(BundleSolutionInfo *bundleSolutionInfo)
Slot to connect to the bundleSolutionInfoAdded() signal from a project.
void onRowsRemoved(const QModelIndex &parent, int start, int end)
Slot to connect to the rowsAboutToBeRemoved() signal from QAbstractItemModel.
ProjectItem * parent() const
Returns the parent item of this item.
void onTargetsAdded(TargetBodyList *targets)
Slot to connect to the targetsAdded() signal from a Project.
ImageList * imageList() const
Returns the ImageList stored in the data of the item.
void setName(QString newName)
Set the human-readable name of this shape list.
QString name() const
Get the human-readable name of this gui cameray list.
bool isBundleSolutionInfo() const
Returns true if a BundleSolutionInfo is stored in the data of the item.
void projectNameEdited(QString)
This signal is emitted when the project name is edited.
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...
void setName(QString name)
Sets the name of the bundle.
void itemRemoved(ProjectItem *)
This signal is emitted when a ProjectItem is removed to the model.
virtual void removeItems(QList< ProjectItem *> items)
Removes a list of items and their children from the model.
void appendRow(ProjectItem *item)
Appends a top-level item to the model.
QItemSelectionModel * selectionModel()
Returns the internal selection model.
void clean()
Used to clean the ProjectItemModel of everything but the headers.
void onGuiCamerasAdded(GuiCameraList *cameras)
Slot to connect to the guiCamerasAdded() signal from a Project.
TargetBodyQsp targetBody() const
Returns the TargetBodyQsp stored in the data of the item.
BundleSolutionInfo * bundleSolutionInfo() const
Returns the BundleSolutionInfo stored in the data of the item.
virtual void removeItem(ProjectItem *item)
Removes an item and its children from the model.
Image * image() const
Returns the Image stored in the data of the item.
ImageDisplayProperties * displayProperties()
Get the display (GUI) properties (information) associated with this image.
ProjectItem * item(int row)
Returns the top-level item at the given row.
void onNameChanged(QString newName)
Slot to connect to the nameChanged() signal from a Project.
~ProjectItemModel()
Destructs the model.
List of GuiCameras saved as QSharedPointers.
Qt::ItemFlags flags(const QModelIndex &index) const
This virtual method was added to handle changing the project name by double-clicking the project name...
void setItem(int row, ProjectItem *item)
Sets the item at the top-level row.
void onRowsInserted(const QModelIndex &parent, int start, int end)
Slot to connect to the rowsInserted() signal from QAbstractItemModel.
QString name() const
Get the human-readable name of this control list.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
ProjectItem * child(int row) const
Returns the child item at a given row.
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
Slot to connect to the selectionChanged() signal from a selection model.
bool isControlList() const
Returns true if a ControlList is stored in the data of the item.
QList< ProjectItem * > selectedItems()
Returns a list of the selected items of the internal selection model.
void onTemplatesAdded(TemplateList *templateList)
Slot connected to the templatesAdded() signal from a project.
Represents an item of a ProjectItemModel in Qt's model-view framework.
QString name() const
Get the human-readable name of this target body list.
QString type() const
Get the type of template in this TemplateList.
QList< ProjectItem * > selectedBOSSImages()
ProjectItemModel::selectedBOSSImages.
Namespace for ISIS/Bullet specific routines.
QString name() const
Get the human-readable name of this shape list.
QString savedBundleOutputFilename()
Returns bundleout text filename.
A container for a filename to be represented as a ProjectItem on the project tree.
QItemSelectionModel * m_selectionModel
The internal selection model.
QString id() const
Access the unique ID associated with this Control.
ProjectItemModel(QObject *parent=0)
Constructs an empty model.
void setName(QString newName)
Set the human-readable name of this image list.
QString savedImagesFilename()
Returns filename of output bundle images csv file.
void onShapesAdded(ShapeList *shapes)
Slot to connect to the shapesAdded() signal from a Project.
ProjectItem * addProject(Project *project)
Adds a Project to the model.
void setClean(bool value)
Function to change the clean state of the project.
ShapeList * shapeList() const
Returns the ShapeList stored in the data of the item.