Skip to content

Commit 93fadb5

Browse files
author
telwertowski
committedJan 21, 2007
Convert six dialogs to Qt 4.2 StandardButton API.
Also use the full accept code path rather than overriding accept to do apply but look like reject to the caller. Remove deletion of the raster layer from the reaster properties destructor (which was called only after accept and may be why accept was avoided). git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6447 c8812cc2-4d05-0410-92ff-de0c093fc19c

18 files changed

+160
-542
lines changed
 

‎src/app/legend/qgslegend.cpp

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -760,66 +760,47 @@ void QgsLegend::legendLayerShowProperties()
760760
//QgsDebugMsg("Showing layer properties dialog");
761761

762762
QgsMapLayer* ml = llf->layer();
763-
763+
764+
/*
765+
TODO: Consider reusing the property dialogs again.
766+
Sometimes around mid 2005, the property dialogs were saved for later reuse;
767+
this resulted in a time savings when reopening the dialog. The code below
768+
cannot be used as is, however, simply by saving the dialog pointer here.
769+
Either the map layer needs to be passed as an argument to sync or else
770+
a separate copy of the dialog pointer needs to be stored with each layer.
771+
*/
772+
764773
if (ml->type() == QgsMapLayer::RASTER)
765774
{
766-
QgsRasterLayerProperties *rlp = new QgsRasterLayerProperties(ml);
767-
connect(rlp, SIGNAL(refreshLegend(QString)), this, SLOT(refreshLayerSymbology(QString)));
768-
if (rlp->exec())
775+
QgsRasterLayerProperties *rlp = NULL; // See note above about reusing this
776+
if (rlp)
769777
{
770-
delete rlp;
771-
QCoreApplication::processEvents();
778+
rlp->sync();
772779
}
773-
774-
/*
775-
void QgsRasterLayer::showLayerProperties()
776-
{
777-
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
778-
if ( ! mLayerProperties )
779-
{
780-
mLayerProperties = new QgsRasterLayerProperties(this);
781-
QgsDebugMsg("Creating new raster properties dialog instance");
782-
}
783-
784-
mLayerProperties->sync();
785-
mLayerProperties->raise();
786-
mLayerProperties->show();
787-
qApp->restoreOverrideCursor();
788-
} // QgsRasterLayer::showLayerProperties()
789-
*/
780+
else
781+
{
782+
rlp = new QgsRasterLayerProperties(ml);
783+
connect(rlp, SIGNAL(refreshLegend(QString)), this, SLOT(refreshLayerSymbology(QString)));
784+
}
785+
rlp->exec();
786+
delete rlp; // delete since dialog cannot be reused without updating code
790787
}
791788
else // VECTOR
792789
{
793790
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>(ml);
794-
795-
QgsVectorLayerProperties* vlp = new QgsVectorLayerProperties(vlayer);
796-
connect(vlp, SIGNAL(refreshLegend(QString)), this, SLOT(refreshLayerSymbology(QString)));
797-
if (vlp->exec())
791+
792+
QgsVectorLayerProperties *vlp = NULL; // See note above about reusing this
793+
if (vlp)
798794
{
799-
delete vlp;
800-
QCoreApplication::processEvents();
795+
vlp->reset();
801796
}
802-
803-
/*
804-
// TODO: this was previous implementation which saved the instance of the dialog
805-
806-
// Set wait cursor while the property dialog is created
807-
// and initialized
808-
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
809-
810-
QgsVectorLayerProperties* propertiesDialog = new QgsVectorLayerProperties(vlayer);
811-
812-
// Make sure that the UI starts out with the correct display
813-
// field value
814-
propertiesDialog->setDisplayField(displayField());
815-
816-
propertiesDialog->reset();
817-
propertiesDialog->raise();
818-
propertiesDialog->show();
819-
820-
// restore normal cursor
821-
qApp->restoreOverrideCursor();
822-
*/
797+
else
798+
{
799+
vlp = new QgsVectorLayerProperties(vlayer);
800+
connect(vlp, SIGNAL(refreshLegend(QString)), this, SLOT(refreshLayerSymbology(QString)));
801+
}
802+
vlp->exec();
803+
delete vlp; // delete since dialog cannot be reused without updating code
823804
}
824805

825806
llf->updateLegendItem();

‎src/app/qgsgeomtypedialog.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ QgsGeomTypeDialog::QgsGeomTypeDialog(QWidget *parent, Qt::WFlags fl)
2323
: QDialog(parent, fl)
2424
{
2525
setupUi(this);
26-
connect(mOkButton, SIGNAL(clicked()), this, SLOT(accept()));
27-
connect(mCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
26+
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
27+
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
2828

2929
mPointRadioButton->setChecked(true);
3030
mAttributeView->removeColumn(0);
@@ -34,6 +34,8 @@ QgsGeomTypeDialog::QgsGeomTypeDialog(QWidget *parent, Qt::WFlags fl)
3434
/*mFileFormatComboBox->insertItem("Comma Separated Value");
3535
mFileFormatComboBox->insertItem("GML");
3636
mFileFormatComboBox->insertItem("Mapinfo File");*/
37+
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
38+
mOkButton->setEnabled(false);
3739
}
3840

3941
QgsGeomTypeDialog::~QgsGeomTypeDialog()
@@ -86,10 +88,11 @@ void QgsGeomTypeDialog::on_mRemoveAttributeButton_clicked()
8688

8789
}
8890

89-
void QgsGeomTypeDialog::on_btnHelp_clicked()
91+
void QgsGeomTypeDialog::on_buttonBox_helpRequested()
9092
{
9193
QgsContextHelp::run(context_id);
9294
}
95+
9396
void QgsGeomTypeDialog::attributes(std::list<std::pair<QString, QString> >& at) const
9497
{
9598
Q3ListViewItemIterator it(mAttributeView);

‎src/app/qgsgeomtypedialog.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ class QgsGeomTypeDialog: public QDialog, private Ui::QgsGeomTypeDialogBase
4040
protected slots:
4141
void on_mAddAttributeButton_clicked();
4242
void on_mRemoveAttributeButton_clicked();
43-
void on_btnHelp_clicked();
43+
void on_buttonBox_helpRequested();
44+
4445
private:
46+
QAbstractButton *mOkButton;
4547
static const int context_id = 165149618;
4648

4749
};

‎src/app/qgsoptions.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
4343
connect(cmbTheme, SIGNAL(activated(const QString&)), this, SLOT(themeChanged(const QString&)));
4444
connect(cmbTheme, SIGNAL(highlighted(const QString&)), this, SLOT(themeChanged(const QString&)));
4545
connect(cmbTheme, SIGNAL(textChanged(const QString&)), this, SLOT(themeChanged(const QString&)));
46-
connect(buttonOk, SIGNAL(clicked()), this, SLOT(saveOptions()));
47-
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
46+
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
47+
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
48+
connect(this, SIGNAL(accepted()), this, SLOT(saveOptions()));
4849

4950
qparent = parent;
5051
// read the current browser and set it
@@ -243,17 +244,9 @@ void QgsOptions::saveOptions()
243244
settings.writeEntry("/qgis/zoom_factor", spinZoomFactor->value());
244245

245246
settings.setValue("/qgis/splitterRedraw", cbxSplitterRedraw->isChecked());
246-
247-
//all done
248-
accept();
249247
}
250248

251249

252-
253-
254-
255-
256-
257250
void QgsOptions::on_btnFindBrowser_clicked()
258251
{
259252
QString filter;

‎src/app/qgsprojectproperties.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ QgsProjectProperties::QgsProjectProperties(QgsMapCanvas* mapCanvas, QWidget *par
4141
: QDialog(parent, fl), mMapCanvas(mapCanvas)
4242
{
4343
setupUi(this);
44-
45-
connect(buttonApply, SIGNAL(clicked()), this, SLOT(apply()));
46-
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
47-
connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
44+
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
45+
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
46+
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
47+
connect(this, SIGNAL(accepted()), this, SLOT(apply()));
4848

4949
///////////////////////////////////////////////////////////
5050
// Properties stored in map canvas's QgsMapRender
@@ -253,21 +253,14 @@ void QgsProjectProperties::apply()
253253
emit refresh();
254254
}
255255

256-
//when user clicks ok
257-
void QgsProjectProperties::accept()
258-
{
259-
apply();
260-
close();
261-
}
262-
263256
bool QgsProjectProperties::isProjected()
264257
{
265258
return cbxProjectionEnabled->isChecked();
266259
}
267260

268261
void QgsProjectProperties::showProjectionsTab()
269262
{
270-
tabWidget2->setCurrentPage(1);
263+
tabWidget->setCurrentPage(1);
271264
}
272265

273266
void QgsProjectProperties::on_pbnDigitisedLineColour_clicked()
@@ -296,7 +289,8 @@ void QgsProjectProperties::on_pbnCanvasColor_clicked()
296289
pbnCanvasColor->setColor(color);
297290
}
298291
}
299-
void QgsProjectProperties::on_pbnHelp_clicked()
292+
293+
void QgsProjectProperties::on_buttonBox_helpRequested()
300294
{
301295
std::cout << "running help" << std::endl;
302296
QgsContextHelp::run(context_id);

‎src/app/qgsprojectproperties.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,16 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
5757

5858
/*! Accessor for projection */
5959
QString projectionWKT();
60+
6061
/*! Indicates that the projection switch is on */
6162
bool isProjected();
63+
6264
public slots:
6365
/*!
64-
* Slot called when apply button is pressed
66+
* Slot called when apply button is pressed or dialog is accepted
6567
*/
6668
void apply();
67-
/*!
68-
* Slot called when ok button pressed (inherits from gui base)
69-
*/
70-
void accept();
69+
7170
/*!
7271
* Slot to show the projections tab when the dialog is opened
7372
*/
@@ -91,11 +90,12 @@ public slots:
9190
/*!
9291
* Slot to show the context help for this dialog
9392
*/
94-
void on_pbnHelp_clicked();
93+
void on_buttonBox_helpRequested();
9594

9695
signals:
9796
//! Signal used to inform listeners that the mouse display precision may have changed
9897
void displayPrecisionChanged();
98+
9999
//! let listening canvases know to refresh
100100
void refresh();
101101

‎src/app/qgsrasterlayerproperties.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer *lyr, QWidget *pa
5454
}
5555

5656
setupUi(this);
57-
connect(buttonApply, SIGNAL(clicked()), this, SLOT(apply()));
58-
connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
59-
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
57+
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
58+
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
59+
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
60+
connect(this, SIGNAL(accepted()), this, SLOT(apply()));
6061
connect(sliderTransparency, SIGNAL(valueChanged(int)), this, SLOT(sliderTransparency_valueChanged(int)));
6162

6263
// set up the scale based layer visibility stuff....
@@ -265,7 +266,6 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer *lyr, QWidget *pa
265266

266267
QgsRasterLayerProperties::~QgsRasterLayerProperties()
267268
{
268-
delete rasterLayer;
269269
}
270270

271271

@@ -437,11 +437,6 @@ void QgsRasterLayerProperties::apply()
437437
rasterLayer->triggerRepaint();
438438
}//apply
439439

440-
void QgsRasterLayerProperties::accept()
441-
{
442-
apply();
443-
close();
444-
}//accept
445440
void QgsRasterLayerProperties::sliderTransparency_valueChanged(int theValue)
446441
{
447442
//set the transparency percentage label to a suitable value
@@ -450,10 +445,6 @@ void QgsRasterLayerProperties::sliderTransparency_valueChanged(int theValue)
450445
}//sliderTransparency_valueChanged
451446

452447

453-
454-
455-
456-
457448
void QgsRasterLayerProperties::on_rbtnSingleBand_toggled(bool)
458449
{}
459450

@@ -1143,7 +1134,7 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()
11431134

11441135
leSpatialRefSys->setText(rasterLayer->srs().proj4String());
11451136
}
1146-
void QgsRasterLayerProperties::on_buttonHelp_clicked()
1137+
void QgsRasterLayerProperties::on_buttonBox_helpRequested()
11471138
{
11481139
QgsContextHelp::run(context_id);
11491140
}

‎src/app/qgsrasterlayerproperties.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
4646
public slots:
4747
/** \brief Applies the settings made in the dialog without closing the box */
4848
void apply();
49-
/** \bried Apply the settings made and close the dialog. */
50-
void accept();
5149
/** \brief slot executed when the transparency level changes. */
5250
void sliderTransparency_valueChanged( int );
5351
/** \brief slot executed when the max red level changes. */
@@ -61,7 +59,7 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
6159
/** Override the SRS specified when the layer was loaded */
6260
void on_pbnChangeSpatialRefSys_clicked();
6361
/** Help button */
64-
void on_buttonHelp_clicked();
62+
void on_buttonBox_helpRequested();
6563

6664
signals:
6765

‎src/app/qgsvectorlayerproperties.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(QgsVectorLayer * lyr,
4545
mRendererDialog(0)
4646
{
4747
setupUi(this);
48+
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
49+
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
50+
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
51+
connect(this, SIGNAL(accepted()), this, SLOT(apply()));
52+
4853
// Create the Label dialog tab
4954
QVBoxLayout *layout = new QVBoxLayout( labelOptionsFrame );
5055
layout->setMargin(0);
@@ -64,7 +69,6 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(QgsVectorLayer * lyr,
6469
actionLayout->addWidget( actionDialog );
6570

6671
reset();
67-
pbnOK->setFocus();
6872
if(layer->getDataProvider())//enable spatial index button group if supported by provider
6973
{
7074
int capabilities=layer->getDataProvider()->capabilities();
@@ -240,20 +244,12 @@ void QgsVectorLayerProperties::reset( void )
240244
// methods reimplemented from qt designer base class
241245
//
242246

243-
void QgsVectorLayerProperties::on_pbnCancel_clicked()
244-
{
245-
reject();
246-
}
247-
void QgsVectorLayerProperties::on_btnHelp_clicked()
247+
void QgsVectorLayerProperties::on_buttonBox_helpRequested()
248248
{
249249
QgsContextHelp::run(context_id);
250250
}
251-
void QgsVectorLayerProperties::on_pbnOK_clicked()
252-
{
253-
on_pbnApply_clicked();
254-
close(true);
255-
}
256-
void QgsVectorLayerProperties::on_pbnApply_clicked()
251+
252+
void QgsVectorLayerProperties::apply()
257253
{
258254
//
259255
// Set up sql subset query if applicable

‎src/app/qgsvectorlayerproperties.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,14 @@ class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPrope
5252
void sliderTransparency_valueChanged(int theValue);
5353
/** Toggles on the label check box */
5454
void setLabelCheckBox();
55-
55+
/** Called when apply button is pressed or dialog is accepted */
56+
void apply();
57+
5658
//
5759
//methods reimplemented from qt designer base class
5860
//
5961

60-
61-
void on_pbnCancel_clicked();
62-
void on_pbnOK_clicked();
63-
void on_pbnApply_clicked();
64-
void on_btnHelp_clicked();
62+
void on_buttonBox_helpRequested();
6563
void on_pbnQueryBuilder_clicked();
6664
void on_pbnIndex_clicked();
6765
void on_pbnChangeSpatialRefSys_clicked();

0 commit comments

Comments
 (0)
Please sign in to comment.