summaryrefslogtreecommitdiff
path: root/src/bookmarks/bookmarkstreeformat_xbel.h
blob: c156eb24f9976478932063b23413697388aab6f3 (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 true if parsing was successful, false if errors occurred
 */
[[nodiscard]] bool 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