* Saves the contents to a file. */
| 563 | * Saves the contents to a file. |
| 564 | */ |
| 565 | bool EditorView::saveFile() |
| 566 | { |
| 567 | if (d->fileName.isEmpty()) { |
| 568 | return saveAs(); |
| 569 | } |
| 570 | |
| 571 | QFile file(d->fileName); |
| 572 | if (!file.open(QFile::WriteOnly)) { |
| 573 | return false; |
| 574 | } |
| 575 | QTextStream ts(&file); |
| 576 | #if QT_VERSION < 0x060000 |
| 577 | ts.setCodec("UTF-8"); |
| 578 | #endif |
| 579 | ts << d->textEdit->document()->toPlainText(); |
| 580 | file.close(); |
| 581 | d->textEdit->document()->setModified(false); |
| 582 | |
| 583 | QFileInfo fi(d->fileName); |
| 584 | d->timeStamp = fi.lastModified().toSecsSinceEpoch(); |
| 585 | return true; |
| 586 | } |
| 587 | |
| 588 | void EditorView::undoAvailable(bool undo) |
| 589 | { |
nothing calls this directly
no test coverage detected