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


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

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


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

示例1: insertLineBeforeBracket

int OpenedFile::insertLineBeforeBracket(const int start_line, const QString &new_line)
{
    QTextCursor parsingCursor = textCursor();
    QString new_text = new_line;

    parsingCursor.setPosition(0);

    while(parsingCursor.blockNumber() != start_line)
    {
        parsingCursor.movePosition(QTextCursor::Down);
    }

    while(!parsingCursor.atEnd())
    {
        if(parsingCursor.block().text().contains('}'))
            break;

        parsingCursor.movePosition(QTextCursor::Down);
    }

    parsingCursor.movePosition(QTextCursor::StartOfLine);

    new_text.remove(".0000", Qt::CaseInsensitive);
    parsingCursor.insertText(new_text);
    parsingCursor.insertText("\n");
    parsingCursor.movePosition(QTextCursor::Up);
    setTextCursor(parsingCursor);
    return parsingCursor.blockNumber();

}
开发者ID:bkchr,项目名称:Rockete,代码行数:30,代码来源:OpenedFile.cpp

示例2: commentSelected

/*!
 * \brief TextDoc::commentSelected toggles the comment of selected text
 * See also QucsApp::slotEditActivate
 */
void TextDoc::commentSelected ()
{
  QTextCursor cursor = this->textCursor();

  if(!cursor.hasSelection())
      return; // No selection available

  // get range of selection
  int start = cursor.selectionStart();
  int end = cursor.selectionEnd();

  cursor.setPosition(start);
  int firstLine = cursor.blockNumber();
  cursor.setPosition(end, QTextCursor::KeepAnchor);
  int lastLine = cursor.blockNumber();

  // use comment string indicator depending on language
  QString co;

  switch (language) {
  case LANG_VHDL:
    co = "--";
    break;
  case LANG_VERILOG:
  case LANG_VERILOGA:
    co = "//";
    break;
  case LANG_OCTAVE:
    co = "%";
    break;
  default:
    co = "";
    break;
  }

  QStringList newlines;
  for (int i=firstLine; i<=lastLine; i++) {
      QString line = document()->findBlockByLineNumber(i).text();
      if (line.startsWith(co)){
          // uncomment
          line.remove(0,co.length());
          newlines << line;
      }
      else {
          // comment
          line = line.insert(0, co);
          newlines << line;
      }
  }
  insertPlainText(newlines.join("\n"));
}
开发者ID:NextGenIntelligence,项目名称:qucs,代码行数:55,代码来源:textdoc.cpp

示例3: mousePressEvent

void OCamlSource::mousePressEvent ( QMouseEvent * e )
{
    QTextCursor current_cur = textCursor();
    QTextCursor cur = cursorForPosition( e->pos() );
    if ( current_cur.hasSelection() )
        cur = current_cur;

    _breakpoint_line   = cur.blockNumber() + 1;
    _breakpoint_column = cur.position() - cur.block().position() + 1;
    if ( ! cur.hasSelection() )
    {
        cur.select(QTextCursor::WordUnderCursor);
        setTextCursor(cur);
    }
    _selected_text = cur.selectedText();
    if ( e->button() == Qt::LeftButton )
    {
        lineSearchArea->hide();
        lineSearchArea->setEnabled(false);
        setFocus();
    }

    if ( e->button() == Qt::MidButton )
    {
        watchVar();
    }
    else
        QPlainTextEdit::mousePressEvent(e);
}
开发者ID:modlfo,项目名称:oqamldebug_qt5,代码行数:29,代码来源:ocamlsource.cpp

示例4: updatePositionStatus

void TextView::updatePositionStatus() {
    QTextCursor cursor = textEdit()->textCursor();
    int line = cursor.blockNumber() + 1;
    int column = cursor.columnNumber() + 1;

    Q_EMIT status(tr("Line %1, Column %2").arg(line).arg(column));
}
开发者ID:8l,项目名称:snowman,代码行数:7,代码来源:TextView.cpp

示例5: cursorChanged

void SkinDocument::cursorChanged()
{
    if(editor->isError(editor->textCursor().blockNumber() + 1))
    {
        QTextCursor line = editor->textCursor();
        line.movePosition(QTextCursor::StartOfLine);
        line.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
        skin_parse(line.selectedText().toAscii());
        if(skin_error_line() > 0)
            parseStatus = tr("Error on line ") +
                          QString::number(line.blockNumber() + 1) + tr(": ") +
                          skin_error_message();
        statusLabel->setText(parseStatus);
    }
    else if(editor->hasErrors())
    {
        parseStatus = tr("Errors in document");
        statusLabel->setText(parseStatus);
    }
    else
    {
        emit lineChanged(editor->textCursor().blockNumber() + 1);
    }

}
开发者ID:eisnerd,项目名称:rockbox,代码行数:25,代码来源:skindocument.cpp

示例6: appendRecord

void KCDocumentRecorder::appendRecord(KCCodeEditor *editor, bool untitled)
{
    UnclosedFileStatus currentStatus;
    QTextCursor cursor;
    currentStatus.untitled=untitled;
    if(untitled)
    {
        //This will treat as a untitled file.
        QString cacheFilePath=QString(unclosedUntitledFileDir +
                                      QString::number(cacheCount++));
        //Save the file as a cache file
        editor->writeCacheFile(cacheFilePath);
        cursor=editor->getTextCursor();
        currentStatus.filePath=cacheFilePath;
    }
    else
    {
        cursor=editor->getTextCursor();
        currentStatus.filePath=editor->getFilePath();
    }
    currentStatus.horizontalCursorPosition=cursor.blockNumber();
    currentStatus.verticalCursorPosition=cursor.columnNumber();
    currentStatus.horizontalScrollPosition=editor->getHScrollValue();
    currentStatus.verticalScrollPosition=editor->getVScrollValue();
    unclosedFileInfos.prepend(currentStatus);
}
开发者ID:Kreogist,项目名称:Cuties,代码行数:26,代码来源:kcdocumentrecorder.cpp

示例7: cursorPositionChanged

void TextEditViewImpl::cursorPositionChanged()
{
    QTextCursor cur = textEdit.textCursor();
    std::stringstream s;
    s << cur.blockNumber()+1 << "  :  " << cur.columnNumber()+1 << "  ";
    lineLabel.setText(QString(s.str().c_str()));
}
开发者ID:hattorishizuko,项目名称:choreonoid,代码行数:7,代码来源:TextEditView.cpp

示例8: startLocalRenaming

void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
                                           CppTools::ProjectPart *projectPart,
                                           RenameCallback &&renameSymbolsCallback)
{
    using CppTools::CompilerOptionsBuilder;

    setRefactoringEngineAvailable(false);

    m_client.setLocalRenamingCallback(std::move(renameSymbolsCallback));

    QString filePath = data.filePath().toString();
    QTextCursor textCursor = data.cursor();
    CompilerOptionsBuilder optionsBuilder{*projectPart, CLANG_VERSION, CLANG_RESOURCE_DIR};
    Utils::SmallStringVector commandLine{optionsBuilder.build(
                    fileKindInProjectPart(projectPart, filePath),
                    CppTools::getPchUsage())};

    commandLine.push_back(filePath);

    RequestSourceLocationsForRenamingMessage message(ClangBackEnd::FilePath(filePath),
                                                     uint(textCursor.blockNumber() + 1),
                                                     uint(textCursor.positionInBlock() + 1),
                                                     textCursor.document()->toPlainText(),
                                                     std::move(commandLine),
                                                     textCursor.document()->revision());


    m_server.requestSourceLocationsForRenamingMessage(std::move(message));
}
开发者ID:choenig,项目名称:qt-creator,代码行数:29,代码来源:refactoringengine.cpp

示例9: executeQuery

void QueryPanel::executeQuery() {
    QTextCursor c = editor->textCursor();
    QString stmt = getActiveStatement(c.blockNumber(), c.columnNumber());
    error->hide();
    status->hide();
    model->setQuery(stmt);
    model->select();
}
开发者ID:ohwgiles,项目名称:sequeljoe,代码行数:8,代码来源:querypanel.cpp

示例10: showCursorPosition

void TikzEditor::showCursorPosition()
{
	QTextCursor cursor = textCursor();
	const int cursorPosition = cursor.position();
	cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor);
	const int startPosition = cursor.position();
	emit cursorPositionChanged(cursor.blockNumber() + 1, cursorPosition - startPosition + 1);
}
开发者ID:jfmcarreira,项目名称:ktikz-old,代码行数:8,代码来源:tikzeditor.cpp

示例11: slotCursorPosChanged

/*!
 * \brief TextDoc::slotCursorPosChanged update status bar with line:column
 */
void TextDoc::slotCursorPosChanged()
{
  QTextCursor pos = textCursor();
  int x = pos.blockNumber();
  int y = pos.columnNumber();
  emit signalCursorPosChanged(x+1, y+1);
  tmpPosX = x;
  tmpPosY = y;
}
开发者ID:NextGenIntelligence,项目名称:qucs,代码行数:12,代码来源:textdoc.cpp

示例12: slotCursorPosChanged

/*!
 * \brief TextDoc::slotCursorPosChanged update status bar with line:column
 */
void TextDoc::slotCursorPosChanged()
{
  QTextCursor pos = textCursor();
  int x = pos.blockNumber();
  int y = pos.columnNumber();
  App->printCursorPosition(x+1, y+1);
  tmpPosX = x;
  tmpPosY = y;
}
开发者ID:mdavidsaver,项目名称:qucs,代码行数:12,代码来源:textdoc.cpp

示例13: findLineNumber

int OpenedFile::findLineNumber(const QString &str, const int start_line_number)
{
    QTextCursor parsingCursor = textCursor();
    
    parsingCursor.setPosition(0);
    
    while(parsingCursor.blockNumber() != start_line_number)
    {
        parsingCursor.movePosition(QTextCursor::Down);
    }

    while(!parsingCursor.atEnd())
    {
        if(parsingCursor.block().text().contains(str))
            return parsingCursor.blockNumber();

        parsingCursor.movePosition(QTextCursor::Down);
    }

    return -1;
}
开发者ID:bkchr,项目名称:Rockete,代码行数:21,代码来源:OpenedFile.cpp

示例14: from_pos

static void from_pos(CTEXTAREA *_object, int pos, int *par, int *car)
{
	QTextCursor cursor = WIDGET->textCursor();
	
	if (pos >= get_length(THIS))
		cursor.movePosition(QTextCursor::End);
	else
		cursor.setPosition(pos);
	
	*par = cursor.blockNumber();
	*car = cursor.position() - cursor.block().position();
}
开发者ID:ramonelalto,项目名称:gambas,代码行数:12,代码来源:CTextArea.cpp

示例15: cursorPositionChanged

void MdiChild::cursorPositionChanged()
{
	QTextCursor cursor      = this->textCursor();

	// Current line text
	//QString cur_line_text   = cursor.block().text().trimmed();

	std::ostringstream oss;
	oss <<"Line:"<< cursor.blockNumber()+1 <<"  Colum:"<<cursor.columnNumber();
	statusBar->showMessage( QString::fromStdString(oss.str()));

}
开发者ID:cooltype,项目名称:Compilers,代码行数:12,代码来源:mdichild.cpp


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