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