MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / readFile

Method readFile

src/plugins/codeeditor/gui/private/texteditor_p.cpp:304–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302}
303
304bool TextEditorPrivate::readFile(const QString &encode)
305{
306 QFile file(fileName);
307 if (file.open(QIODevice::ReadOnly)) {
308 QByteArray fileContent = file.readAll();
309 QString newEncode = encode;
310 if (newEncode.isEmpty())
311 newEncode = DetectCode::getFileEncodingFormat(fileName, fileContent.left(1024 * 1024));
312
313 QByteArray outData;
314 DetectCode::changeFileEncodingFormat(fileContent, outData, newEncode, QString("UTF-8"));
315 if (outData.isEmpty()) {
316 outData = fileContent;
317 newEncode = "UTF-8";
318 }
319 q->setText(outData);
320 file.close();
321 documentEncode = newEncode;
322 q->setModified(false);
323 return true;
324 }
325 return false;
326}
327
328int TextEditorPrivate::cursorPosition() const
329{

Callers 2

openFileMethod · 0.45
reloadMethod · 0.45

Calls 8

readAllMethod · 0.80
leftMethod · 0.80
QStringClass · 0.50
openMethod · 0.45
isEmptyMethod · 0.45
setTextMethod · 0.45
closeMethod · 0.45
setModifiedMethod · 0.45

Tested by

no test coverage detected