summaryrefslogtreecommitdiff
path: root/src/bookmarks/bookmarkstreeformat_xbel.h
blob: af7345c529c7ceb84a54e6d66b1d101143017e42 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* ============================================================
 * rekonq
 * ============================================================
 * SPDX-License-Identifier: GPL-3.0-only
 * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
 * ============================================================
 * Description: rekonq bookmarks model
 * ============================================================ */

#pragma once

#include <QVector>

class QIODevice;
class BookmarksTreeItem;

namespace xbel {
/**
 * Parse an XBEL-formatted BookmarkItem tree
 * @param device QIODEvice pointer to read from
 * @param root BookmarkItem tree root pointer
 * @return list of parse errors, if any
 */
[[nodiscard]] QList<QString> read(QIODevice *device, BookmarksTreeItem *root);

/**
 * Write items into device
 * @param device
 * @param items
 * @return true on success
 */
[[nodiscard]] bool write(QIODevice *device, const QVector<const BookmarksTreeItem *> &items);

// 3.2 Top-level Information
constexpr auto *elem_xbel{"xbel"};
constexpr auto *attr_version{"version"};
constexpr auto *attr_version_value{"1.0"};

// 3.3 Common Elements
static const QLatin1String elem_title{"title"};
static const QLatin1String elem_desc{"desc"};
static const QLatin1String elem_info{"info"};
static const QLatin1String elem_metadata{"metadata"};
static const QLatin1String elem_metadata_owner{"owner"};
static const QLatin1String elem_metadata_owner_value{"rekonq"};

// 3.4 Data Organization
static const QLatin1String elem_bookmark{"bookmark"};
static const QLatin1String elem_folder{"folder"};
static const QLatin1String elem_separator{"separator"};
static const QLatin1String elem_alias{"alias"};

// node attributes
constexpr auto *attr_id{"id"};
constexpr auto *attr_added{"added"};

// url attributes
constexpr auto *attr_href{"href"};
constexpr auto *attr_visited{"visited"};
constexpr auto *attr_modified{"modified"};

constexpr auto *attr_ref{"ref"};
constexpr auto *attr_folded{"folded"};
constexpr auto *attr_folded_yes{"yes"};
constexpr auto *attr_folded_no{"no"};

} // namespace xbel