Unverified Commit 140777e4 authored by Tyler Wilson's avatar Tyler Wilson Committed by GitHub
Browse files

Merge pull request #260 from twilson271828/ipceBundleWindow

Created SortFilterProxyModel class
parents a6cbc6c9 995d51ed
Loading
Loading
Loading
Loading
+18 −22
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
#include "ProjectItem.h"
#include "ProjectItemProxyModel.h"
#include "SpecialPixel.h"
#include "SubTreeProxyModel.h"
#include "SortFilterProxyModel.h"
#include "ui_JigsawSetupDialog.h"

namespace Isis {
@@ -1326,39 +1326,31 @@ namespace Isis {


  void JigsawSetupDialog::createObservationSolveSettingsTreeView() {
    // Proof-of-

    QList<ProjectItem *> selectedItems = m_project->directory()->model()->selectedItems();
    QList<ProjectItem *> selectedBOSSItems = m_project->directory()->model()->selectedBOSSImages();

    foreach(ProjectItem *item,selectedItems){
      qDebug() << "Selected Item:  " << item->text();
    }
    qDebug() << "JigsawSetupDialog::createObservationSolveSettingsTreeView()";

//    m_ui->treeView->setModel((QAbstractItemModel*)(m_project->directory()->model()));
    ProjectItemModel *model = m_project->directory()->model();

    SubTreeProxyModel *osspm = new SubTreeProxyModel;
    SortFilterProxyModel *osspm = new SortFilterProxyModel;
    osspm->setSourceModel(model);

    //osspm->setDynamicSortFilter(true);
    osspm->setSelectedItems(selectedBOSSItems );
    m_ui->treeView->setModel(osspm);

     //QModelIndex SubTreeProxyModel::mapFromSource(const QModelIndex &sourceIndex)
    // find the root "Images" and set it in the proxy
    //QStandardItem *item = model->invisibleRootItem()->child(0)->child(1);
    //qDebug() << "ITEM: " << item << ", " << item->text();
    //qDebug() << "PARENT: " << item->parent() << ", " << item->parent()->text();


    // i think source model tries to add top root item, which is invalid???

    m_ui->treeView->setModel(osspm);
         ProjectItem *imgRoot = model->findItemData(QVariant("Images"),0);
         if (imgRoot) {

    //Set the root index to display the subtree we are interested in.  This requires
    //computing the proxy index from the source model.
    if (selectedItems.count() > 0) {
      m_ui->treeView->setRootIndex(osspm->mapFromSource(selectedItems[0]->index() ));
            m_ui->treeView->setRootIndex(osspm->mapFromSource(imgRoot->index()));
         }
         else {
          m_ui->treeView->setRootIndex(QModelIndex());
         }
    

    // Generate observation numbers for the images
    QStringList observationNumbers;

@@ -1373,9 +1365,12 @@ namespace Isis {
    // Add apply button to the tab view
    // set the text to bold?


  }




// Commented out since it contains some unimplemented functions (i.e. pseudo-code)

  void JigsawSetupDialog::on_applySettingsPushButton_clicked() {}
@@ -1465,4 +1460,5 @@ namespace Isis {
  // void JigsawSetupDialog::generateObservationNumbers() {

  // }

}
+4 −0
Original line number Diff line number Diff line
@@ -66,6 +66,10 @@ namespace Isis {
   *   @history 2018-06-21 Ian Humphrey - Added on_applySettingsPushButtonClicked() to listen for when
   *                           the apply button is clicked on the observation solve settings tab.
   *                           References #497.
   *   @history 2018-06-21 Tyler Wilson - Added support in the Bundle Observations Solve Settings
   *                           (BOSS) tab for displaying user-selected images from the main Project
   *                           treeview.  All changes were made in the
   *                           createObservationSolveSettingsTreeView() function.  References #497.
   */

  class JigsawSetupDialog : public QDialog {
+67 −0
Original line number Diff line number Diff line
@@ -171,12 +171,78 @@ namespace Isis {
    QItemSelection selection = selectionModel()->selection();
    QList<ProjectItem *> items;


    foreach ( QModelIndex index, selection.indexes() ) {
      items.append( itemFromIndex(index) );
    }

    return items;
  }
  /**
   * @brief ProjectItemModel::selectedBOSSImages
   * @return 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.
   */
  QList<ProjectItem *> ProjectItemModel::selectedBOSSImages() {

    QItemSelection selection = selectionModel()->selection();
    QList<ProjectItem *> items;

    //Query the selected items to see if they have children
    foreach ( QModelIndex ix, selection.indexes() ) {

      ProjectItem *item = this->itemFromIndex(ix);

      //Anything that is not an image or an image list does
      //not make sense to display in the BOSS treeview tab,
      //so we need to exclude these items.
      if (item->isImageList() || item->isImage() ) {
        items.append( item );
      }
      else {
        return items;
      }

      //If the selected ImageList has children, include all of the children.
      if (this->hasChildren(ix)) {

        //If the node has children, loop through all of them
        //and add them to selected items.
        int numChildren = this->rowCount(ix);
        for (int i = 0; i < numChildren;i++) {
          QModelIndex ixchild = this->index(i,0,ix);
          items.append(this->itemFromIndex(ixchild ));
          }  //end for
      }//end if

      //Append the parent of any selected child.  This is so
      //the children aren't hanging on the tree without
      //a collapsible parent node.
      if( item->parent() ->hasChildren()) {
        ProjectItem * parent = item->parent();
        if (!items.contains(parent)){
          items.append(parent);
        }// end inner if
      }//end outer if
      //Also include the grandparent.  This handles the event
      //that we may have multiple image lists selected to the treeview
      //and we need a grandparent node attached to group them under.
      if (this->itemFromIndex(ix)->parent()->parent() ){
        ProjectItem *grandparent = this->itemFromIndex(ix)->parent()->parent();
        if (!items.contains(grandparent)) {
          items.append(grandparent);
        } //end inner if

      } //end outer if

  }// end foreach

    return items;

  }


  /**
@@ -697,6 +763,7 @@ namespace Isis {
        item->image()->displayProperties()->setSelected(false);
      }
    }

  }


+7 −0
Original line number Diff line number Diff line
@@ -130,6 +130,11 @@ namespace Isis {
   *                           bundleoutput.txt (Summary) file to the BundleSolution Statistics
   *                           node. Also changed the name of the Images node under Statistics to
   *                           Image to prevent Import Images to appear on it's context menu.
   *   @history 2018-06-21 Tyler Wilson - Added the function selectedBOSSImages().  This is a
   *                           refinement of selectedItems and is used by the JigsawSetupDialog
   *                           Bundle Observation Solve Settings (BOSS) tab when displaying a
   *                           subset of user-selected images.  References #497
   *
   */
  class ProjectItemModel : public QStandardItemModel {

@@ -155,6 +160,8 @@ namespace Isis {

      ProjectItem *currentItem();
      QList<ProjectItem *> selectedItems();
      QList<ProjectItem *> selectedBOSSImages();


      void appendRow(ProjectItem *item);
      void clean();
+7 −0
Original line number Diff line number Diff line
ifeq ($(ISISROOT), $(BLANK))
.SILENT:
error:
	echo "Please set ISISROOT";
else
	include $(ISISROOT)/make/isismake.objs
endif
 No newline at end of file
Loading