Exemplo n.º 1
0
QList<CatItem> Catalog::extractStubs(CatItem& it){
    QList<CatItem> res;
    QList<CatItem> items = it.getParents();
    it.setChildStubbed(false);
    items.append(it.getChildren());
    for(int i=0; i<items.count();i++){
        if(items[i].isStub()){
            res.append(items[i]);
        }
    }
    return res;
}
Exemplo n.º 2
0
QList<CatItem> Catalog::parseRequest(InputList & inputData, int itemsDesired, int* beginPos){


    if(inputData.customVerbChosen() && !inputData.isOperationChosen()){
        return cat_store.getItemsByKey(inputData.getUserKeys(), &inputData, itemsDesired);
    }
    if(inputData.isOperationChosen()){
        return getOperationChildren(inputData);
    }

    if(!inputData.getParentItem().isEmpty() ){
        if(inputData.getParentItem().canFilterWith()){
            return cat_store.getAssociatedDocuments(&inputData, inputData.getParentItem(), itemsDesired);
        } else {
            CatItem par = cat_store.getItemByPath(inputData.getParentItem().getPath(),1);
            CatBuilder::updateItem(par,2,UserEvent::SELECTED);
            return par.getChildren();
        }
    }

    QList<CatItem> res;
    if(inputData.getUserKeys().length() >0){
        QString userKeys = inputData.getUserKeys();
        res.append(cat_store.getItemsByKey(userKeys, &inputData, itemsDesired, beginPos));
    } else if(inputData.slotCount() ==1 || inputData.isOperationChosen()){
        res.append(cat_store.getInitialItems(&inputData, itemsDesired, beginPos));
    }
    if(res.count()>0 && beginPos){ (*beginPos)++; }


    if(inputData.slotCount()>1 ){
        QList<CatItem> extra_actions;
        if(inputData.isCustomVerbChoosableByArgSig())
            { extra_actions = parseCustomVerbSelection(inputData); }

        QList<CatItem> operations = getOperations(inputData);

        if(extra_actions.count() > MAX_SEPERATE_VERBS){
            res.push_front(
                    CatItem::createTempfolder(EXTRA_ACTIONS_PSUEDO_FOLD_NAME, extra_actions));
        } else
            { res.append(extra_actions); }
        res.append(operations);


        //At "bare" verb - possibly w/ operation
        if(inputData.verbPosition() ==0){
            if(inputData.hasVerb() && !inputData.customVerbChosen() && inputData.nounList().length()==0){
                res.push_front(CatItem::createRunPseudoItem());
            }
            res.append(cat_store.getAssociatedDocuments(&inputData, inputData.getFilterItem(), itemsDesired));
        }
        if(inputData.atPossibleVerbSlot()){
            inputData.setDefaultVerbIfNeeded();
            CatItem defVerb = inputData.getItemDefaultVerb();
            if(!defVerb.isEmpty()) { res.append(defVerb); }

            QList<CatItem> associations = inputData.getNormalAssociation();
            CatItem defaultVerb = inputData.getItemDefaultVerb();
            if(!defaultVerb.isEmpty())
                { res.append(defaultVerb); }
            if(associations.count() > MAX_SEPERATE_VERBS){
                res.push_front(
                        CatItem::createTempfolder(ASSOCIATED_APPS_PSUEDO_FOLD_NAME, associations));
            } else
                { res.append(associations); }
        }
    }

    CatItem curArg = inputData.argChosenType();
    if(!curArg.isEmpty())
        { res.append(cat_store.getItemChildren(&inputData, curArg)); }
    qDebug() << res.count() << " items found";

    return res;
}