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

Made a change to JigsawSetupDialog::createObservationSolveSettingsTreeView()...

Made a change to JigsawSetupDialog::createObservationSolveSettingsTreeView() to display subtree views of the main project tree view.
parent 8f53d00b
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
#include "Control.h"
#include "IString.h"
#include "MaximumLikelihoodWFunctions.h"
#include "ObservationSolveSettingsProxyModel.h"
#include "SubTreeProxyModel.h"
#include "Project.h"
#include "ProjectItemProxyModel.h"
#include "SpecialPixel.h"
@@ -1128,21 +1128,40 @@ namespace Isis {


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

    qDebug() << "JigsawSetupDialog::createObservationSolveSettingsTreeView()";

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

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


     //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???
    osspm->setRoot(item);    
    //osspm->setRoot(item);

    m_ui->treeView->setModel(osspm);

    //Set the root index to display the subtree we are interesting in.  This requires
    //computing the proxy index from the source model.
     m_ui->treeView->setRootIndex(osspm->mapFromSource(item->index() ));










    // Try to loop through the view here to add the "groups" so they aren't part of the model
+24 −13
Original line number Diff line number Diff line
#include "ObservationSolveSettingsProxyModel.h"
#include "SubTreeProxyModel.h"

#include <QAbstractItemModel>
#include <QIdentityProxyModel>
@@ -17,10 +17,11 @@ namespace Isis {
      QIdentityProxyModel(parent) {
  }


  // Returns the model index in the proxy model corresponding to the sourceIndex from the
  // source model
  QModelIndex SubTreeProxyModel::mapFromSource(const QModelIndex &sourceIndex) const {
    // return QIdentityProxyModel::mapFromSource(sourceIndex);
    qDebug() << "BEGIN mapFromSource(" << sourceIndex << ")";
    //qDebug() << "BEGIN mapFromSource(" << sourceIndex << ")";
    // QModelIndex parent = sourceIndex.parent();
    // int row = sourceIndex.row();
    // if (!sourceIndex.isValid()) {
@@ -34,18 +35,18 @@ namespace Isis {

    // First check to see if the source index is the proxy root
    if (sourceIndex == m_root) {
      qDebug() << "source exactly matches root already.";
      //qDebug() << "source exactly matches root already.";
      return createIndex(sourceIndex.row(), 0, sourceIndex.internalId());
    }

    // If the source index is a child of the proxy root, one if its ancestors IS proxy root
    QModelIndex ancestorIndex = sourceIndex.parent();
    QString n = "";
    qDebug() << ancestorIndex;
    //qDebug() << ancestorIndex;
    while (ancestorIndex.isValid() && ancestorIndex != m_root) {
      ancestorIndex = ancestorIndex.parent();
      n += "\t";
      qDebug() << n << ancestorIndex;
      //qDebug() << n << ancestorIndex;
    }
    if (ancestorIndex.isValid()) {
      return createIndex(sourceIndex.row(), 0, sourceIndex.internalId());
@@ -93,7 +94,8 @@ namespace Isis {
    // return QIdentityProxyModel::mapFromSource(sourceIndex);
  }


  //Returns the model index in the source that corresponds to the proxy index
  //in the proxy model
  QModelIndex SubTreeProxyModel::mapToSource(const QModelIndex &proxyIndex) const {
    // return proxyIndex;
    return QIdentityProxyModel::mapToSource(proxyIndex);
@@ -114,12 +116,12 @@ namespace Isis {

    
    if (persistentIndex.isValid()) {
      qDebug() << "persistent index is valid: " << persistentIndex;
      qDebug() << "parent index: " << persistentIndex.parent();
      //qDebug() << "persistent index is valid: " << persistentIndex;
      //qDebug() << "parent index: " << persistentIndex.parent();
      m_root = persistentIndex;
    }
    else {
      qDebug() << "persistent index NOT valid.";
      //qDebug() << "persistent index NOT valid.";
      m_root = QPersistentModelIndex(QModelIndex());
    }

@@ -134,13 +136,22 @@ namespace Isis {
  bool SubTreeProxyModel::setRoot(const QStandardItem *item) {
    qDebug() << "setRoot() item->index() " << item->index();
    qDebug() << "\titem->parent()->index() " << item->parent()->index();
    m_root = QPersistentModelIndex(item->index());
    qDebug() << "Perisentent Model Index ROOT: " << m_root << " is valid ? " << (m_root.isValid() ? "yes" : "no");
    //m_root = QPersistentModelIndex(item->index());

    QAbstractItemModel::removeRows(1,2,item->index());




    //qDebug() << "Perisentent Model Index ROOT: " << m_root << " is valid ? " << (m_root.isValid() ? "yes" : "no");
    qDebug() << "Persistent's PARENT: " << m_root.parent();
    if (m_root.isValid()) {
      qDebug() <<"m_root is valid";
      return true;
    }
    else {
      qDebug() <<"m_root is not valid";

      return false;
    }
  }
+2 −2
Original line number Diff line number Diff line
#ifndef ObservationSolveSettingsProxyModel_h
#define ObservationSolveSettingsProxyModel_h
#ifndef SubtreeProxyModel_h
#define SubTreeProxyModel_h

#include <QIdentityProxyModel>
#include <QPersistentModelIndex>