KBookmarks

kbookmark.cpp
1// -*- c-basic-offset:4; indent-tabs-mode:nil -*-
2/*
3 This file is part of the KDE libraries
4 SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
5 SPDX-FileCopyrightText: 2003 Alexander Kellett <lypanov@kde.org>
6 SPDX-FileCopyrightText: 2008 Norbert Frese <nf2@scheinwelt.at>
7
8 SPDX-License-Identifier: LGPL-2.0-only
9*/
10
11#include "kbookmark.h"
12
13#include <KStringHandler>
14#include <kurlmimedata.h>
15
16#include <QCoreApplication>
17#include <QMimeDatabase>
18#include <QStack>
19#include <QDateTime>
20#include <QMimeData>
21
22namespace
23{
24namespace Strings
25{
26QString metaDataKDEOwner()
27{
28 return QStringLiteral("http://www.kde.org");
29}
30QString metaDataFreedesktopOwner()
31{
32 return QStringLiteral("http://freedesktop.org");
33}
34QString metaDataMimeOwner()
35{
36 return QStringLiteral("http://www.freedesktop.org/standards/shared-mime-info");
37}
38
39QString xbelMimeType()
40{
41 return QStringLiteral("application/x-xbel");
42}
43}
44}
45
46////// utility functions
47
48static QDomNode cd(QDomNode node, const QString &name, bool create)
49{
50 QDomNode subnode = node.namedItem(name);
51 if (create && subnode.isNull()) {
52 subnode = node.ownerDocument().createElement(name);
53 node.appendChild(subnode);
54 }
55 return subnode;
56}
57
58static QDomNode cd_or_create(const QDomNode &node, const QString &name)
59{
60 return cd(node, name, true);
61}
62
63static QDomText get_or_create_text(QDomNode node)
64{
65 QDomNode subnode = node.firstChild();
66 if (subnode.isNull()) {
67 subnode = node.ownerDocument().createTextNode(QLatin1String(""));
68 node.appendChild(subnode);
69 }
70 return subnode.toText();
71}
72
73static QDomNode findMetadata(const QString &forOwner, QDomNode &parent, bool create)
74{
75 const bool forOwnerIsKDE = (forOwner == Strings::metaDataKDEOwner());
76
77 QDomElement metadataElement;
78 for (QDomNode _node = parent.firstChild(); !_node.isNull(); _node = _node.nextSibling()) {
79 QDomElement elem = _node.toElement();
80 if (!elem.isNull() && elem.tagName() == QLatin1String("metadata")) {
81 const QString owner = elem.attribute(QStringLiteral("owner"));
82 if (owner == forOwner) {
83 return elem;
84 }
85 if (owner.isEmpty() && forOwnerIsKDE) {
86 metadataElement = elem;
87 }
88 }
89 }
90 if (create && metadataElement.isNull()) {
91 metadataElement = parent.ownerDocument().createElement(QStringLiteral("metadata"));
92 parent.appendChild(metadataElement);
93 metadataElement.setAttribute(QStringLiteral("owner"), forOwner);
94
95 } else if (!metadataElement.isNull() && forOwnerIsKDE) {
96 // i'm not sure if this is good, we shouldn't take over foreign metadata
97 metadataElement.setAttribute(QStringLiteral("owner"), Strings::metaDataKDEOwner());
98 }
99 return metadataElement;
100}
101
102//////
103
108
110 : KBookmark(elem)
111{
112}
113
115{
116 return element.attribute(QStringLiteral("folded")) == QLatin1String("no"); // default is: folded
117}
118
120{
121 return KBookmark(nextKnownTag(element.firstChildElement(), true));
122}
123
125{
126 return KBookmark(nextKnownTag(current.element.previousSiblingElement(), false));
127}
128
130{
131 return KBookmark(nextKnownTag(current.element.nextSiblingElement(), true));
132}
133
134int KBookmarkGroup::indexOf(const KBookmark &child) const
135{
136 int counter = 0;
137 for (KBookmark bk = first(); !bk.isNull(); bk = next(bk), ++counter) {
138 if (bk.element == child.element) {
139 return counter;
140 }
141 }
142 return -1;
143}
144
145QDomElement KBookmarkGroup::nextKnownTag(const QDomElement &start, bool goNext) const
146{
147 for (QDomElement elem = start; !elem.isNull();) {
148 QString tag = elem.tagName();
149 if (tag == QLatin1String("folder") || tag == QLatin1String("bookmark") || tag == QLatin1String("separator")) {
150 return elem;
151 }
152 if (goNext) {
153 elem = elem.nextSiblingElement();
154 } else {
155 elem = elem.previousSiblingElement();
156 }
157 }
158 return QDomElement();
159}
160
162{
163 if (isNull()) {
164 return KBookmarkGroup();
165 }
166 QDomDocument doc = element.ownerDocument();
167 QDomElement groupElem = doc.createElement(QStringLiteral("folder"));
168 element.appendChild(groupElem);
169 QDomElement textElem = doc.createElement(QStringLiteral("title"));
170 groupElem.appendChild(textElem);
171 textElem.appendChild(doc.createTextNode(text));
172 return KBookmarkGroup(groupElem);
173}
174
176{
177 if (isNull()) {
178 return KBookmark();
179 }
180 QDomDocument doc = element.ownerDocument();
181 Q_ASSERT(!doc.isNull());
182 QDomElement sepElem = doc.createElement(QStringLiteral("separator"));
183 element.appendChild(sepElem);
184 return KBookmark(sepElem);
185}
186
187bool KBookmarkGroup::moveBookmark(const KBookmark &item, const KBookmark &after)
188{
189 QDomNode n;
190 if (!after.isNull()) {
191 n = element.insertAfter(item.element, after.element);
192 } else { // first child
193 if (element.firstChild().isNull()) { // Empty element -> set as real first child
194 n = element.insertBefore(item.element, QDomElement());
195 }
196
197 // we have to skip everything up to the first valid child
198 QDomElement firstChild = nextKnownTag(element.firstChild().toElement(), true);
199 if (!firstChild.isNull()) {
200 if (firstChild == item.element) { // item is already the first child, done
201 return true;
202 }
203 n = element.insertBefore(item.element, firstChild);
204 } else {
205 // No real first child -> append after the <title> etc.
206 n = element.appendChild(item.element);
207 }
208 }
209 return (!n.isNull());
210}
211
213{
214 element.appendChild(bm.internalElement());
215 return bm;
216}
217
218KBookmark KBookmarkGroup::addBookmark(const QString &text, const QUrl &url, const QString &icon)
219{
220 if (isNull()) {
221 return KBookmark();
222 }
223 QDomDocument doc = element.ownerDocument();
224 QDomElement elem = doc.createElement(QStringLiteral("bookmark"));
225 elem.setAttribute(QStringLiteral("href"), url.toString(QUrl::FullyEncoded));
226
227 QDomElement textElem = doc.createElement(QStringLiteral("title"));
228 elem.appendChild(textElem);
229 textElem.appendChild(doc.createTextNode(text));
230
231 KBookmark newBookmark = addBookmark(KBookmark(elem));
232
233 // as icons are moved to metadata, we have to use the KBookmark API for this
234 newBookmark.setIcon(icon);
235 return newBookmark;
236}
237
239{
240 element.removeChild(bk.element);
241}
242
244{
245 return (element.attribute(QStringLiteral("toolbar")) == QLatin1String("yes"));
246}
247
249{
250 if (element.attribute(QStringLiteral("toolbar")) == QLatin1String("yes")) {
251 return element;
252 }
253 for (QDomElement e = element.firstChildElement(QStringLiteral("folder")); !e.isNull(); e = e.nextSiblingElement(QStringLiteral("folder"))) {
254 QDomElement result = KBookmarkGroup(e).findToolbar();
255 if (!result.isNull()) {
256 return result;
257 }
258 }
259 return QDomElement();
260}
261
263{
264 QList<QUrl> urlList;
265 for (KBookmark bm = first(); !bm.isNull(); bm = next(bm)) {
266 if (bm.isSeparator() || bm.isGroup()) {
267 continue;
268 }
269 urlList << bm.url();
270 }
271 return urlList;
272}
273
274//////
275
279
281 : element(elem)
282{
283}
284
286{
287 QString tag = element.tagName();
288 return tag == QLatin1String("folder") //
289 || tag == QLatin1String("xbel"); // don't forget the toplevel group
290}
291
293{
294 return (element.tagName() == QLatin1String("separator"));
295}
296
298{
299 return element.isNull();
300}
301
303{
304 QDomElement parent = element.parentNode().toElement();
305 return !parent.isNull();
306}
307
312
314{
315 if (isSeparator()) {
316 return QCoreApplication::translate("KBookmark", "--- separator ---", "Bookmark separator");
317 }
318
319 QString text = element.namedItem(QStringLiteral("title")).toElement().text();
320 text.replace(QLatin1Char('\n'), QLatin1Char(' ')); // #140673
321 return text;
322}
323
324void KBookmark::setFullText(const QString &fullText)
325{
326 QDomNode titleNode = element.namedItem(QStringLiteral("title"));
327 if (titleNode.isNull()) {
328 titleNode = element.ownerDocument().createElement(QStringLiteral("title"));
329 element.appendChild(titleNode);
330 }
331
332 if (titleNode.firstChild().isNull()) {
333 QDomText domtext = titleNode.ownerDocument().createTextNode(QLatin1String(""));
334 titleNode.appendChild(domtext);
335 }
336
337 QDomText domtext = titleNode.firstChild().toText();
338 domtext.setData(fullText);
339}
340
342{
343 return QUrl(element.attribute(QStringLiteral("href")));
344}
345
346void KBookmark::setUrl(const QUrl &url)
347{
348 element.setAttribute(QStringLiteral("href"), url.toString());
349}
350
352{
353 QDomNode metaDataNode = metaData(Strings::metaDataFreedesktopOwner(), false);
354 QDomElement iconElement = cd(metaDataNode, QStringLiteral("bookmark:icon"), false).toElement();
355
356 QString icon = iconElement.attribute(QStringLiteral("name"));
357
358 // migration code
359 if (icon.isEmpty()) {
360 icon = element.attribute(QStringLiteral("icon"));
361 }
362 if (icon == QLatin1String("www")) { // common icon for kde3 bookmarks
363 return QStringLiteral("internet-web-browser");
364 }
365 // end migration code
366
367 if (icon == QLatin1String("bookmark_folder")) {
368 return QStringLiteral("folder-bookmarks");
369 }
370 if (icon.isEmpty()) {
371 // Default icon depends on URL for bookmarks, and is default directory
372 // icon for groups.
373 if (isGroup()) {
374 icon = QStringLiteral("folder-bookmarks");
375 } else {
376 if (isSeparator()) {
377 icon = QStringLiteral("edit-clear"); // whatever
378 } else {
379 // get icon from mimeType
380 QMimeDatabase db;
381 QMimeType mime;
382 QString _mimeType = mimeType();
383 if (!_mimeType.isEmpty()) {
384 mime = db.mimeTypeForName(_mimeType);
385 } else {
386 mime = db.mimeTypeForUrl(url());
387 }
388 if (mime.isValid()) {
389 icon = mime.iconName();
390 }
391 }
392 }
393 }
394 return icon;
395}
396
398{
399 QDomNode metaDataNode = metaData(Strings::metaDataFreedesktopOwner(), true);
400 QDomElement iconElement = cd_or_create(metaDataNode, QStringLiteral("bookmark:icon")).toElement();
401 iconElement.setAttribute(QStringLiteral("name"), icon);
402
403 // migration code
404 if (!element.attribute(QStringLiteral("icon")).isEmpty()) {
405 element.removeAttribute(QStringLiteral("icon"));
406 }
407}
408
410{
411 if (isSeparator()) {
412 return QString();
413 }
414
415 QString description = element.namedItem(QStringLiteral("desc")).toElement().text();
416 description.replace(QLatin1Char('\n'), QLatin1Char(' ')); // #140673
417 return description;
418}
419
420void KBookmark::setDescription(const QString &description)
421{
422 QDomNode descNode = element.namedItem(QStringLiteral("desc"));
423 if (descNode.isNull()) {
424 descNode = element.ownerDocument().createElement(QStringLiteral("desc"));
425 element.appendChild(descNode);
426 }
427
428 if (descNode.firstChild().isNull()) {
429 QDomText domtext = descNode.ownerDocument().createTextNode(QString());
430 descNode.appendChild(domtext);
431 }
432
433 QDomText domtext = descNode.firstChild().toText();
434 domtext.setData(description);
435}
436
438{
439 QDomNode metaDataNode = metaData(Strings::metaDataMimeOwner(), false);
440 QDomElement mimeTypeElement = cd(metaDataNode, QStringLiteral("mime:mime-type"), false).toElement();
441 return mimeTypeElement.attribute(QStringLiteral("type"));
442}
443
444void KBookmark::setMimeType(const QString &mimeType)
445{
446 QDomNode metaDataNode = metaData(Strings::metaDataMimeOwner(), true);
447 QDomElement iconElement = cd_or_create(metaDataNode, QStringLiteral("mime:mime-type")).toElement();
448 iconElement.setAttribute(QStringLiteral("type"), mimeType);
449}
450
452{
453 if (element.hasAttribute(QStringLiteral("showintoolbar"))) {
454 bool show = element.attribute(QStringLiteral("showintoolbar")) == QLatin1String("yes");
455 const_cast<QDomElement *>(&element)->removeAttribute(QStringLiteral("showintoolbar"));
456 const_cast<KBookmark *>(this)->setShowInToolbar(show);
457 }
458 return metaDataItem(QStringLiteral("showintoolbar")) == QLatin1String("yes");
459}
460
462{
463 setMetaDataItem(QStringLiteral("showintoolbar"), show ? QStringLiteral("yes") : QStringLiteral("no"));
464}
465
470
472{
473 Q_ASSERT(isGroup());
474 return KBookmarkGroup(element);
475}
476
478{
479 if (element.tagName() == QLatin1String("xbel")) {
480 return QLatin1String(""); // not QString() !
481 } else {
482 // Use keditbookmarks's DEBUG_ADDRESSES flag to debug this code :)
483 if (element.parentNode().isNull()) {
484 Q_ASSERT(false);
485 return QStringLiteral("ERROR"); // Avoid an infinite loop
486 }
487 KBookmarkGroup group = parentGroup();
488 QString parentAddress = group.address();
489 int pos = group.indexOf(*this);
490 Q_ASSERT(pos != -1);
491 return parentAddress + QLatin1Char('/') + QString::number(pos);
492 }
493}
494
496{
497 return parentGroup().indexOf(*this);
498}
499
501{
502 return element;
503}
504
505KBookmark KBookmark::standaloneBookmark(const QString &text, const QUrl &url, const QString &icon)
506{
507 QDomDocument doc(QStringLiteral("xbel"));
508 QDomElement elem = doc.createElement(QStringLiteral("xbel"));
509 doc.appendChild(elem);
510 KBookmarkGroup grp(elem);
511 grp.addBookmark(text, url, icon);
512 return grp.first();
513}
514
515QString KBookmark::commonParent(const QString &first, const QString &second)
516{
517 QString A = first;
518 QString B = second;
519 QString error(QStringLiteral("ERROR"));
520 if (A == error || B == error) {
521 return error;
522 }
523
524 A += QLatin1Char('/');
525 B += QLatin1Char('/');
526
527 int lastCommonSlash = 0;
528 int lastPos = A.length() < B.length() ? A.length() : B.length();
529 for (int i = 0; i < lastPos; ++i) {
530 if (A[i] != B[i]) {
531 return A.left(lastCommonSlash);
532 }
533 if (A[i] == QLatin1Char('/')) {
534 lastCommonSlash = i;
535 }
536 }
537 return A.left(lastCommonSlash);
538}
539
541{
542 // qCDebug(KBOOKMARKS_LOG) << "KBookmark::updateAccessMetadata " << address() << " " << url();
543
544 const uint timet = QDateTime::currentDateTimeUtc().toSecsSinceEpoch();
545 setMetaDataItem(QStringLiteral("time_added"), QString::number(timet), DontOverwriteMetaData);
546 setMetaDataItem(QStringLiteral("time_visited"), QString::number(timet));
547
548 QString countStr = metaDataItem(QStringLiteral("visit_count")); // TODO use spec'ed name
549 bool ok;
550 int currentCount = countStr.toInt(&ok);
551 if (!ok) {
552 currentCount = 0;
553 }
554 currentCount++;
555 setMetaDataItem(QStringLiteral("visit_count"), QString::number(currentCount));
556
557 // TODO - time_modified
558}
559
564
566{
568}
569
571{
572 uint pp = positionInParent(address);
573 return pp > 0 ? parentAddress(address) + QLatin1Char('/') + QString::number(pp - 1) : QString();
574}
575
580
581QDomNode KBookmark::metaData(const QString &owner, bool create) const
582{
583 QDomNode infoNode = cd(internalElement(), QStringLiteral("info"), create);
584 if (infoNode.isNull()) {
585 return QDomNode();
586 }
587 return findMetadata(owner, infoNode, create);
588}
589
591{
592 QDomNode metaDataNode = metaData(Strings::metaDataKDEOwner(), false);
593 for (QDomElement e = metaDataNode.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
594 if (e.tagName() == key) {
595 return e.text();
596 }
597 }
598 return QString();
599}
600
601void KBookmark::setMetaDataItem(const QString &key, const QString &value, MetaDataOverwriteMode mode)
602{
603 QDomNode metaDataNode = metaData(Strings::metaDataKDEOwner(), true);
604 QDomNode item = cd_or_create(metaDataNode, key);
605 QDomText text = get_or_create_text(item);
606 if (mode == DontOverwriteMetaData && !text.data().isEmpty()) {
607 return;
608 }
609
610 text.setData(value);
611}
612
613bool KBookmark::operator==(const KBookmark &rhs) const
614{
615 return element == rhs.element;
616}
617
618////
619
620KBookmarkGroupTraverser::~KBookmarkGroupTraverser()
621{
622}
623
624void KBookmarkGroupTraverser::traverse(const KBookmarkGroup &root)
625{
627 stack.push(root);
628 KBookmark bk = root.first();
629 for (;;) {
630 if (bk.isNull()) {
631 if (stack.count() == 1) { // only root is on the stack
632 return;
633 }
634 if (!stack.isEmpty()) {
635 visitLeave(stack.top());
636 bk = stack.pop();
637 }
638 bk = stack.top().next(bk);
639 } else if (bk.isGroup()) {
640 KBookmarkGroup gp = bk.toGroup();
641 visitEnter(gp);
642 bk = gp.first();
643 stack.push(gp);
644 } else {
645 visit(bk);
646 bk = stack.top().next(bk);
647 }
648 }
649}
650
651void KBookmarkGroupTraverser::visit(const KBookmark &)
652{
653}
654
655void KBookmarkGroupTraverser::visitEnter(const KBookmarkGroup &)
656{
657}
658
659void KBookmarkGroupTraverser::visitLeave(const KBookmarkGroup &)
660{
661}
662
664{
665 KBookmark::List bookmarkList;
666 bookmarkList.append(*this);
667 bookmarkList.populateMimeData(mimeData);
668}
669
670KBookmark::List::List()
671 : QList<KBookmark>()
672{
673}
674
676{
677 QList<QUrl> urls;
678
679 QDomDocument doc(QStringLiteral("xbel"));
680 QDomElement elem = doc.createElement(QStringLiteral("xbel"));
681 doc.appendChild(elem);
682
683 for (const_iterator it = begin(), end = this->end(); it != end; ++it) {
684 urls.append((*it).url());
685 elem.appendChild((*it).internalElement().cloneNode(true /* deep */));
686 }
687
688 // This sets text/uri-list and text/plain into the mimedata
689 mimeData->setUrls(urls);
690
691 mimeData->setData(Strings::xbelMimeType(), doc.toByteArray());
692}
693
695{
696 return mimeData->hasFormat(Strings::xbelMimeType()) || mimeData->hasUrls();
697}
698
700{
701 return QStringList() << Strings::xbelMimeType() << KUrlMimeData::mimeDataTypes();
702}
703
705{
706 KBookmark::List bookmarks;
707 const QByteArray payload = mimeData->data(Strings::xbelMimeType());
708 if (!payload.isEmpty()) {
709 doc.setContent(payload);
710 QDomElement elem = doc.documentElement();
711 const QDomNodeList children = elem.childNodes();
712 bookmarks.reserve(children.count());
713 for (int childno = 0; childno < children.count(); childno++) {
714 bookmarks.append(KBookmark(children.item(childno).toElement()));
715 }
716 return bookmarks;
717 }
718 const QList<QUrl> urls = KUrlMimeData::urlsFromMimeData(mimeData);
719 bookmarks.reserve(urls.size());
720 for (int i = 0; i < urls.size(); ++i) {
721 const QUrl url = urls.at(i);
722 bookmarks.append(KBookmark::standaloneBookmark(url.toDisplayString(), url, QString() /*TODO icon*/));
723 }
724 return bookmarks;
725}
A group of bookmarks.
Definition kbookmark.h:316
bool isToolbarGroup() const
KBookmark next(const KBookmark &current) const
Return the next sibling of a child bookmark of this group.
KBookmark first() const
Return the first child bookmark of this group.
bool isOpen() const
void deleteBookmark(const KBookmark &bk)
Delete a bookmark - it has to be one of our children ! Don't forget to use KBookmarkManager::self()->...
KBookmarkGroup()
Create an invalid group.
KBookmark previous(const KBookmark &current) const
Return the previous sibling of a child bookmark of this group.
bool moveBookmark(const KBookmark &bookmark, const KBookmark &after)
Moves bookmark after after (which should be a child of ours).
KBookmark createNewSeparator()
Create a new bookmark separator Don't forget to use KBookmarkManager::self()->emitChanged( parentBook...
KBookmark addBookmark(const KBookmark &bm)
Create a new bookmark, as the last child of this group Don't forget to use KBookmarkManager::self()->...
int indexOf(const KBookmark &child) const
Return the index of a child bookmark, -1 if not found.
QDomElement findToolbar() const
QList< QUrl > groupUrlList() const
KBookmarkGroup createNewFolder(const QString &text)
Create a new bookmark folder, as the last child of this group.
KBookmark::List is a QList that contains bookmarks with a few convenience methods.
Definition kbookmark.h:43
static KBookmark::List fromMimeData(const QMimeData *mimeData, QDomDocument &parentDocument)
Extract a list of bookmarks from the contents of mimeData.
static bool canDecode(const QMimeData *mimeData)
Return true if mimeData contains bookmarks.
static QStringList mimeDataTypes()
Return the list of mimeTypes that can be decoded by fromMimeData.
void populateMimeData(QMimeData *mimeData) const
Adds this list of bookmark into the given QMimeData.
A class representing a bookmark.
Definition kbookmark.h:27
QString text() const
Text shown for the bookmark If bigger than 40, the text is shortened by replacing middle characters w...
static QString nextAddress(const QString &address)
KBookmarkGroup parentGroup() const
QString icon() const
void setMetaDataItem(const QString &key, const QString &value, MetaDataOverwriteMode mode=OverwriteMetaData)
Change the value of a specific metadata item, or create the given item if it doesn't exist already (o...
void updateAccessMetadata()
Updates the bookmarks access metadata Call when a user accesses the bookmark.
KBookmark()
Constructs a null bookmark, i.e.
QString description() const
bool isNull() const
bool showInToolbar() const
QDomNode metaData(const QString &owner, bool create) const
bool isGroup() const
Whether the bookmark is a group or a normal bookmark.
QString fullText() const
Text shown for the bookmark, not truncated.
bool hasParent() const
KBookmarkGroup toGroup() const
Convert this to a group - do this only if isGroup() returns true.
bool isSeparator() const
Whether the bookmark is a separator.
int positionInParent() const
Return the position in the parent, i.e.
static QString commonParent(const QString &A, const QString &B)
void setDescription(const QString &description)
Set the description of the bookmark.
QString mimeType() const
void setUrl(const QUrl &url)
Set the URL of the bookmark.
static QString previousAddress(const QString &address)
void setMimeType(const QString &mimeType)
Set the Mime-Type of this item.
static QString parentAddress(const QString &address)
QDomElement internalElement() const
void setFullText(const QString &fullText)
Set the text shown for the bookmark.
QString address() const
Return the "address" of this bookmark in the whole tree.
bool operator==(const KBookmark &rhs) const
Comparison operator.
void setIcon(const QString &icon)
Set the icon name of the bookmark.
void setShowInToolbar(bool show)
Set whether this bookmark is show in a filterd toolbar.
void populateMimeData(QMimeData *mimeData) const
Adds this bookmark into the given QMimeData.
static KBookmark standaloneBookmark(const QString &text, const QUrl &url, const QString &icon)
Creates a stand alone bookmark.
QUrl url() const
URL contained by the bookmark.
QString metaDataItem(const QString &key) const
Get the value of a specific metadata item (owner = "http://www.kde.org").
Q_SCRIPTABLE Q_NOREPLY void start()
KCOREADDONS_EXPORT QString csqueeze(const QString &str, int maxlen=40)
KCOREADDONS_EXPORT QStringList mimeDataTypes()
KCOREADDONS_EXPORT QList< QUrl > urlsFromMimeData(const QMimeData *mimeData, DecodeOptions decodeOptions=PreferKdeUrls, MetaDataMap *metaData=nullptr)
bool isEmpty() const const
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
QDateTime currentDateTimeUtc()
qint64 toSecsSinceEpoch() const const
void setData(const QString &v)
QDomElement createElement(const QString &tagName)
QDomText createTextNode(const QString &value)
QDomElement documentElement() const const
ParseResult setContent(QAnyStringView text, ParseOptions options)
QByteArray toByteArray(int indent) const const
QString attribute(const QString &name, const QString &defValue) const const
bool hasAttribute(const QString &name) const const
void removeAttribute(const QString &name)
void setAttribute(const QString &name, const QString &value)
QString tagName() const const
QString text() const const
QDomNode appendChild(const QDomNode &newChild)
QDomNodeList childNodes() const const
QDomNode firstChild() const const
QDomElement firstChildElement(const QString &tagName, const QString &namespaceURI) const const
QDomNode insertAfter(const QDomNode &newChild, const QDomNode &refChild)
QDomNode insertBefore(const QDomNode &newChild, const QDomNode &refChild)
bool isNull() const const
QDomNode namedItem(const QString &name) const const
QDomElement nextSiblingElement(const QString &tagName, const QString &namespaceURI) const const
QDomDocument ownerDocument() const const
QDomNode parentNode() const const
QDomElement previousSiblingElement(const QString &tagName, const QString &namespaceURI) const const
QDomNode removeChild(const QDomNode &oldChild)
QDomElement toElement() const const
QDomText toText() const const
int count() const const
QDomNode item(int index) const const
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
qsizetype count() const const
bool isEmpty() const const
void reserve(qsizetype size)
qsizetype size() const const
QByteArray data(const QString &mimeType) const const
virtual bool hasFormat(const QString &mimeType) const const
bool hasUrls() const const
void setData(const QString &mimeType, const QByteArray &data)
void setUrls(const QList< QUrl > &urls)
QMimeType mimeTypeForName(const QString &nameOrAlias) const const
QMimeType mimeTypeForUrl(const QUrl &url) const const
bool isValid() const const
void push(const T &t)
T & top()
QChar * data()
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) const const
qsizetype length() const const
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
int toInt(bool *ok, int base) const const
QStringView mid(qsizetype start, qsizetype length) const const
int toInt(bool *ok, int base) const const
FullyEncoded
QString toDisplayString(FormattingOptions options) const const
QString toString(FormattingOptions options) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:56:13 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.