Exemplo n.º 1
0
QList<CatItem> Catalog::indexItemList(QList<CatItem>* catListPtr){
    Q_ASSERT(catListPtr);
    QList<CatItem> outList;
    cat_store.beginAddGroup();
    for(int i=0;i< catListPtr->count();i++){
        CatItem it = (*catListPtr)[i];
        if(it.isEmpty()){
            continue;
        }
        if(it.isForDBInsertOnly()){
            cat_store.addItemInGroup(it);
            continue;
        } else if(it.getIsTempItem()){
            outList.append((it));
        } else {
            outList.append(cat_store.addItemInGroup(it));
        }
        //THREAD_SLEEP;
    }
    cat_store.endAddGroup();
    return outList;
}
Exemplo n.º 2
0
QList<CatItem> Catalog::expandStubs(QString userKeys, QList<CatItem>* inList){

    QList<CatItem> stubs; QList<CatItem> oldStubs;
    QList<CatItem>* workingList = inList;
    QList<CatItem> res;
    bool refreshNeeded =false;
    int rep=0;

    QSet<QString> updated;
    while((workingList->length()>0)) {
        cat_store.beginAddGroup();
        for(int i=0; i<workingList->count();i++){
            CatItem toAdd = workingList->at(i);
            bool atStub = toAdd.isStub();
            if(plugins.itemLoading(&toAdd, UserEvent::BECOMING_VISIBLE)){
                if(toAdd.isForDelete()) {
                    cat_store.removeItem(workingList->at(i));
                    continue;
                }
                if(atStub) {
                    refreshNeeded = true;
                    //toAdd.setStub(false);
                    cat_store.addItemInGroup(toAdd);
                }
            }
            QList<CatItem> newStubs = extractStubs(toAdd);
            for(int j=0; j<newStubs.count(); j++){
                if(!updated.contains(newStubs[j].getPath())){
                    updated.insert(newStubs[j].getPath());
                    stubs.append(newStubs[j]);
                }
            }
        }
        oldStubs = stubs;
        workingList = &oldStubs;
        cat_store.endAddGroup();
        stubs.clear();
        Q_ASSERT(workingList->count() <1000);
        rep++;
        Q_ASSERT(rep<10);
    }

    cat_store.beginAddGroup();
    for(int i=0; i<inList->count();i++){
        CatItem toAdd = inList->at(i);
        if(toAdd.isForDBInsertOnly()){
            cat_store.addItemInGroup(toAdd);
            continue;
        }
        if(userKeys.isEmpty() || matches(&toAdd, userKeys) || toAdd.getTakesAnykeys()) {
            if(refreshNeeded){
                CatItem refreshed = cat_store.getItemByPath(toAdd.getPath());
                if(!refreshed.isEmpty()){
                    toAdd.mergeItem(refreshed,true);
                }
                toAdd.setMatchIndex(QList<int>());
            }
            if(!toAdd.hasLabel(BUILTIN))
                { res.append(toAdd);}
        }}
    cat_store.endAddGroup();
    return res;
}