23 #include "IsisDebug.h" 28 #include <QItemSelection> 31 #include <QModelIndex> 63 return proxyItem->index();
84 return sourceItem->index();
102 const QItemSelection &sourceSelection) {
104 QItemSelection proxySelection = QItemSelection();
106 foreach ( QModelIndex sourceIndex, sourceSelection.indexes() ) {
108 if ( proxyIndex.isValid() ) {
109 proxySelection.select(proxyIndex, proxyIndex);
113 return proxySelection;
127 QItemSelection sourceSelection = QItemSelection();
129 foreach ( QModelIndex proxyIndex, proxySelection.indexes() ) {
131 if ( sourceIndex.isValid() ) {
132 sourceSelection.select(sourceIndex, sourceIndex);
136 return sourceSelection;
149 return m_sourceProxyMap.value(sourceItem, 0);
162 return m_sourceProxyMap.key(proxyItem, 0);
189 proxyItem =
addChild(sourceItem, parentItem);
192 proxyItem =
addChild(sourceItem, 0);
195 for (
int i=0; i < sourceItem->rowCount(); i++) {
252 SIGNAL( currentChanged(
const QModelIndex &,
const QModelIndex &) ),
256 SIGNAL( currentChanged(
const QModelIndex &,
const QModelIndex &) ),
260 SIGNAL( selectionChanged(
const QItemSelection &,
const QItemSelection &) ),
264 SIGNAL( selectionChanged(
const QItemSelection &,
const QItemSelection &) ),
294 proxyItem->setProjectItem(sourceItem);
307 selectionModel()->setCurrentIndex(newProxyCurrent, QItemSelectionModel::Current);
320 QItemSelectionModel::Current);
333 selectionModel()->select(newProxySelection, QItemSelectionModel::ClearAndSelect);
347 QItemSelectionModel::ClearAndSelect);
378 if ( parentItem && (parentItem->
model() !=
this) ) {
387 m_sourceProxyMap.insert(sourceItem, proxyItem);
391 oldParent->takeRow( proxyItem->row() );
394 model->takeRow( proxyItem->row() );
433 Qt::DropAction action,
435 const QModelIndex &parent)
const {
452 Qt::DropAction action,
454 const QModelIndex &parent) {
455 if ( data->hasFormat(
"application/x-qabstractitemmodeldatalist") ) {
QModelIndex mapIndexFromSource(const QModelIndex &sourceIndex)
Returns the QModelIndex of an item in the proxy model that corresponds with the QModelIndex of an ite...
void addItems(QList< ProjectItem *> sourceItems)
Adds a list of items to the proxy model.
void updateProxySelection()
Slot that updates the selection in the proxy model only if it is different than the corresponding sel...
void appendRow(ProjectItem *item)
Appends an item to the children of this item.
void updateSourceSelection()
Slot that updates the selection in the source model only if it is different than the corresponding se...
ProjectItem * itemFromIndex(const QModelIndex &index)
Returns the ProjectItem corresponding to a given QModelIndex.
void updateItem(ProjectItem *sourceItem)
Given an item in the source model, this method changes the data of the corresponding item in the prox...
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
Returns true.
ProjectItemModel * model() const
Returns the ProjectItemModel associated with this item.
ProjectItem * parent() const
Returns the parent item of this item.
ProjectItemProxyModel(QObject *parent=0)
Constructs the proxy model.
Provides access to data stored in a Project through Qt's model-view framework.
ProjectItem * addItem(ProjectItem *sourceItem)
Adds an item and its children to the proxy model.
void setProjectItem(ProjectItem *item)
Sets the text, icon, and data to those of another item.
void updateProxyCurrent()
Slot that updates the current item in the proxy model only if it is different than the corresponding ...
QModelIndex mapIndexToSource(const QModelIndex &proxyIndex)
Returns the QModelIndex of an item in the souce model that corresponds with the QModelIndex of an ite...
void appendRow(ProjectItem *item)
Appends a top-level item to the model.
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...
QItemSelectionModel * selectionModel()
Returns the internal selection model.
void updateSourceCurrent()
Slot that updates the current item in the proxy model only if it is different than the corresponding ...
virtual void removeItem(ProjectItem *item)
Removes an item and its children from the model.
ProjectItem * item(int row)
Returns the top-level item at the given row.
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.
ProjectItemModel * sourceModel()
Returns the source model.
ProjectItem * mapItemToSource(ProjectItem *proxyItem)
Returns the ProjectItem in the source model that corresponds with a ProjectItem in the source model...
ProjectItemModel * m_sourceModel
The source model. Map of items from the source model to the proxy model.
QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection)
Returns a QItemSelection of items in the proxy model that corresponds with a QItemSelection of items ...
void onItemChanged(QStandardItem *item)
Signal to connect to the itemChanged() signal from a ProjectItemModel.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
ProjectItem * child(int row) const
Returns the child item at a given row.
QList< ProjectItem * > selectedItems()
Returns a list of the selected items of the internal selection model.
Represents an item of a ProjectItemModel in Qt's model-view framework.
Namespace for ISIS/Bullet specific routines.
void removeItem(ProjectItem *item)
Removes an item and its children from the proxy model.
ProjectItem * mapItemFromSource(ProjectItem *sourceItem)
Returns the ProjectItem in the proxy model that corresponds with a ProjectItem in the source model...
QItemSelection mapSelectionToSource(const QItemSelection &proxySelection)
Returns a QItemSelection of items in the source model that corresponds with a QItemSelection of itesm...
void setSourceModel(ProjectItemModel *sourceModel)
Sets the source model.