Skip to content

Commit 96cd236

Browse files
author
jef
committed
[FEATURE] more identify changes:
- down hide highlights when the identify tool is deactivated - add context menu entries to clear results and highlights [fix] - remove QSharedPointer usage (Qt 4.5 dependency) git-svn-id: http://svn.osgeo.org/qgis/trunk@12309 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5d543e2 commit 96cd236

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

src/app/qgsidentifyresults.cpp

+26-8
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q
123123

124124
QgsIdentifyResults::~QgsIdentifyResults()
125125
{
126+
clearRubberbands();
126127
delete mActionPopup;
127128
}
128129

@@ -340,8 +341,11 @@ void QgsIdentifyResults::contextMenuEvent( QContextMenuEvent* event )
340341
mActionPopup->addAction( tr( "Copy attribute value" ), this, SLOT( copyAttributeValue() ) );
341342
mActionPopup->addAction( tr( "Copy feature attributes" ), this, SLOT( copyFeatureAttributes() ) );
342343
mActionPopup->addSeparator();
344+
mActionPopup->addAction( tr( "Clear results" ), this, SLOT( clear() ) );
345+
mActionPopup->addAction( tr( "Clear highlights" ), this, SLOT( clearRubberbands() ) );
343346
mActionPopup->addAction( tr( "Highlight all" ), this, SLOT( highlightAll() ) );
344347
mActionPopup->addAction( tr( "Highlight layer" ), this, SLOT( highlightLayer() ) );
348+
mActionPopup->addSeparator();
345349
mActionPopup->addAction( tr( "Expand all" ), this, SLOT( expandAll() ) );
346350
mActionPopup->addAction( tr( "Collapse all" ), this, SLOT( collapseAll() ) );
347351

@@ -398,6 +402,16 @@ void QgsIdentifyResults::expandColumnsToFit()
398402
lstResults->resizeColumnToContents( 1 );
399403
}
400404

405+
void QgsIdentifyResults::clearRubberbands()
406+
{
407+
foreach( QgsRubberBand *rb, mRubberBands )
408+
{
409+
delete rb;
410+
}
411+
412+
mRubberBands.clear();
413+
}
414+
401415
void QgsIdentifyResults::clear()
402416
{
403417
for ( int i = 0; i < lstResults->topLevelItemCount(); i++ )
@@ -406,15 +420,17 @@ void QgsIdentifyResults::clear()
406420
}
407421

408422
lstResults->clear();
409-
mRubberBands.clear();
423+
clearRubberbands();
410424
}
411425

412426
void QgsIdentifyResults::activate()
413427
{
414-
foreach( QSharedPointer<QgsRubberBand> rb, mRubberBands )
428+
#if 0
429+
foreach( QgsRubberBand *rb, mRubberBands )
415430
{
416431
rb->show();
417432
}
433+
#endif
418434

419435
if ( lstResults->topLevelItemCount() > 0 )
420436
{
@@ -425,10 +441,12 @@ void QgsIdentifyResults::activate()
425441

426442
void QgsIdentifyResults::deactivate()
427443
{
428-
foreach( QSharedPointer<QgsRubberBand> rb, mRubberBands )
444+
#if 0
445+
foreach( QgsRubberBand *rb, mRubberBands )
429446
{
430447
rb->hide();
431448
}
449+
#endif
432450
}
433451

434452
void QgsIdentifyResults::doAction( QTreeWidgetItem *item, int action )
@@ -558,7 +576,7 @@ void QgsIdentifyResults::handleCurrentItemChanged( QTreeWidgetItem *current, QTr
558576
}
559577
else
560578
{
561-
mRubberBands.clear();
579+
clearRubberbands();
562580
highlightFeature( current );
563581
}
564582
}
@@ -575,7 +593,7 @@ void QgsIdentifyResults::layerDestroyed()
575593
{
576594
for ( int j = 0; j < layItem->childCount(); j++ )
577595
{
578-
mRubberBands.remove( layItem->child( i ) );
596+
delete mRubberBands.take( layItem->child( i ) );
579597
}
580598
}
581599
}
@@ -621,7 +639,7 @@ void QgsIdentifyResults::featureDeleted( int fid )
621639

622640
if ( featItem && featItem->data( 0, Qt::UserRole ).toInt() == fid )
623641
{
624-
mRubberBands.remove( featItem );
642+
delete mRubberBands.take( featItem );
625643
break;
626644
}
627645
}
@@ -670,7 +688,7 @@ void QgsIdentifyResults::highlightFeature( QTreeWidgetItem *item )
670688
rb->setWidth( 2 );
671689
rb->setColor( Qt::red );
672690
rb->show();
673-
mRubberBands.insert( featItem, QSharedPointer<QgsRubberBand>( rb ) );
691+
mRubberBands.insert( featItem, rb );
674692
}
675693
}
676694

@@ -805,7 +823,7 @@ void QgsIdentifyResults::highlightLayer( QTreeWidgetItem *item )
805823
if ( !layItem )
806824
return;
807825

808-
mRubberBands.clear();
826+
clearRubberbands();
809827

810828
for ( int i = 0; i < layItem->childCount(); i++ )
811829
{

src/app/qgsidentifyresults.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#include <QWidget>
2727
#include <QList>
28-
#include <QSharedPointer>
2928

3029
class QCloseEvent;
3130
class QTreeWidgetItem;
@@ -60,9 +59,6 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
6059
const QMap< QString, QString > &attributes,
6160
const QMap< QString, QString > &derivedAttributes );
6261

63-
/** Remove results */
64-
void clear();
65-
6662
/** map tool was deactivated */
6763
void deactivate();
6864

@@ -75,6 +71,8 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
7571
void selectedFeatureChanged( QgsVectorLayer *, int featureId );
7672

7773
public slots:
74+
/** Remove results */
75+
void clear();
7876

7977
void show();
8078

@@ -91,6 +89,7 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
9189
void copyFeatureAttributes();
9290
void highlightAll();
9391
void highlightLayer();
92+
void clearRubberbands();
9493
void expandAll();
9594
void collapseAll();
9695

@@ -110,7 +109,7 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
110109

111110
private:
112111
QMenu *mActionPopup;
113-
QMap<QTreeWidgetItem *, QSharedPointer<QgsRubberBand> > mRubberBands;
112+
QMap<QTreeWidgetItem *, QgsRubberBand * > mRubberBands;
114113
QgsMapCanvas *mCanvas;
115114

116115
QgsVectorLayer *vectorLayer( QTreeWidgetItem *item );

0 commit comments

Comments
 (0)