Commit aff69673 authored by Ian Humphrey's avatar Ian Humphrey
Browse files

removed commented code from SubTreeProxyModel

parent def12d38
Loading
Loading
Loading
Loading
+0 −36
Original line number Diff line number Diff line
@@ -34,14 +34,6 @@ namespace Isis {
  // 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 << ")";
    // QModelIndex parent = sourceIndex.parent();
    // int row = sourceIndex.row();
    // if (!sourceIndex.isValid()) {
    //   return m_root;
    // }

    // check if the model index corresponds to the invisible root item in source model
    if (sourceIndex == 
            static_cast<QStandardItemModel *>(sourceModel())->invisibleRootItem()->index()) {
@@ -52,22 +44,16 @@ namespace Isis {

    // First check to see if the source index is the proxy root
    if (sourceIndex == m_root) {
      //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;
    while (ancestorIndex.isValid() && ancestorIndex != m_root) {
      ancestorIndex = ancestorIndex.parent();
      n += "\t";
      //qDebug() << n << ancestorIndex;
    }
    if (ancestorIndex.isValid()) {
      return createIndex(sourceIndex.row(), 0, sourceIndex.internalId());
      // return QModelIndex(parent.child(row));
    }
    else {
      return QModelIndex();
@@ -78,38 +64,20 @@ namespace Isis {
  //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);
  }


  void SubTreeProxyModel::setSourceModel(QAbstractItemModel *newSourceModel) {
    // QVariant data = newSourceModel->data(newSourceModel->index(0,0,QModelIndex()));
    // qDebug() << data;
    // qDebug() << "can convert to project item: " << data.canConvert<ProjectItem *>();
    qDebug() << typeid(*newSourceModel).name();
    
    // QStandardItem *item = static_cast<QStandardItemModel *>(newSourceModel)->invisibleRootItem();
    QPersistentModelIndex persistentIndex(newSourceModel->index(0,0,QModelIndex()));
    // QPersistentModelIndex persistentIndex(item->index());
    // qDebug() << "root item: " << item;
    // qDebug() << "root item index: " << item->index();


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

    // // qDebug() << "can convert to qstandarditem: " << data.canConvert<QStandardItem *>();
    // if (data.canConvert<ProjectItem *>()) {
    //  m_root = data.value<ProjectItem *>();
    // }
    QIdentityProxyModel::setSourceModel(newSourceModel);
  }

@@ -117,14 +85,10 @@ namespace Isis {
  bool SubTreeProxyModel::setRoot(const QStandardItem *item) {
    QAbstractItemModel::removeRows(1,2,item->index());

    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;
    }
  }