大文本打开只读模式。20230126新增,这种模式打开时建立索引;todo:后续可多线程在后台建立索引
| 4308 | |
| 4309 | //大文本打开只读模式。20230126新增,这种模式打开时建立索引;todo:后续可多线程在后台建立索引 |
| 4310 | bool CCNotePad::openBigTextRoFile(QString filePath) |
| 4311 | { |
| 4312 | QFileInfo fi(filePath); |
| 4313 | QString fileLabel(fi.fileName()); |
| 4314 | |
| 4315 | //如果4M一个分块,则1024则是4G文件,2048则是8G文件。目前暂时最大支持8G的文件,进行文本编辑。 |
| 4316 | BigTextEditFileMgr* txtFile = nullptr; |
| 4317 | |
| 4318 | RC_LINE_FORM lineEnd(UNKNOWN_LINE); |
| 4319 | |
| 4320 | if (!FileManager::getInstance().loadFileDataWithIndex(filePath, txtFile)) |
| 4321 | { |
| 4322 | return false; |
| 4323 | } |
| 4324 | |
| 4325 | ScintillaEditView* pEdit = FileManager::getInstance().newEmptyDocument(true); |
| 4326 | pEdit->setReadOnly(true); |
| 4327 | pEdit->setNoteWidget(this); |
| 4328 | |
| 4329 | //必须要在editTabWidget->addTab之前,因为一旦add时会出发tabchange,其中没有doctype会导致错误 |
| 4330 | pEdit->execute(SCI_SETSCROLLWIDTH, 80 * 10); |
| 4331 | setDocTypeProperty(pEdit, BIG_TEXT_RO_TYPE); |
| 4332 | |
| 4333 | showBigTextFile(pEdit, txtFile,0); |
| 4334 | |
| 4335 | lineEnd = (RC_LINE_FORM)txtFile->lineEndType; |
| 4336 | |
| 4337 | disconnect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged); |
| 4338 | int curIndex = ui.editTabWidget->addTab(pEdit, QIcon((StyleSet::getCurrentSytleId() != DEEP_BLACK) ? TabNoNeedSave : TabNoNeedSaveDark32), getShortName(fileLabel)); |
| 4339 | |
| 4340 | ui.editTabWidget->setCurrentIndex(curIndex); |
| 4341 | connect(ui.editTabWidget, &QTabWidget::currentChanged, this, &CCNotePad::slot_tabCurrentChanged, Qt::UniqueConnection); |
| 4342 | |
| 4343 | connect(pEdit, &ScintillaEditView::cursorPositionChanged, this, &CCNotePad::slot_LineNumIndexChange, Qt::QueuedConnection); |
| 4344 | |
| 4345 | autoSetDocLexer(pEdit); |
| 4346 | |
| 4347 | //pEdit->showBigEidTextLineNum(txtFile); |
| 4348 | |
| 4349 | QVariant editViewFilePath(filePath); |
| 4350 | pEdit->setProperty(Edit_View_FilePath, editViewFilePath); |
| 4351 | |
| 4352 | //setWindowTitle(QString("%1 (%2)").arg(filePath).arg(tr("Big Text File ReadOnly"))); |
| 4353 | |
| 4354 | ui.editTabWidget->setTabToolTip(curIndex, filePath); |
| 4355 | |
| 4356 | QVariant editViewNewFile(-1); |
| 4357 | pEdit->setProperty(Edit_File_New, editViewNewFile); |
| 4358 | |
| 4359 | QVariant editTextChange(false); |
| 4360 | pEdit->setProperty(Edit_Text_Change, editTextChange); |
| 4361 | |
| 4362 | setCodeTypeProperty(pEdit, txtFile->loadWithCode); |
| 4363 | setCodeBarLabel((CODE_ID)txtFile->loadWithCode); |
| 4364 | |
| 4365 | setLineEndBarLabel(lineEnd); |
| 4366 | setEndTypeProperty(pEdit, lineEnd); |
| 4367 | setDocEolMode(pEdit, lineEnd); |
nothing calls this directly
no test coverage detected