Skip to content
Permalink
Browse files

Renamed buttons for bad layers dialog

  • Loading branch information
elpaso committed Nov 2, 2018
1 parent 70d9b6c commit fbea9f5d5033fe2f9838e2e7e65054657d67a3df
Showing with 23 additions and 58 deletions.
  1. +20 −21 src/app/qgshandlebadlayers.cpp
  2. +1 −2 src/app/qgshandlebadlayers.h
  3. +2 −35 src/ui/qgshandlebadlayersbase.ui
@@ -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" ),
@@ -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 );
@@ -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();
@@ -364,7 +378,6 @@ void QgsHandleBadLayers::accept()
{
apply();

/*
if ( mLayerList->rowCount() > 0 &&
QMessageBox::warning( this,
tr( "Unhandled layer will be lost." ),
@@ -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()
@@ -39,7 +39,7 @@ class QPushButton;

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

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

private:
QPushButton *mBrowseButton = nullptr;
@@ -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.
You can’t perform that action at this time.