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


C++ QTextCursor::isNull方法代码示例

本文整理汇总了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;
}
开发者ID:ololoepepe,项目名称:TeX-Creator,代码行数:13,代码来源:pretexfiletype.cpp

示例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;
    }
}
开发者ID:furaga,项目名称:CPUExSolver,代码行数:13,代码来源:finddialog.cpp

示例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();
}
开发者ID:DSastre,项目名称:supercollider,代码行数:13,代码来源:line_indicator.cpp

示例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();
    }
}
开发者ID:ChaoticConundrum,项目名称:yaptlytoti,代码行数:22,代码来源:mainwindow.cpp

示例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();
    }
}
开发者ID:hfeeki,项目名称:liteide,代码行数:39,代码来源:findeditor.cpp

示例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);
}
开发者ID:vertexclique,项目名称:travertine,代码行数:42,代码来源:mibeditor.cpp

示例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;
}
开发者ID:aton0511,项目名称:CAMotics,代码行数:14,代码来源:ConsoleWriter.cpp

示例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();
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:14,代码来源:qtextdocumentfragment.cpp

示例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);
}
开发者ID:vanhuman,项目名称:supercollider-rvh,代码行数:15,代码来源:sc_editor.cpp

示例10: addParagraph

void MainWindow::addParagraph(const QString &paragraph){
    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();

}
开发者ID:ChaoticConundrum,项目名称:yaptlytoti,代码行数:15,代码来源:mainwindow.cpp

示例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;
        }
    }
}
开发者ID:ELVIS-Project,项目名称:VISIntervalSonifier,代码行数:16,代码来源:sc_editor.cpp

示例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;
}
开发者ID:MipScope,项目名称:mipscope,代码行数:16,代码来源:FindDialog.cpp

示例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();
    }
}
开发者ID:iphydf,项目名称:qTox,代码行数:16,代码来源:text.cpp

示例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);
   }
}
开发者ID:tomvodi,项目名称:QTail,代码行数:16,代码来源:PlainTextViewWidget.cpp

示例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;
}
开发者ID:hfeeki,项目名称:liteide,代码行数:46,代码来源:findeditor.cpp


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