// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qtpropertymanager.h"
#include "qtpropertybrowserutils_p.h"
#include <QtCore/QDateTime>
#include <QtCore/QHash>
#include <QtCore/QLocale>
#include <QtCore/QMap>
#include <QtCore/QMetaEnum>
#include <QtCore/QRegularExpression>
#include <QtCore/QTimer>
#include <QtGui/QFontDatabase>
#include <QtGui/QIcon>
#include <QtGui/QPainter>
#include <QtWidgets/QApplication>
#include <QtWidgets/QLabel>
#include <QtWidgets/QStyle>
#include <QtWidgets/QStyleOption>
#include <limits>
#include <limits.h>
#include <float.h>
#if defined(Q_CC_MSVC)
# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */
#endif
QT_BEGIN_NAMESPACE
template <class PrivateData, class Value>
static void setSimpleMinimumData(PrivateData *data, const Value &minVal)
{
data->minVal = minVal;
if (data->maxVal < data->minVal)
data->maxVal = data->minVal;
if (data->val < data->minVal)
data->val = data->minVal;
}
template <class PrivateData, class Value>
static void setSimpleMaximumData(PrivateData *data, const Value &maxVal)
{
data->maxVal = maxVal;
if (data->minVal > data->maxVal)
data->minVal = data->maxVal;
if (data->val > data->maxVal)
data->val = data->maxVal;
}
template <class PrivateData, class Value>
static void setSizeMinimumData(PrivateData *data, const Value &newMinVal)
{
data->minVal = newMinVal;
if (data->maxVal.width() < data->minVal.width())
data->maxVal.setWidth(data->minVal.width());
if (data->maxVal.height() < data->minVal.height())
data->maxVal.setHeight(data->minVal.height());
if (data->val.width() < data->minVal.width())
data->val.setWidth(data->minVal.width());
if (data->val.height() < data->minVal.height())
data->val.setHeight(data->minVal.height());
}
template <class PrivateData, class Value>
static void setSizeMaximumData(PrivateData *data, const Value &newMaxVal)
{
data->maxVal = newMaxVal;
if (data->minVal.width() > data->maxVal.width())
data->minVal.setWidth(data->maxVal.width());
if (data->minVal.height() > data->maxVal.height())
data->minVal.setHeight(data->maxVal.height());
if (data->val.width() > data->maxVal.width())
data->val.setWidth(data->maxVal.width());
if (data->val.height() > data->maxVal.height())
data->val.setHeight(data->maxVal.height());
}
template <class SizeValue>
static SizeValue qBoundSize(const SizeValue &minVal, const SizeValue &val, const SizeValue &maxVal)
{
SizeValue croppedVal = val;
if (minVal.width() > val.width())
croppedVal.setWidth(minVal.width());
else if (maxVal.width() < val.width())
croppedVal.setWidth(maxVal.width());
if (minVal.height() > val.height())
croppedVal.setHeight(minVal.height());
else if (maxVal.height() < val.height())
croppedVal.setHeight(maxVal.height());
return croppedVal;
}
// Match the exact signature of qBound for VS 6.
QSize qBound(QSize minVal, QSize val, QSize maxVal)
{
return qBoundSize(minVal, val, maxVal);
}
QSizeF qBound(QSizeF minVal, QSizeF val, QSizeF maxVal)
{
return qBoundSize(minVal, val, maxVal);
}
namespace {
namespace {
template <class Value>
void orderBorders(Value &minVal, Value &maxVal)
{
if (minVal > maxVal)
qSwap(minVal, maxVal);
}
template <class Value>
static void orderSizeBorders(Value &minVal, Value &maxVal)
{
Value fromSize = minVal;
Value toSize = maxVal;
if (fromSize.width() > toSize.width()) {
fromSize.setWidth(maxVal.width());
toSize.setWidth(minVal.width());
}
if (fromSize.height() > toSize.height()) {
fromSize.setHeight(maxVal.height());
toSize.setHeight(minVal.height());
}
minVal = fromSize;
maxVal = toSize;
}
void orderBorders(QSize &minVal, QSize &maxVal)
{
orderSizeBorders(minVal, maxVal);
}
void orderBorders(QSizeF &minVal, QSizeF &maxVal)
{
orderSizeBorders(minVal, maxVal);
}
}
}
////////
template <class Value, class PrivateData>
static Value getData(const QHash<const QtProperty *, PrivateData> &propertyMap,
Value PrivateData::*data,
const QtProperty *property, const Value &defaultValue = Value())
{
const auto it = propertyMap.constFind(property);
if (it == propertyMap.constEnd())
return defaultValue;
return it.value().*data;
}
template <class Value, class PrivateData>
static Value getValue(const QHash<const QtProperty *, PrivateData> &propertyMap,
const QtProperty *property, const Value &defaultValue = Value())
{
return getData<Value>(propertyMap, &PrivateData::val, property, defaultValue);
}
template <class Value, class PrivateData>
static Value getMinimum(const QHash<const QtProperty *, PrivateData> &propertyMap,
const QtProperty *property, const Value &defaultValue = Value())
{
return getData<Value>(propertyMap, &PrivateData::minVal, property, defaultValue);
}
template <class Value, class PrivateData>
static Value getMaximum(const QHash<const QtProperty *, PrivateData> &propertyMap,
const QtProperty *property, const Value &defaultValue = Value())
{
return getData<Value>(propertyMap, &PrivateData::maxVal, property, defaultValue);
}
template <class ValueChangeParameter, class Value, class PropertyManager>
static void setSimpleValue(QHash<const QtProperty *, Value> &propertyMap,
PropertyManager *manager,
void (PropertyManager::*propertyChangedSignal)(QtProperty *),
void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter),
QtProperty *property, const Value &val)
{
const auto it = propertyMap.find(property);
if (it == propertyMap.end())
return;
if (it.value() == val)
return;
it.value() = val;
emit (manager->*propertyChangedSignal)(property);
emit (manager->*valueChangedSignal)(property, val);
}
template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value>
static void setValueInRange(PropertyManager *manager, PropertyManagerPrivate *managerPrivate,
void (PropertyManager::*propertyChangedSignal)(QtProperty *),
void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter),
QtProperty *property, const Value &val,
void (PropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, ValueChangeParameter))
{
const auto it = managerPrivate->m_values.find(property);
if (it == managerPrivate->m_values.end())
return;
auto &data = it.value();
if (data.val == val)
return;
const Value oldVal = data.val;
data.val = qBound(data.minVal, val, data.maxVal);
if (data.val == oldVal)
return;
if (setSubPropertyValue)
(managerPrivate->*setSubPropertyValue)(property, data.val);
emit (manager->*propertyChangedSignal)(property);
emit (manager->*valueChangedSignal)(property, data.val);
}
template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value>
static void setBorderValues(PropertyManager *manager, PropertyManagerPrivate *managerPrivate,
void (PropertyManager::*propertyChangedSignal)(QtProperty *),
void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter),
void (PropertyManager::*rangeChangedSignal)(QtProperty *, ValueChangeParameter, ValueChangeParameter),
QtProperty *property, ValueChangeParameter minVal, ValueChangeParameter maxVal,
void (Prop
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
qtpropertybrowser.zip (42个子文件)
qttreepropertybrowser.h 3KB
qtgroupboxpropertybrowser.h 914B
qtpropertybrowser.cpp 61KB
qtpropertybrowserutils.cpp 10KB
qtpropertybrowser_p.h 8KB
qttreepropertybrowser.cpp 33KB
qtvariantproperty_p.h 4KB
qtvariantproperty.cpp 96KB
qtpropertymanager_p.h 23KB
qtbuttonpropertybrowser_p.h 1KB
qttreepropertybrowser_p.h 3KB
qtpropertybrowser.h 8KB
qtbuttonpropertybrowser.h 1KB
qtvariantproperty.h 4KB
qtgroupboxpropertybrowser_p.h 1KB
qteditorfactory.h 10KB
images
cursor-forbidden.png 199B
cursor-sizev.png 141B
cursor-wait.png 172B
cursor-busy.png 201B
cursor-vsplit.png 161B
cursor-cross.png 130B
cursor-closedhand.png 147B
cursor-sizeall.png 174B
cursor-whatsthis.png 191B
cursor-arrow.png 171B
cursor-uparrow.png 132B
cursor-hsplit.png 155B
cursor-sizef.png 161B
cursor-openhand.png 160B
cursor-sizeb.png 161B
cursor-sizeh.png 145B
cursor-ibeam.png 124B
cursor-hand.png 159B
qtgroupboxpropertybrowser.cpp 15KB
qteditorfactory_p.h 10KB
qtpropertybrowserutils_p.h 2KB
qtpropertybrowser.pri 1KB
qteditorfactory.cpp 76KB
qtpropertymanager.cpp 206KB
qtbuttonpropertybrowser.cpp 18KB
qtpropertymanager.h 23KB
共 42 条
- 1
资源评论
不秃头的yao
- 粉丝: 50
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 实训任务1 图形化方式创建数据库表及约束.sql
- 数据集大小对分析结果的影响:深入探讨与Python代码实践
- NX1P2 CPU单元内置I/O及扩展板使用指南
- GuardLogix 5580与Compact GuardLogix 5380控制器系统安全参考手册
- 强网杯基于python实现完整源代码分享给需要的同学
- SDRAM手册-W9825G6KH
- java程序设计-基于JAVA的RSA文件加密软件的设计与实现(源代码+论文)79.rar
- 基于JAVA的RSA文件加密软件的设计与实现(源代码+论文)
- Kinetix运动控制选型指南:罗克韦尔自动化运动控制解决方案及其应用
- CompactLogix 5380 控制器的高级功能及应用场景解析
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功