当前位置: 首页>>代码示例>>C++>>正文


C++ WordList::values方法代码示例

本文整理汇总了C++中WordList::values方法的典型用法代码示例。如果您正苦于以下问题:C++ WordList::values方法的具体用法?C++ WordList::values怎么用?C++ WordList::values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WordList的用法示例。


在下文中一共展示了WordList::values方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addMisspelledWords

void SpellCheckerCore::addMisspelledWords(const QString &fileName, const WordList &words)
{
    d->spellingMistakesModel->insertSpellingMistakes(fileName, words, d->filesInStartupProject.contains(fileName));
    if(d->currentFilePath == fileName) {
        d->mistakesModel->setCurrentSpellingMistakes(words);
    }

    /* Only apply the underlines to the current file. This is done so that if the
     * whole project is scanned, it does not add selections to pages that might
     * potentially never be opened. This can especially be a problem in large
     * projects.
     */
    if(d->currentFilePath != fileName) {
        return;
    }
    TextEditor::BaseTextEditor* baseEditor = qobject_cast<TextEditor::BaseTextEditor*>(d->currentEditor);
    if(baseEditor == NULL) {
        return;
    }
    TextEditor::TextEditorWidget* editorWidget = baseEditor->editorWidget();
    if(editorWidget == NULL) {
        return;
    }
    QList<QTextEdit::ExtraSelection> selections;
    foreach(const Word& word, words.values()) {
        QTextCursor cursor(editorWidget->document());
        /* Walk to the correct position using the line and column number since the
         * absolute position is not available and I do not know of a way to get/
         * calculate the absolute position from that information.
         *
         * One would think that the position from the CppDocumentParser::tokenizeWords()
         * function can be used if stored in the Word, but it is not the correct position. */
        cursor.setPosition(0);
        cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, word.lineNumber - 1);
        cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, word.columnNumber - 1);
        cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, word.length);

        /* Get the current format from the cursor, this is to make sure that the text font
         * and color stays the same, we just want to underline the mistake. */
        QTextCharFormat format = cursor.charFormat();
        format.setFontUnderline(true);
        format.setUnderlineColor(QColor(Qt::red));
        format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
        format.setToolTip(word.suggestions.isEmpty() ? QLatin1String("Incorrect spelling")
                                                     : QString(QLatin1String("Incorrect spelling, did you mean '%1' ?")).arg(word.suggestions.first()));
        QTextEdit::ExtraSelection selection;
        selection.cursor = cursor;
        selection.format = format;
        selections.append(selection);
    }
    editorWidget->setExtraSelections(Core::Id(SpellChecker::Constants::SPELLCHECK_MISTAKE_ID), selections);

    /* The model updated, check if the word under the cursor is now a mistake
     * and notify the rest of the checker with this information. */
    Word word;
    bool wordIsMisspelled = isWordUnderCursorMistake(word);
    emit wordUnderCursorMistake(wordIsMisspelled, word);
}
开发者ID:Typz,项目名称:SpellChecker-Plugin,代码行数:58,代码来源:spellcheckercore.cpp


注:本文中的WordList::values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。