* loads history contents from the default history file */
| 1492 | * loads history contents from the default history file |
| 1493 | */ |
| 1494 | void 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 |