Skip to content
Permalink
Browse files

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
  • Loading branch information
telwertowski
telwertowski committed Jan 21, 2007
1 parent 1c6a5be commit 93fadb5a02308d2bbff3dad99ca84cd99556dd7d
@@ -760,66 +760,47 @@ void QgsLegend::legendLayerShowProperties()
//QgsDebugMsg("Showing layer properties dialog");

QgsMapLayer* ml = llf->layer();


/*
TODO: Consider reusing the property dialogs again.
Sometimes around mid 2005, the property dialogs were saved for later reuse;
this resulted in a time savings when reopening the dialog. The code below
cannot be used as is, however, simply by saving the dialog pointer here.
Either the map layer needs to be passed as an argument to sync or else
a separate copy of the dialog pointer needs to be stored with each layer.
*/

if (ml->type() == QgsMapLayer::RASTER)
{
QgsRasterLayerProperties *rlp = new QgsRasterLayerProperties(ml);
connect(rlp, SIGNAL(refreshLegend(QString)), this, SLOT(refreshLayerSymbology(QString)));
if (rlp->exec())
QgsRasterLayerProperties *rlp = NULL; // See note above about reusing this
if (rlp)
{
delete rlp;
QCoreApplication::processEvents();
rlp->sync();
}

/*
void QgsRasterLayer::showLayerProperties()
{
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
if ( ! mLayerProperties )
{
mLayerProperties = new QgsRasterLayerProperties(this);
QgsDebugMsg("Creating new raster properties dialog instance");
}
mLayerProperties->sync();
mLayerProperties->raise();
mLayerProperties->show();
qApp->restoreOverrideCursor();
} // QgsRasterLayer::showLayerProperties()
*/
else
{
rlp = new QgsRasterLayerProperties(ml);
connect(rlp, SIGNAL(refreshLegend(QString)), this, SLOT(refreshLayerSymbology(QString)));
}
rlp->exec();
delete rlp; // delete since dialog cannot be reused without updating code
}
else // VECTOR
{
QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>(ml);

QgsVectorLayerProperties* vlp = new QgsVectorLayerProperties(vlayer);
connect(vlp, SIGNAL(refreshLegend(QString)), this, SLOT(refreshLayerSymbology(QString)));
if (vlp->exec())

QgsVectorLayerProperties *vlp = NULL; // See note above about reusing this
if (vlp)
{
delete vlp;
QCoreApplication::processEvents();
vlp->reset();
}

/*
// TODO: this was previous implementation which saved the instance of the dialog
// Set wait cursor while the property dialog is created
// and initialized
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
QgsVectorLayerProperties* propertiesDialog = new QgsVectorLayerProperties(vlayer);
// Make sure that the UI starts out with the correct display
// field value
propertiesDialog->setDisplayField(displayField());
propertiesDialog->reset();
propertiesDialog->raise();
propertiesDialog->show();
// restore normal cursor
qApp->restoreOverrideCursor();
*/
else
{
vlp = new QgsVectorLayerProperties(vlayer);
connect(vlp, SIGNAL(refreshLegend(QString)), this, SLOT(refreshLayerSymbology(QString)));
}
vlp->exec();
delete vlp; // delete since dialog cannot be reused without updating code
}

llf->updateLegendItem();
@@ -23,8 +23,8 @@ QgsGeomTypeDialog::QgsGeomTypeDialog(QWidget *parent, Qt::WFlags fl)
: QDialog(parent, fl)
{
setupUi(this);
connect(mOkButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(mCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

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

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

}

void QgsGeomTypeDialog::on_btnHelp_clicked()
void QgsGeomTypeDialog::on_buttonBox_helpRequested()
{
QgsContextHelp::run(context_id);
}

void QgsGeomTypeDialog::attributes(std::list<std::pair<QString, QString> >& at) const
{
Q3ListViewItemIterator it(mAttributeView);
@@ -40,8 +40,10 @@ class QgsGeomTypeDialog: public QDialog, private Ui::QgsGeomTypeDialogBase
protected slots:
void on_mAddAttributeButton_clicked();
void on_mRemoveAttributeButton_clicked();
void on_btnHelp_clicked();
void on_buttonBox_helpRequested();

private:
QAbstractButton *mOkButton;
static const int context_id = 165149618;

};
@@ -43,8 +43,9 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
connect(cmbTheme, SIGNAL(activated(const QString&)), this, SLOT(themeChanged(const QString&)));
connect(cmbTheme, SIGNAL(highlighted(const QString&)), this, SLOT(themeChanged(const QString&)));
connect(cmbTheme, SIGNAL(textChanged(const QString&)), this, SLOT(themeChanged(const QString&)));
connect(buttonOk, SIGNAL(clicked()), this, SLOT(saveOptions()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(this, SIGNAL(accepted()), this, SLOT(saveOptions()));

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

settings.setValue("/qgis/splitterRedraw", cbxSplitterRedraw->isChecked());

//all done
accept();
}







void QgsOptions::on_btnFindBrowser_clicked()
{
QString filter;
@@ -41,10 +41,10 @@ QgsProjectProperties::QgsProjectProperties(QgsMapCanvas* mapCanvas, QWidget *par
: QDialog(parent, fl), mMapCanvas(mapCanvas)
{
setupUi(this);

connect(buttonApply, SIGNAL(clicked()), this, SLOT(apply()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
connect(this, SIGNAL(accepted()), this, SLOT(apply()));

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

//when user clicks ok
void QgsProjectProperties::accept()
{
apply();
close();
}

bool QgsProjectProperties::isProjected()
{
return cbxProjectionEnabled->isChecked();
}

void QgsProjectProperties::showProjectionsTab()
{
tabWidget2->setCurrentPage(1);
tabWidget->setCurrentPage(1);
}

void QgsProjectProperties::on_pbnDigitisedLineColour_clicked()
@@ -296,7 +289,8 @@ void QgsProjectProperties::on_pbnCanvasColor_clicked()
pbnCanvasColor->setColor(color);
}
}
void QgsProjectProperties::on_pbnHelp_clicked()

void QgsProjectProperties::on_buttonBox_helpRequested()
{
std::cout << "running help" << std::endl;
QgsContextHelp::run(context_id);
@@ -57,17 +57,16 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas

/*! Accessor for projection */
QString projectionWKT();

/*! Indicates that the projection switch is on */
bool isProjected();

public slots:
/*!
* Slot called when apply button is pressed
* Slot called when apply button is pressed or dialog is accepted
*/
void apply();
/*!
* Slot called when ok button pressed (inherits from gui base)
*/
void accept();

/*!
* Slot to show the projections tab when the dialog is opened
*/
@@ -91,11 +90,12 @@ public slots:
/*!
* Slot to show the context help for this dialog
*/
void on_pbnHelp_clicked();
void on_buttonBox_helpRequested();

signals:
//! Signal used to inform listeners that the mouse display precision may have changed
void displayPrecisionChanged();

//! let listening canvases know to refresh
void refresh();

@@ -54,9 +54,10 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer *lyr, QWidget *pa
}

setupUi(this);
connect(buttonApply, SIGNAL(clicked()), this, SLOT(apply()));
connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
connect(this, SIGNAL(accepted()), this, SLOT(apply()));
connect(sliderTransparency, SIGNAL(valueChanged(int)), this, SLOT(sliderTransparency_valueChanged(int)));

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

QgsRasterLayerProperties::~QgsRasterLayerProperties()
{
delete rasterLayer;
}


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

void QgsRasterLayerProperties::accept()
{
apply();
close();
}//accept
void QgsRasterLayerProperties::sliderTransparency_valueChanged(int theValue)
{
//set the transparency percentage label to a suitable value
@@ -450,10 +445,6 @@ void QgsRasterLayerProperties::sliderTransparency_valueChanged(int theValue)
}//sliderTransparency_valueChanged






void QgsRasterLayerProperties::on_rbtnSingleBand_toggled(bool)
{}

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

leSpatialRefSys->setText(rasterLayer->srs().proj4String());
}
void QgsRasterLayerProperties::on_buttonHelp_clicked()
void QgsRasterLayerProperties::on_buttonBox_helpRequested()
{
QgsContextHelp::run(context_id);
}
@@ -46,8 +46,6 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
public slots:
/** \brief Applies the settings made in the dialog without closing the box */
void apply();
/** \bried Apply the settings made and close the dialog. */
void accept();
/** \brief slot executed when the transparency level changes. */
void sliderTransparency_valueChanged( int );
/** \brief slot executed when the max red level changes. */
@@ -61,7 +59,7 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
/** Override the SRS specified when the layer was loaded */
void on_pbnChangeSpatialRefSys_clicked();
/** Help button */
void on_buttonHelp_clicked();
void on_buttonBox_helpRequested();

signals:

@@ -45,6 +45,11 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(QgsVectorLayer * lyr,
mRendererDialog(0)
{
setupUi(this);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
connect(this, SIGNAL(accepted()), this, SLOT(apply()));

// Create the Label dialog tab
QVBoxLayout *layout = new QVBoxLayout( labelOptionsFrame );
layout->setMargin(0);
@@ -64,7 +69,6 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(QgsVectorLayer * lyr,
actionLayout->addWidget( actionDialog );

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

void QgsVectorLayerProperties::on_pbnCancel_clicked()
{
reject();
}
void QgsVectorLayerProperties::on_btnHelp_clicked()
void QgsVectorLayerProperties::on_buttonBox_helpRequested()
{
QgsContextHelp::run(context_id);
}
void QgsVectorLayerProperties::on_pbnOK_clicked()
{
on_pbnApply_clicked();
close(true);
}
void QgsVectorLayerProperties::on_pbnApply_clicked()

void QgsVectorLayerProperties::apply()
{
//
// Set up sql subset query if applicable
@@ -52,16 +52,14 @@ class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPrope
void sliderTransparency_valueChanged(int theValue);
/** Toggles on the label check box */
void setLabelCheckBox();

/** Called when apply button is pressed or dialog is accepted */
void apply();

//
//methods reimplemented from qt designer base class
//


void on_pbnCancel_clicked();
void on_pbnOK_clicked();
void on_pbnApply_clicked();
void on_btnHelp_clicked();
void on_buttonBox_helpRequested();
void on_pbnQueryBuilder_clicked();
void on_pbnIndex_clicked();
void on_pbnChangeSpatialRefSys_clicked();

0 comments on commit 93fadb5

Please sign in to comment.
You can’t perform that action at this time.