Commit b6dbf9d3 authored by Tyler Wilson's avatar Tyler Wilson
Browse files

Added ProjectItemModel::selectedChildItems(), which returns a selected...

Added ProjectItemModel::selectedChildItems(), which returns a selected ProjectItem, and all children for that ProjectItem.  Also removed static var from SortFilterProxyModel::filterAcceptsRow(...)
parent bb999375
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -1327,6 +1327,7 @@ namespace Isis {

  void JigsawSetupDialog::createObservationSolveSettingsTreeView() {

     QList<ProjectItem *> selectedChildItems = m_project->directory()->model()->selectedChildItems();

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

@@ -1335,12 +1336,18 @@ namespace Isis {

    SortFilterProxyModel *osspm = new SortFilterProxyModel;
    osspm->setSourceModel(model);
    QList<ProjectItem*> selected = model->selectedItems();
    QList<ProjectItem*> selected = model->selectedChildItems();

    //selected.append(selectedItems[0]->parent() );

    qDebug() << "Selected Child items:  ";
    foreach(ProjectItem * item,selectedChildItems) {
      qDebug() << item->index().data(0).toString();

    }

    qDebug() << "Selected items:  ";
    foreach(ProjectItem * item,selected) {
    foreach(ProjectItem * item,selectedItems) {
      qDebug() << item->index().data(0).toString();

    }
+22 −0
Original line number Diff line number Diff line
@@ -171,6 +171,7 @@ namespace Isis {
    QItemSelection selection = selectionModel()->selection();
    QList<ProjectItem *> items;


    foreach ( QModelIndex index, selection.indexes() ) {
      items.append( itemFromIndex(index) );
    }
@@ -178,6 +179,26 @@ namespace Isis {
    return items;
  }

  QList<ProjectItem *> ProjectItemModel::selectedChildItems() {
    QItemSelection selection = selectionModel()->selection();
    QList<ProjectItem *> items;


    foreach ( QModelIndex ix, selection.indexes() ) {
      items.append( itemFromIndex(ix) );
      if (this->hasChildren(ix)) {
        int numChildren = this->rowCount(ix);
        for (int i = 0; i < numChildren;i++) {
          QModelIndex ixchild = this->index(i,0,ix);
          items.append(this->itemFromIndex(ixchild ));

          }
      }
    }

    return items;
  }


  /**
   * Returns the first item found that contains the given data in the given
@@ -697,6 +718,7 @@ namespace Isis {
        item->image()->displayProperties()->setSelected(false);
      }
    }

  }


+1 −0
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@ namespace Isis {

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

      void appendRow(ProjectItem *item);
      void clean();
+17 −11
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ namespace Isis {
  bool SortFilterProxyModel::filterAcceptsRow(int sourceRow,
                                                        const QModelIndex &sourceParent) const {

    static QList<QModelIndex> accepted = selectedIndices;
    //static QList<QModelIndex> accepted = selectedIndices;

    qDebug() << "filterAcceptsRow";
    bool accept(false);
@@ -98,27 +98,33 @@ namespace Isis {
           qDebug() << "Has children:  " << ix.data(0).toString();
           accept = true;
         }
         if (accepted.contains(ix)  && (this->sourceModel()->hasChildren(ix))) {


         if (selectedIndices.contains(ix)  && (this->sourceModel()->hasChildren(ix))) {
           qDebug() << "Accepted (has children):" << ix.data(0).toString();
           int numChildren = this->sourceModel()->rowCount(ix);
           for (int i = 0; i < numChildren;i++) {
           //int numChildren = this->sourceModel()->rowCount(ix);
           //for (int i = 0; i < numChildren;i++) {

             QModelIndex ixchild = this->sourceModel()->index(i,0,ix);
             accepted.append(ixchild);
             //QModelIndex ixchild = this->sourceModel()->index(i,0,ix);
             //accepted.append(ixchild);

             //}
           }
           }
         }
         if (accepted.contains(ix) ) {


         if (selectedIndices.contains(ix) ) {
           qDebug() << "Accepted:  " << ix.data(0).toString();
           accept = true;
         }

         qDebug() << "Rejected:  " << ix.data(0).toString();
       }

       return accept;
       }//end if (ix.isValid() )



    }
     return accept;
  }