void ChatView::checkWord(QTextCursor &cursor, QString &message)
{
    // extract the first word
    QString rest;
    QString fullWordUpToSpaceOrEnd = extractNextWord(message, rest);

    // check urls
    if (fullWordUpToSpaceOrEnd.startsWith("http://", Qt::CaseInsensitive) ||
        fullWordUpToSpaceOrEnd.startsWith("https://", Qt::CaseInsensitive) ||
        fullWordUpToSpaceOrEnd.startsWith("www.", Qt::CaseInsensitive))
    {
        QUrl qUrl(fullWordUpToSpaceOrEnd);
        if (qUrl.isValid())
        {
            appendUrlTag(cursor, fullWordUpToSpaceOrEnd);
            cursor.insertText(rest, defaultFormat);
            return;
        }
    }

    // check word mentions
    foreach (QString word, highlightedWords)
    {
        if (fullWordUpToSpaceOrEnd.compare(word, Qt::CaseInsensitive) == 0)
        {
            // You have received a valid mention of custom word!!
            highlightFormat.setBackground(QBrush(getCustomHighlightColor()));
            highlightFormat.setForeground(settingsCache->getChatHighlightForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
            cursor.insertText(fullWordUpToSpaceOrEnd, highlightFormat);
            cursor.insertText(rest, defaultFormat);
            QApplication::alert(this);
            return;
        }
    }

    // not a special word; just print it
    cursor.insertText(fullWordUpToSpaceOrEnd + rest, defaultFormat);
}
Beispiel #2
0
            if (file.bad()) {
                LOG(logERROR) << "Incorrect format in " <<
                    m_path << ":" << line_number;
                throw CorruptObjFileException();
            }

            if (definition == "v") { // Position.
                addPosition(v1, v2, v3);

            } else if (definition == "vn") { // Normal
                addNormal(v1, v2, v3);

            }

        } else if (definition == "mtllib") {
            string mtllib_name = extractNextWord(file);
            loadMaterials(mtllib_name);

        } else if (definition == "usemtl") {
            string mtl_name = extractNextWord(file);
            try {
                current_mtl = m_mtl_table.at(mtl_name);
            } catch (std::out_of_range) {
                LOG(logERROR) << "Unknown material in " <<
                m_path << ":" << line_number;
                throw CorruptObjFileException();
            }

        } else if (definition == "f") { // Triangle.
            // position, normal, texcoord.
            GLuint p1, t1, n1;