Exemple #1
0
bool Sequence::operator==(const Sequence& that) const {
    if (this->length() != that.length())
        return false;
    auto this_it = this->cbegin(),
         that_it = that.cbegin();
    while (this_it != this->cend() && that_it != that.cend()) {
        if (*this_it != *that_it)
            return false;
        ++this_it;
        ++that_it;
    }
    return true;
}
Exemple #2
0
QString KeyLogger::sequenceString(const Sequence & sequence)
{
    QStringList keys;

    std::vector<int> keyList(sequence.cbegin(), sequence.cend());
    std::sort(keyList.begin(), keyList.end(), std::greater<int>());

    for(int keyCode : keyList)
    {
        auto stringFound = KEY_STRING_MAP.find(keyCode);

        keys << (stringFound != KEY_STRING_MAP.end() ? 
                 stringFound->second :
                 KEY_TO_STRING(keyCode));
    }

    return keys.join(" + ");
}