Newer
Older
Roman Tolchenov
committed
This signal is emitted whenever a property created by this manager
changes its range of valid values, passing a pointer to the
\a property and the new \a minimum and \a maximum values
\sa setRange()
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtDoublePropertyManager::decimalsChanged(QtProperty *property, int prec)
This signal is emitted whenever a property created by this manager
changes its precision of value, passing a pointer to the
\a property and the new \a prec value
\sa setDecimals()
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtDoublePropertyManager::singleStepChanged(QtProperty *property, double step)
This signal is emitted whenever a property created by this manager
changes its single step property, passing a pointer to the
\a property and the new \a step value
\sa setSingleStep()
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Creates a manager with the given \a parent.
*/
QtDoublePropertyManager::QtDoublePropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent)
{
d_ptr = new QtDoublePropertyManagerPrivate;
d_ptr->q_ptr = this;
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Destroys this manager, and all the properties it has created.
*/
QtDoublePropertyManager::~QtDoublePropertyManager()
{
clear();
delete d_ptr;
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's value.
If the given property is not managed by this manager, this
function returns 0.
\sa setValue()
*/
double QtDoublePropertyManager::value(const QtProperty *property) const
{
return getValue<double>(d_ptr->m_values, property, 0.0);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's minimum value.
\sa maximum(), setRange()
*/
double QtDoublePropertyManager::minimum(const QtProperty *property) const
{
return getMinimum<double>(d_ptr->m_values, property, 0.0);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's maximum value.
\sa minimum(), setRange()
*/
double QtDoublePropertyManager::maximum(const QtProperty *property) const
{
return getMaximum<double>(d_ptr->m_values, property, 0.0);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's step value.
The step is typically used to increment or decrement a property value while pressing an arrow key.
\sa setSingleStep()
*/
double QtDoublePropertyManager::singleStep(const QtProperty *property) const
{
return getData<double>(d_ptr->m_values, &QtDoublePropertyManagerPrivate::Data::singleStep, property, 0);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's precision, in decimals.
\sa setDecimals()
*/
int QtDoublePropertyManager::decimals(const QtProperty *property) const
{
return getData<int>(d_ptr->m_values, &QtDoublePropertyManagerPrivate::Data::decimals, property, 0);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\reimp
*/
QString QtDoublePropertyManager::valueText(const QtProperty *property) const
{
const QtDoublePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QString();
Roman Tolchenov
committed
double absVal = fabs(it.value().val);
char format = absVal > 1e5 || (absVal != 0 && absVal < 1e-5) ? 'e' : 'f';
return QString::number(it.value().val,format , it.value().decimals);
Roman Tolchenov
committed
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtDoublePropertyManager::setValue(QtProperty *property, double value)
Sets the value of the given \a property to \a value.
If the specified \a value is not valid according to the given
\a property's range, the \a value is adjusted to the nearest valid value
within the range.
\sa value(), setRange(), valueChanged()
*/
void QtDoublePropertyManager::setValue(QtProperty *property, double val)
{
void (QtDoublePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, double) = 0;
setValueInRange<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(this, d_ptr,
&QtDoublePropertyManager::propertyChanged,
&QtDoublePropertyManager::valueChanged,
property, val, setSubPropertyValue);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
Sets the step value for the given \a property to \a step.
The step is typically used to increment or decrement a property value while pressing an arrow key.
\sa singleStep()
*/
void QtDoublePropertyManager::setSingleStep(QtProperty *property, double step)
{
const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
QtDoublePropertyManagerPrivate::Data data = it.value();
if (step < 0)
step = 0;
if (data.singleStep == step)
return;
data.singleStep = step;
it.value() = data;
emit singleStepChanged(property, data.singleStep);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
\fn void QtDoublePropertyManager::setDecimals(QtProperty *property, int prec)
Sets the precision of the given \a property to \a prec.
The valid decimal range is 0-13. The default is 2.
\sa decimals()
*/
void QtDoublePropertyManager::setDecimals(QtProperty *property, int prec)
{
const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
QtDoublePropertyManagerPrivate::Data data = it.value();
if (prec > 13)
prec = 13;
else if (prec < 0)
prec = 0;
if (data.decimals == prec)
return;
data.decimals = prec;
it.value() = data;
emit decimalsChanged(property, data.decimals);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Sets the minimum value for the given \a property to \a minVal.
When setting the minimum value, the maximum and current values are
adjusted if necessary (ensuring that the range remains valid and
that the current value is within in the range).
\sa minimum(), setRange(), rangeChanged()
*/
void QtDoublePropertyManager::setMinimum(QtProperty *property, double minVal)
{
setMinimumValue<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double, QtDoublePropertyManagerPrivate::Data>(this, d_ptr,
&QtDoublePropertyManager::propertyChanged,
&QtDoublePropertyManager::valueChanged,
&QtDoublePropertyManager::rangeChanged,
property, minVal);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Sets the maximum value for the given \a property to \a maxVal.
When setting the maximum value, the minimum and current values are
adjusted if necessary (ensuring that the range remains valid and
that the current value is within in the range).
\sa maximum(), setRange(), rangeChanged()
*/
void QtDoublePropertyManager::setMaximum(QtProperty *property, double maxVal)
{
setMaximumValue<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double, QtDoublePropertyManagerPrivate::Data>(this, d_ptr,
&QtDoublePropertyManager::propertyChanged,
&QtDoublePropertyManager::valueChanged,
&QtDoublePropertyManager::rangeChanged,
property, maxVal);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
\fn void QtDoublePropertyManager::setRange(QtProperty *property, double minimum, double maximum)
Sets the range of valid values.
This is a convenience function defining the range of valid values
in one go; setting the \a minimum and \a maximum values for the
given \a property with a single function call.
When setting a new range, the current value is adjusted if
necessary (ensuring that the value remains within range).
\sa setMinimum(), setMaximum(), rangeChanged()
*/
void QtDoublePropertyManager::setRange(QtProperty *property, double minVal, double maxVal)
{
void (QtDoublePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, double, double, double) = 0;
setBorderValues<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(this, d_ptr,
&QtDoublePropertyManager::propertyChanged,
&QtDoublePropertyManager::valueChanged,
&QtDoublePropertyManager::rangeChanged,
property, minVal, maxVal, setSubPropertyRange);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\reimp
*/
void QtDoublePropertyManager::initializeProperty(QtProperty *property)
{
d_ptr->m_values[property] = QtDoublePropertyManagerPrivate::Data();
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
\reimp
*/
void QtDoublePropertyManager::uninitializeProperty(QtProperty *property)
{
d_ptr->m_values.remove(property);
}
// QtStringPropertyManager
class QtStringPropertyManagerPrivate
{
QtStringPropertyManager *q_ptr;
Q_DECLARE_PUBLIC(QtStringPropertyManager)
public:
struct Data
{
Data() : regExp(QString(QLatin1Char('*')), Qt::CaseSensitive, QRegExp::Wildcard)
{
}
QString val;
QRegExp regExp;
};
typedef QMap<const QtProperty *, Data> PropertyValueMap;
QMap<const QtProperty *, Data> m_values;
};
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\class QtStringPropertyManager
\brief The QtStringPropertyManager provides and manages QString properties.
A string property's value can be retrieved using the value()
function, and set using the setValue() slot.
The current value can be checked against a regular expression. To
set the regular expression use the setRegExp() slot, use the
regExp() function to retrieve the currently set expression.
In addition, QtStringPropertyManager provides the valueChanged() signal
which is emitted whenever a property created by this manager
changes, and the regExpChanged() signal which is emitted whenever
such a property changes its currently set regular expression.
\sa QtAbstractPropertyManager, QtLineEditFactory
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtStringPropertyManager::valueChanged(QtProperty *property, const QString &value)
This signal is emitted whenever a property created by this manager
changes its value, passing a pointer to the \a property and the
new \a value as parameters.
\sa setValue()
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtStringPropertyManager::regExpChanged(QtProperty *property, const QRegExp ®Exp)
This signal is emitted whenever a property created by this manager
changes its currenlty set regular expression, passing a pointer to
the \a property and the new \a regExp as parameters.
\sa setRegExp()
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Creates a manager with the given \a parent.
*/
QtStringPropertyManager::QtStringPropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent)
{
d_ptr = new QtStringPropertyManagerPrivate;
d_ptr->q_ptr = this;
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Destroys this manager, and all the properties it has created.
*/
QtStringPropertyManager::~QtStringPropertyManager()
{
clear();
delete d_ptr;
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's value.
If the given property is not managed by this manager, this
function returns an empty string.
\sa setValue()
*/
QString QtStringPropertyManager::value(const QtProperty *property) const
{
return getValue<QString>(d_ptr->m_values, property);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's currently set regular expression.
If the given \a property is not managed by this manager, this
function returns an empty expression.
\sa setRegExp()
*/
QRegExp QtStringPropertyManager::regExp(const QtProperty *property) const
{
return getData<QRegExp>(d_ptr->m_values, &QtStringPropertyManagerPrivate::Data::regExp, property, QRegExp());
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\reimp
*/
QString QtStringPropertyManager::valueText(const QtProperty *property) const
{
const QtStringPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QString();
return it.value().val;
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
\fn void QtStringPropertyManager::setValue(QtProperty *property, const QString &value)
Sets the value of the given \a property to \a value.
If the specified \a value doesn't match the given \a property's
regular expression, this function does nothing.
\sa value(), setRegExp(), valueChanged()
*/
void QtStringPropertyManager::setValue(QtProperty *property, const QString &val)
{
const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
QtStringPropertyManagerPrivate::Data data = it.value();
if (data.val == val)
return;
if (data.regExp.isValid() && !data.regExp.exactMatch(val))
return;
data.val = val;
it.value() = data;
emit propertyChanged(property);
emit valueChanged(property, data.val);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
Sets the regular expression of the given \a property to \a regExp.
\sa regExp(), setValue(), regExpChanged()
*/
void QtStringPropertyManager::setRegExp(QtProperty *property, const QRegExp ®Exp)
{
const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
if (it == d_ptr->m_values.end())
return;
QtStringPropertyManagerPrivate::Data data = it.value() ;
if (data.regExp == regExp)
return;
data.regExp = regExp;
it.value() = data;
emit regExpChanged(property, data.regExp);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\reimp
*/
void QtStringPropertyManager::initializeProperty(QtProperty *property)
{
d_ptr->m_values[property] = QtStringPropertyManagerPrivate::Data();
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\reimp
*/
void QtStringPropertyManager::uninitializeProperty(QtProperty *property)
{
d_ptr->m_values.remove(property);
}
// QtBoolPropertyManager
class QtBoolPropertyManagerPrivate
{
QtBoolPropertyManager *q_ptr;
Q_DECLARE_PUBLIC(QtBoolPropertyManager)
public:
QMap<const QtProperty *, bool> m_values;
};
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\class QtBoolPropertyManager
\brief The QtBoolPropertyManager class provides and manages boolean properties.
The property's value can be retrieved using the value() function,
and set using the setValue() slot.
In addition, QtBoolPropertyManager provides the valueChanged() signal
which is emitted whenever a property created by this manager
changes.
\sa QtAbstractPropertyManager, QtCheckBoxFactory
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtBoolPropertyManager::valueChanged(QtProperty *property, bool value)
This signal is emitted whenever a property created by this manager
changes its value, passing a pointer to the \a property and the
new \a value as parameters.
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Creates a manager with the given \a parent.
*/
QtBoolPropertyManager::QtBoolPropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent)
{
d_ptr = new QtBoolPropertyManagerPrivate;
d_ptr->q_ptr = this;
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Destroys this manager, and all the properties it has created.
*/
QtBoolPropertyManager::~QtBoolPropertyManager()
{
clear();
delete d_ptr;
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's value.
If the given \a property is not managed by \e this manager, this
function returns false.
\sa setValue()
*/
bool QtBoolPropertyManager::value(const QtProperty *property) const
{
return d_ptr->m_values.value(property, false);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
\reimp
*/
QString QtBoolPropertyManager::valueText(const QtProperty *property) const
{
const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QString();
static const QString trueText = tr("True");
static const QString falseText = tr("False");
return it.value() ? trueText : falseText;
}
// Return an icon containing a check box indicator
static QIcon drawCheckBox(bool value)
{
QStyleOptionButton opt;
opt.state |= value ? QStyle::State_On : QStyle::State_Off;
opt.state |= QStyle::State_Enabled;
const QStyle *style = QApplication::style();
// Figure out size of an indicator and make sure it is not scaled down in a list view item
// by making the pixmap as big as a list view icon and centering the indicator in it.
// (if it is smaller, it can't be helped)
const int indicatorWidth = style->pixelMetric(QStyle::PM_IndicatorWidth, &opt);
const int indicatorHeight = style->pixelMetric(QStyle::PM_IndicatorHeight, &opt);
const int listViewIconSize = indicatorWidth;
const int pixmapWidth = indicatorWidth;
const int pixmapHeight = qMax(indicatorHeight, listViewIconSize);
opt.rect = QRect(0, 0, indicatorWidth, indicatorHeight);
QPixmap pixmap = QPixmap(pixmapWidth, pixmapHeight);
pixmap.fill(Qt::transparent);
{
// Center?
const int xoff = (pixmapWidth > indicatorWidth) ? (pixmapWidth - indicatorWidth) / 2 : 0;
const int yoff = (pixmapHeight > indicatorHeight) ? (pixmapHeight - indicatorHeight) / 2 : 0;
QPainter painter(&pixmap);
painter.translate(xoff, yoff);
style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &painter);
}
return QIcon(pixmap);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\reimp
*/
QIcon QtBoolPropertyManager::valueIcon(const QtProperty *property) const
{
const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QIcon();
static const QIcon checkedIcon = drawCheckBox(true);
static const QIcon uncheckedIcon = drawCheckBox(false);
return it.value() ? checkedIcon : uncheckedIcon;
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtBoolPropertyManager::setValue(QtProperty *property, bool value)
Sets the value of the given \a property to \a value.
\sa value()
*/
void QtBoolPropertyManager::setValue(QtProperty *property, bool val)
{
setSimpleValue<bool, bool, QtBoolPropertyManager>(d_ptr->m_values, this,
&QtBoolPropertyManager::propertyChanged,
&QtBoolPropertyManager::valueChanged,
property, val);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\reimp
*/
void QtBoolPropertyManager::initializeProperty(QtProperty *property)
{
d_ptr->m_values[property] = false;
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
\reimp
*/
void QtBoolPropertyManager::uninitializeProperty(QtProperty *property)
{
d_ptr->m_values.remove(property);
}
// QtDatePropertyManager
class QtDatePropertyManagerPrivate
{
QtDatePropertyManager *q_ptr;
Q_DECLARE_PUBLIC(QtDatePropertyManager)
public:
struct Data
{
Data() : val(QDate::currentDate()), minVal(QDate(1752, 9, 14)),
maxVal(QDate(7999, 12, 31)) {}
QDate val;
QDate minVal;
QDate maxVal;
QDate minimumValue() const { return minVal; }
QDate maximumValue() const { return maxVal; }
void setMinimumValue(const QDate &newMinVal) { setSimpleMinimumData(this, newMinVal); }
void setMaximumValue(const QDate &newMaxVal) { setSimpleMaximumData(this, newMaxVal); }
};
QString m_format;
typedef QMap<const QtProperty *, Data> PropertyValueMap;
QMap<const QtProperty *, Data> m_values;
};
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
\class QtDatePropertyManager
\brief The QtDatePropertyManager provides and manages QDate properties.
A date property has a current value, and a range specifying the
valid dates. The range is defined by a minimum and a maximum
value.
The property's values can be retrieved using the minimum(),
maximum() and value() functions, and can be set using the
setMinimum(), setMaximum() and setValue() slots. Alternatively,
the range can be defined in one go using the setRange() slot.
In addition, QtDatePropertyManager provides the valueChanged() signal
which is emitted whenever a property created by this manager
changes, and the rangeChanged() signal which is emitted whenever
such a property changes its range of valid dates.
\sa QtAbstractPropertyManager, QtDateEditFactory, QtDateTimePropertyManager
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtDatePropertyManager::valueChanged(QtProperty *property, const QDate &value)
This signal is emitted whenever a property created by this manager
changes its value, passing a pointer to the \a property and the new
\a value as parameters.
\sa setValue()
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtDatePropertyManager::rangeChanged(QtProperty *property, const QDate &minimum, const QDate &maximum)
This signal is emitted whenever a property created by this manager
changes its range of valid dates, passing a pointer to the \a
property and the new \a minimum and \a maximum dates.
\sa setRange()
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Creates a manager with the given \a parent.
*/
QtDatePropertyManager::QtDatePropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent)
{
d_ptr = new QtDatePropertyManagerPrivate;
d_ptr->q_ptr = this;
QLocale loc;
d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Destroys this manager, and all the properties it has created.
*/
QtDatePropertyManager::~QtDatePropertyManager()
{
clear();
delete d_ptr;
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's value.
If the given \a property is not managed by \e this manager, this
function returns an invalid date.
\sa setValue()
*/
QDate QtDatePropertyManager::value(const QtProperty *property) const
{
return getValue<QDate>(d_ptr->m_values, property);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's minimum date.
\sa maximum(), setRange()
*/
QDate QtDatePropertyManager::minimum(const QtProperty *property) const
{
return getMinimum<QDate>(d_ptr->m_values, property);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's maximum date.
\sa minimum(), setRange()
*/
QDate QtDatePropertyManager::maximum(const QtProperty *property) const
{
return getMaximum<QDate>(d_ptr->m_values, property);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\reimp
*/
QString QtDatePropertyManager::valueText(const QtProperty *property) const
{
const QtDatePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QString();
return it.value().val.toString(d_ptr->m_format);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtDatePropertyManager::setValue(QtProperty *property, const QDate &value)
Sets the value of the given \a property to \a value.
If the specified \a value is not a valid date according to the
given \a property's range, the value is adjusted to the nearest
valid value within the range.
\sa value(), setRange(), valueChanged()
*/
void QtDatePropertyManager::setValue(QtProperty *property, const QDate &val)
{
void (QtDatePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, const QDate &) = 0;
setValueInRange<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, const QDate>(this, d_ptr,
&QtDatePropertyManager::propertyChanged,
&QtDatePropertyManager::valueChanged,
property, val, setSubPropertyValue);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Sets the minimum value for the given \a property to \a minVal.
When setting the minimum value, the maximum and current values are
adjusted if necessary (ensuring that the range remains valid and
that the current value is within in the range).
\sa minimum(), setRange()
*/
void QtDatePropertyManager::setMinimum(QtProperty *property, const QDate &minVal)
{
setMinimumValue<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate, QtDatePropertyManagerPrivate::Data>(this, d_ptr,
&QtDatePropertyManager::propertyChanged,
&QtDatePropertyManager::valueChanged,
&QtDatePropertyManager::rangeChanged,
property, minVal);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Sets the maximum value for the given \a property to \a maxVal.
When setting the maximum value, the minimum and current
values are adjusted if necessary (ensuring that the range remains
valid and that the current value is within in the range).
\sa maximum(), setRange()
*/
void QtDatePropertyManager::setMaximum(QtProperty *property, const QDate &maxVal)
{
setMaximumValue<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate, QtDatePropertyManagerPrivate::Data>(this, d_ptr,
&QtDatePropertyManager::propertyChanged,
&QtDatePropertyManager::valueChanged,
&QtDatePropertyManager::rangeChanged,
property, maxVal);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
\fn void QtDatePropertyManager::setRange(QtProperty *property, const QDate &minimum, const QDate &maximum)
Sets the range of valid dates.
This is a convenience function defining the range of valid dates
in one go; setting the \a minimum and \a maximum values for the
given \a property with a single function call.
When setting a new date range, the current value is adjusted if
necessary (ensuring that the value remains in date range).
\sa setMinimum(), setMaximum(), rangeChanged()
*/
void QtDatePropertyManager::setRange(QtProperty *property, const QDate &minVal, const QDate &maxVal)
{
void (QtDatePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, const QDate &,
const QDate &, const QDate &) = 0;
setBorderValues<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate>(this, d_ptr,
&QtDatePropertyManager::propertyChanged,
&QtDatePropertyManager::valueChanged,
&QtDatePropertyManager::rangeChanged,
property, minVal, maxVal, setSubPropertyRange);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\reimp
*/
void QtDatePropertyManager::initializeProperty(QtProperty *property)
{
d_ptr->m_values[property] = QtDatePropertyManagerPrivate::Data();
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
\reimp
*/
void QtDatePropertyManager::uninitializeProperty(QtProperty *property)
{
d_ptr->m_values.remove(property);
}
// QtTimePropertyManager
class QtTimePropertyManagerPrivate
{
QtTimePropertyManager *q_ptr;
Q_DECLARE_PUBLIC(QtTimePropertyManager)
public:
QString m_format;
typedef QMap<const QtProperty *, QTime> PropertyValueMap;
PropertyValueMap m_values;
};
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\class QtTimePropertyManager
\brief The QtTimePropertyManager provides and manages QTime properties.
A time property's value can be retrieved using the value()
function, and set using the setValue() slot.
In addition, QtTimePropertyManager provides the valueChanged() signal
which is emitted whenever a property created by this manager
changes.
\sa QtAbstractPropertyManager, QtTimeEditFactory
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtTimePropertyManager::valueChanged(QtProperty *property, const QTime &value)
This signal is emitted whenever a property created by this manager
changes its value, passing a pointer to the \a property and the
new \a value as parameters.
\sa setValue()
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Creates a manager with the given \a parent.
*/
QtTimePropertyManager::QtTimePropertyManager(QObject *parent)
: QtAbstractPropertyManager(parent)
{
d_ptr = new QtTimePropertyManagerPrivate;
d_ptr->q_ptr = this;
QLocale loc;
d_ptr->m_format = loc.timeFormat(QLocale::ShortFormat);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Destroys this manager, and all the properties it has created.
*/
QtTimePropertyManager::~QtTimePropertyManager()
{
clear();
delete d_ptr;
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Returns the given \a property's value.
If the given property is not managed by this manager, this
function returns an invalid time object.
\sa setValue()
*/
QTime QtTimePropertyManager::value(const QtProperty *property) const
{
return d_ptr->m_values.value(property, QTime());
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\reimp
*/
QString QtTimePropertyManager::valueText(const QtProperty *property) const
{
const QtTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
if (it == d_ptr->m_values.constEnd())
return QString();
return it.value().toString(d_ptr->m_format);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtTimePropertyManager::setValue(QtProperty *property, const QTime &value)
Sets the value of the given \a property to \a value.
\sa value(), valueChanged()
*/
void QtTimePropertyManager::setValue(QtProperty *property, const QTime &val)
{
setSimpleValue<const QTime &, QTime, QtTimePropertyManager>(d_ptr->m_values, this,
&QtTimePropertyManager::propertyChanged,
&QtTimePropertyManager::valueChanged,
property, val);
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\reimp
*/
void QtTimePropertyManager::initializeProperty(QtProperty *property)
{
d_ptr->m_values[property] = QTime::currentTime();
}
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
\reimp
*/
void QtTimePropertyManager::uninitializeProperty(QtProperty *property)
{
d_ptr->m_values.remove(property);
}
// QtDateTimePropertyManager
class QtDateTimePropertyManagerPrivate
{
QtDateTimePropertyManager *q_ptr;
Q_DECLARE_PUBLIC(QtDateTimePropertyManager)
public:
QString m_format;
typedef QMap<const QtProperty *, QDateTime> PropertyValueMap;
PropertyValueMap m_values;
};
Janik Zikovsky
committed
/** \class QtDateTimePropertyManager
Roman Tolchenov
committed
\brief The QtDateTimePropertyManager provides and manages QDateTime properties.
A date and time property has a current value which can be
retrieved using the value() function, and set using the setValue()
slot. In addition, QtDateTimePropertyManager provides the
valueChanged() signal which is emitted whenever a property created
by this manager changes.
\sa QtAbstractPropertyManager, QtDateTimeEditFactory, QtDatePropertyManager
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
\fn void QtDateTimePropertyManager::valueChanged(QtProperty *property, const QDateTime &value)
This signal is emitted whenever a property created by this manager
changes its value, passing a pointer to the \a property and the new
\a value as parameters.
*/
Janik Zikovsky
committed
/**
Roman Tolchenov
committed
Creates a manager with the given \a parent.
*/
QtDateTimePropertyManager::QtDateTimePropertyManager(QObject *parent)