Isis Developer Reference
ProjectItemProxyModel.h
Go to the documentation of this file.
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
18class QItemSelection;
19template <typename T> class QList;
20class QMimeData;
21class QModelIndex;
22class QStandardItem;
23
24namespace 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.
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();
115
116 protected:
117 ProjectItem *addChild(ProjectItem *sourceItem, ProjectItem *parentItem);
118
119 private slots:
120 void onItemChanged(QStandardItem *item);
121
122 private:
123 ProjectItemModel *m_sourceModel;
125 QMap<ProjectItem *, ProjectItem *> m_sourceProxyMap;
126 };
127}
128#endif
Represents an item of a ProjectItemModel in Qt's model-view framework.
Definition ProjectItem.h:134
Provides access to data stored in a Project through Qt's model-view framework.
Definition ProjectItemModel.h:132
ProjectItem * item(int row)
Returns the top-level item at the given row.
Definition ProjectItemModel.cpp:387
Allows access to items in a ProjectItemModel through a proxy model.
Definition ProjectItemProxyModel.h:70
ProjectItemProxyModel(QObject *parent=0)
Constructs the proxy model.
Definition ProjectItemProxyModel.cpp:28
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:276
void updateProxySelection()
Slot that updates the selection in the proxy model only if it is different than the corresponding sel...
Definition ProjectItemProxyModel.cpp:313
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:43
ProjectItemModel * sourceModel()
Returns the source model.
Definition ProjectItemProxyModel.cpp:264
ProjectItem * addItem(ProjectItem *sourceItem)
Adds an item and its children to the proxy model.
Definition ProjectItemProxyModel.cpp:165
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:349
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:64
void removeItem(ProjectItem *item)
Removes an item and its children from the proxy model.
Definition ProjectItemProxyModel.cpp:206
void updateSourceCurrent()
Slot that updates the current item in the proxy model only if it is different than the corresponding ...
Definition ProjectItemProxyModel.cpp:300
QItemSelection mapSelectionToSource(const QItemSelection &proxySelection)
Returns a QItemSelection of items in the source model that corresponds with a QItemSelection of itesm...
Definition ProjectItemProxyModel.cpp:110
void updateProxyCurrent()
Slot that updates the current item in the proxy model only if it is different than the corresponding ...
Definition ProjectItemProxyModel.cpp:287
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:435
void addItems(QList< ProjectItem * > sourceItems)
Adds a list of items to the proxy model.
Definition ProjectItemProxyModel.cpp:193
QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection)
Returns a QItemSelection of items in the proxy model that corresponds with a QItemSelection of items ...
Definition ProjectItemProxyModel.cpp:85
void updateSourceSelection()
Slot that updates the selection in the source model only if it is different than the corresponding se...
Definition ProjectItemProxyModel.cpp:326
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
Returns true.
Definition ProjectItemProxyModel.cpp:416
ProjectItem * mapItemToSource(ProjectItem *proxyItem)
Returns the ProjectItem in the source model that corresponds with a ProjectItem in the source model.
Definition ProjectItemProxyModel.cpp:145
void setSourceModel(ProjectItemModel *sourceModel)
Sets the source model.
Definition ProjectItemProxyModel.cpp:222
void itemRemoved(ProjectItem *)
ProjectItem * mapItemFromSource(ProjectItem *sourceItem)
Returns the ProjectItem in the proxy model that corresponds with a ProjectItem in the source model.
Definition ProjectItemProxyModel.cpp:132
This is free and unencumbered software released into the public domain.
Definition BoxcarCachingAlgorithm.h:13
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16