Ejemplo n.º 1
0
AIDA::IHistogram3D*
AIDA_ROOT::AIDA_HistogramFactory::createHistogram3D( const std::string& name, const std::string& title, int nBinsX, double lowerEdgeX, double upperEdgeX, int nBinsY, double lowerEdgeY, double upperEdgeY, int nBinsZ, double lowerEdgeZ, double upperEdgeZ, const std::string& options )
{
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  try{
#endif
  AIDA::Dev::IDevHistogram3D* p = m_factory.createHistogram3D( title, nBinsX, lowerEdgeX, upperEdgeX, nBinsY, lowerEdgeY, upperEdgeY, nBinsZ, lowerEdgeZ, upperEdgeZ, options );
  return registerObject( p, name );
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  }
  catch( std::exception& e ) {
    HISTOGRAM_REPORT_ERROR( e.what() );
    return 0;
  }
#endif
}
Ejemplo n.º 2
0
AIDA::IHistogram2D*
AIDA_ROOT::AIDA_HistogramFactory::sliceYZ( const std::string& name, const AIDA::IHistogram3D& h, int indexX1, int indexX2 )
{
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  try{
#endif
  AIDA::Dev::IDevHistogram2D* p = m_factory.sliceYZ( h, indexX1, indexX2 );
  return registerObject( p, name );
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  }
  catch( std::exception& e ) {
    HISTOGRAM_REPORT_ERROR( e.what() );
    return 0;
  }
#endif
}
Ejemplo n.º 3
0
AIDA::IProfile2D*
AIDA_ROOT::AIDA_HistogramFactory::createProfile2D( const std::string& name, int nBinsX, double lowerEdgeX, double upperEdgeX, int nBinsY, double lowerEdgeY, double upperEdgeY, double lowerValue, double upperValue )
{
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  try{
#endif
  AIDA::Dev::IDevProfile2D* p = m_factory.createProfile2D( nBinsX, lowerEdgeX, upperEdgeX, nBinsY, lowerEdgeY, upperEdgeY, lowerValue, upperValue );
  return registerObject( p, name );
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  }
  catch( std::exception& e ) {
    HISTOGRAM_REPORT_ERROR( e.what() );
    return 0;
  }
#endif
}
Ejemplo n.º 4
0
AIDA::IHistogram2D*
AIDA_ROOT::AIDA_HistogramFactory::divide( const std::string& name, const AIDA::IHistogram2D& a, const AIDA::IHistogram2D& b )
{
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  try{
#endif
  AIDA::Dev::IDevHistogram2D* p = m_factory.divide( a, b );
  return registerObject( p, name );
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  }
  catch( std::exception& e ) {
    HISTOGRAM_REPORT_ERROR( e.what() );
    return 0;
  }
#endif
}
Ejemplo n.º 5
0
AIDA::IProfile2D*
AIDA_ROOT::AIDA_HistogramFactory::createProfile2D( const std::string& name, const std::string& title, const std::vector< double >& binEdgeX, const std::vector< double >& binEdgeY, const std::string& options )
{
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  try{
#endif
  AIDA::Dev::IDevProfile2D* p = m_factory.createProfile2D( title, binEdgeX, binEdgeY, options );
  return registerObject( p, name );
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  }
  catch( std::exception& e ) {
    HISTOGRAM_REPORT_ERROR( e.what() );
    return 0;
  }
#endif
}
Ejemplo n.º 6
0
AIDA::ICloud1D*
AIDA_ROOT::AIDA_HistogramFactory::createCloud1D( const std::string& name )
{
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  try{
#endif
  AIDA::Dev::IDevCloud1D* p = m_factory.createCloud1D();
  return registerObject( p, name );
#ifdef AIDA_ROOT_HISTOGRAM_NO_EXCEPTIONS_TO_USER
  }
  catch( std::exception& e ) {
    HISTOGRAM_REPORT_ERROR( e.what() );
    return 0;
  }
#endif
}
Ejemplo n.º 7
0
	Server::Server ()
	: QObject ()
	{
		qInstallMsgHandler (Write);
		const auto pid = QCoreApplication::applicationPid ();

		RegisterTypes ();

		auto sb = QDBusConnection::sessionBus ();
		const auto& serviceName = QString ("org.LeechCraft.Wrapper_%1").arg (pid);
		qDebug () << "registering service..." << sb.registerService (serviceName);
		qDebug () << "registering primary object..." << sb.registerObject ("/org/LeechCraft/Control",
				this, QDBusConnection::ExportAllContents);

		QLocalSocket socket;
		socket.connectToServer (QString ("lc_waiter_%1").arg (pid));
		qDebug () << "notifying master..." << socket.waitForConnected ();
	}
Ejemplo n.º 8
0
Foam::regIOobject::regIOobject
(
    const IOobject& io,
    const regIOobject& rio
)
:
    IOobject(io),
    registered_(false),
    ownedByRegistry_(false),
    watchIndex_(-1),
    eventNo_(db().getEvent()),
    isPtr_(NULL)
{
    if (registerObject())
    {
        checkIn();
    }
}
Ejemplo n.º 9
0
AudioOutputPort *AudioOutputPortCache::getAudioOutputPort(const char* portName, const char* connection)
{
    int key = std::hash<std::string>()(portName);
    // see if port already exists in map
    AudioOutputPort *port = findObject(key);
    if(!port) {
        // create system port
        jack_port_t *jackPort = AudioEngine::instance().registerAudioOutputPort(portName);
        if(!jackPort) {
            throw std::logic_error(std::string("Failed to register port ") + portName);
        }
        port = new AudioOutputPort(jackPort);
        registerObject(key, port);
    }
    if(connection) {
        port->systemConnect(connection);
    }
    return port;
}
Ejemplo n.º 10
0
// Assign to IOobject
void Foam::regIOobject::operator=(const IOobject& io)
{
    if (isPtr_)
    {
        delete isPtr_;
        isPtr_ = NULL;
    }

    // Check out of objectRegistry
    checkOut();

    IOobject::operator=(io);

    if (registerObject())
    {
        // Re-register object with objectRegistry
        checkIn();
    }
}
Ejemplo n.º 11
0
// Construct from IOobject
Foam::regIOobject::regIOobject(const IOobject& io, const bool isTime)
:
    IOobject(io),
    registered_(false),
    ownedByRegistry_(false),
    watchIndex_(-1),
    eventNo_                // Do not get event for top level Time database
    (
        isTime
      ? 0
      : db().getEvent()
    ),
    isPtr_(NULL)
{
    // Register with objectRegistry if requested
    if (registerObject())
    {
        checkIn();
    }
}
Ejemplo n.º 12
0
void AkVCam::PluginInterface::destroyDevice(const std::string &deviceId)
{
    AkLoggerLog("AkVCam::PluginInterface::destroyDevice");

    for (auto it = this->m_devices.begin(); it != this->m_devices.end(); it++) {
        auto device = *it;

        std::string curDeviceId;
        device->properties().getProperty(kCMIODevicePropertyDeviceUID,
                                         &curDeviceId);

        if (curDeviceId == deviceId) {
            device->stopStreams();
            device->registerObject(false);
            device->registerStreams(false);
            this->m_devices.erase(it);

            break;
        }
    }
}
Ejemplo n.º 13
0
AudioInputPort *AudioInputPortCache::getAudioInputPort(const char *name, const char *connection)
{
    // see if port already exists in map
    int key = std::hash<std::string>()(name);
    AudioInputPort *port = findObject(key);
    if (!port) {
        // create new jack port
        jack_port_t *jackPort = AudioEngine::instance().registerAudioInputPort(name);
        if(!jackPort) {
            throw "Failed to register port ";
        }
        // add to map
        port = new AudioInputPort(jackPort);
        registerObject(key, port);
        // auto connect output port
    }
    if (connection) {
        port->systemConnect(connection);
    }
    return port;
}
Ejemplo n.º 14
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setOrganizationName("kylin");
    a.setApplicationName("Kylin Weather (indication-china-weather)");
    a.setApplicationVersion("3.0.1");
    a.setQuitOnLastWindowClosed(false);//Avoid that after hiding mainwindow, close the sub window would cause the program exit

    QString locale = QLocale::system().name();
    QTranslator translator;
    if(locale == "zh_CN") {
        if(!translator.load("indicator-china-weather_" + locale + ".qm",
                            ":/qm/translation/"))
            qDebug() << "Load translation file:"<< "indicator-china-weather_" + locale + ".qm" << " failed!";
        else
            a.installTranslator(&translator);
    }

//    QTranslator qtTranslator;
//    qtTranslator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
//    a.installTranslator(&qtTranslator);

    MainWindow w;
    DbusAdaptor adaptor(&w);
    Q_UNUSED(adaptor);
    auto connection = QDBusConnection::sessionBus();
    if (!connection.registerService("com.kylin.weather") || !connection.registerObject("/com/kylin/weather", &w/*, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals*/)) {
        //qCritical() << "QDbus register service failed reason:" << connection.lastError();
        QDBusInterface iface("com.kylin.weather",
                                       "/com/kylin/weather",
                                       "com.kylin.weather",
                                       connection);
        iface.call("showMainWindow");

        return 0;
    }//QDBusConnection::sessionBus().unregisterService("com.kylin.weather");
    //w.show();

    return a.exec();
}
Ejemplo n.º 15
0
bool MasterConfig::init()
{
    LBASSERT( !_objects );
    _objects = new ObjectMap( *this, *getApplication( ));

    co::Object* initData = getInitData();
    if( initData )
        LBCHECK( _objects->register_( initData, OBJECTTYPE_INITDATA ));
    _objects->setInitData( initData );

    LBCHECK( registerObject( _objects ));

    if( !eq::Config::init( _objects->getID( )))
    {
        LBWARN << "Error during initialization" << std::endl;
        exit();
        return false;
    }

    _redraw = true;
    return true;
}
Ejemplo n.º 16
0
int mainMenu(void)
{
   int option = -1;

   //system("clear");

   printf("Welcome\n");
   printf("1. Register\n");
   printf("2. Unregister\n");
   printf("3. Query\n");
   printf("4. Exit\n");
   printf("\nOption: ");
   scanf("%d", &option);

   switch (option)
   {
      case 1:
         registerObject();
         break;
      case 2:
         unregisterObject();
         break;
      case 3:
         query();
         break;
      case 4:
         printf("All done!\n");
         break;
      default:
         // no point printing message; system("clear") will erase it.
         //printf("Enter a valid Option, 1 - 4");

         // this will flush the input stream
         while (getchar() != '\n');
         break;
   }

   return option;
}
Ejemplo n.º 17
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    auto props = new PropertiesServer(&a);
    new PropertiesAdaptor(props);
    new AccountsUserAdaptor(props);

    auto accounts = new AccountsServer(props, &a);
    new AccountsAdaptor(accounts);
    new SecurityPrivacyAdaptor(accounts);
    new LocationAdaptor(accounts);
    new AccountsPrivateAdaptor(accounts);
    // We use the session bus for testing.  The real plugin uses the system bus
    auto connection = QDBusConnection::sessionBus();
    if (!connection.registerObject("/org/freedesktop/Accounts", accounts))
        return 1;
    if (!connection.registerService("org.freedesktop.Accounts"))
        return 1;

    return a.exec();
}
Ejemplo n.º 18
0
ScriptEngine::ScriptEngine()
	: m_engine(asCreateScriptEngine())
{
	if (!m_engine)
		return;

	// Set the message callback to receive information on errors in human readable form.
	int r = m_engine->SetMessageCallback(asFUNCTION(MessageCallback), &m_errorString, asCALL_CDECL); assert(r >= 0);

	RegisterStdString(m_engine);
	//	RegisterStdStringUtils(engine);

	// The scripts can directly print text
	r = m_engine->RegisterGlobalFunction("void print(const string &in message)", asMETHOD(ScriptEngine, print), asCALL_THISCALL_ASGLOBAL, this); assert(r >= 0);

	RegisterScriptMath(m_engine);
	aatc::RegisterAllContainers(m_engine);
	
	registerObject(m_engine);
	registerAllTypes(m_engine);
	
	generateReference();
}
Ejemplo n.º 19
0
void debugsupport_registerMonitorCommand(ObjectDesc * self, ObjectDesc * name, ObjectDesc * cmd)
{
#if defined(MONITOR)
#if defined(JAVA_MONITOR_COMMANDS)
	char value[128];
	Proxy *proxy;
	u4_t quota = 1000;
	DomainDesc *domain = CALLERDOMAIN;
	if (name == 0 || cmd == 0)
		return;
	stringToChar(name, value, sizeof(value));

	DISABLE_IRQ;
#ifdef COPY_TO_DOMAINZERO
	proxy = cmd;
#else
	proxy = copy_reference(domain, curdom(), cmd, &quota);
#endif
	RESTORE_IRQ;

	register_command(value, registerObject(curdom(), proxy), domain);
#endif
#endif				/* MONITOR */
}
Ejemplo n.º 20
0
BattleScripting::BattleScripting(QScriptEngine *engine, BaseBattleWindowInterface *_interface)
{
    myinterface = _interface;
    myengine = engine;
    myengine->setParent(this);
    setParent(_interface);

    registerObject(ProxyDataContainer);
    registerObject(TeamProxy);
    registerObject(PokeProxy);
    registerObject(MoveProxy);
    registerObject(AuxPokeDataProxy);
    registerObject(FieldProxy);
    qScriptRegisterMetaType<BattleChoice>(engine, &toBattleChoice, &fromBattleChoice);

    advbattledata_proxy *data = _interface->getBattleData();
    ProxyDataContainer *pdata = data->exposedData();
    int me = data->isPlayer(1) ? 1 : 0;
    int opp = !me;

    QScriptValue battle = myengine->newQObject(_interface);
    myengine->globalObject().setProperty("battle", battle);
    battle.setProperty("data", myengine->newQObject(dynamic_cast<QObject*>(pdata)));
    battle.setProperty("me", QScriptValue(me));
    battle.setProperty("opp", QScriptValue(opp));
    battle.setProperty("id", _interface->battleId());

    /* Removes clientscripting' print function and add ours. Client scripting's print function
      can still be accessed with sys.print() */
    QScriptValue printfun = myengine->newFunction(nativePrint);
    printfun.setData(myengine->newQObject(this));
    myengine->globalObject().setProperty("print", myengine->nullValue());
    myengine->globalObject().setProperty("print", printfun);

    _interface->addOutput(this);
}
 InputObject::InputObject()
 {
   registerObject(this) ;
 }
Ejemplo n.º 22
0
QString Uic::createObjectImpl( const QDomElement &e, const QString& parentClass, const QString& par, const QString& layout )
{
    QString parent( par );
    if ( parent == "this" && isMainWindow ) {
	if ( !createdCentralWidget )
	    out << indent << "setCentralWidget( new QWidget( this, \"qt_central_widget\" ) );" << endl;
	createdCentralWidget = TRUE;
	parent = "centralWidget()";
    }
    QDomElement n;
    QString objClass, objName;
    int numItems = 0;
    int numColumns = 0;
    int numRows = 0;

    if ( layouts.contains( e.tagName() ) )
	return createLayoutImpl( e, parentClass, parent, layout );

    objClass = getClassName( e );
    if ( objClass.isEmpty() )
	return objName;
    objName = getObjectName( e );

    QString definedName = objName;
    bool isTmpObject = objName.isEmpty() || objClass == "QLayoutWidget";
    if ( isTmpObject ) {
	if ( objClass[0] == 'Q' )
	    objName = objClass.mid(1);
	else
	    objName = objClass.lower();
	objName.prepend( "private" );
    }

    bool isLine = objClass == "Line";
    if ( isLine )
	objClass = "QFrame";

    out << endl;
    if ( objClass == "QLayoutWidget" ) {
	if ( layout.isEmpty() ) {
	    // register the object and unify its name
	    objName = registerObject( objName );
	    out << "    QWidget* " << objName << " = new QWidget( " << parent << ", \"" << definedName << "\" );" << endl;
	} else {
	    // the layout widget is not necessary, hide it by creating its child in the parent
	    QString result;
	    for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
		if (tags.contains( n.tagName() ) )
		    result = createObjectImpl( n, parentClass, parent, layout );
	    }
	    return result;
	}
    } else if ( objClass != "QToolBar" && objClass != "QMenuBar" ) {
	// register the object and unify its name
	objName = registerObject( objName );
	out << "    ";
	if ( isTmpObject )
	    out << objClass << "* ";
	out << objName << " = new " << createObjectInstance( objClass, parent, objName ) << ";" << endl;
    }

    if ( objClass == "QAxWidget" ) {
	QString controlId;
	for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
	    if ( n.tagName() == "property" && n.attribute( "name" ) == "control" ) {
		controlId = n.firstChild().toElement().text();
	    }
	}
	out << "    ";
	out << objName << "->setControl(\"" << controlId << "\");" << endl;
    }

    lastItem = "0";
    // set the properties and insert items
    bool hadFrameShadow = FALSE;
    for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
	if ( n.tagName() == "property" ) {
	    bool stdset = stdsetdef;
	    if ( n.hasAttribute( "stdset" ) )
		stdset = toBool( n.attribute( "stdset" ) );
	    QString prop = n.attribute( "name" );
	    if ( prop == "database" )
		continue;
	    QString value = setObjectProperty( objClass, objName, prop, n.firstChild().toElement(), stdset );
	    if ( value.isEmpty() )
		continue;
	    if ( prop == "name" )
		continue;
	    if ( isLine && prop == "frameShadow" )
		hadFrameShadow = TRUE;
	    if ( prop == "buddy" && value.startsWith("\"") && value.endsWith("\"") ) {
		buddies << Buddy( objName, value.mid(1, value.length() - 2 ) );
		continue;
	    }
	    if ( isLine && prop == "orientation" ) {
		prop = "frameShape";
		if ( value.right(10) == "Horizontal" )
		    value = "QFrame::HLine";
		else
		    value = "QFrame::VLine";
		if ( !hadFrameShadow ) {
		    prop = "frameStyle";
		    value += " | QFrame::Sunken";
		}
	    }
	    if ( prop == "buttonGroupId" ) {
		if ( parentClass == "QButtonGroup" )
		    out << indent << parent << "->insert( " << objName << ", " << value << " );" << endl;
		continue;
	    }
	    if ( prop == "frameworkCode" )
		continue;
	    if ( objClass == "QMultiLineEdit" &&
		 QRegExp("echoMode|hMargin|maxLength|maxLines|undoEnabled").exactMatch(prop) )
		continue;

	    QString call = objName + "->";
	    if ( stdset ) {
		call += mkStdSet( prop ) + "( ";
	    } else {
		call += "setProperty( \"" + prop + "\", ";
	    }
	    if ( prop == "accel" )
		call += "QKeySequence( " + value + " ) );";
	    else
		call += value + " );";

	    if ( n.firstChild().toElement().tagName() == "string" ||
		 prop == "currentItem" ) {
		trout << indent << call << endl;
	    } else {
		out << indent << call << endl;
	    }
	} else if ( n.tagName() == "item" ) {
	    QString call;
	    QString value;

	    if ( objClass.contains( "ListBox" ) ) {
		call = createListBoxItemImpl( n, objName );
		if ( !call.isEmpty() ) {
		    if ( numItems == 0 )
			trout << indent << objName << "->clear();" << endl;
		    trout << indent << call << endl;
		}
	    } else if ( objClass.contains( "ComboBox" ) ) {
		call = createListBoxItemImpl( n, objName, &value );
		if ( !call.isEmpty() ) {
		    if ( numItems == 0 )
			trout << indent << objName << "->clear();" << endl;
		    trout << indent << call << endl;
		}
	    } else if ( objClass.contains( "IconView" ) ) {
		call = createIconViewItemImpl( n, objName );
		if ( !call.isEmpty() ) {
		    if ( numItems == 0 )
			trout << indent << objName << "->clear();" << endl;
		    trout << indent << call << endl;
		}
	    } else if ( objClass.contains( "ListView" ) ) {
		call = createListViewItemImpl( n, objName, QString::null );
		if ( !call.isEmpty() ) {
		    if ( numItems == 0 )
			trout << indent << objName << "->clear();" << endl;
		    trout << call << endl;
		}
	    }
	    if ( !call.isEmpty() )
		numItems++;
	} else if ( n.tagName() == "column" || n.tagName() == "row" ) {
	    QString call;
	    QString value;

	    if ( objClass.contains( "ListView" ) ) {
		call = createListViewColumnImpl( n, objName, &value );
		if ( !call.isEmpty() ) {
		    out << call;
		    trout << indent << objName << "->header()->setLabel( "
			  << numColumns++ << ", " << value << " );\n";
		}
	    } else if ( objClass ==  "QTable" || objClass == "QDataTable" ) {
		bool isCols = ( n.tagName() == "column" );
		call = createTableRowColumnImpl( n, objName, &value );
		if ( !call.isEmpty() ) {
		    out << call;
		    trout << indent << objName << "->"
			  << ( isCols ? "horizontalHeader" : "verticalHeader" )
			  << "()->setLabel( "
			  << ( isCols ? numColumns++ : numRows++ )
			  << ", " << value << " );\n";
		}
	    }
	}
    }

    // create all children, some widgets have special requirements

    if ( objClass == "QTabWidget" ) {
	for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
	    if ( tags.contains( n.tagName()  ) ) {
		QString page = createObjectImpl( n, objClass, objName );
		QString comment;
		QString label = DomTool::readAttribute( n, "title", "", comment ).toString();
		out << indent << objName << "->insertTab( " << page << ", QString::fromLatin1(\"\") );" << endl;
		trout << indent << objName << "->changeTab( " << page << ", "
		      << trcall( label, comment ) << " );" << endl;
	    }
	}
    } else if ( objClass == "QWidgetStack" ) {
	for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
	    if ( tags.contains( n.tagName()  ) ) {
		QString page = createObjectImpl( n, objClass, objName );
		int id = DomTool::readAttribute( n, "id", "" ).toInt();
		out << indent << objName << "->addWidget( " << page << ", " << id << " );" << endl;
	    }
	}
    } else if ( objClass == "QToolBox" ) {
	for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
	    if ( tags.contains( n.tagName()  ) ) {
		QString page = createObjectImpl( n, objClass, objName );
		QString comment;
		QString label = DomTool::readAttribute( n, "label", "", comment ).toString();
		out << indent << objName << "->addItem( " << page << ", QString::fromLatin1(\"\") );" << endl;
		trout << indent << objName << "->setItemLabel( " << objName 
		      << "->indexOf(" << page << "), " << trcall( label, comment ) 
		      << " );" << endl;
	    }
	}
     } else if ( objClass != "QToolBar" && objClass != "QMenuBar" ) { // standard widgets
	 WidgetInterface *iface = 0;
	 widgetManager()->queryInterface( objClass, &iface );
#ifdef QT_CONTAINER_CUSTOM_WIDGETS
	 int id = WidgetDatabase::idFromClassName( objClass );
	 if ( WidgetDatabase::isContainer( id ) && WidgetDatabase::isCustomPluginWidget( id ) && iface ) {
	     QWidgetContainerInterfacePrivate *iface2 = 0;
	     iface->queryInterface( IID_QWidgetContainer, (QUnknownInterface**)&iface2 );
	     if ( iface2 ) {
		 bool supportsPages = iface2->supportsPages( objClass );
		 for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
		     if ( tags.contains( n.tagName()  ) ) {
			 if ( supportsPages ) {
			     QString page = createObjectImpl( n, objClass, objName );
			     QString comment;
			     QString label = DomTool::readAttribute( n, "label", "", comment ).toString();
			     out << indent << iface2->createCode( objClass, objName, page, label ) << endl;
			 } else {
			     createObjectImpl( n, objClass, objName );
			 }
		     }
		 }
		 iface2->release();
	     }
	     iface->release();
	 } else {
#endif
	     for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
		 if ( tags.contains( n.tagName() ) )
		     createObjectImpl( n, objClass, objName );
	     }
#ifdef QT_CONTAINER_CUSTOM_WIDGETS
	 }
#endif
     }

    return objName;
}
Ejemplo n.º 23
0
/*!  Attention: this function has to be in sync with
  Resource::saveProperty() and DomTool::elementToVariant. If you
  change one, change all.
 */
QString Uic::setObjectProperty( const QString& objClass, const QString& obj, const QString &prop, const QDomElement &e, bool stdset )
{
    QString v;
    if ( e.tagName() == "rect" ) {
	QDomElement n3 = e.firstChild().toElement();
	int x = 0, y = 0, w = 0, h = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "x" )
		x = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "y" )
		y = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "width" )
		w = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "height" )
		h = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QRect( %1, %2, %3, %4 )";
	v = v.arg(x).arg(y).arg(w).arg(h);

    } else if ( e.tagName() == "point" ) {
	QDomElement n3 = e.firstChild().toElement();
	int x = 0, y = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "x" )
		x = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "y" )
		y = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QPoint( %1, %2 )";
	v = v.arg(x).arg(y);
    } else if ( e.tagName() == "size" ) {
	QDomElement n3 = e.firstChild().toElement();
	int w = 0, h = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "width" )
		w = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "height" )
		h = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QSize( %1, %2 )";
	v = v.arg(w).arg(h);
    } else if ( e.tagName() == "color" ) {
	QDomElement n3 = e.firstChild().toElement();
	int r = 0, g = 0, b = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "red" )
		r = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "green" )
		g = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "blue" )
		b = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QColor( %1, %2, %3 )";
	v = v.arg(r).arg(g).arg(b);
    } else if ( e.tagName() == "font" ) {
	QDomElement n3 = e.firstChild().toElement();
	QString attrname = e.parentNode().toElement().attribute( "name", "font" );
	QString fontname;
	if ( !obj.isEmpty() ) {
	    fontname = registerObject( obj + "_" + attrname );
	    out << indent << "QFont "  << fontname << "(  " << obj << "->font() );" << endl;
	} else {
	    fontname = registerObject( "f" );
	    out << indent << "QFont "  << fontname << "( font() );" << endl;
	}
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "family" )
		out << indent << fontname << ".setFamily( \"" << n3.firstChild().toText().data() << "\" );" << endl;
	    else if ( n3.tagName() == "pointsize" )
		out << indent << fontname << ".setPointSize( " << n3.firstChild().toText().data() << " );" << endl;
	    else if ( n3.tagName() == "bold" )
		out << indent << fontname << ".setBold( " << mkBool( n3.firstChild().toText().data() ) << " );" << endl;
	    else if ( n3.tagName() == "italic" )
		out << indent << fontname << ".setItalic( " << mkBool( n3.firstChild().toText().data() ) << " );" << endl;
	    else if ( n3.tagName() == "underline" )
		out << indent << fontname << ".setUnderline( " << mkBool( n3.firstChild().toText().data() ) << " );" << endl;
	    else if ( n3.tagName() == "strikeout" )
		out << indent << fontname << ".setStrikeOut( " << mkBool( n3.firstChild().toText().data() ) << " );" << endl;
	    n3 = n3.nextSibling().toElement();
	}

	if ( prop == "font" ) {
	    if ( !obj.isEmpty() )
		out << indent << obj << "->setFont( " << fontname << " ); " << endl;
	    else
		out << indent << "setFont( " << fontname << " ); " << endl;
	} else {
	    v = fontname;
	}
    } else if ( e.tagName() == "string" ) {
	QString txt = e.firstChild().toText().data();
	QString com = getComment( e.parentNode() );

	if ( prop == "toolTip" && objClass != "QAction" && objClass != "QActionGroup" ) {
	    if ( !obj.isEmpty() )
		trout << indent << "QToolTip::add( " << obj << ", "
		      << trcall( txt, com ) << " );" << endl;
	    else
		trout << indent << "QToolTip::add( this, "
		      << trcall( txt, com ) << " );" << endl;
	} else if ( prop == "whatsThis" && objClass != "QAction" && objClass != "QActionGroup" ) {
	    if ( !obj.isEmpty() )
		trout << indent << "QWhatsThis::add( " << obj << ", "
		      << trcall( txt, com ) << " );" << endl;
	    else
		trout << indent << "QWhatsThis::add( this, "
		      << trcall( txt, com ) << " );" << endl;
	} else {
	    v = trcall( txt, com );
	}
    } else if ( e.tagName() == "cstring" ) {
	    v = "\"%1\"";
	    v = v.arg( e.firstChild().toText().data() );
    } else if ( e.tagName() == "number" ) {
	v = "%1";
	v = v.arg( e.firstChild().toText().data() );
    } else if ( e.tagName() == "bool" ) {
	if ( stdset )
	    v = "%1";
	else
	    v = "QVariant( %1, 0 )";
	v = v.arg( mkBool( e.firstChild().toText().data() ) );
    } else if ( e.tagName() == "pixmap" ) {
	v = e.firstChild().toText().data();
	if ( !pixmapLoaderFunction.isEmpty() ) {
	    v.prepend( pixmapLoaderFunction + "( " + QString( externPixmaps ? "\"" : "" ) );
	    v.append( QString( externPixmaps ? "\"" : "" ) + " )" );
	}
    } else if ( e.tagName() == "iconset" ) {
	v = "QIconSet( %1 )";
	QString s = e.firstChild().toText().data();
	if ( !pixmapLoaderFunction.isEmpty() ) {
	    s.prepend( pixmapLoaderFunction + "( " + QString( externPixmaps ? "\"" : "" ) );
	    s.append( QString( externPixmaps ? "\"" : "" ) + " )" );
	}
	v = v.arg( s );
    } else if ( e.tagName() == "image" ) {
	v = e.firstChild().toText().data() + ".convertToImage()";
    } else if ( e.tagName() == "enum" ) {
	if ( stdset )
	    v = "%1::%2";
	else
	    v = "\"%1\"";
	QString oc = objClass;
	QString ev = e.firstChild().toText().data();
	if ( oc == "QListView" && ev == "Manual" ) // #### workaround, rename QListView::Manual in 4.0
	    oc = "QScrollView";
	if ( stdset )
	    v = v.arg( oc ).arg( ev );
	else
	    v = v.arg( ev );
    } else if ( e.tagName() == "set" ) {
	QString keys( e.firstChild().toText().data() );
	QStringList lst = QStringList::split( '|', keys );
	v = "int( ";
	QStringList::Iterator it = lst.begin();
	while ( it != lst.end() ) {
	    v += objClass + "::" + *it;
	    if ( it != lst.fromLast() )
		v += " | ";
	    ++it;
	}
	v += " )";
    } else if ( e.tagName() == "sizepolicy" ) {
	QDomElement n3 = e.firstChild().toElement();
	QSizePolicy sp;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "hsizetype" )
		sp.setHorData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "vsizetype" )
		sp.setVerData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "horstretch" )
		sp.setHorStretch( n3.firstChild().toText().data().toInt() );
	    else if ( n3.tagName() == "verstretch" )
		sp.setVerStretch( n3.firstChild().toText().data().toInt() );
	    n3 = n3.nextSibling().toElement();
	}
	QString tmp;
	if ( !obj.isEmpty() )
	    tmp = obj + "->";
	v = "QSizePolicy( (QSizePolicy::SizeType)%1, (QSizePolicy::SizeType)%2, %3, %4, " + tmp + "sizePolicy().hasHeightForWidth() )";
	v = v.arg( (int)sp.horData() ).arg( (int)sp.verData() ).arg( sp.horStretch() ).arg( sp.verStretch() );
    } else if ( e.tagName() == "palette" ) {
	QPalette pal;
	bool no_pixmaps = e.elementsByTagName( "pixmap" ).count() == 0;
	QDomElement n;
	if ( no_pixmaps ) {
	    n = e.firstChild().toElement();
	    while ( !n.isNull() ) {
		QColorGroup cg;
		if ( n.tagName() == "active" ) {
		    cg = loadColorGroup( n );
		    pal.setActive( cg );
		} else if ( n.tagName() == "inactive" ) {
		    cg = loadColorGroup( n );
		    pal.setInactive( cg );
		} else if ( n.tagName() == "disabled" ) {
		    cg = loadColorGroup( n );
		    pal.setDisabled( cg );
		}
		n = n.nextSibling().toElement();
	    }
	}
	if ( no_pixmaps && pal == QPalette( pal.active().button(), pal.active().background() ) ) {
	    v = "QPalette( QColor( %1, %2, %3 ), QColor( %1, %2, %3 ) )";
	    v = v.arg( pal.active().button().red() ).arg( pal.active().button().green() ).arg( pal.active().button().blue() );
	    v = v.arg( pal.active().background().red() ).arg( pal.active().background().green() ).arg( pal.active().background().blue() );
	} else {
	    QString palette = "pal";
	    if ( !pal_used ) {
		out << indent << "QPalette " << palette << ";" << endl;
		pal_used = TRUE;
	    }
	    QString cg = "cg";
	    if ( !cg_used ) {
		out << indent << "QColorGroup " << cg << ";" << endl;
		cg_used = TRUE;
	    }
	    n = e.firstChild().toElement();
	    while ( !n.isNull() && n.tagName() != "active" )
		n = n.nextSibling().toElement();
	    createColorGroupImpl( cg, n );
	    out << indent << palette << ".setActive( " << cg << " );" << endl;

	    n = e.firstChild().toElement();
	    while ( !n.isNull() && n.tagName() != "inactive" )
		n = n.nextSibling().toElement();
	    createColorGroupImpl( cg, n );
	    out << indent << palette << ".setInactive( " << cg << " );" << endl;

	    n = e.firstChild().toElement();
	    while ( !n.isNull() && n.tagName() != "disabled" )
		n = n.nextSibling().toElement();
	    createColorGroupImpl( cg, n );
	    out << indent << palette << ".setDisabled( " << cg << " );" << endl;
	    v = palette;
	}
    } else if ( e.tagName() == "cursor" ) {
	v = "QCursor( %1 )";
	v = v.arg( e.firstChild().toText().data() );
    } else if ( e.tagName() == "date" ) {
	QDomElement n3 = e.firstChild().toElement();
	int y, m, d;
	y = m = d = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "year" )
		y = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "month" )
		m = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "day" )
		d = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QDate( %1, %2, %3 )";
	v = v.arg(y).arg(m).arg(d);
    } else if ( e.tagName() == "time" ) {
	QDomElement n3 = e.firstChild().toElement();
	int h, m, s;
	h = m = s = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "hour" )
		h = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "minute" )
		m = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "second" )
		s = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QTime( %1, %2, %3 )";
	v = v.arg(h).arg(m).arg(s);
    } else if ( e.tagName() == "datetime" ) {
	QDomElement n3 = e.firstChild().toElement();
	int h, mi, s, y, mo, d;
	h = mi = s = y = mo = d = 0;
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "hour" )
		h = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "minute" )
		mi = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "second" )
		s = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "year" )
		y = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "month" )
		mo = n3.firstChild().toText().data().toInt();
	    else if ( n3.tagName() == "day" )
		d = n3.firstChild().toText().data().toInt();
	    n3 = n3.nextSibling().toElement();
	}
	v = "QDateTime( QDate( %1, %2, %3 ), QTime( %4, %5, %6 ) )";
	v = v.arg(y).arg(mo).arg(d).arg(h).arg(mi).arg(s);
    } else if ( e.tagName() == "stringlist" ) {
	QStringList l;
	QDomElement n3 = e.firstChild().toElement();
	QString listname = "l";
	if ( !obj.isEmpty() ) {
	    listname = obj + "_stringlist";
	    listname = registerObject( listname );
	    out << indent << "QStringList "  << listname << ";" << endl;
	} else {
	    listname = registerObject( listname );
	    out << indent << "QStringList "  << listname << ";" << endl;
	}
	while ( !n3.isNull() ) {
	    if ( n3.tagName() == "string" )
		out << indent << listname << " << \"" << n3.firstChild().toText().data().simplifyWhiteSpace() << "\";" << endl;
	    n3 = n3.nextSibling().toElement();
	}
	v = listname;
    }
    return v;
}
Ejemplo n.º 24
0
    FunctionFactory::FunctionFactory() : CloningFactory<Function::Element*>("Function::Element") {

        //OPERATORS:
        int p = 100;
        //First order: not, negate:
        registerObject("!", new Function::Element("!", "Logical NOT",
                Function::Element::OPERATOR, &(fl::Op::logicalNot), p, 1)); //logical not
        registerObject("~", new Function::Element("~", "Negation",
                Function::Element::OPERATOR, &(fl::Op::negate), p, 1)); // ~ negates a number

        p -= 10;
        //Second order: power
        registerObject("^", new Function::Element("^", "Power",
                Function::Element::OPERATOR, &(std::pow), p, 1));

        p -= 10;
        //Third order: multiplication, division, modulo
        registerObject("*", new Function::Element("*", "Multiplication",
                Function::Element::OPERATOR, &(fl::Op::multiply), p));
        registerObject("/", new Function::Element("/", "Division",
                Function::Element::OPERATOR, &(fl::Op::divide), p));
        registerObject("%", new Function::Element("%", "Modulo",
                Function::Element::OPERATOR, &(fl::Op::modulo), p));

        p -= 10;
        //Fourth order: addition, subtraction
        registerObject("+", new Function::Element("+", "Addition",
                Function::Element::OPERATOR, &(fl::Op::add), p));
        registerObject("-", new Function::Element("-", "Subtraction",
                Function::Element::OPERATOR, &(fl::Op::subtract), p));

        //Fifth order: logical and, logical or
        p -= 10; //Logical AND
        registerObject(fl::Rule::andKeyword(), new Function::Element(fl::Rule::andKeyword(), "Logical AND",
                Function::Element::OPERATOR, &(fl::Op::logicalAnd), p));
        p -= 10; //Logical OR
        registerObject(fl::Rule::orKeyword(), new Function::Element(fl::Rule::orKeyword(), "Logical OR",
                Function::Element::OPERATOR, &(fl::Op::logicalOr), p));

        //FUNCTIONS

        registerObject("gt", new Function::Element("gt", "Greater than (>)",
                Function::Element::FUNCTION, &(fl::Op::gt)));
        registerObject("ge", new Function::Element("ge", "Greater than or equal to (>=)",
                Function::Element::FUNCTION, &(fl::Op::ge)));
        registerObject("eq", new Function::Element("eq", "Equal to (==)",
                Function::Element::FUNCTION, &(fl::Op::eq)));
        registerObject("neq", new Function::Element("neq", "Not equal to (!=)",
                Function::Element::FUNCTION, &(fl::Op::neq)));
        registerObject("le", new Function::Element("le", "Less than or equal to (<=)",
                Function::Element::FUNCTION, &(fl::Op::le)));
        registerObject("lt", new Function::Element("lt", "Less than (<)",
                Function::Element::FUNCTION, &(fl::Op::lt)));

        registerObject("acos", new Function::Element("acos", "Inverse cosine",
                Function::Element::FUNCTION, &(std::acos)));
        registerObject("asin", new Function::Element("asin", "Inverse sine",
                Function::Element::FUNCTION, &(std::asin)));
        registerObject("atan", new Function::Element("atan", "Inverse tangent",
                Function::Element::FUNCTION, &(std::atan)));

        registerObject("ceil", new Function::Element("ceil", "Ceiling",
                Function::Element::FUNCTION, &(std::ceil)));
        registerObject("cos", new Function::Element("cos", "Cosine",
                Function::Element::FUNCTION, &(std::cos)));
        registerObject("cosh", new Function::Element("cosh", "Hyperbolic cosine",
                Function::Element::FUNCTION, &(std::cosh)));
        registerObject("exp", new Function::Element("exp", "Exponential",
                Function::Element::FUNCTION, &(std::exp)));
        registerObject("fabs", new Function::Element("fabs", "Absolute",
                Function::Element::FUNCTION, &(std::fabs)));
        registerObject("floor", new Function::Element("floor", "Floor",
                Function::Element::FUNCTION, &(std::floor)));
        registerObject("log", new Function::Element("log", "Natural logarithm",
                Function::Element::FUNCTION, &(std::log)));
        registerObject("log10", new Function::Element("log10", "Common logarithm",
                Function::Element::FUNCTION, &(std::log10)));
        registerObject("round", new Function::Element("round", "Round",
                Function::Element::FUNCTION, &(fl::Op::round)));
        registerObject("sin", new Function::Element("sin", "Sine",
                Function::Element::FUNCTION, &(std::sin)));
        registerObject("sinh", new Function::Element("sinh", "Hyperbolic sine",
                Function::Element::FUNCTION, &(std::sinh)));
        registerObject("sqrt", new Function::Element("sqrt", "Square root",
                Function::Element::FUNCTION, &(std::sqrt)));
        registerObject("tan", new Function::Element("tan", "Tangent",
                Function::Element::FUNCTION, &(std::tan)));
        registerObject("tanh", new Function::Element("tanh", "Hyperbolic tangent",
                Function::Element::FUNCTION, &(std::tanh)));

#if defined(FL_UNIX) && !defined(FL_USE_FLOAT)
        //found in Unix when using double precision. not found in Windows.
        registerObject("log1p", new Function::Element("log1p", "Natural logarithm plus one",
                Function::Element::FUNCTION, &(log1p)));
        registerObject("acosh", new Function::Element("acosh", "Inverse hyperbolic cosine",
                Function::Element::FUNCTION, &(acosh)));
        registerObject("asinh", new Function::Element("asinh", "Inverse hyperbolic sine",
                Function::Element::FUNCTION, &(asinh)));
        registerObject("atanh", new Function::Element("atanh", "Inverse hyperbolic tangent",
                Function::Element::FUNCTION, &(atanh)));
#endif

        registerObject("pow", new Function::Element("pow", "Power",
                Function::Element::FUNCTION, &(std::pow)));
        registerObject("atan2", new Function::Element("atan2", "Inverse tangent (y,x)",
                Function::Element::FUNCTION, &(std::atan2)));
        registerObject("fmod", new Function::Element("fmod", "Floating-point remainder",
                Function::Element::FUNCTION, &(std::fmod)));
    }
Ejemplo n.º 25
0
void
MooseTestApp::registerObjects(Factory & factory)
{
  // Kernels
  registerKernel(ConservativeAdvection);
  registerKernel(CoeffParamDiffusion);
  registerKernel(CoupledConvection);
  registerKernel(ForcingFn);
  registerKernel(MatDiffusion);
  registerKernel(DiffMKernel);
  registerKernel(GaussContForcing);
  registerKernel(CoefDiffusion);
  registerKernel(RestartDiffusion);
  registerKernel(MatCoefDiffusion);
  registerKernel(FuncCoefDiffusion);
  registerKernel(CoefReaction);
  registerKernel(Convection);
  registerKernel(PolyDiffusion);
  registerKernel(PolyConvection);
  registerKernel(PolyForcing);
  registerKernel(PolyReaction);
  registerKernel(MMSImplicitEuler);
  registerKernel(MMSDiffusion);
  registerKernel(MMSConvection);
  registerKernel(MMSForcing);
  registerKernel(MMSReaction);
  registerKernel(Diffusion0);
  registerKernel(GenericDiffusion);
  registerKernel(Advection0);
  registerKernel(AdvDiffReaction1);
  registerKernel(ForcingFunctionXYZ0);
  registerKernel(TEJumpFFN);
  registerKernel(NanKernel);
  registerKernel(NanAtCountKernel);
  registerKernel(ExceptionKernel);
  registerKernel(MatConvection);
  registerKernel(PPSDiffusion);
  registerKernel(DefaultPostprocessorDiffusion);
  registerKernel(DotCouplingKernel);
  registerKernel(UserObjectKernel);
  registerKernel(DiffusionPrecompute);
  registerKernel(ConvectionPrecompute);
  registerKernel(CoupledKernelGradTest);
  registerKernel(CoupledKernelValueTest);
  registerKernel(SplineFFn);
  registerKernel(BlkResTestDiffusion);
  registerKernel(DiffTensorKernel);
  registerKernel(ScalarLagrangeMultiplier);
  registerKernel(OptionallyCoupledForce);
  registerKernel(FDDiffusion);
  registerKernel(FDAdvection);
  registerKernel(MaterialEigenKernel);
  registerKernel(PHarmonic);
  registerKernel(PMassEigenKernel);
  registerKernel(CoupledEigenKernel);
  registerKernel(ConsoleMessageKernel);
  registerKernel(WrongJacobianDiffusion);
  registerKernel(DefaultMatPropConsumerKernel);
  registerKernel(DoNotCopyParametersKernel);

  // Aux kernels
  registerAux(CoupledAux);
  registerAux(CoupledScalarAux);
  registerAux(CoupledGradAux);
  registerAux(PolyConstantAux);
  registerAux(MMSConstantAux);
  registerAux(MultipleUpdateAux);
  registerAux(MultipleUpdateElemAux);
  registerAux(PeriodicDistanceAux);
  registerAux(MatPropUserObjectAux);
  registerAux(SumNodalValuesAux);
  registerAux(UniqueIDAux);
  registerAux(RandomAux);
  registerAux(PostprocessorAux);
  registerAux(FluxAverageAux);
  registerAux(OldMaterialAux);
  registerAux(DotCouplingAux);

  // DG kernels
  registerDGKernel(DGMatDiffusion);
  registerDGKernel(DGAdvection);

  // Interface kernels
  registerInterfaceKernel(InterfaceDiffusion);

  // Boundary Conditions
  registerBoundaryCondition(RobinBC);
  registerBoundaryCondition(InflowBC);
  registerBoundaryCondition(OutflowBC);
  registerBoundaryCondition(MTBC);
  registerBoundaryCondition(PolyCoupledDirichletBC);
  registerBoundaryCondition(MMSCoupledDirichletBC);
  registerBoundaryCondition(DirichletBCfuncXYZ0);
  registerBoundaryCondition(TEJumpBC);
  registerBoundaryCondition(OnOffDirichletBC);
  registerBoundaryCondition(OnOffNeumannBC);
  registerBoundaryCondition(ScalarVarBC);
  registerBoundaryCondition(BndTestDirichletBC);
  registerBoundaryCondition(MatTestNeumannBC);

  registerBoundaryCondition(DGMDDBC);
  registerBoundaryCondition(DGFunctionConvectionDirichletBC);

  registerBoundaryCondition(CoupledKernelGradBC);

  registerBoundaryCondition(DivergenceBC);
  registerBoundaryCondition(MatDivergenceBC);
  registerBoundaryCondition(CoupledDirichletBC);
  registerBoundaryCondition(TestLapBC);

  // Initial conditions
  registerInitialCondition(TEIC);
  registerInitialCondition(MTICSum);
  registerInitialCondition(MTICMult);
  registerInitialCondition(DataStructIC);

  // Materials
  registerMaterial(MTMaterial);
  registerMaterial(TypesMaterial);
  registerMaterial(StatefulMaterial);
  registerMaterial(SpatialStatefulMaterial);
  registerMaterial(ComputingInitialTest);
  registerMaterial(StatefulTest);
  registerMaterial(StatefulSpatialTest);
  registerMaterial(CoupledMaterial);
  registerMaterial(CoupledMaterial2);
  registerMaterial(LinearInterpolationMaterial);
  registerMaterial(VarCouplingMaterial);
  registerMaterial(VarCouplingMaterialEigen);
  registerMaterial(BadStatefulMaterial);
  registerMaterial(OutputTestMaterial);
  registerMaterial(SumMaterial);
  registerMaterial(VecRangeCheckMaterial);
  registerMaterial(DerivativeMaterialInterfaceTestProvider);
  registerMaterial(DerivativeMaterialInterfaceTestClient);
  registerMaterial(DefaultMatPropConsumerMaterial);
  registerMaterial(RandomMaterial);
  registerMaterial(RecomputeMaterial);
  registerMaterial(NewtonMaterial);


  registerScalarKernel(ExplicitODE);
  registerScalarKernel(ImplicitODEx);
  registerScalarKernel(ImplicitODEy);
  registerScalarKernel(AlphaCED);
  registerScalarKernel(PostprocessorCED);

  // Functions
  registerFunction(TimestepSetupFunction);
  registerFunction(PostprocessorFunction);
  registerFunction(MTPiecewiseConst1D);
  registerFunction(MTPiecewiseConst2D);
  registerFunction(MTPiecewiseConst3D);
  registerFunction(TestSetupPostprocessorDataActionFunction);

  // DiracKernels
  registerDiracKernel(ReportingConstantSource);
  registerDiracKernel(FrontSource);
  registerDiracKernel(MaterialPointSource);
  registerDiracKernel(MaterialMultiPointSource);
  registerDiracKernel(StatefulPointSource);
  registerDiracKernel(CachingPointSource);
  registerDiracKernel(BadCachingPointSource);
  registerDiracKernel(NonlinearSource);

  // meshes
  registerObject(StripeMesh);

  registerConstraint(EqualValueNodalConstraint);

  // UserObjects
  registerUserObject(MTUserObject);
  registerUserObject(RandomHitUserObject);
  registerUserObject(RandomHitSolutionModifier);
  registerUserObject(MaterialPropertyUserObject);
  registerUserObject(MaterialCopyUserObject);
  registerUserObject(InsideUserObject);
  registerUserObject(RestartableTypes);
  registerUserObject(RestartableTypesChecker);
  registerUserObject(PointerStoreError);
  registerUserObject(PointerLoadError);
  registerUserObject(VerifyElementUniqueID);
  registerUserObject(VerifyNodalUniqueID);
  registerUserObject(RandomElementalUserObject);
  registerUserObject(TrackDiracFront);
  registerUserObject(BoundaryUserObject);
  registerUserObject(TestBoundaryRestrictableAssert);
  registerUserObject(GetMaterialPropertyBoundaryBlockNamesTest);
  registerUserObject(GeneralSetupInterfaceCount);
  registerUserObject(ElementSetupInterfaceCount);
  registerUserObject(SideSetupInterfaceCount);
  registerUserObject(InternalSideSetupInterfaceCount);
  registerUserObject(NodalSetupInterfaceCount);
  registerUserObject(ReadDoubleIndex);

  registerPostprocessor(InsideValuePPS);
  registerPostprocessor(TestCopyInitialSolution);
  registerPostprocessor(TestSerializedSolution);
  registerPostprocessor(BoundaryValuePPS);
  registerPostprocessor(NumInternalSides);
  registerPostprocessor(NumElemQPs);
  registerPostprocessor(NumSideQPs);
  registerPostprocessor(ElementL2Diff);
  registerPostprocessor(TestPostprocessor);
  registerPostprocessor(ElementSidePP);
  registerPostprocessor(RealControlParameterReporter);

  registerMarker(RandomHitMarker);
  registerMarker(QPointMarker);
  registerMarker(CircleMarker);

  registerExecutioner(TestSteady);
  registerExecutioner(AdaptAndModify);

  registerProblem(MooseTestProblem);
  registerProblem(FailingProblem);

  // Outputs
  registerOutput(OutputObjectTest);

  // Controls
  registerControl(TestControl);
}
Ejemplo n.º 26
0
/*!
    \internal
    \since 4.8
    Registers a QDBusTreeNode for a path. It can handle a path including all child paths, thus
    handling multiple DBus nodes.

    To unregister a QDBusTreeNode use the unregisterObject() function with its path.
*/
bool QDBusConnection::registerVirtualObject(const QString &path, QDBusVirtualObject *treeNode,
                      VirtualObjectRegisterOption options)
{
    int opts = options | QDBusConnectionPrivate::VirtualObject;
    return registerObject(path, (QObject*) treeNode, (RegisterOptions) opts);
}
/*!
  Creates an implementation (cpp-file) for the form given in \a e.

  \sa createFormDecl(), createObjectImpl()
 */
void Ui3Reader::createFormImpl(const QDomElement &e)
{
    QDomElement n;
    QDomNodeList nl;
    int i;
    QString objClass = getClassName(e);
    if (objClass.isEmpty())
        return;
    QString objName = getObjectName(e);

    // generate local and local includes required
    QStringList globalIncludes, localIncludes;
    QStringList::Iterator it;

    QMap<QString, CustomInclude> customWidgetIncludes;

    // find additional slots and functions
    QStringList extraFuncts;
    QStringList extraFunctTyp;
    QStringList extraFunctSpecifier;

    nl = e.parentNode().toElement().elementsByTagName(QLatin1String("slot"));
    for (i = 0; i < (int) nl.length(); i++) {
        n = nl.item(i).toElement();
        if (n.parentNode().toElement().tagName() != QLatin1String("slots")
             && n.parentNode().toElement().tagName() != QLatin1String("connections"))
            continue;
        if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
            continue;
        QString functionName = n.firstChild().toText().data().trimmed();
        if (functionName.endsWith(QLatin1Char(';')))
            functionName.chop(1);
        extraFuncts += functionName;
        extraFunctTyp += n.attribute(QLatin1String("returnType"), QLatin1String("void"));
        extraFunctSpecifier += n.attribute(QLatin1String("specifier"), QLatin1String("virtual"));
    }

    nl = e.parentNode().toElement().elementsByTagName(QLatin1String("function"));
    for (i = 0; i < (int) nl.length(); i++) {
        n = nl.item(i).toElement();
        if (n.parentNode().toElement().tagName() != QLatin1String("functions"))
            continue;
        if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
            continue;
        QString functionName = n.firstChild().toText().data().trimmed();
        if (functionName.endsWith(QLatin1Char(';')))
            functionName.chop(1);
        extraFuncts += functionName;
        extraFunctTyp += n.attribute(QLatin1String("returnType"), QLatin1String("void"));
        extraFunctSpecifier += n.attribute(QLatin1String("specifier"), QLatin1String("virtual"));
    }

    // additional includes (local or global) and forward declaractions
    nl = e.parentNode().toElement().elementsByTagName(QLatin1String("include"));
    for (i = 0; i < (int) nl.length(); i++) {
        QDomElement n2 = nl.item(i).toElement();
        QString s = n2.firstChild().toText().data();
        if (n2.attribute(QLatin1String("location")) != QLatin1String("local")) {
            if (s.right(5) == QLatin1String(".ui.h") && !QFile::exists(s))
                continue;
            if (n2.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) != QLatin1String("in implementation"))
                continue;
            globalIncludes += s;
        }
    }

    registerDatabases(e);
    dbConnections = unique(dbConnections);
    bool dbForm = false;
    if (dbForms[QLatin1String("(default)")].count())
        dbForm = true;
    bool subDbForms = false;
    for (it = dbConnections.begin(); it != dbConnections.end(); ++it) {
        if (!(*it).isEmpty()  && (*it) != QLatin1String("(default)")) {
            if (dbForms[(*it)].count()) {
                subDbForms = true;
                break;
            }
        }
    }

    // do the local includes afterwards, since global includes have priority on clashes
    for (i = 0; i < (int) nl.length(); i++) {
        QDomElement n2 = nl.item(i).toElement();
        QString s = n2.firstChild().toText().data();
        if (n2.attribute(QLatin1String("location")) == QLatin1String("local") && !globalIncludes.contains(s)) {
            if (s.right(5) == QLatin1String(".ui.h") && !QFile::exists(s))
                continue;
            if (n2.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) != QLatin1String("in implementation"))
                continue;
            localIncludes += s;
        }
    }

    // additional custom widget headers
    nl = e.parentNode().toElement().elementsByTagName(QLatin1String("header"));
    for (i = 0; i < (int) nl.length(); i++) {
        QDomElement n2 = nl.item(i).toElement();
        QString s = n2.firstChild().toText().data();
        if (n2.attribute(QLatin1String("location")) != QLatin1String("local"))
            globalIncludes += s;
        else
            localIncludes += s;
    }

    out << "#include <qvariant.h>" << endl; // first for gcc 2.7.2

    globalIncludes = unique(globalIncludes);
    for (it = globalIncludes.begin(); it != globalIncludes.end(); ++it) {
        if (!(*it).isEmpty())
            out << "#include <" << fixHeaderName(*it) << '>' << endl;
    }

    if (externPixmaps) {
        out << "#include <qimage.h>" << endl;
        out << "#include <qpixmap.h>" << endl << endl;
    }

    /*
      Put local includes after all global includes
    */
    localIncludes = unique(localIncludes);
    for (it = localIncludes.begin(); it != localIncludes.end(); ++it) {
        if (!(*it).isEmpty() && *it != QFileInfo(fileName + QLatin1String(".h")).fileName())
            out << "#include \"" << fixHeaderName(*it) << '\"' << endl;
    }

    QString uiDotH = fileName + QLatin1String(".h");
    if (QFile::exists(uiDotH)) {
        if (!outputFileName.isEmpty())
            uiDotH = QString::fromUtf8(combinePath(uiDotH.ascii(), outputFileName.ascii()));
        out << "#include \"" << uiDotH << '\"' << endl;
        writeFunctImpl = false;
    }

    // register the object and unify its name
    objName = registerObject(objName);

    if (externPixmaps) {
        pixmapLoaderFunction = QLatin1String("QPixmap::fromMimeSource");
    }

    // constructor
    if (objClass == QLatin1String("QDialog") || objClass == QLatin1String("QWizard")) {
        out << "/*" << endl;
        out << " *  Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl;
        out << " *  name 'name' and widget flags set to 'f'." << endl;
        out << " *" << endl;
        out << " *  The " << objClass.mid(1).toLower() << " will by default be modeless, unless you set 'modal' to" << endl;
        out << " *  true to construct a modal " << objClass.mid(1).toLower() << '.' << endl;
        out << " */" << endl;
        out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)" << endl;
        out << "    : " << objClass << "(parent, name, modal, fl)";
    } else if (objClass == QLatin1String("QWidget"))  {
        out << "/*" << endl;
        out << " *  Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl;
        out << " *  name 'name' and widget flags set to 'f'." << endl;
        out << " */" << endl;
        out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name, Qt::WindowFlags fl)" << endl;
        out << "    : " << objClass << "(parent, name, fl)";
    } else if (objClass == QLatin1String("QMainWindow") || objClass == QLatin1String("Q3MainWindow")) {
        out << "/*" << endl;
        out << " *  Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl;
        out << " *  name 'name' and widget flags set to 'f'." << endl;
        out << " *" << endl;
        out << " */" << endl;
        out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name, Qt::WindowFlags fl)" << endl;
        out << "    : " << objClass << "(parent, name, fl)";
        isMainWindow = true;
    } else {
        out << "/*" << endl;
        out << " *  Constructs a " << nameOfClass << " which is a child of 'parent', with the" << endl;
        out << " *  name 'name'.' " << endl;
        out << " */" << endl;
        out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name)" << endl;
        out << "    : " << objClass << "(parent, name)";
    }

    out << endl;

    out << '{' << endl;

//
// setup the gui
//
    out << indent << "setupUi(this);" << endl << endl;


    if (isMainWindow)
        out << indent << "(void)statusBar();" << endl;

    // database support
    dbConnections = unique(dbConnections);
    if (dbConnections.count())
        out << endl;
    for (it = dbConnections.begin(); it != dbConnections.end(); ++it) {
        if (!(*it).isEmpty() && (*it) != QLatin1String("(default)")) {
            out << indent << (*it) << "Connection = QSqlDatabase::database(\"" <<(*it) << "\");" << endl;
        }
    }

    nl = e.parentNode().toElement().elementsByTagName(QLatin1String("widget"));
    for (i = 1; i < (int) nl.length(); i++) { // start at 1, 0 is the toplevel widget
        n = nl.item(i).toElement();
        QString s = getClassName(n);
        if ((dbForm || subDbForms) && (s == QLatin1String("QDataBrowser") || s == QLatin1String("QDataView"))) {
            QString objName = getObjectName(n);
            QString tab = getDatabaseInfo(n, QLatin1String("table"));
            QString con = getDatabaseInfo(n, QLatin1String("connection"));
            out << indent << "QSqlForm* " << objName << "Form = new QSqlForm(this);" << endl;
            out << indent << objName << "Form->setObjectName(\"" << objName << "Form\");" << endl;
            QDomElement n2;
            for (n2 = n.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement())
                createFormImpl(n2, objName, con, tab);
            out << indent << objName << "->setForm(" << objName << "Form);" << endl;
        }
    }

    if (extraFuncts.contains(QLatin1String("init()")))
        out << indent << "init();" << endl;

    // end of constructor
    out << '}' << endl;
    out << endl;

    // destructor
    out << "/*" << endl;
    out << " *  Destroys the object and frees any allocated resources" << endl;
    out << " */" << endl;
    out << nameOfClass << "::~" << bareNameOfClass << "()" << endl;
    out << '{' << endl;
    if (extraFuncts.contains(QLatin1String("destroy()")))
        out << indent << "destroy();" << endl;
    out << indent << "// no need to delete child widgets, Qt does it all for us" << endl;
    out << '}' << endl;
    out << endl;

    // handle application events if required
    bool needFontEventHandler = false;
    bool needSqlTableEventHandler = false;
    bool needSqlDataBrowserEventHandler = false;
    nl = e.elementsByTagName(QLatin1String("widget"));
    for (i = 0; i < (int) nl.length(); i++) {
        if (!DomTool::propertiesOfType(nl.item(i).toElement() , QLatin1String("font")).isEmpty())
            needFontEventHandler = true;
        QString s = getClassName(nl.item(i).toElement());
        if (s == QLatin1String("QDataTable") || s == QLatin1String("QDataBrowser")) {
            if (!isFrameworkCodeGenerated(nl.item(i).toElement()))
                 continue;
            if (s == QLatin1String("QDataTable"))
                needSqlTableEventHandler = true;
            if (s == QLatin1String("QDataBrowser"))
                needSqlDataBrowserEventHandler = true;
        }
        if (needFontEventHandler && needSqlTableEventHandler && needSqlDataBrowserEventHandler)
            break;
    }

    out << "/*" << endl;
    out << " *  Sets the strings of the subwidgets using the current" << endl;
    out << " *  language." << endl;
    out << " */" << endl;
    out << "void " << nameOfClass << "::languageChange()" << endl;
    out << '{' << endl;
    out << "    retranslateUi(this);" << endl;
    out << '}' << endl;
    out << endl;

    // create stubs for additional slots if necessary
    if (!extraFuncts.isEmpty() && writeFunctImpl) {
        it = extraFuncts.begin();
        QStringList::Iterator it2 = extraFunctTyp.begin();
        QStringList::Iterator it3 = extraFunctSpecifier.begin();
        while (it != extraFuncts.end()) {
            QString type = fixDeclaration(*it2);
            if (type.isEmpty())
                type = QLatin1String("void");
            type = type.simplified();
            QString fname = fixDeclaration(Parser::cleanArgs(*it));
            if (!(*it3).startsWith(QLatin1String("pure"))) { // "pure virtual" or "pureVirtual"
                out << type << ' ' << nameOfClass << "::" << fname << endl;
                out << '{' << endl;
                if (*it != QLatin1String("init()") && *it != QLatin1String("destroy()")) {
                    QRegExp numeric(QLatin1String("^(?:signed|unsigned|u?char|u?short|u?int"
                                     "|u?long|Q_U?INT(?:8|16|32)|Q_U?LONG|float"
                                     "|double)$"));
                    QString retVal;

                    /*
                      We return some kind of dummy value to shut the
                      compiler up.

                      1.  If the type is 'void', we return nothing.

                      2.  If the type is 'bool', we return 'false'.

                      3.  If the type is 'unsigned long' or
                          'quint16' or 'double' or similar, we
                          return '0'.

                      4.  If the type is 'Foo *', we return '0'.

                      5.  If the type is 'Foo &', we create a static
                          variable of type 'Foo' and return it.

                      6.  If the type is 'Foo', we assume there's a
                          default constructor and use it.
                    */
                    if (type != QLatin1String("void")) {
                        QStringList toks = type.split(QLatin1String(" "));
                        bool isBasicNumericType =
                                (toks.filter(numeric).count() == toks.count());

                        if (type == QLatin1String("bool")) {
                            retVal = QLatin1String("false");
                        } else if (isBasicNumericType || type.endsWith(QLatin1Char('*'))) {
                            retVal = QLatin1String("0");
                        } else if (type.endsWith(QLatin1Char('&'))) {
                            do {
                                type.chop(1);
                            } while (type.endsWith(QLatin1Char(' ')));
                            retVal = QLatin1String("uic_temp_var");
                            out << indent << "static " << type << ' ' << retVal << ';' << endl;
                        } else {
                            retVal = type + QLatin1String("()");
                        }
                    }

                    out << indent << "qWarning(\"" << nameOfClass << "::" << fname << ": Not implemented yet\");" << endl;
                    if (!retVal.isEmpty())
                        out << indent << "return " << retVal << ';' << endl;
                }
                out << '}' << endl;
                out << endl;
            }
            ++it;
            ++it2;
            ++it3;
        }
    }
}
/*!
  Creates a declaration (header file) for the form given in \a e

  \sa createFormImpl()
*/
void Ui3Reader::createFormDecl(const QDomElement &e)
{
    QDomElement body = e;

    QDomElement n;
    QDomNodeList nl;
    int i;
    QString objClass = getClassName(e);
    if (objClass.isEmpty())
        return;
    QString objName = getObjectName(e);

    QStringList typeDefs;

    QMap<QString, CustomInclude> customWidgetIncludes;

    /*
      We are generating a few QImage members that are not strictly
      necessary in some cases. Ideally, we would use requiredImage,
      which is computed elsewhere, to keep the generated .h and .cpp
      files synchronized.
    */

    // at first the images
    QMap<QString, int> customWidgets;
    QStringList forwardDecl;
    QStringList forwardDecl2;
    for (n = e; !n.isNull(); n = n.nextSibling().toElement()) {
        if (n.tagName().toLower() == QLatin1String("customwidgets")) {
            QDomElement n2 = n.firstChild().toElement();
            while (!n2.isNull()) {
                if (n2.tagName().toLower() == QLatin1String("customwidget")) {
                    QDomElement n3 = n2.firstChild().toElement();
                    QString cl;
                    while (!n3.isNull()) {
                        QString tagName = n3.tagName().toLower();
                        if (tagName == QLatin1String("class")) {
                            cl = n3.firstChild().toText().data();
                            if (m_options & CustomWidgetForwardDeclarations)
                                forwardDecl << cl;
                            customWidgets.insert(cl, 0);
                        } else if (tagName == QLatin1String("header")) {
                            CustomInclude ci;
                            ci.header = n3.firstChild().toText().data();
                            ci.location = n3.attribute(QLatin1String("location"), QLatin1String("global"));
                            if (!ci.header.isEmpty())
                                forwardDecl.removeAll(cl);
                            customWidgetIncludes.insert(cl, ci);
                        }
                        n3 = n3.nextSibling().toElement();
                    }
                }
                n2 = n2.nextSibling().toElement();
            }
        }
    }

    // register the object and unify its name
    objName = registerObject(objName);
    QString protector = objName.toUpper() + QLatin1String("_H");
    protector.replace(QLatin1String("::"), QLatin1String("_"));
    out << "#ifndef " << protector << endl;
    out << "#define " << protector << endl;
    out << endl;

    out << "#include <qvariant.h>" << endl; // for broken HP-UX compilers

    QStringList globalIncludes, localIncludes;

    {
        QMap<QString, CustomInclude>::Iterator it = customWidgetIncludes.find(objClass);
        if (it != customWidgetIncludes.end()) {
            if ((*it).location == QLatin1String("global"))
                globalIncludes += (*it).header;
            else
                localIncludes += (*it).header;
        }
    }

    QStringList::ConstIterator it;

    globalIncludes = unique(globalIncludes);
    for (it = globalIncludes.constBegin(); it != globalIncludes.constEnd(); ++it) {
        if (!(*it).isEmpty()) {
            QString header = fixHeaderName(*it);
            out << "#include <" << header << '>' << endl;
        }
    }
    localIncludes = unique(localIncludes);
    for (it = localIncludes.constBegin(); it != localIncludes.constEnd(); ++it) {
        if (!(*it).isEmpty()) {
            QString header = fixHeaderName(*it);
            out << "#include \"" << header << '\"' << endl;
        }
    }
    out << endl;

    bool dbForm = false;
    registerDatabases(e);
    dbConnections = unique(dbConnections);
    if (dbForms[QLatin1String("(default)")].count())
        dbForm = true;
    bool subDbForms = false;
    for (it = dbConnections.constBegin(); it != dbConnections.constEnd(); ++it) {
        if (!(*it).isEmpty() && (*it) != QLatin1String("(default)")) {
            if (dbForms[(*it)].count()) {
                subDbForms = true;
                break;
            }
        }
    }

    // some typedefs, maybe
    typeDefs = unique(typeDefs);
    for (it = typeDefs.constBegin(); it != typeDefs.constEnd(); ++it) {
        if (!(*it).isEmpty())
            out << "typedef " << *it << ';' << endl;
    }

    nl = e.parentNode().toElement().elementsByTagName(QLatin1String("forward"));
    for (i = 0; i < (int) nl.length(); i++)
        forwardDecl2 << fixDeclaration(nl.item(i).toElement().firstChild().toText().data());

    forwardDecl = unique(forwardDecl);
    for (it = forwardDecl.constBegin(); it != forwardDecl.constEnd(); ++it) {
        if (!(*it).isEmpty() && (*it) != objClass) {
            QString forwardName = *it;
            QStringList forwardNamespaces = forwardName.split(QLatin1String("::"));
            forwardName = forwardNamespaces.last();
            forwardNamespaces.removeAt(forwardNamespaces.size()-1);

            QStringList::ConstIterator ns = forwardNamespaces.constBegin();
            while (ns != forwardNamespaces.constEnd()) {
                out << "namespace " << *ns << " {" << endl;
                ++ns;
            }
            out << "class " << forwardName << ';' << endl;
            for (int i = 0; i < (int) forwardNamespaces.count(); i++)
                out << '}' << endl;
        }
    }

    for (it = forwardDecl2.constBegin(); it != forwardDecl2.constEnd(); ++it) {
        QString fd = *it;
        fd = fd.trimmed();
        if (!fd.endsWith(QLatin1Char(';')))
            fd += QLatin1Char(';');
        out << fd << endl;
    }

    out << endl;

    Driver d;
    d.option().headerProtection = false;
    d.option().copyrightHeader = false;
    d.option().extractImages = m_extractImages;
    d.option().limitXPM_LineLength = (m_options & LimitXPM_LineLength) ? 1 : 0;
    d.option().qrcOutputFile = m_qrcOutputFile;
    d.option().implicitIncludes = (m_options & ImplicitIncludes) ? 1 : 0;
    if (trmacro.size())
        d.option().translateFunction = trmacro;
    DomUI *ui = generateUi4(e);
    d.uic(fileName, ui, &out);
    delete ui;

    createWrapperDeclContents(e);

    out << "#endif // " << protector << endl;
}
Ejemplo n.º 29
0
/*!
  Creates the implementation of a layout tag. Called from createObjectImpl().
 */
QString Uic::createLayoutImpl( const QDomElement &e, const QString& parentClass, const QString& parent, const QString& layout )
{
    QDomElement n;
    QString objClass, objName;
    objClass = e.tagName();

    QString qlayout = "QVBoxLayout";
    if ( objClass == "hbox" )
	qlayout = "QHBoxLayout";
    else if ( objClass == "grid" )
	qlayout = "QGridLayout";

    bool isGrid = e.tagName() == "grid" ;
    objName = registerObject( getLayoutName( e ) );
    layoutObjects += objName;

    QString margin = DomTool::readProperty( e, "margin", defMargin ).toString();
    QString spacing = DomTool::readProperty( e, "spacing", defSpacing ).toString();
    QString resizeMode = DomTool::readProperty( e, "resizeMode", QString::null ).toString();

    QString optcells;
    if ( isGrid )
	optcells = "1, 1, ";
    if ( (parentClass == "QGroupBox" || parentClass == "QButtonGroup") && layout.isEmpty() ) {
	// special case for group box
	out << indent << parent << "->setColumnLayout(0, Qt::Vertical );" << endl;
	out << indent << parent << "->layout()->setSpacing( " << spacing << " );" << endl;
	out << indent << parent << "->layout()->setMargin( " << margin << " );" << endl;
	out << indent << objName << " = new " << qlayout << "( " << parent << "->layout() );" << endl;
	out << indent << objName << "->setAlignment( Qt::AlignTop );" << endl;
    } else {
	out << indent << objName << " = new " << qlayout << "( ";
	if ( layout.isEmpty() )
	    out << parent;
	else {
	    out << "0";
	    if ( !DomTool::hasProperty( e, "margin" ) )
		margin = "0";
	}
	out << ", " << optcells << margin << ", " << spacing << ", \"" << objName << "\"); " << endl;
    }
    if ( !resizeMode.isEmpty() )
	out << indent << objName << "->setResizeMode( QLayout::" << resizeMode << " );" << endl;

    if ( !isGrid ) {
	for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
	    if ( n.tagName() == "spacer" ) {
		QString child = createSpacerImpl( n, parentClass, parent, objName );
		out << indent << objName << "->addItem( " << child << " );" << endl;
	    } else if ( tags.contains( n.tagName() ) ) {
		QString child = createObjectImpl( n, parentClass, parent, objName );
		if ( isLayout( child ) )
		    out << indent << objName << "->addLayout( " << child << " );" << endl;
		else
		    out << indent << objName << "->addWidget( " << child << " );" << endl;
	    }
	}
    } else {
	for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
	    QDomElement ae = n;
	    int row = ae.attribute( "row" ).toInt();
	    int col = ae.attribute( "column" ).toInt();
	    int rowspan = ae.attribute( "rowspan" ).toInt();
	    int colspan = ae.attribute( "colspan" ).toInt();
	    if ( rowspan < 1 )
		rowspan = 1;
	    if ( colspan < 1 )
		colspan = 1;
	    if ( n.tagName() == "spacer" ) {
		QString child = createSpacerImpl( n, parentClass, parent, objName );
		if ( rowspan * colspan != 1 )
		    out << indent << objName << "->addMultiCell( " << child << ", "
			<< row << ", " << ( row + rowspan - 1 ) << ", " << col << ", " << ( col  + colspan - 1 ) << " );" << endl;
		else
		    out << indent << objName << "->addItem( " << child << ", "
			<< row << ", " << col << " );" << endl;
	    } else if ( tags.contains( n.tagName() ) ) {
		QString child = createObjectImpl( n, parentClass, parent, objName );
		out << endl;
		QString o = "Widget";
		if ( isLayout( child ) )
		    o = "Layout";
		if ( rowspan * colspan != 1 )
		    out << indent << objName << "->addMultiCell" << o << "( " << child << ", "
			<< row << ", " << ( row + rowspan - 1 ) << ", " << col << ", " << ( col  + colspan - 1 ) << " );" << endl;
		else
		    out << indent << objName << "->add" << o << "( " << child << ", "
			<< row << ", " << col << " );" << endl;
	    }
	}
    }

    return objName;
}
Ejemplo n.º 30
0
void NotifyObserver::registerPrefix(const string& command, BaseNotify* obj)
{
    registerObject(command, obj, _prefix);
}