本文整理汇总了C++中Plugin::getPawn方法的典型用法代码示例。如果您正苦于以下问题:C++ Plugin::getPawn方法的具体用法?C++ Plugin::getPawn怎么用?C++ Plugin::getPawn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugin
的用法示例。
在下文中一共展示了Plugin::getPawn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addPlugin
void PluginManager::addPlugin(QDir* dir) {
QDomDocument doc;
QFile pluginXmlFile(dir->absolutePath()+QDir::separator()+"plugin.xml");
if(!pluginXmlFile.exists()) {
qDebug("error plugin.xml not exist "+dir->absolutePath().toUtf8());
return;
}
pluginXmlFile.open(QIODevice::ReadOnly);
doc.setContent(&pluginXmlFile);
pluginXmlFile.close();
QDomElement plugin = doc.documentElement();
QString name = plugin.lastChildElement("name").text();
QString version = plugin.lastChildElement("version").text();
QString description = plugin.lastChildElement("description").text();
QString cellBackground = dir->absolutePath()+QDir::separator()+plugin.lastChildElement("cellBackground").text();
Plugin* p = new Plugin(name, description,version);
p->setCellBackground(cellBackground);
qDebug("Plugin: "+name.toUtf8());
QDomNodeList listPawns = plugin.lastChildElement("pawns").elementsByTagName("pawn");
for(int i = 0;i < listPawns.count(); i++)
{
QString pid = listPawns.at(i).lastChildElement("id").text();
QString pname = listPawns.at(i).lastChildElement("name").text();
QString picon = dir->absolutePath()+QDir::separator()+listPawns.at(i).lastChildElement("icon").text();
if(!p->existPawn(pid))
{
qDebug(" Pawn: "+pname.toUtf8()+" (id:"+pid.toUtf8()+", icon:"+picon.toUtf8()+")");
Pawn* pawn = new Pawn(pid, pname, picon);
p->addPawn(pawn);
}
else
{
qDebug(" Pawn can't add");
}
}
QDomNodeList listrules = plugin.lastChildElement("rules").elementsByTagName("rule");
for(int i = 0;i < listrules.count(); i++)
{
QString from = listrules.at(i).attributes().namedItem("pawn").toAttr().value();
QString to = listrules.at(i).attributes().namedItem("newPawn").toAttr().value();
if(p->existPawn(from) && p->existPawn(to)) {
Rule* r = new Rule(p->getPawn(from), p->getPawn(to));
qDebug(" Rule: (from:"+from.toUtf8()+" to:"+to.toUtf8()+")");
for(int j = 0;j < listrules.at(i).childNodes().count(); j++)
{
QString op = listrules.at(i).childNodes().at(j).nodeName();
QString pawn = listrules.at(i).childNodes().at(j).attributes().namedItem("pawn").toAttr().value();
QString value = listrules.at(i).childNodes().at(j).toElement().text();
int intValue = value.toInt();
AbstractOperator* o = NULL;
if(op == "pawnNumberIsEqual")
o = new EqualOperator(intValue, pawn);
if(op == "pawnNumberIsLower")
o = new LowerOperator(intValue, pawn);
if(op == "pawnNumberIsGreater")
o = new GreaterOperator(intValue, pawn);
if(o != NULL && p->existPawn(pawn))
{
r->addOperator(o);
qDebug(" with "+pawn.toUtf8()+" "+op.toUtf8()+" "+value.toUtf8());
}
else
{
qDebug(" Operator can't add");
}
}
p->getPawn(from)->addRule(r);
}
else
{
qDebug(" Rule can't add");
}
}
plugins->push_back(p);
}