예제 #1
2
파일: lister.cpp 프로젝트: liesen/quackle
void NumAnagramsFilter::apply()
{
    int numTwlAnagrams = m_twlAnagramsSpinner->value();
    int numOswOnlyAnagrams = m_oswOnlyAnagramsSpinner->value();

    Dict::WordList filteredList;

    QMap<QString, Dict::WordList> map(m_dialog->anagramMap());

    Dict::WordList::Iterator end = m_dialog->wordList().end();
    for (Dict::WordList::Iterator it = m_dialog->wordList().begin(); it != end; ++it)
    {
        int twl = 0;
        int british = 0;
        int playability = 0;
        QString alphagram(QuackleIO::DictFactory::querier()->alphagram((*it).word));

        for (Dict::WordList::Iterator word = map[alphagram].begin(); word != map[alphagram].end(); ++word)
        {
            if ((*word).british)
                british++;
            else
                twl++;

            playability += (*word).playability;
        }

        if ((twl == numTwlAnagrams) && (british == numOswOnlyAnagrams))
            filteredList.append(*it);
    }

    m_dialog->setWordList(filteredList);
}
예제 #2
0
파일: lister.cpp 프로젝트: liesen/quackle
void PlayabilityFilter::apply()
{
    int minimumRank = m_minRankSpinner->value();
    int maximumRank = m_maxRankSpinner->value();
    if (maximumRank == 0)
        maximumRank = INT_MAX;

    const bool useProb = m_dialog->flags() & ListerDialog::ProbabilityInsteadOfPlayability;

    QMap<QString, Dict::WordList> map(m_dialog->anagramMap());

    Dict::WordList intermediateList;

    QMap<QString, Dict::WordList>::Iterator end = map.end();
    for (QMap<QString, Dict::WordList>::Iterator it = map.begin(); it != end; ++it)
    {
        Dict::Word newEntry;
        newEntry.word = it.key();

        for (Dict::WordList::Iterator extIt = it.value().begin(); extIt != it.value().end(); ++extIt)
        {
            if (useProb)
                newEntry.probability += (*extIt).probability;
            else
                newEntry.playability += (*extIt).playability;
        }

        intermediateList.append(newEntry);
    }

    int index = 0;

    if (useProb)
        intermediateList.setSortBy(Dict::WordList::Probability);
    else
        intermediateList.setSortBy(Dict::WordList::Playability);
    qSort(intermediateList);

    Dict::WordList filteredList;

    Dict::WordList::Iterator intermediateEnd = intermediateList.end();
    for (Dict::WordList::Iterator it = intermediateList.begin(); it != intermediateEnd; ++it)
    {
        ++index;

        if (index > maximumRank)
            break;

        if (index < minimumRank)
            continue;

        filteredList += map[(*it).word];
    }

    m_dialog->setWordList(filteredList);
}
예제 #3
0
파일: lister.cpp 프로젝트: liesen/quackle
void KeepBritishFilter::apply()
{
    Dict::WordList filteredList;
    const Dict::WordList &list = m_dialog->wordList();;
    Dict::WordList::ConstIterator end = list.end();

    for (Dict::WordList::ConstIterator it = list.begin(); it != end; ++it)
        if ((*it).british)
            filteredList.append(*it);

    m_dialog->setWordList(filteredList);
}
예제 #4
0
파일: lister.cpp 프로젝트: liesen/quackle
void RegexFilter::apply()
{
    QRegExp regexp(m_lineEdit->text());
    regexp.setCaseSensitivity(Qt::CaseInsensitive);

    Dict::WordList filteredList;
    const Dict::WordList &list = m_dialog->wordList();;
    Dict::WordList::ConstIterator end = list.end();

    for (Dict::WordList::ConstIterator it = list.begin(); it != end; ++it)
        if (regexp.indexIn((*it).word) >= 0)
            filteredList.append(*it);

    m_dialog->setWordList(filteredList);
}
예제 #5
0
파일: lister.cpp 프로젝트: liesen/quackle
void ListerDialog::setRemoveSowpods(bool removeSowpods)
{
    if (!removeSowpods)
        return;

    Dict::WordList filteredWords;

    Dict::WordList::Iterator end = m_wordList.end();
    for (Dict::WordList::Iterator it = m_wordList.begin(); it != end; ++it)
    {
        if (!(*it).british)
            filteredWords.append((*it));
    }

    m_wordList = filteredWords;
    populateListBox();
}