예제 #1
0
/* Find all important data nodes in
 * this individual's GEDCOM sub-tree
 * @n = Individual's first child node
 */
void GIndiEntry::parseIndiData(GNode * n) {
    while (n) {
        // Name
        if (!_nameNode && n->type() == TYPE_NAME) {
            parseNames(n);
        }
        // Sex
        else if (!_sexNode && n->type() == TYPE_SEX) {
            _sexNode = n;
        }
        // Birth
        else if (!_birthDateNode && n->type() == TYPE_BIRTH) {
            parseBirth(n);
        }
        // Death
        else if (!_deathDateNode && n->type() == TYPE_DEATH) {
            parseDeath(n);
        }
        // Family (Child)
        else if (n->type() == TYPE_FAMC) {
            // Check adoption status
            GNode * m = n->firstChild();
            bool isAdoptiveFam = false;
            // Check other properties under family
            while (m) {
                if (m->type() == TYPE_PEDI && m->data() == PROP_ADOPTED) {
                    isAdoptiveFam = true;
                    break;
                }
                m = m->next();
            }
            // Prefer natural family in the family tree
            if (!_famcNode || !isAdoptiveFam) {
                _famcNode = n;
                _adopted = isAdoptiveFam;
            }
        }
        // Family (Parent)
        else if (n->type() == TYPE_FAMS) {
            // First marriage
            if (!_famsNode) {
                _famsNode = n;
            }
            // Second marriage
            else if (!_marriages) {
                _marriages = new QStringList();
                _marriages->append(_famsNode->data());
                _marriages->append(n->data());
            }
            // Third, fourth, ...
            else {
                _marriages->append(n->data());
            }
        }
        n = n->next();
    }
}
예제 #2
0
/* Set a new value for the romanized name
 * string value in the GNode data tree, and
 * create a node in the tree if needed.
 */
void GIndiEntry::setRomanizedName(const QString & romanName) {
    // Append a new node to the tree if needed
    if (!_romanNode) {
        // Create the new node
        _romanNode = new GNode("2 ROMN " + romanName);
        // Append it to the end of _nameNode's children
        GNode * n = _nameNode->firstChild();
        if (!n) { // No existing first child
            _nameNode->setFirstChild(_romanNode);
        }
        else { // Pre-existing sub-list
            // Go to the end of the sub-list
            while (n->next()) n = n->next();
            // Append the new node there
            n->setNext(_romanNode);
        }
    }
    // Alter the existing node if needed
    else {
        _romanNode->setData(romanName);
    }
}