MCPcopy Create free account
hub / github.com/cxasm/notepad-- / openSuperBigTextFile

Method openSuperBigTextFile

src/cceditor/ccnotepad.cpp:4399–4484  ·  view source on GitHub ↗

按照超大文本文件进行只读打开

Source from the content-addressed store, hash-verified

4397
4398//按照超大文本文件进行只读打开
4399bool CCNotePad::openSuperBigTextFile(QString filePath)
4400{
4401 QFileInfo fi(filePath);
4402 QString fileLabel(fi.fileName());
4403
4404 TextFileMgr* txtFile = nullptr;
4405
4406 RC_LINE_FORM lineEnd(UNKNOWN_LINE);
4407
4408 if (!FileManager::getInstance().loadFileData(filePath, txtFile, lineEnd))
4409 {
4410 return false;
4411 }
4412
4413 ScintillaEditView* pEdit = FileManager::getInstance().newEmptyDocument(true);
4414 pEdit->setReadOnly(true);
4415 pEdit->setNoteWidget(this);
4416
4417 //必须要在editTabWidget->addTab之前,因为一旦add时会出发tabchange,其中没有doctype会导致错误
4418 pEdit->execute(SCI_SETSCROLLWIDTH, 80 * 10);
4419 setDocTypeProperty(pEdit, SUPER_BIG_TEXT_RO_TYPE);
4420
4421 showBigTextFile(pEdit, txtFile);
4422 lineEnd = (RC_LINE_FORM)txtFile->lineEndType;
4423
4424 disconnect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged);
4425 int curIndex = ui.editTabWidget->addTab(pEdit, QIcon((StyleSet::getCurrentSytleId() != DEEP_BLACK) ? TabNoNeedSave : TabNoNeedSaveDark32), getShortName(fileLabel));
4426
4427 ui.editTabWidget->setCurrentIndex(curIndex);
4428 connect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged, Qt::UniqueConnection);
4429 connect(pEdit, &ScintillaEditView::cursorPositionChanged, this, &CCNotePad::slot_LineNumIndexChange, Qt::QueuedConnection);
4430
4431
4432 autoSetDocLexer(pEdit);
4433
4434 pEdit->showBigTextLineAddr(txtFile->fileOffset - txtFile->contentRealSize, txtFile->fileOffset);
4435
4436 QVariant editViewFilePath(filePath);
4437 pEdit->setProperty(Edit_View_FilePath, editViewFilePath);
4438
4439 //setWindowTitle(QString("%1 (%2)").arg(filePath).arg(tr("Big Text File ReadOnly")));
4440
4441 ui.editTabWidget->setTabToolTip(curIndex, filePath);
4442
4443 QVariant editViewNewFile(-1);
4444 pEdit->setProperty(Edit_File_New, editViewNewFile);
4445
4446 QVariant editTextChange(false);
4447 pEdit->setProperty(Edit_Text_Change, editTextChange);
4448
4449 setCodeTypeProperty(pEdit, txtFile->loadWithCode);
4450 setCodeBarLabel((CODE_ID)txtFile->loadWithCode);
4451
4452 setLineEndBarLabel(lineEnd);
4453 setEndTypeProperty(pEdit, lineEnd);
4454 setDocEolMode(pEdit, lineEnd);
4455
4456 syncCurDocEncodeToMenu(pEdit);

Callers

nothing calls this directly

Calls 14

setDocTypePropertyFunction · 0.85
setCodeTypePropertyFunction · 0.85
setEndTypePropertyFunction · 0.85
setFileOpenAttrPropertyFunction · 0.85
setEditShowBlankStatusFunction · 0.85
loadFileDataMethod · 0.80
newEmptyDocumentMethod · 0.80
setReadOnlyMethod · 0.80
showBigTextLineAddrMethod · 0.80
zoomToMethod · 0.80
setNoteWidgetMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected