本文整理汇总了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);
}