mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
graduated dialogs keep settings now if classification field or classification mode are changed
git-svn-id: http://svn.osgeo.org/qgis/trunk@1407 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
c2fd2985d3
commit
0936e4304e
@ -111,8 +111,8 @@ QgsGraMaDialog::QgsGraMaDialog(QgsVectorLayer* layer): QgsGraMaDialogBase(), ext
|
||||
|
||||
//do the necessary signal/slot connections
|
||||
QObject::connect(mNumberOfClassesSpinbox, SIGNAL(valueChanged(int)), this, SLOT(adjustNumberOfClasses()));
|
||||
QObject::connect(mClassificationComboBox, SIGNAL(activated(int)), this, SLOT(adjustNumberOfClasses()));
|
||||
QObject::connect(mModeComboBox, SIGNAL(activated(int)), this, SLOT(adjustNumberOfClasses()));
|
||||
QObject::connect(mClassificationComboBox, SIGNAL(activated(int)), this, SLOT(adjustClassification()));
|
||||
QObject::connect(mModeComboBox, SIGNAL(activated(int)), this, SLOT(adjustClassification()));
|
||||
}
|
||||
|
||||
QgsGraMaDialog::QgsGraMaDialog()
|
||||
@ -358,3 +358,29 @@ void QgsGraMaDialog::adjustNumberOfClasses()
|
||||
QgsGraMaDialogBaseLayout->addMultiCellWidget(ext, 5, 5, 0, 3);
|
||||
ext->show();
|
||||
}
|
||||
|
||||
void QgsGraMaDialog::adjustClassification()
|
||||
{
|
||||
//find out the number of the classification field
|
||||
QString fieldstring = mClassificationComboBox->currentText();
|
||||
if (fieldstring.isEmpty()) //don't do anything, it there is no classification field
|
||||
{
|
||||
show();
|
||||
return;
|
||||
}
|
||||
|
||||
std::map < QString, int >::iterator iter = mFieldMap.find(fieldstring);
|
||||
int field = iter->second;
|
||||
|
||||
if(ext)
|
||||
{
|
||||
if (mModeComboBox->currentText() == "Empty")
|
||||
{
|
||||
ext->setClassification(QgsGraSyDialog::EMPTY,field);
|
||||
}
|
||||
else if(mModeComboBox->currentText() == "Equal Interval")
|
||||
{
|
||||
ext->setClassification(QgsGraSyDialog::EQUAL_INTERVAL,field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,9 @@ public slots:
|
||||
void apply();
|
||||
protected slots:
|
||||
/**Creates a new extension widget*/
|
||||
void adjustNumberOfClasses();
|
||||
void adjustNumberOfClasses();
|
||||
/**Tells the extensionwidget to change the values of the lower and upper text fields*/
|
||||
void adjustClassification();
|
||||
private:
|
||||
/**Default constructor is privat to not use is*/
|
||||
QgsGraMaDialog();
|
||||
|
@ -118,8 +118,6 @@ QgsGraMaExtensionWidget::QgsGraMaExtensionWidget(QWidget* parent, int classfield
|
||||
}
|
||||
|
||||
addChild(mWidget);
|
||||
//resizeContents(200,50*(mNumberOfClasses+1));
|
||||
//updateContents();
|
||||
|
||||
}
|
||||
|
||||
@ -220,3 +218,40 @@ void QgsGraMaExtensionWidget::handleReturnPressed()
|
||||
}
|
||||
adjustMarker(indexnumber);
|
||||
}
|
||||
|
||||
void QgsGraMaExtensionWidget::setClassification(QgsGraSyDialog::mode mode, int field)
|
||||
{
|
||||
mClassField=field;
|
||||
mMode=mode;
|
||||
|
||||
QgsDataProvider *provider=mVectorLayer->getDataProvider();
|
||||
|
||||
if (provider)
|
||||
{
|
||||
if (mMode == QgsGraSyDialog::EQUAL_INTERVAL)
|
||||
{
|
||||
double minimum=0;
|
||||
double maximum=0;
|
||||
|
||||
minimum = provider->minValue(mClassField).toDouble();
|
||||
maximum = provider->maxValue(mClassField).toDouble();
|
||||
|
||||
for(int i=0;i<mNumberOfClasses;++i)
|
||||
{
|
||||
((QLineEdit*)getWidget(0,i))->setText(QString::number(minimum + (maximum - minimum) / mNumberOfClasses * i, 'f', 2));
|
||||
((QLineEdit*)getWidget(1,i))->setText(QString::number(minimum + (maximum - minimum) / mNumberOfClasses * (i+1), 'f', 2));
|
||||
}
|
||||
|
||||
}
|
||||
else if (mMode == QgsGraSyDialog::EMPTY) //don't waste performance if mMode is QgsGraSyDialog::EMPTY
|
||||
{
|
||||
for(int i=0;i<mNumberOfClasses;++i)
|
||||
{
|
||||
((QLineEdit*)getWidget(0,i))->clear();
|
||||
((QLineEdit*)getWidget(1,i))->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ class QgsGraMaExtensionWidget: public QScrollView
|
||||
void adjustMarkers();
|
||||
/**Adjusts the marker size in one row*/
|
||||
void adjustMarker(int row);
|
||||
/**Changes the classification*/
|
||||
void setClassification(QgsGraSyDialog::mode mode,int field);
|
||||
|
||||
protected:
|
||||
/**Number of the field to classify*/
|
||||
|
@ -137,8 +137,8 @@ QgsGraSyDialog::QgsGraSyDialog(QgsVectorLayer * layer):QgsGraSyDialogBase(), ext
|
||||
|
||||
//do the necessary signal/slot connections
|
||||
QObject::connect(numberofclassesspinbox, SIGNAL(valueChanged(int)), this, SLOT(adjustNumberOfClasses()));
|
||||
QObject::connect(classificationComboBox, SIGNAL(activated(int)), this, SLOT(adjustNumberOfClasses()));
|
||||
QObject::connect(modeComboBox, SIGNAL(activated(int)), this, SLOT(adjustNumberOfClasses()));
|
||||
QObject::connect(classificationComboBox, SIGNAL(activated(int)), this, SLOT(adjustClassification()));
|
||||
QObject::connect(modeComboBox, SIGNAL(activated(int)), this, SLOT(adjustClassification()));
|
||||
}
|
||||
|
||||
QgsGraSyDialog::QgsGraSyDialog()
|
||||
@ -384,3 +384,29 @@ void QgsGraSyDialog::apply()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QgsGraSyDialog::adjustClassification()
|
||||
{
|
||||
//find out the number of the classification field
|
||||
QString fieldstring = classificationComboBox->currentText();
|
||||
if (fieldstring.isEmpty()) //don't do anything, it there is no classification field
|
||||
{
|
||||
show();
|
||||
return;
|
||||
}
|
||||
|
||||
std::map < QString, int >::iterator iter = mFieldMap.find(fieldstring);
|
||||
int field = iter->second;
|
||||
|
||||
if(ext)
|
||||
{
|
||||
if (modeComboBox->currentText() == "Empty")
|
||||
{
|
||||
ext->setClassification(QgsGraSyDialog::EMPTY,field);
|
||||
}
|
||||
else if(modeComboBox->currentText() == "Equal Interval")
|
||||
{
|
||||
ext->setClassification(QgsGraSyDialog::EQUAL_INTERVAL,field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ class QgsGraSyDialog: public QgsGraSyDialogBase
|
||||
protected slots:
|
||||
/**Creates a new extension widget*/
|
||||
void adjustNumberOfClasses();
|
||||
/**Tells the extensionwidget to change the values of the lower and upper text fields*/
|
||||
void adjustClassification();
|
||||
protected:
|
||||
/**Pointer to the curret extension widget*/
|
||||
QgsGraSyExtensionWidget* ext;
|
||||
|
@ -257,3 +257,41 @@ void QgsGraSyExtensionWidget::selectOutlineStyle()
|
||||
((QPushButton *) sender())->setPixmap(QgsSymbologyUtils::penStyle2Pixmap(linestyledialog.style()));
|
||||
}
|
||||
}
|
||||
|
||||
void QgsGraSyExtensionWidget::setClassification(QgsGraSyDialog::mode mode,int field)
|
||||
{
|
||||
double minimum=0;
|
||||
double maximum=0;
|
||||
|
||||
m_classfield=field;
|
||||
mMode=mode;
|
||||
|
||||
QgsDataProvider *provider=mVectorLayer->getDataProvider();
|
||||
|
||||
if (provider)
|
||||
{
|
||||
if (mMode == QgsGraSyDialog::EQUAL_INTERVAL)
|
||||
{
|
||||
double minimum=0;
|
||||
double maximum=0;
|
||||
|
||||
minimum = provider->minValue(m_classfield).toDouble();
|
||||
maximum = provider->maxValue(m_classfield).toDouble();
|
||||
|
||||
for(int i=0;i<mNumberOfClasses;++i)
|
||||
{
|
||||
((QLineEdit*)getWidget(0,i))->setText(QString::number(minimum + (maximum - minimum) / mNumberOfClasses * i, 'f', 2));
|
||||
((QLineEdit*)getWidget(1,i))->setText(QString::number(minimum + (maximum - minimum) / mNumberOfClasses * (i+1), 'f', 2));
|
||||
}
|
||||
|
||||
}
|
||||
else if (mMode == QgsGraSyDialog::EMPTY) //don't waste performance if mMode is QgsGraSyDialog::EMPTY
|
||||
{
|
||||
for(int i=0;i<mNumberOfClasses;++i)
|
||||
{
|
||||
((QLineEdit*)getWidget(0,i))->clear();
|
||||
((QLineEdit*)getWidget(1,i))->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ class QgsGraSyExtensionWidget: public QScrollView
|
||||
int classfield();
|
||||
/**Access to the widget objects. In QgsGraSyDialog, the widgets have to be casted to the proper subclasses to retrieve their information*/
|
||||
QWidget* getWidget(int column, int row);
|
||||
/**Changes the classification*/
|
||||
void setClassification(QgsGraSyDialog::mode mode,int field);
|
||||
protected:
|
||||
/**Number of the field to classify*/
|
||||
int m_classfield;
|
||||
|
Loading…
x
Reference in New Issue
Block a user