Beispiel #1
0
    /**
     * Iterate over the attributes of the given PetalNode and for each recognized
     * attribute do the following:
     *   - invoke createListItem()
     *   - fill common properties such as name, unique ID, visibility, etc. into
     *     the new UMLClassifierListItem
     *   - invoke insertAtParent() with the new classifier list item as the argument
     * This is the user entry point.
     */
    void read(const PetalNode *node, const QString& name)
    {
        PetalNode *attributes = node->findAttribute(m_attributeTag).node;
        if (attributes == NULL) {
#ifdef VERBOSE_DEBUGGING
            uDebug() << "read(" << name << "): no " << m_attributeTag << " found";
#endif
            return;
        }
        PetalNode::NameValueList attributeList = attributes->attributes();
        for (int i = 0; i < attributeList.count(); ++i) {
            PetalNode *attNode = attributeList[i].second.node;
            QStringList initialArgs = attNode->initialArgs();
            if (attNode->name() != m_elementName) {
                uDebug() << "read(" << name << "): expecting " << m_elementName
                         << ", " << "found " << initialArgs[0];
                continue;
            }
            UMLObject *item = createListItem();
            if (initialArgs.count() > 1)
                item->setName(clean(initialArgs[1]));
            item->setID(quid(attNode));
            QString quidref = quidu(attNode);
            QString type = clean(attNode->findAttribute(m_itemTypeDesignator).string);
            setTypeReferences(item, quidref, type);
            transferVisibility(attNode, item);
            QString doc = attNode->findAttribute("documentation").string;
            if (! doc.isEmpty())
                item->setDoc(doc);
            insertAtParent(attNode, item);
        }
    }
void MainWindow::fetchListFinished()
{
    ui->loadButton->setEnabled(true);

    QNetworkReply *reply = senderAsReply();
    if (reply == nullptr || reply->error() != QNetworkReply::NoError)
    {
        return;
    }

    QJsonDocument json = jsonFromReply(reply);
    if (!json.isArray())
    {
        logMessage(tr("Error: not array"));
        return;
    }

    QJsonArray arr = json.array();
    for (QJsonValue v : arr)
    {
        QJsonObject task = v.toObject();
        QVariant taskId = task["id"].toVariant();
        QString taskName = task["name"].toString();
        createListItem(taskId, taskName);
    }

    ui->deleteButton->setEnabled(true);
    ui->addButton->setEnabled(true);
}
Beispiel #3
0
/// Function name  : appendChildToXMLTreeNode
// Description     : Append an XML Tree node to a specified node's list of children
// 
// XML_TREE*       pTree   : [in] XML Tree containing the nodes
// XML_TREE_NODE*  pParent : [in] XML Tree Node to be appended
// XML_TREE_NODE*  pChild  : [in] XML Tree Node to append
// 
VOID  appendChildToXMLTreeNode(XML_TREE*  pTree, XML_TREE_NODE*  pParent, XML_TREE_NODE*  pChild)
{
   // Set ListItem + Index
   pChild->pParent = pParent;
   pChild->pItem   = createListItem((LPARAM)pChild);
   pChild->iIndex  = getXMLNodeCount(pParent);  

   // Append
   appendItemToList(&pParent->oChildren, pChild->pItem);

   // Increment tree size
   pTree->iCount++;
}
Beispiel #4
0
// insert new item into the list
int insertListItem(List *list, double value, int i, int j, int isFull, int inserted){
    ListItem *item;
    ListItem *nextItem;
    ListItem *newFirst;
    int searchPlace = 1;
    double v;

    item = list->firstItem;

    // the list is empty
    if(item == NULL){
        list->firstItem = createListItem(value, i, j);
        lastBest = value;
        inserted--;
        return inserted;
    }

    // this listItem should be the first?
    if(value < item->value){
        newFirst = createListItem(value, i, j);
        newFirst->nextItem = item;
        list->firstItem = newFirst;
         if(isFull){
            removeLastItem(list->firstItem);
        }
        inserted--;
        return inserted;
    }

    /* search the right place */
    while(searchPlace){
        // insert in the same list item
        v = item->value;

        if(item->value == value){
             insertValues(item, i, j);
             return inserted;
        }
        nextItem = item->nextItem;

        // there is no next item
        if(nextItem == NULL){
            item->nextItem = createListItem(value, i, j);
            lastBest = value;
            inserted--;
            return inserted;
        }
        // should we add a new list item between two existing items?
        if(nextItem->value > value){
            item->nextItem = createListItem(value, i, j);
            item->nextItem->nextItem = nextItem;
            if(isFull){
                removeLastItem(list->firstItem);
            }
            inserted--;
            return inserted;
        }
        item = item->nextItem;
    }
    return 0;
}
void MainWindow::on_addButton_clicked()
{
    QListWidget *list = ui->taskList;
    QListWidgetItem *item = createListItem(QVariant(), tr("New Task"));
    list->editItem(item);
}