QGIS API Documentation  2.13.0-Master
qgscomposermodel.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposermodel.cpp
3  -----------------
4  begin : July 2014
5  copyright : (C) 2014 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgsapplication.h"
19 #include "qgscomposermodel.h"
20 #include "qgscomposition.h"
21 #include "qgscomposeritem.h"
22 #include "qgspaperitem.h"
23 #include "qgslogger.h"
24 #include <QApplication>
25 #include <QGraphicsItem>
26 #include <QDomDocument>
27 #include <QDomElement>
28 #include <QMimeData>
29 #include <QSettings>
30 #include <QMessageBox>
31 #include <QIcon>
32 
34  : QAbstractItemModel( parent )
35  , mComposition( composition )
36 {
37 
38 }
39 
41 {
42 }
43 
44 QgsComposerItem* QgsComposerModel::itemFromIndex( const QModelIndex &index ) const
45 {
46  //try to return the QgsComposerItem corresponding to a QModelIndex
47  if ( !index.isValid() )
48  {
49  return nullptr;
50  }
51 
52  QgsComposerItem * item = static_cast<QgsComposerItem*>( index.internalPointer() );
53  return item;
54 }
55 
56 QModelIndex QgsComposerModel::index( int row, int column,
57  const QModelIndex &parent ) const
58 {
59  if ( column < 0 || column >= columnCount() )
60  {
61  //column out of bounds
62  return QModelIndex();
63  }
64 
65  if ( !parent.isValid() && row >= 0 && row < mItemsInScene.size() )
66  {
67  //return an index for the composer item at this position
68  return createIndex( row, column, mItemsInScene.at( row ) );
69  }
70 
71  //only top level supported for now
72  return QModelIndex();
73 }
74 
75 void QgsComposerModel::refreshItemsInScene()
76 {
78 
79  //filter deleted and paper items from list
80  //TODO - correctly handle grouped item z order placement
82  for ( ; itemIt != mItemZList.constEnd(); ++itemIt )
83  {
84  if ((( *itemIt )->type() != QgsComposerItem::ComposerPaper ) && !( *itemIt )->isRemoved() )
85  {
86  mItemsInScene.push_back(( *itemIt ) );
87  }
88  }
89 }
90 
92 {
93  Q_UNUSED( index );
94 
95  //all items are top level for now
96  return QModelIndex();
97 }
98 
100 {
101  if ( !parent.isValid() )
102  {
103  return mItemsInScene.size();
104  }
105 
106  QGraphicsItem * parentItem = itemFromIndex( parent );
107 
108  if ( !parentItem )
109  {
110  return mItemsInScene.size();
111  }
112  else
113  {
114  //no children for now
115  return 0;
116  }
117 }
118 
120 {
121  Q_UNUSED( parent );
122  return 3;
123 }
124 
125 QVariant QgsComposerModel::data( const QModelIndex &index, int role ) const
126 {
127  if ( !index.isValid() )
128  return QVariant();
129 
130  QgsComposerItem *item = itemFromIndex( index );
131  if ( !item )
132  {
133  return QVariant();
134  }
135 
136  switch ( role )
137  {
138  case Qt::DisplayRole:
139  if ( index.column() == ItemId )
140  {
141  return item->displayName();
142  }
143  else
144  {
145  return QVariant();
146  }
147 
148  case Qt::EditRole:
149  if ( index.column() == ItemId )
150  {
151  return item->id();
152  }
153  else
154  {
155  return QVariant();
156  }
157 
158  case Qt::UserRole:
159  //store item uuid in userrole so we can later get the QModelIndex for a specific item
160  return item->uuid();
161 
162  case Qt::TextAlignmentRole:
163  return Qt::AlignLeft & Qt::AlignVCenter;
164 
165  case Qt::CheckStateRole:
166  switch ( index.column() )
167  {
168  case Visibility:
169  //column 0 is visibility of item
170  return item->isVisible() ? Qt::Checked : Qt::Unchecked;
171  case LockStatus:
172  //column 1 is locked state of item
173  return item->positionLock() ? Qt::Checked : Qt::Unchecked;
174  default:
175  return QVariant();
176  }
177 
178  case Qt::FontRole:
179  if ( index.column() == ItemId && item->isSelected() )
180  {
181  //draw name of selected items in bold
182  QFont boldFont;
183  boldFont.setBold( true );
184  return boldFont;
185  }
186  return QVariant();
187 
188  default:
189  return QVariant();
190  }
191 }
192 
193 bool QgsComposerModel::setData( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole )
194 {
195  Q_UNUSED( role );
196 
197  if ( !index.isValid() )
198  return false;
199 
200  QgsComposerItem *item = itemFromIndex( index );
201  if ( !item )
202  {
203  return false;
204  }
205 
206  switch ( index.column() )
207  {
208  case Visibility:
209  //first column is item visibility
210  item->setVisibility( value.toBool() );
211  emit dataChanged( index, index );
212  return true;
213 
214  case LockStatus:
215  //second column is item lock state
216  item->setPositionLock( value.toBool() );
217  emit dataChanged( index, index );
218  return true;
219 
220  case ItemId:
221  //last column is item id
222  item->setId( value.toString() );
223  emit dataChanged( index, index );
224  return true;
225  }
226 
227  return false;
228 }
229 
230 QVariant QgsComposerModel::headerData( int section, Qt::Orientation orientation, int role ) const
231 {
232  static QIcon lockIcon;
233  if ( lockIcon.isNull() )
234  lockIcon = QgsApplication::getThemeIcon( "/locked.svg" );
235  static QIcon showIcon;
236  if ( showIcon.isNull() )
237  showIcon = QgsApplication::getThemeIcon( "/mActionShowAllLayers.png" );
238 
239  switch ( role )
240  {
241  case Qt::DisplayRole:
242  {
243  if ( section == ItemId )
244  {
245  return tr( "Item" );
246  }
247  return QVariant();
248  }
249 
250  case Qt::DecorationRole:
251  {
252  if ( section == Visibility )
253  {
254  return qVariantFromValue( showIcon );
255  }
256  else if ( section == LockStatus )
257  {
258  return qVariantFromValue( lockIcon );
259  }
260 
261  return QVariant();
262  }
263 
264  case Qt::TextAlignmentRole:
265  return Qt::AlignLeft & Qt::AlignVCenter;
266 
267  default:
268  return QAbstractItemModel::headerData( section, orientation, role );
269  }
270 
271 }
272 
274 {
275  return Qt::MoveAction;
276 }
277 
279 {
280  QStringList types;
281  types << "application/x-vnd.qgis.qgis.composeritemid";
282  return types;
283 }
284 
285 QMimeData* QgsComposerModel::mimeData( const QModelIndexList &indexes ) const
286 {
287  QMimeData *mimeData = new QMimeData();
288  QByteArray encodedData;
289 
290  QDataStream stream( &encodedData, QIODevice::WriteOnly );
291 
292  Q_FOREACH ( const QModelIndex &index, indexes )
293  {
294  if ( index.isValid() && index.column() == ItemId )
295  {
296  QgsComposerItem *item = itemFromIndex( index );
297  if ( !item )
298  {
299  continue;
300  }
301  QString text = item->uuid();
302  stream << text;
303  }
304  }
305 
306  mimeData->setData( "application/x-vnd.qgis.qgis.composeritemid", encodedData );
307  return mimeData;
308 }
309 
311 {
312  return item1->zValue() > item2->zValue();
313 }
314 
316  Qt::DropAction action, int row, int column, const QModelIndex &parent )
317 {
318  if ( column != ItemId )
319  {
320  return false;
321  }
322 
323  if ( action == Qt::IgnoreAction )
324  {
325  return true;
326  }
327 
328  if ( !data->hasFormat( "application/x-vnd.qgis.qgis.composeritemid" ) )
329  {
330  return false;
331  }
332 
333  if ( parent.isValid() )
334  {
335  return false;
336  }
337 
338  int beginRow = row != -1 ? row : rowCount( QModelIndex() );
339 
340  QByteArray encodedData = data->data( "application/x-vnd.qgis.qgis.composeritemid" );
341  QDataStream stream( &encodedData, QIODevice::ReadOnly );
342  QList<QgsComposerItem*> droppedItems;
343  int rows = 0;
344 
345  while ( !stream.atEnd() )
346  {
347  QString text;
348  stream >> text;
349  const QgsComposerItem* item = mComposition->getComposerItemByUuid( text );
350  if ( item )
351  {
352  droppedItems << const_cast<QgsComposerItem*>( item );
353  ++rows;
354  }
355  }
356 
357  if ( droppedItems.length() == 0 )
358  {
359  //no dropped items
360  return false;
361  }
362 
363  //move dropped items
364 
365  //first sort them by z-order
366  qSort( droppedItems.begin(), droppedItems.end(), zOrderDescending );
367 
368  //calculate position in z order list to drop items at
369  int destPos = 0;
370  if ( beginRow < rowCount() )
371  {
372  QgsComposerItem* itemBefore = mItemsInScene.at( beginRow );
373  destPos = mItemZList.indexOf( itemBefore );
374  }
375  else
376  {
377  //place items at end
378  destPos = mItemZList.size();
379  }
380 
381  //calculate position to insert moved rows to
382  int insertPos = destPos;
383  QList<QgsComposerItem*>::iterator itemIt = droppedItems.begin();
384  for ( ; itemIt != droppedItems.end(); ++itemIt )
385  {
386  int listPos = mItemZList.indexOf( *itemIt );
387  if ( listPos == -1 )
388  {
389  //should be impossible
390  continue;
391  }
392 
393  if ( listPos < destPos )
394  {
395  insertPos--;
396  }
397  }
398 
399  //remove rows from list
400  itemIt = droppedItems.begin();
401  for ( ; itemIt != droppedItems.end(); ++itemIt )
402  {
403  mItemZList.removeOne( *itemIt );
404  }
405 
406  //insert items
407  itemIt = droppedItems.begin();
408  for ( ; itemIt != droppedItems.end(); ++itemIt )
409  {
410  mItemZList.insert( insertPos, *itemIt );
411  insertPos++;
412  }
413 
414  rebuildSceneItemList();
415  mComposition->updateZValues( false );
416 
417  return true;
418 }
419 
420 bool QgsComposerModel::removeRows( int row, int count, const QModelIndex &parent )
421 {
422  Q_UNUSED( count );
423  if ( parent.isValid() )
424  {
425  return false;
426  }
427 
428  if ( row >= rowCount() )
429  {
430  return false;
431  }
432 
433  //do nothing - moves are handled by the dropMimeData method
434  return true;
435 }
436 
438 {
439  //totally reset model
440  beginResetModel();
441  mItemZList.clear();
442  refreshItemsInScene();
443  endResetModel();
444 }
445 
447 {
448  return mItemZList.size();
449 }
450 
452 {
453  QList<QgsComposerItem*> sortedList;
454  //rebuild the item z order list based on the current zValues of items in the scene
455 
456  //get items in descending zValue order
457  QList<QGraphicsItem*> itemList = mComposition->items( Qt::DescendingOrder );
458  QList<QGraphicsItem*>::iterator itemIt = itemList.begin();
459  for ( ; itemIt != itemList.end(); ++itemIt )
460  {
461  QgsComposerItem* composerItem = dynamic_cast<QgsComposerItem*>( *itemIt );
462  if ( composerItem )
463  {
464  if ( composerItem->type() != QgsComposerItem::ComposerPaper )
465  {
466  sortedList.append( composerItem );
467  }
468  }
469  }
470 
471  mItemZList = sortedList;
472  rebuildSceneItemList();
473 }
474 
475 void QgsComposerModel::rebuildSceneItemList()
476 {
477  //step through the z list and rebuild the items in scene list,
478  //emitting signals as required
479  int row = 0;
480  Q_FOREACH ( QgsComposerItem* item, mItemZList )
481  {
482  if (( item->type() == QgsComposerItem::ComposerPaper ) || item->isRemoved() )
483  {
484  //item not in scene, skip it
485  continue;
486  }
487 
488  int sceneListPos = mItemsInScene.indexOf( item );
489  if ( sceneListPos == row )
490  {
491  //already in list in correct position, nothing to do
492 
493  }
494  else if ( sceneListPos != -1 )
495  {
496  //in list, but in wrong spot
497  beginMoveRows( QModelIndex(), sceneListPos, sceneListPos, QModelIndex(), row );
498  mItemsInScene.removeAt( sceneListPos );
499  mItemsInScene.insert( row, item );
500  endMoveRows();
501  }
502  else
503  {
504  //needs to be inserted into list
505  beginInsertRows( QModelIndex(), row, row );
506  mItemsInScene.insert( row, item );
507  endInsertRows();
508  }
509  row++;
510  }
511 }
512 
514 {
515  beginInsertRows( QModelIndex(), 0, 0 );
516  mItemZList.push_front( item );
517  refreshItemsInScene();
518  item->setZValue( mItemZList.size() );
519  endInsertRows();
520 }
521 
523 {
524  if ( !item )
525  {
526  //nothing to do
527  return;
528  }
529 
530  int pos = mItemZList.indexOf( item );
531  if ( pos == -1 )
532  {
533  //item not in z list, nothing to do
534  return;
535  }
536 
537  //need to get QModelIndex of item
538  QModelIndex itemIndex = indexForItem( item );
539  if ( !itemIndex.isValid() )
540  {
541  //removing an item not in the scene (eg, deleted item)
542  //we need to remove it from the list, but don't need to call
543  //beginRemoveRows or endRemoveRows since the item was not used by the model
544  mItemZList.removeAt( pos );
545  refreshItemsInScene();
546  return;
547  }
548 
549  //remove item from model
550  int row = itemIndex.row();
551  beginRemoveRows( QModelIndex(), row, row );
552  mItemZList.removeAt( pos );
553  refreshItemsInScene();
554  endRemoveRows();
555 }
556 
558 {
559  if ( !item )
560  {
561  //nothing to do
562  return;
563  }
564 
565  int pos = mItemZList.indexOf( item );
566  if ( pos == -1 )
567  {
568  //item not in z list, nothing to do
569  return;
570  }
571 
572  //need to get QModelIndex of item
573  QModelIndex itemIndex = indexForItem( item );
574  if ( !itemIndex.isValid() )
575  {
576  return;
577  }
578 
579  //removing item
580  int row = itemIndex.row();
581  beginRemoveRows( QModelIndex(), row, row );
582  item->setIsRemoved( true );
583  refreshItemsInScene();
584  endRemoveRows();
585 }
586 
588 {
589  if ( !item )
590  {
591  //nothing to do
592  return;
593  }
594 
595  int pos = mItemZList.indexOf( item );
596  if ( pos == -1 )
597  {
598  //item not in z list, nothing to do
599  return;
600  }
601 
602  item->setIsRemoved( false );
603  rebuildSceneItemList();
604 }
605 
607 {
608  if ( !item )
609  {
610  //nothing to do
611  return;
612  }
613 
614  //need to get QModelIndex of item
615  QModelIndex itemIndex = indexForItem( item, ItemId );
616  if ( !itemIndex.isValid() )
617  {
618  return;
619  }
620 
621  //emit signal for item id change
622  emit dataChanged( itemIndex, itemIndex );
623 }
624 
626 {
627  if ( !item )
628  {
629  //nothing to do
630  return;
631  }
632 
633  //need to get QModelIndex of item
634  QModelIndex itemIndex = indexForItem( item, LockStatus );
635  if ( !itemIndex.isValid() )
636  {
637  return;
638  }
639 
640  //emit signal for item lock status change
641  emit dataChanged( itemIndex, itemIndex );
642 }
643 
645 {
646  if ( !item )
647  {
648  //nothing to do
649  return;
650  }
651 
652  //need to get QModelIndex of item
653  QModelIndex itemIndex = indexForItem( item, Visibility );
654  if ( !itemIndex.isValid() )
655  {
656  return;
657  }
658 
659  //emit signal for item visibility change
660  emit dataChanged( itemIndex, itemIndex );
661 }
662 
664 {
665  if ( !item )
666  {
667  //nothing to do
668  return;
669  }
670 
671  //need to get QModelIndex of item
672  QModelIndex itemIndex = indexForItem( item, ItemId );
673  if ( !itemIndex.isValid() )
674  {
675  return;
676  }
677 
678  //emit signal for item visibility change
679  emit dataChanged( itemIndex, itemIndex );
680 }
681 
683 {
684  if ( !item )
685  {
686  return false;
687  }
688 
689  if ( mItemsInScene.at( 0 ) == item )
690  {
691  //item is already topmost item present in scene, nothing to do
692  return false;
693  }
694 
695  //move item in z list
697  if ( ! it.findNext( item ) )
698  {
699  //can't find item in z list, nothing to do
700  return false;
701  }
702 
703  it.remove();
704  while ( it.hasPrevious() )
705  {
706  //search through item z list to find previous item which is present in the scene
707  //(deleted items still exist in the z list so that they can be restored to their correct stacking order,
708  //but since they are not in the scene they should be ignored here)
709  it.previous();
710  if ( it.value() && !( it.value()->isRemoved() ) )
711  {
712  break;
713  }
714  }
715  it.insert( item );
716 
717  //also move item in scene items z list and notify of model changes
718  QModelIndex itemIndex = indexForItem( item );
719  if ( !itemIndex.isValid() )
720  {
721  return true;
722  }
723 
724  //move item up in scene list
725  int row = itemIndex.row();
726  beginMoveRows( QModelIndex(), row, row, QModelIndex(), row - 1 );
727  refreshItemsInScene();
728  endMoveRows();
729  return true;
730 }
731 
733 {
734  if ( !item )
735  {
736  return false;
737  }
738 
739  if ( mItemsInScene.last() == item )
740  {
741  //item is already lowest item present in scene, nothing to do
742  return false;
743  }
744 
745  //move item in z list
747  if ( ! it.findNext( item ) )
748  {
749  //can't find item in z list, nothing to do
750  return false;
751  }
752 
753  it.remove();
754  while ( it.hasNext() )
755  {
756  //search through item z list to find next item which is present in the scene
757  //(deleted items still exist in the z list so that they can be restored to their correct stacking order,
758  //but since they are not in the scene they should be ignored here)
759  it.next();
760  if ( it.value() && !( it.value()->isRemoved() ) )
761  {
762  break;
763  }
764  }
765  it.insert( item );
766 
767  //also move item in scene items z list and notify of model changes
768  QModelIndex itemIndex = indexForItem( item );
769  if ( !itemIndex.isValid() )
770  {
771  return true;
772  }
773 
774  //move item down in scene list
775  int row = itemIndex.row();
776  beginMoveRows( QModelIndex(), row, row, QModelIndex(), row + 2 );
777  refreshItemsInScene();
778  endMoveRows();
779  return true;
780 }
781 
783 {
784  if ( !item || !mItemsInScene.contains( item ) )
785  {
786  return false;
787  }
788 
789  if ( mItemsInScene.at( 0 ) == item )
790  {
791  //item is already topmost item present in scene, nothing to do
792  return false;
793  }
794 
795  //move item in z list
797  if ( it.findNext( item ) )
798  {
799  it.remove();
800  }
801  mItemZList.push_front( item );
802 
803  //also move item in scene items z list and notify of model changes
804  QModelIndex itemIndex = indexForItem( item );
805  if ( !itemIndex.isValid() )
806  {
807  return true;
808  }
809 
810  //move item to top
811  int row = itemIndex.row();
812  beginMoveRows( QModelIndex(), row, row, QModelIndex(), 0 );
813  refreshItemsInScene();
814  endMoveRows();
815  return true;
816 }
817 
819 {
820  if ( !item || !mItemsInScene.contains( item ) )
821  {
822  return false;
823  }
824 
825  if ( mItemsInScene.last() == item )
826  {
827  //item is already lowest item present in scene, nothing to do
828  return false;
829  }
830 
831  //move item in z list
833  if ( it.findNext( item ) )
834  {
835  it.remove();
836  }
837  mItemZList.push_back( item );
838 
839  //also move item in scene items z list and notify of model changes
840  QModelIndex itemIndex = indexForItem( item );
841  if ( !itemIndex.isValid() )
842  {
843  return true;
844  }
845 
846  //move item to bottom
847  int row = itemIndex.row();
848  beginMoveRows( QModelIndex(), row, row, QModelIndex(), rowCount() );
849  refreshItemsInScene();
850  endMoveRows();
851  return true;
852 }
853 
855 {
856  //search item z list for selected item
858  it.toBack();
859  if ( it.findPrevious( item ) )
860  {
861  //move position to before selected item
862  while ( it.hasPrevious() )
863  {
864  //now find previous item, since list is sorted from lowest->highest items
865  if ( it.hasPrevious() && !it.peekPrevious()->isGroupMember() )
866  {
867  return it.previous();
868  }
869  it.previous();
870  }
871  }
872  return nullptr;
873 }
874 
876 {
877  //search item z list for selected item
879  if ( it.findNext( item ) )
880  {
881  //return next item (list is sorted from lowest->highest items)
882  while ( it.hasNext() )
883  {
884  if ( !it.peekNext()->isGroupMember() )
885  {
886  return it.next();
887  }
888  it.next();
889  }
890  }
891  return nullptr;
892 }
893 
895 {
896  return &mItemZList;
897 }
898 
899 
901 {
903 
904  if ( ! index.isValid() )
905  {
906  return flags | Qt::ItemIsDropEnabled;
907  }
908 
909  switch ( index.column() )
910  {
911  case Visibility:
912  case LockStatus:
913  return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
914  case ItemId:
915  return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
916  default:
917  return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
918  }
919 }
920 
921 QModelIndex QgsComposerModel::indexForItem( QgsComposerItem *item, const int column )
922 {
923  if ( !item )
924  {
925  return QModelIndex();
926  }
927 
928  int row = mItemsInScene.indexOf( item );
929  if ( row == -1 )
930  {
931  //not found
932  return QModelIndex();
933  }
934 
935  return index( row, column );
936 }
937 
939 {
940  QgsComposerItem *item = itemFromIndex( index );
941  if ( !item )
942  {
943  return;
944  }
945 
946  mComposition->setSelectedItem( item );
947 }
bool positionLock() const
Returns whether position lock for mouse drags is enabled returns true if item is locked for mouse mov...
Qt::DropActions supportedDropActions() const override
void clear()
QByteArray data(const QString &mimeType) const
QgsComposerItem * getComposerItemAbove(QgsComposerItem *item) const
Finds the next composer item above an item.
const T & next()
bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
void push_back(const T &value)
const T & previous()
int length() const
QList< QGraphicsItem * > items() const
virtual bool hasFormat(const QString &mimeType) const
void rebuildZList()
Rebuilds the z-order list, based on the current stacking of items in the composition.
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
int zOrderListSize() const
Returns the size of the z-order list, which includes items which may have been removed from the compo...
const T & at(int i) const
const T & peekNext() const
A item that forms part of a map composition.
void setSelectedItem(QgsComposerItem *item)
Clears any selected items and sets an item as the current selection.
bool findPrevious(const T &value)
void removeAt(int i)
void push_front(const T &value)
void updateItemVisibility(QgsComposerItem *item)
Must be called when an item&#39;s visibility changes.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
const QgsComposerItem * getComposerItemByUuid(const QString &theUuid) const
Returns a composer item given its unique identifier.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
virtual QStringList mimeTypes() const override
virtual QMimeData * mimeData(const QModelIndexList &indexes) const override
void setItemRestored(QgsComposerItem *item)
Restores an item to the composition.
bool reorderItemDown(QgsComposerItem *item)
Moves an item down the z-order list.
QString tr(const char *sourceText, const char *disambiguation, int n)
void updateItemDisplayName(QgsComposerItem *item)
Must be called when an item&#39;s display name is modified.
bool zOrderDescending(QgsComposerItem *item1, QgsComposerItem *item2)
int size() const
bool hasPrevious() const
int indexOf(const T &value, int from) const
QList< QgsComposerItem * > * zOrderList()
Returns the item z-order list.
void setBold(bool enable)
void updateItemLockStatus(QgsComposerItem *item)
Must be called when an item&#39;s lock status changes.
bool isValid() const
QString uuid() const
Get item identification name.
qreal zValue() const
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QList< QgsComposerItem * > mItemZList
Maintains z-Order of items.
void append(const T &value)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
void setIsRemoved(const bool removed)
Sets whether this item has been removed from the composition.
bool isSelected() const
void clear()
Clears all items from z-order list and resets the model.
bool findNext(const T &value)
void beginRemoveRows(const QModelIndex &parent, int first, int last)
int row() const
void * internalPointer() const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QList< QgsComposerItem * > mItemsInScene
Cached list of items from mItemZList which are currently in the scene.
bool atEnd() const
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
Graphics scene for map printing.
QVariant data(const QModelIndex &index, int role) const override
QModelIndex createIndex(int row, int column, void *ptr) const
iterator end()
bool findNext(const T &value)
virtual bool isRemoved() const
Returns whether this item has been removed from the composition.
bool contains(const T &value) const
bool hasNext() const
void removeItem(QgsComposerItem *item)
Removes an item from the z-order list.
virtual QString displayName() const
Get item display name.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void beginInsertRows(const QModelIndex &parent, int first, int last)
void setPositionLock(const bool lock)
Locks / unlocks the item position for mouse drags.
void setSelected(const QModelIndex &index)
Sets an item as the current selection from a QModelIndex.
bool isVisible() const
bool hasPrevious() const
bool reorderItemUp(QgsComposerItem *item)
Moves an item up the z-order list.
QgsComposerItem * getComposerItemBelow(QgsComposerItem *item) const
Finds the next composer item below an item.
typedef DropActions
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
void insert(int i, const T &value)
bool isNull() const
virtual void setId(const QString &id)
Set item&#39;s id (which is not necessarly unique)
T & last()
int columnCount(const QModelIndex &parent=QModelIndex()) const override
int column() const
bool toBool() const
const T & peekPrevious() const
void updateItemSelectStatus(QgsComposerItem *item)
Must be called when an item&#39;s selection status changes.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
void setData(const QString &mimeType, const QByteArray &data)
void setItemRemoved(QgsComposerItem *item)
Marks an item as removed from the composition.
QgsComposerModel(QgsComposition *composition, QObject *parent=nullptr)
Constructor.
const_iterator constEnd() const
const_iterator constBegin() const
bool reorderItemToTop(QgsComposerItem *item)
Moves an item to the top of the z-order list.
QObject * parent() const
void insert(const T &value)
QString toString() const
void setZValue(qreal z)
void addItemAtTop(QgsComposerItem *item)
Adds an item to the top of the composition z stack.
bool removeOne(const T &value)
virtual void setVisibility(const bool visible)
Sets visibility for item.
iterator begin()
bool reorderItemToBottom(QgsComposerItem *item)
Moves an item to the bottom of the z-order list.
virtual int type() const override
Return correct graphics item type.
Qt::ItemFlags flags(const QModelIndex &index) const override
typedef ItemFlags
bool hasNext() const
QString id() const
Get item&#39;s id (which is not necessarly unique)