Exemplo n.º 1
0
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();
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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();
}
Exemplo n.º 4
0
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);
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
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 );
}
Exemplo n.º 7
0
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 );
}
Exemplo n.º 8
0
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 );
}