Skip to content

Commit

Permalink
Renamed buttons for bad layers dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Nov 5, 2018
1 parent 70d9b6c commit fbea9f5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 58 deletions.
41 changes: 20 additions & 21 deletions src/app/qgshandlebadlayers.cpp
Expand Up @@ -33,13 +33,18 @@
#include <QPushButton>
#include <QToolButton>
#include <QMessageBox>
#include <QDialogButtonBox>
#include <QUrl>

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" ) );

if ( dialog->layerCount() < layers.size() )
QgisApp::instance()->messageBar()->pushMessage(
tr( "Handle bad layers" ),
Expand Down Expand Up @@ -72,6 +77,8 @@ QgsHandleBadLayers::QgsHandleBadLayers( const QList<QDomNode> &layers )
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( buttonBox->button( QDialogButtonBox::Ignore ), &QPushButton::clicked, this, &QgsHandleBadLayers::reject );
connect( buttonBox->button( QDialogButtonBox::Discard ), &QPushButton::clicked, this, &QgsHandleBadLayers::accept );

mLayerList->clear();
mLayerList->setSortingEnabled( true );
Expand Down Expand Up @@ -340,6 +347,13 @@ void QgsHandleBadLayers::editAuthCfg()

void QgsHandleBadLayers::apply()
{
QList<QgsMapLayer *> toRemove;
for ( const auto &l : QgsProject::instance()->mapLayers( ) )
{
if ( ! l->isValid() )
toRemove << l;
}
QgsProject::instance()->removeMapLayers( toRemove );
for ( int i = 0; i < mLayerList->rowCount(); i++ )
{
int idx = mLayerList->item( i, 0 )->data( Qt::UserRole ).toInt();
Expand All @@ -364,7 +378,6 @@ void QgsHandleBadLayers::accept()
{
apply();

/*
if ( mLayerList->rowCount() > 0 &&
QMessageBox::warning( this,
tr( "Unhandled layer will be lost." ),
Expand All @@ -376,29 +389,15 @@ void QgsHandleBadLayers::accept()
{
return;
}
*/

QDialog::accept();
}

void QgsHandleBadLayers::reject()
{

/*
if ( mLayerList->rowCount() > 0 &&
QMessageBox::warning( this,
tr( "Unhandled layer will be lost." ),
tr( "There are still %n unhandled layer(s), that will be lost if you closed now.",
"unhandled layers",
mLayerList->rowCount() ),
QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Cancel ) == QMessageBox::Cancel )
QList<QgsMapLayer *> toRemove;
for ( const auto &l : QgsProject::instance()->mapLayers( ) )
{
return;
if ( ! l->isValid() )
toRemove << l;
}
*/
mLayerList->clear();

QDialog::reject();
QDialog::accept();
}

int QgsHandleBadLayers::layerCount()
Expand Down
3 changes: 1 addition & 2 deletions src/app/qgshandlebadlayers.h
Expand Up @@ -39,7 +39,7 @@ class QPushButton;

class APP_EXPORT QgsHandleBadLayers
: public QDialog
, private Ui::QgsHandleBadLayersBase
, public Ui::QgsHandleBadLayersBase
{
Q_OBJECT

Expand All @@ -54,7 +54,6 @@ class APP_EXPORT QgsHandleBadLayers
void editAuthCfg();
void apply();
void accept() override;
void reject() override;

private:
QPushButton *mBrowseButton = nullptr;
Expand Down
37 changes: 2 additions & 35 deletions src/ui/qgshandlebadlayersbase.ui
Expand Up @@ -27,45 +27,12 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Discard|QDialogButtonBox::Ignore</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QgsHandleBadLayersBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QgsHandleBadLayersBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

0 comments on commit fbea9f5

Please sign in to comment.