Qt IOC Container 3.5


PropertyListInjector.cpp

Go to the documentation of this file.
00001 #include "ReferenceInjector.h"
00002 #include "PropertyListInjector.h"
00003 
00004 #include <QString>
00005 #include <QHash>
00006 #include <QtPlugin>
00007 
00008 using namespace qic;
00009 
00010 QVariant
00011 PropertyListInjector::injectReference (QVariant & prop, ReferenceResolver * resolver, QHash <QString, QObject *> & injector_map)
00012 {
00013   QVariantList list;
00014   foreach (QVariant val, prop.value<QVariantList>())
00015   {
00016     QString type(val.typeName());
00017     if (injector_map.contains(type))
00018     {
00019       QObject * injector_obj = injector_map[type];
00020       ReferenceInjector * injector = qobject_cast<ReferenceInjector *>(injector_obj);
00021       QVariant propVal = injector->injectReference( val, resolver, injector_map);
00022       list.append(propVal); 
00023     }
00024     else
00025     {
00026       list.append(val);
00027     }
00028   }
00029   return QVariant::fromValue(list);
00030 }
00031 
00032 Q_EXPORT_PLUGIN2(list_injector, PropertyListInjector)