Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
identify results:
* restore identify dock (implements #10152)
* add clear button (implements #10149)
* automatically set only item current
* move controls to bottom
  • Loading branch information
jef-n committed May 2, 2014
1 parent 366fdbc commit 0c52039
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 153 deletions.
2 changes: 2 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -635,6 +635,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
* @note added in 2.1 */
void refreshActionFeatureAction();

QMenu *panelMenu() { return mPanelMenu; }

protected:

//! Handle state changes (WindowTitleChange)
Expand Down
104 changes: 25 additions & 79 deletions src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -177,22 +177,6 @@ QSize QgsIdentifyResultsWebView::sizeHint() const
return s;
}

class QgsIdentifyResultsDock : public QDockWidget
{
public:
QgsIdentifyResultsDock( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 )
: QDockWidget( title, parent, flags )
{
setObjectName( "IdentifyResultsTableDock" ); // set object name so the position can be saved
}

virtual void closeEvent( QCloseEvent *e )
{
Q_UNUSED( e );
deleteLater();
}
};

QgsIdentifyResultsFeatureItem::QgsIdentifyResultsFeatureItem( const QgsFields &fields, const QgsFeature &feature, const QgsCoordinateReferenceSystem &crs, const QStringList & strings )
: QTreeWidgetItem( strings )
, mFields( fields )
Expand Down Expand Up @@ -271,11 +255,14 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
mOpenFormButton->setDisabled( true );

QSettings mySettings;
restoreGeometry( mySettings.value( "/Windows/Identify/geometry" ).toByteArray() );
mDock = new QgsIdentifyResultsDock( tr( "Identify Results" ) , QgisApp::instance() );
mDock = new QDockWidget( tr( "Identify Results" ) , QgisApp::instance() );
mDock->setObjectName( "IdentifyResultsDock" );
mDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
mDock->setWidget( this );
QgisApp::instance()->addDockWidget( Qt::LeftDockWidgetArea, mDock );
if ( !QgisApp::instance()->restoreDockWidget( mDock ) )
QgisApp::instance()->addDockWidget( Qt::LeftDockWidgetArea, mDock );
else
QgisApp::instance()->panelMenu()->addAction( mDock->toggleViewAction() );

mExpandNewToolButton->setChecked( mySettings.value( "/Map/identifyExpand", false ).toBool() );
mCopyToolButton->setEnabled( false );
Expand All @@ -299,8 +286,6 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
cmbIdentifyMode->setCurrentIndex( cmbIdentifyMode->findData( identifyMode ) );
cbxAutoFeatureForm->setChecked( mySettings.value( "/Map/identifyAutoFeatureForm", false ).toBool() );

connect( buttonBox, SIGNAL( rejected() ), this, SLOT( close() ) );

connect( lstResults, SIGNAL( itemExpanded( QTreeWidgetItem* ) ),
this, SLOT( itemExpanded( QTreeWidgetItem* ) ) );

Expand All @@ -310,17 +295,19 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
connect( lstResults, SIGNAL( itemClicked( QTreeWidgetItem*, int ) ),
this, SLOT( itemClicked( QTreeWidgetItem*, int ) ) );

connect( mPrintToolButton, SIGNAL( clicked() ),
this, SLOT( printCurrentItem() ) );

connect( mOpenFormButton, SIGNAL( clicked() ),
this, SLOT( featureForm() ) );

connect( mPrintToolButton, SIGNAL( clicked() ), this, SLOT( printCurrentItem() ) );
connect( mOpenFormButton, SIGNAL( clicked() ), this, SLOT( featureForm() ) );
connect( mClearToolButton, SIGNAL( clicked() ), this, SLOT( clear() ) );
connect( mHelpToolButton, SIGNAL( clicked() ), this, SLOT( helpRequested() ) );
}

QgsIdentifyResultsDialog::~QgsIdentifyResultsDialog()
{
clearHighlights();

QSettings settings;
settings.setValue( "/Windows/Identify/columnWidth", lstResults->columnWidth( 0 ) );

if ( mActionPopup )
delete mActionPopup;
}
Expand Down Expand Up @@ -653,17 +640,19 @@ void QgsIdentifyResultsDialog::show()
QTreeWidgetItem *layItem = lstResults->topLevelItem( 0 );
QTreeWidgetItem *featItem = layItem->child( 0 );

if ( lstResults->topLevelItemCount() == 1 &&
layItem->childCount() == 1 &&
QSettings().value( "/Map/identifyAutoFeatureForm", false ).toBool() )
if ( lstResults->topLevelItemCount() == 1 && layItem->childCount() == 1 )
{
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layItem->data( 0, Qt::UserRole ).value<QObject *>() );
if ( layer )
lstResults->setCurrentItem( featItem );

if ( QSettings().value( "/Map/identifyAutoFeatureForm", false ).toBool() )
{
// if this is the only feature and it's on a vector layer
// don't show the form dialog instead of the results window
lstResults->setCurrentItem( featItem );
featureForm();
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layItem->data( 0, Qt::UserRole ).value<QObject *>() );
if ( layer )
{
// if this is the only feature and it's on a vector layer
// don't show the form dialog instead of the results window
featureForm();
}
}
}

Expand All @@ -682,30 +671,6 @@ void QgsIdentifyResultsDialog::show()
raise();
}

// Slot called when user clicks the Close button
// (saves the current window size/position)
void QgsIdentifyResultsDialog::close()
{
clear();

delete mActionPopup;
mActionPopup = 0;

saveWindowLocation();
done( 0 );

mDock->close();
}

// Save the current window size/position before closing
// from window menu or X in titlebar
void QgsIdentifyResultsDialog::closeEvent( QCloseEvent *e )
{
// We'll close in our own good time thanks...
e->ignore();
close();
}

void QgsIdentifyResultsDialog::itemClicked( QTreeWidgetItem *item, int column )
{
Q_UNUSED( column );
Expand Down Expand Up @@ -852,15 +817,6 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent* event )
mActionPopup->popup( event->globalPos() );
}

// Save the current window location (store in ~/.qt/qgisrc)
void QgsIdentifyResultsDialog::saveWindowLocation()
{
QSettings settings;
settings.setValue( "/Windows/Identify/geometry", saveGeometry() );
// first column width
settings.setValue( "/Windows/Identify/columnWidth", lstResults->columnWidth( 0 ) );
}

void QgsIdentifyResultsDialog::setColumnText( int column, const QString & label )
{
QTreeWidgetItem* header = lstResults->headerItem();
Expand Down Expand Up @@ -1154,11 +1110,6 @@ void QgsIdentifyResultsDialog::layerDestroyed()

disconnectLayer( theSender );
delete layerItem( theSender );

if ( lstResults->topLevelItemCount() == 0 )
{
close();
}
}

void QgsIdentifyResultsDialog::disconnectLayer( QObject *layer )
Expand Down Expand Up @@ -1205,11 +1156,6 @@ void QgsIdentifyResultsDialog::featureDeleted( QgsFeatureId fid )
{
delete layItem;
}

if ( lstResults->topLevelItemCount() == 0 )
{
close();
}
}

void QgsIdentifyResultsDialog::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &val )
Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsidentifyresultsdialog.h
Expand Up @@ -127,8 +127,6 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
/** map tool was activated */
void activate();

void closeEvent( QCloseEvent *e );

signals:
void selectedFeatureChanged( QgsVectorLayer *, QgsFeatureId featureId );

Expand All @@ -145,7 +143,6 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti

void show();

void close();
void contextMenuEvent( QContextMenuEvent* );

void layerDestroyed();
Expand Down Expand Up @@ -178,7 +175,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti

QTreeWidgetItem *retrieveAttributes( QTreeWidgetItem *item, QgsAttributeMap &attributes, int &currentIdx );

void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
void helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

void on_cmbIdentifyMode_currentIndexChanged( int index );

Expand Down Expand Up @@ -221,7 +218,6 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti

void setColumnText( int column, const QString & label );
void expandColumnsToFit();
void saveWindowLocation();

void highlightFeature( QTreeWidgetItem *item );

Expand Down
139 changes: 70 additions & 69 deletions src/ui/qgsidentifyresultsbase.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>317</width>
<width>341</width>
<height>409</height>
</rect>
</property>
Expand All @@ -17,47 +17,6 @@
<property name="margin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="mIdentifyModeHorizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cmbIdentifyMode"/>
</item>
<item>
<spacer name="horizontalSpacer_43">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="mOpenFormButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxAutoFeatureForm">
<property name="text">
<string>Auto open form</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="lstResults">
<property name="lineWidth">
Expand Down Expand Up @@ -123,6 +82,34 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mOpenFormButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionPropertyItem.png</normaloff>:/images/themes/default/mActionPropertyItem.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mClearToolButton">
<property name="toolTip">
<string>Clear Results</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionDeselectAll.svg</normaloff>:/images/themes/default/mActionDeselectAll.svg</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mCopyToolButton">
<property name="toolTip">
Expand Down Expand Up @@ -174,45 +161,59 @@
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QToolButton" name="mHelpToolButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Help</set>
<property name="text">
<string>Help</string>
</property>
<property name="centerButtons">
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="mIdentifyModeHorizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cmbIdentifyMode"/>
</item>
<item>
<spacer name="horizontalSpacer_43">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="cbxAutoFeatureForm">
<property name="text">
<string>Auto open form</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QgsIdentifyResultsBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>261</x>
<y>298</y>
</hint>
<hint type="destinationlabel">
<x>204</x>
<y>313</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

4 comments on commit 0c52039

@slarosa
Copy link
Member

@slarosa slarosa commented on 0c52039 May 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jef-n, it looks like after having activated the identify result dockwidget, if the user close it, it is not longer possible show up the identify dialog. This is happening after this commit. Am I missing something?

Thanks!

@NathanW2
Copy link
Member

@NathanW2 NathanW2 commented on 0c52039 May 3, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jef-n
Copy link
Member Author

@jef-n jef-n commented on 0c52039 May 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you close the dock, you can reopen it in the panel menu - just like with any other dock.

@slarosa
Copy link
Member

@slarosa slarosa commented on 0c52039 May 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you close the dock, you can reopen it in the panel menu - just like with any other dock.

Sure, I was wondering.... shouldn't automatically be shown by clicking on the map?
I would expect a similar behavior to how it was before.

Please sign in to comment.