MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / loadHistory

Method loadHistory

src/Gui/PythonConsole.cpp:1494–1516  ·  view source on GitHub ↗

* loads history contents from the default history file */

Source from the content-addressed store, hash-verified

1492 * loads history contents from the default history file
1493 */
1494void PythonConsole::loadHistory() const
1495{
1496 // only load contents if history is empty, to not overwrite anything
1497 if (!d->history.isEmpty()) {
1498 return;
1499 }
1500
1501 if (!d->hGrpSettings->GetBool("SavePythonHistory", false)) {
1502 return;
1503 }
1504 QFile f(d->historyFile);
1505 if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
1506 QString l;
1507 while (!f.atEnd()) {
1508 l = QString::fromUtf8(f.readLine());
1509 if (!l.isEmpty()) {
1510 l.chop(1); // removes the last \n
1511 d->history.append(l);
1512 }
1513 }
1514 f.close();
1515 }
1516}
1517
1518/**
1519 * saves the current history to the default history file

Callers

nothing calls this directly

Calls 5

GetBoolMethod · 0.80
isEmptyMethod · 0.45
openMethod · 0.45
appendMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected