示例#1
0
void outputSinglePuzzle(int index, const std::string& property, const std::string& value, const std::string& propertyAsked) {
	std::cout << "<input type=\"hidden\" name=\"INDEX[]\" value=\"" << index << "\">\n";
	std::cout << "<input type=\"hidden\" name=\"PROPERTY[]\" value=\"" << propertyAsked << "\">\n";
	std::cout << "<table id=\"marginTable\">\n";
	std::cout << "<tr><th width=\"165px\">" << outputProperty(property) << "</th><td width=\"50px\"><center>" << outputPronom(property) << "</center></td><td><center>" << value << "</center></td></tr>\n";
	std::cout << "<tr><th width=\"165px\">" << outputProperty(propertyAsked) << "</th><td width=\"50px\"><center>" << outputPronom(propertyAsked) << "</center></td><td><input type=\"text\" name=\"ANSWER[]\">\n";
	std::cout << "</table>\n";
}
示例#2
0
void outputFindWord(const std::vector<Verb>& verbs, const std::string& findStr) {
	int minDistance = 100000000;
	int verbIndex = -1;
	for(size_t i=0; i<verbs.size(); ++i) {
		for(auto it = verbs[i].values.begin(); it != verbs[i].values.end(); ++it) {
			int dist = editDistance(findStr, it->second);
			if(dist < minDistance) {
				minDistance = dist;
				verbIndex = i;
			}
		}
	}
	std::cout << "<div style=\"padding-top:25px\">\n";
	std::cout << "<table>\n";
	Verb v = verbs[verbIndex];
	for(auto it = v.values.begin(); it != v.values.end(); ++it) {
		std::cout << "<tr><th align=\"left\">" << outputProperty(it->first) << "</th><td align=\"center\" width=\"50px\">" << outputPronom(it->first) << "</td><td align=\"center\">" << it->second << "</td></tr>\n";
	}
	std::cout << "</table>\n";
	std::cout << "</div>\n";
}
示例#3
0
static void outputLayoutWidgetsSubLayout( QMap<int, QStringList>& buddies,
					  UibIndexMap& objects,
					  UibStrTable& strings,
					  QDataStream& out, QDomElement elem )
{
    int subLayoutNo = -1;
    QCString name;
    QDomElement nameElem;

    QDomElement f = elem.firstChild().toElement();
    while ( !f.isNull() ) {
	QString tag = f.tagName();
	if ( tag == "grid" || tag == "hbox" || tag == "vbox" ) {
	    out << (Q_UINT8) Object_SubLayout;
	    subLayoutNo = outputObject( buddies, objects, strings, out, f,
					layoutForTag(tag) );
	} else if ( tag == "property" ) {
	    if ( f.attribute("name") == "name" ) {
		name = DomTool::elementToVariant( f, name ).asCString();
		nameElem = f;
	    }
	}
	f = f.nextSibling().toElement();
    }

    if ( subLayoutNo != -1 ) {
	/*
	  Remove the sub-layout's Object_End marker, append the grid
	  cell and the correct name property, and put the Object_End
	  marker back.
	*/
	out.device()->at( out.device()->at() - 1 );
	outputGridCell( out, elem );
	outputProperty( buddies, subLayoutNo, strings, out, nameElem );
	out << (Q_UINT8) Object_End;

	objects.setName( subLayoutNo, name );
    }
}
示例#4
0
static int outputObject( QMap<int, QStringList>& buddies,
			 UibIndexMap& objects, UibStrTable& strings,
			 QDataStream& out, QDomElement elem,
			 QCString className )
{
    bool isQObject = !className.isEmpty();

    if ( className == "QToolBar" )
	out << (Q_UINT8) elem.attribute( "dock", "0" ).toInt();
    if ( className == "QWidget" )
	className = elem.attribute( "class", className ).latin1();

    int objectNo = -1;
    if ( isQObject ) {
	packCString( strings, out, className );
	objectNo = objects.insert();
    }

    outputGridCell( out, elem );

    // optimization: insert '&Foo' into string-table before 'Foo'
    if ( className == "QAction" || className == "QActionGroup" ) {
	QVariant value = DomTool::readProperty( elem, "menuText", QVariant() );
	if ( value.asString().startsWith("&") )
	    strings.insertString( value.asString() );
    }

    QDomElement f = elem.firstChild().toElement();
    while ( !f.isNull() ) {
	QString tag = f.tagName();
	if ( tag == "action" ) {
	    if ( elem.tagName() == "item" || elem.tagName() == "toolbar" ) {
		QString actionName = f.attribute( "name" );
		int no = objects.find( actionName );
		if ( no != -1 ) {
		    out << (Q_UINT8) Object_ActionRef;
		    packUInt16( out, no );
		}
	    } else {
		out << (Q_UINT8) Object_SubAction;
		outputObject( buddies, objects, strings, out, f, "QAction" );
	    }
	} else if ( tag == "actiongroup" ) {
	    out << (Q_UINT8) Object_SubAction;
	    outputObject( buddies, objects, strings, out, f, "QActionGroup" );
	} else if ( tag == "attribute" ) {
	    out << (Q_UINT8) Object_Attribute;
	    outputProperty( buddies, objectNo, strings, out, f );
	} else if ( tag == "column" ) {
	    out << (Q_UINT8) Object_Column;
	    outputObject( buddies, objects, strings, out, f );
	} else if ( tag == "event" ) {
	    out << (Q_UINT8) Object_Event;
	    packCString( strings, out, f.attribute("name").latin1() );
	    packVariant( strings, out,
			 QStringList::split(',', f.attribute("functions")) );
	} else if ( tag == "grid" || tag == "hbox" || tag == "vbox" ) {
	    out << (Q_UINT8) Object_SubLayout;
	    outputObject( buddies, objects, strings, out, f,
			  layoutForTag(tag) );
	} else if ( tag == "item" ) {
	    if ( elem.tagName() == "menubar" ) {
		out << (Q_UINT8) Object_MenuItem;
		packCString( strings, out, f.attribute("name").latin1() );
		packCString( strings, out, f.attribute("text").utf8() );
		outputObject( buddies, objects, strings, out, f );
	    } else {
		out << (Q_UINT8) Object_Item;
		outputObject( buddies, objects, strings, out, f );
	    }
	} else if ( tag == "property" ) {
	    outputProperty( buddies, objectNo, strings, out, f );
	} else if ( tag == "row" ) {
	    out << (Q_UINT8) Object_Row;
	    outputObject( buddies, objects, strings, out, f );
	} else if ( tag == "separator" ) {
	    out << (Q_UINT8) Object_Separator;
	} else if ( tag == "spacer" ) {
	    out << (Q_UINT8) Object_Spacer;
	    outputObject( buddies, objects, strings, out, f );
	} else if ( tag == "widget" ) {
	    if ( f.attribute("class") == "QLayoutWidget" &&
		 elem.tagName() != "widget" ) {
		outputLayoutWidgetsSubLayout( buddies, objects, strings, out,
					      f );
	    } else {
		out << (Q_UINT8) Object_SubWidget;
		outputObject( buddies, objects, strings, out, f, "QWidget" );
	    }
	}
	f = f.nextSibling().toElement();
    }
    out << (Q_UINT8) Object_End;
    if ( isQObject )
	objects.setName( objectNo,
			 DomTool::readProperty(elem, "name", "").asString() );
    return objectNo;
}