@@ -123,6 +123,7 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q
123
123
124
124
QgsIdentifyResults::~QgsIdentifyResults ()
125
125
{
126
+ clearRubberbands ();
126
127
delete mActionPopup ;
127
128
}
128
129
@@ -340,8 +341,11 @@ void QgsIdentifyResults::contextMenuEvent( QContextMenuEvent* event )
340
341
mActionPopup ->addAction ( tr ( " Copy attribute value" ), this , SLOT ( copyAttributeValue () ) );
341
342
mActionPopup ->addAction ( tr ( " Copy feature attributes" ), this , SLOT ( copyFeatureAttributes () ) );
342
343
mActionPopup ->addSeparator ();
344
+ mActionPopup ->addAction ( tr ( " Clear results" ), this , SLOT ( clear () ) );
345
+ mActionPopup ->addAction ( tr ( " Clear highlights" ), this , SLOT ( clearRubberbands () ) );
343
346
mActionPopup ->addAction ( tr ( " Highlight all" ), this , SLOT ( highlightAll () ) );
344
347
mActionPopup ->addAction ( tr ( " Highlight layer" ), this , SLOT ( highlightLayer () ) );
348
+ mActionPopup ->addSeparator ();
345
349
mActionPopup ->addAction ( tr ( " Expand all" ), this , SLOT ( expandAll () ) );
346
350
mActionPopup ->addAction ( tr ( " Collapse all" ), this , SLOT ( collapseAll () ) );
347
351
@@ -398,6 +402,16 @@ void QgsIdentifyResults::expandColumnsToFit()
398
402
lstResults->resizeColumnToContents ( 1 );
399
403
}
400
404
405
+ void QgsIdentifyResults::clearRubberbands ()
406
+ {
407
+ foreach ( QgsRubberBand *rb, mRubberBands )
408
+ {
409
+ delete rb;
410
+ }
411
+
412
+ mRubberBands .clear ();
413
+ }
414
+
401
415
void QgsIdentifyResults::clear ()
402
416
{
403
417
for ( int i = 0 ; i < lstResults->topLevelItemCount (); i++ )
@@ -406,15 +420,17 @@ void QgsIdentifyResults::clear()
406
420
}
407
421
408
422
lstResults->clear ();
409
- mRubberBands . clear ();
423
+ clearRubberbands ();
410
424
}
411
425
412
426
void QgsIdentifyResults::activate ()
413
427
{
414
- foreach ( QSharedPointer<QgsRubberBand> rb, mRubberBands )
428
+ #if 0
429
+ foreach( QgsRubberBand *rb, mRubberBands )
415
430
{
416
431
rb->show();
417
432
}
433
+ #endif
418
434
419
435
if ( lstResults->topLevelItemCount () > 0 )
420
436
{
@@ -425,10 +441,12 @@ void QgsIdentifyResults::activate()
425
441
426
442
void QgsIdentifyResults::deactivate ()
427
443
{
428
- foreach ( QSharedPointer<QgsRubberBand> rb, mRubberBands )
444
+ #if 0
445
+ foreach( QgsRubberBand *rb, mRubberBands )
429
446
{
430
447
rb->hide();
431
448
}
449
+ #endif
432
450
}
433
451
434
452
void QgsIdentifyResults::doAction ( QTreeWidgetItem *item, int action )
@@ -558,7 +576,7 @@ void QgsIdentifyResults::handleCurrentItemChanged( QTreeWidgetItem *current, QTr
558
576
}
559
577
else
560
578
{
561
- mRubberBands . clear ();
579
+ clearRubberbands ();
562
580
highlightFeature ( current );
563
581
}
564
582
}
@@ -575,7 +593,7 @@ void QgsIdentifyResults::layerDestroyed()
575
593
{
576
594
for ( int j = 0 ; j < layItem->childCount (); j++ )
577
595
{
578
- mRubberBands .remove ( layItem->child ( i ) );
596
+ delete mRubberBands .take ( layItem->child ( i ) );
579
597
}
580
598
}
581
599
}
@@ -621,7 +639,7 @@ void QgsIdentifyResults::featureDeleted( int fid )
621
639
622
640
if ( featItem && featItem->data ( 0 , Qt::UserRole ).toInt () == fid )
623
641
{
624
- mRubberBands .remove ( featItem );
642
+ delete mRubberBands .take ( featItem );
625
643
break ;
626
644
}
627
645
}
@@ -670,7 +688,7 @@ void QgsIdentifyResults::highlightFeature( QTreeWidgetItem *item )
670
688
rb->setWidth ( 2 );
671
689
rb->setColor ( Qt::red );
672
690
rb->show ();
673
- mRubberBands .insert ( featItem, QSharedPointer<QgsRubberBand>( rb ) );
691
+ mRubberBands .insert ( featItem, rb );
674
692
}
675
693
}
676
694
@@ -805,7 +823,7 @@ void QgsIdentifyResults::highlightLayer( QTreeWidgetItem *item )
805
823
if ( !layItem )
806
824
return ;
807
825
808
- mRubberBands . clear ();
826
+ clearRubberbands ();
809
827
810
828
for ( int i = 0 ; i < layItem->childCount (); i++ )
811
829
{
0 commit comments