MCPcopy Create free account
hub / github.com/KDE/krusader / exportToFile

Method exportToFile

app/BookMan/krbookmarkhandler.cpp:204–227  ·  view source on GitHub ↗

export to file using the xbel standard Developer Web Site Title of this folder KDE Web Site My own bookmarks Calligra Suite W

Source from the content-addressed store, hash-verified

202// </folder>
203// </xbel>
204void KrBookmarkHandler::exportToFile()
205{
206 QDomDocument doc("xbel");
207 QDomElement root = doc.createElement("xbel");
208 doc.appendChild(root);
209
210 exportToFileFolder(doc, root, _root);
211 if (!doc.firstChild().isProcessingInstruction()) {
212 // adding: <?xml version="1.0" encoding="UTF-8" ?> if not already present
213 QDomProcessingInstruction instr = doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\" ");
214 doc.insertBefore(instr, doc.firstChild());
215 }
216
217 QString filename = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + BOOKMARKS_FILE;
218 QFile file(filename);
219 if (file.open(QIODevice::WriteOnly)) {
220 QTextStream stream(&file);
221 // By default, UTF-8 is used for reading and writing in QTextStream
222 stream << doc.toString();
223 file.close();
224 } else {
225 KMessageBox::error(_mainWindow->widget(), i18n("Unable to write to %1", filename), i18n("Error"));
226 }
227}
228
229bool KrBookmarkHandler::importFromFileBookmark(QDomElement &e, KrBookmark *parent, const QString &path, QString *errorMsg)
230{

Callers

nothing calls this directly

Calls 3

openMethod · 0.80
closeMethod · 0.45
widgetMethod · 0.45

Tested by

no test coverage detected