//------------------------------------------------------------------------------------------------- void tNdp2kTableDataSources::OnMyRowChanged( int row ) { tDataType dataType; tSourceSelections selections; { tQMutexLocker locker( &m_Lock ); if (row >= m_Table.count()) return; dataType = m_Table[ row ].dataType; selections = m_Table[ row ].selections; } if (row < m_DefaultFormatRows && m_ShareChanges == true) { tDataType type = m_pDefaultFormatTypes[ row ]; Assert( type == dataType ); eDigitalDataSourceSettingId settingID = m_pSourceSettings->DataTypeToSettingId( type ); if (m_pSourceSettings->SettingIdToDataType( settingID ) == type) { tDigitalDataSourceSettings::tGlobalSetting setting(*m_pSourceSettings); setting.SetDataSourceList( selections ); setting.Save( settingID, eDDSFrom_Table ); } } Settings().SetValue( QString::number(row), ToVariant( dataType, selections ) ); }
//------------------------------------------------------------------------------------------------- bool tNdp2kTableDataSources::OnGlobalDataSourceChanged( int row, eDigitalDataSourceSettingId sid, eDigitalDataSourceFrom ) { if (row < 0) { Assert(row >= 0); return false; } if (row >= m_DefaultFormatRows) { Assert(row < m_DefaultFormatRows); return false; } if (m_pSourceSettings->SettingIdToDataType(sid) != m_pDefaultFormatTypes[row]) { Assert(m_pSourceSettings->SettingIdToDataType(sid) == m_pDefaultFormatTypes[row]); return false; } tDigitalDataSourceSettings::tGlobalSetting setting(*m_pSourceSettings); setting.Load( sid ); bool changed = false; tDataType dataType = DATA_TYPE_INVALID; // just to keep the compiler happy { tQMutexLocker locker( &m_Lock ); if (setting.DataSourceList() != m_Table.at( row ).selections) { dataType = m_Table.at( row ).dataType; m_Table[ row ].selections = setting.DataSourceList(); m_Table[ row ].dirty = true; changed = true; } } if (changed) { Settings().SetValue( QString::number(row), ToVariant( dataType, setting.DataSourceList() ) ); if (m_SelectionInProgress) m_ExtendedDelay = true; if (m_ShareChanges == true) PostponeSyncs( m_ExtendedDelay ? 36 : 5 ); m_UpdateTimer.start( m_ExtendedDelay ? 18000 : 2000 ); //(from == eDDSFrom_UDB)? 2000 : 1000 ); return true; } return false; }
//--------------------------------------------------------------------------------------- void tNdp2kTableDataSources::SaveSettings() { Settings().Remove( QString() ); // remove everything OnSaveVersion( GetCachedVersion() ); Settings().SetValue( cKeyFormat, GetFormat() ); Settings().SetValue( cKeyFormatRows, m_Table.count() ); for (unsigned row = 0, end = m_Table.count(); row < end; ++row) { const tRow& info = m_Table.at( row ); Settings().SetValue( QString::number(row), ToVariant( info.dataType, info.selections ) ); } }
Urho3D::VariantMap ToVariantMap(const Dictionary* d) { if (!d) return Urho3D::VariantMap(); int i = 0; String key; Variant* v; Urho3D::VariantMap map; while (i <= d->Size()) { d->Iterate(i,key,v); map[key.CString()] = ToVariant(v); } return map; }
QVariant GetPropertyValue( AEditableProperty* theProperty ) { if (theProperty->Is<EdProperty_Bool>()) { EdProperty_Bool* pProperty = static_cast< EdProperty_Bool* >( theProperty ); return QVariant(pProperty->Get()); } else if (theProperty->Is<EdProperty_UInt32>()) { EdProperty_UInt32* pProperty = static_cast< EdProperty_UInt32* >( theProperty ); return QVariant(pProperty->Get()); } else if (theProperty->Is<EdProperty_Float>()) { EdProperty_Float* pProperty = static_cast< EdProperty_Float* >( theProperty ); return QVariant(pProperty->Get()); } else if (theProperty->Is<EdProperty_Vector3D>()) { EdProperty_Vector3D* pProperty = static_cast< EdProperty_Vector3D* >( theProperty ); return ToVariant(pProperty->Get()); } else if (theProperty->Is<EdProperty_Quat>()) { EdProperty_Quat* pProperty = static_cast< EdProperty_Quat* >( theProperty ); return ToVariant(pProperty->Get()); } else if (theProperty->Is<EdProperty_Array>()) { EdProperty_Array* pPropertyArray = static_cast< EdProperty_Array* >( theProperty ); (void)pPropertyArray; #if 0 QList<QVariant> valueList; valueList.reserve(pPropertyArray->Num()); for( UINT iProperty = 0; iProperty < pPropertyArray->Num(); iProperty++ ) { AProperty * pProperty = pPropertyArray->ToPtr()[ iProperty ]; valueList.append( GetPropertyValue( pProperty ) ); } return QVariant(valueList); #else return QVariant(); #endif } MX_REMOVE_OLD_CODE //else if (theProperty->Is<EdProperty_AssetReference>()) //{ // EdProperty_AssetReference* pProperty = static_cast< EdProperty_AssetReference* >( theProperty ); // const SResourceObject* resource = pProperty->Get(); // if( resource != nil ) // { // return QVariant(QString(resource->edGetEditorInterface()->edToChars(0))); // } // else // { // return "NULL"; // } // //return QVariant(QString(EdResourceIdToChars(resource->GetResourceGUID()))); //} else if (theProperty->Is<EdProperty_String>()) { EdProperty_String* pProperty = static_cast< EdProperty_String* >( theProperty ); return ToVariant(pProperty->Get()); } else if (theProperty->Is<EdProperty_ClassGuid>()) { EdProperty_ClassGuid* pProperty = static_cast< EdProperty_ClassGuid* >( theProperty ); return ToVariant(pProperty->rttiGetTypeName()); } else if (theProperty->Is<EdProperty_FileTime>()) { EdProperty_FileTime* pProperty = static_cast< EdProperty_FileTime* >( theProperty ); return ToVariant(pProperty->Get()); } else if (theProperty->Is<Property_32BitHexId>()) { Property_32BitHexId* pProperty = static_cast< Property_32BitHexId* >( theProperty ); return ResourceIdToVariant(pProperty->Get()); } else if (theProperty->Is<EdProperty_ColorRGBA>()) { EdProperty_ColorRGBA* pProperty = static_cast< EdProperty_ColorRGBA* >( theProperty ); return ColorToVariant(pProperty->Get()); } else if (theProperty->Is<EdProperty_VoidPointer>()) { EdProperty_VoidPointer* pProperty = static_cast< EdProperty_VoidPointer* >( theProperty ); return VoidPointerIdToVariant(pProperty->Get()); } else if (theProperty->Is<EdProperty_Enum>()) { EdProperty_Enum* pProperty = static_cast< EdProperty_Enum* >( theProperty ); return pProperty->GetCurrEnumItem().name.ToChars(); } else { Unimplemented; return nil; } }
QByteArray Serialize(const QObject *object, const QStringList &ignoredPropertyNames, IndentMode indentMode, bool *ok) { if (object) return Serialize(ToVariant(object, ignoredPropertyNames), indentMode, ok); return QByteArray(); }
void ToVariant(const std::string& str, VARIANT* var) { ToVariant(str.c_str(), var); }