-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHistoryWriter.cpp
More file actions
40 lines (32 loc) · 1.25 KB
/
Copy pathHistoryWriter.cpp
File metadata and controls
40 lines (32 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "HistoryWriter.h"
#include <iostream>
HistoryWriter::HistoryWriter() {
successfullyOpenedHistoryFile = false;
settingsDir = QDir::home();
settingsDir.cd(".WebRender");
file = new QFile(settingsDir.absoluteFilePath("history.xml"));
successfullyOpenedHistoryFile = file->open(QIODevice::WriteOnly | QIODevice::Append);
}
void HistoryWriter::addHistoryItem(QWebHistoryItem item) {
QDomDocument history("history");
QDomElement historyElement = history.createElement("history");
history.appendChild(historyElement);
QDomElement titleElement = history.createElement("title");
historyElement.appendChild(titleElement);
QDomText title = history.createTextNode(item.title());
titleElement.appendChild(title);
QDomElement urlElement = history.createElement("url");
historyElement.appendChild(urlElement);
QDomText url = history.createTextNode(item.url().toString());
urlElement.appendChild(url);
QDomElement dateElement = history.createElement("date");
historyElement.appendChild(dateElement);
QDomText date = history.createTextNode(item.lastVisited().toString());
dateElement.appendChild(date);
xmlContent.append(history.toString());
}
void HistoryWriter::save() {
if(!successfullyOpenedHistoryFile) return;
QTextStream doc(file);
doc<<xmlContent;
}