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

refactor ObservationSolveSettingsProxyModel to SubTreeProxyModel

parent cd461838
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -13,11 +13,12 @@

namespace Isis {

  ObservationSolveSettingsProxyModel::ObservationSolveSettingsProxyModel(QObject *parent) : QIdentityProxyModel(parent) {
  SubTreeProxyModel::SubTreeProxyModel(QObject *parent) :
      QIdentityProxyModel(parent) {
  }


  QModelIndex ObservationSolveSettingsProxyModel::mapFromSource(const QModelIndex &sourceIndex) const {
  QModelIndex SubTreeProxyModel::mapFromSource(const QModelIndex &sourceIndex) const {
    // return QIdentityProxyModel::mapFromSource(sourceIndex);
    qDebug() << "BEGIN mapFromSource(" << sourceIndex << ")";
    // QModelIndex parent = sourceIndex.parent();
@@ -26,6 +27,11 @@ namespace Isis {
    //   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()) {
      return createIndex(sourceIndex.row(), 0, sourceIndex.internalId());
    }

    // First check to see if the source index is the proxy root
    if (sourceIndex == m_root) {
      qDebug() << "source exactly matches root already.";
@@ -88,13 +94,13 @@ namespace Isis {
  }


  QModelIndex ObservationSolveSettingsProxyModel::mapToSource(const QModelIndex &proxyIndex) const {
  QModelIndex SubTreeProxyModel::mapToSource(const QModelIndex &proxyIndex) const {
    // return proxyIndex;
    return QIdentityProxyModel::mapToSource(proxyIndex);
  }


  void ObservationSolveSettingsProxyModel::setSourceModel(QAbstractItemModel *newSourceModel) {
  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 *>();
@@ -125,7 +131,7 @@ namespace Isis {
  }


  bool ObservationSolveSettingsProxyModel::setRoot(const QStandardItem *item) {
  bool SubTreeProxyModel::setRoot(const QStandardItem *item) {
    qDebug() << "setRoot() item->index() " << item->index();
    qDebug() << "\titem->parent()->index() " << item->parent()->index();
    m_root = QPersistentModelIndex(item->index());
+3 −3
Original line number Diff line number Diff line
@@ -12,11 +12,11 @@ class QVariant;

namespace Isis {
  
  class ObservationSolveSettingsProxyModel : public QIdentityProxyModel {
  class SubTreeProxyModel : public QIdentityProxyModel {
    Q_OBJECT

    public:
      explicit ObservationSolveSettingsProxyModel(QObject *parent = 0);
      explicit SubTreeProxyModel(QObject *parent = 0);

      QModelIndex mapFromSource(const QModelIndex &sourceIndex) const Q_DECL_OVERRIDE;
      QModelIndex mapToSource(const QModelIndex &proxyIndex) const Q_DECL_OVERRIDE;