void ProjectFile::SetAttribute(QString parentTag, QString childTag, QString attribute, QString value)
{
	QDomElement parentTagElement = documentElement().namedItem(parentTag).toElement();
	if (parentTagElement.isNull())
	{
		parentTagElement = createElement(parentTag);
		documentElement().appendChild(parentTagElement);
	}

	QDomElement childTagElement = parentTagElement.namedItem(childTag).toElement();
	if (childTagElement.isNull())
	{
		childTagElement = createElement(childTag);
		parentTagElement.appendChild(childTagElement);
	}

	QDomNode attributeNode = childTagElement.namedItem(value);
	if (!attributeNode.isNull())
	{
		childTagElement.removeChild(attributeNode);
	}

	QDomElement attributeElement = createElement(attribute);
	attributeElement.appendChild(createTextNode(value));
	childTagElement.appendChild(attributeElement);

	SaveProject();
}
std::string _test_vertical_layout() {
	struct LayoutProperties layoutProperties;
	layoutPropertiesInitialize(&layoutProperties);
	struct Element* e1 = createElement(composite); // Device - top level window
	layoutProperties.width.valueType = fill;
	layoutProperties.width.value = NAN;
	layoutProperties.height.valueType = fill;
	layoutProperties.height.value = NAN;
	struct Element* e2 = createElement(composite);
	measureNodeForVerticalLayout(layoutProperties, e2);
	layoutProperties.width = {fixed, 100};
	layoutProperties.height = {fixed, 100};
	struct Element* e3 = createElement(composite);
	measureNodeForVerticalLayout(layoutProperties, e3);
	addChildElement(e1, e2);
	addChildElement(e2, e3);
	doVerticalLayout((*e1)._children, 449, 662, false, false);
	ut_assert("error, absolute position top e2", (*e3)._measuredTop == 281);
	ut_assert("error, absolute position left e2", (*e3)._measuredLeft == 174.5);
	ut_assert("error, absolute width e2", (*e3)._measuredWidth == 100);
	ut_assert("error, absolute height e2", (*e3)._measuredHeight == 100);
	ut_assert("error, absolute position top e3", (*e2)._measuredTop == 0);
	ut_assert("error, absolute position left e3", (*e2)._measuredLeft == 0);
	ut_assert("error, absolute position width e3", (*e2)._measuredWidth == 449);
	ut_assert("error, absolute position height e3", (*e2)._measuredHeight == 662);
	return "";
}
Example #3
0
void XMLElementSommet::update()
{
    //On réaffecte l'ID :
    setAttribute(QString("id"),sommet->getNom());

    //De même avec la forme :
    QDomElement ancienDomForme=firstChildElement("Forme");
    QDomElement newDomForme=createElement(QString("Forme"));
    newDomForme.setNodeValue(sommet->getForme());

    if(ancienDomForme.isNull())
        domSommet->appendChild(newDomForme);
    else
        replaceChild(newDomForme, ancienDomForme);

    //Si c'est coloré, on s'en occupe :
    if(colore){
        SommetColore* sommetColore=(SommetColore*) sommet;
        QDomElement ancienDomCouleur=firstChildElement("Couleur");
        QDomElement newDomCouleur=createElement(QString("Couleur"));
        newDomForme.setNodeValue(QString(sommetColore->getCouleur()));
        if(ancienDomCouleur.isNull())
            domSommet->appendChild(newDomCouleur);
        else
            replaceChild(newDomCouleur, ancienDomCouleur);

    }
}
TupStoryboardExportPackage::TupStoryboardExportPackage(const QString &title, const QString &topics, const QString &description, const QList<int> sceneIndexes): QDomDocument()
{
    QDomElement root = createElement("project_storyboard");
    root.setAttribute("version", "0");
    appendChild(root);
    
    QString indexes = "";
    for (int i=0; i < sceneIndexes.size(); i++)
         indexes += QString::number(sceneIndexes.at(i)) + ","; 

    indexes.remove(indexes.length() - 1, 1);

    QDomElement story = createElement("storyboard");
    story.setAttribute("scenes", indexes);

    QDomText titleDom = createTextNode(title);
    QDomText topicDom = createTextNode(topics);
    QDomText descDom = createTextNode(description);

    story.appendChild(createElement("title")).appendChild(titleDom);
    story.appendChild(createElement("topics")).appendChild(topicDom);
    story.appendChild(createElement("description")).appendChild(descDom);
    
    root.appendChild(story);
}
QueryProject::QueryProject(const QString & name): QDomDocument() , d(new Private)
{
	QDomElement root = createElement( "queryproject" );
	root.setAttribute( "version",  "0" );
	appendChild(root);
	d->name = createTextNode(name);
	root.appendChild(createElement("name")).appendChild(d->name);
}
RemoveUser::RemoveUser(const QString& login): QDomDocument(), d(new Private)
{
	QDomElement root = createElement( "removeuser" );
	root.setAttribute( "version",  "0" );
	appendChild(root);
	d->login = createTextNode(login);
	root.appendChild(createElement("login")).appendChild(d->login);
}
RegisterUser::RegisterUser(const QString &login, const QString &email) : QDomDocument()
{
	QDomElement root = createElement("registeruser");
	
	root.appendChild( createElement("login") ).appendChild(createTextNode(login));
	root.appendChild( createElement("email") ).appendChild(createTextNode(email));
	
	appendChild(root);
}
CChatPackage::CChatPackage(const QString &msg) : QDomDocument()
{
	QDomElement root = createElement("Chat");
	
	QDomElement message = createElement("Message");
	message.setAttribute( "value", msg);
	root.appendChild(message);
	
	appendChild(root);
}
Example #9
0
TupNoticePackage::TupNoticePackage(const QString &text): QDomDocument()
{
    QDomElement root = createElement("communication_notice");
    root.setAttribute("version", 0);
    appendChild(root);
    
    QDomElement message = createElement("message");
    message.setAttribute("text", text); 
    root.appendChild(message);
}
SChatPackage::SChatPackage(const QString &login,const QString &msg) : QDomDocument()
{
	QDomElement root = createElement("Chat");
	QDomElement emsg = createElement("Message");
	emsg.setAttribute( "value", msg);
	emsg.setAttribute( "login", login);
	
	root.appendChild(emsg);
	appendChild(root);
}
Example #11
0
int main(){
    
    Stack * stack1;
    stack1 = createStack();
    
    Element *e1, *e2, *e3, *e4, *e5;
    int a, b, c, d, e;
    
    
    a = 1;
    b = 2;
    c = 3;
    
    e1 = createElement(&a);
    e2 = createElement(&b);
    e3 = createElement(&c);
    
    int empty = isEmpty(stack1);
    if (empty == 1)
        printf("The stack is empty!\n");
    else 
        printf("Why is the stack not empty?\n");
    
    /* Add a Element to the stack and check if the stack is empty*/
    push(stack1, e1);
    
    empty = isEmpty(stack1);
    
    if (empty == 1)
        printf("Why is the stack empty?\n");
    else 
        printf("The stack is not empty!\n");
    
    /* Add another Element to the stack and check it is at the top 
    by calling peek() */
    
    push(stack1, e2);
    Element * test;
    test = peek(stack1);
    printf("The top element is: %d\n", *(int *)(test->elementPtr));
    
    /* remove the top element and test with peek() */
    test = pop(stack1);
    test = peek(stack1);
    printf("The top element is: %d\n", *(int *)(test->elementPtr));
    
    /* Add another and check with peek() */
    push(stack1, e3);
    test = peek(stack1);
    printf("The top element is: %d\n", *(int *)(test->elementPtr));
    
    destroyStack(stack1);
    
    return 0;
}
KTOpenPackage::KTOpenPackage(const QString& projectName): QDomDocument()
{
	QDomElement root = createElement("openproject");
	root.setAttribute("version", "0");
	appendChild(root);
	
	QDomElement m_project = createElement("project");
	m_project.setAttribute("name", projectName);
	root.appendChild(m_project);
	
}
void ProjectFile::CreateEmptyProject()
{
	clear();
	appendChild(createElement(TAG_PROJECT));
	QDomElement fullDomainElement = createElement(TAG_FULL_DOMAIN);
	QDomElement subDomainElement = createElement(TAG_SUB_DOMAIN);
	QDomElement settingsElement = createElement(TAG_SETTINGS);
	documentElement().appendChild(fullDomainElement);
	documentElement().appendChild(subDomainElement);
	documentElement().appendChild(settingsElement);
}
KTChatPackage::KTChatPackage(const QString &text) : QDomDocument()
{
    QDomElement root = createElement("chat");
    root.setAttribute("version", "0");
    appendChild(root);
    
    QDomElement message = createElement("message");
    message.setAttribute("text", text);
    
    root.appendChild(message);
}
Example #15
0
AddBan::AddBan(const QString &pattern)
 : QDomDocument()
{
	QDomElement root = createElement("addban");
	root.setAttribute("version", "0");
	QDomElement patterne = createElement("pattern");
	patterne.setAttribute("value", pattern);
	
	root.appendChild(patterne);
	
	appendChild(root);
}
Example #16
0
Error::Error(const QString &message, Level level)
    : QDomDocument()
{
    QDomElement root = createElement ("error");
    root.setAttribute("version", "0");
    appendChild(root);
    
    m_message = createElement("message");
    root.appendChild(m_message);
    m_message.appendChild(createTextNode(message));
    m_message.setAttribute("level", level);
}
void KTPaletteDocument::addGradient(const QGradient &gradient)
{
    QDomElement element = createElement("Gradient");
    
    element.setAttribute("type", gradient.type());
    element.setAttribute("spread", gradient.spread());
    const QGradient *gr = &gradient;
    switch (gradient.type()) {
            case QGradient::LinearGradient:
            {
                 element.setAttribute("startX", static_cast<const QLinearGradient *>(gr)->start().x());
                 element.setAttribute("startY", static_cast<const QLinearGradient *>(gr)->start().y());
                
                 element.setAttribute("finalX", static_cast<const QLinearGradient *>(gr)->finalStop().x());
                 element.setAttribute("finalY", static_cast<const QLinearGradient *>(gr)->finalStop().y());
            }
            break;
            case QGradient::RadialGradient:
            {
                 element.setAttribute("centerX", static_cast<const QRadialGradient *>(gr)->center().x());
                 element.setAttribute("centerY", static_cast<const QRadialGradient *>(gr)->center().y());
                
                 element.setAttribute("focalX", static_cast<const QRadialGradient *>(gr)->focalPoint().x());
                 element.setAttribute("focalY", static_cast<const QRadialGradient *>(gr)->focalPoint().y());
                
                 element.setAttribute("radius", static_cast<const QRadialGradient *>(gr)->radius());
            }
            break;
            case QGradient::ConicalGradient:
            {
                 element.setAttribute("centerX", static_cast<const QRadialGradient *>(gr)->center().x());
                 element.setAttribute("centerY", static_cast<const QRadialGradient *>(gr)->center().y());
                
                 element.setAttribute("angle", static_cast<const QConicalGradient *>(gr)->angle());
            }
            break;
            case QGradient::NoGradient:
            {
            }
            break;
    }
    
    QGradientStops stops = gradient.stops();
    
    foreach (QGradientStop stop, stops) {
             QDomElement stopElement = createElement("Stop");
             stopElement.setAttribute("value", stop.first);
             stopElement.setAttribute("colorName", stop.second.name());
             stopElement.setAttribute("alpha", stop.second.alpha());
        
             element.appendChild(stopElement);
    }
ADConnectPackage::ADConnectPackage(const QString &login, const QString &passwd) : QDomDocument()
{
	QDomElement root = createElement("Connection");
	
	QDomElement elogin = createElement("Login");
	elogin.setAttribute( "value", login);
	root.appendChild(elogin);
	
	QDomElement epasswd = createElement("Password");
	epasswd.setAttribute( "value", passwd);
	root.appendChild(epasswd);
	
	appendChild(root);
}
void KThemeDocument::addSelections(ThemeKey tk)
{
    QDomElement general = createElement("Selections");
    QStringList keys = tk.keys();
    QStringList values = tk.values();

    for (int i = 0; i < keys.count(); i++) {
         QDomElement e = createElement(keys[i]);
         e.setAttribute("color", values[i]);
         general.appendChild(e);
    }

    documentElement().appendChild(general);
}
void ResultDocument::setError(int c, const QString &m) {

	QDomElement errorResult = createElement("error_result");
	appendChild(errorResult);
	QDomElement errorCode = createElement("error_code");
	errorResult.appendChild(errorCode);
	QDomText code = createTextNode(QString::number(c));
	errorCode.appendChild(code);
	
	QDomElement errorMessage = createElement("error_message");
	errorResult.appendChild(errorMessage);
	QDomText message = createTextNode(m);
	errorMessage.appendChild(message);
}
Example #21
0
struct queue * push(int data){
	if(head == NULL)
		head = createElement(data);
	else{
		struct queue *current, *newElement=NULL;
		current = head;
		while(current->next!=NULL){
			current = current->next;
		}
		newElement = createElement(data);
		current->next = newElement;
	}
	return head;
}
Example #22
0
TupImportProjectPackage::TupImportProjectPackage(const QString &projectPath)
{
    QDomElement root = createElement("project_import");
    root.setAttribute("version", "0");
    appendChild(root);

    QFile file(projectPath);
    file.open(QIODevice::ReadOnly);
    QByteArray data = file.readAll().toBase64();

    QDomElement content = createElement("data");
    content.setAttribute("file", projectPath);
    content.appendChild(createCDATASection(data));
    root.appendChild(content);
}
Example #23
0
void addSortedElement(List *list, CipherTree *tree) {

	ListElement *currentElement = list->head;

	while (true) {
		if (currentElement->next == nullptr) {
			createElement(currentElement, nullptr, tree);
			break;
		} else if (currentElement->next->tree->value >= tree->value) {
			createElement(currentElement, currentElement->next, tree);
			break;
		} else {
			currentElement = currentElement->next;
		}
	}
}
Example #24
0
    void AbstractXULParser::startElement(const Poco::XML::XMLString & uri,
                                         const Poco::XML::XMLString & localName,
                                         const Poco::XML::XMLString & qname,
                                         const Poco::XML::Attributes & attributes)
    {
        try
        {
            if (mIgnores > 0)
            {
                mIgnores++;
                return;
            }

            Element * parent = getCurrentParentElement();
            AttributesMapping attr;
            getAttributes(attributes, attr);
            ElementPtr element;
            if (createElement(localName, parent, attr, element))
            {
                pushStack(element);
            }
            else
            {
                mIgnores++;
                ReportError("Element is null and will be ignored.");
                return;
            }
        }
        catch (const Poco::Exception & inExc)
        {
            ReportError(inExc.displayText());
        }
    }
Example #25
0
int list2_addElement(struct list2 * listContext, void * data) 
{

    int error;
    
    // Testa dados de entrada.
    if ( (!(data)) || (!(listContext)) ) {
        return E_NULL_PARAMETER;
    };
    
    // Cria elemento com parâmetros específicos.
    listContext->last = createElement(data, listContext->last, NULL, &error);
    if (!(listContext->last)) {
        return error;
    };
    
    // Se não existe o primeiro elemento, o último e o primeiro serão o mesmo.
    if (!(listContext->first)) {
        listContext->first = listContext->last;
    };
    
    // Incrementa número de elementos na lista.
    (listContext->numElements)++;

    return E_OK;

};
std::string _test_measure_vertical_node() {
	struct LayoutProperties layoutProperties;
	layoutPropertiesInitialize(&layoutProperties);
	struct Element* element = createElement(vertical);
	layoutProperties.width = {fixed, 100};
	layoutProperties.height = {fixed, 100};
	measureNodeForVerticalLayout(layoutProperties, element);
	// width height rule
	ut_assert("error, layout width coefficient x1", (*element)._layoutCoefficients.width.x1 == 0);
	ut_assert("error, layout width coefficient x2", (*element)._layoutCoefficients.width.x2 == 100);
	ut_assert("error, layout height coefficient x1", (*element)._layoutCoefficients.height.x1 == 0);
	ut_assert("error, layout height coefficient x2", (*element)._layoutCoefficients.height.x2 == 100);
	// min-width min-height rule
	ut_assert("error, layout min width coefficient x1", isNaN((*element)._layoutCoefficients.minWidth.x1));
	ut_assert("error, layout min width coefficient x2", isNaN((*element)._layoutCoefficients.minWidth.x2));
	ut_assert("error, layout min width coefficient x3", isNaN((*element)._layoutCoefficients.minWidth.x3));
	ut_assert("error, layout min height coefficient x1", isNaN((*element)._layoutCoefficients.minHeight.x1));
	ut_assert("error, layout min height coefficient x2", isNaN((*element)._layoutCoefficients.minHeight.x2));
	ut_assert("error, layout min height coefficient x3", isNaN((*element)._layoutCoefficients.minHeight.x3));
	// top left rule
	ut_assert("error, layout width coefficient x1", (*element)._layoutCoefficients.top.x1 == 0.5);
	ut_assert("error, layout width coefficient x2", (*element)._layoutCoefficients.top.x2 == -0.5);
	ut_assert("error, layout height coefficient x1", (*element)._layoutCoefficients.left.x1 == 0.5);
	ut_assert("error, layout height coefficient x2", (*element)._layoutCoefficients.left.x2 == -0.5);
	return "";
}
Example #27
0
/** 解析特效元素 */
void VEffectManager::_parseElement(const VString &type, Ogre::DataStreamPtr &stream, VEffect *effect)
{
	VEffectElement *element = createElement(type);
	assert(element != VNULL);

	effect->addElement(element);

	Ogre::String line;

	while (!stream->eof())
	{
		line = stream->getLine();
		++mParsingLineNumber;

		if (!(line.empty() || line.substr(0, 2) == "//"))
		{
			// 跳过空行和注释行
			if (line == "}")
			{
				break;
			}
			else
			{
				_parseElementAttrib(line, element);
			}
		}
	}
}
Example #28
0
Element AutomailPattern::handleMatch(const ElementTree &, const QRegularExpressionMatch &m)
{
    Element el = createElement("a");
    QString email = this->unescape(m.captured(2));
    if ( email.startsWith("mailto:") ) {
        email = email.mid(7);
    }

    QString letters;
    for ( const QChar &ch : email ) {
        if ( codepoint2name.contains(ch) ) {
            letters += QString("%1%2;").arg(util::AMP_SUBSTITUTE).arg(codepoint2name[ch]);
        } else {
            letters += QString("%1#%2;").arg(util::AMP_SUBSTITUTE).arg(QString::number(ch.unicode()));
        }
    }
    el->text = letters;
    el->atomic = true;

    QString mailto = "mailto:"+email;
    QString buff;
    for ( int i = 0; i < mailto.size(); ++i ) {
        QChar ch = mailto.at(i);
        buff.append(QString("%1#%2;").arg(util::AMP_SUBSTITUTE, QString::number(ch.unicode())));
    }
    mailto = buff;

    el->set("href", this->unescape(mailto));
    return el;
}
Example #29
0
void UserList::addUser(const Users::User *user)
{
    QDomElement userE = createElement("user");
    userE.setAttribute("login", user->login());
    userE.setAttribute("name", user->name());
    firstChild().appendChild(userE);
}
ADUpdatePackage::ADUpdatePackage(const QString &table, const QStringList &fields, const QStringList &values) : ADSqlPackageBase()
{
	QDomElement root = createElement("Update");
	
	appendChild( root );
	addTable( table, fields, values);
}