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

Method reloadTextFileWithCode

src/cceditor/ccnotepad.cpp:4218–4305  ·  view source on GitHub ↗

重新加载文件以指定的编码方式。单纯的修改编码,不视作文件做了修改。

Source from the content-addressed store, hash-verified

4216
4217//重新加载文件以指定的编码方式。单纯的修改编码,不视作文件做了修改。
4218bool CCNotePad::reloadTextFileWithCode(CODE_ID code)
4219{
4220 QWidget* pw = ui.editTabWidget->currentWidget();
4221 //16进制的处理逻辑
4222
4223 int docType = getDocTypeProperty(pw);
4224
4225 if (HEX_TYPE == docType)
4226 {
4227 ui.statusBar->showMessage(tr("Only Text File Can Use it, Current Doc is a Hex File !"), 10000);
4228 QApplication::beep();
4229 return false;
4230 }
4231
4232 ScintillaEditView* pEdit = dynamic_cast<ScintillaEditView*>(pw);
4233
4234 //新建文件不需要重新打开文件,只修改编码显示
4235 if (-1 == getFileNewIndexProperty(pw))
4236 {
4237 QString filePath = pw->property(Edit_View_FilePath).toString();
4238
4239 RC_LINE_FORM lineEnd;
4240
4241 disEnableEditTextChangeSign(pEdit);
4242
4243 pEdit->clear();
4244
4245 if (docType == TXT_TYPE)
4246 {
4247 int errCode = FileManager::getInstance().loadFileDataInText(pEdit, filePath, code, lineEnd, this, false,this);
4248 if (errCode == 6)
4249 {
4250 //有乱码
4251 }
4252 else if (errCode != 0)
4253 {
4254 delete pEdit;
4255 return false;
4256 }
4257 }
4258 else if (BIG_TEXT_RO_TYPE == docType)
4259 {
4260 //大文本索引加载模式,不需要再读取文本。只需要进行编码的转换即可
4261 BigTextEditFileMgr* fileMgr = FileManager::getInstance().getBigFileEditMgr(filePath);
4262 if (fileMgr != nullptr)
4263 {
4264 fileMgr->loadWithCode = code;
4265 showBigTextFile(pEdit, fileMgr, fileMgr->m_curBlockIndex);
4266 }
4267 else
4268 {
4269 return false;
4270 }
4271 }
4272 else if (SUPER_BIG_TEXT_RO_TYPE == docType)
4273 {
4274 TextFileMgr* fileMgr = FileManager::getInstance().getSuperBigFileMgr(filePath);
4275 if (fileMgr != nullptr)

Callers

nothing calls this directly

Calls 9

getDocTypePropertyFunction · 0.85
getFileNewIndexPropertyFunction · 0.85
loadFileDataInTextMethod · 0.80
getBigFileEditMgrMethod · 0.80
getSuperBigFileMgrMethod · 0.80
showBigTextLineAddrMethod · 0.80
clearMethod · 0.45
lexerMethod · 0.45

Tested by

no test coverage detected