|
38 | 38 | #include "qgscomposerattributetable.h"
|
39 | 39 | #include "qgslogger.h"
|
40 | 40 | #include "qgsaddremovemultiframecommand.h"
|
| 41 | +#include "qgspaperitem.h" |
41 | 42 |
|
42 | 43 | QgsComposerView::QgsComposerView( QWidget* parent, const char* name, Qt::WFlags f )
|
43 | 44 | : QGraphicsView( parent )
|
@@ -595,6 +596,77 @@ void QgsComposerView::deleteSelectedItems()
|
595 | 596 | }
|
596 | 597 | }
|
597 | 598 |
|
| 599 | +void QgsComposerView::selectAll() |
| 600 | +{ |
| 601 | + if ( !composition() ) |
| 602 | + { |
| 603 | + return; |
| 604 | + } |
| 605 | + |
| 606 | + //select all items in composer |
| 607 | + QList<QGraphicsItem *> itemList = composition()->items(); |
| 608 | + QList<QGraphicsItem *>::iterator itemIt = itemList.begin(); |
| 609 | + for ( ; itemIt != itemList.end(); ++itemIt ) |
| 610 | + { |
| 611 | + QgsComposerItem* mypItem = dynamic_cast<QgsComposerItem *>( *itemIt ); |
| 612 | + QgsPaperItem* paperItem = dynamic_cast<QgsPaperItem*>( *itemIt ); |
| 613 | + if ( mypItem && !paperItem ) |
| 614 | + { |
| 615 | + if ( !mypItem->positionLock() ) |
| 616 | + { |
| 617 | + mypItem->setSelected( true ); |
| 618 | + } |
| 619 | + else |
| 620 | + { |
| 621 | + //deselect all locked items |
| 622 | + mypItem->setSelected( false ); |
| 623 | + } |
| 624 | + emit selectedItemChanged( mypItem ); |
| 625 | + } |
| 626 | + } |
| 627 | +} |
| 628 | + |
| 629 | +void QgsComposerView::selectNone() |
| 630 | +{ |
| 631 | + if ( !composition() ) |
| 632 | + { |
| 633 | + return; |
| 634 | + } |
| 635 | + |
| 636 | + composition()->clearSelection(); |
| 637 | +} |
| 638 | + |
| 639 | +void QgsComposerView::selectInvert() |
| 640 | +{ |
| 641 | + if ( !composition() ) |
| 642 | + { |
| 643 | + return; |
| 644 | + } |
| 645 | + |
| 646 | + //check all items in composer |
| 647 | + QList<QGraphicsItem *> itemList = composition()->items(); |
| 648 | + QList<QGraphicsItem *>::iterator itemIt = itemList.begin(); |
| 649 | + for ( ; itemIt != itemList.end(); ++itemIt ) |
| 650 | + { |
| 651 | + QgsComposerItem* mypItem = dynamic_cast<QgsComposerItem *>( *itemIt ); |
| 652 | + QgsPaperItem* paperItem = dynamic_cast<QgsPaperItem*>( *itemIt ); |
| 653 | + if ( mypItem && !paperItem ) |
| 654 | + { |
| 655 | + //flip selected state for items (and deselect any locked items) |
| 656 | + if ( mypItem->selected() || mypItem->positionLock() ) |
| 657 | + { |
| 658 | + |
| 659 | + mypItem->setSelected( false ); |
| 660 | + } |
| 661 | + else |
| 662 | + { |
| 663 | + mypItem->setSelected( true ); |
| 664 | + emit selectedItemChanged( mypItem ); |
| 665 | + } |
| 666 | + } |
| 667 | + } |
| 668 | +} |
| 669 | + |
598 | 670 | void QgsComposerView::keyPressEvent( QKeyEvent * e )
|
599 | 671 | {
|
600 | 672 | if ( !composition() )
|
|
0 commit comments