本文整理汇总了C++中QTextCursor::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextCursor::isNull方法的具体用法?C++ QTextCursor::isNull怎么用?C++ QTextCursor::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextCursor
的用法示例。
在下文中一共展示了QTextCursor::isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
QList<PreTeXFileType::AutocompletionItem> PreTeXFileType::createAutocompletionItemList(
BAbstractCodeEditorDocument *doc, QTextCursor cursor)
{
QList<AutocompletionItem> list;
if (!doc || cursor.isNull())
return list;
cursor.select(QTextCursor::WordUnderCursor);
if (!cursor.hasSelection())
return list;
QString word = cursor.selectedText();
list << builtinFunctionAutocompletionItemListForWord(word);
return list;
}
示例2: find
bool FindDialog::find() {
QTextEdit* textEdit = getCurrentTextEdit();
if (textEdit == NULL) return false;
int from = textEdit->textCursor().selectionEnd();
QTextCursor cursor = textEdit->document()->find(ui->findString->text(), from);
if (!cursor.isNull()) {
textEdit->setTextCursor(cursor);
return true;
}
else {
return false;
}
}
示例3: mouseMoveEvent
void LineIndicator::mouseMoveEvent( QMouseEvent *e )
{
QTextCursor cursor = mEditor->cursorForPosition(QPoint(0, e->pos().y()));
if(cursor.isNull() || cursor.position() == mLastCursorPos)
return;
QTextCursor origCursor = mEditor->textCursor();
origCursor.setPosition( cursor.position(), QTextCursor::KeepAnchor );
mEditor->setTextCursor(origCursor);
mLastCursorPos = cursor.position();
// The selectionChanged() signal of the editor does not always fire here!
// Qt bug?
update();
}
示例4: insertCustomer
void MainWindow::insertCustomer(const QString &customer){
if (customer.isEmpty())
return;
QStringList customerList = customer.split(", ");
QTextDocument *document = chatbox->document();
QTextCursor cursor = document->find("NAME");
if (!cursor.isNull()) {
cursor.beginEditBlock();
cursor.insertText(customerList.at(0));
QTextCursor oldcursor = cursor;
cursor = document->find("ADDRESS");
if (!cursor.isNull()) {
for (int i = 1; i < customerList.size(); ++i) {
cursor.insertBlock();
cursor.insertText(customerList.at(i));
}
cursor.endEditBlock();
}
else
oldcursor.endEditBlock();
}
}
示例5: findHelper
void FindEditor::findHelper(FindOption *opt)
{
bool bFocus = m_findEdit->hasFocus();
LiteApi::IEditor *editor = m_liteApp->editorManager()->currentEditor();
if (!editor) {
return;
}
LiteApi::ITextEditor *textEditor = LiteApi::getTextEditor(editor);
QTextCursor find;
if (textEditor) {
QPlainTextEdit *ed = LiteApi::getPlainTextEdit(editor);
if (ed) {
find = findEditor(ed->document(),ed->textCursor(),opt);
if (!find.isNull()) {
ed->setTextCursor(find);
}
}
} else {
QTextBrowser *ed = LiteApi::findExtensionObject<QTextBrowser*>(editor,"LiteApi.QTextBrowser");
if (ed) {
find = findEditor(ed->document(),ed->textCursor(),opt);
if (!find.isNull()) {
ed->setTextCursor(find);
}
}
}
if (find.isNull()) {
m_status->setText(tr("Not find"));
} else {
m_status->setText(QString("Ln:%1 Col:%2").
arg(find.blockNumber()+1).
arg(find.columnNumber()+1));
}
if (bFocus) {
m_findEdit->setFocus();
} else if (textEditor) {
textEditor->onActive();
}
}
示例6: Replace
//
// Replace text if doreplace is true, otherwise only do "find next"
// Returns true if the find next failed (end of document)
//
bool MibEditor::Replace(bool doreplace)
{
QTextCursor tc;
ff = 0;
find_string = replace_uid.comboFind->currentText();
if (!find_strings.contains(find_string))
find_strings.append(find_string);
replace_string = replace_uid.comboReplace->currentText();
if (!replace_strings.contains(replace_string))
replace_strings.append(replace_string);
if (replace_uid.checkWords->isChecked())
ff |= QTextDocument::FindWholeWords;
if (replace_uid.checkCase->isChecked())
ff |= QTextDocument::FindCaseSensitively;
if (replace_uid.checkBackward->isChecked())
ff |= QTextDocument::FindBackward;
tc = s->MainUI()->MIBFile->textCursor();
if(doreplace && !tc.isNull() && tc.hasSelection() &&
(tc.selectedText().compare(find_string,
(replace_uid.checkCase->isChecked()?
Qt::CaseSensitive:Qt::CaseInsensitive))==0))
tc.insertText(replace_uid.comboReplace->currentText());
tc = s->MainUI()->MIBFile->document()->find(find_string,
s->MainUI()->MIBFile->textCursor(),
ff);
if (!tc.isNull())
{
s->MainUI()->MIBFile->setTextCursor(tc);
tc.select(QTextCursor::WordUnderCursor);
}
return (tc.isNull()?true:false);
}
示例7: findOnce
bool ConsoleWriter::findOnce(QString find, bool regex, int options) {
QTextCursor cursor = textCursor();
QTextDocument::FindFlag opts = (QTextDocument::FindFlag)options;
if (regex) cursor = document()->find(QRegExp(find), cursor, opts);
else cursor = document()->find(find, cursor, opts);
if (!cursor.isNull()) {
setTextCursor(cursor);
return true;
}
return false;
}
示例8: insert
void QTextDocumentFragmentPrivate::insert(QTextCursor &_cursor) const
{
if (_cursor.isNull())
return;
QTextDocumentPrivate *destPieceTable = _cursor.d->priv;
destPieceTable->beginEditBlock();
QTextCursor sourceCursor(doc);
sourceCursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
QTextCopyHelper(sourceCursor, _cursor, importedFromPlainText, _cursor.charFormat()).copy();
destPieceTable->endEditBlock();
}
示例9: mouseDoubleClickEvent
void ScCodeEditor::mouseDoubleClickEvent( QMouseEvent * e )
{
if (e->button() == Qt::LeftButton) {
QTextCursor cursor = cursorForPosition(e->pos());
QTextCursor selection = selectionForPosition( cursor.position() );
if (!selection.isNull()) {
mMouseBracketMatch = true;
setTextCursor(selection);
return;
}
}
GenericCodeEditor::mouseDoubleClickEvent(e);
}
示例10: addParagraph
void MainWindow::addParagraph(const QString ¶graph){
if (paragraph.isEmpty())
return;
QTextDocument *document = chatbox->document();
QTextCursor cursor = document->find(tr("Yours sincerely,"));
if (cursor.isNull())
return;
cursor.beginEditBlock();
cursor.movePosition(QTextCursor::PreviousBlock, QTextCursor::MoveAnchor, 2);
cursor.insertBlock();
cursor.insertText(paragraph);
cursor.insertBlock();
cursor.endEditBlock();
}
示例11: mouseDoubleClickEvent
void ScCodeEditor::mouseDoubleClickEvent( QMouseEvent * e )
{
// Always pass to superclass so as to handle line selection on triple click
GenericCodeEditor::mouseDoubleClickEvent(e);
if (e->button() == Qt::LeftButton) {
QTextCursor cursor = cursorForPosition(e->pos());
QTextCursor selection = selectionForPosition( cursor.position() );
if (!selection.isNull()) {
mMouseBracketMatch = true;
setTextCursor(selection);
return;
}
}
}
示例12: replace
QTextCursor FindDialog::replace(const QTextCursor &start, QTextDocument *doc, int startPos, int endPos) {
QTextCursor result = find(start, doc);
if (!result.isNull()) {
if ((endPos > 0 && result.selectionEnd() > endPos) ||
(startPos > 0 && result.selectionStart() < startPos)) {
result = QTextCursor(); // null cursor
} else {
result.removeSelectedText();
result.insertText(getReplaceString());
//result.setPosition(result.position() + getReplaceString().length());
}
}
return result;
}
示例13: selectText
void Text::selectText(QTextCursor& cursor, const std::pair<int, int>& point)
{
if (!cursor.isNull()) {
cursor.beginEditBlock();
cursor.setPosition(point.first);
cursor.setPosition(point.first + point.second, QTextCursor::KeepAnchor);
cursor.endEditBlock();
QTextCharFormat format;
format.setBackground(QBrush(QColor(COLOR_HIGHLIGHT)));
cursor.mergeCharFormat(format);
regenerate();
update();
}
}
示例14: gotoLastResult
void PlainTextViewWidget::gotoLastResult()
{
if (m_searchResults.isEmpty()) {
return;
}
QTextCursor cursor = m_searchResults.last();
if (cursor == m_currentSearchResult) {
return;
}
m_currentSearchResult = cursor;
if (!cursor.isNull()) {
jumpToHighlightResult(cursor);
}
}
示例15: findEditor
QTextCursor FindEditor::findEditor(QTextDocument *doc, const QTextCursor &cursor, FindOption *opt, bool wrap)
{
QTextDocument::FindFlags flags = 0;
if (opt->backWard) {
flags |= QTextDocument::FindBackward;
}
if (opt->matchCase) {
flags |= QTextDocument::FindCaseSensitively;
}
if (opt->matchWord) {
flags |= QTextDocument::FindWholeWords;
}
Qt::CaseSensitivity cs = Qt::CaseInsensitive;
if (opt->matchCase) {
cs = Qt::CaseSensitive;
}
int from = cursor.position();
if (cursor.hasSelection()) {
if (opt->backWard) {
from = cursor.selectionStart();
} else {
from = cursor.selectionEnd();
}
}
QTextCursor find;
if (opt->useRegexp) {
find = doc->find(QRegExp(opt->findText,cs),from,flags);
} else {
find = doc->find(opt->findText,from,flags);
}
if (find.isNull() && opt->wrapAround && wrap) {
if (opt->backWard) {
from = doc->lastBlock().position()+doc->lastBlock().length();
} else {
from = 0;
}
if (opt->useRegexp) {
find = doc->find(QRegExp(opt->findText,cs),from,flags);
} else {
find = doc->find(opt->findText,from,flags);
}
}
return find;
}