示例#1
0
bool ClientUI::ZoomToObject(const std::string& name) {
    const ObjectMap& objects = GetUniverse().Objects();
    for (ObjectMap::const_iterator<> it = objects.const_begin(); it != objects.const_end(); ++it)
        if (boost::iequals(it->Name(), name))
            return ZoomToObject(it->ID());
    return false;
}
bool JsonDbEphemeralPartition::get(const QUuid &uuid, JsonDbObject *result) const
{
    ObjectMap::const_iterator it = mObjects.find(uuid);
    if (it == mObjects.end())
        return false;
    if (result)
        *result = it.value();
    return true;
}
QGraphicsWidget* HbXmlLoaderBaseActions::findWidget( const QString &name )
{
    QGraphicsWidget *result = 0;
    
    ObjectMap::const_iterator it = mObjectMap.find(name);
    if (it != mObjectMap.end() && it.value().mType == HbXml::WIDGET ) {
        result = static_cast<QGraphicsWidget *>(it.value().mObject.data());
    }    
        
    return result;        
}
HbXmlLoaderBaseActions::ObjectMapItem HbXmlLoaderBaseActions::lookUp(const QString& type, const QString &name, const QString &plugin)
{   
    const bool nameNotEmpty = name.size() != 0;
    bool doLookUp = true;
    ObjectMapItem current;
    current.mObject = 0;
    current.mType = HbXml::OBJECT;
    
    if (nameNotEmpty) {
        ObjectMap::const_iterator it = mObjectMap.find(name);
        if (it != mObjectMap.end()) {
            current = it.value();
            
            if (!current.mObject) {
                mObjectMap.remove(name);
            }
            // CHECK DISABLED FOR NOW.
            /*
            if (current.mObject && !type.isEmpty()) {
                const QByteArray array = type.toUtf8();
                
                if (!current.mObject->inherits(array.data())) {                    
                    HB_DOCUMENTLOADER_PRINT( QString( "Existing object requested with invalid type" ) );
                    // We have object already in mObjectMap, but it does not fulfill
                    // all needs. So object look up has failed.
                    doLookUp = false;
                    current.mObject = 0;
                }
            }
            */
        }
    }
    
    if (doLookUp && !current.mObject) {
        QObject *obj = createObject(type, name, plugin);        
        if (obj) {
            current.mObject = obj;
            current.mType = qobject_cast<QGraphicsWidget*>(obj) ? HbXml::WIDGET : HbXml::OBJECT;
        }
        if (nameNotEmpty) {
            mObjectMap.insert(name, current);
        }
    }

    return current;
}