Switch identify results dock to use a toolbar

This commit is contained in:
Nyall Dawson 2015-05-31 10:19:53 +10:00
parent 310419566b
commit fb3f95316f
3 changed files with 151 additions and 183 deletions

View File

@ -255,13 +255,7 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
{
setupUi( this );
mExpandToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionExpandTree.svg" ) );
mCollapseToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionCollapseTree.svg" ) );
mExpandNewToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionExpandNewTree.svg" ) );
mCopyToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionEditCopy.png" ) );
mPrintToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionFilePrint.png" ) );
mOpenFormButton->setIcon( QgsApplication::getThemeIcon( "/mActionPropertyItem.svg" ) );
mOpenFormButton->setDisabled( true );
mOpenFormAction->setDisabled( true );
QSettings mySettings;
mDock = new QDockWidget( tr( "Identify Results" ), QgisApp::instance() );
@ -273,8 +267,8 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
else
QgisApp::instance()->panelMenu()->addAction( mDock->toggleViewAction() );
mExpandNewToolButton->setChecked( mySettings.value( "/Map/identifyExpand", false ).toBool() );
mCopyToolButton->setEnabled( false );
mExpandNewAction->setChecked( mySettings.value( "/Map/identifyExpand", false ).toBool() );
mActionCopy->setEnabled( false );
lstResults->setColumnCount( 2 );
lstResults->sortByColumn( -1 );
setColumnText( 0, tr( "Feature" ) );
@ -327,9 +321,9 @@ 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( mClearToolButton, SIGNAL( clicked() ), this, SLOT( clear() ) );
connect( mActionPrint, SIGNAL( triggered( bool ) ), this, SLOT( printCurrentItem() ) );
connect( mOpenFormAction, SIGNAL( triggered( bool ) ), this, SLOT( featureForm() ) );
connect( mClearResultsAction, SIGNAL( triggered( bool ) ), this, SLOT( clear() ) );
connect( mHelpToolButton, SIGNAL( clicked() ), this, SLOT( helpRequested() ) );
}
@ -826,8 +820,8 @@ void QgsIdentifyResultsDialog::editingToggled()
continue;
QTreeWidgetItem *editItem = actions->child( j );
mOpenFormButton->setToolTip( vlayer->isEditable() ? tr( "Edit feature form" ) : tr( "View feature form" ) );
editItem->setText( 1, mOpenFormButton->toolTip() );
mOpenFormAction->setToolTip( vlayer->isEditable() ? tr( "Edit feature form" ) : tr( "View feature form" ) );
editItem->setText( 1, mOpenFormAction->toolTip() );
}
}
@ -863,7 +857,7 @@ void QgsIdentifyResultsDialog::show()
}
// expand all if enabled
if ( mExpandNewToolButton->isChecked() )
if ( mExpandNewAction->isChecked() )
{
lstResults->expandAll();
}
@ -1080,7 +1074,7 @@ void QgsIdentifyResultsDialog::clear()
// keep it visible but disabled, it can switch from disabled/enabled
// after raster format change
mPrintToolButton->setDisabled( true );
mActionPrint->setDisabled( true );
}
void QgsIdentifyResultsDialog::updateViewModes()
@ -1302,16 +1296,16 @@ void QgsIdentifyResultsDialog::handleCurrentItemChanged( QTreeWidgetItem *curren
{
Q_UNUSED( previous );
mPrintToolButton->setEnabled( false );
mActionPrint->setEnabled( false );
QgsIdentifyResultsFeatureItem *featItem = dynamic_cast<QgsIdentifyResultsFeatureItem *>( featureItem( current ) );
mCopyToolButton->setEnabled( featItem && featItem->feature().isValid() );
mOpenFormButton->setEnabled( featItem && featItem->feature().isValid() );
mActionCopy->setEnabled( featItem && featItem->feature().isValid() );
mOpenFormAction->setEnabled( featItem && featItem->feature().isValid() );
QgsVectorLayer *vlayer = vectorLayer( current );
if ( vlayer )
{
mOpenFormButton->setToolTip( vlayer->isEditable() ? tr( "Edit feature form" ) : tr( "View feature form" ) );
mOpenFormAction->setToolTip( vlayer->isEditable() ? tr( "Edit feature form" ) : tr( "View feature form" ) );
}
if ( !current )
@ -1326,7 +1320,7 @@ void QgsIdentifyResultsDialog::handleCurrentItemChanged( QTreeWidgetItem *curren
QgsIdentifyResultsWebViewItem *wv = dynamic_cast<QgsIdentifyResultsWebViewItem*>( current->child( i ) );
if ( wv != 0 )
{
mPrintToolButton->setEnabled( true );
mActionPrint->setEnabled( true );
break;
}
}
@ -1758,13 +1752,13 @@ void QgsIdentifyResultsDialog::on_cbxAutoFeatureForm_toggled( bool checked )
settings.setValue( "/Map/identifyAutoFeatureForm", checked );
}
void QgsIdentifyResultsDialog::on_mExpandNewToolButton_toggled( bool checked )
void QgsIdentifyResultsDialog::on_mExpandNewAction_triggered( bool checked )
{
QSettings settings;
settings.setValue( "/Map/identifyExpand", checked );
}
void QgsIdentifyResultsDialog::on_mCopyToolButton_clicked( bool checked )
void QgsIdentifyResultsDialog::on_mActionCopy_triggered( bool checked )
{
Q_UNUSED( checked );
copyFeature();

View File

@ -199,14 +199,14 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
void on_cmbViewMode_currentIndexChanged( int index );
void on_mExpandNewToolButton_toggled( bool checked );
void on_mExpandNewAction_triggered( bool checked );
void on_cbxAutoFeatureForm_toggled( bool checked );
void on_mExpandToolButton_clicked( bool checked ) { Q_UNUSED( checked ); expandAll(); }
void on_mCollapseToolButton_clicked( bool checked ) { Q_UNUSED( checked ); collapseAll(); }
void on_mExpandAction_triggered( bool checked ) { Q_UNUSED( checked ); expandAll(); }
void on_mCollapseAction_triggered( bool checked ) { Q_UNUSED( checked ); collapseAll(); }
void on_mCopyToolButton_clicked( bool checked );
void on_mActionCopy_triggered( bool checked );
void formatChanged( int index );

View File

@ -17,7 +17,16 @@
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -30,165 +39,37 @@
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>5</number>
<widget class="QToolBar" name="mIdentifyToolbar">
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="rightMargin">
<number>5</number>
<property name="floatable">
<bool>false</bool>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QToolButton" name="mExpandToolButton">
<property name="toolTip">
<string>Expand tree</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionExpandTree.png</normaloff>../../images/themes/default/mActionExpandTree.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mCollapseToolButton">
<property name="toolTip">
<string>Collapse tree</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionCollapseTree.png</normaloff>../../images/themes/default/mActionCollapseTree.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mExpandNewToolButton">
<property name="toolTip">
<string>New results will be expanded by default.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionExpandNewTree.png</normaloff>../../images/themes/default/mActionExpandNewTree.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</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>
<property name="autoRaise">
<bool>true</bool>
</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>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mCopyToolButton">
<property name="toolTip">
<string>Copy selected feature to clipboard.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionEditCopy.png</normaloff>:/images/themes/default/mActionEditCopy.png</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mPrintToolButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Print selected HTML response.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionFilePrint.png</normaloff>../../images/themes/default/mActionFilePrint.png</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<addaction name="mExpandAction"/>
<addaction name="mCollapseAction"/>
<addaction name="mExpandNewAction"/>
<addaction name="mOpenFormAction"/>
<addaction name="mClearResultsAction"/>
<addaction name="mActionCopy"/>
<addaction name="mActionPrint"/>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="lstResults">
@ -268,7 +149,16 @@
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -362,6 +252,90 @@
</layout>
</item>
</layout>
<action name="mExpandAction">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionExpandTree.svg</normaloff>:/images/themes/default/mActionExpandTree.svg</iconset>
</property>
<property name="text">
<string>Expand Tree</string>
</property>
</action>
<action name="mCollapseAction">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionCollapseTree.svg</normaloff>:/images/themes/default/mActionCollapseTree.svg</iconset>
</property>
<property name="text">
<string>Collapse Tree</string>
</property>
<property name="toolTip">
<string>Collapse Tree</string>
</property>
</action>
<action name="mExpandNewAction">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionExpandNewTree.svg</normaloff>:/images/themes/default/mActionExpandNewTree.svg</iconset>
</property>
<property name="text">
<string>Expand New Results</string>
</property>
<property name="toolTip">
<string>New results will be expanded by default.</string>
</property>
</action>
<action name="mOpenFormAction">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionPropertyItem.svg</normaloff>:/images/themes/default/mActionPropertyItem.svg</iconset>
</property>
<property name="text">
<string>Open Form</string>
</property>
<property name="toolTip">
<string>Open Form</string>
</property>
</action>
<action name="mClearResultsAction">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionDeselectAll.svg</normaloff>:/images/themes/default/mActionDeselectAll.svg</iconset>
</property>
<property name="text">
<string>Clear Results</string>
</property>
<property name="toolTip">
<string>Clear Results</string>
</property>
</action>
<action name="mActionCopy">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionEditCopy.png</normaloff>:/images/themes/default/mActionEditCopy.png</iconset>
</property>
<property name="text">
<string>Copy Feature</string>
</property>
<property name="toolTip">
<string>Copy selected feature to clipboard.</string>
</property>
</action>
<action name="mActionPrint">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionFilePrint.png</normaloff>:/images/themes/default/mActionFilePrint.png</iconset>
</property>
<property name="text">
<string>Print Response</string>
</property>
<property name="toolTip">
<string>Print selected HTML response.</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>