mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-30 07:03:46 +08:00
update
This commit is contained in:
parent
636dddaa84
commit
20852ac6bf
@ -139,7 +139,7 @@ target_include_directories(example PRIVATE
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/component
|
${CMAKE_CURRENT_SOURCE_DIR}/src/component
|
||||||
)
|
)
|
||||||
|
|
||||||
#如何是静态库则需要手动注册插件,导入FluentUI.h头文件
|
#如果是静态库则需要手动注册插件,导入FluentUI.h头文件
|
||||||
if(FLUENTUI_BUILD_STATIC_LIB)
|
if(FLUENTUI_BUILD_STATIC_LIB)
|
||||||
target_include_directories(example PRIVATE
|
target_include_directories(example PRIVATE
|
||||||
${CMAKE_SOURCE_DIR}/src
|
${CMAKE_SOURCE_DIR}/src
|
||||||
|
@ -35,7 +35,9 @@ bool ViewModelManager::exist(const QString& key){
|
|||||||
void ViewModelManager::refreshViewModel(FluViewModel* viewModel,QString key,QVariant value){
|
void ViewModelManager::refreshViewModel(FluViewModel* viewModel,QString key,QVariant value){
|
||||||
foreach (auto item, _viewmodel) {
|
foreach (auto item, _viewmodel) {
|
||||||
if(item->getKey() == viewModel->getKey()){
|
if(item->getKey() == viewModel->getKey()){
|
||||||
|
item->enablePropertyChange = false;
|
||||||
item->setProperty(key.toStdString().c_str(),value);
|
item->setProperty(key.toStdString().c_str(),value);
|
||||||
|
item->enablePropertyChange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,14 +53,16 @@ PropertyObserver::~PropertyObserver(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PropertyObserver::_propertyChange(){
|
void PropertyObserver::_propertyChange(){
|
||||||
|
auto viewModel = (FluViewModel*)parent();
|
||||||
|
if(viewModel->enablePropertyChange){
|
||||||
auto value = _property.read();
|
auto value = _property.read();
|
||||||
_model->setProperty(_name.toStdString().c_str(),value);
|
_model->setProperty(_name.toStdString().c_str(),value);
|
||||||
ViewModelManager::getInstance()->refreshViewModel((FluViewModel*)parent(),_name,value);
|
ViewModelManager::getInstance()->refreshViewModel(viewModel,_name,value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluViewModel::FluViewModel(QObject *parent):QObject{parent}{
|
FluViewModel::FluViewModel(QObject *parent):QObject{parent}{
|
||||||
scope(FluViewModelType::Scope::Window);
|
scope(FluViewModelType::Scope::Window);
|
||||||
target(nullptr);
|
|
||||||
ViewModelManager::getInstance()->insertViewModel(this);
|
ViewModelManager::getInstance()->insertViewModel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +81,7 @@ void FluViewModel::componentComplete(){
|
|||||||
}
|
}
|
||||||
const QMetaObject* obj = metaObject();
|
const QMetaObject* obj = metaObject();
|
||||||
if(_scope == FluViewModelType::Scope::Window){
|
if(_scope == FluViewModelType::Scope::Window){
|
||||||
_key = property("objectName_").toString()+QString::number(reinterpret_cast<qulonglong>(_window), 16);
|
_key = property("objectName").toString()+"-"+QString::number(reinterpret_cast<qulonglong>(_window), 16);
|
||||||
}else{
|
}else{
|
||||||
_key = property("objectName").toString();
|
_key = property("objectName").toString();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ class FluViewModel : public QObject, public QQmlParserStatus
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(QQmlParserStatus)
|
Q_INTERFACES(QQmlParserStatus)
|
||||||
Q_PROPERTY_AUTO(int,scope);
|
Q_PROPERTY_AUTO(int,scope);
|
||||||
Q_PROPERTY_AUTO(QObject*,target);
|
|
||||||
QML_NAMED_ELEMENT(FluViewModel)
|
QML_NAMED_ELEMENT(FluViewModel)
|
||||||
public:
|
public:
|
||||||
explicit FluViewModel(QObject *parent = nullptr);
|
explicit FluViewModel(QObject *parent = nullptr);
|
||||||
@ -29,6 +28,7 @@ public:
|
|||||||
void componentComplete() override;
|
void componentComplete() override;
|
||||||
Q_SIGNAL void initData();
|
Q_SIGNAL void initData();
|
||||||
QString getKey();
|
QString getKey();
|
||||||
|
bool enablePropertyChange = true;
|
||||||
private:
|
private:
|
||||||
QObject* _window = nullptr;
|
QObject* _window = nullptr;
|
||||||
QString _key = "";
|
QString _key = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user