Isis 3 Programmer Reference
ProjectItemProxyModel.h
1 #ifndef ProjectItemProxyModel_h
2 #define ProjectItemProxyModel_h
3 
10 /* SPDX-License-Identifier: CC0-1.0 */
11 
12 #include <QList>
13 #include <QMap>
14 
15 #include "ProjectItem.h"
16 #include "ProjectItemModel.h"
17 
18 class QItemSelection;
19 template <typename T> class QList;
20 class QMimeData;
21 class QModelIndex;
22 class QStandardItem;
23 
24 namespace Isis {
71 
72  Q_OBJECT
73 
74  public:
75  ProjectItemProxyModel(QObject *parent = 0);
76 
77  QModelIndex mapIndexFromSource(const QModelIndex &sourceIndex);
78  QModelIndex mapIndexToSource(const QModelIndex &proxyIndex);
79 
80  QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection);
81  QItemSelection mapSelectionToSource(const QItemSelection &proxySelection);
82 
85 
87 
90 
91  virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
92  int row, int column, const QModelIndex &parent) const;
93  virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
94  int row, int column, const QModelIndex &parent);
95 
96  signals:
97  // This signal was added to speed up the Footprint2DView. Previously images were added one at a
98  // time which was extremely slow. This not the ideal handling, but without re-writing
99  // ProjectItemModel and ProjectItemProxyModel to add insertRows method so that beginInsertRows
100  // and endInsertRows are called which would automatically emit the signal rowsInserted after
101  // alls items are inserted into the model rather than calling after each row that is inserted.
102  void itemsAdded();
103  void itemRemoved(ProjectItem *);
104 
105  public slots:
106  ProjectItem *addItem(ProjectItem *sourceItem);
107  void addItems(QList<ProjectItem *> sourceItems);
108 
109  protected slots:
110  void updateItem(ProjectItem *sourceItem);
111  void updateProxyCurrent();
112  void updateSourceCurrent();
113  void updateProxySelection();
114  void updateSourceSelection();
115 
116  protected:
117  ProjectItem *addChild(ProjectItem *sourceItem, ProjectItem *parentItem);
118 
119  private slots:
121 
122  private:
124  QMap<ProjectItem *, ProjectItem *> m_sourceProxyMap;
126  };
127 }
128 #endif
Isis::ProjectItemModel
Provides access to data stored in a Project through Qt's model-view framework.
Definition: ProjectItemModel.h:132
Isis::ProjectItemProxyModel::m_sourceModel
ProjectItemModel * m_sourceModel
The source model. Map of items from the source model to the proxy model.
Definition: ProjectItemProxyModel.h:123
Isis::ProjectItemProxyModel::mapSelectionFromSource
QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection)
Returns a QItemSelection of items in the proxy model that corresponds with a QItemSelection of items ...
Definition: ProjectItemProxyModel.cpp:87
Isis::ProjectItemProxyModel::dropMimeData
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Adds the data (selected items) from the source model to the proxy model.
Definition: ProjectItemProxyModel.cpp:437
Isis::ProjectItemProxyModel::updateProxyCurrent
void updateProxyCurrent()
Slot that updates the current item in the proxy model only if it is different than the corresponding ...
Definition: ProjectItemProxyModel.cpp:289
Isis::ProjectItemProxyModel::addItems
void addItems(QList< ProjectItem * > sourceItems)
Adds a list of items to the proxy model.
Definition: ProjectItemProxyModel.cpp:195
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::ProjectItemProxyModel::mapIndexToSource
QModelIndex mapIndexToSource(const QModelIndex &proxyIndex)
Returns the QModelIndex of an item in the souce model that corresponds with the QModelIndex of an ite...
Definition: ProjectItemProxyModel.cpp:66
Isis::ProjectItemProxyModel::addChild
ProjectItem * addChild(ProjectItem *sourceItem, ProjectItem *parentItem)
Creates an item in the proxy model corresponding to an item in the source model as a child of a paren...
Definition: ProjectItemProxyModel.cpp:351
Isis::ProjectItemProxyModel::updateSourceCurrent
void updateSourceCurrent()
Slot that updates the current item in the proxy model only if it is different than the corresponding ...
Definition: ProjectItemProxyModel.cpp:302
Isis::ProjectItemProxyModel
Allows access to items in a ProjectItemModel through a proxy model.
Definition: ProjectItemProxyModel.h:70
Isis::ProjectItemProxyModel::sourceModel
ProjectItemModel * sourceModel()
Returns the source model.
Definition: ProjectItemProxyModel.cpp:266
Isis::ProjectItemProxyModel::onItemChanged
void onItemChanged(QStandardItem *item)
Signal to connect to the itemChanged() signal from a ProjectItemModel.
Definition: ProjectItemProxyModel.cpp:402
Isis::ProjectItemProxyModel::mapItemToSource
ProjectItem * mapItemToSource(ProjectItem *proxyItem)
Returns the ProjectItem in the source model that corresponds with a ProjectItem in the source model.
Definition: ProjectItemProxyModel.cpp:147
Isis::ProjectItemProxyModel::mapSelectionToSource
QItemSelection mapSelectionToSource(const QItemSelection &proxySelection)
Returns a QItemSelection of items in the source model that corresponds with a QItemSelection of itesm...
Definition: ProjectItemProxyModel.cpp:112
Isis::ProjectItemModel::item
ProjectItem * item(int row)
Returns the top-level item at the given row.
Definition: ProjectItemModel.cpp:389
Isis::ProjectItemProxyModel::removeItem
void removeItem(ProjectItem *item)
Removes an item and its children from the proxy model.
Definition: ProjectItemProxyModel.cpp:208
Isis::ProjectItemProxyModel::mapIndexFromSource
QModelIndex mapIndexFromSource(const QModelIndex &sourceIndex)
Returns the QModelIndex of an item in the proxy model that corresponds with the QModelIndex of an ite...
Definition: ProjectItemProxyModel.cpp:45
Isis::ProjectItemProxyModel::updateProxySelection
void updateProxySelection()
Slot that updates the selection in the proxy model only if it is different than the corresponding sel...
Definition: ProjectItemProxyModel.cpp:315
Isis::ProjectItemProxyModel::mapItemFromSource
ProjectItem * mapItemFromSource(ProjectItem *sourceItem)
Returns the ProjectItem in the proxy model that corresponds with a ProjectItem in the source model.
Definition: ProjectItemProxyModel.cpp:134
Isis::ProjectItemProxyModel::setSourceModel
void setSourceModel(ProjectItemModel *sourceModel)
Sets the source model.
Definition: ProjectItemProxyModel.cpp:224
Isis::ProjectItemProxyModel::updateSourceSelection
void updateSourceSelection()
Slot that updates the selection in the source model only if it is different than the corresponding se...
Definition: ProjectItemProxyModel.cpp:328
Isis::ProjectItemProxyModel::addItem
ProjectItem * addItem(ProjectItem *sourceItem)
Adds an item and its children to the proxy model.
Definition: ProjectItemProxyModel.cpp:167
Isis::ProjectItemProxyModel::updateItem
void updateItem(ProjectItem *sourceItem)
Given an item in the source model, this method changes the data of the corresponding item in the prox...
Definition: ProjectItemProxyModel.cpp:278
Isis::ProjectItemProxyModel::canDropMimeData
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
Returns true.
Definition: ProjectItemProxyModel.cpp:418
QMap
This is free and unencumbered software released into the public domain.
Definition: CubeIoHandler.h:22
QObject
QStandardItem
Isis::ProjectItemProxyModel::ProjectItemProxyModel
ProjectItemProxyModel(QObject *parent=0)
Constructs the proxy model.
Definition: ProjectItemProxyModel.cpp:30
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::ProjectItem
Represents an item of a ProjectItemModel in Qt's model-view framework.
Definition: ProjectItem.h:134