Isis 3 Developer Reference
ProjectItemProxyModel.h
Go to the documentation of this file.
1 #ifndef ProjectItemProxyModel_h
2 #define ProjectItemProxyModel_h
3 
26 #include <QList>
27 #include <QMap>
28 
29 #include "ProjectItem.h"
30 #include "ProjectItemModel.h"
31 
32 class QItemSelection;
33 template <typename T> class QList;
34 class QMimeData;
35 class QModelIndex;
36 class QStandardItem;
37 
38 namespace Isis {
85 
86  Q_OBJECT
87 
88  public:
89  ProjectItemProxyModel(QObject *parent = 0);
90 
91  QModelIndex mapIndexFromSource(const QModelIndex &sourceIndex);
92  QModelIndex mapIndexToSource(const QModelIndex &proxyIndex);
93 
94  QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection);
95  QItemSelection mapSelectionToSource(const QItemSelection &proxySelection);
96 
99 
100  void removeItem(ProjectItem *item);
101 
104 
105  virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
106  int row, int column, const QModelIndex &parent) const;
107  virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
108  int row, int column, const QModelIndex &parent);
109 
110  signals:
111  // This signal was added to speed up the Footprint2DView. Previously images were added one at a
112  // time which was extremely slow. This not the ideal handling, but without re-writing
113  // ProjectItemModel and ProjectItemProxyModel to add insertRows method so that beginInsertRows
114  // and endInsertRows are called which would automatically emit the signal rowsInserted after
115  // alls items are inserted into the model rather than calling after each row that is inserted.
116  void itemsAdded();
117  void itemRemoved(ProjectItem *);
118 
119  public slots:
120  ProjectItem *addItem(ProjectItem *sourceItem);
121  void addItems(QList<ProjectItem *> sourceItems);
122 
123  protected slots:
124  void updateItem(ProjectItem *sourceItem);
125  void updateProxyCurrent();
126  void updateSourceCurrent();
127  void updateProxySelection();
128  void updateSourceSelection();
129 
130  protected:
131  ProjectItem *addChild(ProjectItem *sourceItem, ProjectItem *parentItem);
132 
133  private slots:
134  void onItemChanged(QStandardItem *item);
135 
136  private:
137  ProjectItemModel *m_sourceModel;
138  QMap<ProjectItem *, ProjectItem *> m_sourceProxyMap;
140  };
141 }
142 #endif
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:59
void addItems(QList< ProjectItem *> sourceItems)
Adds a list of items to the proxy model.
Definition: ProjectItemProxyModel.cpp:209
$Date$ $Revision$
void updateProxySelection()
Slot that updates the selection in the proxy model only if it is different than the corresponding sel...
Definition: ProjectItemProxyModel.cpp:329
void updateSourceSelection()
Slot that updates the selection in the source model only if it is different than the corresponding se...
Definition: ProjectItemProxyModel.cpp:342
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:292
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
Returns true.
Definition: ProjectItemProxyModel.cpp:432
ProjectItemProxyModel(QObject *parent=0)
Constructs the proxy model.
Definition: ProjectItemProxyModel.cpp:44
Provides access to data stored in a Project through Qt&#39;s model-view framework.
Definition: ProjectItemModel.h:146
ProjectItem * addItem(ProjectItem *sourceItem)
Adds an item and its children to the proxy model.
Definition: ProjectItemProxyModel.cpp:181
void updateProxyCurrent()
Slot that updates the current item in the proxy model only if it is different than the corresponding ...
Definition: ProjectItemProxyModel.cpp:303
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:80
Allows access to items in a ProjectItemModel through a proxy model.
Definition: ProjectItemProxyModel.h:84
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:365
void itemRemoved(ProjectItem *)
void updateSourceCurrent()
Slot that updates the current item in the proxy model only if it is different than the corresponding ...
Definition: ProjectItemProxyModel.cpp:316
ProjectItem * item(int row)
Returns the top-level item at the given row.
Definition: ProjectItemModel.cpp:401
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:451
ProjectItemModel * sourceModel()
Returns the source model.
Definition: ProjectItemProxyModel.cpp:280
ProjectItem * mapItemToSource(ProjectItem *proxyItem)
Returns the ProjectItem in the source model that corresponds with a ProjectItem in the source model...
Definition: ProjectItemProxyModel.cpp:161
QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection)
Returns a QItemSelection of items in the proxy model that corresponds with a QItemSelection of items ...
Definition: ProjectItemProxyModel.cpp:101
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Represents an item of a ProjectItemModel in Qt&#39;s model-view framework.
Definition: ProjectItem.h:146
Definition: BoxcarCachingAlgorithm.h:29
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void removeItem(ProjectItem *item)
Removes an item and its children from the proxy model.
Definition: ProjectItemProxyModel.cpp:222
ProjectItem * mapItemFromSource(ProjectItem *sourceItem)
Returns the ProjectItem in the proxy model that corresponds with a ProjectItem in the source model...
Definition: ProjectItemProxyModel.cpp:148
QItemSelection mapSelectionToSource(const QItemSelection &proxySelection)
Returns a QItemSelection of items in the source model that corresponds with a QItemSelection of itesm...
Definition: ProjectItemProxyModel.cpp:126
Definition: CubeIoHandler.h:38
void setSourceModel(ProjectItemModel *sourceModel)
Sets the source model.
Definition: ProjectItemProxyModel.cpp:238