Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bad layers dialog new button labels and icon #8435

Merged
merged 5 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions src/app/qgsapplayertreeviewmenuprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,6 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()

menu->addSeparator();

// change data source is only supported for vectors and rasters
if ( vlayer || rlayer )
{

QAction *a = new QAction( tr( "Change data source…" ), menu );
connect( a, &QAction::triggered, [ = ]
{
QgisApp::instance()->changeDataSource( layer );
} );
menu->addAction( a );
}

if ( vlayer )
{
QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing();
Expand Down Expand Up @@ -251,6 +239,26 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
}
}

// change data source is only supported for vectors and rasters
if ( vlayer || rlayer )
{

QAction *a = new QAction( tr( "Change data source…" ), menu );
// Disable when layer is editable
if ( layer->isEditable() )
{
a->setEnabled( false );
}
else
{
connect( a, &QAction::triggered, [ = ]
{
QgisApp::instance()->changeDataSource( layer );
} );
}
menu->addAction( a );
}

menu->addSeparator();

if ( layer && layer->isSpatial() )
Expand Down
19 changes: 12 additions & 7 deletions src/app/qgshandlebadlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ void QgsHandleBadLayersHandler::handleBadLayers( const QList<QDomNode> &layers )
QApplication::setOverrideCursor( Qt::ArrowCursor );
QgsHandleBadLayers *dialog = new QgsHandleBadLayers( layers );

dialog->buttonBox->button( QDialogButtonBox::Ignore )->setToolTip( tr( "Import all bad layers unmodified (you can fix them later)." ) );
dialog->buttonBox->button( QDialogButtonBox::Apply )->setToolTip( tr( "Apply fixes to bad layers (remaining bad layers will be removed from the project)." ) );
dialog->buttonBox->button( QDialogButtonBox::Discard )->setToolTip( tr( "Remove all bad layers from the project" ) );
dialog->buttonBox->button( QDialogButtonBox::Ignore )->setToolTip( tr( "Import all unavailable layers unmodified (you can fix them later)." ) );
dialog->buttonBox->button( QDialogButtonBox::Ignore )->setText( tr( "Keep unavailable layers" ) );
dialog->buttonBox->button( QDialogButtonBox::Discard )->setToolTip( tr( "Remove all unavailable layers from the project" ) );
dialog->buttonBox->button( QDialogButtonBox::Discard )->setText( tr( "Remove unavailable layers" ) );
dialog->buttonBox->button( QDialogButtonBox::Discard )->setIcon( QgsApplication::getThemeIcon( "/mActionDeleteSelected.svg" ) );

if ( dialog->layerCount() < layers.size() )
QgisApp::instance()->messageBar()->pushMessage(
tr( "Handle bad layers" ),
tr( "%1 of %2 bad layers were not fixable." )
tr( "Handle unavailable layers" ),
tr( "%1 of %2 unavailable layers were not fixable." )
.arg( layers.size() - dialog->layerCount() )
.arg( layers.size() ),
Qgis::Warning, QgisApp::instance()->messageTimeout() );
Expand All @@ -74,10 +76,13 @@ QgsHandleBadLayers::QgsHandleBadLayers( const QList<QDomNode> &layers )
mBrowseButton = new QPushButton( tr( "Browse" ) );
buttonBox->addButton( mBrowseButton, QDialogButtonBox::ActionRole );
mBrowseButton->setDisabled( true );
mApplyButton = new QPushButton( tr( "Apply changes" ) );
mApplyButton->setToolTip( tr( "Apply fixes to unavailable layers (remaining unavailable layers will be removed from the project)." ) );
buttonBox->addButton( mApplyButton, QDialogButtonBox::ActionRole );

connect( mLayerList, &QTableWidget::itemSelectionChanged, this, &QgsHandleBadLayers::selectionChanged );
connect( mBrowseButton, &QAbstractButton::clicked, this, &QgsHandleBadLayers::browseClicked );
connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsHandleBadLayers::apply );
connect( mApplyButton, &QAbstractButton::clicked, this, &QgsHandleBadLayers::apply );
connect( buttonBox->button( QDialogButtonBox::Ignore ), &QPushButton::clicked, this, &QgsHandleBadLayers::reject );
connect( buttonBox->button( QDialogButtonBox::Discard ), &QPushButton::clicked, this, &QgsHandleBadLayers::accept );

Expand Down Expand Up @@ -349,7 +354,7 @@ void QgsHandleBadLayers::editAuthCfg()
void QgsHandleBadLayers::apply()
{
QgsProject::instance()->layerTreeRegistryBridge()->setEnabled( true );

buttonBox->button( QDialogButtonBox::Ignore )->setEnabled( false );
QList<QgsMapLayer *> toRemove;
for ( const auto &l : QgsProject::instance()->mapLayers( ) )
{
Expand Down
1 change: 1 addition & 0 deletions src/app/qgshandlebadlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class APP_EXPORT QgsHandleBadLayers

private:
QPushButton *mBrowseButton = nullptr;
QPushButton *mApplyButton = nullptr;
const QList<QDomNode> &mLayers;
QList<int> mRows;
QString mVectorFileFilter;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgslayertreeviewbadlayerindicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ QString QgsLayerTreeViewBadLayerIndicatorProvider::iconName( QgsMapLayer *layer
QString QgsLayerTreeViewBadLayerIndicatorProvider::tooltipText( QgsMapLayer *layer )
{
Q_UNUSED( layer );
return tr( "<b>Bad layer!</b><br>Layer data source could not be found. Click to set a new data source" );
return tr( "<b>Unavailable layer!</b><br>Layer data source could not be found. Click to set a new data source" );
}

bool QgsLayerTreeViewBadLayerIndicatorProvider::acceptLayer( QgsMapLayer *layer )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsprojectbadlayerhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

void QgsProjectBadLayerHandler::handleBadLayers( const QList<QDomNode> &layers )
{
QgsApplication::messageLog()->logMessage( QObject::tr( "%1 bad layers found:" ).arg( layers.size() ) );
QgsApplication::messageLog()->logMessage( QObject::tr( "%1 unavailable layers found:" ).arg( layers.size() ) );
Q_FOREACH ( const QDomNode &layer, layers )
{
QgsApplication::messageLog()->logMessage( QObject::tr( " * %1" ).arg( dataSource( layer ) ) );
Expand Down
4 changes: 2 additions & 2 deletions src/ui/qgshandlebadlayersbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Handle Bad Layers</string>
<string>Handle Unavailable Layers</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
Expand All @@ -27,7 +27,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Discard|QDialogButtonBox::Ignore</set>
<set>QDialogButtonBox::Discard|QDialogButtonBox::Ignore</set>
</property>
</widget>
</item>
Expand Down
Binary file modified tests/testdata/projects/bad_layers_test.gpkg
Binary file not shown.