MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / loadTextFile

Method loadTextFile

gui/fileviewdialog.cpp:49–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49void FileViewDialog::loadTextFile(const QString &filename, QTextEdit *edit)
50{
51 QFile file(filename);
52 if (!file.exists()) {
53 QString msg(tr("Could not find the file: %1"));
54 msg = msg.arg(filename);
55
56 QMessageBox msgbox(QMessageBox::Critical,
57 tr("Cppcheck"),
58 msg,
59 QMessageBox::Ok,
60 this);
61 msgbox.exec();
62 return;
63 }
64
65 (void)file.open(QIODevice::ReadOnly | QIODevice::Text); // TODO: check result
66 if (!file.isReadable()) {
67 QString msg(tr("Could not read the file: %1"));
68 msg = msg.arg(filename);
69
70 QMessageBox msgbox(QMessageBox::Critical,
71 tr("Cppcheck"),
72 msg,
73 QMessageBox::Ok,
74 this);
75 msgbox.exec();
76 return;
77 }
78 QByteArray filedata = file.readAll();
79 file.close();
80
81 edit->setPlainText(filedata);
82}

Callers

nothing calls this directly

Calls 4

readAllMethod · 0.80
existsMethod · 0.45
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected