Isis 3.0
Back | Home
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 {
83 
84  Q_OBJECT
85 
86  public:
87  ProjectItemProxyModel(QObject *parent = 0);
88 
89  QModelIndex mapIndexFromSource(const QModelIndex &sourceIndex);
90  QModelIndex mapIndexToSource(const QModelIndex &proxyIndex);
91 
92  QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection);
93  QItemSelection mapSelectionToSource(const QItemSelection &proxySelection);
94 
97 
99 
102 
103  virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
104  int row, int column, const QModelIndex &parent) const;
105  virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
106  int row, int column, const QModelIndex &parent);
107 
108  signals:
109  void itemRemoved(ProjectItem *);
110 
111  public slots:
112  ProjectItem *addItem(ProjectItem *sourceItem);
113  void addItems(QList<ProjectItem *> sourceItems);
114 
115  protected slots:
116  void updateItem(ProjectItem *sourceItem);
117  void updateProxyCurrent();
118  void updateSourceCurrent();
119  void updateProxySelection();
120  void updateSourceSelection();
121 
122  protected:
123  ProjectItem *addChild(ProjectItem *sourceItem, ProjectItem *parentItem);
124 
125  private slots:
126  void onItemChanged(QStandardItem *item);
127 
128  private:
129  ProjectItemModel *m_sourceModel;
130  QMap<ProjectItem *, ProjectItem *> m_sourceProxyMap;
132  };
133 }
134 #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
$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:330
void updateSourceSelection()
Slot that updates the selection in the source model only if it is different than the corresponding se...
Definition: ProjectItemProxyModel.cpp:343
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:293
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:94
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:304
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:82
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:366
void itemRemoved(ProjectItem *)
Definition: moc_ProjectItemProxyModel.cpp:172
void updateSourceCurrent()
Slot that updates the current item in the proxy model only if it is different than the corresponding ...
Definition: ProjectItemProxyModel.cpp:317
ProjectItem * item(int row)
Returns the top-level item at the given row.
Definition: ProjectItemModel.cpp:265
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:452
ProjectItemModel * sourceModel()
Returns the source model.
Definition: ProjectItemProxyModel.cpp:281
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
Returns true.
Definition: ProjectItemProxyModel.cpp:433
void addItems(QList< ProjectItem * > sourceItems)
Adds a list of items to the proxy model.
Definition: ProjectItemProxyModel.cpp:210
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
$Date$ $Revision$
Represents an item of a ProjectItemModel in Qt&#39;s model-view framework.
Definition: ProjectItem.h:113
Definition: BoxcarCachingAlgorithm.h:29
void removeItem(ProjectItem *item)
Removes an item and its children from the proxy model.
Definition: ProjectItemProxyModel.cpp:223
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:239

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:26:28