Exemplo n.º 1
0
QString summarizeMessage(CatItem it){
    QString res;

    if(it.hasLabel(NAME_IS_TITLE_KEY_STR)){
        res+= it.getName() + " ";
    }

    if(it.hasLabel(AUTHOR_KEY_STR)){
        res+= QString("<br>") + FROM_PERSON__PHRASE + it.getAuthor();
    }

    if(!it.getDescription().isEmpty()){
        res+=it.getDescription();
    } else if(!it.getLongText().isEmpty()){
        res+=it.getLongText().left(UI_MAX_MESSAGE_DESCRIPTION_LEN);
    }

    if(it.hasLabel(TIME_EXPLICITELY_SET_KEY_STR)){
        res+="(";
        time_t tm = (MAX(it.getCreationTime(), it.getModificationTime()));
        QDateTime t;
        t.fromTime_t(tm);
        res+= contextualTimeString(t);
        res+=")";
    }

    return res;
}
Exemplo n.º 2
0
void testpluginPlugin::extendCatalog(SearchInfo* , QList<CatItem>* r)
{
    r=r;
#ifdef TEST_GUI
    qDebug() << "testpluginPlugin::extendCatalog";
    QList <CatItem> in_list = *(info->itemListPtr);
    QString extend_suffix = "/extended/";
    CatItem me(itemPath);

    for(int i=0;i< in_list.count();i++){
        if(in_list[i].getPath().right(extend_suffix.length()) !=extend_suffix){
            CatItem e = in_list[i];
            CatItem f(e.getPath() + extend_suffix, e.getName() + extend_suffix);
            f.setExternalWeight(0,me);
            r->append(f);
        }
    }
#endif

}
Exemplo n.º 3
0
ItemRep::ItemRep(CatItem it, Tuple internalId, int change_count,
                 short nthPiece, bool nameFromDescript){
    Q_ASSERT(!it.isEmpty());
    matchType = it.getMatchType();
    matchIndex = it.getMatchIndex();
    //description = it.fullDescription;
    m_internalId = internalId;
    m_name = it.getName();
    Q_ASSERT(!m_name.isEmpty());
    //Q_ASSERT(it.getFullWeight());
    totalWeight = it.getFullWeight();
    change_cn = change_count;
    l_to_match = -1;
    skip_m = false;
    this->itemType = it.getItemType();

    //change_cn = 0;

    m_nthPiece= nthPiece;
    m_name_from_description=nameFromDescript;

}
Exemplo n.º 4
0
void TrieNode::insertFull(CatItem it, QList<int> kl,
                           int charChanges,Tuple tpl  )
{
    if(!it.hasRealName()){ return;}

    if(tpl.isEmpty())
        {tpl = mp_container->getInternalId(it); }

    ItemRep ir(it, tpl, charChanges);
    if(kl.length() > 0)
        {ir.setMatchKeyList(kl);}
    insertRep(ir);

    if(it.getName().contains(" ")){
        QList<QString> descriptionWords = it.getDescription().split(' ');
        for(int i=0; i<MIN(descriptionWords.length(),MAX_WORDS_IN_KEY_SEARCH); i++){
            if(!descriptionWords[i].isEmpty() && descriptionWords[i].count()>5){
                addItemPiece(it,tpl,descriptionWords[i],i, false);
            }
        }
    }
}
Exemplo n.º 5
0
bool TrieNode::breadthSearch(QHash<qint32,CatItem>& alreadyFound, QString matchString,
                    int desired, int depth, int digDepth, int skipDepth, ItemFilter* filter){


    bool worthLookingFurther = (digDepth >0);
    if(skipDepth<=0){
        worthLookingFurther = true;

        QLinkedList<ItemRep>::iterator i = m_bestItems.begin();
        for(;i != m_bestItems.end();i++){

            //This step optimizes - skip what you know is wrong before paying for a full check
            QList<int> outIndex;
            CatItem it_approx((*i).getName(),(*i).getName());
            if(!matchString.isEmpty() && !userkey_match(it_approx,matchString, &outIndex))
                { continue; }

            CatItem::ItemType mt = (*i).getItemType();
            if(!CatItem::matchOrganizingTypes(filter->getOrganizeingType(),mt))
                {continue;}

            //Now the "real" matching
            CatItem it = mp_container->getByInternalIdProtectMe((*i).getInternalId());
            outIndex.clear();

            //We want to allow names that are parts of the main name...
            if(!matchString.isEmpty() && !userkey_match(it,matchString, &outIndex)){
                if(matchString.length() < MIN_SUBSTR_MATCH_LEN)
                    { continue; }
                if(!it.getName().contains(matchString))
                    { continue; }
            }

            if (!filter || filter->acceptItem(&(it) )){
                worthLookingFurther =true;
                if(outIndex.length() > 0){
                    it.setMatchIndex(outIndex);
                }
                //it.setMatchIndex((*i).getMatchIndex());
                alreadyFound[it.getItemId()] = it;
            }
            if(alreadyFound.count() > desired){ return false; }
        }
    }


    if(depth<=0){ return true; }

    if(worthLookingFurther || matchString.length() <=BROAD_KEYSEARCH_MAXLEN ||
       (skipDepth) > 0) {
        for(int i=0;i < m_entries.count();i++){
            if(!m_entries[i]){continue;}
            m_entries[i]->breadthSearch(alreadyFound, matchString, desired, depth-1,
                                      digDepth-1,
                                      skipDepth-1, filter);
            if(alreadyFound.count() > desired){ return false; }
        }
    }

    return worthLookingFurther;
}