Skip to content

Commit

Permalink
Switch identify results dock to use a toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 31, 2015
1 parent 3104195 commit fb3f953
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 183 deletions.
40 changes: 17 additions & 23 deletions src/app/qgsidentifyresultsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand All @@ -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" ) );
Expand Down Expand Up @@ -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() ) );
}

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

Expand Down Expand Up @@ -863,7 +857,7 @@ void QgsIdentifyResultsDialog::show()
}

// expand all if enabled
if ( mExpandNewToolButton->isChecked() )
if ( mExpandNewAction->isChecked() )
{
lstResults->expandAll();
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 )
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsidentifyresultsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
Loading

0 comments on commit fb3f953

Please sign in to comment.