StelDialog.cpp   StelDialog.cpp 
skipping to change at line 31 skipping to change at line 31
#include "StelDialog_p.hpp" #include "StelDialog_p.hpp"
#include "StelMainView.hpp" #include "StelMainView.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelActionMgr.hpp" #include "StelActionMgr.hpp"
#include "StelPropertyMgr.hpp" #include "StelPropertyMgr.hpp"
#include <QDebug> #include <QDebug>
#include <QAbstractButton> #include <QAbstractButton>
#include <QComboBox> #include <QComboBox>
#include <QDialog> #include <QDialog>
#include <QGraphicsSceneWheelEvent>
#include <QMetaProperty> #include <QMetaProperty>
#include <QStyleOptionGraphicsItem> #include <QStyleOptionGraphicsItem>
#include <QSlider> #include <QSlider>
#include <QSpinBox> #include <QSpinBox>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <QScroller> #include <QScroller>
#endif #endif
StelDialog::StelDialog(QObject* parent) StelDialog::StelDialog(QString dialogName, QObject* parent)
: QObject(parent) : QObject(parent)
, dialog(NULL) , dialog(NULL)
, proxy(NULL) , proxy(NULL)
, dialogName(dialogName)
{ {
if (parent == NULL) if (parent == NULL)
setParent(StelMainView::getInstance().getGuiWidget()); setParent(StelMainView::getInstance().getGuiWidget());
} }
StelDialog::~StelDialog() StelDialog::~StelDialog()
{ {
} }
void StelDialog::close() void StelDialog::close()
skipping to change at line 213 skipping to change at line 215
void StelDialog::connectIntProperty(QComboBox *comboBox, const QString &pro pName) void StelDialog::connectIntProperty(QComboBox *comboBox, const QString &pro pName)
{ {
StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName); StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName);
Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist"); Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist");
//use a proxy for the connection //use a proxy for the connection
new QComboBoxStelPropertyConnectionHelper(prop,comboBox); new QComboBoxStelPropertyConnectionHelper(prop,comboBox);
} }
void StelDialog::connectIntProperty(QSlider *slider, const QString &propNam
e,int minValue, int maxValue)
{
StelProperty* prop = StelApp::getInstance().getStelPropertyManager()
->getProperty(propName);
Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist");
//The connection is handled by a helper class. It is automatically d
estroyed when the slider is destroyed.
new QSliderStelPropertyConnectionHelper(prop,minValue,maxValue,slide
r);
}
void StelDialog::connectDoubleProperty(QDoubleSpinBox *spinBox, const QStri ng &propName) void StelDialog::connectDoubleProperty(QDoubleSpinBox *spinBox, const QStri ng &propName)
{ {
StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName); StelProperty* prop = StelApp::getInstance().getStelPropertyManager() ->getProperty(propName);
Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist"); Q_ASSERT_X(prop,"StelDialog", "StelProperty does not exist");
//use a proxy for the connection //use a proxy for the connection
new QDoubleSpinBoxStelPropertyConnectionHelper(prop,spinBox); new QDoubleSpinBoxStelPropertyConnectionHelper(prop,spinBox);
} }
void StelDialog::connectDoubleProperty(QSlider *slider, const QString &prop Name,double minValue, double maxValue) void StelDialog::connectDoubleProperty(QSlider *slider, const QString &prop Name,double minValue, double maxValue)
skipping to change at line 374 skipping to change at line 385
bool ok = val.canConvert<double>(); bool ok = val.canConvert<double>();
Q_ASSERT_X(ok,"QSliderStelPropertyConnectionHelper","Can not convert to double datatype"); Q_ASSERT_X(ok,"QSliderStelPropertyConnectionHelper","Can not convert to double datatype");
Q_UNUSED(ok); Q_UNUSED(ok);
dRange = maxValue - minValue; dRange = maxValue - minValue;
onPropertyChanged(val); onPropertyChanged(val);
connect(slider,SIGNAL(valueChanged(int)),this,SLOT(sliderIntValueCha nged(int))); connect(slider,SIGNAL(valueChanged(int)),this,SLOT(sliderIntValueCha nged(int)));
} }
QSliderStelPropertyConnectionHelper::QSliderStelPropertyConnectionHelper(St
elProperty *prop, int minValue, int maxValue, QSlider *slider)
: StelPropertyProxy(prop,slider),slider(slider),minValue(minValue),m
axValue(maxValue)
{
QVariant val = prop->getValue();
bool ok = val.canConvert<double>();
Q_ASSERT_X(ok,"QSliderStelPropertyConnectionHelper","Can not convert
to double datatype");
Q_UNUSED(ok);
dRange = maxValue - minValue;
onPropertyChanged(val);
connect(slider,SIGNAL(valueChanged(int)),this,SLOT(sliderIntValueCha
nged(int)));
}
void QSliderStelPropertyConnectionHelper::sliderIntValueChanged(int val) void QSliderStelPropertyConnectionHelper::sliderIntValueChanged(int val)
{ {
double dVal = ((val - slider->minimum()) / (double)(slider->maximum( ) - slider->minimum())) * dRange + minValue; double dVal = ((val - slider->minimum()) / (double)(slider->maximum( ) - slider->minimum())) * dRange + minValue;
prop->setValue(dVal); prop->setValue(dVal);
} }
void QSliderStelPropertyConnectionHelper::onPropertyChanged(const QVariant& val) void QSliderStelPropertyConnectionHelper::onPropertyChanged(const QVariant& val)
{ {
double dVal = val.toDouble(); double dVal = val.toDouble();
int iRange = slider->maximum() - slider->minimum(); int iRange = slider->maximum() - slider->minimum();
 End of changes. 5 change blocks. 
1 lines changed or deleted 33 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/