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
|
||||
)
|
||||
|
||||
#如何是静态库则需要手动注册插件,导入FluentUI.h头文件
|
||||
#如果是静态库则需要手动注册插件,导入FluentUI.h头文件
|
||||
if(FLUENTUI_BUILD_STATIC_LIB)
|
||||
target_include_directories(example PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
|
@ -35,7 +35,9 @@ bool ViewModelManager::exist(const QString& key){
|
||||
void ViewModelManager::refreshViewModel(FluViewModel* viewModel,QString key,QVariant value){
|
||||
foreach (auto item, _viewmodel) {
|
||||
if(item->getKey() == viewModel->getKey()){
|
||||
item->enablePropertyChange = false;
|
||||
item->setProperty(key.toStdString().c_str(),value);
|
||||
item->enablePropertyChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,14 +53,16 @@ PropertyObserver::~PropertyObserver(){
|
||||
}
|
||||
|
||||
void PropertyObserver::_propertyChange(){
|
||||
auto viewModel = (FluViewModel*)parent();
|
||||
if(viewModel->enablePropertyChange){
|
||||
auto value = _property.read();
|
||||
_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}{
|
||||
scope(FluViewModelType::Scope::Window);
|
||||
target(nullptr);
|
||||
ViewModelManager::getInstance()->insertViewModel(this);
|
||||
}
|
||||
|
||||
@ -77,7 +81,7 @@ void FluViewModel::componentComplete(){
|
||||
}
|
||||
const QMetaObject* obj = metaObject();
|
||||
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{
|
||||
_key = property("objectName").toString();
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ class FluViewModel : public QObject, public QQmlParserStatus
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QQmlParserStatus)
|
||||
Q_PROPERTY_AUTO(int,scope);
|
||||
Q_PROPERTY_AUTO(QObject*,target);
|
||||
QML_NAMED_ELEMENT(FluViewModel)
|
||||
public:
|
||||
explicit FluViewModel(QObject *parent = nullptr);
|
||||
@ -29,6 +28,7 @@ public:
|
||||
void componentComplete() override;
|
||||
Q_SIGNAL void initData();
|
||||
QString getKey();
|
||||
bool enablePropertyChange = true;
|
||||
private:
|
||||
QObject* _window = nullptr;
|
||||
QString _key = "";
|
||||
|
Loading…
Reference in New Issue
Block a user