Skip to content

Commit

Permalink
[FEATURE] more identify changes:
Browse files Browse the repository at this point in the history
- 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/qgis@12309 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 2, 2009
1 parent 4820fa0 commit 513b068
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
34 changes: 26 additions & 8 deletions src/app/qgsidentifyresults.cpp
Expand Up @@ -123,6 +123,7 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q

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

Expand Down Expand Up @@ -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() ) );

Expand Down Expand Up @@ -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++ )
Expand All @@ -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 )
{
Expand All @@ -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 )
Expand Down Expand Up @@ -558,7 +576,7 @@ void QgsIdentifyResults::handleCurrentItemChanged( QTreeWidgetItem *current, QTr
}
else
{
mRubberBands.clear();
clearRubberbands();
highlightFeature( current );
}
}
Expand All @@ -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 ) );
}
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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 );
}
}

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

mRubberBands.clear();
clearRubberbands();

for ( int i = 0; i < layItem->childCount(); i++ )
{
Expand Down
9 changes: 4 additions & 5 deletions src/app/qgsidentifyresults.h
Expand Up @@ -25,7 +25,6 @@

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

class QCloseEvent;
class QTreeWidgetItem;
Expand Down Expand Up @@ -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();

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

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

void show();

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

Expand All @@ -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 );
Expand Down

0 comments on commit 513b068

Please sign in to comment.