void NormalInterpolatorNode::outputContext(ostream &printStream, const char *indentString) 
{
	if (0 < getNKeys()) {
		MFFloat *key = getKeyField();
		printStream << indentString << "\tkey [" << endl;
		key->MField::outputContext(printStream, indentString, "\t\t");
		printStream << indentString << "\t]" << endl;
	}

	if (0 < getNKeyValues()) {
		MFVec3f *keyValue = getKeyValueField();
		printStream << indentString << "\tkeyValue [" << endl;
		keyValue->MField::outputContext(printStream, indentString, "\t\t");
		printStream << indentString << "\t]" << endl;
	}
}
示例#2
0
CoeusListRowComponent * AccountsTableListBoxModel::refreshComponentForRow(int rowNumber, bool isRowSelected, CoeusListRowComponent *existingComponentToUpdate)
{
    // create
    if (existingComponentToUpdate == nullptr) {
        AccountsRowComponent *newComp = new AccountsRowComponent(*this, false);
        newComp->addMouseListener(this, true);
        newComp->addChangeListener(this);
        newComp->setRow(rowNumber);
        
        const bool dView = (rowNumber < getNumRows()) ? rowSizes[rowNumber] == AccountsRowComponent::maxRowSize : false;
        const StringArray keys = (qe != nullptr) ? qe->getFieldFromRow(rowNumber, getKeyField()) : StringArray();
		const auto keysT = (qeTransactions != nullptr) ? qeTransactions->getFieldFromRow(rowNumber, getKeyFieldForTransaction()) : StringArray();
        if (keys.size() && (rowsToUpdate.find(keys) != rowsToUpdate.end())) {
            newComp->updateFromMapForRow(qe, rowsToUpdate[keys], rowNumber, dView, editedRows.contains(rowNumber));
			newComp->updateFromTransactionsMapForRow(qe, rowsToUpdate[keysT], rowNumber, dView, editedRows.contains(rowNumber));
        }
        else {
            newComp->updateFromQueryForRow(qe, rowNumber,  dView, editedRows.contains(rowNumber));
			newComp->updateFromTransactionsQueryForRow(qe, numTransactions[keysT], rowNumber, dView, editedRows.contains(rowNumber));
        }
        newComp->shouldShowControls(isRowSelected || rowUnderMouse == rowNumber);
        
        return newComp;
    }
    // update
    else {
        AccountsRowComponent * cmp = dynamic_cast<AccountsRowComponent *>(existingComponentToUpdate);
        
        if(cmp) {
            const bool dView = (rowNumber < getNumRows()) ? rowSizes[rowNumber] == AccountsRowComponent::maxRowSize : false;
            const StringArray keys = (qe != nullptr) ? qe->getFieldFromRow(rowNumber, getKeyField()) : StringArray();
			const auto keysT = (qeTransactions != nullptr) ? qeTransactions->getFieldFromRow(rowNumber, getKeyFieldForTransaction()) : StringArray();
            if (keys.size() && (rowsToUpdate.find(keys) != rowsToUpdate.end())) {
                cmp->updateFromMapForRow(qe, rowsToUpdate[keys], rowNumber, dView, editedRows.contains(rowNumber));
				cmp->updateFromTransactionsMapForRow(qe, rowsToUpdate[keysT], rowNumber, dView, editedRows.contains(rowNumber));
            }
            else {
                cmp->updateFromQueryForRow(qe, rowNumber,  dView, editedRows.contains(rowNumber));
				cmp->updateFromTransactionsQueryForRow(qeTransactions, numTransactions[keysT], rowNumber, dView, editedRows.contains(rowNumber));
            }
            cmp->shouldShowControls(isRowSelected || rowUnderMouse == rowNumber);
        }
        
        return existingComponentToUpdate;
    }
}
示例#3
0
void odkFormReader::extractFields(QDomNode child, QString tableName, TtableDef &parentTable, QString groupCode, QString xmlCode)
{
    QDomElement item;
    QDomNode node;
    QDomNode childNode;

    QString fieldCode;
    QString fieldName;
    QString fieldOutput;
    QString fieldType;
    QStringList ftypes;
    QStringList ftsizes;

    QString sameTable;
    QString grpCode;

    QString childName;
    QString mselptable;
    QString repeatXMLCode;
    QString fieldXMLCode;


    TtableDef table;
    TtableDef tempTable;
    int pos;

    tableIndex++;
    int tindex;
    tindex = tableIndex;

    bool fieldinmselt;

    TfieldDef fsurveyID;
    TfieldDef foriginID;



    if ((tableName.toLower() != parentTable.name.toLower()) || (parentTable.fields.count() == 0)) //We are not processing a group
    {
        //qDebug() << "Table: " + tableName.toLower() + " Parent: " + parentTable.name.toLower() + ". Fields: " + QString::number(parentTable.fields.count());

        if (tableName.toLower() == mTable.toLower())
        {
            table.name = tableName;
            table.desc = "Main survey Table - Change this description";
            table.xmlCode = xmlCode;
            table.parentTable = "NULL";

            /*fsurveyID.name = "surveyid";
            fsurveyID.desc = "Survey ID (UUID)";
            fsurveyID.type = "varchar";
            fsurveyID.size = 80;
            fsurveyID.decSize = 0;
            fsurveyID.section = "main";
            fsurveyID.rField = "";
            fsurveyID.rTable = "";
            fsurveyID.key = false;
            fsurveyID.xmlCode = "NONE";
            table.fields.append(fsurveyID);

            foriginID.name = "originid";
            foriginID.desc = "Origin ID: formhub or aggregate";
            foriginID.type = "varchar";
            foriginID.size = 15;
            foriginID.decSize = 0;
            foriginID.section = "main";
            foriginID.rField = "";
            foriginID.rTable = "";
            foriginID.key = false;
            foriginID.xmlCode = "NONE";
            table.fields.append(foriginID);*/

        }
        else
        {
            table.name = tableName;
            table.xmlCode = xmlCode;
            table.parentTable = parentTable.name;
            table.desc = "Repeat " + tableName + " - Change this description";
            /*
            //Add the key fields of the parent
            for (pos = 0; pos <= parentTable.fields.count()-1;pos++)
            {
                if (parentTable.fields[pos].key == true)
                {
                    TfieldDef parentKeyField;
                    parentKeyField.name = parentTable.fields[pos].name;
                    parentKeyField.desc = parentTable.fields[pos].desc;
                    parentKeyField.key = true;
                    parentKeyField.type = parentTable.fields[pos].type;
                    parentKeyField.size = parentTable.fields[pos].size;
                    parentKeyField.decSize = parentTable.fields[pos].decSize;
                    parentKeyField.rTable = parentTable.name;
                    parentKeyField.rField = parentTable.fields[pos].name;
                    parentKeyField.xmlCode = "NONE";
                    table.fields.append(parentKeyField);
                }
            }*/

            /*TfieldDef KeyField;
            KeyField.name = tableName + "_rowid";
            KeyField.section = "main";
            KeyField.desc = "Unique row ID";
            KeyField.key = true;
            KeyField.type = "int";
            KeyField.size = 3;
            KeyField.decSize = 0;
            KeyField.rTable = "";
            KeyField.rField = "";
            KeyField.xmlCode = "NONE";
            table.fields.append(KeyField);*/

        }
    }



    node = child;
    while (!node.isNull())
    {
        item = node.toElement();
        if ((item.tagName() == "input") || (item.tagName() == "select1") || (item.tagName() == "select"))
        {
            childNode = item.firstChild();
            fieldCode = item.attribute("ref","CodeNotFound!");
            fieldName = getItemLabel(childNode);
            fieldOutput = getItemOutput(childNode);
            if (fieldOutput != "NONE")
            {
                if (getFieldType(fieldOutput) != "Unknown")
                    fieldCode = fieldOutput;
            }

            fieldName = fieldName.replace("\r","");
            fieldName = fieldName.replace("\n","");
            fieldName = fieldName.replace("\t","");
            fieldName = fieldName.replace("'","");
            fieldName = fieldName.replace(";","");

            fieldType = getFieldType(fieldCode);

            fieldXMLCode = fieldCode.replace("/" + surveyID + "/","");

            pos = fieldCode.lastIndexOf("/");
            fieldCode = fieldCode.right(fieldCode.length()-pos-1);

            fieldCode = fieldCode.replace("-","_");
            fieldCode = fieldCode.replace("'","");
            fieldCode = fieldCode.replace(";","");

            //qDebug() << fieldCode;
            //qDebug() << MainField.toLower();


            if (fieldType != "READONLY")
            {
                TfieldDef field;

                field.name = fieldCode;
                field.xmlCode = fieldXMLCode;
                field.section = groupCode;
                field.desc = fieldName;
                //if (fieldCode.toLower() == MainField.toLower())
                //    field.key = true;
                //else
                    field.key = false;

                ftypes = fieldType.split("|",QString::SkipEmptyParts);
                if (ftypes.count() > 1)
                {
                    field.type = ftypes[0];
                    ftsizes =  ftypes[1].split(",",QString::SkipEmptyParts);
                    if (ftsizes.count() > 1)
                    {
                        field.size = ftsizes[0].toInt();
                        field.decSize = ftsizes[1].toInt();
                    }
                    else
                    {
                        field.size = ftsizes[0].toInt();
                        field.decSize = 0;
                    }
                }
                else
                    field.type = fieldType;

                field.rTable = "";
                field.rField = "";
                fieldinmselt = false;

                if (item.tagName() == "select1")
                {
                    if ((isLookUpYesNo(getSelectValues(item)) == false) || ((isLookUpYesNo(getSelectValues(item)) == true) && (ignoreYesNo == false)))
                    {

                        TtableDef lktable;


                        lktable.lkpValues.append(getSelectValues(item));



                        if (areValuesStrings(lktable.lkpValues))
                        {
                            //qDebug() << lktable.name;
                            field.type = "varchar";
                            field.size = getMaxValueLength(lktable.lkpValues);
                            field.decSize = 0;
                        }

                        lktable.name = "lkp" + fieldCode;
                        lktable.desc = "Lookup table [" + fieldName + "]";
                        lktable.pos = -1;
                        lktable.islookup = true;

                        TfieldDef lkpCode;
                        lkpCode.name = fieldCode + "_cod";
                        lkpCode.desc = "Code";
                        lkpCode.key = true;
                        lkpCode.type = field.type;
                        lkpCode.size = field.size;
                        lkpCode.decSize = field.decSize;
                        lktable.fields.append(lkpCode);

                        TfieldDef lkpDesc;
                        lkpDesc.name = fieldCode + "_des";
                        lkpDesc.desc = "Description";
                        lkpDesc.key = false;
                        lkpDesc.type = "varchar";
                        lkpDesc.size = 255;
                        lkpDesc.decSize = 0;
                        lktable.fields.append(lkpDesc);



                        sameTable = isLkpDuplicated(lktable);

                        if (sameTable.isEmpty())
                        {
                            tables.append(lktable);
                            field.rTable = lktable.name;
                            field.rField = fieldCode + "_cod";
                        }
                        else
                        {
                            field.rTable = sameTable;
                            field.rField = getKeyField(sameTable);
                            //qDebug() << lktable.name + " = " + sameTable + ". " + sameTable + " used instead";
                        }
                    }
                }
                if (item.tagName() == "select")
                {

                    //We change the field type to be varchar(255) and add it to the main table so stores values separated by space. The by a separate process we split the values in the child tables.
                    field.type = "varchar";
                    field.size = 255;
                    field.decSize = 0;

                    if (tableName.toLower() != parentTable.name.toLower()) //If we are not processing a group
                        table.fields.append(field);
                    else
                        parentTable.fields.append(field); //If we are processing a group then the field goes to the parent

                    //Then we change it back to a select type
                    field.type = "int";
                    field.size = 9;


                    //*********************Creates a new table to store the multiselect in different rows**************************

                    TtableDef mselTable;
                    if (tableName.toLower() != parentTable.name.toLower()) //If we are not processing a group
                    {
                        mselptable = table.name;
                        tempTable = table;
                    }
                    else
                    {
                        mselptable = parentTable.name;
                        tempTable = parentTable;
                    }

                    mselTable.name =  mselptable + "_msel_" + fieldCode;
                    mselTable.desc = "Table for multiple select of field " + fieldCode;
                    mselTable.islookup = false;
                    tableIndex++;
                    mselTable.pos = tableIndex;
                    mselTable.xmlCode = "NONE";

                    //Move the keys to the multi select table
                    for (pos = 0; pos <= tempTable.fields.count()-1;pos++)
                    {
                        if (tempTable.fields[pos].key == true)
                        {
                            TfieldDef mselKeyField;
                            mselKeyField.name = tempTable.fields[pos].name;
                            mselKeyField.desc = tempTable.fields[pos].desc;
                            mselKeyField.key = true;
                            mselKeyField.type = tempTable.fields[pos].type;
                            mselKeyField.size = tempTable.fields[pos].size;
                            mselKeyField.decSize = tempTable.fields[pos].decSize;
                            mselKeyField.rTable = tempTable.name;
                            mselKeyField.rField = tempTable.fields[pos].name;
                            mselTable.fields.append(mselKeyField);
                        }
                    }

                    //************************* Creates the lookup table *********************************

                    if ((isLookUpYesNo(getSelectValues(item)) == false) || ((isLookUpYesNo(getSelectValues(item)) == true) && (ignoreYesNo == false)))
                    {

                        TtableDef lktable;


                        lktable.lkpValues.append(getSelectValues(item));



                        if (areValuesStrings(lktable.lkpValues))
                        {
                            //qDebug() << lktable.name;
                            field.type = "varchar";
                            field.size = getMaxValueLength(lktable.lkpValues);
                            field.decSize = 0;
                        }

                        lktable.name = "lkp" + fieldCode;
                        lktable.desc = "Lookup table [" + fieldName + "]";
                        lktable.pos = -1;
                        lktable.islookup = true;

                        TfieldDef lkpCode;
                        lkpCode.name = fieldCode + "_cod";
                        lkpCode.desc = "Code";
                        lkpCode.key = true;
                        lkpCode.type = field.type;
                        lkpCode.size = field.size;
                        lkpCode.decSize = field.decSize;
                        lktable.fields.append(lkpCode);

                        TfieldDef lkpDesc;
                        lkpDesc.name = fieldCode + "_des";
                        lkpDesc.desc = "Description";
                        lkpDesc.key = false;
                        lkpDesc.type = "varchar";
                        lkpDesc.size = 255;
                        lkpDesc.decSize = 0;
                        lktable.fields.append(lkpDesc);



                        sameTable = isLkpDuplicated(lktable);

                        if (sameTable.isEmpty())
                        {
                            tables.append(lktable);
                            field.rTable = lktable.name;
                            field.rField = fieldCode + "_cod";
                        }
                        else
                        {
                            field.rTable = sameTable;
                            field.rField = getKeyField(sameTable);
                            //qDebug() << lktable.name + " = " + sameTable + ". " + sameTable + " used instead";
                        }
                    }

                    fieldinmselt = true;
                    field.key = true;
                    mselTable.fields.append(field);
                    tables.append(mselTable);

                }
                if (fieldinmselt == false)
                {
                    if (tableName.toLower() != parentTable.name.toLower()) //If we are not processing a group
                        table.fields.append(field);
                    else
                        parentTable.fields.append(field); //If we are processing a group then the field goes to the parent
                }

            }
        }
        else
        {
            if (item.tagName() == "group")
            {
                grpCode = item.attribute("ref","/GRPNotKnown");
                pos = grpCode.lastIndexOf("/");
                grpCode = grpCode.right(grpCode.length()-pos-1);
                grpCode = grpCode;
                //qDebug() << "Group:" + item.attribute("ref","/GRPNotKnown");
                //qDebug() << "Group table:" + table.name;

                if (!table.name.isEmpty())
                    extractFields(item.firstChild(),table.name,table,grpCode,xmlCode); //Recursive call for group
                else
                    extractFields(item.firstChild(),parentTable.name,parentTable,grpCode,xmlCode); //Recursive call for group
            }
            if (item.tagName() == "repeat")
            {
                childName = item.attribute("nodeset","unknowrepeat");

                repeatXMLCode = childName.replace("/" + surveyID + "/","");

                pos = childName.lastIndexOf("/");
                childName = childName.right(childName.length()-pos-1);
                if (!table.name.isEmpty())
                    extractFields(item.firstChild(),childName,table,"main",repeatXMLCode); //Recursive call for repeat
                else
                    extractFields(item.firstChild(),childName,parentTable,"main",repeatXMLCode); //Recursive call for repeat
            }
        }


        node = node.nextSibling();
    }

    if (tableName.toLower() != parentTable.name.toLower())
    {
        table.pos = tindex;
        table.islookup = false;
        tables.append(table);
    }

}