Skip to content
Permalink
Browse files

[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
  • Loading branch information
jef
jef committed Dec 2, 2009
1 parent 5d543e2 commit 96cd236117ba0420e02786b6f8fa3c032d27c3f0
Showing with 30 additions and 13 deletions.
  1. +26 −8 src/app/qgsidentifyresults.cpp
  2. +4 −5 src/app/qgsidentifyresults.h
@@ -123,6 +123,7 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q

QgsIdentifyResults::~QgsIdentifyResults()
{
clearRubberbands();
delete mActionPopup;
}

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

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

void QgsIdentifyResults::clearRubberbands()
{
foreach( QgsRubberBand *rb, mRubberBands )
{
delete rb;
}

mRubberBands.clear();
}

void QgsIdentifyResults::clear()
{
for ( int i = 0; i < lstResults->topLevelItemCount(); i++ )
@@ -406,15 +420,17 @@ void QgsIdentifyResults::clear()
}

lstResults->clear();
mRubberBands.clear();
clearRubberbands();
}

void QgsIdentifyResults::activate()
{
foreach( QSharedPointer<QgsRubberBand> rb, mRubberBands )
#if 0
foreach( QgsRubberBand *rb, mRubberBands )
{
rb->show();
}
#endif

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

void QgsIdentifyResults::deactivate()
{
foreach( QSharedPointer<QgsRubberBand> rb, mRubberBands )
#if 0
foreach( QgsRubberBand *rb, mRubberBands )
{
rb->hide();
}
#endif
}

void QgsIdentifyResults::doAction( QTreeWidgetItem *item, int action )
@@ -558,7 +576,7 @@ void QgsIdentifyResults::handleCurrentItemChanged( QTreeWidgetItem *current, QTr
}
else
{
mRubberBands.clear();
clearRubberbands();
highlightFeature( current );
}
}
@@ -575,7 +593,7 @@ void QgsIdentifyResults::layerDestroyed()
{
for ( int j = 0; j < layItem->childCount(); j++ )
{
mRubberBands.remove( layItem->child( i ) );
delete mRubberBands.take( layItem->child( i ) );
}
}
}
@@ -621,7 +639,7 @@ void QgsIdentifyResults::featureDeleted( int fid )

if ( featItem && featItem->data( 0, Qt::UserRole ).toInt() == fid )
{
mRubberBands.remove( featItem );
delete mRubberBands.take( featItem );
break;
}
}
@@ -670,7 +688,7 @@ void QgsIdentifyResults::highlightFeature( QTreeWidgetItem *item )
rb->setWidth( 2 );
rb->setColor( Qt::red );
rb->show();
mRubberBands.insert( featItem, QSharedPointer<QgsRubberBand>( rb ) );
mRubberBands.insert( featItem, rb );
}
}

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

mRubberBands.clear();
clearRubberbands();

for ( int i = 0; i < layItem->childCount(); i++ )
{
@@ -25,7 +25,6 @@

#include <QWidget>
#include <QList>
#include <QSharedPointer>

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

/** Remove results */
void clear();

/** map tool was deactivated */
void deactivate();

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

public slots:
/** Remove results */
void clear();

void show();

@@ -91,6 +89,7 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
void copyFeatureAttributes();
void highlightAll();
void highlightLayer();
void clearRubberbands();
void expandAll();
void collapseAll();

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

private:
QMenu *mActionPopup;
QMap<QTreeWidgetItem *, QSharedPointer<QgsRubberBand> > mRubberBands;
QMap<QTreeWidgetItem *, QgsRubberBand * > mRubberBands;
QgsMapCanvas *mCanvas;

QgsVectorLayer *vectorLayer( QTreeWidgetItem *item );

0 comments on commit 96cd236

Please sign in to comment.