void QgsComposerModel::setItemRemoved( QgsComposerItem *item ) { if ( !item ) { //nothing to do return; } int pos = mItemZList.indexOf( item ); if ( pos == -1 ) { //item not in z list, nothing to do return; } //need to get QModelIndex of item QModelIndex itemIndex = indexForItem( item ); if ( !itemIndex.isValid() ) { return; } //removing item int row = itemIndex.row(); beginRemoveRows( QModelIndex(), row, row ); item->setIsRemoved( true ); refreshItemsInScene(); endRemoveRows(); }
bool QgsComposerModel::reorderItemToBottom( QgsComposerItem *item ) { if ( !item || !mItemsInScene.contains( item ) ) { return false; } if ( mItemsInScene.last() == item ) { //item is already lowest item present in scene, nothing to do return false; } //move item in z list QMutableListIterator<QgsComposerItem *> it( mItemZList ); if ( it.findNext( item ) ) { it.remove(); } mItemZList.push_back( item ); //also move item in scene items z list and notify of model changes QModelIndex itemIndex = indexForItem( item ); if ( !itemIndex.isValid() ) { return true; } //move item to bottom int row = itemIndex.row(); beginMoveRows( QModelIndex(), row, row, QModelIndex(), rowCount() ); refreshItemsInScene(); endMoveRows(); return true; }
void QgsComposerModel::removeItem( QgsComposerItem *item ) { if ( !item ) { //nothing to do return; } int pos = mItemZList.indexOf( item ); if ( pos == -1 ) { //item not in z list, nothing to do return; } //need to get QModelIndex of item QModelIndex itemIndex = indexForItem( item ); if ( !itemIndex.isValid() ) { //removing an item not in the scene (e.g., deleted item) //we need to remove it from the list, but don't need to call //beginRemoveRows or endRemoveRows since the item was not used by the model mItemZList.removeAt( pos ); refreshItemsInScene(); return; } //remove item from model int row = itemIndex.row(); beginRemoveRows( QModelIndex(), row, row ); mItemZList.removeAt( pos ); refreshItemsInScene(); endRemoveRows(); }
void RegisterHandler::setNumberFormat(const QByteArray &name, RegisterFormat format) { RegisterItem *reg = m_registerByName.value(name, 0); QTC_ASSERT(reg, return); reg->m_format = format; QModelIndex index = indexForItem(reg); emit dataChanged(index, index); }
bool QgsComposerModel::reorderItemDown( QgsComposerItem *item ) { if ( !item ) { return false; } if ( mItemsInScene.last() == item ) { //item is already lowest item present in scene, nothing to do return false; } //move item in z list QMutableListIterator<QgsComposerItem *> it( mItemZList ); if ( ! it.findNext( item ) ) { //can't find item in z list, nothing to do return false; } it.remove(); while ( it.hasNext() ) { //search through item z list to find next item which is present in the scene //(deleted items still exist in the z list so that they can be restored to their correct stacking order, //but since they are not in the scene they should be ignored here) it.next(); if ( it.value() && !( it.value()->isRemoved() ) ) { break; } } it.insert( item ); //also move item in scene items z list and notify of model changes QModelIndex itemIndex = indexForItem( item ); if ( !itemIndex.isValid() ) { return true; } //move item down in scene list int row = itemIndex.row(); beginMoveRows( QModelIndex(), row, row, QModelIndex(), row + 2 ); refreshItemsInScene(); endMoveRows(); return true; }
void QgsComposerModel::updateItemSelectStatus( QgsComposerItem *item ) { if ( !item ) { //nothing to do return; } //need to get QModelIndex of item QModelIndex itemIndex = indexForItem( item, ItemId ); if ( !itemIndex.isValid() ) { return; } //emit signal for item visibility change emit dataChanged( itemIndex, itemIndex ); }
void QgsComposerModel::updateItemLockStatus( QgsComposerItem *item ) { if ( !item ) { //nothing to do return; } //need to get QModelIndex of item QModelIndex itemIndex = indexForItem( item, LockStatus ); if ( !itemIndex.isValid() ) { return; } //emit signal for item lock status change emit dataChanged( itemIndex, itemIndex ); }
void QgsComposerModel::updateItemDisplayName( QgsComposerItem *item ) { if ( !item ) { //nothing to do return; } //need to get QModelIndex of item QModelIndex itemIndex = indexForItem( item, ItemId ); if ( !itemIndex.isValid() ) { return; } //emit signal for item id change emit dataChanged( itemIndex, itemIndex ); }